@popovych.co/witness 0.24.0 → 0.24.2

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/awake.js CHANGED
@@ -1,4 +1,4 @@
1
- import { spawn } from 'node:child_process';
1
+ import { spawn } from './spawn.js';
2
2
  export function keepAwake(env, platform, pid) {
3
3
  // Test seam, on WITNESS_DRIVE_AGENT_BIN's precedent: never documented.
4
4
  const bin = env.WITNESS_KEEP_AWAKE_BIN ?? (platform === 'darwin' ? 'caffeinate' : undefined);
package/dist/calibrate.js CHANGED
@@ -1,4 +1,3 @@
1
- import { spawnSync } from 'node:child_process';
2
1
  import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
3
2
  import { tmpdir } from 'node:os';
4
3
  import { dirname, join } from 'node:path';
@@ -14,7 +13,7 @@ import { defaultValues, withValues } from './settings.js';
14
13
  import { ok, refuse, renderRefusal, v } from './refusal.js';
15
14
  import { PROMPT_NAMES, invokeReviewer, parseVerdictText, resolvePrompt } from './reviewer.js';
16
15
  import { findById, loadCanon } from './scan.js';
17
- import { resolveSpawn } from './spawn.js';
16
+ import { resolveSpawn, spawnSync } from './spawn.js';
18
17
  import { anchorMenu, parseVerdict, verdictViolations } from './verdict.js';
19
18
  import { createWorktree } from './worktree.js';
20
19
  import { deltaBlock, deltaView, demote, reportedBy } from './delta.js';
package/dist/cli.js CHANGED
@@ -5,6 +5,7 @@ import { stateFloor } from './floor.js';
5
5
  import { primaryRoot } from './gitio.js';
6
6
  import { withJournalCtx } from './journal.js';
7
7
  import { renderRefusal, v } from './refusal.js';
8
+ import { NO_CONSOLE_ENV, withoutConsole } from './spawn.js';
8
9
  import { NPX_LATEST, compareTriple, version } from './version.js';
9
10
  export const EXIT = { OK: 0, FINDINGS: 1, REFUSED: 2, BLOCKED: 3 };
10
11
  const VERBS = {
@@ -106,6 +107,14 @@ export function usage() {
106
107
  ].join('\n');
107
108
  }
108
109
  export async function main(ctx, argv) {
110
+ // Row 201. The background drive has no console, so everything this invocation starts —
111
+ // the floor gate's git calls below included — starts hidden. The marker describes this
112
+ // process alone: a session it starts has a console, the hidden one its spawn gave it.
113
+ // It leaves process.env too, which every child started without an env of its own inherits.
114
+ if (ctx.env[NO_CONSOLE_ENV] !== undefined) {
115
+ delete process.env[NO_CONSOLE_ENV];
116
+ return withoutConsole(() => main({ ...ctx, env: { ...ctx.env, [NO_CONSOLE_ENV]: undefined } }, argv));
117
+ }
109
118
  const [verb, ...rest] = argv;
110
119
  if (verb === '--version' || verb === '-v') {
111
120
  ctx.out(version());
@@ -1,5 +1,5 @@
1
1
  import { Lexer, isCollection, isMap, isScalar, parseDocument } from 'yaml';
2
- import { LEGACY_COMMENTS } from './legacy-comments.js';
2
+ import { RELEASED_COMMENTS } from './released-comments.js';
3
3
  import { CHANGE_CLASSES, FIRST_LINE, GROUP_HEADINGS, SCHEMA_COMMENT, SETTINGS, getIn, inlineValue, } from './settings.js';
4
4
  import { sectionsOf } from './migration.js';
5
5
  const EMPTY = { top: [], above: new Map(), end: [] };
@@ -73,6 +73,9 @@ const CURRENT_COMMENTS = new Set([
73
73
  FIRST_LINE.slice(1).trim(),
74
74
  ...Object.values(GROUP_HEADINGS).map((h) => h.slice(1).trim()),
75
75
  ]);
76
+ // What a released witness wrote and this one no longer does: derived from the one record, so a
77
+ // reworded comment's old text can never be left out of it.
78
+ const LEGACY_COMMENTS = new Set([...RELEASED_COMMENTS].filter((t) => !CURRENT_COMMENTS.has(t)));
76
79
  // Where a human line can be printed: every setting and section, and a per-class reviewer line.
77
80
  const PRINTABLE = new Set([
78
81
  ...SETTINGS.map((s) => s.path),
@@ -150,7 +153,7 @@ export function readComments(text) {
150
153
  const comment = token.trimEnd();
151
154
  const body = comment.slice(1).trim();
152
155
  const ownLine = src.slice(lineStarts[line], at).trim() === '';
153
- if (LEGACY_COMMENTS.has(body) || CURRENT_COMMENTS.has(body)) {
156
+ if (RELEASED_COMMENTS.has(body) || CURRENT_COMMENTS.has(body)) {
154
157
  // A line of its own vanishes; one on a setting's line, or the first line, is replaced.
155
158
  if (ownLine && line !== 0 && LEGACY_COMMENTS.has(body))
156
159
  legacy++;
package/dist/config.js CHANGED
@@ -1,4 +1,3 @@
1
- import { execFileSync } from 'node:child_process';
2
1
  import { existsSync, readFileSync } from 'node:fs';
3
2
  import { isAbsolute, join } from 'node:path';
4
3
  import { parse as parseYaml } from 'yaml';
@@ -7,6 +6,7 @@ import { migrateValues, newestSchema, olderSchemaWarning, sectionsOf, withoutEmp
7
6
  import { checkPin } from './pin.js';
8
7
  import { ok, refuse, v } from './refusal.js';
9
8
  import { CHANGE_CLASSES, GATE_NAMES, RETIRED, SETTINGS, defaultAt, getIn, knownAt, settingAt, } from './settings.js';
9
+ import { execFileSync } from './spawn.js';
10
10
  // Row 193 §4.2: every setting present, nothing unknown. Always the list's newest schema.
11
11
  export const SCHEMA_VERSION = 2;
12
12
  // Every DEFAULT_* below is the list's (settings.ts), read at schema 1, where each was born.
@@ -97,8 +97,10 @@ export function acquireDriveLock(root, info, pid = process.pid) {
97
97
  }
98
98
  // A path is quoted only when it needs it, so the common line stays the one a human types.
99
99
  const shellArg = (p) => /^[\w@%+=:,./-]+$/.test(p) ? p : `'${p.replaceAll("'", "'\\''")}'`;
100
- export function watchLine(h) {
100
+ // Row 201: `kill` is not a Windows command, and PowerShell's alias ends drive alone.
101
+ export function watchLine(h, platform = process.platform) {
102
+ const stop = platform === 'win32' ? `taskkill /PID ${h.pid} /T /F` : `kill ${h.pid}`;
101
103
  return h.log !== undefined
102
- ? `tail -f ${shellArg(h.log)} · stop it: kill ${h.pid}`
104
+ ? `tail -f ${shellArg(h.log)} · stop it: ${stop}`
103
105
  : `the terminal running witness drive · pid ${h.pid}`;
104
106
  }
package/dist/drive.js CHANGED
@@ -1,4 +1,3 @@
1
- import { spawn } from 'node:child_process';
2
1
  import { closeSync, constants, fstatSync, mkdirSync, openSync, writeSync } from 'node:fs';
3
2
  import { dirname, join } from 'node:path';
4
3
  import { fileURLToPath } from 'node:url';
@@ -8,7 +7,7 @@ import { withoutSession } from './context.js';
8
7
  import { detectionVariables, resolveJudge } from './harness.js';
9
8
  import { ok, refuse, renderRefusal, v } from './refusal.js';
10
9
  import { findById, loadCanon } from './scan.js';
11
- import { resolveSpawn } from './spawn.js';
10
+ import { NO_CONSOLE_ENV, resolveSpawn, spawn, treeStop } from './spawn.js';
12
11
  import { computeNext, conversationStage } from './verbs/next.js';
13
12
  import { DRIVE_DEADLINE_ENV, DRIVE_ENV, DRIVE_LOG, DRIVE_LOG_ENV, TARGETLESS } from './drive-presence.js';
14
13
  import { ASK_STREAM } from './ask.js';
@@ -115,6 +114,23 @@ function lineSink(prefix, emit) {
115
114
  },
116
115
  };
117
116
  }
117
+ // How drive stops a session it started: its process group (F11), or on Windows, which has no
118
+ // groups to signal, its process tree (row 201).
119
+ export function signalSession(child, grouped, env, sig) {
120
+ try {
121
+ if (grouped && child.pid !== undefined)
122
+ process.kill(-child.pid, sig);
123
+ else if (child.pid === undefined)
124
+ child.kill(sig);
125
+ else if (child.exitCode === null && child.signalCode === null) {
126
+ // Only while it runs: Node closes the handle before it reports the exit, and from then on
127
+ // the pid may name another process, which a tree kill would take down with its own.
128
+ const stop = treeStop(child.pid, env);
129
+ spawn(stop.file, stop.args, { stdio: 'ignore' }).on('error', () => { });
130
+ }
131
+ }
132
+ catch { /* already gone */ }
133
+ }
118
134
  // One headless session, in the action's home, streamed to the driver's terminal.
119
135
  //
120
136
  // The harness is the JUDGE ladder's answer (declared first, detection as fallback), not
@@ -176,7 +192,8 @@ export async function spawnSession(step, cfg, ctx, spawnN, opts = {}) {
176
192
  return await new Promise((resolve) => {
177
193
  // Final review F11: its own process group, so a stop reaches the tools, shells and gates
178
194
  // the session started, not just the agent — an orphan would keep writing state after
179
- // drive moved on. Windows has no groups to signal; the agent alone is stopped there.
195
+ // drive moved on. Windows has no groups to signal: there the stop is a tree kill from the
196
+ // shim down, because libuv's job object lets the agent under the shim break away (row 201).
180
197
  const grouped = process.platform !== 'win32';
181
198
  const child = spawn(run.value.file, run.value.args, {
182
199
  cwd: step.home,
@@ -185,15 +202,7 @@ export async function spawnSession(step, cfg, ctx, spawnN, opts = {}) {
185
202
  windowsVerbatimArguments: run.value.windowsVerbatimArguments,
186
203
  detached: grouped,
187
204
  });
188
- const signal = (sig) => {
189
- try {
190
- if (grouped && child.pid !== undefined)
191
- process.kill(-child.pid, sig);
192
- else
193
- child.kill(sig);
194
- }
195
- catch { /* already gone */ }
196
- };
205
+ const signal = (sig) => signalSession(child, grouped, run.value.env, sig);
197
206
  if (grouped && child.pid !== undefined)
198
207
  LIVE_GROUPS.add(child.pid);
199
208
  let outcome = 'exited';
@@ -734,7 +743,7 @@ export function detachDrive(root, ctx, args) {
734
743
  try {
735
744
  const child = spawn(file, argv, {
736
745
  cwd: root, detached: true, stdio: ['ignore', fd, fd],
737
- env: { ...ctx.env, [DRIVE_LOG_ENV]: log },
746
+ env: { ...ctx.env, [DRIVE_LOG_ENV]: log, [NO_CONSOLE_ENV]: '1' },
738
747
  });
739
748
  if (child.pid === undefined)
740
749
  return refuse([v('--detach', 'spawn-failed', file, 'a runnable witness CLI')]);
package/dist/gitio.js CHANGED
@@ -1,7 +1,7 @@
1
- import { execFileSync } from 'node:child_process';
2
1
  import { dirname } from 'node:path';
3
2
  import { canonPaths } from './config.js';
4
3
  import { ok, refuse, v } from './refusal.js';
4
+ import { execFileSync } from './spawn.js';
5
5
  // D158 (#20). A reviewer-bound diff is legitimately multi-megabyte and Node's spawnSync
6
6
  // default is 1 MiB, which crashed ship/gate as `spawnSync git ENOBUFS` — and, worse,
7
7
  // silently truncated every tryGit consumer into a wrong answer. Sized like reviewer.ts's
package/dist/install.js CHANGED
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
  import { version } from './cli.js';
5
5
  import { tryGit } from './gitio.js';
6
6
  import { ok, refuse, v } from './refusal.js';
7
+ import { SETTINGS } from './settings.js';
7
8
  import { NPX_LATEST, compareTriple, pinIn } from './version.js';
8
9
  // dist/install.js and src/install.ts both sit one level under the package root, so the
9
10
  // same '..' works built and under vitest — the pattern model.ts:14 already uses. This is
@@ -258,7 +259,8 @@ export function recordHarness(configText, name) {
258
259
  return { text: configText, changed: false, declared: found[1] };
259
260
  const suffix = configText.endsWith('\n') ? '' : '\n';
260
261
  return {
261
- text: `${configText}${suffix}harness: ${name} # the judge — which harness runs this repo's gate reviewers; declared wins\n`,
262
+ // The setting's own comment, as a fresh init writes it: one source of witness's comment text.
263
+ text: `${configText}${suffix}harness: ${name} # ${SETTINGS.find((s) => s.path === 'harness').comment}\n`,
262
264
  changed: true,
263
265
  };
264
266
  }
package/dist/needs.js CHANGED
@@ -1,5 +1,5 @@
1
- import { execSync } from 'node:child_process';
2
1
  import { ensureTrusted } from './allowlist.js';
2
+ import { execSync } from './spawn.js';
3
3
  // Row 179. What a journaled satisfaction names a need by: its id, else its manual text.
4
4
  export function needKey(n) {
5
5
  return n.id ?? n.manual;
package/dist/notify.js CHANGED
@@ -1,5 +1,5 @@
1
- import { spawnSync } from 'node:child_process';
2
1
  import { resolves } from './opener.js';
2
+ import { spawnSync } from './spawn.js';
3
3
  // Row 184. The desktop notification an autonomous run ends with (design B6). A machine-local
4
4
  // `notify:` command receives the run summary as its one argument; otherwise the platform
5
5
  // notifier, and none on Windows.
package/dist/opener.js CHANGED
@@ -1,4 +1,4 @@
1
- import { spawnSync, spawn } from 'node:child_process';
1
+ import { spawnSync, spawn } from './spawn.js';
2
2
  // Platform default openers. `start` is a cmd builtin, hence the shell wrapper.
3
3
  function platformOpener() {
4
4
  if (process.platform === 'darwin')
@@ -29,7 +29,8 @@ export function openArtifact(opener, absPath) {
29
29
  if (!resolves(cmd))
30
30
  return { outcome: 'failed', command: cmd };
31
31
  try {
32
- const child = spawn(cmd, [...pre, absPath], { detached: true, stdio: 'ignore' });
32
+ // The one window witness means to show: never hidden, even from a background drive (row 201).
33
+ const child = spawn(cmd, [...pre, absPath], { detached: true, stdio: 'ignore', windowsHide: false });
33
34
  child.unref();
34
35
  return { outcome: 'spawned', command: cmd };
35
36
  }
package/dist/probe.js CHANGED
@@ -1,5 +1,4 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { resolveSpawn } from './spawn.js';
1
+ import { resolveSpawn, spawnSync } from './spawn.js';
3
2
  // Revision 3. The old form passed no `env`, so it silently answered about process.env
4
3
  // while reviewer.ts:133 spawns `claude` with `env: ctx.env` — two different questions,
5
4
  // one answer. It also made the finding untestable: helpers.ts runs main() in-process,
@@ -0,0 +1,79 @@
1
+ // Row 193 §4.5. Every comment text a released witness wrote into witness.config.yaml — the one
2
+ // record of which comments are witness's. A comment line whose trimmed text is one of these is
3
+ // witness's wherever it sits: `migrate` writes the current text on a setting's line and drops an
4
+ // old one on a line of its own, since what it described now exists for real. An edited copy no
5
+ // longer matches, so it is the human's. Append-only: rewording a comment in `src/settings.ts`
6
+ // adds its new text here and leaves the old one, which is what keeps every file an older witness
7
+ // wrote readable (tests/config-file.test.ts fails on a written text missing from the record).
8
+ // What this witness no longer writes is derived (config-file.ts), never a second list to keep.
9
+ export const RELEASED_COMMENTS = new Set([
10
+ // ── Before 0.21.0: each version of `init`'s template (git log -p --follow -- src/verbs/init.ts,
11
+ // the specflow era included; a continuation line is its own entry) and both of
12
+ // `recordHarness`'s texts (src/install.ts).
13
+ 'any gate block may pin its own model (wins over the global pin), e.g.',
14
+ 'conventions: [docs/code/architecture.md] # → injected into code-reviewer at implement + ship (cache-keyed)',
15
+ 'declared beats the ambient session (init --agent writes it once)',
16
+ 'decompose: { reviewers: [slicing-critic], model: claude-opus-4-8 }',
17
+ 'docs: # repo docs registry — enumerated keys, unknown keys refused',
18
+ "harness: pi # the judge — which harness runs this repo's gate reviewers;",
19
+ 'or: runner: full-suite + report: junit:**/reports/junit.xml',
20
+ 'paths: { specs: docs/specs, plans: docs/plans } # optional canon roots (defaults: specs, plans); git mv existing docs when changing',
21
+ 'per change class; a plain list = all classes',
22
+ 'reviewer model pin — exact id, aliases refused',
23
+ 'reviewerTimeoutMs: 600000 # ms per reviewer invocation (machine auth/extension knobs live in .witness/config.local.yaml)',
24
+ 'specflow.config.yaml — the whole surface',
25
+ 'witness.config.yaml — the whole surface',
26
+ "the judge — which harness runs this repo's gate reviewers; declared wins",
27
+ 'detection wins; this is the fallback',
28
+ // The end-of-line comments of the template's commented-out settings, which the template meant
29
+ // the human to uncomment (final review I3).
30
+ 'optional canon roots (defaults: specs, plans); git mv existing docs when changing',
31
+ 'repo docs registry — enumerated keys, unknown keys refused',
32
+ '→ injected into code-reviewer at implement + ship (cache-keyed)',
33
+ "the judge — which harness runs this repo's gate reviewers;",
34
+ 'ms per reviewer invocation (machine auth/extension knobs live in .witness/config.local.yaml)',
35
+ // ── Since 0.21.0 the template is `src/settings.ts`: every setting's comment, the per-class
36
+ // `for a …` lines, the schema line, the first line and the group headings, in every release.
37
+ // Collected from the published tarballs 0.21.0, 0.21.1, 0.22.0, 0.23.0 and 0.24.0.
38
+ "% of the context window at which a session hands over to a fresh one · 1–100",
39
+ "code docs handed to code-reviewer at implement and ship · file list, [] = none",
40
+ "design docs handed to design-critic and design-reviewer · file list, [] = none",
41
+ "extra globs never scanned for criteria tags · [] = none",
42
+ "folder for approved designs, repo-relative · git mv the docs when you change it",
43
+ "folder for plans, repo-relative · git mv the docs when you change it",
44
+ "folder for specs, repo-relative · git mv the docs when you change it",
45
+ "for a chore",
46
+ "for a feature",
47
+ "for a fix",
48
+ "format version · witness migrate raises it; never edit by hand",
49
+ "gate rounds one target may run across budget resets, then it is parked · ≥ 1",
50
+ "how a spec's criteria run · a command with {id}, or full-suite",
51
+ "how ship merges its own PR under autonomy · merge | squash | rebase",
52
+ "let test runs in two worktrees overlap · true | false",
53
+ "model for the arbiter that settles stops and checks recaps under autonomy · exact id, no aliases",
54
+ "model for the arbiter that settles stops under autonomy · exact id, no aliases",
55
+ "model for this gate's reviewers AND for the agent that writes the code",
56
+ "model for this gate's reviewers · exact id, [provider/]id[:thinking], no aliases",
57
+ "model for this gate's reviewers · exact id, no aliases",
58
+ "model for this gate's reviewers · runs only on specs marked ui",
59
+ "ms green CI must hold still before an autonomous merge · 0–1800000",
60
+ "ms of session time one target may take in one run (16 h), then it is parked · ≥ 1",
61
+ "ms one reviewer, or the arbiter, may run before it is stopped (10 min) · ≥ 1",
62
+ "ms one spawned session may run before it is stopped (1 h) · ≥ 1",
63
+ "on = the CLI settles its own stops and merges green PRs · on | off · counts once committed",
64
+ "reviewers this gate runs · one list, or one list per class",
65
+ "reviewers this gate runs · one list, or one list per class (feature, fix, chore)",
66
+ "sessions drive runs at once, one per target · ≥ 1",
67
+ "sessions one target may take in one run, then it is parked · ≥ 1",
68
+ "steps an implement session takes when its context fill can't be read · ≥ 1",
69
+ "the branch witness ships into",
70
+ "the judge: the agent CLI that runs this repo's gate reviewers and arbiter · claude-code | pi",
71
+ "the junit report witness reads · junit:<glob>, or none · full-suite needs one",
72
+ "the lint command ship runs",
73
+ "the suite command ship runs · full-suite criteria run it too",
74
+ "upstream resets one target may take, then it is parked · ≥ 1",
75
+ "witness.config.yaml — every setting witness reads. Change a value in place; `witness migrate` keeps the file current.",
76
+ "── Behavior: how witness works here ─────────────────────────────────────────",
77
+ "── Setup: what this repo is ─────────────────────────────────────────────────",
78
+ "── Tuning: witness drive ────────────────────────────────────────────────────",
79
+ ]);
package/dist/reviewer.js CHANGED
@@ -1,11 +1,10 @@
1
- import { spawn, spawnSync } from 'node:child_process';
2
1
  import { createHash } from 'node:crypto';
3
2
  import { existsSync, readFileSync } from 'node:fs';
4
3
  import { dirname, join } from 'node:path';
5
4
  import { fileURLToPath } from 'node:url';
6
5
  import { validatePin } from './harness.js';
7
6
  import { ok, refuse, v } from './refusal.js';
8
- import { resolveSpawn } from './spawn.js';
7
+ import { resolveSpawn, spawn, spawnSync } from './spawn.js';
9
8
  import { DRIVE_DEADLINE_ENV, driveChild } from './drive-presence.js';
10
9
  import { duration, limitIn, realClock, SINGLE_WAIT_MAX_MS, waitFor } from './usage.js';
11
10
  export const PROMPT_NAMES = [
package/dist/runner.js CHANGED
@@ -1,10 +1,10 @@
1
- import { execSync } from 'node:child_process';
2
1
  import { rmSync } from 'node:fs';
3
2
  import { join } from 'node:path';
4
3
  import { ensureTrusted } from './allowlist.js';
5
4
  import { mergeReports, reportFiles } from './junit.js';
6
5
  import { ok, refuse, v } from './refusal.js';
7
6
  import { withRunnerTurn } from './runner-lock.js';
7
+ import { execSync } from './spawn.js';
8
8
  // The values' own shapes (a runner with {id}, a junit: report) are refused when the file loads
9
9
  // (row 193); what is left is what only a combination says, and what an older file never set.
10
10
  export function runnerConfig(cfg) {
package/dist/ship.js CHANGED
@@ -1,4 +1,3 @@
1
- import { execFileSync } from 'node:child_process';
2
1
  import { EXIT } from './cli.js';
3
2
  import { autonomyAt, loadConfig } from './config.js';
4
3
  import { acquireLock } from './lock.js';
@@ -19,6 +18,7 @@ import { authoringOwed, gateSettled } from './verbs/next.js';
19
18
  import { diffReviewedSha } from './reviewed.js';
20
19
  import { diffBase } from './evidence.js';
21
20
  import { handOverIfDue } from './slice.js';
21
+ import { execFileSync } from './spawn.js';
22
22
  // Static, unlike gate.ts and next.ts: this module lies outside gate.ts's static import graph,
23
23
  // so reaching decide.ts from here closes no registration cycle.
24
24
  import { settleStop, settledCode } from './settle.js';
package/dist/snapshot.js CHANGED
@@ -1,8 +1,8 @@
1
- import { execFileSync } from 'node:child_process';
2
1
  import { existsSync, lstatSync, mkdtempSync, readlinkSync, rmSync } from 'node:fs';
3
2
  import { tmpdir } from 'node:os';
4
3
  import { join } from 'node:path';
5
4
  import { gitBlob, tryGit } from './gitio.js';
5
+ import { execFileSync } from './spawn.js';
6
6
  // Row 186. What a gate's battery read, kept as a git tree so a later round can diff against
7
7
  // it. Nothing reviewed is in the object database today: `blobOf` hashes without `-w` and
8
8
  // `reviewed_sha` is a sha256 over (path, blob) pairs, not an object. The trees are
package/dist/spawn.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import * as cp from 'node:child_process';
1
3
  import { statSync } from 'node:fs';
2
4
  import { extname, join, win32 } from 'node:path';
3
5
  import { ok, refuse, v } from './refusal.js';
@@ -105,3 +107,39 @@ export function resolveSpawn(cmd, args, env, platform = process.platform) {
105
107
  windowsVerbatimArguments: true,
106
108
  });
107
109
  }
110
+ // Row 201. The one module that starts a child process. A console program started by a process
111
+ // with no console of its own gets a new console, and on Windows a new console is a window: the
112
+ // background drive `drive --detach` starts has none (libuv's DETACHED_PROCESS), so each git call
113
+ // and each session it ran opened one. `windowsHide` asks for CREATE_NO_WINDOW instead, which
114
+ // libuv grants only when no stdio slot inherits a handle — a hidden child pipes or ignores all
115
+ // three. It is asked for only where witness has no console to lend: a child given a hidden
116
+ // console of its own no longer shares the terminal's, and Ctrl+C typed there never reaches it —
117
+ // a foreground drive's sessions rely on exactly that. Async-local, like the journal stamp (row
118
+ // 191 §4.8), so an invocation run in process — drive's decisions, a test's CLI — keeps its own
119
+ // answer. The scope only ever turns hiding on: a nested `main` inherits it.
120
+ export const NO_CONSOLE_ENV = 'WITNESS_NO_CONSOLE';
121
+ const noConsole = new AsyncLocalStorage();
122
+ export function withoutConsole(fn) {
123
+ return noConsole.run(true, fn);
124
+ }
125
+ // child_process takes `(file, args?, options?)` or `(file, options?)`, and an argv left out
126
+ // (`undefined`, `null`) still has the options behind it; they are found whichever form a caller
127
+ // used, and an explicit `windowsHide` — the viewer's — wins.
128
+ function hidden(rest) {
129
+ const [a, b] = rest;
130
+ const opts = (o) => ({ windowsHide: noConsole.getStore() === true, ...o });
131
+ return Array.isArray(a) || (a == null && rest.length > 1) ? [a, opts(b)] : [opts(a)];
132
+ }
133
+ export const spawn = ((file, ...rest) => cp.spawn(file, ...hidden(rest)));
134
+ export const spawnSync = ((file, ...rest) => cp.spawnSync(file, ...hidden(rest)));
135
+ export const execFileSync = ((file, ...rest) => cp.execFileSync(file, ...hidden(rest)));
136
+ export const execSync = ((command, ...rest) => cp.execSync(command, ...hidden(rest)));
137
+ // Row 201. A Windows session's stop: its whole tree, from the shim down, the twin of the POSIX
138
+ // group kill. System32's taskkill, never PATH's, where a repo could plant one — resolveSpawn's
139
+ // System32 `cmd.exe` precedent.
140
+ export function treeStop(pid, env) {
141
+ return {
142
+ file: win32.join(envGet(env, 'SYSTEMROOT') ?? 'C:\\Windows', 'System32', 'taskkill.exe'),
143
+ args: ['/PID', String(pid), '/T', '/F'],
144
+ };
145
+ }
package/dist/stamp.js CHANGED
@@ -1,4 +1,3 @@
1
- import { execFileSync } from 'node:child_process';
2
1
  import { existsSync } from 'node:fs';
3
2
  import { join } from 'node:path';
4
3
  import { deferralMoves } from './deferral.js';
@@ -8,6 +7,7 @@ import { appendEntry, entryLine, journalRel, readStream } from './journal.js';
8
7
  import { acquireLock } from './lock.js';
9
8
  import { canonicalSha } from './sha.js';
10
9
  import { findById } from './scan.js';
10
+ import { execFileSync } from './spawn.js';
11
11
  import { crashPoint, withTxn } from './txn.js';
12
12
  import { autoSync } from './verbs/sync.js';
13
13
  import { removeWorktree, worktreePath } from './worktree.js';
@@ -1,4 +1,3 @@
1
- import { execFileSync } from 'node:child_process';
2
1
  import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
2
  import { tmpdir } from 'node:os';
4
3
  import { join } from 'node:path';
@@ -13,6 +12,7 @@ import { acquireLock } from '../lock.js';
13
12
  import { deepEqual, migrateValues, withoutEmpty } from '../migration.js';
14
13
  import { renderRefusal, v } from '../refusal.js';
15
14
  import { GATE_NAMES, SETTINGS, getIn, settingAt } from '../settings.js';
15
+ import { execFileSync } from '../spawn.js';
16
16
  import { kv } from '../toon.js';
17
17
  // Row 193 §4.6, the verb row 23 reserved: bring witness.config.yaml to this CLI's schema and
18
18
  // make it complete — every setting with its comment, every value that is a choice kept, every
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popovych.co/witness",
3
- "version": "0.24.0",
3
+ "version": "0.24.2",
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",
@@ -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.24.0",
4
+ "version": "0.24.2",
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.24.0}"
15
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.24.2}"
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.24.0} 2>/dev/null || true
6
+ ${WITNESS_BIN:-npx -y @popovych.co/witness@0.24.2} 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.24.0}"
19
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.24.2}"
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.24.0}"
13
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.24.2}"
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.24.0}"
19
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.24.2}"
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.24.0}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.24.2}"
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.24.0}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.24.2}"
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.24.0}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.24.2}"
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.
@@ -1,30 +0,0 @@
1
- // Row 193 §4.5. Every comment text a released witness wrote into witness.config.yaml: each
2
- // version of `init`'s template (git log -p --follow -- src/verbs/init.ts, the specflow era
3
- // included; a continuation line is its own entry) and both of `recordHarness`'s texts
4
- // (src/install.ts). A comment line whose trimmed text is one of these is witness's, wherever it
5
- // sits: `migrate` replaces it on a setting's line and drops it on a line of its own, since what
6
- // it described now exists for real. An edited copy no longer matches, so it is the human's.
7
- export const LEGACY_COMMENTS = new Set([
8
- 'any gate block may pin its own model (wins over the global pin), e.g.',
9
- 'conventions: [docs/code/architecture.md] # → injected into code-reviewer at implement + ship (cache-keyed)',
10
- 'declared beats the ambient session (init --agent writes it once)',
11
- 'decompose: { reviewers: [slicing-critic], model: claude-opus-4-8 }',
12
- 'docs: # repo docs registry — enumerated keys, unknown keys refused',
13
- "harness: pi # the judge — which harness runs this repo's gate reviewers;",
14
- 'or: runner: full-suite + report: junit:**/reports/junit.xml',
15
- 'paths: { specs: docs/specs, plans: docs/plans } # optional canon roots (defaults: specs, plans); git mv existing docs when changing',
16
- 'per change class; a plain list = all classes',
17
- 'reviewer model pin — exact id, aliases refused',
18
- 'reviewerTimeoutMs: 600000 # ms per reviewer invocation (machine auth/extension knobs live in .witness/config.local.yaml)',
19
- 'specflow.config.yaml — the whole surface',
20
- 'witness.config.yaml — the whole surface',
21
- "the judge — which harness runs this repo's gate reviewers; declared wins",
22
- 'detection wins; this is the fallback',
23
- // The end-of-line comments of the template's commented-out settings, which the template meant
24
- // the human to uncomment (final review I3).
25
- 'optional canon roots (defaults: specs, plans); git mv existing docs when changing',
26
- 'repo docs registry — enumerated keys, unknown keys refused',
27
- '→ injected into code-reviewer at implement + ship (cache-keyed)',
28
- "the judge — which harness runs this repo's gate reviewers;",
29
- 'ms per reviewer invocation (machine auth/extension knobs live in .witness/config.local.yaml)',
30
- ]);