@nodii/dev 0.6.133 → 0.6.135

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
@@ -118,6 +118,7 @@ import {
118
118
  amendmentGuard,
119
119
  amendLaneCommand,
120
120
  foldLaneCommand,
121
+ laneAmendmentsCommand,
121
122
  laneAuthorityCommand,
122
123
  coordinatorCommand,
123
124
  gatherLaneCommand,
@@ -196,7 +197,9 @@ Usage: nodii-dev <command> [options] [--json]
196
197
  # scopes: component:NODE page:NODE section:NODE foundations create:PAGE:NAME;
197
198
  # no --scope locks the whole file (DEC-0032)
198
199
  figma scope add CHANGE_SET --scope KIND:ID [--scope ...] # widen a held set's scopes
199
- figma scope set CHANGE_SET --scope KIND:ID [--scope ...] # narrow to exactly these; the rest frees
200
+ figma scope set CHANGE_SET --scope KIND:ID [--scope ...] [--lane-reads FILE]
201
+ # narrow to exactly these; the rest frees. The gate runs on your
202
+ # MCP and REST reads; reads over 8 MB go up to the set in chunks (hub-310)
200
203
  figma publish-plan FILE_KEY [--lane-reads FILE]
201
204
  # what to publish, and what to leave unchecked in Figma's dialog. With
202
205
  # --lane-reads Dev runs no job: it takes your MCP reads, and the version
@@ -344,8 +347,17 @@ Usage: nodii-dev <command> [options] [--json]
344
347
  # Figma scope by published key: --route derives it from the
345
348
  # DS catalog (route -> Surfaces -> componentSetKey -> file)
346
349
  lane amend <key> --objective|--scope|--rules TEXT --reason TEXT
347
- # an --objective or --scope amendment needs the person's recorded
348
- # scope_change first (MW1-12.5); a --rules amendment needs none
350
+ # hub-400: a coordinator's or steward's amendment waits for the
351
+ # operator's approval; prints the diff against the lane's brief and the
352
+ # open.md line. A pivot (most of the brief rewritten) is refused
353
+ # AMENDMENT_IS_A_PIVOT: stop the lane --launched-in-error instead.
354
+ # The stepped-up operator's own amendment applies at once; the operator's
355
+ # approval is the recorded word an --objective/--scope one needs (MW1-12.5)
356
+ lane amendments [<key>] [--all|--state pending|approved|rejected|withdrawn|refused_pivot]
357
+ lane amendments show|withdraw <request>
358
+ lane amendments approve|reject <request> [--note TEXT]
359
+ # approve/reject: the operator only (TOTP step-up); approval applies the
360
+ # amendment and the lane acks it with lane gather --delta
349
361
  lane fold <key> --versions 3,4,5|3-9 --summary TEXT --reason TEXT
350
362
  # folds superseded scope/rules amendments into one rules note, so a
351
363
  # lane at its note cap (LANE_NOTES_FULL) takes amendments again;
@@ -477,6 +489,10 @@ Usage: nodii-dev <command> [options] [--json]
477
489
  lane freeze swap <key> --section SECTION [--item ID] --file VALUE.json --reason TEXT
478
490
  lane freeze show|history <key> # durable compact-safe contract and all versions
479
491
  lane stop <key> [<key> ...] --reason TEXT [--sweeper LANE] [--no-closeout] [--no-closeout-push]
492
+ [--launched-in-error [--replaced-by NEW_KEY]]
493
+ # hub-400: a lane launched with the wrong brief is stopped, not pivoted;
494
+ # the operator may stop it so alone; its coordinator only as replaced
495
+ # (MW1-28.2): --replaced-by the lane launched with the correct brief
480
496
  # hub-268: several keys stop one after another in one process, so the
481
497
  # operator's one TOTP code covers them all; a lane that fails is reported
482
498
  # and the rest still stop (LANE_STOP_INCOMPLETE names each failure)
@@ -1074,6 +1090,7 @@ export async function main(argv = process.argv.slice(2)) {
1074
1090
  return emit({ data: result.data }, json, result.text);
1075
1091
  }
1076
1092
  if (command === "lane" && action === "amend") return emitCommand(await amendLaneCommand(rest[0], f));
1093
+ if (command === "lane" && action === "amendments") return emitCommand(await laneAmendmentsCommand(rest, f));
1077
1094
  if (command === "lane" && action === "fold") return emitCommand(await foldLaneCommand(rest[0], f));
1078
1095
  if (command === "lane" && action === "authority") return emitCommand(await laneAuthorityCommand(rest[0], rest[1], f));
1079
1096
  if (command === "lane" && action === "gather") {
@@ -1410,8 +1427,10 @@ export async function main(argv = process.argv.slice(2)) {
1410
1427
  if (action === "lock")
1411
1428
  return emit(await figmaLock(rest[0], requireFlag(f, "title"), { scopes: scopesFrom(f), ...(f["lane-reads"] ? { laneReads: await readLaneReads(f["lane-reads"]) } : {}) }).catch((error) => { throw laneReadsRefusal(error); }), json, (p) => figmaLockText(p.data));
1412
1429
  if (action === "scope") {
1413
- if (!["add", "set"].includes(rest[0]) || !rest[1] || rest.length > 2) throw new CliError("USAGE", "figma scope add|set CHANGE_SET --scope KIND:ID [--scope ...]", 2);
1414
- if (rest[0] === "set") return emit(await figmaScopeSet(rest[1], scopesFrom(f)), json, (p) => figmaScopeSetText(rest[1], p.data));
1430
+ if (!["add", "set"].includes(rest[0]) || !rest[1] || rest.length > 2) throw new CliError("USAGE", "figma scope add|set CHANGE_SET --scope KIND:ID [--scope ...] (set also takes --lane-reads FILE)", 2);
1431
+ if (rest[0] === "set")
1432
+ return emit(await figmaScopeSet(rest[1], scopesFrom(f), f["lane-reads"] ? { laneReads: await readLaneReads(f["lane-reads"]) } : {}), json, (p) => figmaScopeSetText(rest[1], p.data));
1433
+ if (f["lane-reads"]) throw new CliError("USAGE", "figma scope add does not take --lane-reads: Dev reads nothing to widen a set. Narrowing takes them: figma scope set CHANGE_SET --scope KIND:ID --lane-reads FILE", 2);
1415
1434
  return emit(await figmaScopeAdd(rest[1], scopesFrom(f)), json, (p) =>
1416
1435
  `${rest[1]} holds ${p.data?.scopes?.length ?? "its"} scope(s)${p.data?.scopes?.length ? `: ${p.data.scopes.map(scopeText).join(", ")}` : ""}`);
1417
1436
  }
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.133";
7
+ export const VERSION = "0.6.135";
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
@@ -706,11 +706,14 @@ export async function figmaScopeAdd(id, scopes, { request = devRequest, laneScop
706
706
  * sit inside what the set holds: the whole file holds everything, a page its
707
707
  * components and creates.
708
708
  */
709
- export async function figmaScopeSet(id, scopes, { request = devRequest, laneScope = currentLaneFigmaScope } = {}) {
710
- if (!id || !scopes.length) throw new CliError("USAGE", `figma scope set CHANGE_SET ${SCOPE_USAGE} [--scope ...]`, 2);
709
+ export async function figmaScopeSet(id, scopes, { request = devRequest, laneScope = currentLaneFigmaScope, laneReads, progress } = {}) {
710
+ if (!id || !scopes.length) throw new CliError("USAGE", `figma scope set CHANGE_SET ${SCOPE_USAGE} [--scope ...] [--lane-reads FILE]`, 2);
711
711
  await assertChangeSetInLaneScope(id, scopes, request, laneScope);
712
712
  try {
713
- return await request("PUT", `/api/v1/design/change-sets/${encode(id)}/scopes`, { scopes });
713
+ // MW1-57.11: the narrowing's gate runs on the lane's reads; reads over a
714
+ // chunk go up to the set first and are named by readIds (hub-310).
715
+ const reads = await laneReadsBody(id, laneReads, { request, ...(progress ? { progress } : {}) });
716
+ return await request("PUT", `/api/v1/design/change-sets/${encode(id)}/scopes`, { scopes, ...reads });
714
717
  } catch (error) {
715
718
  if (error?.code === "SCOPE_NOT_NARROWER")
716
719
  throw new CliError(error.code, `${error.message}\nscope set only narrows; to claim more, run nodii-dev figma scope add ${id} --scope ...`, error.exitCode ?? 1, error.details);
@@ -725,7 +728,7 @@ export async function figmaScopeSet(id, scopes, { request = devRequest, laneScop
725
728
  error.exitCode ?? 1,
726
729
  error.details,
727
730
  );
728
- throw scopeRefusal(error, id) ?? error;
731
+ throw laneReadsRefusal(scopeRefusal(error, id) ?? error);
729
732
  }
730
733
  }
731
734
 
package/dist/flags.js CHANGED
@@ -29,6 +29,7 @@ export const COMMAND_FLAGS = {
29
29
  ],
30
30
  "lane amend": ["objective", "scope", "rules", "reason"],
31
31
  "lane fold": ["versions", "summary", "reason"],
32
+ "lane amendments": ["all", "state", "note"],
32
33
  "lane authority": ["kind", "quote", "at", "to-agent"],
33
34
  "lane start": ["key", "issue", "title", "kind", "side", "repo", "branch", "worktree", "step-limit"],
34
35
  "lane step": ["side", "start", "done", "block", "not-applicable", "reason", "reason-code", "note", "review", "delta"],
@@ -44,7 +45,7 @@ export const COMMAND_FLAGS = {
44
45
  "lane resume": ["override", "reason", "host-lost", "min-free-gb", "stagger-seconds", "profile", "class"],
45
46
  "lane transfer": ["reason", "to-agent"],
46
47
  "inbox ack": ["note"],
47
- "lane stop": ["reason", "sweeper", "no-closeout", "no-closeout-push"],
48
+ "lane stop": ["reason", "sweeper", "no-closeout", "no-closeout-push", "launched-in-error", "replaced-by"],
48
49
  "lane closeout": ["reason"],
49
50
  "lane repo": ["repo", "branch", "worktree", "read-only", "reason"],
50
51
  // hub-232: the honest close-out and the governor.
@@ -75,6 +76,7 @@ export const COMMAND_FLAGS = {
75
76
  "figma changeset": ["file", "actionable", "all", "limit"],
76
77
  "figma apply": ["file", "figma-version", "lane-reads"],
77
78
  "figma lock": ["title", "scope", "lane-reads"],
79
+ "figma scope": ["scope", "lane-reads"],
78
80
  "surface generate": ["write", "check", "fetch", "all", "module", "type", "figma-version", "report", "post-scoreboard", "resume"],
79
81
  };
80
82
 
package/dist/governor.js CHANGED
@@ -64,6 +64,14 @@ export function governorLines(g) {
64
64
  lines.push(` GOVERNOR_NO_READY: ${g.noReady.length} lane run(s) ended with an open PR and no READY (no done check):`);
65
65
  for (const lane of g.noReady.slice(0, 10)) lines.push(` ${lane.key} ${lane.prs.join(" ")}`);
66
66
  }
67
+ // hub-400: the coordinator meter counts amendments per live lane.
68
+ const amendments = g.amendments;
69
+ if (amendments?.lanes?.length) {
70
+ const t = amendments.totals;
71
+ lines.push(` Amendments: ${t.applied} applied, ${t.pending} waiting for the operator, ${t.notApplied} not applied; ${t.last24h} in the last 24 h. Most amended live lanes:`);
72
+ for (const lane of amendments.lanes.slice(0, 10))
73
+ lines.push(` ${lane.key} ${lane.applied} applied${lane.pending ? `, ${lane.pending} pending` : ""}${lane.notApplied ? `, ${lane.notApplied} not applied` : ""} (${lane.last24h} in 24 h)`);
74
+ }
67
75
  if (g.state !== "open")
68
76
  lines.push(" Close out a lane that marked itself finished, as its machine coordinator (MW1-28.2): nodii-dev lane close <key> --reason TEXT [--delivered-by <verified PR URL|on_dev lane key|done issue key>]. Every other lane needs on_dev or a staff stop (MW1-28).");
69
77
  return lines;
package/dist/lanes.js CHANGED
@@ -1185,7 +1185,19 @@ export async function laneCommand(action, args, flags, deps = {}) {
1185
1185
  if (action === "stop") {
1186
1186
  const reason = requireFlag(flags, "reason");
1187
1187
  // Dev first: a stop it refuses changes nothing on this machine (hub-244).
1188
- const payload = await request("POST", `/api/v1/lanes/${encode(id)}/stop`, { reason, ...(flags.sweeper ? { sweeper: String(flags.sweeper) } : {}), ...via });
1188
+ // hub-400: a lane launched with the wrong brief is stopped, not
1189
+ // pivoted. The operator may stop it so alone; its coordinator names the
1190
+ // lane it launched with the correct brief (MW1-28.2).
1191
+ if (flags["replaced-by"] !== undefined && (flags["replaced-by"] === true || !String(flags["replaced-by"]).trim()))
1192
+ throw new CliError("USAGE", "--replaced-by needs the key of the lane that replaces this one.", 2);
1193
+ const body = {
1194
+ reason,
1195
+ ...(flags.sweeper ? { sweeper: String(flags.sweeper) } : {}),
1196
+ ...(flags["launched-in-error"] ? { launchedInError: true } : {}),
1197
+ ...(flags["replaced-by"] ? { replacedBy: String(flags["replaced-by"]).trim() } : {}),
1198
+ ...via,
1199
+ };
1200
+ const payload = await request("POST", `/api/v1/lanes/${encode(id)}/stop`, body);
1189
1201
  const closing = !flags["no-closeout"];
1190
1202
  // Printed before the close-out starts: the stop is recorded, and what follows only tidies this machine.
1191
1203
  if (closing) stopProgress(deps)(`${ref}: stopped. Closing out on this machine; the stop stands whatever happens next.`);
package/dist/starting.js CHANGED
@@ -719,7 +719,17 @@ export async function launchLaneCommand(key, flags, {
719
719
  // What each amendment refusal means: Dev's message only repeats the code.
720
720
  const AMEND_REFUSALS = {
721
721
  LANE_NOT_FOUND: (key) => `Dev has no lane ${key}.`,
722
- COORDINATOR_REQUIRED: (key) => `Only the machine coordinator that launched ${key} may amend it; run lane amend under that coordinator's identity.`,
722
+ COORDINATOR_REQUIRED: (key) => `Only the machine coordinator that launched ${key} may amend it (or a steward over one of its repositories, or the operator); run lane amend under that coordinator's identity.`,
723
+ // hub-400: a rebrief is small and incremental; a pivot is a new lane.
724
+ AMENDMENT_IS_A_PIVOT: (key, details) =>
725
+ [
726
+ `This amendment changes ${details?.changedPercent === undefined ? "most" : `${details.changedPercent}%`} of ${key}'s brief (${pivotReason(details?.pivot)}): it is a pivot, not a rebrief, and Dev refused it. Nothing reaches the lane.`,
727
+ `Stop ${key} as launched in error and launch a new lane with the correct brief. The operator stops it: nodii-dev lane stop ${key} --launched-in-error --reason TEXT. Its coordinator may stop it only as replaced (MW1-28.2): once the lane with the correct brief, sharing ${key}'s issue, is launched and ${key} has no live run, nodii-dev lane stop ${key} --launched-in-error --replaced-by NEW_KEY --reason TEXT.`,
728
+ details?.diff ? `\nDiff against the current brief:\n${details.diff}` : "",
729
+ ].filter(Boolean).join("\n"),
730
+ AMENDMENT_PENDING: (key, details) =>
731
+ `${key} already has an amendment waiting for the operator (request ${details?.requestId ?? "?"}). Wait for the answer, or take it back: nodii-dev lane amendments withdraw ${details?.requestId ?? "<request>"}.`,
732
+ LANE_TERMINAL: (key, details) => `${key} has ended (${details?.status ?? "terminal"}); it takes no amendment.`,
723
733
  LANE_LAUNCH_NOT_FOUND: (key) => `${key} was not started with nodii-dev lane launch, so it has no launch contract to amend.`,
724
734
  // MW1-12.5: an objective or scope amendment needs the person's own word.
725
735
  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.`,
@@ -729,6 +739,30 @@ const AMEND_REFUSALS = {
729
739
  };
730
740
  const ERROR_CODE = /^[A-Z][A-Z0-9_]*$/;
731
741
 
742
+ function pivotReason(pivot) {
743
+ return (
744
+ {
745
+ brief_rewritten: "it removes or replaces more than half the brief",
746
+ brief_outgrown: "it adds more than half the brief again",
747
+ ask_replaced: "it replaces the ask with a different one",
748
+ }[pivot] ?? "it rewrites most of the brief"
749
+ );
750
+ }
751
+
752
+ /** hub-400: what a pending amendment request prints, with the operator's open.md line (MW4-32). */
753
+ export function pendingAmendmentText(key, request, summary) {
754
+ const reason = String(request.reason ?? "").replace(/\s+/g, " ").slice(0, 160);
755
+ return [
756
+ `Asked the operator to amend ${key}: request ${request.id}, ${summary?.changedPercent ?? request.changedPercent ?? "?"}% of the brief. The lane sees nothing until the operator approves it.`,
757
+ "",
758
+ "Diff against the current brief:",
759
+ request.diff ?? "(Dev sent no diff; read it with nodii-dev lane amendments show " + request.id + ")",
760
+ "",
761
+ "Add the ask to the operator's one sheet, the machine coordinator's file in nodii-infra (docs/open/<coordinator>.md; MW4-31, MW4-32); a steward gives it to the coordinator:",
762
+ `- [ ] Approve lane amendment ${key} (request ${request.id}): ${reason}. Approve: nodii-dev lane amendments approve ${request.id}. Reject: nodii-dev lane amendments reject ${request.id}.`,
763
+ ].join("\n");
764
+ }
765
+
732
766
  const FOLD_REFUSALS = {
733
767
  LANE_NOT_FOUND: AMEND_REFUSALS.LANE_NOT_FOUND,
734
768
  LANE_LAUNCH_NOT_FOUND: AMEND_REFUSALS.LANE_LAUNCH_NOT_FOUND,
@@ -795,9 +829,59 @@ export async function amendLaneCommand(key, flags, { request = devRequest, now =
795
829
  }
796
830
  throw error;
797
831
  }
832
+ // hub-400: Dev holds a coordinator's or steward's amendment for the
833
+ // operator (202); only the stepped-up operator's own applies at once.
834
+ if (payload?.pending) return { payload, human: pendingAmendmentText(key, payload.data, payload.diffSummary) };
798
835
  return { payload, human: `Recorded amendment ${payload.data.version} for ${key}.` };
799
836
  }
800
837
 
838
+ const REQUEST_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
839
+ const requestLine = (r) => `${r.id}\t${r.laneKey}\t${r.state}\t${r.changedPercent}%\t${r.createdAt}\t${String(r.reason ?? "").replace(/\s+/g, " ").slice(0, 100)}`;
840
+
841
+ /**
842
+ * hub-400: `lane amendments [<key>] [--all|--state STATE]`,
843
+ * `lane amendments show|approve|reject|withdraw <request> [--note TEXT]`.
844
+ * Approve and reject are the operator's: the CLI asks for their TOTP code
845
+ * (STAFF_OPERATOR_REQUIRED), and an agent's call is refused as it stands.
846
+ */
847
+ export async function laneAmendmentsCommand(args, flags, { request = devRequest } = {}) {
848
+ const [first, second] = args;
849
+ const decisions = ["show", "approve", "reject", "withdraw"];
850
+ if (decisions.includes(first)) {
851
+ if (!REQUEST_ID.test(second ?? "")) throw new CliError("USAGE", `lane amendments ${first} needs the request id (lane amendments lists them).`, 2);
852
+ const path = `/api/v1/lane-amendment-requests/${encode(second)}`;
853
+ if (first === "show") {
854
+ const r = (await request("GET", path)).data;
855
+ return {
856
+ payload: { data: r },
857
+ 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"),
858
+ };
859
+ }
860
+ const body = first === "withdraw" ? { via: "nodii-dev" } : { ...(flags.note ? { note: String(flags.note) } : {}), via: "nodii-dev" };
861
+ const payload = await request("POST", `${path}/${first}`, body);
862
+ const r = payload.data;
863
+ const human =
864
+ first === "approve"
865
+ ? `Approved: ${r.laneKey} amendment ${payload.amendment?.version ?? "?"} applied. Its run picks it up with nodii-dev lane gather --delta.`
866
+ : first === "reject"
867
+ ? `Rejected: ${r.laneKey} keeps its brief.`
868
+ : `Withdrawn: ${r.laneKey}'s amendment request ${r.id}.`;
869
+ return { payload, human };
870
+ }
871
+ if (first !== undefined && args.length > 1) throw new CliError("USAGE", "lane amendments [<key>] [--all|--state STATE] | show|approve|reject|withdraw <request> [--note TEXT]", 2);
872
+ if (flags.all && flags.state) throw new CliError("USAGE", "lane amendments takes --all or --state, not both.", 2);
873
+ const params = new URLSearchParams();
874
+ if (first) params.set("lane", first);
875
+ if (flags.all) params.set("all", "true");
876
+ else if (flags.state) params.set("state", String(flags.state));
877
+ const search = params.toString();
878
+ const rows = (await request("GET", `/api/v1/lane-amendment-requests${search ? `?${search}` : ""}`)).data ?? [];
879
+ return {
880
+ payload: { data: rows },
881
+ human: rows.length ? rows.map(requestLine).join("\n") : `No ${flags.all ? "" : `${flags.state ?? "pending"} `}lane amendment requests${first ? ` for ${first}` : ""}.`,
882
+ };
883
+ }
884
+
801
885
  // MW1-12.5 (DEC-0418): what each authority refusal means.
802
886
  const AUTHORITY_REFUSALS = {
803
887
  LANE_NOT_FOUND: (key) => `Dev has no lane ${key}.`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.133",
3
+ "version": "0.6.135",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {