@nodii/dev 0.6.72 → 0.6.74
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 +150 -7
- package/dist/cli.js +84 -16
- package/dist/core.js +2 -2
- package/dist/design.js +46 -2
- package/dist/doctor.js +17 -7
- package/dist/figma.js +44 -0
- package/dist/flags.js +5 -1
- package/dist/freeze.js +12 -0
- package/dist/gather.js +51 -23
- package/dist/harness.js +8 -4
- package/dist/hooks.js +1 -25
- package/dist/lanes.js +74 -23
- package/dist/managed-hooks.js +60 -9
- package/dist/nudges.js +166 -2
- package/dist/receipt.js +365 -0
- package/dist/review.js +76 -4
- package/dist/safety.js +8 -1
- package/dist/session-kind.js +243 -0
- package/dist/setup.js +8 -6
- package/dist/surface.js +847 -0
- package/dist/vendor/render-templates.mjs +740 -0
- package/package.json +1 -1
package/dist/figma.js
CHANGED
|
@@ -708,6 +708,50 @@ export async function figmaPublishPlan(value, { request = devRequest, sleep = de
|
|
|
708
708
|
return planJobOutcome(job);
|
|
709
709
|
}
|
|
710
710
|
|
|
711
|
+
// The whole-file Surfaces check (DESIGN-SYSTEM-253): Dev reads every Surface of
|
|
712
|
+
// the file as a job, a few at a time at Figma's pace, so the POST answers 202 and
|
|
713
|
+
// the job is polled until it ends, as the publish plan is.
|
|
714
|
+
const SURFACES_JOB_WAIT_MS = 65 * 60_000;
|
|
715
|
+
const surfacesJobPath = (key, id) => `/api/v1/design/files/${encode(key)}/surfaces-check/jobs/${encode(id)}`;
|
|
716
|
+
|
|
717
|
+
/** A finished Surfaces check job as its report, or the refusal Dev ended it with. */
|
|
718
|
+
export function surfacesJobOutcome(job) {
|
|
719
|
+
if (job.state === "succeeded") return job.result;
|
|
720
|
+
const e = job.error ?? {};
|
|
721
|
+
if (e.code === "SURFACES_CHECK_JOB_LOST") throw new CliError(e.code, `${e.message ?? "Dev lost this job"} (job ${job.id} on ${job.fileKey}). Run the same command again.`, 1, e.details);
|
|
722
|
+
throw new CliError(!e.code || GATEWAY.has(e.code) ? "SURFACES_CHECK_JOB_FAILED" : e.code, e.message ?? `Dev's Surfaces check job ${job.id} failed with HTTP ${job.httpStatus}`, 1, e.details);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/** Starts or joins the file's Surfaces check (startDesignSurfacesCheck) and polls it until it ends. */
|
|
726
|
+
export async function surfacesCheck(value, { request = devRequest, sleep = delay, progress = stderrLine, now = Date.now } = {}) {
|
|
727
|
+
const key = figmaFileKey(value);
|
|
728
|
+
const call = fileCall(key, request);
|
|
729
|
+
let job = (await call("POST", `/api/v1/design/files/${encode(key)}/surfaces-check`, {})).data;
|
|
730
|
+
const start = now();
|
|
731
|
+
let printed = start;
|
|
732
|
+
let misses = 0;
|
|
733
|
+
for (let n = 0; !DONE.has(job.state); n++) {
|
|
734
|
+
if (now() - start > SURFACES_JOB_WAIT_MS)
|
|
735
|
+
throw new CliError("SURFACES_CHECK_JOB_TIMEOUT", `Dev's Surfaces check job ${job.id} on ${key} is still running after ${Math.round(SURFACES_JOB_WAIT_MS / 60_000)} minutes. Run the same command again to join it.`, 1);
|
|
736
|
+
await sleep(JOB_POLL_MS[Math.min(n, JOB_POLL_MS.length - 1)]);
|
|
737
|
+
try {
|
|
738
|
+
job = (await call("GET", surfacesJobPath(key, job.id))).data;
|
|
739
|
+
misses = 0;
|
|
740
|
+
} catch (error) {
|
|
741
|
+
if (!TRANSIENT.has(error?.code)) throw error;
|
|
742
|
+
if (++misses > 5) throw new CliError("SURFACES_CHECK_JOB_UNREACHABLE", `Lost touch with Dev (${error.code}) while its Surfaces check job ${job.id} on ${key} runs. Run the same command again to join it.`, 1);
|
|
743
|
+
progress(`polling ${job.id} again (${error.code})`);
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
if (!DONE.has(job.state) && now() - printed >= JOB_PROGRESS_MS) {
|
|
747
|
+
printed = now();
|
|
748
|
+
const done = job.progress ? `, ${job.progress.checked} of ${job.progress.total} Surfaces checked` : "";
|
|
749
|
+
progress(`${key}: Surfaces check job ${job.id} still running (${Math.round((printed - start) / 1000)} s${done})`);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return surfacesJobOutcome(job);
|
|
753
|
+
}
|
|
754
|
+
|
|
711
755
|
const planLine = (x) => ` ${x.nodeId ?? (x.kind ? scopeText(x) : "(no node)")} ${x.name ?? ""} (${x.changeSetId} ${x.state}${x.title ? `: ${x.title}` : ""})`;
|
|
712
756
|
|
|
713
757
|
/** The publish plan as two groups: what to publish, and what to leave unchecked in Figma's publish dialog. */
|
package/dist/flags.js
CHANGED
|
@@ -30,7 +30,10 @@ export const COMMAND_FLAGS = {
|
|
|
30
30
|
"lane amend": ["objective", "scope", "rules", "reason"],
|
|
31
31
|
"lane start": ["key", "issue", "title", "kind", "side", "repo", "branch", "worktree", "step-limit"],
|
|
32
32
|
"lane step": ["side", "start", "done", "block", "not-applicable", "reason", "reason-code", "note", "review", "delta"],
|
|
33
|
-
"lane evidence": ["pr", "commit", "figma", "deploy", "dev-check"],
|
|
33
|
+
"lane evidence": ["pr", "commit", "figma", "deploy", "dev-check", "file"],
|
|
34
|
+
"receipt write": ["kind", "lane", "commit", "run", "from-file", "out"],
|
|
35
|
+
"receipt verify": ["commit"],
|
|
36
|
+
"sync pending": ["discard", "reason"],
|
|
34
37
|
"lane done-check": ["evidence"],
|
|
35
38
|
"lane heartbeat": ["note"],
|
|
36
39
|
"lane resume": ["override", "reason", "host-lost", "min-free-gb", "stagger-seconds", "profile", "class"],
|
|
@@ -54,6 +57,7 @@ export const COMMAND_FLAGS = {
|
|
|
54
57
|
"figma abandon": ["file"],
|
|
55
58
|
"figma apply": ["file", "figma-version"],
|
|
56
59
|
"figma lock": ["title", "scope"],
|
|
60
|
+
"surface generate": ["write", "check", "fetch", "all", "module", "type", "figma-version", "report"],
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
/** Refuse a flag the command does not declare (USAGE, exit 2), naming the valid ones. */
|
package/dist/freeze.js
CHANGED
|
@@ -266,6 +266,18 @@ export async function regroundCurrentLane(
|
|
|
266
266
|
) {
|
|
267
267
|
const lane = await currentLane({ cwd }, { request, config });
|
|
268
268
|
if (!lane) return { shown: false, reason: "no active lane" };
|
|
269
|
+
return regroundLane(lane, { force, write }, { request });
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Re-ground one known lane: a worktree's lane, or a steward's, which has no
|
|
274
|
+
* worktree and is found by its agent (MW1-94).
|
|
275
|
+
*/
|
|
276
|
+
export async function regroundLane(
|
|
277
|
+
lane,
|
|
278
|
+
{ force = false, write = (text) => process.stderr.write(text) } = {},
|
|
279
|
+
{ request = devRequest } = {},
|
|
280
|
+
) {
|
|
269
281
|
const response = await request(
|
|
270
282
|
"GET",
|
|
271
283
|
`/api/v1/lanes/${encode(lane.key)}/freeze`,
|
package/dist/gather.js
CHANGED
|
@@ -122,21 +122,41 @@ async function jsonRequest(path, { baseUrl = ollamaUrl(), fetchImpl = fetch, tim
|
|
|
122
122
|
return payload;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
const PINNED =
|
|
125
|
+
const PINNED = TUNING_MODELS["gemma-12b"];
|
|
126
|
+
|
|
127
|
+
/** Names the picker may be set to: the 12B default and every pinned tuning model. */
|
|
128
|
+
export const PICKER_MODEL_NAMES = Object.values(TUNING_MODELS).map((x) => x.name);
|
|
129
|
+
/** The environment variable that picks this machine's Gather model. */
|
|
130
|
+
export const PICKER_MODEL_ENV = "NODII_DEV_PICKER_MODEL";
|
|
131
|
+
/** The picker model name this machine is set to: the variable, else the 12B default. Never throws. */
|
|
132
|
+
export function pickerModelName(env = process.env) {
|
|
133
|
+
const value = env?.[PICKER_MODEL_ENV];
|
|
134
|
+
return typeof value === "string" && value.trim() ? value.trim() : PICKER_MODEL;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The pinned picker this machine uses (name and accepted digests). Only models
|
|
138
|
+
* the CLI pins are accepted, so a typo fails here, not as a silent unpinned pull.
|
|
139
|
+
*/
|
|
140
|
+
export function pickerPin(env = process.env) {
|
|
141
|
+
const name = pickerModelName(env);
|
|
142
|
+
const pin = Object.values(TUNING_MODELS).find((x) => x.name === name);
|
|
143
|
+
if (!pin) throw new CliError("USAGE", `${PICKER_MODEL_ENV} is ${name}, which this CLI does not pin. Use one of: ${PICKER_MODEL_NAMES.join(", ")} (default ${PICKER_MODEL}), or unset it.`, 2, { allowed: PICKER_MODEL_NAMES });
|
|
144
|
+
return pin;
|
|
145
|
+
}
|
|
126
146
|
// Ollama's /api/tags reports the manifest digest as bare hex; the pin carries
|
|
127
147
|
// the registry's `sha256:` form. Compare them without the algorithm prefix.
|
|
128
148
|
const bareDigest = (digest) => typeof digest === "string" ? digest.replace(/^sha256:/, "") : null;
|
|
129
149
|
// A pin names one digest, or an allowlist of registry builds of the same tag.
|
|
130
|
-
const pinDigests = (pin) => pin.digests ?? [pin.digest];
|
|
150
|
+
export const pinDigests = (pin) => pin.digests ?? [pin.digest];
|
|
131
151
|
/** The accepted digest(s) of a pin, for messages: "X" or "X or Y". */
|
|
132
|
-
export const pinnedDigests = (pin =
|
|
152
|
+
export const pinnedDigests = (pin = pickerPin()) => pinDigests(pin).join(" or ");
|
|
133
153
|
/** The accepted gemma4:12b build a digest is, or null when it is not one of them. */
|
|
134
154
|
export function pickerBuild(digest) {
|
|
135
155
|
return PICKER_MODEL_BUILDS.find((x) => bareDigest(x.digest) === bareDigest(digest)) ?? null;
|
|
136
156
|
}
|
|
137
157
|
|
|
138
158
|
export async function inspectOllama(options = {}) {
|
|
139
|
-
const pin = options.model ??
|
|
159
|
+
const pin = options.model ?? pickerPin();
|
|
140
160
|
const [version, tags, ps] = await Promise.all([
|
|
141
161
|
jsonRequest("/api/version", options),
|
|
142
162
|
jsonRequest("/api/tags", options),
|
|
@@ -159,9 +179,9 @@ export async function inspectOllama(options = {}) {
|
|
|
159
179
|
}
|
|
160
180
|
|
|
161
181
|
export async function requirePicker(options = {}) {
|
|
162
|
-
const pin = options.model ??
|
|
182
|
+
const pin = options.model ?? pickerPin();
|
|
163
183
|
// setup pulls only the 12B Gather default; tuning-only models are pulled by hand.
|
|
164
|
-
const fix = pin.name ===
|
|
184
|
+
const fix = pin.name === pickerModelName() ? "Run `nodii-dev setup --yes`" : `Run \`ollama pull ${pin.name}\``;
|
|
165
185
|
const status = await inspectOllama(options);
|
|
166
186
|
if (!status.modelInstalled)
|
|
167
187
|
throw new CliError("PICKER_MODEL_MISSING", `Local Gather picker is missing ${pin.name}. ${fix} to pull it.`, 1, status);
|
|
@@ -176,7 +196,7 @@ export async function requirePicker(options = {}) {
|
|
|
176
196
|
*/
|
|
177
197
|
export async function warmPicker(options = {}) {
|
|
178
198
|
const status = await requirePicker(options);
|
|
179
|
-
const model = (options.model ??
|
|
199
|
+
const model = (options.model ?? pickerPin()).name;
|
|
180
200
|
// Ollama keeps the context a model was loaded with; a later num_ctx does not
|
|
181
201
|
// reload it (hub-58: resident at 262144). Unload a wrong-context copy first.
|
|
182
202
|
if (status.loadedContext !== null && status.loadedContext !== PICKER_CONTEXT) await unloadPicker(model, options);
|
|
@@ -217,7 +237,7 @@ export function gatherDeadline(ms) {
|
|
|
217
237
|
};
|
|
218
238
|
}
|
|
219
239
|
|
|
220
|
-
function pickerPrompt({ objective, files = [], triggers }, schema) {
|
|
240
|
+
export function pickerPrompt({ objective, files = [], triggers }, schema) {
|
|
221
241
|
return [
|
|
222
242
|
"Select every rule document that applies to this software task.",
|
|
223
243
|
schema
|
|
@@ -233,13 +253,18 @@ function pickerPrompt({ objective, files = [], triggers }, schema) {
|
|
|
233
253
|
|
|
234
254
|
const forced = (trigger) => Array.isArray(trigger?.forcedBy) ? trigger.forcedBy.length > 0 : Boolean(trigger?.forcedBy);
|
|
235
255
|
|
|
256
|
+
const budgetText = (ms) => (ms >= 1000 ? `${Math.round(ms / 1000)} s` : `${ms} ms`);
|
|
257
|
+
|
|
236
258
|
/**
|
|
237
259
|
* Why a lane Gather hands the pick to the agent instead (hub-58, 30 Oct): this
|
|
238
260
|
* Mac has no picker model, or no Ollama at all, or a model without structured
|
|
239
|
-
* output answered invalid JSON twice (Q-155)
|
|
261
|
+
* output answered invalid JSON twice (Q-155), or the model is too slow on this
|
|
262
|
+
* Mac to answer within the first-pick budget (rerunning only times out again).
|
|
263
|
+
* Null for every other failure.
|
|
240
264
|
*/
|
|
241
265
|
export function agentFallbackReason(error) {
|
|
242
|
-
if (error?.code === "PICKER_MODEL_MISSING") return `${error.details?.model ??
|
|
266
|
+
if (error?.code === "PICKER_MODEL_MISSING") return `${error.details?.model ?? pickerModelName()} not installed; run nodii-dev setup`;
|
|
267
|
+
if (error?.code === "PICKER_TIMEOUT") return `${error.details?.model ?? pickerModelName()} did not answer within ${budgetText(error.details?.timeoutMs ?? PICKER_FIRST_PICK_TIMEOUT_MS)} on this Mac`;
|
|
243
268
|
if (error?.code === "PICKER_UNAVAILABLE" && error.details?.unreachable) return `no local Ollama at ${error.details.url}; run nodii-dev setup`;
|
|
244
269
|
if (error?.code === "PICKER_RESPONSE_INVALID" && error.details?.unconstrained) return "gemma output invalid";
|
|
245
270
|
return null;
|
|
@@ -255,7 +280,7 @@ export async function pickDocuments(input, options = {}) {
|
|
|
255
280
|
const deadline = setTimeout(() => controller.abort(), timeoutMs);
|
|
256
281
|
const signal = combineSignals([options.signal, controller.signal]);
|
|
257
282
|
const timedOptions = { ...options, timeoutMs, signal };
|
|
258
|
-
const model = (options.model ??
|
|
283
|
+
const model = (options.model ?? pickerPin()).name;
|
|
259
284
|
const started = Date.now();
|
|
260
285
|
try {
|
|
261
286
|
await requirePicker(timedOptions);
|
|
@@ -281,7 +306,7 @@ export async function pickDocuments(input, options = {}) {
|
|
|
281
306
|
if (controller.signal.aborted && !options.signal?.aborted) {
|
|
282
307
|
// Not awaited: the refusal is immediate; the unload finishes before exit.
|
|
283
308
|
unloadPicker(model, options).catch(() => {});
|
|
284
|
-
throw new CliError("PICKER_TIMEOUT", `Local Gather picker ${model} did not answer within ${Math.round(timeoutMs / 1000)} s; the pick was stopped and the model unloaded. Rerun the command.`, 1);
|
|
309
|
+
throw new CliError("PICKER_TIMEOUT", `Local Gather picker ${model} did not answer within ${Math.round(timeoutMs / 1000)} s; the pick was stopped and the model unloaded. Rerun the command.`, 1, { model, timeoutMs });
|
|
285
310
|
}
|
|
286
311
|
throw error;
|
|
287
312
|
} finally {
|
|
@@ -520,7 +545,7 @@ const LATENCY_PROBE = {
|
|
|
520
545
|
|
|
521
546
|
/** Cold (model unloaded, confirmed gone) and warm pick latency for one pinned picker. */
|
|
522
547
|
export async function measurePickerLatency(options = {}, { pick = pickDocuments, unload = unloadPicker, loaded = modelLoaded, sleep = (ms) => new Promise((r) => setTimeout(r, ms)) } = {}) {
|
|
523
|
-
const model = (options.model ??
|
|
548
|
+
const model = (options.model ?? pickerPin()).name;
|
|
524
549
|
await requirePicker(options);
|
|
525
550
|
await unload(model, options);
|
|
526
551
|
for (let i = 0; i < 50 && (await loaded(model, options)); i += 1) await sleep(200);
|
|
@@ -550,7 +575,8 @@ const tags = (clause) => {
|
|
|
550
575
|
const parts = [
|
|
551
576
|
...(repos.length ? [`repo: ${repos.join(", ")}`] : []),
|
|
552
577
|
...(steps.length ? [`step: ${steps.join(", ")}`] : []),
|
|
553
|
-
|
|
578
|
+
// MW1-96: pinned for the repository and side, whatever the objective.
|
|
579
|
+
...(clause.alwaysOn ? ["always-on"] : clause.laneBase ? ["lane base"] : []),
|
|
554
580
|
];
|
|
555
581
|
return parts.length ? ` [${parts.join("; ")}]` : "";
|
|
556
582
|
};
|
|
@@ -599,16 +625,18 @@ async function run(command, args, exec = execFileAsync) {
|
|
|
599
625
|
catch (error) { throw new CliError("OLLAMA_SETUP_FAILED", `${command} ${args.join(" ")} failed: ${error.message}`, 1); }
|
|
600
626
|
}
|
|
601
627
|
|
|
602
|
-
export async function setupOllama({ check = false, inspect = inspectOllama, exec = execFileAsync, os = platform() } = {}) {
|
|
628
|
+
export async function setupOllama({ check = false, inspect = inspectOllama, exec = execFileAsync, os = platform(), env = process.env } = {}) {
|
|
629
|
+
const pin = pickerPin(env);
|
|
630
|
+
const model = pin.name;
|
|
603
631
|
try {
|
|
604
|
-
const current = await inspect();
|
|
632
|
+
const current = await inspect({ model: pin });
|
|
605
633
|
if (current.modelInstalled && current.modelMatches) {
|
|
606
634
|
const embed = await setupEmbedModel({ check, inspect, exec });
|
|
607
635
|
return { changed: embed.changed, ...current, embed };
|
|
608
636
|
}
|
|
609
637
|
if (check && current.modelInstalled)
|
|
610
|
-
throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `${
|
|
611
|
-
if (check) throw new CliError("PICKER_MODEL_MISSING", `${
|
|
638
|
+
throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `${model} digest is ${current.digest ?? "unknown"}; this CLI pins ${pinnedDigests(pin)}. Run \`nodii-dev setup --yes\` to pull it; ${STALE_PIN_HINT}`, 1, current);
|
|
639
|
+
if (check) throw new CliError("PICKER_MODEL_MISSING", `${model} is not installed.`, 1, current);
|
|
612
640
|
} catch (error) {
|
|
613
641
|
if (check || !["PICKER_UNAVAILABLE", "PICKER_MODEL_MISSING"].includes(error?.code)) throw error;
|
|
614
642
|
if (os !== "darwin")
|
|
@@ -616,13 +644,13 @@ export async function setupOllama({ check = false, inspect = inspectOllama, exec
|
|
|
616
644
|
await run("brew", ["install", "ollama"], exec);
|
|
617
645
|
await run("brew", ["services", "start", "ollama"], exec);
|
|
618
646
|
}
|
|
619
|
-
await run("ollama", ["pull",
|
|
620
|
-
const ready = await inspect();
|
|
621
|
-
if (!ready.modelInstalled) throw new CliError("PICKER_MODEL_MISSING", `Ollama pull finished but ${
|
|
647
|
+
await run("ollama", ["pull", model], exec);
|
|
648
|
+
const ready = await inspect({ model: pin });
|
|
649
|
+
if (!ready.modelInstalled) throw new CliError("PICKER_MODEL_MISSING", `Ollama pull finished but ${model} is not installed.`, 1, ready);
|
|
622
650
|
// A fresh pull is what the registry serves now, so a mismatch here is a stale pin.
|
|
623
|
-
if (!ready.modelMatches) throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `The Ollama registry serves ${
|
|
651
|
+
if (!ready.modelMatches) throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `The Ollama registry serves ${model} at ${ready.digest ?? "an unknown digest"}, but this CLI pins ${pinnedDigests(pin)}: the pin is stale, so pulling again will not help. Update nodii-dev to a release with the current pin.`, 1, { ...ready, stalePin: true });
|
|
624
652
|
const embed = await setupEmbedModel({ check, inspect, exec });
|
|
625
|
-
return { changed: [
|
|
653
|
+
return { changed: [model, ...embed.changed], ...ready, embed };
|
|
626
654
|
}
|
|
627
655
|
|
|
628
656
|
/** The section embedding pin, pulled beside the picker (AGENT-HARNESS-58). */
|
package/dist/harness.js
CHANGED
|
@@ -10,7 +10,7 @@ import { dirname, join, normalize, sep } from "node:path";
|
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
import { promisify } from "node:util";
|
|
12
12
|
import { CliError, devRequest, query } from "./core.js";
|
|
13
|
-
import { classifyClaudeManaged, claudeManagedSettingsPath, managedClaudeHookBundle, managedHookBundle, nodiiCommandArgs, writeManagedClaudeHookBundle, writeManagedHookBundle } from "./managed-hooks.js";
|
|
13
|
+
import { classifyClaudeManaged, claudeManagedSettingsPath, managedClaudeHookBundle, managedHookBundle, nodiiCommandArgs, refreshManagedDispatchers, writeManagedClaudeHookBundle, writeManagedHookBundle } from "./managed-hooks.js";
|
|
14
14
|
import { nudgeSettingsSnippet } from "./nudges.js";
|
|
15
15
|
import { codexSafetyHooksSnippet, regroundingHooksSnippet, safetySettingsSnippet } from "./safety.js";
|
|
16
16
|
|
|
@@ -462,7 +462,7 @@ async function checkCommand(root, repo, state, fetchHarness) {
|
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
-
export async function harnessCommand(action, flags, { request = devRequest, context = repoContext, managedHome, managedCliPath = fileURLToPath(new URL("../bin/nodii-dev", import.meta.url)), writeManaged = writeManagedHookBundle, writeManagedClaude = writeManagedClaudeHookBundle, claudeManagedPath = claudeManagedSettingsPath(), readSystem = optional } = {}) {
|
|
465
|
+
export async function harnessCommand(action, flags, { request = devRequest, context = repoContext, managedHome, managedCliPath = fileURLToPath(new URL("../bin/nodii-dev", import.meta.url)), writeManaged = writeManagedHookBundle, writeManagedClaude = writeManagedClaudeHookBundle, refreshManaged = refreshManagedDispatchers, claudeManagedPath = claudeManagedSettingsPath(), readSystem = optional } = {}) {
|
|
466
466
|
if (!["install", "update", "check"].includes(action)) throw new CliError("USAGE", "harness install|update|check [--repo NAME] [--service ID] [--include-drafts[=false]] [--adopt PATH,...] [--dry-run] [--check] [--system]", 2);
|
|
467
467
|
if (flags.fleet || flags.all) throw new CliError("USAGE", "The harness is installed one service at a time, in that service's repository. There is no fleet mode.", 2);
|
|
468
468
|
if (flags.root === true || flags.repo === true) throw new CliError("USAGE", "--root and --repo need a value.", 2);
|
|
@@ -539,7 +539,7 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
|
|
|
539
539
|
claudePlan = claudeSystemInstallPlan(claudeBundle, { target: claudeManagedPath, current, unreadable });
|
|
540
540
|
}
|
|
541
541
|
const claudeText = !claudePlan ? ""
|
|
542
|
-
: claudePlan.commands.length ? `\nManaged Claude hooks are staged in ${claudeBundle.dir}. One operator install covers every Claude profile on this machine and acts only in lanes; review ${claudePlan.source}, then run:\n${claudePlan.commands.join("\n")}`
|
|
542
|
+
: claudePlan.commands.length ? `\nManaged Claude hooks are staged in ${claudeBundle.dir}. One operator install covers every Claude profile on this machine and acts only in lanes, except the Surface-generation nudge (MW8-17), which every session gets; review ${claudePlan.source}, then run:\n${claudePlan.commands.join("\n")}`
|
|
543
543
|
: `\nManaged Claude hooks are staged in ${claudeBundle.dir}; ${CLAUDE_PLAN_TEXT[claudePlan.state](claudePlan)}`;
|
|
544
544
|
const systemText = systemCommands.length
|
|
545
545
|
? `\nManaged Codex hooks are staged in ${managedBundle.dir}. One operator install covers codex-personal and codex-work; review ${join(managedBundle.dir, "requirements.toml")}, then run:\n${systemCommands.join("\n")}${claudeText}\nNo privileged command was run. Later --system updates refresh the user-owned managed directories without sudo.`
|
|
@@ -547,6 +547,10 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
|
|
|
547
547
|
await applyHarness(ctx.root, plan);
|
|
548
548
|
if (managedBundle) await writeManaged(managedBundle);
|
|
549
549
|
if (claudeBundle) await writeManagedClaude(claudeBundle);
|
|
550
|
+
// Without --system, a machine that already has managed hooks still gets the
|
|
551
|
+
// current dispatcher (its lane-free nudges included), with no sudo.
|
|
552
|
+
const refreshed = claudeBundle ? [] : await refreshManaged(managedHome ? { home: managedHome } : {}).catch(() => []);
|
|
553
|
+
const refreshText = refreshed.length ? `\nRefreshed the managed hook dispatcher in ${refreshed.join(", ")}.` : "";
|
|
550
554
|
const claudeData = claudePlan ? { claudeManagedDir: claudeBundle.dir, claudeManaged: { state: claudePlan.state, target: claudePlan.target, systemCommands: claudePlan.commands } } : {};
|
|
551
|
-
return { payload: { data: { ...summary, applied: true, ...(systemCommands.length ? { systemCommands: [...systemCommands, ...(claudePlan?.commands ?? [])], managedDir: managedBundle.dir } : {}), ...claudeData } }, human: `${lines.join("\n")}\n${plan.changes.length ? `${action === "install" ? "Installed" : "Updated"}: ${plan.changes.length} change${plan.changes.length === 1 ? "" : "s"}.` : "Harness already current."}${systemText}` };
|
|
555
|
+
return { payload: { data: { ...summary, applied: true, ...(systemCommands.length ? { systemCommands: [...systemCommands, ...(claudePlan?.commands ?? [])], managedDir: managedBundle.dir } : {}), ...claudeData, ...(refreshed.length ? { managedDispatchRefreshed: refreshed } : {}) } }, human: `${lines.join("\n")}\n${plan.changes.length ? `${action === "install" ? "Installed" : "Updated"}: ${plan.changes.length} change${plan.changes.length === 1 ? "" : "s"}.` : "Harness already current."}${systemText}${refreshText}` };
|
|
552
556
|
}
|
package/dist/hooks.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { CliError, devRequest
|
|
1
|
+
import { CliError, devRequest } from "./core.js";
|
|
2
2
|
import { FOUNDATIONS_ID, figmaLockCheck, outOfScopeText } from "./figma.js";
|
|
3
3
|
import { assertWithinLaneScope, currentLaneFigmaScope } from "./figma-scope.js";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
7
|
import { safetySettingsSnippet } from "./safety.js";
|
|
8
|
-
import { regroundCurrentLane } from "./freeze.js";
|
|
9
8
|
|
|
10
9
|
const execFileAsync = promisify(execFile);
|
|
11
10
|
|
|
@@ -240,29 +239,6 @@ export async function heartbeatCurrentLane(request = devRequest) {
|
|
|
240
239
|
return { heartbeated: true, key: lane.key };
|
|
241
240
|
}
|
|
242
241
|
|
|
243
|
-
/** SessionStart compact context, plain text for both Claude and Codex. */
|
|
244
|
-
export async function sessionStartContext(payload, { request = devRequest, config = readConfig } = {}) {
|
|
245
|
-
if (payload?.source !== "compact") return null;
|
|
246
|
-
let context = "";
|
|
247
|
-
const result = await regroundCurrentLane(
|
|
248
|
-
{
|
|
249
|
-
cwd: payload.cwd ?? process.cwd(),
|
|
250
|
-
force: true,
|
|
251
|
-
write: (text) => {
|
|
252
|
-
context += text;
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
{ request, config },
|
|
256
|
-
);
|
|
257
|
-
// A Freeze written before it referenced the Clause map has no pointer to it.
|
|
258
|
-
const pointer = result.shown && !context.includes("lane gather show")
|
|
259
|
-
? `\nFull Clause map: \`nodii-dev lane gather show ${result.lane.key}\`; one clause in full: \`nodii-dev rules show <ID>\`.`
|
|
260
|
-
: "";
|
|
261
|
-
return result.shown
|
|
262
|
-
? `${context.trimEnd()}${pointer}`
|
|
263
|
-
: "Freeze re-grounding: no active Dev lane with initialized Freeze was available for this worktree; run `nodii-dev lane freeze show <key>` (and `nodii-dev lane gather show <key>` for its Clause map) before continuing.";
|
|
264
|
-
}
|
|
265
|
-
|
|
266
242
|
export function workflowSuggestion(payload) {
|
|
267
243
|
const command = payload?.tool_input?.command ?? "";
|
|
268
244
|
if (/\bgit\s+push\b/.test(command)) return "nodii-dev: pushed work; record it with `nodii-dev lane evidence <key> --commit <sha>` or `--pr <url>`.";
|
package/dist/lanes.js
CHANGED
|
@@ -6,14 +6,16 @@ import { coordinatorMachineId, listAccounts, profilePath, reportUsage } from "./
|
|
|
6
6
|
import { CliError, encode, devRequest, query, readConfig, requireFlag } from "./core.js";
|
|
7
7
|
import { launchRecovery } from "./runtime-launcher.js";
|
|
8
8
|
import { recordReviewReceipt, reviewCommitContext } from "./safety.js";
|
|
9
|
-
import { GATHER_TIMEOUT_MS, PICKER_FIRST_PICK_TIMEOUT_MS,
|
|
9
|
+
import { GATHER_TIMEOUT_MS, PICKER_FIRST_PICK_TIMEOUT_MS, agentFallbackReason, gatherDeadline, gatherText, pickDocuments, pickerModelName, pickTimingLine, pickTimingStats, readPickTimings, recordPickTiming, warmPicker, withPickLock } from "./gather.js";
|
|
10
10
|
import { storeGatherFreeze } from "./freeze.js";
|
|
11
11
|
import { doneCheckRecorded } from "./lane-supervisor.js";
|
|
12
|
+
import { STEWARD_DONE_CHECK, stewardObjective } from "./session-kind.js";
|
|
12
13
|
import { availableMemoryBytes } from "./host.js";
|
|
14
|
+
import { assertNothingPending, devDown, queuePending, receiptEvidenceBody, signedBuiltAck } from "./receipt.js";
|
|
13
15
|
import { SWAP_BOUNDARIES, componentsForScope, guidelineLookup, laneFigmaScope, loadDsCatalog } from "./figma-scope.js";
|
|
14
16
|
import { designCheck } from "./design.js";
|
|
15
17
|
import { LANE_ENV_FIX, laneEnvProblem, laneEnvReport } from "./lane-env.js";
|
|
16
|
-
import { REVIEW_FILE, checkLines, checkReviewChecks, diffDigest, laneDiff, privateStore, repoGeneratedPaths, runLaneCheck, runOutcome, worktreeCommitted } from "./review.js";
|
|
18
|
+
import { GATES_RECEIPT, REVIEW_FILE, checkLines, checkReviewChecks, diffDigest, laneDiff, privateStore, repoGeneratedPaths, runLaneCheck, runOutcome, worktreeCommitted } from "./review.js";
|
|
17
19
|
|
|
18
20
|
const execFileAsync = promisify(execFile);
|
|
19
21
|
const via = { via: "nodii-dev" };
|
|
@@ -77,7 +79,7 @@ function agentPickerFlags(flags) {
|
|
|
77
79
|
return null;
|
|
78
80
|
}
|
|
79
81
|
if (flags.picker !== "agent")
|
|
80
|
-
throw new CliError("USAGE", `--picker accepts only agent; without it the local ${
|
|
82
|
+
throw new CliError("USAGE", `--picker accepts only agent; without it the local ${pickerModelName()} picks.`, 2);
|
|
81
83
|
const shortlist = typeof flags.shortlist === "string" ? flags.shortlist.trim() : undefined;
|
|
82
84
|
const documents = typeof flags.documents === "string" ? list(flags.documents) : undefined;
|
|
83
85
|
if ((flags.shortlist !== undefined && !shortlist) || (flags.documents !== undefined && !documents?.length))
|
|
@@ -87,6 +89,13 @@ function agentPickerFlags(flags) {
|
|
|
87
89
|
return { shortlist, documents };
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
/** lane check's Delta gather flags; with an agent pick, the record step for that shortlist (hub-58). */
|
|
93
|
+
export const deltaGatherFlags = (paths, pick) => ({
|
|
94
|
+
delta: true,
|
|
95
|
+
paths: paths.join(","),
|
|
96
|
+
...(pick ? { picker: "agent", shortlist: pick.shortlist, documents: pick.documents.join(",") } : {}),
|
|
97
|
+
});
|
|
98
|
+
|
|
90
99
|
// hub-58: the reason is a fixed code (Dev stores its canonical text); a note may add context.
|
|
91
100
|
export const NOT_APPLICABLE_REASON_CODES = ["pre_harness_lane"];
|
|
92
101
|
function notApplicableRuling(flags) {
|
|
@@ -256,6 +265,9 @@ async function currentGatherLane(request, config, gitContext) {
|
|
|
256
265
|
const branch = active.filter((lane) => repositories(lane).some((repository) =>
|
|
257
266
|
repository.branch === context.branch && repoName(repository.repo ?? "") === context.repo));
|
|
258
267
|
const matches = exact.length ? exact : branch;
|
|
268
|
+
// A steward has no worktree (MW1-93): outside any lane's worktree, its own lane.
|
|
269
|
+
const stewards = active.filter((lane) => lane.kind === "steward");
|
|
270
|
+
if (!matches.length && stewards.length === 1) return stewards[0].key;
|
|
259
271
|
if (matches.length !== 1)
|
|
260
272
|
throw new CliError("CURRENT_LANE_AMBIGUOUS", matches.length
|
|
261
273
|
? `This worktree matches ${matches.length} active lanes (${matches.map((lane) => lane.key).join(", ")}); pass one key explicitly.`
|
|
@@ -279,7 +291,7 @@ async function localPick(lane, warming, pick, { budgetMs, timings }) {
|
|
|
279
291
|
const warmed = await warming;
|
|
280
292
|
const pickStarted = Date.now();
|
|
281
293
|
const entry = (outcome, picked) => ({
|
|
282
|
-
at: new Date().toISOString(), lane, model: picked?.model ??
|
|
294
|
+
at: new Date().toISOString(), lane, model: picked?.model ?? pickerModelName(), outcome,
|
|
283
295
|
warmMs: pickStarted - started, warmLoadMs: warmed?.loadMs ?? null,
|
|
284
296
|
pickMs: picked?.latency?.wallMs ?? Date.now() - pickStarted, loadMs: picked?.latency?.loadMs ?? null,
|
|
285
297
|
totalMs: Date.now() - started, budgetMs,
|
|
@@ -387,7 +399,7 @@ async function resumeHostLost(flags, deps, { request, config }) {
|
|
|
387
399
|
}
|
|
388
400
|
|
|
389
401
|
export async function laneCommand(action, args, flags, deps = {}) {
|
|
390
|
-
const { request = devRequest, config = readConfig, refreshAccounts = refreshMoveAccounts, gitContext = inferGitContext, commitsOf = branchCommits, read = (path) => readFile(path, "utf8"), reviewContext = reviewCommitContext, reviewReceipt = recordReviewReceipt, picker = pickDocuments, warm = warmPicker, firstPickTimeoutMs = PICKER_FIRST_PICK_TIMEOUT_MS, timings = { record: recordPickTiming, read: readPickTimings }, changedPaths = laneChangedPaths, gatherTimeoutMs = GATHER_TIMEOUT_MS, deadline: outerDeadline, storeFreeze = storeGatherFreeze, launch = launchRecovery, rebind = rebindLaneConfig, catalog = loadDsCatalog, pickLock = withPickLock, check: checkDeps = {} } = deps;
|
|
402
|
+
const { request = devRequest, config = readConfig, refreshAccounts = refreshMoveAccounts, gitContext = inferGitContext, commitsOf = branchCommits, read = (path) => readFile(path, "utf8"), reviewContext = reviewCommitContext, reviewReceipt = recordReviewReceipt, picker = pickDocuments, warm = warmPicker, firstPickTimeoutMs = PICKER_FIRST_PICK_TIMEOUT_MS, timings = { record: recordPickTiming, read: readPickTimings }, changedPaths = laneChangedPaths, gatherTimeoutMs = GATHER_TIMEOUT_MS, deadline: outerDeadline, storeFreeze = storeGatherFreeze, launch = launchRecovery, rebind = rebindLaneConfig, catalog = loadDsCatalog, pickLock = withPickLock, check: checkDeps = {}, signReceipt = null } = deps;
|
|
391
403
|
if (action === "resume" && flags["host-lost"]) {
|
|
392
404
|
if (args[0]) throw new CliError("USAGE", "lane resume --host-lost takes no <key>: it resumes every host_lost lane on this machine.", 2);
|
|
393
405
|
return resumeHostLost(flags, deps, { request, config });
|
|
@@ -457,14 +469,21 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
457
469
|
if (explicitObjective && durableObjective && explicitObjective !== durableObjective.trim())
|
|
458
470
|
throw new CliError("GATHER_OBJECTIVE_CONFLICT", `${ref} already has a different objective. Use lane amend; Gather cannot rewrite the durable contract.`, 1);
|
|
459
471
|
const issueObjective = typeof lane.issue?.bodyMd === "string" && lane.issue.bodyMd.trim() ? lane.issue.bodyMd : undefined;
|
|
460
|
-
|
|
472
|
+
// A steward (MW1-93, MW1-94) gathers for its role and the operator's
|
|
473
|
+
// current focus: its Lane contract's ask (the title, or the latest
|
|
474
|
+
// objective amendment). It has no branch, worktree or changed paths.
|
|
475
|
+
const steward = lane.kind === "steward";
|
|
476
|
+
const roleObjective = steward && !durableObjective && !explicitObjective
|
|
477
|
+
? stewardObjective(await request("GET", `/api/v1/lanes/${encode(id)}/contract`, undefined, { signal }).then((x) => x.data?.objective?.ask, () => null) ?? lane.title)
|
|
478
|
+
: undefined;
|
|
479
|
+
const objective = durableObjective ?? explicitObjective ?? roleObjective ?? issueObjective;
|
|
461
480
|
if (!objective) throw new CliError("GATHER_OBJECTIVE_MISSING", `${ref} has no recorded objective. Amend the lane or pass --objective; the CLI does not invent one.`, 1);
|
|
462
481
|
if (objective.length > 20_000) throw new CliError("USAGE", "The recorded Gather objective exceeds Dev's 20,000-character limit.", 2);
|
|
463
482
|
const durableDoneCheck = [lane.doneCheck, lane.freeze?.objective?.doneCheck].find((x) => typeof x === "string" && x.trim());
|
|
464
483
|
const explicitDoneCheck = typeof flags["done-check"] === "string" ? flags["done-check"].trim() : undefined;
|
|
465
484
|
if (explicitDoneCheck && durableDoneCheck && explicitDoneCheck !== durableDoneCheck.trim())
|
|
466
485
|
throw new CliError("GATHER_DONE_CHECK_CONFLICT", `${ref} already has a different done check. Use lane amend; Gather cannot rewrite the durable contract.`, 1);
|
|
467
|
-
const doneCheck = durableDoneCheck ?? explicitDoneCheck;
|
|
486
|
+
const doneCheck = durableDoneCheck ?? explicitDoneCheck ?? (steward ? STEWARD_DONE_CHECK : undefined);
|
|
468
487
|
if (!doneCheck) throw new CliError("GATHER_DONE_CHECK_MISSING", `${ref} has no recorded done check. Pass --done-check before Gather records anything.`, 1);
|
|
469
488
|
if (doneCheck.length > 10_000) throw new CliError("USAGE", "The Gather done check exceeds Dev's 10,000-character limit.", 2);
|
|
470
489
|
const legacyRepository = {
|
|
@@ -473,17 +492,19 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
473
492
|
worktree: lane.worktree,
|
|
474
493
|
ownedPaths: lane.ownedPaths ?? [],
|
|
475
494
|
};
|
|
476
|
-
const sourceRepositories =
|
|
477
|
-
? lane.
|
|
478
|
-
: lane.
|
|
479
|
-
? lane.
|
|
480
|
-
:
|
|
495
|
+
const sourceRepositories = steward
|
|
496
|
+
? (lane.repos ?? []).map((repo) => ({ repo: typeof repo === "string" ? repo : repo.repo }))
|
|
497
|
+
: lane.repositories?.length
|
|
498
|
+
? lane.repositories
|
|
499
|
+
: lane.freeze?.boundaries?.repos?.length
|
|
500
|
+
? lane.freeze.boundaries.repos
|
|
501
|
+
: [legacyRepository];
|
|
481
502
|
const repositories = sourceRepositories.map((repository) => Object.fromEntries(
|
|
482
503
|
["repo", "branch", "worktree", "ownedPaths"]
|
|
483
504
|
.map((key) => [key, repository[key]])
|
|
484
505
|
.filter(([, value]) => value !== undefined),
|
|
485
506
|
));
|
|
486
|
-
if (!repositories.length || repositories.some((repository) => !repository.repo || !repository.branch || !repository.worktree))
|
|
507
|
+
if (!repositories.length || repositories.some((repository) => !repository.repo || (!steward && (!repository.branch || !repository.worktree))))
|
|
487
508
|
throw new CliError("GATHER_BOUNDARIES_MISSING", `${ref} has an incomplete repository boundary. Repair its repo, branch, and worktree before Gather records anything.`, 1);
|
|
488
509
|
const limit = flags.limit === undefined ? undefined : Number(flags.limit);
|
|
489
510
|
if (limit !== undefined && (!Number.isInteger(limit) || limit < 1 || limit > 500))
|
|
@@ -496,7 +517,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
496
517
|
...(lane.freeze?.boundaries?.repos ?? []).flatMap((repository) => repository.ownedPaths ?? []),
|
|
497
518
|
...(lane.ownedPaths ?? []),
|
|
498
519
|
];
|
|
499
|
-
const driftPaths = await changedPaths(lane, { signal });
|
|
520
|
+
const driftPaths = steward ? [] : await changedPaths(lane, { signal });
|
|
500
521
|
if (driftPaths === null)
|
|
501
522
|
throw new CliError("GATHER_PATHS_UNAVAILABLE", "Gather could not read every recorded worktree. Repair the lane boundary or make its repositories available before continuing.", 1);
|
|
502
523
|
const paths = flags.paths ? list(flags.paths) : [...new Set([...recordedPaths, ...driftPaths])];
|
|
@@ -579,7 +600,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
579
600
|
mode: flags.delta ? "delta" : "full",
|
|
580
601
|
...(sectionLimit !== undefined ? { sectionLimitPerDocument: sectionLimit } : {}),
|
|
581
602
|
shortlistId,
|
|
582
|
-
picker: byAgent ? "agent" : picked.model ??
|
|
603
|
+
picker: byAgent ? "agent" : picked.model ?? pickerModelName(),
|
|
583
604
|
doneCheck,
|
|
584
605
|
}, { signal });
|
|
585
606
|
const figma = figmaScope.map((file) => ({
|
|
@@ -637,7 +658,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
637
658
|
}
|
|
638
659
|
// MW2-45: `lane review` and a step's `--done --review` record through one path.
|
|
639
660
|
// `lane check` hands its own body over, already shaped.
|
|
640
|
-
const recordReview = async (reviewFlags = flags, prepared = null) => {
|
|
661
|
+
const recordReview = async (reviewFlags = flags, prepared = null, ranGates = [], cwd = null) => {
|
|
641
662
|
// The input is checked before git is read, so a bad call never touches the worktree.
|
|
642
663
|
const notRequired = !prepared && reviewFlags["not-required"] ? notRequiredCitation(reviewFlags) : null;
|
|
643
664
|
const filed = prepared ?? (notRequired ? null : await reviewBody(reviewFlags, read));
|
|
@@ -649,6 +670,18 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
649
670
|
`The review file covers base ${body.base ?? "(missing)"} and head ${body.head ?? "(missing)"}, but this worktree is base ${current.base} and head ${current.commit}. Review the current diff and write a new receipt.`,
|
|
650
671
|
2,
|
|
651
672
|
);
|
|
673
|
+
// Signed and attached first: no proof on Dev, no passed review on Dev (S06-53).
|
|
674
|
+
// Only gates this tool saw pass for this head: lane check hands over its gates receipt's commands.
|
|
675
|
+
// A --gate flag on lane review is a claim, not a run, so it signs nothing. Their scope, stack and
|
|
676
|
+
// auth posture are unknown to this tool, so a test receipt comes from receipt write or the stack tool.
|
|
677
|
+
const gatesRun = ranGates.map((command) => ({ command, exitCode: 0 }));
|
|
678
|
+
const attachReceipt = await signReceipt?.(ref, "review", { commit: body.head, ...(cwd ? { cwd } : {}), details: {
|
|
679
|
+
checks: [...gatesRun, ...(body.checks?.length
|
|
680
|
+
? body.checks.map((check) => ({ name: check.check, outcome: check.outcome, exitCode: runOutcome([check]) === "CLEAN" ? 0 : 1 }))
|
|
681
|
+
: [{ name: "review", outcome: body.exitReason, exitCode: ["CLEAN", "NOT_REQUIRED"].includes(body.exitReason) ? 0 : 1 }])],
|
|
682
|
+
review: { exitReason: body.exitReason, base: body.base, head: body.head, findings: body.findings?.length ?? 0 },
|
|
683
|
+
} });
|
|
684
|
+
await attachReceipt?.();
|
|
652
685
|
const payload = await request("POST", `/api/v1/lanes/${encode(id)}/review`, body);
|
|
653
686
|
try { await reviewReceipt(); }
|
|
654
687
|
catch (error) {
|
|
@@ -683,11 +716,12 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
683
716
|
const run = await runLaneCheck(ref, flags, {
|
|
684
717
|
request, lane, freeze, current, cwd: context.worktree, store,
|
|
685
718
|
diff,
|
|
686
|
-
deltaGather: checkDeps.deltaGather ?? ((key, paths) => laneCommand("gather", [key],
|
|
719
|
+
deltaGather: checkDeps.deltaGather ?? ((key, paths, pick) => laneCommand("gather", [key], deltaGatherFlags(paths, pick), deps)),
|
|
687
720
|
catalog: checkDeps.catalog ?? catalog,
|
|
688
721
|
designCheck: checkDeps.designCheck ?? designCheck,
|
|
689
722
|
...(checkDeps.gate ? { gate: checkDeps.gate } : {}),
|
|
690
723
|
...(checkDeps.reviewer ? { reviewer: checkDeps.reviewer } : {}),
|
|
724
|
+
...(checkDeps.picker ? { picker: checkDeps.picker } : {}),
|
|
691
725
|
...(checkDeps.now ? { now: checkDeps.now } : {}),
|
|
692
726
|
});
|
|
693
727
|
// AGENT-HARNESS-61: an agent here without the lane's config gets no managed
|
|
@@ -710,7 +744,9 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
710
744
|
if (!committed || diffDigest((await diff(context.worktree)).text) !== run.digest)
|
|
711
745
|
throw new CliError("REVIEW_WORKTREE_DIRTY", `${[...lines, `run: nothing recorded. ${committed ? "The worktree changed while the reviewers ran" : "The reviewed diff has uncommitted or untracked changes"}, and Dev records a review for commit ${run.body.head} only. Commit them (or drop them) and rerun nodii-dev lane check ${ref}; this round does not count.`].join("\n")}`, 1);
|
|
712
746
|
const file = await store.write(REVIEW_FILE, run.body);
|
|
713
|
-
const
|
|
747
|
+
const gates = await store.read(GATES_RECEIPT).catch(() => null);
|
|
748
|
+
const ranGates = gates?.commit === run.body.head && gates?.base === run.body.base && Array.isArray(gates.commands) ? gates.commands : [];
|
|
749
|
+
const payload = await recordReview(flags, run.body, ranGates, context.worktree);
|
|
714
750
|
await run.saveLoop();
|
|
715
751
|
const outcome = runOutcome(run.body.checks);
|
|
716
752
|
return {
|
|
@@ -783,11 +819,20 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
783
819
|
return { payload: reason ? { ...payload, reason } : payload, human: `${ref}: ${side}/${step.stepKey} ${selected[0]}${reason ? `: ${reason}` : ""}` };
|
|
784
820
|
}
|
|
785
821
|
if (action === "evidence") {
|
|
786
|
-
const body = evidence(flags);
|
|
787
|
-
const
|
|
788
|
-
|
|
822
|
+
const body = flags.file !== undefined ? await receiptEvidenceBody(requireFlag(flags, "file"), ref) : evidence(flags);
|
|
823
|
+
const path = `/api/v1/lanes/${encode(id)}/evidence`;
|
|
824
|
+
try {
|
|
825
|
+
const payload = await request("POST", path, body);
|
|
826
|
+
return { payload, human: `${ref}: recorded ${body.kind} evidence.` };
|
|
827
|
+
} catch (error) {
|
|
828
|
+
if (!devDown(error)) throw error;
|
|
829
|
+
// MW1-64: Dev is down, so the record waits here and blocks the lane's close.
|
|
830
|
+
const file = await queuePending(path, body, { lane: ref });
|
|
831
|
+
return { payload: { data: { queued: true, file } }, human: `${ref}: Dev is unreachable; ${body.kind} evidence is waiting at ${file}. Run nodii-dev sync pending before the lane closes (MW1-64).` };
|
|
832
|
+
}
|
|
789
833
|
}
|
|
790
834
|
if (action === "done-check") {
|
|
835
|
+
await assertNothingPending(ref);
|
|
791
836
|
// NODII-DEV-CLI-4: the agent met the lane's done check. A launched run that
|
|
792
837
|
// exits after this ends finished instead of orphaned (lane-supervisor.js).
|
|
793
838
|
const value = typeof flags.evidence === "string" ? flags.evidence.trim() : "";
|
|
@@ -911,6 +956,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
911
956
|
},
|
|
912
957
|
};
|
|
913
958
|
}
|
|
959
|
+
if (action === "land") await assertNothingPending(ref);
|
|
914
960
|
if (action === "land") return { payload: await request("POST", `/api/v1/lanes/${encode(id)}/land`, via), human: `${ref}: recorded on main.` };
|
|
915
961
|
if (action === "review") return { payload: await recordReview(), human: (p) => `${ref}: ${reviewSummary(p)}.` };
|
|
916
962
|
if (action === "reviews") {
|
|
@@ -1016,14 +1062,19 @@ export async function nextCommand(ref, flags, { request = devRequest, changedPat
|
|
|
1016
1062
|
return { payload: { data, ...(rules ? { rules } : {}) }, human };
|
|
1017
1063
|
}
|
|
1018
1064
|
|
|
1019
|
-
export async function builtCommand(action, args, flags, { request = devRequest } = {}) {
|
|
1065
|
+
export async function builtCommand(action, args, flags, { request = devRequest, signAck = signedBuiltAck } = {}) {
|
|
1020
1066
|
if (action === "list") {
|
|
1021
1067
|
const payload = await request("GET", `/api/v1/built${query({ cursor: flags.cursor, limit: flags.limit, includeAcknowledged: flags["include-acknowledged"] })}`);
|
|
1022
1068
|
return { payload, human: (p) => p.data.map(laneLine).join("\n") || "No built lanes awaiting acknowledgement." };
|
|
1023
1069
|
}
|
|
1024
1070
|
if (action === "ack") {
|
|
1025
1071
|
if (!args.length) throw new CliError("USAGE", "built ack needs one or more lane keys", 2);
|
|
1026
|
-
const results = await Promise.all(args.map((ref) =>
|
|
1072
|
+
const results = await Promise.all(args.map(async (ref) => {
|
|
1073
|
+
// STD-22: the acknowledgement is signed and linked to what contributed; it is never verification.
|
|
1074
|
+
const lane = (await request("GET", `/api/v1/lanes/${encode(ref)}`)).data;
|
|
1075
|
+
const receipt = await signAck(ref, lane);
|
|
1076
|
+
return request("POST", `/api/v1/built/${encode(ref)}/acknowledge`, { ...(flags.note !== undefined ? { note: flags.note } : {}), receipt, ...via });
|
|
1077
|
+
}));
|
|
1027
1078
|
return { payload: args.length === 1 ? results[0] : { data: results.map((x) => x.data) }, human: `Acknowledged ${args.join(", ")}.` };
|
|
1028
1079
|
}
|
|
1029
1080
|
throw new CliError("USAGE", `Unknown built action: ${action}`, 2);
|