@nodii/dev 0.6.114 → 0.6.116

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/dist/cli.js CHANGED
@@ -114,6 +114,7 @@ import {
114
114
  import {
115
115
  amendmentGuard,
116
116
  amendLaneCommand,
117
+ foldLaneCommand,
117
118
  laneAuthorityCommand,
118
119
  coordinatorCommand,
119
120
  gatherLaneCommand,
@@ -206,9 +207,11 @@ Usage: nodii-dev <command> [options] [--json]
206
207
  figma lane-reads-script --nodes ID[,ID]
207
208
  # prints the read-only use_figma script that gathers the nodes for --lane-reads
208
209
  figma check|log-write|submit|apply|abandon|release
209
- figma submit CHANGE_SET --file SUBMIT.json [--sync] [--dry-run]
210
+ figma submit CHANGE_SET --file SUBMIT.json [--sync] [--dry-run] [--lane-reads FILE]
210
211
  # --dry-run (submit and resubmit) runs Dev's dry run of the
211
212
  # submit gate on the same body, as design check --change-set; never writes
213
+ # --lane-reads (submit, resubmit, --dry-run): Dev runs no job and answers on
214
+ # the request from your MCP and REST reads; it names any read it still needs
212
215
  # SUBMIT.json: { figmaVersion, writeUp, items: [{ figmaNodeId, change, context,
213
216
  # variants: [{ nodeId, name, context, afterPngBase64 }] }] } (DEC-0204);
214
217
  # a missing writeUp, context or variant name, or an item with no variants,
@@ -231,7 +234,7 @@ Usage: nodii-dev <command> [options] [--json]
231
234
  # must be back at the set's base version first (CHANGE_ITEM_NOT_AT_BASE lists
232
235
  # the ones that differ); a withdrawn item never publishes, and the scopes only
233
236
  # it sat in are released
234
- figma resubmit CHANGE_SET PAYLOAD.json [--sync] [--dry-run]
237
+ figma resubmit CHANGE_SET PAYLOAD.json [--sync] [--dry-run] [--lane-reads FILE]
235
238
  # holder re-submits every rejected item: applying -> in_review, round + 1;
236
239
  # each item needs context, each variant name and context; writeUp optional
237
240
  figma changeset show CHANGE_SET # write-up, items, context, variants, round, decision and comment (with the previous round's)
@@ -315,6 +318,10 @@ Usage: nodii-dev <command> [options] [--json]
315
318
  lane amend <key> --objective|--scope|--rules TEXT --reason TEXT
316
319
  # an --objective or --scope amendment needs the person's recorded
317
320
  # scope_change first (MW1-12.5); a --rules amendment needs none
321
+ lane fold <key> --versions 3,4,5|3-9 --summary TEXT --reason TEXT
322
+ # folds superseded scope/rules amendments into one rules note, so a
323
+ # lane at its note cap (LANE_NOTES_FULL) takes amendments again;
324
+ # coordinator, staff or stepped-up operator (hub-306)
318
325
  lane authority record <key> --kind scope_change|handover|deploy_go --quote TEXT --at ISO [--to-agent ID]
319
326
  # a person's word, verbatim, with when they said it (MW1-12.5);
320
327
  # recorded from their own sign-in, never from a lane's config
@@ -992,6 +999,7 @@ export async function main(argv = process.argv.slice(2)) {
992
999
  return emit({ data: result.data }, json, result.text);
993
1000
  }
994
1001
  if (command === "lane" && action === "amend") return emitCommand(await amendLaneCommand(rest[0], f));
1002
+ if (command === "lane" && action === "fold") return emitCommand(await foldLaneCommand(rest[0], f));
995
1003
  if (command === "lane" && action === "authority") return emitCommand(await laneAuthorityCommand(rest[0], rest[1], f));
996
1004
  if (command === "lane" && action === "gather") {
997
1005
  const result = await gatherLaneCommand(rest[0], f);
@@ -1337,8 +1345,9 @@ export async function main(argv = process.argv.slice(2)) {
1337
1345
  // --dry-run runs Dev's dry run of the submit gate (design check --change-set)
1338
1346
  // on the same body, and never writes (CLI-18).
1339
1347
  const dryRun = async (id, text, file) => {
1348
+ const laneReads = f["lane-reads"] ? await readLaneReads(f["lane-reads"]) : undefined;
1340
1349
  const result = await designCheckChangeSet(undefined, { "change-set": id, ...(text ? { file } : {}), ...(f["figma-version"] ? { "figma-version": f["figma-version"] } : {}), ...(f.sync ? { sync: true } : {}), ...(f.async ? { async: true } : {}) },
1341
- { read: async () => text });
1350
+ { read: async () => text, ...(laneReads ? { laneReads } : {}) }).catch((error) => { throw laneReadsRefusal(error); });
1342
1351
  emit(result.payload, json, result.human);
1343
1352
  if (result.exitCode) {
1344
1353
  if (!json) console.error(`DS_CONFORMANCE_FAILED: ${result.payload.data.findings.length} finding(s)`);
@@ -1361,7 +1370,8 @@ export async function main(argv = process.argv.slice(2)) {
1361
1370
  if (action === "submit") {
1362
1371
  const payload = f.file ? JSON.parse(await readFile(f.file, "utf8")) : { figmaVersion: requireFlag(f, "figma-version") };
1363
1372
  // A 200 carries top-level warnings (STALE_FIGMA_VERSION): print them.
1364
- return emit(await figmaSubmit(rest[0], payload, { sync: submitMode(f), file: f.file || "the submit (no --file)" }), json, (p) =>
1373
+ const laneReads = f["lane-reads"] ? await readLaneReads(f["lane-reads"]) : undefined;
1374
+ return emit(await figmaSubmit(rest[0], payload, { sync: submitMode(f), file: f.file || "the submit (no --file)", ...(laneReads ? { laneReads } : {}) }), json, (p) =>
1365
1375
  [JSON.stringify(p.data, null, 2), ...conformanceLines({ warnings: p.warnings })].join("\n"));
1366
1376
  }
1367
1377
  if (action === "file") {
@@ -1447,7 +1457,7 @@ export async function main(argv = process.argv.slice(2)) {
1447
1457
  return emit(await figmaWithdraw(rest[0]), json, (p) => `Withdrew ${rest[0]}; it is back in ${p.data?.state ?? "editing"}.`);
1448
1458
  }
1449
1459
  if (action === "resubmit")
1450
- return emit(await figmaResubmit(rest[0], rest[1], { sync: submitMode(f) }), json, (p) =>
1460
+ return emit(await figmaResubmit(rest[0], rest[1], { sync: submitMode(f), ...(f["lane-reads"] ? { laneReads: await readLaneReads(f["lane-reads"]) } : {}) }), json, (p) =>
1451
1461
  [`Re-submitted ${rest[0]}; it is ${p.data.state}.`, figmaChangeSetText(p.data), ...conformanceLines({ warnings: p.warnings })].join("\n"));
1452
1462
  if (action === "changeset") {
1453
1463
  if (rest[0] === "list") {
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.114";
7
+ export const VERSION = "0.6.116";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/design.js CHANGED
@@ -445,9 +445,10 @@ export function designCheckText({ data }) {
445
445
  * plus the submit-time guards against the set's items: IMAGE_NOT_TRUECOLOR
446
446
  * refuses; STALE_FIGMA_VERSION is a warning. Changes no state.
447
447
  */
448
- export async function designCheckChangeSet(target, flags, { request = devRequest, send, progress, read = (f) => readFile(f, "utf8") } = {}) {
448
+ export async function designCheckChangeSet(target, flags, { request = devRequest, send, progress, read = (f) => readFile(f, "utf8"), laneReads } = {}) {
449
449
  const id = flags["change-set"];
450
- const sync = submitMode(flags);
450
+ // On the lane's reads Dev answers on the request, with no job (hub-295).
451
+ const sync = laneReads ? true : submitMode(flags);
451
452
  if (id === true || !id) throw new CliError("USAGE", "--change-set needs a change set id, e.g. --change-set CS-123", 2);
452
453
  if (target !== undefined) throw new CliError("USAGE", "design check --change-set CS takes no file: Dev checks the set's own items", 2);
453
454
  if (flags["figma-version"] === true) throw new CliError("USAGE", "--figma-version needs a version id", 2);
@@ -464,6 +465,7 @@ export async function designCheckChangeSet(target, flags, { request = devRequest
464
465
  if (!body || typeof body !== "object" || Array.isArray(body)) throw new CliError("USAGE", `${flags.file}: expected the submit body, a JSON object`, 2);
465
466
  }
466
467
  if (flags["figma-version"]) body = { ...body, figmaVersion: String(flags["figma-version"]) };
468
+ if (laneReads) body = { ...body, laneReads };
467
469
  let p;
468
470
  try {
469
471
  p = await figmaConformance(id, body, { request, sync, ...(send ? { send } : {}), ...(progress ? { progress } : {}) });
package/dist/figma.js CHANGED
@@ -358,7 +358,7 @@ async function submitCall(id, kind, body, { sync = false, request = devRequest,
358
358
  }
359
359
  }
360
360
 
361
- export async function figmaResubmit(id, file, { request = devRequest, read = (f) => readFile(f, "utf8"), ...options } = {}) {
361
+ export async function figmaResubmit(id, file, { request = devRequest, read = (f) => readFile(f, "utf8"), laneReads, ...options } = {}) {
362
362
  if (!id || !file) throw new CliError("USAGE", "figma resubmit CHANGE_SET PAYLOAD.json", 2);
363
363
  let text;
364
364
  try {
@@ -368,8 +368,10 @@ export async function figmaResubmit(id, file, { request = devRequest, read = (f)
368
368
  }
369
369
  const body = assertContext(resubmitPayload(text, file), { resubmit: true, file });
370
370
  try {
371
- return await submitCall(id, "resubmit", body, { request, ...options });
371
+ // On the lane's reads Dev answers on the request, with no job (hub-295).
372
+ return await submitCall(id, "resubmit", laneReads ? { ...body, laneReads } : body, { request, ...options, ...(laneReads ? { sync: true } : {}) });
372
373
  } catch (error) {
374
+ if (error?.code === "FIGMA_READS_NEEDED") throw laneReadsRefusal(error);
373
375
  const say = RESUBMIT_REFUSALS[error?.code];
374
376
  if (!say) throw scopeRefusal(error, id) ?? error;
375
377
  throw new CliError(error.code, say(id, error.details, error.message), error.exitCode ?? 1, error.details);
@@ -473,6 +475,13 @@ export function figmaChangeSetListText(rows = [], total = rows.length) {
473
475
  * the previous round's decision and comment, context and variants. An item with
474
476
  * no variants needs a re-submit (DESIGN-SYSTEM-PARITY-4): it is flagged, never hidden.
475
477
  */
478
+ const JOB_KINDS = { conformance: "dry run", resubmit: "re-submit", represent: "re-present", log_write: "logged write" };
479
+ const jobLine = (job) => {
480
+ const head = `${job.state === "running" || job.state === "queued" ? "job" : "last job"}: ${JOB_KINDS[job.kind] ?? job.kind} ${job.id} ${job.state}`;
481
+ if (job.state !== "failed") return job.finishedAt ? `${head} at ${job.finishedAt}` : head;
482
+ return `${head}${job.finishedAt ? ` at ${job.finishedAt}` : ""}: ${job.error?.code ?? "INTERNAL"}${job.error?.message ? `: ${job.error.message}` : ""}`;
483
+ };
484
+
476
485
  export function figmaChangeSetText(cs) {
477
486
  const c = cs.itemCounts ?? {};
478
487
  const lines = [
@@ -481,6 +490,9 @@ export function figmaChangeSetText(cs) {
481
490
  `${c.total ?? cs.items.length} items: ${c.approved ?? 0} approved, ${c.rejected ?? 0} rejected, ${c.pending ?? 0} pending`,
482
491
  `write-up: ${cs.writeUp ?? (cs.state === "editing" ? "none yet" : `none (${BEFORE_CONTEXT})`)}`,
483
492
  ];
493
+ // Dev shows the running job, else the last one and how it ended (hub-295),
494
+ // so a failed job never reads as no job.
495
+ if (cs.job) lines.push(jobLine(cs.job));
484
496
  for (const item of cs.items ?? []) {
485
497
  lines.push(`- ${item.decision} round ${item.round} ${item.figmaNodeId} ${item.entryKey ?? "(new)"} ${item.change} item ${item.id}`);
486
498
  if (item.comment) lines.push(` comment: ${item.comment}`);
@@ -736,10 +748,14 @@ export function checkSubmitPayload(payload, file = "the submit body") {
736
748
  return assertContext(payload, { file });
737
749
  }
738
750
 
739
- export async function figmaSubmit(id, payload, { request = devRequest, file = "the submit body", ...options } = {}) {
751
+ export async function figmaSubmit(id, payload, { request = devRequest, file = "the submit body", laneReads, ...options } = {}) {
740
752
  checkSubmitPayload(payload, file);
741
- return changeSetCall(id, (method, path, body) => submitCall(id, "submit", body, { request, ...options }))(
742
- "POST", `/api/v1/design/change-sets/${encode(id)}/submit`, payload);
753
+ // On the lane's reads Dev answers on the request, with no job (hub-295).
754
+ const sync = laneReads ? { sync: true } : {};
755
+ return changeSetCall(id, (method, path, body) => submitCall(id, "submit", body, { request, ...options, ...sync }))(
756
+ "POST", `/api/v1/design/change-sets/${encode(id)}/submit`, laneReads ? { ...payload, laneReads } : payload).catch((error) => {
757
+ throw laneReadsRefusal(error);
758
+ });
743
759
  }
744
760
 
745
761
  /** checkDesignConformance: the submit gate's dry run on a change set; changes no state. Body: { figmaVersion?, items? }. Async unless `sync`. */
@@ -1026,11 +1042,18 @@ export async function readLaneReads(path, { read = readFile } = {}) {
1026
1042
  export function laneReadsRefusal(error) {
1027
1043
  if (error?.code !== "FIGMA_READS_NEEDED") return error;
1028
1044
  const ids = error.details?.nodeIds ?? [];
1029
- const next = error.details?.read === "base"
1045
+ const read = error.details?.read;
1046
+ // documents, rest and render are REST reads in the lane's own session; Dev's
1047
+ // message names what to read and where it goes (hub-295).
1048
+ const next = read === "base"
1030
1049
  ? "Compare each with the set's base, add it to base.atBase or base.offBase in the lane-reads file (base.absent if the base version didn't have it, such as the component a create made), and say how in base.how. Then send this again."
1031
- : ids.length
1032
- ? `Add them with the MCP: nodii-dev figma lane-reads-script --nodes ${ids.join(",")}\nThen send this again.`
1033
- : "This check has no MCP path yet: tell the Steward (hub-295).";
1050
+ : read === "render"
1051
+ ? "Add the images to the submit body as Dev says, then send this again."
1052
+ : read === "documents" || read === "rest"
1053
+ ? "Add the answers to the lane-reads file as Dev says, then send this again."
1054
+ : ids.length
1055
+ ? `Add them with the MCP: nodii-dev figma lane-reads-script --nodes ${ids.join(",")}\nThen send this again.`
1056
+ : "This check has no MCP path yet: tell the Steward (hub-295).";
1034
1057
  return new CliError(error.code, `${error.message}\n${next}`, error.exitCode ?? 1, error.details);
1035
1058
  }
1036
1059
 
package/dist/flags.js CHANGED
@@ -28,6 +28,7 @@ export const COMMAND_FLAGS = {
28
28
  "subagents", "notes", "narrowing-note", "narrowing-remainder", "heartbeat-seconds",
29
29
  ],
30
30
  "lane amend": ["objective", "scope", "rules", "reason"],
31
+ "lane fold": ["versions", "summary", "reason"],
31
32
  "lane authority": ["kind", "quote", "at", "to-agent"],
32
33
  "lane start": ["key", "issue", "title", "kind", "side", "repo", "branch", "worktree", "step-limit"],
33
34
  "lane step": ["side", "start", "done", "block", "not-applicable", "reason", "reason-code", "note", "review", "delta"],
@@ -64,8 +65,8 @@ export const COMMAND_FLAGS = {
64
65
  "request file": ["from", "to", "kind", "summary", "spec", "spec-file", "required-capability", "target-artifact-type", "target-artifact-id"],
65
66
  "docs upload": ["class", "change-class", "pending", "decision", "meaning-unchanged", "conformance-ref", "base", "no-embed", ...WAIT],
66
67
  "docs ratify": ["domain", "decision", ...WAIT],
67
- "figma submit": ["file", "figma-version", ...SUBMIT_MODE, "dry-run"],
68
- "figma resubmit": [...SUBMIT_MODE, "dry-run"],
68
+ "figma submit": ["file", "figma-version", ...SUBMIT_MODE, "dry-run", "lane-reads"],
69
+ "figma resubmit": [...SUBMIT_MODE, "dry-run", "lane-reads"],
69
70
  "figma withdraw": ["items", "reason", "lane-reads"],
70
71
  "figma lane-reads-script": ["nodes"],
71
72
  "figma abandon": ["file"],
package/dist/starting.js CHANGED
@@ -723,9 +723,49 @@ const AMEND_REFUSALS = {
723
723
  LANE_LAUNCH_NOT_FOUND: (key) => `${key} was not started with nodii-dev lane launch, so it has no launch contract to amend.`,
724
724
  // MW1-12.5: an objective or scope amendment needs the person's own word.
725
725
  SCOPE_CHANGE_AUTHORITY_REQUIRED: (key) => `An --objective or --scope amendment needs a person's recorded word first: they run nodii-dev lane authority record ${key} --kind scope_change --quote TEXT --at ISO-TIME from their own sign-in. A --rules amendment needs none.`,
726
+ // hub-306: Dev refuses the amendment that would cross the note cap.
727
+ LANE_NOTES_FULL: (key, details) =>
728
+ `${key} would have ${details?.notes ?? "too many"} notes; a lane holds at most ${details?.max ?? 100}. Nothing was recorded. Fold superseded amendments into one note first: nodii-dev lane fold ${key} --versions V,V,... --summary TEXT --reason TEXT (lane show ${key} lists the versions).`,
726
729
  };
727
730
  const ERROR_CODE = /^[A-Z][A-Z0-9_]*$/;
728
731
 
732
+ const FOLD_REFUSALS = {
733
+ LANE_NOT_FOUND: AMEND_REFUSALS.LANE_NOT_FOUND,
734
+ LANE_LAUNCH_NOT_FOUND: AMEND_REFUSALS.LANE_LAUNCH_NOT_FOUND,
735
+ COORDINATOR_REQUIRED: (key) => `Only the machine coordinator that launched ${key}, a staff person, or the operator with a TOTP step-up may fold its amendments.`,
736
+ };
737
+
738
+ /**
739
+ * hub-306: `lane fold <key> --versions 3,4,5 --summary TEXT --reason TEXT`
740
+ * replaces superseded scope or rules amendments with one rules note. The
741
+ * originals stay on the lane and in the audit log; the lane acks the new note.
742
+ */
743
+ export async function foldLaneCommand(key, flags, { request = devRequest } = {}) {
744
+ if (!key) throw new CliError("USAGE", "lane fold needs <key>.", 2);
745
+ const raw = requireFlag(flags, "versions");
746
+ const versions = String(raw).split(",").map((part) => part.trim()).filter(Boolean).flatMap((part) => {
747
+ const range = /^(\d+)-(\d+)$/.exec(part);
748
+ if (!range) return [Number(part)];
749
+ const [from, to] = [Number(range[1]), Number(range[2])];
750
+ if (to < from || to - from > 500) return [Number.NaN];
751
+ return Array.from({ length: to - from + 1 }, (_, index) => from + index);
752
+ });
753
+ if (versions.length < 2 || versions.some((version) => !Number.isInteger(version) || version < 1))
754
+ throw new CliError("USAGE", "lane fold needs --versions with two or more amendment versions, as 3,4,5 or 3-9.", 2);
755
+ const summary = requireFlag(flags, "summary");
756
+ const reason = requireFlag(flags, "reason");
757
+ let payload;
758
+ try {
759
+ payload = await request("POST", `/api/v1/lanes/${encode(key)}/amendments/fold`, { versions, summary, reason, ...via });
760
+ } catch (error) {
761
+ const say = FOLD_REFUSALS[error?.code];
762
+ if (say) throw new CliError(error.code, say(key), error.exitCode ?? 1, error.details);
763
+ throw error;
764
+ }
765
+ const { amendment, folded, notes } = payload.data;
766
+ return { payload, human: `Folded ${folded.length} amendments of ${key} into amendment ${amendment.version}; the lane now has ${notes} notes. Its run acks the new note with lane gather --delta.` };
767
+ }
768
+
729
769
  export async function amendLaneCommand(key, flags, { request = devRequest, now = Date.now, config = readConfig } = {}) {
730
770
  if (!key) throw new CliError("USAGE", "lane amend needs <key>.", 2);
731
771
  const change = Object.fromEntries([["objective", flags.objective], ["scope", flags.scope], ["rules", flags.rules]].filter(([, value]) => value));
@@ -736,7 +776,7 @@ export async function amendLaneCommand(key, flags, { request = devRequest, now =
736
776
  payload = await request("POST", `/api/v1/lanes/${encode(key)}/amendments`, { change, reason, ...via });
737
777
  } catch (error) {
738
778
  const say = AMEND_REFUSALS[error?.code];
739
- if (say) throw new CliError(error.code, say(key), error.exitCode ?? 1, error.details);
779
+ if (say) throw new CliError(error.code, say(key, error.details), error.exitCode ?? 1, error.details);
740
780
  // A Dev before NODII-DEV-CLI-17 answered a recorded amendment with a 409
741
781
  // whose code is the reason itself. Read the lane back for the row.
742
782
  if (error?.code && !ERROR_CODE.test(error.code) && error.code === reason.trim()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.114",
3
+ "version": "0.6.116",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {