@popovych.co/witness 0.26.0 → 0.26.1

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/dist/arbiter.js CHANGED
@@ -94,8 +94,8 @@ export async function arbitrate(ctx, root, cfg, req) {
94
94
  // and every approve over a failed deterministic check — it may overrule a reviewer, never a
95
95
  // check. `amendment-ack` alone is the exception: approving IS its acknowledgement.
96
96
  // The design gate is the exception that holds whatever the evidence says: the look is the
97
- // human's (§3 G2), so no approve of it is ever offered — at the bound, on a fallback round or
98
- // past a spent ladder the arbiter may revise, reset upstream, repair or park, never stamp.
97
+ // human's (§3 G2), so no approve of it is ever offered — at the bound or past a spent ladder
98
+ // the arbiter may revise, reset upstream, repair or park, never stamp.
99
99
  export function menuFor(block, run) {
100
100
  const failed = run.checks.filter((c) => !c.ok);
101
101
  const approveBarred = run.gate === 'design' || (failed.length > 0 && !failed.every((c) => c.name === 'amendment-ack'));
package/dist/awake.js CHANGED
@@ -44,14 +44,21 @@ export function awakeArgv(env, platform, pid) {
44
44
  const nameOf = (file) => file.split(/[\\/]/).pop() ?? file;
45
45
  // Why a helper that ended before drive let go of it no longer holds the host, or undefined when
46
46
  // its end is no news: a signal (drive's own group stop, the terminal's Ctrl+C), a clean exit
47
- // (caffeinate's `-w` pid ended), or win32's Ctrl+C status.
48
- export function lostWhy(platform, file, code, signal) {
47
+ // (caffeinate's `-w` pid ended), or win32's Ctrl+C status. The cause is named: exit 3 is
48
+ // AWAKE_SCRIPT's own, and otherwise `said` — the helper's first stderr line, which in Windows
49
+ // PowerShell 5.1's error view is the message of the error that stopped it, ahead of its
50
+ // `At line`, `~~~`, `+ CategoryInfo` and `+ FullyQualifiedErrorId` lines.
51
+ export function lostWhy(platform, file, code, signal, said = '') {
49
52
  if (signal !== null || code === null || code === 0)
50
53
  return undefined;
51
54
  if (platform === 'win32' && code === CTRL_C_EXIT)
52
55
  return undefined;
53
- return `${nameOf(file)} exited ${code}`;
56
+ if (platform === 'win32' && code === 3)
57
+ return `${nameOf(file)} exited 3 — SetThreadExecutionState refused the request`;
58
+ return said ? `${nameOf(file)} exited ${code}: ${said}` : `${nameOf(file)} exited ${code}`;
54
59
  }
60
+ // The first non-empty line a helper wrote to stderr, capped: one row's worth for the warning.
61
+ const firstLine = (text) => text.trim().split(/\r?\n/)[0]?.trim().slice(0, 200) ?? '';
55
62
  export function keepAwake(env, platform, pid, onLost = () => { }) {
56
63
  const a = awakeArgv(env, platform, pid);
57
64
  if (a === undefined)
@@ -63,10 +70,15 @@ export function keepAwake(env, platform, pid, onLost = () => { }) {
63
70
  done = true;
64
71
  onLost(why);
65
72
  };
66
- const child = spawn(a.file, a.args, { stdio: 'ignore', ...(a.env ? { env: { ...env, ...a.env } } : {}) });
67
- // A helper that cannot hold the host costs the guard, never the run — but it says so.
73
+ const child = spawn(a.file, a.args, { stdio: ['ignore', 'ignore', 'pipe'], ...(a.env ? { env: { ...env, ...a.env } } : {}) });
74
+ // A helper that cannot hold the host costs the guard, never the run — but it says so, and why.
75
+ let said = '';
76
+ child.stderr?.setEncoding('utf8').on('data', (d) => { if (said.length < 4096)
77
+ said += d; });
78
+ child.stderr?.unref?.(); // the pipe never holds drive open
68
79
  child.on('error', (e) => lost(`${nameOf(a.file)} failed to start (${e.code ?? e.message})`));
69
- child.on('exit', (code, signal) => lost(lostWhy(platform, a.file, code, signal)));
80
+ // 'close', not 'exit': the helper's stderr has been read in full only once its pipe closed.
81
+ child.on('close', (code, signal) => lost(lostWhy(platform, a.file, code, signal, firstLine(said))));
70
82
  child.unref();
71
83
  return {
72
84
  shown: a.shown,
package/dist/opener.js CHANGED
@@ -1,19 +1,26 @@
1
- import { spawnSync, spawn } from './spawn.js';
2
- // Platform default openers. `start` is a cmd builtin, hence the shell wrapper.
3
- function platformOpener() {
4
- if (process.platform === 'darwin')
1
+ import { existsSync } from 'node:fs';
2
+ import { win32 } from 'node:path';
3
+ import { spawnSync, spawn, system32 } from './spawn.js';
4
+ // Platform default openers. `start` is a cmd builtin, hence the shell wrapper — System32's
5
+ // cmd.exe by absolute path (row 201), never a bare name another cmd.exe on PATH answers to.
6
+ export function platformOpener(platform = process.platform, env = process.env) {
7
+ if (platform === 'darwin')
5
8
  return ['open'];
6
- if (process.platform === 'win32')
7
- return ['cmd', '/c', 'start', ''];
9
+ if (platform === 'win32')
10
+ return [system32(env, 'cmd.exe'), '/c', 'start', ''];
8
11
  return ['xdg-open'];
9
12
  }
10
- // win32 has no `sh`, so a POSIX probe there would report every opener missing and
11
- // make approve permanently unreachable. `where` is the cmd equivalent.
13
+ // win32 has no `sh`, so a POSIX probe there would report every opener missing and make approve
14
+ // permanently unreachable. System32's `where` is the cmd equivalent, but it matches name
15
+ // patterns, never paths, so an absolute opener there is probed by existence.
16
+ export function probeArgv(cmd, platform = process.platform, env = process.env) {
17
+ if (platform !== 'win32')
18
+ return { file: 'sh', args: ['-c', `command -v ${cmd}`] };
19
+ return win32.isAbsolute(cmd) ? { exists: cmd } : { file: system32(env, 'where.exe'), args: [cmd] };
20
+ }
12
21
  export function resolves(cmd) {
13
- const probe = process.platform === 'win32'
14
- ? spawnSync('where', [cmd], { encoding: 'utf8' })
15
- : spawnSync('sh', ['-c', `command -v ${cmd}`], { encoding: 'utf8' });
16
- return probe.status === 0;
22
+ const probe = probeArgv(cmd);
23
+ return 'exists' in probe ? existsSync(probe.exists) : spawnSync(probe.file, probe.args, { encoding: 'utf8' }).status === 0;
17
24
  }
18
25
  // Show a file to the human. Returns the resolved command alongside the outcome so the
19
26
  // caller can journal WHAT was run — a degenerate opener (`opener: /usr/bin/true` in
package/dist/recommend.js CHANGED
@@ -1,4 +1,4 @@
1
- import { anchorRecurrence, boundReached, ladderSpent, lastGateRun, notePrefill, pendingDecision, repairGranted, roundBudget, roundsSinceApprove, } from './rounds.js';
1
+ import { anchorRecurrence, boundReached, ladderSpent, lastGateRun, notePrefill, pendingDecision, repairsOnRegate, repairGranted, roundBudget, roundsSinceApprove, } from './rounds.js';
2
2
  // Commands are emitted raw (D120): `esc` would quote the `--note "…"` argument and the
3
3
  // line would paste into a shell as an empty note.
4
4
  export function renderDecision(d) {
@@ -129,7 +129,11 @@ function recommendCore(ctx) {
129
129
  key: 'next', rule: 'malformed-rerun',
130
130
  options: [
131
131
  opt(`witness gate ${gate} ${target}`, 'root', {
132
- why: `the battery emitted ${last.malformed?.length ?? 0} schema violation(s) and no verdict — this round judged nothing, and malformed rounds do not spend the budget, so re-running is free${last.malformed?.length ? `, and it re-asks only ${last.malformed.map((m) => m.reviewer).join(' · ')}` : ''}`,
132
+ why: `the battery emitted ${last.malformed?.length ?? 0} schema violation(s) and no verdict — this round judged nothing, and malformed rounds do not spend the budget, so re-running is free${
133
+ // A promise of what appendKind does (row 209): moved content is a fresh round, every
134
+ // lens asked; a revise since makes it changed-nothing; a fallen-back round re-runs.
135
+ last.malformed?.length && !stale && repairsOnRegate(entries, gate)
136
+ ? `, and on unchanged content and setup it re-asks only ${last.malformed.map((m) => m.reviewer).join(' · ')}` : ''}`,
133
137
  note: 'a second malformed round on the same pin and prompts trips malformed-streak, which names the config remedy',
134
138
  }),
135
139
  ],
package/dist/reviewer.js CHANGED
@@ -200,7 +200,7 @@ export async function invokeReviewerAsync(ctx, harness, opts) {
200
200
  const limit = usageLimitOf(c, clock.now());
201
201
  if (!limit)
202
202
  return c;
203
- // A wait spends no timeout retry: the same rung is asked again after the reset.
203
+ // A wait spends no timeout retry: the same model is asked again after the reset.
204
204
  const wait = waitFor(limit, streak, clock.now());
205
205
  // Inside a drive session the wait must also end before drive kills the session (F14).
206
206
  const deadline = Number(ctx.env[DRIVE_DEADLINE_ENV]);
package/dist/rounds.js CHANGED
@@ -254,6 +254,19 @@ export function openReopen(entries, gate) {
254
254
  }
255
255
  return undefined;
256
256
  }
257
+ const revisedAfter = (entries, runIdx, gate) => entries.slice(runIdx + 1).some((e) => isDecision(e, gate) && ['revise', 'revise-upstream'].includes(e.decision));
258
+ // Row 209: does a re-gate on unchanged content and setup repair the last run — re-ask only its
259
+ // lenses with no verdict — rather than re-run, resume or refuse? appendKind's own rule, minus the
260
+ // key only the gate can build, so the recommender's promise of a repair reads the same rule.
261
+ export function repairsOnRegate(entries, gate) {
262
+ for (let i = entries.length - 1; i >= 0; i--) {
263
+ if (!isRun(entries[i], gate))
264
+ continue;
265
+ const last = entries[i];
266
+ return last.outcome === 'malformed' && !fellBack(last) && !revisedAfter(entries, i, gate);
267
+ }
268
+ return false;
269
+ }
257
270
  export function appendKind(entries, gate, key) {
258
271
  let lastRunIdx = -1;
259
272
  for (let i = entries.length - 1; i >= 0; i--) {
@@ -276,9 +289,7 @@ export function appendKind(entries, gate, key) {
276
289
  // re-ran nothing while its own block said re-running is free. A re-gate repairs it instead —
277
290
  // the lenses that answered are carried and the ones that did not are asked again.
278
291
  if (!fellBack(last) && sameKey(keyOf(last), key)) {
279
- const revised = entries.slice(lastRunIdx + 1).some((e) => isDecision(e, gate) &&
280
- ['revise', 'revise-upstream'].includes(e.decision));
281
- if (revised)
292
+ if (revisedAfter(entries, lastRunIdx, gate))
282
293
  return { kind: 'changed-nothing', entry: last };
283
294
  return last.outcome === 'malformed' ? { kind: 'repair', from: last } : { kind: 'resume', entry: last };
284
295
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popovych.co/witness",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
4
4
  "description": "Evidence-gated spec-driven development pipeline for AI coding agents: brainstorm to PR in six stages, where specs are state, plans are motion, and no transition passes without evidence. Drives from Claude Code or Pi.",
5
5
  "keywords": [
6
6
  "spec-driven-development",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "packageManager": "pnpm@10.22.0",
43
43
  "bin": {
44
- "witness": "./dist/bin.js"
44
+ "witness": "dist/bin.js"
45
45
  },
46
46
  "files": [
47
47
  "dist",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "witness",
3
3
  "description": "Spec-driven development with evidence gates: brainstorm → PR through six stages and five gates. Skills author, the pinned witness CLI writes state and witnesses evidence; gates stop where judgment is owed.",
4
- "version": "0.26.0",
4
+ "version": "0.26.1",
5
5
  "author": {
6
6
  "name": "Kostiantyn Popovych"
7
7
  },
@@ -12,7 +12,7 @@ Any other words in `$ARGUMENTS` are the human's ask: run `$WITNESS ask "<those w
12
12
  Resolve the CLI once:
13
13
 
14
14
  ```bash
15
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.0}"
15
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.1}"
16
16
  ```
17
17
 
18
18
  If the repo has no `witness.config.yaml`, run `$WITNESS init` first (one bootstrap commit), then proceed. If init or any verb refuses on a dirty tree, the human commits or cleans it — **never `git commit` yourself, anywhere, at any stage**: the CLI makes its own state commits, and the ship phase makes the sole code commit.
@@ -3,4 +3,4 @@
3
3
  # context). Silent everywhere that isn't a witness repo; failures swallowed:
4
4
  # session start must never hang or die on this.
5
5
  [ -f witness.config.yaml ] || exit 0
6
- ${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.0} 2>/dev/null || true
6
+ ${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.1} 2>/dev/null || true
@@ -16,7 +16,7 @@ recap, keeps a local draft, writes no document. See NOTICE.md. -->
16
16
  Resolve the CLI once per session:
17
17
 
18
18
  ```bash
19
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.0}"
19
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.1}"
20
20
  ```
21
21
 
22
22
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -10,7 +10,7 @@ description: Slice a witness effort's confirmed recap into vertical spec slices,
10
10
  Resolve the CLI once per session:
11
11
 
12
12
  ```bash
13
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.0}"
13
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.1}"
14
14
  ```
15
15
 
16
16
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -16,7 +16,7 @@ No text copied verbatim; the design-critic lens is new material. -->
16
16
  Resolve the CLI once per session:
17
17
 
18
18
  ```bash
19
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.0}"
19
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.1}"
20
20
  ```
21
21
 
22
22
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -15,7 +15,7 @@ tests carry the parent spec's tag in their NAME. See NOTICE.md. -->
15
15
  Resolve the CLI once per session:
16
16
 
17
17
  ```bash
18
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.0}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.1}"
19
19
  ```
20
20
 
21
21
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -15,7 +15,7 @@ parent's criteria. See NOTICE.md. -->
15
15
  Resolve the CLI once per session:
16
16
 
17
17
  ```bash
18
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.0}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.1}"
19
19
  ```
20
20
 
21
21
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -15,7 +15,7 @@ model can. See NOTICE.md. -->
15
15
  Resolve the CLI once per session:
16
16
 
17
17
  ```bash
18
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.0}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.26.1}"
19
19
  ```
20
20
 
21
21
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.