@nodii/dev 0.6.173 → 0.6.175
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 +242 -8
- package/dist/cli.js +178 -14
- package/dist/coordinator-items.js +235 -0
- package/dist/core.js +13 -2
- package/dist/flags.js +10 -1
- package/dist/harness.js +2 -0
- package/dist/lane-asks.js +115 -0
- package/dist/lane-supervisor.js +83 -5
- package/dist/lanes.js +43 -3
- package/dist/leeway.js +218 -0
- package/dist/managed-hooks.js +37 -4
- package/dist/nudges.js +1 -1
- package/dist/repo-policy.js +13 -1
- package/dist/safety.js +11 -1
- package/dist/session-kind.js +18 -5
- package/dist/setup.js +5 -4
- package/dist/starting.js +111 -20
- package/dist/surface.js +17 -0
- package/dist/tooling-docs.js +127 -0
- package/package.json +1 -1
package/dist/managed-hooks.js
CHANGED
|
@@ -59,10 +59,10 @@ const laneConfig = (env) => /^lane-[a-z0-9_-]+\.json$/i.test(basename(env.NODII_
|
|
|
59
59
|
// nudged to cite before it steers (MW1-95): these handlers, on these events,
|
|
60
60
|
// run for every session. Everything else stays lane-only.
|
|
61
61
|
export const SESSION_SCOPED_EVENTS = ["SessionStart", "UserPromptSubmit", "PreToolUse"];
|
|
62
|
-
export const SESSION_SCOPED_COMMANDS = ["nodii-dev hook session-start", "nodii-dev hook session-kind", "nodii-dev hook nudge-pre"];
|
|
62
|
+
export const SESSION_SCOPED_COMMANDS = ["nodii-dev hook session-start", "nodii-dev hook session-kind", "nodii-dev hook nudge-pre", "nodii-dev hook tooling-docs"];
|
|
63
63
|
// The shell's cheap screen for a non-lane PreToolUse: only a call that could
|
|
64
64
|
// be a steering act (MW1-95) starts the CLI. The CLI decides exactly.
|
|
65
|
-
const STEER_MARKERS = ['*\'"SendMessage"\'*', "*'lane amend'*", "*'gh pr '*", "*'nodii.repo.yaml'*", "*'lefthook.yml'*", "*'.github/workflows/'*"];
|
|
65
|
+
const STEER_MARKERS = ['*\'"SendMessage"\'*', "*'lane amend'*", "*'gh pr '*", "*'git push'*", "*' push'*", "*'nodii.repo.yaml'*", "*'lefthook.yml'*", "*'.github/workflows/'*"];
|
|
66
66
|
const sessionScoped = (event, handler) => SESSION_SCOPED_EVENTS.includes(event) && SESSION_SCOPED_COMMANDS.includes(String(handler?.command ?? "").trim());
|
|
67
67
|
const emptyResponse = (event) => ["Stop", "SubagentStop"].includes(event) ? "{}\n" : "";
|
|
68
68
|
|
|
@@ -105,7 +105,9 @@ export function managedHookBundle(hooksText, { home, cliPath, cliVersion = VERSI
|
|
|
105
105
|
// The stable shell entry point both runtimes call. A lane config gets every
|
|
106
106
|
// event; any other session only the session-scoped ones: SessionStart,
|
|
107
107
|
// UserPromptSubmit, and a PreToolUse that names a lane launch or resume (the
|
|
108
|
-
// governor, hub-232) or could be a steering act (MW1-95),
|
|
108
|
+
// governor, hub-232) or could be a steering act (MW1-95), a coordinator
|
|
109
|
+
// session's nodii-dev call or operator question (the coordinator gate,
|
|
110
|
+
// MW1-37.2: only where coordinator.json sits beside the config), plus the MW8-17
|
|
109
111
|
// Surface-generation nudge: an edit whose payload names a product page goes to
|
|
110
112
|
// `hook surface-gen-pre`, which reads only the edit. Every failure ends in the
|
|
111
113
|
// runtime's empty answer (fail open), except a governed launch, which the
|
|
@@ -134,6 +136,11 @@ export function dispatchScript(cliPath, action, stopJson) {
|
|
|
134
136
|
"}",
|
|
135
137
|
"managed_buffered=",
|
|
136
138
|
"managed_governed=",
|
|
139
|
+
// MW1-37.2: `coordinator start` writes coordinator.json beside the config.
|
|
140
|
+
// Only a session with it pays for the coordinator gate, and only on a call
|
|
141
|
+
// that names nodii-dev or asks the operator.
|
|
142
|
+
'managed_config=${NODII_DEV_CONFIG_PATH:-$HOME/.config/nodii-dev/config.json}',
|
|
143
|
+
'managed_coordinator="${managed_config%/*}/coordinator.json"',
|
|
137
144
|
'case "${NODII_DEV_CONFIG_PATH##*/}" in',
|
|
138
145
|
" lane-*.json) ;;",
|
|
139
146
|
' *) case "$1" in',
|
|
@@ -142,7 +149,7 @@ export function dispatchScript(cliPath, action, stopJson) {
|
|
|
142
149
|
" managed_payload=$(cat)",
|
|
143
150
|
" managed_buffered=1",
|
|
144
151
|
` if printf '%s' "$managed_payload" | grep -Eq 'lane([[:space:]]|\\\\[nrt])+(launch|resume)'; then managed_governed=1;`,
|
|
145
|
-
` else ${SURFACE_GEN}case "$managed_payload" in ${STEER_MARKERS.join("|")}) ;; *) empty_response "$1"; exit 0 ;; esac; fi ;;`,
|
|
152
|
+
` else ${SURFACE_GEN}case "$managed_payload" in ${STEER_MARKERS.join("|")}) ;; *'"AskUserQuestion"'*|*nodii-dev*|*@nodii/dev*) if [ ! -f "$managed_coordinator" ]; then empty_response "$1"; exit 0; fi ;; *) empty_response "$1"; exit 0 ;; esac; fi ;;`,
|
|
146
153
|
' *) empty_response "$1"; exit 0 ;;',
|
|
147
154
|
" esac ;;",
|
|
148
155
|
"esac",
|
|
@@ -184,6 +191,24 @@ async function governorVerdict(event, payloadText, deps) {
|
|
|
184
191
|
}
|
|
185
192
|
}
|
|
186
193
|
|
|
194
|
+
/**
|
|
195
|
+
* MW1-37.2: the coordinator gate's verdict for a session outside a lane, on
|
|
196
|
+
* PreToolUse. It fails open: any failure is no verdict. The governor's launch
|
|
197
|
+
* gate above is separate and stays fail-closed.
|
|
198
|
+
*/
|
|
199
|
+
async function coordinatorGateVerdict(event, payloadText, deps) {
|
|
200
|
+
if (event !== "PreToolUse") return null;
|
|
201
|
+
try {
|
|
202
|
+
const gate = deps.coordinatorGate ?? (await import("./coordinator-items.js")).coordinatorGate;
|
|
203
|
+
return (await gate(JSON.parse(payloadText), deps)) || null;
|
|
204
|
+
} catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** The governor's context and the gate's, as one. */
|
|
210
|
+
const withGate = (governor, gate) => (gate?.context ? { context: [governor?.context, gate.context].filter(Boolean).join("\n") } : governor);
|
|
211
|
+
|
|
187
212
|
const governorDeny = (event, verdict) => `${JSON.stringify({ hookSpecificOutput: { hookEventName: event, permissionDecision: "deny", permissionDecisionReason: verdict.deny } })}\n`;
|
|
188
213
|
const governorContext = (event, verdict) => (verdict?.context ? `${JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext: verdict.context } })}\n` : "");
|
|
189
214
|
|
|
@@ -333,6 +358,10 @@ export async function dispatchManagedHook(event, payloadText, deps = {}) {
|
|
|
333
358
|
// hub-232: the governor answers first; its deny needs no hooks.json.
|
|
334
359
|
governor = lane ? null : await governorVerdict(event, payloadText, deps);
|
|
335
360
|
if (governor?.deny) return governorDeny(event, governor);
|
|
361
|
+
// MW1-37.2: then the coordinator gate, for a coordinator session.
|
|
362
|
+
const gate = lane ? null : await coordinatorGateVerdict(event, payloadText, deps);
|
|
363
|
+
if (gate?.deny) return governorDeny(event, gate);
|
|
364
|
+
governor = withGate(governor, gate);
|
|
336
365
|
const dir = deps.dir ?? env.NODII_DEV_MANAGED_HOOKS_DIR ?? managedHooksDir();
|
|
337
366
|
const config = JSON.parse(await (deps.read ?? readFile)(join(dir, "hooks.json"), "utf8"));
|
|
338
367
|
validateManagedHooks(config.hooks ?? {});
|
|
@@ -393,6 +422,10 @@ export async function dispatchManagedClaudeHook(event, payloadText, deps = {}) {
|
|
|
393
422
|
// hub-232: the governor answers first; its deny needs no hooks.json.
|
|
394
423
|
governor = lane ? null : await governorVerdict(event, payloadText, deps);
|
|
395
424
|
if (governor?.deny) return governorDeny(event, governor);
|
|
425
|
+
// MW1-37.2: then the coordinator gate, for a coordinator session.
|
|
426
|
+
const gate = lane ? null : await coordinatorGateVerdict(event, payloadText, deps);
|
|
427
|
+
if (gate?.deny) return governorDeny(event, gate);
|
|
428
|
+
governor = withGate(governor, gate);
|
|
396
429
|
const read = deps.read ?? readFile;
|
|
397
430
|
const dir = deps.dir ?? env.NODII_DEV_MANAGED_HOOKS_DIR ?? managedClaudeHooksDir();
|
|
398
431
|
const config = JSON.parse(await read(join(dir, "hooks.json"), "utf8"));
|
package/dist/nudges.js
CHANGED
|
@@ -713,7 +713,7 @@ export async function nudgeStop(payload, context, { lastText = lastAssistantText
|
|
|
713
713
|
if (claimsDone(text) && lane.status !== "on_dev")
|
|
714
714
|
notes.push(`${lane.key} reads ${lane.status}, not on_dev: done means merged, deployed and verified live on dev (MW3). Run \`nodii-dev lane show ${lane.key}\`, and say what is left instead of "done"`);
|
|
715
715
|
if (COULDNT.test(text) && !FILED.test(text))
|
|
716
|
-
notes.push('you said you couldn\'t do something and cited no filed issue; file it (`nodii-dev issues create`, or a request or drift entry) so it is not lost');
|
|
716
|
+
notes.push('you said you couldn\'t do something and cited no filed issue; file it (`nodii-dev issues create`, or a request or drift entry) so it is not lost. If it blocks this lane and is an open issue that no live lane holds, do not stop there: ask for leeway with `nodii-dev lane leeway` (MW1-12.6, DEC-0486)');
|
|
717
717
|
const unconfirmed = openUnconfirmed(lane);
|
|
718
718
|
if (unconfirmed.length)
|
|
719
719
|
notes.push(`${unconfirmed.length} Unconfirmed item${unconfirmed.length === 1 ? " is" : "s are"} still open in ${lane.key}'s Freeze; confirm or drop each with a reason (\`nodii-dev lane freeze\`)`);
|
package/dist/repo-policy.js
CHANGED
|
@@ -119,13 +119,17 @@ const isObject = (x) => x !== null && typeof x === "object" && !Array.isArray(x)
|
|
|
119
119
|
const isStringList = (x) => Array.isArray(x) && x.every((item) => typeof item === "string" && item);
|
|
120
120
|
const isText = (x) => typeof x === "string" && x.trim().length > 0;
|
|
121
121
|
const ALLOWED_KEYS = {
|
|
122
|
-
"": ["schema", "service", "merge", "ci", "review", "tests", "docs"],
|
|
122
|
+
"": ["schema", "service", "merge", "ci", "review", "tests", "docs", "toolingDocs"],
|
|
123
123
|
merge: ["mode"],
|
|
124
124
|
ci: ["pr", "full", "required", "reporting"],
|
|
125
125
|
review: ["engine", "command", "severities"],
|
|
126
126
|
tests: ["full", "tiers"],
|
|
127
127
|
docs: ["layout", "open", "scratch", "rootAllow"],
|
|
128
128
|
};
|
|
129
|
+
// MW1-46.3: the files that hold a repository's commands, routes, refusal codes and hooks, and the
|
|
130
|
+
// files that describe them (`repo docs-check`). A repository without the block is not checked.
|
|
131
|
+
const OPTIONAL_SECTIONS = ["toolingDocs"];
|
|
132
|
+
ALLOWED_KEYS.toolingDocs = ["tooling", "docs"];
|
|
129
133
|
// MW4-31.1 names these as what must not sit at the root; a repo cannot declare them away.
|
|
130
134
|
const STRAY_KIND = /\.(md|mdx|markdown|png|jpe?g|gif|webp|bmp|tiff?|heic|svg|log)$/i;
|
|
131
135
|
const safeRelativePath = (path) => isText(path) && !path.startsWith("/") && !path.split("/").includes("..");
|
|
@@ -136,6 +140,7 @@ export function validatePolicy(policy) {
|
|
|
136
140
|
const errors = [];
|
|
137
141
|
for (const [section, keys] of Object.entries(ALLOWED_KEYS)) {
|
|
138
142
|
const target = section ? policy[section] : policy;
|
|
143
|
+
if (OPTIONAL_SECTIONS.includes(section) && target === undefined) continue;
|
|
139
144
|
if (section && !isObject(target)) { errors.push(`${section}: required, and must be a map`); continue; }
|
|
140
145
|
for (const key of Object.keys(target)) if (!keys.includes(key)) errors.push(`${section ? `${section}.` : ""}${key}: unknown key; allowed: ${keys.join(", ")}`);
|
|
141
146
|
}
|
|
@@ -185,6 +190,12 @@ export function validatePolicy(policy) {
|
|
|
185
190
|
else for (const name of rootAllow) if (STRAY_KIND.test(name) || name.includes("/")) errors.push(`docs.rootAllow: "${name}" cannot be allowed; markdown, screenshots and logs never sit at the root (MW4-31.1)`);
|
|
186
191
|
}
|
|
187
192
|
}
|
|
193
|
+
if (isObject(policy.toolingDocs)) {
|
|
194
|
+
for (const key of ["tooling", "docs"]) {
|
|
195
|
+
const globs = policy.toolingDocs[key];
|
|
196
|
+
if (!(isStringList(globs) && globs.length && globs.every(safeRelativePath))) errors.push(`toolingDocs.${key}: must be a non-empty list of path globs inside the repository (MW1-46.3)`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
188
199
|
return errors;
|
|
189
200
|
}
|
|
190
201
|
|
|
@@ -301,6 +312,7 @@ const humanPolicy = ({ root, policy: p }) => [
|
|
|
301
312
|
`review: ${p.review.engine} · ${p.review.command} · ${p.review.severities.join(", ")}`,
|
|
302
313
|
`tests: ${p.tests.full}${p.tests.tiers.length ? `; tiers ${p.tests.tiers.join(", ")}` : ""}`,
|
|
303
314
|
`docs: ${p.docs.layout}${p.docs.open ? ` · ${p.docs.open}` : ""}`,
|
|
315
|
+
...(p.toolingDocs ? [`tooling docs: a change to ${p.toolingDocs.tooling.join(", ")} moves with ${p.toolingDocs.docs.join(", ")} (repo docs-check)`] : []),
|
|
304
316
|
].join("\n");
|
|
305
317
|
|
|
306
318
|
const humanLint = ({ root, findings }) => (findings.length
|
package/dist/safety.js
CHANGED
|
@@ -623,7 +623,7 @@ export function commandViolations(raw, context) {
|
|
|
623
623
|
// cannot have its review checked, so it is refused, not judged as the hook's own (P-8).
|
|
624
624
|
if (lane && gitCommands.some((x) => x.verb === "push") && pushTargets(command, context.cwd ?? context.root).includes(null))
|
|
625
625
|
block("SAFETY_PUSH_TARGET_UNKNOWN", "Push blocked: the hook cannot tell which repository this push runs in. Push with a literal path: git -C <worktree> push, or cd <worktree> && git push.");
|
|
626
|
-
if (lane && context.reviewFlowKnown && gitCommands.some((x) => x.verb === "push")) {
|
|
626
|
+
if (lane && context.reviewFlowKnown && context.reviewReceiptRequired !== false && gitCommands.some((x) => x.verb === "push")) {
|
|
627
627
|
// Each push is judged against the repository it pushes (hub-266):
|
|
628
628
|
// its own head, origin/main and review receipt, in its own worktree.
|
|
629
629
|
const repos = context.pushRepos?.length ? context.pushRepos : [{ root: context.root, head: context.head, base: context.base, receipt: context.reviewReceipt }];
|
|
@@ -826,6 +826,14 @@ export async function safetyContext(cwd = process.cwd(), { request = devRequest,
|
|
|
826
826
|
cwd: await realpath(cwd).catch(() => payloadCwd(cwd)), root, branch, head, base, role, lane, provenLane: Boolean(lane), reviewFlowKnown,
|
|
827
827
|
// True when `lane` was read from Dev by key during this call (the Stop gate then reads nothing more).
|
|
828
828
|
laneDetail,
|
|
829
|
+
// Resolve only for a push. Only an explicit disabled policy relaxes the receipt gate.
|
|
830
|
+
loadReviewReceiptRequired: async () => {
|
|
831
|
+
try {
|
|
832
|
+
const response = await request("GET", "/api/v1/rules/review/settings");
|
|
833
|
+
const settings = response?.data ?? response;
|
|
834
|
+
return settings?.gatesReceiptRequiredSince !== null;
|
|
835
|
+
} catch { return true; }
|
|
836
|
+
},
|
|
829
837
|
ownedPaths: ownership.paths,
|
|
830
838
|
ownershipKnown: role === "coordinator" || ownership.known,
|
|
831
839
|
generatedPaths: [...await harnessGenerated(root), ...(state.generatedPaths ?? [])],
|
|
@@ -859,6 +867,8 @@ export async function safetyPreHook(payload, contextOrResolver = safetyContext,
|
|
|
859
867
|
context.cwd = await realpath(cwd).catch(() => resolve(cwd));
|
|
860
868
|
if (SHELL_TOOLS.has(tool)) {
|
|
861
869
|
const command = String(payload.tool_input?.command ?? "");
|
|
870
|
+
if (provenLane(context) && pushTargets(command, context.cwd).length && typeof context.loadReviewReceiptRequired === "function")
|
|
871
|
+
context.reviewReceiptRequired = await context.loadReviewReceiptRequired();
|
|
862
872
|
await expandLaneScope(command, context);
|
|
863
873
|
// Read here, for this call, so it can only come from Dev. A failed read leaves null, which refuses.
|
|
864
874
|
context.devBoundaries = provenLane(context) && createsAnyBranch(command) ? await devBoundaries(context.lane?.key, request) : null;
|
package/dist/session-kind.js
CHANGED
|
@@ -13,6 +13,7 @@ import { basename, dirname, join } from "node:path";
|
|
|
13
13
|
import { CliError, configPath, devRequest, encode, query, readConfig, requireFlag } from "./core.js";
|
|
14
14
|
import { currentLane, regroundLane } from "./freeze.js";
|
|
15
15
|
import { gatherText } from "./gather.js";
|
|
16
|
+
import { laneAsksOn } from "./lane-asks.js";
|
|
16
17
|
import { managedBehindText } from "./managed-version.js";
|
|
17
18
|
|
|
18
19
|
export const SESSION_KINDS = ["lane", "coordinator", "steward", "operator_assistant"];
|
|
@@ -84,9 +85,10 @@ const focusOf = (steward) => String(steward?.title ?? "");
|
|
|
84
85
|
|
|
85
86
|
/** The clauses each kind's contract rests on, printed as Dev serves them (P-19). */
|
|
86
87
|
export const KIND_CLAUSES = {
|
|
87
|
-
|
|
88
|
+
// MW1-12.6 to MW1-12.8 (DEC-0486): leeway. The lane asks, the coordinator's grant is enough, and what it never reaches.
|
|
89
|
+
lane: ["MW1-92", "MW1-12.6", "MW1-12.8"],
|
|
88
90
|
steward: ["MW1-92", "MW1-93", "MW1-94", "MW1-95"],
|
|
89
|
-
coordinator: ["MW1-92", "K01-22", "MW1-49.1"],
|
|
91
|
+
coordinator: ["MW1-92", "K01-22", "MW1-49.1", "MW1-12.7"],
|
|
90
92
|
operator_assistant: ["MW1-92"],
|
|
91
93
|
};
|
|
92
94
|
|
|
@@ -101,21 +103,32 @@ async function clauseLines(ids, request) {
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
/** The kind's contract: the clauses it rests on, from Dev, then the session's next commands. */
|
|
104
|
-
export async function kindContract(resolved, { request = devRequest } = {}) {
|
|
106
|
+
export async function kindContract(resolved, { request = devRequest, env = process.env } = {}) {
|
|
105
107
|
const { kind } = resolved;
|
|
106
108
|
const next = {
|
|
107
109
|
lane: () => {
|
|
108
110
|
const key = resolved.lane?.key ?? resolved.promptKey ?? "<key>";
|
|
109
|
-
return [
|
|
111
|
+
return [
|
|
112
|
+
`Next: the Lane contract of ${key} is the work. \`nodii-dev lane gather ${key}\` if it has not gathered, then the Task; when the done check is met, \`nodii-dev lane done-check ${key}\` and \`nodii-dev lane land ${key}\`.`,
|
|
113
|
+
// The rule is MW1-12.6, served above from Dev; this line only names the commands.
|
|
114
|
+
`Blocked on an open issue that no live lane holds (MW1-12.6): \`nodii-dev lane leeway ${key} --blocker ISSUE --reason TEXT\` asks your coordinator; \`nodii-dev lane gather ${key} --delta\` acknowledges the grant.`,
|
|
115
|
+
];
|
|
110
116
|
},
|
|
111
117
|
steward: () => {
|
|
112
118
|
const key = resolved.steward?.key ?? "<key>";
|
|
113
119
|
return [
|
|
114
120
|
...(resolved.steward ? [`Focus: ${focusOf(resolved.steward)}`] : []),
|
|
115
121
|
`Next: \`nodii-dev lane gather ${key} --picker agent\`; steer only through the coordinator or \`nodii-dev lane amend <lane>\`, naming the clause or DEC id each time.`,
|
|
122
|
+
"A lane's leeway fix arrives as its own PR; what leeway covers is in Dev: `nodii-dev rules show MW1-12.8`.",
|
|
116
123
|
];
|
|
117
124
|
},
|
|
118
|
-
coordinator: () => [
|
|
125
|
+
coordinator: () => [
|
|
126
|
+
// What lanes wait on this coordinator for comes before its next action (MW1-12.6, MW1-12.7; DEC-0486).
|
|
127
|
+
`First, before your next action: \`nodii-dev coordinator items\` lists what lanes wait on you for, each with its command (\`nodii-dev lane leeway grant|refuse ID\`, ${laneAsksOn(env) ? "\`nodii-dev lane answer ID --text TEXT\`, " : ""}\`nodii-dev lane defer ID --reason TEXT\`). \`lane leeway grant\` asks for no TOTP code; the rule is in Dev: \`nodii-dev rules show MW1-12.7\`.`,
|
|
128
|
+
// The rule is MW1-38.15 in Dev's rulebook (`nodii-dev rules show MW1-38.15`); this line only names the command's default.
|
|
129
|
+
"MW1-38.15: `lane launch` gives a lane 4 subagent slots unless `--subagents N` says otherwise (fewer lanes, subagents fanned out inside each).",
|
|
130
|
+
"Next: `nodii-dev lane list` for this machine's lanes.",
|
|
131
|
+
],
|
|
119
132
|
operator_assistant: () => [],
|
|
120
133
|
}[kind]();
|
|
121
134
|
return ["Contract (from Dev's rulebook):", ...(await clauseLines(KIND_CLAUSES[kind], request)), ...next];
|
package/dist/setup.js
CHANGED
|
@@ -18,11 +18,12 @@ description: Drive every Nodii build lane through nodii-dev from start to verifi
|
|
|
18
18
|
|
|
19
19
|
Use \`nodii-dev\` as the control plane. It talks only to Dev, through the platform edge, signed in with \`nodii-dev login\` as the platform tenant's OAuth app. The canonical policy is the build-workflow rulebook in Dev (\`nodii-dev rulebook list\`), §§1–8 (operator rulings A-020/A-021). Never change lane state in Dev by another route.
|
|
20
20
|
|
|
21
|
-
1. The machine coordinator runs \`nodii-dev coordinator start --machine NAME [--account RUNTIME:PROFILE ...]\` (each model account a lane may run on is registered once; its usage is reported then, before each launch and by the watchdog), then \`nodii-dev lane launch KEY\` with the issue (whose title is the objective), done check, build kind/side, repeated repository/branch pairs, runtime profile/model,
|
|
22
|
-
2. Re-run \`nodii-dev lane gather\` for the current steps and rules; start, complete, or block the reported API step with \`nodii-dev lane step\`. After an authoritative \`lane amend\`, every run is blocked until its own \`lane gather --delta\` acknowledgement.
|
|
21
|
+
1. The machine coordinator runs \`nodii-dev coordinator start --machine NAME [--account RUNTIME:PROFILE ...]\` (each model account a lane may run on is registered once; its usage is reported then, before each launch and by the watchdog), then \`nodii-dev lane launch KEY\` with the issue (whose title is the objective), done check, build kind/side, repeated repository/branch pairs, runtime profile/model, and the lane's class (\`--class long|short|no-build\`, weighed against the account's usage band). \`--subagents N\` is optional and defaults to 4 (\`nodii-dev rules show MW1-38.15\`). A launched agent begins with \`nodii-dev lane gather\` from its worktree. Before its next action the coordinator clears what lanes wait on it for: \`nodii-dev coordinator items\` lists each item with its command (\`lane leeway grant|refuse ID\`, \`lane answer ID --text TEXT\`, \`lane defer ID --reason TEXT\`). \`lane leeway grant\` asks for no TOTP code (\`nodii-dev rules show MW1-12.7\`).
|
|
22
|
+
2. Re-run \`nodii-dev lane gather\` for the current steps and rules; start, complete, or block the reported API step with \`nodii-dev lane step\`. After an authoritative \`lane amend\`, every run is blocked until its own \`lane gather --delta\` acknowledgement. For a lane blocked on an open issue that no live lane holds, the command is \`nodii-dev lane leeway KEY --blocker ISSUE --reason TEXT\`; Dev refuses a second lane with \`LEEWAY_BLOCKER_HELD\` and names the holder, and \`lane gather --delta\` acknowledges the grant. The rules are in Dev: \`nodii-dev rules show MW1-12.6\` and \`MW1-12.8\`.
|
|
23
23
|
3. Record durable evidence with \`nodii-dev lane evidence KEY --pr|--commit|--figma|--deploy|--dev-check REF\` and heartbeat long-running work with \`nodii-dev lane heartbeat KEY --note "..."\` (notes are at most 500 characters).
|
|
24
|
-
4.
|
|
25
|
-
5.
|
|
24
|
+
4. Before a push or a pull request that changes a command, route, refusal code or hook, run \`nodii-dev repo docs-check\`: it reads the \`toolingDocs\` block of \`nodii.repo.yaml\`, and \`hook tooling-docs\` refuses \`git push\` and \`gh pr create|ready\` with \`TOOLING_DOCS_STALE\` on the same finding. The rule is in Dev: \`nodii-dev rules show MW1-46.3\`.
|
|
25
|
+
5. Record the review gate with \`nodii-dev lane review KEY\`. After merge, run \`nodii-dev lane land KEY\`. Done still means deployed and checked live on dev as the right user: \`nodii-dev lane verify KEY --dev-check REF\`.
|
|
26
|
+
6. Use \`nodii-dev lane prioritize|deprioritize KEY --reason "..."\` when priority changes; the reason is required. The lane stays on Built until a staff login runs \`nodii-dev built ack KEY\`. Never treat acknowledgement as testing.
|
|
26
27
|
|
|
27
28
|
## Steps
|
|
28
29
|
|
package/dist/starting.js
CHANGED
|
@@ -11,7 +11,8 @@ import { laneCommand, nextCommand } from "./lanes.js";
|
|
|
11
11
|
import { assertGovernorOpen, readGovernor } from "./governor.js";
|
|
12
12
|
import { laneConfigName } from "./lane-env.js";
|
|
13
13
|
import { hostBootedAt } from "./host.js";
|
|
14
|
-
import { cachedGet } from "./read-cache.js";
|
|
14
|
+
import { cachedGet, laneReadCache } from "./read-cache.js";
|
|
15
|
+
import { clearCoordinatorMarker, coordinatorMarkerPath } from "./coordinator-items.js";
|
|
15
16
|
import { accountFlags, listAccounts, profilePath, registerAccount, reportUsage, usageLine } from "./accounts.js";
|
|
16
17
|
|
|
17
18
|
const execFile = promisify(execFileCallback);
|
|
@@ -189,6 +190,15 @@ export async function findCoordinatorRun(machine, {
|
|
|
189
190
|
return newest;
|
|
190
191
|
}
|
|
191
192
|
|
|
193
|
+
/**
|
|
194
|
+
* MW1-37.2: coordinator.json beside the config marks this identity's sessions
|
|
195
|
+
* as a coordinator's, so the managed dispatcher runs the coordinator gate for
|
|
196
|
+
* them and for no other session. Best effort: the gate is off without it.
|
|
197
|
+
*/
|
|
198
|
+
async function markCoordinatorSession(save, state) {
|
|
199
|
+
try { await save(coordinatorMarkerPath({ NODII_DEV_CONFIG_PATH: configPath() }), state); } catch {}
|
|
200
|
+
}
|
|
201
|
+
|
|
192
202
|
const coordinatorState = (machine, run, agentId) => ({
|
|
193
203
|
machine,
|
|
194
204
|
machineId: run.metadata.machineId,
|
|
@@ -202,6 +212,7 @@ const coordinatorState = (machine, run, agentId) => ({
|
|
|
202
212
|
* state file and restart the heartbeater. Dev's run is unchanged.
|
|
203
213
|
*/
|
|
204
214
|
async function adoptCoordinatorRun(machine, run, c, { save, heartbeater, existingHeartbeater, installWatchdog }) {
|
|
215
|
+
await markCoordinatorSession(save, coordinatorState(machine, run, c.agentId));
|
|
205
216
|
await save(stateFile(machine), coordinatorState(machine, run, c.agentId));
|
|
206
217
|
const expected = run.expectedHeartbeatSeconds ?? 60;
|
|
207
218
|
// A heartbeater still beating this run keeps it; a second is never started.
|
|
@@ -276,6 +287,7 @@ export async function coordinatorHeartbeatLoop({ machine, runId, pid, processSta
|
|
|
276
287
|
catch (error) { if (error?.code !== "EEXIST") throw error; }
|
|
277
288
|
},
|
|
278
289
|
sleep = (ms) => delay(ms),
|
|
290
|
+
clearMarker = clearCoordinatorMarker,
|
|
279
291
|
} = {}) {
|
|
280
292
|
for (;;) {
|
|
281
293
|
const current = await currentRunId();
|
|
@@ -296,6 +308,8 @@ export async function coordinatorHeartbeatLoop({ machine, runId, pid, processSta
|
|
|
296
308
|
} catch (error) {
|
|
297
309
|
if (error?.code !== "RUN_ALREADY_TERMINAL") throw error;
|
|
298
310
|
}
|
|
311
|
+
// The session is gone: its coordinator marker goes with it (MW1-37.2).
|
|
312
|
+
await clearMarker(runId).catch(() => {});
|
|
299
313
|
return { stopped: "session_exited" };
|
|
300
314
|
}
|
|
301
315
|
try {
|
|
@@ -424,13 +438,15 @@ export async function coordinatorCommand(action, flags, {
|
|
|
424
438
|
} catch {}
|
|
425
439
|
throw new CliError("COORDINATOR_WATCH_FAILED", `Coordinator run ${payload.data.run.id} was registered, but its session could not be watched: ${error.message}`, 1);
|
|
426
440
|
}
|
|
427
|
-
|
|
441
|
+
const started = {
|
|
428
442
|
machine,
|
|
429
443
|
machineId: payload.data.machine.id,
|
|
430
444
|
runId: payload.data.run.id,
|
|
431
445
|
agentId: c.agentId,
|
|
432
446
|
startedAt: payload.data.run.startedAt,
|
|
433
|
-
}
|
|
447
|
+
};
|
|
448
|
+
await markCoordinatorSession(save, started);
|
|
449
|
+
await save(stateFile(machine), started);
|
|
434
450
|
// The run expects a heartbeat every expectedHeartbeatSeconds; heartbeat at
|
|
435
451
|
// half that so one late beat never makes it quiet.
|
|
436
452
|
const expected = payload.data.run.expectedHeartbeatSeconds ?? (flags["heartbeat-seconds"] ? Number(flags["heartbeat-seconds"]) : 60);
|
|
@@ -464,7 +480,7 @@ export async function coordinatorCommand(action, flags, {
|
|
|
464
480
|
};
|
|
465
481
|
}
|
|
466
482
|
|
|
467
|
-
async function createWorktrees(repositories, run = execFile) {
|
|
483
|
+
export async function createWorktrees(repositories, run = execFile) {
|
|
468
484
|
for (const repository of repositories) {
|
|
469
485
|
try {
|
|
470
486
|
const { stdout } = await run("git", ["-C", repository.worktree, "branch", "--show-current"], { encoding: "utf8" });
|
|
@@ -484,7 +500,7 @@ async function createWorktrees(repositories, run = execFile) {
|
|
|
484
500
|
}
|
|
485
501
|
}
|
|
486
502
|
|
|
487
|
-
async function writeLaneMarkers(repositories, marker, run = execFile, save = saveJson) {
|
|
503
|
+
export async function writeLaneMarkers(repositories, marker, run = execFile, save = saveJson) {
|
|
488
504
|
for (const repository of repositories) {
|
|
489
505
|
const { stdout } = await run("git", ["-C", repository.worktree, "rev-parse", "--git-dir"], { encoding: "utf8" });
|
|
490
506
|
const gitDir = isAbsolute(stdout.trim()) ? stdout.trim() : resolve(repository.worktree, stdout.trim());
|
|
@@ -530,6 +546,15 @@ async function refreshAccountUsage(machineId, runtime, profile, { request }) {
|
|
|
530
546
|
return reportUsage(accounts, { request, probe: true });
|
|
531
547
|
}
|
|
532
548
|
|
|
549
|
+
/** MW1-38.15: a lane launched without --subagents gets this many subagent slots. */
|
|
550
|
+
export const DEFAULT_SUBAGENT_QUOTA = 4;
|
|
551
|
+
|
|
552
|
+
/** Dev clamps a new lane's quota in the two_builds and one_build usage bands; say so when it did. */
|
|
553
|
+
function quotaClampLine(clamp) {
|
|
554
|
+
if (!clamp || clamp.granted === undefined) return null;
|
|
555
|
+
return `Subagent quota: asked ${clamp.asked ?? "?"}, granted ${clamp.granted}${clamp.band ? ` (account usage band ${clamp.band})` : ""}.`;
|
|
556
|
+
}
|
|
557
|
+
|
|
533
558
|
/** MW1-38.12: name the lanes Dev counted, so the coordinator can see which one to close. */
|
|
534
559
|
function laneCapRefusal(error) {
|
|
535
560
|
if (!["LANE_CAP_REACHED", "LANE_CAP_LAPSED"].includes(error?.code)) return error;
|
|
@@ -611,7 +636,8 @@ export async function launchLaneCommand(key, flags, {
|
|
|
611
636
|
profile,
|
|
612
637
|
devConfigPath,
|
|
613
638
|
model: requireFlag(flags, "model"),
|
|
614
|
-
|
|
639
|
+
// MW1-38.15: 4 subagent slots unless the coordinator says otherwise; 0 stays 0.
|
|
640
|
+
subagentQuota: flags.subagents === undefined ? DEFAULT_SUBAGENT_QUOTA : typeof flags.subagents === "string" ? Number(flags.subagents) : Number.NaN,
|
|
615
641
|
workClass,
|
|
616
642
|
...(flags.notes ? { notes: flags.notes } : {}),
|
|
617
643
|
...(flags["narrowing-note"] ? { narrowingNote: flags["narrowing-note"] } : {}),
|
|
@@ -681,10 +707,11 @@ export async function launchLaneCommand(key, flags, {
|
|
|
681
707
|
}
|
|
682
708
|
throw new CliError("LANE_LAUNCH_FAILED", `Lane ${key} is registered but its runtime did not start: ${error.message}. Dev recorded it for lane resume.`, 1);
|
|
683
709
|
}
|
|
710
|
+
const clampLine = quotaClampLine(payload.data?.subagentQuotaClamp ?? payload.subagentQuotaClamp);
|
|
684
711
|
const figmaLines = body.figmaScopes.map((scope) => `Figma scope: ${scope.fileKey} ${scope.componentSets.length ? `component sets ${scope.componentSets.join(", ")}` : "(whole file)"}`);
|
|
685
712
|
return {
|
|
686
713
|
payload: { ...payload, figmaScopes: body.figmaScopes },
|
|
687
|
-
human: [`Launched ${key}: ${payload.data.brief}`, ...(figmaLines.length ? figmaLines : ["Figma scope: none declared"])].join("\n"),
|
|
714
|
+
human: [`Launched ${key}: ${payload.data.brief}`, ...(clampLine ? [clampLine] : []), ...(figmaLines.length ? figmaLines : ["Figma scope: none declared"])].join("\n"),
|
|
688
715
|
};
|
|
689
716
|
}
|
|
690
717
|
|
|
@@ -812,35 +839,63 @@ const requestLine = (r) => `${r.id}\t${r.laneKey}\t${r.state}\t${r.changedPercen
|
|
|
812
839
|
|
|
813
840
|
/**
|
|
814
841
|
* hub-400: `lane amendments [<key>] [--all|--state STATE]`,
|
|
815
|
-
* `lane amendments show|
|
|
842
|
+
* `lane amendments show|withdraw <request>`,
|
|
843
|
+
* `lane amendments approve|reject <request> [<request> ...]|--all-pending [--note TEXT]`.
|
|
816
844
|
* Approve and reject are the operator's: the CLI asks for their TOTP code
|
|
817
845
|
* (STAFF_OPERATOR_REQUIRED), and an agent's call is refused as it stands.
|
|
846
|
+
* hub-525: Dev's step-up grant lasts 10 minutes and this CLI holds it for one
|
|
847
|
+
* process, so one command answers several requests under one code.
|
|
818
848
|
*/
|
|
819
849
|
export async function laneAmendmentsCommand(args, flags, { request = devRequest } = {}) {
|
|
820
|
-
const [first,
|
|
850
|
+
const [first, ...named] = args;
|
|
821
851
|
const decisions = ["show", "approve", "reject", "withdraw"];
|
|
822
852
|
if (decisions.includes(first)) {
|
|
823
|
-
|
|
824
|
-
const
|
|
853
|
+
const many = first === "approve" || first === "reject";
|
|
854
|
+
const allPending = Boolean(flags["all-pending"]);
|
|
855
|
+
if (allPending && (!many || named.length))
|
|
856
|
+
throw new CliError("USAGE", "--all-pending goes with lane amendments approve or reject, and takes no request id.", 2);
|
|
857
|
+
if (!allPending && (named.length < 1 || (!many && named.length > 1) || named.some((id) => !REQUEST_ID.test(id))))
|
|
858
|
+
throw new CliError("USAGE", `lane amendments ${first} needs ${many ? "one or more request ids, or --all-pending" : "the request id"} (lane amendments lists them).`, 2);
|
|
859
|
+
const pathOf = (id) => `/api/v1/lane-amendment-requests/${encode(id)}`;
|
|
825
860
|
if (first === "show") {
|
|
826
|
-
const r = (await request("GET",
|
|
861
|
+
const r = (await request("GET", pathOf(named[0]))).data;
|
|
827
862
|
return {
|
|
828
863
|
payload: { data: r },
|
|
829
864
|
human: [`${r.laneKey}: ${r.state}, ${r.changedPercent}% of the brief${r.pivot ? ` (refused: ${r.pivot})` : ""}, asked ${r.createdAt}.`, `Reason: ${r.reason}`, "", r.diff].join("\n"),
|
|
830
865
|
};
|
|
831
866
|
}
|
|
832
867
|
const body = first === "withdraw" ? { via: "nodii-dev" } : { ...(flags.note ? { note: String(flags.note) } : {}), via: "nodii-dev" };
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
first === "approve"
|
|
868
|
+
const line = (payload) => {
|
|
869
|
+
const r = payload.data;
|
|
870
|
+
return first === "approve"
|
|
837
871
|
? `Approved: ${r.laneKey} amendment ${payload.amendment?.version ?? "?"} applied. Its run picks it up with nodii-dev lane gather --delta.`
|
|
838
872
|
: first === "reject"
|
|
839
873
|
? `Rejected: ${r.laneKey} keeps its brief.`
|
|
840
874
|
: `Withdrawn: ${r.laneKey}'s amendment request ${r.id}.`;
|
|
841
|
-
|
|
875
|
+
};
|
|
876
|
+
const ids = allPending ? ((await request("GET", "/api/v1/lane-amendment-requests")).data ?? []).map((r) => r.id) : named;
|
|
877
|
+
if (!ids.length) return { payload: { data: [] }, human: `No pending lane amendment requests to ${first}.` };
|
|
878
|
+
if (ids.length === 1 && !allPending) {
|
|
879
|
+
const payload = await request("POST", `${pathOf(ids[0])}/${first}`, body);
|
|
880
|
+
return { payload, human: line(payload) };
|
|
881
|
+
}
|
|
882
|
+
// One after another, in this process: the first asks for the code, the
|
|
883
|
+
// rest reuse its grant. A refusal stops the run and says where it stands.
|
|
884
|
+
const answered = [];
|
|
885
|
+
for (const [index, id] of ids.entries()) {
|
|
886
|
+
try {
|
|
887
|
+
answered.push(await request("POST", `${pathOf(id)}/${first}`, body));
|
|
888
|
+
} catch (error) {
|
|
889
|
+
if (!(error instanceof CliError)) throw error;
|
|
890
|
+
const rest = ids.slice(index + 1);
|
|
891
|
+
const report = [...answered.map(line), `${id}: ${error.message}`, ...(rest.length ? [`Not tried: ${rest.join(", ")}`] : [])];
|
|
892
|
+
throw new CliError(error.code, report.join("\n"), error.exitCode ?? 1, error.details);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
return { payload: { data: answered.map((payload) => ({ ...payload.data, amendment: payload.amendment ?? null })) }, human: answered.map(line).join("\n") };
|
|
842
896
|
}
|
|
843
|
-
if (first !== undefined && args.length > 1) throw new CliError("USAGE", "lane amendments [<key>] [--all|--state STATE] | show|approve|reject
|
|
897
|
+
if (first !== undefined && args.length > 1) throw new CliError("USAGE", "lane amendments [<key>] [--all|--state STATE] | show|withdraw <request> | approve|reject <request> [<request> ...]|--all-pending [--note TEXT]", 2);
|
|
898
|
+
if (flags["all-pending"]) throw new CliError("USAGE", "--all-pending goes with lane amendments approve or reject.", 2);
|
|
844
899
|
if (flags.all && flags.state) throw new CliError("USAGE", "lane amendments takes --all or --state, not both.", 2);
|
|
845
900
|
const params = new URLSearchParams();
|
|
846
901
|
if (first) params.set("lane", first);
|
|
@@ -881,7 +936,7 @@ export async function laneAuthorityCommand(sub, key, flags, { request = devReque
|
|
|
881
936
|
if (extra.length) throw new CliError("USAGE", `lane authority list takes no ${extra.map((flag) => `--${flag}`).join(", ")}.`, 2);
|
|
882
937
|
const payload = await request("GET", `/api/v1/lanes/${encode(key)}/authority`);
|
|
883
938
|
const rows = payload.data ?? [];
|
|
884
|
-
const line = (row) => `${row.createdAt} ${row.kind}${row.toAgentId ? ` to ${row.toAgentId}` : ""} ${row.personId} at ${row.saidAt}: "${row.quote}"${row.appliedAt ? ` (applied ${row.appliedAt})` : ""}`;
|
|
939
|
+
const line = (row) => `${row.createdAt} ${row.kind}${row.toAgentId ? ` to ${row.toAgentId}` : ""} ${row.personId ?? (row.standingOrderRef ? `standing order ${row.standingOrderRef}` : "no person")}${row.saidAt ? ` at ${row.saidAt}` : ""}${row.quote ? `: "${row.quote}"` : ""}${row.appliedAt ? ` (applied ${row.appliedAt})` : ""}`;
|
|
885
940
|
return { payload, human: rows.length ? rows.map(line).join("\n") : `${key} has no recorded authority.` };
|
|
886
941
|
}
|
|
887
942
|
if (basename(path).startsWith("lane-"))
|
|
@@ -923,11 +978,47 @@ export async function currentMarker(run = execFile, load = loadJson, env = proce
|
|
|
923
978
|
return { ...marker, runId };
|
|
924
979
|
}
|
|
925
980
|
|
|
981
|
+
// An amendment, a leeway, a question and its answer or deferral change no brief by themselves.
|
|
982
|
+
const GUARD_EXEMPT_LANE_ACTIONS = new Set(["amend", "leeway", "ask", "asks", "answer", "defer"]);
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* MW1-12.9: what a lane hook tells a long-running session about an amendment
|
|
986
|
+
* it has not acknowledged (an answer, a leeway grant, a rebrief), so it learns
|
|
987
|
+
* of it without running a nodii-dev command itself. The read goes through the
|
|
988
|
+
* 15-second cache under its own key, so the guard below still blocks from
|
|
989
|
+
* Dev's own answer; each newest version is said once a minute at most. Null
|
|
990
|
+
* when there is nothing to say, and on any failure.
|
|
991
|
+
*/
|
|
992
|
+
export async function pendingAmendmentContext({ request = devRequest, marker = currentMarker, cache = laneReadCache(), told = laneReadCache({ ttlMs: 60_000 }) } = {}) {
|
|
993
|
+
try {
|
|
994
|
+
const lane = await marker();
|
|
995
|
+
if (!lane) return null;
|
|
996
|
+
const path = `/api/v1/lanes/${encode(lane.laneKey)}/amendments${query({ runId: lane.runId })}`;
|
|
997
|
+
let pending = await cache.get(`${path}#context`);
|
|
998
|
+
if (pending === undefined) {
|
|
999
|
+
pending = await request("GET", path);
|
|
1000
|
+
await cache.set(`${path}#context`, pending);
|
|
1001
|
+
}
|
|
1002
|
+
const rows = [...(pending?.data ?? [])].sort((a, b) => a.version - b.version);
|
|
1003
|
+
if (!rows.length) return null;
|
|
1004
|
+
const newest = rows.at(-1).version;
|
|
1005
|
+
if ((await told.get(`${path}#told`)) === newest) return null;
|
|
1006
|
+
await told.set(`${path}#told`, newest);
|
|
1007
|
+
const listed = rows.map((row) => `v${row.version} ${String(row.reason ?? "").replace(/\s+/g, " ").trim().slice(0, 160)}`).join("; ");
|
|
1008
|
+
const many = rows.length > 1;
|
|
1009
|
+
return `nodii-dev: lane ${lane.laneKey} has ${many ? `${rows.length} amendments` : "an amendment"} it has not acknowledged (${listed}). Run \`nodii-dev lane gather ${lane.laneKey} --delta\` now: it shows ${many ? "them" : "it"} and acknowledges ${many ? "them" : "it"}, and every other nodii-dev command is refused until then.`;
|
|
1010
|
+
} catch {
|
|
1011
|
+
return null;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
|
|
926
1015
|
export async function amendmentGuard(argv, { request = devRequest, marker = currentMarker, cache = null } = {}) {
|
|
927
1016
|
const lane = await marker();
|
|
928
1017
|
if (!lane) return null;
|
|
929
1018
|
const [command, action] = argv.filter((token) => !token.startsWith("--"));
|
|
930
|
-
|
|
1019
|
+
// MW1-12.6: asking for leeway, and a coordinator's grant or refusal, change
|
|
1020
|
+
// no brief by themselves; a grant reaches the lane as its own amendment.
|
|
1021
|
+
if ((command === "lane" && action === "gather" && argv.includes("--delta")) || (command === "lane" && GUARD_EXEMPT_LANE_ACTIONS.has(action)) || (command === "coordinator" && action === "items")) return lane;
|
|
931
1022
|
// cli-134: only "nothing pending" is cached, so a pending amendment always
|
|
932
1023
|
// blocks from Dev's own answer and its acknowledgement is seen at once.
|
|
933
1024
|
const pending = await cachedGet(cache, request, `/api/v1/lanes/${encode(lane.laneKey)}/amendments${query({ runId: lane.runId })}`, (answer) => Array.isArray(answer?.data) && !answer.data.length);
|
package/dist/surface.js
CHANGED
|
@@ -3474,6 +3474,23 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
3474
3474
|
const notYetRows = f.all && !f.fetch ? selected.filter((row) => !generated(row)) : [];
|
|
3475
3475
|
const notYet = notYetRows.map((row) => row.id);
|
|
3476
3476
|
|
|
3477
|
+
// Preflight every target before fetching/saving trees or writing any page. Even an
|
|
3478
|
+
// invalid mark can contain a user's patch, so it must not be silently erased.
|
|
3479
|
+
if (f.write) {
|
|
3480
|
+
const protectedFiles = [];
|
|
3481
|
+
for (const row of targets) {
|
|
3482
|
+
const path = generatedPath(root, row);
|
|
3483
|
+
if (!existsSync(path)) continue;
|
|
3484
|
+
const marks = readFileSync(path, "utf8").split(/\r?\n/).flatMap((line, index) => {
|
|
3485
|
+
if (!/\/\*\s*@handrolled\b/.test(line)) return [];
|
|
3486
|
+
const key = /@handrolled\s+([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*-\d+)\s*:/.exec(line)?.[1];
|
|
3487
|
+
return [`${key ?? "missing issue key"} at line ${index + 1}`];
|
|
3488
|
+
});
|
|
3489
|
+
if (marks.length) protectedFiles.push(`${relative(root, path)}: ${marks.join(", ")}`);
|
|
3490
|
+
}
|
|
3491
|
+
if (protectedFiles.length) throw new CliError("SURFACE_HANDROLLED", `Refusing to overwrite handrolled Surfaces:\n${protectedFiles.join("\n")}\nGenerate without --write to inspect the replacement and resolve the marked patches explicitly.`, 1);
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3477
3494
|
let figmaGet = injected;
|
|
3478
3495
|
const indexes = new Map();
|
|
3479
3496
|
const trees = new Map();
|