@popovych.co/witness 0.26.1 → 0.27.0

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.
Files changed (41) hide show
  1. package/README.md +4 -3
  2. package/dist/battery.js +2 -1
  3. package/dist/cli.js +13 -0
  4. package/dist/deferral.js +5 -4
  5. package/dist/design.js +534 -1
  6. package/dist/drift.js +2 -1
  7. package/dist/drive-presence.js +16 -5
  8. package/dist/drive.js +275 -43
  9. package/dist/gate.js +155 -46
  10. package/dist/gates/decompose.js +1 -0
  11. package/dist/gates/design.js +6 -9
  12. package/dist/gates/implement.js +3 -0
  13. package/dist/gates/plan.js +1 -0
  14. package/dist/gates/ship.js +1 -0
  15. package/dist/harness.js +48 -10
  16. package/dist/review.js +74 -0
  17. package/dist/reviewer.js +4 -1
  18. package/dist/rounds.js +7 -2
  19. package/dist/session-clock.js +5 -0
  20. package/dist/toon.js +19 -2
  21. package/dist/usage.js +5 -2
  22. package/dist/verbs/log.js +5 -4
  23. package/dist/verbs/next.js +1 -1
  24. package/dist/verbs/read.js +5 -1
  25. package/dist/verbs/review.js +127 -0
  26. package/dist/worker-stream.js +447 -0
  27. package/package.json +1 -1
  28. package/plugin/.claude-plugin/plugin.json +1 -1
  29. package/plugin/commands/witness.md +4 -2
  30. package/plugin/hooks/session-dashboard.sh +3 -1
  31. package/plugin/skills/witness-brainstorm/SKILL.md +1 -1
  32. package/plugin/skills/witness-decompose/SKILL.md +1 -1
  33. package/plugin/skills/witness-design/SKILL.md +20 -5
  34. package/plugin/skills/witness-implement/SKILL.md +2 -2
  35. package/plugin/skills/witness-plan/SKILL.md +2 -2
  36. package/plugin/skills/witness-ship/SKILL.md +1 -1
  37. package/prompts/arbiter.md +1 -1
  38. package/prompts/design-critic.md +5 -3
  39. package/prompts/drift-reviewer.md +1 -1
  40. package/prompts/plan-critic.md +1 -1
  41. package/prompts/slicing-critic.md +1 -1
package/README.md CHANGED
@@ -255,7 +255,7 @@ an older file keeps working: witness reads it as `migrate` would, changes nothin
255
255
  There is no `provider:` key. `witness gate` spawns the DECLARED harness's headless
256
256
  mode for every reviewer (Decisions 88, 105): claude-code renders bare Anthropic ids, pi
257
257
  renders `provider/model[:thinking]` with the provider witness knows it needs. The pi
258
- reviewer runs hermetic (`--no-extensions --no-skills --no-context-files`); machine
258
+ reviewer runs hermetic (`--no-extensions --no-skills --no-context-files`); claude's runs with `--safe-mode` (no hooks, `CLAUDE.md`, plugins or MCP servers) and saves no session; every reviewer gets no tools, or read-only file tools where it must open files, and witness refuses any verb but read, index, log and diff inside one; machine
259
259
  extensions it must keep — e.g. an OAuth adapter that supplies your Anthropic auth —
260
260
  are declared in machine config, not env:
261
261
 
@@ -280,7 +280,7 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
280
280
  | `draft <key> [--file <json>]` | a grill's or design session's local draft — saved after every settled answer, read back to resume; never committed or journaled |
281
281
  | `write <id> --effort <e> --meta <json> --body <md>` | validated manifest → spec/plan on disk + journal entry; a spec's `covers` and `carries` map it to the recap's goals and decisions |
282
282
  | `diff <spec-id>` | delta since the last realized state (plan pin → empty), and the decisions that moved since that plan |
283
- | `read <id> [--design] [--outline] [--lines <a>-<b>] [--decisions]` | print a spec/plan/design from the primary root — the read route, since a worktree carries no canon copy; `--outline` names each anchor's line range for fat artifacts; `--decisions` prints the decisions a spec carries with its effort's constraints and non-goals, or an effort's whole recap |
283
+ | `read <id> [--design] [--outline] [--lines <a>-<b>] [--decisions]` | print a spec/plan/design from the primary root — the read route, since a worktree carries no canon copy; `--outline` names each anchor's line range for fat artifacts, and for a look its controls and hidden states; `--decisions` prints the decisions a spec carries with its effort's constraints and non-goals, or an effort's whole recap |
284
284
  | `check` | schema, graph, invariants, needs, trailer audit, probes |
285
285
  | `index` | id · summary · status · depends across the canon, then each spec's plans |
286
286
  | `satisfy <id> --need <id\|n\|text>` | journal a manual need as met — the spec is never rewritten |
@@ -291,9 +291,10 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
291
291
  | `gate <decompose\|plan\|implement\|ship\|design> <id>` | run the reviewer gate; journals the round, stamps on pass |
292
292
  | `decide <gate> <id> --approve\|--revise [--pin <policy>]` | record the human decision on a stopped gate; `--pin` adds a standing content policy |
293
293
  | `design <spec-id> --file <html>\|--open\|--reconfirm\|--preview <html>` | register/show a `ui` spec's approved look; `--preview` opens a page and records nothing |
294
+ | `review design <spec-id> [--file <html>]` | the design gate's reviewers on a look — the registered one, or a page not yet registered — asking the gate's full-review question; journals nothing, decides nothing, and replays the gate's answer when the gate already judged the same bytes in full |
294
295
  | `start <plan-id>` | create/re-attach the plan's worktree (`.witness/worktrees/<id>`) — code only: the canon dirs are excluded from it, so a plan cannot go stale in there |
295
296
  | `next` | the one next action across every effort |
296
- | `drive [--flow <plan-id>] [--max-spawns <n>] [--manual] [--detach]` | runs every session itself · under autonomy it needs no terminal and reports when nothing else can move. Up to `drive.parallel` targets at once, one session per target; usage limits are waited out; a target past a cap is parked. `--detach` (autonomy only) runs it in the background into `.witness/drive.log`; `--manual` runs serially and asks you at every stop. One drive per repo. A session drive spawned is refused — agents are what drive spawns, never what spawns drive |
297
+ | `drive [--flow <plan-id>] [--max-spawns <n>] [--manual] [--detach]` | runs every session itself · under autonomy it needs no terminal and reports when nothing else can move. Up to `drive.parallel` targets at once, one session per target; usage limits are waited out; a target past a cap is parked. `--detach` (autonomy only) runs it in the background into `.witness/drive.log` — each session's start, every command and file its agent touches, every act it journals for its flow, a `still running` line after 5 quiet minutes, and how it ended; drive's pi sessions are kept in pi's session store under `witness-drive/`; `--manual` runs serially and asks you at every stop. One drive per repo. A session drive spawned is refused — agents are what drive spawns, never what spawns drive |
297
298
  | `ship <plan-id> [--manual]` | lanes → ship gate → PR → CI watch → under autonomy: merge on green · `--manual` keeps that run's stop and merge for a human |
298
299
  | `test-evidence <plan-id> --phase red\|green [--step <id>]` / `verify-red <plan-id> [--base <ref>] [--step <id>]` | journal red/green criteria evidence from a worktree; `--step` names the plan step the cycle closes — required before the plan's first implement gate (on a plan with a criteria step), left off for a fix round after it. A green that closes a step prints `context:`, `steps:` and `slice:` |
299
300
  | `step-close <plan-id> --step <id>` | close a scaffolding step, which has no red→green to witness; prints `context:`, `steps:` and `slice:` as a closing green does, and closing it again changes nothing |
package/dist/battery.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SESSION_DEFAULT } from './model.js';
2
2
  import { ok, refuse } from './refusal.js';
3
- import { invokeReviewerAsync, parseVerdictText } from './reviewer.js';
3
+ import { invokeReviewerAsync, parseVerdictText, toolsFor } from './reviewer.js';
4
4
  import { parseVerdict, verdictViolations } from './verdict.js';
5
5
  // Row 169, amended by row 212: every lens is asked on the stage's one model, and a lens that
6
6
  // cannot be invoked refuses at once — there is no stand-in to fall back to.
@@ -10,6 +10,7 @@ async function runLens(ctx, harness, model, lens, opts) {
10
10
  for (let attempt = 0;; attempt++) {
11
11
  const r = await invokeReviewerAsync(ctx, harness, {
12
12
  ...opts, prompt, model: model === SESSION_DEFAULT ? undefined : model, lens: lens.name,
13
+ tools: toolsFor(lens.reviewed), // row 217: read-only file tools only for content named by path
13
14
  });
14
15
  if (!r.ok)
15
16
  return refuse(r.violations);
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { configPath } from './config.js';
3
3
  import { journalStamp } from './context.js';
4
+ import { isReviewer } from './drive-presence.js';
4
5
  import { stateFloor } from './floor.js';
5
6
  import { primaryRoot } from './gitio.js';
6
7
  import { withJournalCtx } from './journal.js';
@@ -39,6 +40,8 @@ const VERBS = {
39
40
  gate: () => import('./verbs/gate.js'),
40
41
  decide: () => import('./verbs/decide.js'),
41
42
  design: () => import('./verbs/design.js'),
43
+ // Row 215. The design gate's reviewers on demand: the gate's question, journaled nowhere.
44
+ review: () => import('./verbs/review.js'),
42
45
  start: () => import('./verbs/start.js'),
43
46
  // The orientation screen has a name (D101). Bare `witness` stays as its alias, but
44
47
  // an unnamed command cannot be referenced — commands/witness.md instructs the
@@ -86,6 +89,7 @@ const VERB_USAGE = {
86
89
  recover: 'witness recover [--complete | --rollback]',
87
90
  rename: 'witness rename <old-id> <new-id>',
88
91
  retry: 'witness retry <target>',
92
+ review: 'witness review design <spec-id> [--file <html>]',
89
93
  satisfy: 'witness satisfy <doc-id> --need <id | index | text>',
90
94
  dismiss: 'witness dismiss <artifact> --deferral <id|index> --cause <superseded|lens-retired|judged-wrong> --note "<why>"',
91
95
  ship: 'witness ship <plan-id> [--manual]',
@@ -98,6 +102,8 @@ const VERB_USAGE = {
98
102
  'verify-red': 'witness verify-red <plan-id> [--base <ref>] [--step <id>]',
99
103
  wait: 'witness wait [--since <token>] — blocks until something new needs you · the chat runs it under autonomy',
100
104
  };
105
+ // Row 217. The verbs a reviewer may run: each only reads.
106
+ const REVIEWER_VERBS = new Set(['read', 'index', 'log', 'diff']);
101
107
  // Row 116 moved the body to version.ts, which journal.ts can import without closing a
102
108
  // cycle. Re-exported here because eleven call sites already ask the CLI shell for it and
103
109
  // the question they are asking has not changed.
@@ -145,6 +151,13 @@ export async function main(ctx, argv) {
145
151
  // the human nothing they can act on.
146
152
  const helpRequested = verb === 'help' || verb === '--help'
147
153
  || rest.includes('--help') || rest.includes('-h');
154
+ // Row 217. A reviewer reads; it never acts. Its tools are already gone (the spawn flags); this tripwire
155
+ // refuses what a harness that ignored them could still run. Checked directly: a reviewer spawned inside
156
+ // a drive session carries both markers, and `sessionMarker` names the drive's first.
157
+ if (isReviewer(ctx.env) && !helpRequested && !REVIEWER_VERBS.has(verb ?? '')) {
158
+ renderRefusal([v('witness', 'reviewer-cannot', `${verb ?? '(no verb)'} under WITNESS_REVIEWER`, 'nothing — a reviewer reads and never acts; it may run witness read, index, log or diff')]).forEach((l) => ctx.err(l));
159
+ return EXIT.REFUSED;
160
+ }
148
161
  if (!helpRequested && verb !== 'floor') {
149
162
  const gateRoot = primaryRoot(ctx.cwd);
150
163
  if (gateRoot.ok) {
package/dist/deferral.js CHANGED
@@ -26,8 +26,9 @@ export function openDeferrals(entries) {
26
26
  }
27
27
  return [...open.values()];
28
28
  }
29
- // Injected into every lens, exactly as `pinsBlock` is, and joined to `prompts_sha` so a new
30
- // obligation invalidates the verdict cache and the next round cannot judge without it.
29
+ // Injected into every lens that can read the debt (row 216), beside `pinsBlock`, and joined to
30
+ // `prompts_sha` so a new obligation invalidates the verdict cache and the next round cannot
31
+ // judge without it.
31
32
  // Deliberately the INVERSE of a pin: a pin tells reviewers not to re-litigate, this tells
32
33
  // them to report the thing if it is still there. Pins suppress findings; obligations
33
34
  // solicit them — which is what makes the discharge automatic and evidence-shaped.
@@ -50,8 +51,8 @@ export function deferralsBlock(open) {
50
51
  return '## Open deferrals (approved over findings — report these if they still hold)\n\n' +
51
52
  'This artifact was approved over the findings below rather than fixed. They are NOT settled ' +
52
53
  'policy and they are NOT pins. If a defect is still present, report it as a finding anchored ' +
53
- 'exactly as listed: that keeps its obligation open. Silence is read as fixed: an obligation ' +
54
- 'this round does not report is discharged.\n\n' +
54
+ 'exactly as listed: that keeps its obligation open. The gate reads silence as fixed: an ' +
55
+ 'obligation a gate round does not report is discharged.\n\n' +
55
56
  open.map(line).join('\n') + '\n\n';
56
57
  }
57
58
  // D122 + D166. A debt changes homes when the artifact holding it stops being the one the next