@nodii/dev 0.6.181 → 0.6.183

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 CHANGED
@@ -347,6 +347,7 @@ nodii-dev figma apply CHANGE_SET --figma-version VERSION
347
347
  nodii-dev figma published FILE_KEY|CHANGE_SET --figma-version VERSION
348
348
  nodii-dev figma abandon CHANGE_SET
349
349
  nodii-dev figma withdraw CHANGE_SET # take back a submit before anything is decided
350
+ nodii-dev figma split CHANGE_SET --nodes NODE[,NODE] --title TEXT # move written nodes to a new set
350
351
  nodii-dev figma resubmit CHANGE_SET PAYLOAD.json # round 2: re-submit every rejected item
351
352
  nodii-dev figma changeset show CHANGE_SET # items, variants, round, decision, comment
352
353
  nodii-dev figma release FILE_KEY
@@ -435,6 +436,34 @@ library publish's version id). Dev holds back a set whose component an
435
436
  unfinished set now holds, and flags any published component from an
436
437
  unfinished set. `figma published CS-123 ...` keeps the per-set route.
437
438
 
439
+ `figma split CS --nodes NODE[,NODE] --title TEXT` moves written nodes out of an
440
+ editing set's write log into a new set you hold (Dev's `splitDesignChangeSet`,
441
+ hub-572). Use it when the write log holds more Surface sets than one review
442
+ should take, and a submit that names items for only some of them is refused
443
+ `WRITE_OUTSIDE_DECLARED`.
444
+
445
+ How a split works:
446
+ - **What you name:** written node ids. Read a Surface set's written ids through
447
+ the MCP; Dev can't place a written node by component set without Figma.
448
+ - **What moves:** the receipts for those nodes and for anything inside them.
449
+ A receipt moves and is never copied.
450
+ - **The new set:** the same file, base version and base seal state as the
451
+ source.
452
+ - **What stays with the source:** the lock (one lock per file per agent).
453
+ Restore one on the new set with `figma lock` once the source releases the
454
+ file.
455
+ - **Scopes:** a held scope rooted exactly at a moved node moves with it.
456
+ - **Record:** both sets record the split.
457
+
458
+ The title follows the change-set title rule (`CHANGE_SET_TITLE_STYLE`).
459
+
460
+ Dev refuses with:
461
+ - `SPLIT_NODE_IN_ITEM` for a node that an item of the source names;
462
+ - `SPLIT_NODE_NOT_WRITTEN` for a node that isn't in the write log;
463
+ - `SPLIT_NOTHING_TO_MOVE` when nothing is named;
464
+ - `CHANGE_SET_NOT_EDITABLE` while the set is in review or its submit is running;
465
+ - `CHANGE_SET_HOLDER_REQUIRED` for anyone but the holder.
466
+
438
467
  `figma withdraw` moves a change set you hold from `in_review` back to
439
468
  `editing`, as long as no item has been decided (Dev's
440
469
  `withdrawDesignChangeSet`). Dev refuses when the change set doesn't exist
@@ -501,6 +530,25 @@ outside its item (the CLI lists each item and the variants outside it). When
501
530
  Figma can't answer that check, Dev refuses with `503 FIGMA_UNAVAILABLE`; the CLI
502
531
  says when to retry (`details.retryAfter` seconds).
503
532
 
533
+ A change set changes only what was asked (MW6-22). Every removal of a
534
+ control, action, data, role view, metric, section or page, and every component
535
+ swap, is a line in `writeUp` or in the item's `context`, and quotes the
536
+ operator's ask behind it verbatim and dated:
537
+
538
+ ```
539
+ Removed: <what> · ask: "<verbatim quote>" (<who>, <date>)
540
+ Replaced: <old> → <new> · ask: "<verbatim quote>" (<who>, <date>)
541
+ ```
542
+
543
+ The date may be `19 Nov 2026`, `19 November`, `19th Nov`, `19 Nov`, `Nov 19, 2026`,
544
+ `19/11/2026` or `2026-11-19`. A `Removed:` or
545
+ `Replaced:` line with no quoted ask, or with an ask but no date, is refused
546
+ before Dev is called (exit `2`, `CHANGE_SET_SCOPE_UNASKED`), naming the item
547
+ and the line. `figma submit`, `figma resubmit` and `figma submit --dry-run` all
548
+ run this check, and Dev refuses the same. A removal or swap that no ask names
549
+ is not drawn: put it back, or ask the coordinator to put the question on the
550
+ operator's sheet (MW6-24).
551
+
504
552
  `figma resubmit` is round 2 inside the same change set (Dev's
505
553
  `resubmitDesignChangeSet`). When every item is decided and some were
506
554
  rejected, the set is `applying`: rework the rejected items in Figma (the lock
@@ -713,7 +761,10 @@ nodii-dev lane resume KEY --if-changed
713
761
  # runs/resume-fingerprints.json. A blocker that could not
714
762
  # be read (gh or Dev failed) is no change: it prints
715
763
  # BLOCKERS_UNREADABLE, exits 0 and records nothing. A
716
- # resume carries the gate's reason as data.resumeGate. A superseded lane (every
764
+ # resume carries the gate's reason as data.resumeGate.
765
+ # A run that ends BLOCKED records its fingerprint as the
766
+ # baseline, so its own last heartbeat (new waits) or a
767
+ # leeway it acknowledged is not a change. A superseded lane (every
717
768
  # issue it holds closed) is refused as LANE_DEAD with the
718
769
  # evidence; nothing stops it here (the coordinator ends it by
719
770
  # the MW1-28 exit that fits). A
package/dist/cli.js CHANGED
@@ -68,6 +68,10 @@ import {
68
68
  removedNodesFrom,
69
69
  removedNodesInReads,
70
70
  withdrawItemsFrom,
71
+ figmaSplit,
72
+ figmaSplitText,
73
+ listFlag,
74
+ SPLIT_USAGE,
71
75
  checkSubmitPayload,
72
76
  assertContext,
73
77
  resubmitPayload,
@@ -260,7 +264,10 @@ Usage: nodii-dev <command> [options] [--json]
260
264
  # variants: [{ nodeId, name, context, afterPngBase64 }] }] } (DEC-0204);
261
265
  # a missing writeUp, context or variant name, or an item with no variants,
262
266
  # is refused before Dev is called (writeUp <= 2000, context <= 500, name <= 120;
263
- # never a bare node id). The CLI adds evidence { baseVersion, finishVersion,
267
+ # never a bare node id). Each removal or swap line in writeUp or an item's
268
+ # context quotes its ask, verbatim and dated (MW6-22), or the CLI and Dev
269
+ # refuse CHANGE_SET_SCOPE_UNASKED: Removed: <what> · ask: "<quote>" (<who>,
270
+ # <date>), or Replaced: <old> → <new> · ask: ... The CLI adds evidence { baseVersion, finishVersion,
264
271
  # nodes: [{ nodeId, afterSha256 }] }: list any node written beyond the variants
265
272
  # in the body's evidence.nodes, or Dev refuses WRITE_OUTSIDE_DECLARED
266
273
  figma checked CHANGE_SET --unused-properties --stale-placeholders --dialog-body # the hand checks the submit nudge asks for
@@ -271,6 +278,11 @@ Usage: nodii-dev <command> [options] [--json]
271
278
  # coordinator or staff: move an open set, with its lock and scopes, to a live
272
279
  # lane's agent, even from a stopped lane. The target can hold no other lock on
273
280
  # the file (TARGET_HOLDS_FILE_LOCK)
281
+ figma split CHANGE_SET --nodes NODE[,NODE] --title TEXT
282
+ # holder: move written nodes (and what is inside them) out of an editing set's
283
+ # write log into a new set you hold on the same file, base and seal; receipts
284
+ # move, never copied. A node an item names stays (SPLIT_NODE_IN_ITEM); the lock
285
+ # stays with the source. hub-572
274
286
  figma withdraw CHANGE_SET # holder takes back a submit: in_review -> editing (or a re-submit -> applying)
275
287
  figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT [--lane-reads FILE [--removed-nodes NODE[,NODE]]]
276
288
  # holder, coordinator or operator: take rejected items (item or node ids)
@@ -1818,6 +1830,14 @@ export async function main(argv = process.argv.slice(2)) {
1818
1830
  throw new CliError("USAGE", `--reason goes with --items: ${WITHDRAW_ITEMS_USAGE} (a whole submit is withdrawn with: figma withdraw CHANGE_SET)`, 2);
1819
1831
  return emit(await figmaWithdraw(rest[0]), json, (p) => `Withdrew ${rest[0]}; it is back in ${p.data?.state ?? "editing"}.`);
1820
1832
  }
1833
+ if (action === "split") {
1834
+ if (rest.length !== 1) throw new CliError("USAGE", SPLIT_USAGE, 2);
1835
+ return emit(
1836
+ await figmaSplit(rest[0], { nodeIds: listFlag(f, "nodes"), title: f.title === true ? "" : f.title }),
1837
+ json,
1838
+ (p) => figmaSplitText(rest[0], p.data),
1839
+ );
1840
+ }
1821
1841
  if (action === "resubmit")
1822
1842
  return emit(await figmaResubmit(rest[0], rest[1], { sync: submitMode(f), ...(f["lane-reads"] ? { laneReads: await readLaneReads(f["lane-reads"]) } : {}) }), json, (p) =>
1823
1843
  [`Re-submitted ${rest[0]}; it is ${p.data.state}.`, figmaChangeSetText(p.data), ...conformanceLines({ warnings: p.warnings })].join("\n"));
package/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
4
  import { homedir, platform } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.181";
7
+ export const VERSION = "0.6.183";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/figma.js CHANGED
@@ -137,6 +137,45 @@ function assertEvidenceShape(evidence, file) {
137
137
  });
138
138
  }
139
139
 
140
+ // MW6-22 (DEC-0509): a change set changes only what was asked. Every removal
141
+ // or component swap in the write-up names the ask behind it, verbatim and
142
+ // dated, in this form; one with no ask is not drawn.
143
+ export const SCOPE_ASK_FORMAT = 'Removed: <what> · ask: "<verbatim quote>" (<who>, <date>) | Replaced: <old> → <new> · ask: "<verbatim quote>" (<who>, <date>)';
144
+ const SCOPE_LINE = /(?:^|\n)[ \t]*[-*]?[ \t]*((?:Removed|Replaced)[ \t]*:[^\n]*)/gi;
145
+ const MONTH = "(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*";
146
+ // The forms Dev's check takes (Dev's scope-asks check, hub #698): 2026-11-19, 19/11/2026,
147
+ // 19 Nov 2026, 19 November, 19th Nov, 19 Nov, Nov 19 and Nov 19, 2026.
148
+ const ASK_DATE = new RegExp(`\\b(?:\\d{4}-\\d{2}-\\d{2}|\\d{1,2}/\\d{1,2}/\\d{4}|\\d{1,2}(?:st|nd|rd|th)?\\s+${MONTH}(?:\\s+\\d{4})?|${MONTH}\\s+\\d{1,2}(?:st|nd|rd|th)?(?:,?\\s+\\d{4})?)\\b`, "i");
149
+
150
+ /** Each Removed: or Replaced: line of a write-up or item context that lacks a verbatim, dated ask (MW6-22). */
151
+ export function scopeAskProblems(body) {
152
+ const problems = [];
153
+ const scan = (text, at) => {
154
+ for (const [, line] of String(text ?? "").matchAll(SCOPE_LINE)) {
155
+ const ask = /\bask\s*:\s*["“]([^"”]+)["”]\s*(?:\(([^)]*)\))?/i.exec(line);
156
+ const problem = !ask ? "no_ask" : !ASK_DATE.test(ask[2] ?? "") ? "no_date" : null;
157
+ if (problem) problems.push({ ...at, line: line.trim(), problem });
158
+ }
159
+ };
160
+ scan(body?.writeUp, { field: "writeUp" });
161
+ (Array.isArray(body?.items) ? body.items : []).forEach((item, itemIndex) =>
162
+ scan(item?.context, { field: "item.context", itemIndex, figmaNodeId: item?.figmaNodeId ?? null }));
163
+ return problems;
164
+ }
165
+
166
+ /** One plain-English line per unasked removal or swap. */
167
+ export function scopeAskLines(lines = []) {
168
+ return lines.map((l) => {
169
+ const where = l.field === "writeUp" ? "writeUp" : `${itemLabel(l)} context`;
170
+ return ` ${where}: ${JSON.stringify(l.line)} ${l.problem === "no_date" ? "has an ask with no date" : "has no ask"}`;
171
+ });
172
+ }
173
+
174
+ const scopeAskHelp = () => [
175
+ `Quote the operator's ask behind each one, verbatim and dated: ${SCOPE_ASK_FORMAT}`,
176
+ "A removal or swap no ask names is not drawn: put it back, or ask the coordinator to put the question on the operator's sheet (MW6-22, MW6-24).",
177
+ ];
178
+
140
179
  export function assertContext(body, { resubmit = false, file = "the payload" } = {}) {
141
180
  assertEvidenceShape(body.evidence, file);
142
181
  const { items, problems } = contextProblems(body, { resubmit });
@@ -155,11 +194,20 @@ export function assertContext(body, { resubmit = false, file = "the payload" } =
155
194
  2,
156
195
  { problems },
157
196
  );
197
+ const unasked = scopeAskProblems(body);
198
+ if (unasked.length)
199
+ throw new CliError(
200
+ "CHANGE_SET_SCOPE_UNASKED",
201
+ [`${file}: ${unasked.length} removal or swap line(s) carry no verbatim, dated operator ask (MW6-22); nothing was sent:`, ...scopeAskLines(unasked), ...scopeAskHelp()].join("\n"),
202
+ 2,
203
+ { lines: unasked },
204
+ );
158
205
  return body;
159
206
  }
160
207
 
161
208
  // Dev's refusals of a submit or re-submit's context and component scope (DEC-0204), with what to do next.
162
209
  const CONTEXT_REFUSALS = {
210
+ CHANGE_SET_SCOPE_UNASKED: (message, details) => [message, ...scopeAskLines(details?.lines), ...scopeAskHelp()].join("\n"),
163
211
  CHANGE_SET_ITEM_NO_VARIANTS: (message, details) => [message, ...noVariantLines(details?.items)].join("\n"),
164
212
  CHANGE_SET_CONTEXT_MISSING: (message, details) => [message, ...contextProblemLines(details?.problems)].join("\n"),
165
213
  CHANGE_SET_MIXED_COMPONENTS: (message, details) =>
@@ -1064,6 +1112,47 @@ export async function figmaWithdrawItems(id, items, reason, { request = devReque
1064
1112
  }
1065
1113
  }
1066
1114
 
1115
+ // hub-572: move part of a set's write log, by written node, into a new set
1116
+ // held by the same lane (splitDesignChangeSet). Dev places no written node by
1117
+ // component set without Figma, so the lane reads a Surface set's written node
1118
+ // ids through the MCP and names them.
1119
+ export const SPLIT_USAGE = "figma split CHANGE_SET --nodes NODE[,NODE] --title TEXT";
1120
+
1121
+ /** A repeatable, comma-separated list flag; [] when absent. */
1122
+ export function listFlag(flags, name) {
1123
+ const given = [flags[name]].flat().filter((x) => x !== undefined);
1124
+ if (given.some((x) => x === true)) throw new CliError("USAGE", `--${name} needs values: ${SPLIT_USAGE}`, 2);
1125
+ return [...new Set(given.flatMap((x) => String(x).split(",")).map((x) => x.trim()).filter(Boolean))];
1126
+ }
1127
+
1128
+ const SPLIT_REFUSALS = {
1129
+ SPLIT_NODE_IN_ITEM: (id, details) => `${(details?.nodeIds ?? []).join(", ") || "A node you named"} is named by an item of ${id}, so it stays in ${id}. Withdraw or edit that item first, or leave the node out.`,
1130
+ SPLIT_NODE_NOT_WRITTEN: (id, details) => `${(details?.nodeIds ?? []).join(", ") || "A node you named"} is not in ${id}'s write log, so there is no write to move. Name written node ids (figma changeset show ${id}).`,
1131
+ SPLIT_NOTHING_TO_MOVE: (id) => `nothing to move: no write in ${id}'s write log matches what you named.`,
1132
+ CHANGE_SET_NOT_EDITABLE: (id) => `${id} is not editing (or its submit is running), so its write log can't be split. Withdraw the submit first (figma withdraw ${id}).`,
1133
+ CHANGE_SET_HOLDER_REQUIRED: (id) => `You don't hold ${id}; only its holder can split it.`,
1134
+ };
1135
+
1136
+ export async function figmaSplit(id, { nodeIds = [], title } = {}, { request = devRequest } = {}) {
1137
+ if (!id) throw new CliError("USAGE", SPLIT_USAGE, 2);
1138
+ if (typeof title !== "string" || !title.trim()) throw new CliError("USAGE", `--title needs the new set's name: ${SPLIT_USAGE}`, 2);
1139
+ if (!nodeIds.length) throw new CliError("USAGE", `name the written nodes that move with --nodes: ${SPLIT_USAGE}`, 2);
1140
+ try {
1141
+ return await request("POST", `/api/v1/design/change-sets/${encode(id)}/split`, { nodeIds, title: title.trim() });
1142
+ } catch (error) {
1143
+ const say = SPLIT_REFUSALS[error?.code];
1144
+ if (say) throw new CliError(error.code, say(id, error.details), error.exitCode ?? 1, error.details);
1145
+ throw error;
1146
+ }
1147
+ }
1148
+
1149
+ export function figmaSplitText(id, data) {
1150
+ const moved = data?.moved ?? {};
1151
+ const count = moved.nodeIds?.length ?? 0;
1152
+ const created = data?.created ?? {};
1153
+ return `Moved ${count} node${count === 1 ? "" : "s"} (${moved.receipts ?? 0} write receipt${moved.receipts === 1 ? "" : "s"}) from ${id} to ${created.id} "${created.title}". Both sets are yours and editing; each submits with its own items.`;
1154
+ }
1155
+
1067
1156
  /**
1068
1157
  * Apply on the lane's reads (MW1-57.11): the reads' Figma version unless one
1069
1158
  * is named. Reads over a chunk go up to the set first and are named by
package/dist/flags.js CHANGED
@@ -83,6 +83,7 @@ export const COMMAND_FLAGS = {
83
83
  "figma submit": ["file", "figma-version", ...SUBMIT_MODE, "dry-run", "lane-reads"],
84
84
  "figma resubmit": [...SUBMIT_MODE, "dry-run", "lane-reads"],
85
85
  "figma withdraw": ["items", "reason", "lane-reads", "removed-nodes"],
86
+ "figma split": ["nodes", "title"],
86
87
  "figma lane-reads-script": ["nodes"],
87
88
  "figma abandon": ["file"],
88
89
  // hub-260: list takes these; show takes none.
@@ -362,12 +362,23 @@ const messageCoordinator = (laneKey, body, { env = process.env } = {}) =>
362
362
  * The lane's Dev status and whether its done check is recorded. Unreadable
363
363
  * reads as unfinished.
364
364
  */
365
+ /** The supervisor's default: the lane's blocker baseline in the store lane resume --if-changed reads. */
366
+ async function blockerBaselineAtExit(laneKey, lane, { request = devRequest } = {}) {
367
+ if (!lane) return null;
368
+ // Loaded at call time: runtime-launcher imports this module.
369
+ const [{ defaultReaders, fingerprintStore, recordBlockerBaseline }, { recoveryStateRoot }] = await Promise.all([import("./resume-gate.js"), import("./runtime-launcher.js")]);
370
+ return recordBlockerBaseline({ ...lane, key: lane.key ?? laneKey }, {
371
+ ...defaultReaders({ request }),
372
+ store: fingerprintStore(join(recoveryStateRoot(), "resume-fingerprints.json")),
373
+ });
374
+ }
375
+
365
376
  async function laneProgress(request, laneKey) {
366
377
  try {
367
378
  const lane = (await request("GET", `/api/v1/lanes/${encode(laneKey)}`)).data;
368
- return { status: lane?.status ?? null, finished: doneCheckRecorded(lane), blocked: laneBlockedReason(lane), finishEvidence: laneFinishEvidence(lane), coordinatorGate: coordinatorGateNote(lane) };
379
+ return { lane, status: lane?.status ?? null, finished: doneCheckRecorded(lane), blocked: laneBlockedReason(lane), finishEvidence: laneFinishEvidence(lane), coordinatorGate: coordinatorGateNote(lane) };
369
380
  } catch {
370
- return { status: null, finished: false, blocked: null, finishEvidence: null, coordinatorGate: null };
381
+ return { lane: null, status: null, finished: false, blocked: null, finishEvidence: null, coordinatorGate: null };
371
382
  }
372
383
  }
373
384
 
@@ -412,9 +423,10 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
412
423
  now = () => new Date(),
413
424
  markExhausted = recordExhaustedAccount,
414
425
  tellCoordinator = messageCoordinator,
426
+ recordBaseline = blockerBaselineAtExit,
415
427
  } = {}) {
416
428
  const worktree = await inspect(worktrees);
417
- const { status, finished, blocked, finishEvidence, coordinatorGate } = await laneProgress(request, laneKey);
429
+ const { lane, status, finished, blocked, finishEvidence, coordinatorGate } = await laneProgress(request, laneKey);
418
430
  const clean = exitCode === 0 && !signal;
419
431
  const exitRef = signal ? `signal ${signal}` : String(exitCode ?? -1);
420
432
  const exited = signal ? `was ended by ${signal}` : `exited with code ${exitCode ?? -1}`;
@@ -426,6 +438,17 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
426
438
  let outcome;
427
439
  let body;
428
440
  let accountFailure = null;
441
+ // NODII-DEV-CLI-191: a run that died on its account says so, and the
442
+ // account is recorded exhausted so lane resume does not relaunch onto it.
443
+ const readAccountFailure = async (logTail) => {
444
+ const failure = signal ? NO_FAILURE : classifyRuntimeFailure(logTail, { now: now() });
445
+ if (!failure.kind) return { failure, note: "" };
446
+ const account = profilePath(profile) || join(home ?? homedir(), runtime === "codex" ? ".codex" : ".claude");
447
+ const until = failure.resetAt ?? new Date(now().getTime() + ACCOUNT_WAIT_MS[failure.kind]).toISOString();
448
+ accountFailure = { kind: failure.kind, resetAt: failure.resetAt, until, profile: account };
449
+ await markExhausted(account, { kind: failure.kind, resetAt: failure.resetAt, until, laneKey, runId, line: failure.line, recordedAt: now().toISOString() }).catch(() => {});
450
+ return { failure, note: ` The runtime's log shows an account failure (${failure.kind}, ${failure.resetAt ? `resets ${failure.resetAt}` : "no reset time given"}): ${JSON.stringify(failure.line.slice(0, 300))}. ${account} is recorded exhausted until ${until}: lane resume moves the lane to another account with headroom, or refuses ACCOUNT_EXHAUSTED until then.` };
451
+ };
429
452
  if (finished && clean) {
430
453
  outcome = worktree.state === "clean" ? "done" : "handed_off";
431
454
  body = outcome === "done"
@@ -434,26 +457,22 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
434
457
  } else if (finished) {
435
458
  // A finished lane has nothing to resume, so a failed exit is not a death.
436
459
  outcome = "failed";
437
- body = { status: "failed", reason: `The lane process ${exited} after lane ${laneKey} reached ${status}.`, evidence };
460
+ // A lane whose done check is recorded but which is not terminal (READY,
461
+ // waiting to land) can still be resumed: its account death is recorded.
462
+ const { note } = FINISHED_LANE.has(status) ? { note: "" } : await readAccountFailure(redactRunText(await tail(logPath).catch(() => "")).trim());
463
+ body = { status: "failed", reason: `The lane process ${exited} after lane ${laneKey} reached ${status}.${note}`, evidence };
438
464
  } else if (blocked) {
439
465
  // hub-58 (30 Oct): a lane that recorded BLOCKED stopped on purpose. Its
440
466
  // run ends blocked: never an orphan, never a death to resume.
441
467
  outcome = "blocked";
442
468
  body = { status: "blocked", reason: `${blocked} The lane process ${exited} while BLOCKED.`, evidence };
469
+ // NODII-DEV-CLI-191: what it stopped knowing is the baseline the next
470
+ // --if-changed compares with, so its own last heartbeat is not a change.
471
+ await recordBaseline(laneKey, lane, { request }).catch(() => {});
443
472
  } else {
444
473
  outcome = "process_exit";
445
474
  const logTail = redactRunText(await tail(logPath).catch(() => "")).trim();
446
- // NODII-DEV-CLI-191: a run that died on its account says so, and the
447
- // account is recorded exhausted so lane resume does not relaunch onto it.
448
- const failure = signal ? NO_FAILURE : classifyRuntimeFailure(logTail, { now: now() });
449
- let accountNote = "";
450
- if (failure.kind) {
451
- const account = profilePath(profile) || join(home ?? homedir(), runtime === "codex" ? ".codex" : ".claude");
452
- const until = failure.resetAt ?? new Date(now().getTime() + ACCOUNT_WAIT_MS[failure.kind]).toISOString();
453
- accountFailure = { kind: failure.kind, resetAt: failure.resetAt, until, profile: account };
454
- await markExhausted(account, { kind: failure.kind, resetAt: failure.resetAt, until, laneKey, runId, line: failure.line, recordedAt: now().toISOString() }).catch(() => {});
455
- accountNote = ` The runtime's log shows an account failure (${failure.kind}, ${failure.resetAt ? `resets ${failure.resetAt}` : "no reset time given"}): ${JSON.stringify(failure.line.slice(0, 300))}. ${account} is recorded exhausted until ${until}: lane resume moves the lane to another account with headroom, or refuses ACCOUNT_EXHAUSTED until then.`;
456
- }
475
+ const { failure, note: accountNote } = await readAccountFailure(logTail);
457
476
  body = {
458
477
  reason: `The lane process ${exited} before lane ${laneKey}'s done check was recorded (lane ${status ?? "status unknown"}), so the run is unfinished; its worktree is ${worktree.state}.${continuations ? ` It was continued in the same session ${continuations} time${continuations === 1 ? "" : "s"} first (NODII-DEV-CLI-9).` : ""}${accountNote}`,
459
478
  deathFingerprint: failure.kind ? `lane-account-${failure.kind}` : signal ? `lane-signal-${signal}` : clean ? "lane-unfinished-exit-0" : `lane-exit-${exitCode ?? -1}`,
@@ -130,6 +130,22 @@ export function fingerprintStore(path) {
130
130
  };
131
131
  }
132
132
 
133
+ /**
134
+ * The fingerprint of what a lane knew when its run stopped BLOCKED, as the
135
+ * baseline the next --if-changed compares with. Without it the baseline is
136
+ * the last resume, so the run's own heartbeat (new waits), a leeway granted
137
+ * and acknowledged mid-run, or an amendment it acknowledged reads as a change
138
+ * once it stops, and it is resumed at once with nothing new. A read that
139
+ * failed leaves the old baseline alone.
140
+ */
141
+ export async function recordBlockerBaseline(lane, { store, ...readers }) {
142
+ const now = await blockerFingerprint(lane, readers);
143
+ if (now.parts.some((part) => /: unreadable \(/.test(part))) return null;
144
+ const value = { fingerprint: now.fingerprint, parts: now.parts, at: new Date().toISOString(), by: "run end (blocked)" };
145
+ await store.set(lane.key, value);
146
+ return value;
147
+ }
148
+
133
149
  /**
134
150
  * Whether to resume a lane now. `record()` stores the fingerprint once the
135
151
  * resume went through, so the next look compares against what it resumed on.
package/dist/surface.js CHANGED
@@ -34,7 +34,7 @@ import { MIN_FIGMA_INTERVAL_MS, figmaRest } from "./figma-rest.js";
34
34
  import { createRenderer } from "./vendor/render-templates.mjs";
35
35
 
36
36
  /** Bumped whenever the emitted code changes shape for the same inputs. */
37
- export const GENERATOR_FORMAT = 41;
37
+ export const GENERATOR_FORMAT = 42;
38
38
  export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
39
39
  export const GENERATED_SUFFIX = ".surface.generated.tsx";
40
40
  /** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
@@ -326,6 +326,9 @@ function catalogStateJoin(entry, row, version) {
326
326
  return (variant) => variantToState.get(variant.id) ?? null;
327
327
  }
328
328
 
329
+ /** The saved-tree format trimTree writes: 2 keeps nested slot content (NODII-DEV-CLI-226). */
330
+ export const TREE_FORMAT = 2;
331
+
329
332
  export function trimTree(entry, { row, version }) {
330
333
  const components = entry.components ?? {};
331
334
  const sets = entry.componentSets ?? {};
@@ -479,6 +482,10 @@ export function trimTree(entry, { row, version }) {
479
482
  return {
480
483
  $comment: "Generated by `nodii-dev surface generate --fetch --write` from Figma's REST nodes API (read-only). The input of the product page's generated file; never edit by hand.",
481
484
  generator: "nodii-dev surface generate",
485
+ // Format 2 keeps nested slot content: an exposed or overridden nested instance keeps its
486
+ // slots (#379), so the corpus gate no longer counts the tree as shallow input. A tree with
487
+ // no treeFormat is format 1 and still generates (NODII-DEV-CLI-226, lane gen-tree).
488
+ treeFormat: TREE_FORMAT,
482
489
  fileKey: row.fileKey,
483
490
  componentSetKey: row.componentSetKey,
484
491
  componentSetName: doc.name,
@@ -2061,7 +2068,7 @@ function dataProps(views, propsType) {
2061
2068
  const ref = `${m[1]}.${m[2]}`;
2062
2069
  const mixed = mixedPiiExpressions(body).find(expression => m.index >= expression.at && m.index < expression.end)?.expression;
2063
2070
  const alternatives = mixed ? [
2064
- `{ kind: "person" } & ${PII_ROW_FIELD}`,
2071
+ `{ kind: "person" } & ${piiRowField(PII_UNION_KIND)}`,
2065
2072
  ...(mixed.includes(`${ref}.kind === "text"`) ? ['{ kind: "text"; text: string }'] : []),
2066
2073
  ...(mixed.includes(`${ref}.kind === "badge"`) ? ['{ kind: "badge"; text: string }'] : []),
2067
2074
  ].join(" | ") : null;
@@ -2781,7 +2788,14 @@ function tabStrip(run, ctx) {
2781
2788
  * PiiText's is offered, so a row can never force a value visible (U05; cli-140).
2782
2789
  */
2783
2790
  const PII_KINDS = new Set(["name", "email", "phone", "address", "dob", "document", "text"]);
2784
- const PII_ROW_FIELD = `{ ${["kind?", "maskHint?", "model", "relation", "value"].map((k) => `${k}: ComponentProps<typeof PiiText>[${JSON.stringify(k.replace("?", ""))}]`).join("; ")} }`;
2791
+ const piiRowField = (kindField) =>
2792
+ `{ ${[`${kindField}?`, "maskHint?", "model", "relation", "value"].map((k) => `${k}: ComponentProps<typeof PiiText>[${JSON.stringify(k === `${kindField}?` ? "kind" : k.replace("?", ""))}]`).join("; ")} }`;
2793
+ const PII_ROW_FIELD = piiRowField("kind");
2794
+ /**
2795
+ * In a person-or-text union `kind` is the discriminant, so the person's PiiText kind is
2796
+ * `piiKind` there: `{ kind: "person" } & { kind?: PiiKind }` is never (NODII-DEV-CLI-225).
2797
+ */
2798
+ const PII_UNION_KIND = "piiKind";
2785
2799
  const PII_ROW_READ = /<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind=/g;
2786
2800
 
2787
2801
  /**
@@ -2947,7 +2961,7 @@ function piiTreeKind(cell) {
2947
2961
  }
2948
2962
 
2949
2963
  /** That cell's PiiText, reading the served pair at `ref` (`row.employee`), with the kind the tree states for it. */
2950
- function piiCellText({ cell, code }, ref) {
2964
+ function piiCellText({ cell, code }, ref, kindField = "kind") {
2951
2965
  const { attrs = "", before = "", after = "" } = piiCellParts({ code }) ?? {};
2952
2966
  const kind = piiTreeKind(cell);
2953
2967
  const size = /\ssize="\w+"/.exec(attrs)?.[0] ?? "";
@@ -2955,7 +2969,7 @@ function piiCellText({ cell, code }, ref) {
2955
2969
  // a permissive ambient provider. Keep the served self relation unchanged.
2956
2970
  // The kind is the record's (a contact column lists emails and phones): the row may say
2957
2971
  // its own, and the kind Figma drew is the default (NODII-DEV-CLI-223).
2958
- return `${before}<PiiText value={${ref}.value} kind={${ref}.kind ?? "${kind}"} model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint} surface="bulk"${size} />${after}`;
2972
+ return `${before}<PiiText value={${ref}.value} kind={${ref}.${kindField} ?? "${kind}"} model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint} surface="bulk"${size} />${after}`;
2959
2973
  }
2960
2974
 
2961
2975
  /** A non-person alternative must be plain text or a plain Badge, never arbitrary JSX. */
@@ -2969,7 +2983,7 @@ function plainPiiAlternative(part) {
2969
2983
  }
2970
2984
 
2971
2985
  function mixedPiiText(mixed, ref) {
2972
- const branches = [`${ref}.kind === "person" ? (${piiCellText(mixed.sample, ref)})`];
2986
+ const branches = [`${ref}.kind === "person" ? (${piiCellText(mixed.sample, ref, PII_UNION_KIND)})`];
2973
2987
  if (mixed.text) branches.push(`${ref}.kind === "text" ? (<>{${ref}.text}</>)`);
2974
2988
  if (mixed.badge) branches.push(`${ref}.kind === "badge" ? (${mixed.badge.replace("__plainCellText__", `${ref}.text`)})`);
2975
2989
  return `{${branches.join(" : ")} : null}`;
@@ -3019,11 +3033,16 @@ export function columnWidth(cell) {
3019
3033
  return null;
3020
3034
  }
3021
3035
  const widthAttr = (w) => (w === null ? "" : typeof w === "number" ? ` width={${w}}` : ` width="${w}"`);
3036
+ /**
3037
+ * The DS Table parts that take a column width (`TableColumnWidthProps`). Others, such as
3038
+ * TableSelectionCell, have no `width` prop, so they never get one (hub-573).
3039
+ */
3040
+ const COLUMN_WIDTH_PART = /^\s*<(?:TableHead|TableSortHead|TableCell)[\s>/]/;
3022
3041
  /** Add `width` to a TableHead/TableCell's opening tag, unless its template already declares one. */
3023
3042
  function withWidth(code, w) {
3024
3043
  if (!code) return code;
3025
3044
  // A cell whose sizing says no width takes none: the placeholder is never left for the page to fill.
3026
- if (w === null) return code.replace(/^(\s*<Table[A-Za-z]*\b[^>]*?)\swidth=\{(?:__s\d+_)?width\}/, "$1");
3045
+ if (w === null || !COLUMN_WIDTH_PART.test(code)) return code.replace(/^(\s*<Table[A-Za-z]*\b[^>]*?)\swidth=\{(?:__s\d+_)?width\}/, "$1");
3027
3046
  const m = /^(\s*<Table[A-Za-z]*)([\s>/])/.exec(code);
3028
3047
  if (!m) return code;
3029
3048
  const tagEnd = code.indexOf(">", m[0].length - 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.181",
3
+ "version": "0.6.183",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {