Compare commits

...
27 Commits
Author SHA1 Message Date
Ansho ReiandClaude Opus 5 e6fe51e31e (996afd7) Monitor several boards in the tui as tabs, and bump to 0.9.0
`worklane tui` takes any number of paths, each resolved to the first `.worklane`
at or above it the way the working directory always was. With more than one board
there is a tab per project plus an `all` tab merging them, and `tab`/`shift+tab`
between them.

The selection moves onto `Tab`: sharing one column and card index across projects
would point it at whatever unrelated ticket sat in the same place. The merge is
sorted through `by_priority_then_title`, now exported, rather than concatenated,
so its order does not depend on the order of the arguments. On the merge a card
and the overlay border name the project after the id, since across boards seven
characters of uuid are not an address.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 17:25:21 +02:00
Ansho ReiandClaude Opus 5 c606b5ba43 (4edc7fa) Lay the tui card out as corners, with a due date and a criteria count, and bump to 0.8.5
A card was three left-aligned rows: mark and id, one row of title, then owner
and due as prose. The title got one row, so worklane's own titles, routinely
longer than a quarter of a terminal, were cut mid-word with nothing to say so.
The due sat at the end of the bottom row where nothing drew the eye to it, and
nothing showed how far along a ticket was.

    ●◐ (1b78a24)        2026-12-31
    The tui detail view cannot
    scroll, and the footer says…
    Ansho Rei                [3/9]

The title takes one row or two, wrapped on spaces, ellipsis when even two are
not enough, one row when one is enough. A card's height therefore depends on the
column's width, so `card_lines` and `card_height` take it, and `column_areas` is
now shared between the draw and `follow_selection`: `Ratio` hands its remainder
column to whichever slot it likes, and reproducing that arithmetic by hand is
how a measurement and a draw come to disagree about where a card starts.

A corner that will not fit is dropped whole rather than truncated or moved to a
row of its own. Half a date reads as a different date, and a card that reflows
in a narrow column changes height, which the scroll would then have to chase.
The left corner is the ticket's identity and always stays. Checked by eye at
120, 76 and 52 columns; at 52 the due goes and the count still fits.

The criteria count is a field on `TicketItem`, filled in `collect_ticket_items`
where the file is already being read, so a rescan pays for it once rather than
every draw re-reading every ticket body. Counted through `criteria()`, so a
checkbox in a description is neither counted here nor numbered by `show`, and
`None` rather than `[0/0]` when a ticket has none.

`due_date` cuts a due value back to its date only when it has one. The field is
not validated, see daa0e79, so it holds whatever was typed; taking the first
word regardless would turn "next friday" into "next". A set due is now the
timestamp colour per the colour guideline, which is what makes the corner worth
looking at, and an unset one stays grey like everywhere else.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 16:56:38 +02:00
Ansho ReiandClaude Opus 5 90b313952b (6d327df) Stop colour escapes leaking into the board's detail view, and bump to 0.8.4
The detail view renders with colour off, because ratatui draws styled spans and
an escape sequence inside a paragraph is not one. `detail_of` asks for that with
`content_trim(&content, false)`. Two paths ignored the argument and asked the
terminal instead.

`colorize_ordered` took no colour parameter at all and called `color_text`,
which is `paint(.., should_use_colors())`, and `content_trim` routes every
Implementation Plan line through it. In the TUI stdout is a terminal, so each
numbered step arrived as ESC[36m, the number, ESC[0m, then the text: exactly the
gap between the number and the step text where the reported artifact showed.
`colorize_line` did the same for a hand-written line inside a Metadata section,
and `colorize_bold` honoured its `enabled` flag on the early return and then
asked `should_use_colors()` again for the bold run, which made the flag a lie in
half the function.

`colorize_ordered` now takes the decision and is private, `content_trim` being
its only caller. `colorize_line` is deleted rather than given the argument: it
was a `pub` alias for `colorize_bold` with one caller, and asking the terminal
was the only thing it added, so `render_metadata_table` calls `colorize_bold`
with the decision it already holds.

Why this shipped, and the reason for the shape of the tests. The guard was an
assert that the detail view holds no escape byte, and it could not fail: a test
binary has no tty, so `should_use_colors()` was false and the leaking branch was
never taken. An absence is now asserted alongside a presence, `content_trim(..,
false)` carries no escape and `content_trim(.., true)` still colours, which pins
the flag as the only thing that decides. A third test scans this file for
`color_text` callers and fails on a new one; it also corrected the assumption
this commit started from, since the remaining caller is `ambiguous` and not
`display_ticket_items`.

The visible symptom is a terminal artifact that no test here can see, since
TestBackend applies cell updates and parses no escapes. What is proven is that
the escapes are gone, and that the CLI still paints its plan numbers cyan in a
pty, which is the condition the leak needed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 16:48:01 +02:00
Ansho ReiandClaude Opus 5 7240fc263b Record the overlay title decisions, and bump to 0.8.3
The bump for 0721739, which landed in the commit before this one. The board
section of AGENTS.md gains the two facts the next change to the modal needs:
the name travels beside the text in `Detail` rather than inside it, since
anything in the paragraph scrolls away and `content_trim` drops the heading on
purpose; and `detail_title` cuts the string itself because ratatui truncates a
block title at whatever cell it reaches and would take the id with it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 16:42:53 +02:00
Ansho ReiandClaude Opus 5 580e3cf7f0 (0721739) Show the ticket id and title on the detail overlay's border
The modal named nothing. It showed a description, criteria and a metadata table
belonging to a ticket whose title is nowhere in the text, because content_trim
drops the `# ` heading on purpose: `cmd_show` prints it. The card behind the
overlay carries it, but the overlay covers most of the board, and the seven
characters of id in the metadata table were the only thing identifying what was
open.

The id and the name now sit on the block title, `(1111111) · First one`. The id
goes first because that is how every other view addresses a ticket, and both sit
on the border rather than at the head of the paragraph, so reading to the end of
a long ticket cannot carry them off the screen.

The string is cut here rather than left to the renderer, which truncates an
overlong block title at whatever cell it reaches and would take the id with it.
Cut against the inner width, the id survives whole and the name ends in an
ellipsis where it was trimmed.

`Board::detail` is now a `Detail` carrying the title, the id and the text, since
the title has to travel beside the body rather than inside it.

Written in an opencode session, lost from the working tree to a `git checkout
src/tui.rs` that Claude ran to drop a scratch test, and recovered from the
opencode snapshot store. The diff is unchanged from what was written, bar one
rebase conflict where both sides had added a test helper in the same place.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 16:41:26 +02:00
Ansho ReiandClaude Opus 5 2298d3373a (8528c50) Hide the done column in the tui until d asks for it, and bump to 0.8.2
Done only grows. It already holds more tickets than the other three columns
together, so a quarter of the width was going to the column least often read
while the ones being worked got squeezed for it.

Not a new opinion: `ls` already counts done in its summary and leaves it out of
the listing below. The board now does the same, and the footer carries the
count while the column is hidden, which is the board's version of that summary
line. It reads `d show done (17)` while hidden and `d hide done` while shown,
so the count only appears where a column heading is not already carrying it.
The modal footer names the key too, since it works with a ticket open.

Hiding is a change to what is drawn, never to what is read. `reload` still
scans the done directory and `digest` still watches it, so the count is right
and revealing the column needs no rescan.

`visible()` returns a prefix of the columns rather than a filter, which is what
keeps `column` and `offsets` valid as indices into either. It is derived from
where DONE actually sits rather than assuming the last slot, and a test pins
done as last: a status inserted after it would otherwise hide two columns in
silence. DONE is now a constant, since `ls` and the board are two readers of
the same rule.

Hiding the column under the selection moves the selection to the last drawn
column and closes an open detail view. Refreshing the modal onto whichever
ticket the selection landed on was the alternative, and it swaps what someone
is reading without saying so, which is how a person acts on the wrong ticket.
Showing done again is a no-op for the selection, since a column is appended
rather than inserted.

Three existing tests asserted a column heading with `screen.contains("done
(0)")` over the whole render, and the new footer holds that string whether the
column is drawn or not, so all three passed for the wrong reason the moment
done was hidden. They now assert against the top border row through a
`headings()` helper, with `footer()` beside it.

The choice is not remembered between runs: worklane has no config file, and one
flag is not a reason to start one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 16:30:06 +02:00
Ansho ReiandClaude Opus 5 8013c2b74d (d8e78cd) Clear the clippy warnings, and bump to 0.8.1
`cargo clippy --all-targets` was reporting 96 warnings, 14 of them in the
binary. It is now clean from a cold cache, and the 211 tests still pass.

`clippy --fix` took the mechanical ones: needless borrows, `map_or` that is
`is_some_and`, `push_str` of a single character, manual `split_once`, and
`&PathBuf` parameters in the test fixtures. It also moved the `handlers.rs`
test module to the end of the file, which is what `items_after_test_module`
was pointing at.

Three by hand. `cmd_add` took nine parameters threaded from `main`, and now
takes `AddArgs`, which is how `set`, `append` and `check` already pass theirs;
the handler destructures it so the body reads as before, and `add --help` is
unchanged. The collapsed `if` in `content_trim` needed reindenting, since
`--fix` left its body at the old depth. And the two `split_once` rewrites read
as `.split_once(..).map(|(_, value)| value)` rather than clippy's `.map(|x|
x.1)`.

The two eight-argument `create_ticket` test fixtures keep an
`allow(too_many_arguments)` carrying the reason: the lint is right that
twenty-five positional call sites read as a wall of strings, but replacing them
with a named-field struct is a refactor and not a warning sweep. a34a316 tracks
it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 15:37:11 +02:00
Ansho ReiandClaude Opus 5 6178d7bd3d (dd36e97) Add install-skill, shipping the agent skill in the binary, and bump to 0.8.0
worklane's agent instructions only existed for someone with the repo checked
out. Anyone who installed the binary with cargo install got no document at
all, because cargo install places binaries and nothing else.

The skill now lives at assets/SKILL.md and is embedded with include_str, so an
installed copy can never be a different version from the binary that describes
it. `worklane install-skill` writes it, `--print` sends it to stdout so a
modified copy can be diffed, and a copy that was edited is reported and left
alone unless --force: it may have been changed on purpose, and silently
discarding that is worse than stopping.

One path serves both agents, ~/.claude/skills/worklane/SKILL.md. That was
settled empirically rather than from documentation: opencode 1.15.10 loads
~/.claude/skills as an external skill source alongside its own
~/.config/opencode/skill, and with HOME pointed at a temp directory holding
only what install-skill wrote, `opencode debug skill` lists the document under
the name worklane. Writing opencode's own path as well would be two copies of
one document, free to drift, for no gain.

The document is new rather than the one under .opencode, which is the user's
and not this repo's to ship. The ticket-workflow prose moved out of AGENTS.md
into it, so how to use worklane has one writer, and AGENTS.md points there.

The mechanism is in install.rs rather than skill.rs, and install() takes its
root as an argument: install-tool is coming, it needs a different root and the
same compare-and-refuse logic, and passing the root is what lets the tests
install into a temp directory instead of the home of whoever runs the suite.

Three tests guard the document itself, which is the part that goes stale
quietly: the frontmatter has to parse, every `worklane <x>` it shows has to be
a real subcommand, and every subcommand outside NOT_FOR_AGENTS has to appear in
it, so a new command cannot ship invisible to an agent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 15:25:31 +02:00
Ansho Rei f740e42d1c Improvements to AGENTS.md file 2026-08-21 15:00:00 +02:00
Ansho Rei 220789efea (6b8f4d13) Scroll the tui board columns with the selection, and bump to 0.7.2 2026-08-21 14:24:19 +02:00
Ansho ReiandClaude Opus 5 c1137f29cf (1b78a24) Scroll the tui detail view on pgup and pgdn, and bump to 0.7.1
The detail view had no scrolling at all: no offset on Board, nothing passed
to Paragraph::scroll, so anything past the height of the overlay was
unreachable. Every ticket in this repo is longer than that. The footer read
"↑↓ scroll" while up and down moved the selection, so it named a key that did
nothing and sent the reader looking for their own mistake.

The scroll goes on pgup and pgdn rather than taking up and down. Up and down
stay on the selection with the modal open, so a whole column can be read
without closing it and the modal follows the selection. That is worth more
than the two keys.

The offset is clamped against the wrapped line count from
Paragraph::line_count, which is why ratatui now carries the
unstable-rendered-line-info feature. The paragraph wraps on words, so a clamp
on the raw lines would stop short of the end or run past it into blank space,
and counting the wrapping by hand would only agree with the widget until one
of the two changed. The clamp runs on the keypress and again in the draw,
since the terminal can be resized between them and a tick can shorten the
ticket under a reader who is already at the end.

The offset resets when the selection moves and when the modal is closed, so a
ticket opens at its top. It deliberately does not reset on a tick: an edit
elsewhere in the tree must not throw the reader back to the top of what they
are reading.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 12:38:54 +02:00
Ansho ReiandClaude Opus 5 77bf2d9e2a Say when to move a ticket, not just how
Both AGENTS.md and the kanban skill listed the statuses and the mv command
without ever saying at what point to run it, so a ticket could sit in backlog
until the work was finished and the board said nothing while it was in progress.
That is what happened to f6af387.

The rule is now in both places, and in both for a reason: the skill is what an
agent loads to work tickets in any repo, and AGENTS.md is what an agent working
on worklane itself reads, possibly without ever loading the skill. The skill's
Workflow section also becomes a sequence for working one ticket rather than an
unordered list of commands, with the command list kept separately.

Worth stating because it is self-enforcing: only one stage forward is allowed at
a time, so a ticket left in backlog cannot go straight to reviewing and has to
be walked through committed regardless. Moving it up front is the same two
commands in a more useful order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 11:54:23 +02:00
Ansho ReiandClaude Opus 5 78831f1a39 (f6af387) Add the board view, and bump to 0.7.0
worklane was one-shot commands only, so reading the board meant running ls again
and again and nothing ever showed the four statuses side by side, which is the
one view a kanban flow is for.

Four columns, a card per ticket carrying the priority mark, short id, title,
owner and due. Arrows or hjkl to move, enter for the detail view, q to quit.
Read only: moving a card by keypress is a follow-up, kept out until the watch
and render loop were solid.

Modelled on frig throughout, same crates and same shape: event poll on a 250ms
timeout so the tick runs when nobody is typing, a panic hook that leaves the
alternate screen before the backtrace, and the terminal restored on the error
path as well as on quit. A bare worklane opens it, as a bare frig does, so
Cli::command is now an Option.

The watch looks at files, not directories. A directory's mtime only moves on
create and rename, so a ticket edited in place would be missed; the digest
hashes every ticket and comment file's path, length and mtime. Comment files
are in it because a comment added elsewhere has to reach the detail view. It
guards the rescan rather than the draw, since ratatui diffs its buffer but
reading the tree every frame would not be free. notify is deliberately not a
dependency, and the reason is on the ticket.

Two orderings are deliberate. The worklane directory is looked for before the
terminal, so running outside one gives the usual message rather than a complaint
about the tty, and both errors stay testable without a pty. And a missing tty is
refused by name, since raw mode on a pipe fails with a bare "No such device or
address" that explains nothing.

The palette is now a Color enum rather than a string, so the escape the CLI
writes and the ratatui colour the board draws come from one definition and a
colour missing from either is a compile error. That retires the test which
existed only to catch a name with no entry, the failure that once left magenta
undefined.

Cards come from collect_ticket_items, so there is no second parser;
TicketItem gained the path the detail view opens. content_trim and
format_comments_with take the colour decision, because ratatui draws spans and
would print an escape as literal bytes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 11:44:37 +02:00
Ansho ReiandClaude Opus 5 bbb1568a0f (eadaca9) Add check and uncheck for one acceptance criterion, and bump to 0.6.0
Criteria are stored as - [ ] lines and nothing could tick one, so marking
progress meant replacing the whole list through set, losing the state of every
other item.

check and uncheck are separate commands rather than one verb with a flag,
sharing CheckArgs and cmd_check. The criterion is an index first and a substring
second, so a criterion whose text is literally "2" is reachable only by
substring. A number out of range is reported as a bad index rather than as a
substring that missed.

Only the character between the brackets is spliced, so the text keeps whatever
indentation and spacing it had. Criteria are counted inside the Acceptance
Criteria section only, so a checkbox written into a description is not a
criterion and a handwritten line in the section takes no number.

With the criterion omitted, the criteria are listed and the number asked for
when stdin is a terminal. Where it is not, the same list comes back as an error
instead. Prompting regardless would leave the opencode wrapper blocked on a
stdin that never closes, and that is the choice resolve_ticket already makes for
an ambiguous match, for the same reason: the wrapper keeps stderr and throws on
the code, so a list printed to stdout would be discarded.

Any listing of a subset keeps the real numbers. Renumbering the matches from one
would contradict the advice to use the number and point at the wrong criterion.

show now numbers the criteria as "1. [x] text", so the index is visible where
the ticket is read. That also drops a manual prefix strip, so clippy is one
warning below where it started.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 10:46:07 +02:00
Ansho ReiandClaude Opus 5 3810e442c6 (da03690) Add set and append for editing a ticket, and bump to 0.5.0
Nothing could change a ticket after it was created. mv wrote status, comment
appended a file, and that was the whole set of mutations, so correcting a typo
or adding a criterion meant hand editing the markdown.

Two commands rather than the one vague "edit" the ticket described. set replaces
a field, append adds to a section, so the verb carries the meaning instead of a
prefix on seven flag names, and append only offers the three sections that hold
multiple lines. Owner is absent from both, it belongs to the chown command filed
alongside this, and status stays mv's. One field, one writer.

Sections are a table, DESCRIPTION, ACCEPTANCE and PLAN, each carrying a heading,
a label, the placeholder add writes when empty, and a kind. Both commands walk
it, so a section added later is one entry rather than edits in two places.

Everything is targeted line surgery and never a regenerated file, which is what
keeps a ticked criterion ticked and a handwritten section intact when an
unrelated field changes. Appending to a numbered section continues from the
count already there rather than renumbering above it, so a handwritten line
survives exactly as written. Appending to an empty section replaces the
placeholder instead of following it.

An empty value is a paragraph break for a section and a usage error for a
scalar, since it looks like a way to clear a field and clearing is not supported
yet. No-op detection compares the whole file before and after each edit, so a
field set to the value it already holds is reported unchanged and nothing is
written.

Two things came out of building it. move_ticket_file's staged write is extracted
as write_then_replace, now the only way any ticket file is written. And the file
is located by uuid rather than by title: titles are not unique, add allows
duplicates on purpose, and the old title scan meant mv <uuid-of-second> moved
the first ticket sharing its title. Reproduced, fixed, and pinned by a test.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 02:36:20 +02:00
Ansho ReiandClaude Opus 5 6c43e62a4b (8cc254c, 47aa0fe, a1dbd60) Fix the documented examples and the add tool schema
Three doc tickets in one commit, since two of them are the same check: run
everything the docs claim and see what fails.

8cc254c: the add example in the kanban skill passed -t twice, once where -g for
tags was meant, and gave -p three bare positional values instead of three flags.
Clap rejected it with exit 2, reproduced verbatim. Rewritten, with a line saying
why -t is not tags and why each step needs its own -p, since the example alone
does not explain the trap. The "--due (or --due)" filler is gone; --due and
--priority have no short form and now say so.

a1dbd60: only title is required in the add schema now. The other six fields were
unmarked, so the model had to invent a value for every field on every ticket.
The other four tool schemas were checked and are already right: ls is fully
optional, and the required arguments on show, mv and comment are genuinely
required. Every add field was already guarded in execute, so an omitted field
adds no flag.

47aa0fe: the README row it describes was already fixed in passing by ddbd45e,
which rewrote it for the priority work. "ls --status" appears nowhere. What was
left was the second criterion, and running every example turned up a different
problem: the 141 exit code documented for a truncated pipe only happens when the
output exceeds the 64 KiB a pipe holds. A short listing lands in the buffer
whole and reports 0. That was my own wording from b28ddb9 and it is now precise.

Every example in both files was run against the built binary, with real ids
substituted where they use placeholders, and the four documented exit codes were
measured rather than assumed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 01:18:36 +02:00
Ansho ReiandClaude Opus 5 39ee86e308 (4c516e6) Preserve paragraph breaks in ticket descriptions, and bump to 0.4.1
The opencode add tool split the description on newlines and then dropped the
empty ones with filter(Boolean), so every multi paragraph description arrived as
a single paragraph, against the tool's own instruction to separate paragraphs
with newlines.

cmd_add needed no change for this. Joining the values with a single newline is
what makes an empty value a paragraph break, so the capability was already
there and only the wrapper was throwing it away. Verified by hand before
touching anything.

The wrapper now keeps interior blanks and trims only the ends, and only trims
trailing whitespace within a line, since leading whitespace is what makes a
nested list or an indented block survive. --acceptance and --plan keep dropping
blanks: each value there is one criterium or step, so an empty line is spacing.

trim_blank_ends in cmd_add makes the second criterion hold whoever calls it, not
just the wrapper: blank values at either end are dropped so a break never lands
against a section heading, and an all-blank description reads as none. Interior
runs are kept verbatim rather than collapsed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 00:29:22 +02:00
Ansho ReiandClaude Opus 5 5a7cfeb849 (b8aa66b) Evaluate ticket resolution in tiers, from four characters up, and bump to 0.4.0
resolve_ticket ORed the uuid prefix, title and filename predicates into one flat
list, so an exact prefix match was reported as ambiguous against any title that
merely mentioned that id. Reproduced: `show 641e3d5` on a board where another
ticket's title quoted it failed with "Multiple tickets found", and told the user
to use the displayed id, which was the id they had just used.

The three tiers are now evaluated in order and the first non-empty one wins
outright, which is what AGENTS.md always claimed.

The ticket also asked for prefix matching to require eight characters, and that
is not implemented. The guard it replaced read short_id.len() >= 8 where
short_id was always the full uuid, so it was always true and any length already
worked. Eight would have regressed that: ls prints seven characters, so the id
the tool displays would drop out of the uuid tier and lose to any title quoting
it, which is the very bug above. MIN_ID_SEARCH is four, so a short search is
still text and `show 641` remains a title search.

Docs corrected in four places that all stated the eight character rule: README,
AGENTS.md, the opencode tool descriptions and the kanban skill.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 23:38:29 +02:00
Ansho ReiandClaude Opus 5 e20396ce6b (322150c) Make mv crash-safe by writing before renaming, and bump to 0.3.3
cmd_mv renamed the ticket into its new directory and only then wrote the updated
content, so a write that failed left the ticket in the target directory still
claiming the old status. Reproduced with a read-only ticket file: the move
reported a bare "Permission denied" and left the file in committed/ carrying
"Status: backlog".

move_ticket_file now stages the content in a temp file, renames it over the
source, and only then renames the file into the target directory. Two atomic
steps, so a partial write is discarded and the original is untouched. The other
obvious order, writing to the target and deleting the source afterwards, was
rejected because it has the ticket in two directories at once.

The worst case left is a ticket still in its old directory with a Status one
move ahead, which the next mv corrects since the directory is what decides the
current status. Tested, including the retry.

The temp file is staged under .worklane/ rather than beside the ticket, so a
leftover from a hard kill is invisible to ticket lookup and to the listing
instead of appearing as a stray untitled ticket. IO errors now name the ticket
and the path rather than propagating bare.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 23:12:17 +02:00
Ansho ReiandClaude Opus 5 f5204f6d8b (866a4eb) Accept prose values that begin with a hyphen, and bump to 0.3.2
clap read any value starting with a hyphen as a flag, so a criterion quoting
--print was refused with "unexpected argument found" and no ticket was written
at all. Ticket text quotes flag names constantly, and the space form is what
both a person and the opencode wrapper produce, so the failure was routine.

allow_hyphen_values on the five arguments that carry prose: add --title,
--description, --acceptance, --plan, and the comment body. The trade is that a
genuinely mistyped flag there now lands as content instead of raising a usage
error, which is the right way round for prose and the wrong way round for
anything else, so due, priority, tags, owner and status are left alone and still
fail with exit 2. Written down in AGENTS.md.

The bare double hyphen is the one shape this does not reach: as an option value
it is stored as text, but in a positional it is clap's end-of-options marker and
is consumed before assignment. A comment body of exactly -- therefore needs its
own separator. Without it the body is reported missing and nothing is written,
so it is a clear failure rather than a silent drop. Tested, along with the
ordering that lets mv reach a hyphen-leading title.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 18:00:52 +02:00
Ansho ReiandClaude Opus 5 b28ddb9210 (eed7309) Die quietly on a truncated pipe, and bump to 0.3.1
Rust sets SIGPIPE to SIG_IGN at startup, so a write to a closed pipe returned
EPIPE and println panicked on it. `worklane ls | head -3` printed a panic and a
backtrace on stderr instead of three lines, which reads as a real fault and is
not what any other tool in a pipeline does.

main now restores the default disposition before any output, the same six lines
frig carries for the same reason. The cost is that a truncated pipe kills the
process with signal 13, so a shell reports 141 rather than 101. That is what
head and sort do, and it is now in the README next to the other exit codes.

The tests drop the read end rather than racing head for it, over a listing large
enough to exceed the 64 KiB a pipe holds, since a smaller one lands entirely in
the buffer and proves nothing. A shell pipeline into head is covered too, and
the exit codes for a real error and a usage mistake are pinned so the reset
cannot quietly change them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 17:34:45 +02:00
Ansho ReiandClaude Opus 5 f557437f62 (277a527) Render the metadata section as an aligned table, and bump to 0.3.0
show printed the Metadata block as the markdown list the file stores, so with
seven fields the values did not line up and the block read as file contents
rather than as a summary. It now renders as two aligned columns: field names
left, values right. The file is untouched, this is display only.

content_trim_colored streamed one line at a time, so nothing ever saw the whole
section. The Metadata lines are now taken as a block, since the field column
cannot be sized until every name has been seen.

Column width is measured on the raw names, in characters, and padding is applied
before anything is styled. Measuring a coloured name counts its escape sequences
towards its width, which tilts the table with colour on and not with it off.
paint() is color_text() with the decision passed in, which is what lets a test
render both ways in one process and compare.

colorize_metadata is folded into the renderer, its only caller. A line in the
section that is not a field is carried through rather than dropped, so a hand
written note survives, and an unrecognised field still gets a row.

Plain columns, no border characters: nothing to degrade on a font that lacks
them, and the section rules already carry the only box drawing here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 17:12:57 +02:00
Ansho ReiandClaude Opus 5 75fb2b3a6d (4b1e7e8) Print the ticket title once in show
cmd_show printed the resolved title with its rule, then content_trim_colored
printed the "# " heading again out of the file content, so every show output
carried the title twice.

The body now skips the heading, along with the blank line the template puts
under it so nothing is left where it was. cmd_show keeps the surviving copy and
colours it green, which is where the colour guideline puts a title.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 17:12:22 +02:00
Ansho ReiandClaude Opus 5 8b440593e2 (594c741) Measure heading rules on the displayed name
Section rules repeated the character for the byte length of the whole heading
line, so every rule ran three past its heading for the "## " prefix. The title
rule in cmd_show used byte length, which over-draws for a non-ASCII title.

Both now count characters of the text as displayed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 17:11:43 +02:00
Ansho ReiandClaude Opus 5 ab1dae098c (641e3d5) Scope metadata field lookup to the Metadata section, and bump to 0.2.1
parse_ticket_field searched every line of the file with contains, and
set_status_field rewrote the first line starting with the Status marker
wherever it sat. Tickets in this repo quote field markers in their
descriptions, so a description list shaped like metadata was read in place
of the real value and rewritten by mv, leaving the metadata stale.

Both now scan only the lines under the Metadata heading and match on a line
prefix rather than a substring. A file with no Metadata heading has no
fields, so mv reports the missing Status field instead of editing prose.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 16:38:35 +02:00
Ansho ReiandClaude Opus 5 2503f9aee9 (3b7edd7) Show priority as a glyph, and bump to 0.2.0
A bare digit in a listing is easy to skip over. Levels render as a
two-segment meter that empties as the level rises: ●● 1, ●◐ 2, ●○ 3,
◐○ 4, ○○ 5, with ·· for unset and ?? for a value outside the range.

Only ●, ◐, ○ and · are used, because they are what frig draws for its
status indicators and so are known to be in the terminal font. The first
cut of this used the quadrant circles ◕ and ◔, which are in a quarter as
many fonts, so terminals substituted them from a fallback that drew them
oversized and the column came out ragged. Two cells of a three-level ramp
gives five steps of ink, 2, 1.5, 1, 0.5, 0, without leaving that safe set.
Tests pin the safe set, the equal width and the monotonic emptying.

The mark carries the level on its own, because colour cannot. Output is
colourless whenever it is piped, which is how the opencode tools and every
script read it, and NO_COLOR turns it off in a terminal too. Colour only
accentuates: brightred, red, orange, cyan, grey, skipping green because
green means title.

The number counts up while the meter empties, since 1 is the most urgent.
That is the convention, but it reads as a bug unless written down, so it
is in AGENTS.md and in the legend.

Both the ramp and the legend come from priority_mark, and `ls --help`
prints the legend, since nothing in a listing explains a mark. brightred
is indexed like grey, for the same reason: it is the spelling that
renders.

Minor bump: two new flags, a new metadata field and a changed ls row,
covering dca0b61 and this ticket.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 15:50:09 +02:00
Ansho ReiandClaude Opus 5 ddbd45e332 (dca0b61) Add priority as a ticket field
Priority lived in tags, as p1 to p3, which ls could neither sort nor
filter on, nothing validated, and a typo like P1 passed silently. ls
sorted by title only, so a backlog of any size gave no ordering signal.

Levels are 1 to 5 with 1 most urgent, matching what the tags meant.
Omitting the flag leaves the field _Not set_, like Due and Owner: there is
no implicit middle level, because a priority nobody chose is worse than
none. clap rejects anything outside the range before a ticket is written.

Priority parses to three states rather than two. A stored value outside
the range is Invalid, kept distinct from Unset, so a typo cannot read as
"no priority": it shows as ? and sorts just ahead of the unset tail.

ls sorts on priority and falls back to the old title sort, and --priority
filters, composing with the status filter in both the grouped and the
filtered listing. TicketItem becomes a struct, since a sixth tuple field
was past reading.

Migrated the 31 tickets already carrying p1 to p3 tags: the level moves to
the field and the tag is dropped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 15:36:19 +02:00
23 changed files with 8623 additions and 442 deletions
+97 -13
View File
@@ -35,11 +35,15 @@ Add a new ticket to the backlog.
- `--acceptance` (or `-a`): Acceptance criteria (repeat flag for each criterium)
- `--plan` (or `-p`): Implementation plan steps (repeat flag for each step)
- `--tags` (or `-g`): Tags (comma-separated)
- `--due` (or `--due`): Due date in YYYY-MM-DD format
- `--due`: Due date in YYYY-MM-DD format. No short form
- `--owner` (or `-o`): Owner name
- `--priority`: Priority level, 1 (most urgent) to 5 (least). Unset if omitted. No short form
Tags are `-g`, not `-t`: `-t` is the title, and passing it twice is an error. Each
plan step needs its own `-p`, since a bare value after one is not a second step.
```bash
worklane add -t "Implement login" -d "Add user login page" -t login,auth -p "Design UI" "Build backend" "Write tests" --due 2026-06-01 --owner "ilya"
worklane add -t "Implement login" -d "Add user login page" -g login,auth -p "Design UI" -p "Build backend" -p "Write tests" --due 2026-06-01 --owner "ilya"
```
When there's multiple acceptance criteria, add each using a separate `--acceptance` or `-a` flag.
@@ -56,11 +60,15 @@ List tickets, optionally filtered by status.
**Valid statuses:** `backlog`, `committed`, `reviewing`, `done`
```
worklane ls # List all tickets
worklane ls backlog # List tickets in backlog
worklane ls done # List completed tickets
worklane ls # List all tickets
worklane ls backlog # List tickets in backlog
worklane ls done # List completed tickets
worklane ls --priority 1 # Only the most urgent, any status
worklane ls backlog --priority 2 # Composes with the status filter
```
Tickets are listed priority first, then by title. Tickets with no priority sort last.
### `worklane show`
Show the full details of a single ticket by UUID or title.
@@ -74,7 +82,7 @@ worklane show "ticket title or uuid"
Move a ticket between statuses.
**Positional arguments:**
- `<id>`: Ticket UUID (8+ characters) or title
- `<id>`: Ticket UUID prefix (4+ characters) or title
**Required options:**
- `--status <target>`: Target status (`backlog`, `committed`, `reviewing`, `done`)
@@ -93,12 +101,69 @@ worklane mv a1b2c3d4 --status committed # Move by UUID prefix
worklane mv "My Ticket" --status done -f # Move by title with force
```
### `worklane set`
Replace fields on an existing ticket. Only the fields given are touched; ticked
criteria and handwritten sections are left alone. At least one field is required.
**Positional arguments:**
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
**Options:** `--title`, `--description` (or `-d`), `--acceptance` (or `-a`), `--plan`
(or `-p`), `--tags` (or `-g`), `--due`, `--priority`
Owner is not settable here, and neither is status: `mv` owns status. Changing the
title renames the file, keeping the UUID.
```bash
worklane set a1b2c3d4 --priority 1
worklane set a1b2c3d4 --title "A clearer title" --due 2026-12-31
worklane set a1b2c3d4 -a "First criterium" -a "Second criterium"
```
### `worklane append`
Add to a section without replacing what is there. The description gains a new
paragraph; criteria and steps go on the end of their lists, steps numbered on from
the last. At least one section is required.
**Positional arguments:**
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
**Options:** `--description` (or `-d`), `--acceptance` (or `-a`), `--plan` (or `-p`)
```bash
worklane append a1b2c3d4 -d "A paragraph amending the description."
worklane append a1b2c3d4 -a "One more criterium"
worklane append a1b2c3d4 -p "A later step"
```
### `worklane check` and `worklane uncheck`
Tick or untick a single acceptance criterion. Every other criterion keeps its state,
and handwritten lines in the section are left alone.
**Positional arguments:**
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
- `[criterion]`: The number as shown by `worklane show`, or a substring of its text
Omit the criterion and the numbered criteria are listed and the number asked for. With
no terminal, as when driving the CLI from a tool, the same list comes back as an error
instead, so re-run with the number. A substring matching more than one criterion is an
error listing the matches with their real numbers.
```bash
worklane check a1b2c3d4 2
worklane check a1b2c3d4 "renames the file"
worklane uncheck a1b2c3d4 2
```
### `worklane comment`
Add a comment to a ticket.
**Positional arguments:**
- `<ticket>`: Ticket UUID (8+ characters) or title
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
- `<body>`: Comment text
Comments are stored as timestamped markdown files in `.worklane/comments/<ticket-uuid>/` and include the git author and timestamp.
@@ -111,10 +176,29 @@ worklane comment "My Ticket" "Needs changes to the UI"
worklane comment a1b2c3d4 "LGTM, approved"
```
## Workflow
## Working a ticket
1. Use `worklane add` to create tickets with all relevant details
2. Use `worklane ls [status]` to view tickets by status
3. Use `worklane show <id>` to view full ticket details
4. Use `worklane mv <id> --status <target>` to move tickets through the workflow
5. Use `worklane comment <ticket> <body>` to add notes to tickets
Move the ticket as you work it, not afterwards. The board should say what is happening
now, not only what already landed.
1. `worklane show <id>` to read it
2. **`worklane mv <id> --status committed` before writing any code.** This is what marks
the ticket as being worked on, so it belongs at the start
3. Do the work. `worklane check <id> <n>` as each criterion is met
4. `worklane comment <id> <body>` with anything worth recording: a decision, a rejected
acceptance criterion, something the ticket got wrong
5. **`worklane mv <id> --status reviewing` once it is done and the tests pass**
Only one stage forward is allowed at a time, so a ticket left in `backlog` until the end
cannot go straight to `reviewing`. It has to be walked through `committed` anyway, which
makes moving it up front the same two commands in a more useful order.
## Commands
- `worklane add` creates tickets with all relevant details
- `worklane ls [status]` views tickets by status
- `worklane show <id>` views full ticket details
- `worklane mv <id> --status <target>` moves tickets through the workflow
- `worklane set <ticket>` corrects a field, `worklane append <ticket>` adds to a section
- `worklane check <ticket> <n>` ticks a criterion as it is met
- `worklane comment <ticket> <body>` adds notes to tickets
+241 -25
View File
@@ -38,6 +38,39 @@ async function run(cmd: string[], context: ToolContext): Promise<string> {
return stdout.trim();
}
/**
* Description lines as worklane wants them, one --description value per line,
* blank ones included.
*
* cmd_add joins the values with a single newline, so an empty value is how a
* paragraph break is spelled. Dropping the blanks here, which is what the old
* filter(Boolean) did, collapsed every multi paragraph description into a single
* paragraph, against this tool's own instruction to separate paragraphs with
* newlines.
*
* Only the ends are trimmed, and only trailing whitespace within a line. Leading
* whitespace is content: it is what makes a nested markdown list or an indented
* block survive the trip.
*/
function descriptionLines(text: string): string[] {
const lines = text.split("\n").map((line: string) => line.trimEnd());
let start = 0;
let end = lines.length;
while (start < end && lines[start] === "") start++;
while (end > start && lines[end - 1] === "") end--;
return lines.slice(start, end);
}
/** One value per non-empty line, for the arguments that hold a list of items. */
function itemLines(text: string): string[] {
return text
.split("\n")
.map((line: string) => line.trim())
.filter(Boolean);
}
export const init = tool({
description:
"Initialize worklane in the current project. Creates the .worklane/ directory with backlog, committed, reviewing, and done subdirectories.",
@@ -54,28 +87,41 @@ export const init = tool({
export const add = tool({
description:
"Add a new ticket to the worklane backlog. Requires a title. Description, acceptance criteria, and plan each support multiple lines (one item per line). Tags are comma-separated.",
// Title is the only required field. Every other flag is left off entirely when
// the field is omitted, so an unmarked schema only forced the model to invent a
// value for fields it had nothing to say about.
args: {
title: tool.schema
.string()
.describe("Ticket title (required)"),
description: tool.schema
.string()
.describe("Description text. Use newlines between paragraphs."),
.describe("Description text. Use newlines between paragraphs.")
.optional(),
acceptance: tool.schema
.string()
.describe("Acceptance criteria, one per line. Put each criterium on its own line."),
.describe("Acceptance criteria, one per line. Put each criterium on its own line.")
.optional(),
plan: tool.schema
.string()
.describe("Implementation plan steps, one per line. Put each step on its own line."),
.describe("Implementation plan steps, one per line. Put each step on its own line.")
.optional(),
tags: tool.schema
.string()
.describe("Comma-separated tags, e.g. 'bug,frontend,urgent'"),
.describe("Comma-separated tags, e.g. 'bug,frontend,urgent'")
.optional(),
due: tool.schema
.string()
.describe("Due date in YYYY-MM-DD format"),
.describe("Due date in YYYY-MM-DD format")
.optional(),
owner: tool.schema
.string()
.describe("Ticket owner name. If omitted, defaults to the git user."),
.describe("Ticket owner name. If omitted, defaults to the git user.")
.optional(),
priority: tool.schema
.string()
.describe("Priority level, 1 (most urgent) to 5 (least). Left unset if omitted.")
.optional(),
},
async execute(args: Record<string, any>, context: ToolContext) {
if (!args.title) {
@@ -83,32 +129,27 @@ export const add = tool({
}
const cmd: string[] = ["add", "--title", args.title];
if (args.description) {
args.description
.split("\n")
.map((l: string) => l.trim())
.filter(Boolean)
.forEach((line: string) => cmd.push("--description", line));
descriptionLines(args.description).forEach((line: string) =>
cmd.push("--description", line),
);
}
// Blanks are dropped from these two on purpose: each value is one criterium or
// one step, so an empty line between them is spacing rather than content.
if (args.acceptance) {
args.acceptance
.split("\n")
.map((l: string) => l.trim())
.filter(Boolean)
.forEach((line: string) => cmd.push("--acceptance", line));
itemLines(args.acceptance).forEach((line: string) =>
cmd.push("--acceptance", line),
);
}
if (args.plan) {
args.plan
.split("\n")
.map((l: string) => l.trim())
.filter(Boolean)
.forEach((line: string) => cmd.push("--plan", line));
itemLines(args.plan).forEach((line: string) => cmd.push("--plan", line));
}
if (args.tags) cmd.push("--tags", args.tags);
if (args.due) cmd.push("--due", args.due);
if (args.owner) cmd.push("--owner", args.owner);
if (args.priority) cmd.push("--priority", String(args.priority));
try {
return await run(cmd, context);
@@ -120,15 +161,20 @@ export const add = tool({
export const ls = tool({
description:
"List all worklane tickets. Optionally filter by status (backlog, committed, reviewing, done).",
"List all worklane tickets, sorted by priority then title. Optionally filter by status and by priority.",
args: {
status: tool.schema
.enum(["backlog", "committed", "reviewing", "done"])
.describe("Filter by status")
.optional(),
priority: tool.schema
.string()
.describe("Only show tickets at this priority, 1 (most urgent) to 5 (least)")
.optional(),
},
async execute(args: Record<string, any>, context: ToolContext) {
const cmd = args.status ? ["ls", args.status] : ["ls"];
if (args.priority) cmd.push("--priority", String(args.priority));
try {
return await run(cmd, context);
} catch (err: any) {
@@ -145,7 +191,7 @@ export const show = tool({
args: {
id: tool.schema
.string()
.describe("Ticket UUID (8+ chars) or title substring (required)"),
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
},
async execute(args: Record<string, any>, context: ToolContext) {
if (!args.id) {
@@ -165,7 +211,7 @@ export const mv = tool({
args: {
ticket: tool.schema
.string()
.describe("Ticket UUID (8+ chars) or title substring (required)"),
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
status: tool.schema
.enum(["backlog", "committed", "reviewing", "done"])
.describe("Target status (required)"),
@@ -197,7 +243,7 @@ export const comment = tool({
args: {
ticket: tool.schema
.string()
.describe("Ticket UUID (8+ chars) or title substring (required)"),
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
body: tool.schema
.string()
.describe("Comment body text (required). Supports markdown formatting and multiple paragraphs separated by newlines."),
@@ -224,3 +270,173 @@ export const comment = tool({
}
},
});
export const set = tool({
description:
"Replace fields on an existing worklane ticket. Only the fields given are touched; everything else in the file, including ticked criteria and handwritten sections, is left alone. Owner is not settable here, use chown. Status is not settable here, use mv. To add to a section instead of replacing it, use append.",
args: {
ticket: tool.schema
.string()
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
title: tool.schema
.string()
.describe("New title. The file is renamed to match, keeping the UUID.")
.optional(),
description: tool.schema
.string()
.describe("New description, replacing the whole section. Use newlines between paragraphs.")
.optional(),
acceptance: tool.schema
.string()
.describe("New acceptance criteria, one per line, replacing the whole list.")
.optional(),
plan: tool.schema
.string()
.describe("New implementation plan steps, one per line, replacing the whole list.")
.optional(),
tags: tool.schema
.string()
.describe("New comma-separated tags, replacing the existing ones.")
.optional(),
due: tool.schema
.string()
.describe("New due date in YYYY-MM-DD format")
.optional(),
priority: tool.schema
.string()
.describe("New priority level, 1 (most urgent) to 5 (least)")
.optional(),
},
async execute(args: Record<string, any>, context: ToolContext) {
if (!args.ticket) {
return "Error setting fields: ticket is required";
}
const cmd: string[] = ["set", args.ticket];
if (args.title) cmd.push("--title", args.title);
if (args.description) {
descriptionLines(args.description).forEach((line: string) =>
cmd.push("--description", line),
);
}
if (args.acceptance) {
itemLines(args.acceptance).forEach((line: string) =>
cmd.push("--acceptance", line),
);
}
if (args.plan) {
itemLines(args.plan).forEach((line: string) => cmd.push("--plan", line));
}
if (args.tags) cmd.push("--tags", args.tags);
if (args.due) cmd.push("--due", args.due);
if (args.priority) cmd.push("--priority", String(args.priority));
if (cmd.length === 2) {
return "Error setting fields: give at least one field to change";
}
try {
return await run(cmd, context);
} catch (err: any) {
return `Error setting fields: ${err.message}`;
}
},
});
export const append = tool({
description:
"Add to a section of an existing worklane ticket without replacing what is there. The description gains a new paragraph; acceptance criteria and plan steps are added to the end of their lists, with steps numbered on from the last. Ticked criteria and handwritten content are left alone. To replace a section outright, use set.",
args: {
ticket: tool.schema
.string()
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
description: tool.schema
.string()
.describe("Text to add as a new paragraph at the end of the description.")
.optional(),
acceptance: tool.schema
.string()
.describe("Acceptance criteria to add, one per line.")
.optional(),
plan: tool.schema
.string()
.describe("Implementation plan steps to add, one per line.")
.optional(),
},
async execute(args: Record<string, any>, context: ToolContext) {
if (!args.ticket) {
return "Error appending: ticket is required";
}
const cmd: string[] = ["append", args.ticket];
if (args.description) {
descriptionLines(args.description).forEach((line: string) =>
cmd.push("--description", line),
);
}
if (args.acceptance) {
itemLines(args.acceptance).forEach((line: string) =>
cmd.push("--acceptance", line),
);
}
if (args.plan) {
itemLines(args.plan).forEach((line: string) => cmd.push("--plan", line));
}
if (cmd.length === 2) {
return "Error appending: give at least one section to add to";
}
try {
return await run(cmd, context);
} catch (err: any) {
return `Error appending: ${err.message}`;
}
},
});
/**
* check and uncheck differ only in the verb, so the tool is built once.
*
* The criterion is required here even though the CLI makes it optional: without it the
* CLI prompts, and there is no terminal on this side of the pipe. The CLI answers a
* missing criterion with the numbered list on stderr, which run() relays, so the model
* sees the options and can retry with a number.
*/
function checkboxTool(verb: "check" | "uncheck") {
const past = verb === "check" ? "Checked" : "Unchecked";
return tool({
description:
`${past === "Checked" ? "Tick" : "Untick"} one acceptance criterion on a worklane ticket. ` +
"Every other criterion keeps its state. Identify the criterion by its number as shown by show, " +
"or by a substring of its text; a substring matching more than one is an error listing them.",
args: {
ticket: tool.schema
.string()
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
criterion: tool.schema
.string()
.describe(
"Criterion number as shown by show, or a substring of its text (required)",
),
},
async execute(args: Record<string, any>, context: ToolContext) {
if (!args.ticket) {
return `Error running ${verb}: ticket is required`;
}
if (!args.criterion) {
return `Error running ${verb}: criterion is required, give the number or a substring`;
}
try {
return await run([verb, args.ticket, String(args.criterion)], context);
} catch (err: any) {
return `Error running ${verb}: ${err.message}`;
}
},
});
}
export const check = checkboxTool("check");
export const uncheck = checkboxTool("uncheck");
+123 -7
View File
@@ -1,14 +1,21 @@
# AGENTS.md
## Project Structure
- `src/main.rs` - All application logic
- `src/main.rs` - dispatch, the SIGPIPE reset, and the TUI event loop
- `src/command.rs` - CLI argument definitions using clap derive
- `tests/` - Integration tests using `assert_cmd` and `assert_fs`
- `src/handlers.rs` - one `cmd_*` per subcommand
- `src/util.rs` - the ticket format, resolution, rendering and the palette
- `src/tui.rs` - board state, the change digest, and the ratatui draw
- `src/install.rs` - the embedded agent assets and the compare-and-refuse install
- `assets/SKILL.md` - the agent skill `install-skill` ships, embedded with `include_str!`
- `tests/` - Integration tests using `assert_cmd` and `assert_fs`, one file per command
- Unit tests live beside the code in `#[cfg(test)] mod tests`, in `util.rs`, `handlers.rs` and `tui.rs`
- Ticket files stored as `.md` in `.worklane/<status>/` directories
## Ticket File Format
- Filenames: `<uuid_v4>_<slug>.md`
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Tags`, `Due`, `Owner`, `Created At`, `Status`
- The slug is the title through `slug()`: lowercased, alphanumerics plus `-` and `_` kept, spaces turned into dashes. `Ticket 06` lands as `<uuid>_ticket-06.md`. Derive fixture filenames through `slug()`, never by hand
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Status`
- Format: `**Field Name**: value`
- Ticket structure: `# Title` → `## Description` → `## Acceptance Criteria` → `## Implementation Plan` → `## Metadata`
- Comments stored in `.worklane/comments/<ticket_uuid>/<timestamp>.md` with `**Comment**`, `**Author**`, `**Time**` fields
@@ -16,11 +23,18 @@
## Status Workflow
`backlog` → `committed` → `reviewing` → `done`
**How to use worklane is in `assets/SKILL.md`, not here.** That document is what
`worklane install-skill` ships, so it is the one place the flow, the move-as-you-work
rule and the argument traps are written down. Read it before working a ticket in this
repo. Do not restate any of it in this file: a second copy is a copy that goes stale,
and this file is for what someone changing worklane's own code needs.
## Testing
- Run: `cargo test`
- Tests use `assert_cmd` and `assert_fs` for CLI testing
- `setup_worklane()` creates temp `.worklane/` with all four status folders pre-created
- `create_ticket()` writes fully-formed markdown files directly (no `--` separator for positional args in test commands)
- **`cargo clippy --all-targets` is clean. Keep it clean**, and do not silence a lint that is pointing at something real. The only two `allow`s in the tree sit on the `create_ticket` fixtures in `cmd_mv.rs` and `cmd_show.rs`, each carrying the reason and what would replace it
## Coding Guidelines
@@ -30,13 +44,107 @@
- Prefer explicit `match` over `unwrap_or_default()` for clarity
- Use `unwrap_or_else(|| expr)` for lazy defaults, `unwrap_or(val)` for eager defaults
- Use `anyhow!()` with context strings that include identifying info (e.g. UUID, title) not bare values
- A command whose arguments run past a handful takes a clap `Args` struct, not an inline variant with a matching parameter list: `AddArgs`, `SetArgs`, `AppendArgs`, `CheckArgs`. `add` was nine positional parameters threaded from `main` before it became `AddArgs`, and the handler destructures the struct so the body reads the same as before
### CLI Arguments
- The prose arguments carry `allow_hyphen_values`, via the `PROSE` constant in `command.rs`: `add --title`, `--description`, `--acceptance`, `--plan`, and the `comment` body. Ticket text quotes flag names constantly, and without it a criterion reading `--print is supported` is parsed as a flag and the whole ticket is refused with nothing written
- **The trade:** on those five arguments a genuinely mistyped flag now lands as content rather than raising a usage error. That is the right way round for prose and the wrong way round for anything else, which is why `due`, `priority`, `tags`, `owner` and `status` are deliberately left without it. A mistyped flag there is still a usage error, exit 2, and no ticket is written. Do not add `PROSE` to a new argument unless it holds prose
- The ticket positionals (`show <id>`, `mv <ticket>`, `comment <ticket>`) are also left alone, so a search term starting with a hyphen is a usage error. Reachable now that a hyphen-leading title can be stored: use the UUID, or put the flags first and separate with `--`, as in `mv --status committed -- -leading-title`
- A bare `--` is a value when it follows an option (`--title -- ` stores `--`) and clap's end-of-options marker when it sits in a positional. So a `comment` body of exactly `--` needs its own separator, `comment <ticket> -- --`. Without it the body is reported missing and nothing is written, which is a clear failure rather than a silent drop
- `add` has no positionals, so anything after a bare `--` is an unexpected argument and fails
- **A paragraph break in a description is an empty `--description` value.** `cmd_add` joins the values with a single newline, so `-d "First." -d "" -d "Second."` writes the blank line. `trim_blank_ends()` drops blank values at either end, so a break never lands against a section heading, and an all-blank description reads as no description. Interior runs are kept verbatim rather than collapsed
- `--acceptance` and `--plan` are lists, one criterium or step per value, so a blank there is spacing rather than content and the opencode wrapper drops it. Only `--description` preserves blanks
### Editing a Ticket
- `set` replaces a field, `append` adds to a section. The verb carries the meaning, so no flag needs a replace-or-append prefix, and `append` only offers the sections that hold multiple lines
- **One field, one writer.** `set` has no `--owner` (that is `chown`'s, once it exists) and no `--status` (that is `mv`'s). Do not add either
- Sections are a table in `util.rs`: `DESCRIPTION`, `ACCEPTANCE`, `PLAN`, each with a heading, a label, the placeholder `add` writes when empty, and a `SectionKind`. Adding a section later is one entry, not edits in both commands
- Everything is targeted line surgery, never a regenerated file. That is what keeps a ticked criterion ticked and a handwritten `## Notes` section intact when an unrelated field changes. `section_body()` finds the lines to touch, `set_metadata_line()` does the metadata, and every other byte is copied through
- 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` in `command.rs`. Clearing a field is not supported yet, and the error says so rather than guessing
- No-op detection compares the whole file before and after each edit, so a field set to the value it already holds is reported unchanged and nothing is written
- `find_ticket_file()` matches on the uuid, never the title. Duplicate titles are allowed, so a title scan can land on a different ticket than the one resolved: `mv <uuid-of-second>` used to move the first ticket sharing its title
- `write_then_replace()` is the only way a ticket file is written. Content first, rename second, so a failure leaves a correct ticket under a stale name rather than a half-written one
### Checking Off a Criterion
- `check` and `uncheck` are separate commands, not one verb with a flag. They share `CheckArgs` and `cmd_check(args, checked)`
- `criteria()` is scoped to the Acceptance Criteria section and counts only checkbox lines, so a checkbox written into a description is not a criterion and a handwritten line inside the section takes no number
- `set_criterion()` splices only the character between the brackets. Rebuilding the line would normalise its indentation and whatever spacing followed the checkbox
- The criterion argument is an index first, a substring second, so a criterion whose text is literally `2` is reachable only by substring
- **A number out of range is a bad index, not a failed substring search**, and says so. `is_index()` makes that distinction
- Any listing of a subset must keep the real numbers, via `numbered_criteria()`. Renumbering the matches from one contradicts the advice to use the number and points at the wrong criterion
- With the criterion omitted: prompt when stdin is a terminal, otherwise return the numbered list as an error. Never prompt unconditionally, the opencode wrapper has no tty and would block on a stdin that never closes. This is the same choice `resolve_ticket` makes for an ambiguous match, and for the same reason
- `show` numbers the criteria as `1. [x] text`, so the index is visible where the ticket is read. The number replaces the list marker rather than joining it
### The Board View
- `worklane` with no subcommand and `worklane tui` both open it, the way a bare `frig` does. `Cli::command` is therefore an `Option`
- The worklane directory is looked for **before** the terminal, so running outside one gives the usual "No .worklane directory found" rather than a complaint about the tty. Both errors stay reachable and both are testable without a pty
- A missing tty is refused with a message naming a subcommand. Raw mode on a pipe fails with a bare "No such device or address (os error 6)", which explains nothing
- **The watch looks at files, not directories.** A directory's mtime only moves on create and rename, so a ticket edited in place would be missed. `digest()` hashes every ticket and comment file's path, length and mtime. Comment files are in it because a comment added elsewhere has to reach the detail view
- The digest guards the *rescan*, not the draw. ratatui diffs its buffer, so drawing every iteration is free; reading the tree every iteration is not
- `notify` is deliberately not a dependency. Polling a tree of tens of small files on the 250ms tick is enough, and the reason is recorded on f6af387
- Cards come from `collect_ticket_items`, the same source `ls` uses, so there is no second parser. `TicketItem::path` exists for the detail view
- **The detail view scrolls on `pgup` and `pgdn`, not on up and down.** Up and down stay on the selection with the modal open, so a whole column can be read without closing it, and the modal follows. That is worth more than the two keys, which is why the scroll went elsewhere rather than taking them
- The scroll offset is clamped against the *wrapped* line count, from `Paragraph::line_count`, which is why `ratatui` carries the `unstable-rendered-line-info` feature. The paragraph wraps on words, so a clamp on the raw lines would stop short of the end or scroll past it into blank space. Counting the wrapping by hand would only agree with the widget until one of the two changed
- The clamp runs on the keypress and again in the draw. The terminal can be resized between the two, and a tick can shorten the ticket under a reader who is already at the end
- The offset resets when the selection moves and when the modal is closed, so a ticket opens at its top. It deliberately does *not* reset on a tick: an edit elsewhere in the tree must not throw the reader back to the top of what they are reading
- **Columns scroll to keep the selected card in view.** `Board::offsets` holds one offset per column, parallel to `columns` and resized in step by `reload`, so a column you leave stays where it was. The keypress aligns the focused column via `follow_selection(screen)`, taking the screen size for the same reason `scroll_detail` does: the visible height belongs to the terminal, which only the caller measures between draws
- Card heights are measured on `card_lines`, never assumed, on both the keypress and the draw side (`card_height`, and the `starts` vec as the cards are built). An alignment that trusted a fixed card height would drift from the renderer the first time the card changed shape
- The draw aligns the focused column again on its own geometry, so a resize between keypress and frame cannot hide the selection, and caps every column against blank space past its last card. The stored value may go stale after a tick shrinks the column; that is fine, because what is drawn is corrected immediately and the next navigation writes the correction back
- Entering another column follows the selection rather than resetting to its top. The card index carries across columns, so a reset would open the column with the highlight below the fold whenever it was — the opposite of the detail view's reset-on-selection-move, where each ticket genuinely starts at its own top. The index is shared and clamps permanently when a shorter column pulls it down, so a column you return to follows the selection to where it now sits rather than holding your old place
- **The footer names only keys that work.** It read `↑↓ scroll` when nothing scrolled at all, which sends the reader looking for their own mistake. A UI that misdescribes itself is worse than one that is merely incomplete
- **The overlay names its ticket on the border, not at the head of the paragraph.** `Board::detail` is a `Detail` carrying the title, the id and the text, because the name has to travel beside the body rather than inside it: `content_trim` drops the `# ` heading on purpose, since `cmd_show` prints it, and anything in the paragraph scrolls away
- `detail_title` cuts the string itself instead of leaving it to ratatui, which truncates an overlong block title at whatever cell it reaches and would take the id with it. Cut against the inner width, so the id survives whole and the name ends in an ellipsis. The id goes first because that is how every other view addresses a ticket
- The detail view renders with colour off. ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_comments_with` take the colour decision for that reason
- Read only. Moving a card by keypress is a follow-up, deliberately kept out until the watch and render loop were solid
- **A card is four corners with the title between them:** mark and short id top left, due top right, owner bottom left, criteria count bottom right. The two numbers are in corners because that is where the eye goes for one, and both were invisible at the end of a line of prose
- The title takes one row or two, wrapped on spaces, with an ellipsis when even two are not enough. One row when one is enough: a second, blank row on every short ticket spends the column's height on nothing
- **A card's height therefore depends on the column's width**, so `card_lines` and `card_height` both take it. `column_areas` is shared between the draw and `follow_selection` for the same reason: `Ratio` hands the remainder column to whichever slot it likes, and reproducing that arithmetic by hand is how the measurement and the draw come to disagree about where a card starts
- **A corner that will not fit is dropped whole**, never truncated or wrapped: half a date reads as a different date, and a card that reflows in a narrow column changes height, which the scroll would then have to chase. The left corner is the ticket's identity and always stays
- The criteria count is a field on `TicketItem`, filled in `collect_ticket_items` where the file is already being read, and counted through `criteria()` so a checkbox in a description is not counted here or numbered by `show`. Do not count per card: that re-reads every ticket body on every draw instead of on the tick that changed something. `None` rather than `[0/0]` for a ticket with no criteria
- `due_date` cuts a due value back to its date only when it has one. The field is not validated (daa0e79), so it can hold a time or free text, and taking the first word regardless would turn "next friday" into "next"
- **Done is hidden until `d` asks for it.** Not a new opinion: `ls` already counts done in its summary and leaves it out of the listing. Done only grows, so a quarter of the width was going to the column least often read. The footer carries its count while it is hidden, which is the board's version of that summary line
- **Hiding is a change to what is drawn, never to what is read.** `reload` still scans the done directory and `digest` still watches it, so the footer count is right and revealing the column needs no rescan. Do not "optimise" that into a conditional scan
- `visible()` returns a prefix of `columns`, not a filter, which is what keeps `column` and `offsets` valid as indices into either. It is derived from where `DONE` actually sits rather than assuming the last slot, and `the_done_column_is_last` pins the assumption. A status inserted after done would otherwise hide two columns in silence
- Hiding the column under the selection moves the selection to the last drawn column and **closes an open detail view**. The alternative, refreshing the modal onto whichever ticket the selection landed on, swaps what someone is reading without saying so, which is how a person acts on the wrong ticket. Showing done again is a no-op for the selection, since a column is appended rather than inserted
- The choice is not remembered between runs. worklane has no config file and one flag is not a reason to start one; if it should persist, that is its own ticket
- **Assert a column heading against the top border row, not the whole screen.** The footer names done too, so `screen.contains("done (0)")` passes on the footer whether the column is drawn or not. Three tests went vacuous that way the moment done was hidden; `headings()` and `footer()` exist so the next one does not. `headings()` locates the row through `board_area()` rather than taking row zero, since the tab row sits above it when more than one board is monitored
### Monitoring Several Boards
- `worklane tui <path>...` takes any number of paths, each resolved through `find_worklane_dir` the way the working directory is: the first `.worklane` at or above it. No path is the working directory, so a bare `worklane` and `worklane tui` are unchanged
- The failure **names the path** that had no board, since with several arguments "No .worklane directory found" does not say which one was wrong. Only when a path was given: a bare `worklane` has no path to name and keeps the message every other command gives, which is what its integration test asserts
- Two paths inside one project resolve to the same `.worklane` and are monitored once. `projects()` dedupes on the resolved directory, not on the argument
- **`Tab` owns the selection**, `column`, `card` and `offsets`, not `Board`. Sharing them across projects would point the selection at whatever unrelated ticket sat at the same place in the tab you switched to. `Board::current()` is the tab in view, and `show_done` stays on the board because it is a preference about the flow rather than about a project
- The tabs are fixed for the run: a project cannot be added or dropped without restarting, so `Board::new` builds the tab list once and `reload` only refills each tab's columns. `reload` clamps **every** tab, and `select_tab` clamps again on arrival, because done may have been hidden while another tab was in view
- The merge tab goes **first** and is where the view opens: it is the reason to monitor several boards at once. It is materialised in `reload`, from the cards already read, rather than computed per draw — the same reason the criteria count is filled in `collect_ticket_items`
- The merge is **sorted**, through `by_priority_then_title` in `util.rs`, not concatenated. An overview whose order depended on the order of the arguments would bury one project's p1 under another's p5. That comparator is exported for this and is the one `collect_ticket_items` uses, so the two orders cannot drift
- `Card` wraps a `TicketItem` with the project it came from, `Some` only on the merge tab. Decided at reload rather than passed down to `card_lines` as a "which tab is this" flag. `TicketItem` is therefore `Clone`: the merge holds a second copy rather than re-reading every tree
- **The project follows the id, on the card and on the overlay border.** Across boards the id is not an address: two projects can hold the same title, and seven characters do not say where they live. `project_label` takes what the row has left after the mark and the id and ends in an ellipsis, and it is measured before the due date, so on the merge the project wins the narrow column and the date is what `corner_line` drops
- `tab` and `shift+tab` cycle rather than clamp, unlike the cards and columns: a row of tabs is a ring, and there is no end of a list to run off. Both were free of every other binding — the columns took `hjkl` and the arrows
- **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
### 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
- **One install path serves both agents:** `~/.claude/skills/worklane/SKILL.md`. Claude Code reads it, and opencode loads that directory as an external skill source alongside its own `~/.config/opencode/skill/`. Verified against opencode 1.15.10, whose built-in `customize-opencode` skill documents the table and whose `opencode debug skill` lists what it found there. Do not add the second path: it is two copies of one document, free to drift, for no gain
- `Asset` carries the content, the path under its root and the word used in messages, so `install-tool` adds an entry and its own root rather than a second copy of the compare-and-refuse logic. That is why the module is `install.rs` and not `skill.rs`
- `install()` takes the root as an argument. That is what lets the tests install into a temp directory instead of the home of whoever runs the suite, and the integration test redirects `HOME` for the same reason
- **A modified copy is refused, not overwritten.** Someone may have edited it on purpose, and the message names `--print` so it can be diffed and `--force` so it can be replaced. A read error is not treated as absent either: the write reports the real reason
- Three tests guard the document rather than the mechanism, and they are the ones that earn their keep: the frontmatter has to parse (both agents silently ignore a document without it), every `worklane <x>` the skill shows has to be a real subcommand, and every subcommand outside `NOT_FOR_AGENTS` has to appear in the skill. The last one catches a new command that nothing tells an agent about
- `install-skill` looks for no board. The skill is what teaches an agent worklane, so needing a `.worklane` to install it would put it out of reach exactly when it is wanted
- The assets under `.opencode/` are the user's, not this repo's to ship. Do not embed or install them
### Color and Output
- Use `color_text()` helper for colored output — it respects `should_use_colors()` (terminal detection)
- Color codes are defined in `get_color()`: red (31), cyan (36), orange (33), green (32), grey (38;5;8), magenta (1;35)
- 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 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
- Bold uses `\x1b[1;35m` (magenta bold)
- Always test color output works correctly in both terminal and pipe modes
- `quiet_broken_pipe()` runs first in `main`, restoring the default `SIGPIPE` disposition. A truncated pipe therefore kills the process with signal 13, which a shell reports as 141, instead of making `println!` panic. Do not wrap prints to handle write errors and do not reinstate `SIG_IGN`; the exit codes are documented in the README
### Color Guideline
- UUID → red (31)
@@ -44,16 +152,24 @@
- Timestamp → cyan (36)
- Title → green (32)
- Unknown values (`_None_`, `_Not set_`) → grey (38;5;8)
- Priority ramp → brightred (1), red (2), orange (3), cyan (4), grey (5). Green is deliberately absent: it means title
- 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_line`, `colorize_metadata`, `colorize_ordered`, `content_trim_colored`) handle markdown formatting
- 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 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
- `parse_ticket_field()` handles extracting metadata values from markdown format
- `move_ticket_file()` stages the updated content in a temp file under `.worklane/`, renames it over the source, and only then renames the file into the target directory. Do not reorder these: renaming first and writing second leaves a ticket in its new directory claiming the old status, and writing to the target then deleting the source puts it in two directories at once. The temp lives outside the status directories so a leftover is never read as a ticket. A failure at the last step leaves the ticket in its old directory with a Status one move ahead, which the next `mv` corrects
- Field lookup, read and write, is scoped to the lines under the `## Metadata` heading and anchored to the start of the line. Prose above it is free text: tickets in this repo quote field markers in their descriptions, and an unscoped search reads or rewrites those instead. `set_status_field()` carries the same scoping
### Ticket Resolution
- `resolve_ticket()` returns `(status, title, content)` tuple
- Priority: exact UUID prefix (8+ chars) > title substring > filename substring
- Three tiers, evaluated in order: UUID prefix > title substring > filename substring. The first non-empty tier wins outright and later tiers are not consulted. This is not cosmetic: ticket titles reference other tickets by id, so a flat OR of the three reported an exact prefix match as ambiguous against whichever title mentioned it
- The UUID tier applies from `MIN_ID_SEARCH` (4) characters up. Not 8: `ls` prints `SHORT_ID_WIDTH` (7) characters, so a longer minimum would drop the printed id out of the UUID tier and let any title quoting it win instead. Below the minimum the search is text, so `show 641` is a title search
- The filename tier earns its place by reaching the middle of a UUID, which the prefix tier cannot. It is also why a short UUID search still resolves under a longer minimum, just at the wrong precedence, so a test for the minimum needs a decoy title to be meaningful
- Ambiguous matches (multiple results) print options and exit(1)
- Never return empty strings for required fields — use `_Not set_` or `_None_` as defaults
Generated
+485 -17
View File
@@ -11,6 +11,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "android_system_properties"
version = "0.1.5"
@@ -56,7 +62,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys",
"windows-sys 0.61.2",
]
[[package]]
@@ -67,7 +73,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys",
"windows-sys 0.61.2",
]
[[package]]
@@ -135,6 +141,21 @@ version = "3.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
[[package]]
name = "cassowary"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "castaway"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
dependencies = [
"rustversion",
]
[[package]]
name = "cc"
version = "1.2.62"
@@ -196,7 +217,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
"syn 2.0.117",
]
[[package]]
@@ -211,6 +232,20 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "compact_str"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fd622ebbb56a5b2ccb651b32b911cdeb2a9b4b11776b2473bf26a26a286244e"
dependencies = [
"castaway",
"cfg-if",
"itoa",
"rustversion",
"ryu",
"static_assertions",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
@@ -242,6 +277,65 @@ version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crossterm"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
dependencies = [
"bitflags",
"crossterm_winapi",
"mio",
"parking_lot",
"rustix 0.38.44",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]]
name = "crossterm_winapi"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
dependencies = [
"winapi",
]
[[package]]
name = "darling"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"
dependencies = [
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn 3.0.3",
]
[[package]]
name = "darling_macro"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
dependencies = [
"darling_core",
"quote",
"syn 3.0.3",
]
[[package]]
name = "difflib"
version = "0.4.0"
@@ -254,6 +348,12 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "780955b8b195a21ab8e4ac6b60dd1dbdcec1dc6c51c0617964b08c81785e12c9"
[[package]]
name = "either"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
[[package]]
name = "equivalent"
version = "1.0.2"
@@ -267,7 +367,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys",
"windows-sys 0.61.2",
]
[[package]]
@@ -355,6 +455,8 @@ version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash",
]
@@ -400,6 +502,12 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "ignore"
version = "0.4.25"
@@ -428,12 +536,43 @@ dependencies = [
"serde_core",
]
[[package]]
name = "indoc"
version = "2.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
dependencies = [
"rustversion",
]
[[package]]
name = "instability"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf84e73fa6f27f299dec58e13223cf70db80da872eb921d4f6138342a0eabc8"
dependencies = [
"darling",
"indoc",
"proc-macro2",
"quote",
"syn 3.0.3",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "itertools"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.18"
@@ -464,24 +603,60 @@ version = "0.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
[[package]]
name = "linux-raw-sys"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
[[package]]
name = "lock_api"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "lru"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
dependencies = [
"hashbrown 0.15.5",
]
[[package]]
name = "memchr"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "mio"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427"
dependencies = [
"libc",
"log",
"wasi",
"windows-sys 0.61.2",
]
[[package]]
name = "num-traits"
version = "0.2.19"
@@ -503,6 +678,35 @@ version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "parking_lot"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-link",
]
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pin-project-lite"
version = "0.2.17"
@@ -543,7 +747,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn",
"syn 2.0.117",
]
[[package]]
@@ -570,6 +774,36 @@ version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]]
name = "ratatui"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
dependencies = [
"bitflags",
"cassowary",
"compact_str",
"crossterm",
"indoc",
"instability",
"itertools",
"lru",
"paste",
"strum",
"unicode-segmentation",
"unicode-truncate",
"unicode-width 0.2.0",
]
[[package]]
name = "redox_syscall"
version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
"bitflags",
]
[[package]]
name = "regex-automata"
version = "0.4.14"
@@ -587,6 +821,19 @@ version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
[[package]]
name = "rustix"
version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys 0.4.15",
"windows-sys 0.59.0",
]
[[package]]
name = "rustix"
version = "1.1.4"
@@ -596,8 +843,8 @@ dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
"linux-raw-sys 0.12.1",
"windows-sys 0.61.2",
]
[[package]]
@@ -606,6 +853,12 @@ version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
name = "ryu"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
[[package]]
name = "same-file"
version = "1.0.6"
@@ -615,6 +868,12 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.28"
@@ -647,7 +906,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.117",
]
[[package]]
@@ -669,18 +928,83 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
dependencies = [
"libc",
"signal-hook-registry",
]
[[package]]
name = "signal-hook-mio"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc"
dependencies = [
"libc",
"mio",
"signal-hook",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
dependencies = [
"errno",
"libc",
]
[[package]]
name = "slab"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "smallvec"
version = "1.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck",
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.117",
]
[[package]]
name = "syn"
version = "2.0.117"
@@ -692,6 +1016,17 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn"
version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tempfile"
version = "3.27.0"
@@ -701,8 +1036,8 @@ dependencies = [
"fastrand",
"getrandom",
"once_cell",
"rustix",
"windows-sys",
"rustix 1.1.4",
"windows-sys 0.61.2",
]
[[package]]
@@ -717,6 +1052,35 @@ version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "unicode-segmentation"
version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
[[package]]
name = "unicode-truncate"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
dependencies = [
"itertools",
"unicode-segmentation",
"unicode-width 0.1.14",
]
[[package]]
name = "unicode-width"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
[[package]]
name = "unicode-width"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
[[package]]
name = "unicode-xid"
version = "0.2.6"
@@ -759,6 +1123,12 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasip2"
version = "1.0.3+wasi-0.2.9"
@@ -809,7 +1179,7 @@ dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn",
"syn 2.0.117",
"wasm-bindgen-shared",
]
@@ -856,15 +1226,37 @@ dependencies = [
"semver",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys",
"windows-sys 0.61.2",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-core"
version = "0.62.2"
@@ -886,7 +1278,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.117",
]
[[package]]
@@ -897,7 +1289,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.117",
]
[[package]]
@@ -924,6 +1316,15 @@ dependencies = [
"windows-link",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.61.2"
@@ -933,6 +1334,70 @@ dependencies = [
"windows-link",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "wit-bindgen"
version = "0.51.0"
@@ -969,7 +1434,7 @@ dependencies = [
"heck",
"indexmap",
"prettyplease",
"syn",
"syn 2.0.117",
"wasm-metadata",
"wit-bindgen-core",
"wit-component",
@@ -985,7 +1450,7 @@ dependencies = [
"prettyplease",
"proc-macro2",
"quote",
"syn",
"syn 2.0.117",
"wit-bindgen-core",
"wit-bindgen-rust",
]
@@ -1029,13 +1494,16 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.1.2"
version = "0.9.0"
dependencies = [
"anyhow",
"assert_cmd",
"assert_fs",
"chrono",
"clap",
"crossterm",
"libc",
"ratatui",
"tempfile",
"uuid",
]
+7 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.1.2"
version = "0.9.0"
edition = "2024"
[dependencies]
@@ -8,6 +8,12 @@ clap = { version = "4", features = ["derive"] }
anyhow = "1"
uuid = { version = "1", features = ["v4"] }
chrono = { version = "0.4", features = ["serde"] }
libc = "0.2"
# unstable-rendered-line-info for Paragraph::line_count, which is how the detail view
# knows where its text ends. Counting the wrapping by hand would only agree with the
# widget until one of us changed.
ratatui = { version = "0.29", features = ["unstable-rendered-line-info"] }
crossterm = "0.28"
[dev-dependencies]
assert_cmd = "2"
+27 -3
View File
@@ -5,9 +5,33 @@ Worklane is a local Kanban flow for agentic software development.
## Commands
| Command | Description |
|---------|-------------|
| `worklane` or `worklane tui [path...]` | Opens the board: four status columns, redrawn when the tree changes. Read only. Opens on backlog, committed and reviewing; `d` shows or hides done, whose count stays in the footer either way. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket, `q` to quit. Each path opens the first `.worklane` at or above it, the working directory by default. Several paths are monitored together, as a tab per project plus an `all` tab that merges them, with `tab` and `shift+tab` between them |
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner` flags |
| `worklane ls` | Lists tickets, optionally filtered by `--status` |
| `worklane show <id>` | Shows ticket by UUID prefix (8+ chars) or title substring |
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags |
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
| `worklane show <id>` | Shows ticket by UUID prefix (4+ chars), title substring, or filename substring |
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
| `worklane set <ticket>` | Replaces fields with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--priority`. At least one required. Changing the title renames the file, keeping the UUID |
| `worklane append <ticket>` | Adds to a section with `--description`, `--acceptance`, `--plan`. At least one required. The description gains a paragraph; list items go on the end, steps numbered on from the last |
| `worklane check <ticket> [criterion]` | Ticks one acceptance criterion, by number as shown by `show` or by a substring. Prompts with the numbered list if omitted, or errors with it when there is no terminal |
| `worklane uncheck <ticket> [criterion]` | Unticks one acceptance criterion, addressed the same way |
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
| `worklane install-skill` | Writes the embedded agent skill to `~/.claude/skills/worklane/SKILL.md`, which Claude Code and opencode both read. Leaves a modified copy alone unless `--force`; `--print` writes it to stdout instead |
## Exit codes
| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | An error, such as no matching ticket or an ambiguous search |
| 2 | A usage mistake, such as an unknown flag |
| 141 | Output was piped to a reader that stopped early, for example `worklane ls \| head -3` |
141 is 128 + 13, the shell's way of reporting death by `SIGPIPE`. Worklane restores
the default signal disposition so a truncated pipe is quiet, the way `head` and
`sort` are, rather than printing a panic. A script using `set -o pipefail` will see
141 for a case that is not a failure, so guard for it there.
Whether a truncated pipe reports 141 or 0 depends on the size of the output, not on
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.
+143
View File
@@ -0,0 +1,143 @@
---
name: worklane
description: Manage tickets on a local worklane kanban board with the `worklane` CLI, backed by markdown files in a `.worklane/` directory. Use whenever you need to file, find, read, update, comment on or move a ticket, when asked what is on the board or what to pick up next, and when reporting work you are not going to do in the change at hand. Covers the four statuses, how a ticket is addressed, what belongs in each section, and the argument traps that silently swallow a flag.
---
# worklane
A kanban board as files. Every ticket is one markdown file in `.worklane/<status>/`,
named `<uuid>_<slug>.md`, and comments live in `.worklane/comments/<uuid>/`. The CLI is
the only thing that writes there: do not hand-edit or hand-place a file, because the
filename, the `Status` field and the directory have to agree and the commands are what
keep them agreeing.
Commands walk up from the working directory to find the nearest `.worklane`, so **run
`worklane` inside the repo the ticket belongs to**. Which directory you run it in is
what decides which board the ticket lands on.
`worklane` with no subcommand opens an interactive board and needs a terminal. It is for
a person, not for you: it takes over the screen and does not return until quit.
## The flow
`backlog` → `committed` → `reviewing` → `done`
**Move the ticket as you work it, not afterwards.** `worklane mv <id> --status committed`
before writing any code, and `--status reviewing` once it is done and the tests pass. The
board is then true while the work is in progress, not only after it lands, which is the
whole point of having a `committed` column.
Only one stage at a time is allowed, so a ticket left in `backlog` until the end cannot
go straight to `reviewing` and has to be walked through `committed` anyway. Doing it up
front is the same two commands in a more useful order. `-f` allows a backward or
skipping move, for correcting a mistake.
## Reading the board
```
worklane ls # every status, counts then tickets
worklane ls backlog # one status
worklane ls --priority 1 # only the most urgent
worklane show 1b78a24 # one ticket, body and comments
```
`ls` prints a seven-character id per ticket. That is what you address it by.
## Working a ticket
```
worklane mv 1b78a24 --status committed
worklane check 1b78a24 3 # tick acceptance criterion 3
worklane check 1b78a24 "the footer describes" # or a substring of it
worklane uncheck 1b78a24 3
worklane comment 1b78a24 "Found the cause: the offset was never passed to the widget."
worklane mv 1b78a24 --status reviewing
```
Criteria are numbered by `show`. With the criterion omitted, `check` prompts when there
is a terminal and otherwise fails with the numbered list, so **always pass the criterion
when you are not sitting at a prompt**.
## Filing a ticket
```
worklane add \
--title "The tui detail view cannot scroll" \
--description "Opening a ticket and pressing down moves to the next one instead." \
--description "" \
--description "Up and down are bound to select_card unconditionally, src/main.rs." \
--acceptance "PageUp and PageDown scroll the detail view" \
--acceptance "The footer describes the keys that exist" \
--plan "Add a scroll offset to Board and pass it to Paragraph::scroll" \
--plan "Clamp against the wrapped line count, not the raw line count" \
--priority 2 --tags bug,tui
```
`add` always lands in `backlog`. Nothing is created without `--title`.
- **`--description`** is the case for the ticket: the symptom, then what is actually
wrong, naming the files, functions and settings involved. Repeat the flag for more
lines; an empty `--description ""` between two values is a paragraph break.
- **`--acceptance`** takes one criterion per flag, each a statement that can be
checked off as true or false.
- **`--plan`** takes one step per flag, numbered for you.
- **`--priority`** runs 1 (most urgent) to 5 (least), and is left unset if omitted.
Editing afterwards, on a ticket in any status:
```
worklane set 1b78a24 --priority 1 # replace a field
worklane set 1b78a24 --title "A better title" # renames the file, keeps the uuid
worklane append 1b78a24 --acceptance "One more criterion"
worklane append 1b78a24 --description "What was learned since."
```
`set` replaces, `append` adds. Neither has `--owner` or `--status`: owner is its own
command's, and status is `mv`'s. A field set to the value it already holds is reported
unchanged and nothing is written.
`worklane init` creates `.worklane/` with the four status directories, for a repo that
has no board yet.
## Search the backlog before filing
Run `worklane ls` in the directory the ticket would land in and look for the same issue,
including tickets already committed, in review or done. Search by the symptom and by the
name of the function or setting involved, not only by your own phrasing of the title: an
existing ticket will have been written from a different angle.
- Already there and still open: add what you learned as a comment, not a second ticket.
- Already there and closed, but the issue is back: file a **new** ticket naming the old
id, and say it is a regression. There is no way to reopen one, and moving a done
ticket back would destroy the record of the original fix.
- Related but not the same: file it and reference the neighbour by id.
## Addressing a ticket
Every command that takes a ticket accepts, in this order of precedence:
1. a UUID prefix, from four characters up
2. a substring of the title
3. a substring of the filename
The first tier that matches anything wins outright; the later tiers are not consulted.
This matters because ticket titles quote other tickets' ids, and a flat search reported
an exact id as ambiguous against whichever title mentioned it. An ambiguous match prints
the candidates and exits 1 rather than guessing.
## Traps
- **Prose arguments accept a leading hyphen**: `--title`, `--description`,
`--acceptance`, `--plan` and the `comment` body. A criterion reading
`--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.
- 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:
`worklane comment 1b78a24 -- --`.
- An empty value for a scalar is a usage error. Clearing a field back to unset is not
supported yet.
- Piping is safe: `worklane ls | head -3` exits on the closed pipe instead of panicking.
+213 -30
View File
@@ -1,5 +1,25 @@
use clap::Parser;
use std::sync::LazyLock;
use crate::util::{PRIORITY_RANGE, priority_legend};
/// clap wants a `&str` with a long enough lifetime, and the legend is built from
/// the same ramp the listing uses rather than spelled out a second time.
static PRIORITY_LEGEND: LazyLock<String> = LazyLock::new(priority_legend);
/// Reject a level outside the range at parse time, so no command has to.
fn priority_level(raw: &str) -> Result<u8, String> {
match raw.parse::<u8>() {
Ok(level) if PRIORITY_RANGE.contains(&level) => Ok(level),
_ => Err(format!(
"priority must be a whole number from {} to {}",
PRIORITY_RANGE.start(),
PRIORITY_RANGE.end()
)),
}
}
/// What `--version` prints: the crate version and the commit it was built from.
///
/// The sha is the part that matters. Two binaries built weeks apart both call
@@ -13,50 +33,54 @@ const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", env!("WORKLANE_GI
#[command(version = VERSION)]
#[command(propagate_version = true)]
pub struct Cli {
/// Absent opens the board view, the way a bare `frig` does.
#[command(subcommand)]
pub command: Command,
pub command: Option<Command>,
}
/// Reject an empty value at parse time, so it lands as a usage error rather than a
/// runtime one.
///
/// An empty value looks like a way to clear a field, and clearing is not supported
/// yet. Refusing it keeps the gap visible and stops an accidentally empty variable
/// from silently blanking a field. Only the scalars use this: for the multi-line
/// sections an empty value is a paragraph break.
fn non_empty(raw: &str) -> Result<String, String> {
if raw.trim().is_empty() {
return Err("value cannot be empty, and clearing a field is not supported yet".to_string());
}
Ok(raw.to_string())
}
/// Arguments that carry prose, and therefore have to accept a value starting with
/// a hyphen.
///
/// Ticket text quotes flag names constantly, and without this a criterion reading
/// "--print is supported" is parsed as a flag and the whole ticket is refused. The
/// trade, spelled out in AGENTS.md: on these arguments a genuinely mistyped flag
/// now lands as content instead of raising a usage error. That is the right way
/// round for prose, and it is why `due`, `priority`, `tags`, `owner` and `status`
/// are deliberately left without it.
const PROSE: bool = true;
#[derive(clap::Subcommand)]
pub enum Command {
/// Initialize worklane in the current project
Init,
/// Add a new ticket to the backlog
Add {
/// Ticket title
#[arg(short, long)]
title: String,
/// Ticket description. Use multiple flags to create multiline descriptions.
#[arg(short, long)]
description: Vec<String>,
/// Acceptance criteria. Accepts multiple flags, each will be interpreted as a single criterium
#[arg(short, long)]
acceptance: Vec<String>,
/// Implementation plan. Accepts multiple flags, each will be interpreted as a single step
#[arg(short, long)]
plan: Vec<String>,
/// Tags (comma-separated)
#[arg(short = 'g', long)]
tags: Vec<String>,
/// Due date (YYYY-MM-DD)
#[arg(long)]
due: Option<String>,
/// Owner
#[arg(short, long)]
owner: Option<String>,
},
Add(AddArgs),
/// List tickets, optionally filtered by status
#[command(after_help = PRIORITY_LEGEND.as_str())]
Ls {
/// Filter by status (backlog, committed, reviewing, done)
status: Option<String>,
/// Only show tickets at this priority, 1 (most urgent) to 5 (least)
#[arg(long, value_parser = priority_level)]
priority: Option<u8>,
},
/// Show a ticket by UUID or title
@@ -79,16 +103,175 @@ pub enum Command {
force: bool,
},
/// Replace fields on an existing ticket
Set(SetArgs),
/// Add to a section of an existing ticket
Append(AppendArgs),
/// Open the board view
Tui {
/// Projects to monitor, each resolved to the first `.worklane` at or above it.
/// Several are shown as tabs. Defaults to the working directory
paths: Vec<std::path::PathBuf>,
},
/// Tick an acceptance criterion
Check(CheckArgs),
/// Untick an acceptance criterion
Uncheck(CheckArgs),
/// Add a comment to a ticket
Comment {
/// Ticket UUID or title
ticket: String,
/// Comment body (required)
#[arg(allow_hyphen_values = PROSE)]
body: String,
/// Owner
#[arg(short, long)]
owner: Option<String>,
},
/// Install the agent skill that teaches an agent to use worklane
InstallSkill {
/// Overwrite an existing copy that has been modified
#[arg(long)]
force: bool,
/// Write it to stdout instead of installing it
#[arg(long)]
print: bool,
},
}
/// `add` carries every field a new ticket can hold, so it is a struct rather than an
/// inline variant: nine parameters at the call site is what `too_many_arguments` is
/// for, and `set`, `append` and `check` already pass their arguments this way.
///
/// No `ArgGroup`: `--title` is required on its own, and everything else is optional
/// because a ticket with only a title is a valid thing to file.
#[derive(clap::Args)]
pub struct AddArgs {
/// Ticket title
#[arg(short, long, allow_hyphen_values = PROSE)]
pub title: String,
/// Ticket description. Use multiple flags to create multiline descriptions.
#[arg(short, long, allow_hyphen_values = PROSE)]
pub description: Vec<String>,
/// Acceptance criteria. Accepts multiple flags, each will be interpreted as a single criterium
#[arg(short, long, allow_hyphen_values = PROSE)]
pub acceptance: Vec<String>,
/// Implementation plan. Accepts multiple flags, each will be interpreted as a single step
#[arg(short, long, allow_hyphen_values = PROSE)]
pub plan: Vec<String>,
/// Tags (comma-separated)
#[arg(short = 'g', long)]
pub tags: Vec<String>,
/// Due date (YYYY-MM-DD)
#[arg(long)]
pub due: Option<String>,
/// Owner
#[arg(short, long)]
pub owner: Option<String>,
/// Priority, 1 (most urgent) to 5 (least). Left unset if omitted.
#[arg(long, value_parser = priority_level)]
pub priority: Option<u8>,
}
/// `set` replaces a field outright. Owner is deliberately absent: `chown` owns that
/// field, and status is `mv`'s, so no field has two writers.
///
/// The group makes at least one field mandatory, so a bare `worklane set <ticket>` is
/// a usage error rather than a silent no-op.
#[derive(clap::Args)]
#[command(group(
clap::ArgGroup::new("set_fields")
.required(true)
.multiple(true)
.args(["title", "description", "acceptance", "plan", "tags", "due", "priority"])
))]
pub struct SetArgs {
/// Ticket UUID or title
pub ticket: String,
/// Replace the ticket title, renaming the file to match
#[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
#[arg(short, long, allow_hyphen_values = PROSE)]
pub description: Vec<String>,
/// Replace the acceptance criteria. Repeat the flag, one criterium per value
#[arg(short, long, allow_hyphen_values = PROSE)]
pub acceptance: Vec<String>,
/// Replace the implementation plan. Repeat the flag, one step per value
#[arg(short, long, allow_hyphen_values = PROSE)]
pub plan: Vec<String>,
/// Replace the tags
#[arg(short = 'g', long, value_parser = non_empty)]
pub tags: Vec<String>,
/// Replace the due date (YYYY-MM-DD)
#[arg(long, value_parser = non_empty)]
pub due: Option<String>,
/// Replace the priority, 1 (most urgent) to 5 (least)
#[arg(long, value_parser = priority_level)]
pub priority: Option<u8>,
}
/// `append` only offers the sections that hold multiple lines, since appending to a
/// scalar has no meaning.
#[derive(clap::Args)]
#[command(group(
clap::ArgGroup::new("append_fields")
.required(true)
.multiple(true)
.args(["description", "acceptance", "plan"])
))]
pub struct AppendArgs {
/// Ticket UUID or title
pub ticket: String,
/// Add a paragraph to the description. Repeat the flag for more lines within it
#[arg(short, long, allow_hyphen_values = PROSE)]
pub description: Vec<String>,
/// Add acceptance criteria. Repeat the flag, one criterium per value
#[arg(short, long, allow_hyphen_values = PROSE)]
pub acceptance: Vec<String>,
/// Add implementation plan steps, numbered on from the last. Repeat the flag
#[arg(short, long, allow_hyphen_values = PROSE)]
pub plan: Vec<String>,
}
/// `check` and `uncheck` are separate commands rather than one verb with a flag,
/// because the two read as opposites at the call site and neither needs the other's
/// name to make sense.
///
/// The criterion is optional: without it the criteria are listed and the index asked
/// for, or, where there is no terminal to ask at, returned as an error carrying the
/// same list.
#[derive(clap::Args)]
pub struct CheckArgs {
/// Ticket UUID or title
pub ticket: String,
/// Criterion index as shown by `show`, or a substring of its text. Prompts if omitted
pub criterion: Option<String>,
}
+539 -101
View File
@@ -1,9 +1,11 @@
use anyhow::{Result, anyhow};
use chrono::Local;
use std::fs;
use std::io::Write;
use std::io::{BufRead, IsTerminal, Write};
use std::path::Path;
use crate::command::{AddArgs, AppendArgs, CheckArgs, SetArgs};
use crate::install;
use crate::util::*;
pub fn cmd_init(start: &Path) -> Result<()> {
@@ -29,7 +31,11 @@ pub fn cmd_init(start: &Path) -> Result<()> {
Ok(())
}
pub fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()> {
pub fn cmd_ls(
status_filter: &Option<String>,
priority_filter: Option<u8>,
worklane_dir: &Path,
) -> Result<()> {
if let Some(status) = status_filter {
let status_path = worklane_dir.join(status);
if !status_path.exists() {
@@ -39,7 +45,7 @@ pub fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()>
));
}
let items = collect_ticket_items(&status_path)?;
let items = filter_by_priority(collect_ticket_items(&status_path)?, priority_filter);
if items.is_empty() {
println!("No tickets in '{}' status.", status);
@@ -57,15 +63,15 @@ pub fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()>
if !status_path.exists() {
continue;
}
let entries: Vec<_> = fs::read_dir(&status_path)?.filter_map(|e| e.ok()).collect();
let count = entries.len();
let items = filter_by_priority(collect_ticket_items(&status_path)?, priority_filter);
let count = items.len();
let label = if count == 1 { "ticket" } else { "tickets" };
println!(" [{}] {} {}", status.to_uppercase(), count, label);
}
// Show all tickets except done grouped by status
for status in &statuses {
if *status == "done" {
if *status == DONE {
continue;
}
let status_path = worklane_dir.join(status);
@@ -73,13 +79,13 @@ pub fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()>
continue;
}
let items = match collect_ticket_items(&status_path) {
Ok(items) => items,
Ok(items) => filter_by_priority(items, priority_filter),
Err(_) => continue,
};
if items.is_empty() {
continue;
}
let status_header = color_text(&format!("[{}]", status.to_uppercase()), "orange");
let status_header = color_text(&format!("[{}]", status.to_uppercase()), Color::Orange);
println!("\n{}", status_header);
display_ticket_items(&items);
}
@@ -88,16 +94,29 @@ pub fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()>
Ok(())
}
pub fn cmd_add(
title: &str,
description: &[String],
acceptance: &[String],
plan: &[String],
tags: &[String],
due: &Option<String>,
owner: &Option<String>,
start: &Path,
) -> Result<()> {
/// Keep only the tickets at `level`, or everything when no level was asked for.
fn filter_by_priority(items: Vec<TicketItem>, level: Option<u8>) -> Vec<TicketItem> {
match level {
Some(level) => items
.into_iter()
.filter(|item| item.priority == Priority::Level(level))
.collect(),
None => items,
}
}
pub fn cmd_add(args: &AddArgs, start: &Path) -> Result<()> {
let AddArgs {
title,
description,
acceptance,
plan,
tags,
due,
owner,
priority,
} = args;
let owner = match owner {
Some(o) => Some(o.clone()),
None => get_git_user(),
@@ -120,6 +139,9 @@ pub fn cmd_add(
return Err(anyhow!("A ticket with this title already exists."));
}
// Joined with a single newline, so an empty value is how a caller spells a
// paragraph break and an all-blank description is no description at all.
let description = trim_blank_ends(description);
let description_text = if description.is_empty() {
"_No description provided._".to_string()
} else {
@@ -141,6 +163,7 @@ pub fn cmd_add(
## Metadata\n\
\n\
- **ID**: {}\n\
- **Priority**: {}\n\
- **Tags**: {}\n\
- **Due**: {}\n\
- **Owner**: {}\n\
@@ -168,6 +191,10 @@ pub fn cmd_add(
.join("\n")
},
id,
match priority {
Some(level) => level.to_string(),
None => "_Not set_".to_string(),
},
if tags.is_empty() {
"_None_".to_string()
} else {
@@ -185,7 +212,8 @@ pub fn cmd_add(
Ok(())
}
fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, String)>> {
/// Public for the TUI's detail view, which shows the same comments `show` does.
pub fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, String)>> {
if !comments_dir.exists() {
return Ok(vec![]);
}
@@ -195,7 +223,7 @@ fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, Str
for entry in fs::read_dir(comments_dir)? {
let entry = entry?;
let path = entry.path();
if path.extension().map_or(false, |e| e == "md") {
if path.extension().is_some_and(|e| e == "md") {
let content = fs::read_to_string(&path)?;
let filename = path
.file_stem()
@@ -205,14 +233,16 @@ fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, Str
let author = content
.lines()
.find(|l| l.starts_with("**Author**"))
.and_then(|l| l.splitn(2, "**Author**:").nth(1))
.and_then(|l| l.split_once("**Author**:"))
.map(|(_, value)| value)
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
let time = content
.lines()
.find(|l| l.starts_with("**Time**"))
.and_then(|l| l.splitn(2, "**Time**:").nth(1))
.and_then(|l| l.split_once("**Time**:"))
.map(|(_, value)| value)
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
@@ -273,8 +303,11 @@ pub fn cmd_show(search: &str, worklane_dir: &Path) -> Result<()> {
let (_status, title, content) = resolve_ticket(search, worklane_dir)?;
let ticket_uuid = parse_ticket_field(&content, "ID");
println!("{}", title);
println!("{}", "─".repeat(title.len()));
// The only title in the output: content_trim_colored used to print it a second
// time from the file content. Green per the colour guideline, and the rule is
// measured in characters so a non-ASCII title is not over-drawn.
println!("{}", color_text(&title, Color::Green));
println!("{}", "─".repeat(title.chars().count()));
println!("\n{}", content_trim_colored(&content));
if ticket_uuid != "_Not set_" {
@@ -287,6 +320,120 @@ pub fn cmd_show(search: &str, worklane_dir: &Path) -> Result<()> {
Ok(())
}
/// Write `content` over `path`, without ever leaving half a file behind.
///
/// Staged in a temp file and renamed into place, because `fs::write` truncates before
/// it writes and a partial write would corrupt the ticket. The temp sits under
/// `.worklane/` rather than beside the ticket, so a leftover from a hard kill is
/// invisible to ticket lookup and to the listing instead of showing up as a stray
/// untitled ticket.
fn write_then_replace(
worklane_dir: &Path,
path: &Path,
filename: &str,
content: &str,
title: &str,
) -> Result<()> {
let temp = worklane_dir.join(format!(".wl-{}.tmp", filename));
if let Err(e) = fs::write(&temp, content) {
let _ = fs::remove_file(&temp);
return Err(anyhow!(
"Could not stage the update for ticket '{}' at {}: {}",
title,
temp.display(),
e
));
}
if let Err(e) = fs::rename(&temp, path) {
let _ = fs::remove_file(&temp);
return Err(anyhow!(
"Could not write ticket '{}' at {}: {}",
title,
path.display(),
e
));
}
Ok(())
}
/// The ticket file in `dir` carrying `uuid`.
///
/// Matched on the uuid, not the title. Titles are not unique, `add` allows duplicates
/// on purpose, so a title scan could land on a different ticket than the one that was
/// resolved: `mv <uuid-of-second>` moved the first ticket sharing its title.
fn find_ticket_file(dir: &Path, uuid: &str, title: &str) -> Result<String> {
if uuid.trim().is_empty() || is_unknown_value(uuid) {
return Err(anyhow!(
"Ticket '{}' has no ID field, so its file cannot be located",
title
));
}
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if !path.extension().is_some_and(|e| e == "md") {
continue;
}
let name = match path.file_name() {
Some(name) => name.to_string_lossy().to_string(),
None => continue,
};
if name.starts_with(uuid) {
return Ok(name);
}
}
Err(anyhow!(
"Could not find the file for ticket '{}' in {}",
title,
dir.display()
))
}
/// Put `content` in `filename` and move it from `from` to `to`, without ever
/// leaving the ticket in two status directories or with half a file in it.
///
/// Two atomic steps, in this order. The content is staged in a temp file and
/// renamed over the source, so a partial write is thrown away and the original is
/// untouched. Only then is the file renamed into the target directory.
///
/// The old order renamed first and wrote second, so a failure in between left the
/// ticket sitting in its new directory still claiming the old status. Writing
/// straight to the target and deleting the source afterwards would instead have it
/// in both directories at once. Neither happens here. The worst case is a ticket
/// still in its old directory carrying a Status field one move ahead, which the
/// next `mv` corrects, since the directory is what decides the current status.
fn move_ticket_file(
worklane_dir: &Path,
from: &Path,
to: &Path,
filename: &str,
content: &str,
title: &str,
) -> Result<()> {
let source = from.join(filename);
let dest = to.join(filename);
write_then_replace(worklane_dir, &source, filename, content, title)?;
// The content is correct and in one place by now, so a failure here leaves the
// ticket where it started rather than half moved.
fs::rename(&source, &dest).map_err(|e| {
anyhow!(
"Could not move ticket '{}' to {}: {}",
title,
dest.display(),
e
)
})
}
pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -> Result<()> {
let valid_statuses = ["backlog", "committed", "reviewing", "done"];
let forward_order = ["backlog", "committed", "reviewing", "done"];
@@ -300,7 +447,7 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
}
let worklane_dir = find_worklane_dir(start)?;
let (current_status, title, _) = resolve_ticket(ticket_id, &worklane_dir)?;
let (current_status, title, resolved) = resolve_ticket(ticket_id, &worklane_dir)?;
let current_idx = forward_order
.iter()
@@ -314,8 +461,8 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
if !force && target_idx < current_idx {
return Err(anyhow!(
"Cannot move backward from {} to {}. Use --force (-f) to allow.",
color_text(&current_status, "orange"),
color_text(target_status, "orange"),
color_text(&current_status, Color::Orange),
color_text(target_status, Color::Orange),
));
}
@@ -328,7 +475,7 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
if current_status == target_status {
println!(
"Ticket is already in '{}' status.",
color_text(&target_status, "orange")
color_text(target_status, Color::Orange)
);
return Ok(());
}
@@ -336,89 +483,32 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
let current_path = worklane_dir.join(&current_status);
let target_path = worklane_dir.join(target_status);
// Find the ticket file
let mut found_filename = String::new();
for entry in fs::read_dir(&current_path)? {
let entry = entry?;
let path = entry.path();
if path.extension().map_or(false, |e| e == "md") {
let file_content = fs::read_to_string(&path)?;
let file_title = file_content
.lines()
.find(|l| l.starts_with("# "))
.map(|l| l[2..].trim())
.unwrap_or("")
.to_string();
if file_title == title {
found_filename = path.file_name().unwrap().to_string_lossy().to_string();
break;
}
}
}
// Updated before the file is even located, so a ticket without a Status field is
// refused for that reason rather than for whatever the lookup notices first.
let content = set_status_field(&resolved, target_status, &title)?;
if found_filename.is_empty() {
return Err(anyhow!(
"Could not find ticket file in {}",
color_text(&current_status, "orange")
));
}
let found_filename =
find_ticket_file(&current_path, &parse_ticket_field(&resolved, "ID"), &title)?;
// Read and update the ticket content before touching the filesystem, so a ticket
// without a Status field is never half-moved.
let source_path = current_path.join(&found_filename);
let content = fs::read_to_string(&source_path)?;
let content = set_status_field(&content, target_status, &title)?;
// Move the file
let dest_path = target_path.join(&found_filename);
fs::rename(&source_path, &dest_path)?;
// Write back updated content
fs::write(&dest_path, content)?;
move_ticket_file(
&worklane_dir,
&current_path,
&target_path,
&found_filename,
&content,
&title,
)?;
println!(
"Moved ticket '{}' from {} to {}",
color_text(&title, "green"),
color_text(&current_status, "orange"),
color_text(target_status, "orange"),
color_text(&title, Color::Green),
color_text(&current_status, Color::Orange),
color_text(target_status, Color::Orange),
);
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
/// The collision path cannot be provoked from the CLI, since two processes
/// 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 first = write_new_comment(&dir, "20260820_143012_123456", "first").unwrap();
let second = write_new_comment(&dir, "20260820_143012_123456", "second").unwrap();
let third = write_new_comment(&dir, "20260820_143012_123456", "third").unwrap();
assert_eq!(first, "20260820_143012_123456.md");
assert_eq!(second, "20260820_143012_123456_01.md");
assert_eq!(third, "20260820_143012_123456_02.md");
// Nothing was truncated on the way through
assert_eq!(fs::read_to_string(dir.join(&first)).unwrap(), "first");
assert_eq!(fs::read_to_string(dir.join(&second)).unwrap(), "second");
assert_eq!(fs::read_to_string(dir.join(&third)).unwrap(), "third");
// read_comments sorts on the stem, so the names must sort in write order
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();
}
}
pub fn cmd_comment(
ticket_id: &str,
body: &str,
@@ -464,3 +554,351 @@ pub fn cmd_comment(
println!("Comment added to '{}' ({})", title, filename);
Ok(())
}
/// The sections `set` and `append` can rewrite, paired with the flag that carries them.
///
/// One list, so both commands walk the same table and a section added later needs no
/// change here.
fn section_args<'a>(
description: &'a [String],
acceptance: &'a [String],
plan: &'a [String],
) -> [(&'static Section, &'a [String]); 3] {
[
(&DESCRIPTION, description),
(&ACCEPTANCE, acceptance),
(&PLAN, plan),
]
}
/// 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
/// reason as `mv`: a failure at the rename leaves a correct ticket under a stale name,
/// which lookup still finds by uuid or title, rather than a half-written one.
fn save_ticket(
worklane_dir: &Path,
status: &str,
uuid: &str,
title: &str,
new_title: Option<&String>,
content: &str,
) -> Result<()> {
let status_path = worklane_dir.join(status);
let filename = find_ticket_file(&status_path, uuid, title)?;
let path = status_path.join(&filename);
write_then_replace(worklane_dir, &path, &filename, content, title)?;
// The uuid is kept, so the new name cannot collide with another ticket, and an
// unchanged slug means there is nothing to rename.
if let Some(new_title) = new_title {
let renamed = format!("{}_{}.md", uuid, slug(new_title));
if renamed != filename {
let destination = status_path.join(&renamed);
fs::rename(&path, &destination).map_err(|e| {
anyhow!(
"Ticket '{}' was updated but could not be renamed to {}: {}",
title,
destination.display(),
e
)
})?;
}
}
Ok(())
}
fn report(fields: &[&str], title: &str, verb: &str) {
if fields.is_empty() {
println!("No changes to '{}'", color_text(title, Color::Green));
return;
}
println!(
"{} {} on '{}'",
verb,
fields.join(", "),
color_text(title, Color::Green)
);
}
pub fn cmd_set(args: &SetArgs, start: &Path) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let (status, title, original) = resolve_ticket(&args.ticket, &worklane_dir)?;
let uuid = parse_ticket_field(&original, "ID");
let mut content = original.clone();
let mut changed: Vec<&str> = Vec::new();
// Each edit is compared against the content going in, so a field set to the value
// it already holds is reported as unchanged rather than claimed as an update.
let mut apply = |content: &mut String, field: &'static str, next: String| {
if *content != next {
content.clone_from(&next);
changed.push(field);
}
};
if let Some(new_title) = &args.title {
let next = set_title(&content, new_title)?;
apply(&mut content, "title", next);
}
for (section, values) in section_args(&args.description, &args.acceptance, &args.plan) {
if values.is_empty() {
continue;
}
let items = section.normalise(values);
if items.is_empty() {
return Err(anyhow!(
"An empty {} is not a way to clear the section, and clearing is not supported yet",
section.label
));
}
let next = set_section_body(&content, section, &items)?;
apply(&mut content, section.label, next);
}
if !args.tags.is_empty() {
let next = set_metadata_field(&content, "Tags", &args.tags.join(", "), &title)?;
apply(&mut content, "tags", next);
}
if let Some(due) = &args.due {
let next = set_metadata_field(&content, "Due", due, &title)?;
apply(&mut content, "due", next);
}
if let Some(priority) = args.priority {
let next = set_metadata_field(&content, "Priority", &priority.to_string(), &title)?;
apply(&mut content, "priority", next);
}
if changed.is_empty() {
report(&changed, &title, "Updated");
return Ok(());
}
let renamed = changed.contains(&"title").then_some(()).and(args.title.as_ref());
save_ticket(&worklane_dir, &status, &uuid, &title, renamed, &content)?;
let shown = args.title.clone().unwrap_or(title);
report(&changed, &shown, "Updated");
Ok(())
}
pub fn cmd_append(args: &AppendArgs, start: &Path) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let (status, title, original) = resolve_ticket(&args.ticket, &worklane_dir)?;
let uuid = parse_ticket_field(&original, "ID");
let mut content = original.clone();
let mut changed: Vec<&str> = Vec::new();
for (section, values) in section_args(&args.description, &args.acceptance, &args.plan) {
if values.is_empty() {
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
));
}
content = append_section_body(&content, section, &items)?;
changed.push(section.label);
}
save_ticket(&worklane_dir, &status, &uuid, &title, None, &content)?;
report(&changed, &title, "Appended to");
Ok(())
}
/// Which criterion to act on, asked for when the caller did not say.
///
/// A terminal gets the list and a prompt. Anything else gets the same list as an
/// error, which is what `resolve_ticket` does for an ambiguous match and for the same
/// reason: the opencode wrapper throws on the exit code and keeps stderr, so a list
/// printed to stdout would be discarded and an agent would learn nothing. Prompting
/// regardless would leave it blocked on a stdin that never closes.
fn ask_which_criterion(criteria: &[Criterion], title: &str) -> Result<usize> {
let listing = criteria_list(criteria);
if !std::io::stdin().is_terminal() {
return Err(anyhow!(
"Which criterion of '{}'?\n{}\n\nRe-run with the number, or a substring of the text.",
title,
listing
));
}
println!("Acceptance criteria of '{}':", color_text(title, Color::Green));
println!("{}", listing);
// Either form, since find_criteria takes both.
print!("Number or text: ");
std::io::stdout().flush()?;
let mut answer = String::new();
std::io::stdin().lock().read_line(&mut answer)?;
// An empty needle matches every criterion, so it would otherwise be reported as
// ambiguous rather than as nothing having been chosen.
if answer.trim().is_empty() {
return Err(anyhow!("No criterion chosen"));
}
let chosen = find_criteria(criteria, &answer);
match chosen.len() {
1 => Ok(chosen[0]),
0 => Err(anyhow!(
"'{}' matches none of the {} criteria",
answer.trim(),
criteria.len()
)),
_ => Err(anyhow!(
"'{}' matches more than one criterion, use the number",
answer.trim()
)),
}
}
pub fn cmd_check(args: &CheckArgs, checked: bool, start: &Path) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let (status, title, content) = resolve_ticket(&args.ticket, &worklane_dir)?;
let criteria = criteria(&content);
if criteria.is_empty() {
return Err(anyhow!("Ticket '{}' has no acceptance criteria", title));
}
let chosen = match &args.criterion {
None => ask_which_criterion(&criteria, &title)?,
Some(search) => {
let found = find_criteria(&criteria, search);
match found.len() {
1 => found[0],
0 if is_index(search) => {
return Err(anyhow!(
"'{}' is not one of the {} criteria of '{}':\n{}",
search.trim(),
criteria.len(),
title,
criteria_list(&criteria)
));
}
0 => {
return Err(anyhow!(
"No criterion of '{}' matches '{}'. Its criteria are:\n{}",
title,
search,
criteria_list(&criteria)
));
}
_ => {
return Err(anyhow!(
"'{}' matches {} criteria of '{}':\n{}\n\nUse the number instead.",
search,
found.len(),
title,
numbered_criteria(&criteria, &found)
));
}
}
}
};
let criterion = &criteria[chosen];
let verb = if checked { "checked" } else { "unchecked" };
if criterion.checked == checked {
println!(
"Already {}: {}",
verb,
color_text(&criterion.text, Color::Green)
);
return Ok(());
}
let updated = set_criterion(&content, criterion.line, checked);
let uuid = parse_ticket_field(&content, "ID");
save_ticket(&worklane_dir, &status, &uuid, &title, None, &updated)?;
println!(
"{} {}: {}",
if checked { "Checked" } else { "Unchecked" },
chosen + 1,
color_text(&criterion.text, Color::Green)
);
Ok(())
}
/// Install the agent skill, or print it so a modified copy can be diffed.
///
/// No board is looked for. The document is what teaches an agent worklane, so needing
/// a `.worklane` to install it would put it out of reach exactly when it is wanted.
pub fn cmd_install_skill(force: bool, print: bool) -> Result<()> {
if print {
print!("{}", install::SKILL.content);
return Ok(());
}
let root = install::skills_root()?;
match install::SKILL.install(&root, force)? {
install::Outcome::Written(path) => {
println!("Installed the worklane {} to: {}", install::SKILL.what, path.display());
println!("Claude Code and opencode pick it up on their next session");
}
install::Outcome::Unchanged(path) => {
println!("Already up to date: {}", path.display());
}
install::Outcome::Refused(path) => {
println!("Differs from the version in this binary: {}", path.display());
println!(
"Compare with `worklane install-skill --print`, or overwrite with --force"
);
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
/// The collision path cannot be provoked from the CLI, since two processes
/// 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 first = write_new_comment(&dir, "20260820_143012_123456", "first").unwrap();
let second = write_new_comment(&dir, "20260820_143012_123456", "second").unwrap();
let third = write_new_comment(&dir, "20260820_143012_123456", "third").unwrap();
assert_eq!(first, "20260820_143012_123456.md");
assert_eq!(second, "20260820_143012_123456_01.md");
assert_eq!(third, "20260820_143012_123456_02.md");
// Nothing was truncated on the way through
assert_eq!(fs::read_to_string(dir.join(&first)).unwrap(), "first");
assert_eq!(fs::read_to_string(dir.join(&second)).unwrap(), "second");
assert_eq!(fs::read_to_string(dir.join(&third)).unwrap(), "third");
// read_comments sorts on the stem, so the names must sort in write order
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();
}
}
+282
View File
@@ -0,0 +1,282 @@
//! Shipping the agent assets with the binary.
//!
//! The skill document lives at `assets/SKILL.md` in this repo and is embedded with
//! `include_str!` rather than copied by an install script, because `cargo install`
//! places binaries and nothing else. Embedding means the document can never be a
//! different version from the binary it describes, and there is no second file to
//! lose track of.
//!
//! The machinery is written once for both assets this repo will ship. The tool file
//! for opencode is executable code needing Bun, so it gets its own command and its
//! own root, but the compare-and-refuse logic is the same and lives here.
use std::io;
use std::path::{Path, PathBuf};
use anyhow::{Result, anyhow};
/// One thing the binary carries and can write into a user's agent configuration.
pub struct Asset {
/// What it is called in messages, e.g. `skill`.
pub what: &'static str,
/// Where it goes under its root, e.g. `worklane/SKILL.md`.
pub relative: &'static str,
pub content: &'static str,
}
/// The skill document, as of the commit this binary was built from.
pub const SKILL: Asset = Asset {
what: "skill",
relative: "worklane/SKILL.md",
content: include_str!("../assets/SKILL.md"),
};
/// Where a skill has to sit to be found, for both agents worklane is used from.
///
/// One path serves both. Claude Code reads `~/.claude/skills/<name>/SKILL.md`, and
/// opencode loads that same directory as an external skill source, alongside its own
/// `~/.config/opencode/skill/`. Checked against opencode 1.15.10, whose built-in
/// `customize-opencode` skill documents it and whose `opencode debug skill` lists the
/// documents found there. Writing both paths would be two copies of one document, free
/// to drift apart, for no gain.
pub fn skills_root() -> Result<PathBuf> {
let home = std::env::var_os("HOME").ok_or_else(|| {
anyhow!("cannot tell where your skills live because HOME is not set in the environment")
})?;
Ok(Path::new(&home).join(".claude/skills"))
}
#[derive(Debug, PartialEq, Eq)]
pub enum Outcome {
Written(PathBuf),
/// Already byte-identical, so writing it again would be a no-op.
Unchanged(PathBuf),
/// Present but different, and no `--force`. Refused rather than overwritten: it
/// may have been edited on purpose, and silently discarding that is worse than
/// stopping.
Refused(PathBuf),
}
impl Asset {
pub fn path(&self, root: &Path) -> PathBuf {
root.join(self.relative)
}
/// Write the asset under `root`, unless what is there is the same or was changed.
///
/// The root is passed in rather than looked up, so a test can install into a
/// temporary directory instead of the home of whoever runs the suite.
pub fn install(&self, root: &Path, force: bool) -> io::Result<Outcome> {
let path = self.path(root);
// A read error is not treated as "absent": the write below reports it, with
// the real reason, rather than this guessing that the file is missing.
match std::fs::read_to_string(&path) {
Ok(existing) if existing == self.content => return Ok(Outcome::Unchanged(path)),
Ok(_) if !force => return Ok(Outcome::Refused(path)),
_ => {}
}
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)?;
}
std::fs::write(&path, self.content)?;
Ok(Outcome::Written(path))
}
}
/// The `name:` and `description:` from the YAML frontmatter.
///
/// Used by the tests that guard the shipping mechanism, which is the only thing that
/// needs it: both agents decide whether to load a document from these two fields, and
/// a document missing them is ignored in silence.
#[cfg_attr(not(test), allow(dead_code))]
fn frontmatter_field(text: &str, key: &str) -> Option<String> {
let body = text.strip_prefix("---\n")?;
let end = body.find("\n---")?;
body[..end]
.lines()
.find_map(|line| line.strip_prefix(&format!("{key}:")))
.map(|value| value.trim().to_string())
}
#[cfg(test)]
mod tests {
use super::*;
fn root() -> tempfile::TempDir {
tempfile::tempdir().unwrap()
}
#[test]
fn the_skill_installs_into_a_directory_that_does_not_exist_yet() {
let root = root();
let path = SKILL.path(root.path());
assert_eq!(
SKILL.install(root.path(), false).unwrap(),
Outcome::Written(path.clone())
);
assert_eq!(std::fs::read_to_string(&path).unwrap(), SKILL.content);
}
/// Installing twice is a no-op rather than a rewrite, so the mtime of an
/// up-to-date copy does not move.
#[test]
fn a_second_install_reports_the_copy_unchanged() {
let root = root();
SKILL.install(root.path(), false).unwrap();
assert_eq!(
SKILL.install(root.path(), false).unwrap(),
Outcome::Unchanged(SKILL.path(root.path()))
);
}
/// The case worth being careful about: an edited copy is someone's work.
#[test]
fn a_modified_copy_is_refused_and_left_alone() {
let root = root();
let path = SKILL.path(root.path());
SKILL.install(root.path(), false).unwrap();
std::fs::write(&path, "hand written\n").unwrap();
assert_eq!(
SKILL.install(root.path(), false).unwrap(),
Outcome::Refused(path.clone())
);
assert_eq!(std::fs::read_to_string(&path).unwrap(), "hand written\n");
assert_eq!(
SKILL.install(root.path(), true).unwrap(),
Outcome::Written(path.clone())
);
assert_eq!(std::fs::read_to_string(&path).unwrap(), SKILL.content);
}
#[test]
fn the_skill_lands_where_both_agents_look_for_it() {
let root = skills_root().unwrap();
assert!(root.ends_with(".claude/skills"), "{}", root.display());
assert!(
SKILL.path(&root).ends_with(".claude/skills/worklane/SKILL.md"),
"{}",
SKILL.path(&root).display()
);
}
#[test]
fn the_embedded_skill_has_usable_frontmatter() {
// Guards the whole shipping mechanism: without frontmatter, or under a name
// that does not match its directory, both agents ignore the document and
// nothing else would notice.
assert_eq!(frontmatter_field(SKILL.content, "name").as_deref(), Some("worklane"));
let description =
frontmatter_field(SKILL.content, "description").expect("a description to trigger on");
assert!(
description.len() > 80,
"the description is what decides whether the skill loads at all"
);
}
/// Every code span and fenced-block line, which is where commands live.
///
/// Prose has to be excluded: the document opens by calling worklane a kanban
/// board, and treating that sentence as a command makes the check useless.
fn code_snippets(text: &str) -> Vec<String> {
let mut snippets = Vec::new();
let mut fenced = false;
for line in text.lines() {
if line.trim_start().starts_with("```") {
fenced = !fenced;
continue;
}
if fenced {
snippets.push(line.to_string());
continue;
}
// Inline spans: the odd-numbered pieces between backticks.
for (index, piece) in line.split('`').enumerate() {
if index % 2 == 1 {
snippets.push(piece.to_string());
}
}
}
snippets
}
#[test]
fn the_embedded_skill_only_names_commands_that_exist() {
// Taken from clap rather than written out here. A hand-maintained list is the
// very drift this test exists to catch.
use clap::CommandFactory;
let mut known: Vec<String> = crate::Cli::command()
.get_subcommands()
.map(|c| c.get_name().to_string())
.collect();
known.push("--help".to_string());
known.push("--version".to_string());
let mut checked = 0;
for snippet in code_snippets(SKILL.content) {
let mut words = snippet.split_whitespace();
// Only a snippet that *starts* with worklane is a command being shown.
if words.next() != Some("worklane") {
continue;
}
let Some(candidate) = words.next() else { continue };
// A flag before the subcommand, as in the `mv -- -leading-title` example.
if candidate.starts_with("--") && !known.iter().any(|k| k == candidate) {
continue;
}
checked += 1;
assert!(
known.iter().any(|k| k == candidate),
"the skill shows `worklane {candidate}`, which is not a subcommand"
);
}
assert!(checked > 8, "expected the skill to show commands, checked only {checked}");
}
/// Subcommands the skill has no business teaching: the board is interactive and
/// belongs to a person, `install-skill` is how the document arrived, and `help`
/// is clap's own.
const NOT_FOR_AGENTS: [&str; 3] = ["tui", "install-skill", "help"];
/// The converse, and the one that goes stale on its own: a *new* subcommand absent
/// from the skill is invisible to an agent, and nothing else would notice.
#[test]
fn every_agent_facing_subcommand_is_documented() {
use clap::CommandFactory;
for command in crate::Cli::command().get_subcommands() {
let name = command.get_name();
if NOT_FOR_AGENTS.contains(&name) {
continue;
}
assert!(
SKILL.content.contains(&format!("worklane {name}")),
"the skill never mentions `worklane {name}`, so an agent will not know it exists"
);
}
}
/// The facts an agent cannot infer from the help output and would get wrong.
#[test]
fn the_embedded_skill_documents_what_the_help_does_not() {
for required in [
"committed",
"as you work it",
"UUID prefix",
"leading hyphen",
"Search the backlog before filing",
] {
assert!(
SKILL.content.contains(required),
"the skill no longer mentions {required:?}"
);
}
}
}
+156 -25
View File
@@ -3,50 +3,181 @@ use clap::Parser;
mod command;
mod handlers;
mod install;
mod tui;
mod util;
use command::*;
use handlers::*;
use util::*;
/// Die quietly when stdout is closed early, the way every other Unix tool does.
///
/// Rust sets `SIGPIPE` to `SIG_IGN` at startup, which turns a closed pipe into an
/// io error that `println!` panics on. So `worklane ls | head -3` printed a panic
/// and a backtrace instead of three lines, which is both alarming and easy to
/// mistake for a real fault. Restoring the default handler makes `| head` behave.
///
/// The cost is that a truncated pipe now kills the process with signal 13 rather
/// than returning a code, so `pipefail` sees 141 instead of 101. That is what
/// `head` and `sort` do, and it is recorded in the README.
fn quiet_broken_pipe() {
// SAFETY: setting a signal disposition to the default is always valid, and
// this runs before any thread is spawned.
unsafe {
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
}
}
fn main() -> Result<()> {
// Before any output, so no write can beat it to a closed pipe.
quiet_broken_pipe();
let cli = Cli::parse();
let start = std::env::current_dir()?;
match cli.command {
Command::Init => cmd_init(&start),
Command::Add {
title,
description,
acceptance,
plan,
tags,
due,
owner,
} => cmd_add(
&title,
&description,
&acceptance,
&plan,
&tags,
&due,
&owner,
&start,
),
Command::Ls { status } => {
// No subcommand opens the board, the way a bare `frig` does, and with no path
// it opens the board above the working directory.
None => run_tui(&[], &start),
Some(Command::Tui { paths }) => run_tui(&paths, &start),
Some(Command::Init) => cmd_init(&start),
Some(Command::Add(args)) => cmd_add(&args, &start),
Some(Command::Ls { status, priority }) => {
let worklane_dir = find_worklane_dir(&start)?;
cmd_ls(&status, &worklane_dir)
cmd_ls(&status, priority, &worklane_dir)
}
Command::Show { id } => {
Some(Command::Show { id }) => {
let worklane_dir = find_worklane_dir(&start)?;
cmd_show(&id, &worklane_dir)
}
Command::Mv {
Some(Command::Mv {
ticket,
status,
force,
} => cmd_mv(&ticket, &status, force, &start),
Command::Comment { ticket, body, owner } => cmd_comment(&ticket, &body, &owner, &start),
}) => cmd_mv(&ticket, &status, force, &start),
Some(Command::Set(args)) => cmd_set(&args, &start),
Some(Command::Append(args)) => cmd_append(&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),
// No board is looked for: the point of the skill is to teach an agent worklane
// before there is a `.worklane` anywhere.
Some(Command::InstallSkill { force, print }) => cmd_install_skill(force, print),
}
}
// ---------------------------------------------------------------------- tui --
/// Restore the terminal whatever happens.
///
/// A panic inside the draw loop with raw mode still on leaves the shell unusable and
/// the backtrace unreadable, so the hook runs before the default one.
fn install_panic_hook() {
let previous = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
let _ = restore_terminal();
previous(info);
}));
}
fn restore_terminal() -> std::io::Result<()> {
crossterm::terminal::disable_raw_mode()?;
crossterm::execute!(
std::io::stdout(),
crossterm::terminal::LeaveAlternateScreen
)
}
fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()> {
use crossterm::event::{self, Event, KeyCode, KeyEventKind, KeyModifiers};
use std::io::IsTerminal;
// The boards are looked for before the terminal is, so running this outside a
// worklane directory gives the same message every other command gives rather than
// a complaint about the terminal.
let projects = tui::projects(paths, start)?;
// Without this, entering raw mode on a pipe fails with a bare "No such device or
// address (os error 6)", which says nothing about the actual mistake. A bare
// `worklane` is how the board is opened, so a script that reaches it by accident
// has to be pointed at a subcommand.
if !std::io::stdin().is_terminal() {
return Err(anyhow::anyhow!(
"`worklane` with no subcommand opens the board, which needs a terminal.\n\
For scripted use try `worklane ls` or `worklane show`; `worklane --help` \
lists everything."
));
}
let mut board = tui::Board::new(projects)?;
install_panic_hook();
crossterm::terminal::enable_raw_mode()?;
crossterm::execute!(std::io::stdout(), crossterm::terminal::EnterAlternateScreen)?;
let mut terminal =
ratatui::Terminal::new(ratatui::backend::CrosstermBackend::new(std::io::stdout()))?;
let result = (|| -> Result<()> {
while !board.should_quit {
board.tick()?;
terminal.draw(|frame| tui::draw(frame, &board))?;
// Taken after the draw, so a scroll measures the overlay that is on screen.
let screen = terminal.size()?;
// Bounded, so the tick still runs when nobody is typing.
if !event::poll(tui::POLL)? {
continue;
}
let Event::Key(key) = event::read()? else {
continue;
};
if key.kind != KeyEventKind::Press {
continue;
}
match key.code {
KeyCode::Char('q') => board.should_quit = true,
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
board.should_quit = true
}
// Esc closes the detail view, and only quits when there is nothing
// left to dismiss.
KeyCode::Esc => match board.detail {
Some(_) => board.toggle_detail(),
None => board.should_quit = true,
},
KeyCode::Enter | KeyCode::Char(' ') => board.toggle_detail(),
KeyCode::Left | KeyCode::Char('h') => board.select_column(-1, screen),
KeyCode::Right | KeyCode::Char('l') => board.select_column(1, screen),
// Up and down stay on the selection, open detail view or not, so a
// column can be read through without closing the modal. Scrolling the
// open ticket is a page at a time.
KeyCode::Up | KeyCode::Char('k') => board.select_card(-1, screen),
KeyCode::Down | KeyCode::Char('j') => board.select_card(1, screen),
KeyCode::PageUp => board.scroll_detail(-1, screen),
KeyCode::PageDown => board.scroll_detail(1, screen),
// Tabs cycle rather than clamp, the way tabs everywhere do, and are
// a no-op with a single board. Free of every other binding: the
// columns took hjkl and the arrows.
KeyCode::Tab => board.select_tab(1, screen),
KeyCode::BackTab => board.select_tab(-1, screen),
// Free of the other bindings, and the footer names it in both states.
KeyCode::Char('d') => board.toggle_done(screen),
_ => {}
}
}
Ok(())
})();
// Before the error surfaces, so a failure does not leave the shell in raw mode.
restore_terminal()?;
result
}
+2669
View File
File diff suppressed because it is too large Load Diff
+1539 -167
View File
File diff suppressed because it is too large Load Diff
+173
View File
@@ -0,0 +1,173 @@
use assert_fs::TempDir;
use assert_fs::fixture::{PathChild, PathCreateDir};
use std::fs;
use std::os::unix::process::ExitStatusExt;
use std::process::{Command, Stdio};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
/// What a truncated pipe costs: the process dies by signal rather than returning a
/// code, so a shell reports 128 + 13. Asserted here so the README and the code stay
/// honest about what `pipefail` sees.
const SIGPIPE: i32 = 13;
/// A pipe holds 64 KiB on Linux before a write blocks. Below that the whole listing
/// lands in the buffer, the writer never notices the reader is gone, and a test
/// proves nothing. Every ticket here is one `ls` row of roughly a hundred bytes.
const TICKETS: usize = 1200;
fn setup_crowded_board(temp: &TempDir) -> std::path::PathBuf {
let worklane = temp.child(".worklane");
worklane.create_dir_all().unwrap();
for dir in ["backlog", "committed", "reviewing", "done"] {
worklane.child(dir).create_dir_all().unwrap();
}
let backlog = worklane.path().join("backlog");
for i in 0..TICKETS {
let id = format!("{:08x}-0000-4000-8000-000000000000", i);
let title = format!("A ticket with a title long enough to fill a row {}", i);
fs::write(
backlog.join(format!("{}_ticket-{}.md", id, i)),
format!(
"# {}\n\n## Metadata\n\n\
- **ID**: {}\n\
- **Owner**: someone with a name\n\
- **Status**: backlog\n",
title, id
),
)
.unwrap();
}
temp.path().to_path_buf()
}
fn panic_text(stderr: &str) -> bool {
stderr.contains("panicked")
|| stderr.contains("failed printing to stdout")
|| stderr.contains("Broken pipe")
}
/// The reader closed before the writer finished: dropping the read end here is the
/// same thing `head` does when it has seen enough, without the timing luck.
fn run_with_stdout_dropped(dir: &std::path::Path, args: &[&str]) -> std::process::Output {
let mut child = Command::new(BIN_NAME)
.args(args)
.current_dir(dir)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.unwrap();
drop(child.stdout.take().unwrap());
child.wait_with_output().unwrap()
}
#[test]
fn ls_says_nothing_when_the_reader_goes_away() {
let temp = TempDir::new().unwrap();
let dir = setup_crowded_board(&temp);
let output = run_with_stdout_dropped(&dir, &["ls", "backlog"]);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(!panic_text(&stderr), "stderr was {stderr:?}");
assert_ne!(output.status.code(), Some(101), "panicked instead of dying");
assert_eq!(
output.status.signal(),
Some(SIGPIPE),
"expected death by SIGPIPE, got {:?}",
output.status
);
}
#[test]
fn show_says_nothing_when_the_reader_goes_away() {
let temp = TempDir::new().unwrap();
let dir = setup_crowded_board(&temp);
// A ticket carrying more comments than a pipe will hold, since the comment list
// is the longest thing show prints and the last thing it reaches.
let comments = temp
.path()
.join(".worklane")
.join("comments")
.join("00000000-0000-4000-8000-000000000000");
fs::create_dir_all(&comments).unwrap();
for i in 0..800 {
fs::write(
comments.join(format!("2026082{}_120000_{:06}.md", i % 10, i)),
format!(
"**Comment**\nA comment body long enough to be worth buffering, number {}.\n\n\
**Author**: someone\n**Time**: 2026-08-20 12:00:00\n",
i
),
)
.unwrap();
}
let output = run_with_stdout_dropped(&dir, &["show", "00000000-0000-4000"]);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(!panic_text(&stderr), "stderr was {stderr:?}");
assert_ne!(output.status.code(), Some(101), "panicked instead of dying");
assert_eq!(
output.status.signal(),
Some(SIGPIPE),
"expected death by SIGPIPE, got {:?}",
output.status
);
}
/// The real invocation, through a shell into `head`, which is how this was found.
/// Whether the writer gets far enough to notice is up to the scheduler, so this
/// asserts only what must hold either way: `head` gets its lines and nothing
/// alarming reaches stderr.
#[test]
fn a_shell_pipeline_into_head_prints_lines_and_not_a_panic() {
let temp = TempDir::new().unwrap();
let dir = setup_crowded_board(&temp);
let output = Command::new("sh")
.arg("-c")
.arg(format!("{} ls backlog | head -3", BIN_NAME))
.current_dir(&dir)
.output()
.unwrap();
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
assert_eq!(stdout.lines().count(), 3, "stdout was {stdout:?}");
assert!(!panic_text(&stderr), "stderr was {stderr:?}");
}
/// The reset must not touch anything else: a real failure still returns its code.
#[test]
fn real_exit_codes_are_unchanged() {
let temp = TempDir::new().unwrap();
let dir = setup_crowded_board(&temp);
let ok = Command::new(BIN_NAME)
.args(["ls", "backlog"])
.current_dir(&dir)
.output()
.unwrap();
assert_eq!(ok.status.code(), Some(0));
let missing = Command::new(BIN_NAME)
.args(["show", "no-such-ticket-anywhere"])
.current_dir(&dir)
.output()
.unwrap();
assert_eq!(missing.status.code(), Some(1));
let misuse = Command::new(BIN_NAME)
.arg("--bogus")
.current_dir(&dir)
.output()
.unwrap();
assert_eq!(misuse.status.code(), Some(2));
}
+266 -8
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use assert_fs::fixture::{PathChild, PathCreateDir};
use assert_fs::TempDir;
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
@@ -23,7 +23,7 @@ fn add_creates_ticket_in_backlog() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("add")
.args(["--title", "Test ticket"])
.assert()
@@ -46,7 +46,7 @@ fn add_formats_ticket_correctly() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args([
"add",
"--title",
@@ -103,7 +103,7 @@ fn add_joins_multiple_descriptions() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args([
"add",
"--title", "Multi desc ticket",
@@ -132,7 +132,7 @@ fn add_with_optional_fields_uses_defaults() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Minimal ticket"])
.assert()
.success();
@@ -156,13 +156,13 @@ fn add_allows_duplicate_titles() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Existing title"])
.assert()
.success();
let mut cmd2 = Command::cargo_bin(BIN_NAME).unwrap();
cmd2.current_dir(&temp.path())
cmd2.current_dir(temp.path())
.args(["add", "--title", "Existing title"])
.assert()
.success();
@@ -182,7 +182,7 @@ fn add_file_has_uuid_prefix() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "UUID test"])
.assert()
.success();
@@ -199,3 +199,261 @@ fn add_file_has_uuid_prefix() {
assert_eq!(parts[0].len(), 36);
assert_eq!(parts[0].chars().filter(|c| c.is_ascii_hexdigit()).count(), 32);
}
#[test]
fn add_writes_the_priority_field() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(temp.path())
.args(["add", "--title", "Urgent thing", "--priority", "1"])
.assert()
.success();
let files: Vec<_> = fs::read_dir(temp.child(".worklane").join("backlog"))
.unwrap()
.filter_map(|e| e.ok())
.collect();
let content = fs::read_to_string(files[0].path()).unwrap();
assert!(content.contains("- **Priority**: 1"), "was {content:?}");
}
#[test]
fn add_leaves_priority_unset_when_omitted() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(temp.path())
.args(["add", "--title", "Whenever"])
.assert()
.success();
let files: Vec<_> = fs::read_dir(temp.child(".worklane").join("backlog"))
.unwrap()
.filter_map(|e| e.ok())
.collect();
let content = fs::read_to_string(files[0].path()).unwrap();
assert!(content.contains("- **Priority**: _Not set_"), "was {content:?}");
}
/// Rejected at parse time, so no ticket is written at all.
#[test]
fn add_rejects_a_level_outside_the_range() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
// The `=` form, so a negative value reaches the validator instead of being
// read as a flag.
for bad in ["0", "6", "high", "-1"] {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title", "Bad level", &format!("--priority={bad}")])
.assert()
.failure();
let stderr = String::from_utf8(cmd.assert().get_output().stderr.clone()).unwrap();
assert!(stderr.contains("priority must be"), "for {bad}: {stderr}");
}
let count = fs::read_dir(worklane.join("backlog")).unwrap().count();
assert_eq!(count, 0, "a ticket was written despite a bad level");
}
/// Ticket text quotes flag names constantly, and the space form is what both a
/// person and the opencode wrapper produce. Every one of these used to be refused
/// with "unexpected argument found", writing no ticket at all.
#[test]
fn add_accepts_prose_values_that_begin_with_a_hyphen() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title", "-t is a flag name"])
.args(["--description", "-x does nothing"])
.args(["--acceptance", "--print should be supported"])
.args(["--plan", "-f skips the check"])
.assert()
.success();
let content = only_ticket(&worklane);
// Stored verbatim, hyphens and all
assert!(content.contains("# -t is a flag name"), "was {content:?}");
assert!(content.contains("-x does nothing"), "was {content:?}");
assert!(
content.contains("- [ ] --print should be supported"),
"was {content:?}"
);
assert!(content.contains("1. -f skips the check"), "was {content:?}");
}
/// The docs and the habit both use it, and it reaches the parser as one token, so
/// it has to keep working alongside the space form.
#[test]
fn add_still_accepts_the_equals_form() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title=-x equals form"])
.args(["--acceptance=--print via equals"])
.assert()
.success();
let content = only_ticket(&worklane);
assert!(content.contains("# -x equals form"), "was {content:?}");
assert!(
content.contains("- [ ] --print via equals"),
"was {content:?}"
);
}
/// Never silently dropped: a value that is nothing but hyphens is content.
#[test]
fn add_stores_a_title_that_is_only_hyphens() {
for bare in ["-", "--", "---"] {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title", bare])
.assert()
.success();
let content = only_ticket(&worklane);
assert!(
content.starts_with(&format!("# {}\n", bare)),
"for {bare:?}: {content:?}"
);
}
}
/// The other half of the trade. These arguments were deliberately left alone, so a
/// mistyped flag there is still a usage error rather than stored text.
#[test]
fn add_still_rejects_a_mistyped_flag_on_a_non_prose_argument() {
for flag in ["--due", "--priority", "--tags", "--owner"] {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title", "Mistyped", flag, "--bogus"])
.assert()
.failure();
let count = fs::read_dir(worklane.join("backlog")).unwrap().count();
assert_eq!(count, 0, "{flag} wrote a ticket anyway");
}
}
/// `add` has no positionals, so a bare `--` ends the options and whatever follows
/// has nowhere to go. Recorded because clap's separator and a hyphen-leading value
/// are easy to confuse.
#[test]
fn add_rejects_arguments_after_a_bare_separator() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title", "Sep", "--", "--title", "second"])
.assert()
.failure();
let count = fs::read_dir(worklane.join("backlog")).unwrap().count();
assert_eq!(count, 0);
}
fn only_ticket(worklane: &Path) -> String {
let files: Vec<_> = fs::read_dir(worklane.join("backlog"))
.unwrap()
.filter_map(|e| e.ok())
.collect();
assert_eq!(files.len(), 1, "expected exactly one ticket");
fs::read_to_string(files[0].path()).unwrap()
}
/// The contract the opencode wrapper relies on: values are joined with a single
/// newline, so an empty value is how a paragraph break is spelled. The wrapper used
/// to drop those blanks, collapsing every multi paragraph description into one.
#[test]
fn add_keeps_a_paragraph_break_in_the_description() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title", "Two Paras"])
.args(["--description", "First paragraph."])
.args(["--description", ""])
.args(["--description", "Second paragraph."])
.assert()
.success();
let content = only_ticket(&worklane);
assert!(
content.contains("## Description\nFirst paragraph.\n\nSecond paragraph.\n"),
"was {content:?}"
);
// And it survives the round trip back out
let mut show = Command::cargo_bin(BIN_NAME).unwrap();
show.current_dir(temp.path()).args(["show", "Two Paras"]);
let stdout = String::from_utf8(show.assert().success().get_output().stdout.clone()).unwrap();
assert!(
stdout.contains("First paragraph.\n\nSecond paragraph."),
"was {stdout:?}"
);
}
/// A break belongs between paragraphs, not against the section headings.
#[test]
fn add_discards_blank_descriptions_at_either_end() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title", "Padded"])
.args(["--description", ""])
.args(["--description", " "])
.args(["--description", "The only line."])
.args(["--description", ""])
.assert()
.success();
let content = only_ticket(&worklane);
assert!(
content.contains("## Description\nThe only line.\n\n## Acceptance Criteria"),
"was {content:?}"
);
}
/// Nothing but blanks is no description, not an empty section.
#[test]
fn add_treats_an_all_blank_description_as_none() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["add", "--title", "Blank"])
.args(["--description", ""])
.args(["--description", " "])
.assert()
.success();
let content = only_ticket(&worklane);
assert!(
content.contains("## Description\n_No description provided._"),
"was {content:?}"
);
}
+287
View File
@@ -0,0 +1,287 @@
use assert_cmd::Command;
use assert_fs::TempDir;
use assert_fs::fixture::{PathChild, PathCreateDir};
use std::fs;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
const UUID: &str = "475534a3-8a0d-45cb-9a97-39c251dd8e39";
fn setup_worklane(temp: &TempDir) -> PathBuf {
let worklane = temp.child(".worklane");
worklane.create_dir_all().unwrap();
for dir in ["backlog", "committed", "reviewing", "done"] {
worklane.child(dir).create_dir_all().unwrap();
}
worklane.path().to_path_buf()
}
/// One criterion already ticked, one handwritten line inside the section, and a
/// checkbox in the description that must not be counted as a criterion.
fn create_ticket(worklane: &Path) {
// Written without line continuations on purpose: a trailing `\` strips the next
// line's leading whitespace, so the indented line would arrive unindented and the
// test would prove nothing about preserving it.
let lines = [
"# Check me",
"",
"## Description",
"- [ ] A checkbox in the description, which is not a criterion.",
"",
"## Acceptance Criteria",
"- [ ] alpha shared",
"- [x] beta alone",
" A handwritten line inside the section.",
"- [ ] gamma shared",
"",
"## Implementation Plan",
"1. Step one",
"",
"## Metadata",
"",
&format!("- **ID**: {}", UUID),
"- **Status**: backlog",
"",
];
fs::write(
worklane.join("backlog").join(format!("{}_check-me.md", UUID)),
lines.join("\n"),
)
.unwrap();
}
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(args);
cmd.assert().get_output().clone()
}
fn ticket(worklane: &Path) -> String {
fs::read_to_string(worklane.join("backlog").join(format!("{}_check-me.md", UUID))).unwrap()
}
/// The whole point: one line changes and every other keeps its state.
#[test]
fn check_ticks_one_criterion_by_index() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["check", UUID, "1"]);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let content = ticket(&worklane);
assert!(content.contains("- [x] alpha shared\n"), "{content}");
assert!(content.contains("- [x] beta alone\n"), "beta lost its tick: {content}");
assert!(content.contains("- [ ] gamma shared\n"), "{content}");
}
#[test]
fn check_ticks_one_criterion_by_substring() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["check", UUID, "GAMMA"]);
assert!(ticket(&worklane).contains("- [x] gamma shared\n"));
}
#[test]
fn uncheck_unticks_one_criterion() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["uncheck", UUID, "2"]);
let content = ticket(&worklane);
assert!(content.contains("- [ ] beta alone\n"), "{content}");
assert!(content.contains("- [ ] alpha shared\n"), "{content}");
}
/// The handwritten line sits between two criteria, so it is the thing most likely to
/// be lost by a rewrite, and it must not take a number either.
#[test]
fn a_handwritten_line_in_the_section_survives_and_is_not_numbered() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
// gamma is the third criterion even though it is the fourth line of the section
run(&temp, &["check", UUID, "3"]);
let content = ticket(&worklane);
assert!(content.contains("- [x] gamma shared\n"), "{content}");
assert!(
content.contains(" A handwritten line inside the section.\n"),
"the handwritten line was lost or reindented: {content}"
);
}
/// A checkbox outside the section is not a criterion, so the numbering starts inside it.
#[test]
fn a_checkbox_in_the_description_is_not_a_criterion() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["check", UUID, "1"]);
let content = ticket(&worklane);
assert!(
content.contains("- [ ] A checkbox in the description, which is not a criterion.\n"),
"the description checkbox was ticked: {content}"
);
}
#[test]
fn checking_an_already_checked_criterion_changes_nothing() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["check", UUID, "2"]);
assert!(out.status.success());
assert!(
String::from_utf8_lossy(&out.stdout).contains("Already checked"),
"{:?}",
String::from_utf8_lossy(&out.stdout)
);
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
}
/// The listed numbers have to be the real ones, or the advice to use the number points
/// at the wrong criterion. alpha and gamma are 1 and 3, never 1 and 2.
#[test]
fn an_ambiguous_substring_lists_the_matches_with_their_real_numbers() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["check", UUID, "shared"]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1));
assert!(stderr.contains("matches 2 criteria"), "{stderr:?}");
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
assert!(stderr.contains("3. [ ] gamma shared"), "{stderr:?}");
assert!(!stderr.contains("2. [ ] gamma"), "renumbered: {stderr:?}");
assert_eq!(ticket(&worklane), before);
}
#[test]
fn a_substring_matching_nothing_is_an_error_listing_the_criteria() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["check", UUID, "nowhere"]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1));
assert!(stderr.contains("No criterion"), "{stderr:?}");
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
}
/// A number out of range is a bad index, not a substring that happened to miss.
#[test]
fn an_index_out_of_range_says_so() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["check", UUID, "9"]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1));
assert!(stderr.contains("is not one of the 3 criteria"), "{stderr:?}");
}
/// No terminal to prompt at, so the list comes back as an error instead. This is the
/// path the opencode wrapper takes, and it must not block on stdin.
#[test]
fn omitting_the_criterion_without_a_terminal_returns_the_list_as_an_error() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["check", UUID]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1));
assert!(stderr.contains("Which criterion"), "{stderr:?}");
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
assert!(stderr.contains("2. [x] beta alone"), "{stderr:?}");
assert!(stderr.contains("3. [ ] gamma shared"), "{stderr:?}");
assert_eq!(ticket(&worklane), before);
}
#[test]
fn a_ticket_with_no_criteria_says_so() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
fs::write(
worklane.join("backlog").join("aaaaaaaa-0000-4000-8000-000000000000_bare.md"),
"# Bare\n\n## Acceptance Criteria\n_No acceptance criteria provided._\n\n## Metadata\n\n- **ID**: aaaaaaaa-0000-4000-8000-000000000000\n- **Status**: backlog\n",
)
.unwrap();
let out = run(&temp, &["check", "aaaaaaaa", "1"]);
assert_eq!(out.status.code(), Some(1));
assert!(
String::from_utf8_lossy(&out.stderr).contains("no acceptance criteria"),
"{:?}",
String::from_utf8_lossy(&out.stderr)
);
}
/// show numbers the criteria, so the index check takes is visible where it is read.
#[test]
fn show_numbers_the_criteria() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["show", UUID]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(stdout.contains("1. [ ] alpha shared"), "{stdout:?}");
assert!(stdout.contains("2. [x] beta alone"), "{stdout:?}");
assert!(stdout.contains("3. [ ] gamma shared"), "{stdout:?}");
// The handwritten line is shown but takes no number
assert!(stdout.contains(" A handwritten line inside the section."), "{stdout:?}");
assert!(!stdout.contains("4. ["), "the handwritten line was numbered: {stdout:?}");
// And the description checkbox is left as it is, outside the numbering
assert!(
stdout.contains("- [ ] A checkbox in the description"),
"{stdout:?}"
);
}
#[test]
fn check_leaves_nothing_behind() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["check", UUID, "1"]);
let strays: Vec<String> = fs::read_dir(&worklane)
.unwrap()
.filter_map(|e| e.ok())
.map(|e| e.file_name().into_string().unwrap())
.filter(|name| {
!["backlog", "committed", "reviewing", "done", "comments"].contains(&name.as_str())
})
.collect();
assert_eq!(strays, Vec::<String>::new());
}
+100 -11
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use assert_fs::fixture::{PathChild, PathCreateDir};
use assert_fs::TempDir;
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
@@ -18,7 +18,7 @@ fn setup_worklane(temp: &TempDir) -> PathBuf {
}
fn create_ticket(
worklane_dir: &PathBuf,
worklane_dir: &Path,
status: &str,
title: &str,
) -> String {
@@ -53,7 +53,7 @@ fn comment_creates_file_with_valid_ticket_uuid() {
let uuid = create_ticket(&worklane, "backlog", "Test Ticket");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "This is a test comment"])
.assert()
@@ -78,7 +78,7 @@ fn comment_creates_file_with_valid_ticket_title() {
create_ticket(&worklane, "committed", "My Ticket");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args(["My Ticket", "Testing title lookup"])
.assert()
@@ -105,7 +105,7 @@ fn comment_includes_git_user_and_body() {
let uuid = create_ticket(&worklane, "backlog", "Comment Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "My comment body"])
.assert()
@@ -129,7 +129,7 @@ fn comment_stored_in_timestamped_file() {
let uuid = create_ticket(&worklane, "done", "Timestamp Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Timestamp test"])
.assert()
@@ -156,7 +156,7 @@ fn comment_creates_comments_directory() {
assert!(!comments_dir.exists());
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Create dir test"])
.assert()
@@ -173,7 +173,7 @@ fn comment_uses_owner_flag_when_provided() {
let uuid = create_ticket(&worklane, "backlog", "Owner Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Test comment with owner"])
.arg("-o")
@@ -198,7 +198,7 @@ fn comment_falls_back_to_git_user_when_owner_omitted() {
let uuid = create_ticket(&worklane, "done", "Fallback Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Test comment fallback"])
.assert()
@@ -225,7 +225,7 @@ fn comments_added_back_to_back_are_both_kept() {
for body in ["first comment", "second comment", "third comment"] {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(&temp.path())
.current_dir(temp.path())
.arg("comment")
.args([&uuid, body])
.assert()
@@ -241,7 +241,7 @@ fn comments_added_back_to_back_are_both_kept() {
// And show has to render them in the order they were added
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg(&uuid);
cmd.current_dir(temp.path()).arg("show").arg(&uuid);
let assert = cmd.assert().success();
let stdout = String::from_utf8(assert.get_output().stdout.clone()).unwrap();
@@ -250,3 +250,92 @@ fn comments_added_back_to_back_are_both_kept() {
let third = stdout.find("third comment").expect("third comment missing");
assert!(first < second && second < third, "comments out of order");
}
/// The body is a positional, and the case that motivated this: a review comment
/// quoting a flag name used to be refused outright.
#[test]
fn comment_accepts_a_body_that_begins_with_a_hyphen() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = create_ticket(&worklane, "backlog", "Hyphen body");
for body in ["--print is the flag I mean", "-f skips the check", "-"] {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["comment", &uuid, body])
.assert()
.success();
}
let bodies: String = fs::read_dir(worklane.join("comments").join(&uuid))
.unwrap()
.filter_map(|e| e.ok())
.map(|e| fs::read_to_string(e.path()).unwrap())
.collect();
for body in ["--print is the flag I mean", "-f skips the check"] {
assert!(bodies.contains(body), "{body:?} missing from {bodies:?}");
}
}
/// The ticket positional was deliberately left alone, so a hyphen-leading search
/// term is still a usage error. A bare separator is the way through, and it is the
/// only way through for `comment` since the body follows in the same position.
#[test]
fn comment_needs_a_separator_for_a_hyphen_leading_ticket() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "-leading");
let mut without = Command::cargo_bin(BIN_NAME).unwrap();
without
.current_dir(temp.path())
.args(["comment", "-leading", "a body"])
.assert()
.failure();
let mut with = Command::cargo_bin(BIN_NAME).unwrap();
with.current_dir(temp.path())
.args(["comment", "--", "-leading", "a body"])
.assert()
.success();
}
/// The one shape `allow_hyphen_values` does not reach: a lone `--` in a positional
/// is clap's end-of-options marker, consumed before any value is assigned. So a
/// comment body of exactly `--` needs its own separator in front of it.
///
/// Not a silent drop either way, which is what matters: without the separator the
/// body is reported missing and nothing is written.
#[test]
fn a_bare_double_hyphen_body_needs_a_separator() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = create_ticket(&worklane, "backlog", "Bare separator");
let mut without = Command::cargo_bin(BIN_NAME).unwrap();
let assert = without
.current_dir(temp.path())
.args(["comment", &uuid, "--"])
.assert()
.failure();
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
assert!(stderr.contains("<BODY>"), "unclear error: {stderr}");
assert!(
!worklane.join("comments").join(&uuid).exists(),
"a comment was written despite the error"
);
let mut with = Command::cargo_bin(BIN_NAME).unwrap();
with.current_dir(temp.path())
.args(["comment", &uuid, "--", "--"])
.assert()
.success();
let stored: String = fs::read_dir(worklane.join("comments").join(&uuid))
.unwrap()
.filter_map(|e| e.ok())
.map(|e| fs::read_to_string(e.path()).unwrap())
.collect();
assert!(stored.contains("**Comment**\n--\n"), "was {stored:?}");
}
+96
View File
@@ -0,0 +1,96 @@
use assert_cmd::Command;
use assert_fs::TempDir;
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
/// The document as this test's binary carries it, so the print path is pinned to the
/// file in the repo rather than to a description of it.
const SKILL: &str = include_str!("../assets/SKILL.md");
/// `HOME` is redirected, so the suite never writes into the home of whoever runs it.
/// A temp directory rather than the real one is also what makes the already-installed
/// and the modified cases reachable at all.
fn run(home: &TempDir, args: &[&str]) -> std::process::Output {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.env("HOME", home.path()).args(args);
cmd.assert().get_output().clone()
}
fn installed(home: &TempDir) -> std::path::PathBuf {
home.path().join(".claude/skills/worklane/SKILL.md")
}
/// Nothing about the skill needs a board, and it is wanted before there is one.
#[test]
fn the_skill_installs_outside_a_worklane_directory() {
let home = TempDir::new().unwrap();
let out = run(&home, &["install-skill"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(out.status.code(), Some(0), "{stdout}");
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
assert!(stdout.contains(".claude/skills/worklane/SKILL.md"), "{stdout}");
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
}
#[test]
fn a_second_install_says_it_is_already_up_to_date() {
let home = TempDir::new().unwrap();
run(&home, &["install-skill"]);
let out = run(&home, &["install-skill"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(out.status.code(), Some(0), "{stdout}");
assert!(stdout.contains("Already up to date"), "{stdout}");
}
/// A copy someone edited is theirs. The command says what to do next rather than
/// discarding it, and only `--force` overwrites.
#[test]
fn a_modified_copy_is_reported_and_needs_force() {
let home = TempDir::new().unwrap();
run(&home, &["install-skill"]);
std::fs::write(installed(&home), "hand written\n").unwrap();
let out = run(&home, &["install-skill"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(out.status.code(), Some(0), "{stdout}");
assert!(stdout.contains("Differs from the version in this binary"), "{stdout}");
assert!(stdout.contains("--force"), "{stdout}");
assert!(stdout.contains("--print"), "the message never says how to compare: {stdout}");
assert_eq!(
std::fs::read_to_string(installed(&home)).unwrap(),
"hand written\n",
"the modified copy was overwritten anyway"
);
let out = run(&home, &["install-skill", "--force"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
}
/// The print path is what makes a modified copy diffable, so it has to be the document
/// byte for byte and it must not install anything on the way past.
#[test]
fn print_writes_the_document_to_stdout_and_installs_nothing() {
let home = TempDir::new().unwrap();
let out = run(&home, &["install-skill", "--print"]);
assert_eq!(out.status.code(), Some(0));
assert_eq!(String::from_utf8_lossy(&out.stdout), SKILL);
assert!(!installed(&home).exists(), "--print installed the skill anyway");
}
/// The command has to be findable by someone who does not already know it exists.
#[test]
fn the_help_lists_the_install_skill_command() {
let home = TempDir::new().unwrap();
let stdout = String::from_utf8_lossy(&run(&home, &["--help"]).stdout).to_string();
assert!(stdout.contains("install-skill"), "{stdout}");
}
+89 -9
View File
@@ -17,7 +17,7 @@ fn setup_worklane(temp: &TempDir) -> std::path::PathBuf {
}
fn create_ticket(
worklane_dir: &std::path::PathBuf,
worklane_dir: &std::path::Path,
status: &str,
title: &str,
owner: &str,
@@ -71,7 +71,7 @@ fn ls_without_status_shows_overview() {
create_ticket(&worklane, "done", "Feature D", "dave", "2026-09-01");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").assert().success();
cmd.current_dir(temp.path()).arg("ls").assert().success();
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("BACKLOG"));
@@ -94,7 +94,7 @@ fn ls_with_status_filters_tickets() {
create_ticket(&worklane, "reviewing", "Feature C", "charlie", "2026-08-01");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").args(["committed"]);
cmd.current_dir(temp.path()).arg("ls").args(["committed"]);
cmd.assert().success();
@@ -107,7 +107,7 @@ fn ls_with_invalid_status_fails() {
let temp = TempDir::new().unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("ls")
.args(["nonexistent"])
.assert()
@@ -124,7 +124,7 @@ fn ls_listed_tickets_sorted_alphabetically() {
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-08-01");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("ls")
.args(["backlog"])
.assert()
@@ -146,7 +146,7 @@ fn ls_empty_status_shows_message() {
// Intentionally leave "done" empty
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("ls")
.args(["done"])
.assert()
@@ -164,7 +164,7 @@ fn ls_displays_owner_and_due() {
create_ticket(&worklane, "backlog", "Test ticket", "alice", "2026-12-31");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("ls")
.args(["backlog"])
.assert()
@@ -191,7 +191,7 @@ fn ls_handles_short_and_non_ascii_filenames() {
}
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").arg("backlog").assert().success();
cmd.current_dir(temp.path()).arg("ls").arg("backlog").assert().success();
let stdout = get_stdout(&mut cmd);
assert_eq!(stdout.matches("Odd Name").count(), 3);
@@ -209,10 +209,90 @@ fn ls_survives_a_malformed_created_at() {
.unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").arg("backlog").assert().success();
cmd.current_dir(temp.path()).arg("ls").arg("backlog").assert().success();
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Bad Date"));
// Unparseable, so the timestamp column is dropped rather than printed raw
assert!(!stdout.contains("日本語"));
}
fn create_ticket_with_priority(worklane_dir: &std::path::Path, title: &str, priority: &str) {
let slug: String = title.to_lowercase().replace(' ', "-");
let body = format!(
"# {}\n\n## Metadata\n\n- **ID**: 00000000-0000-0000-0000-00000000000{}\n\
- **Priority**: {}\n- **Tags**: test\n- **Due**: _Not set_\n\
- **Owner**: alice\n- **Status**: backlog\n",
title,
slug.len() % 10,
priority
);
let filename = format!("0000000{}-0000-0000-0000-000000000001_{}.md", slug.len() % 10, slug);
fs::write(worklane_dir.join("backlog").join(filename), body).unwrap();
}
#[test]
fn ls_sorts_by_priority_then_title() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_priority(&worklane, "Zebra urgent", "1");
create_ticket_with_priority(&worklane, "Apple later", "4");
create_ticket_with_priority(&worklane, "Middle one", "2");
create_ticket(&worklane, "backlog", "No priority at all", "alice", "_Not set_");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("ls").arg("backlog");
let stdout = get_stdout(&mut cmd);
let at = |needle: &str| stdout.find(needle).unwrap_or_else(|| panic!("{needle} missing"));
assert!(at("Zebra urgent") < at("Middle one"), "priority 1 must lead");
assert!(at("Middle one") < at("Apple later"), "2 before 4");
// Unset sorts last even though its title would come first alphabetically
assert!(at("Apple later") < at("No priority at all"), "unset must trail");
}
#[test]
fn ls_filters_by_priority_and_composes_with_status() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_priority(&worklane, "Urgent one", "1");
create_ticket_with_priority(&worklane, "Lower one", "3");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--priority", "1"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Urgent one"));
assert!(!stdout.contains("Lower one"), "filter let a level 3 through");
// Same filter without a status, through the grouped listing
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "--priority", "3"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Lower one"));
assert!(!stdout.contains("Urgent one"));
}
#[test]
fn ls_shows_a_mark_for_the_level() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_priority(&worklane, "Top level", "1");
create_ticket_with_priority(&worklane, "Bottom level", "5");
create_ticket(&worklane, "backlog", "Nothing set", "alice", "_Not set_");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("ls").arg("backlog");
let stdout = get_stdout(&mut cmd);
// Piped, so no escapes: the glyph is carrying the level by itself
assert!(!stdout.contains('\u{1b}'));
assert!(stdout.contains("\u{25cf}\u{25cf} "), "no full meter for level 1 in {stdout:?}");
assert!(stdout.contains("\u{25cb}\u{25cb} "), "no empty meter for level 5");
assert!(stdout.contains("\u{b7}\u{b7} "), "no unset mark");
// The raw number is not what the listing shows
assert!(!stdout.contains(" 1 "), "the digit leaked into the row");
}
+227 -13
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use assert_fs::TempDir;
use assert_fs::fixture::{PathChild, PathCreateDir};
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
@@ -17,8 +17,13 @@ fn setup_worklane(temp: &TempDir) -> PathBuf {
worklane.path().to_path_buf()
}
/// Every metadata field a ticket has, positionally. The lint is right that the call
/// site reads as a wall of strings, and the fix is a struct with named fields, but
/// that is a change to thirteen call sites in this file alone and belongs in its own
/// commit rather than in a warning sweep.
#[allow(clippy::too_many_arguments)]
fn create_ticket(
worklane_dir: &PathBuf,
worklane_dir: &Path,
status: &str,
title: &str,
description: &str,
@@ -89,7 +94,7 @@ fn mv_forwards_from_backlog_to_committed() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -133,7 +138,7 @@ fn mv_blocks_backward_move() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -163,7 +168,7 @@ fn mv_allows_backward_move_with_force() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -197,7 +202,7 @@ fn mv_blocks_nonsequential_forward_move() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -227,7 +232,7 @@ fn mv_allows_skipping_stages_with_force() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -259,7 +264,7 @@ fn mv_ignores_already_in_same_status() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -290,7 +295,7 @@ fn mv_rejects_invalid_status() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -320,7 +325,7 @@ fn mv_uses_ticket_id_for_resolution() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -354,7 +359,7 @@ fn mv_keeps_status_in_sync_across_consecutive_moves() {
for target in ["committed", "reviewing"] {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(&temp.path())
.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -392,7 +397,7 @@ fn mv_repairs_legacy_status_field() {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(&temp.path())
.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -415,7 +420,7 @@ fn mv_fails_when_status_field_is_missing() {
fs::write(&path, "# No Status\n\n## Metadata\n\n- **Owner**: jack\n").unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -431,3 +436,212 @@ fn mv_fails_when_status_field_is_missing() {
assert!(worklane.join("backlog").join(filename).exists());
assert!(!worklane.join("committed").join(filename).exists());
}
use std::os::unix::fs::PermissionsExt;
fn chmod(path: &std::path::Path, mode: u32) {
let mut perms = fs::metadata(path).unwrap().permissions();
perms.set_mode(mode);
fs::set_permissions(path, perms).unwrap();
}
fn md_files(dir: &std::path::Path) -> Vec<String> {
match fs::read_dir(dir) {
Ok(entries) => entries
.filter_map(|e| e.ok())
.map(|e| e.file_name().into_string().unwrap())
.filter(|name| name.ends_with(".md"))
.collect(),
Err(_) => vec![],
}
}
/// Nothing is staged in a status directory, so nothing can be left behind that the
/// listing would read as a ticket.
fn stray_files(worklane: &std::path::Path) -> Vec<String> {
let mut stray: Vec<String> = fs::read_dir(worklane)
.unwrap()
.filter_map(|e| e.ok())
.map(|e| e.file_name().into_string().unwrap())
.filter(|name| !["backlog", "committed", "reviewing", "done", "comments"].contains(&name.as_str()))
.collect();
for dir in ["backlog", "committed", "reviewing", "done"] {
stray.extend(
fs::read_dir(worklane.join(dir))
.into_iter()
.flatten()
.filter_map(|e| e.ok())
.map(|e| e.file_name().into_string().unwrap())
.filter(|name| !name.ends_with(".md")),
);
}
stray
}
/// The bug this fixes. The old order renamed first and wrote second, so a write
/// that failed left the ticket in its new directory still claiming the old status.
/// A read-only ticket file is the cheapest way to make the write fail.
#[test]
fn mv_never_leaves_stale_content_in_the_target_directory() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = create_ticket(
&worklane,
"backlog",
"Read Only",
"A description.",
"abc123def456789012345678901234567890",
"alice",
"2026-12-31",
"test",
);
let source = worklane.join("backlog").join(&filename);
chmod(&source, 0o444);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["mv", "abc123def4567", "--status", "committed"])
.assert()
.success();
// Wherever it ended up, its Status must agree with the directory it is in
let moved = worklane.join("committed").join(&filename);
assert!(moved.exists(), "ticket did not move");
let content = fs::read_to_string(&moved).unwrap();
assert!(
content.contains("- **Status**: committed"),
"stale status: {content:?}"
);
assert!(!content.contains("- **Status**: backlog"), "{content:?}");
assert_eq!(md_files(&worklane.join("backlog")).len(), 0);
assert_eq!(stray_files(&worklane), Vec::<String>::new());
}
/// The other criterion: one directory or the other, never both. An unwritable
/// target directory fails the move at the last step, which is the step that would
/// have to be reordered to break this.
#[test]
fn mv_leaves_the_ticket_in_one_place_when_the_move_fails() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = create_ticket(
&worklane,
"backlog",
"Blocked Move",
"A description.",
"abc123def456789012345678901234567890",
"alice",
"2026-12-31",
"test",
);
let target = worklane.join("committed");
chmod(&target, 0o555);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
let assert = cmd
.current_dir(temp.path())
.args(["mv", "abc123def4567", "--status", "committed"])
.assert()
.failure();
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
// Named, not a bare io error
assert!(stderr.contains("Blocked Move"), "{stderr}");
assert_eq!(
md_files(&worklane.join("backlog")),
vec![filename.clone()],
"the ticket left its own directory"
);
assert_eq!(md_files(&target).len(), 0, "the ticket is in both places");
assert_eq!(stray_files(&worklane), Vec::<String>::new());
// The documented worst case: still in its old directory, carrying a Status one
// move ahead because the content was written before the move was attempted.
let left = fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap();
assert!(left.contains("- **Status**: committed"), "{left:?}");
// And the state is recoverable, because the directory is what decides the
// current status, so a retry moves it rather than refusing.
chmod(&target, 0o755);
let mut retry = Command::cargo_bin(BIN_NAME).unwrap();
retry
.current_dir(temp.path())
.args(["mv", "abc123def4567", "--status", "committed"])
.assert()
.success();
assert_eq!(md_files(&target), vec![filename]);
assert_eq!(md_files(&worklane.join("backlog")).len(), 0);
}
#[test]
fn mv_leaves_nothing_behind_on_success() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(
&worklane,
"backlog",
"Clean Move",
"A description.",
"abc123def456789012345678901234567890",
"alice",
"2026-12-31",
"test",
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["mv", "abc123def4567", "--status", "committed"])
.assert()
.success();
assert_eq!(stray_files(&worklane), Vec::<String>::new());
}
/// Duplicate titles are allowed, so the file cannot be located by title. It used to be,
/// and `mv <uuid-of-second>` moved the first ticket that shared its title.
#[test]
fn mv_moves_the_resolved_ticket_when_two_share_a_title() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
for uuid in [
"11111111-aaaa-bbbb-cccc-dddddddddddd",
"22222222-aaaa-bbbb-cccc-dddddddddddd",
] {
fs::write(
worklane.join("backlog").join(format!("{}_foo.md", uuid)),
format!(
"# Foo\n\n## Metadata\n\n- **ID**: {}\n- **Status**: backlog\n",
uuid
),
)
.unwrap();
}
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["mv", "22222222", "--status", "committed"])
.assert()
.success();
assert_eq!(
md_files(&worklane.join("committed")),
vec!["22222222-aaaa-bbbb-cccc-dddddddddddd_foo.md".to_string()],
"the wrong ticket moved"
);
assert_eq!(
md_files(&worklane.join("backlog")),
vec!["11111111-aaaa-bbbb-cccc-dddddddddddd_foo.md".to_string()]
);
}
+417
View File
@@ -0,0 +1,417 @@
use assert_cmd::Command;
use assert_fs::TempDir;
use assert_fs::fixture::{PathChild, PathCreateDir};
use std::fs;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
const UUID: &str = "475534a3-8a0d-45cb-9a97-39c251dd8e39";
fn setup_worklane(temp: &TempDir) -> PathBuf {
let worklane = temp.child(".worklane");
worklane.create_dir_all().unwrap();
for dir in ["backlog", "committed", "reviewing", "done"] {
worklane.child(dir).create_dir_all().unwrap();
}
worklane.path().to_path_buf()
}
/// A fully populated ticket, with one criterion already ticked and a section the tool
/// knows nothing about, so every test can check both survive.
fn create_ticket(worklane: &Path) -> String {
let filename = format!("{}_original-title.md", UUID);
fs::write(
worklane.join("backlog").join(&filename),
format!(
"# Original title\n\
\n\
## Description\n\
First paragraph.\n\
\n\
Second paragraph.\n\
\n\
## Acceptance Criteria\n\
- [x] Crit one\n\
- [ ] Crit two\n\
\n\
## Implementation Plan\n\
1. Step one\n\
2. Step two\n\
\n\
## Notes\n\
A handwritten note the tool knows nothing about.\n\
\n\
## Metadata\n\
\n\
- **ID**: {}\n\
- **Priority**: 3\n\
- **Tags**: alpha\n\
- **Due**: 2026-09-01\n\
- **Owner**: alice\n\
- **Created At**: 2026-08-21 02:10:17\n\
- **Status**: backlog\n",
UUID
),
)
.unwrap();
filename
}
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(args);
cmd.assert().get_output().clone()
}
fn ticket(worklane: &Path) -> String {
let entry = fs::read_dir(worklane.join("backlog"))
.unwrap()
.filter_map(|e| e.ok())
.find(|e| e.file_name().to_string_lossy().ends_with(".md"))
.expect("no ticket file");
fs::read_to_string(entry.path()).unwrap()
}
fn stray_files(worklane: &Path) -> Vec<String> {
fs::read_dir(worklane)
.unwrap()
.filter_map(|e| e.ok())
.map(|e| e.file_name().into_string().unwrap())
.filter(|name| {
!["backlog", "committed", "reviewing", "done", "comments"].contains(&name.as_str())
})
.collect()
}
#[test]
fn set_replaces_each_field_it_is_given() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(
&temp,
&[
"set", UUID,
"--description", "Only paragraph.",
"--acceptance", "New crit",
"--plan", "New step",
"--tags", "beta,gamma",
"--due", "2026-12-31",
"--priority", "1",
],
);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let content = ticket(&worklane);
assert!(content.contains("## Description\nOnly paragraph.\n"), "{content}");
assert!(content.contains("## Acceptance Criteria\n- [ ] New crit\n"), "{content}");
assert!(content.contains("## Implementation Plan\n1. New step\n"), "{content}");
assert!(content.contains("- **Tags**: beta,gamma"), "{content}");
assert!(content.contains("- **Due**: 2026-12-31"), "{content}");
assert!(content.contains("- **Priority**: 1"), "{content}");
// The fields it was not given are untouched
assert!(content.contains("- **Owner**: alice"), "{content}");
assert!(content.contains("- **Status**: backlog"), "{content}");
}
/// The criterion is ticked in the fixture, so an unrelated edit must leave it ticked.
#[test]
fn set_leaves_a_ticked_criterion_and_an_unknown_section_alone() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["set", UUID, "--due", "2026-12-31"]);
let content = ticket(&worklane);
assert!(content.contains("- [x] Crit one"), "the tick was lost: {content}");
assert!(
content.contains("## Notes\nA handwritten note the tool knows nothing about.\n"),
"the unknown section was lost: {content}"
);
}
#[test]
fn set_renames_the_file_for_a_new_title_and_keeps_the_uuid() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["set", UUID, "--title", "A brand new title"]);
let names: Vec<String> = fs::read_dir(worklane.join("backlog"))
.unwrap()
.filter_map(|e| e.ok())
.map(|e| e.file_name().into_string().unwrap())
.collect();
assert_eq!(names, vec![format!("{}_a-brand-new-title.md", UUID)]);
assert!(ticket(&worklane).starts_with("# A brand new title\n"));
// And the renamed ticket is still reachable, by the new title and by the uuid
for search in ["brand new", "475534a3"] {
let out = run(&temp, &["show", search]);
assert!(out.status.success(), "{search} did not resolve");
assert!(String::from_utf8_lossy(&out.stdout).contains("A brand new title"));
}
}
#[test]
fn set_reports_no_change_and_leaves_the_file_alone() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["set", UUID, "--due", "2026-09-01", "--priority", "3"]);
assert!(out.status.success());
assert!(
String::from_utf8_lossy(&out.stdout).contains("No changes"),
"{:?}",
String::from_utf8_lossy(&out.stdout)
);
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
}
/// Only the field that actually differs is claimed, so the report cannot overstate.
#[test]
fn set_reports_only_the_fields_that_changed() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["set", UUID, "--due", "2026-09-01", "--priority", "5"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(stdout.contains("priority"), "{stdout:?}");
assert!(!stdout.contains("due"), "{stdout:?}");
}
/// An empty scalar looks like a way to clear a field, and clearing is not supported.
#[test]
fn set_refuses_an_empty_scalar_as_a_usage_error() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
for flag in ["--title", "--due", "--tags"] {
let out = run(&temp, &["set", UUID, flag, ""]);
assert_eq!(out.status.code(), Some(2), "{flag} was accepted");
assert!(
String::from_utf8_lossy(&out.stderr).contains("clearing a field is not supported"),
"{flag}: {:?}",
String::from_utf8_lossy(&out.stderr)
);
}
assert_eq!(ticket(&worklane), before);
}
/// An empty value is a paragraph break for a section, so an all-blank one is a
/// clearing attempt rather than a break.
#[test]
fn set_refuses_to_clear_a_section() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["set", UUID, "--description", ""]);
assert_eq!(out.status.code(), Some(1));
assert!(
String::from_utf8_lossy(&out.stderr).contains("clearing is not supported"),
"{:?}",
String::from_utf8_lossy(&out.stderr)
);
assert_eq!(ticket(&worklane), before);
}
/// A bare `set <ticket>` would otherwise be a silent no-op.
#[test]
fn set_requires_at_least_one_field() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(&temp, &["set", UUID]);
assert_eq!(out.status.code(), Some(2));
}
/// Interior blanks are paragraph breaks, per 4c516e6, so they have to reach the file.
#[test]
fn set_keeps_a_paragraph_break_in_a_replaced_description() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(
&temp,
&["set", UUID, "-d", "One.", "-d", "", "-d", "Two."],
);
assert!(
ticket(&worklane).contains("## Description\nOne.\n\nTwo.\n\n## Acceptance"),
"{}",
ticket(&worklane)
);
}
#[test]
fn set_accepts_prose_that_begins_with_a_hyphen() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(
&temp,
&["set", UUID, "-a", "--print should be supported", "-t", "-t is the title flag"],
);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let content = ticket(&worklane);
assert!(content.contains("- [ ] --print should be supported"), "{content}");
assert!(content.starts_with("# -t is the title flag\n"), "{content}");
}
#[test]
fn set_leaves_nothing_behind() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["set", UUID, "--due", "2026-12-31"]);
assert_eq!(stray_files(&worklane), Vec::<String>::new());
}
#[test]
fn append_adds_a_paragraph_items_and_numbered_steps() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let out = run(
&temp,
&[
"append", UUID,
"-d", "A third paragraph.",
"-a", "Crit three",
"-a", "Crit four",
"-p", "Step three",
],
);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
let content = ticket(&worklane);
assert!(
content.contains("Second paragraph.\n\nA third paragraph.\n"),
"no paragraph break: {content}"
);
assert!(
content.contains("- [x] Crit one\n- [ ] Crit two\n- [ ] Crit three\n- [ ] Crit four\n"),
"{content}"
);
// Numbered on from the last step, and the steps above are untouched
assert!(
content.contains("1. Step one\n2. Step two\n3. Step three\n"),
"{content}"
);
}
#[test]
fn append_replaces_an_empty_section_rather_than_following_its_placeholder() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let mut add = Command::cargo_bin(BIN_NAME).unwrap();
add.current_dir(temp.path())
.args(["add", "--title", "Bare ticket"])
.assert()
.success();
let uuid = fs::read_dir(worklane.join("backlog"))
.unwrap()
.filter_map(|e| e.ok())
.map(|e| e.file_name().into_string().unwrap())
.next()
.map(|name| name.split('_').next().unwrap().to_string())
.unwrap();
run(
&temp,
&["append", &uuid, "-d", "A description arrives late.", "-a", "First crit", "-p", "First step"],
);
let content = ticket(&worklane);
assert!(!content.contains("_No description provided._"), "{content}");
assert!(!content.contains("_No acceptance criteria provided._"), "{content}");
assert!(!content.contains("_No implementation plan provided._"), "{content}");
assert!(content.contains("## Description\nA description arrives late.\n"), "{content}");
assert!(content.contains("## Implementation Plan\n1. First step\n"), "{content}");
}
#[test]
fn append_leaves_a_ticked_criterion_and_an_unknown_section_alone() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
run(&temp, &["append", UUID, "-a", "Crit three"]);
let content = ticket(&worklane);
assert!(content.contains("- [x] Crit one"), "{content}");
assert!(
content.contains("## Notes\nA handwritten note the tool knows nothing about.\n"),
"{content}"
);
}
#[test]
fn append_refuses_when_every_value_is_blank() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
let before = ticket(&worklane);
let out = run(&temp, &["append", UUID, "-a", " "]);
assert_eq!(out.status.code(), Some(1));
assert!(
String::from_utf8_lossy(&out.stderr).contains("Nothing to append"),
"{:?}",
String::from_utf8_lossy(&out.stderr)
);
assert_eq!(ticket(&worklane), before);
}
#[test]
fn append_requires_at_least_one_section() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
assert_eq!(run(&temp, &["append", UUID]).status.code(), Some(2));
}
/// Owner belongs to chown and status to mv, so neither command offers them.
#[test]
fn neither_command_can_write_owner_or_status() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane);
for args in [
vec!["set", UUID, "--owner", "bob"],
vec!["set", UUID, "--status", "committed"],
vec!["append", UUID, "--owner", "bob"],
] {
let out = run(&temp, &args);
assert_eq!(out.status.code(), Some(2), "{args:?} was accepted");
}
let content = ticket(&worklane);
assert!(content.contains("- **Owner**: alice"));
assert!(content.contains("- **Status**: backlog"));
}
+297 -12
View File
@@ -16,8 +16,11 @@ fn setup_worklane(temp: &TempDir) -> std::path::PathBuf {
worklane.path().to_path_buf()
}
/// Same fixture, same trade as `cmd_mv.rs`: positional today, a struct when the call
/// sites in both files are converted together.
#[allow(clippy::too_many_arguments)]
fn create_ticket(
worklane_dir: &std::path::PathBuf,
worklane_dir: &std::path::Path,
status: &str,
title: &str,
description: &str,
@@ -86,7 +89,7 @@ fn show_displays_ticket_by_full_uuid() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("abc123def456789012345678901234567890")
.assert()
@@ -118,7 +121,7 @@ fn show_displays_ticket_by_partial_uuid() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("abc123def4567890")
.assert()
@@ -147,7 +150,7 @@ fn show_displays_ticket_by_title() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("login")
.assert()
@@ -178,7 +181,7 @@ fn show_displays_ticket_by_partial_title() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("fix")
.assert()
@@ -206,7 +209,7 @@ fn show_shows_both_uuid_and_title_in_output() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("test")
.assert()
@@ -222,7 +225,7 @@ fn show_fails_for_nonexistent_ticket() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("nonexistent")
.assert()
@@ -259,7 +262,7 @@ fn show_asks_for_disambiguation_when_multiple_matches() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("est");
cmd.current_dir(temp.path()).arg("show").arg("est");
let stderr = get_stderr(&mut cmd);
assert!(stderr.contains("Multiple tickets found"));
@@ -299,7 +302,7 @@ fn show_reports_ambiguity_on_stderr_with_a_failing_exit() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("ambiguous")
.assert()
@@ -333,7 +336,7 @@ fn show_disambiguates_tickets_with_short_filenames() {
.unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("short");
cmd.current_dir(temp.path()).arg("show").arg("short");
let stderr = get_stderr(&mut cmd);
assert!(stderr.contains("Multiple tickets found"));
@@ -356,7 +359,7 @@ fn show_disambiguates_tickets_with_non_ascii_filenames() {
}
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("accented");
cmd.current_dir(temp.path()).arg("show").arg("accented");
let stderr = get_stderr(&mut cmd);
assert!(stderr.contains("Multiple tickets found"));
@@ -383,7 +386,7 @@ fn show_searches_across_all_statuses() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("committed")
.assert()
@@ -393,3 +396,285 @@ fn show_searches_across_all_statuses() {
assert!(stdout.contains("Committed Task"));
assert!(stdout.contains("This is in committed."));
}
#[test]
fn show_renders_the_priority_mark_beside_the_number() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = "abc123def456789012345678901234567890_prio.md";
fs::write(
worklane.join("backlog").join(filename),
"# Prio Ticket\n\n## Metadata\n\n- **ID**: abc123def456789012345678901234567890\n\
- **Priority**: 2\n- **Status**: backlog\n",
)
.unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("show").arg("Prio");
let stdout = get_stdout(&mut cmd);
// Mark for the eye, number still there for the file's sake
assert!(stdout.contains("\u{25cf}\u{25d0}"), "no mark in {stdout:?}");
assert!(stdout.contains("Priority"));
assert!(stdout.contains('2'));
// And the file itself is untouched
let content = fs::read_to_string(worklane.join("backlog").join(filename)).unwrap();
assert!(content.contains("- **Priority**: 2"));
}
#[test]
fn show_prints_the_title_once() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(
&worklane,
"backlog",
"Once Only",
"A description that does not name the title.",
"abc123def456789012345678901234567890",
"alice",
"2026-12-31",
"test",
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("show").arg("Once Only");
let stdout = get_stdout(&mut cmd);
assert_eq!(
stdout.matches("Once Only").count(),
1,
"title repeated in {stdout:?}"
);
// The rule under it is still the width of the title
assert!(stdout.contains("Once Only\n─────────\n"), "{stdout:?}");
}
#[test]
fn show_renders_the_metadata_as_an_aligned_table() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = "abc123def456789012345678901234567890_table.md";
fs::write(
worklane.join("backlog").join(filename),
"# Table Ticket\n\n## Metadata\n\n\
- **ID**: abc123def456789012345678901234567890\n\
- **Created At**: 2026-08-20 15:51:01\n\
- **Owner**: alice\n\
- **Status**: backlog\n",
)
.unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("show").arg("Table");
let stdout = get_stdout(&mut cmd);
// Every value starts in the same column, sized by the longest field name
assert!(
stdout.contains(
"ID abc123def456789012345678901234567890\n\
Created At 2026-08-20 15:51:01\n\
Owner alice\n\
Status backlog\n"
),
"{stdout:?}"
);
// Display only: the file is still the markdown list it was
let content = fs::read_to_string(worklane.join("backlog").join(filename)).unwrap();
assert!(content.contains("- **Owner**: alice"));
}
/// Write a ticket with an exact uuid and title, since both matter to resolution.
fn ticket_with(worklane: &std::path::Path, status: &str, uuid: &str, title: &str, slug: &str) {
fs::write(
worklane.join(status).join(format!("{}_{}.md", uuid, slug)),
format!(
"# {}\n\n## Metadata\n\n- **ID**: {}\n- **Status**: {}\n",
title, uuid, status
),
)
.unwrap();
}
fn show(temp: &TempDir, search: &str) -> std::process::Output {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("show").arg(search);
cmd.assert().get_output().clone()
}
/// The bug. A flat OR of the three predicates put an exact uuid prefix and a title
/// that merely mentions it in the same list, so the search reported as ambiguous
/// the very id the listing had just printed.
#[test]
fn show_prefers_a_uuid_prefix_over_a_title_that_mentions_it() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
ticket_with(
&worklane,
"backlog",
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
"Alpha",
"alpha",
);
ticket_with(
&worklane,
"backlog",
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"Notes on 641e3d5 regression",
"notes",
);
let out = show(&temp, "641e3d5");
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
assert!(stdout.contains("Alpha"), "{stdout:?}");
assert!(!stdout.contains("Notes on"), "{stdout:?}");
}
/// `ls` prints SHORT_ID_WIDTH characters, so pasting that back has to resolve. This
/// is the guard against reinstating an eight character minimum.
#[test]
fn show_resolves_the_short_id_the_listing_prints() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let uuid = "641e3d5d-ef23-4213-8346-e8b0114b84e9";
ticket_with(&worklane, "backlog", uuid, "Alpha", "alpha");
let mut ls = Command::cargo_bin(BIN_NAME).unwrap();
ls.current_dir(temp.path()).args(["ls", "backlog"]);
let listing = String::from_utf8(ls.assert().success().get_output().stdout.clone()).unwrap();
// Take the id exactly as printed, so this couples to the display width rather
// than to a hardcoded number
let printed = listing
.split('(')
.nth(1)
.and_then(|rest| rest.split(')').next())
.expect("no id in the listing")
.to_string();
assert!(printed.len() < 8, "the listing prints {} chars", printed.len());
// A decoy whose title quotes that id. Without it the search would still land on
// Alpha through the filename tier, since the filename contains the uuid, and the
// test would pass under a minimum longer than the printed id.
ticket_with(
&worklane,
"backlog",
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
&format!("Notes on {} regression", printed),
"notes",
);
let out = show(&temp, &printed);
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(out.status.success(), "{printed} did not resolve");
assert!(stdout.contains("Alpha"), "{stdout:?}");
assert!(!stdout.contains("Notes on"), "{stdout:?}");
}
#[test]
fn show_resolves_a_four_character_uuid_prefix() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
ticket_with(
&worklane,
"backlog",
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
"Alpha",
"alpha",
);
let out = show(&temp, "641e");
assert!(out.status.success());
assert!(String::from_utf8_lossy(&out.stdout).contains("Alpha"));
}
/// Below four characters the search is text, so it must not be read as a prefix
/// matching a large slice of the board.
#[test]
fn show_treats_a_search_below_four_characters_as_text() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
ticket_with(
&worklane,
"backlog",
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
"Alpha",
"alpha",
);
ticket_with(
&worklane,
"backlog",
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"Notes on 641 regression",
"notes",
);
// "641" prefixes Alpha's uuid, but it is too short to be read as one, so the
// title match is the only match
let out = show(&temp, "641");
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
assert!(stdout.contains("Notes on"), "{stdout:?}");
assert!(!stdout.contains("Alpha"), "{stdout:?}");
}
/// The last tier earns its place: it reaches the middle of a uuid, which the prefix
/// tier cannot.
#[test]
fn show_falls_back_to_the_filename_for_a_mid_uuid_substring() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
ticket_with(
&worklane,
"backlog",
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
"Alpha",
"alpha",
);
let out = show(&temp, "ef23");
assert!(out.status.success());
assert!(String::from_utf8_lossy(&out.stdout).contains("Alpha"));
}
/// Tiering removes false ambiguity across tiers, not real ambiguity inside one.
#[test]
fn show_still_reports_ambiguity_within_the_uuid_tier() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
ticket_with(
&worklane,
"backlog",
"5eeddeed-1111-2222-3333-444444444444",
"Beta",
"beta",
);
ticket_with(
&worklane,
"backlog",
"5eedbeef-9999-8888-7777-666666666666",
"Gamma",
"gamma",
);
let out = show(&temp, "5eed");
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(!out.status.success());
assert!(stderr.contains("Multiple tickets found"), "{stderr:?}");
assert!(stderr.contains("Beta") && stderr.contains("Gamma"), "{stderr:?}");
}
+150
View File
@@ -0,0 +1,150 @@
use assert_cmd::Command;
use assert_fs::TempDir;
use assert_fs::fixture::{PathChild, PathCreateDir};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
fn setup_worklane(temp: &TempDir) {
let worklane = temp.child(".worklane");
worklane.create_dir_all().unwrap();
for dir in ["backlog", "committed", "reviewing", "done"] {
worklane.child(dir).create_dir_all().unwrap();
}
}
/// A project inside the temp directory, for the path arguments. The temp directory
/// itself is left without a board, so a path that resolves has to resolve to this one.
fn setup_project(temp: &TempDir, name: &str) -> std::path::PathBuf {
let project = temp.child(name);
let worklane = project.child(".worklane");
worklane.create_dir_all().unwrap();
for dir in ["backlog", "committed", "reviewing", "done"] {
worklane.child(dir).create_dir_all().unwrap();
}
project.path().to_path_buf()
}
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(args);
cmd.assert().get_output().clone()
}
/// Same message every other command gives. Checked before the terminal is, so the
/// missing board is what gets reported rather than the missing tty.
#[test]
fn the_tui_outside_a_worklane_directory_gives_the_usual_message() {
let temp = TempDir::new().unwrap();
for args in [vec!["tui"], vec![]] {
let out = run(&temp, &args);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1), "{args:?}");
assert!(
stderr.contains("No .worklane directory found"),
"{args:?}: {stderr:?}"
);
}
}
/// Raw mode on a pipe fails with a bare "No such device or address", which says nothing
/// about the mistake. A bare `worklane` is how the board opens, so a script that lands
/// here by accident has to be pointed at a subcommand.
#[test]
fn the_tui_without_a_terminal_says_so_and_names_an_alternative() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
for args in [vec!["tui"], vec![]] {
let out = run(&temp, &args);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1), "{args:?}");
assert!(stderr.contains("needs a terminal"), "{args:?}: {stderr:?}");
assert!(stderr.contains("worklane ls"), "{args:?}: {stderr:?}");
assert!(
!stderr.contains("os error"),
"the raw mode error leaked: {stderr:?}"
);
}
}
/// The subcommands must keep working now that the subcommand is optional.
#[test]
fn an_unknown_subcommand_is_still_a_usage_error() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
assert_eq!(run(&temp, &["nonsense"]).status.code(), Some(2));
assert_eq!(run(&temp, &["--bogus"]).status.code(), Some(2));
}
/// A path argument is resolved before the terminal is, the same way the working
/// directory is: reaching the tty complaint is what says the board was found.
#[test]
fn a_path_argument_names_the_board_to_open() {
let temp = TempDir::new().unwrap();
let project = setup_project(&temp, "project");
// Run from a directory with no board of its own, so only the argument can find one.
let out = run(&temp, &["tui", project.to_str().unwrap()]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
}
/// And several of them, which is the point of taking paths at all.
#[test]
fn several_path_arguments_are_accepted() {
let temp = TempDir::new().unwrap();
let first = setup_project(&temp, "first");
let second = setup_project(&temp, "second");
let out = run(
&temp,
&["tui", first.to_str().unwrap(), second.to_str().unwrap()],
);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
}
/// With several paths, "No .worklane directory found" does not say which one was wrong.
#[test]
fn a_path_with_no_board_is_named_in_the_failure() {
let temp = TempDir::new().unwrap();
let project = setup_project(&temp, "project");
let elsewhere = temp.child("elsewhere");
elsewhere.create_dir_all().unwrap();
let path = elsewhere.path().to_str().unwrap().to_string();
// The first path resolves, the second does not.
let out = run(&temp, &["tui", project.to_str().unwrap(), &path]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
assert!(stderr.contains(&path), "the failing path is not named: {stderr:?}");
assert!(
stderr.contains("No .worklane directory found"),
"the usual message is gone: {stderr:?}"
);
}
/// `tui` has to appear in the help, or nothing points at it.
#[test]
fn the_help_lists_the_tui_command() {
let temp = TempDir::new().unwrap();
let out = run(&temp, &["--help"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(out.status.success());
assert!(stdout.contains("tui"), "{stdout:?}");
}