Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88918b2f8a | ||
|
|
6784d80324 | ||
|
|
ae3ee1bb9e | ||
|
|
5ae9c7fe00 | ||
|
|
ce32b42ae4 | ||
|
|
ece201e3ab | ||
|
|
c437d87e9e | ||
|
|
0ce3fdb246 | ||
|
|
37dbd722e0 | ||
|
|
4502de7ee3 | ||
|
|
a16169ce8c | ||
|
|
3d6a74bc53 | ||
|
|
7a0dd625ce | ||
|
|
8d8ae8abfe | ||
|
|
d5fb22cfd8 | ||
|
|
2c0a99f7c4 | ||
|
|
91bbc19c32 | ||
|
|
5b0bac9c2d | ||
|
|
41a65f95b2 |
+20
-10
@@ -425,39 +425,49 @@ export const chown = tool({
|
||||
/**
|
||||
* check and uncheck differ only in the verb, so the tool is built once.
|
||||
*
|
||||
* The criterion is required here even though the CLI makes it optional: without it the
|
||||
* CLI prompts, and there is no terminal on this side of the pipe. The CLI answers a
|
||||
* The criteria are required here even though the CLI makes them optional: without any
|
||||
* the CLI prompts, and there is no terminal on this side of the pipe. The CLI answers a
|
||||
* missing criterion with the numbered list on stderr, which run() relays, so the model
|
||||
* sees the options and can retry with a number.
|
||||
*
|
||||
* One value per line, like the other list arguments, and every value goes in one call.
|
||||
* The CLI resolves them all before it writes, so a bad term costs nothing, and finishing
|
||||
* a ticket is one tool call rather than one per box.
|
||||
*/
|
||||
function checkboxTool(verb: "check" | "uncheck") {
|
||||
const past = verb === "check" ? "Checked" : "Unchecked";
|
||||
|
||||
return tool({
|
||||
description:
|
||||
`${past === "Checked" ? "Tick" : "Untick"} one acceptance criterion on a worklane ticket. ` +
|
||||
"Every other criterion keeps its state. Identify the criterion by its number as shown by show, " +
|
||||
"or by a substring of its text; a substring matching more than one is an error listing them.",
|
||||
`${past === "Checked" ? "Tick" : "Untick"} acceptance criteria on a worklane ticket. ` +
|
||||
"Every criterion not named keeps its state. Identify each one by its number as shown by show, " +
|
||||
"or by a substring of its text; a substring matching more than one is an error listing them. " +
|
||||
`Pass several, one per line, to ${verb} them in a single call, or the single word all for every ` +
|
||||
"criterion on the ticket. If any value cannot be resolved the whole call is refused and nothing " +
|
||||
"is written, so a partly wrong list never leaves the ticket half-marked.",
|
||||
args: {
|
||||
ticket: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
criterion: tool.schema
|
||||
criteria: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"Criterion number as shown by show, or a substring of its text (required)",
|
||||
"Criterion numbers as shown by show, or substrings of their text, one per line. " +
|
||||
"Or the single word all for every criterion (required)",
|
||||
),
|
||||
},
|
||||
async execute(args: Record<string, any>, context: ToolContext) {
|
||||
if (!args.ticket) {
|
||||
return `Error running ${verb}: ticket is required`;
|
||||
}
|
||||
if (!args.criterion) {
|
||||
return `Error running ${verb}: criterion is required, give the number or a substring`;
|
||||
|
||||
const terms = args.criteria ? itemLines(String(args.criteria)) : [];
|
||||
if (terms.length === 0) {
|
||||
return `Error running ${verb}: criteria is required, give the numbers, substrings, or all`;
|
||||
}
|
||||
|
||||
try {
|
||||
return await run([verb, args.ticket, String(args.criterion)], context);
|
||||
return await run([verb, args.ticket, ...terms], context);
|
||||
} catch (err: any) {
|
||||
return `Error running ${verb}: ${err.message}`;
|
||||
}
|
||||
|
||||
@@ -5,17 +5,22 @@
|
||||
- `src/command.rs` - CLI argument definitions using clap derive
|
||||
- `src/handlers.rs` - one `cmd_*` per subcommand
|
||||
- `src/util.rs` - the ticket format, resolution, rendering and the palette
|
||||
- `src/campaign.rs` - the campaign file format, its resolution, its index and its members
|
||||
- `src/tui.rs` - board state, the change digest, and the ratatui draw
|
||||
- `src/clipboard.rs` - the OSC 52 write and the base64 it carries, the board's only way out to the clipboard
|
||||
- `src/install.rs` - the embedded agent assets and the compare-and-refuse install
|
||||
- `assets/SKILL.md` - the agent skill `install-skill` ships, embedded with `include_str!`
|
||||
- `assets/SKILL.md` - the agent skill for the CLI itself, embedded with `include_str!`
|
||||
- `assets/REVIEW.md` - the agent skill for reviewing a finished ticket, shipped the same way. Assets are named after the role they teach; `SKILL.md` keeps its name because the role it teaches is the CLI
|
||||
- `assets/PLAN.md` - the agent skill for grooming the whole board: priorities, due dates, tags and campaigns
|
||||
- `tests/` - Integration tests using `assert_cmd` and `assert_fs`, one file per command
|
||||
- Unit tests live beside the code in `#[cfg(test)] mod tests`, in `util.rs`, `handlers.rs` and `tui.rs`
|
||||
- Ticket files stored as `.md` in `.worklane/<status>/` directories
|
||||
- Campaign files stored as `.md` in `.worklane/campaigns/`, which is beside the status directories and deliberately not in `status_dirs()`
|
||||
|
||||
## Ticket File Format
|
||||
- Filenames: `<uuid_v4>_<slug>.md`
|
||||
- The slug is the title through `slug()`: lowercased, alphanumerics plus `-` and `_` kept, spaces turned into dashes. `Ticket 06` lands as `<uuid>_ticket-06.md`. Derive fixture filenames through `slug()`, never by hand
|
||||
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Status`
|
||||
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Campaign`, `Status`. `Campaign` is the one no ticket is born with: `add` does not write it, so it is inserted on demand
|
||||
- Format: `**Field Name**: value`
|
||||
- Ticket structure: `# Title` → `## Description` → `## Acceptance Criteria` → `## Implementation Plan` → `## Metadata`
|
||||
- Comments stored in `.worklane/comments/<ticket_uuid>/<timestamp>.md` with `**Comment**`, `**Author**`, `**Time**` fields
|
||||
@@ -32,7 +37,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
## Testing
|
||||
- Run: `cargo test`
|
||||
- Tests use `assert_cmd` and `assert_fs` for CLI testing
|
||||
- `setup_worklane()` creates temp `.worklane/` with all four status folders pre-created
|
||||
- `setup_worklane()` creates temp `.worklane/` with all four status folders pre-created, plus `campaigns/` in `cmd_campaign.rs`, which is also where the on-demand creation is tested from a board without it
|
||||
- `create_ticket()` writes fully-formed markdown files directly (no `--` separator for positional args in test commands)
|
||||
- **`cargo clippy --all-targets` is clean. Keep it clean**, and do not silence a lint that is pointing at something real. The only two `allow`s in the tree sit on the `create_ticket` fixtures in `cmd_mv.rs` and `cmd_show.rs`, each carrying the reason and what would replace it
|
||||
|
||||
@@ -49,12 +54,25 @@ and this file is for what someone changing worklane's own code needs.
|
||||
### CLI Arguments
|
||||
- The prose arguments carry `allow_hyphen_values`, via the `PROSE` constant in `command.rs`: `add --title`, `--description`, `--acceptance`, `--plan`, and the `comment` body. Ticket text quotes flag names constantly, and without it a criterion reading `--print is supported` is parsed as a flag and the whole ticket is refused with nothing written
|
||||
- **The trade:** on those five arguments a genuinely mistyped flag now lands as content rather than raising a usage error. That is the right way round for prose and the wrong way round for anything else, which is why `due`, `priority`, `tags`, `owner` and `status` are deliberately left without it. A mistyped flag there is still a usage error, exit 2, and no ticket is written. Do not add `PROSE` to a new argument unless it holds prose
|
||||
- **`--due` is validated at parse time by `iso_date`, the way `--priority` is by `priority_level`.** A date that is not real is a usage error, exit 2, with nothing written, which is the whole point of leaving the scalars without `PROSE`. One parser serves `add` and `set`: the field has one definition of what it accepts, and validating only `add` would leave `set` open, which is the command a grooming sweep actually uses
|
||||
- **The shape is checked before chrono is asked.** `%Y-%m-%d` accepts an unpadded `2026-8-9`, which would be stored exactly as typed and sort before `2026-10-01` in any string comparison. Checking the length and the two dashes first is what lets a valid date be stored unchanged instead of normalised on the way in, which is the difference between validating and rewriting
|
||||
- **Strict on the way in, tolerant on the way out.** `util::due_date` still cuts `2026-12-31T09:30:00Z` down to its date. A file written before the parser existed, or by hand, can hold one and still has to render; refusing to display what is already stored would punish the reader for the writer's mistake
|
||||
- An empty `--due` keeps `non_empty`'s message about clearing rather than the date message. Somebody typing it is reaching for a way to clear the field, and the useful answer is that clearing is not supported yet
|
||||
- The ticket positionals (`show <id>`, `mv <ticket>`, `comment <ticket>`) are also left alone, so a search term starting with a hyphen is a usage error. Reachable now that a hyphen-leading title can be stored: use the UUID, or put the flags first and separate with `--`, as in `mv --status committed -- -leading-title`
|
||||
- A bare `--` is a value when it follows an option (`--title -- ` stores `--`) and clap's end-of-options marker when it sits in a positional. So a `comment` body of exactly `--` needs its own separator, `comment <ticket> -- --`. Without it the body is reported missing and nothing is written, which is a clear failure rather than a silent drop
|
||||
- `add` has no positionals, so anything after a bare `--` is an unexpected argument and fails
|
||||
- **A paragraph break in a description is an empty `--description` value.** `cmd_add` joins the values with a single newline, so `-d "First." -d "" -d "Second."` writes the blank line. `trim_blank_ends()` drops blank values at either end, so a break never lands against a section heading, and an all-blank description reads as no description. Interior runs are kept verbatim rather than collapsed
|
||||
- `--acceptance` and `--plan` are lists, one criterium or step per value, so a blank there is spacing rather than content and the opencode wrapper drops it. Only `--description` preserves blanks
|
||||
|
||||
### Filtering the Listing
|
||||
- **The filters are one call, `filtered`,** because `ls` collects a column in three places (a named status, the counts, and the grouped listing) and three call sites are three chances to apply a different set. Every filter is an `Option` and none asked for keeps everything, which is what makes them compose in any combination without a rule per pair
|
||||
- **`--tag` matches whole values, not the field.** `parse_tags` has already split the comma-separated field, so the filter compares against those trimmed values: `--tag bug` is not answered by a ticket tagged `bugfix`, and `--tag "cli, filter"` matches nothing, because the field as written is not itself a tag. A ticket with no tags matches none
|
||||
- **Case sensitive**, the opinion the field already takes: `tag_color` draws `Bug` and `bug` in two colours because they are two tags. A filter that folded them would list tickets carrying a tag nobody asked for, and would hide exactly the split a grooming sweep is looking for
|
||||
- **One tag per invocation.** Several would have to decide between and and or, and neither reading is obviously right for a board this size. That decision is its own ticket, along with a substring or regex match and a tag filter on the tui
|
||||
- **A tag nothing carries lists nothing rather than being refused**, which is the opposite of `--campaign`. A campaign is an object that either exists or does not, so it is resolved before anything is read and an unknown one is an error. A tag is free text with no registry: there is nothing to resolve against, and refusing an unknown one would mean maintaining a vocabulary the format deliberately does not have. `assets/PLAN.md` tells the agent to check the spelling when a listing comes back empty, since that is the failure this trades for
|
||||
- An emptied status keeps the message `ls` already gives, `No tickets in '<status>' status.`, rather than one per filter naming what excluded them. That is pre-existing behaviour for `--priority` and `--campaign`, and one message for every filter is the consistent half of it. If it should name the filter, that is a change to what the CLI prints for three flags at once and belongs in its own ticket
|
||||
- **`cmd_ls` is now at the boundary the Rust Style rule names:** four filters and the directory. Two of them are adjacent `&Option<String>` parameters, which a caller can swap silently, so the next filter added here takes an `LsArgs` struct the way `add` took `AddArgs`, rather than a fifth positional
|
||||
|
||||
### Editing a Ticket
|
||||
- `set` replaces a field, `append` adds to a section. The verb carries the meaning, so no flag needs a replace-or-append prefix, and `append` only offers the sections that hold multiple lines
|
||||
- **One field, one writer.** `set` has no `--owner` (that is `chown`'s) and no `--status` (that is `mv`'s). Do not add either
|
||||
@@ -72,11 +90,16 @@ and this file is for what someone changing worklane's own code needs.
|
||||
### Checking Off a Criterion
|
||||
- `check` and `uncheck` are separate commands, not one verb with a flag. They share `CheckArgs` and `cmd_check(args, checked)`
|
||||
- `criteria()` is scoped to the Acceptance Criteria section and counts only checkbox lines, so a checkbox written into a description is not a criterion and a handwritten line inside the section takes no number
|
||||
- `set_criterion()` splices only the character between the brackets. Rebuilding the line would normalise its indentation and whatever spacing followed the checkbox
|
||||
- The criterion argument is an index first, a substring second, so a criterion whose text is literally `2` is reachable only by substring
|
||||
- `set_criteria()` splices only the character between the brackets, and takes every line in one pass. Rebuilding the line would normalise its indentation and whatever spacing followed the checkbox
|
||||
- Each criterion term is the keyword `all` first, an index second, a substring third. So a criterion whose text is literally `2` is reachable only by substring, and one whose text merely contains "all" only by its number or a longer substring. `is_all_criteria()` and `is_index()` sit beside each other in `util.rs` for that reason
|
||||
- **The keyword wins over the text on purpose.** Ticking every box is the reason the word is typed, and a board where `all` sometimes means one criterion and sometimes means the lot would be worse than one that can be addressed another way. `all_is_the_keyword_and_not_a_substring_of_the_text` pins it against its own fixture, so the shared one keeps its three criteria and its numbering
|
||||
- **A number out of range is a bad index, not a failed substring search**, and says so. `is_index()` makes that distinction
|
||||
- Any listing of a subset must keep the real numbers, via `numbered_criteria()`. Renumbering the matches from one contradicts the advice to use the number and points at the wrong criterion
|
||||
- With the criterion omitted: prompt when stdin is a terminal, otherwise return the numbered list as an error. Never prompt unconditionally, the opencode wrapper has no tty and would block on a stdin that never closes. This is the same choice `resolve_ticket` makes for an ambiguous match, and for the same reason
|
||||
- **The criterion positional is variadic**, so `check <ticket> 1 3 "the footer"` is one call and one write. Variadic rather than a repeated flag: the terms address criteria that are already there, the way the ticket positional does, instead of carrying content the way `--acceptance` does. The prompt path is unchanged and fires on an empty list
|
||||
- **`resolve_criteria()` resolves every term before a byte is written, and one bad term refuses the whole batch.** A call that ticked the terms it understood and then failed would leave the ticket half-marked with nothing in the file to say which half was meant. It names the offending term alone rather than every failure at once, since each message carries the criteria listing and a batch of them would repeat the list per bad term
|
||||
- The chosen offsets are sorted and deduped, so the report reads in `show`'s order whatever order the terms arrived in, and a criterion named twice, or by both `all` and its own number, is marked and reported once
|
||||
- **Every named criterion gets a line, in `show`'s order, printed after the write.** A criterion already in the target state reads `Already checked 2: text` and does not count towards the write, so a batch where every box is already ticked writes nothing, which is the whole-file no-op rule the editing commands keep. The number is on the unchanged line too: without it a batch cannot be read back against `show`
|
||||
- `show` numbers the criteria as `1. [x] text`, so the index is visible where the ticket is read. The number replaces the list marker rather than joining it
|
||||
|
||||
### Relating Tickets
|
||||
@@ -90,9 +113,27 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- `ensure_section` inserts against `SECTION_ORDER`, before the first following section that is actually in the file, and adds no blank line that was not already there. A handwritten `## Notes` between the plan and the metadata therefore keeps its place, and Metadata is in that list as an anchor rather than as something anything appends to
|
||||
- **The blocker check runs on every move**, after the already-in-that-status return and behind `force`. An open blocker is a reason not to start and a reason not to finish, and one rule is easier to hold than a table of which transitions care. A move to the status the ticket is already in is not a move, so it is not refused. `-f` now bypasses three rules, which is the right home for it: each one is a deliberate override of something the board would otherwise keep true
|
||||
- **A blocker that is not on the board warns and allows the move.** Refusing would wedge the ticket with no way out but `-f`, and a uuid nothing carries is a bookkeeping fault rather than a dependency. The refusal names **every** open blocker, since clearing the one that happened to be printed would leave the ticket blocked
|
||||
- Left out on purpose: removing a relation, which 4179958 assigns to 74904dc, and a blocked marker on the TUI card, which is its own ticket. Nothing on a card is worth a scan of the board per tick until the card is designed for it
|
||||
- Left out on purpose: removing a relation, which 4179958 assigns to 74904dc. The blocked marker on the card landed in b8ce18c, and it cost no scan of the board: the blockers ride along on the read that already builds the cards. See The Board View
|
||||
|
||||
### Campaigns
|
||||
|
||||
- **A campaign's state is derived, never stored.** Open until every member is done, computed by `Standing` from the members. A `Status` field on the campaign would be the same state in two places, and the two would disagree the moment a member moved. It is also why there is no `campaign mv` and no forward-only ruleset beside `mv`'s
|
||||
- **A campaign with no members is neither open nor done.** `Standing::state()` returns `None` there, and both callers print `no members`. Calling it done would make a container nothing has been filed against the most complete thing on the board; calling it open would claim work that does not exist
|
||||
- **Membership is one field on the member**, `Campaign` in the ticket Metadata, written only by `assign`. The member list is deliberately *not* on the campaign: that would put membership in two places, and would make one file that every assignment edits, which is contended the moment two agents share a board. So `add` has no `--campaign` and `set` has no `--campaign`, the same rule as Owner and Status
|
||||
- **The full uuid is stored and the title is resolved for display**, as the Relations section already does. `reference_cell` is shared between the two, so a dangling campaign and a dangling relation target are both spelled `_missing_` rather than each inventing a spelling
|
||||
- **`add` does not write the field.** Every ticket written before campaigns existed has none, so the insertion path has to exist regardless; leaving it out of `add` means one path that is always exercised rather than two. Same reasoning as the Relations section
|
||||
- `set_or_insert_metadata_field()` is the upsert, and `METADATA_ORDER` is its anchor list, the way `SECTION_ORDER` is `ensure_section`'s. Campaign is placed before Status, so Status stays last where every file already keeps it. A file with no `## Metadata` heading is an **error, not an insertion**: per 641e3d5 such a file has no fields at all, and writing one above the prose would invent a shape nothing reads
|
||||
- **The three tiers are `resolve_in()`, shared by tickets and campaigns.** A campaign is addressed exactly the way a ticket is, and a second resolver would be a second copy of the precedence rules to keep in step. `Found.dir` is the status for a ticket and empty for a campaign, which is what makes the ambiguity listing drop the bracket for one
|
||||
- **`resolve_ticket` explains a search that names a campaign**, rather than each command doing it. One place, so `mv`, `show`, `chown` and everything else that takes a ticket give the same reason instead of a bare "no ticket found". Checked only on the zero-match path, so it costs nothing normally, and only when exactly one campaign matches: an ambiguous ticket error must not be replaced by a complaint about a directory the caller never mentioned
|
||||
- **`Resolved` carries what `content_trim` cannot render from the file.** The relations block and the campaign cell both come from elsewhere on the board. A struct rather than two more parameters, so the next such field is one entry here instead of an edit at every call site
|
||||
- `campaign show` lists **done** members, unlike `ls`, which leaves the done column out of its listing. What is finished against what is left is the whole question a campaign asks, so hiding half the answer is not an option. `ls --campaign` is the other way round: it is the ordinary board filtered, and keeps every rule `ls` already has
|
||||
- `campaign ls` scans the status directories **once per campaign** to count members. That is a scan per row rather than one walk reused, and it is deliberate: the map-from-uuid version is worth writing when a board has enough campaigns to notice
|
||||
- **The TUI gets neither a campaign tab nor a card marker**, for now. The detail view resolves the field because it renders the body, and that is all. A marker on a card would want a campaigns read per reload, which is more than the blocked mark cost: that one reads the ticket's own Relations section on the pass that already builds the card, and a campaign title is in another directory
|
||||
- `campaign_body()` builds the file from `DESCRIPTION` and `METADATA_HEADING` rather than its own string literals, so the two file formats cannot drift apart on the spelling of a heading. A campaign has no acceptance criteria (its definition of done is derived), no implementation plan and no Status
|
||||
- The campaigns directory is created by `init` and **on demand** by `campaign add`, since every board made before campaigns existed has none and a `worklane init` over a live board to get one would be a strange thing to have to do
|
||||
|
||||
### The Board View
|
||||
- **The board is for a person, and only for a person.** Scripts and agents drive worklane through the CLI, which is what `assets/SKILL.md` teaches and what the integration tests pin. Nothing parses the drawn frame, so its layout is free to change: a new row on a card, a moved corner, a different colour or a hidden column breaks no caller. Judge a change here on whether it reads well, not on what it might break, and do not preserve a layout for compatibility's sake. What the CLI prints is the opposite case and is not covered by this
|
||||
- `worklane` with no subcommand and `worklane tui` both open it, the way a bare `frig` does. `Cli::command` is therefore an `Option`
|
||||
- The worklane directory is looked for **before** the terminal, so running outside one gives the usual "No .worklane directory found" rather than a complaint about the tty. Both errors stay reachable and both are testable without a pty
|
||||
- A missing tty is refused with a message naming a subcommand. Raw mode on a pipe fails with a bare "No such device or address (os error 6)", which explains nothing
|
||||
@@ -104,11 +145,20 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- The scroll offset is clamped against the *wrapped* line count, from `Paragraph::line_count`, which is why `ratatui` carries the `unstable-rendered-line-info` feature. The paragraph wraps on words, so a clamp on the raw lines would stop short of the end or scroll past it into blank space. Counting the wrapping by hand would only agree with the widget until one of the two changed
|
||||
- The clamp runs on the keypress and again in the draw. The terminal can be resized between the two, and a tick can shorten the ticket under a reader who is already at the end
|
||||
- The offset resets when the selection moves and when the modal is closed, so a ticket opens at its top. It deliberately does *not* reset on a tick: an edit elsewhere in the tree must not throw the reader back to the top of what they are reading
|
||||
- **The overlay carries a page indicator on the bottom right of its border**, `pg 2/8`, so a long ticket does not open looking exactly like a short one. `Block::title_bottom` with a right-aligned `Line`, which spends no text row, the trade the title already makes on the top border. The two cannot crowd each other: they are on opposite borders
|
||||
- **`wrapped_height` is the one measurement.** `last_offset` is it less the viewport and `page_indicator` takes the same two numbers, so the clamp and the indicator cannot disagree. A second `line_count` call, or a count of the raw lines, is a number free to drift, and an indicator that says there is more to read where the scroll refuses to move is worse than none
|
||||
- **The furthest offset is the last page by definition, not by division.** The clamp stops at the wrapped height less the viewport, which is not a page boundary, so the final screenful is partial: `offset / step + 1` reads `pg 2/3` at the bottom of a 25 row ticket in a 10 row viewport and claims there is more below
|
||||
- **The pages are counted in `scroll_step`, a screenful less the overlap line, not in whole screenfuls.** The step is what the keys take, so counting in it names only pages `pgdn` can land on. Counting by screenfuls puts a 30 row ticket in a 10 row viewport at `pg 3/3` two rows short of its end, since three presses are what it takes to get there
|
||||
- The indicator is dropped whole on an overlay too narrow for it, the rule a corner and the tags row already follow, and absent entirely when nothing scrolls, the way an untagged card spends no row on tags
|
||||
- `page_indicator` takes four numbers and returns an `Option<String>`, so every case above is pinned without a terminal. The drawn tests exist for the two things arithmetic cannot answer: which border it landed on and what colour it reached the screen in
|
||||
- **Columns scroll to keep the selected card in view.** `Board::offsets` holds one offset per column, parallel to `columns` and resized in step by `reload`, so a column you leave stays where it was. The keypress aligns the focused column via `follow_selection(screen)`, taking the screen size for the same reason `scroll_detail` does: the visible height belongs to the terminal, which only the caller measures between draws
|
||||
- Card heights are measured on `card_lines`, never assumed, on both the keypress and the draw side (`card_height`, and the `starts` vec as the cards are built). An alignment that trusted a fixed card height would drift from the renderer the first time the card changed shape
|
||||
- The draw aligns the focused column again on its own geometry, so a resize between keypress and frame cannot hide the selection, and caps every column against blank space past its last card. The stored value may go stale after a tick shrinks the column; that is fine, because what is drawn is corrected immediately and the next navigation writes the correction back
|
||||
- Entering another column follows the selection rather than resetting to its top. The card index carries across columns, so a reset would open the column with the highlight below the fold whenever it was — the opposite of the detail view's reset-on-selection-move, where each ticket genuinely starts at its own top. The index is shared and clamps permanently when a shorter column pulls it down, so a column you return to follows the selection to where it now sits rather than holding your old place
|
||||
- **The footer names only keys that work.** It read `↑↓ scroll` when nothing scrolled at all, which sends the reader looking for their own mistake. A UI that misdescribes itself is worse than one that is merely incomplete
|
||||
- **`q` and `esc` are one key: close what is open, quit when there is nothing left to close.** `q` used to set `should_quit` outright, so a reader who pressed it to put a ticket away lost the board instead, which is not what `q` does anywhere else that lays a document over a list. One match arm in `main.rs`, not two: two arms carrying one rule is how a later edit changes it for one key and not the other
|
||||
- **The rule is `Board::dismiss`, not the match arm.** The dispatch in `main.rs` is not reachable from a test, so anything decided there is undecidable by the suite. The arm is the line that names the keys and nothing else. `the_dispatch_gives_q_and_esc_one_arm_and_leaves_ctrl_c_quitting` scans `main.rs` for what the arm cannot say for itself, over whitespace-collapsed source so rustfmt cannot fail it
|
||||
- **The footer's last slot always answers how to get out**, and with a ticket open the honest answer is `ctrl-c`, the only key left that quits in one press. Going on saying `q quit` there would be 1b78a24 in the other direction: a footer describing a key by what it used to do
|
||||
- **The overlay names its ticket on the border, not at the head of the paragraph.** `Board::detail` is a `Detail` carrying the title, the id and the text, because the name has to travel beside the body rather than inside it: `content_trim` drops the `# ` heading on purpose, since `cmd_show` prints it, and anything in the paragraph scrolls away
|
||||
- `detail_title` cuts the string itself instead of leaving it to ratatui, which truncates an overlong block title at whatever cell it reaches and would take the id with it. Cut against the inner width, so the id survives whole and the name ends in an ellipsis. The id goes first because that is how every other view addresses a ticket
|
||||
- The detail view renders with colour off. ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_comments_with` take the colour decision for that reason
|
||||
@@ -118,6 +168,14 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- **A card's height therefore depends on the column's width**, so `card_lines` and `card_height` both take it. `column_areas` is shared between the draw and `follow_selection` for the same reason: `Ratio` hands the remainder column to whichever slot it likes, and reproducing that arithmetic by hand is how the measurement and the draw come to disagree about where a card starts
|
||||
- **A corner that will not fit is dropped whole**, never truncated or wrapped: half a date reads as a different date, and a card that reflows in a narrow column changes height, which the scroll would then have to chase. The left corner is the ticket's identity and always stays
|
||||
- The criteria count is a field on `TicketItem`, filled in `collect_ticket_items` where the file is already being read, and counted through `criteria()` so a checkbox in a description is not counted here or numbered by `show`. Do not count per card: that re-reads every ticket body on every draw instead of on the tick that changed something. `None` rather than `[0/0]` for a ticket with no criteria
|
||||
- **The tags go under the title, dimmed, each prefixed with `#`.** The field was invisible on the board: nothing said a ticket was tagged `bug` without opening it. The marker is what stops the row reading as a third line of the title, since a tag is an ordinary word and the title sits directly above it. The row is dropped whole when the column will not hold it, the rule a corner follows, and an untagged ticket spends no row at all, the way a short title spends no second one
|
||||
- `tags` is a field on `TicketItem`, filled in `collect_ticket_items` through `parse_tags`, for the reason the criteria count is. `parse_tags` splits the comma-separated field into whole trimmed values, so a caller asking for `bug` is not answered by `bugfix`, and reads absent, `_None_` and empty as the same answer
|
||||
- **A held-up card carries `BLOCKED_MARK`, `×`, after its id, in brightred.** The constant lives in `util.rs` and the relations block draws the same one, since both say the same word. A ticket waiting on an open blocker looked exactly like one that is ready, and the board is where the next thing to pick up is chosen. Not a fourth circle from Geometric Shapes: those belong to the priority meter two cells away and would read as part of that ramp. The multiplication sign is Latin-1, like the middle dot the unset priority draws, so it renders wherever the meter does
|
||||
- **The mark goes after the id, not before it.** Ahead of the id it would push every id in the column out of line whenever one card was blocked, which costs more than one card's state is worth. It is measured before the project label and the due date, so both give way to it: those are context for a ticket somebody can start, and this is the one thing on a card that says not to. Dropped whole when the row cannot hold the identity and the mark together, the rule a corner follows
|
||||
- **`blocked` is on `Card`, not on `TicketItem`.** The answer lives on two tickets at once, so no card can reach it alone, and it is settled at reload the way `project` is. What `collect_ticket_items` fills is the ticket's own `uuid` and its `blockers`, both read off the file it is already holding; `mark_blocked` then walks the four columns once for a uuid-to-status map and once to answer every card. No file is read twice and nothing is asked per draw
|
||||
- **A blocker the board does not hold marks nothing**, the answer `mv` already gives a dangling uuid. A Relations section that cannot be parsed reads as no blockers, the exception `detail_of` makes for the same reason: `show` and `mv` are where a hand-edited file is reported, and a board that will not draw because one ticket is malformed is the worse failure
|
||||
- **The merge carries the flag rather than recomputing it.** `relate` resolves its target inside one `.worklane`, so a blocker in another project is not a relation anything can record; resolving over the merged columns would let one project's uuid match another project's ticket. That is b8ce18c's fourth plan step and the answer is no
|
||||
- `project_label` takes the width the row has already spent, measured off the spans, rather than adding up the widths those spans are supposed to have. The hand-written version left out the space after the priority mark, so a cut label was handed one cell more than the column had; `the_project_label_leaves_the_row_inside_the_column` pins it
|
||||
- `due_date` cuts a due value back to its date only when it has one. The field is not validated (daa0e79), so it can hold a time or free text, and taking the first word regardless would turn "next friday" into "next"
|
||||
- **Done is hidden until `d` asks for it.** Not a new opinion: `ls` already counts done in its summary and leaves it out of the listing. Done only grows, so a quarter of the width was going to the column least often read. The footer carries its count while it is hidden, which is the board's version of that summary line
|
||||
- **Hiding is a change to what is drawn, never to what is read.** `reload` still scans the done directory and `digest` still watches it, so the footer count is right and revealing the column needs no rescan. Do not "optimise" that into a conditional scan
|
||||
@@ -126,6 +184,55 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- The choice is not remembered between runs. worklane has no config file and one flag is not a reason to start one; if it should persist, that is its own ticket
|
||||
- **Assert a column heading against the top border row, not the whole screen.** The footer names done too, so `screen.contains("done (0)")` passes on the footer whether the column is drawn or not. Three tests went vacuous that way the moment done was hidden; `headings()` and `footer()` exist so the next one does not. `headings()` locates the row through `board_area()` rather than taking row zero, since the tab row sits above it when more than one board is monitored
|
||||
|
||||
### The Search Prompt
|
||||
- **`search: Option<Search>` is the whole mode**, the shape `detail` uses: "the prompt is open" and "what is in it" cannot disagree, and closing it leaves nothing to reset. `Search` also carries `missed`, set when enter found nothing and cleared by the next edit, since the message is about the query that missed
|
||||
- **The prompt swallows every key it is given.** `Board::search_key` runs ahead of the action arms in `main.rs` and reports what it took, rather than every arm below asking whether a search is open. Typing `d` into a query must not toggle done and `q` must not quit; with no prompt open it takes nothing, so the dispatch is unchanged for every other state. The rule is on `Board` for the reason `dismiss` is: the arm is not reachable from a test
|
||||
- **`ctrl-c` is the one key it declines**, because a terminal application always honours it and a prompt that ate it would leave no way off the board. Every *other* control combination is swallowed and does nothing: it must not type its letter, and it must not fall through either, since the action arms match on the code alone and `ctrl-d` would reach the one bound to `d`
|
||||
- **Esc is consumed by the search before it can mean anything else**, which is the collision e7612de left behind: `esc` and `q` close the overlay, and both have to lose to an open prompt. It falls out of the pre-branch rather than being ordered by hand
|
||||
- **`first_match` searches the *visible columns*, every card in them, not the rows on screen.** A query that answered differently on a tall terminal and a short one is not a search, and the jump scrolls the match into view anyway. Hidden columns stay out: with done hidden, a match there would put the highlight on a ticket that is not on the board. Reading order is column by column, then top to bottom
|
||||
- Id and title only, per 3b16540, both lowercased. The title has to be case insensitive to be worth typing, and giving the id the same treatment lets a pasted id match whatever case it was copied in. An empty or all-space query matches **nothing** rather than everything
|
||||
- **The jump goes through `select_at`, the tail `select_card` already used.** `follow_selection` scrolls the column the card is in, and the offsets are per column and on the `Tab`, so a jump across columns moves the right one; `refresh_detail` keeps an open overlay on the ticket the selection names. A second version of either is how a jump comes to scroll differently from the arrow keys
|
||||
- **A hit closes the prompt and a miss keeps it open**, marked, with the selection untouched. The query can then be corrected in place instead of retyped from `/`. Doing nothing visible is what makes a reader retype a query that was already right
|
||||
- **The prompt takes the whole footer row**, because the key list it replaces describes nothing that currently works while every key is going into the buffer. The typed query is drawn in the default foreground and the keys in grey: one is content, the other is chrome. `no match` is brightred beside the query it is about, since grey chrome is what a reader skips
|
||||
- **The real terminal cursor goes after the query**, not a glyph standing in for one. ratatui shows the cursor only for a frame that asked for it, so `set_cursor_position` is also what says "you are typing" while the query is still empty. Clamped to the row, so a query longer than the terminal leaves it on the last cell
|
||||
- Both closed footers name `/`, since the jump works with a ticket open as well: it moves the selection and the overlay follows
|
||||
- Out of scope on purpose, each its own ticket once the input mode exists: `n` and `N` for the next and previous match, searching the description, tags or owner, regex, and filtering the board down to matches rather than selecting one
|
||||
|
||||
### The Copy Key
|
||||
- **`y` copies the selected card's short id, over OSC 52 written by hand.** The board is where a ticket is found and the CLI is where it is acted on, and the only thing joining them was seven characters retyped off the screen. `y` reads as yank to the readers a keyboard board is for, and was the letter left: `q`, `esc`, `enter`, `space`, `hjkl`, the arrows, `pgup`, `pgdn`, `tab`, `backtab`, `d` and `/` were taken
|
||||
- **The mechanism was chosen against ssh**, which is where a board is often read. An escape sequence is the only one of the three ways that crosses the connection, since it is the terminal at the reader's end that owns the clipboard. A crate (`arboard` and its kind) wants X11 and Wayland libraries at build time, and on X11 the selection belongs to the process that set it: copy an id, quit, and the paste buffer is empty, which is precisely this flow. Shelling out to `wl-copy`, `xclip` or `pbcopy` is platform sniffing plus a process spawn, and does nothing on a machine where none of them is installed or on the far end of a connection. crossterm 0.28 is what ratatui 0.29 pins and it ships no clipboard command, and the backend types have to match whatever ratatui pins, so a newer crossterm cannot be picked up on its own
|
||||
- **The cost is paid knowingly: a terminal that ignores OSC 52 ignores it silently**, and tmux needs `set-clipboard on`. What `clipboard::copy` reports is whether the sequence was written, not whether it was honoured, and the footer message says no more than that. There is no reply to read: the query form of OSC 52 is refused by most emulators as a security matter, so nothing better is available to us
|
||||
- Base64 is twenty lines here rather than a dependency, because the only thing that goes through it is a seven-character id. Pinned on the RFC 4648 vectors, which cover both padding forms, since a wrong encoder would put plausible-looking rubbish on the clipboard
|
||||
- **`c` and not `p`**: the clipboard proper, not the X11 primary selection, since this is pasted into a command line. Terminated with BEL, which is what tmux documents and what every emulator that implements this at all accepts
|
||||
- **What is copied is `ticket.id`, the seven characters the card prints**, not the full uuid: they are what stops the retyping and what `show`, `mv` and `comment` all resolve. Decided by `Board::copy_text` rather than inside the arm that copies, so the string is a question the suite can ask without a clipboard. `None` on an empty column, since an empty string would take away whatever the reader had there and give nothing back
|
||||
- The project is left off even on the merge tab, where the id alone is not an address. This goes onto a clipboard to be pasted into a command line, and a second word in it would have to be deleted every time; running the command in the wrong project fails to resolve rather than acting on the wrong ticket
|
||||
- **The clipboard is handed to `Board::copy_selected_id` as an argument**, `clipboard::copy` from the dispatch and a closure from a test. That is what makes both answers drivable, and it keeps the terminal write out of the board state
|
||||
- **A failure is said in the footer, not returned.** There is nobody above it to handle one: the board goes on being drawn, and an error swallowed there would look exactly like a copy that worked until the paste came out wrong
|
||||
- **`Notice` is the board's one channel for saying something in words**, since a copy leaves nothing on screen to look at. `failed` means "nothing reached the clipboard" rather than "an error occurred", so an empty column and a refused write are one answer to the reader, both in brightred for the reason `no match` is
|
||||
- **It takes the whole footer row**, on a weaker reason than the prompt's: every key still works while a notice is up. It is that a message squeezed in beside the key list would move every key in it, and the row is the only part of the board that is not a ticket. Drawn after the prompt, which is an input and cannot be covered
|
||||
- **The notice is cleared by the next keypress, not by a timer.** No clock on the board and no wakeup in the loop, and the moment the reader does anything else the message has been read or was never going to be. Doing nothing leaves it up, which is the one state where it is still worth reading. `Board::clear_notice` runs ahead of `search_key` as well as the arms, since a key typed into a query is still a key, and it must never move into `tick`: the board redraws four times a second and a notice cleared there would never be read
|
||||
|
||||
### The Relations Block
|
||||
- **One builder, two painters.** `relation_rows` decides which edges there are, what they are called and which direction comes first; `relation_cells` decides the layout, the mark and the colours; `paint_cells` turns cells into escapes for the CLI and `span_of` turns the same cells into ratatui spans for the board. Two builders producing one block in two shapes is a pair free to disagree about ordering or padding, which is what this shape exists to prevent
|
||||
- **`Cell` is the unit both renderers take**: a run of text and the colour it is drawn in, `None` for the default foreground. The same trick as the palette itself, where `Color::ansi()` and `From<Color> for ratatui::style::Color` keep one colour from existing for one renderer and not the other
|
||||
- **`reference_cells` is the one spelling of a cross reference**, and `reference_cell` is it painted. The relations block and the Campaign field both go through it, so a dangling reference reads the same way wherever it is shown
|
||||
- **A row carries two marks, kind then status**: what sort of edge this is, then how far the ticket at the other end has got. `blocked by × ◐ (6ce2c47) Title`. Two questions are asked of this block and one glyph could not answer both: which rows hold this ticket up, and whether the ones that do are finished
|
||||
- The status went through one bad shape first. It was a rising bar, `▁▄▆█`, as the only mark, which read as an undifferentiated column of blocks and left the kind to five long words that blur when a ticket carries several. Then the kind took the column alone and the status was lost. Both, in that order, is the answer
|
||||
- **Both directions of a kind carry one mark.** `blocked by` and `blocks` are the same edge read from two ends, and the label is what says which end you are on. `both_directions_of_a_kind_carry_one_mark` pins it
|
||||
- **`×` is `BLOCKED_MARK`, the same constant a held-up card draws**, in the same brightred. On a card it says this ticket is held up and in the block it says this edge is what holds one, which is one word, so one glyph and one definition. It lives in `util.rs` for that reason, not in `tui.rs` where the card is
|
||||
- **The kind marks stay out of the priority vocabulary**, which owns `●◐○·`, and `no_relation_mark_is_a_priority_glyph` pins that against every level. They are the arrows the footer already draws, so they render wherever it does
|
||||
- **The status marks are those very circles, and what keeps them from reading as a level is width**: the meter is always two cells and a status mark is one. `the_status_mark_is_one_cell_where_the_meter_is_two` pins both halves. A card carries the meter and never a status mark, and the block carries the status mark and never a meter, so the two never sit in one column
|
||||
- **Both marks go ahead of the id**, where they describe the target rather than the row. Every row carries both, so nothing is pushed out of line the way the card's blocked mark would have been, which is why that one sits after the id and these before it
|
||||
- **The kind mark survives a target the board cannot find and the status mark cannot**, since a kind is read from the ticket's own file and a status from the board. `?` holds the column so the id does not move, and `_missing_` in grey is what says the target is gone
|
||||
- **Committed and reviewing are told apart by colour alone**, both being `◐`, so a pipe cannot tell them apart: `should_use_colors` is false and both read as under way. Accepted, because `●` and `○` are the two answers usually wanted and `show` on the target settles the rest, and `assets/SKILL.md` says so outright rather than leaving an agent to infer it. Do not fix this by giving one of them a colour that means something else
|
||||
- `RelationTarget` carries the title and the status in one `Option`, because they come from the same lookup and are absent together. It was taken out when the mark keyed on the kind alone and put back one commit later, which is the cost of a field nothing reads: correct at the time, and churn either way
|
||||
- **`show` and the board carry the same mark**, decided rather than left to be discovered: the rows are one builder, so giving the CLI the mark cost nothing, and two views disagreeing about what a relation shows would be the kind of difference nobody can explain later. That makes it a change to what the CLI prints, so it is a minor
|
||||
- **`Resolved.relations` is rows, not a rendered block.** That is what lets the board style them: an escape sequence in a ratatui paragraph is drawn as literal bytes (6d327df), so the block cannot arrive pre-painted. `content_parts` hands the text through already painted and the rows through untouched, which is the asymmetry the two renderers need
|
||||
- **`BodyPart` splits the body rather than building it twice.** Everything outside the relations block is rendered once, by `content_parts`; `content_trim` is that with the rows painted, and the board is that with the rows styled. `Body` is the accumulator, so a caller pushes text and rows without tracking which it pushed last
|
||||
- **`Detail.body` is a `Text`, and it is the only thing measured.** `last_offset` and the `Paragraph` both take it, so the clamp cannot wrap the body differently from the draw. `Detail::plain()` flattens it for the suite and is `#[cfg(test)]`: a second representation carried alongside the spans is a second thing to disagree
|
||||
- `detail_body` closes a line only where the text says, so a part that does not end on a newline runs on into the next one. The seam between text and rows is wherever the body put it rather than wherever a part happened to end
|
||||
- **The relations block is the only coloured part of the overlay body, and that is a decision, not an oversight.** The headings, the plan numbers, the criteria marks, the bold runs and the grey unset values are all painted by `show` and all flat on the board. The block earned its colour because it is where a reader compares several references at once, and because it was already data rather than prose: it arrives as rows for the status mark, so styling it cost nothing extra. Colouring the rest means giving every painted run in `content_parts` the `Cell` treatment, which is a much larger change with no reader's question behind it, and it is its own ticket. Do not paint one more section here without taking that on: two coloured sections and five plain ones reads as a bug, where one clearly does not
|
||||
|
||||
### Monitoring Several Boards
|
||||
- `worklane tui <path>...` takes any number of paths, each resolved through `find_worklane_dir` the way the working directory is: the first `.worklane` at or above it. No path is the working directory, so a bare `worklane` and `worklane tui` are unchanged
|
||||
- The failure **names the path** that had no board, since with several arguments "No .worklane directory found" does not say which one was wrong. Only when a path was given: a bare `worklane` has no path to name and keeps the message every other command gives, which is what its integration test asserts
|
||||
@@ -148,7 +255,16 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- **A modified copy is refused, not overwritten.** Someone may have edited it on purpose, and the message names `--print` so it can be diffed and `--force` so it can be replaced. A read error is not treated as absent either: the write reports the real reason
|
||||
- Three tests guard the document rather than the mechanism, and they are the ones that earn their keep: the frontmatter has to parse (both agents silently ignore a document without it), every `worklane <x>` the skill shows has to be a real subcommand, and every subcommand outside `NOT_FOR_AGENTS` has to appear in the skill. The last one catches a new command that nothing tells an agent about
|
||||
- `install-skill` looks for no board. The skill is what teaches an agent worklane, so needing a `.worklane` to install it would put it out of reach exactly when it is wanted
|
||||
- The assets under `.opencode/` are the user's, not this repo's to ship. Do not embed or install them
|
||||
- The assets under `.opencode/` are the user's, not this repo's to ship. Do not embed or install them. `reviewing-agent.md` there is the prior art the review skill grew out of and is deliberately **left in place**: its content is now in `assets/REVIEW.md`, but deleting a file under `.opencode/` is not this repo's call. Whether the stale copies there go is b2c5531's question
|
||||
- **`install-skill` writes every shipped document, and the name narrows it.** One document teaches the CLI and the others teach a job done with it, so a person who learned the invocation before a document existed still receives it. Requiring a name per document would mean a new skill silently never arrives for anyone who does not read the changelog
|
||||
- **`--print` requires the name.** It exists so a modified copy can be diffed, and a diff is against one document; printing them concatenated would be neither of them. The unnamed case errors with the list of names rather than guessing, the same choice the `comment --` body makes
|
||||
- The refusal message names the document it is about, `install-skill worklane --print`, since with several installed "compare with --print" does not say compare what
|
||||
- **A refused document does not stop the ones behind it.** The loop reports an outcome per document and the "pick it up on their next session" line is printed once, and only when something was actually written
|
||||
- **A role skill is its own document, not a section of `SKILL.md`.** The frontmatter description is the whole of what decides whether a skill loads, and one description cannot name both "anything touching a ticket" and "only when a review is asked for" without fitting neither. It is also why the review document does not restate the CLI: it says to read the `worklane` skill too
|
||||
- The review skill's own rules are guarded by `the_review_skill_keeps_the_decisions_that_define_it`, because each of them is a line an edit could drop without breaking anything: **the reviewer never ticks a criterion** (a tick is the implementer's claim, unticking is the review disagreeing, and one mark for both loses the disagreement), **never moves the ticket** (`mv` belongs to whoever does the work, the reviewer's half is the recommendation), and **never reviews the working tree when no commit names the ticket** (it says what it searched for and stops, since an untraceable ticket in `reviewing` is itself the finding)
|
||||
- **The plan skill is the one that can do damage, so its rules are the ones under test.** `set --tags` replaces the whole field, so a sweep that restates a ticket's tags incompletely deletes the rest, and a due date is neither validated nor clearable. `the_plan_skill_keeps_the_rules_that_bound_a_sweep` pins propose-then-apply and those two traps, because a document that loses them still reads like a plan
|
||||
- `.opencode/agent/feature-planner-agent.md` is **deliberately not folded into `PLAN.md`**. It decomposes a feature request into new tickets, which is intake; `PLAN.md` orders the tickets that already exist. Merging them would give one document two jobs and a frontmatter description that fits neither, which is the same reason the review skill is its own document
|
||||
- `every_agent_facing_subcommand_is_documented` stays on `SKILL` alone. It owns the CLI surface; a role document uses the handful of commands its job needs, and requiring the rest would fill a review document with `init` and campaigns to satisfy a test. The two checks that do run over every document are the frontmatter and that no document shows a command that does not exist
|
||||
|
||||
### Color and Output
|
||||
- Use `color_text()` for coloured output — it respects `should_use_colors()` (terminal detection), and `paint()` is the same with the decision passed in
|
||||
@@ -168,6 +284,14 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- Title → green (32)
|
||||
- Unknown values (`_None_`, `_Not set_`) → grey (38;5;8)
|
||||
- Priority ramp → brightred (1), red (2), orange (3), cyan (4), grey (5). Green is deliberately absent: it means title
|
||||
- Relation kind mark → brightred `×` blocked by and blocks, cyan `→` relates to, orange `←` regression of and regressed by. A small ramp inside one column, the way the priority meter is: the mark says which kind of edge the row is, so none of these three is a colour standing in for the uuid or the title beside it. Brightred on the cross rather than red, because the id one cell to its right is red and the two would blend. It is the colour and the glyph a held-up card already carries, which is the point: one vocabulary for blocking
|
||||
- Relation status mark → grey `○` backlog, orange `◐` committed, cyan `◐` reviewing, green `●` done, grey `?` for a target the board does not hold. The second ramp in that column: the shape says how far the target has got and the colour tells the two middle stages apart, since both are half circles. **Green is here and deliberately absent from the priority ramp**, where it would sit on a whole line and read as a title; on a one-cell mark with no title behind it, it is the obvious colour for finished and nothing else wants it. Orange keeps the meaning it already has, Status, and grey keeps unset for the one row with no status to show
|
||||
- Chrome → grey. The footer's key names, a rendered `[ ]`, and the overlay's page indicator. Not a new slot: grey already means "what a reader skips", which is the other half of the unset-value meaning, and none of these is a value. The indicator in orange would read as the title it faces across the overlay, in cyan as a timestamp, and in the priority ramp's colours as a level
|
||||
- **The palette splits in two: seven colours that each mean one thing, and `TAG_COLORS`, the eight a tag may be drawn in.** A tag in red would read as a uuid, in green as a title, in grey as an unset value, so the tag slots are reserved as a list rather than picked at the call site. Do not assign a new meaning to a colour in `TAG_COLORS`, and do not draw a tag in one outside it
|
||||
- `tag_color()` is a pure function of the tag string, so the same tag is the same colour on every card, in every view and on every board, with nothing stored. Case sensitive, because `Bug` and `bug` are two different tags to the field and to every search
|
||||
- **The hash is FNV-1a written out here, not `DefaultHasher`.** std does not promise its output is stable across releases, and a board that repaints itself on a toolchain upgrade has lost the only property the mapping is for. `the_tag_mapping_is_pinned` fails on any change to it, so a repaint is a decision rather than a surprise
|
||||
- **The index is multiply-shift, not `% TAG_COLORS.len()`.** The length is a power of two, so a modulus keeps only the low three bits of the hash, and FNV-1a's low bits carry only the low bits of the input bytes: multiplication cannot move information downwards. Under a modulus every pair of tags differing above bit 2, `bug` and `BUG` among them, landed in one slot regardless of the rest of the string. It looked like a *good* palette on this board, two colliding cards out of sixty-four, because the vocabulary had been folded into a handful of slots. Taking the top bits of a 128-bit product uses the whole hash
|
||||
- Eight tag colours means roughly one card in five shows two tags alike. That is arithmetic and is accepted: the colour groups a tag across cards, it does not tell two tags apart within one, and the tag text is beside it either way. Do not widen the list to chase the number on one board
|
||||
- Grey is indexed colour 8 in the 256-colour form, not SGR 90 or 37. Both of those failed on a real palette: 90 leans on the bright-black slot and 37 can sit on top of the default foreground. `\x1b[38;5;8m` is byte for byte what crossterm emits for ratatui's `Color::DarkGray`, the grey frig and pantop use for dimmed rows
|
||||
|
||||
### Code Organization
|
||||
@@ -197,6 +321,8 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- Before every commit, decide whether the change warrants a version bump in `Cargo.toml`
|
||||
- Always ask the user to confirm the bump and its kind before making it — never bump silently, and never skip the question because the answer looks obvious
|
||||
- Pre-1.0, so: patch for fixes and internal changes, minor for a new command, flag or changed output, major only for a deliberate 1.0
|
||||
- **Changed output means the CLI's output.** That is the surface scripts and agents read, so a changed listing, message or exit code is a minor. A change to what the board draws is a patch however visible it is, since nothing consumes the frame. See The Board View
|
||||
- **Settling output that shipped one version ago is a patch**, not a second minor. 0.15.1 changed the relation mark 0.15.0 had just introduced, and 0.15.2 added the status mark beside it: the minor was the arrival of a marked relations block, and settling what it marks belongs to that. Three minors in an hour would tell anyone reading the tags that there were three features
|
||||
- No bump for docs-only, tests-only or `--fixup` commits
|
||||
- When one body of work spans several commits, bump once on the final commit rather than on each
|
||||
- Bump `Cargo.toml` and the `worklane` entry in `Cargo.lock` together, in the commit that carries the bump
|
||||
|
||||
Generated
+1
-1
@@ -1494,7 +1494,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.11.0"
|
||||
version = "0.16.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.11.0"
|
||||
version = "0.16.1"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -5,20 +5,20 @@ Worklane is a local Kanban flow for agentic software development.
|
||||
## Commands
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `worklane` or `worklane tui [path...]` | Opens the board: four status columns, redrawn when the tree changes. Read only. Opens on backlog, committed and reviewing; `d` shows or hides done, whose count stays in the footer either way. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket, `q` to quit. Each path opens the first `.worklane` at or above it, the working directory by default. Several paths are monitored together, as a tab per project plus an `all` tab that merges them, with `tab` and `shift+tab` between them |
|
||||
| `worklane` or `worklane tui [path...]` | Opens the board: four status columns, redrawn when the tree changes. Read only. Opens on backlog, committed and reviewing; `d` shows or hides done, whose count stays in the footer either way. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket, whose border carries a page indicator while there is more of it than fits, `/` to jump to the first ticket whose id or title matches, `y` to copy the selected ticket's short id to the clipboard, `q` to quit. Each path opens the first `.worklane` at or above it, the working directory by default. Several paths are monitored together, as a tab per project plus an `all` tab that merges them, with `tab` and `shift+tab` between them |
|
||||
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
|
||||
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags |
|
||||
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
|
||||
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags. `--due` takes `YYYY-MM-DD` and refuses anything else at parse time |
|
||||
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>`, `--tag <tag>` and `--campaign <campaign>`, which compose in any combination. `--tag` matches a whole value of the comma-separated Tags field, case sensitively, so `--tag bug` does not list a ticket tagged `bugfix` or one tagged `Bug` |
|
||||
| `worklane show <id>` | Shows ticket by UUID prefix (4+ chars), title substring, or filename substring |
|
||||
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
|
||||
| `worklane set <ticket>` | Replaces fields with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--priority`. At least one required. Changing the title renames the file, keeping the UUID |
|
||||
| `worklane append <ticket>` | Adds to a section with `--description`, `--acceptance`, `--plan`. At least one required. The description gains a paragraph; list items go on the end, steps numbered on from the last |
|
||||
| `worklane relate <ticket>` | Records an edge to another ticket with `--blocked-by`, `--regression-of` or `--relates-to`, each repeatable. At least one required. Only the ticket named is written; `show` derives the other end by scanning. `mv` refuses to move a ticket blocked by one that is not done, unless `-f` |
|
||||
| `worklane chown <user> <ticket>` | Sets the Owner field, the only command that writes it. Free text, checked against nothing. User first and ticket second, after Unix `chown` |
|
||||
| `worklane check <ticket> [criterion]` | Ticks one acceptance criterion, by number as shown by `show` or by a substring. Prompts with the numbered list if omitted, or errors with it when there is no terminal |
|
||||
| `worklane uncheck <ticket> [criterion]` | Unticks one acceptance criterion, addressed the same way |
|
||||
| `worklane check <ticket> [criteria...]` | Ticks acceptance criteria, each by number as shown by `show` or by a substring. Several in one call, or `all` for every one of them. Prompts with the numbered list if none is given, or errors with it when there is no terminal |
|
||||
| `worklane uncheck <ticket> [criteria...]` | Unticks acceptance criteria, addressed the same way |
|
||||
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
|
||||
| `worklane install-skill` | Writes the embedded agent skill to `~/.claude/skills/worklane/SKILL.md`, which Claude Code and opencode both read. Leaves a modified copy alone unless `--force`; `--print` writes it to stdout instead |
|
||||
| `worklane install-skill [skill]` | Writes the embedded agent skills to `~/.claude/skills/<skill>/SKILL.md`, which Claude Code and opencode both read. Three ship: `worklane` teaches the CLI, `worklane-review` reviews a finished ticket against the code that claims to close it, `worklane-plan` grooms the board as a whole, its priorities, due dates, tags and campaigns. Every document unless one is named. Leaves a modified copy alone unless `--force`; `--print` writes one to stdout instead and needs the name |
|
||||
|
||||
## Exit codes
|
||||
| Code | Meaning |
|
||||
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
---
|
||||
name: worklane-plan
|
||||
description: Groom a worklane board as a whole rather than one ticket at a time: review whether the priorities are right relative to each other, plan work by setting due dates, check the tags for consistency, and find the tickets that belong together in a campaign. Use for questions about the backlog as a body of work, what to do next week, what is mis-prioritised or mis-tagged, and what could become one goal. Not for filing or working a single ticket.
|
||||
---
|
||||
|
||||
# Planning a worklane board
|
||||
|
||||
For "are the backlog priorities right", "plan in tickets for next week", "check the
|
||||
tagging", "which of these could be one campaign". The subject is the board, not a
|
||||
ticket. Filing one, working one and reviewing one are other jobs.
|
||||
|
||||
The CLI itself is the `worklane` skill: the statuses, how a ticket is addressed and
|
||||
which command owns which field. Read it too. This document is the judgement.
|
||||
|
||||
## The one rule
|
||||
|
||||
**Propose the whole set of edits, wait, then apply exactly what was approved.**
|
||||
|
||||
Every job here writes to many tickets at once, and no field can be cleared back to unset
|
||||
yet, so a date written onto the wrong ticket can only be overwritten, never taken off. A wrong
|
||||
edit to one ticket is a mistake; a wrong sweep is thirty of them with no undo. So a
|
||||
proposal is a list, one line per intended edit, each naming the ticket and the command
|
||||
that would make it:
|
||||
|
||||
```
|
||||
(1b78a24) priority 3 -> 1 worklane set 1b78a24 --priority 1
|
||||
(4179958) due -> 2026-08-29 worklane set 4179958 --due 2026-08-29
|
||||
```
|
||||
|
||||
Then apply what was approved and nothing else. Not "and a few obvious ones while I was
|
||||
there": an approval is for the list that was shown.
|
||||
|
||||
## Who writes what
|
||||
|
||||
Every field has exactly one command that writes it, and a sweep that reaches for any
|
||||
other way is editing the file by hand:
|
||||
|
||||
| Field | Writer |
|
||||
|-------|--------|
|
||||
| Priority, Due, Tags | `worklane set <ticket> --priority` / `--due` / `--tags` |
|
||||
| Relations | `worklane relate <ticket> --blocked-by` / `--regression-of` / `--relates-to` |
|
||||
| Campaign membership | `worklane assign <campaign> <ticket>` |
|
||||
| Owner | `worklane chown <user> <ticket>` |
|
||||
| Status | `worklane mv <ticket> --status <target>` |
|
||||
|
||||
**Never edit a ticket file directly.** The filename, the `Status` field and the directory
|
||||
have to agree, and the commands are what keep them agreeing. A hand-written Relations
|
||||
line is worse still: it is the one section read back by machine, and a target that does
|
||||
not resolve to a uuid is an error on every later read of that ticket.
|
||||
|
||||
The last two rows are in the table to be recognised, not used. See the closing section.
|
||||
|
||||
## Read the board first
|
||||
|
||||
```
|
||||
worklane ls # every status, counts then tickets
|
||||
worklane ls backlog # one status
|
||||
worklane ls --priority 1 # the top of the pile
|
||||
worklane ls --tag bug # one tag's worth of the board
|
||||
worklane show 1b78a24 # one ticket, with its relations and comments
|
||||
worklane campaign ls # the goals that already exist
|
||||
```
|
||||
|
||||
`ls` prints the mark, the id, the title, the owner and the due date. It does **not**
|
||||
print tags, so the vocabulary itself still has to be read off the tickets: `--tag` answers
|
||||
"what is tagged `bug`" and cannot answer "what tags exist", which is the question a
|
||||
grooming sweep starts from. Count the vocabulary with a `show` per ticket, then use
|
||||
`--tag` to check each candidate, and remember that `--tag` matches whole values case
|
||||
sensitively: `bug` and `Bug` are two answers, which is exactly the split worth reporting.
|
||||
|
||||
Read `done` too when the question is about what to do next. What was finished last is the
|
||||
best evidence of what this board actually moves at, and a plan that ignores it is a wish.
|
||||
|
||||
## Priorities
|
||||
|
||||
Priority runs **1 most urgent to 5 least**, and may be unset. `worklane set <ticket>
|
||||
--priority <n>` is the only writer.
|
||||
|
||||
Priority is relative. A ticket is never urgent by itself, it is urgent above something
|
||||
else, so every proposed change has to name what it now sits above and below. "This looks
|
||||
important" is not a reason; "this blocks three tickets that are all dated before it" is.
|
||||
|
||||
What to look for:
|
||||
|
||||
- **A blocker priced below what it blocks.** Read the Relations. A ticket that others are
|
||||
`blocked by` cannot be less urgent than the most urgent of them, or the board is asking
|
||||
for work in an order it will not allow.
|
||||
- **A flat board.** If almost everything is 3, the field is carrying no information and
|
||||
the answer is not to renumber everything at once. Propose the few that are genuinely 1
|
||||
and the few that are genuinely 5, and leave the middle alone.
|
||||
- **Too many 1s.** If everything is urgent, nothing is. Say how many there are before
|
||||
proposing another.
|
||||
- **A low priority already in `committed`.** Either the priority is wrong or starting it
|
||||
was, and which one it is decides whether the fix is a `set` or a conversation.
|
||||
- **A priority nobody has touched since the ticket was filed.** It is the filer's first
|
||||
guess, not a decision. That is the pile worth reading.
|
||||
|
||||
## Due dates
|
||||
|
||||
`worklane set <ticket> --due 2026-08-29`, format `YYYY-MM-DD`.
|
||||
|
||||
A value that is not a real calendar date in that exact form is refused before anything
|
||||
is written, so a typo costs nothing. `2026-8-9` is refused too: the padding is part of
|
||||
the format. What is still true is that a date, once written, **cannot be cleared**, only
|
||||
replaced by another date, so a plan applied to the wrong ticket has no undo.
|
||||
|
||||
Ask the system what today is rather than assuming it. A plan built on a guessed date is
|
||||
wrong by however much the guess was wrong.
|
||||
|
||||
The rules a dating plan has to keep:
|
||||
|
||||
- **Nothing is dated before the ticket it is blocked by.** Read the Relations first and
|
||||
date blockers ahead of their dependents. A dependent dated before its blocker is a date
|
||||
`mv` will refuse to honour anyway.
|
||||
- **A blocker left undated makes its dependent's date a fiction.** Either date both or
|
||||
neither.
|
||||
- **Date what fits, not what exists.** Ask how much capacity the week holds, or take the
|
||||
answer from what `done` shows the board finishing in a comparable stretch. Dating the
|
||||
whole backlog produces a board where every ticket is late, which is the same as no
|
||||
dates at all.
|
||||
- **Do not date `done`.** It is finished; a date on it is noise in every listing.
|
||||
- Leave the rest unset. An unset due date is honest about what has not been planned.
|
||||
|
||||
## Tags
|
||||
|
||||
`worklane set <ticket> --tags bug,cli` is the writer, and it **replaces the whole
|
||||
field**. Restate every tag the ticket should keep, or the ones you left out are gone.
|
||||
This is the single most destructive thing in this document.
|
||||
|
||||
Derive the vocabulary from the board rather than inventing one. Read the tickets, count
|
||||
what is actually used, and show the count before proposing anything. What to report:
|
||||
|
||||
- **Two spellings of one idea.** `bug` and `bugfix`, `tui` and `ui`. Pick the one already
|
||||
used more and say so.
|
||||
- **A tag used exactly once.** Either it is the start of a category and should be applied
|
||||
to its siblings, or it is a private note and should go. Do not leave it as it is without
|
||||
saying which.
|
||||
- **A tag that restates a field.** A `p1` tag beside a Priority field, an `open` tag
|
||||
beside a Status, an owner's name as a tag. The field is the writer; the tag is a copy
|
||||
that will disagree with it. This board already made that mistake once with priority and
|
||||
undid it deliberately.
|
||||
- **An untagged ticket** in a board where everything else is tagged. It is invisible to
|
||||
every question asked by tag, `worklane ls --tag` included.
|
||||
|
||||
Tags are for kind, not for state and not for goal. State is the status directory and the
|
||||
fields; a goal is a campaign.
|
||||
|
||||
## Campaigns
|
||||
|
||||
```
|
||||
worklane campaign ls
|
||||
worklane campaign show "v1 release"
|
||||
worklane campaign add --title "..." --description "..."
|
||||
worklane assign "v1 release" 1b78a24
|
||||
```
|
||||
|
||||
A campaign is the tickets that have to be finished **together** for one outcome. The test
|
||||
is whether you can name the outcome in a single line without listing the members. "The
|
||||
tui is usable on a narrow terminal" is a campaign. "The tui tickets" is a tag.
|
||||
|
||||
- **Do not group by tag.** Ten tickets tagged `bug` share a kind, not a goal, and putting
|
||||
them in a container says nothing that the tag did not already say.
|
||||
- **Check what exists first.** `campaign ls` before proposing a new one, or you will
|
||||
propose a second container for a goal that already has one.
|
||||
- **A ticket is in at most one campaign**, and `assign` moves it rather than adding a
|
||||
second. So two proposed campaigns that overlap are really one proposal to take members
|
||||
out of the other, and it has to say so.
|
||||
- **A campaign's state is derived**, open until every member is done. There is nothing to
|
||||
close and nothing to move. A campaign whose members are all done is finished already.
|
||||
- `assign` takes the **campaign first and the ticket second**, like `chown`.
|
||||
|
||||
Proposing a campaign means naming the goal, the members, and what is deliberately left
|
||||
out of it. The last part is what makes it a goal rather than a pile.
|
||||
|
||||
## What a planner does not touch
|
||||
|
||||
- **Descriptions, acceptance criteria and implementation plans.** They are the ticket
|
||||
author's account of the work, and grooming is about how the work is ordered, not what
|
||||
it is. Something wrong in there is a comment on that ticket.
|
||||
- **Status.** `mv` belongs to whoever does the work. A plan that moves tickets between
|
||||
columns is reporting progress that did not happen.
|
||||
- **Owner.** `chown` records a commitment a person made. Propose it, do not write it,
|
||||
unless you were asked to assign the work.
|
||||
- **New tickets.** Grooming is about what is on the board. Something genuinely missing is
|
||||
worth filing, by the rules in the `worklane` skill, but say it is a new ticket rather
|
||||
than folding it into a grooming sweep.
|
||||
@@ -0,0 +1,162 @@
|
||||
---
|
||||
name: worklane-review
|
||||
description: Review a finished worklane ticket against the code that claims to close it, and record the verdict on the board. Use when asked to review a ticket, to check whether a ticket is really done, or to verify that an implementation matches its acceptance criteria, whether the ticket is named by id, by title or as "the one in reviewing". Covers finding the commits, judging each criterion against the code, and what a reviewer may and may not write back to the board.
|
||||
---
|
||||
|
||||
# Reviewing a worklane ticket
|
||||
|
||||
For "review ticket 1b78a24", "is 4179958 actually done", "check the work on the tui
|
||||
scroll ticket". The subject is one ticket. Reviewing a diff that no ticket claims is
|
||||
ordinary code review and not this job.
|
||||
|
||||
This document is the review only. The CLI itself, the statuses, how a ticket is
|
||||
addressed and the argument traps, is the `worklane` skill; read that too.
|
||||
|
||||
## What a review produces
|
||||
|
||||
Three things, in this order, and nothing else:
|
||||
|
||||
1. **One comment** on the ticket, in the structure below.
|
||||
2. **Unticked criteria**, for the ones the code does not actually meet.
|
||||
3. **Appended criteria**, for work the review found that the ticket never asked for.
|
||||
|
||||
You do not tick a criterion, you do not move the ticket, and you do not fix the code.
|
||||
Each of those has a reason, given where it comes up.
|
||||
|
||||
## 1. Read the ticket before the code
|
||||
|
||||
```
|
||||
worklane show 1b78a24
|
||||
```
|
||||
|
||||
All of it, comments included. The description says what was wrong, the criteria say what
|
||||
"done" was supposed to mean, the plan says what someone intended to do about it, and the
|
||||
comments are where the intent moved after filing. A criterion that contradicts a comment
|
||||
is one of the more useful things you can find: it means the ticket was not updated when
|
||||
the plan changed, and one of the two is now lying to whoever reads the board.
|
||||
|
||||
Read the Relations too. A `blocked by` that is not done, or a `regression of`, changes
|
||||
what the change was allowed to do and what the review has to check twice.
|
||||
|
||||
## 2. Find the work
|
||||
|
||||
The board stores no branch and no sha, so the link from ticket to code has to be found.
|
||||
Check the repo's own commit convention first, in its `AGENTS.md`, `CLAUDE.md` or in
|
||||
`git log`, rather than assuming the id appears in the message at all.
|
||||
|
||||
```
|
||||
git log --all --oneline --grep 1b78a24 # where commits name the ticket
|
||||
git log --oneline -20 # where they do not, read the recent ones
|
||||
git branch -a --list '*scroll*' # a branch named after the work
|
||||
git diff main...HEAD # the whole change, once you have both ends
|
||||
```
|
||||
|
||||
Widen it with the files the description names, since a ticket that names
|
||||
`src/tui.rs` is reviewable through `git log -p -- src/tui.rs` even when no commit
|
||||
message mentions it.
|
||||
|
||||
**If nothing names the ticket, that is the finding.** Do not review the working tree on
|
||||
the assumption that whatever is uncommitted must be the work, and do not report a pass
|
||||
you could not check. Comment what you searched for and stop: a ticket sitting in
|
||||
`reviewing` with no traceable work is exactly what a reviewer is for.
|
||||
|
||||
## 3. Judge each criterion separately
|
||||
|
||||
One criterion at a time, by its number from `show`, and each against **the code**. Never
|
||||
against the implementation plan: the plan is what someone meant to do, and a review that
|
||||
confirms the plan was followed cannot notice that following it was not enough.
|
||||
|
||||
Read the code the criterion is about, not only the lines the diff touched. A criterion
|
||||
that the diff satisfies and the surrounding code defeats is not met.
|
||||
|
||||
Give each one a verdict and its evidence, a file and a line:
|
||||
|
||||
- **met** - and where.
|
||||
- **not met** - and what is missing.
|
||||
- **cannot tell** - and what would settle it. This is a real verdict. Use it instead of
|
||||
guessing, and say what you would have to run or read.
|
||||
|
||||
Run whatever the repo runs, its test suite and its linter. A suite that fails is not a
|
||||
criterion, but no criterion is met while it fails.
|
||||
|
||||
Then the two questions the criteria cannot ask themselves:
|
||||
|
||||
- **What did this change break that no criterion covers?** Silent behaviour changes,
|
||||
a message or exit code something else reads, an edge case the ticket never named.
|
||||
- **What did the ticket never think of?** That is what you append in step 5.
|
||||
|
||||
## 4. Write one comment
|
||||
|
||||
One call, one comment. Not one per criterion: the board renders comments in the order
|
||||
they were written, and a review split over eight of them cannot be read as a verdict.
|
||||
|
||||
```
|
||||
worklane comment 1b78a24 "**Verdict**: two criteria unmet, the scroll clamp is off by the header
|
||||
|
||||
**Work reviewed**: 4edc7fa, 6d327df on master
|
||||
|
||||
**Criteria**
|
||||
1. met - PageUp and PageDown reach detail_scroll, src/tui.rs:412
|
||||
2. not met - the footer still lists the arrow keys, src/tui.rs:88
|
||||
3. cannot tell - no test covers a ticket longer than the viewport
|
||||
|
||||
**Findings**
|
||||
- The clamp uses the raw line count, so a wrapped ticket scrolls past its end, src/tui.rs:430
|
||||
- Unticked criterion 2 accordingly
|
||||
|
||||
**Recommendation**: back to committed, the clamp is the ticket's own subject"
|
||||
```
|
||||
|
||||
Keep the structure, drop the sections that have nothing in them. `**Work reviewed**` is
|
||||
never empty: it holds the shas, the branch, or what you searched for and did not find.
|
||||
Write for the person who has to act on it, so every finding says where it is.
|
||||
|
||||
The comment body takes a leading hyphen without being parsed as a flag, so a finding can
|
||||
quote `--force` literally. A body of exactly `--` needs its own separator.
|
||||
|
||||
## 5. Write the verdict back to the ticket
|
||||
|
||||
```
|
||||
worklane uncheck 1b78a24 2 5
|
||||
worklane append 1b78a24 --acceptance "The footer lists only the keys that are bound"
|
||||
```
|
||||
|
||||
Untick every criterion you found unmet, by the numbers `show` printed, in one call. Do
|
||||
it after the comment so there is a written reason on the board before the mark changes.
|
||||
Do not reach for `all`: a review unticks what it found unmet, and unticking the lot would
|
||||
erase the implementer's claim on the criteria you agreed with.
|
||||
|
||||
**Never tick a criterion.** A tick is the implementer's claim that something is done, and
|
||||
unticking is the review disagreeing with that claim. A reviewer that also ticks makes
|
||||
both the same mark, and the board stops recording that anyone ever disagreed. A criterion
|
||||
you found met but left unticked is a line in the comment, not a mark for you to fix.
|
||||
|
||||
Append a criterion only for work the next commit has to make true, phrased so it can be
|
||||
ticked off. Advice, praise and anything already covered by an existing criterion belong in
|
||||
the comment. An appended criterion that restates a finding just makes the ticket longer
|
||||
without making it clearer.
|
||||
|
||||
**Do not move the ticket.** `mv` belongs to whoever does the work, the same way ticking
|
||||
does. Your half is the recommendation in the comment; acting on it is theirs. A reviewer
|
||||
that reviews and closes in one breath leaves nobody to disagree with.
|
||||
|
||||
## What a reviewer does not touch
|
||||
|
||||
- **The description, plan, title, priority and tags.** Rewriting the ticket you are
|
||||
reviewing destroys the record of what was asked for, which is the only thing your
|
||||
verdict can be measured against. Say it in the comment.
|
||||
- **The code.** Even a one-line fix is a finding: whoever wrote it gets to make the
|
||||
change, and gets to keep the review that asked for it. Fix it only if you are asked to,
|
||||
and then it is a new piece of work with its own comment.
|
||||
- **Another ticket's business.** Something you found that is genuinely out of scope gets
|
||||
its own ticket, filed the way the `worklane` skill says, and
|
||||
`worklane relate <new> --relates-to <this>` so the two are findable from each other.
|
||||
|
||||
## Reviewing what is waiting
|
||||
|
||||
```
|
||||
worklane ls reviewing
|
||||
```
|
||||
|
||||
One ticket at a time, with its own comment. A single comment covering four tickets lands
|
||||
on one of them and is lost to the other three.
|
||||
+74
-4
@@ -41,26 +41,47 @@ A move is also refused while the ticket is blocked by one that is not done yet,
|
||||
worklane ls # every status, counts then tickets
|
||||
worklane ls backlog # one status
|
||||
worklane ls --priority 1 # only the most urgent
|
||||
worklane ls --tag bug # only the tickets carrying that tag
|
||||
worklane show 1b78a24 # one ticket, body and comments
|
||||
```
|
||||
|
||||
`ls` prints a seven-character id per ticket. That is what you address it by.
|
||||
|
||||
The filters compose in any combination, with each other and with the status positional:
|
||||
`worklane ls backlog --tag bug --priority 1`. `--tag` takes one tag and matches it
|
||||
against the whole values of the comma-separated `Tags` field, case sensitively, so
|
||||
`--tag bug` finds neither a ticket tagged `bugfix` nor one tagged `Bug`. A ticket with no
|
||||
tags matches none. A tag nothing carries lists nothing rather than failing, so when a
|
||||
listing comes back empty check the spelling against a ticket you know is tagged.
|
||||
|
||||
## Working a ticket
|
||||
|
||||
```
|
||||
worklane mv 1b78a24 --status committed
|
||||
worklane check 1b78a24 3 # tick acceptance criterion 3
|
||||
worklane check 1b78a24 "the footer describes" # or a substring of it
|
||||
worklane check 1b78a24 1 3 "the footer" # several in one call
|
||||
worklane check 1b78a24 all # every criterion on the ticket
|
||||
worklane uncheck 1b78a24 3
|
||||
worklane comment 1b78a24 "Found the cause: the offset was never passed to the widget."
|
||||
worklane mv 1b78a24 --status reviewing
|
||||
```
|
||||
|
||||
Criteria are numbered by `show`. With the criterion omitted, `check` prompts when there
|
||||
is a terminal and otherwise fails with the numbered list, so **always pass the criterion
|
||||
Criteria are numbered by `show`. With no criterion given, `check` prompts when there
|
||||
is a terminal and otherwise fails with the numbered list, so **always pass the criteria
|
||||
when you are not sitting at a prompt**.
|
||||
|
||||
One call takes as many terms as you like, mixing numbers and substrings, and `all` stands
|
||||
for every criterion on the ticket. Use it when the work is done: it is one write instead
|
||||
of one per box. `all` is a keyword, checked before the text, so a criterion whose own
|
||||
words include "all" is reached by its number or by a longer substring.
|
||||
|
||||
**Every term is resolved before anything is written.** One term that matches nothing, or
|
||||
matches more than one criterion, refuses the whole call and names that term, so the ticket
|
||||
is never left half-marked. A criterion already in the state you asked for is reported
|
||||
unchanged rather than refused, and a call that would change nothing writes nothing. Both
|
||||
apply to `uncheck` exactly as they do to `check`.
|
||||
|
||||
## Filing a ticket
|
||||
|
||||
```
|
||||
@@ -85,6 +106,9 @@ worklane add \
|
||||
checked off as true or false.
|
||||
- **`--plan`** takes one step per flag, numbered for you.
|
||||
- **`--priority`** runs 1 (most urgent) to 5 (least), and is left unset if omitted.
|
||||
- **`--due`** takes `YYYY-MM-DD` and nothing else. Anything that is not a real calendar
|
||||
date in that exact form, `2026-8-9` and `2026-02-30` included, is a usage error with
|
||||
nothing written. The same parser guards `set --due`.
|
||||
|
||||
Editing afterwards, on a ticket in any status:
|
||||
|
||||
@@ -105,8 +129,8 @@ one command here that does not start with the ticket. The user is free text and
|
||||
checked against nothing. Swap the two and the call fails, because the username has to
|
||||
resolve as a ticket.
|
||||
|
||||
`worklane init` creates `.worklane/` with the four status directories, for a repo that
|
||||
has no board yet.
|
||||
`worklane init` creates `.worklane/` with the four status directories and the campaigns
|
||||
directory beside them, for a repo that has no board yet.
|
||||
|
||||
## Relating tickets
|
||||
|
||||
@@ -130,6 +154,52 @@ Recording a relation the ticket already holds reports no change. A ticket cannot
|
||||
to itself, and a target that later disappears shows as `_missing_` rather than silently
|
||||
going away.
|
||||
|
||||
`show` marks each row twice, kind then status. The kind is `×` for `blocked by` and
|
||||
`blocks`, `→` for `relates to`, `←` for `regression of` and `regressed by`; both
|
||||
directions of one kind carry one mark, and the label is what says which end you are on.
|
||||
The status is the target's own: `○` backlog, `◐` committed or reviewing, `●` done, and
|
||||
`?` for a target the board no longer holds. So `blocked by × ● (1b78a24)` is a blocker
|
||||
that is finished and `blocked by × ○ (1b78a24)` is one nobody has started. The board
|
||||
draws the same block.
|
||||
|
||||
Colour is what tells committed from reviewing, since both are `◐`, and **your output is a
|
||||
pipe, so you do not get the colour**. Read `◐` as under way, and if it matters which
|
||||
stage, `worklane show` on that target says so in its Status field. `●` and `○` are
|
||||
unambiguous without it, which are the two answers usually being asked for.
|
||||
|
||||
## Campaigns
|
||||
|
||||
A campaign groups the tickets that have to be finished together: a release, a migration,
|
||||
anything whose parts are separate tickets but whose goal is one thing. It is a file of
|
||||
its own under `.worklane/campaigns/`, with a title and a description, and it sits in no
|
||||
status directory. Its state is derived instead, open until every member is done, so
|
||||
there is no such thing as a done campaign holding an open ticket.
|
||||
|
||||
```
|
||||
worklane campaign add --title "v1 release" \
|
||||
--description "Everything that has to ship before the tag."
|
||||
worklane campaign ls # every campaign and how far it has got
|
||||
worklane campaign show "v1 release" # its body, then its members by status
|
||||
worklane assign "v1 release" 1b78a24 # put a ticket in it
|
||||
worklane ls --campaign "v1 release" # only that campaign's tickets
|
||||
```
|
||||
|
||||
`assign` takes the **campaign first and the ticket second**, like `chown`, and is the
|
||||
only writer of the field. `add` has no `--campaign` and neither has `set`, so membership
|
||||
has one writer the way owner and status do.
|
||||
|
||||
A ticket is in at most one campaign, so assigning one that already belongs somewhere
|
||||
moves it rather than adding a second. Assigning it to the campaign it already names
|
||||
reports no change and writes nothing.
|
||||
|
||||
`campaign show` lists done members too, unlike `ls`, which leaves the done column out of
|
||||
its listing: a campaign is precisely the question of what is finished against what is
|
||||
left.
|
||||
|
||||
A campaign is addressed the way a ticket is, by uuid prefix, title or filename, but it
|
||||
is not a ticket. Passing one where a ticket is expected is refused with a message saying
|
||||
so, and there is no way to move a campaign, because it has no status to move.
|
||||
|
||||
## Search the backlog before filing
|
||||
|
||||
Run `worklane ls` in the directory the ticket would land in and look for the same issue,
|
||||
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
//! Campaigns: the container for tickets that have to be finished together.
|
||||
//!
|
||||
//! A campaign is a file of its own under `.worklane/campaigns/`, holding a title, a
|
||||
//! description and metadata. It has no status directory and never sits in one. Its
|
||||
//! state is derived instead: open until every member is done. Deriving it means there
|
||||
//! is no such thing as a done campaign holding an open ticket, and no second
|
||||
//! forward-only ruleset to reason about beside `mv`'s.
|
||||
//!
|
||||
//! Membership is one field on the *member*, `Campaign` in the ticket Metadata, written
|
||||
//! only by `assign`. The member list is deliberately not stored on the campaign: that
|
||||
//! would put membership in two places, and would make one file that every assignment
|
||||
//! edits, which is contended the moment two agents share a board.
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::util::*;
|
||||
|
||||
/// Where campaigns live, beside the status directories rather than among them.
|
||||
pub const CAMPAIGNS_DIR: &str = "campaigns";
|
||||
|
||||
pub fn campaigns_dir(worklane_dir: &Path) -> PathBuf {
|
||||
worklane_dir.join(CAMPAIGNS_DIR)
|
||||
}
|
||||
|
||||
/// The campaigns directory, created if the board predates it.
|
||||
///
|
||||
/// `init` writes it for a new board, but every board made before campaigns existed has
|
||||
/// none, and refusing to file a campaign there would mean a `worklane init` over a live
|
||||
/// board just to get a directory.
|
||||
pub fn ensure_campaigns_dir(worklane_dir: &Path) -> Result<PathBuf> {
|
||||
let dir = campaigns_dir(worklane_dir);
|
||||
|
||||
fs::create_dir_all(&dir)
|
||||
.map_err(|e| anyhow!("Could not create {}: {}", dir.display(), e))?;
|
||||
|
||||
Ok(dir)
|
||||
}
|
||||
|
||||
/// A campaign as it comes off disk.
|
||||
pub struct Campaign {
|
||||
pub uuid: String,
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
/// The campaigns directory as [`resolve_in`] takes it.
|
||||
///
|
||||
/// The name is empty because a campaign has no status: it is what makes the ambiguity
|
||||
/// listing print an id and a title with no bracket after it.
|
||||
fn campaign_paths(worklane_dir: &Path) -> Vec<(String, PathBuf)> {
|
||||
vec![(String::new(), campaigns_dir(worklane_dir))]
|
||||
}
|
||||
|
||||
/// A campaign by the same three tiers a ticket resolves by, scoped to its own
|
||||
/// directory.
|
||||
///
|
||||
/// The tiers are [`resolve_in`]'s, not a second copy: a campaign is addressed the way
|
||||
/// everything else here is, and two resolvers would be two sets of precedence rules to
|
||||
/// keep in step.
|
||||
pub fn resolve_campaign(search: &str, worklane_dir: &Path) -> Result<Campaign> {
|
||||
let mut matches = resolve_in(search, &campaign_paths(worklane_dir))?;
|
||||
|
||||
if matches.is_empty() {
|
||||
return Err(anyhow!("No campaign found matching '{}'", search));
|
||||
}
|
||||
|
||||
if matches.len() > 1 {
|
||||
return Err(ambiguous("campaign", search, &matches));
|
||||
}
|
||||
|
||||
let found = matches.remove(0);
|
||||
let uuid = parse_ticket_field(&found.content, "ID");
|
||||
|
||||
if uuid.trim().is_empty() || is_unknown_value(&uuid) {
|
||||
return Err(anyhow!(
|
||||
"Campaign '{}' has no ID field, so nothing can be assigned to it",
|
||||
found.title
|
||||
));
|
||||
}
|
||||
|
||||
Ok(Campaign {
|
||||
uuid,
|
||||
title: found.title,
|
||||
content: found.content,
|
||||
})
|
||||
}
|
||||
|
||||
/// The title of the campaign a search names, for a caller that only needs to say so.
|
||||
///
|
||||
/// Used by `resolve_ticket` to explain a search that names a campaign rather than a
|
||||
/// ticket. Deliberately swallows both failures: nothing matched and too much matched
|
||||
/// both mean "this is not the explanation", and an error here would replace a clear
|
||||
/// "no ticket found" with a complaint about a directory the caller never mentioned.
|
||||
pub fn campaign_named(search: &str, worklane_dir: &Path) -> Option<String> {
|
||||
resolve_campaign(search, worklane_dir)
|
||||
.ok()
|
||||
.map(|campaign| campaign.title)
|
||||
}
|
||||
|
||||
/// Every campaign on the board, read in one pass.
|
||||
///
|
||||
/// One pass for the same reason [`RelationIndex`] takes one: rendering a ticket's
|
||||
/// Campaign field or listing the campaigns both need every one of them, and a lookup
|
||||
/// per ticket would read the directory once per row.
|
||||
pub struct CampaignIndex {
|
||||
campaigns: Vec<Campaign>,
|
||||
}
|
||||
|
||||
impl CampaignIndex {
|
||||
pub fn load(worklane_dir: &Path) -> Result<Self> {
|
||||
let dir = campaigns_dir(worklane_dir);
|
||||
let mut campaigns = Vec::new();
|
||||
|
||||
// A board with no campaigns directory has no campaigns, which is not an error:
|
||||
// every board made before campaigns existed is in that state.
|
||||
if !dir.exists() {
|
||||
return Ok(Self { campaigns });
|
||||
}
|
||||
|
||||
for entry in fs::read_dir(&dir)?.filter_map(|e| e.ok()) {
|
||||
let path = entry.path();
|
||||
if !path.extension().is_some_and(|e| e == "md") {
|
||||
continue;
|
||||
}
|
||||
let Ok(content) = fs::read_to_string(&path) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
campaigns.push(Campaign {
|
||||
uuid: parse_ticket_field(&content, "ID"),
|
||||
title: heading_title(&content),
|
||||
content,
|
||||
});
|
||||
}
|
||||
|
||||
// By title, so a listing does not depend on the order the directory hands its
|
||||
// entries back in.
|
||||
campaigns.sort_by_key(|campaign| campaign.title.to_lowercase());
|
||||
Ok(Self { campaigns })
|
||||
}
|
||||
|
||||
/// The campaign carrying `uuid`, or nothing when the board no longer has it.
|
||||
pub fn get(&self, uuid: &str) -> Option<&Campaign> {
|
||||
self.campaigns.iter().find(|campaign| campaign.uuid == uuid)
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &Campaign> {
|
||||
self.campaigns.iter()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.campaigns.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// The Campaign field as it reads, or empty for a ticket in no campaign.
|
||||
///
|
||||
/// A uuid no campaign carries renders as `_missing_`, the way a dangling relation
|
||||
/// target does, rather than as the bare value the file stores: the value is a full
|
||||
/// uuid, so showing it raw is thirty-six characters that say nothing about what is
|
||||
/// gone.
|
||||
pub fn campaign_cell(content: &str, index: &CampaignIndex, colored: bool) -> String {
|
||||
let Some(uuid) = parse_campaign(content) else {
|
||||
return String::new();
|
||||
};
|
||||
|
||||
reference_cell(
|
||||
&uuid,
|
||||
index.get(&uuid).map(|campaign| campaign.title.as_str()),
|
||||
colored,
|
||||
)
|
||||
}
|
||||
|
||||
/// The parts [`content_trim`] cannot render from the ticket file alone.
|
||||
///
|
||||
/// Both halves read the tree beside the ticket, so they are gathered in one place
|
||||
/// rather than at each call site.
|
||||
pub fn resolved_for(content: &str, worklane_dir: &Path, colored: bool) -> Result<Resolved> {
|
||||
Ok(Resolved {
|
||||
relations: relations_for(content, worklane_dir)?,
|
||||
campaign: campaign_cell(content, &CampaignIndex::load(worklane_dir)?, colored),
|
||||
})
|
||||
}
|
||||
|
||||
/// The members of a campaign, grouped by status in flow order.
|
||||
///
|
||||
/// Read through `collect_ticket_items`, the source `ls` and the board already use, so
|
||||
/// there is no second parser and the rows print the way every other listing does.
|
||||
/// Empty groups are kept: a campaign's shape is the four statuses, and a caller that
|
||||
/// wants only the filled ones can say so.
|
||||
pub fn members(worklane_dir: &Path, uuid: &str) -> Result<Vec<(&'static str, Vec<TicketItem>)>> {
|
||||
let mut grouped = Vec::new();
|
||||
|
||||
for status in status_dirs() {
|
||||
let status_path = worklane_dir.join(status);
|
||||
let items = match status_path.exists() {
|
||||
true => collect_ticket_items(&status_path)?,
|
||||
false => Vec::new(),
|
||||
};
|
||||
|
||||
grouped.push((
|
||||
status,
|
||||
items
|
||||
.into_iter()
|
||||
.filter(|item| item.campaign.as_deref() == Some(uuid))
|
||||
.collect(),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(grouped)
|
||||
}
|
||||
|
||||
/// How far a campaign has got: members done against members held.
|
||||
pub struct Standing {
|
||||
pub done: usize,
|
||||
pub total: usize,
|
||||
}
|
||||
|
||||
impl Standing {
|
||||
pub fn of(grouped: &[(&'static str, Vec<TicketItem>)]) -> Self {
|
||||
Self {
|
||||
done: grouped
|
||||
.iter()
|
||||
.filter(|(status, _)| *status == DONE)
|
||||
.map(|(_, items)| items.len())
|
||||
.sum(),
|
||||
total: grouped.iter().map(|(_, items)| items.len()).sum(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The count as it reads, or `no members` for a campaign nothing has been filed
|
||||
/// against.
|
||||
pub fn label(&self) -> String {
|
||||
match self.total {
|
||||
0 => "no members".to_string(),
|
||||
total => format!("{}/{} done", self.done, total),
|
||||
}
|
||||
}
|
||||
|
||||
/// A campaign is done when it holds members and every one of them is done.
|
||||
///
|
||||
/// An empty campaign is neither, hence the `None`: calling it done would make a
|
||||
/// container nothing has been filed against the most complete thing on the board,
|
||||
/// and calling it open would claim work that does not exist.
|
||||
pub fn state(&self) -> Option<&'static str> {
|
||||
match (self.total, self.done == self.total) {
|
||||
(0, _) => None,
|
||||
(_, true) => Some(DONE),
|
||||
(_, false) => Some("open"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The campaign file as it is written.
|
||||
///
|
||||
/// The same shape a ticket has, minus what a campaign has no use for: no acceptance
|
||||
/// criteria, because its definition of done is derived from its members rather than
|
||||
/// written down, no implementation plan, and no Status, because it sits in no status
|
||||
/// directory. The headings and the placeholder come from the section table in
|
||||
/// `util.rs`, so the two file formats cannot drift apart on the spelling of a heading.
|
||||
pub fn campaign_body(
|
||||
title: &str,
|
||||
description: &[String],
|
||||
id: &uuid::Uuid,
|
||||
owner: Option<&str>,
|
||||
created_at: &str,
|
||||
) -> String {
|
||||
// Joined with a single newline, so an empty value is how a caller spells a
|
||||
// paragraph break, exactly as it is for a ticket.
|
||||
let description = trim_blank_ends(description);
|
||||
let description_text = match description.is_empty() {
|
||||
true => DESCRIPTION.placeholder.to_string(),
|
||||
false => description.join("\n"),
|
||||
};
|
||||
|
||||
format!(
|
||||
"# {title}\n\
|
||||
\n\
|
||||
{description_heading}\n\
|
||||
{description_text}\n\
|
||||
\n\
|
||||
{metadata_heading}\n\
|
||||
\n\
|
||||
- **ID**: {id}\n\
|
||||
- **Owner**: {owner}\n\
|
||||
- **Created At**: {created_at}\n\
|
||||
",
|
||||
description_heading = DESCRIPTION.heading,
|
||||
metadata_heading = METADATA_HEADING,
|
||||
owner = owner.unwrap_or("_Not set_"),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//! Putting text on the clipboard of whatever terminal is drawing the board.
|
||||
//!
|
||||
//! OSC 52, written by hand, and the reasoning is in AGENTS.md under The Copy Key. The
|
||||
//! short of it: the board is often being read over ssh, and an escape sequence is the
|
||||
//! only one of the three ways that crosses the connection. crossterm 0.28 is what
|
||||
//! ratatui 0.29 pins and it ships no clipboard command, so the sequence and the base64
|
||||
//! it carries are written here rather than pulled in.
|
||||
//!
|
||||
//! The honest limit is that a terminal which ignores OSC 52 ignores it silently: what
|
||||
//! this reports is whether the sequence was written, not whether it was honoured.
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
/// Ask the terminal to put `text` on the system clipboard.
|
||||
///
|
||||
/// `52;c` is the clipboard proper rather than `p`, the X11 primary selection, because
|
||||
/// this is for pasting into a command line with ctrl-shift-v or cmd-v. Terminated with
|
||||
/// BEL rather than ST: both are accepted, and BEL is what tmux's `set-clipboard`
|
||||
/// documents and what every emulator that implements this at all takes.
|
||||
///
|
||||
/// Written straight to stdout, which is where ratatui's own frames go, and flushed
|
||||
/// before returning so a failure belongs to this call rather than to the next draw.
|
||||
pub fn copy(text: &str) -> Result<()> {
|
||||
let mut out = std::io::stdout();
|
||||
write!(out, "\x1b]52;c;{}\x07", base64(text.as_bytes()))
|
||||
.and_then(|()| out.flush())
|
||||
.context("could not write to the terminal")
|
||||
}
|
||||
|
||||
/// Standard base64, the alphabet OSC 52 requires, padding included.
|
||||
///
|
||||
/// Twenty lines against a dependency: the only thing encoded here is a seven-character
|
||||
/// id, and the crate would be carried for its own sake.
|
||||
fn base64(bytes: &[u8]) -> String {
|
||||
const ALPHABET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
let mut out = String::with_capacity(bytes.len().div_ceil(3) * 4);
|
||||
for chunk in bytes.chunks(3) {
|
||||
// The missing bytes of a short chunk read as zero, and the characters they
|
||||
// would have produced are the ones that become padding below.
|
||||
let triple = chunk
|
||||
.iter()
|
||||
.chain([0u8; 2].iter())
|
||||
.take(3)
|
||||
.fold(0u32, |acc, byte| (acc << 8) | u32::from(*byte));
|
||||
|
||||
for slot in 0..4 {
|
||||
match slot <= chunk.len() {
|
||||
true => out.push(char::from(ALPHABET[(triple >> (18 - 6 * slot) & 0x3f) as usize])),
|
||||
false => out.push('='),
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// The vectors from RFC 4648, which is what a terminal decodes with. Every chunk
|
||||
/// length is in here, so the padding is covered in both of its forms.
|
||||
#[test]
|
||||
fn base64_encodes_the_rfc_vectors() {
|
||||
assert_eq!(base64(b""), "");
|
||||
assert_eq!(base64(b"f"), "Zg==");
|
||||
assert_eq!(base64(b"fo"), "Zm8=");
|
||||
assert_eq!(base64(b"foo"), "Zm9v");
|
||||
assert_eq!(base64(b"foob"), "Zm9vYg==");
|
||||
assert_eq!(base64(b"fooba"), "Zm9vYmE=");
|
||||
assert_eq!(base64(b"foobar"), "Zm9vYmFy");
|
||||
}
|
||||
|
||||
/// What actually goes on the wire for a short id, which is the whole use.
|
||||
#[test]
|
||||
fn base64_encodes_a_short_id() {
|
||||
assert_eq!(base64(b"0546fc5"), "MDU0NmZjNQ==");
|
||||
}
|
||||
|
||||
/// The high bits reach the end of the alphabet, which an off-by-one in the shift
|
||||
/// would miss entirely on ascii input.
|
||||
#[test]
|
||||
fn base64_reaches_the_whole_alphabet() {
|
||||
assert_eq!(base64(&[0xff, 0xff, 0xff]), "////");
|
||||
assert_eq!(base64(&[0xfb, 0xff, 0xfe]), "+//+");
|
||||
assert_eq!(base64(&[0x00, 0x00, 0x00]), "AAAA");
|
||||
}
|
||||
}
|
||||
+135
-8
@@ -2,6 +2,8 @@ use clap::Parser;
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
|
||||
use crate::util::{PRIORITY_RANGE, RelationKind, priority_legend};
|
||||
|
||||
/// clap wants a `&str` with a long enough lifetime, and the legend is built from
|
||||
@@ -53,6 +55,42 @@ fn non_empty(raw: &str) -> Result<String, String> {
|
||||
Ok(raw.to_string())
|
||||
}
|
||||
|
||||
/// Reject a due date that is not a real calendar date in the promised form.
|
||||
///
|
||||
/// At parse time, like `priority_level`, so a mistyped date is a usage error with
|
||||
/// nothing written rather than a value the board goes on showing. `--due` is one of the
|
||||
/// scalars deliberately left without `PROSE`, so this is the same bargain: nothing here
|
||||
/// holds prose, and a wrong value should stop the command.
|
||||
///
|
||||
/// **The shape is checked before chrono sees it.** `%Y-%m-%d` accepts an unpadded
|
||||
/// `2026-8-9`, which would then be stored exactly as typed and sort before `2026-10-01`
|
||||
/// in any comparison of the strings. Checking the length and the two dashes first is
|
||||
/// what lets a valid date be stored unchanged rather than normalised on the way in.
|
||||
///
|
||||
/// Strict on the way in, tolerant on the way out: `util::due_date` still cuts a
|
||||
/// datetime down to its date, because a file written before this existed, or by hand,
|
||||
/// can hold one and still has to render.
|
||||
fn iso_date(raw: &str) -> Result<String, String> {
|
||||
// An empty value keeps the message that explains why it is refused, since somebody
|
||||
// typing it is reaching for a way to clear the field rather than mistyping a date.
|
||||
non_empty(raw)?;
|
||||
|
||||
let bytes = raw.as_bytes();
|
||||
let shaped = raw.len() == 10 && bytes[4] == b'-' && bytes[7] == b'-';
|
||||
|
||||
if !shaped || NaiveDate::parse_from_str(raw, "%Y-%m-%d").is_err() {
|
||||
// Not echoing the value: clap has already printed `invalid value '...' for
|
||||
// '--due <DUE>'` above this line, and `priority_level` says its piece the same
|
||||
// way.
|
||||
return Err(
|
||||
"due date must be a real calendar date written as YYYY-MM-DD, for example 2026-08-29"
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(raw.to_string())
|
||||
}
|
||||
|
||||
/// Arguments that carry prose, and therefore have to accept a value starting with
|
||||
/// a hyphen.
|
||||
///
|
||||
@@ -81,6 +119,14 @@ pub enum Command {
|
||||
/// Only show tickets at this priority, 1 (most urgent) to 5 (least)
|
||||
#[arg(long, value_parser = priority_level)]
|
||||
priority: Option<u8>,
|
||||
|
||||
/// Only show tickets carrying this tag, matched whole
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
tag: Option<String>,
|
||||
|
||||
/// Only show the members of this campaign, by UUID or title
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
campaign: Option<String>,
|
||||
},
|
||||
|
||||
/// Show a ticket by UUID or title
|
||||
@@ -139,10 +185,10 @@ pub enum Command {
|
||||
paths: Vec<std::path::PathBuf>,
|
||||
},
|
||||
|
||||
/// Tick an acceptance criterion
|
||||
/// Tick acceptance criteria
|
||||
Check(CheckArgs),
|
||||
|
||||
/// Untick an acceptance criterion
|
||||
/// Untick acceptance criteria
|
||||
Uncheck(CheckArgs),
|
||||
|
||||
/// Add a comment to a ticket
|
||||
@@ -159,8 +205,37 @@ pub enum Command {
|
||||
owner: Option<String>,
|
||||
},
|
||||
|
||||
/// Install the agent skill that teaches an agent to use worklane
|
||||
/// Group tickets that have to be finished together
|
||||
Campaign {
|
||||
#[command(subcommand)]
|
||||
command: CampaignCommand,
|
||||
},
|
||||
|
||||
/// Put a ticket in a campaign
|
||||
///
|
||||
/// Campaign first, ticket second, after `chown` and for the same reason: the
|
||||
/// container is what the call is about, and the order is worth being consistent
|
||||
/// about across the two commands that name two things.
|
||||
///
|
||||
/// The only writer of the Campaign field. `add` has no `--campaign` and `set` has
|
||||
/// no `--campaign`, so the field keeps one writer the way Owner and Status do.
|
||||
Assign {
|
||||
/// Campaign UUID or title
|
||||
campaign: String,
|
||||
|
||||
/// Ticket UUID or title
|
||||
ticket: String,
|
||||
},
|
||||
|
||||
/// Install the agent skills that teach an agent to use worklane
|
||||
///
|
||||
/// Every shipped document by default. The optional name narrows it to one, and
|
||||
/// `--print` requires it: a diff is against one document, and printing them all
|
||||
/// concatenated would only look like one.
|
||||
InstallSkill {
|
||||
/// Skill to install or print, all of them if omitted
|
||||
skill: Option<String>,
|
||||
|
||||
/// Overwrite an existing copy that has been modified
|
||||
#[arg(long)]
|
||||
force: bool,
|
||||
@@ -171,6 +246,48 @@ pub enum Command {
|
||||
},
|
||||
}
|
||||
|
||||
/// What a campaign can be asked for.
|
||||
///
|
||||
/// No `mv`: a campaign has no status to move it to, its state is derived from its
|
||||
/// members. No `set` or `append` either, which is a gap rather than a decision, since
|
||||
/// nothing yet edits a campaign after it is filed.
|
||||
#[derive(clap::Subcommand)]
|
||||
pub enum CampaignCommand {
|
||||
/// File a new campaign
|
||||
Add(CampaignAddArgs),
|
||||
|
||||
/// List campaigns with their member counts
|
||||
Ls,
|
||||
|
||||
/// Show a campaign and its members grouped by status
|
||||
Show {
|
||||
/// Campaign UUID or title
|
||||
campaign: String,
|
||||
},
|
||||
}
|
||||
|
||||
/// What a campaign holds: a title, a description and an owner.
|
||||
///
|
||||
/// Deliberately narrower than [`AddArgs`]. There are no acceptance criteria, because a
|
||||
/// campaign's definition of done is derived from its members rather than written down,
|
||||
/// and no implementation plan. Priority, tags and a due date are left out because
|
||||
/// nothing reads them yet, and a field written but never shown is a field that goes
|
||||
/// stale unnoticed.
|
||||
#[derive(clap::Args)]
|
||||
pub struct CampaignAddArgs {
|
||||
/// Campaign title
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub title: String,
|
||||
|
||||
/// What the campaign is for. Use multiple flags for multiline descriptions
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub description: Vec<String>,
|
||||
|
||||
/// Owner. Defaults to the git user
|
||||
#[arg(short, long)]
|
||||
pub owner: Option<String>,
|
||||
}
|
||||
|
||||
/// `add` carries every field a new ticket can hold, so it is a struct rather than an
|
||||
/// inline variant: nine parameters at the call site is what `too_many_arguments` is
|
||||
/// for, and `set`, `append` and `check` already pass their arguments this way.
|
||||
@@ -200,7 +317,7 @@ pub struct AddArgs {
|
||||
pub tags: Vec<String>,
|
||||
|
||||
/// Due date (YYYY-MM-DD)
|
||||
#[arg(long)]
|
||||
#[arg(long, value_parser = iso_date)]
|
||||
pub due: Option<String>,
|
||||
|
||||
/// Owner
|
||||
@@ -249,7 +366,11 @@ pub struct SetArgs {
|
||||
pub tags: Vec<String>,
|
||||
|
||||
/// Replace the due date (YYYY-MM-DD)
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
///
|
||||
/// The same parser as `add`: one field, one definition of what a due date is. The
|
||||
/// planning skill sets dates through `set` rather than `add`, so validating only
|
||||
/// the one that files a ticket would leave the path that is actually used open.
|
||||
#[arg(long, value_parser = iso_date)]
|
||||
pub due: Option<String>,
|
||||
|
||||
/// Replace the priority, 1 (most urgent) to 5 (least)
|
||||
@@ -331,14 +452,20 @@ impl RelateArgs {
|
||||
/// because the two read as opposites at the call site and neither needs the other's
|
||||
/// name to make sense.
|
||||
///
|
||||
/// The criterion is optional: without it the criteria are listed and the index asked
|
||||
/// The criteria are optional: without any the criteria are listed and the index asked
|
||||
/// for, or, where there is no terminal to ask at, returned as an error carrying the
|
||||
/// same list.
|
||||
///
|
||||
/// Several terms in one call because finishing a ticket means ticking every box, and
|
||||
/// one invocation per box resolved the ticket and rewrote the file each time. The
|
||||
/// terms are variadic rather than a repeated flag: they address something that is
|
||||
/// already there, the way the ticket positional does, instead of carrying content the
|
||||
/// way `--acceptance` does.
|
||||
#[derive(clap::Args)]
|
||||
pub struct CheckArgs {
|
||||
/// Ticket UUID or title
|
||||
pub ticket: String,
|
||||
|
||||
/// Criterion index as shown by `show`, or a substring of its text. Prompts if omitted
|
||||
pub criterion: Option<String>,
|
||||
/// Criterion indexes as shown by `show`, substrings of their text, or `all`. Prompts if omitted
|
||||
pub criteria: Vec<String>,
|
||||
}
|
||||
|
||||
+372
-76
@@ -4,7 +4,8 @@ use std::fs;
|
||||
use std::io::{BufRead, IsTerminal, Write};
|
||||
use std::path::Path;
|
||||
|
||||
use crate::command::{AddArgs, AppendArgs, CheckArgs, RelateArgs, SetArgs};
|
||||
use crate::campaign::*;
|
||||
use crate::command::{AddArgs, AppendArgs, CampaignAddArgs, CheckArgs, RelateArgs, SetArgs};
|
||||
use crate::install;
|
||||
use crate::util::*;
|
||||
|
||||
@@ -27,6 +28,11 @@ pub fn cmd_init(start: &Path) -> Result<()> {
|
||||
fs::create_dir_all(worklane_dir.join(folder))?;
|
||||
}
|
||||
|
||||
// Beside the status directories, not among them: a campaign has no status. Created
|
||||
// here for a new board, and on demand by `campaign add` for a board that predates
|
||||
// campaigns, which is why `status_dirs()` is untouched.
|
||||
fs::create_dir_all(campaigns_dir(&worklane_dir))?;
|
||||
|
||||
println!("Initialized worklane in: {}", worklane_dir.display());
|
||||
Ok(())
|
||||
}
|
||||
@@ -34,8 +40,27 @@ pub fn cmd_init(start: &Path) -> Result<()> {
|
||||
pub fn cmd_ls(
|
||||
status_filter: &Option<String>,
|
||||
priority_filter: Option<u8>,
|
||||
tag_filter: &Option<String>,
|
||||
campaign_filter: &Option<String>,
|
||||
worklane_dir: &Path,
|
||||
) -> Result<()> {
|
||||
// Resolved before anything is read, so an unknown campaign is refused rather than
|
||||
// silently listing nothing, and the name is available for the heading.
|
||||
let campaign = match campaign_filter {
|
||||
Some(search) => Some(resolve_campaign(search, worklane_dir)?),
|
||||
None => None,
|
||||
};
|
||||
let uuid = campaign.as_ref().map(|campaign| campaign.uuid.as_str());
|
||||
let tag = tag_filter.as_deref();
|
||||
|
||||
if let Some(campaign) = &campaign {
|
||||
println!(
|
||||
"Members of campaign ({}) {}\n",
|
||||
color_text(short_id(&campaign.uuid), Color::Red),
|
||||
color_text(&campaign.title, Color::Green),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(status) = status_filter {
|
||||
let status_path = worklane_dir.join(status);
|
||||
if !status_path.exists() {
|
||||
@@ -45,7 +70,7 @@ pub fn cmd_ls(
|
||||
));
|
||||
}
|
||||
|
||||
let items = filter_by_priority(collect_ticket_items(&status_path)?, priority_filter);
|
||||
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
|
||||
|
||||
if items.is_empty() {
|
||||
println!("No tickets in '{}' status.", status);
|
||||
@@ -63,7 +88,7 @@ pub fn cmd_ls(
|
||||
if !status_path.exists() {
|
||||
continue;
|
||||
}
|
||||
let items = filter_by_priority(collect_ticket_items(&status_path)?, priority_filter);
|
||||
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
|
||||
let count = items.len();
|
||||
let label = if count == 1 { "ticket" } else { "tickets" };
|
||||
println!(" [{}] {} {}", status.to_uppercase(), count, label);
|
||||
@@ -79,7 +104,7 @@ pub fn cmd_ls(
|
||||
continue;
|
||||
}
|
||||
let items = match collect_ticket_items(&status_path) {
|
||||
Ok(items) => filter_by_priority(items, priority_filter),
|
||||
Ok(items) => filtered(items, priority_filter, uuid, tag),
|
||||
Err(_) => continue,
|
||||
};
|
||||
if items.is_empty() {
|
||||
@@ -94,6 +119,53 @@ pub fn cmd_ls(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The listing filters in one call, so the three places `ls` collects a column cannot
|
||||
/// end up applying a different set of them.
|
||||
///
|
||||
/// Every filter is `Option`, and none asked for is everything kept, which is what makes
|
||||
/// them compose in any combination without a rule per pair.
|
||||
fn filtered(
|
||||
items: Vec<TicketItem>,
|
||||
level: Option<u8>,
|
||||
campaign: Option<&str>,
|
||||
tag: Option<&str>,
|
||||
) -> Vec<TicketItem> {
|
||||
filter_by_tag(
|
||||
filter_by_campaign(filter_by_priority(items, level), campaign),
|
||||
tag,
|
||||
)
|
||||
}
|
||||
|
||||
/// Keep only the tickets carrying `tag`, or everything when none was asked for.
|
||||
///
|
||||
/// Matched against the whole values `parse_tags` split out of the field rather than as a
|
||||
/// substring of it, so `--tag bug` is not answered by a ticket tagged `bugfix`, and a
|
||||
/// ticket with no tags matches nothing at all.
|
||||
///
|
||||
/// Case sensitive, the opinion the field already takes everywhere else: `tag_color`
|
||||
/// draws `Bug` and `bug` in two colours because they are two tags, and a filter that
|
||||
/// folded them would list tickets carrying a tag nobody asked for.
|
||||
fn filter_by_tag(items: Vec<TicketItem>, tag: Option<&str>) -> Vec<TicketItem> {
|
||||
match tag {
|
||||
Some(tag) => items
|
||||
.into_iter()
|
||||
.filter(|item| item.tags.iter().any(|carried| carried == tag))
|
||||
.collect(),
|
||||
None => items,
|
||||
}
|
||||
}
|
||||
|
||||
/// Keep only the members of `campaign`, or everything when none was asked for.
|
||||
fn filter_by_campaign(items: Vec<TicketItem>, campaign: Option<&str>) -> Vec<TicketItem> {
|
||||
match campaign {
|
||||
Some(uuid) => items
|
||||
.into_iter()
|
||||
.filter(|item| item.campaign.as_deref() == Some(uuid))
|
||||
.collect(),
|
||||
None => items,
|
||||
}
|
||||
}
|
||||
|
||||
/// Keep only the tickets at `level`, or everything when no level was asked for.
|
||||
fn filter_by_priority(items: Vec<TicketItem>, level: Option<u8>) -> Vec<TicketItem> {
|
||||
match level {
|
||||
@@ -304,14 +376,14 @@ pub fn cmd_show(search: &str, worklane_dir: &Path) -> Result<()> {
|
||||
let ticket_uuid = parse_ticket_field(&content, "ID");
|
||||
// Read before anything is printed, so a board that cannot be read fails instead of
|
||||
// half printing a ticket.
|
||||
let relations = relations_block(&content, worklane_dir, should_use_colors())?;
|
||||
let resolved = resolved_for(&content, worklane_dir, should_use_colors())?;
|
||||
|
||||
// The only title in the output: content_trim_colored used to print it a second
|
||||
// time from the file content. Green per the colour guideline, and the rule is
|
||||
// measured in characters so a non-ASCII title is not over-drawn.
|
||||
println!("{}", color_text(&title, Color::Green));
|
||||
println!("{}", "─".repeat(title.chars().count()));
|
||||
println!("\n{}", content_trim_colored(&content, &relations));
|
||||
println!("\n{}", content_trim_colored(&content, &resolved));
|
||||
|
||||
if ticket_uuid != "_Not set_" {
|
||||
let comments_dir = worklane_dir.join("comments").join(&ticket_uuid);
|
||||
@@ -883,6 +955,156 @@ pub fn cmd_relate(args: &RelateArgs, start: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------- campaigns --
|
||||
|
||||
/// File a new campaign.
|
||||
///
|
||||
/// Written through `write_then_replace` rather than `fs::write`, so a failure leaves no
|
||||
/// half-written campaign behind. `cmd_add` predates that primitive and still uses the
|
||||
/// plain write; the difference is noted on the ticket rather than fixed here.
|
||||
pub fn cmd_campaign_add(args: &CampaignAddArgs, start: &Path) -> Result<()> {
|
||||
let CampaignAddArgs {
|
||||
title,
|
||||
description,
|
||||
owner,
|
||||
} = args;
|
||||
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let dir = ensure_campaigns_dir(&worklane_dir)?;
|
||||
|
||||
let owner = match owner {
|
||||
Some(owner) => Some(owner.clone()),
|
||||
None => get_git_user(),
|
||||
};
|
||||
|
||||
let id = uuid::Uuid::new_v4();
|
||||
let filename = format!("{}_{}.md", id, slug(title));
|
||||
let path = dir.join(&filename);
|
||||
|
||||
let body = campaign_body(
|
||||
title,
|
||||
description,
|
||||
&id,
|
||||
owner.as_deref(),
|
||||
&Local::now().format(TIMESTAMP_FORMAT).to_string(),
|
||||
);
|
||||
|
||||
write_then_replace(&worklane_dir, &path, &filename, &body, title)?;
|
||||
|
||||
println!("Created campaign: {}", filename);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// List the campaigns with how far each has got.
|
||||
///
|
||||
/// The counts come from one pass over the status directories per campaign. That is a
|
||||
/// scan per row rather than one scan reused, and it is deliberate: the alternative is a
|
||||
/// map from campaign uuid to counts built in a single walk, which is worth writing when
|
||||
/// a board has enough campaigns to notice and is premature now.
|
||||
pub fn cmd_campaign_ls(worklane_dir: &Path) -> Result<()> {
|
||||
let index = CampaignIndex::load(worklane_dir)?;
|
||||
|
||||
if index.is_empty() {
|
||||
println!("No campaigns yet. `worklane campaign add --title` files one.");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let colored = should_use_colors();
|
||||
println!("Campaigns:\n");
|
||||
|
||||
for campaign in index.iter() {
|
||||
let standing = Standing::of(&members(worklane_dir, &campaign.uuid)?);
|
||||
let state = match standing.state() {
|
||||
Some(state) => format!(" [{}]", paint(state, Color::Orange, colored)),
|
||||
None => String::new(),
|
||||
};
|
||||
|
||||
println!(
|
||||
" ({}) {} | {}{}",
|
||||
paint(short_id(&campaign.uuid), Color::Red, colored),
|
||||
campaign.title,
|
||||
standing.label(),
|
||||
state,
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Show a campaign, then its members grouped by status.
|
||||
///
|
||||
/// Every status is shown, done included, unlike `ls`, which leaves done out of its
|
||||
/// listing. A campaign's whole point is what is finished against what is left, so
|
||||
/// hiding the finished half would hide the answer.
|
||||
pub fn cmd_campaign_show(search: &str, worklane_dir: &Path) -> Result<()> {
|
||||
let campaign = resolve_campaign(search, worklane_dir)?;
|
||||
|
||||
println!("{}", color_text(&campaign.title, Color::Green));
|
||||
println!("{}", "─".repeat(campaign.title.chars().count()));
|
||||
// No relations and no campaign of its own: a campaign is not a ticket, and neither
|
||||
// belongs to one.
|
||||
println!(
|
||||
"\n{}",
|
||||
content_trim_colored(&campaign.content, &Resolved::default())
|
||||
);
|
||||
|
||||
let grouped = members(worklane_dir, &campaign.uuid)?;
|
||||
let standing = Standing::of(&grouped);
|
||||
|
||||
println!("{}", color_text("Members", Color::Orange));
|
||||
println!("{}", "─".repeat("Members".chars().count()));
|
||||
println!("\n{}", standing.label());
|
||||
|
||||
for (status, items) in &grouped {
|
||||
if items.is_empty() {
|
||||
continue;
|
||||
}
|
||||
println!(
|
||||
"\n{}",
|
||||
color_text(&format!("[{}]", status.to_uppercase()), Color::Orange)
|
||||
);
|
||||
display_ticket_items(items);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Put a ticket in a campaign, the only writer of the Campaign field.
|
||||
///
|
||||
/// The campaign is resolved first, so a call naming a good ticket and a bad campaign
|
||||
/// writes nothing. A ticket names at most one campaign because the field is rewritten
|
||||
/// rather than added to, so assigning a ticket that is already in one moves it.
|
||||
///
|
||||
/// No-op detection compares the whole file, the way `set` and `chown` do, so assigning
|
||||
/// a ticket to the campaign it already names writes nothing.
|
||||
pub fn cmd_assign(campaign_search: &str, ticket_id: &str, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let campaign = resolve_campaign(campaign_search, &worklane_dir)?;
|
||||
let (status, title, original) = resolve_ticket(ticket_id, &worklane_dir)?;
|
||||
let uuid = parse_ticket_field(&original, "ID");
|
||||
|
||||
let content =
|
||||
set_or_insert_metadata_field(&original, CAMPAIGN_FIELD, &campaign.uuid, &title)?;
|
||||
|
||||
if content == original {
|
||||
println!(
|
||||
"Ticket '{}' is already in campaign '{}'",
|
||||
color_text(&title, Color::Green),
|
||||
campaign.title,
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
save_ticket(&worklane_dir, &status, &uuid, &title, None, &content)?;
|
||||
|
||||
println!(
|
||||
"Assigned '{}' to campaign '{}'",
|
||||
color_text(&title, Color::Green),
|
||||
campaign.title,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Which criterion to act on, asked for when the caller did not say.
|
||||
///
|
||||
/// A terminal gets the list and a prompt. Anything else gets the same list as an
|
||||
@@ -931,6 +1153,66 @@ fn ask_which_criterion(criteria: &[Criterion], title: &str) -> Result<usize> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Every criterion the terms name, in the order `show` numbers them and without
|
||||
/// repeats.
|
||||
///
|
||||
/// Resolved before a byte is written, and one bad term refuses the whole batch. A call
|
||||
/// that ticked the terms it understood and then failed would leave the ticket
|
||||
/// half-marked, with nothing in the file to say which half the caller meant, and the
|
||||
/// obvious retry would be reading the ticket back to find out.
|
||||
///
|
||||
/// The offending term is named on its own rather than every failure at once: each
|
||||
/// message carries the criteria listing, so a batch of them would repeat the list per
|
||||
/// bad term and bury the first one.
|
||||
fn resolve_criteria(criteria: &[Criterion], terms: &[String], title: &str) -> Result<Vec<usize>> {
|
||||
let mut chosen: Vec<usize> = Vec::new();
|
||||
|
||||
for term in terms {
|
||||
if is_all_criteria(term) {
|
||||
chosen.extend(0..criteria.len());
|
||||
continue;
|
||||
}
|
||||
|
||||
let found = find_criteria(criteria, term);
|
||||
match found.len() {
|
||||
1 => chosen.push(found[0]),
|
||||
0 if is_index(term) => {
|
||||
return Err(anyhow!(
|
||||
"'{}' is not one of the {} criteria of '{}':\n{}",
|
||||
term.trim(),
|
||||
criteria.len(),
|
||||
title,
|
||||
criteria_list(criteria)
|
||||
));
|
||||
}
|
||||
0 => {
|
||||
return Err(anyhow!(
|
||||
"No criterion of '{}' matches '{}'. Its criteria are:\n{}",
|
||||
title,
|
||||
term,
|
||||
criteria_list(criteria)
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow!(
|
||||
"'{}' matches {} criteria of '{}':\n{}\n\nUse the number instead.",
|
||||
term,
|
||||
found.len(),
|
||||
title,
|
||||
numbered_criteria(criteria, &found)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sorted so the report reads in the order `show` numbers the criteria whatever
|
||||
// order the terms arrived in, and deduped so a criterion named twice, or by both
|
||||
// `all` and its own number, is reported once.
|
||||
chosen.sort_unstable();
|
||||
chosen.dedup();
|
||||
Ok(chosen)
|
||||
}
|
||||
|
||||
pub fn cmd_check(args: &CheckArgs, checked: bool, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let (status, title, content) = resolve_ticket(&args.ticket, &worklane_dir)?;
|
||||
@@ -940,94 +1222,108 @@ pub fn cmd_check(args: &CheckArgs, checked: bool, start: &Path) -> Result<()> {
|
||||
return Err(anyhow!("Ticket '{}' has no acceptance criteria", title));
|
||||
}
|
||||
|
||||
let chosen = match &args.criterion {
|
||||
None => ask_which_criterion(&criteria, &title)?,
|
||||
Some(search) => {
|
||||
let found = find_criteria(&criteria, search);
|
||||
match found.len() {
|
||||
1 => found[0],
|
||||
0 if is_index(search) => {
|
||||
return Err(anyhow!(
|
||||
"'{}' is not one of the {} criteria of '{}':\n{}",
|
||||
search.trim(),
|
||||
criteria.len(),
|
||||
title,
|
||||
criteria_list(&criteria)
|
||||
));
|
||||
}
|
||||
0 => {
|
||||
return Err(anyhow!(
|
||||
"No criterion of '{}' matches '{}'. Its criteria are:\n{}",
|
||||
title,
|
||||
search,
|
||||
criteria_list(&criteria)
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow!(
|
||||
"'{}' matches {} criteria of '{}':\n{}\n\nUse the number instead.",
|
||||
search,
|
||||
found.len(),
|
||||
title,
|
||||
numbered_criteria(&criteria, &found)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
let chosen = match args.criteria.as_slice() {
|
||||
[] => vec![ask_which_criterion(&criteria, &title)?],
|
||||
terms => resolve_criteria(&criteria, terms, &title)?,
|
||||
};
|
||||
|
||||
let criterion = &criteria[chosen];
|
||||
let verb = if checked { "checked" } else { "unchecked" };
|
||||
// Only the criteria that are not already in the target state, so a batch where
|
||||
// every box is already ticked writes nothing, the way a single one always has.
|
||||
let changing: Vec<usize> = chosen
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|offset| criteria[*offset].checked != checked)
|
||||
.collect();
|
||||
|
||||
if criterion.checked == checked {
|
||||
println!(
|
||||
"Already {}: {}",
|
||||
verb,
|
||||
color_text(&criterion.text, Color::Green)
|
||||
);
|
||||
return Ok(());
|
||||
if !changing.is_empty() {
|
||||
let lines: Vec<usize> = changing
|
||||
.iter()
|
||||
.map(|offset| criteria[*offset].line)
|
||||
.collect();
|
||||
let updated = set_criteria(&content, &lines, checked);
|
||||
let uuid = parse_ticket_field(&content, "ID");
|
||||
save_ticket(&worklane_dir, &status, &uuid, &title, None, &updated)?;
|
||||
}
|
||||
|
||||
let updated = set_criterion(&content, criterion.line, checked);
|
||||
let uuid = parse_ticket_field(&content, "ID");
|
||||
save_ticket(&worklane_dir, &status, &uuid, &title, None, &updated)?;
|
||||
// Reported after the write, one line per criterion the call named, so nothing
|
||||
// claims a mark the file does not carry.
|
||||
let verb = if checked { "checked" } else { "unchecked" };
|
||||
let past = if checked { "Checked" } else { "Unchecked" };
|
||||
|
||||
for offset in chosen {
|
||||
let criterion = &criteria[offset];
|
||||
let state = if criterion.checked == checked {
|
||||
format!("Already {}", verb)
|
||||
} else {
|
||||
past.to_string()
|
||||
};
|
||||
|
||||
println!(
|
||||
"{} {}: {}",
|
||||
state,
|
||||
offset + 1,
|
||||
color_text(&criterion.text, Color::Green)
|
||||
);
|
||||
}
|
||||
|
||||
println!(
|
||||
"{} {}: {}",
|
||||
if checked { "Checked" } else { "Unchecked" },
|
||||
chosen + 1,
|
||||
color_text(&criterion.text, Color::Green)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Install the agent skill, or print it so a modified copy can be diffed.
|
||||
/// Install the agent skills, or print one so a modified copy can be diffed.
|
||||
///
|
||||
/// No board is looked for. The document is what teaches an agent worklane, so needing
|
||||
/// a `.worklane` to install it would put it out of reach exactly when it is wanted.
|
||||
pub fn cmd_install_skill(force: bool, print: bool) -> Result<()> {
|
||||
/// No board is looked for. The documents are what teach an agent worklane, so needing
|
||||
/// a `.worklane` to install them would put them out of reach exactly when they are
|
||||
/// wanted.
|
||||
///
|
||||
/// With no name, every shipped document is installed. Narrowing to one is the
|
||||
/// exception rather than the rule, so that a document added in a later version reaches
|
||||
/// anyone who already knows the command.
|
||||
pub fn cmd_install_skill(skill: Option<&str>, force: bool, print: bool) -> Result<()> {
|
||||
if print {
|
||||
print!("{}", install::SKILL.content);
|
||||
// Printing every document would run them together into something that is not
|
||||
// any of them, and the point of `--print` is to diff one against its copy.
|
||||
let name = skill.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"name the skill to print, as in `worklane install-skill worklane --print`. This binary ships {}",
|
||||
install::skill_names()
|
||||
)
|
||||
})?;
|
||||
print!("{}", install::skill_named(name)?.content);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let chosen: Vec<&install::Asset> = match skill {
|
||||
Some(name) => vec![install::skill_named(name)?],
|
||||
None => install::SKILLS.iter().collect(),
|
||||
};
|
||||
|
||||
let root = install::skills_root()?;
|
||||
match install::SKILL.install(&root, force)? {
|
||||
install::Outcome::Written(path) => {
|
||||
println!("Installed the worklane {} to: {}", install::SKILL.what, path.display());
|
||||
println!("Claude Code and opencode pick it up on their next session");
|
||||
}
|
||||
install::Outcome::Unchanged(path) => {
|
||||
println!("Already up to date: {}", path.display());
|
||||
}
|
||||
install::Outcome::Refused(path) => {
|
||||
println!("Differs from the version in this binary: {}", path.display());
|
||||
println!(
|
||||
"Compare with `worklane install-skill --print`, or overwrite with --force"
|
||||
);
|
||||
let mut written = false;
|
||||
for asset in chosen {
|
||||
match asset.install(&root, force)? {
|
||||
install::Outcome::Written(path) => {
|
||||
println!("Installed the {} {} to: {}", asset.name, asset.what, path.display());
|
||||
written = true;
|
||||
}
|
||||
install::Outcome::Unchanged(path) => {
|
||||
println!("Already up to date: {}", path.display());
|
||||
}
|
||||
install::Outcome::Refused(path) => {
|
||||
println!("Differs from the version in this binary: {}", path.display());
|
||||
println!(
|
||||
"Compare with `worklane install-skill {} --print`, or overwrite with --force",
|
||||
asset.name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Once, and only when something arrived: repeating it per document would make the
|
||||
// instruction look like part of each outcome rather than the one thing to do next.
|
||||
if written {
|
||||
println!("Claude Code and opencode pick it up on their next session");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
+179
-37
@@ -1,13 +1,18 @@
|
||||
//! Shipping the agent assets with the binary.
|
||||
//!
|
||||
//! The skill document lives at `assets/SKILL.md` in this repo and is embedded with
|
||||
//! The skill documents live in `assets/` in this repo and are embedded with
|
||||
//! `include_str!` rather than copied by an install script, because `cargo install`
|
||||
//! places binaries and nothing else. Embedding means the document can never be a
|
||||
//! places binaries and nothing else. Embedding means a document can never be a
|
||||
//! different version from the binary it describes, and there is no second file to
|
||||
//! lose track of.
|
||||
//!
|
||||
//! The machinery is written once for both assets this repo will ship. The tool file
|
||||
//! for opencode is executable code needing Bun, so it gets its own command and its
|
||||
//! `SKILLS` is every skill the binary carries, and `install-skill` writes all of them.
|
||||
//! One document teaches the CLI and the others teach a job done with it; a person who
|
||||
//! has learned the invocation should not have to learn a new name for each document
|
||||
//! added later, or the new one silently never arrives.
|
||||
//!
|
||||
//! The machinery is written once for both kinds of asset this repo will ship. The tool
|
||||
//! file for opencode is executable code needing Bun, so it gets its own command and its
|
||||
//! own root, but the compare-and-refuse logic is the same and lives here.
|
||||
|
||||
use std::io;
|
||||
@@ -17,6 +22,9 @@ use anyhow::{Result, anyhow};
|
||||
|
||||
/// One thing the binary carries and can write into a user's agent configuration.
|
||||
pub struct Asset {
|
||||
/// How it is addressed on the command line. For a skill this is also its directory
|
||||
/// and its frontmatter `name:`, which both agents require to agree.
|
||||
pub name: &'static str,
|
||||
/// What it is called in messages, e.g. `skill`.
|
||||
pub what: &'static str,
|
||||
/// Where it goes under its root, e.g. `worklane/SKILL.md`.
|
||||
@@ -24,13 +32,63 @@ pub struct Asset {
|
||||
pub content: &'static str,
|
||||
}
|
||||
|
||||
/// The skill document, as of the commit this binary was built from.
|
||||
/// The skill that teaches the CLI, as of the commit this binary was built from.
|
||||
pub const SKILL: Asset = Asset {
|
||||
name: "worklane",
|
||||
what: "skill",
|
||||
relative: "worklane/SKILL.md",
|
||||
content: include_str!("../assets/SKILL.md"),
|
||||
};
|
||||
|
||||
/// The skill that reviews a finished ticket against the code that claims to close it.
|
||||
///
|
||||
/// A document of its own rather than a section of `SKILL`, because it is loaded for a
|
||||
/// different job: the CLI skill is wanted for anything touching a ticket, and this is
|
||||
/// wanted only when a review is asked for. One document holding both would be loaded
|
||||
/// constantly to say nothing, and the frontmatter description, which is the whole of
|
||||
/// what decides the loading, cannot describe two jobs without fitting neither.
|
||||
pub const REVIEW_SKILL: Asset = Asset {
|
||||
name: "worklane-review",
|
||||
what: "skill",
|
||||
relative: "worklane-review/SKILL.md",
|
||||
content: include_str!("../assets/REVIEW.md"),
|
||||
};
|
||||
|
||||
/// The skill that grooms the board as a whole rather than a ticket at a time.
|
||||
///
|
||||
/// Its own document for the reason `REVIEW_SKILL` is: it is wanted for questions about
|
||||
/// the backlog as a body of work, and loading it for every ticket touched would be a
|
||||
/// description that fits nothing. It is also the document where the destructive edits
|
||||
/// live, since every job in it writes to many tickets at once.
|
||||
pub const PLAN_SKILL: Asset = Asset {
|
||||
name: "worklane-plan",
|
||||
what: "skill",
|
||||
relative: "worklane-plan/SKILL.md",
|
||||
content: include_str!("../assets/PLAN.md"),
|
||||
};
|
||||
|
||||
/// Every skill this binary carries, in the order they install.
|
||||
///
|
||||
/// A `static` rather than a `const` so the slice borrowed from it outlives the
|
||||
/// statement that took it: a `const` is inlined at each use and the borrow dies there.
|
||||
pub static SKILLS: [Asset; 3] = [SKILL, REVIEW_SKILL, PLAN_SKILL];
|
||||
|
||||
/// The skill a name on the command line asks for.
|
||||
pub fn skill_named(name: &str) -> Result<&'static Asset> {
|
||||
SKILLS.iter().find(|asset| asset.name == name).ok_or_else(|| {
|
||||
anyhow!("no skill named {name:?}. This binary ships {}", skill_names())
|
||||
})
|
||||
}
|
||||
|
||||
/// The names, for the errors that have to say what there is to choose from.
|
||||
pub fn skill_names() -> String {
|
||||
SKILLS
|
||||
.iter()
|
||||
.map(|asset| asset.name)
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
}
|
||||
|
||||
/// Where a skill has to sit to be found, for both agents worklane is used from.
|
||||
///
|
||||
/// One path serves both. Claude Code reads `~/.claude/skills/<name>/SKILL.md`, and
|
||||
@@ -157,29 +215,53 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_skill_lands_where_both_agents_look_for_it() {
|
||||
fn every_skill_lands_where_both_agents_look_for_it() {
|
||||
let root = skills_root().unwrap();
|
||||
assert!(root.ends_with(".claude/skills"), "{}", root.display());
|
||||
assert!(
|
||||
SKILL.path(&root).ends_with(".claude/skills/worklane/SKILL.md"),
|
||||
"{}",
|
||||
SKILL.path(&root).display()
|
||||
);
|
||||
|
||||
for asset in &SKILLS {
|
||||
let path = asset.path(&root);
|
||||
assert!(
|
||||
path.ends_with(format!(".claude/skills/{}/SKILL.md", asset.name)),
|
||||
"{}",
|
||||
path.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Two documents that install to one path means the second silently replaces the
|
||||
/// first, and only whichever is listed last is ever read. A copy-pasted `relative`
|
||||
/// is exactly how that happens.
|
||||
#[test]
|
||||
fn no_two_shipped_skills_share_a_name_or_a_path() {
|
||||
for (index, asset) in SKILLS.iter().enumerate() {
|
||||
for other in &SKILLS[index + 1..] {
|
||||
assert_ne!(asset.name, other.name);
|
||||
assert_ne!(asset.relative, other.relative);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_embedded_skill_has_usable_frontmatter() {
|
||||
fn every_embedded_skill_has_usable_frontmatter() {
|
||||
// Guards the whole shipping mechanism: without frontmatter, or under a name
|
||||
// that does not match its directory, both agents ignore the document and
|
||||
// nothing else would notice.
|
||||
assert_eq!(frontmatter_field(SKILL.content, "name").as_deref(), Some("worklane"));
|
||||
for asset in &SKILLS {
|
||||
assert_eq!(
|
||||
frontmatter_field(asset.content, "name").as_deref(),
|
||||
Some(asset.name),
|
||||
"the frontmatter name has to match the directory it installs into"
|
||||
);
|
||||
|
||||
let description =
|
||||
frontmatter_field(SKILL.content, "description").expect("a description to trigger on");
|
||||
assert!(
|
||||
description.len() > 80,
|
||||
"the description is what decides whether the skill loads at all"
|
||||
);
|
||||
let description = frontmatter_field(asset.content, "description")
|
||||
.unwrap_or_else(|| panic!("{} ships without a description to trigger on", asset.name));
|
||||
assert!(
|
||||
description.len() > 80,
|
||||
"{}: the description is what decides whether the skill loads at all",
|
||||
asset.name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Every code span and fenced-block line, which is where commands live.
|
||||
@@ -209,7 +291,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_embedded_skill_only_names_commands_that_exist() {
|
||||
fn no_embedded_skill_names_a_command_that_does_not_exist() {
|
||||
// Taken from clap rather than written out here. A hand-maintained list is the
|
||||
// very drift this test exists to catch.
|
||||
use clap::CommandFactory;
|
||||
@@ -220,25 +302,34 @@ mod tests {
|
||||
known.push("--help".to_string());
|
||||
known.push("--version".to_string());
|
||||
|
||||
let mut checked = 0;
|
||||
for snippet in code_snippets(SKILL.content) {
|
||||
let mut words = snippet.split_whitespace();
|
||||
// Only a snippet that *starts* with worklane is a command being shown.
|
||||
if words.next() != Some("worklane") {
|
||||
continue;
|
||||
let mut total = 0;
|
||||
for asset in &SKILLS {
|
||||
let mut checked = 0;
|
||||
for snippet in code_snippets(asset.content) {
|
||||
let mut words = snippet.split_whitespace();
|
||||
// Only a snippet that *starts* with worklane is a command being shown.
|
||||
if words.next() != Some("worklane") {
|
||||
continue;
|
||||
}
|
||||
let Some(candidate) = words.next() else { continue };
|
||||
// A flag before the subcommand, as in the `mv -- -leading-title` example.
|
||||
if candidate.starts_with("--") && !known.iter().any(|k| k == candidate) {
|
||||
continue;
|
||||
}
|
||||
checked += 1;
|
||||
assert!(
|
||||
known.iter().any(|k| k == candidate),
|
||||
"{} shows `worklane {candidate}`, which is not a subcommand",
|
||||
asset.name
|
||||
);
|
||||
}
|
||||
let Some(candidate) = words.next() else { continue };
|
||||
// A flag before the subcommand, as in the `mv -- -leading-title` example.
|
||||
if candidate.starts_with("--") && !known.iter().any(|k| k == candidate) {
|
||||
continue;
|
||||
}
|
||||
checked += 1;
|
||||
assert!(
|
||||
known.iter().any(|k| k == candidate),
|
||||
"the skill shows `worklane {candidate}`, which is not a subcommand"
|
||||
);
|
||||
// A skill that shows no command at all is either not about worklane or has
|
||||
// had its examples emptied out, and either way the check above passed on
|
||||
// nothing.
|
||||
assert!(checked > 0, "{} shows no worklane command at all", asset.name);
|
||||
total += checked;
|
||||
}
|
||||
assert!(checked > 8, "expected the skill to show commands, checked only {checked}");
|
||||
assert!(total > 8, "expected the skills to show commands, checked only {total}");
|
||||
}
|
||||
|
||||
/// Subcommands the skill has no business teaching: the board is interactive and
|
||||
@@ -248,6 +339,11 @@ mod tests {
|
||||
|
||||
/// The converse, and the one that goes stale on its own: a *new* subcommand absent
|
||||
/// from the skill is invisible to an agent, and nothing else would notice.
|
||||
///
|
||||
/// `SKILL` alone, deliberately. It is the document that owns the CLI surface, and
|
||||
/// the others teach one job with the handful of commands that job uses. Requiring
|
||||
/// every subcommand of each of them would fill a review document with campaigns
|
||||
/// and `init` to satisfy a test.
|
||||
#[test]
|
||||
fn every_agent_facing_subcommand_is_documented() {
|
||||
use clap::CommandFactory;
|
||||
@@ -279,4 +375,50 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The rules that keep a grooming sweep from being a silent rewrite of the board.
|
||||
///
|
||||
/// Every one of these is a line an edit could drop while leaving a document that
|
||||
/// still reads like a plan: `set --tags` replacing the whole field is how thirty
|
||||
/// tickets quietly lose their tags, and propose-then-apply is the only thing
|
||||
/// standing between a wrong judgement and thirty wrong tickets.
|
||||
#[test]
|
||||
fn the_plan_skill_keeps_the_rules_that_bound_a_sweep() {
|
||||
for required in [
|
||||
"Propose the whole set of edits",
|
||||
"replaces the whole\nfield", // `set --tags` is the destructive one
|
||||
"cannot be cleared", // and a due date cannot be taken back
|
||||
"blocked by", // ordering constrains any dating plan
|
||||
"worklane campaign ls",
|
||||
"does not touch",
|
||||
] {
|
||||
assert!(
|
||||
PLAN_SKILL.content.contains(required),
|
||||
"the plan skill no longer says {required:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The decisions that make the review document a review rather than a rewrite.
|
||||
///
|
||||
/// Each of these is a rule an edit would drop without breaking anything else: a
|
||||
/// reviewer that ticks criteria or moves the ticket still runs, and produces a
|
||||
/// board where nothing records that anyone disagreed.
|
||||
#[test]
|
||||
fn the_review_skill_keeps_the_decisions_that_define_it() {
|
||||
for required in [
|
||||
"worklane show", // the ticket is read before the code
|
||||
"nothing names the ticket", // and the no-work-found case is answered
|
||||
"Never tick a criterion",
|
||||
"Do not move the ticket",
|
||||
"worklane uncheck",
|
||||
"worklane append",
|
||||
"cannot tell",
|
||||
] {
|
||||
assert!(
|
||||
REVIEW_SKILL.content.contains(required),
|
||||
"the review skill no longer says {required:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+57
-10
@@ -1,6 +1,8 @@
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
|
||||
mod campaign;
|
||||
mod clipboard;
|
||||
mod command;
|
||||
mod handlers;
|
||||
mod install;
|
||||
@@ -44,9 +46,14 @@ fn main() -> Result<()> {
|
||||
Some(Command::Tui { paths }) => run_tui(&paths, &start),
|
||||
Some(Command::Init) => cmd_init(&start),
|
||||
Some(Command::Add(args)) => cmd_add(&args, &start),
|
||||
Some(Command::Ls { status, priority }) => {
|
||||
Some(Command::Ls {
|
||||
status,
|
||||
priority,
|
||||
tag,
|
||||
campaign,
|
||||
}) => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_ls(&status, priority, &worklane_dir)
|
||||
cmd_ls(&status, priority, &tag, &campaign, &worklane_dir)
|
||||
}
|
||||
Some(Command::Show { id }) => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
@@ -68,9 +75,23 @@ fn main() -> Result<()> {
|
||||
body,
|
||||
owner,
|
||||
}) => cmd_comment(&ticket, &body, &owner, &start),
|
||||
Some(Command::Campaign { command }) => match command {
|
||||
CampaignCommand::Add(args) => cmd_campaign_add(&args, &start),
|
||||
CampaignCommand::Ls => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_campaign_ls(&worklane_dir)
|
||||
}
|
||||
CampaignCommand::Show { campaign } => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_campaign_show(&campaign, &worklane_dir)
|
||||
}
|
||||
},
|
||||
Some(Command::Assign { campaign, ticket }) => cmd_assign(&campaign, &ticket, &start),
|
||||
// No board is looked for: the point of the skill is to teach an agent worklane
|
||||
// before there is a `.worklane` anywhere.
|
||||
Some(Command::InstallSkill { force, print }) => cmd_install_skill(force, print),
|
||||
Some(Command::InstallSkill { skill, force, print }) => {
|
||||
cmd_install_skill(skill.as_deref(), force, print)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,17 +165,34 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
|
||||
continue;
|
||||
}
|
||||
|
||||
// Every keypress takes away what the last one said, so a notice never
|
||||
// outlives the moment it belongs to. Ahead of the prompt as well as the
|
||||
// arms: a key typed into a query is still a key. The rule is
|
||||
// `Board::clear_notice`, where a test can reach it, and the arm below that
|
||||
// sets one runs after this.
|
||||
board.clear_notice();
|
||||
|
||||
// Ahead of the arms, because a prompt has to swallow every key it is
|
||||
// given: typing `d` into a query must not toggle the done column and `q`
|
||||
// must not quit. It reports what it took, so the arms below stay a plain
|
||||
// match on the keys it did not, and it takes nothing when no prompt is open.
|
||||
// The rule is `Board::search_key`, where a test can reach it.
|
||||
if board.search_key(key, screen) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match key.code {
|
||||
KeyCode::Char('q') => board.should_quit = true,
|
||||
// One arm, because the two keys mean one thing: close what is open, and
|
||||
// quit when there is nothing left to close. Two arms carrying one rule
|
||||
// is how a later edit changes it for one key and not the other, which is
|
||||
// what `q` quitting out from under an open ticket already was. The rule
|
||||
// itself is `Board::dismiss`, where a test can reach it.
|
||||
KeyCode::Esc | KeyCode::Char('q') => board.dismiss(),
|
||||
// The only key that leaves the board from an open ticket, which is why
|
||||
// the footer names it there.
|
||||
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
board.should_quit = true
|
||||
}
|
||||
// Esc closes the detail view, and only quits when there is nothing
|
||||
// left to dismiss.
|
||||
KeyCode::Esc => match board.detail {
|
||||
Some(_) => board.toggle_detail(),
|
||||
None => board.should_quit = true,
|
||||
},
|
||||
KeyCode::Enter | KeyCode::Char(' ') => board.toggle_detail(),
|
||||
KeyCode::Left | KeyCode::Char('h') => board.select_column(-1, screen),
|
||||
KeyCode::Right | KeyCode::Char('l') => board.select_column(1, screen),
|
||||
@@ -172,6 +210,15 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
|
||||
KeyCode::BackTab => board.select_tab(-1, screen),
|
||||
// Free of the other bindings, and the footer names it in both states.
|
||||
KeyCode::Char('d') => board.toggle_done(screen),
|
||||
// An ordinary single-shot action like the rest: it opens the prompt, and
|
||||
// from the next keypress on `search_key` above has the keyboard. A `/`
|
||||
// typed into an open prompt is taken there as a character, so this arm
|
||||
// is only ever the way in.
|
||||
KeyCode::Char('/') => board.open_search(),
|
||||
// `y` as in yank, for the readers this board is for, and the only letter
|
||||
// left that a vim hand would reach for. The clipboard is handed in rather
|
||||
// than reached for inside `Board`, so the suite can drive both answers.
|
||||
KeyCode::Char('y') => board.copy_selected_id(clipboard::copy),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+2112
-71
File diff suppressed because it is too large
Load Diff
+1342
-126
File diff suppressed because it is too large
Load Diff
@@ -457,3 +457,107 @@ fn add_treats_an_all_blank_description_as_none() {
|
||||
"was {content:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The help, the README and the skill all promise `YYYY-MM-DD`, and until this the
|
||||
/// value was written to the ticket whatever it said.
|
||||
#[test]
|
||||
fn add_stores_a_valid_due_date_unchanged() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Dated"])
|
||||
.args(["--due", "2026-08-29"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = read_only_ticket(&worklane.join("backlog"));
|
||||
assert!(content.contains("- **Due**: 2026-08-29"), "{content}");
|
||||
}
|
||||
|
||||
/// Every one of these is refused at parse time, so the exit code is 2 and nothing is
|
||||
/// written. A date that cannot happen is as wrong as a word: `2026-02-30` has the shape
|
||||
/// and is not a day.
|
||||
#[test]
|
||||
fn add_refuses_a_due_date_that_is_not_a_real_iso_date() {
|
||||
for value in ["next friday", "29-08-2026", "2026-13-01", "2026-02-30", "2026/08/29", ""] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let out = cmd
|
||||
.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Dated"])
|
||||
.args(["--due", value])
|
||||
.assert()
|
||||
.failure()
|
||||
.get_output()
|
||||
.clone();
|
||||
|
||||
assert_eq!(out.status.code(), Some(2), "{value:?} was not a usage error");
|
||||
assert_eq!(
|
||||
fs::read_dir(worklane.join("backlog")).unwrap().count(),
|
||||
0,
|
||||
"{value:?} wrote a ticket anyway"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// An unpadded date parses as a date and would be stored as typed, which sorts before
|
||||
/// `2026-10-01` and is not the format anything promises.
|
||||
#[test]
|
||||
fn add_refuses_an_unpadded_due_date_rather_than_padding_it() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let stderr = String::from_utf8_lossy(
|
||||
&cmd.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Dated"])
|
||||
.args(["--due", "2026-8-9"])
|
||||
.assert()
|
||||
.failure()
|
||||
.get_output()
|
||||
.stderr,
|
||||
)
|
||||
.to_string();
|
||||
|
||||
assert!(stderr.contains("YYYY-MM-DD"), "the error never names the format: {stderr}");
|
||||
}
|
||||
|
||||
/// An empty value keeps the message about clearing, since that is what somebody typing
|
||||
/// it is reaching for.
|
||||
#[test]
|
||||
fn an_empty_due_date_says_clearing_is_not_supported() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let stderr = String::from_utf8_lossy(
|
||||
&cmd.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Dated"])
|
||||
.args(["--due", ""])
|
||||
.assert()
|
||||
.failure()
|
||||
.get_output()
|
||||
.stderr,
|
||||
)
|
||||
.to_string();
|
||||
|
||||
assert!(stderr.contains("clearing a field is not supported"), "{stderr}");
|
||||
}
|
||||
|
||||
fn read_only_ticket(dir: &Path) -> String {
|
||||
let file = fs::read_dir(dir)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.find(|e| e.path().extension().is_some_and(|ext| ext == "md"))
|
||||
.expect("no ticket written");
|
||||
|
||||
fs::read_to_string(file.path()).unwrap()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,602 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
/// Two campaigns, so a filter has something to exclude, and three tickets: one in each
|
||||
/// campaign and one in neither.
|
||||
const CAMP_A: &str = "aa11bb22-33cc-4dd4-8ee5-ff6677889900";
|
||||
const CAMP_B: &str = "bb22cc33-44dd-4ee5-8ff6-001122334455";
|
||||
const MEMBER: &str = "641e3d5c-1b0e-4d2f-9a7e-3c8b5f0a2d61";
|
||||
const OTHER: &str = "b1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d";
|
||||
const LONER: &str = "f1f2f3f4-5a6b-4c7d-8e9f-0a1b2c3d4e5f";
|
||||
|
||||
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done", "campaigns"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
fn slug(title: &str) -> String {
|
||||
title
|
||||
.to_lowercase()
|
||||
.chars()
|
||||
.filter(|c| c.is_alphanumeric() || *c == ' ' || *c == '-' || *c == '_')
|
||||
.map(|c| if c == ' ' { '-' } else { c })
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// A ticket with a ticked criterion, a section the tool knows nothing about and a
|
||||
/// metadata field it has never heard of, so every test can check that an assignment
|
||||
/// leaves all three exactly as they were.
|
||||
///
|
||||
/// Deliberately carries no Campaign field: no ticket written before campaigns existed
|
||||
/// has one, and `add` still does not write one, so the insertion path is what every
|
||||
/// assignment goes through.
|
||||
fn create_ticket(worklane: &Path, status: &str, title: &str, uuid: &str) -> PathBuf {
|
||||
let path = worklane
|
||||
.join(status)
|
||||
.join(format!("{}_{}.md", uuid, slug(title)));
|
||||
|
||||
fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"# {title}\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
Prose that mentions **Campaign**: not a field, in the body.\n\
|
||||
\n\
|
||||
## Acceptance Criteria\n\
|
||||
- [x] Crit one\n\
|
||||
\n\
|
||||
## Implementation Plan\n\
|
||||
1. Step one\n\
|
||||
\n\
|
||||
## Notes\n\
|
||||
A handwritten note the tool knows nothing about.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {uuid}\n\
|
||||
- **Priority**: 3\n\
|
||||
- **Tags**: alpha\n\
|
||||
- **Due**: _Not set_\n\
|
||||
- **Handled By Team**: ops\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n\
|
||||
- **Status**: {status}\n"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
fn create_campaign(worklane: &Path, title: &str, uuid: &str) -> PathBuf {
|
||||
let path = worklane
|
||||
.join("campaigns")
|
||||
.join(format!("{}_{}.md", uuid, slug(title)));
|
||||
|
||||
fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"# {title}\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
What has to ship together.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {uuid}\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
fn board(temp: &TempDir) -> PathBuf {
|
||||
let worklane = setup_worklane(temp);
|
||||
create_campaign(&worklane, "v1 release", CAMP_A);
|
||||
create_campaign(&worklane, "v2 release", CAMP_B);
|
||||
create_ticket(&worklane, "backlog", "The member", MEMBER);
|
||||
create_ticket(&worklane, "done", "The other member", OTHER);
|
||||
create_ticket(&worklane, "backlog", "The loner", LONER);
|
||||
worklane
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn stdout(out: &std::process::Output) -> String {
|
||||
String::from_utf8_lossy(&out.stdout).to_string()
|
||||
}
|
||||
|
||||
fn stderr(out: &std::process::Output) -> String {
|
||||
String::from_utf8_lossy(&out.stderr).to_string()
|
||||
}
|
||||
|
||||
fn find(worklane: &Path, uuid: &str) -> PathBuf {
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
for entry in fs::read_dir(worklane.join(status))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
{
|
||||
if entry.file_name().to_string_lossy().starts_with(uuid) {
|
||||
return entry.path();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
panic!("no file for ticket {uuid}");
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path, uuid: &str) -> String {
|
||||
fs::read_to_string(find(worklane, uuid)).unwrap()
|
||||
}
|
||||
|
||||
fn campaigns(worklane: &Path) -> Vec<String> {
|
||||
let mut names: Vec<String> = fs::read_dir(worklane.join("campaigns"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().to_string_lossy().to_string())
|
||||
.collect();
|
||||
names.sort();
|
||||
names
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ filing one --
|
||||
|
||||
#[test]
|
||||
fn campaign_add_writes_a_uuid_title_description_and_metadata() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"add",
|
||||
"--title",
|
||||
"v1 release",
|
||||
"--description",
|
||||
"Everything that ships together.",
|
||||
"--owner",
|
||||
"alice",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let names = campaigns(&worklane);
|
||||
assert_eq!(names.len(), 1, "{names:?}");
|
||||
let name = &names[0];
|
||||
assert!(name.ends_with("_v1-release.md"), "{name}");
|
||||
|
||||
let content = fs::read_to_string(worklane.join("campaigns").join(name)).unwrap();
|
||||
assert!(content.starts_with("# v1 release\n"), "{content}");
|
||||
assert!(content.contains("Everything that ships together."), "{content}");
|
||||
assert!(content.contains("- **Owner**: alice"), "{content}");
|
||||
assert!(content.contains("- **Created At**: 20"), "{content}");
|
||||
|
||||
// The uuid in the file is the one in the filename, since that is what `assign`
|
||||
// stores and what every lookup compares against.
|
||||
let uuid = name.split('_').next().unwrap();
|
||||
assert!(content.contains(&format!("- **ID**: {uuid}")), "{content}");
|
||||
}
|
||||
|
||||
/// A campaign has no status, so its file carries none. A Status field would be a second
|
||||
/// place for a state that is derived, and the two would disagree the moment a member
|
||||
/// moved.
|
||||
#[test]
|
||||
fn a_campaign_carries_no_status_and_no_criteria() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
run(&temp, &["campaign", "add", "--title", "v1 release"]);
|
||||
|
||||
let name = campaigns(&worklane).remove(0);
|
||||
let content = fs::read_to_string(worklane.join("campaigns").join(name)).unwrap();
|
||||
|
||||
assert!(!content.contains("**Status**"), "{content}");
|
||||
assert!(!content.contains("Acceptance Criteria"), "{content}");
|
||||
assert!(!content.contains("Implementation Plan"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nothing_is_created_without_a_title() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "add", "--description", "No title here."]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(2), "{}", stderr(&out));
|
||||
assert!(campaigns(&worklane).is_empty(), "{:?}", campaigns(&worklane));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn init_creates_the_campaigns_directory() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&temp, &["init"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
assert!(temp.child(".worklane").child("campaigns").path().is_dir());
|
||||
}
|
||||
|
||||
/// A board made before campaigns existed has no such directory, and a `worklane init`
|
||||
/// over a live board to get one would be a strange thing to have to do.
|
||||
#[test]
|
||||
fn the_campaigns_directory_is_created_for_a_board_that_predates_it() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
assert!(!worklane.child("campaigns").path().exists());
|
||||
|
||||
let out = run(&temp, &["campaign", "add", "--title", "v1 release"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
assert_eq!(campaigns(worklane.path()).len(), 1);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------- assigning --
|
||||
|
||||
#[test]
|
||||
fn assign_writes_the_campaign_field_in_the_metadata_section() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let content = ticket(&worklane, MEMBER);
|
||||
assert!(content.contains(&format!("- **Campaign**: {CAMP_A}")), "{content}");
|
||||
|
||||
// Scoped to the section: the description quotes the marker, and the field has to
|
||||
// land under the heading rather than over the prose.
|
||||
let metadata = content.split("## Metadata").nth(1).unwrap();
|
||||
assert!(metadata.contains(&format!("- **Campaign**: {CAMP_A}")), "{content}");
|
||||
assert!(
|
||||
content.contains("Prose that mentions **Campaign**: not a field, in the body."),
|
||||
"the description was rewritten: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The field goes in its place among the others rather than at the end, so Status stays
|
||||
/// last, which is where every file already keeps it.
|
||||
#[test]
|
||||
fn the_field_is_inserted_before_status() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
|
||||
let content = ticket(&worklane, MEMBER);
|
||||
let campaign_at = content.find("- **Campaign**:").unwrap();
|
||||
let status_at = content.find("- **Status**:").unwrap();
|
||||
assert!(campaign_at < status_at, "{content}");
|
||||
}
|
||||
|
||||
/// All three tiers, since a campaign is addressed the way a ticket is: a uuid prefix, a
|
||||
/// title substring, and a substring reaching the middle of the filename.
|
||||
#[test]
|
||||
fn a_campaign_resolves_by_uuid_prefix_title_or_filename() {
|
||||
for search in ["aa11", "v1 release", "4dd4"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["assign", search, MEMBER]);
|
||||
assert!(out.status.success(), "{search}: {}", stderr(&out));
|
||||
assert!(
|
||||
ticket(&worklane, MEMBER).contains(&format!("- **Campaign**: {CAMP_A}")),
|
||||
"{search}: {}",
|
||||
ticket(&worklane, MEMBER)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_ticket_names_at_most_one_campaign() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
let out = run(&temp, &["assign", "v2 release", MEMBER]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let content = ticket(&worklane, MEMBER);
|
||||
assert_eq!(
|
||||
content.matches("- **Campaign**:").count(),
|
||||
1,
|
||||
"reassigning added a second field: {content}"
|
||||
);
|
||||
assert!(content.contains(&format!("- **Campaign**: {CAMP_B}")), "{content}");
|
||||
assert!(!content.contains(CAMP_A), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assigning_the_campaign_already_named_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
let before = ticket(&worklane, MEMBER);
|
||||
|
||||
let out = run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("already in campaign"), "{}", stdout(&out));
|
||||
assert_eq!(ticket(&worklane, MEMBER), before);
|
||||
}
|
||||
|
||||
/// The campaign is resolved before the ticket is touched, so a call naming a good
|
||||
/// ticket and a campaign that does not exist writes nothing at all.
|
||||
#[test]
|
||||
fn an_unknown_campaign_leaves_the_ticket_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = ticket(&worklane, MEMBER);
|
||||
|
||||
let out = run(&temp, &["assign", "v9 release", MEMBER]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
assert!(stderr(&out).contains("No campaign found matching"), "{}", stderr(&out));
|
||||
assert_eq!(ticket(&worklane, MEMBER), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn content_the_tool_does_not_know_survives_an_assignment() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
|
||||
let content = ticket(&worklane, MEMBER);
|
||||
assert!(content.contains("## Notes"), "{content}");
|
||||
assert!(
|
||||
content.contains("A handwritten note the tool knows nothing about."),
|
||||
"{content}"
|
||||
);
|
||||
assert!(content.contains("- **Handled By Team**: ops"), "{content}");
|
||||
// And the ticked criterion is still ticked.
|
||||
assert!(content.contains("- [x] Crit one"), "{content}");
|
||||
}
|
||||
|
||||
/// One field, one writer. `assign` owns Campaign the way `chown` owns Owner.
|
||||
#[test]
|
||||
fn neither_add_nor_set_offers_a_campaign_flag() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let added = run(&temp, &["add", "--title", "New one", "--campaign", "v1 release"]);
|
||||
assert_eq!(added.status.code(), Some(2), "{}", stderr(&added));
|
||||
|
||||
let set = run(&temp, &["set", MEMBER, "--campaign", "v1 release"]);
|
||||
assert_eq!(set.status.code(), Some(2), "{}", stderr(&set));
|
||||
|
||||
// The stored shape, not the bare marker: the fixture description quotes the marker
|
||||
// on purpose, so an unscoped match here would pass whatever the commands did.
|
||||
assert!(!ticket(&worklane, MEMBER).contains("- **Campaign**:"));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------- reading --
|
||||
|
||||
#[test]
|
||||
fn campaign_ls_lists_campaigns_with_their_member_counts() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
run(&temp, &["assign", "v1 release", OTHER]);
|
||||
|
||||
let out = run(&temp, &["campaign", "ls"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let listing = stdout(&out);
|
||||
// One of the two members is in done, so the campaign is open and half finished.
|
||||
assert!(listing.contains("v1 release | 1/2 done [open]"), "{listing}");
|
||||
// Nothing has been filed against the other one.
|
||||
assert!(listing.contains("v2 release | no members"), "{listing}");
|
||||
}
|
||||
|
||||
/// A campaign is done when it holds members and every one of them is done. An empty one
|
||||
/// is neither, which is why it reads `no members` rather than `0/0 done`.
|
||||
#[test]
|
||||
fn a_campaign_whose_every_member_is_done_reads_done() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", OTHER]);
|
||||
|
||||
let listing = stdout(&run(&temp, &["campaign", "ls"]));
|
||||
assert!(listing.contains("v1 release | 1/1 done [done]"), "{listing}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn campaign_show_prints_the_body_and_the_members_grouped_by_status() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
run(&temp, &["assign", "v1 release", OTHER]);
|
||||
|
||||
let out = run(&temp, &["campaign", "show", "aa11"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let shown = stdout(&out);
|
||||
assert!(shown.contains("v1 release"), "{shown}");
|
||||
assert!(shown.contains("What has to ship together."), "{shown}");
|
||||
assert!(shown.contains("1/2 done"), "{shown}");
|
||||
assert!(shown.contains("[BACKLOG]"), "{shown}");
|
||||
assert!(shown.contains("The member"), "{shown}");
|
||||
// Done members are shown here, unlike in `ls`: what is finished against what is
|
||||
// left is the whole question a campaign asks.
|
||||
assert!(shown.contains("[DONE]"), "{shown}");
|
||||
assert!(shown.contains("The other member"), "{shown}");
|
||||
// And a ticket in no campaign is not a member of this one.
|
||||
assert!(!shown.contains("The loner"), "{shown}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ls_campaign_lists_only_that_campaigns_members() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
run(&temp, &["assign", "v2 release", LONER]);
|
||||
|
||||
let out = run(&temp, &["ls", "--campaign", "v1 release"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let listing = stdout(&out);
|
||||
assert!(listing.contains("The member"), "{listing}");
|
||||
assert!(!listing.contains("The loner"), "{listing}");
|
||||
assert!(listing.contains("[BACKLOG] 1 ticket"), "{listing}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ls_campaign_refuses_a_campaign_that_does_not_exist() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["ls", "--campaign", "v9 release"]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
assert!(stderr(&out).contains("No campaign found matching"), "{}", stderr(&out));
|
||||
}
|
||||
|
||||
/// The stored value is a full uuid, so a campaign that has been deleted has to be
|
||||
/// reported as gone rather than shown raw, the way a dangling relation target is.
|
||||
#[test]
|
||||
fn a_campaign_that_no_longer_exists_reads_as_missing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
fs::remove_file(worklane.join("campaigns").join(format!("{CAMP_A}_v1-release.md"))).unwrap();
|
||||
|
||||
let out = run(&temp, &["show", MEMBER]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let shown = stdout(&out);
|
||||
assert!(shown.contains("_missing_"), "{shown}");
|
||||
// The short id survives, since it is the only thing left to go looking for.
|
||||
assert!(shown.contains("(aa11bb2)"), "{shown}");
|
||||
assert!(!shown.contains(CAMP_A), "the bare uuid was shown: {shown}");
|
||||
}
|
||||
|
||||
/// The title is shown rather than the uuid the file stores: thirty-six characters of
|
||||
/// hex in a metadata table say nothing about which campaign it is.
|
||||
#[test]
|
||||
fn a_ticket_shows_the_campaign_title_not_its_uuid() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", MEMBER]));
|
||||
assert!(shown.contains("(aa11bb2) v1 release"), "{shown}");
|
||||
assert!(!shown.contains(CAMP_A), "{shown}");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------- not a ticket --
|
||||
|
||||
/// A campaign is in no status directory, so `mv` has nothing to move. It says so rather
|
||||
/// than reporting a ticket it could not find, which would send the caller hunting for a
|
||||
/// typo in a name that is perfectly correct.
|
||||
#[test]
|
||||
fn mv_refuses_a_campaign() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["mv", "v1 release", "--status", "committed"]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
let message = stderr(&out);
|
||||
assert!(message.contains("is a campaign, not a ticket"), "{message}");
|
||||
assert!(message.contains("no status directory"), "{message}");
|
||||
|
||||
// And it stayed where it was: nothing was moved into a status directory.
|
||||
assert!(
|
||||
worklane
|
||||
.join("campaigns")
|
||||
.join(format!("{CAMP_A}_v1-release.md"))
|
||||
.exists()
|
||||
);
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
let moved = fs::read_dir(worklane.join(status))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.any(|e| e.file_name().to_string_lossy().starts_with(CAMP_A));
|
||||
assert!(!moved, "a campaign reached the {status} directory");
|
||||
}
|
||||
}
|
||||
|
||||
/// Every command that takes a ticket gives the same explanation, because the refusal is
|
||||
/// in resolution rather than in `mv`.
|
||||
#[test]
|
||||
fn a_campaign_is_refused_wherever_a_ticket_is_expected() {
|
||||
for args in [
|
||||
vec!["show", "v1 release"],
|
||||
vec!["comment", "v1 release", "A note."],
|
||||
vec!["chown", "bob", "v1 release"],
|
||||
] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &args);
|
||||
assert!(!out.status.success(), "{args:?}");
|
||||
assert!(
|
||||
stderr(&out).contains("is a campaign, not a ticket"),
|
||||
"{args:?}: {}",
|
||||
stderr(&out)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A search that names neither still says nothing was found, rather than complaining
|
||||
/// about a directory the caller never mentioned.
|
||||
#[test]
|
||||
fn a_search_that_names_nothing_still_reports_no_ticket() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["show", "nothing at all"]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
assert!(
|
||||
stderr(&out).contains("No ticket found matching"),
|
||||
"{}",
|
||||
stderr(&out)
|
||||
);
|
||||
}
|
||||
|
||||
/// A campaign resolves by the same tiers a ticket does, so it can be ambiguous the same
|
||||
/// way, and the listing has to name campaigns rather than tickets.
|
||||
#[test]
|
||||
fn an_ambiguous_campaign_lists_the_candidates() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "show", "release"]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
let message = stderr(&out);
|
||||
assert!(message.contains("Multiple campaigns found matching"), "{message}");
|
||||
assert!(message.contains("v1 release"), "{message}");
|
||||
assert!(message.contains("v2 release"), "{message}");
|
||||
}
|
||||
@@ -53,6 +53,43 @@ fn create_ticket(worklane: &Path) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// A second ticket whose criteria carry the word `all`, so the keyword's precedence
|
||||
/// can be pinned without renumbering the shared fixture.
|
||||
const ALL_UUID: &str = "6b1f9c22-0d4e-4a1b-9f37-2c85ab4d1e70";
|
||||
|
||||
fn create_all_in_text_ticket(worklane: &Path) {
|
||||
let lines = [
|
||||
"# All in the text",
|
||||
"",
|
||||
"## Acceptance Criteria",
|
||||
"- [ ] all the boxes are listed",
|
||||
"- [ ] the footer is drawn",
|
||||
"",
|
||||
"## Metadata",
|
||||
"",
|
||||
&format!("- **ID**: {}", ALL_UUID),
|
||||
"- **Status**: backlog",
|
||||
"",
|
||||
];
|
||||
|
||||
fs::write(
|
||||
worklane
|
||||
.join("backlog")
|
||||
.join(format!("{}_all-in-the-text.md", ALL_UUID)),
|
||||
lines.join("\n"),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn all_in_text_ticket(worklane: &Path) -> String {
|
||||
fs::read_to_string(
|
||||
worklane
|
||||
.join("backlog")
|
||||
.join(format!("{}_all-in-the-text.md", ALL_UUID)),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
@@ -285,3 +322,239 @@ fn check_leaves_nothing_behind() {
|
||||
.collect();
|
||||
assert_eq!(strays, Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// The common case the batch exists for: the work is done, every box is true.
|
||||
#[test]
|
||||
fn all_ticks_every_criterion() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "all"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [x] beta alone\n"), "{content}");
|
||||
assert!(content.contains("- [x] gamma shared\n"), "{content}");
|
||||
|
||||
// beta was already ticked, so it is reported unchanged rather than as a new mark
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(stdout.contains("Checked 1: alpha shared"), "{stdout:?}");
|
||||
assert!(stdout.contains("Already checked 2: beta alone"), "{stdout:?}");
|
||||
assert!(stdout.contains("Checked 3: gamma shared"), "{stdout:?}");
|
||||
|
||||
// And nothing outside the section was touched
|
||||
assert!(
|
||||
content.contains("- [ ] A checkbox in the description, which is not a criterion.\n"),
|
||||
"the description checkbox was ticked: {content}"
|
||||
);
|
||||
assert!(
|
||||
content.contains(" A handwritten line inside the section.\n"),
|
||||
"the handwritten line was lost: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// An index and a substring in one call, each addressed by the existing rules.
|
||||
#[test]
|
||||
fn one_call_takes_several_mixed_terms() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "3", "ALPHA"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [x] gamma shared\n"), "{content}");
|
||||
|
||||
// Reported in show's order whatever order the terms arrived in
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
let alpha = stdout.find("Checked 1: alpha");
|
||||
let gamma = stdout.find("Checked 3: gamma");
|
||||
assert!(
|
||||
matches!((alpha, gamma), (Some(alpha), Some(gamma)) if alpha < gamma),
|
||||
"reported out of order, or one of them is missing: {stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The same criterion named twice, once by number and once by text, is one mark and
|
||||
/// one line of output.
|
||||
#[test]
|
||||
fn a_criterion_named_twice_is_reported_once() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1", "alpha", "all"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert_eq!(
|
||||
stdout.matches("alpha shared").count(),
|
||||
1,
|
||||
"alpha was reported more than once: {stdout:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
stdout.lines().count(),
|
||||
3,
|
||||
"one line per criterion, not per term: {stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Nothing to change, so nothing is written, the way a single already-ticked
|
||||
/// criterion already behaves.
|
||||
#[test]
|
||||
fn a_batch_that_would_change_nothing_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", UUID, "all"]);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "all"]);
|
||||
assert!(out.status.success());
|
||||
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert_eq!(
|
||||
stdout.matches("Already checked").count(),
|
||||
3,
|
||||
"{stdout:?}"
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
|
||||
}
|
||||
|
||||
/// One term that matches nothing refuses the whole call, so the ticket is never left
|
||||
/// half-marked.
|
||||
#[test]
|
||||
fn a_term_matching_nothing_leaves_the_batch_unwritten() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1", "nowhere", "3"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("nowhere"), "the term was not named: {stderr:?}");
|
||||
assert_eq!(ticket(&worklane), before, "alpha was ticked anyway");
|
||||
}
|
||||
|
||||
/// An ambiguous term in a batch is refused the same way a lone one is, and names
|
||||
/// itself rather than whichever term happened to come first.
|
||||
#[test]
|
||||
fn an_ambiguous_term_in_a_batch_names_itself_and_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1", "shared"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("'shared' matches 2 criteria"), "{stderr:?}");
|
||||
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
|
||||
assert!(stderr.contains("3. [ ] gamma shared"), "{stderr:?}");
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// An index out of range in a batch is still a bad index, not a failed text search.
|
||||
#[test]
|
||||
fn an_index_out_of_range_in_a_batch_leaves_the_file_untouched() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1", "9"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("is not one of the 3 criteria"), "{stderr:?}");
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// The decision this pins: `all` is the keyword, checked before the substring the way
|
||||
/// the index is, so it ticks every criterion and not the one whose text says "all".
|
||||
#[test]
|
||||
fn all_is_the_keyword_and_not_a_substring_of_the_text() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_all_in_text_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", ALL_UUID, "all"]);
|
||||
|
||||
let content = all_in_text_ticket(&worklane);
|
||||
assert!(content.contains("- [x] all the boxes are listed\n"), "{content}");
|
||||
assert!(
|
||||
content.contains("- [x] the footer is drawn\n"),
|
||||
"all matched its own text instead of every criterion: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// And the criterion whose text carries the word is still reachable, by its number or
|
||||
/// by a longer substring.
|
||||
#[test]
|
||||
fn a_criterion_whose_text_contains_all_is_still_reachable() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_all_in_text_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", ALL_UUID, "all the boxes"]);
|
||||
|
||||
let content = all_in_text_ticket(&worklane);
|
||||
assert!(content.contains("- [x] all the boxes are listed\n"), "{content}");
|
||||
assert!(content.contains("- [ ] the footer is drawn\n"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uncheck_takes_all() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["uncheck", UUID, "all"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [ ] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [ ] beta alone\n"), "{content}");
|
||||
assert!(content.contains("- [ ] gamma shared\n"), "{content}");
|
||||
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(stdout.contains("Unchecked 2: beta alone"), "{stdout:?}");
|
||||
assert!(stdout.contains("Already unchecked 1: alpha shared"), "{stdout:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uncheck_takes_several_mixed_terms() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", UUID, "all"]);
|
||||
let out = run(&temp, &["uncheck", UUID, "2", "gamma"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [ ] beta alone\n"), "{content}");
|
||||
assert!(content.contains("- [ ] gamma shared\n"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_failing_term_refuses_an_uncheck_batch_too() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["uncheck", UUID, "2", "nowhere"]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert_eq!(ticket(&worklane), before, "beta was unticked anyway");
|
||||
}
|
||||
|
||||
+111
-8
@@ -3,9 +3,11 @@ use assert_fs::TempDir;
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
/// The document as this test's binary carries it, so the print path is pinned to the
|
||||
/// file in the repo rather than to a description of it.
|
||||
/// The documents as this test's binary carries them, so the print path is pinned to the
|
||||
/// files in the repo rather than to a description of them.
|
||||
const SKILL: &str = include_str!("../assets/SKILL.md");
|
||||
const REVIEW: &str = include_str!("../assets/REVIEW.md");
|
||||
const PLAN: &str = include_str!("../assets/PLAN.md");
|
||||
|
||||
/// `HOME` is redirected, so the suite never writes into the home of whoever runs it.
|
||||
/// A temp directory rather than the real one is also what makes the already-installed
|
||||
@@ -20,9 +22,21 @@ fn installed(home: &TempDir) -> std::path::PathBuf {
|
||||
home.path().join(".claude/skills/worklane/SKILL.md")
|
||||
}
|
||||
|
||||
/// Nothing about the skill needs a board, and it is wanted before there is one.
|
||||
fn installed_review(home: &TempDir) -> std::path::PathBuf {
|
||||
home.path().join(".claude/skills/worklane-review/SKILL.md")
|
||||
}
|
||||
|
||||
fn installed_plan(home: &TempDir) -> std::path::PathBuf {
|
||||
home.path().join(".claude/skills/worklane-plan/SKILL.md")
|
||||
}
|
||||
|
||||
/// Nothing about the skills needs a board, and they are wanted before there is one.
|
||||
///
|
||||
/// One invocation writes every document. A person who learned the command before the
|
||||
/// review skill existed gets it without learning anything new, which is the whole
|
||||
/// reason there is no name to pass.
|
||||
#[test]
|
||||
fn the_skill_installs_outside_a_worklane_directory() {
|
||||
fn every_skill_installs_outside_a_worklane_directory() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill"]);
|
||||
@@ -31,7 +45,51 @@ fn the_skill_installs_outside_a_worklane_directory() {
|
||||
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
||||
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
|
||||
assert!(stdout.contains(".claude/skills/worklane/SKILL.md"), "{stdout}");
|
||||
assert!(stdout.contains("Installed the worklane-review skill"), "{stdout}");
|
||||
assert!(stdout.contains(".claude/skills/worklane-review/SKILL.md"), "{stdout}");
|
||||
assert!(stdout.contains("Installed the worklane-plan skill"), "{stdout}");
|
||||
assert!(stdout.contains(".claude/skills/worklane-plan/SKILL.md"), "{stdout}");
|
||||
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
|
||||
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
||||
assert_eq!(std::fs::read_to_string(installed_plan(&home)).unwrap(), PLAN);
|
||||
|
||||
// Once, not per document: it is the one thing to do next, not part of an outcome.
|
||||
assert_eq!(
|
||||
stdout.matches("pick it up on their next session").count(),
|
||||
1,
|
||||
"{stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Narrowing to one document is the exception, and it must leave the others alone.
|
||||
#[test]
|
||||
fn a_named_skill_installs_only_that_one() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill", "worklane-review"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
||||
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
||||
assert!(!installed(&home).exists(), "a named install wrote the other document too");
|
||||
assert!(!installed_plan(&home).exists(), "a named install wrote the other document too");
|
||||
}
|
||||
|
||||
/// A name nothing ships is a stop, with the choices in the message: guessing at the
|
||||
/// nearest match would install a document nobody asked for.
|
||||
#[test]
|
||||
fn an_unknown_skill_name_is_refused_and_lists_what_there_is() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill", "reviewer"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_ne!(out.status.code(), Some(0), "{stderr}");
|
||||
assert!(stderr.contains("no skill named"), "{stderr}");
|
||||
assert!(stderr.contains("worklane-review"), "{stderr}");
|
||||
assert!(!installed(&home).exists());
|
||||
assert!(!installed_review(&home).exists());
|
||||
assert!(!installed_plan(&home).exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -73,17 +131,62 @@ fn a_modified_copy_is_reported_and_needs_force() {
|
||||
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
|
||||
}
|
||||
|
||||
/// One refused document must not stop the ones behind it: the message is per document,
|
||||
/// and the run still reports what it did with each.
|
||||
#[test]
|
||||
fn a_modified_copy_does_not_stop_the_other_documents() {
|
||||
let home = TempDir::new().unwrap();
|
||||
run(&home, &["install-skill"]);
|
||||
std::fs::write(installed(&home), "hand written\n").unwrap();
|
||||
std::fs::remove_file(installed_review(&home)).unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
||||
assert!(stdout.contains("Differs from the version in this binary"), "{stdout}");
|
||||
assert!(stdout.contains("install-skill worklane --print"), "{stdout}");
|
||||
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), "hand written\n");
|
||||
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
||||
assert_eq!(std::fs::read_to_string(installed_plan(&home)).unwrap(), PLAN);
|
||||
}
|
||||
|
||||
/// The print path is what makes a modified copy diffable, so it has to be the document
|
||||
/// byte for byte and it must not install anything on the way past.
|
||||
#[test]
|
||||
fn print_writes_the_document_to_stdout_and_installs_nothing() {
|
||||
fn print_writes_the_named_document_to_stdout_and_installs_nothing() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill", "worklane", "--print"]);
|
||||
assert_eq!(out.status.code(), Some(0));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout), SKILL);
|
||||
|
||||
let out = run(&home, &["install-skill", "worklane-review", "--print"]);
|
||||
assert_eq!(out.status.code(), Some(0));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout), REVIEW);
|
||||
|
||||
let out = run(&home, &["install-skill", "worklane-plan", "--print"]);
|
||||
assert_eq!(out.status.code(), Some(0));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout), PLAN);
|
||||
|
||||
assert!(!installed(&home).exists(), "--print installed the skill anyway");
|
||||
assert!(!installed_review(&home).exists(), "--print installed the skill anyway");
|
||||
assert!(!installed_plan(&home).exists(), "--print installed the skill anyway");
|
||||
}
|
||||
|
||||
/// A diff is against one document. Printing them all run together would be neither of
|
||||
/// them, so an unnamed `--print` says what to type instead of guessing.
|
||||
#[test]
|
||||
fn print_without_a_name_says_which_names_there_are() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill", "--print"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(0));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout), SKILL);
|
||||
assert!(!installed(&home).exists(), "--print installed the skill anyway");
|
||||
assert_ne!(out.status.code(), Some(0), "{stderr}");
|
||||
assert!(stderr.contains("name the skill to print"), "{stderr}");
|
||||
assert!(stderr.contains("worklane-review"), "{stderr}");
|
||||
assert!(String::from_utf8_lossy(&out.stdout).is_empty(), "a document was printed anyway");
|
||||
}
|
||||
|
||||
/// The command has to be findable by someone who does not already know it exists.
|
||||
|
||||
+174
@@ -296,3 +296,177 @@ fn ls_shows_a_mark_for_the_level() {
|
||||
// The raw number is not what the listing shows
|
||||
assert!(!stdout.contains(" 1 "), "the digit leaked into the row");
|
||||
}
|
||||
|
||||
/// A ticket whose Tags field is whatever the test needs it to be, written verbatim so a
|
||||
/// missing field, an unset one and a real list are all reachable.
|
||||
fn create_ticket_with_tags(
|
||||
worklane_dir: &std::path::Path,
|
||||
status: &str,
|
||||
title: &str,
|
||||
tags: &str,
|
||||
priority: &str,
|
||||
) {
|
||||
let slug: String = title.to_lowercase().replace(' ', "-");
|
||||
let body = format!(
|
||||
"# {title}\n\n## Metadata\n\n - **ID**: 00000000-0000-0000-0000-000000000001\n - **Priority**: {priority}\n{tags} - **Due**: _Not set_\n- **Owner**: alice\n- **Status**: {status}\n"
|
||||
);
|
||||
fs::write(
|
||||
worklane_dir
|
||||
.join(status)
|
||||
.join(format!("00000000-0000-0000-0000-000000000001_{slug}.md")),
|
||||
body,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// The Tags line as a ticket carries it, for the common case of a real list.
|
||||
fn tags(list: &str) -> String {
|
||||
format!("- **Tags**: {list}\n")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ls_filters_by_tag_and_composes_with_status_and_priority() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_tags(&worklane, "backlog", "Tagged bug", &tags("bug,cli"), "1");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Tagged feature", &tags("feature"), "1");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Lower bug", &tags("bug"), "3");
|
||||
create_ticket_with_tags(&worklane, "committed", "Started bug", &tags("bug"), "1");
|
||||
|
||||
// Alone, through the grouped listing: every status, only the tagged tickets.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "--tag", "bug"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Tagged bug"), "{stdout}");
|
||||
assert!(stdout.contains("Lower bug"), "{stdout}");
|
||||
assert!(stdout.contains("Started bug"), "a tagged ticket in another status was dropped");
|
||||
assert!(!stdout.contains("Tagged feature"), "an untagged ticket came through");
|
||||
// The counts are filtered too, since they are the same collect.
|
||||
assert!(stdout.contains("[BACKLOG] 2 tickets"), "{stdout}");
|
||||
assert!(stdout.contains("[COMMITTED] 1 ticket"), "{stdout}");
|
||||
|
||||
// With the status positional.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "bug"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Tagged bug"));
|
||||
assert!(stdout.contains("Lower bug"));
|
||||
assert!(!stdout.contains("Started bug"), "the status was ignored");
|
||||
|
||||
// With --priority, and with both: none asked for is everything kept, so the three
|
||||
// compose without a rule per pair.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "--tag", "bug", "--priority", "1"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Tagged bug"));
|
||||
assert!(stdout.contains("Started bug"));
|
||||
assert!(!stdout.contains("Lower bug"), "the priority was ignored");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "bug", "--priority", "1"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Tagged bug"));
|
||||
assert!(!stdout.contains("Lower bug"), "the priority was ignored");
|
||||
assert!(!stdout.contains("Started bug"), "the status was ignored");
|
||||
assert!(!stdout.contains("Tagged feature"), "the tag was ignored");
|
||||
}
|
||||
|
||||
/// The field is a list of whole values, not a string to search: a ticket tagged `bugfix`
|
||||
/// is not a ticket tagged `bug`, and neither is one tagged `Bug`. Case sensitive is the
|
||||
/// opinion the field already takes, since `tag_color` draws those two differently.
|
||||
#[test]
|
||||
fn ls_matches_a_whole_tag_value_and_not_a_substring_or_another_case() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_tags(&worklane, "backlog", "Real bug", &tags("bug"), "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Only bugfix", &tags("bugfix"), "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Capital Bug", &tags("Bug"), "2");
|
||||
// A value that only appears with its neighbours around it, so a match on the raw
|
||||
// field would find it and a match on the split values cannot.
|
||||
create_ticket_with_tags(&worklane, "backlog", "Spaced list", &tags("cli, filter"), "2");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "bug"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Real bug"), "{stdout}");
|
||||
assert!(!stdout.contains("Only bugfix"), "bug matched bugfix");
|
||||
assert!(!stdout.contains("Capital Bug"), "bug matched Bug");
|
||||
|
||||
// Trimmed on the way in, so the space after the comma is not part of the tag.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "filter"]);
|
||||
assert!(get_stdout(&mut cmd).contains("Spaced list"));
|
||||
|
||||
// And the field as written is not itself a tag.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "cli, filter"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(!stdout.contains("Spaced list"), "the whole field matched as one tag");
|
||||
}
|
||||
|
||||
/// No tags is no match, however the ticket spells it: the field absent, unset, or empty.
|
||||
#[test]
|
||||
fn ls_never_matches_a_ticket_carrying_no_tags() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_tags(&worklane, "backlog", "Has one", &tags("bug"), "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Field unset", &tags("_None_"), "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Field empty", "- **Tags**:\n", "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Field missing", "", "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Only commas", &tags(", ,"), "2");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "bug"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Has one"), "{stdout}");
|
||||
for absent in ["Field unset", "Field empty", "Field missing", "Only commas"] {
|
||||
assert!(!stdout.contains(absent), "{absent} matched a tag it does not carry");
|
||||
}
|
||||
|
||||
// Nor does an empty tag reach the filter: the value parser refuses it, so nothing is
|
||||
// listed rather than everything.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", ""]);
|
||||
cmd.assert().failure().code(2);
|
||||
}
|
||||
|
||||
/// A tag nothing carries lists nothing and still succeeds. The message is the one `ls`
|
||||
/// already gives for a filter that empties a status, rather than a second one invented
|
||||
/// here for tags alone.
|
||||
#[test]
|
||||
fn ls_with_a_tag_nothing_carries_lists_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_tags(&worklane, "backlog", "Tagged bug", &tags("bug"), "2");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "frontend"]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "frontend"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(!stdout.contains("Tagged bug"), "{stdout}");
|
||||
assert!(stdout.contains("No tickets in 'backlog' status."), "{stdout}");
|
||||
|
||||
// Through the grouped listing the counts go to zero and no section is drawn.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "--tag", "frontend"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("[BACKLOG] 0 tickets"), "{stdout}");
|
||||
assert!(!stdout.contains("Tagged bug"), "{stdout}");
|
||||
}
|
||||
|
||||
+44
-4
@@ -289,6 +289,21 @@ fn relate_leaves_everything_it_was_not_asked_about_alone() {
|
||||
assert!(content.contains("- **Owner**: alice"), "{content}");
|
||||
}
|
||||
|
||||
/// The mark each kind prints before the id. Written out rather than imported: these
|
||||
/// tests drive the binary, so they see only its output.
|
||||
///
|
||||
/// The cross is the one a held-up card already carries, since both say the same word.
|
||||
const BLOCKED_MARK: &str = "\u{d7}";
|
||||
const RELATES_MARK: &str = "\u{2192}";
|
||||
|
||||
/// And the mark for the status of the ticket the row names, which follows the kind: a
|
||||
/// circle filling up as the target moves through the flow.
|
||||
const BACKLOG_MARK: &str = "\u{25cb}";
|
||||
const DONE_MARK: &str = "\u{25cf}";
|
||||
/// A target the board no longer holds has no status, and `?` holds the column so the id
|
||||
/// does not move.
|
||||
const NO_STATUS_MARK: &str = "?";
|
||||
|
||||
/// The kind, the short id and the title, so the section reads without a second lookup.
|
||||
#[test]
|
||||
fn show_renders_the_kind_the_short_id_and_the_title() {
|
||||
@@ -299,7 +314,10 @@ fn show_renders_the_kind_the_short_id_and_the_title() {
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(shown.contains("Relations"), "{shown}");
|
||||
assert!(shown.contains("blocked by (b1b2c3d) The blocker"), "{shown}");
|
||||
assert!(
|
||||
shown.contains(&format!("blocked by {BLOCKED_MARK} {BACKLOG_MARK} (b1b2c3d) The blocker")),
|
||||
"{shown}"
|
||||
);
|
||||
// Never the stored line: a bare uuid says nothing about what it points at.
|
||||
assert!(!shown.contains(BLOCKER), "{shown}");
|
||||
}
|
||||
@@ -314,12 +332,31 @@ fn show_lists_the_relation_the_other_ticket_holds() {
|
||||
run(&temp, &["relate", GATED, "--relates-to", FIXED]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", BLOCKER]));
|
||||
assert!(shown.contains("blocks (641e3d5) The gated one"), "{shown}");
|
||||
assert!(
|
||||
shown.contains(&format!("blocks {BLOCKED_MARK} {BACKLOG_MARK} (641e3d5) The gated one")),
|
||||
"{shown}"
|
||||
);
|
||||
assert!(!ticket(&worklane, BLOCKER).contains("Relations"));
|
||||
|
||||
// Two kinds on one ticket, each with its own mark, and the second mark is the state
|
||||
// of the ticket at the far end: the old fix is in done and the blocker is not. That
|
||||
// is the pair the block is for, which kind of edge and whether it is finished.
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(
|
||||
shown.contains(&format!("blocked by {BLOCKED_MARK} {BACKLOG_MARK} (b1b2c3d) The blocker")),
|
||||
"{shown}"
|
||||
);
|
||||
assert!(
|
||||
shown.contains(&format!("relates to {RELATES_MARK} {DONE_MARK} (f1f2f3f) The old fix")),
|
||||
"{shown}"
|
||||
);
|
||||
|
||||
// `relates to` is symmetric, so it reads the same way from either end.
|
||||
let shown = stdout(&run(&temp, &["show", FIXED]));
|
||||
assert!(shown.contains("relates to (641e3d5) The gated one"), "{shown}");
|
||||
assert!(
|
||||
shown.contains(&format!("relates to {RELATES_MARK} {BACKLOG_MARK} (641e3d5) The gated one")),
|
||||
"{shown}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -331,7 +368,10 @@ fn a_target_that_no_longer_exists_renders_as_missing() {
|
||||
fs::remove_file(find(&worklane, BLOCKER)).unwrap();
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(shown.contains("blocked by (b1b2c3d) _missing_"), "{shown}");
|
||||
assert!(
|
||||
shown.contains(&format!("blocked by {BLOCKED_MARK} {NO_STATUS_MARK} (b1b2c3d) _missing_")),
|
||||
"{shown}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The section is the one part of a ticket read back by machine, so a line nobody can
|
||||
|
||||
@@ -415,3 +415,50 @@ fn neither_command_can_write_owner_or_status() {
|
||||
assert!(content.contains("- **Owner**: alice"));
|
||||
assert!(content.contains("- **Status**: backlog"));
|
||||
}
|
||||
|
||||
/// The same parser `add` uses, from one definition. Grooming a board sets dates through
|
||||
/// `set`, so validating only the command that files a ticket would leave the path that
|
||||
/// is actually used wide open.
|
||||
#[test]
|
||||
fn set_refuses_a_due_date_that_is_not_a_real_iso_date() {
|
||||
for value in ["next friday", "2026-02-30", "2026-8-9"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_ticket(&worklane);
|
||||
let before = fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let out = cmd
|
||||
.current_dir(temp.path())
|
||||
.args(["set", UUID])
|
||||
.args(["--due", value])
|
||||
.assert()
|
||||
.failure()
|
||||
.get_output()
|
||||
.clone();
|
||||
|
||||
assert_eq!(out.status.code(), Some(2), "{value:?} was not a usage error");
|
||||
assert_eq!(
|
||||
fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap(),
|
||||
before,
|
||||
"{value:?} changed the ticket anyway"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_stores_a_valid_due_date_unchanged() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_ticket(&worklane);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["set", UUID])
|
||||
.args(["--due", "2026-12-31"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap();
|
||||
assert!(content.contains("- **Due**: 2026-12-31"), "{content}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user