Compare commits

..
9 Commits
Author SHA1 Message Date
Ansho ReiandClaude Opus 5 a1bdb5df49 (87862df) Attribute an entry to WORKLANE_ACTOR, not to the git user, and bump to 0.28.0
Every comment the CLI wrote was attributed to the git user, so a board
several agents write to read as a list of things one human had done.
resolve_actor is now the single source: flag, then WORKLANE_ACTOR, then
get_git_user(), then unknown.

comment --owner is renamed to --actor with no alias, since it names the
writer of the entry and not the ticket's assignee, which is chown's.
add --owner and campaign add --owner still default to the git user.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 12:34:51 +02:00
Ansho Rei c2ee165108 (e4d0bb7) Colour the whole detail overlay body, not just its relations, and bump to 0.27.3
The block was the only coloured part because it arrived as rows while
everything else arrived as a painted string, and the board had to ask for
the unpainted one: an escape in a ratatui paragraph is drawn as literal
bytes.

content_parts now paints nothing. BodyPart::Text becomes
BodyPart::Cells, so content_trim is the cells through paint_cells and the
board is the same cells through span_from. push_heading, ordered_cells,
inline_cells, metadata_cells, metadata_value_cells and tag_cells replace
the painters they were. Resolved.campaign is cells too, which made
reference_cell dead at its last caller.

The colored flag still reaches content_parts and no longer means paint.
It says whether this renderer can carry a colour at all, and one thing
turns on it: **bold** gives its markers up to the colour that replaces
them, so a renderer with none has to keep them.

Color::Magenta.ansi() is \x1b[1;35m, so span_from adds the bold modifier
on the board's side, since From<Color> carries only the colour and the
same cell must not be painted two ways.

show's output is pinned byte for byte against what it printed before,
both by a fixture holding one of every painted run and by diffing the
old binary against the new one over every ticket and campaign on this
board, coloured and piped.
2026-08-24 11:57:25 +02:00
Ansho Rei 407cb14fe6 (e6e3a1b) Guard the README command table against a missing row
The campaign and assign rows landed with 528566d. What was left was the
checking, done here against the built binary rather than against the
ticket that added them.

The campaign ls row was incomplete: the listing also prints the derived
state, [open] until every member is done and [done] after, and reads
"no members" with no state for a campaign nothing has been filed
against, which is neither. Corrected.

every_subcommand_has_a_row_in_the_readme_command_table walks clap's own
subcommands, one level of nesting included, against the table's rows.
Two commands hid behind an otherwise complete table for two minor
versions because the only thing walking it was somebody remembering to.
The tag subcommands are named in a PENDING list rather than skipped,
since f7dd1a1 rewrites that row.
2026-08-24 11:28:32 +02:00
Ansho Rei 108e21ad7f (25d3018) Fix the markdown link colorization branch, and bump to 0.27.2
The branch searched for a closing square bracket after the ]( sequence
instead of a closing parenthesis, so it fired only on text that was not
a link, and when it fired it pushed the matched span and dropped the
rest of the line.

Folded into colorize_bold, now colorize_inline: one walk over the source
line recognising both **bold** and [text](url). A second pass over the
first one's output would be scanning text that already holds escape
sequences, and \x1b[36m carries an opening bracket, so the link scan
would take the escape for markup. Unterminated markup of either kind
falls through to the ordinary character push, so the rest of the line
survives as literal text.

Criteria text and hand-written metadata rows get links too, since they
already went through this function. The whole span is painted, markers
and url kept: show prints to a terminal worklane cannot assume will make
a link clickable.
2026-08-24 11:15:15 +02:00
Ansho Rei 26b93f8f53 Add Makefile 2026-08-24 11:03:28 +02:00
Ansho ReiandClaude Opus 5 7126138d46 (0fd1ddc) Pick a tag in the tui, and bump to 0.27.1
The board could be cut by campaign and not by the axis `ls --tag` has answered
since 2f3796e. `t` opens a picker of every tag the board declares or carries,
and taking one filters every column to the cards carrying it, matched whole and
case sensitively the way the listing matches.

The picker is one piece of machinery over two lists rather than a second
picker. `PickerRow::key` is what made that cheap: a campaign is keyed by its
uuid and a tag by itself, both strings, so stepping over selectable rows,
keeping the highlight across a rebuild and taking a row with `enter` are
written once. Only the list and what the answer filters differ.

`Tab::campaign` became `Tab::filter`, an enum of whole, campaign or tag, with
`select_filter` its only writer. Picking either clears the other because they
are one field rather than because two setters remember to, which is also what
the shared frame slot needs: it holds one frame and can now only be asked to
name one thing.

The tag sections are declared above undeclared and neither is truncated, where
the completed campaigns are: a finished campaign is done with and that tail
only grows, while an undeclared tag is the row a reader most wants to see.
`campaign` and `campaigns` would have sat one under the other here the day the
second was invented.

The digest stamps `tags.md`, or a tag declared elsewhere would never reach an
open picker. The footer names the tag in its own colour beside `q board`,
because a tag draws no frame until 2a83bd4 and nothing else would say why the
cards are missing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 10:03:29 +02:00
Ansho ReiandClaude Opus 5 3592584747 Edit a campaign's description, and bump to 0.27.0
`campaign set` reached the title and the codename, so the description a
campaign was filed with was the description it kept: fixing a typo in the
one field nothing could edit meant a hand edit of the file, or refiling the
campaign and reassigning every member.

Both halves arrive together, which is why d637288 left this out rather than
adding the flag. `campaign set --description` replaces the section and
`campaign append --description` adds a paragraph to it, because a `set` with
no `append` is the half that is easy to reach for and wrong: replacing a
description to add a sentence is how the rest of it gets lost.

`append` is a campaign's own subcommand rather than the top-level one, which
resolves a ticket. `resolve_in`'s tiers are the same over both directories,
so one positional naming either object could resolve in each with nothing
but a flag to say which was meant, and it would make a liar of the
explanation `resolve_ticket` gives a ticket search that names a campaign.

The section is the `DESCRIPTION` entry and the surgery is
`set_section_body`, `append_section_body` and `Section::normalise`, not a
copy scoped to campaigns. `SECTION_ORDER` needs no campaign variant: a
campaign holds one section where a ticket holds four, and the followers a
campaign does not have are simply not in the file, so its description
anchors against `## Metadata`, where `campaign_body` writes it.

Still no `--clear`, and that is now a decision rather than a deferral: a
campaign's description has no cleared form, so an empty `--description ""`
is a paragraph break here as it is everywhere else, and the refusal for an
all-blank value says there is nowhere to go back to instead of naming a flag
that does not exist. `replaced_items` and `appended_items` hold that check
once for both objects, with the way out as the caller's argument.

The section refusal no longer says "Ticket", since a campaign reaches it
too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 04:53:49 +02:00
Ansho ReiandClaude Opus 5 5dc087d49e (9564ac9) Show the annotation in tags ls, and bump to 0.26.4
Since tags.md there are two vocabularies, the one the file declares and the one
the tickets carry, and the listing reported only the second. A tag declared and
never applied was invisible, and a word somebody invented in a hurry read
exactly like one the board had agreed on. Those two cases are the whole reason
to declare tags at all.

The listing is now the union: still alphabetical, still case sensitive, with the
annotation's opening line as a third tab-separated field and a count of zero for
a tag nothing carries.

**The absence of the third field is what marks a carried but undeclared tag.**
Nothing could be appended to the first field without a completion offering a tag
that does not exist, and nothing could be added to the second without it
stopping being a number. Absence costs neither, and it buys the property a
marker could not have: a board with no tags.md has every tag undeclared, so it
prints two fields a line, which is byte for byte what this printed before the
file existed. An older completion script on a newer binary keeps working, which
is the same compatibility 1db02e5 kept for the bare form.

A declared tag with nothing said about it answers the placeholder rather than an
empty string. An empty third field is a trailing tab and nothing else, so the
one difference between declared and not would have been invisible in a terminal
and in a completion alike. It is also what the file itself holds under that
heading, so the field is the section's opening line either way.

`TagIndex::summary` does the cut to one line, the way `CampaignRow::summary`
takes one line off a description the read carries whole: the annotation is prose
with paragraphs in it, and how much of it a view wants is the view's business.

The two fish rules pipe through `cut -f1,3`, since fish takes everything after
the *first* tab as one description and the count would otherwise land in the
middle of the prose. What is left is the annotation, and a tag the board has
never declared is offered with no description at all, which says what the count
used to say more weakly. `cut` rather than `string replace` because columns are
what is being picked, and `cut -f1` is how a script reads this listing anyway.
A test pins both rules rather than the script as a whole, so a rule added later
that reads `worklane tags` raw is caught.

`assets/ADMIN.md` claimed a declared and unapplied tag does not appear in the
listing, which is now the opposite of the truth; it lists at zero. Fixed here
rather than left to f7dd1a1, which does not list that file. The same stale
sentence in SKILL.md and PLAN.md is recorded on that ticket.

Filed on the way past: an annotation carrying a tab splits the listing into a
fourth field, 8f650fc, and the `tags set` completion offers the undeclared tags
it refuses, which only became filterable now that the listing tells them apart,
193f9be.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 03:58:04 +02:00
Ansho ReiandClaude Opus 5 07c783410c (b74dc5a) Remove a test's fixture directory with a guard, not a trailing line
Every unit test here built its board under the system temp directory,
and the ones that remembered a `remove_dir_all` at the end only cleaned
up when their assertions passed. Most had no such line at all. /tmp
reached 18363 of these and filled the disk, which failed a link step and
then a `git add` with "No space left on device": an error naming neither
the tests nor what they had left behind.

`util::Fixture` is a uuid-named directory whose `Drop` removes it, which
is the only shape that also runs when an assertion fails, since
unwinding runs destructors. It derefs to `Path` and implements
`AsRef<Path>`, because the two reach different call sites: a parameter
typed `&Path` is a coercion site and one bound by `impl AsRef<Path>` is
not. So nothing changed at the ~160 call sites but the type, and the 85
trailing cleanup lines are gone.

Five leaking prefixes, not the two the ticket names.
`worklane-project-*` from `project_tree` and `worklane-bare-*` never
cleaned up at all, and the four `worklane-count/blocked/stray/stamps-*`
sites in `util.rs` cleaned up only on the passing path.
`Fixture::child` is what covers `project_tree`, which needs the fixture
to point at the project and remove the directory above it.

`assert_fs::TempDir` is a dev-dependency already and was still not the
answer: it names its directories `.tmpXXXXXX`, which says nothing about
whose they are for the one case that matters, the one left on disk on
purpose. Wrapping it to add a prefix and a printed path is more code
than the guard.

`WORKLANE_KEEP_FIXTURES=1` keeps them and prints each path, opt-in
rather than kept-automatically-on-failure: the assertions here carry the
state they are about, so a path printed on every failure would be noise
on almost all of them. Read once when a fixture is made rather than at
drop time, so the answer cannot change mid-test, and `Fixture::swept()`
turns it off for the three tests that are about the guard itself and
must not be failed by a reader's environment.

Verified against a clean temp dir rather than against /tmp, which still
holds the historical leak: `TMPDIR=/tmp/scratch cargo test` leaves zero
directories behind, with the variable set and unset, 383 green either
way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 03:35:23 +02:00
20 changed files with 3123 additions and 659 deletions
+41 -13
View File
@@ -45,6 +45,10 @@ and this file is for what someone changing worklane's own code needs.
- Tests use `assert_cmd` and `assert_fs` for CLI testing
- `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)
- **Every unit-test fixture directory goes through `util::Fixture`, and nothing calls `remove_dir_all` at the end of a test.** `Fixture::new(prefix)` makes a uuid-named directory under the system temp dir and its `Drop` removes it, which is the only shape that also runs when an assertion fails — a trailing line does not, and a failing test is exactly when a fixture is most likely to be stranded. That was b74dc5a: `/tmp` reached 18363 of these and filled the disk, failing a link step and then a `git add` with "No space left on device", an error naming neither the tests nor what they left behind
- **`Fixture` derefs to `Path` and also implements `AsRef<Path>`**, because the two reach different call sites: a parameter typed `&Path` is a coercion site and one bound by `impl AsRef<Path>` is not. `Fixture::child(name)` points the fixture at a directory inside itself while still removing the parent, which is the tree `project_tree` needs. The prefix earns its place on the one path that is ever left behind, which is why this is a small guard rather than `assert_fs::TempDir` — that names its directories `.tmpXXXXXX`, which says nothing about whose they are
- **`WORKLANE_KEEP_FIXTURES=1 cargo test` keeps the fixtures and prints each path.** Opt-in rather than kept-automatically-on-failure, because the assertions here carry the state they are about: a failing board test prints the rendered rows. The flag is read once when a fixture is made rather than at drop time, so the answer cannot change mid-test, and `Fixture::swept()` turns it off for the three tests that are about the guard itself and must not be failed by a reader's environment
- **Verify a claim about leaked fixtures against a clean temp dir, not against `/tmp`.** `TMPDIR=/tmp/scratch cargo test` then count what is left in it: `/tmp` still holds the historical leak, so counting there measures the past rather than the change
- In `tui.rs`, `write_member_card` is `write_tagged_card` plus a Campaign field and `write_campaign` puts a campaign on disk, creating the campaigns directory as it goes — `board_dir()` deliberately does not, so every test that does not write one is also the test that a board with no campaigns draws. `picker_rows` cuts the picker's list out of the frame by its own geometry, for the reason `overlay_title_row` exists: a card carries the same campaign label, so a search over every row finds the board rather than the list
- **`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
- **`cargo fmt --check` is clean too, and `rustfmt.toml` is what makes that affordable.** rustfmt is the formatter here, run it. The config is four stable width settings and nothing else:
@@ -121,6 +125,7 @@ and this file is for what someone changing worklane's own code needs.
- Appending to a numbered section continues from the count of steps already there and does not renumber what is above it, so a handwritten line in the section survives exactly as written
- Appending to an empty section replaces the placeholder rather than following it, or the ticket would read `_No description provided._` above its description
- An empty value is a paragraph break for the three sections and a usage error for the scalars, via `non_empty` and `clearable` in `command.rs`. Neither spells clearing, and both errors name the flag that does
- **A call whose values are *every one* blank is refused, by `replaced_items` for `set` and `appended_items` for `append`.** The check is the section's rather than the object's, so `campaign set --description` shares it. What differs is the way out, which is why `replaced_items` takes it as an argument: a ticket's section is emptied with `--clear <field>` and a campaign's description cannot be emptied at all, so a single hard-coded tail would name a flag that does not exist on one of the two
### Clearing a Field
- **`set --clear <field>` is the one way to take a value away, and it is a flag with the field as its value.** Not a per-field `--clear-due`, which is a flag per field to keep in step with the field it undoes, and not an empty value, which is already a paragraph break for a section and would make an accidentally empty variable a silent delete. Repeatable, so one call empties as many fields as it likes
@@ -170,7 +175,7 @@ and this file is for what someone changing worklane's own code needs.
- **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
- **The full uuid is stored and the title is resolved for display**, as the Relations section already does. `reference_cells` 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 four 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
@@ -181,9 +186,14 @@ and this file is for what someone changing worklane's own code needs.
- `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 got a card label and a frame, not a campaign tab.** 61879a4 decided it. A tab would have had to answer what its columns are, and a campaign groups *across* the flow rather than within one status, so the honest answer is the four statuses filtered — which is a filter on the board it already has rather than a fifth tab. So: a label on the card, a frame above the columns while one is selected, and `c` for the picker. The cost the earlier decision balked at, a campaigns read per reload, is paid once per project in `columns_of` and is what names the label; see The Board View
- **A campaign is named by its codename on the board, and by its short id when it has none.** The uuid does not fit on a card and the title is a sentence, which is the gap `Codename` fills. `campaign_label` builds it in one place, as a `Cell`, so the CLI paints it and the board makes a span of it; the mark is `CAMPAIGN_MARK`, `~`, beside `#` for a tag
- **`campaign set` is the only writer of a filed campaign's fields, and it carries the two scalars.** d637288 decided it: a `set` rather than a flag on something narrower, because the file has more than one editable thing and the moment somebody wants to fix a typo in a title there would be a second command to design. `--title`, which renames the file the way `set --title` does, and `--codename`. `campaign add` writing a field at creation is not a second writer, exactly as `add --title` and `set --title` coexist
- **`campaign set` and `campaign append` are the only writers of a filed campaign's fields.** d637288 decided the command: a `set` rather than a flag on something narrower, because the file has more than one editable thing and the moment somebody wants to fix a typo in a title there would be a second command to design. `set` carries `--title`, which renames the file the way `set --title` does, `--description` and `--codename`; `append` carries `--description` alone. `campaign add` writing a field at creation is not a second writer, exactly as `add --title` and `set --title` coexist
- **Replacing a codename the campaign already has needs `--force`.** Once a campaign has one it is referred to by it: it is on every card in the campaign, it is what resolves the campaign at the command line, and it is in somebody's shell history. Changing it silently is the mistake `install-skill --force` exists to prevent, so it is refused and the refusal names both words and the flag rather than leaving it to be found. Checked before any edit is applied, like `SetArgs::contested`, so a call also carrying `--title` writes neither field. Setting the codename a campaign already carries stays a **no-op, not a refusal** — `--force` is about overwriting a *different* word, which is the same division `install::Outcome` draws between `Unchanged` and `Refused`. `--force` guards the codename alone: a campaign always has a title, so guarding that would mean the flag was always required
- **No `campaign set --description`, and that is the line, not an oversight.** `set` and `append` are a pair for a prose section: a way to replace a description with no way to add a paragraph is half of it. The two scalars have no append form at all, which is the same line `append` already draws for a ticket. `campaign_set_offers_no_description_and_no_owner` pins it. No `--owner` either, because nothing writes a campaign's Owner today and giving `set` one would settle by accident whether `chown` grows a campaign; and no `--clear`, because a wrong codename is replaced rather than emptied and `Clearable` is `SetArgs`'s, its variants being a ticket's fields
- **The description arrived as a pair, `set --description` and `campaign append`, 32e98ab.** Never one without the other: for a prose section `set` replaces and `append` adds, and a way to replace a description with no way to add a paragraph is the half that is easy to reach for and wrong, since replacing a description to add a sentence to it is how the rest of it gets lost. The two scalars have no append form at all, which is the same line `append` already draws for a ticket, and `campaign_append_offers_only_the_description` pins that. Neither flag takes `--force`: a description is prose written to be revised, the same reason `tags set --annotation` has none
- **`append` is a campaign's own subcommand, not the top-level `append`.** That one resolves a ticket, and one positional naming either object is the ambiguity `resolve_in` makes real: its tiers are the same over both directories, so a search can resolve in each and nothing but a flag could say which was meant. It would also make a liar of `resolve_ticket`, which explains a ticket search that *names* a campaign. Under `campaign` the object is settled by the command, as it is for `set`, `show` and `ls`
- **Still no `--owner` and still no `--clear`.** No `--owner`, because nothing writes a campaign's Owner today and giving `set` one would settle by accident whether `chown` grows a campaign. No `--clear`, which 32e98ab settled rather than deferred: a codename is replaced rather than emptied, and emptying the description of a container six tickets are filed against is not a thing anybody has asked for, so the only spellings left would be `Clearable` on a campaign, whose variants are a ticket's fields, or a second enum with one variant in it. `campaign_set_offers_no_owner_and_no_clear` pins both
- **An empty `--description ""` is a paragraph break here too, and the refusal for an all-blank value names no flag.** Every prose argument in the tool reads a blank value that way, `add`, `set` and `tags --annotation` alike, so a campaign reading it as *empty the section* would be the one exception. With no `--clear` to point at, the refusal says a campaign's description has no cleared form instead of naming a flag that does not exist. `replaced_items` is where the check lives, shared with `set`, and the way out is the caller's argument for exactly that reason
- **`SECTION_ORDER` needs no campaign variant, and that is what the one-section file proves.** A campaign holds Description and Metadata where a ticket holds four sections and Metadata. Every consumer of the list looks for the headings that follow, *filtered by what is actually in the file*, so a campaign's description anchors against `## Metadata` — which is where `campaign_body` writes it. `the_description_is_edited_in_place_in_a_file_with_one_section` pins that no section a campaign does not have gets inserted to anchor against
- **A campaign whose Description heading is gone is refused, not given the section back.** No `ensure_section` on this path: every campaign the tool has ever filed carries the heading, so an insertion here would be reachable only from a hand-edited file, which is the opposite of the Relations case, where `add` writes nothing and the insertion is the only path there is. The refusal therefore names the section and **not** the object — "There is no description section to write to" — because both a ticket and a campaign reach `replace_section_body` now. `write_then_replace` still carries the noun, where the message is about a file
- **The codename is written through `set_or_insert_metadata_field`, not `set_metadata_field`.** Every campaign filed before the field existed has no such line, and those are exactly the campaigns the command is for, which is the same reasoning that puts `assign` on the upsert. **`Codename` is therefore in `METADATA_ORDER`, directly after ID**, so an inserted one lands where `campaign_body` writes it and a campaign given a codename later is the same file as one filed with it. Nothing upserts it on a ticket, so its place in a ticket's order costs nothing
- **One write path for tickets and campaigns.** `save_entry` is the body, `save_ticket` and `save_campaign` are the named wrappers, and `write_then_replace` and `find_entry_file` take the noun as a `&str` so a failure says "campaign" where it is one. A campaign file is a ticket file in every way that matters here, `<uuid>_<slug>.md` in a directory, and the rename happens only after the write has landed. Every message puts the noun mid-sentence so there is no capital to case
- `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
@@ -232,7 +242,7 @@ and this file is for what someone changing worklane's own code needs.
- **`the_count_is_read_when_the_items_are_collected_and_not_per_draw` takes the comments directory away after the board is built**, and is paired with `a_comment_added_after_the_board_was_built_reaches_the_card_on_reload`, because a count that never asks the filesystem again would pass the first test by never changing. The digest already moves when a comment lands, so the reload is what recounts
- **A card names its campaign on the label row, before the tags, in bold.** `labels_line` draws both, `CAMPAIGN_MARK` (`~`) for the campaign and `#` for a tag, and the campaign takes the row's width first: two cards in one campaign is what a reader looking for a campaign is looking for, and the tags are the context around it. So a row too narrow for both drops the tags whole and keeps the campaign, the order `corner_line` and `project_label` already follow, and a campaign the row will not hold at all goes whole too. A ticket in neither spends no row, so **a ticket in no campaign renders exactly as it did before campaigns reached the card**
- **`Card::campaign` is a resolved `Cell`, not a uuid**, settled at reload the way `project` and `blocked` are. `TicketItem::campaign` already carries the uuid off the pass that builds the card; the name is in another directory, so `columns_of` reads `CampaignIndex` once per project and hands it to every card. Never per draw, the rule `criteria` and `tags` already hold. The merge carries the resolved cell rather than looking it up again, for the reason it carries `blocked`: a campaign is addressed inside one `.worklane`, so a merged lookup could answer one project's uuid with another project's campaign
- **A campaign the board does not hold labels nothing**, the answer `mark_blocked` gives a dangling blocker. `campaign_cell` renders that case as `_missing_` because a metadata table is a place to report a dangling reference; a card is not
- **A campaign the board does not hold labels nothing**, the answer `mark_blocked` gives a dangling blocker. `campaign_cells` renders that case as `_missing_` because a metadata table is a place to report a dangling reference; a card is not
- **`c` opens the campaign picker, and taking a campaign filters the tab's columns to its members.** Not a fifth tab: a campaign groups across the flow, so the shape of the answer is the four statuses with fewer cards in them, which is what `campaign show` already answers the question in. Every column is kept, empty ones included. The filter is applied in `reload`, where the columns are built, so nothing downstream has to ask whether a campaign is selected — the board simply holds fewer cards, and `first_match`, `done_count` and the copy key all keep working unchanged
- **`Tab::campaign` is a uuid on the tab, not on the `Board`.** A campaign belongs to one `.worklane`, so a filter carried onto another project's tab would empty it and say nothing about why. It is looked up by uuid rather than held as an index, and a selection whose campaign has left the board is cleared by `reload` rather than left filtering the board to nothing
- **The frame above the columns has two heights, and `Chrome` is what every measurement takes.** `Chrome::campaign` is an `Option<FrameSize>`, not a bool: `None` for a tab showing the whole board, and `Collapsed` or `Expanded` for one filtered to a campaign, because both heights have to be measured the same way by everything that measures the board. `frame_rows` grew a row, so the two bools that decide the geometry became one `Chrome`, copied from `Board::chrome`: adjacent same-typed parameters are what the Rust Style rule warns about, and the draw and `follow_selection` have to measure one answer or a keypress scrolls against a board the next frame does not draw. The row indices are named (`TAB_ROW`, `CAMPAIGN_ROW`, `BOARD_ROW`, `FOOTER_ROW`), since an index written out by hand goes on meaning what it used to
@@ -318,7 +328,7 @@ and this file is for what someone changing worklane's own code needs.
### 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
- **`reference_cells` is the one spelling of a cross reference.** The relations block and the Campaign field both go through it, so a dangling reference reads the same way wherever it is shown. There was a `reference_cell` beside it that painted the cells for the CLI; once the whole body became cells the Campaign field stopped needing a string and it was the last caller, so it is gone
- **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
@@ -330,11 +340,15 @@ and this file is for what someone changing worklane's own code needs.
- **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
- **`Resolved.relations` is rows, not a rendered block, and `Resolved.campaign` is cells for the same reason.** An escape sequence in a ratatui paragraph is drawn as literal bytes (6d327df), so nothing in `Resolved` can arrive pre-painted. This was the asymmetry the two renderers needed while the rest of the body was a painted string; there is no asymmetry left, since `content_parts` paints nothing at all
- **`BodyPart` splits the body rather than building it twice.** It is `Cells` or `Relations`: everything outside the block is laid out once, by `content_parts`, and `content_trim` is that run through `paint_cells` while the board is the same cells run through `span_from`. `Body` is the accumulator, so a caller pushes cells and rows without tracking which it pushed last, and it merges a run into the trailing cell when the colour matches, because the board draws a span per cell and the body is pushed a character at a time in places
- **`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
- `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. It now splits **per cell** rather than per part, since a `Cells` part holds many runs and a newline can fall inside any of them
- **The whole overlay body is coloured now, and `content_parts` paints nothing.** The block used to be the only coloured part, because it arrived as rows while everything else arrived as a painted string; e4d0bb7 gave the rest the same `Cell` treatment. So the headings, the plan numbers, the criteria numbers and marks, the bold runs, the field names, the priority glyph, the tags and the grey unset values are one layout that `show` paints and the board styles. Do not reintroduce a `paint` call in `content_parts`: the flat overlay was exactly that, a renderer forced to ask for the unpainted string because the painted one held escapes
- **`colored` still reaches `content_parts`, and it no longer means paint.** It says whether *this* renderer can carry a colour at all, and one thing turns on it: `**bold**` gives its markers up to the colour that replaces them, so a renderer with none has to keep them or the emphasis is lost rather than moved. The board passes `true`, `content_trim` passes the CLI's decision, and a piped `show` still reads its markers. Nothing else in the body consults it
- **Magenta means bold, and `span_from` is where the board learns that.** `Color::Magenta.ansi()` is `\x1b[1;35m`, so the CLI draws every bold run bold as well as magenta, and `From<Color>` can carry only the colour. Without the modifier added on the board's side the same cell would be painted two ways, which is the one thing the shared layout exists to prevent
- **The conversion is pinned from both ends.** `show_prints_the_same_body_it_printed_before_the_cells_conversion` holds a body with one of every painted run and asserts the CLI's output byte for byte, written from what it printed before the change, so the risk in sharing a layout, the CLI's output drifting to suit the board, fails the suite. `the_whole_body_is_styled_in_the_overlay_and_no_escape_reached_it` is the other end and is paired the way the guideline demands: a renderer that dropped every colour passes the absence, and one that went back to painting strings passes the presence
- **The comments block is still flat, and it is the last piece that is.** `format_comments_with` is a string the board appends after the body rather than part of what `content_parts` lays out, so it was outside e4d0bb7. Its own ticket
### Finding the Board
- **`find_worklane_dir` classifies the entry before it follows it.** `exists()` follows a link, so a `.worklane` that was a dangling symlink answered the same as no `.worklane` at all: the walk carried on up the tree and the first board above the project became the one every write landed in, silently. `classify` reads `symlink_metadata` first and answers one of four, `Absent`, `Board`, `Dangling` or `NotADirectory`, and **`Absent` is the only one the walk carries on from**. A `.worklane` that is there but unusable is this project's board and is reported, not handed upward
@@ -357,6 +371,17 @@ and this file is for what someone changing worklane's own code needs.
- **The tab row is drawn only when there is more than one board**, so a single board is the view it has always been. `frame_rows()` gives it `Length(0)` otherwise, which keeps the row indices the same for both cases and is shared with `card_width` and `column_text_height` for the reason `column_areas` is: geometry reproduced by hand drifts from the draw
- `digest_of` hashes each board's `digest` into one value, so a change in any of them redraws. Do not watch only the first
### Who Wrote an Entry
- **Identity is supplied, not detected.** Every option that needs no cooperation fails: a harness variable such as `CLAUDECODE` names the tool rather than the instance and breaks across versions, walking the parent process is platform specific and also only names the harness, and a terminal check separates interactive from not, which a human piping output is too. So the actor is `WORKLANE_ACTOR`, set once per session, with `--actor` as the per-call override
- **Precedence: flag, then `WORKLANE_ACTOR`, then `get_git_user()`, then `unknown`.** `resolve_actor` is the only caller of `get_git_user` for an entry's author, and every entry the CLI writes goes through it. The two halves are separate pure functions, `session_actor` and `entry_actor`, tested without touching the process environment for the reason `colors_wanted` is split that way
- **The session half is cached in a `OnceLock`, the way `should_use_colors` is:** neither the variable nor the git user can change mid-run, and the fallback costs a `git config` subprocess. `session_actor` takes the git user as a closure so that subprocess is not run when the variable already answered
- An **empty `WORKLANE_ACTOR` counts as unset**, the convention `colors_wanted` follows for `NO_COLOR`, so a wrapper script can clear an inherited one. Whitespace counts the same, since a shell quoting a missing value writes one
- **The actor is free text, checked against nothing**, like the `chown` user: there is no registry of actors, and the same reason `ls --tag` refuses to validate a tag
- **It was `comment --owner`, renamed with no alias.** Owner is the ticket's assignee and has one writer, `chown`; this names the writer of the entry, which is a different field. Pre-1.0, and two names for one thing is what splitting `set` and `chown` avoided. `the_owner_flag_is_gone` pins the refusal, since an alias kept "for now" is what makes the wrong name permanent
- **`add --owner` and `campaign add --owner` still default to the git user, deliberately.** Those write the assignee, and a ticket an agent files is work for the person whose board it is; attributing it to the agent would put its name in the Owner column of everything it reported
- **An entry does not record whether the call had a terminal.** It is the one agent signal that needs no cooperation, so it was worth considering, and it was rejected: it cannot name an actor, a human piping output produces the same value, and once the actor is explicit the extra field answers no question anybody asks
- **Set it in the agent's configuration, not per call.** `env` in `~/.claude/settings.json` reaches every command Claude Code runs. opencode has no equivalent: its config is JSON with no `env` block for the tools it spawns, so it inherits the environment it was started with, which means a wrapper or a shell function around `opencode`. Both are documented in `assets/SKILL.md` rather than assumed
### Shipping the Agent Assets
- The skill is embedded with `include_str!` from `assets/SKILL.md`, not copied by an install script. `cargo install` places binaries and nothing else, so an installed document that is not in the binary is a document that drifts from it
- **`assets/SKILL.md` is the only worklane skill document in this repo, and nothing may reintroduce a second.** There was one: `.opencode/skill/worklane-kanban-skill/SKILL.md`, 223 lines of the same document that nothing shipped and no test checked, and it drifted exactly as far as a copy nobody reads does. Its frontmatter still called the skill `worklane_kanban`, its examples still used short flags the CLI had stopped accepting, and it knew nothing about `relate`, `campaign`, `chown`, `check` or the four-status flow. It was **not** inert while it existed: `opencode debug skill` listed it, so an agent working in this repo saw two worklane skills and could load either. Deleted by b2c5531. A copy under `.opencode/`, in a second assets file, or in the README is the same mistake; the document has one home and `install-skill` is how it travels
@@ -384,11 +409,12 @@ and this file is for what someone changing worklane's own code needs.
- **The wrapper is behind the CLI and nothing guards it.** It has no tool for `relate`, `campaign`, `assign` or `tags`, so an agent holding the tools cannot reach campaigns or relations at all. `every_tool_the_wrapper_exports_is_a_real_subcommand` catches the drift in the direction that breaks at call time, a tool for a command that no longer exists, and deliberately not the reverse: the gap is real, nobody has decided to close it, and a test asserting it would fail on that decision rather than on a mistake
- **Installing it globally reproduces fb3dec6 for the wrapper.** Global tools apply in every project including this one, so once `install-tool` has run, an agent working on worklane uses the installed copy of `assets/TOOL.ts` and not the tree it is editing. Same trap as the `worklane` on `PATH`, second instance
- `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
- **The README command table has the same guard, `every_subcommand_has_a_row_in_the_readme_command_table` in `command.rs`.** The skill and the table are the two places a command is discovered, one by an agent and one by a person, and the skill was the only one under test: `campaign` and `assign` shipped in 0.12.0 and were still absent from the table at 0.20.0, e6e3a1b, along with the `--campaign` flag on the `ls` row. It walks clap's own subcommands, one level of nesting included, against the `|` lines of `README.md`, so a new command fails the suite until the table lists it. `help` is excluded, being clap's. The tag subcommands are named in a `PENDING` list rather than skipped, since f7dd1a1 rewrites that row and emptying the list is part of closing it
### 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
- **`color_text()` is for the CLI's own printing only. Anything reachable from `content_trim` takes the decision as an argument and calls `paint()`**, because the board renders with colour off and an escape sequence in a ratatui paragraph is drawn as literal bytes. `nothing_the_body_renders_asks_the_terminal_for_the_colour_decision` scans this file and fails on a new caller; the allowlist is `ambiguous`, which builds a failed-search message for stderr
- A function that takes an `enabled` flag must use it all the way down. `colorize_bold` honoured its flag on the early return and then asked `should_use_colors()` for the bold run, which made the flag a lie in half the function
- A function that takes an `enabled` flag must use it all the way down. The inline pass honoured its flag on the early return and then asked `should_use_colors()` for the bold run, which made the flag a lie in half the function. The better answer, where it fits, is to take no flag: `ordered_cells` and `metadata_value_cells` return the colour rather than a decision about it
- **A test that asserts an absence has to be paired with one that asserts the presence.** The guard for this, an assert that the detail view holds no escape byte, could not fail: a test binary has no tty, so `should_use_colors()` was false and the leaking branch was never taken. The pair is now `content_trim(.., false)` has no escape and `content_trim(.., true)` still colours, which pins the flag as the only thing that decides
- **The palette is the `Color` enum, not a string.** `Color::ansi()` gives the CLI its SGR sequence and `From<Color> for ratatui::style::Color` gives the TUI its equivalent, so a colour that exists for one renderer and not the other is a compile error. The stringly-typed version needed a test for exactly that, and a missing entry silently produced an empty prefix, which is how `magenta` came to be undefined
- Reset color with `\x1b[0m` after colored text
@@ -405,6 +431,7 @@ and this file is for what someone changing worklane's own code needs.
- 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
- Markdown link → cyan, markers and url kept. Not a new meaning for the colour: the plan numbers, the criterion numbers and the `relates to` mark are already cyan inside a rendered body, and a link is the same kind of thing, a pointer the reader may follow rather than a value. The url is not hidden behind the text the way a renderer would hide it, because `show` prints to a terminal worklane cannot assume will make it clickable, and a link whose target cannot be read is worse than a long line
- 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
- Campaign label → its codename through `tag_color`, bold, marked `~`. The colour is what groups a campaign across the cards that carry it, which is exactly what a tag's colour is for, and one word is one colour in every view because `tag_color` is a pure function of it. The mark and the bold are what tell it from a tag on a row that holds both: the mark is not `#`, or the row would read as a list of tags with a stranger in it, and not `@`, which reads as a person on every board anyone has used. `Codename` in a metadata table takes the colour without the mark, since the field name has already said what it is
- Campaign label with no codename → grey. The label is then the short id, and grey keeps a reserved meaning off a `TAG_COLORS` slot in the one case where it would land on one: red is the uuid's everywhere else, and grey already means what a reader skips, which is what a campaign with no codename has to say for itself
@@ -416,8 +443,9 @@ and this file is for what someone changing worklane's own code needs.
- 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
- Colorization functions (`colorize_ordered`, `colorize_bold`, `content_trim_colored`) handle markdown formatting. `colorize_line` is gone: it was a `pub` alias for `colorize_bold` with one caller, and the only thing it added was asking the terminal
- `show` renders the Metadata section as a two column table via `render_metadata_table`, not line by line. Column width is measured on the raw field names in characters and padding is applied before anything is styled: measuring a coloured string counts its escapes towards its width. `paint()` is `color_text()` with the colour decision passed in, which is what lets a test render both ways in one process
- The body's painters return cells, not strings: `ordered_cells`, `inline_cells`, `metadata_cells`, `metadata_value_cells`, `tag_cells` and `push_heading`. `content_trim_colored` is the CLI entry point and `paint_cells` is the only thing that writes an escape. `colorize_line` is gone: it was a `pub` alias for the bold pass with one caller, and the only thing it added was asking the terminal
- **`inline_cells` walks the line once for both inline markers**, `**bold**` and `[text](url)`, rather than running one pass over the output of the other. A second pass would be scanning text that already holds escape sequences, and `\x1b[36m` carries an opening bracket, so the link scan would take the escape for markup. The source is the only string in which either marker means what it says. It was `colorize_bold` while links lived in a branch of their own in `content_parts`; that branch is gone, which is also what gives the criteria text and the metadata `Other` rows their links, since those already went through this function
- `show` renders the Metadata section as a two column table via `metadata_cells`, not line by line. Column width is measured on the raw field names in characters and the padding goes into a cell of its own, so nothing is ever measured with a colour on it: measuring a painted string counts its escapes towards its width. `paint()` is `color_text()` with the colour decision passed in, which is what lets a test render both ways in one process
- The title is printed once, by `cmd_show`. `content_trim_colored` skips the `# ` heading in the file content
- Rules under headings are measured on the displayed name in characters, never on the raw line or in bytes
- `resolve_ticket()` scans all status directories — it's the single source for ticket lookup by UUID prefix, title, or filename
@@ -444,12 +472,12 @@ and this file is for what someone changing worklane's own code needs.
### Version Bumps
- 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
- **`make patch`, `make minor` and `make major` do the mechanics**, run after the commit is in: each bumps `Cargo.toml` and the `worklane` entry in `Cargo.lock`, appends `, and bump to <version>` to the commit's subject, folds the bump into that commit, and tags it. Bumping by hand is how a version comes to be left untagged, which is what the one action is for. It refuses on a dirty tree, on an already-tagged `HEAD` and on a `HEAD` that is already pushed, since each of those makes the amend lose work, orphan a tag or need a force push
- 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
- Every bump gets a matching annotated tag, `v<version>`, on the bump commit — a bumped version is never left untagged
- Tag locally only; never push a tag unless asked
- `worklane --version` reports the crate version alongside the build sha, so the bump is what makes one release distinguishable from another
Generated
+1 -1
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.26.3"
version = "0.28.0"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.26.3"
version = "0.28.0"
edition = "2024"
[dependencies]
+92
View File
@@ -0,0 +1,92 @@
# Release helpers.
#
# `make patch|minor|major` bumps the version in Cargo.toml and Cargo.lock, folds
# that bump into the last commit, and tags it. Everything is one action so a
# release cannot end up half-done: no version bump left untagged, no tag without
# a bump.
.PHONY: help patch minor major version release install
help:
@echo "make patch bump $(CURRENT) -> next patch, amend into HEAD, tag"
@echo "make minor bump $(CURRENT) -> next minor, amend into HEAD, tag"
@echo "make major bump $(CURRENT) -> next major, amend into HEAD, tag"
@echo "make version print the current version"
@echo "make install cargo install --path . && worklane install-skill"
# Read from the [package] table of Cargo.toml, which is the version the binary
# reports through `--version`, so it is the single source of truth. The name is
# what finds this crate's own entry in Cargo.lock.
PACKAGE = $(shell awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p && /^name *= *"/{print $$2; exit}' Cargo.toml)
CURRENT = $(shell awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p && /^version *= *"/{print $$2; exit}' Cargo.toml)
# 1 appends ", and bump to <version>" to the amended commit's subject; empty
# leaves the message alone.
AMEND_SUBJECT = 1
version:
@echo $(CURRENT)
patch: BUMP = patch
minor: BUMP = minor
major: BUMP = major
patch minor major: release
# A release rewrites the last commit, so refuse anything that would make that
# rewrite lose work or orphan a tag.
release:
@set -e; \
if ! git rev-parse -q --verify HEAD >/dev/null 2>&1; then \
echo "error: no commits yet, so there is no commit to fold a version bump into. Commit first." >&2; \
exit 1; \
fi; \
if [ -n "$$(git status --porcelain)" ]; then \
echo "error: working tree is dirty. Commit or stash first, and decide whether that work belongs in this version:" >&2; \
git status --short >&2; \
exit 1; \
fi; \
if [ -n "$$(git tag --points-at HEAD)" ]; then \
echo "error: HEAD is already tagged $$(git tag --points-at HEAD | paste -sd' '). Amending it would leave that tag on an orphaned commit. Commit something first." >&2; \
exit 1; \
fi; \
if upstream=$$(git rev-parse --abbrev-ref --symbolic-full-name '@{u}' 2>/dev/null) && \
git merge-base --is-ancestor HEAD "$$upstream" 2>/dev/null; then \
echo "error: HEAD is already pushed to $$upstream. Amending it would need a force push. Commit something first." >&2; \
exit 1; \
fi; \
current="$(CURRENT)"; \
if [ -z "$$current" ]; then echo "error: no version found in the [package] table of Cargo.toml" >&2; exit 1; fi; \
new=$$(echo "$$current" | awk -F. -v kind=$(BUMP) '{ \
if (NF != 3) exit 1; \
if (kind == "patch") printf "%d.%d.%d\n", $$1, $$2, $$3 + 1; \
else if (kind == "minor") printf "%d.%d.0\n", $$1, $$2 + 1; \
else printf "%d.0.0\n", $$1 + 1 }'); \
if [ -z "$$new" ]; then echo "error: cannot bump version '$$current': expected major.minor.patch" >&2; exit 1; fi; \
if git rev-parse -q --verify "refs/tags/v$$new" >/dev/null; then \
echo "error: tag v$$new already exists" >&2; exit 1; \
fi; \
awk -v v="$$new" '/^\[package\]/{p=1} /^\[/ && !/^\[package\]/{p=0} p && /^version *= *"/{sub(/"[^"]*"/, "\"" v "\"")} {print}' Cargo.toml > Cargo.toml.bump; \
mv Cargo.toml.bump Cargo.toml; \
git add Cargo.toml; \
if [ -f Cargo.lock ] && git ls-files --error-unmatch Cargo.lock >/dev/null 2>&1; then \
awk -v v="$$new" -v pkg="$(PACKAGE)" '$$0 == "name = \"" pkg "\""{f=1} f && /^version = "/{sub(/"[^"]*"/, "\"" v "\""); f=0} {print}' Cargo.lock > Cargo.lock.bump; \
mv Cargo.lock.bump Cargo.lock; \
git add Cargo.lock; \
fi; \
if [ -n "$(AMEND_SUBJECT)" ]; then \
subject=$$(git log -1 --format=%s | sed -E 's/, and bump to [0-9]+\.[0-9]+\.[0-9]+$$//'); \
body=$$(git log -1 --format=%b); \
if [ -n "$$body" ]; then \
git commit --quiet --amend -m "$$subject, and bump to $$new" -m "$$body"; \
else \
git commit --quiet --amend -m "$$subject, and bump to $$new"; \
fi; \
else \
git commit --quiet --amend --no-edit; \
fi; \
git tag -a "v$$new" -m "v$$new"; \
echo "$$current -> $$new, tagged v$$new on $$(git rev-parse --short HEAD) ($$(git log -1 --format=%s))"
install:
cargo install --path .
worklane install-skill
+29 -3
View File
@@ -17,10 +17,11 @@ Worklane is a local Kanban flow for agentic software development.
| `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 chown --clear <ticket>` returns the field to unset, taking the ticket in the flag since there is no user to give, and not to the git user `add` falls back to |
| `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 comment <ticket> <body>` | Adds a comment to a ticket by UUID or title. The author is `--actor`, or `WORKLANE_ACTOR`, or the git user, in that order |
| `worklane campaign add` | Files a campaign in `.worklane/campaigns/` with `--title`, `--description`, `--codename` and `--owner`. A campaign has no status: its state is derived, open until every member is done. `--codename` is one word to call it by, `v1` or `beaver`, which is what the board draws on every card in it and what every command that takes a campaign will also resolve it by |
| `worklane campaign set <campaign>` | Replaces `--title`, which renames the file keeping the uuid, and `--codename`. At least one required. The only way to change a campaign after it is filed, and the way a campaign filed before codenames existed gets one. Replacing a codename the campaign already has needs `--force`, since that is the word it is referred to by everywhere; setting the one it already has is a no-op either way. No `--description`: replacing prose without an `append` to add a paragraph is half a pair |
| `worklane campaign ls` | Lists the campaigns as their short id, their codename, their title and how many members are done. `--ids` prints one per line as the id, a tab and the title, unstyled, for a script or a completion |
| `worklane campaign set <campaign>` | Replaces `--title`, which renames the file keeping the uuid, `--description` and `--codename`. At least one required. The way a campaign filed before codenames existed gets one, and the way a description filed with a typo in it gets fixed. Replacing a codename the campaign already has needs `--force`, since that is the word it is referred to by everywhere; setting the one it already has is a no-op either way. A description needs no `--force`: it is prose written to be revised. No `--clear` and no `--owner` |
| `worklane campaign append <campaign>` | Adds a paragraph to a campaign's description with `--description`, which is required. The other half of `campaign set --description`, so adding a line to a description does not mean retyping the rest of it. Repeat the flag for more lines within the one paragraph. Its own subcommand rather than the top-level `append`, which resolves a ticket |
| `worklane campaign ls` | Lists the campaigns as their short id, their codename, their title, how many members are done, and the state that count derives: `[open]` until every member is done and `[done]` after. A campaign nothing has been filed against reads `no members` and carries no state, being neither. `--ids` prints one per line as the id, a tab and the title, unstyled and without the counts, which read every ticket on the board, for a script or a completion |
| `worklane campaign show <campaign>` | Shows a campaign and its members grouped by status, done included, since what is finished against what is left is the question a campaign asks |
| `worklane assign <campaign> <ticket>` | Puts a ticket in a campaign, the only command that writes the Campaign field. Campaign first and ticket second, after `chown`. A ticket is in at most one, so assigning one that already belongs somewhere moves it |
| `worklane tags` | Lists the tags the board carries as the tag, a tab and how many tickets carry it, one per line, unstyled and alphabetical. Case sensitive like `ls --tag`, so `bug` and `Bug` list separately and land next to each other. Every status, done included. The one command that answers what tags exist rather than what carries a tag already known |
@@ -28,6 +29,14 @@ Worklane is a local Kanban flow for agentic software development.
| `worklane install-skill [skill]` | Writes the embedded agent skills to `~/.claude/skills/<skill>/SKILL.md`, which Claude Code and opencode both read. Four 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, and `worklane-admin` sets a board up and repairs one, its tag vocabulary and the faults a board can develop. Every document unless one is named. Leaves a modified copy alone unless `--force`; `--print` writes one to stdout instead and needs the name |
| `worklane install-tool` | Writes the embedded opencode tool definitions to `$XDG_CONFIG_HOME/opencode/tool/worklane.ts`, or `~/.config/opencode/tool/` without it, where opencode loads them for every project. One file and so no name to pass. `--force` and `--print` behave as they do for a skill. opencode only: it registers the eleven `worklane_*` tools from the file name and its exports, and Claude Code has no directory it scans for a tool definition, so reaching it would mean an MCP server rather than this. Restart opencode after installing, since it reads its config at startup and never reloads it. Nothing else to install: the file runs inside opencode's own runtime, so neither Bun nor `@opencode-ai/plugin` has to be on the machine |
## Environment
| Variable | Effect |
|----------|--------|
| `WORKLANE_ACTOR` | Who every entry the CLI writes is attributed to: today the author of a comment. Set it once, in the environment an agent runs in, and every call it makes is attributed to it instead of to the git user of whoever's machine it is on. `--actor` overrides it per call, an empty value counts as unset, and with neither supplied the author is the git user and then `unknown`. Free text, checked against nothing |
| `NO_COLOR` | Set and non-empty turns colour off, whatever the value, per no-color.org. Colour is also off when output is not a terminal, and when `TERM` is `dumb` or empty |
| `XDG_CONFIG_HOME` | Where `install-tool` looks for opencode's config root, `$XDG_CONFIG_HOME/opencode`, defaulting to `~/.config`. `install-skill` does not follow it: `~/.claude` is not an XDG path |
## Completions
```sh
@@ -77,3 +86,20 @@ Whether a truncated pipe reports 141 or 0 depends on the size of the output, not
the command. A pipe holds 64 KiB, so a listing that fits lands in the buffer whole
and the writer never learns the reader left, giving 0. Only output past that gets far
enough to be cut off. Either way nothing is printed to stderr.
## Releasing
```sh
make patch # 0.27.1 -> next patch
make minor # 0.27.1 -> next minor
make major # 0.27.1 -> next major
```
Each bumps `Cargo.toml` and `Cargo.lock`, folds that bump into the last commit, and tags it
`v<version>`. One action, so no bump is left untagged and no tag lands without a bump. In this repo
it also appends `, and bump to <version>` to the commit's subject, the way the release commits
before it read.
It refuses to run when the working tree is dirty, when `HEAD` is already tagged, or when `HEAD` is
already pushed. The first asks you to decide whether that work belongs in the version; the other two
mean the amend would orphan a tag or need a force push.
+10 -5
View File
@@ -122,7 +122,7 @@ question asked by tag.
## Annotating a tag
```
worklane tags # every tag carried, with counts
worklane tags # every tag, its count and what it means
worklane tags add kitchen --annotation "..." # declare one, and say what it means
worklane tags set kitchen --annotation "..." # change what it means
```
@@ -132,10 +132,15 @@ annotation under it. It is what a person opens to find out what the board means
and it is what an agent reads before choosing one.
**Declaring a tag tags nothing, and tagging a ticket declares nothing.** The two lists are
separate on purpose: `worklane tags` counts what the tickets carry, `tags.md` records what
separate on purpose: the counts come from what the tickets carry, `tags.md` records what
the board agreed on, and the difference between them is the thing worth looking at. A tag
carried by tickets but never declared is a word somebody invented in a hurry.
`worklane tags` reports both, as the tag, a tab, the count, and a tab and the annotation's
opening line for a tag that is declared. So the two cases worth finding read off the
listing: a tag at a count of zero is declared and nobody has reached for it, and a tag with
no annotation column at all is carried and was never declared.
### What an annotation has to say
The definition is the easy half and does the least work. What stops drift is the boundary
@@ -177,9 +182,9 @@ ones two people quietly disagree about.
not. Each names the other, so the refusal tells you which you wanted.
- A tag cannot contain a comma, because a comma is what separates one tag from the next in
the Tags field. Surrounding spaces are trimmed.
- `worklane tags` counts tickets, so a tag you have declared and never applied does not
appear in it. That is not a fault; it is the file and the board disagreeing, which is
the state that tells you the vocabulary has not landed yet.
- A tag you have declared and never applied lists at a count of zero. That is not a fault;
it is the file and the board disagreeing, which is the state that tells you the
vocabulary has not landed yet.
- Nothing removes a declaration. There is no `tags rm`, so a tag declared in error stays
in the file with whatever its annotation says. Say it is retired in the annotation.
+8 -1
View File
@@ -168,7 +168,8 @@ fields; a goal is a campaign.
worklane campaign ls
worklane campaign show v1
worklane campaign add --title "..." --codename v1 --description "..."
worklane campaign set v1 --title "..." # or --codename, on one already filed
worklane campaign set v1 --title "..." # or --description or --codename, on one already filed
worklane campaign append v1 -d "..." # add a paragraph to the description
worklane assign v1 1b78a24
```
@@ -194,6 +195,12 @@ tui is usable on a narrow terminal" is a campaign. "The tui tickets" is a tag.
- **Do not propose renaming a codename a campaign already has.** It is what the campaign is
called on every card in it and at the command line, so changing it is churn dressed as
grooming. `campaign set` refuses it without `--force` for that reason.
- **A campaign's description is editable, so a wrong one is a fix rather than a refiling.**
A container whose description no longer describes what its members are for is worth
pointing out: it is the line every one of those tickets was filed against. `campaign set
--description` replaces it and `campaign append --description` adds to it, so neither
needs the campaign refiled and its members reassigned. Adding to it is the usual answer;
replacing prose to add a sentence to it is how the rest of it gets lost.
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.
+38 -6
View File
@@ -211,7 +211,8 @@ worklane campaign add --title "First public release" --codename v1 \
worklane campaign ls # every campaign, its codename, how far it has got
worklane campaign ls --ids # id and title, tab separated, like ls --ids
worklane campaign show v1 # its body, then its members by status
worklane campaign set v1 --title "..." # replace the title or the codename
worklane campaign set v1 --title "..." # replace the title, description or codename
worklane campaign append v1 -d "..." # add a paragraph to the description
worklane assign v1 1b78a24 # put a ticket in it
worklane ls --campaign v1 # only that campaign's tickets
```
@@ -226,9 +227,16 @@ existed needs. **Replacing a codename it already has needs `--force`**: that wor
the campaign is referred to on the board and at the command line, so changing it is a
decision rather than a correction. Setting the one it already has is a no-op either way.
`campaign set` is the only way to change a campaign after it is filed, and it reaches the
title and the codename only. There is no way to edit a campaign's description or its owner
yet.
`campaign set` and `campaign append` are the only ways to change a campaign after it is
filed. `set` replaces the title, the description or the codename; `append` adds a paragraph
to the description, which is what to use when the description is right and only incomplete,
since replacing prose to add a sentence to it is how the rest of it gets lost. An empty
`--description ""` between two values is a paragraph break, exactly as it is for a ticket,
and a call whose every value is blank is refused: a campaign's description cannot be
emptied. There is still no way to change a campaign's owner.
`append` here is `campaign append` and not the top-level `append`, which takes a ticket. The
two objects are addressed the same way, so the command is what says which one is meant.
`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
@@ -262,6 +270,27 @@ existing ticket will have been written from a different angle.
- Related but not the same: file it, and record it with `relate <new> --relates-to <old>`
rather than only mentioning the id in prose.
## Who your entries are attributed to
Every comment carries an author, and by default that is the git user of the machine you
are running on, which is the human whose checkout it is and not you. Set
`WORKLANE_ACTOR` in your own environment and it becomes the author of every entry you
write, so a board several agents write to says which of them said what:
```
WORKLANE_ACTOR=claude worklane comment 1b78a24 "The offset was never passed to the widget."
```
Set it once where your session's environment is configured, not on each call: `env` in
`~/.claude/settings.json` for Claude Code, and the environment opencode is started with
for opencode, since it passes its own environment to the tools it runs. `--actor` on
`comment` overrides it for one call, an empty value counts as unset and falls back to the
git user, and with nothing at all the author is `unknown`. It is free text, checked
against nothing: name yourself something a person reading the board will recognise.
If the variable is not set and you cannot set it, pass `--actor` rather than letting the
comment claim to be the user's.
## Shell completions
```
@@ -292,8 +321,8 @@ the candidates and exits 1 rather than guessing.
`--print is supported` is stored, not parsed as a flag. The cost is that a genuinely
mistyped flag there lands as content instead of failing, so read back what you wrote
with `worklane show`.
- `--due`, `--priority`, `--tags`, `--owner` and `--status` do *not* accept one, so a
mistyped flag on those is a usage error and nothing is written.
- `--due`, `--priority`, `--tags`, `--owner`, `--actor` and `--status` do *not* accept one,
so a mistyped flag on those is a usage error and nothing is written.
- A ticket argument that starts with a hyphen needs the flags first and a separator:
`worklane mv --status committed -- -leading-title`.
- A comment body of exactly `--` needs its own separator:
@@ -301,4 +330,7 @@ the candidates and exits 1 rather than guessing.
- An empty value for a scalar is a usage error, not a way to clear the field: use
`--clear`. For a section an empty value is a paragraph break, so it cannot mean empty
the section either, and an all-blank one is refused with the `--clear` for it named.
- **`comment` has no `--owner`.** Owner is the ticket's assignee, which `chown` writes;
the author of a comment is `--actor` or `WORKLANE_ACTOR`. The old spelling is a usage
error, not an alias.
- Piping is safe: `worklane ls | head -3` exits on the closed pipe instead of panicking.
+3 -3
View File
@@ -247,9 +247,9 @@ export const comment = tool({
body: tool.schema
.string()
.describe("Comment body text (required). Supports markdown formatting and multiple paragraphs separated by newlines."),
owner: tool.schema
actor: tool.schema
.string()
.describe("Comment author. If omitted, defaults to the git user.")
.describe("Who the comment is attributed to. If omitted, WORKLANE_ACTOR is used, then the git user, then \"unknown\". Set WORKLANE_ACTOR in the environment opencode is started with rather than passing this on every call.")
.optional(),
},
async execute(args: Record<string, any>, context: ToolContext) {
@@ -261,7 +261,7 @@ export const comment = tool({
}
const cmd: string[] = ["comment", args.ticket, args.body];
if (args.owner) cmd.push("--owner", args.owner);
if (args.actor) cmd.push("--actor", args.actor);
try {
return await run(cmd, context);
+5 -5
View File
@@ -173,22 +173,22 @@ impl CampaignIndex {
/// 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 {
pub fn campaign_cells(content: &str, index: &CampaignIndex) -> Vec<Cell> {
let Some(uuid) = parse_campaign(content) else {
return String::new();
return Vec::new();
};
reference_cell(&uuid, index.get(&uuid).map(|campaign| campaign.title.as_str()), colored)
reference_cells(&uuid, index.get(&uuid).map(|campaign| campaign.title.as_str()))
}
/// 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> {
pub fn resolved_for(content: &str, worklane_dir: &Path) -> Result<Resolved> {
Ok(Resolved {
relations: relations_for(content, worklane_dir)?,
campaign: campaign_cell(content, &CampaignIndex::load(worklane_dir)?, colored),
campaign: campaign_cells(content, &CampaignIndex::load(worklane_dir)?),
})
}
+135 -19
View File
@@ -267,9 +267,13 @@ pub enum Command {
#[arg(allow_hyphen_values = PROSE)]
body: String,
/// Owner
#[arg(short, long)]
owner: Option<String>,
/// Who the comment is attributed to, overriding `WORKLANE_ACTOR` and the git
/// user. Free text, checked against nothing
///
/// Named after the writer of the entry, not after the ticket's assignee, which
/// is `chown`'s. It was `--owner`, which said the wrong one of the two.
#[arg(long)]
actor: Option<String>,
},
/// Group tickets that have to be finished together
@@ -358,10 +362,18 @@ pub enum Command {
/// No `mv`: a campaign has no status to move it to, its state is derived from its
/// members.
///
/// No `append`, and therefore no `set --description`: `set` and `append` are a pair for a
/// prose section, and a way to replace a description with no way to add a paragraph to one
/// is half of it. That pair is its own ticket. `set` here carries the two scalars, which
/// have no append form at all, the same line `append` already draws for a ticket.
/// `set` and `append` arrive together, 32e98ab, because for a prose section they are a
/// pair: a way to replace a description with no way to add a paragraph to one is the half
/// that is easy to reach for and wrong, since replacing a description to add a sentence is
/// how the rest of it gets lost. The two scalars have no append form at all, which is the
/// same line `append` already draws for a ticket.
///
/// **`append` is a campaign's own subcommand and not the top-level `append`.** That one
/// resolves a ticket, and its positional would then name either object: `resolve_in`'s tiers
/// are the same over both directories, so a search can resolve in each and nothing but a
/// flag could say which was meant. It would also make a liar of `resolve_ticket`, which
/// explains a ticket search that names a campaign. Under `campaign` the object is settled by
/// the command, the way it is for `set`, `show` and `ls`.
#[derive(clap::Subcommand)]
pub enum CampaignCommand {
/// File a new campaign
@@ -369,11 +381,19 @@ pub enum CampaignCommand {
/// Replace fields on an existing campaign
///
/// The only way to change a campaign after it is filed. `campaign add --codename` writes
/// the field at creation the way `add --title` does for a ticket; this is what replaces
/// it, so every campaign filed before the field existed can still be given one.
/// The only way to change a campaign's title or codename after it is filed.
/// `campaign add --codename` writes the field at creation the way `add --title` does for
/// a ticket; this is what replaces it, so every campaign filed before the field existed
/// can still be given one.
Set(CampaignSetArgs),
/// Add a paragraph to a campaign's description
///
/// The other half of `campaign set --description`, and the half that keeps what is
/// already written: a description is the sentence a whole campaign's members are filed
/// against, so adding a line to it must not mean retyping it.
Append(CampaignAppendArgs),
/// List campaigns with their member counts
Ls {
/// Print one campaign per line as its id and title, tab separated, for a script
@@ -394,25 +414,30 @@ pub enum CampaignCommand {
},
}
/// What can be replaced on a campaign that is already filed: its title and its codename.
///
/// The two scalars, and deliberately not the description. See [`CampaignCommand`].
/// What can be replaced on a campaign that is already filed: everything it holds but its
/// owner.
///
/// No `--owner`: nothing writes a campaign's Owner today, and giving `set` one would settle
/// by accident whether `chown` grows a campaign or `set` keeps the field, which is the
/// one-field-one-writer question and not this command's to answer.
///
/// No `--clear`: nothing has asked to empty a codename, a wrong one is replaced rather than
/// emptied, and the vocabulary is a real question — `Clearable` is `SetArgs`'s and its
/// variants are a ticket's fields, so reusing it here would put a ticket's enum on a
/// campaign and inventing a second one is a decision worth making on purpose.
/// No `--clear`, which is 32e98ab's decision and not a deferral. A codename is replaced
/// rather than emptied, and a campaign's one prose section has no cleared form worth
/// reaching: emptying the description of a container six tickets are filed against is not a
/// thing anybody has asked for, and the only ways to spell it would be to put [`Clearable`]
/// on a campaign, whose variants are a ticket's fields, or to invent a second enum with one
/// variant in it. So an empty `--description ""` stays a paragraph break here exactly as it
/// is everywhere else, and the refusal for an all-blank value says there is nowhere to go
/// back to rather than naming a flag that does not exist.
///
/// `--force` guards the codename and nothing else. A campaign that already has one is
/// referred to by it: it is on every card in the campaign, it is what resolves it at the
/// command line, and it is very likely in somebody's shell history. Replacing that silently
/// is the same mistake overwriting an edited skill document would be, which is what
/// `install-skill --force` exists for. A title needs no guard, since a campaign always has
/// one and replacing it is the whole point of the flag.
/// one and replacing it is the whole point of the flag. Neither does a description: it is
/// prose written to be revised, the same reason `tags set --annotation` has no guard, and a
/// guard in front of the command's whole purpose is worse than no command.
///
/// The group makes at least one field mandatory, so a bare `worklane campaign set <c>` is a
/// usage error rather than a silent no-op, exactly as it is for [`SetArgs`].
@@ -421,7 +446,7 @@ pub enum CampaignCommand {
clap::ArgGroup::new("campaign_set_fields")
.required(true)
.multiple(true)
.args(["title", "codename"])
.args(["title", "description", "codename"])
))]
pub struct CampaignSetArgs {
/// Campaign UUID, title, filename or codename
@@ -431,6 +456,13 @@ pub struct CampaignSetArgs {
#[arg(short, long, allow_hyphen_values = PROSE, value_parser = non_empty)]
pub title: Option<String>,
/// Replace the description. Repeat the flag for more lines, empty for a paragraph break
///
/// The whole section, so a paragraph added to it is `campaign append --description`
/// rather than the description retyped
#[arg(short, long, allow_hyphen_values = PROSE)]
pub description: Vec<String>,
/// Replace the codename, a single word to call the campaign by
///
/// The same parser `campaign add --codename` takes, so a codename is one thing however
@@ -449,6 +481,25 @@ pub struct CampaignSetArgs {
pub force: bool,
}
/// What can be added to a campaign that is already filed: a paragraph of its description.
///
/// One field, so it is `required` rather than a group of one, which is the longer way to say
/// the same thing and the shape [`TagSetArgs`] already takes. A bare
/// `worklane campaign append <c>` is therefore a usage error rather than a silent no-op.
///
/// No `--title` and no `--codename`, because appending to a scalar has no meaning. That is
/// the line `append` already draws for a ticket, where the title is absent for the same
/// reason.
#[derive(clap::Args)]
pub struct CampaignAppendArgs {
/// Campaign UUID, title, filename or codename
pub campaign: String,
/// Add a paragraph to the description. Repeat the flag for more lines within it
#[arg(short, long, required = true, allow_hyphen_values = PROSE)]
pub description: Vec<String>,
}
/// What a campaign holds: a title, a description and an owner.
///
/// Deliberately narrower than [`AddArgs`]. There are no acceptance criteria, because a
@@ -834,3 +885,68 @@ pub struct CheckArgs {
/// Criterion indexes as shown by `show`, substrings of their text, or `all`. Prompts if omitted
pub criteria: Vec<String>,
}
#[cfg(test)]
mod tests {
use super::*;
use clap::CommandFactory;
/// The command names as the README table would have to spell them: `campaign add`
/// for a nested one, the bare name for a top level one. `help` is clap's own and
/// documents nothing.
fn documented_names() -> Vec<String> {
let cli = Cli::command();
let mut names = Vec::new();
for sub in cli.get_subcommands() {
if sub.get_name() == "help" {
continue;
}
names.push(sub.get_name().to_string());
for nested in sub.get_subcommands() {
if nested.get_name() == "help" {
continue;
}
names.push(format!("{} {}", sub.get_name(), nested.get_name()));
}
}
names
}
/// Every subcommand has a row in the README's command table.
///
/// `campaign` and `assign` went undocumented for two minor versions, e6e3a1b, and
/// the `--campaign` flag went with them, because the only thing walking the table
/// was somebody remembering to. This is what walks it. A command whose row is
/// missing is a command a reader of the README cannot discover at all, which is a
/// worse failure than a row that is merely out of date.
#[test]
fn every_subcommand_has_a_row_in_the_readme_command_table() {
// The tag subcommands are f7dd1a1's, which rewrites the `worklane tags` row
// once the vocabulary work above it has landed. Listed rather than skipped, so
// emptying this is part of closing that ticket rather than something to
// rediscover.
const PENDING: [&str; 3] = ["tags add", "tags set", "tags ls"];
let readme = include_str!("../README.md");
let table: String = readme.lines().filter(|line| line.starts_with('|')).collect();
let missing: Vec<String> = documented_names()
.into_iter()
.filter(|name| !PENDING.contains(&name.as_str()))
.filter(|name| !table.contains(&format!("`worklane {}", name)))
.collect();
assert!(
missing.is_empty(),
"no row in the README command table for {missing:?}. A new command is not \
shipped until the table lists it: that table is the only place a reader \
discovers one, and two commands hid behind an otherwise complete table \
for two minor versions."
);
}
}
+51 -10
View File
@@ -50,11 +50,16 @@ pub const CAMPAIGN_COMMANDS: [&str; 1] = ["assign"];
/// Nested subcommands whose first argument is a campaign, as `parent child`.
///
/// `campaign show` and `campaign set`, and they are why the fish half needs a third
/// position helper: their argument is the *third* token, where `__worklane_first_arg_of`
/// reads the second and `__worklane_second_arg_of` counts a top-level command's arguments.
/// Neither can tell `campaign show <TAB>` from `chown alice <TAB>` by position.
pub const CAMPAIGN_NESTED_COMMANDS: [(&str, &str); 2] = [("campaign", "show"), ("campaign", "set")];
/// `campaign show`, `campaign set` and `campaign append`, and they are why the fish half
/// needs a third position helper: their argument is the *third* token, where
/// `__worklane_first_arg_of` reads the second and `__worklane_second_arg_of` counts a
/// top-level command's arguments. Neither can tell `campaign show <TAB>` from
/// `chown alice <TAB>` by position.
pub const CAMPAIGN_NESTED_COMMANDS: [(&str, &str); 3] = [
("campaign", "show"),
("campaign", "set"),
("campaign", "append"),
];
/// Options whose value is a campaign.
pub const CAMPAIGN_FLAGS: [&str; 1] = ["campaign"];
@@ -192,14 +197,21 @@ complete -c worklane -n '__worklane_command_is ls' {campaign_flags} \
-x -a '(worklane campaign ls --ids)'
# Tags come from `worklane tags` rather than from a listing of objects, since a tag has no
# id. The count after the tab lands as fish's description, which is what makes the list
# worth reading: it says which spelling the board actually uses.
complete -c worklane -n '__worklane_command_is ls' {tag_flags} -x -a '(worklane tags)'
# id. Three fields now, the tag, its count and its annotation, and fish takes everything
# after the *first* tab as one description, so the count is dropped here rather than landing
# in the middle of the prose. `cut` and not `string replace` because the columns are what is
# being picked, and `cut -f1` is how a script reads this listing anyway.
#
# What is left is the annotation, and a tag the board carries but has never declared has
# none: it is offered with no description at all, which is the near-duplicate the file was
# added to catch. The count used to be the description and said the same thing more weakly.
complete -c worklane -n '__worklane_command_is ls' {tag_flags} \
-x -a '(worklane tags | cut -f1,3)'
# And `tags set` names one that is already declared, so it reads the same listing. `tags
# add` has no rule on purpose: it takes a tag the board does not have, so the candidates
# here are the values it refuses.
complete -c worklane -n '{tag_nested}' -a '(worklane tags)'
complete -c worklane -n '{tag_nested}' -a '(worklane tags | cut -f1,3)'
# `chown --clear` names the ticket in the flag too, since with no user to give there is
# no second positional to put it in. Scoped to `chown`, unlike the rule above: `set`
@@ -367,7 +379,10 @@ mod tests {
// A guard on the walker itself: if it stopped finding arguments, every assertion
// above would pass by never running.
assert_eq!(seen, 4, "expected assign, campaign show, campaign set and ls --campaign");
assert_eq!(
seen, 5,
"expected assign, campaign show, campaign set, campaign append and ls --campaign"
);
}
/// Commands whose tag positional names a tag that does not exist yet.
@@ -514,6 +529,32 @@ mod tests {
assert!(script.contains("__worklane_first_arg_of assign"), "{script}");
}
/// Every rule that reads the tag listing drops the count, because `worklane tags` prints
/// three fields and fish takes everything after the first tab as the description. Left
/// whole, a tag would be described as its count, a tab and its annotation.
///
/// Pinned per rule rather than once over the script: a rule added later that reads
/// `worklane tags` raw is the bug this catches, and it would not show up in a single
/// `contains`.
#[test]
fn every_tag_rule_takes_the_annotation_as_its_description() {
let script = fish_dynamic();
let reading: Vec<&str> = script
.lines()
.filter(|line| line.contains("(worklane tags"))
.collect();
assert_eq!(
reading.len(),
2,
"expected the ls --tag rule and the tags set one: {reading:?}"
);
for line in reading {
assert!(line.contains("(worklane tags | cut -f1,3)"), "{line}");
}
}
/// The one status positional and the one shell positional, which clap does not emit
/// possible values for. Read off the enums, so a fifth status would appear here on
/// its own.
+130 -36
View File
@@ -7,8 +7,8 @@ use std::path::Path;
use crate::campaign::*;
use crate::command::{
AddArgs, AppendArgs, CampaignAddArgs, CampaignSetArgs, CheckArgs, ChownArgs, LsArgs,
RelateArgs, SetArgs, TagAddArgs, TagSetArgs,
AddArgs, AppendArgs, CampaignAddArgs, CampaignAppendArgs, CampaignSetArgs, CheckArgs,
ChownArgs, LsArgs, RelateArgs, SetArgs, TagAddArgs, TagSetArgs,
};
use crate::install;
use crate::tag::{TAGS_FILE, TagIndex, tags_path};
@@ -443,7 +443,7 @@ 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 resolved = resolved_for(&content, worklane_dir, should_use_colors())?;
let resolved = resolved_for(&content, worklane_dir)?;
// 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
@@ -725,7 +725,7 @@ pub fn cmd_mv(ticket_id: &str, target: Status, force: bool, start: &Path) -> Res
pub fn cmd_comment(
ticket_id: &str,
body: &str,
owner: &Option<String>,
actor: &Option<String>,
start: &Path,
) -> Result<()> {
if body.is_empty() {
@@ -745,10 +745,7 @@ pub fn cmd_comment(
let stem = Local::now().format(COMMENT_FILE_FORMAT).to_string();
let author = match owner {
Some(o) => o.clone(),
None => get_git_user().unwrap_or_else(|| "unknown".to_string()),
};
let author = resolve_actor(actor.as_deref());
let comment_content = format!(
"**Comment**\n\
@@ -784,6 +781,42 @@ fn section_args<'a>(
]
}
/// The lines a caller's values amount to, or the refusal an all-blank call earns.
///
/// An empty value is a paragraph break, so a call whose values are *every one* blank asked
/// for nothing, and writing an empty section is not what it meant. Shared by `set` and
/// `campaign set` because the rule is the section's rather than the object's.
///
/// `instead` is the way out, and it is the caller's because the callers differ: a ticket's
/// section is emptied with `--clear <field>`, and a campaign's description has no cleared
/// form at all, per [`CampaignSetArgs`].
fn replaced_items(section: &Section, values: &[String], instead: &str) -> Result<Vec<String>> {
let items = section.normalise(values);
if items.is_empty() {
return Err(anyhow!(
"An empty value is a paragraph break, not a way to empty the {}: {}",
section.label,
instead
));
}
Ok(items)
}
/// The same for `append`, which has no way out to name: appending nothing was never a way
/// to empty anything, so the message says only that there was nothing to add.
fn appended_items(section: &Section, values: &[String]) -> Result<Vec<String>> {
let items = section.normalise(values);
if items.is_empty() {
return Err(anyhow!(
"Nothing to append to the {}: every value given was blank",
section.label
));
}
Ok(items)
}
/// Write the ticket back, renaming the file when a new title changes its slug.
///
/// The content goes down first and the rename second, the same order and for the same
@@ -917,14 +950,8 @@ pub fn cmd_set(args: &SetArgs, start: &Path) -> Result<()> {
continue;
}
let items = section.normalise(values);
if items.is_empty() {
return Err(anyhow!(
"An empty value is a paragraph break, not a way to empty the {}: use --clear {}",
section.label,
section.clear.map_or("", Clearable::name)
));
}
let clear = format!("use --clear {}", section.clear.map_or("", Clearable::name));
let items = replaced_items(section, values, &clear)?;
let next = set_section_body(&content, section, &items)?;
apply(&mut content, &mut changed, section.label, next);
@@ -1031,13 +1058,7 @@ pub fn cmd_append(args: &AppendArgs, start: &Path) -> Result<()> {
continue;
}
let items = section.normalise(values);
if items.is_empty() {
return Err(anyhow!(
"Nothing to append to the {}: every value given was blank",
section.label
));
}
let items = appended_items(section, values)?;
content = append_section_body(&content, section, &items)?;
changed.push(section.label);
@@ -1217,27 +1238,52 @@ pub fn cmd_campaign_ls(worklane_dir: &Path, ids: bool) -> Result<()> {
Ok(())
}
/// Every tag on the board, with how many tickets carry it.
/// Every tag on the board: the ones the tickets carry, the ones the file declares, and
/// what each declared one means.
///
/// The vocabulary itself, which nothing else could answer: `ls --tag` filters by a tag
/// already known, and the decorated listing does not print tags at all. A grooming sweep
/// starts by asking what the vocabulary *is*, and `assets/PLAN.md` used to have to say
/// that the question could only be answered by reading the tickets.
///
/// **The union of the two vocabularies, not either one.** Since `tags.md` exists there are
/// two: the tags the file declares and the tags the tickets carry. A declared tag nothing
/// carries lists at zero rather than being dropped, and a carried tag nothing declares
/// still lists. Those two cases are the whole reason to declare tags at all, so this is
/// the command that has to show them apart.
///
/// **Alphabetical, and case sensitive.** `--tag` matches a whole value case sensitively,
/// so `bug` and `Bug` are two tags and listing them as one would hide the reason a filter
/// came back short. Sorting puts them next to each other, which is where a near-duplicate
/// is spotted.
///
/// Machine-readable, the second output in the tree that is: the tag, a tab, the count.
/// Fish reads what follows the tab as a description, a script takes `cut -f1`, and neither
/// wants an escape sequence. Every status, done included, for the reason `ls --ids`
/// includes it: a tag retired months ago is still part of the answer to what the
/// vocabulary has been.
/// Machine-readable, the second output in the tree that is: the tag, a tab, the count, and
/// a tab and the annotation's opening line for a tag the file declares. Fish reads what
/// follows the first tab as a description, a script takes `cut -f1`, and neither wants an
/// escape sequence.
///
/// **A carried but undeclared tag is marked by the absence of the third field**, which is
/// where the shape comes from. Anything appended to the tag itself would have a completion
/// offer a tag that does not exist, and anything added to the count would stop the second
/// field being a number. Absence costs neither, and it buys the one property a marker
/// could not: a board with no `tags.md` has every tag undeclared, so it prints two fields
/// a line, which is byte for byte what this printed before the file existed. The shipped
/// fish completion of an older version is still reading that.
///
/// Every status, done included, for the reason `ls --ids` includes it: a tag retired months
/// ago is still part of the answer to what the vocabulary has been.
pub fn cmd_tags(worklane_dir: &Path) -> Result<()> {
// Through the same `load` `tags add` uses, so a file that is there and cannot be read
// is an error here too. The listing is the one tag command that could go on without the
// file, and reporting a vocabulary while silently treating a broken file as no file is
// the wrong half of the answer.
let index = TagIndex::load(worklane_dir)?;
// BTreeMap rather than a sort afterwards: the order is the point, and the counting
// wants a map anyway.
let mut counts: BTreeMap<String, usize> = BTreeMap::new();
// wants a map anyway. Seeded from the vocabulary rather than merged into afterwards,
// which is what puts a declared tag nothing carries in at zero.
let mut counts: BTreeMap<String, usize> =
index.names().map(|tag| (tag.to_string(), 0)).collect();
for status in status_dirs() {
let status_path = worklane_dir.join(status);
@@ -1253,7 +1299,10 @@ pub fn cmd_tags(worklane_dir: &Path) -> Result<()> {
}
for (tag, count) in counts {
println!("{}\t{}", tag, count);
match index.summary(&tag) {
Some(summary) => println!("{tag}\t{count}\t{summary}"),
None => println!("{tag}\t{count}"),
}
}
Ok(())
@@ -1381,6 +1430,18 @@ pub fn cmd_tag_set(args: &TagSetArgs, start: &Path) -> Result<()> {
/// No-op detection compares the whole file, the way `set` and `chown` do, so setting a
/// codename a campaign already carries writes nothing. That is a no-op and not a refusal:
/// `--force` is about overwriting a *different* word, and there is nothing to overwrite.
///
/// **The description goes through `set_section_body` and the `DESCRIPTION` entry**, the
/// section table `cmd_set` and `campaign_body` already read, so what a campaign's one prose
/// section *is* stays decided in one place. A second definition scoped to campaigns would
/// drift on the spelling of the heading, which is the drift `campaign_body` was written
/// against.
///
/// A campaign whose Description heading is gone is refused by that call rather than given
/// the section back through `ensure_section`. Every campaign the tool has ever filed carries
/// the heading, so an insertion path here would be reachable only from a hand-edited file:
/// that is the opposite of the Relations case, where `add` writes nothing and the insertion
/// is the only path there is.
pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let campaign = resolve_campaign(&args.campaign, &worklane_dir)?;
@@ -1408,6 +1469,16 @@ pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
apply(&mut content, &mut changed, "title", next);
}
if !args.description.is_empty() {
let items = replaced_items(
&DESCRIPTION,
&args.description,
"a campaign's description has no cleared form",
)?;
let next = set_section_body(&content, &DESCRIPTION, &items)?;
apply(&mut content, &mut changed, DESCRIPTION.label, next);
}
if let Some(codename) = &args.codename {
let next = set_or_insert_metadata_field(&content, CODENAME_FIELD, codename, &title)?;
apply(&mut content, &mut changed, "codename", next);
@@ -1425,6 +1496,32 @@ pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
Ok(())
}
/// Add a paragraph to a campaign's description.
///
/// The other half of `campaign set --description`, and `cmd_append` for a campaign: the same
/// `append_section_body` and the same `DESCRIPTION` entry, so a paragraph lands under a
/// campaign's description the way it lands under a ticket's, blank line and all. A campaign
/// filed with no description holds the placeholder, and that is replaced rather than
/// followed, which is `append_section_body`'s rule and not a case handled here.
///
/// No whole-file comparison, unlike `set`: every value blank is refused above, so there is
/// nothing left that appends nothing. `cmd_append` says it the same way.
///
/// One section, so there is no loop and no list to report: what changed is the description
/// or the call failed.
pub fn cmd_campaign_append(args: &CampaignAppendArgs, start: &Path) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let campaign = resolve_campaign(&args.campaign, &worklane_dir)?;
let items = appended_items(&DESCRIPTION, &args.description)?;
let content = append_section_body(&campaign.content, &DESCRIPTION, &items)?;
save_campaign(&worklane_dir, &campaign.uuid, &campaign.title, None, &content)?;
report(&[DESCRIPTION.label], &campaign.title, "Appended to");
Ok(())
}
/// Show a campaign, then its members grouped by status.
///
/// Every status is shown, done included, unlike `ls`, which leaves done out of its
@@ -1766,8 +1863,7 @@ mod tests {
/// will not share a microsecond, but it is the whole point of the guard.
#[test]
fn a_colliding_stem_takes_the_next_name_and_keeps_the_first() {
let dir = std::env::temp_dir().join(format!("worklane-test-{}", uuid::Uuid::new_v4()));
fs::create_dir_all(&dir).unwrap();
let dir = Fixture::new("worklane-test");
let first = write_new_comment(&dir, "20260820_143012_123456", "first").unwrap();
let second = write_new_comment(&dir, "20260820_143012_123456", "second").unwrap();
@@ -1786,7 +1882,5 @@ mod tests {
let mut names = vec![second.clone(), third.clone(), first.clone()];
names.sort();
assert_eq!(names, vec![first, second, third]);
fs::remove_dir_all(&dir).unwrap();
}
}
+8 -3
View File
@@ -63,8 +63,8 @@ fn main() -> Result<()> {
Some(Command::Chown(args)) => cmd_chown(&args, &start),
Some(Command::Check(args)) => cmd_check(&args, true, &start),
Some(Command::Uncheck(args)) => cmd_check(&args, false, &start),
Some(Command::Comment { ticket, body, owner }) => {
cmd_comment(&ticket, &body, &owner, &start)
Some(Command::Comment { ticket, body, actor }) => {
cmd_comment(&ticket, &body, &actor, &start)
}
Some(Command::Campaign { command }) => match command {
CampaignCommand::Add(args) => cmd_campaign_add(&args, &start),
@@ -73,6 +73,7 @@ fn main() -> Result<()> {
cmd_campaign_ls(&worklane_dir, ids)
}
CampaignCommand::Set(args) => cmd_campaign_set(&args, &start),
CampaignCommand::Append(args) => cmd_campaign_append(&args, &start),
CampaignCommand::Show { campaign } => {
let worklane_dir = find_worklane_dir(&start)?;
cmd_campaign_show(&campaign, &worklane_dir)
@@ -247,7 +248,11 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
// The way in to the campaign picker, like `/` is to the search prompt: from
// the next keypress on `picker_key` above has the keyboard. Free of every
// other binding, and `ctrl-c` is matched above this so quitting still wins.
KeyCode::Char('c') => board.open_picker(),
KeyCode::Char('c') => board.open_picker(tui::PickerKind::Campaign, screen),
// The other axis the board is cut along, and the one `ls --tag` has
// answered since 2f3796e. Free of every other binding: `tab` is its own
// key code, not this letter.
KeyCode::Char('t') => board.open_picker(tui::PickerKind::Tag, screen),
_ => {}
}
}
+49
View File
@@ -153,6 +153,55 @@ impl TagIndex {
self.tags.contains_key(tag)
}
/// Every tag the file declares, alphabetical, whatever the board carries.
///
/// The half of the listing the status directories cannot answer. A tag declared and
/// never applied is carried by no ticket, so counting alone drops it, and that tag is
/// most of the reason the file exists: a word the board agreed on and nobody has
/// reached for yet is exactly what a grooming sweep wants to see.
pub fn names(&self) -> impl Iterator<Item = &str> {
self.tags.keys().map(String::as_str)
}
/// What a tag means, whole, or `None` for a tag the file does not declare.
///
/// The raw section, paragraphs and all, where [`Self::summary`] is the one line a
/// listing has room for. `Some("")` is a tag declared with nothing said about it, which
/// the caller has to tell apart from `None`: the board draws the two in different
/// sections.
pub fn annotation(&self, tag: &str) -> Option<&str> {
self.tags.get(tag).map(String::as_str)
}
/// The opening line of what a tag means, or `None` for a tag the file does not declare.
///
/// The cut to one line lives here rather than on the parse, the way
/// [`CampaignRow::summary`] takes one line off a description the read carries whole:
/// the annotation is prose with paragraphs in it, and which view wants how much of it
/// is the view's business.
///
/// **`None` is what marks a carried but undeclared tag**, since `cmd_tags` prints no
/// third field for it. Nothing is appended to the tag itself and nothing is added to
/// the count, so `cut -f1` still yields the tag values and a board with no file at all
/// lists what it listed before the file existed.
///
/// A declared tag with nothing said about it answers [`NO_ANNOTATION`] rather than an
/// empty string, because an empty third field is a trailing tab and nothing else: it
/// would be the only difference between declared and not, and it would be invisible in
/// a terminal and in a completion alike. The placeholder is also what the file itself
/// holds under that heading, so the field stays the section's opening line either way.
///
/// [`CampaignRow::summary`]: crate::tui::CampaignRow::summary
/// [`NO_ANNOTATION`]: crate::tag::NO_ANNOTATION
pub fn summary(&self, tag: &str) -> Option<&str> {
let annotation = self.tags.get(tag)?;
Some(match annotation.lines().next() {
Some(line) => line,
None => NO_ANNOTATION,
})
}
/// Declare `tag`, or replace what it means.
///
/// One writer for both, because the file holds one section per tag either way and the
+1137 -356
View File
File diff suppressed because it is too large Load Diff
+699 -169
View File
File diff suppressed because it is too large Load Diff
+445 -5
View File
@@ -1129,11 +1129,13 @@ fn an_unknown_campaign_is_refused_and_nothing_is_written() {
);
}
/// No `--description`: `set` and `append` are a pair for a prose section, and a way to
/// replace a description with no way to add a paragraph is half of it. Pinned so the
/// omission stays a decision rather than becoming an oversight somebody fills in.
/// `--description` arrived with `campaign append`, 32e98ab, because for a prose section the
/// two are a pair. What is still deliberately absent is what this pins: no `--owner`, which
/// would settle by accident whether `chown` grows a campaign, and no `--clear`, because a
/// campaign's description has no cleared form and `Clearable`'s variants are a ticket's
/// fields.
#[test]
fn campaign_set_offers_no_description_and_no_owner() {
fn campaign_set_offers_no_owner_and_no_clear() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
@@ -1142,7 +1144,7 @@ fn campaign_set_offers_no_description_and_no_owner() {
assert!(help.contains("--codename"), "{help}");
assert!(help.contains("--title"), "{help}");
assert!(!help.contains("--description"), "{help}");
assert!(help.contains("--description"), "{help}");
assert!(!help.contains("--owner"), "{help}");
assert!(!help.contains("--clear"), "{help}");
}
@@ -1263,3 +1265,441 @@ fn the_title_is_replaced_without_force() {
assert!(out.status.success(), "{}", stderr(&out));
assert!(campaign_file(&worklane, CAMP_A).starts_with("# First public release\n"));
}
// ---------------------------------------------- campaign set --description --
/// The point of 32e98ab: the description a campaign was filed with is no longer the one it
/// keeps. `create_campaign` writes prose, so this is a replacement rather than a first line.
#[test]
fn campaign_set_replaces_the_description() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let out = run(
&temp,
&[
"campaign",
"set",
"v1 release",
"--description",
"What the tag has to hold.",
],
);
assert!(out.status.success(), "{}", stderr(&out));
assert!(stdout(&out).contains("Updated description"), "{}", stdout(&out));
let content = campaign_file(&worklane, CAMP_A);
assert!(content.contains("What the tag has to hold."), "{content}");
assert!(
!content.contains("What has to ship together."),
"the old description survived: {content}"
);
}
/// An empty value between two others is the paragraph break, the rule every prose argument
/// in the tool follows: `add --description`, `set --description` and `tags --annotation`.
#[test]
fn an_empty_value_is_a_paragraph_break_in_a_campaigns_description() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let out = run(
&temp,
&[
"campaign",
"set",
"v1 release",
"-d",
"The tag itself.",
"-d",
"",
"-d",
"And what blocks it.",
],
);
assert!(out.status.success(), "{}", stderr(&out));
let content = campaign_file(&worklane, CAMP_A);
assert!(content.contains("The tag itself.\n\nAnd what blocks it."), "{content}");
}
/// And an all-blank value is refused rather than emptying the section. The refusal names no
/// flag, because there is none: a campaign's description has no cleared form, which is the
/// `Clearable` question 32e98ab settled rather than deferred.
#[test]
fn an_all_blank_description_is_refused_and_names_no_clear_flag() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let before = campaign_file(&worklane, CAMP_A);
let out = run(&temp, &["campaign", "set", "v1 release", "-d", "", "-d", " "]);
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
let said = stderr(&out);
assert!(said.contains("An empty value is a paragraph break"), "{said}");
assert!(said.contains("no cleared form"), "{said}");
assert!(!said.contains("--clear"), "it named a flag that does not exist: {said}");
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the file was written");
}
/// The whole-file comparison `set`, `chown` and the codename already use, so a description
/// replaced with the one it already holds writes nothing.
#[test]
fn setting_the_description_a_campaign_already_has_writes_nothing() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let before = campaign_file(&worklane, CAMP_A);
let out = run(
&temp,
&[
"campaign",
"set",
"v1 release",
"-d",
"What has to ship together.",
],
);
assert!(out.status.success(), "{}", stderr(&out));
assert!(stdout(&out).contains("No changes"), "{}", stdout(&out));
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the file was rewritten");
}
/// Three fields in one call, since the group is `multiple` and the description is in it.
#[test]
fn campaign_set_takes_the_title_the_description_and_the_codename_together() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let out = run(
&temp,
&[
"campaign",
"set",
"v1 release",
"-t",
"First public release",
"-d",
"What the tag has to hold.",
"-c",
"v1",
],
);
assert!(out.status.success(), "{}", stderr(&out));
assert!(stdout(&out).contains("title, description, codename"), "{}", stdout(&out));
let content = campaign_file(&worklane, CAMP_A);
assert!(content.starts_with("# First public release\n"), "{content}");
assert!(content.contains("What the tag has to hold."), "{content}");
assert!(content.contains("- **Codename**: v1"), "{content}");
}
/// A refused codename takes the description down with it, the way it already takes the
/// title: checked before any edit is applied, so a call writes all of what it asked for or
/// none of it.
#[test]
fn a_refused_codename_takes_the_description_down_with_it() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
let before = campaign_file(&worklane, CAMP_A);
let out = run(
&temp,
&[
"campaign",
"set",
"v1",
"-d",
"Rewritten anyway.",
"-c",
"beaver",
],
);
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the description went through");
}
// ---------------------------------------------------------- campaign append --
/// The other half of the pair, and the reason `set --description` is not a flag on its own:
/// adding a line to a description must not mean retyping the rest of it.
#[test]
fn campaign_append_adds_a_paragraph_without_replacing_the_description() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let out = run(
&temp,
&[
"campaign",
"append",
"v1 release",
"-d",
"And what is out of scope.",
],
);
assert!(out.status.success(), "{}", stderr(&out));
assert!(stdout(&out).contains("Appended to description"), "{}", stdout(&out));
let content = campaign_file(&worklane, CAMP_A);
// The paragraph lands after the one that was there, with the blank line between them
// that makes it a paragraph rather than a run-on.
assert!(
content.contains("What has to ship together.\n\nAnd what is out of scope.\n"),
"{content}"
);
}
/// Several values in one call are lines *within* the paragraph, not several paragraphs. The
/// same reading `append --description` gives a ticket, since it is the same section entry.
#[test]
fn the_values_of_one_append_are_lines_within_the_paragraph() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(
&temp,
&[
"campaign",
"append",
"v1 release",
"-d",
"Out of scope:",
"-d",
"the installer.",
],
);
let content = campaign_file(&worklane, CAMP_A);
assert!(content.contains("Out of scope:\nthe installer.\n"), "{content}");
}
/// A campaign filed with no description holds the placeholder, and appending replaces it
/// rather than following it: the alternative reads `_No description provided._` above the
/// description. `append_section_body`'s rule, so nothing here handles the case.
#[test]
fn appending_to_an_empty_description_replaces_the_placeholder() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "add", "--title", "No prose yet"]);
let uuid = {
let names = campaigns(&worklane);
let name = names
.iter()
.find(|name| name.ends_with("_no-prose-yet.md"))
.expect("the campaign was not filed");
name.split('_').next().unwrap().to_string()
};
assert!(
campaign_file(&worklane, &uuid).contains("_No description provided._"),
"the placeholder is not what add writes any more"
);
let out = run(
&temp,
&[
"campaign",
"append",
"No prose yet",
"-d",
"The first thing said.",
],
);
assert!(out.status.success(), "{}", stderr(&out));
let content = campaign_file(&worklane, &uuid);
assert!(content.contains("The first thing said."), "{content}");
assert!(
!content.contains("_No description provided._"),
"the placeholder is still above the description: {content}"
);
}
/// Every value blank is refused rather than writing nothing quietly, the answer `append`
/// gives a ticket, in the same words: appending nothing was never a way to empty anything,
/// so there is no flag to name.
#[test]
fn an_all_blank_append_is_refused() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let before = campaign_file(&worklane, CAMP_A);
let out = run(&temp, &["campaign", "append", "v1 release", "-d", " "]);
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
assert!(stderr(&out).contains("Nothing to append"), "{}", stderr(&out));
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the file was written");
}
/// A bare `campaign append <campaign>` is a usage error rather than a silent no-op, the way
/// a bare `campaign set` is. `--description` is `required` rather than a group of one.
#[test]
fn campaign_append_with_no_description_is_a_usage_error() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let before = campaign_file(&worklane, CAMP_A);
let out = run(&temp, &["campaign", "append", "v1 release"]);
assert_eq!(out.status.code(), Some(2), "{}", stderr(&out));
assert_eq!(campaign_file(&worklane, CAMP_A), before, "something was written");
}
/// Appending to a scalar has no meaning, which is the line `append` already draws for a
/// ticket: no `--title` there and none here, and no `--codename` either.
#[test]
fn campaign_append_offers_only_the_description() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
let out = run(&temp, &["campaign", "append", "--help"]);
let help = stdout(&out);
assert!(help.contains("--description"), "{help}");
assert!(!help.contains("--title"), "{help}");
assert!(!help.contains("--codename"), "{help}");
assert!(!help.contains("--force"), "{help}");
}
/// A campaign is addressed here by the same tiers everything else takes, codename included,
/// because it goes through `resolve_campaign` rather than a lookup of its own.
#[test]
fn campaign_append_resolves_the_campaign_by_its_codename() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "set", "v1 release", "-c", "beaver"]);
let out = run(&temp, &["campaign", "append", "beaver", "-d", "One more thing."]);
assert!(out.status.success(), "{}", stderr(&out));
assert!(
campaign_file(&worklane, CAMP_A).contains("One more thing."),
"{}",
campaign_file(&worklane, CAMP_A)
);
}
/// An unknown campaign leaves every campaign alone, the answer `campaign set` and `assign`
/// already give.
#[test]
fn campaign_append_refuses_an_unknown_campaign() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let before = campaign_file(&worklane, CAMP_A);
let out = run(&temp, &["campaign", "append", "nothing-by-that-name", "-d", "Text."]);
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
assert!(stderr(&out).contains("No campaign found"), "{}", stderr(&out));
assert_eq!(campaign_file(&worklane, CAMP_A), before, "something was written");
}
// ------------------------------------------------------ the shared machinery --
/// A campaign has one section where a ticket has four, and the section table in `util.rs` is
/// what both go through. So the surgery has to land against `## Metadata`, which is the only
/// heading that follows a campaign's description, and leave everything outside the body
/// alone: a handwritten section, the owner, and the codename in its place.
#[test]
fn the_description_is_edited_in_place_in_a_file_with_one_section() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
let path = worklane
.join("campaigns")
.join(format!("{}_{}.md", CAMP_A, slug("v1 release")));
let original = fs::read_to_string(&path).unwrap();
fs::write(
&path,
original.replace("## Metadata", "## Notes\nA handwritten note.\n\n## Metadata"),
)
.unwrap();
run(&temp, &["campaign", "set", "v1", "-d", "Replaced."]);
run(&temp, &["campaign", "append", "v1", "-d", "Added."]);
let content = campaign_file(&worklane, CAMP_A);
assert!(content.contains("## Description\nReplaced.\n\nAdded.\n"), "{content}");
// Nothing outside the body moved: the section that follows it, the handwritten one
// between them, and the fields under it.
assert!(content.contains("## Notes\nA handwritten note."), "{content}");
assert!(content.contains("- **Codename**: v1"), "{content}");
assert!(content.contains("- **Owner**: alice"), "{content}");
assert!(!content.contains("**Status**"), "a status was invented: {content}");
// And no section a campaign does not have was inserted to anchor against.
assert!(!content.contains("## Acceptance Criteria"), "{content}");
assert!(!content.contains("## Implementation Plan"), "{content}");
}
/// The heading is the one in the section table, so `campaign set --description` reaches the
/// section `campaign_body` wrote and `campaign show` prints. A second spelling scoped to
/// campaigns is what this would catch.
#[test]
fn the_description_a_campaign_is_filed_with_is_the_one_set_replaces() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(
&temp,
&[
"campaign",
"add",
"--title",
"Filed with prose",
"--description",
"As filed.",
],
);
run(&temp, &["campaign", "set", "Filed with prose", "-d", "As replaced."]);
let out = run(&temp, &["campaign", "show", "Filed with prose"]);
let shown = stdout(&out);
assert!(shown.contains("As replaced."), "{shown}");
assert!(!shown.contains("As filed."), "{shown}");
// One Description heading in the file, not a second one written beside it.
let names = campaigns(&worklane);
let name = names
.iter()
.find(|name| name.ends_with("_filed-with-prose.md"))
.expect("not filed");
let content = fs::read_to_string(worklane.join("campaigns").join(name)).unwrap();
assert_eq!(content.matches("## Description").count(), 1, "{content}");
}
/// A campaign file with no Description heading is refused rather than given one back. Every
/// campaign the tool files carries the heading, so an insertion path here would be reachable
/// only from a hand-edited file, which is the opposite of the Relations case. The message
/// names the section and not the object, because both a ticket and a campaign reach it.
#[test]
fn a_campaign_with_no_description_section_is_refused() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let path = worklane
.join("campaigns")
.join(format!("{}_{}.md", CAMP_A, slug("v1 release")));
let original = fs::read_to_string(&path).unwrap();
fs::write(
&path,
original.replace("## Description\nWhat has to ship together.\n\n", ""),
)
.unwrap();
let before = fs::read_to_string(&path).unwrap();
for args in [
["campaign", "set", "v1 release", "-d", "Text."],
["campaign", "append", "v1 release", "-d", "Text."],
] {
let out = run(&temp, &args);
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
let said = stderr(&out);
assert!(said.contains("no description section"), "{said}");
assert!(!said.contains("Ticket"), "a campaign was called a ticket: {said}");
assert_eq!(fs::read_to_string(&path).unwrap(), before, "the file was written");
}
}
+132 -12
View File
@@ -41,6 +41,24 @@ fn create_ticket(worklane_dir: &Path, status: &str, title: &str) -> String {
uuid
}
/// The one comment on a ticket, which every author test writes exactly one of.
fn only_comment(worklane_dir: &Path, uuid: &str) -> String {
let files: Vec<_> = fs::read_dir(worklane_dir.join("comments").join(uuid))
.unwrap()
.filter_map(|e| e.ok())
.collect();
assert_eq!(files.len(), 1, "expected one comment");
fs::read_to_string(files[0].path()).unwrap()
}
/// A git config file holding nothing but a `user.name`, for the tests that need the
/// fallback to answer something known instead of whatever the machine is configured with.
fn git_config_naming(temp: &TempDir, name: &str) -> PathBuf {
let path = temp.path().join("gitconfig");
fs::write(&path, format!("[user]\n\tname = {}\n", name)).unwrap();
path
}
#[test]
fn comment_creates_file_with_valid_ticket_uuid() {
let temp = TempDir::new().unwrap();
@@ -162,32 +180,134 @@ fn comment_creates_comments_directory() {
}
#[test]
fn comment_uses_owner_flag_when_provided() {
fn comment_uses_actor_flag_when_provided() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = create_ticket(&worklane, "backlog", "Owner Test");
let uuid = create_ticket(&worklane, "backlog", "Actor Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Test comment with owner"])
.arg("-o")
.arg("TestUser")
.args([&uuid, "Test comment with actor"])
.args(["--actor", "TestUser"])
.assert()
.success();
let comments_dir = worklane.join("comments").join(&uuid);
let files: Vec<_> = fs::read_dir(&comments_dir)
assert!(only_comment(&worklane, &uuid).contains("**Author**: TestUser"));
}
/// The flag it was, which named the ticket's assignee and not the writer of the entry.
/// Renamed without an alias, so the old spelling is a usage error rather than something
/// that half works.
#[test]
fn the_owner_flag_is_gone() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = create_ticket(&worklane, "backlog", "Gone Test");
for flag in ["--owner", "-o"] {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(temp.path())
.arg("comment")
.args([&uuid, "A body"])
.args([flag, "TestUser"])
.assert()
.failure();
}
assert!(
!worklane.join("comments").join(&uuid).exists(),
"a comment was written despite the usage error"
);
}
/// The variable is the case an agent runs in: set once by its configuration and
/// inherited by every call, where a flag can be forgotten on the fortieth one.
#[test]
fn comment_takes_the_author_from_the_actor_variable() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = create_ticket(&worklane, "backlog", "Variable Test");
Command::cargo_bin(BIN_NAME)
.unwrap()
.filter_map(|e| e.ok())
.collect();
let content = fs::read_to_string(files[0].path()).unwrap();
assert!(content.contains("**Author**: TestUser"));
.current_dir(temp.path())
.env("WORKLANE_ACTOR", "claude")
.arg("comment")
.args([&uuid, "Written by an agent"])
.assert()
.success();
assert!(only_comment(&worklane, &uuid).contains("**Author**: claude"));
}
#[test]
fn comment_falls_back_to_git_user_when_owner_omitted() {
fn the_actor_flag_overrides_the_variable() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = create_ticket(&worklane, "backlog", "Override Test");
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(temp.path())
.env("WORKLANE_ACTOR", "claude")
.arg("comment")
.args([&uuid, "Written by the other one"])
.args(["--actor", "opencode"])
.assert()
.success();
assert!(only_comment(&worklane, &uuid).contains("**Author**: opencode"));
}
/// An empty variable counts as unset, the convention `NO_COLOR` follows, so a wrapper
/// script can clear an inherited one and get the git user back.
#[test]
fn an_empty_actor_variable_falls_through_to_the_git_user() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = create_ticket(&worklane, "backlog", "Empty Variable Test");
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(temp.path())
.env("WORKLANE_ACTOR", "")
.env("GIT_CONFIG_GLOBAL", git_config_naming(&temp, "Configured User"))
.env("GIT_CONFIG_NOSYSTEM", "1")
.arg("comment")
.args([&uuid, "Written by a person"])
.assert()
.success();
assert!(only_comment(&worklane, &uuid).contains("**Author**: Configured User"));
}
/// The last resort. Reached with a git that has no `user.name`, which is why the config
/// files are redirected: the machine running the suite has one.
#[test]
fn the_author_is_unknown_when_nothing_names_one() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = create_ticket(&worklane, "backlog", "Unknown Test");
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(temp.path())
.env_remove("WORKLANE_ACTOR")
.env("GIT_CONFIG_GLOBAL", temp.path().join("no-such-gitconfig"))
.env("GIT_CONFIG_NOSYSTEM", "1")
.arg("comment")
.args([&uuid, "Written by nobody in particular"])
.assert()
.success();
assert!(only_comment(&worklane, &uuid).contains("**Author**: unknown"));
}
#[test]
fn comment_falls_back_to_git_user_when_actor_omitted() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
+109 -11
View File
@@ -5,10 +5,11 @@
//! under test are the ones that question needs: every status counted, case kept apart,
//! alphabetical order, and an output a shell can parse.
//!
//! `tags add` is the other half of the same question. The listing reports the vocabulary
//! the tickets *carry*; the file reports the one the board *intends*, and the tests below
//! are mostly about the two being allowed to disagree without either one damaging the
//! other.
//! `tags add` is the other half of the same question. The file reports the vocabulary the
//! board *intends* and the tickets carry the one it *has*, and the tests below are mostly
//! about the two being allowed to disagree without either one damaging the other. The
//! listing reports both and marks which is which, so the tests for the output shape are
//! about the marking: which field it lands in, and what a board with no file still prints.
use assert_cmd::Command;
use assert_fs::TempDir;
@@ -380,19 +381,113 @@ fn a_vocabulary_that_cannot_be_read_is_refused_rather_than_replaced() {
assert!(stray.is_empty(), "a temp file was left in .worklane");
}
/// The vocabulary does not touch the listing, which counts tickets. The two disagreeing is
/// the normal state and the thing the file is for.
/// The listing is the union of the two vocabularies, and the two disagreeing is the normal
/// state rather than a fault: a declaration tags no ticket, and tagging a ticket declares
/// nothing.
///
/// Both halves of the disagreement in one assertion, since neither is legible without the
/// other. `chore` is declared and carried by nothing, so it lists at zero with what it
/// means; `bug` is carried and declared by nothing, so it lists with a count and no third
/// field at all.
#[test]
fn a_declared_tag_is_not_a_carried_one() {
fn the_listing_is_the_union_of_the_declared_and_the_carried() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "bug");
run(&temp, &["tags", "add", "chore", "-a", "Housekeeping."]);
// `chore` is declared and carried by nothing, `bug` is carried and declared by nothing,
// and the listing still answers only the second question. Reporting both is 9564ac9.
assert_eq!(tags(&temp), vec!["bug\t1"]);
assert_eq!(tags(&temp), vec!["bug\t1", "chore\t0\tHousekeeping."]);
}
/// The third field is the annotation's *opening* line. An annotation is prose with
/// paragraphs in it, and a second line in this output would be read as a second tag.
#[test]
fn the_annotation_is_cut_to_its_opening_line() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
run(
&temp,
&[
"tags",
"add",
"bug",
"-a",
"What it is.",
"-a",
"",
"-a",
"When to use it.",
],
);
assert_eq!(tags(&temp), vec!["bug\t0\tWhat it is."]);
}
/// A tag declared with nothing said about it still carries a third field, and it is the
/// placeholder the file itself holds under that heading.
///
/// The subtle case, and the reason the field is not simply left empty: an empty third field
/// is a trailing tab, so the only difference between a declared tag and an undeclared one
/// would be invisible in a terminal and in a completion alike.
#[test]
fn a_tag_declared_without_an_annotation_is_still_marked_as_declared() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "carried");
run(&temp, &["tags", "add", "declared"]);
assert_eq!(tags(&temp), vec!["carried\t1", "declared\t0\t_No annotation provided._"]);
}
/// `cut -f1` over the listing yields exactly the tag values, undeclared ones included.
///
/// The constraint the whole output shape is built around: whatever marks a carried but
/// undeclared tag must stay out of the first field, or a completion offers a tag that does
/// not exist and `ls --tag` comes back empty for it.
#[test]
fn the_first_field_is_the_bare_tag_whether_it_is_declared_or_not() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "carried,both");
run(&temp, &["tags", "add", "both", "-a", "Carried and declared."]);
run(&temp, &["tags", "add", "declared", "-a", "Declared only."]);
let first: Vec<String> = tags(&temp)
.iter()
.map(|line| line.split('\t').next().unwrap().to_string())
.collect();
assert_eq!(first, vec!["both", "carried", "declared"]);
// And each of them is a value `--tag` can match, which is what the first field is for.
for tag in ["both", "carried"] {
let out = run(&temp, &["ls", "--tag", tag, "--ids"]);
assert_eq!(
String::from_utf8_lossy(&out.stdout).lines().count(),
1,
"--tag {tag} matched nothing"
);
}
}
/// A board with no vocabulary lists what it listed before the file existed, byte for byte.
///
/// Every tag on such a board is carried and undeclared, so the absence of the third field
/// is what keeps the old output shape: a marker in it would have changed every line of
/// every board that predates the file, and the shipped fish completion of an older version
/// is still reading this.
#[test]
fn a_board_with_no_vocabulary_lists_what_it_listed_before_the_file_existed() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "bug, cli");
create_ticket(&worklane, "done", "22222222", "bug");
assert!(!temp.path().join(".worklane").join("tags.md").exists());
let out = run(&temp, &["tags"]);
assert_eq!(String::from_utf8_lossy(&out.stdout), "bug\t2\ncli\t1\n");
}
/// The bare form is the listing, byte for byte, because the shipped fish completion calls it
@@ -409,7 +504,10 @@ fn the_bare_form_and_ls_are_the_same_listing() {
assert!(bare.status.success());
assert_eq!(bare.stdout, group.stdout);
assert_eq!(String::from_utf8_lossy(&bare.stdout), "bug\t1\ncli\t1\n");
assert_eq!(
String::from_utf8_lossy(&bare.stdout),
"bug\t1\nchore\t0\t_No annotation provided._\ncli\t1\n"
);
}
// -------------------------------------------------- changing what a tag means --