@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/ship.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cliAct } from './act.js';
|
|
1
2
|
import { EXIT } from './cli.js';
|
|
2
3
|
import { autonomyAt, loadConfig } from './config.js';
|
|
3
4
|
import { acquireLock } from './lock.js';
|
|
@@ -5,10 +6,10 @@ import { crashPoint, guardTxn, withTxn } from './txn.js';
|
|
|
5
6
|
import { journalRel, readStream } from './journal.js';
|
|
6
7
|
import { primaryRoot, stateCommit, stateOnlyAdvance, tryGit } from './gitio.js';
|
|
7
8
|
import { untrustedCmdsFor } from './allowlist.js';
|
|
8
|
-
import { liftedHolds } from './needs.js';
|
|
9
|
+
import { heldSatisfy, liftedHolds } from './needs.js';
|
|
9
10
|
import { criteriaOwner, findById, loadCanon } from './scan.js';
|
|
10
11
|
import { humanCall, ok, refuse, renderRefusal, v } from './refusal.js';
|
|
11
|
-
import { cmd, kv } from './toon.js';
|
|
12
|
+
import { cmd, kv, logSafe, shellLine } from './toon.js';
|
|
12
13
|
import { gateSpec, runGate } from './gate.js';
|
|
13
14
|
import { lastGateRun, liveExits } from './rounds.js';
|
|
14
15
|
import { recommend, renderDecision } from './recommend.js';
|
|
@@ -77,13 +78,17 @@ export function existingPr(ctx, root, branch) {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
// Row 179. A PR shipped while a need held criteria says what was not verified, so the human
|
|
80
|
-
// reading the PR is not told the spec was proven where it was not.
|
|
81
|
-
|
|
81
|
+
// reading the PR is not told the spec was proven where it was not. Row 239 (B13): a PR is a surface
|
|
82
|
+
// too, so each row's command is the one `heldSatisfy` rebuilds from the journaled row, or none, and
|
|
83
|
+
// (ruling R16(a)) its criterion and need are spelled out, so a line break cannot start a line of its own.
|
|
84
|
+
export function prBody(plan, held) {
|
|
82
85
|
const head = `Realizes spec ${String(plan.meta.parent)} at ${String(plan.meta['derives-from']).slice(0, 7)} (witness).`;
|
|
83
86
|
if (held.length === 0)
|
|
84
87
|
return head;
|
|
85
|
-
return [head, '', 'Held — not verified while a need is unmet:',
|
|
86
|
-
|
|
88
|
+
return [head, '', 'Held — not verified while a need is unmet:', ...held.map((h) => {
|
|
89
|
+
const satisfy = heldSatisfy(h);
|
|
90
|
+
return `- ${logSafe(String(h.criterion))}: ${logSafe(String(h.need))} unmet${satisfy ? ` — ${satisfy}` : ''}`;
|
|
91
|
+
})].join('\n');
|
|
87
92
|
}
|
|
88
93
|
export function createPr(ctx, wt, root, plan, parentSummary, held = []) {
|
|
89
94
|
const branch = branchName(String(plan.meta.id));
|
|
@@ -159,7 +164,8 @@ export function rebaseIfMoved(wt, root, shipBranch, remote = 'origin') {
|
|
|
159
164
|
// which is the exact failure this function exists to prevent.
|
|
160
165
|
const fetched = tryGit(wt, 'fetch', remote, shipBranch);
|
|
161
166
|
if (!fetched.ok) {
|
|
162
|
-
|
|
167
|
+
// Row 239: the fetch the want names is another tool's command, through the one renderer.
|
|
168
|
+
return refuse([v('fetch', 'fetch-failed', fetched.out.slice(0, 200), `${shellLine(['git', 'fetch', remote, shipBranch])} to succeed`)]);
|
|
163
169
|
}
|
|
164
170
|
const base = `${remote}/${shipBranch}`;
|
|
165
171
|
if (tryGit(wt, 'merge-base', '--is-ancestor', base, 'HEAD').ok)
|
|
@@ -213,10 +219,12 @@ export function mergeOwnPr(ctx, root, cfg, planId, pr, pushed) {
|
|
|
213
219
|
const entries = readStream(root, planId);
|
|
214
220
|
const wt = worktreePath(root, planId);
|
|
215
221
|
const shipBranch = cfg.ship.branch;
|
|
222
|
+
// Row 239. The command every held line names is an act's line.
|
|
223
|
+
const shipCmd = cliAct('ship', planId).line;
|
|
216
224
|
// `baseMoved` reads a failed fetch as "not moved" so routing degrades offline; here that
|
|
217
225
|
// would merge onto a base nobody could check (F9), so an unreachable remote holds instead.
|
|
218
226
|
if (!tryGit(wt, 'fetch', 'origin', shipBranch).ok) {
|
|
219
|
-
ctx.out(kv('merge', `held — cannot verify ${shipBranch} (the fetch failed) ·
|
|
227
|
+
ctx.out(kv('merge', `held — cannot verify ${shipBranch} (the fetch failed) · ${shipCmd} retries once the remote answers`));
|
|
220
228
|
return EXIT.FINDINGS;
|
|
221
229
|
}
|
|
222
230
|
// The merge is the one irreversible outward act, so its authority comes from the branch it
|
|
@@ -233,7 +241,7 @@ export function mergeOwnPr(ctx, root, cfg, planId, pr, pushed) {
|
|
|
233
241
|
prBase = undefined;
|
|
234
242
|
}
|
|
235
243
|
if (prBase === undefined) {
|
|
236
|
-
ctx.out(kv('merge', `held — the PR's base branch cannot be read ·
|
|
244
|
+
ctx.out(kv('merge', `held — the PR's base branch cannot be read · ${shipCmd} retries`));
|
|
237
245
|
return EXIT.FINDINGS;
|
|
238
246
|
}
|
|
239
247
|
if (prBase !== shipBranch) {
|
|
@@ -244,7 +252,7 @@ export function mergeOwnPr(ctx, root, cfg, planId, pr, pushed) {
|
|
|
244
252
|
// `origin/<base>` is a local ref that `update-ref` or a rewritten fetch refspec can forge.
|
|
245
253
|
// Residual, recorded: an agent with this shell can still rewrite the remote's URL itself.
|
|
246
254
|
if (!tryGit(root, 'fetch', '--no-tags', 'origin', `+refs/heads/${prBase}:refs/witness/ship-authority`).ok) {
|
|
247
|
-
ctx.out(kv('merge', `held — cannot verify ${prBase} (the fetch failed) ·
|
|
255
|
+
ctx.out(kv('merge', `held — cannot verify ${prBase} (the fetch failed) · ${shipCmd} retries once the remote answers`));
|
|
248
256
|
return EXIT.FINDINGS;
|
|
249
257
|
}
|
|
250
258
|
if (!autonomyAt(root, 'refs/witness/ship-authority')) {
|
|
@@ -259,7 +267,7 @@ export function mergeOwnPr(ctx, root, cfg, planId, pr, pushed) {
|
|
|
259
267
|
: !headNow.ok || (pushed !== undefined && headNow.out.trim() !== pushed) ? 'HEAD moved since the push'
|
|
260
268
|
: undefined;
|
|
261
269
|
if (lapsed !== undefined) {
|
|
262
|
-
ctx.out(kv('merge', `held — the ship approval lapsed (${lapsed}) ·
|
|
270
|
+
ctx.out(kv('merge', `held — the ship approval lapsed (${lapsed}) · ${shipCmd} re-gates`));
|
|
263
271
|
return EXIT.FINDINGS;
|
|
264
272
|
}
|
|
265
273
|
// The local checks above prove the WORKTREE is what was judged; `gh pr merge` merges the
|
|
@@ -425,7 +433,8 @@ async function shipPass(ctx, planId, opts) {
|
|
|
425
433
|
// that has already declined. The owed work is the edit the revise asked for.
|
|
426
434
|
if (authoringOwed(entries, 'ship', reviewedSha)) {
|
|
427
435
|
ctx.out(kv('ship', `${planId} — revise owed`));
|
|
428
|
-
|
|
436
|
+
// Row 239. The re-run it names is an act's line.
|
|
437
|
+
ctx.out(`help: edit the code in ${wt} · then re-run ${cliAct('ship', planId).line}`);
|
|
429
438
|
return EXIT.FINDINGS;
|
|
430
439
|
}
|
|
431
440
|
// Rebase BEFORE the battery, never after: the reviewers must judge the tree that will
|
package/dist/slice.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Ctx } from './cli.js';
|
|
2
|
+
import { type Config } from './config.js';
|
|
3
|
+
import { type Fill } from './context.js';
|
|
4
|
+
import { type Entry } from './journal.js';
|
|
5
|
+
import type { CanonDoc } from './scan.js';
|
|
6
|
+
import { type Progress } from './steps.js';
|
|
7
|
+
export declare const ACT_KINDS: ReadonlySet<string>;
|
|
8
|
+
export declare function sessionActed(root: string, hash: string): boolean;
|
|
9
|
+
export declare function largestGrowth(entries: Entry[], p: Progress): number | undefined;
|
|
10
|
+
export declare function closedThisSession(entries: Entry[], p: Progress, hash: string): number;
|
|
11
|
+
export type SliceVerdict = {
|
|
12
|
+
kind: 'gate';
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'continue';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'end';
|
|
17
|
+
why: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'own-count';
|
|
20
|
+
budget: number;
|
|
21
|
+
};
|
|
22
|
+
export declare function stepCloseVerdict(i: {
|
|
23
|
+
fill: Fill;
|
|
24
|
+
limit: number;
|
|
25
|
+
budget: number;
|
|
26
|
+
progress: Progress;
|
|
27
|
+
redOpen: boolean;
|
|
28
|
+
growth?: number;
|
|
29
|
+
closedHere?: number;
|
|
30
|
+
}): SliceVerdict;
|
|
31
|
+
export declare function contextLine(fill: Fill, limit: number, budget: number, growth?: number): string;
|
|
32
|
+
export declare function sliceLine(v: SliceVerdict): string;
|
|
33
|
+
export declare function reportStepClose(ctx: Ctx, root: string, plan: CanonDoc, opts: {
|
|
34
|
+
closed?: string;
|
|
35
|
+
passingGreen: boolean;
|
|
36
|
+
entries?: Entry[];
|
|
37
|
+
}): void;
|
|
38
|
+
export declare function slicesLine(cfg: Config): string;
|
|
39
|
+
export declare function reportHandover(ctx: Ctx, root: string, cfg: Config, opts: {
|
|
40
|
+
guard: boolean;
|
|
41
|
+
}): boolean;
|
|
42
|
+
export declare function handOverIfDue(ctx: Ctx, opts: {
|
|
43
|
+
guard: boolean;
|
|
44
|
+
}): boolean;
|
|
45
|
+
export declare function reportOpening(ctx: Ctx, root: string, cfg: Config): void;
|
package/dist/slice.js
CHANGED
|
@@ -5,7 +5,7 @@ import { primaryRoot } from './gitio.js';
|
|
|
5
5
|
import { relayLine, resolveDriver } from './harness.js';
|
|
6
6
|
import { readStream, streamIds } from './journal.js';
|
|
7
7
|
import { implementGated, redInFlight, stepProgress, stepsLine, vacuousEvidence } from './steps.js';
|
|
8
|
-
import { kv } from './toon.js';
|
|
8
|
+
import { cmd, kv } from './toon.js';
|
|
9
9
|
// Plan's call 8 (row 191 §4.8). An act is the session's own stage work. What the CLI writes on a
|
|
10
10
|
// session's behalf is bookkeeping (`status`, the lazy merge stamp, among it), so a session cannot
|
|
11
11
|
// hand over before it has done anything.
|
|
@@ -173,7 +173,7 @@ export function reportHandover(ctx, root, cfg, opts) {
|
|
|
173
173
|
if (!driver.ok)
|
|
174
174
|
return false;
|
|
175
175
|
ctx.out(kv('context', contextLine(fill, limit, cfg.implement.stepsPerDispatch)));
|
|
176
|
-
ctx.out(
|
|
176
|
+
ctx.out(cmd('relay', relayLine(driver.value.harness)));
|
|
177
177
|
return true;
|
|
178
178
|
}
|
|
179
179
|
// Row 191 §4.4. `reportHandover` at the exit of a verb that holds no root or config there (a
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function snapshotTree(runRoot: string, base: string, files: readonly string[]): string | undefined;
|
|
2
|
+
export declare function snapshotFiles(root: string, files: ReadonlyArray<{
|
|
3
|
+
name: string;
|
|
4
|
+
content: string;
|
|
5
|
+
}>): string | undefined;
|
|
6
|
+
export declare function treeReadable(root: string, tree: string): boolean;
|
|
7
|
+
export declare function treePaths(root: string, tree: string): string[];
|
|
8
|
+
export declare function changedPaths(root: string, from: string, to: string): string[];
|
|
9
|
+
export declare function treeDiff(root: string, from: string, to: string): string;
|
|
10
|
+
export declare function blobText(root: string, tree: string, name: string): string | undefined;
|
package/dist/spawn.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as cp from 'node:child_process';
|
|
2
|
+
import { type Result } from './refusal.js';
|
|
3
|
+
export interface ResolvedSpawn {
|
|
4
|
+
file: string;
|
|
5
|
+
args: string[];
|
|
6
|
+
env: Record<string, string | undefined>;
|
|
7
|
+
windowsVerbatimArguments: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function envGet(env: Record<string, string | undefined>, name: string): string | undefined;
|
|
10
|
+
export declare function system32(env: Record<string, string | undefined>, ...parts: string[]): string;
|
|
11
|
+
export declare function crtQuote(arg: string): string;
|
|
12
|
+
export declare function resolveSpawn(cmd: string, args: readonly string[], env: Record<string, string | undefined>, platform?: NodeJS.Platform): Result<ResolvedSpawn>;
|
|
13
|
+
export declare const NO_CONSOLE_ENV = "WITNESS_NO_CONSOLE";
|
|
14
|
+
export declare function withoutConsole<T>(fn: () => T): T;
|
|
15
|
+
export declare const spawn: typeof cp.spawn;
|
|
16
|
+
export declare const spawnSync: typeof cp.spawnSync;
|
|
17
|
+
export declare const execFileSync: typeof cp.execFileSync;
|
|
18
|
+
export declare const execSync: typeof cp.execSync;
|
|
19
|
+
export declare function treeStop(pid: number, env: Record<string, string | undefined>): {
|
|
20
|
+
file: string;
|
|
21
|
+
args: string[];
|
|
22
|
+
};
|
package/dist/stamp.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Ctx } from './cli.js';
|
|
2
|
+
import { type StatusCause, type StatusEntry } from './journal.js';
|
|
3
|
+
import { type Canon, type CanonDoc } from './scan.js';
|
|
4
|
+
export interface PreparedStamp {
|
|
5
|
+
doc: CanonDoc;
|
|
6
|
+
to: string;
|
|
7
|
+
entry: StatusEntry;
|
|
8
|
+
line: string;
|
|
9
|
+
rel: string;
|
|
10
|
+
stream: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function prepareStamp(doc: CanonDoc, to: string, cause: StatusCause, extra?: Partial<StatusEntry>): PreparedStamp;
|
|
13
|
+
export declare function writeStamp(root: string, s: PreparedStamp): void;
|
|
14
|
+
export interface LazyResult {
|
|
15
|
+
stamped: Array<{
|
|
16
|
+
plan: string;
|
|
17
|
+
spec?: string;
|
|
18
|
+
pr: number;
|
|
19
|
+
}>;
|
|
20
|
+
stale: Array<{
|
|
21
|
+
plan: string;
|
|
22
|
+
why: string;
|
|
23
|
+
}>;
|
|
24
|
+
kept: string[];
|
|
25
|
+
}
|
|
26
|
+
export declare function prState(ctx: Ctx, root: string, pr: number): string | undefined;
|
|
27
|
+
export declare function lazyStamp(root: string, ctx: Ctx, canon: Canon): LazyResult;
|
package/dist/stamp.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { cliAct } from './act.js';
|
|
3
4
|
import { deferralMoves } from './deferral.js';
|
|
4
5
|
import { writeDoc } from './fm.js';
|
|
5
6
|
import { stateCommit } from './gitio.js';
|
|
@@ -47,7 +48,8 @@ export function lazyStamp(root, ctx, canon) {
|
|
|
47
48
|
continue;
|
|
48
49
|
}
|
|
49
50
|
if (state === 'CLOSED') {
|
|
50
|
-
|
|
51
|
+
// Row 239. The command the why names is an act's line.
|
|
52
|
+
result.stale.push({ plan: planId, why: `pr #${pr} closed unmerged — ${cliAct('abandon', planId).line}?` });
|
|
51
53
|
continue;
|
|
52
54
|
}
|
|
53
55
|
if (state !== 'MERGED') {
|
package/dist/steps.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Entry } from './journal.js';
|
|
2
|
+
import { type Violation } from './refusal.js';
|
|
3
|
+
import type { CanonDoc } from './scan.js';
|
|
4
|
+
export type StepKind = 'criteria' | 'scaffolding';
|
|
5
|
+
export interface StepState {
|
|
6
|
+
id: string;
|
|
7
|
+
kind: StepKind;
|
|
8
|
+
closedAt?: number;
|
|
9
|
+
}
|
|
10
|
+
export type Progress = {
|
|
11
|
+
known: true;
|
|
12
|
+
steps: StepState[];
|
|
13
|
+
done: number;
|
|
14
|
+
next?: StepState;
|
|
15
|
+
} | {
|
|
16
|
+
known: false;
|
|
17
|
+
};
|
|
18
|
+
export declare const hasCriteriaStep: (plan: CanonDoc) => boolean;
|
|
19
|
+
export declare const vacuousEvidence: (e: Entry) => boolean;
|
|
20
|
+
export declare function closingIndex(step: Pick<StepState, 'id' | 'kind'>, entries: Entry[]): number | undefined;
|
|
21
|
+
export declare function implementGated(entries: Entry[]): boolean;
|
|
22
|
+
export declare function stepProgress(plan: CanonDoc, entries: Entry[]): Progress;
|
|
23
|
+
export declare function closedAt(p: Progress, index: number): string | undefined;
|
|
24
|
+
export declare function redInFlight(entries: Entry[]): boolean;
|
|
25
|
+
export declare function greenOwedOn(entries: Entry[], stepId: string): boolean;
|
|
26
|
+
export declare function redCycleClosed(entries: Entry[]): boolean;
|
|
27
|
+
export declare function greenOwedStep(plan: CanonDoc, entries: Entry[]): string | undefined;
|
|
28
|
+
export declare function lastRedVacuous(entries: Entry[], stepId: string): boolean;
|
|
29
|
+
export declare function stepsLine(p: Progress): string;
|
|
30
|
+
export declare function checkStep(plan: CanonDoc, entries: Entry[], step: string | undefined, verb: 'evidence' | 'close'): Violation[];
|
package/dist/steps.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { cliAct } from './act.js';
|
|
1
2
|
import { v } from './refusal.js';
|
|
3
|
+
import { shellWord } from './toon.js';
|
|
2
4
|
const manifest = (plan) => (Array.isArray(plan.meta.steps) ? plan.meta.steps : [])
|
|
3
5
|
.filter((s) => typeof s === 'object' && s !== null)
|
|
4
6
|
.map((s) => ({ id: String(s.id), kind: s.scaffolding === true ? 'scaffolding' : 'criteria' }));
|
|
@@ -156,17 +158,20 @@ export function checkStep(plan, entries, step, verb) {
|
|
|
156
158
|
? [v('--step', 'step-required', 'absent', `--step <id> — every cycle before the first implement gate is a plan step's · steps ${stepsLine(p)}`)]
|
|
157
159
|
: [];
|
|
158
160
|
}
|
|
161
|
+
// Row 239. A shape quotes its foreign word, and the prose after it stays as it reads.
|
|
159
162
|
const scaffolding = steps.filter((s) => s.kind === 'scaffolding').map((s) => s.id).join(' · ');
|
|
160
|
-
|
|
163
|
+
const close = `witness step-close ${shellWord(id)} --step <id>`;
|
|
164
|
+
return [v('--step', 'required', 'absent', `${close} — a scaffolding step of ${id}: ${scaffolding || '(none)'}`)];
|
|
161
165
|
}
|
|
162
166
|
const s = steps.find((x) => x.id === step);
|
|
163
167
|
if (s === undefined)
|
|
164
168
|
return [v('--step', 'unknown-step', step, `a step of ${id}: ${steps.map((x) => x.id).join(' · ')}`)];
|
|
169
|
+
// Row 239. The command each want names is an act's line.
|
|
165
170
|
if (verb === 'evidence' && s.kind === 'scaffolding') {
|
|
166
|
-
return [v('--step', 'scaffolding-step', step,
|
|
171
|
+
return [v('--step', 'scaffolding-step', step, `${cliAct('step-close', id, '--step', step).line} — a scaffolding step closes without evidence`)];
|
|
167
172
|
}
|
|
168
173
|
if (verb === 'close' && s.kind === 'criteria') {
|
|
169
|
-
return [v('--step', 'criteria-step', step,
|
|
174
|
+
return [v('--step', 'criteria-step', step, `${cliAct('test-evidence', id, '--phase', 'red', '--step', step).line} — a criteria step closes at its red→green`)];
|
|
170
175
|
}
|
|
171
176
|
return [];
|
|
172
177
|
}
|
package/dist/toon.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const hasControl: (s: string) => boolean;
|
|
2
|
+
export declare const visible: (s: string) => string;
|
|
3
|
+
export declare const shellArg: (p: string) => string;
|
|
4
|
+
export declare const psArg: (p: string) => string;
|
|
5
|
+
export type Platform = NodeJS.Platform;
|
|
6
|
+
export declare function shellWord(w: string, platform?: Platform): string;
|
|
7
|
+
export declare function quotedWord(w: string, platform?: Platform): string;
|
|
8
|
+
export declare function shellWordExact(w: string, platform?: Platform): string;
|
|
9
|
+
export declare function shellLine(argv: readonly string[], platform?: Platform): string;
|
|
10
|
+
export declare function withheldOn(words: readonly string[], platform?: Platform): string | undefined;
|
|
11
|
+
export declare function offeredLine(argv: readonly string[], platform?: Platform): string | undefined;
|
|
12
|
+
export declare function shellWords(line: string): string[] | undefined;
|
|
13
|
+
export declare const logSafe: (s: string) => string;
|
|
14
|
+
export declare function kv(key: string, value: unknown): string;
|
|
15
|
+
export declare function cmd(key: string, command: string): string;
|
|
16
|
+
export declare function list(key: string, values: unknown[]): string;
|
|
17
|
+
export declare function rows(key: string, fields: string[], items: Array<Record<string, unknown>>): string[];
|
package/dist/toon.js
CHANGED
|
@@ -1,23 +1,159 @@
|
|
|
1
|
+
// Row 239. Each shell's quoting that nothing reads through, the one copy of each: inside POSIX
|
|
2
|
+
// single quotes no character is special, so a `'` is written `'\''` (close, an escaped quote,
|
|
3
|
+
// reopen); inside PowerShell's nothing expands, and a single quote is written twice. The one
|
|
4
|
+
// exception is the canon guard, which ships alone and imports nothing from witness:
|
|
5
|
+
// plugin/hooks/canon-guard.mjs carries a twin of `shellWord` and `withheldOn` and all they read,
|
|
6
|
+
// and tests/canon-guard.test.ts holds it equal to these. Change both or neither.
|
|
7
|
+
const posixQuoted = (p) => `'${p.replaceAll("'", "'\\''")}'`;
|
|
8
|
+
const psQuoted = (p) => `'${p.replace(/['‘’‚‛]/g, (q) => q + q)}'`;
|
|
9
|
+
// One character spelled out: the one spelling `shellWord`, `visible` and `logSafe` share.
|
|
10
|
+
const spell = (c) => c === '\n' ? '\\n' : c === '\r' ? '\\r' : c === '\t' ? '\\t'
|
|
11
|
+
: c.codePointAt(0) < 0x100 ? `\\x${c.codePointAt(0).toString(16).padStart(2, '0')}` : `\\u{${c.codePointAt(0).toString(16)}}`;
|
|
12
|
+
// A command a human is asked to trust, or any word offered to be pasted, is repo-authored text: a
|
|
13
|
+
// carriage return or an escape sequence could paint a different command over the real one, a bidi
|
|
14
|
+
// override reorder it (Trojan Source), an invisible filler hide a second command beside it. A
|
|
15
|
+
// denylist always misses one, so the rule is an allowlist: printable ASCII shows as it is, anything
|
|
16
|
+
// else is spelled out (rows 205/237, ruling R27), and a word carrying any of it is never offered.
|
|
17
|
+
const UNSHOWABLE = /[^\x20-\x7e]/u;
|
|
18
|
+
export const hasControl = (s) => UNSHOWABLE.test(s);
|
|
19
|
+
export const visible = (s) => s.replace(new RegExp(UNSHOWABLE.source, 'gu'), spell);
|
|
20
|
+
// Row 239 (ruling R24). The subset of the unshowable that would split the line a word prints on: a
|
|
21
|
+
// control character (a newline, a carriage return, a tab, ESC, a C1 control) or the line and
|
|
22
|
+
// paragraph separators U+2028/U+2029, which editors and some terminals render as a line break. A
|
|
23
|
+
// physical line that starts `run:` is a line the skills run. Its message takes precedence in
|
|
24
|
+
// `withheldOn`, since it is the sharper reason, but every unshowable word is withheld all the same.
|
|
25
|
+
const LINE_BREAKING = /[\p{Cc}\p{Zl}\p{Zp}]/u;
|
|
1
26
|
// A shell word is quoted only when it needs it, so the common line stays the one a human
|
|
2
|
-
// types — a path in drive's watch line, a command in a `--cmd` grant (row 205).
|
|
3
|
-
|
|
27
|
+
// types — a path in drive's watch line, a command in a `--cmd` grant (row 205). Row 239: never
|
|
28
|
+
// bare when it starts with `=`, which zsh's EQUALS option, on by default, reads as the path of a
|
|
29
|
+
// command (probed: a bare `=ls` reached the program as `/bin/ls`).
|
|
30
|
+
export const shellArg = (p) => /^(?!=)[\w@%+=:,./-]+$/.test(p) ? p : posixQuoted(p);
|
|
4
31
|
// Row 214. The same rule for a PowerShell word — drive's Windows watch line. Bare only when no
|
|
5
32
|
// character in it means anything to PowerShell: a bare `,` builds an array, a leading `@` splats
|
|
6
33
|
// and a leading `-` binds as a parameter, so none of them is bare here as in a POSIX word. Else
|
|
7
34
|
// single-quoted, where nothing expands and the one special character is a single quote — any of
|
|
8
35
|
// the five PowerShell reads as one (' ‘ ’ ‚ ‛) — written twice.
|
|
9
|
-
export const psArg = (p) => /^[\w%+=:./\\][\w%+=:./\\-]*$/.test(p) ? p :
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// One
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
export const psArg = (p) => /^[\w%+=:./\\][\w%+=:./\\-]*$/.test(p) ? p : psQuoted(p);
|
|
37
|
+
const WINDOWS_FLAG = /^--?[A-Za-z][A-Za-z0-9-]*$/;
|
|
38
|
+
// The quoting alone, for a word taken as given: bare in the platform's safe set, else quoted.
|
|
39
|
+
function quoteWord(w, platform) {
|
|
40
|
+
if (platform !== 'win32')
|
|
41
|
+
return shellArg(w);
|
|
42
|
+
return WINDOWS_FLAG.test(w) ? w : w.includes('\\') ? psQuoted(w) : psArg(w);
|
|
43
|
+
}
|
|
44
|
+
// Row 239. One quoter for every word witness prints on a line offered to be pasted. Off Windows the
|
|
45
|
+
// line is pasted into bash, zsh or dash and a word prints as `shellArg` prints it; on win32 into
|
|
46
|
+
// PowerShell and it prints as `psArg` prints it, but for a flag (B2) and a `\` word (R22). Ruling
|
|
47
|
+
// R27: every character outside printable ASCII is spelled out first (`visible`), as the trust grant
|
|
48
|
+
// has shown a command since rows 205/237 — a byte above 0x7f is a Meta key to an interactive shell's
|
|
49
|
+
// line editor (probed), and a control character splits the line (R24). Such a word is withheld
|
|
50
|
+
// (`withheldOn`), so this spelled form is only ever shown, never pasted, and need not be exact.
|
|
51
|
+
export function shellWord(w, platform = process.platform) {
|
|
52
|
+
return quoteWord(visible(w), platform);
|
|
53
|
+
}
|
|
54
|
+
// Row 239. Every word quoted, safe or not, as the handoff prints its path and `/witness`.
|
|
55
|
+
export function quotedWord(w, platform = process.platform) {
|
|
56
|
+
return platform === 'win32' ? psQuoted(w) : posixQuoted(w);
|
|
57
|
+
}
|
|
58
|
+
// Row 239 (ruling R27). The quoting with the bytes kept, for the one line a foreign word never
|
|
59
|
+
// reaches and that is never withheld: the watch line's local log path (the plan's B5). It holds no
|
|
60
|
+
// `$(…)`, so an interactive shell's line editor can rearrange it but run nothing, and a human needs
|
|
61
|
+
// the real path to read. The handoff's path is kept the same way, through `quotedWord`.
|
|
62
|
+
export function shellWordExact(w, platform = process.platform) {
|
|
63
|
+
return quoteWord(w, platform);
|
|
64
|
+
}
|
|
65
|
+
// Row 239. Another tool's command as a line to paste.
|
|
66
|
+
export function shellLine(argv, platform = process.platform) {
|
|
67
|
+
return argv.map((w) => shellWord(w, platform)).join(' ');
|
|
68
|
+
}
|
|
69
|
+
// Row 239. Why a command is not offered to be pasted, or `undefined` when it is. Ruling R24: on every
|
|
70
|
+
// platform, a word holding a character that would split the line (`LINE_BREAKING`) withholds it,
|
|
71
|
+
// whatever else the word holds. On Windows a pasted line can reach cmd.exe after PowerShell, because
|
|
72
|
+
// npm's `witness.cmd` and `npx.cmd` shims pass their arguments through it. PowerShell passes a word
|
|
73
|
+
// holding no space unquoted, and cmd.exe then reads `&`, `|`, `<` and `>` in it as new commands or
|
|
74
|
+
// redirections, `^` as its escape, and `%NAME%` (`!NAME!` under delayed expansion) as a variable.
|
|
75
|
+
// Windows PowerShell 5.1 also passes an embedded `"` unescaped, which moves cmd.exe's argument
|
|
76
|
+
// boundaries. No quoting reads as text to both, so a command holding any of these is shown and never
|
|
77
|
+
// offered (the user's call, 2026-11-04: "Refuse risky words now"). Ruling R22: nor one holding a
|
|
78
|
+
// quote-like, which PowerShell's quoting writes twice and Git Bash, where the skills run a line, reads
|
|
79
|
+
// as strings side by side (probed: a grant of `echo 'x; …'` named `echo x; …` there). Elsewhere the
|
|
80
|
+
// quoter alone makes every word text.
|
|
81
|
+
const WINDOWS_RISKY = ['&', '|', '^', '<', '>', '"', '%', '!'];
|
|
82
|
+
const QUOTE_LIKES = ["'"];
|
|
83
|
+
export function withheldOn(words, platform = process.platform) {
|
|
84
|
+
if (words.some((w) => LINE_BREAKING.test(w)))
|
|
85
|
+
return 'not offered — it holds a control or line-break character, which would split the line';
|
|
86
|
+
if (words.some((w) => hasControl(w)))
|
|
87
|
+
return "not offered — it holds a character outside printable ASCII, which a terminal's line editor can read as a command";
|
|
88
|
+
if (platform !== 'win32')
|
|
89
|
+
return undefined;
|
|
90
|
+
const held = (set) => set.filter((c) => words.some((w) => w.includes(c)));
|
|
91
|
+
const risky = held(WINDOWS_RISKY);
|
|
92
|
+
const quotes = held(QUOTE_LIKES);
|
|
93
|
+
const why = [
|
|
94
|
+
...(risky.length > 0 ? [`${risky.join(' ')}, which cmd.exe or Windows PowerShell can read as more than text`] : []),
|
|
95
|
+
...(quotes.length > 0 ? [`${quotes.join(' ')}, which PowerShell and Git Bash read differently`] : []),
|
|
96
|
+
];
|
|
97
|
+
return why.length === 0 ? undefined : `not offered on Windows — it holds ${why.join(', and ')}`;
|
|
98
|
+
}
|
|
99
|
+
// Row 239. Another tool's command as a line offered to be pasted, unless it is withheld.
|
|
100
|
+
export function offeredLine(argv, platform = process.platform) {
|
|
101
|
+
return withheldOn(argv, platform) === undefined ? shellLine(argv, platform) : undefined;
|
|
102
|
+
}
|
|
103
|
+
// Row 239. A line read back into its words, as a human types an answer at drive's `decide>`: a
|
|
104
|
+
// POSIX shell's quoting with nothing expanded, so a line `shellLine` printed reads back as the
|
|
105
|
+
// words it was made of. An unquoted space or tab ends a word; `'…'` is literal; inside `"…"` a
|
|
106
|
+
// backslash escapes only `"`, `\`, `$` and `` ` ``; outside quotes `\x` is `x`. A line an open
|
|
107
|
+
// quote or a trailing backslash leaves unfinished reads as `undefined`, never as a guess.
|
|
108
|
+
export function shellWords(line) {
|
|
109
|
+
const words = [];
|
|
110
|
+
let cur = '';
|
|
111
|
+
let started = false;
|
|
112
|
+
let quote;
|
|
113
|
+
let escaped = false;
|
|
114
|
+
for (const ch of line) {
|
|
115
|
+
if (escaped) {
|
|
116
|
+
cur += quote === '"' && !'"\\$`'.includes(ch) ? `\\${ch}` : ch;
|
|
117
|
+
escaped = false;
|
|
118
|
+
}
|
|
119
|
+
else if (quote === "'") {
|
|
120
|
+
if (ch === "'")
|
|
121
|
+
quote = undefined;
|
|
122
|
+
else
|
|
123
|
+
cur += ch;
|
|
124
|
+
}
|
|
125
|
+
else if (ch === '\\') {
|
|
126
|
+
escaped = true;
|
|
127
|
+
started = true;
|
|
128
|
+
}
|
|
129
|
+
else if (quote === '"') {
|
|
130
|
+
if (ch === '"')
|
|
131
|
+
quote = undefined;
|
|
132
|
+
else
|
|
133
|
+
cur += ch;
|
|
134
|
+
}
|
|
135
|
+
else if (ch === "'" || ch === '"') {
|
|
136
|
+
quote = ch;
|
|
137
|
+
started = true;
|
|
138
|
+
}
|
|
139
|
+
else if (ch === ' ' || ch === '\t') {
|
|
140
|
+
if (started) {
|
|
141
|
+
words.push(cur);
|
|
142
|
+
cur = '';
|
|
143
|
+
started = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
cur += ch;
|
|
148
|
+
started = true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (quote !== undefined || escaped)
|
|
152
|
+
return undefined;
|
|
153
|
+
if (started)
|
|
154
|
+
words.push(cur);
|
|
155
|
+
return words;
|
|
156
|
+
}
|
|
21
157
|
// Row 214. What a session drive runs wrote, on the human's terminal and in .witness/drive.log: the
|
|
22
158
|
// same paint-over and reorder attacks, from text an agent controls (a command, a path, its prose).
|
|
23
159
|
// Nobody grants a log line, so the rule is narrower than `visible`'s — control and format
|
package/dist/txn.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Ctx } from './cli.js';
|
|
2
|
+
import { type Result } from './refusal.js';
|
|
3
|
+
export interface TxnMarker {
|
|
4
|
+
op: string;
|
|
5
|
+
files: string[];
|
|
6
|
+
journal?: {
|
|
7
|
+
stream: string;
|
|
8
|
+
line: string;
|
|
9
|
+
};
|
|
10
|
+
journalMulti?: Array<{
|
|
11
|
+
stream: string;
|
|
12
|
+
line: string;
|
|
13
|
+
}>;
|
|
14
|
+
pid?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function pendingTxn(root: string): TxnMarker | undefined;
|
|
17
|
+
export declare function crashPoint(env: Record<string, string | undefined>, name: string): void;
|
|
18
|
+
export declare function withTxn<T>(root: string, marker: TxnMarker, fn: () => Result<T>): Result<T>;
|
|
19
|
+
export declare function rollbackTxn(root: string, marker: TxnMarker): void;
|
|
20
|
+
export declare function landedJournal(root: string, marker: TxnMarker): Array<{
|
|
21
|
+
stream: string;
|
|
22
|
+
lines: string[];
|
|
23
|
+
landed: number;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function completeTxn(root: string, marker: TxnMarker): Result<{
|
|
26
|
+
sha: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function guardTxn(ctx: Ctx, root: string): number | undefined;
|
package/dist/usage.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type Limit = {
|
|
2
|
+
kind: 'usage';
|
|
3
|
+
text: string;
|
|
4
|
+
resetAt?: number;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'transient';
|
|
7
|
+
text: string;
|
|
8
|
+
};
|
|
9
|
+
export interface Clock {
|
|
10
|
+
now(): number;
|
|
11
|
+
sleep(ms: number): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const realClock: Clock;
|
|
14
|
+
export declare const USAGE_MARGIN_MS = 60000;
|
|
15
|
+
export declare const SINGLE_WAIT_MAX_MS = 21600000;
|
|
16
|
+
export declare const TOTAL_WAIT_MAX_MS = 43200000;
|
|
17
|
+
export declare function limitIn(text: string, now: number): Limit | undefined;
|
|
18
|
+
export declare function sessionLimit(end: {
|
|
19
|
+
code: number | null;
|
|
20
|
+
tail: readonly string[];
|
|
21
|
+
failed?: boolean;
|
|
22
|
+
outcome?: string;
|
|
23
|
+
}, now: number): Limit | undefined;
|
|
24
|
+
export declare function waitFor(limit: Limit, streak: number, now: number): number;
|
|
25
|
+
export declare function duration(ms: number): string;
|
package/dist/verbs/adopt.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { cliAct } from '../act.js';
|
|
2
3
|
import { adoptedCommitsFor, lastWitnessed, positionOf, untrailedCommitsFor } from '../adopt.js';
|
|
3
4
|
import { EXIT } from '../cli.js';
|
|
4
5
|
import { canonPaths } from '../config.js';
|
|
@@ -13,7 +14,7 @@ import { idRetired, pathRetired } from '../departure.js';
|
|
|
13
14
|
import { findById, findCycle, loadCanon } from '../scan.js';
|
|
14
15
|
import { validateDoc } from '../schemas.js';
|
|
15
16
|
import { canonicalJson, canonicalSha, short, VOLATILE_FIELDS } from '../sha.js';
|
|
16
|
-
import { kv } from '../toon.js';
|
|
17
|
+
import { kv, shellLine } from '../toon.js';
|
|
17
18
|
import { crashPoint, guardTxn, withTxn } from '../txn.js';
|
|
18
19
|
export async function run(ctx, argv) {
|
|
19
20
|
const [rel] = argv.filter((a) => !a.startsWith('--'));
|
|
@@ -62,7 +63,9 @@ export async function run(ctx, argv) {
|
|
|
62
63
|
violations.push(...positionMoves(root, rel, id, meta));
|
|
63
64
|
if (violations.length) {
|
|
64
65
|
renderRefusal(violations).forEach(ctx.err);
|
|
65
|
-
|
|
66
|
+
// Row 239. `rel` is the caller's argument, a repo file name a commit chose: the revert is
|
|
67
|
+
// another tool's command, through the one renderer.
|
|
68
|
+
ctx.err(`help: fix the file and re-run, or revert instead: ${shellLine(['git', 'checkout', 'HEAD', '--', rel])}`);
|
|
66
69
|
return EXIT.REFUSED;
|
|
67
70
|
}
|
|
68
71
|
const witnessed = lastWitnessed(root, rel);
|
|
@@ -126,7 +129,8 @@ export async function run(ctx, argv) {
|
|
|
126
129
|
const held = reverify ? reverify.criteria.filter((c) => c.held !== undefined).length : 0;
|
|
127
130
|
if (reverify)
|
|
128
131
|
ctx.out(kv('reverify', reverify.ok ? `lane green${held > 0 ? ` · ${held} held` : ''} — stays live` : 'lane RED — drift stamped immediately (hand-edit, no debounce)'));
|
|
129
|
-
|
|
132
|
+
// Row 239. The log the help names is an act's line.
|
|
133
|
+
ctx.out(`help: history: ${cliAct('log', id).line}`);
|
|
130
134
|
return reverify && !reverify.ok ? EXIT.FINDINGS : EXIT.OK;
|
|
131
135
|
}
|
|
132
136
|
// Row 220 (#65). Position — status, drift, pr, design — is written by the CLI's own transitions
|
|
@@ -140,7 +144,8 @@ function positionMoves(root, rel, id, meta) {
|
|
|
140
144
|
const was = seen?.position ?? positionOf({ status: 'draft' });
|
|
141
145
|
const now = positionOf(meta);
|
|
142
146
|
const shown = (x) => (x === undefined ? '(none)' : typeof x === 'string' ? x : canonicalJson(x));
|
|
147
|
+
// Row 239: the revert is another tool's command, through the one renderer, as adopt's help.
|
|
143
148
|
return VOLATILE_FIELDS.filter((f) => canonicalJson(was[f]) !== canonicalJson(now[f])).map((f) => v(f, 'position-moved', `${shown(was[f])} → ${shown(now[f])}`, seen !== undefined
|
|
144
|
-
? `position is written by the CLI — set ${f} back to ${shown(was[f])}, or revert the file: git checkout
|
|
149
|
+
? `position is written by the CLI — set ${f} back to ${shown(was[f])}, or revert the file: ${shellLine(['git', 'checkout', short(seen.commit), '--', rel])}`
|
|
145
150
|
: `position is written by the CLI — a doc adopt has never seen is born ${f === 'status' ? 'status: draft' : `draft, with no ${f}`}`));
|
|
146
151
|
}
|