@nodii/dev 0.6.62 → 0.6.64

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,46 @@ 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
+
1034
+ A lane that has ended stays ended, so `lane transfer` refuses it
1035
+ (`LANE_ALREADY_TERMINAL`). Its open change sets still move: the holder's machine
1036
+ coordinator or staff runs `figma transfer`, which needs a target that is a live
1037
+ lane's agent (`TRANSFER_TARGET_NOT_LIVE_LANE`) and holds no other lock on that
1038
+ file (`TARGET_HOLDS_FILE_LOCK`).
1039
+
978
1040
  `coordinator start --machine NAME` registers the machine's one watched
979
1041
  coordinator run and shows its running lanes, orphaned runs and unclaimed
980
1042
  results. A live second coordinator is refused; a coordinator whose heartbeat
package/dist/cli.js CHANGED
@@ -46,6 +46,10 @@ import {
46
46
  figmaScopeSet,
47
47
  figmaScopeSetText,
48
48
  figmaSubmit,
49
+ figmaWithdrawItems,
50
+ figmaWithdrawItemsText,
51
+ WITHDRAW_ITEMS_USAGE,
52
+ withdrawItemsFrom,
49
53
  checkSubmitPayload,
50
54
  assertContext,
51
55
  resubmitPayload,
@@ -55,7 +59,7 @@ import {
55
59
  scopesFrom,
56
60
  conformanceLines,
57
61
  } from "./figma.js";
58
- export { figmaLock, submitMode } from "./figma.js";
62
+ export { figmaLock, figmaWithdrawItems, figmaWithdrawItemsText, submitMode, withdrawItemsFrom } from "./figma.js";
59
63
  import { tuneCommand } from "./tune.js";
60
64
  import { PICKER_MODEL, TUNING_MODELS, measurePickerLatency, pickTimingStats, pickTimingText, pickTimingsPath, readPickTimings } from "./gather.js";
61
65
  import { docsCommand, rulebookCommand, rulesCommand } from "./upload.js";
@@ -112,6 +116,11 @@ Usage: nodii-dev <command> [options] [--json]
112
116
  doctor [--figma-file KEY] [--json] # preflight: sign-in, agent, permissions, machine, repo, lane slots,
113
117
  # local Ollama + pinned Gather model, and optional Figma registration
114
118
  agent register --name NAME | agent heartbeat
119
+ agent rename [ID] --name NAME # fix a name; no ID renames this config's agent, an ID
120
+ # may be another of your own agents
121
+ agent list # your agents; * marks this config's agent
122
+ agent disconnect ID # retire one of your agents (there is no delete); its id
123
+ # can't be used again
115
124
  issues list|show|create|update|claim|release
116
125
  issues comment ISSUE --body TEXT # or --body-file FILE; issues update --comment TEXT|--comment-file FILE adds one too
117
126
  issues transition ISSUE --to STATUS [--reason TEXT] [--dev-check REF]
@@ -157,7 +166,17 @@ Usage: nodii-dev <command> [options] [--json]
157
166
  # submit, resubmit and design check --change-set run as a job in Dev
158
167
  # and poll it (a large set outlasts the edge's timeout); --sync waits
159
168
  # on one request instead. A 502/504 is checked against the set, never resent
169
+ figma transfer CHANGE_SET --to LANE --reason TEXT
170
+ # coordinator or staff: move an open set, with its lock and scopes, to a live
171
+ # lane's agent, even from a stopped lane. The target can hold no other lock on
172
+ # the file (TARGET_HOLDS_FILE_LOCK)
160
173
  figma withdraw CHANGE_SET # holder takes back a submit: in_review -> editing (or a re-submit -> applying)
174
+ figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT
175
+ # holder, coordinator or operator: take rejected items (item or node ids)
176
+ # out of an applying set so apply takes the approved ones. Each item's nodes
177
+ # must be back at the set's base version first (CHANGE_ITEM_NOT_AT_BASE lists
178
+ # the ones that differ); a withdrawn item never publishes, and the scopes only
179
+ # it sat in are released
161
180
  figma resubmit CHANGE_SET PAYLOAD.json [--sync] [--dry-run]
162
181
  # holder re-submits every rejected item: applying -> in_review, round + 1;
163
182
  # each item needs context, each variant name and context; writeUp optional
@@ -263,6 +282,16 @@ Usage: nodii-dev <command> [options] [--json]
263
282
  # its last death; the reason is kept on the new run. Any resume is
264
283
  # refused (LANE_PROCESS_LIVE) while the lane has a running run or a
265
284
  # fresh lane-agent heartbeat since the death: one process per lane
285
+ lane resume --host-lost [--min-free-gb N] [--stagger-seconds N]
286
+ # coordinator, after a reboot: resume every host_lost lane on this machine
287
+ # in priority order under its own key, agent, worktree and branch. No
288
+ # amendment or override. Stops at the memory floor (default 4 GiB); run
289
+ # it again to carry on
290
+ lane transfer <key> --reason TEXT [--to-agent ID]
291
+ # move a host_lost lane to the recovering agent (this config's, or ID), which
292
+ # must be a fresh agent named lane-<key> on the same machine: a fresh run,
293
+ # its claims, change sets and file locks. The lane keeps its key, history,
294
+ # worktree and branch; no identity is reused
266
295
  lane review <key> --file REVIEW.json # base/head, outcome and clause-cited findings
267
296
  lane review <key> --not-required --decision DEC-nnnn|--question ID|--quote TEXT --at ISO-TIME
268
297
  # no review needed for this diff: cites the ruling Dev validates (hub-58)
@@ -692,7 +721,10 @@ export async function main(argv = process.argv.slice(2)) {
692
721
  const agent = c.agentId ? (await devRequest("GET", `/api/v1/agents/${encode(c.agentId)}`)).data : null;
693
722
  return emit({ data: { person: c.person, app: c.clientId, installation: c.installationId, edge: c.edgeUrl, agent } }, json);
694
723
  }
695
- const emitCommand = async (result) => emit(result.payload, json, result.human);
724
+ const emitCommand = async (result) => {
725
+ emit(result.payload, json, result.human);
726
+ if (result.exitCode) process.exitCode = result.exitCode;
727
+ };
696
728
  if (command === "setup") return emitCommand(await setupCommand(f));
697
729
  if (command === "doctor") {
698
730
  if (action) throw new CliError("USAGE", `doctor takes no arguments, got: ${[action, ...rest].join(" ")}`, 2);
@@ -865,6 +897,61 @@ export async function main(argv = process.argv.slice(2)) {
865
897
  json,
866
898
  "Heartbeat recorded.",
867
899
  );
900
+ // Dev admits another agent only when it belongs to the same person, so a
901
+ // typo'd or stale agent whose credential is gone can still be fixed.
902
+ if (action === "rename") {
903
+ const id = rest[0] ?? c.agentId;
904
+ if (!id)
905
+ throw new CliError(
906
+ "USAGE",
907
+ "agent rename needs an agent ID, or a registered agent in this config",
908
+ 2,
909
+ );
910
+ const result = await devRequest(
911
+ "PUT",
912
+ `/api/v1/agents/${encode(id)}/name`,
913
+ { name: requireFlag(f, "name") },
914
+ );
915
+ return emit(result, json, `Renamed ${result.data.id} to ${result.data.name}.`);
916
+ }
917
+ if (action === "list")
918
+ return emit(
919
+ await devRequest("GET", "/api/v1/agents"),
920
+ json,
921
+ (p) =>
922
+ p.data
923
+ .map(
924
+ (a) =>
925
+ `${a.id === c.agentId ? "*" : " "} ${a.id}\t${a.status}\t${a.name}`,
926
+ )
927
+ .join("\n") || "No agents.",
928
+ );
929
+ if (action === "disconnect") {
930
+ const id = rest[0];
931
+ if (!id)
932
+ throw new CliError(
933
+ "USAGE",
934
+ "agent disconnect needs the agent ID (see `nodii-dev agent list`)",
935
+ 2,
936
+ );
937
+ const result = await devRequest(
938
+ "POST",
939
+ `/api/v1/agents/${encode(id)}/disconnect`,
940
+ {},
941
+ );
942
+ // A disconnected agent can't call again: drop it from this config so
943
+ // the next step is a fresh registration, not a refused request.
944
+ if (id === c.agentId) {
945
+ const { agentId: _retired, ...signedIn } = c;
946
+ await writeConfig(signedIn);
947
+ return emit(
948
+ result,
949
+ json,
950
+ `Disconnected ${id}, this config's agent. Run \`nodii-dev agent register --name NAME\` next.`,
951
+ );
952
+ }
953
+ return emit(result, json, `Disconnected ${result.data.name} (${id}).`);
954
+ }
868
955
  }
869
956
  if (command === "issues") return issues(action, rest, f, json);
870
957
  if (command === "inbox") {
@@ -1102,8 +1189,24 @@ export async function main(argv = process.argv.slice(2)) {
1102
1189
  json,
1103
1190
  );
1104
1191
  }
1105
- if (action === "withdraw")
1192
+ if (action === "transfer") {
1193
+ const reason = requireFlag(f, "reason");
1194
+ const to = requireFlag(f, "to");
1195
+ const toAgentId = (await devRequest("GET", `/api/v1/lanes/${encode(to)}`)).data.agentId;
1196
+ return emit(
1197
+ await devRequest("POST", `/api/v1/design/change-sets/${encode(rest[0])}/transfer`, { toAgentId, reason }),
1198
+ json,
1199
+ `${rest[0]}: moved to lane ${to}'s agent ${toAgentId}.`,
1200
+ );
1201
+ }
1202
+ if (action === "withdraw") {
1203
+ if (rest.length > 1) throw new CliError("USAGE", `figma withdraw CHANGE_SET | ${WITHDRAW_ITEMS_USAGE}`, 2);
1204
+ if (f.items !== undefined)
1205
+ return emit(await figmaWithdrawItems(rest[0], withdrawItemsFrom(f), f.reason === true ? "" : f.reason), json, (p) => figmaWithdrawItemsText(rest[0], p.data));
1206
+ if (f.reason !== undefined)
1207
+ throw new CliError("USAGE", `--reason goes with --items: ${WITHDRAW_ITEMS_USAGE} (a whole submit is withdrawn with: figma withdraw CHANGE_SET)`, 2);
1106
1208
  return emit(await figmaWithdraw(rest[0]), json, (p) => `Withdrew ${rest[0]}; it is back in ${p.data?.state ?? "editing"}.`);
1209
+ }
1107
1210
  if (action === "resubmit")
1108
1211
  return emit(await figmaResubmit(rest[0], rest[1], { sync: submitMode(f) }), json, (p) =>
1109
1212
  [`Re-submitted ${rest[0]}; it is ${p.data.state}.`, figmaChangeSetText(p.data), ...conformanceLines({ warnings: p.warnings })].join("\n"));
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.62";
7
+ export const VERSION = "0.6.64";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");