@nodii/dev 0.6.61 → 0.6.63

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
@@ -36,6 +36,15 @@ same way (the OAuth client and hosts from the machine's newest config, the
36
36
  person and installation from the token; `NODII_DEV_*` variables override),
37
37
  so a new lane needs no login and no hand-seeded config.
38
38
 
39
+ A typo in `--name` is fixed with `agent rename [ID] --name NEW`: with no ID it
40
+ renames this config's agent, and an ID may be any other agent of yours (Dev
41
+ refuses another person's with `AGENT_OWNER_REQUIRED`). The name is trimmed and
42
+ must be 1–100 characters with no control characters, as at registration.
43
+ `agent list` shows your agents (`*` marks this config's), and
44
+ `agent disconnect ID` retires one. There is no delete: a disconnected agent
45
+ stays on record and its id can't be used again. Disconnecting this config's
46
+ own agent removes it from the config, so the next step is `agent register`.
47
+
39
48
  `nodii-dev` talks only to Dev, through the platform edge
40
49
  (`https://platform.nucleus-cloud.in/devops/*`), signed in as the platform
41
50
  tenant's nodii-dev OAuth app (D1368). There is no other host and no other way
@@ -94,6 +103,9 @@ nodii-dev api OPERATION_ID [--param name=value ...] [--body @file|-|JSON]
94
103
 
95
104
  nodii-dev agent register --name NAME [--session ID] # staff bind the agent to a service on the Dev Agents page
96
105
  nodii-dev agent heartbeat
106
+ nodii-dev agent rename [ID] --name NAME # no ID: this config's agent
107
+ nodii-dev agent list # your agents; * marks this config's
108
+ nodii-dev agent disconnect ID # retire one of your agents; no delete
97
109
  nodii-dev agents spawn SERVICE [--repo-root DIR]
98
110
  nodii-dev agents cowork-tick [--json]
99
111
  nodii-dev agents cowork-tick --plist [--interval SECONDS]
@@ -420,6 +432,15 @@ nodii-dev lane heartbeat KEY [--note TEXT]
420
432
  # a note starting "BLOCKED" or "WAITING:" (capitals) marks
421
433
  # the lane blocked: an exit then ends its run blocked and
422
434
  # never counts toward the two-deaths stop (AGENT-HARNESS-46)
435
+ nodii-dev lane resume --host-lost [--min-free-gb N] [--stagger-seconds N]
436
+ # after a reboot (coordinator): resume every host_lost lane
437
+ # on this machine in priority order, each under its own
438
+ # key, agent, worktree and branch. Stops at the memory floor
439
+ # (default 4 GiB, 15 s between lanes); run it again to carry
440
+ # on (AGENT-HARNESS-67)
441
+ nodii-dev lane transfer KEY --reason TEXT [--to-agent ID]
442
+ # move a host_lost lane to the recovering agent on this
443
+ # machine under a fresh run (AGENT-HARNESS-67)
423
444
  nodii-dev lane resume KEY [--override --reason TEXT]
424
445
  # --override (coordinator): resume a lane the two-identical-
425
446
  # deaths rule stopped; Dev refuses it with
@@ -908,6 +929,7 @@ exits 0 only when every check is `OK`. `--json` returns the same checks as
908
929
  | `figma_scopes` | With `figma_file`, when the file is registered: the change set this agent holds in the file and its lock scopes (or the whole file), or that it holds none (DEC-0032). |
909
930
  | `hooks_claude` | Whether Claude hooks are installed, trusted by that runtime, and have a private firing receipt. |
910
931
  | `hooks_codex_personal`, `hooks_codex_work` | For `~/.codex` and `~/.codex-work`, whether Codex's own hook registry reports the hooks installed and trusted (including managed status), whether the managed absolute CLI is present and new enough, and whether that profile has fired one. |
932
+ | `host_restart` | For the machine's coordinator: whether Dev has recorded this machine's boot, then whether any lane is still `host_lost`. `MISSING` names the next command. Other agents read `OK`. |
911
933
  | `lane_env` | Every `claude` and `codex` process whose working directory is in an active lane's worktree on this machine, and whether its environment carries `NODII_DEV_CONFIG_PATH` naming that lane's `lane-<key>.json`. The managed hooks exit without acting for a process without it (AGENT-HARNESS-61). Run inside a lane, it checks that lane only. `MISSING` names each process; `lane launch` and `lane resume` start the agent with the variable set. `lane check` prints the same report for its lane as `lane_env:` lines, without blocking the review. |
912
934
 
913
935
  Doctor may refresh the access token, as any command does. The permission table
@@ -975,6 +997,40 @@ first.
975
997
 
976
998
  ## Build lanes and repository setup
977
999
 
1000
+ ### After a host crash
1001
+
1002
+ `coordinator start` sends the machine's boot time. Every run whose last
1003
+ heartbeat is older than that boot becomes an Orphan with the reason `host_lost`.
1004
+ It does not count toward the two-identical-deaths stop, and it needs no
1005
+ amendment, `--override` or staff stop. It does the same for a
1006
+ lane's newest run if Dev closed it during the outage, by the heartbeat timeout
1007
+ or the watchdog, as an orphan or as blocked. A run that exited on its own while
1008
+ the host was up keeps its record. The same start takes over the previous
1009
+ coordinator run and lists the `host_lost` lanes.
1010
+
1011
+ To recover a machine, in order:
1012
+
1013
+ ```
1014
+ nodii-dev coordinator start --machine NAME
1015
+ nodii-dev lane resume --host-lost
1016
+ nodii-dev doctor
1017
+ ```
1018
+
1019
+ A lane agent's heartbeat newer than the boot is a live process, so that lane is
1020
+ refused with `LANE_PROCESS_LIVE`. A coordinator heartbeating on schedule
1021
+ disproves a reboot: Dev marks nothing, and the start is refused as usual.
1022
+
1023
+ No session sends a dead agent's identity (K04-10). When a lane should go on
1024
+ under another agent, `lane transfer KEY --reason TEXT [--to-agent ID]` moves it,
1025
+ on the same machine only. The recovering agent is a fresh agent registered as
1026
+ `lane-<key>` (S01-57) with its own id, so Dev refuses any other name
1027
+ (`TRANSFER_AGENT_NAME_REQUIRED`). The machine's coordinator may do this, and so
1028
+ may that session under its own agent, for a lane held by the same person.
1029
+ Dev fences the dead run, starts a fresh one and moves the lane's issue claims.
1030
+ Change sets, their file locks and the old agent's other claims move too, unless
1031
+ that agent has another active lane; then they stay and are listed. Move one
1032
+ with `figma transfer CS --to LANE --reason TEXT`.
1033
+
978
1034
  `coordinator start --machine NAME` registers the machine's one watched
979
1035
  coordinator run and shows its running lanes, orphaned runs and unclaimed
980
1036
  results. A live second coordinator is refused; a coordinator whose heartbeat
package/dist/cli.js CHANGED
@@ -60,7 +60,7 @@ import { tuneCommand } from "./tune.js";
60
60
  import { PICKER_MODEL, TUNING_MODELS, measurePickerLatency, pickTimingStats, pickTimingText, pickTimingsPath, readPickTimings } from "./gather.js";
61
61
  import { docsCommand, rulebookCommand, rulesCommand } from "./upload.js";
62
62
  import { changeSetCommand, guidelineCommand } from "./guidelines.js";
63
- import { designCheck, designCheckChangeSet, designCheckText, designRoles, designRolesText } from "./design.js";
63
+ import { designCheck, designCheckChangeSet, designCheckText, designRoles, designRolesText, surfacesBehind, surfacesBehindText } from "./design.js";
64
64
  import { assertKnownFlags } from "./flags.js";
65
65
  import { watchdogCommand } from "./watchdog.js";
66
66
  import { machineCapacityCommand } from "./accounts.js";
@@ -112,6 +112,11 @@ Usage: nodii-dev <command> [options] [--json]
112
112
  doctor [--figma-file KEY] [--json] # preflight: sign-in, agent, permissions, machine, repo, lane slots,
113
113
  # local Ollama + pinned Gather model, and optional Figma registration
114
114
  agent register --name NAME | agent heartbeat
115
+ agent rename [ID] --name NAME # fix a name; no ID renames this config's agent, an ID
116
+ # may be another of your own agents
117
+ agent list # your agents; * marks this config's agent
118
+ agent disconnect ID # retire one of your agents (there is no delete); its id
119
+ # can't be used again
115
120
  issues list|show|create|update|claim|release
116
121
  issues comment ISSUE --body TEXT # or --body-file FILE; issues update --comment TEXT|--comment-file FILE adds one too
117
122
  issues transition ISSUE --to STATUS [--reason TEXT] [--dev-check REF]
@@ -128,6 +133,9 @@ Usage: nodii-dev <command> [options] [--json]
128
133
  design guideline propose ENTRY --file FILE.md [--summary TEXT] [--dry-run]
129
134
  design changeset list [--entry KEY] [--state STATE] | show ID
130
135
  design roles [ROLE ...] # the role map: each UI role's one DS component (MW6-14)
136
+ design surfaces behind [--behind] # each Surfaces file and the DS publishes it hasn't taken, with
137
+ # its Surfaces sync issue (MW8-8); lane land refuses a lane whose
138
+ # DS change reaches a file without its approved change set
131
139
  design check FILE_KEY|LINK [--nodes A,B] [--roles R,S] [--library]
132
140
  # the DS conformance check Dev's submit runs, before you submit;
133
141
  # reads Figma with FIGMA_PAT; exit 1 = DS_CONFORMANCE_FAILED or an error (--json: data.passed)
@@ -260,6 +268,16 @@ Usage: nodii-dev <command> [options] [--json]
260
268
  # its last death; the reason is kept on the new run. Any resume is
261
269
  # refused (LANE_PROCESS_LIVE) while the lane has a running run or a
262
270
  # fresh lane-agent heartbeat since the death: one process per lane
271
+ lane resume --host-lost [--min-free-gb N] [--stagger-seconds N]
272
+ # coordinator, after a reboot: resume every host_lost lane on this machine
273
+ # in priority order under its own key, agent, worktree and branch. No
274
+ # amendment or override. Stops at the memory floor (default 4 GiB); run
275
+ # it again to carry on
276
+ lane transfer <key> --reason TEXT [--to-agent ID]
277
+ # move a host_lost lane to the recovering agent (this config's, or ID), which
278
+ # must be a fresh agent named lane-<key> on the same machine: a fresh run,
279
+ # its claims, change sets and file locks. The lane keeps its key, history,
280
+ # worktree and branch; no identity is reused
263
281
  lane review <key> --file REVIEW.json # base/head, outcome and clause-cited findings
264
282
  lane review <key> --not-required --decision DEC-nnnn|--question ID|--quote TEXT --at ISO-TIME
265
283
  # no review needed for this diff: cites the ruling Dev validates (hub-58)
@@ -689,7 +707,10 @@ export async function main(argv = process.argv.slice(2)) {
689
707
  const agent = c.agentId ? (await devRequest("GET", `/api/v1/agents/${encode(c.agentId)}`)).data : null;
690
708
  return emit({ data: { person: c.person, app: c.clientId, installation: c.installationId, edge: c.edgeUrl, agent } }, json);
691
709
  }
692
- const emitCommand = async (result) => emit(result.payload, json, result.human);
710
+ const emitCommand = async (result) => {
711
+ emit(result.payload, json, result.human);
712
+ if (result.exitCode) process.exitCode = result.exitCode;
713
+ };
693
714
  if (command === "setup") return emitCommand(await setupCommand(f));
694
715
  if (command === "doctor") {
695
716
  if (action) throw new CliError("USAGE", `doctor takes no arguments, got: ${[action, ...rest].join(" ")}`, 2);
@@ -743,6 +764,10 @@ export async function main(argv = process.argv.slice(2)) {
743
764
  }
744
765
  if (command === "design" && action === "changeset") return emitCommand(await changeSetCommand(rest[0], rest.slice(1), f));
745
766
  if (command === "design" && action === "roles") return emit(await designRoles(rest), json, designRolesText);
767
+ if (command === "design" && action === "surfaces") {
768
+ if (rest[0] !== "behind" || rest.length > 1) throw new CliError("USAGE", "Usage: nodii-dev design surfaces behind [--behind]", 2);
769
+ return emit(await surfacesBehind({ onlyBehind: Boolean(f.behind) }), json, surfacesBehindText);
770
+ }
746
771
  if (command === "design" && action === "check") {
747
772
  if ((!rest[0] && f["change-set"] === undefined) || rest.length > 1)
748
773
  throw new CliError("USAGE", "design check FILE_KEY|LINK [--nodes A,B] [--roles R,S] [--library] | design check --change-set CS [--file SUBMIT.json] [--figma-version V] [--sync]", 2);
@@ -858,6 +883,61 @@ export async function main(argv = process.argv.slice(2)) {
858
883
  json,
859
884
  "Heartbeat recorded.",
860
885
  );
886
+ // Dev admits another agent only when it belongs to the same person, so a
887
+ // typo'd or stale agent whose credential is gone can still be fixed.
888
+ if (action === "rename") {
889
+ const id = rest[0] ?? c.agentId;
890
+ if (!id)
891
+ throw new CliError(
892
+ "USAGE",
893
+ "agent rename needs an agent ID, or a registered agent in this config",
894
+ 2,
895
+ );
896
+ const result = await devRequest(
897
+ "PUT",
898
+ `/api/v1/agents/${encode(id)}/name`,
899
+ { name: requireFlag(f, "name") },
900
+ );
901
+ return emit(result, json, `Renamed ${result.data.id} to ${result.data.name}.`);
902
+ }
903
+ if (action === "list")
904
+ return emit(
905
+ await devRequest("GET", "/api/v1/agents"),
906
+ json,
907
+ (p) =>
908
+ p.data
909
+ .map(
910
+ (a) =>
911
+ `${a.id === c.agentId ? "*" : " "} ${a.id}\t${a.status}\t${a.name}`,
912
+ )
913
+ .join("\n") || "No agents.",
914
+ );
915
+ if (action === "disconnect") {
916
+ const id = rest[0];
917
+ if (!id)
918
+ throw new CliError(
919
+ "USAGE",
920
+ "agent disconnect needs the agent ID (see `nodii-dev agent list`)",
921
+ 2,
922
+ );
923
+ const result = await devRequest(
924
+ "POST",
925
+ `/api/v1/agents/${encode(id)}/disconnect`,
926
+ {},
927
+ );
928
+ // A disconnected agent can't call again: drop it from this config so
929
+ // the next step is a fresh registration, not a refused request.
930
+ if (id === c.agentId) {
931
+ const { agentId: _retired, ...signedIn } = c;
932
+ await writeConfig(signedIn);
933
+ return emit(
934
+ result,
935
+ json,
936
+ `Disconnected ${id}, this config's agent. Run \`nodii-dev agent register --name NAME\` next.`,
937
+ );
938
+ }
939
+ return emit(result, json, `Disconnected ${result.data.name} (${id}).`);
940
+ }
861
941
  }
862
942
  if (command === "issues") return issues(action, rest, f, json);
863
943
  if (command === "inbox") {
@@ -1095,6 +1175,16 @@ export async function main(argv = process.argv.slice(2)) {
1095
1175
  json,
1096
1176
  );
1097
1177
  }
1178
+ if (action === "transfer") {
1179
+ const reason = requireFlag(f, "reason");
1180
+ const to = requireFlag(f, "to");
1181
+ const toAgentId = (await devRequest("GET", `/api/v1/lanes/${encode(to)}`)).data.agentId;
1182
+ return emit(
1183
+ await devRequest("POST", `/api/v1/design/change-sets/${encode(rest[0])}/transfer`, { toAgentId, reason }),
1184
+ json,
1185
+ `${rest[0]}: moved to lane ${to}'s agent ${toAgentId}.`,
1186
+ );
1187
+ }
1098
1188
  if (action === "withdraw")
1099
1189
  return emit(await figmaWithdraw(rest[0]), json, (p) => `Withdrew ${rest[0]}; it is back in ${p.data?.state ?? "editing"}.`);
1100
1190
  if (action === "resubmit")
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.61";
7
+ export const VERSION = "0.6.63";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
@@ -222,7 +222,7 @@ export async function checkLogin() {
222
222
  export const encode = (value) => encodeURIComponent(value);
223
223
  // Switches never take the next token as their value, so
224
224
  // `docs upload --wait rulebook/` keeps rulebook/ as a path.
225
- const SWITCHES = new Set(["json", "wait", "pending", "dry-run", "check", "all", "fleet", "help", "yes", "mine", "no-browser", "include-drafts", "drafted", "library", "async", "sync", "force", "system", "delta", "probe", "no-probe", "not-required", "override", "critical", "no-embed"]);
225
+ const SWITCHES = new Set(["json", "wait", "pending", "dry-run", "check", "all", "fleet", "help", "yes", "mine", "no-browser", "include-drafts", "drafted", "library", "async", "sync", "force", "system", "delta", "probe", "no-probe", "not-required", "override", "critical", "no-embed", "behind"]);
226
226
  export function parseArgs(argv) {
227
227
  const flags = {};
228
228
  const args = [];
package/dist/design.js CHANGED
@@ -53,6 +53,36 @@ export function designRolesText(p) {
53
53
  return lines.join("\n");
54
54
  }
55
55
 
56
+ /**
57
+ * Surfaces behind DS (DESIGN-SYSTEM-PARITY-5, MW8-8): each Surfaces file with
58
+ * the DS publishes it has not taken; `--behind` keeps only those behind.
59
+ */
60
+ export async function surfacesBehind({ onlyBehind = false, request = devRequest } = {}) {
61
+ let payload;
62
+ try {
63
+ payload = await request("GET", "/api/v1/design/surfaces/behind");
64
+ } catch (error) {
65
+ if (error instanceof CliError && ["unroutable", "HTTP_404", "NOT_FOUND", "ROUTE_NOT_FOUND"].includes(error.code))
66
+ throw new CliError("SURFACES_BEHIND_UNAVAILABLE", `Dev doesn't serve Surfaces behind DS yet (GET /design/surfaces/behind, DESIGN-SYSTEM-PARITY-5): ${error.code}: ${error.message}`, 1, error.details);
67
+ throw error;
68
+ }
69
+ return onlyBehind ? { ...payload, data: (payload.data ?? []).filter((file) => file.behind) } : payload;
70
+ }
71
+
72
+ export function surfacesBehindText(p) {
73
+ const files = p.data ?? [];
74
+ if (!files.length) return "No Surfaces files to show.";
75
+ return files
76
+ .map((file) => {
77
+ const head = `${file.name} (${file.file_key})\t${file.behind ? `BEHIND: ${file.pending.length} DS publish${file.pending.length === 1 ? "" : "es"}` : "up to date"}`;
78
+ const rows = file.pending.map(
79
+ (sync) => ` DS ${sync.ds_version}\t${sync.issue_key ?? "no issue"}\t${sync.entries.length ? sync.entries.join(", ") : "unmapped change"}\t${sync.surfaces.length} Surface${sync.surfaces.length === 1 ? "" : "s"}`,
80
+ );
81
+ return [head, ...rows].join("\n");
82
+ })
83
+ .join("\n");
84
+ }
85
+
56
86
  /** The Figma token: FIGMA_PAT, as the design-system scripts read it, or FIGMA_TOKEN. Never printed. */
57
87
  export function figmaToken(env = process.env) {
58
88
  const token = env.FIGMA_PAT || env.FIGMA_TOKEN;