@nodii/dev 0.6.114 → 0.6.115

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
@@ -206,9 +206,11 @@ Usage: nodii-dev <command> [options] [--json]
206
206
  figma lane-reads-script --nodes ID[,ID]
207
207
  # prints the read-only use_figma script that gathers the nodes for --lane-reads
208
208
  figma check|log-write|submit|apply|abandon|release
209
- figma submit CHANGE_SET --file SUBMIT.json [--sync] [--dry-run]
209
+ figma submit CHANGE_SET --file SUBMIT.json [--sync] [--dry-run] [--lane-reads FILE]
210
210
  # --dry-run (submit and resubmit) runs Dev's dry run of the
211
211
  # submit gate on the same body, as design check --change-set; never writes
212
+ # --lane-reads (submit, resubmit, --dry-run): Dev runs no job and answers on
213
+ # the request from your MCP and REST reads; it names any read it still needs
212
214
  # SUBMIT.json: { figmaVersion, writeUp, items: [{ figmaNodeId, change, context,
213
215
  # variants: [{ nodeId, name, context, afterPngBase64 }] }] } (DEC-0204);
214
216
  # a missing writeUp, context or variant name, or an item with no variants,
@@ -231,7 +233,7 @@ Usage: nodii-dev <command> [options] [--json]
231
233
  # must be back at the set's base version first (CHANGE_ITEM_NOT_AT_BASE lists
232
234
  # the ones that differ); a withdrawn item never publishes, and the scopes only
233
235
  # it sat in are released
234
- figma resubmit CHANGE_SET PAYLOAD.json [--sync] [--dry-run]
236
+ figma resubmit CHANGE_SET PAYLOAD.json [--sync] [--dry-run] [--lane-reads FILE]
235
237
  # holder re-submits every rejected item: applying -> in_review, round + 1;
236
238
  # each item needs context, each variant name and context; writeUp optional
237
239
  figma changeset show CHANGE_SET # write-up, items, context, variants, round, decision and comment (with the previous round's)
@@ -1337,8 +1339,9 @@ export async function main(argv = process.argv.slice(2)) {
1337
1339
  // --dry-run runs Dev's dry run of the submit gate (design check --change-set)
1338
1340
  // on the same body, and never writes (CLI-18).
1339
1341
  const dryRun = async (id, text, file) => {
1342
+ const laneReads = f["lane-reads"] ? await readLaneReads(f["lane-reads"]) : undefined;
1340
1343
  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 });
1344
+ { read: async () => text, ...(laneReads ? { laneReads } : {}) }).catch((error) => { throw laneReadsRefusal(error); });
1342
1345
  emit(result.payload, json, result.human);
1343
1346
  if (result.exitCode) {
1344
1347
  if (!json) console.error(`DS_CONFORMANCE_FAILED: ${result.payload.data.findings.length} finding(s)`);
@@ -1361,7 +1364,8 @@ export async function main(argv = process.argv.slice(2)) {
1361
1364
  if (action === "submit") {
1362
1365
  const payload = f.file ? JSON.parse(await readFile(f.file, "utf8")) : { figmaVersion: requireFlag(f, "figma-version") };
1363
1366
  // 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) =>
1367
+ const laneReads = f["lane-reads"] ? await readLaneReads(f["lane-reads"]) : undefined;
1368
+ return emit(await figmaSubmit(rest[0], payload, { sync: submitMode(f), file: f.file || "the submit (no --file)", ...(laneReads ? { laneReads } : {}) }), json, (p) =>
1365
1369
  [JSON.stringify(p.data, null, 2), ...conformanceLines({ warnings: p.warnings })].join("\n"));
1366
1370
  }
1367
1371
  if (action === "file") {
@@ -1447,7 +1451,7 @@ export async function main(argv = process.argv.slice(2)) {
1447
1451
  return emit(await figmaWithdraw(rest[0]), json, (p) => `Withdrew ${rest[0]}; it is back in ${p.data?.state ?? "editing"}.`);
1448
1452
  }
1449
1453
  if (action === "resubmit")
1450
- return emit(await figmaResubmit(rest[0], rest[1], { sync: submitMode(f) }), json, (p) =>
1454
+ return emit(await figmaResubmit(rest[0], rest[1], { sync: submitMode(f), ...(f["lane-reads"] ? { laneReads: await readLaneReads(f["lane-reads"]) } : {}) }), json, (p) =>
1451
1455
  [`Re-submitted ${rest[0]}; it is ${p.data.state}.`, figmaChangeSetText(p.data), ...conformanceLines({ warnings: p.warnings })].join("\n"));
1452
1456
  if (action === "changeset") {
1453
1457
  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.115";
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
@@ -64,8 +64,8 @@ export const COMMAND_FLAGS = {
64
64
  "request file": ["from", "to", "kind", "summary", "spec", "spec-file", "required-capability", "target-artifact-type", "target-artifact-id"],
65
65
  "docs upload": ["class", "change-class", "pending", "decision", "meaning-unchanged", "conformance-ref", "base", "no-embed", ...WAIT],
66
66
  "docs ratify": ["domain", "decision", ...WAIT],
67
- "figma submit": ["file", "figma-version", ...SUBMIT_MODE, "dry-run"],
68
- "figma resubmit": [...SUBMIT_MODE, "dry-run"],
67
+ "figma submit": ["file", "figma-version", ...SUBMIT_MODE, "dry-run", "lane-reads"],
68
+ "figma resubmit": [...SUBMIT_MODE, "dry-run", "lane-reads"],
69
69
  "figma withdraw": ["items", "reason", "lane-reads"],
70
70
  "figma lane-reads-script": ["nodes"],
71
71
  "figma abandon": ["file"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.114",
3
+ "version": "0.6.115",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {