@popovych.co/witness 0.28.2 → 0.28.3
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/README.md +1 -1
- package/dist/abandon.d.ts +67 -0
- package/dist/act.d.ts +16 -0
- package/dist/act.js +61 -0
- package/dist/adopt.d.ts +21 -0
- package/dist/allowlist.d.ts +48 -0
- package/dist/allowlist.js +79 -5
- package/dist/arbiter.d.ts +37 -0
- package/dist/arbiter.js +7 -5
- package/dist/ask.d.ts +29 -0
- package/dist/ask.js +11 -5
- package/dist/autonomy.d.ts +46 -0
- package/dist/autonomy.js +24 -12
- package/dist/awake.d.ts +15 -0
- package/dist/basis.d.ts +9 -0
- package/dist/battery.d.ts +23 -0
- package/dist/bin.d.ts +2 -0
- package/dist/caps.d.ts +20 -0
- package/dist/cli.d.ts +18 -0
- package/dist/config-file.d.ts +12 -0
- package/dist/config.d.ts +96 -0
- package/dist/config.js +2 -1
- package/dist/contain.d.ts +16 -0
- package/dist/context.d.ts +25 -0
- package/dist/criteria.d.ts +27 -0
- package/dist/criteria.js +2 -1
- package/dist/decide-view.d.ts +46 -0
- package/dist/decide-view.js +137 -0
- package/dist/decisions.d.ts +23 -0
- package/dist/deferral.d.ts +26 -0
- package/dist/delta.d.ts +58 -0
- package/dist/departure.d.ts +66 -0
- package/dist/design.d.ts +34 -0
- package/dist/drafts.d.ts +31 -0
- package/dist/drafts.js +5 -3
- package/dist/drift.d.ts +23 -0
- package/dist/drive-presence.d.ts +27 -0
- package/dist/drive-presence.js +15 -4
- package/dist/drive-report.d.ts +24 -0
- package/dist/drive-report.js +4 -4
- package/dist/drive.d.ts +97 -0
- package/dist/drive.js +68 -71
- package/dist/dsl.d.ts +23 -0
- package/dist/dsl.js +8 -3
- package/dist/evidence.d.ts +65 -0
- package/dist/floor.d.ts +6 -0
- package/dist/fm.d.ts +9 -0
- package/dist/gate-run-view.d.ts +57 -0
- package/dist/gate-run-view.js +100 -0
- package/dist/gate.d.ts +91 -0
- package/dist/gate.js +14 -67
- package/dist/gates/decompose.d.ts +1 -0
- package/dist/gates/decompose.js +3 -1
- package/dist/gates/design.d.ts +1 -0
- package/dist/gates/design.js +6 -2
- package/dist/gates/implement.d.ts +1 -0
- package/dist/gates/implement.js +9 -2
- package/dist/gates/index.d.ts +5 -0
- package/dist/gates/plan.d.ts +1 -0
- package/dist/gates/plan.js +10 -4
- package/dist/gates/ship.d.ts +1 -0
- package/dist/gates/ship.js +4 -2
- package/dist/gitio.d.ts +30 -0
- package/dist/gitio.js +4 -1
- package/dist/glob.d.ts +2 -0
- package/dist/harness.d.ts +73 -0
- package/dist/harness.js +36 -15
- package/dist/history.d.ts +10 -0
- package/dist/idlists.d.ts +2 -0
- package/dist/install.d.ts +29 -0
- package/dist/journal.d.ts +74 -0
- package/dist/journal.js +5 -1
- package/dist/junit.d.ts +9 -0
- package/dist/live.d.ts +24 -0
- package/dist/lock.d.ts +9 -0
- package/dist/matcher.d.ts +8 -0
- package/dist/migration.d.ts +25 -0
- package/dist/model.d.ts +8 -0
- package/dist/models.d.ts +9 -0
- package/dist/models.js +10 -0
- package/dist/needs-you.d.ts +75 -0
- package/dist/needs-you.js +104 -40
- package/dist/needs.d.ts +44 -0
- package/dist/needs.js +37 -7
- package/dist/notify.d.ts +12 -0
- package/dist/opener.d.ts +15 -0
- package/dist/pin.d.ts +12 -0
- package/dist/pin.js +9 -2
- package/dist/principles.d.ts +3 -0
- package/dist/probe.d.ts +1 -0
- package/dist/progress.d.ts +3 -0
- package/dist/recommend.d.ts +31 -0
- package/dist/recommend.js +51 -42
- package/dist/refusal.d.ts +20 -0
- package/dist/refusal.js +12 -4
- package/dist/registry.d.ts +1 -0
- package/dist/released-comments.d.ts +1 -0
- package/dist/review.d.ts +27 -0
- package/dist/reviewed.d.ts +23 -0
- package/dist/reviewer.d.ts +47 -0
- package/dist/rounds.d.ts +135 -0
- package/dist/rounds.js +38 -21
- package/dist/runner-lock.d.ts +5 -0
- package/dist/runner.d.ts +30 -0
- package/dist/scan.d.ts +27 -0
- package/dist/schemas.d.ts +11 -0
- package/dist/schemas.js +7 -3
- package/dist/session-clock.d.ts +16 -0
- package/dist/settings.d.ts +73 -0
- package/dist/settings.js +12 -2
- package/dist/settle.d.ts +39 -0
- package/dist/settle.js +59 -30
- package/dist/sha.d.ts +5 -0
- package/dist/ship.d.ts +20 -0
- package/dist/ship.js +21 -12
- package/dist/slice.d.ts +45 -0
- package/dist/slice.js +2 -2
- package/dist/snapshot.d.ts +10 -0
- package/dist/spawn.d.ts +22 -0
- package/dist/stamp.d.ts +27 -0
- package/dist/stamp.js +3 -1
- package/dist/steps.d.ts +30 -0
- package/dist/steps.js +8 -3
- package/dist/toon.d.ts +17 -0
- package/dist/toon.js +150 -14
- package/dist/txn.d.ts +28 -0
- package/dist/usage.d.ts +25 -0
- package/dist/verbs/abandon.d.ts +2 -0
- package/dist/verbs/adopt.d.ts +2 -0
- package/dist/verbs/adopt.js +9 -4
- package/dist/verbs/ask.d.ts +2 -0
- package/dist/verbs/check.d.ts +2 -0
- package/dist/verbs/check.js +29 -10
- package/dist/verbs/clean.d.ts +2 -0
- package/dist/verbs/dashboard.d.ts +59 -0
- package/dist/verbs/dashboard.js +4 -2
- package/dist/verbs/decide.d.ts +34 -0
- package/dist/verbs/decide.js +95 -130
- package/dist/verbs/design.d.ts +2 -0
- package/dist/verbs/design.js +8 -5
- package/dist/verbs/diff.d.ts +2 -0
- package/dist/verbs/diff.js +4 -2
- package/dist/verbs/dismiss.d.ts +2 -0
- package/dist/verbs/dispatch.d.ts +2 -0
- package/dist/verbs/dispatch.js +2 -2
- package/dist/verbs/draft.d.ts +2 -0
- package/dist/verbs/draft.js +6 -3
- package/dist/verbs/drive.d.ts +2 -0
- package/dist/verbs/evidence.d.ts +5 -0
- package/dist/verbs/floor.d.ts +2 -0
- package/dist/verbs/gate.d.ts +3 -0
- package/dist/verbs/index-verb.d.ts +2 -0
- package/dist/verbs/init.d.ts +2 -0
- package/dist/verbs/log.d.ts +9 -0
- package/dist/verbs/migrate.d.ts +13 -0
- package/dist/verbs/next.d.ts +61 -0
- package/dist/verbs/next.js +112 -84
- package/dist/verbs/read.d.ts +2 -0
- package/dist/verbs/read.js +3 -1
- package/dist/verbs/recap.d.ts +28 -0
- package/dist/verbs/recap.js +3 -3
- package/dist/verbs/recover.d.ts +5 -0
- package/dist/verbs/recover.js +14 -9
- package/dist/verbs/rename.d.ts +2 -0
- package/dist/verbs/rename.js +1 -1
- package/dist/verbs/retry.d.ts +2 -0
- package/dist/verbs/review.d.ts +2 -0
- package/dist/verbs/review.js +1 -1
- package/dist/verbs/satisfy.d.ts +2 -0
- package/dist/verbs/ship.d.ts +3 -0
- package/dist/verbs/start.d.ts +2 -0
- package/dist/verbs/start.js +12 -7
- package/dist/verbs/step-close.d.ts +2 -0
- package/dist/verbs/sync.d.ts +15 -0
- package/dist/verbs/trust.d.ts +4 -0
- package/dist/verbs/trust.js +34 -32
- package/dist/verbs/turn.d.ts +2 -0
- package/dist/verbs/wait.d.ts +9 -0
- package/dist/verbs/wait.js +3 -3
- package/dist/verbs/write.d.ts +18 -0
- package/dist/verbs/write.js +11 -5
- package/dist/verdict.d.ts +60 -0
- package/dist/version.d.ts +4 -0
- package/dist/worker-stream.d.ts +22 -0
- package/dist/worktree.d.ts +22 -0
- package/dist/worktree.js +1 -1
- package/package.json +7 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/commands/witness.md +10 -10
- package/plugin/hooks/canon-guard.mjs +71 -10
- package/plugin/hooks/session-dashboard.sh +1 -1
- package/plugin/skills/witness-brainstorm/SKILL.md +3 -3
- package/plugin/skills/witness-decompose/SKILL.md +3 -3
- package/plugin/skills/witness-design/SKILL.md +2 -2
- package/plugin/skills/witness-implement/SKILL.md +2 -2
- package/plugin/skills/witness-plan/SKILL.md +2 -2
- package/plugin/skills/witness-ship/SKILL.md +2 -2
package/dist/needs-you.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { cliAct, exitsLine, runRow } from './act.js';
|
|
3
|
+
import { grantAct, grantRowsOf } from './allowlist.js';
|
|
3
4
|
import { TARGETLESS } from './drive-presence.js';
|
|
4
5
|
import { handoffLine, resolveDriver } from './harness.js';
|
|
5
6
|
import { readStream } from './journal.js';
|
|
6
7
|
import { unmetNeeds } from './needs.js';
|
|
7
8
|
import { findById } from './scan.js';
|
|
8
|
-
import {
|
|
9
|
+
import { cmd, logSafe, shellLine, visible } from './toon.js';
|
|
9
10
|
import { pendingTxn } from './txn.js';
|
|
10
11
|
import { owedDecisions, parkedGates } from './verbs/next.js';
|
|
11
12
|
import { recoverChoice } from './verbs/recover.js';
|
|
@@ -13,55 +14,54 @@ export const WAIT_LABEL = {
|
|
|
13
14
|
'pending-txn': 'pending transaction', 'design-look': 'design look', 'trust-grant': 'trust grant', need: 'unmet need',
|
|
14
15
|
decision: 'decision', conversation: 'conversation', merge: 'merge', parked: 'parked', stuck: 'stuck', capped: 'capped',
|
|
15
16
|
};
|
|
16
|
-
// The kinds `next` never routes: the chat names each, with its command (final review).
|
|
17
17
|
export const HELD_KINDS = new Set(['merge', 'parked', 'stuck', 'capped']);
|
|
18
|
+
export const isHeld = (item) => HELD_KINDS.has(item.kind);
|
|
18
19
|
// The kinds the report counts as waits (each target once), in the order a human answers them.
|
|
19
20
|
export const WAIT_KINDS = new Set(['pending-txn', 'design-look', 'trust-grant', 'need', 'decision', 'conversation', 'merge']);
|
|
20
21
|
const prOf = (line) => /PR #(\d+)/.exec(line)?.[1];
|
|
21
|
-
// Row
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return a.trust.flatMap((c) => [
|
|
28
|
-
`wait: trust grant · ${a.target} · ${shownCmd(c)}`,
|
|
29
|
-
` ${hasControl(c.cmd) ? 'note' : 'run'}: ${grantOf(a.target, c)}`,
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
22
|
+
// Row 239. The frontmatter's `pr`, named only when it is a PR's number: the CLI writes one there
|
|
23
|
+
// (`stampPr`), and a hand edit can write any value. A number counts when it is a whole number from
|
|
24
|
+
// 1, and a string when it is such a number's digits; `Number` would also read `true`, `[7]`, `'0x10'`
|
|
25
|
+
// and `'1e3'` as numbers. Safe integers only, so the word printed is always the number's digits.
|
|
26
|
+
const prOfMeta = (meta) => typeof meta === 'number' ? (Number.isSafeInteger(meta) && meta >= 1 ? String(meta) : undefined)
|
|
27
|
+
: typeof meta === 'string' && /^[1-9]\d*$/.test(meta) ? meta : undefined;
|
|
32
28
|
export function needsYou(root, ctx, cfg, canon, aside) {
|
|
33
29
|
const items = [];
|
|
34
30
|
const named = new Set();
|
|
35
|
-
const add = (
|
|
36
|
-
named.add(target);
|
|
37
|
-
items.push(
|
|
31
|
+
const add = (item) => {
|
|
32
|
+
named.add(item.target);
|
|
33
|
+
items.push(item);
|
|
38
34
|
};
|
|
39
35
|
// A crash no session could recover blocks every write: it is named first (F4).
|
|
40
36
|
const txn = pendingTxn(root);
|
|
41
37
|
if (txn !== undefined) {
|
|
42
|
-
items.push({ kind: 'pending-txn', target: TARGETLESS, key: 'pending-txn:-',
|
|
43
|
-
rows: [`wait: pending transaction · ${txn.op}`, ` run: ${recoverChoice(root, txn).options[0].command}`] });
|
|
38
|
+
items.push({ kind: 'pending-txn', target: TARGETLESS, key: 'pending-txn:-', op: txn.op, recover: recoverChoice(root, txn) });
|
|
44
39
|
}
|
|
45
40
|
for (const a of aside.filter((x) => x.kind === 'kept' && (x.stop === 'design-look' || x.stop === 'trust-grant'))) {
|
|
46
41
|
if (named.has(a.target))
|
|
47
42
|
continue;
|
|
43
|
+
const t = a.target;
|
|
48
44
|
if (a.stop === 'design-look') {
|
|
49
|
-
add('design-look',
|
|
45
|
+
add({ kind: 'design-look', target: t, key: `design-look:${t}`,
|
|
46
|
+
open: cliAct('design', t, '--open'), show: cliAct('decide', 'design', t, '--show') });
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const commands = (a.trust ?? []).map((c) => {
|
|
50
|
+
const grant = grantAct(t, c);
|
|
51
|
+
return { cmd: visible(c.cmd), source: visible(c.source), ...(grant !== undefined ? { grant } : {}) };
|
|
52
|
+
});
|
|
53
|
+
add({ kind: 'trust-grant', target: t, key: `trust-grant:${t}`, ...(commands.length > 0 ? { commands } : {}), list: cliAct('trust', t) });
|
|
50
54
|
}
|
|
51
|
-
else
|
|
52
|
-
add('trust-grant', a.target, trustRows(a));
|
|
53
55
|
}
|
|
54
56
|
for (const u of unmetNeeds(canon)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
held ? `wait: held criterion · ${u.doc} · ${u.text} holds ${u.holds.join(' · ')}` : `wait: unmet need · ${u.doc} · ${u.text}`,
|
|
58
|
-
` run: ${u.satisfy}`,
|
|
59
|
-
], `need:${u.doc}:${u.need}`);
|
|
57
|
+
add({ kind: 'need', target: u.doc, key: `need:${u.doc}:${u.need}`, need: u.need, text: u.text, holds: u.holds,
|
|
58
|
+
satisfy: u.satisfyAct });
|
|
60
59
|
}
|
|
61
60
|
for (const o of owedDecisions(root, canon)) {
|
|
62
61
|
if (named.has(o.target))
|
|
63
62
|
continue;
|
|
64
|
-
add('decision', o.target,
|
|
63
|
+
add({ kind: 'decision', target: o.target, key: `decision:${o.target}:${o.gate}`, gate: o.gate,
|
|
64
|
+
show: cliAct('decide', o.gate, o.target, '--show') });
|
|
65
65
|
}
|
|
66
66
|
const driver = resolveDriver(ctx.env, cfg.harness);
|
|
67
67
|
for (const a of aside.filter((x) => x.kind === 'conversation' || x.kind === 'merge')) {
|
|
@@ -74,38 +74,102 @@ export function needsYou(root, ctx, cfg, canon, aside) {
|
|
|
74
74
|
// queued ask.
|
|
75
75
|
const ask = a.target === TARGETLESS && a.line !== undefined ? / --ask (\S+)/.exec(a.line)?.[1] : undefined;
|
|
76
76
|
if (a.target === TARGETLESS && a.line !== undefined && ask === undefined) {
|
|
77
|
-
items.push({ kind: 'conversation', target: TARGETLESS, key: 'conversation:-', notice: true
|
|
78
|
-
rows: ['nothing queued — /witness <what to build> in a chat'] });
|
|
77
|
+
items.push({ kind: 'conversation', target: TARGETLESS, key: 'conversation:-', notice: true });
|
|
79
78
|
continue;
|
|
80
79
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
...(driver.ok ? [` run: ${handoffLine(driver.value.harness, root, undefined)}`] : [])]);
|
|
80
|
+
add({ kind: 'conversation', target: a.target, key: `conversation:${a.target}`, ...(ask !== undefined ? { ask } : {}),
|
|
81
|
+
...(driver.ok ? { handoff: handoffLine(driver.value.harness, root, undefined) } : {}) });
|
|
84
82
|
}
|
|
85
83
|
else {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
add('merge', a.target, [`wait: merge · ${a.target}${pr ? ` · PR #${pr}` : ''}`, ...(pr ? [` run: gh pr merge ${pr}`] : [])]);
|
|
84
|
+
const pr = (a.line !== undefined ? prOf(a.line) : undefined) ?? prOfMeta(findById(canon, a.target)?.meta.pr);
|
|
85
|
+
add({ kind: 'merge', target: a.target, key: `merge:${a.target}`, ...(pr ? { pr } : {}) });
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
for (const p of parkedGates(root, canon)) {
|
|
92
89
|
const stopped = readStream(root, p.target)
|
|
93
90
|
.filter((e) => e.t === 'human-decision' && e.gate === p.gate)
|
|
94
91
|
.map((e) => e).filter((d) => d.decision === 'stop').at(-1);
|
|
95
|
-
|
|
92
|
+
// A journaled note is parsed JSON: held as the string it prints as.
|
|
93
|
+
const why = stopped?.selected === 'policy' && stopped.note ? String(stopped.note) : `parked at ${p.anchor}`;
|
|
96
94
|
items.push({ kind: 'parked', target: p.target, key: `parked:${p.target}:${p.gate}`,
|
|
97
|
-
|
|
95
|
+
gate: p.gate, ...(p.round !== undefined ? { round: p.round } : {}), why, reopen: p.reopen });
|
|
98
96
|
}
|
|
99
97
|
// A capped target the policy could not park carries no gate (drive.ts): it is stuck too. One
|
|
100
98
|
// the policy parked is the parked row above, read from the journal.
|
|
101
99
|
for (const a of aside.filter((x) => x.kind === 'stuck' || (x.kind === 'capped' && x.gate === undefined))) {
|
|
102
100
|
// Final review: the way back is named — a fix witness cannot see is the human's `retry`.
|
|
103
101
|
items.push({ kind: a.kind, target: a.target, key: `${a.kind}:${a.target}`,
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
...(a.why !== undefined ? { why: a.why } : {}),
|
|
103
|
+
...(a.target !== TARGETLESS ? { retry: cliAct('retry', a.target) } : {}) });
|
|
106
104
|
}
|
|
107
105
|
return items;
|
|
108
106
|
}
|
|
107
|
+
// Row 205. One wait per command, each with its source and the grant that names it. A command
|
|
108
|
+
// the verb would not take (anything outside printable ASCII) gets a note, never a `run:`. An
|
|
109
|
+
// aside with no commands (one read from the live folder) names the listing form. Row 239: the
|
|
110
|
+
// grant's rows are the kept stop's (`grantRowsOf`), so one Windows withholds names the listing.
|
|
111
|
+
function trustRows(item) {
|
|
112
|
+
if (item.commands === undefined || item.commands.length === 0) {
|
|
113
|
+
return [`wait: trust grant · ${item.target}`, runRow(item.list)];
|
|
114
|
+
}
|
|
115
|
+
return item.commands.flatMap((c) => [`wait: trust grant · ${item.target} · ${c.cmd} (${c.source})`, ...grantRowsOf(c.grant, item.list)]);
|
|
116
|
+
}
|
|
117
|
+
// Rows 139/203. An item's rows, laid out from its facts: every command a row offers is an act's
|
|
118
|
+
// line, and only labels, separators and prose pointers are added here. Row 239 (ruling R16): each
|
|
119
|
+
// such row is `runRow`'s, which a withheld act turns into a note, and the prose a repo, a
|
|
120
|
+
// journal or a reviewer wrote on a head line — a need's text and holds, a park's or a stop's why —
|
|
121
|
+
// is spelled out (`logSafe`) where it holds a line break, which would start a `run:` row of its own.
|
|
122
|
+
export function needYouRows(item) {
|
|
123
|
+
switch (item.kind) {
|
|
124
|
+
case 'pending-txn': {
|
|
125
|
+
// `recoverChoice` builds every option from an act; one without an act offers no row.
|
|
126
|
+
const act = item.recover.options[0]?.act;
|
|
127
|
+
return [`wait: pending transaction · ${item.op}`, ...(act !== undefined ? [runRow(act)] : [])];
|
|
128
|
+
}
|
|
129
|
+
case 'design-look':
|
|
130
|
+
return [`wait: design look · ${item.target}`, runRow(item.open), runRow(item.show, 'then')];
|
|
131
|
+
case 'trust-grant':
|
|
132
|
+
return trustRows(item);
|
|
133
|
+
case 'need':
|
|
134
|
+
return [
|
|
135
|
+
item.holds.length > 0
|
|
136
|
+
? `wait: held criterion · ${item.target} · ${logSafe(item.text)} holds ${logSafe(item.holds.join(' · '))}`
|
|
137
|
+
: `wait: unmet need · ${item.target} · ${logSafe(item.text)}`,
|
|
138
|
+
runRow(item.satisfy),
|
|
139
|
+
];
|
|
140
|
+
case 'decision':
|
|
141
|
+
return [`wait: decision · ${item.gate} ${item.target}`, runRow(item.show)];
|
|
142
|
+
case 'conversation': {
|
|
143
|
+
if (item.notice === true)
|
|
144
|
+
return ['nothing queued — /witness <what to build> in a chat'];
|
|
145
|
+
const who = item.target === TARGETLESS ? `brainstorm${item.ask !== undefined ? ` · ask ${item.ask}` : ''}` : item.target;
|
|
146
|
+
return [`wait: conversation · ${who}`, ...(item.handoff !== undefined ? [` run: ${item.handoff}`] : [])];
|
|
147
|
+
}
|
|
148
|
+
// Row 239. Another tool's command, through the one renderer; `needsYou` names only a number.
|
|
149
|
+
case 'merge':
|
|
150
|
+
return [`wait: merge · ${item.target}${item.pr ? ` · PR #${item.pr}` : ''}`,
|
|
151
|
+
...(item.pr ? [` run: ${shellLine(['gh', 'pr', 'merge', item.pr])}`] : [])];
|
|
152
|
+
// Row 239 (design §3.4b). At the bound the reopen is the endgame menu, and a menu pasted whole
|
|
153
|
+
// is a pipeline that runs every act it names: it prints as `exits:`, the label `decide --show`
|
|
154
|
+
// gives a set of choices, and `run:` is kept for one command.
|
|
155
|
+
case 'parked':
|
|
156
|
+
return [`parked: ${item.target} · ${item.gate}${item.round !== undefined ? ` round ${item.round}` : ''} — ${logSafe(item.why)}`,
|
|
157
|
+
item.reopen.length === 1 ? runRow(item.reopen[0]) : ` exits: ${exitsLine(item.reopen)}`];
|
|
158
|
+
// Row 239. The log the head names, when it has no why, is an act's line.
|
|
159
|
+
case 'stuck':
|
|
160
|
+
case 'capped':
|
|
161
|
+
return [`stuck: ${item.target} — ${item.why !== undefined ? logSafe(item.why) : cliAct('log', item.target).line}`,
|
|
162
|
+
...(item.retry !== undefined ? [runRow(item.retry)] : [])];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Row 239 (design §3.4). How `next` names an item it does not route: the item's head as a
|
|
166
|
+
// `waiting:` line, then the rows `needYouRows` prints under it, each command indented on its own.
|
|
167
|
+
// The head is prose a repo or a reviewer can write — a park's note, an anchor — so a command
|
|
168
|
+
// joined to it, as the line once did, could be planted ahead of the real one.
|
|
169
|
+
export function waitingRows(item) {
|
|
170
|
+
const [head, ...more] = needYouRows(item);
|
|
171
|
+
return [cmd('waiting', head.replace(/^wait: /, '')), ...more];
|
|
172
|
+
}
|
|
109
173
|
// The first 12 hex of a sha1 over the sorted keys of what is owed: order-free, text-free.
|
|
110
174
|
export function needsYouToken(items) {
|
|
111
175
|
const keys = [...new Set(items.filter((i) => i.notice !== true).map((i) => i.key))].sort();
|
package/dist/needs.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Act } from './act.js';
|
|
2
|
+
import type { Ctx } from './cli.js';
|
|
3
|
+
import type { GateCheck } from './rounds.js';
|
|
4
|
+
import type { Canon, CanonDoc } from './scan.js';
|
|
5
|
+
export interface NeedResult {
|
|
6
|
+
label: string;
|
|
7
|
+
kind: 'env' | 'cmd' | 'manual';
|
|
8
|
+
status: 'ok' | 'unmet' | 'blocked' | 'declined';
|
|
9
|
+
detail: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function needKey(n: {
|
|
12
|
+
id?: string;
|
|
13
|
+
manual: string;
|
|
14
|
+
}): string;
|
|
15
|
+
export declare function needMet(doc: CanonDoc, n: {
|
|
16
|
+
id?: string;
|
|
17
|
+
manual: string;
|
|
18
|
+
satisfied?: boolean;
|
|
19
|
+
}): boolean;
|
|
20
|
+
export declare function evaluateNeeds(root: string, ctx: Ctx, needs: unknown[], doc: CanonDoc): Promise<NeedResult[]>;
|
|
21
|
+
export declare function satisfyCommand(doc: string, need: string): string;
|
|
22
|
+
export declare function heldCriteria(doc: CanonDoc): Map<string, string[]>;
|
|
23
|
+
export interface HeldRow {
|
|
24
|
+
criterion: string;
|
|
25
|
+
need: string;
|
|
26
|
+
satisfy: string;
|
|
27
|
+
spec?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function heldSatisfy(h: HeldRow): string | undefined;
|
|
30
|
+
export interface UnmetNeed {
|
|
31
|
+
doc: string;
|
|
32
|
+
type: 'spec' | 'plan';
|
|
33
|
+
need: string;
|
|
34
|
+
text: string;
|
|
35
|
+
holds: string[];
|
|
36
|
+
blocks: 'start' | 'nothing';
|
|
37
|
+
ref: string;
|
|
38
|
+
satisfy: string;
|
|
39
|
+
satisfyAct: Act;
|
|
40
|
+
}
|
|
41
|
+
export declare function unmetNeeds(canon: Canon): UnmetNeed[];
|
|
42
|
+
export declare function liftedHolds(doc: CanonDoc | undefined, run: {
|
|
43
|
+
checks: GateCheck[];
|
|
44
|
+
} | undefined): string[];
|
package/dist/needs.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { cliAct } from './act.js';
|
|
1
2
|
import { ensureTrusted, UNGRANTABLE } from './allowlist.js';
|
|
3
|
+
import { isId } from './dsl.js';
|
|
2
4
|
import { execSync } from './spawn.js';
|
|
3
5
|
import { hasControl } from './toon.js';
|
|
4
6
|
// Row 179. What a journaled satisfaction names a need by: its id, else its manual text.
|
|
@@ -47,8 +49,10 @@ export async function evaluateNeeds(root, ctx, needs, doc) {
|
|
|
47
49
|
}
|
|
48
50
|
return out;
|
|
49
51
|
}
|
|
52
|
+
// Rows 139/203. One builder: the inbox's need item carries this command as an act, and every
|
|
53
|
+
// other surface prints that act's line.
|
|
50
54
|
export function satisfyCommand(doc, need) {
|
|
51
|
-
return
|
|
55
|
+
return cliAct('satisfy', doc, '--need', need).line;
|
|
52
56
|
}
|
|
53
57
|
// Row 179. What a spec's unmet manual needs hold: criterion id → the ids of the needs holding
|
|
54
58
|
// it, in needs order. A satisfied need holds nothing, so its criteria run and must pass.
|
|
@@ -74,8 +78,28 @@ export function heldCriteria(doc) {
|
|
|
74
78
|
}
|
|
75
79
|
return out;
|
|
76
80
|
}
|
|
81
|
+
// Row 239 (the plan's B13). A journaled row's command, as a surface prints it. The journal is text
|
|
82
|
+
// anyone with the repo can edit, so its `satisfy` string is never trusted to hold a safe line: a row
|
|
83
|
+
// that journals its ids is rebuilt from them, and one journaled before them (0.28.2) prints its
|
|
84
|
+
// stored string only in the one shape `satisfyCommand` wrote there. Any other row prints none.
|
|
85
|
+
// Review I2: the criterion and the need print ahead of the command, so in either shape a row names
|
|
86
|
+
// one only while both are ids: a forged one could otherwise spell a command before the real one. A
|
|
87
|
+
// journaled row is parsed JSON, so an id is a string too.
|
|
88
|
+
const STORED_SATISFY = /^witness satisfy [a-z0-9][a-z0-9-]* --need [a-z0-9][a-z0-9-]*$/;
|
|
89
|
+
export function heldSatisfy(h) {
|
|
90
|
+
if (!isId(h.criterion) || !isId(h.need))
|
|
91
|
+
return undefined;
|
|
92
|
+
if (h.spec !== undefined)
|
|
93
|
+
return isId(h.spec) ? cliAct('satisfy', h.spec, '--need', h.need).line : undefined;
|
|
94
|
+
return typeof h.satisfy === 'string' && STORED_SATISFY.test(h.satisfy) ? h.satisfy : undefined;
|
|
95
|
+
}
|
|
96
|
+
// Row 239 (the plan's B15). Canon is text a hand edit can change, and a doc's id and a need's are
|
|
97
|
+
// printed into the satisfy offered and on the line that heads it: a doc or a need named outside the
|
|
98
|
+
// id set is never listed. A need with no id keeps its index among every manual need, as `satisfy`
|
|
99
|
+
// counts them.
|
|
77
100
|
export function unmetNeeds(canon) {
|
|
78
101
|
const docs = canon.docs
|
|
102
|
+
.filter((d) => isId(d.meta.id))
|
|
79
103
|
.filter((d) => d.meta.type === 'spec' || (d.meta.type === 'plan' && ['draft', 'approved'].includes(String(d.meta.status))))
|
|
80
104
|
.sort((a, b) => String(a.meta.id).localeCompare(String(b.meta.id)));
|
|
81
105
|
return docs.flatMap((d) => {
|
|
@@ -83,12 +107,18 @@ export function unmetNeeds(canon) {
|
|
|
83
107
|
const type = d.meta.type;
|
|
84
108
|
const needs = Array.isArray(d.meta.needs) ? d.meta.needs : [];
|
|
85
109
|
const manuals = needs.filter((n) => typeof n.manual === 'string');
|
|
86
|
-
return manuals.flatMap((n, i) =>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
110
|
+
return manuals.flatMap((n, i) => {
|
|
111
|
+
if (n.id !== undefined && !isId(n.id))
|
|
112
|
+
return [];
|
|
113
|
+
const ref = n.id ?? String(i + 1);
|
|
114
|
+
const satisfyAct = cliAct('satisfy', id, '--need', ref);
|
|
115
|
+
return needMet(d, n) ? [] : [{
|
|
116
|
+
doc: id, type, need: needKey(n), text: n.manual,
|
|
117
|
+
holds: type === 'spec' && Array.isArray(n.holds) ? n.holds : [],
|
|
118
|
+
blocks: type === 'plan' ? 'start' : 'nothing',
|
|
119
|
+
ref, satisfy: satisfyAct.line, satisfyAct,
|
|
120
|
+
}];
|
|
121
|
+
});
|
|
92
122
|
});
|
|
93
123
|
}
|
|
94
124
|
// Final review F1. The criteria a gate-run recorded as held that no unmet need holds now. A
|
package/dist/notify.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const TOAST_SCRIPT: string;
|
|
2
|
+
export interface NotifyArgv {
|
|
3
|
+
argv: string[];
|
|
4
|
+
env?: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function notifyArgv(platform: NodeJS.Platform, configured: string | undefined, title: string, message: string, env?: Record<string, string | undefined>): NotifyArgv | undefined;
|
|
7
|
+
export declare function notify(configured: string | undefined, title: string, message: string, platform?: NodeJS.Platform, opts?: {
|
|
8
|
+
wait: boolean;
|
|
9
|
+
}): {
|
|
10
|
+
outcome: 'sent' | 'started' | 'failed' | 'none';
|
|
11
|
+
command?: string;
|
|
12
|
+
};
|
package/dist/opener.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type OpenOutcome = 'spawned' | 'failed';
|
|
2
|
+
type Env = Record<string, string | undefined>;
|
|
3
|
+
export declare function platformOpener(platform?: NodeJS.Platform, env?: Env): string[];
|
|
4
|
+
export declare function probeArgv(cmd: string, platform?: NodeJS.Platform, env?: Env): {
|
|
5
|
+
file: string;
|
|
6
|
+
args: string[];
|
|
7
|
+
} | {
|
|
8
|
+
exists: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function resolves(cmd: string): boolean;
|
|
11
|
+
export declare function openArtifact(opener: string | undefined, absPath: string): {
|
|
12
|
+
outcome: OpenOutcome;
|
|
13
|
+
command: string;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
package/dist/pin.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Result } from './refusal.js';
|
|
2
|
+
export declare const THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
3
|
+
export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
4
|
+
export interface ParsedPin {
|
|
5
|
+
provider?: string;
|
|
6
|
+
model: string;
|
|
7
|
+
thinking: ThinkingLevel;
|
|
8
|
+
}
|
|
9
|
+
export declare const CLAUDE_THINKING_BUDGET: Record<Exclude<ThinkingLevel, 'off'>, number>;
|
|
10
|
+
export declare function parsePin(field: string, raw: string): Result<ParsedPin>;
|
|
11
|
+
export declare const MODEL_ALIASES: readonly string[];
|
|
12
|
+
export declare function checkPin(field: string, raw: string): Result<string>;
|
package/dist/pin.js
CHANGED
|
@@ -28,8 +28,12 @@ export function parsePin(field, raw) {
|
|
|
28
28
|
}
|
|
29
29
|
// Names that re-point when a vendor ships a new model, so a pin naming one is no pin.
|
|
30
30
|
export const MODEL_ALIASES = ['sonnet', 'opus', 'haiku', 'fable', 'default', 'latest'];
|
|
31
|
-
//
|
|
32
|
-
//
|
|
31
|
+
// Row 239 (the plan's B14). What a pin may hold: it is printed after `--model` in the handoff a human
|
|
32
|
+
// pastes. `@` keeps a Vertex-style `model@version` id, and `[`, `]` Claude Code's `[1m]` ids, which
|
|
33
|
+
// the quoter quotes; a leading letter or digit keeps a pin from reading as a flag.
|
|
34
|
+
const PIN_CHARSET = /^[A-Za-z0-9][A-Za-z0-9._:\/@\[\]-]*$/;
|
|
35
|
+
// The one pin check (row 193): the grammar, then the alias refusal, then the character set. Every
|
|
36
|
+
// pinned setting — a gate's model, the arbiter's — runs it where it is read and where it is used.
|
|
33
37
|
export function checkPin(field, raw) {
|
|
34
38
|
const parsed = parsePin(field, raw);
|
|
35
39
|
if (!parsed.ok)
|
|
@@ -37,5 +41,8 @@ export function checkPin(field, raw) {
|
|
|
37
41
|
if (MODEL_ALIASES.includes(parsed.value.model)) {
|
|
38
42
|
return refuse([v(field, 'alias-refused', raw, 'an exact model id — an alias re-points when its vendor ships a new model (Decision 55)')]);
|
|
39
43
|
}
|
|
44
|
+
if (!PIN_CHARSET.test(raw)) {
|
|
45
|
+
return refuse([v(field, 'pin-charset', raw, 'letters, digits and . _ : / @ [ ] -, starting with a letter or digit — a pin is printed into commands a human pastes')]);
|
|
46
|
+
}
|
|
40
47
|
return ok(raw);
|
|
41
48
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CanonDoc } from './scan.js';
|
|
2
|
+
export declare const PRINCIPLES_BODY = "# Principles\n\nRepo-wide rules and trade-offs. Amend via `witness write`; chores may name\nthis doc as their plan's parent.\n";
|
|
3
|
+
export declare function templateDraft(root: string, doc: CanonDoc | undefined): doc is CanonDoc;
|
package/dist/probe.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function probe(cmd: string, args: string[], env: Record<string, string | undefined>): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Act } from './act.js';
|
|
2
|
+
import type { Entry } from './journal.js';
|
|
3
|
+
export type Depth = 'root' | 'deferral' | 'terminal';
|
|
4
|
+
export interface Option {
|
|
5
|
+
command: string;
|
|
6
|
+
depth: Depth;
|
|
7
|
+
why?: string;
|
|
8
|
+
when?: string;
|
|
9
|
+
tradeoff?: string;
|
|
10
|
+
note?: string;
|
|
11
|
+
runnable: boolean;
|
|
12
|
+
judgeFirst?: string;
|
|
13
|
+
act?: Act;
|
|
14
|
+
}
|
|
15
|
+
export interface Decision {
|
|
16
|
+
key: string;
|
|
17
|
+
options: Option[];
|
|
18
|
+
rule: string;
|
|
19
|
+
anchor?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function renderDecision(d: Decision): string[];
|
|
22
|
+
export interface GateContext {
|
|
23
|
+
gate: string;
|
|
24
|
+
target: string;
|
|
25
|
+
entries: Entry[];
|
|
26
|
+
upstream: string | undefined;
|
|
27
|
+
stale: boolean;
|
|
28
|
+
untrustedCmds?: string[];
|
|
29
|
+
}
|
|
30
|
+
export declare function option(act: Act, depth: Depth, rest?: Partial<Pick<Option, 'why' | 'when' | 'tradeoff' | 'note' | 'judgeFirst'>>): Option;
|
|
31
|
+
export declare function recommend(ctx: GateContext): Decision | undefined;
|