@bonesofspring/ai-rules 0.2.69 → 0.2.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,52 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 0.2.71
4
+
5
+ ### `team-tasks-ui` — catalog price tiers, model metadata, notes
6
+
7
+ - **Model record.** `version`, `releasedAt`, `notes`, `price.cacheReadPer1MTokens`, and named `price.tiers` (`time` / `context` / `promotion`) join the model contract: `catalog.schema.json`, the `catalog-refresh` write validator, the app schema, DTOs, mapper, model form, and `ModelDetailPage`. The form edits the scalar fields and carries scheduler-authored tiers through unchanged; the detail page lists each tier's kind and, for a context tier, its `from N tokens` boundary.
8
+ - **Providers and windows.** `notes` is written by both catalog writers, edited on the window form, and rendered on the provider detail page.
9
+ - **Validation.** Duplicate tier names, a `minContextTokens` on a non-context tier, a cache-read price without the input/output split, an over-long `version` / `notes`, and a non-ISO `releasedAt` are refused before a file lands.
10
+ - **Refresh keeps tiers.** `writeProviderModels` merges a refreshed `price` into the stored one instead of replacing it, so a scheduler run keeps the tiers and cache-read price the feed does not carry.
11
+ - **Tests.** `catalog.mapper.spec.ts` and `schema.spec.ts` extend, `catalogModelForm.data.spec.ts` is new: the added fields, the tier rules, and the write mapping.
12
+
13
+ ### `team-tasks-ui` — window summaries in Moscow time
14
+
15
+ - **One display zone.** `windowShapeLabel` renders every window in `Europe/Moscow`: a weekly window is shifted from its own zone at `now` (a DST zone changes the shift mid-year), its weekdays move with a midnight-crossing shift, and an absolute range is formatted in Moscow. An unknown source zone falls back to the stored hours and zone instead of failing the page.
16
+ - **`formatTimestamp`** takes an optional `timeZone`; formatters are cached per zone.
17
+ - **Tests.** `windowShapeLabel.spec.ts` covers the shift, the day wrap, DST, and the unknown-zone fallback.
18
+
19
+ ### `catalog` — provider-direct pricing sync (repo-local)
20
+
21
+ - **Sync runner.** `opencode-models-sync.mjs` reconciles `.ai.local/catalog/**` from the live OpenCode provider/model feed, adds the metadata the feed omits, and writes DeepSeek peak/off-peak prices plus provider-scoped peak windows. Manual records are never overwritten, and a record the source stops naming is frozen with its last committed note.
22
+ - **Provider-direct sources.** `deepseek-pricing.mjs` and `zai-pricing.mjs` read one markdown notice each. Z.AI's documented quota multipliers are recorded as notes, never as a USD price, and a document whose duplicated statements disagree throws instead of guessing — the last committed catalog stays.
23
+ - **Schedule.** The `opencode-models-sync` job runs at 08:00 and 20:00 `Europe/Moscow` with `concurrency: skip` through the repo's scheduler.
24
+ - **Tests.** `opencode-models-sync.test.mjs`, `deepseek-pricing.test.mjs`, `zai-pricing.test.mjs`, and the extended `catalog-refresh.test.mjs` cover ownership, freezing, offline runs, and the parsers.
25
+
26
+ ### `opencode` — output-guard discovery off the hot path
27
+
28
+ - **Detached walk.** The context hook no longer awaits usage discovery. After the in-place rewrite it starts one `session.get`, then at most 12 tracked sessions with one `session.context` and one `session.list` each (≤25 RPCs), and never awaits the walk, so the tool result cannot depend on it.
29
+ - **Bounded wait.** `AI_RULES_OUTPUT_GUARD_DISCOVERY_MS` (default 250 ms) bounds how long the hook waits, not the walk: the walk keeps running and a late response still appends its row. Nothing cancels an RPC already in flight, and the plugin README states both bounds.
30
+ - **Goldens and tests.** The 11 opencode CLI goldens are recaptured for the new `README.md` / `index.ts` hashes; `test-output-guard.mjs` grows to 33 cases and covers the detached walk, the deadline, and the isolation of a failing discovery.
31
+
32
+ ### `scripts` — `measure.mjs --strict`
33
+
34
+ - **Section verdicts.** Every `sections.rN` now pairs its `reported {at,text,figures}` claim with measured `data`, a `reproduced` boolean, `unreproducible` reasons, and the section's `ordering` claim, so a consumer reads the JSON instead of the prose.
35
+ - **Exit codes.** `--strict` exits 1 on a scored out-of-band check or a failed comparable `ordering` claim, after printing the report; `referenceOnly` totals and a bare `reproduced: false` never fail. `--strict --live` is refused — a grown ledger is not a reproduction.
36
+ - **Tests.** `test-measure.mjs` covers the verdict shape, the `r4.ordering` claim, `strictFailures`, and the usage error.
37
+
38
+ ### `team-db` — delete-refusal messages stop tripping the SQL-injection rule
39
+
40
+ - **Wording.** The API fallbacks for a refused `jobs delete` / `task delete` now read `removing <id> was refused` and `removal of <slug>` instead of `the delete of …`. The old template literal placed a SQL keyword next to an interpolated `context.params` value, so Semgrep's `tainted-sql-string` rule (CWE-89) reported the error text as a SQL string built from request input; every statement in the module is a parameterized `better-sqlite3` query, which made it a false positive.
41
+ - **Unchanged contract.** Error codes from `mapTeamDbCode`, HTTP statuses, `details`, and both delete operations are untouched — only the fallback `message` text.
42
+ - **Fixtures.** The CLI golden hash snapshots are recaptured by `fix:generated` for the new `team-db-api.mjs` and `.template-base.json` digests.
43
+
44
+ ## 0.2.70
45
+
46
+ ### `next` — `/ui-start` and `/ui-stop` return
47
+
48
+ - **Commands.** The Cursor source and Claude twin, plus the generated Mavis, OpenCode, and ZCode `next` trees, ship `ui-start` and `ui-stop`. `ui-start` stops a running `team-tasks-ui` compose stack, runs `team-db.mjs migrate-tasks`, then rebuilds and starts it; `ui-stop` takes the project down and stops only the API `/ui-start` started.
49
+ - **Scope.** The commands target repositories that contain `apps/team-tasks-ui`; both stop with a clear message when `apps/team-tasks-ui/scripts/stack.mjs` is absent.
4
50
 
5
51
  ### `resume_blocked` — the chain hook re-arms a blocked step
6
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonesofspring/ai-rules",
3
- "version": "0.2.69",
3
+ "version": "0.2.71",
4
4
  "description": "Presets of Cursor, Claude, Mavis, OpenCode, and ZCode rules/commands for Revy Ross personal use",
5
5
  "license": "MIT",
6
6
  "author": "Revy Ross",
@@ -1897,7 +1897,7 @@ const deleteJob = async (context) => {
1897
1897
  });
1898
1898
  if (result.ok !== true) {
1899
1899
  const code = typeof result.code === 'string' ? result.code : 'E_INTERNAL';
1900
- fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(result.message ?? `the delete of ${id} was refused`));
1900
+ fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(result.message ?? `removing ${id} was refused`));
1901
1901
  }
1902
1902
  return { json: { ok: true, id: String(result.id ?? id), runsRemoved: Number(result.runsRemoved ?? 0) } };
1903
1903
  };
@@ -1984,17 +1984,17 @@ const runDeleteChild = async (slug, context) => {
1984
1984
  const parsed = await runTeamDbChild(['delete', '--slug', slug], {
1985
1985
  settings: context.settings,
1986
1986
  timeoutMs: SYNC_CHILD_TIMEOUT_MS,
1987
- label: `delete of ${slug}`,
1987
+ label: `removal of ${slug}`,
1988
1988
  });
1989
1989
  if (parsed.ok === false) {
1990
1990
  const code = typeof parsed.code === 'string' ? parsed.code : 'E_INTERNAL';
1991
1991
  // The guard fires only when the target is the active slug, so the detail
1992
1992
  // names it exactly; the message the child printed names it too.
1993
1993
  const details = code === 'E_ACTIVE_TASK' ? { activeSlug: slug } : undefined;
1994
- fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(parsed.message ?? `the delete of ${slug} was refused`), details);
1994
+ fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(parsed.message ?? `removing ${slug} was refused`), details);
1995
1995
  }
1996
1996
  if (parsed.ok !== true || typeof parsed.slug !== 'string') {
1997
- fail('E_INTERNAL', 500, `the delete of ${slug} reported neither a success nor a documented refusal`);
1997
+ fail('E_INTERNAL', 500, `removing ${slug} reported neither a success nor a documented refusal`);
1998
1998
  }
1999
1999
  return { slug: parsed.slug };
2000
2000
  };
@@ -15,3 +15,8 @@ Slash-command definitions and on-demand scenarios. Copied to `.claude/commands/`
15
15
  `/task-evil` is intentionally autonomous: no plan confirmation, no human gates, no questions; recommended assumptions are recorded in `decisions.md`, and only hard blockers stop the run. On OpenCode, the command selects the `task-evil` primary agent with a hard `question: deny`, broad shell access except `git commit`/`git push` (and `npx jest*`), and edits limited to `.ai.local/team/**`.
16
16
 
17
17
  See also the preset root `README.md`. Artifacts: `.ai.local/team/README.md`.
18
+
19
+ ## UI stack commands
20
+
21
+ - **`/ui-start`** — stop the running `team-tasks-ui` stack, run `team-db.mjs migrate-tasks`, then rebuild and start it.
22
+ - **`/ui-stop`** — stop the `team-tasks-ui` stack and the team-db API that `/ui-start` started.
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: ui-start
3
+ description: "Restart the team-tasks UI stack: stop it when running, refresh the task projection, then start."
4
+ ---
5
+
6
+ # Start the team-tasks UI
7
+
8
+ Bring up `apps/team-tasks-ui` through its own Docker Compose project, rebuilt
9
+ from the current source, and guarantee the host team-db API the UI reads from.
10
+
11
+ ## What to do
12
+
13
+ 1. If `apps/team-tasks-ui/scripts/stack.mjs` is absent, stop and report that this
14
+ repository has no team-tasks UI. Otherwise, from the repository root, run:
15
+
16
+ ```bash
17
+ node apps/team-tasks-ui/scripts/stack.mjs start
18
+ ```
19
+
20
+ 2. Quote the command's stdout verbatim: the `ui:` line and the `api:` line,
21
+ including the owner state. On success the script prints
22
+ `ui: http://127.0.0.1:4300` and
23
+ `api: http://127.0.0.1:4178 (owner: pre-existing|started-by-this-script)`.
24
+ 3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not retry
25
+ with a different compose command and do not start the API by hand.
26
+ 4. The start is restart-safe: when the `team-tasks-ui` project is already
27
+ running, the script stops it first, runs `team-db.mjs migrate-tasks` against
28
+ the projection, then rebuilds the image from the current source and starts
29
+ again. A second start never binds a second stack or a second listener on the
30
+ published port.
31
+
32
+ ## What the script does
33
+
34
+ - Pins every project call to `apps/team-tasks-ui/docker-compose.yml` and the
35
+ `team-tasks-ui` project name.
36
+ - Stops a running `team-tasks-ui` project and the API this script started
37
+ before refreshing the projection.
38
+ - Runs `node .ai.local/scripts/team-db.mjs migrate-tasks --quiet --no-rebuild`
39
+ after that stop and before the rebuild, so the UI serves the current task
40
+ projection.
41
+ - Seeds `team/runner.json` from the default when it is absent.
42
+ - Starts the host API with `node .ai.local/scripts/team-db.mjs serve` only when
43
+ nothing answers on `127.0.0.1:4178`, and records that ownership in the
44
+ git-ignored `.ai.local/.ui/api.json` marker.
45
+ - Repairs a missing derived database once through `team-db.mjs sync`, and never
46
+ repairs an API this script did not start.
47
+
48
+ ## Do not
49
+
50
+ - Write `status.json`, `metrics.json`, or any task or lifecycle file.
51
+ - Run `docker stop`, `docker rm`, `docker kill`, or a bare `docker compose down`.
52
+ - Edit `apps/team-tasks-ui/docker-compose.yml`, the Dockerfile, the app source,
53
+ or the team-db API.
54
+ - Open a browser, tail container logs, or start a second copy of the app.
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: ui-stop
3
+ description: Stop the team-tasks UI compose project and the team-db API that /ui-start started.
4
+ ---
5
+
6
+ # Stop the team-tasks UI
7
+
8
+ Take down the `apps/team-tasks-ui` Docker Compose project and stop the host
9
+ team-db API only when `/ui-start` started it.
10
+
11
+ ## What to do
12
+
13
+ 1. If `apps/team-tasks-ui/scripts/stack.mjs` is absent, stop and report that this
14
+ repository has no team-tasks UI. Otherwise, from the repository root, run:
15
+
16
+ ```bash
17
+ node apps/team-tasks-ui/scripts/stack.mjs stop
18
+ ```
19
+
20
+ 2. Quote the command's stdout verbatim. On an already stopped stack it prints
21
+ `nothing running` and exits 0.
22
+ 3. On a non-zero exit, quote the `error:` line verbatim and stop.
23
+ 4. The stop is idempotent: a second stop exits 0 and changes nothing.
24
+
25
+ ## What the script does
26
+
27
+ - Pins every project call to `apps/team-tasks-ui/docker-compose.yml` and the
28
+ `team-tasks-ui` project name, and removes that project's containers and
29
+ network.
30
+ - Stops only the API process recorded in `.ai.local/.ui/api.json` whose live
31
+ command line is still `team-db.mjs serve`, then removes that marker.
32
+ - Leaves a foreign API alone: a process the marker does not prove is never
33
+ signalled.
34
+
35
+ ## Do not
36
+
37
+ - Write `status.json`, `metrics.json`, or any task or lifecycle file.
38
+ - Run `docker stop`, `docker rm`, `docker kill`, or a bare `docker compose down`.
39
+ - Stop a container outside the `team-tasks-ui` project.
40
+ - Edit `apps/team-tasks-ui/docker-compose.yml`, the Dockerfile, or the app
41
+ source.
42
+ - Kill a process on `127.0.0.1:4178` by port; only the ownership marker
43
+ authorizes a stop.
@@ -46,6 +46,11 @@ On OpenCode, `/task-evil` runs as the `task-evil` primary agent: the `question`
46
46
  → reviewer only
47
47
  ```
48
48
 
49
+ ## UI stack commands
50
+
51
+ - **`/ui-start`** — stop the running `team-tasks-ui` stack, run `team-db.mjs migrate-tasks`, then rebuild and start it.
52
+ - **`/ui-stop`** — stop the `team-tasks-ui` stack and the team-db API that `/ui-start` started.
53
+
49
54
  ## Related files
50
55
 
51
56
  - Subagents: `../agents/` (**24** roles, including `task-router.md`, `codebase-analyzer.md`)
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: ui-start
3
+ description: "Restart the team-tasks UI stack: stop it when running, refresh the task projection, then start."
4
+ ---
5
+
6
+ # Start the team-tasks UI
7
+
8
+ Bring up `apps/team-tasks-ui` through its own Docker Compose project, rebuilt
9
+ from the current source, and guarantee the host team-db API the UI reads from.
10
+
11
+ ## What to do
12
+
13
+ 1. If `apps/team-tasks-ui/scripts/stack.mjs` is absent, stop and report that this
14
+ repository has no team-tasks UI. Otherwise, from the repository root, run:
15
+
16
+ ```bash
17
+ node apps/team-tasks-ui/scripts/stack.mjs start
18
+ ```
19
+
20
+ 2. Quote the command's stdout verbatim: the `ui:` line and the `api:` line,
21
+ including the owner state. On success the script prints
22
+ `ui: http://127.0.0.1:4300` and
23
+ `api: http://127.0.0.1:4178 (owner: pre-existing|started-by-this-script)`.
24
+ 3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not retry
25
+ with a different compose command and do not start the API by hand.
26
+ 4. The start is restart-safe: when the `team-tasks-ui` project is already
27
+ running, the script stops it first, runs `team-db.mjs migrate-tasks` against
28
+ the projection, then rebuilds the image from the current source and starts
29
+ again. A second start never binds a second stack or a second listener on the
30
+ published port.
31
+
32
+ ## What the script does
33
+
34
+ - Pins every project call to `apps/team-tasks-ui/docker-compose.yml` and the
35
+ `team-tasks-ui` project name.
36
+ - Stops a running `team-tasks-ui` project and the API this script started
37
+ before refreshing the projection.
38
+ - Runs `node .ai.local/scripts/team-db.mjs migrate-tasks --quiet --no-rebuild`
39
+ after that stop and before the rebuild, so the UI serves the current task
40
+ projection.
41
+ - Seeds `team/runner.json` from the default when it is absent.
42
+ - Starts the host API with `node .ai.local/scripts/team-db.mjs serve` only when
43
+ nothing answers on `127.0.0.1:4178`, and records that ownership in the
44
+ git-ignored `.ai.local/.ui/api.json` marker.
45
+ - Repairs a missing derived database once through `team-db.mjs sync`, and never
46
+ repairs an API this script did not start.
47
+
48
+ ## Do not
49
+
50
+ - Write `status.json`, `metrics.json`, or any task or lifecycle file.
51
+ - Run `docker stop`, `docker rm`, `docker kill`, or a bare `docker compose down`.
52
+ - Edit `apps/team-tasks-ui/docker-compose.yml`, the Dockerfile, the app source,
53
+ or the team-db API.
54
+ - Open a browser, tail container logs, or start a second copy of the app.
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: ui-stop
3
+ description: Stop the team-tasks UI compose project and the team-db API that /ui-start started.
4
+ ---
5
+
6
+ # Stop the team-tasks UI
7
+
8
+ Take down the `apps/team-tasks-ui` Docker Compose project and stop the host
9
+ team-db API only when `/ui-start` started it.
10
+
11
+ ## What to do
12
+
13
+ 1. If `apps/team-tasks-ui/scripts/stack.mjs` is absent, stop and report that this
14
+ repository has no team-tasks UI. Otherwise, from the repository root, run:
15
+
16
+ ```bash
17
+ node apps/team-tasks-ui/scripts/stack.mjs stop
18
+ ```
19
+
20
+ 2. Quote the command's stdout verbatim. On an already stopped stack it prints
21
+ `nothing running` and exits 0.
22
+ 3. On a non-zero exit, quote the `error:` line verbatim and stop.
23
+ 4. The stop is idempotent: a second stop exits 0 and changes nothing.
24
+
25
+ ## What the script does
26
+
27
+ - Pins every project call to `apps/team-tasks-ui/docker-compose.yml` and the
28
+ `team-tasks-ui` project name, and removes that project's containers and
29
+ network.
30
+ - Stops only the API process recorded in `.ai.local/.ui/api.json` whose live
31
+ command line is still `team-db.mjs serve`, then removes that marker.
32
+ - Leaves a foreign API alone: a process the marker does not prove is never
33
+ signalled.
34
+
35
+ ## Do not
36
+
37
+ - Write `status.json`, `metrics.json`, or any task or lifecycle file.
38
+ - Run `docker stop`, `docker rm`, `docker kill`, or a bare `docker compose down`.
39
+ - Stop a container outside the `team-tasks-ui` project.
40
+ - Edit `apps/team-tasks-ui/docker-compose.yml`, the Dockerfile, or the app
41
+ source.
42
+ - Kill a process on `127.0.0.1:4178` by port; only the ownership marker
43
+ authorizes a stop.
@@ -3,7 +3,7 @@
3
3
  "platform": "mavis",
4
4
  "stack": "next",
5
5
  "semanticSource": "cursor/next",
6
- "sourceRevision": "4cc832fcd394b5f68f4dd3008732965b197e4db0e161cf07adf5f8fbdd6228aa",
6
+ "sourceRevision": "633684ed117315d643a4af6bfcaa880093da59c22aef618fafc931d070330711",
7
7
  "entries": [
8
8
  {
9
9
  "source": "AGENTS.md",
@@ -527,6 +527,22 @@
527
527
  "loadMode": "manual",
528
528
  "reason": "No file-defined slash command API; keep as an explicit procedure plus exec --file"
529
529
  },
530
+ {
531
+ "source": "commands/ui-start.md",
532
+ "target": "commands/ui-start.md",
533
+ "category": "commands",
534
+ "disposition": "transform",
535
+ "loadMode": "manual",
536
+ "reason": "No file-defined slash command API; keep as an explicit procedure plus exec --file"
537
+ },
538
+ {
539
+ "source": "commands/ui-stop.md",
540
+ "target": "commands/ui-stop.md",
541
+ "category": "commands",
542
+ "disposition": "transform",
543
+ "loadMode": "manual",
544
+ "reason": "No file-defined slash command API; keep as an explicit procedure plus exec --file"
545
+ },
530
546
  {
531
547
  "source": "commands/update.md",
532
548
  "target": "commands/update.md",
@@ -46,6 +46,11 @@ On OpenCode, `/task-evil` runs as the `task-evil` primary agent: the `question`
46
46
  → reviewer only
47
47
  ```
48
48
 
49
+ ## UI stack commands
50
+
51
+ - **`/ui-start`** — stop the running `team-tasks-ui` stack, run `team-db.mjs migrate-tasks`, then rebuild and start it.
52
+ - **`/ui-stop`** — stop the `team-tasks-ui` stack and the team-db API that `/ui-start` started.
53
+
49
54
  ## Related files
50
55
 
51
56
  - Subagents: `../agents/` (**24** roles, including `task-router.md`, `codebase-analyzer.md`)
@@ -0,0 +1,49 @@
1
+ # Start the team-tasks UI
2
+
3
+ Bring up `apps/team-tasks-ui` through its own Docker Compose project, rebuilt
4
+ from the current source, and guarantee the host team-db API the UI reads from.
5
+
6
+ ## What to do
7
+
8
+ 1. If `apps/team-tasks-ui/scripts/stack.mjs` is absent, stop and report that this
9
+ repository has no team-tasks UI. Otherwise, from the repository root, run:
10
+
11
+ ```bash
12
+ node apps/team-tasks-ui/scripts/stack.mjs start
13
+ ```
14
+
15
+ 2. Quote the command's stdout verbatim: the `ui:` line and the `api:` line,
16
+ including the owner state. On success the script prints
17
+ `ui: http://127.0.0.1:4300` and
18
+ `api: http://127.0.0.1:4178 (owner: pre-existing|started-by-this-script)`.
19
+ 3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not retry
20
+ with a different compose command and do not start the API by hand.
21
+ 4. The start is restart-safe: when the `team-tasks-ui` project is already
22
+ running, the script stops it first, runs `team-db.mjs migrate-tasks` against
23
+ the projection, then rebuilds the image from the current source and starts
24
+ again. A second start never binds a second stack or a second listener on the
25
+ published port.
26
+
27
+ ## What the script does
28
+
29
+ - Pins every project call to `apps/team-tasks-ui/docker-compose.yml` and the
30
+ `team-tasks-ui` project name.
31
+ - Stops a running `team-tasks-ui` project and the API this script started
32
+ before refreshing the projection.
33
+ - Runs `node .ai.local/scripts/team-db.mjs migrate-tasks --quiet --no-rebuild`
34
+ after that stop and before the rebuild, so the UI serves the current task
35
+ projection.
36
+ - Seeds `team/runner.json` from the default when it is absent.
37
+ - Starts the host API with `node .ai.local/scripts/team-db.mjs serve` only when
38
+ nothing answers on `127.0.0.1:4178`, and records that ownership in the
39
+ git-ignored `.ai.local/.ui/api.json` marker.
40
+ - Repairs a missing derived database once through `team-db.mjs sync`, and never
41
+ repairs an API this script did not start.
42
+
43
+ ## Do not
44
+
45
+ - Write `status.json`, `metrics.json`, or any task or lifecycle file.
46
+ - Run `docker stop`, `docker rm`, `docker kill`, or a bare `docker compose down`.
47
+ - Edit `apps/team-tasks-ui/docker-compose.yml`, the Dockerfile, the app source,
48
+ or the team-db API.
49
+ - Open a browser, tail container logs, or start a second copy of the app.
@@ -0,0 +1,38 @@
1
+ # Stop the team-tasks UI
2
+
3
+ Take down the `apps/team-tasks-ui` Docker Compose project and stop the host
4
+ team-db API only when `/ui-start` started it.
5
+
6
+ ## What to do
7
+
8
+ 1. If `apps/team-tasks-ui/scripts/stack.mjs` is absent, stop and report that this
9
+ repository has no team-tasks UI. Otherwise, from the repository root, run:
10
+
11
+ ```bash
12
+ node apps/team-tasks-ui/scripts/stack.mjs stop
13
+ ```
14
+
15
+ 2. Quote the command's stdout verbatim. On an already stopped stack it prints
16
+ `nothing running` and exits 0.
17
+ 3. On a non-zero exit, quote the `error:` line verbatim and stop.
18
+ 4. The stop is idempotent: a second stop exits 0 and changes nothing.
19
+
20
+ ## What the script does
21
+
22
+ - Pins every project call to `apps/team-tasks-ui/docker-compose.yml` and the
23
+ `team-tasks-ui` project name, and removes that project's containers and
24
+ network.
25
+ - Stops only the API process recorded in `.ai.local/.ui/api.json` whose live
26
+ command line is still `team-db.mjs serve`, then removes that marker.
27
+ - Leaves a foreign API alone: a process the marker does not prove is never
28
+ signalled.
29
+
30
+ ## Do not
31
+
32
+ - Write `status.json`, `metrics.json`, or any task or lifecycle file.
33
+ - Run `docker stop`, `docker rm`, `docker kill`, or a bare `docker compose down`.
34
+ - Stop a container outside the `team-tasks-ui` project.
35
+ - Edit `apps/team-tasks-ui/docker-compose.yml`, the Dockerfile, or the app
36
+ source.
37
+ - Kill a process on `127.0.0.1:4178` by port; only the ownership marker
38
+ authorizes a stop.
@@ -3,7 +3,7 @@
3
3
  "platform": "opencode",
4
4
  "stack": "next",
5
5
  "semanticSource": "cursor/next",
6
- "sourceRevision": "4cc832fcd394b5f68f4dd3008732965b197e4db0e161cf07adf5f8fbdd6228aa",
6
+ "sourceRevision": "633684ed117315d643a4af6bfcaa880093da59c22aef618fafc931d070330711",
7
7
  "entries": [
8
8
  {
9
9
  "source": "AGENTS.md",
@@ -527,6 +527,22 @@
527
527
  "loadMode": "native-skill",
528
528
  "reason": "Native slash commands under .opencode/commands; $ARGUMENTS kept"
529
529
  },
530
+ {
531
+ "source": "commands/ui-start.md",
532
+ "target": "commands/ui-start.md",
533
+ "category": "commands",
534
+ "disposition": "transform",
535
+ "loadMode": "native-skill",
536
+ "reason": "Native slash commands under .opencode/commands; $ARGUMENTS kept"
537
+ },
538
+ {
539
+ "source": "commands/ui-stop.md",
540
+ "target": "commands/ui-stop.md",
541
+ "category": "commands",
542
+ "disposition": "transform",
543
+ "loadMode": "native-skill",
544
+ "reason": "Native slash commands under .opencode/commands; $ARGUMENTS kept"
545
+ },
530
546
  {
531
547
  "source": "commands/update.md",
532
548
  "target": "commands/update.md",
@@ -46,6 +46,11 @@ On OpenCode, `/task-evil` runs as the `task-evil` primary agent: the `question`
46
46
  → reviewer only
47
47
  ```
48
48
 
49
+ ## UI stack commands
50
+
51
+ - **`/ui-start`** — stop the running `team-tasks-ui` stack, run `team-db.mjs migrate-tasks`, then rebuild and start it.
52
+ - **`/ui-stop`** — stop the `team-tasks-ui` stack and the team-db API that `/ui-start` started.
53
+
49
54
  ## Related files
50
55
 
51
56
  - Subagents: `../agents/` (**24** roles, including `task-router.md`, `codebase-analyzer.md`)
@@ -0,0 +1,57 @@
1
+ ---
2
+ description: "Restart the team-tasks UI stack: stop it when running, refresh the task projection, then start."
3
+ ---
4
+
5
+ ## Invocation arguments
6
+
7
+ $ARGUMENTS
8
+
9
+ # Start the team-tasks UI
10
+
11
+ Bring up `apps/team-tasks-ui` through its own Docker Compose project, rebuilt
12
+ from the current source, and guarantee the host team-db API the UI reads from.
13
+
14
+ ## What to do
15
+
16
+ 1. If `apps/team-tasks-ui/scripts/stack.mjs` is absent, stop and report that this
17
+ repository has no team-tasks UI. Otherwise, from the repository root, run:
18
+
19
+ ```bash
20
+ node apps/team-tasks-ui/scripts/stack.mjs start
21
+ ```
22
+
23
+ 2. Quote the command's stdout verbatim: the `ui:` line and the `api:` line,
24
+ including the owner state. On success the script prints
25
+ `ui: http://127.0.0.1:4300` and
26
+ `api: http://127.0.0.1:4178 (owner: pre-existing|started-by-this-script)`.
27
+ 3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not retry
28
+ with a different compose command and do not start the API by hand.
29
+ 4. The start is restart-safe: when the `team-tasks-ui` project is already
30
+ running, the script stops it first, runs `team-db.mjs migrate-tasks` against
31
+ the projection, then rebuilds the image from the current source and starts
32
+ again. A second start never binds a second stack or a second listener on the
33
+ published port.
34
+
35
+ ## What the script does
36
+
37
+ - Pins every project call to `apps/team-tasks-ui/docker-compose.yml` and the
38
+ `team-tasks-ui` project name.
39
+ - Stops a running `team-tasks-ui` project and the API this script started
40
+ before refreshing the projection.
41
+ - Runs `node .ai.local/scripts/team-db.mjs migrate-tasks --quiet --no-rebuild`
42
+ after that stop and before the rebuild, so the UI serves the current task
43
+ projection.
44
+ - Seeds `team/runner.json` from the default when it is absent.
45
+ - Starts the host API with `node .ai.local/scripts/team-db.mjs serve` only when
46
+ nothing answers on `127.0.0.1:4178`, and records that ownership in the
47
+ git-ignored `.ai.local/.ui/api.json` marker.
48
+ - Repairs a missing derived database once through `team-db.mjs sync`, and never
49
+ repairs an API this script did not start.
50
+
51
+ ## Do not
52
+
53
+ - Write `status.json`, `metrics.json`, or any task or lifecycle file.
54
+ - Run `docker stop`, `docker rm`, `docker kill`, or a bare `docker compose down`.
55
+ - Edit `apps/team-tasks-ui/docker-compose.yml`, the Dockerfile, the app source,
56
+ or the team-db API.
57
+ - Open a browser, tail container logs, or start a second copy of the app.
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: "Stop the team-tasks UI compose project and the team-db API that /ui-start started."
3
+ ---
4
+
5
+ ## Invocation arguments
6
+
7
+ $ARGUMENTS
8
+
9
+ # Stop the team-tasks UI
10
+
11
+ Take down the `apps/team-tasks-ui` Docker Compose project and stop the host
12
+ team-db API only when `/ui-start` started it.
13
+
14
+ ## What to do
15
+
16
+ 1. If `apps/team-tasks-ui/scripts/stack.mjs` is absent, stop and report that this
17
+ repository has no team-tasks UI. Otherwise, from the repository root, run:
18
+
19
+ ```bash
20
+ node apps/team-tasks-ui/scripts/stack.mjs stop
21
+ ```
22
+
23
+ 2. Quote the command's stdout verbatim. On an already stopped stack it prints
24
+ `nothing running` and exits 0.
25
+ 3. On a non-zero exit, quote the `error:` line verbatim and stop.
26
+ 4. The stop is idempotent: a second stop exits 0 and changes nothing.
27
+
28
+ ## What the script does
29
+
30
+ - Pins every project call to `apps/team-tasks-ui/docker-compose.yml` and the
31
+ `team-tasks-ui` project name, and removes that project's containers and
32
+ network.
33
+ - Stops only the API process recorded in `.ai.local/.ui/api.json` whose live
34
+ command line is still `team-db.mjs serve`, then removes that marker.
35
+ - Leaves a foreign API alone: a process the marker does not prove is never
36
+ signalled.
37
+
38
+ ## Do not
39
+
40
+ - Write `status.json`, `metrics.json`, or any task or lifecycle file.
41
+ - Run `docker stop`, `docker rm`, `docker kill`, or a bare `docker compose down`.
42
+ - Stop a container outside the `team-tasks-ui` project.
43
+ - Edit `apps/team-tasks-ui/docker-compose.yml`, the Dockerfile, or the app
44
+ source.
45
+ - Kill a process on `127.0.0.1:4178` by port; only the ownership marker
46
+ authorizes a stop.
@@ -16,6 +16,7 @@ outgoing model call; persisted history is untouched.
16
16
  | Replacement | 40-line / 2 KB head + 15-line / 1 KB tail + path + hints |
17
17
  | Saved file | `.ai.local/team/output-guard/<sessionID>/outputs/<callID>-<tool>.txt`, 2 MiB cap |
18
18
  | Stats | `.ai.local/team/output-guard/stats.jsonl` (one row per replacement) |
19
+ | Ledgers | `results.jsonl`, `usage.jsonl`, `context.jsonl` — see [Ledgers](#ledgers) |
19
20
  | Kill switch | `AI_RULES_OUTPUT_GUARD=0` |
20
21
  | Debug | `AI_RULES_OUTPUT_GUARD_DEBUG=1` → `output-guard/debug.log` |
21
22
  | Host | OpenCode V2 with `ctx.session.hook`; a host without it no-ops |
@@ -24,6 +25,46 @@ The replacement keeps the first and last lines because a test log often carries
24
25
  the failure at the end. A JSON-looking result is still replaced, with a
25
26
  `[json: full document at the path]` note so the agent can `jq` the file.
26
27
 
28
+ ## Ledgers
29
+
30
+ All four files live in `.ai.local/team/output-guard/`. None but `results.jsonl`
31
+ and `usage.jsonl` rotate.
32
+
33
+ | File | Row | Written when |
34
+ |---|---|---|
35
+ | `stats.jsonl` | `sessionID`, `callID`, `tool`, `beforeBytes`, `afterBytes`, `path` | a result is replaced |
36
+ | `results.jsonl` | `sessionID`, `callID`, `tool`, `command`, `rawBytes`, `returnedBytes`, `replaced`, `path` | a tool result is seen |
37
+ | `usage.jsonl` | `sessionID`, `messageID`, `agent`, `model`, `input`, `output`, `reasoning`, `cacheRead`, `cacheWrite`, `cost`, `finish` | a message carries token counts |
38
+ | `context.jsonl` | `sessionID`, `toolset`, `tools`, `toolSchemaBytes`, `systemBytes`, `byTool[]`, `mcpServers[]` | a session's toolset changes |
39
+
40
+ `usage.jsonl` covers the session running the hook **and the child sessions it
41
+ discovers**. A child row adds `parentSessionID`; a root row, and every row
42
+ written before this field existed, has no such key — absence means "root or
43
+ unattributed". A session tags its own rows from `session.get({ sessionID })`
44
+ `parentID`, so a child that runs its own `context` hook still writes child rows.
45
+ Discovery is the backstop for a child whose hook never reaches this plugin:
46
+ `session.created` (host v2 `event.subscribe`, payload `data.parentID`) catches
47
+ children created after setup, and `session.list({ directory, parentID })`
48
+ catches children that already existed. A child is read with
49
+ `session.context({ sessionID })`, the same call the root uses.
50
+
51
+ Discovery is bounded and off the hot path: one `session.get`, then at most
52
+ `MAX_TRACKED_SESSIONS = 12` sessions, each read with one `session.context` and
53
+ one `session.list` — ≤25 RPCs per hook. It starts after the rewrite and is not
54
+ awaited, so the tool result never depends on it. `AI_RULES_OUTPUT_GUARD_DISCOVERY_MS`
55
+ (default 250 ms) bounds how long the plugin waits for the whole walk, not the walk
56
+ itself: the walk keeps running and a late response still appends its row; rows are
57
+ absent only when the host never answers.
58
+
59
+ `context.jsonl` keeps one row per distinct `(sessionID, toolset hash)`.
60
+ `toolSchemaBytes` is the summed UTF-8 size of every `{description, input}` tool
61
+ schema at dispatch; `byTool[]` is `{name, bytes}` per tool; `systemBytes` is the
62
+ summed size of the system part texts. `mcpServers[]` is `{name, tools, bytes}`
63
+ for configured MCP servers whose name prefixes at least one tool
64
+ (`<server>_<tool>`); the key is **omitted** when the MCP list call fails, so a
65
+ reader never mistakes a failed call for a measured zero. A session with no
66
+ tools writes no row.
67
+
27
68
  ## Why a hook, not a rule
28
69
 
29
70
  A prose line asks the agent to pipe output; context-mode measured that path at