@nodii/dev 0.6.104 → 0.6.106

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
@@ -54,6 +54,9 @@ import {
54
54
  figmaScopeSetText,
55
55
  figmaSubmit,
56
56
  figmaWithdrawItems,
57
+ laneReadsRefusal,
58
+ laneReadsScript,
59
+ readLaneReads,
57
60
  figmaWithdrawItemsText,
58
61
  WITHDRAW_ITEMS_USAGE,
59
62
  withdrawItemsFrom,
@@ -191,6 +194,11 @@ Usage: nodii-dev <command> [options] [--json]
191
194
  figma scope set CHANGE_SET --scope KIND:ID [--scope ...] # narrow to exactly these; the rest frees
192
195
  figma publish-plan FILE_KEY # what to publish, and what to leave unchecked in Figma's dialog
193
196
  figma published FILE_KEY|CHANGE_SET --figma-version V # a file key marks every awaiting set published
197
+ figma apply CHANGE_SET --lane-reads FILE
198
+ # MW1-57.11: what you read through the Figma MCP, sent as data. Dev runs its
199
+ # gates on it with no job and no Figma call; FIGMA_READS_NEEDED names what's missing
200
+ figma lane-reads-script --nodes ID[,ID]
201
+ # prints the read-only use_figma script that gathers the nodes for --lane-reads
194
202
  figma check|log-write|submit|apply|abandon|release
195
203
  figma submit CHANGE_SET --file SUBMIT.json [--sync] [--dry-run]
196
204
  # --dry-run (submit and resubmit) runs Dev's dry run of the
@@ -211,7 +219,7 @@ Usage: nodii-dev <command> [options] [--json]
211
219
  # lane's agent, even from a stopped lane. The target can hold no other lock on
212
220
  # the file (TARGET_HOLDS_FILE_LOCK)
213
221
  figma withdraw CHANGE_SET # holder takes back a submit: in_review -> editing (or a re-submit -> applying)
214
- figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT
222
+ figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT [--lane-reads FILE]
215
223
  # holder, coordinator or operator: take rejected items (item or node ids)
216
224
  # out of an applying set so apply takes the approved ones. Each item's nodes
217
225
  # must be back at the set's base version first (CHANGE_ITEM_NOT_AT_BASE lists
@@ -1355,6 +1363,18 @@ export async function main(argv = process.argv.slice(2)) {
1355
1363
  }
1356
1364
  if (action === "log-write")
1357
1365
  return emit(await figmaLogWrite(rest[0], requireFlag(f, "tool"), requireFlag(f, "nodes").split(",").filter(Boolean)), json);
1366
+ if (action === "lane-reads-script") return console.log(laneReadsScript(f.nodes));
1367
+ if (action === "apply" && f["lane-reads"]) {
1368
+ const laneReads = await readLaneReads(f["lane-reads"]);
1369
+ return emit(
1370
+ await devRequest(
1371
+ "POST",
1372
+ `/api/v1/design/change-sets/${encode(rest[0])}/apply`,
1373
+ { figmaVersion: f["figma-version"] && f["figma-version"] !== true ? f["figma-version"] : laneReads.figmaVersion, laneReads },
1374
+ ).catch((error) => { throw laneReadsRefusal(error); }),
1375
+ json,
1376
+ );
1377
+ }
1358
1378
  if (["apply", "published", "abandon"].includes(action)) {
1359
1379
  const payload = f.file
1360
1380
  ? JSON.parse(await readFile(f.file, "utf8"))
@@ -1383,7 +1403,7 @@ export async function main(argv = process.argv.slice(2)) {
1383
1403
  if (action === "withdraw") {
1384
1404
  if (rest.length > 1) throw new CliError("USAGE", `figma withdraw CHANGE_SET | ${WITHDRAW_ITEMS_USAGE}`, 2);
1385
1405
  if (f.items !== undefined)
1386
- return emit(await figmaWithdrawItems(rest[0], withdrawItemsFrom(f), f.reason === true ? "" : f.reason), json, (p) => figmaWithdrawItemsText(rest[0], p.data));
1406
+ return emit(await figmaWithdrawItems(rest[0], withdrawItemsFrom(f), f.reason === true ? "" : f.reason, f["lane-reads"] ? { laneReads: await readLaneReads(f["lane-reads"]) } : {}).catch((error) => { throw laneReadsRefusal(error); }), json, (p) => figmaWithdrawItemsText(rest[0], p.data));
1387
1407
  if (f.reason !== undefined)
1388
1408
  throw new CliError("USAGE", `--reason goes with --items: ${WITHDRAW_ITEMS_USAGE} (a whole submit is withdrawn with: figma withdraw CHANGE_SET)`, 2);
1389
1409
  return emit(await figmaWithdraw(rest[0]), json, (p) => `Withdrew ${rest[0]}; it is back in ${p.data?.state ?? "editing"}.`);
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.104";
7
+ export const VERSION = "0.6.106";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/doctor.js CHANGED
@@ -404,7 +404,9 @@ export async function doctorCommand(deps = {}) {
404
404
 
405
405
  // No managed hooks means no managed copy: the hook checks above report that.
406
406
  try {
407
- const copy = await (deps.managedStatus ?? managedStatus)();
407
+ // Someone asked now, so not the hour-old answer SessionStart can use: it would
408
+ // call a copy the latest release just after a new one ships.
409
+ const copy = await (deps.managedStatus ?? managedStatus)({ fresh: true });
408
410
  if (copy) {
409
411
  const extra = { cliPath: copy.cliPath, version: copy.version, latest: copy.latest };
410
412
  if (!copy.latest) checks.push(cannot("managed_cli", `${copy.cliPath} is ${copy.version}; the latest release could not be read from npm`, extra));
package/dist/figma.js CHANGED
@@ -950,11 +950,11 @@ const WITHDRAW_ITEMS_REFUSALS = {
950
950
  * must already be back at the set's base version; apply then takes the
951
951
  * approved items alone, and the scopes only those items sat in are released.
952
952
  */
953
- export async function figmaWithdrawItems(id, items, reason, { request = devRequest } = {}) {
953
+ export async function figmaWithdrawItems(id, items, reason, { request = devRequest, laneReads } = {}) {
954
954
  if (!id || !items?.length) throw new CliError("USAGE", WITHDRAW_ITEMS_USAGE, 2);
955
955
  if (typeof reason !== "string" || !reason.trim()) throw new CliError("USAGE", `--reason needs a reason: ${WITHDRAW_ITEMS_USAGE}`, 2);
956
956
  try {
957
- return await request("POST", `/api/v1/design/change-sets/${encode(id)}/withdraw-items`, { items, reason: reason.trim() });
957
+ return await request("POST", `/api/v1/design/change-sets/${encode(id)}/withdraw-items`, { items, reason: reason.trim(), ...(laneReads ? { laneReads } : {}) });
958
958
  } catch (error) {
959
959
  const say = WITHDRAW_ITEMS_REFUSALS[error?.code];
960
960
  if (say) throw new CliError(error.code, say(id, error.message, error.details), error.exitCode ?? 1, error.details);
@@ -974,3 +974,68 @@ export const figmaWithdrawItemsText = (id, d = {}) => {
974
974
  `Next: apply the approved items with nodii-dev figma apply ${d.changeSetId ?? id} --figma-version V`,
975
975
  ].join("\n");
976
976
  };
977
+
978
+ // MW1-57.11: the lane reads Figma through the MCP in its own session, and sends
979
+ // what it read. Dev runs the same gates on that, with no job and no Figma call.
980
+ export async function readLaneReads(path, { read = readFile } = {}) {
981
+ let reads;
982
+ try { reads = JSON.parse(await read(path, "utf8")); }
983
+ catch (error) { throw new CliError("USAGE", `--lane-reads ${path} is not readable JSON: ${error.message}`, 2); }
984
+ if (typeof reads?.figmaVersion !== "string" || !reads.figmaVersion || !Array.isArray(reads.nodes))
985
+ throw new CliError("USAGE", `--lane-reads ${path} needs figmaVersion and nodes. Print the MCP script that gathers nodes with: nodii-dev figma lane-reads-script --nodes A,B`, 2);
986
+ return reads;
987
+ }
988
+
989
+ /** Says what to do about a read Dev asked for. Any other error is left as it is. */
990
+ export function laneReadsRefusal(error) {
991
+ if (error?.code !== "FIGMA_READS_NEEDED") return error;
992
+ const ids = error.details?.nodeIds ?? [];
993
+ const next = error.details?.read === "base"
994
+ ? "Compare each with the set's base, add it to base.atBase or base.offBase in the lane-reads file, and say how in base.how. Then send this again."
995
+ : ids.length
996
+ ? `Add them with the MCP: nodii-dev figma lane-reads-script --nodes ${ids.join(",")}\nThen send this again.`
997
+ : "This check has no MCP path yet: tell the Steward (hub-295).";
998
+ return new CliError(error.code, `${error.message}\n${next}`, error.exitCode ?? 1, error.details);
999
+ }
1000
+
1001
+ const nodeIdList = (value) => String(value === true ? "" : (value ?? "")).split(",").map((x) => x.trim()).filter(Boolean);
1002
+
1003
+ /** A script for the Figma MCP's use_figma: where each node sits, as --lane-reads takes it. It only reads. */
1004
+ export function laneReadsScript(nodes) {
1005
+ const ids = nodeIdList(nodes);
1006
+ if (!ids.length) throw new CliError("USAGE", "figma lane-reads-script --nodes ID[,ID]", 2);
1007
+ return `// Run through the Figma MCP's use_figma. It only reads. Set figmaVersion in the
1008
+ // result to the version you read at (nodii-dev figma changeset show), and add
1009
+ // base: { atBase, offBase, how } if Dev asks for a base comparison.
1010
+ const ids = ${JSON.stringify(ids)};
1011
+ const nodes = [];
1012
+ const gone = [];
1013
+ for (const id of ids) {
1014
+ const node = await figma.getNodeByIdAsync(id);
1015
+ const ancestorIds = [];
1016
+ let page = null;
1017
+ let set = null;
1018
+ let top = node && (node.type === "COMPONENT" || node.type === "COMPONENT_SET") ? node : null;
1019
+ for (let at = node ? node.parent : null; at; at = at.parent) {
1020
+ if (at.type === "PAGE") { page = at; break; }
1021
+ ancestorIds.unshift(at.id);
1022
+ if (at.type === "COMPONENT_SET" && !set) set = at;
1023
+ if (at.type === "COMPONENT" || at.type === "COMPONENT_SET") top = at;
1024
+ }
1025
+ // A node with no page is deleted, whatever else still answers for it.
1026
+ if (!node || !page) { gone.push(id); continue; }
1027
+ nodes.push({
1028
+ id,
1029
+ type: node.type,
1030
+ name: node.name,
1031
+ pageId: page.id,
1032
+ pageName: page.name,
1033
+ ancestorIds,
1034
+ componentSetId: set ? set.id : null,
1035
+ componentSetName: set ? set.name : null,
1036
+ topComponent: top ? { id: top.id, name: top.name } : null,
1037
+ });
1038
+ }
1039
+ return { figmaVersion: "SET-ME", nodes, gone };
1040
+ `;
1041
+ }
package/dist/flags.js CHANGED
@@ -66,11 +66,12 @@ export const COMMAND_FLAGS = {
66
66
  "docs ratify": ["domain", "decision", ...WAIT],
67
67
  "figma submit": ["file", "figma-version", ...SUBMIT_MODE, "dry-run"],
68
68
  "figma resubmit": [...SUBMIT_MODE, "dry-run"],
69
- "figma withdraw": ["items", "reason"],
69
+ "figma withdraw": ["items", "reason", "lane-reads"],
70
+ "figma lane-reads-script": ["nodes"],
70
71
  "figma abandon": ["file"],
71
72
  // hub-260: list takes these; show takes none.
72
73
  "figma changeset": ["file", "actionable", "all", "limit"],
73
- "figma apply": ["file", "figma-version"],
74
+ "figma apply": ["file", "figma-version", "lane-reads"],
74
75
  "figma lock": ["title", "scope"],
75
76
  "surface generate": ["write", "check", "fetch", "all", "module", "type", "figma-version", "report", "post-scoreboard", "resume"],
76
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.104",
3
+ "version": "0.6.106",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {