(2f3796e) Add a --tag filter to worklane ls, and bump to 0.14.0

Tickets carry a Tags field, but ls could not select on it: finding what is
tagged bug meant reading the board. Step 1 of the plan was already done by
e41802b, which put tags: Vec<String> on TicketItem through parse_tags, so this
is the flag, the filter and the tests.

Whole values, not the field. parse_tags has already split and trimmed the
comma-separated field, so filter_by_tag compares against those values: --tag
bug is not answered by a ticket tagged bugfix, --tag "cli, filter" matches
nothing because the field as written is not itself a tag, and a ticket with no
tags matches none, however it spells it.

Case sensitive, which is the opinion the field already takes everywhere else.
tag_color draws Bug and bug in two colours because they are two tags to the
field, and a filter that folded them would list tickets carrying a tag nobody
asked for while hiding exactly the split a grooming sweep is looking for.

One tag per invocation. Several would have to decide between and and or, and
that decision is its own ticket, along with substring or regex matching and a
tag filter on the board.

A tag nothing carries lists nothing rather than being refused, deliberately
the opposite of --campaign. A campaign is an object that exists or does not,
so it is resolved before anything is read; a tag is free text with no
registry, and refusing an unknown one would mean maintaining a vocabulary the
format does not have. An emptied status keeps the message ls already gives
rather than one per filter naming what excluded them, which is what --priority
and --campaign already do.

The filter goes through filtered, the one call the three collect sites share,
so the counts are filtered by the same set as the rows. Every filter is an
Option and none asked for keeps everything, which is what makes them compose
in any combination. cmd_ls is now at four filters and the directory, two of
them adjacent &Option<String> parameters a caller can swap silently: left as
positionals rather than refactored mid-feature, with AGENTS.md recording that
the next filter takes an LsArgs struct the way add took AddArgs.

assets/PLAN.md said in as many words that there was no tag filter yet, so it
would have been actively wrong. It now says what --tag can and cannot answer:
it finds what is tagged bug, it does not enumerate the vocabulary, which is
the question a grooming sweep starts from. The README's ls row also gained
--campaign, which had never been documented there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-22 14:54:50 +02:00
co-authored by Claude Opus 5
parent 0ce3fdb246
commit c437d87e9e
10 changed files with 244 additions and 13 deletions
+9
View File
@@ -64,6 +64,15 @@ and this file is for what someone changing worklane's own code needs.
- **A paragraph break in a description is an empty `--description` value.** `cmd_add` joins the values with a single newline, so `-d "First." -d "" -d "Second."` writes the blank line. `trim_blank_ends()` drops blank values at either end, so a break never lands against a section heading, and an all-blank description reads as no description. Interior runs are kept verbatim rather than collapsed
- `--acceptance` and `--plan` are lists, one criterium or step per value, so a blank there is spacing rather than content and the opencode wrapper drops it. Only `--description` preserves blanks
### Filtering the Listing
- **The filters are one call, `filtered`,** because `ls` collects a column in three places (a named status, the counts, and the grouped listing) and three call sites are three chances to apply a different set. Every filter is an `Option` and none asked for keeps everything, which is what makes them compose in any combination without a rule per pair
- **`--tag` matches whole values, not the field.** `parse_tags` has already split the comma-separated field, so the filter compares against those trimmed values: `--tag bug` is not answered by a ticket tagged `bugfix`, and `--tag "cli, filter"` matches nothing, because the field as written is not itself a tag. A ticket with no tags matches none
- **Case sensitive**, the opinion the field already takes: `tag_color` draws `Bug` and `bug` in two colours because they are two tags. A filter that folded them would list tickets carrying a tag nobody asked for, and would hide exactly the split a grooming sweep is looking for
- **One tag per invocation.** Several would have to decide between and and or, and neither reading is obviously right for a board this size. That decision is its own ticket, along with a substring or regex match and a tag filter on the tui
- **A tag nothing carries lists nothing rather than being refused**, which is the opposite of `--campaign`. A campaign is an object that either exists or does not, so it is resolved before anything is read and an unknown one is an error. A tag is free text with no registry: there is nothing to resolve against, and refusing an unknown one would mean maintaining a vocabulary the format deliberately does not have. `assets/PLAN.md` tells the agent to check the spelling when a listing comes back empty, since that is the failure this trades for
- An emptied status keeps the message `ls` already gives, `No tickets in '<status>' status.`, rather than one per filter naming what excluded them. That is pre-existing behaviour for `--priority` and `--campaign`, and one message for every filter is the consistent half of it. If it should name the filter, that is a change to what the CLI prints for three flags at once and belongs in its own ticket
- **`cmd_ls` is now at the boundary the Rust Style rule names:** four filters and the directory. Two of them are adjacent `&Option<String>` parameters, which a caller can swap silently, so the next filter added here takes an `LsArgs` struct the way `add` took `AddArgs`, rather than a fifth positional
### Editing a Ticket
- `set` replaces a field, `append` adds to a section. The verb carries the meaning, so no flag needs a replace-or-append prefix, and `append` only offers the sections that hold multiple lines
- **One field, one writer.** `set` has no `--owner` (that is `chown`'s) and no `--status` (that is `mv`'s). Do not add either
Generated
+1 -1
View File
@@ -1494,7 +1494,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.13.7"
version = "0.14.0"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.13.7"
version = "0.14.0"
edition = "2024"
[dependencies]
+1 -1
View File
@@ -8,7 +8,7 @@ Worklane is a local Kanban flow for agentic software development.
| `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, `/` to jump to the first ticket whose id or title matches, `y` to copy the selected ticket's short id to the clipboard, `q` to quit. Each path opens the first `.worklane` at or above it, the working directory by default. Several paths are monitored together, as a tab per project plus an `all` tab that merges them, with `tab` and `shift+tab` between them |
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags. `--due` takes `YYYY-MM-DD` and refuses anything else at parse time |
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>`, `--tag <tag>` and `--campaign <campaign>`, which compose in any combination. `--tag` matches a whole value of the comma-separated Tags field, case sensitively, so `--tag bug` does not list a ticket tagged `bugfix` or one tagged `Bug` |
| `worklane show <id>` | Shows ticket by UUID prefix (4+ chars), title substring, or filename substring |
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
| `worklane set <ticket>` | Replaces fields with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--priority`. At least one required. Changing the title renames the file, keeping the UUID |
+7 -4
View File
@@ -56,14 +56,17 @@ The last two rows are in the table to be recognised, not used. See the closing s
worklane ls # every status, counts then tickets
worklane ls backlog # one status
worklane ls --priority 1 # the top of the pile
worklane ls --tag bug # one tag's worth of the board
worklane show 1b78a24 # one ticket, with its relations and comments
worklane campaign ls # the goals that already exist
```
`ls` prints the mark, the id, the title, the owner and the due date. It does **not**
print tags, and there is no tag filter yet, so any judgement about tags means reading the
tickets themselves. On a board of a few dozen that is a `show` per ticket and is worth
doing rather than guessing from titles.
print tags, so the vocabulary itself still has to be read off the tickets: `--tag` answers
"what is tagged `bug`" and cannot answer "what tags exist", which is the question a
grooming sweep starts from. Count the vocabulary with a `show` per ticket, then use
`--tag` to check each candidate, and remember that `--tag` matches whole values case
sensitively: `bug` and `Bug` are two answers, which is exactly the split worth reporting.
Read `done` too when the question is about what to do next. What was finished last is the
best evidence of what this board actually moves at, and a plan that ignores it is a wish.
@@ -137,7 +140,7 @@ what is actually used, and show the count before proposing anything. What to rep
that will disagree with it. This board already made that mistake once with priority and
undid it deliberately.
- **An untagged ticket** in a board where everything else is tagged. It is invisible to
every question asked by tag.
every question asked by tag, `worklane ls --tag` included.
Tags are for kind, not for state and not for goal. State is the status directory and the
fields; a goal is a campaign.
+8
View File
@@ -41,11 +41,19 @@ A move is also refused while the ticket is blocked by one that is not done yet,
worklane ls # every status, counts then tickets
worklane ls backlog # one status
worklane ls --priority 1 # only the most urgent
worklane ls --tag bug # only the tickets carrying that tag
worklane show 1b78a24 # one ticket, body and comments
```
`ls` prints a seven-character id per ticket. That is what you address it by.
The filters compose in any combination, with each other and with the status positional:
`worklane ls backlog --tag bug --priority 1`. `--tag` takes one tag and matches it
against the whole values of the comma-separated `Tags` field, case sensitively, so
`--tag bug` finds neither a ticket tagged `bugfix` nor one tagged `Bug`. A ticket with no
tags matches none. A tag nothing carries lists nothing rather than failing, so when a
listing comes back empty check the spelling against a ticket you know is tagged.
## Working a ticket
```
+4
View File
@@ -120,6 +120,10 @@ pub enum Command {
#[arg(long, value_parser = priority_level)]
priority: Option<u8>,
/// Only show tickets carrying this tag, matched whole
#[arg(long, value_parser = non_empty)]
tag: Option<String>,
/// Only show the members of this campaign, by UUID or title
#[arg(long, value_parser = non_empty)]
campaign: Option<String>,
+37 -5
View File
@@ -40,6 +40,7 @@ pub fn cmd_init(start: &Path) -> Result<()> {
pub fn cmd_ls(
status_filter: &Option<String>,
priority_filter: Option<u8>,
tag_filter: &Option<String>,
campaign_filter: &Option<String>,
worklane_dir: &Path,
) -> Result<()> {
@@ -50,6 +51,7 @@ pub fn cmd_ls(
None => None,
};
let uuid = campaign.as_ref().map(|campaign| campaign.uuid.as_str());
let tag = tag_filter.as_deref();
if let Some(campaign) = &campaign {
println!(
@@ -68,7 +70,7 @@ pub fn cmd_ls(
));
}
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid);
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
if items.is_empty() {
println!("No tickets in '{}' status.", status);
@@ -86,7 +88,7 @@ pub fn cmd_ls(
if !status_path.exists() {
continue;
}
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid);
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
let count = items.len();
let label = if count == 1 { "ticket" } else { "tickets" };
println!(" [{}] {} {}", status.to_uppercase(), count, label);
@@ -102,7 +104,7 @@ pub fn cmd_ls(
continue;
}
let items = match collect_ticket_items(&status_path) {
Ok(items) => filtered(items, priority_filter, uuid),
Ok(items) => filtered(items, priority_filter, uuid, tag),
Err(_) => continue,
};
if items.is_empty() {
@@ -119,8 +121,38 @@ pub fn cmd_ls(
/// The listing filters in one call, so the three places `ls` collects a column cannot
/// end up applying a different set of them.
fn filtered(items: Vec<TicketItem>, level: Option<u8>, campaign: Option<&str>) -> Vec<TicketItem> {
filter_by_campaign(filter_by_priority(items, level), campaign)
///
/// Every filter is `Option`, and none asked for is everything kept, which is what makes
/// them compose in any combination without a rule per pair.
fn filtered(
items: Vec<TicketItem>,
level: Option<u8>,
campaign: Option<&str>,
tag: Option<&str>,
) -> Vec<TicketItem> {
filter_by_tag(
filter_by_campaign(filter_by_priority(items, level), campaign),
tag,
)
}
/// Keep only the tickets carrying `tag`, or everything when none was asked for.
///
/// Matched against the whole values `parse_tags` split out of the field rather than as a
/// substring of it, so `--tag bug` is not answered by a ticket tagged `bugfix`, and a
/// ticket with no tags matches nothing at all.
///
/// Case sensitive, the opinion the field already takes everywhere else: `tag_color`
/// draws `Bug` and `bug` in two colours because they are two tags, and a filter that
/// folded them would list tickets carrying a tag nobody asked for.
fn filter_by_tag(items: Vec<TicketItem>, tag: Option<&str>) -> Vec<TicketItem> {
match tag {
Some(tag) => items
.into_iter()
.filter(|item| item.tags.iter().any(|carried| carried == tag))
.collect(),
None => items,
}
}
/// Keep only the members of `campaign`, or everything when none was asked for.
+2 -1
View File
@@ -49,10 +49,11 @@ fn main() -> Result<()> {
Some(Command::Ls {
status,
priority,
tag,
campaign,
}) => {
let worklane_dir = find_worklane_dir(&start)?;
cmd_ls(&status, priority, &campaign, &worklane_dir)
cmd_ls(&status, priority, &tag, &campaign, &worklane_dir)
}
Some(Command::Show { id }) => {
let worklane_dir = find_worklane_dir(&start)?;
+174
View File
@@ -296,3 +296,177 @@ fn ls_shows_a_mark_for_the_level() {
// The raw number is not what the listing shows
assert!(!stdout.contains(" 1 "), "the digit leaked into the row");
}
/// A ticket whose Tags field is whatever the test needs it to be, written verbatim so a
/// missing field, an unset one and a real list are all reachable.
fn create_ticket_with_tags(
worklane_dir: &std::path::Path,
status: &str,
title: &str,
tags: &str,
priority: &str,
) {
let slug: String = title.to_lowercase().replace(' ', "-");
let body = format!(
"# {title}\n\n## Metadata\n\n - **ID**: 00000000-0000-0000-0000-000000000001\n - **Priority**: {priority}\n{tags} - **Due**: _Not set_\n- **Owner**: alice\n- **Status**: {status}\n"
);
fs::write(
worklane_dir
.join(status)
.join(format!("00000000-0000-0000-0000-000000000001_{slug}.md")),
body,
)
.unwrap();
}
/// The Tags line as a ticket carries it, for the common case of a real list.
fn tags(list: &str) -> String {
format!("- **Tags**: {list}\n")
}
#[test]
fn ls_filters_by_tag_and_composes_with_status_and_priority() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_tags(&worklane, "backlog", "Tagged bug", &tags("bug,cli"), "1");
create_ticket_with_tags(&worklane, "backlog", "Tagged feature", &tags("feature"), "1");
create_ticket_with_tags(&worklane, "backlog", "Lower bug", &tags("bug"), "3");
create_ticket_with_tags(&worklane, "committed", "Started bug", &tags("bug"), "1");
// Alone, through the grouped listing: every status, only the tagged tickets.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "--tag", "bug"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Tagged bug"), "{stdout}");
assert!(stdout.contains("Lower bug"), "{stdout}");
assert!(stdout.contains("Started bug"), "a tagged ticket in another status was dropped");
assert!(!stdout.contains("Tagged feature"), "an untagged ticket came through");
// The counts are filtered too, since they are the same collect.
assert!(stdout.contains("[BACKLOG] 2 tickets"), "{stdout}");
assert!(stdout.contains("[COMMITTED] 1 ticket"), "{stdout}");
// With the status positional.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "bug"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Tagged bug"));
assert!(stdout.contains("Lower bug"));
assert!(!stdout.contains("Started bug"), "the status was ignored");
// With --priority, and with both: none asked for is everything kept, so the three
// compose without a rule per pair.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "--tag", "bug", "--priority", "1"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Tagged bug"));
assert!(stdout.contains("Started bug"));
assert!(!stdout.contains("Lower bug"), "the priority was ignored");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "bug", "--priority", "1"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Tagged bug"));
assert!(!stdout.contains("Lower bug"), "the priority was ignored");
assert!(!stdout.contains("Started bug"), "the status was ignored");
assert!(!stdout.contains("Tagged feature"), "the tag was ignored");
}
/// The field is a list of whole values, not a string to search: a ticket tagged `bugfix`
/// is not a ticket tagged `bug`, and neither is one tagged `Bug`. Case sensitive is the
/// opinion the field already takes, since `tag_color` draws those two differently.
#[test]
fn ls_matches_a_whole_tag_value_and_not_a_substring_or_another_case() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_tags(&worklane, "backlog", "Real bug", &tags("bug"), "2");
create_ticket_with_tags(&worklane, "backlog", "Only bugfix", &tags("bugfix"), "2");
create_ticket_with_tags(&worklane, "backlog", "Capital Bug", &tags("Bug"), "2");
// A value that only appears with its neighbours around it, so a match on the raw
// field would find it and a match on the split values cannot.
create_ticket_with_tags(&worklane, "backlog", "Spaced list", &tags("cli, filter"), "2");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "bug"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Real bug"), "{stdout}");
assert!(!stdout.contains("Only bugfix"), "bug matched bugfix");
assert!(!stdout.contains("Capital Bug"), "bug matched Bug");
// Trimmed on the way in, so the space after the comma is not part of the tag.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "filter"]);
assert!(get_stdout(&mut cmd).contains("Spaced list"));
// And the field as written is not itself a tag.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "cli, filter"]);
let stdout = get_stdout(&mut cmd);
assert!(!stdout.contains("Spaced list"), "the whole field matched as one tag");
}
/// No tags is no match, however the ticket spells it: the field absent, unset, or empty.
#[test]
fn ls_never_matches_a_ticket_carrying_no_tags() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_tags(&worklane, "backlog", "Has one", &tags("bug"), "2");
create_ticket_with_tags(&worklane, "backlog", "Field unset", &tags("_None_"), "2");
create_ticket_with_tags(&worklane, "backlog", "Field empty", "- **Tags**:\n", "2");
create_ticket_with_tags(&worklane, "backlog", "Field missing", "", "2");
create_ticket_with_tags(&worklane, "backlog", "Only commas", &tags(", ,"), "2");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "bug"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Has one"), "{stdout}");
for absent in ["Field unset", "Field empty", "Field missing", "Only commas"] {
assert!(!stdout.contains(absent), "{absent} matched a tag it does not carry");
}
// Nor does an empty tag reach the filter: the value parser refuses it, so nothing is
// listed rather than everything.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", ""]);
cmd.assert().failure().code(2);
}
/// A tag nothing carries lists nothing and still succeeds. The message is the one `ls`
/// already gives for a filter that empties a status, rather than a second one invented
/// here for tags alone.
#[test]
fn ls_with_a_tag_nothing_carries_lists_nothing() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket_with_tags(&worklane, "backlog", "Tagged bug", &tags("bug"), "2");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "frontend"]);
cmd.assert().success();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--tag", "frontend"]);
let stdout = get_stdout(&mut cmd);
assert!(!stdout.contains("Tagged bug"), "{stdout}");
assert!(stdout.contains("No tickets in 'backlog' status."), "{stdout}");
// Through the grouped listing the counts go to zero and no section is drawn.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "--tag", "frontend"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("[BACKLOG] 0 tickets"), "{stdout}");
assert!(!stdout.contains("Tagged bug"), "{stdout}");
}