From d4887e820d306f7e7c2a5662f2dd9fdea2db8c24 Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 18 Nov 2026 00:20:04 +0100 Subject: [PATCH 1/2] feat(tracker): the tracker's commands follow the command vocabulary Each list narrows by its query, as deals list does, in place of filter flags: issues list team: project: assignee:none state: type:started label:, and archived:include on every list. issues task is issues assign, and its --due takes a time as well as a day. issues search --any is gone. A tracker CLI made from the template then passes cli-dev lint (with cli-base's tracker nouns). Co-Authored-By: Claude Opus 5.5 --- changes/feat-tracker-commands-vocabulary.md | 8 + docs/dev/TRACKER.md | 7 +- src/tracker/cli/commands.test.ts | 14 +- src/tracker/cli/index.ts | 155 ++++++++++---------- 4 files changed, 100 insertions(+), 84 deletions(-) create mode 100644 changes/feat-tracker-commands-vocabulary.md diff --git a/changes/feat-tracker-commands-vocabulary.md b/changes/feat-tracker-commands-vocabulary.md new file mode 100644 index 000000000..f6b646d6f --- /dev/null +++ b/changes/feat-tracker-commands-vocabulary.md @@ -0,0 +1,8 @@ +### Changed — may break callers + +- **The tracker's commands follow the command vocabulary**, so `cli-dev lint` passes a tracker CLI (with cli-base + 0.117.0, which has `issues`, `teams`, `states` and `labels`). Each list narrows by its query, as `deals list` does: + `issues list team: project: assignee:none state: type:started label:`, and `archived:include` on + every list, in place of `--team`, `--project`, `--assignee`, `--state`, `--type`, `--label` and `--archived`. + `issues task` is `issues assign`, and its `--due` takes a time as well as a day. `issues search --any` is gone. + See [Trackers](../docs/dev/TRACKER.md#commands). diff --git a/docs/dev/TRACKER.md b/docs/dev/TRACKER.md index a810b8285..e266c6837 100644 --- a/docs/dev/TRACKER.md +++ b/docs/dev/TRACKER.md @@ -57,15 +57,16 @@ identity linked to a person has, joined when read. Nothing is written to the peo ## An issue as the owner's task -`trackerIssueTask(store, account, issue)` and `issues task ` make an issue the owner's task: `source` is +`trackerIssueTask(store, account, issue)` and `issues assign ` make an issue the owner's task: `source` is `tracker:issue/`, `sourceKind` is `tracker_issue`, and the title is the issue's key only. The task links to the issue and copies none of its text. The same issue again answers the task it already has. ## Commands -`addTrackerCommands(program, { app, open })` mounts `sync`, `issues list|show|search|task`, and `list` for +`addTrackerCommands(program, { app, open })` mounts `sync`, `issues list|show|search|assign`, and `list` for `projects`, `teams`, `users` (each with its person), `states` and `labels`. Every text field from the tracker is named -in the row's `untrusted`. +in the row's `untrusted`. Each list narrows by its query, as `deals list` does: +`issues list team: assignee:none type:started`, and `archived:include` for archived rows too. ## A tracker described as data diff --git a/src/tracker/cli/commands.test.ts b/src/tracker/cli/commands.test.ts index 41c131a2d..ce1392c49 100644 --- a/src/tracker/cli/commands.test.ts +++ b/src/tracker/cli/commands.test.ts @@ -51,13 +51,14 @@ const setup = async () => { const ids = (answer: Answer) => answer.items.map((one) => one.external_id) describe("tracker commands", () => { - it("syncs, then lists, shows, searches and makes a task of an issue", async () => { + it("syncs, then lists, shows, searches and assigns an issue to the owner as a task", async () => { const { cli, store } = await setup() expect((await cli("sync")).item).toMatchObject({ state: "complete", provider: "fake-tracker" }) - expect(ids(await cli("issues", "list", "--type", "started", "--type", "unstarted"))).toEqual(["issue-2", "issue-1"]) - expect(ids(await cli("issues", "list", "--assignee", "none"))).toEqual(["issue-3"]) - const [first] = (await cli("issues", "list", "--label", "label-bug")).items + expect(ids(await cli("issues", "list", "type:started"))).toEqual(["issue-1"]) + expect(ids(await cli("issues", "list", "type:unstarted"))).toEqual(["issue-2"]) + expect(ids(await cli("issues", "list", "assignee:none"))).toEqual(["issue-3"]) + const [first] = (await cli("issues", "list", "label:label-bug")).items expect(first).toMatchObject({ key: "ENG-1", state_name: "In Progress", @@ -77,14 +78,15 @@ describe("tracker commands", () => { expect(ids(second)).toHaveLength(1) expect(ids(second)[0]).not.toBe(one) - const task = (await cli("issues", "task", "ENG-2", "--due", "2026-12-01")).item + const task = (await cli("issues", "assign", "ENG-2", "--due", "2026-12-01")).item expect(task).toMatchObject({ issue: "tracker:issue/issue-2", created: true }) - expect((await cli("issues", "task", "issue-2")).item).toMatchObject({ task_id: task.task_id, created: false }) + expect((await cli("issues", "assign", "issue-2")).item).toMatchObject({ task_id: task.task_id, created: false }) const [stored] = await store.tasks.query("fake-tracker:workspace", undefined, { limit: 10, offset: 0 }) expect(stored).toMatchObject({ title: "ENG-2", task: { source: "tracker:issue/issue-2" } }) expect(stored?.task).not.toHaveProperty("description") expect(ids(await cli("states", "list", "--limit", "10"))).toHaveLength(6) + await expect(cli("issues", "list", "team:a", "team:b")).rejects.toThrow() expect(ids(await cli("projects", "list"))).toEqual(["project-1"]) }) }) diff --git a/src/tracker/cli/index.ts b/src/tracker/cli/index.ts index 47c6e3c7c..ba79004a5 100644 --- a/src/tracker/cli/index.ts +++ b/src/tracker/cli/index.ts @@ -1,4 +1,5 @@ import { annotate, sharedCommand } from "@wirecat/cli-base/commands" +import type { QueryRegistry } from "@wirecat/cli-base/query" import type { NextStep } from "@wirecat/cli-base/standards" import { type Command, InvalidArgumentError } from "commander" import * as v from "valibot" @@ -7,6 +8,7 @@ import { environmentOf, inCommandRun, outputFor, runBudgetOf } from "../../cli/c import { honoursDryRun } from "../../cli/dry-run-guard.js" import { FETCH, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "../../cli/effects.js" import { type Body, itemOf, listOf, renderAnswer } from "../../cli/envelope.js" +import { queryTerms, termField, withQuery } from "../../cli/list-query.js" import { STATE_TYPES, type StateType, @@ -49,17 +51,38 @@ const integer = (most: number) => (value: string) => { return number } -const day = (value: string) => { - if (!/^\d{4}-\d{2}-\d{2}$/.test(value) || Number.isNaN(Date.parse(value))) - throw new InvalidArgumentError("a day as YYYY-MM-DD") - return value +/** A due time as the vocabulary's `