@nodii/dev 0.6.175 → 0.6.177

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
@@ -26,18 +26,18 @@ import { FIGMA_HOOK_DENIALS, heartbeatFromHook, postHook, postHookFailure, preHo
26
26
  import { setupCommand } from "./setup.js";
27
27
  import { harnessCommand } from "./harness.js";
28
28
  import { readPolicy, repoCommand } from "./repo-policy.js";
29
- import { repoDocsCheckCommand, toolingDocsHook } from "./tooling-docs.js";
29
+ import { repoDocsCheckCommand } from "./tooling-docs.js";
30
30
  import { testCommand } from "./impact.js";
31
- import { hookRuntime, recordHookFire, safetyContext, safetyPostHook, safetyPreHook } from "./safety.js";
31
+ import { hookRuntime, recordHookFire, safetyContext } from "./safety.js";
32
32
  import { isLaneRunSession, isReviewSession } from "./review-session.js";
33
- import { SUBMIT_CHECK_FLAGS, changedPaths, nudgeCandidate, nudgePre, nudgeStop, recordGathered, recordGuidelineRead, recordSubmitChecks, steerAct, stewardSteerNudges, surfaceGenPre } from "./nudges.js";
34
- import { activeSteward, firstPromptText, isLaneConfig, sessionStartText, stewardCommand } from "./session-kind.js";
33
+ import { HOOK_ANSWERS, errorText } from "./hook-handlers.js";
34
+ import { SUBMIT_CHECK_FLAGS, changedPaths, nudgeStop, recordGathered, recordGuidelineRead, recordSubmitChecks, surfaceGenPre } from "./nudges.js";
35
+ import { firstPromptText, isLaneConfig, sessionStartText, stewardCommand } from "./session-kind.js";
35
36
  import { doctorCommand } from "./doctor.js";
36
37
  import { installManagedLatest, managedStatus } from "./managed-version.js";
37
38
  import { dispatchManagedClaudeHook, dispatchManagedHook } from "./managed-hooks.js";
38
39
  import { governorCommand, laneClose } from "./governor.js";
39
40
  import { freezeCommand } from "./freeze.js";
40
- import { laneReadCache } from "./read-cache.js";
41
41
  import {
42
42
  figmaChangeSetShow,
43
43
  figmaChangeSetList,
@@ -139,8 +139,11 @@ import {
139
139
  import { superviseLane } from "./lane-supervisor.js";
140
140
  import { laneLeewayCommand } from "./leeway.js";
141
141
  import { laneAnswerCommand, laneAskCommand, laneAsksCommand, laneDeferCommand } from "./lane-asks.js";
142
+ import { laneInboxCommand, laneMessageCommand } from "./lane-messages.js";
142
143
  import { coordinatorGate, coordinatorItemsCommand, observeLaneItems, resetLaneItemsNotice, takeLaneItemsLine } from "./coordinator-items.js";
143
144
  import { awsCli, superviseRemoteRun } from "./remote.js";
145
+ import { issueGroupText, proposeIssueSet } from "./issue-group.js";
146
+ import { assertLaneSwitchOn } from "./lane-switches.js";
144
147
 
145
148
  const NOTICE_KINDS = ["lane_wait", "lane_escalation", "credential_expiry"];
146
149
  const LANE_RUN_HOOKS = new Set(["nudge-pre", "nudge-stop", "lane-heartbeat", "session-start", "session-kind", "workflow-post"]);
@@ -162,6 +165,14 @@ Usage: nodii-dev <command> [options] [--json]
162
165
  agent disconnect ID # retire one of your agents (there is no delete); its id
163
166
  # can't be used again
164
167
  issues list|show|create|update|claim|release
168
+ issues group --objective TEXT [--service ID ...] [--min N>=10] [--max N]
169
+ # OFF unless NODII_DEV_ISSUES_GROUP=1 (NODII-DEV-CLI-191: off until its clause
170
+ # is in Dev's rulebook); off, it refuses ISSUES_GROUP_OFF and calls nothing. On:
171
+ # NODII-DEV-CLI-191 (MW1-21.1): propose a lane's issue set from the open
172
+ # issues: titles that share the objective's terms (rarer terms weigh more)
173
+ # plus the dependency chain (an issue naming a picked one), with each
174
+ # issue's reason, the repos they touch and the lane launch line; under
175
+ # --min (10) it says so and never pads. It proposes; nothing is written
165
176
  issues comment ISSUE --body TEXT # or --body-file FILE; issues update --comment TEXT|--comment-file FILE adds one too
166
177
  issues transition ISSUE --to STATUS [--reason TEXT] [--dev-check REF]
167
178
  # blocked and wont_do need --reason; done needs --dev-check
@@ -538,6 +549,21 @@ Usage: nodii-dev <command> [options] [--json]
538
549
  # MW1-12.9: a lane asks its machine coordinator a question. The answer
539
550
  # reaches it as an amendment it acknowledges with lane gather --delta;
540
551
  # lane ask withdraw <ask id> takes the question back
552
+ lane message <to> --body TEXT|--body-file FILE [--issue ISSUE]
553
+ # OFF unless NODII_DEV_LANE_MESSAGES=1 (off until its clause is in Dev's
554
+ # rulebook): lane message and lane inbox then refuse LANE_MESSAGES_OFF and
555
+ # call nothing, and no hook delivers from an inbox file. On:
556
+ # NODII-DEV-CLI-191: message a lane, a steward (its lane key) or the
557
+ # coordinator by name. Dev keeps the record: a comment on the recipient
558
+ # lane's issue (the coordinator's: the sending lane's; --issue overrides),
559
+ # headed "[lane message] from <sender> to <to> · <time> · id <id>". When <to>
560
+ # runs on this machine its inbox (<config dir>/inbox/<key>.jsonl) rings too.
561
+ # The sender is the session's identity: its lane, else its Dev agent's name.
562
+ # A lane gets an unread message at its next tool call (nudge-pre), its next
563
+ # stop (the Stop hook holds it) or its next continuation (the supervisor
564
+ # puts it ahead of the prompt), Claude and Codex alike
565
+ lane inbox [<key>] [--all] # the unread messages (--all: every one), marked read; also pulls in Dev's
566
+ # record of messages sent from another machine
541
567
  lane answer <ask id> --text TEXT # the coordinator (or staff) answers; Dev delivers it as that amendment
542
568
  lane defer <ask or leeway id> --reason TEXT [--minutes N] [--leeway]
543
569
  # the coordinator puts an ask or a leeway off, with a reason, for N minutes
@@ -561,6 +587,25 @@ Usage: nodii-dev <command> [options] [--json]
561
587
  # account's band doesn't admit the class (ACCOUNT_BAND_REFUSED). The lane keeps its
562
588
  # key, branch, worktree, slot and history. A lane stopped by two deaths moves off
563
589
  # an exhausted account with no amendment or override
590
+ # NODII-DEV-CLI-191: a run that died on a usage limit, auth or the network is
591
+ # reported lane-account-KIND and its profile recorded exhausted until its reset
592
+ # (else 5 h for a limit, 1 h otherwise) in exhausted-accounts.json. Any lane resume
593
+ # then moves the lane to another account of its runtime with headroom, saying so,
594
+ # or refuses ACCOUNT_EXHAUSTED; --profile naming another account still goes
595
+ lane resume <key> --if-changed
596
+ # OFF unless NODII_DEV_RESUME_IF_CHANGED=1 (off until its clause is in Dev's
597
+ # rulebook); off, it refuses RESUME_IF_CHANGED_OFF and resumes nothing. On:
598
+ # NODII-DEV-CLI-191: resume only when what blocks the lane changed since its
599
+ # last resume (a PR's state, head or merge; an issue's status; a blocking
600
+ # lane's status; a leeway; an amendment), else print BLOCKERS_UNCHANGED and
601
+ # exit 0. A superseded lane (every issue it holds closed) is refused as
602
+ # LANE_DEAD with the evidence; nothing stops it here: the coordinator ends it
603
+ # by the MW1-28 exit that fits.
604
+ # A lane whose work is landed (MW1-30.1) before deploy is refused as
605
+ # LANDED_NOT_DONE and never stopped: landed is not done (MW1-28), so it goes
606
+ # on to deploy and the dev check. With NODII_DEV_SAME_SESSION_RESUME=1, a resume
607
+ # continues the dead run's own session when this machine has its log, with a
608
+ # short prompt instead of the Freeze; off (the default) it starts fresh as before
564
609
  lane resume --host-lost [--min-free-gb N] [--stagger-seconds N]
565
610
  # coordinator, after a reboot: resume every host_lost lane on this machine
566
611
  # in priority order under its own key, agent, worktree and branch. No
@@ -680,7 +725,7 @@ notification-registry, skills, open-questions, decisions, drift, requests,
680
725
  rulebook, ad-decisions, domains, standardizations, archive, harness, utils,
681
726
  runs, releases, and operate.
682
727
 
683
- Refusals of leeway, lane questions, the coordinator's items, lane finish, the managed hooks and the docs check
728
+ Refusals of leeway, lane questions, the coordinator's items, lane finish, lane resume, the managed hooks and the docs check
684
729
  (each line: the code, what it means, and what to do next):
685
730
  LEEWAY_BLOCKER_HELD Another live lane already holds leeway for this blocker; Dev names it and records your wait on it. Next: keep working what is not blocked and resume when the holder lands
686
731
  LEEWAY_BRANCH_HELD Another live lane is already working this issue as its own, so its in-flight branch is not yours to change (MW1-12.8). Next: wait on that lane with lane heartbeat KEY --waiting-on LANE
@@ -704,10 +749,14 @@ Refusals of leeway, lane questions, the coordinator's items, lane finish, the ma
704
749
  LANE_NOTES_FULL The grant's or answer's note would take the lane past its note cap. Next: fold superseded amendments into one note first (lane amendments fold)
705
750
  MACHINE_REQUIRED The caller coordinates no machine, so Dev cannot tell whose items or asks to list. Next: pass --machine NAME|ID
706
751
  LANE_ASKS_OFF lane ask, lane answer or lane asks while lane questions are off (the default). Next: write the question as an issue comment or a heartbeat note; NODII_DEV_LANE_ASKS=1 turns the commands on
752
+ RESUME_IF_CHANGED_OFF lane resume --if-changed while it is off (the default). Next: resume without it, as before; NODII_DEV_RESUME_IF_CHANGED=1 turns it on
753
+ LANE_MESSAGES_OFF lane message or lane inbox while lane messages are off (the default). Next: write to the other lane as a comment on its issue; NODII_DEV_LANE_MESSAGES=1 turns them on
754
+ ISSUES_GROUP_OFF issues group while it is off (the default). Next: choose the lane's issue set by hand with issues list; NODII_DEV_ISSUES_GROUP=1 turns it on
707
755
  ASK_NOT_FOUND Dev has no lane ask with this id. Next: list them with lane asks
708
756
  ASK_DECIDED The ask is already answered or withdrawn. Next: read it with lane asks --lane KEY
709
757
  LANE_NOT_FINISHED lane close before the lane's own agent marked the lane finished. Next: the lane runs lane finish KEY --reason TEXT --evidence REF
710
758
  LANE_ALREADY_FINISHED The lane is already marked finished. Next: nothing; its coordinator closes it with lane close
759
+ ACCOUNT_EXHAUSTED lane resume would relaunch onto a profile whose last run died on a usage limit, auth or the network, before its recorded reset, and no other account of its runtime has headroom. Next: resume after the reset it names, or move it with lane resume KEY --profile PATH --class CLASS
711
760
  HARNESS_INVALID A managed hook entry is not one nodii-dev command, or Dev's harness cannot take the managed hooks. Next: run harness update, and file the entry as a harness issue
712
761
  HARNESS_SETTINGS_INVALID .claude/settings.json or .codex/hooks.json is not valid JSON. Next: repair the file, then run harness update
713
762
  TOOLING_DOCS_STALE The change touches a tooling file named in nodii.repo.yaml (toolingDocs.tooling) and no docs file (toolingDocs.docs), so hook tooling-docs refuses the push or the pull request (MW1-46.3). Next: update the docs in the same change, or add the commit trailer Docs-unaffected: <reason>; check with repo docs-check
@@ -795,6 +844,28 @@ async function login(flags, json) {
795
844
  }
796
845
 
797
846
  async function issues(action, args, f, json) {
847
+ if (action === "group") {
848
+ assertLaneSwitchOn("issuesGroup", "ISSUES_GROUP_OFF", "issues group", "Choose the lane's issue set by hand with issues list.");
849
+ const objective = typeof f.objective === "string" ? f.objective.trim() : "";
850
+ if (!objective) throw new CliError("USAGE", "issues group needs --objective TEXT: the lane's rough objective.", 2);
851
+ const min = f.min === undefined ? 10 : Number(f.min);
852
+ const max = f.max === undefined ? 30 : Number(f.max);
853
+ // MW1-21.1: a lane has 10 or more mapped issues, so the minimum never goes below it.
854
+ if (!Number.isInteger(min) || !Number.isInteger(max) || min < 10 || max < min || max > 100) throw new CliError("USAGE", "--min and --max are integers with 10 <= min <= max <= 100 (MW1-21.1: a lane has 10 or more issues).", 2);
855
+ const services = (Array.isArray(f.service) ? f.service : f.service === undefined ? [undefined] : [f.service]);
856
+ const all = [];
857
+ for (const service of services) {
858
+ let cursor;
859
+ for (let page = 0; page < 20; page += 1) {
860
+ const payload = await devRequest("GET", `/api/v1/issues${query({ ...(service ? { serviceId: service } : {}), limit: "100", ...(cursor ? { cursor } : {}) })}`);
861
+ all.push(...(payload.data ?? []));
862
+ cursor = payload.nextCursor;
863
+ if (!cursor) break;
864
+ }
865
+ }
866
+ const set = proposeIssueSet(objective, all, { min, max });
867
+ return emit({ data: { objective, ...set } }, json, () => issueGroupText(set, { objective, min }));
868
+ }
798
869
  if (action === "list") {
799
870
  const payload = await devRequest(
800
871
  "GET",
@@ -987,13 +1058,14 @@ export async function figmaFileAdd(value, flags, { request = devRequest } = {})
987
1058
  // blocks the lane: a blocked lane needs them to unblock itself (AGENT-HARNESS-14).
988
1059
  const readsHelp = (argv) => argv[0] === "help" || argv.some((token) => ["--help", "-h"].includes(token)) || (argv.length === 1 && ["--version", "-v"].includes(argv[0]));
989
1060
 
990
- // cli-134: the managed hooks run this backstop on every tool call (one lane read
991
- // both routes about once a second), yet a hook cannot enforce it: a hook exits 0
992
- // on anything but a SAFETY_ or Figma denial, and its banner is never claimed. So
993
- // a hook reuses an answer for 15 seconds. Every other command reads Dev fresh,
994
- // so it is blocked by an unacknowledged amendment (CTRL-CLI-34) and shows a
995
- // new Result (MW5-16) on its next call, exactly as before.
996
- export const backstopCache = (argv) => (argv[0] === "hook" ? laneReadCache() : null);
1061
+ // Amendment acknowledgement (CTRL-CLI-34) and waiting Results (MW5-16) are a
1062
+ // lane-wide backstop for every command the agent runs, read fresh from Dev each
1063
+ // time. No hook runs it (NODII-DEV-CLI-191): a hook cannot enforce it, since
1064
+ // it exits 0 on anything but a SAFETY_ or Figma denial (a pending amendment
1065
+ // failed the hook, which then skipped its own safety check), and its banner is
1066
+ // never claimed. A lane learns of an amendment from nudge-pre's context
1067
+ // instead (MW1-12.9). The managed hooks paid this read on every tool call.
1068
+ export const runsBackstop = (argv) => argv[0] !== "hook" && argv[0] !== "__run-supervisor" && !readsHelp(argv);
997
1069
 
998
1070
  export async function main(argv = process.argv.slice(2)) {
999
1071
  // Ahead of every check that reaches Dev: a session the lane spawned gets
@@ -1005,16 +1077,9 @@ export async function main(argv = process.argv.slice(2)) {
1005
1077
  setLaneItemsObserver(argv[0] === "hook" || argv[0]?.startsWith("__") ? null : observeLaneItems);
1006
1078
  // A lane's own exit reporter runs after its runtime ends (NODII-DEV-CLI-1).
1007
1079
  if (argv[0] === "__lane-supervisor") return superviseLane();
1008
- // Amendment acknowledgement is a lane-wide backstop for every other command.
1009
- // A nudge hook is fail-open and writes only its own JSON: it cannot run a
1010
- // Delta gather, and a waiting-results banner would corrupt its output.
1011
- // surface-gen-pre runs in every session, lane or not, so it never reaches Dev.
1012
- // The heartbeat hook fires on every tool call, so these checks would call Dev each
1013
- // time past its rate limit, and a failed check would silently stop the heartbeat.
1014
- if (argv[0] !== "__run-supervisor" && !readsHelp(argv) && !(argv[0] === "hook" && (argv[1]?.startsWith("nudge-") || argv[1] === "surface-gen-pre" || argv[1] === "coordinator-gate" || argv[1] === "tooling-docs" || argv[1] === "lane-heartbeat"))) {
1015
- const cache = backstopCache(argv);
1016
- await amendmentGuard(argv, { cache });
1017
- await showWaitingResults({ acknowledge: argv[0] !== "hook", cache });
1080
+ if (runsBackstop(argv)) {
1081
+ await amendmentGuard(argv);
1082
+ await showWaitingResults();
1018
1083
  }
1019
1084
  if (argv.length === 1 && ["--version", "-v"].includes(argv[0]))
1020
1085
  return console.log(VERSION);
@@ -1262,6 +1327,8 @@ export async function main(argv = process.argv.slice(2)) {
1262
1327
  if (command === "lane" && action === "asks") return emitCommand(await laneAsksCommand(rest, f));
1263
1328
  if (command === "lane" && action === "answer") return emitCommand(await laneAnswerCommand(rest, f));
1264
1329
  if (command === "lane" && action === "defer") return emitCommand(await laneDeferCommand(rest, f));
1330
+ if (command === "lane" && action === "message") return emitCommand(await laneMessageCommand(rest, f));
1331
+ if (command === "lane" && action === "inbox") return emitCommand(await laneInboxCommand(rest, f));
1265
1332
  if (command === "lane" && action === "cap") return emitCommand(await laneCapCommand(rest, f));
1266
1333
  if (command === "lane" && action === "close") {
1267
1334
  const result = await laneClose(rest[0], f);
@@ -1807,63 +1874,13 @@ export async function main(argv = process.argv.slice(2)) {
1807
1874
  );
1808
1875
  }
1809
1876
  }
1810
- if (action === "safety-pre") {
1811
- let payload;
1812
- try {
1813
- payload = JSON.parse(await stdinText());
1814
- await recordHookFire(payload).catch(() => {});
1815
- const result = await safetyPreHook(payload);
1816
- const nudges = result.nudges ?? [];
1817
- // Both runtimes show the model a PreToolUse nudge only as additionalContext;
1818
- // Claude keeps plain stdout of an exit-0 hook out of the model's context.
1819
- if (nudges.length)
1820
- console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: nudges.join("\n") } }));
1821
- return;
1822
- } catch (error) {
1823
- // Only an evaluated safety rule may deny. Discovery, parsing, git,
1824
- // config and Dev errors fail open and produce no output.
1825
- if (!String(error?.code ?? "").startsWith("SAFETY_")) return;
1826
- if (payload && hookRuntime(payload) === "codex") {
1827
- console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: error?.message ?? String(error) } }));
1828
- return;
1829
- }
1830
- throw new CliError(
1831
- error?.code ?? "SAFETY_HOOK_FAILED",
1832
- error?.message ?? String(error),
1833
- 2,
1834
- error?.details,
1835
- );
1836
- }
1837
- }
1838
- if (action === "safety-post") {
1839
- let payload;
1840
- try {
1841
- payload = JSON.parse(await stdinText());
1842
- await recordHookFire(payload).catch(() => {});
1843
- await safetyPostHook(payload);
1844
- } catch {}
1845
- return;
1846
- }
1847
- // Guideline nudges (AGENT-HARNESS-21) never block: any error, a payload
1848
- // they don't know or a session outside a lane ends in no output.
1849
- if (action === "nudge-pre") {
1850
- try {
1851
- const payload = JSON.parse(await stdinText());
1852
- await recordHookFire(payload).catch(() => {});
1853
- // Cite before you steer (MW1-95): a steward session, which is never a lane config.
1854
- if (!isLaneConfig() && steerAct(payload)) {
1855
- const config = await readConfig(false).catch(() => null);
1856
- const steward = await activeSteward(config?.agentId).catch(() => null);
1857
- const nudges = await stewardSteerNudges(payload, { steward });
1858
- if (nudges.length) console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: nudges.join("\n") } }));
1859
- if (steward) return;
1860
- }
1861
- // MW1-12.9: a lane that has not acknowledged an amendment (an answer, a leeway grant) is told here.
1862
- const pending = isLaneConfig() ? await pendingAmendmentContext() : null;
1863
- const nudges = (await nudgeCandidate(payload)) ? await nudgePre(payload, await safetyContext(payload.cwd ?? process.cwd())).catch(() => []) : [];
1864
- const context = [pending, ...nudges].filter(Boolean);
1865
- if (context.length) console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: context.join("\n") } }));
1866
- } catch {}
1877
+ // safety-pre, safety-post, nudge-pre and tooling-docs (MW1-46.3). The managed
1878
+ // dispatcher runs them in its own process (NODII-DEV-CLI-191); here
1879
+ // each answers as its own process: its lines, and a denial as exit 2.
1880
+ if (Object.hasOwn(HOOK_ANSWERS, action)) {
1881
+ const { lines, denial } = await HOOK_ANSWERS[action](await stdinText());
1882
+ for (const text of lines) console.log(text);
1883
+ if (denial) throw denial;
1867
1884
  return;
1868
1885
  }
1869
1886
  // MW1-37.2: the coordinator gate, as its own hook. The managed dispatcher
@@ -1877,15 +1894,6 @@ export async function main(argv = process.argv.slice(2)) {
1877
1894
  } catch {}
1878
1895
  return;
1879
1896
  }
1880
- // MW1-46.3: docs move with tooling. Reads git only, never Dev; any error is
1881
- // no output, so a broken check never holds a push.
1882
- if (action === "tooling-docs") {
1883
- try {
1884
- const verdict = await toolingDocsHook(JSON.parse(await stdinText()));
1885
- if (verdict?.deny) console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: verdict.deny } }));
1886
- } catch {}
1887
- return;
1888
- }
1889
1897
  // MW8-17, for every session (the managed dispatcher calls it outside lanes
1890
1898
  // too): reads only the edit, never blocks, and any error is no output.
1891
1899
  if (action === "surface-gen-pre") {
@@ -1995,8 +2003,6 @@ export function fail(error) {
1995
2003
  error instanceof CliError
1996
2004
  ? error
1997
2005
  : new CliError("UNEXPECTED", error?.message ?? String(error));
1998
- console.error(
1999
- `${e.code}: ${e.message}${e.details ? `\n${JSON.stringify(e.details)}` : ""}`,
2000
- );
2006
+ console.error(errorText(e));
2001
2007
  process.exitCode = e.exitCode ?? 1;
2002
2008
  }
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.175";
7
+ export const VERSION = "0.6.177";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
@@ -405,7 +405,7 @@ export async function checkLogin() {
405
405
  export const encode = (value) => encodeURIComponent(value);
406
406
  // Switches never take the next token as their value, so
407
407
  // `docs upload --wait rulebook/` keeps rulebook/ as a path.
408
- const SWITCHES = new Set(["all-pending", "confirm-raise", "actionable", "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", "write", "fetch"]);
408
+ const SWITCHES = new Set(["all-pending", "confirm-raise", "actionable", "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", "write", "fetch", "if-changed"]);
409
409
  export function parseArgs(argv) {
410
410
  const flags = {};
411
411
  const args = [];
package/dist/flags.js CHANGED
@@ -19,6 +19,9 @@ export const COMMAND_FLAGS = {
19
19
  "lane ask": ["question", "options"],
20
20
  "lane asks": ["machine", "state", "lane", "cursor", "limit"],
21
21
  "lane answer": ["text"],
22
+ // NODII-DEV-CLI-191: lane-to-lane messaging.
23
+ "lane message": [...BODY, "issue"],
24
+ "lane inbox": ["all"],
22
25
  "lane defer": ["reason", "minutes", "leeway"],
23
26
  "coordinator heartbeat": ["machine", "run", "pid", "pid-started-at", "interval"],
24
27
  "issues create": ["service", ...ISSUE_FIELDS],
@@ -26,6 +29,7 @@ export const COMMAND_FLAGS = {
26
29
  "issues transition": ["to", "reason", "dev-check"],
27
30
  "issues comment": BODY,
28
31
  "issues claim": ["ttl"],
32
+ "issues group": ["objective", "service", "min", "max"],
29
33
  "issues release": ["note"],
30
34
  "lane launch": [
31
35
  "machine", "coordinator-run", "machine-id", "repo", "branch", "base", "worktree", "owned-path",
@@ -48,7 +52,7 @@ export const COMMAND_FLAGS = {
48
52
  "lane cap": ["confirm-raise", "reason"],
49
53
  "lane heartbeat": ["note", "waiting-on"],
50
54
  "lane waits": ["machine"],
51
- "lane resume": ["override", "reason", "host-lost", "min-free-gb", "stagger-seconds", "profile", "class"],
55
+ "lane resume": ["override", "reason", "host-lost", "min-free-gb", "stagger-seconds", "profile", "class", "if-changed"],
52
56
  "lane transfer": ["reason", "to-agent"],
53
57
  "inbox ack": ["note"],
54
58
  "lane stop": ["reason", "sweeper", "no-closeout", "no-closeout-push", "launched-in-error", "replaced-by"],
package/dist/freeze.js CHANGED
@@ -108,12 +108,42 @@ function checkedGatherClauses(clauses) {
108
108
 
109
109
  export const GATHER_LOOKUP_IDS = ["figma-guidelines"];
110
110
 
111
+ // NODII-DEV-CLI-191: a Dev before hub d14dbbde caps a Freeze's issue body at
112
+ // 20,000 characters and each lane note at 4,000, though its Lane contract
113
+ // carries longer ones. Dev stores the body only as its first-sentence gist
114
+ // (AGENT-HARNESS-45), so sending the body cut to the cap loses nothing it
115
+ // stores; a long note goes as consecutive notes, split between words.
116
+ export const FREEZE_ISSUE_BODY_SEND_MAX = 20_000;
117
+ export const FREEZE_LANE_NOTE_SEND_MAX = 4_000;
118
+
119
+ function issueWithinCap(issue) {
120
+ if (!issue?.body || issue.body.length <= FREEZE_ISSUE_BODY_SEND_MAX) return issue;
121
+ return { ...issue, body: issue.body.slice(0, FREEZE_ISSUE_BODY_SEND_MAX).trimEnd() };
122
+ }
123
+
124
+ function notesWithinCap(notes) {
125
+ return notes.flatMap((note) => {
126
+ if (typeof note !== "string" || note.length <= FREEZE_LANE_NOTE_SEND_MAX) return [note];
127
+ const parts = [];
128
+ let rest = note;
129
+ while (rest.length > FREEZE_LANE_NOTE_SEND_MAX) {
130
+ const space = rest.lastIndexOf(" ", FREEZE_LANE_NOTE_SEND_MAX);
131
+ const cut = space > 0 ? space : FREEZE_LANE_NOTE_SEND_MAX;
132
+ parts.push(rest.slice(0, cut));
133
+ rest = rest.slice(space > 0 ? cut + 1 : cut);
134
+ }
135
+ if (rest) parts.push(rest);
136
+ return parts;
137
+ });
138
+ }
139
+
111
140
  /** Build the stored contract; Delta Gather keeps lane-authored sections. */
112
141
  export function freezeFromGather({
113
142
  gather,
114
143
  ask,
115
144
  boundaries,
116
145
  issue,
146
+ issueSet,
117
147
  laneNotes,
118
148
  doneCheck,
119
149
  lookups = [],
@@ -136,11 +166,14 @@ export function freezeFromGather({
136
166
  objective: {
137
167
  // Dev's Lane contract names the ask; without one, Gather's objective.
138
168
  ask: ask ?? gather.objective,
139
- issue: issue === undefined ? (current?.objective?.issue ?? null) : issue,
140
- laneNotes:
169
+ issue: issueWithinCap(issue === undefined ? (current?.objective?.issue ?? null) : issue),
170
+ // NODII-DEV-CLI-191: the lane's other mapped issues, keys and titles only.
171
+ ...((issueSet ?? current?.objective?.issueSet)?.length ? { issueSet: issueSet ?? current.objective.issueSet } : {}),
172
+ laneNotes: notesWithinCap(
141
173
  laneNotes === undefined
142
174
  ? (current?.objective?.laneNotes ?? [])
143
175
  : laneNotes,
176
+ ),
144
177
  doneCheck: effectiveDoneCheck,
145
178
  },
146
179
  boundaries,
package/dist/gather.js CHANGED
@@ -581,9 +581,20 @@ const tags = (clause) => {
581
581
  return parts.length ? ` [${parts.join("; ")}]` : "";
582
582
  };
583
583
 
584
+ // A breadcrumb names where a clause sits; a SWAP breadcrumb carries the whole
585
+ // swap (24 KB across one lane's map), which `rules show <ID>` prints in full.
586
+ const CRUMB_MAX = 160;
587
+ const crumb = (text) => {
588
+ const flat = String(text ?? "").replace(/\s+/g, " ").trim();
589
+ return flat.length <= CRUMB_MAX ? flat : `${flat.slice(0, CRUMB_MAX - 1).trimEnd()}…`;
590
+ };
591
+
584
592
  export function gatherText(payload, objective = "", reasons = {}) {
585
593
  const data = payload?.data ?? payload ?? {};
586
- const lines = ["Lane contract", data.laneContract ?? LANE_CONTRACT, "", `Clause map${objective ? ` · ${JSON.stringify(objective)}` : ""}`];
594
+ // NODII-DEV-CLI-191: the objective and lane notes are in the contract
595
+ // above; the header no longer repeats them as JSON (4.7 KB on a long lane).
596
+ void objective;
597
+ const lines = ["Lane contract", data.laneContract ?? LANE_CONTRACT, "", "Clause map"];
587
598
  for (const notice of data.notices ?? []) lines.push(`Notice: ${notice}`);
588
599
  const documents = new Map();
589
600
  for (const clause of data.clauses ?? []) {
@@ -597,13 +608,13 @@ export function gatherText(payload, objective = "", reasons = {}) {
597
608
  const why = reasons instanceof Map ? reasons.get(document.code) : reasons[document.code];
598
609
  lines.push(`${document.code}${why ? ` ← ${why}` : ""}`);
599
610
  for (const section of document.sections.values()) {
600
- lines.push(` ${section.breadcrumb}`);
611
+ lines.push(` ${crumb(section.breadcrumb)}`);
601
612
  for (const clause of section.clauses)
602
613
  lines.push(` ${clause.clauseId} ${clause.gist}${clause.counterInstinct ? " ⚑" : ""}${tags(clause)}`.trimEnd());
603
614
  }
604
615
  }
605
616
  if (!documents.size) lines.push(" No clauses matched.");
606
- lines.push("", 'Not sure something applies? nodii-dev rules find "<question>"');
617
+ lines.push("", 'Read a clause in full with `nodii-dev rules show <ID>`. Not sure something applies? nodii-dev rules find "<question>"');
607
618
  return lines.join("\n");
608
619
  }
609
620
 
@@ -0,0 +1,85 @@
1
+ /**
2
+ * hub-548: the keyed hand-patch marks of DEC-0488, DEC-0494 and
3
+ * MW8-17.11. A copy of design-system's infra/code-connect/handrolled.mjs
4
+ * (origin/main 2fb827cdd), so the edit guard judges a mark edit by the same
5
+ * test the surface-gen check and CI run. Keep the two in step.
6
+ */
7
+
8
+ /** Parse keyed, non-nested hand patches. Standalone marker lines add no bytes. */
9
+ export function handrolledRegions(text) {
10
+ const regions = [];
11
+ const tokens = /\/\*\s*@(handrolled|end-handrolled)\b/g;
12
+ let open = null;
13
+ for (const match of text.matchAll(tokens)) {
14
+ const line = text.slice(0, match.index).split("\n").length;
15
+ const end = text.indexOf("*/", match.index);
16
+ const fail = (reason) => {
17
+ throw new Error(`line ${line}: ${reason}`);
18
+ };
19
+ if (end < 0) fail("unclosed handrolled comment");
20
+ const comment = text.slice(match.index, end + 2);
21
+ // JSX comment braces belong to the marker, not to the generated content.
22
+ const before = /\{[ \t]*$/.exec(text.slice(0, match.index));
23
+ const after = /^[ \t]*\}/.exec(text.slice(end + 2));
24
+ const markerStart = before && after ? before.index : match.index;
25
+ const markerEnd = before && after ? end + 2 + after[0].length : end + 2;
26
+ const lineStart = text.lastIndexOf("\n", match.index - 1) + 1;
27
+ const nextLine = text.indexOf("\n", end + 2);
28
+ const lineEnd = nextLine < 0 ? text.length : nextLine;
29
+ const standalone =
30
+ /^\s*$/.test(text.slice(lineStart, markerStart)) &&
31
+ /^\s*$/.test(text.slice(markerEnd, lineEnd));
32
+ const start = standalone ? lineStart : markerStart;
33
+ const stop = standalone
34
+ ? nextLine < 0
35
+ ? text.length
36
+ : nextLine + 1
37
+ : markerEnd;
38
+ if (match[1] === "handrolled") {
39
+ if (open) fail("nested handrolled region");
40
+ const keyed =
41
+ /^\/\*\s*@handrolled\s+([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*-\d+):\s*\S[\s\S]*\*\/$/.exec(
42
+ comment
43
+ );
44
+ if (!keyed) fail("handrolled mark needs an issue key and description");
45
+ open = { key: keyed[1], line, start };
46
+ } else {
47
+ if (!/^\/\*\s*@end-handrolled\s*\*\/$/.test(comment))
48
+ fail("invalid end-handrolled mark");
49
+ if (!open) fail("end-handrolled without an opening mark");
50
+ regions.push({ ...open, endLine: line, end: stop });
51
+ open = null;
52
+ }
53
+ }
54
+ if (open)
55
+ throw new Error(
56
+ `line ${open.line}: unclosed handrolled region ${open.key}`
57
+ );
58
+ return regions;
59
+ }
60
+
61
+ /** Every byte outside the marked spans must occur unchanged, in order. */
62
+ export function compareHandrolled(current, generated) {
63
+ const regions = handrolledRegions(current);
64
+ if (!regions.length) return { equal: current === generated, regions };
65
+ let sourceAt = 0;
66
+ let generatedAt = 0;
67
+ for (let i = 0; i < regions.length; i++) {
68
+ const chunk = current.slice(sourceAt, regions[i].start);
69
+ const at =
70
+ i === 0
71
+ ? generated.startsWith(chunk)
72
+ ? 0
73
+ : -1
74
+ : generated.indexOf(chunk, generatedAt);
75
+ if (at < 0) return { equal: false, regions };
76
+ generatedAt = at + chunk.length;
77
+ sourceAt = regions[i].end;
78
+ }
79
+ const tail = current.slice(sourceAt);
80
+ return {
81
+ equal:
82
+ generated.endsWith(tail) && generated.length - tail.length >= generatedAt,
83
+ regions,
84
+ };
85
+ }