@nodii/dev 0.6.174 → 0.6.176

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
@@ -13,6 +13,7 @@ import {
13
13
  readConfig,
14
14
  requestHash,
15
15
  requireFlag,
16
+ setLaneItemsObserver,
16
17
  writeConfig,
17
18
  } from "./core.js";
18
19
  import {
@@ -25,17 +26,18 @@ import { FIGMA_HOOK_DENIALS, heartbeatFromHook, postHook, postHookFailure, preHo
25
26
  import { setupCommand } from "./setup.js";
26
27
  import { harnessCommand } from "./harness.js";
27
28
  import { readPolicy, repoCommand } from "./repo-policy.js";
29
+ import { repoDocsCheckCommand } from "./tooling-docs.js";
28
30
  import { testCommand } from "./impact.js";
29
- import { hookRuntime, recordHookFire, safetyContext, safetyPostHook, safetyPreHook } from "./safety.js";
31
+ import { hookRuntime, recordHookFire, safetyContext } from "./safety.js";
30
32
  import { isLaneRunSession, isReviewSession } from "./review-session.js";
31
- import { SUBMIT_CHECK_FLAGS, changedPaths, nudgeCandidate, nudgePre, nudgeStop, recordGathered, recordGuidelineRead, recordSubmitChecks, steerAct, stewardSteerNudges, surfaceGenPre } from "./nudges.js";
32
- 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";
33
36
  import { doctorCommand } from "./doctor.js";
34
37
  import { installManagedLatest, managedStatus } from "./managed-version.js";
35
38
  import { dispatchManagedClaudeHook, dispatchManagedHook } from "./managed-hooks.js";
36
39
  import { governorCommand, laneClose } from "./governor.js";
37
40
  import { freezeCommand } from "./freeze.js";
38
- import { laneReadCache } from "./read-cache.js";
39
41
  import {
40
42
  figmaChangeSetShow,
41
43
  figmaChangeSetList,
@@ -120,6 +122,7 @@ import {
120
122
  import { laneTestCommand } from "./red-run.js";
121
123
  import {
122
124
  amendmentGuard,
125
+ pendingAmendmentContext,
123
126
  amendLaneCommand,
124
127
  foldLaneCommand,
125
128
  laneAmendmentsCommand,
@@ -134,12 +137,18 @@ import {
134
137
  superviseRun,
135
138
  } from "./runs.js";
136
139
  import { superviseLane } from "./lane-supervisor.js";
140
+ import { laneLeewayCommand } from "./leeway.js";
141
+ import { laneAnswerCommand, laneAskCommand, laneAsksCommand, laneDeferCommand } from "./lane-asks.js";
142
+ import { laneInboxCommand, laneMessageCommand } from "./lane-messages.js";
143
+ import { coordinatorGate, coordinatorItemsCommand, observeLaneItems, resetLaneItemsNotice, takeLaneItemsLine } from "./coordinator-items.js";
137
144
  import { awsCli, superviseRemoteRun } from "./remote.js";
145
+ import { issueGroupText, proposeIssueSet } from "./issue-group.js";
146
+ import { assertLaneSwitchOn } from "./lane-switches.js";
138
147
 
139
148
  const NOTICE_KINDS = ["lane_wait", "lane_escalation", "credential_expiry"];
140
149
  const LANE_RUN_HOOKS = new Set(["nudge-pre", "nudge-stop", "lane-heartbeat", "session-start", "session-kind", "workflow-post"]);
141
150
 
142
- const HELP = `nodii-dev ${VERSION}
151
+ export const HELP = `nodii-dev ${VERSION}
143
152
 
144
153
  Usage: nodii-dev <command> [options] [--json]
145
154
 
@@ -156,6 +165,14 @@ Usage: nodii-dev <command> [options] [--json]
156
165
  agent disconnect ID # retire one of your agents (there is no delete); its id
157
166
  # can't be used again
158
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
159
176
  issues comment ISSUE --body TEXT # or --body-file FILE; issues update --comment TEXT|--comment-file FILE adds one too
160
177
  issues transition ISSUE --to STATUS [--reason TEXT] [--dev-check REF]
161
178
  # blocked and wont_do need --reason; done needs --dev-check
@@ -278,7 +295,7 @@ Usage: nodii-dev <command> [options] [--json]
278
295
  figma file retire FILE_KEY --reason TEXT
279
296
  # staff or the hub's Steward: not canonical. Closes its sets still editing
280
297
  # or awaiting publish, and refuses new locks
281
- hook claude-figma-pre|claude-figma-post|safety-pre|safety-post|nudge-pre|nudge-stop|surface-gen-pre|session-start|session-kind|managed-dispatch|claude-managed-dispatch|print-settings
298
+ hook claude-figma-pre|claude-figma-post|safety-pre|safety-post|nudge-pre|nudge-stop|surface-gen-pre|coordinator-gate|tooling-docs|session-start|session-kind|managed-dispatch|claude-managed-dispatch|print-settings
282
299
  # session-start and session-kind (first prompt) print the session's kind:
283
300
  # lane, coordinator, steward or operator assistant, with its contract (MW1-92)
284
301
  steward register --focus TEXT --repos R,... [--side frontend|backend|both] [--key KEY]
@@ -294,6 +311,14 @@ Usage: nodii-dev <command> [options] [--json]
294
311
  repo policy # print this repository's nodii.repo.yaml facts (STD-11)
295
312
  repo lint # 0 clean, 1 findings: policy file missing or invalid, stray root
296
313
  # files, docs layout, scratch not gitignored, test scripts
314
+ repo docs-check [--base REF] # MW1-46.3: docs move with tooling. 0 clean or not checked, 1 TOOLING_DOCS_STALE:
315
+ # the range REF...HEAD (default origin/main) changes a file matching
316
+ # toolingDocs.tooling in nodii.repo.yaml (commands, routes, refusal codes,
317
+ # hooks) and none matching toolingDocs.docs, and no commit in it carries
318
+ # the trailer "Docs-unaffected: <reason>". A repository without the
319
+ # toolingDocs block is not checked. hook tooling-docs (PreToolUse on Bash,
320
+ # installed by the harness, every session) refuses git push and
321
+ # gh pr create|ready on the same finding; it reads git only and fails open
297
322
  watchdog install [--interval SECONDS] # install/update the per-machine liveness sweep (default 60s): launchd on
298
323
  # macOS, a systemd user timer (nodii-watchdog.timer) on Linux
299
324
  watchdog sweep # the job's entrypoint: report dead runs, stale sockets, unpushed worktrees,
@@ -352,18 +377,34 @@ Usage: nodii-dev <command> [options] [--json]
352
377
  # the library publish dialog through the shared Chrome: ticks only the
353
378
  # components of finished sets (awaiting_publish), unticks the rest, reports
354
379
  # what it can't map, publishes and records it (figma published)
380
+ coordinator items [--machine NAME|ID]
381
+ # MW1-37.2: what lanes wait on this coordinator for (questions, leeway asks,
382
+ # waits, escalations), each with the command that clears it. Every command
383
+ # a coordinator runs prints the count first, on stderr:
384
+ # 3 from lanes waiting on you: 1 leeway (k), 2 questions (k 34 min, ...)
385
+ # While an ask or a leeway has waited over 10 minutes, the managed hooks
386
+ # refuse the coordinator's next nodii-dev write until it is answered, granted,
387
+ # refused or deferred; a question to the operator is never held (MW1-116) and
388
+ # passes with the waiting items named. Reads, inbox,
389
+ # lane answer|defer, lane leeway grant|refuse, lane resume|close|stop pass.
390
+ # The gate runs only where coordinator start wrote coordinator.json beside
391
+ # the config, and passes when Dev cannot be read
355
392
  coordinator start --machine NAME [--account RUNTIME:PROFILE ...]
356
393
  # register this machine's one watched coordinator; refuses a live second;
357
394
  # registers each --account and reports every account's usage; a background
358
395
  # heartbeater keeps the run alive while this session lives, then ends it
359
396
  lane launch <key> --done-check TEXT --kind KIND --side SIDE
360
397
  --issue KEY --repo NAME=/SOURCE --branch NAME=BRANCH [--repo ... --branch ...]
361
- --machine NAME --runtime claude|codex --profile PATH --model MODEL --subagents N
398
+ --machine NAME --runtime claude|codex --profile PATH --model MODEL [--subagents N]
362
399
  --class long|short|no-build # MW1-38.3 class, weighed against the account's MW1-38.2 band
363
400
  [--base NAME=REF] [--worktree NAME=PATH] [--owned-path NAME=PATH]
364
401
  [--route /app/... ...] [--figma FILE_KEY[=COMPONENT_SET_KEY[,KEY]]] [--notes TEXT]
365
402
  [--narrowing-note TEXT --narrowing-remainder DESTINATION]
366
403
  # authoritative preflight, one worktree per repo, watched launch
404
+ # --subagents defaults to 4 (0 to 100; 0 is none). Default shape: fewer
405
+ # lanes, with subagents fanned out inside each (MW1-38.15). Dev clamps a new
406
+ # lane's quota to 2 or 1 in the two_builds or one_build usage band and the
407
+ # launch prints the clamp
367
408
  # uses the provisioned agents/lane-<key>.json Dev identity
368
409
  # Figma scope by published key: --route derives it from the
369
410
  # DS catalog (route -> Surfaces -> componentSetKey -> file)
@@ -373,12 +414,18 @@ Usage: nodii-dev <command> [options] [--json]
373
414
  # open.md line. A pivot (most of the brief rewritten) is refused
374
415
  # AMENDMENT_IS_A_PIVOT: stop the lane --launched-in-error instead.
375
416
  # The stepped-up operator's own amendment applies at once; the operator's
376
- # approval is the recorded word an --objective/--scope one needs (MW1-12.5)
417
+ # approval is the recorded word an --objective/--scope one needs (MW1-12.5).
418
+ # A leeway grant is not held this way: the coordinator's grant is enough, with
419
+ # no operator approval and no TOTP code (MW1-12.7, DEC-0486)
377
420
  lane amendments [<key>] [--all|--state pending|approved|rejected|withdrawn|refused_pivot]
378
421
  lane amendments show|withdraw <request>
379
- lane amendments approve|reject <request> [--note TEXT]
422
+ lane amendments approve|reject <request> [<request> ...]|--all-pending [--note TEXT]
380
423
  # approve/reject: the operator only (TOTP step-up); approval applies the
381
- # amendment and the lane acks it with lane gather --delta
424
+ # amendment and the lane acks it with lane gather --delta. Several ids, or
425
+ # --all-pending (every pending request Dev lists to you), are answered in
426
+ # one run under ONE code; a shell loop asks for a code per request. A
427
+ # refusal stops the run and names what was done and what was not tried.
428
+ # A leeway grant never waits here (MW1-12.7, DEC-0486)
382
429
  lane fold <key> --versions 3,4,5|3-9 --summary TEXT --reason TEXT
383
430
  # folds superseded scope/rules amendments into one rules note, so a
384
431
  # lane at its note cap (LANE_NOTES_FULL) takes amendments again;
@@ -409,7 +456,9 @@ Usage: nodii-dev <command> [options] [--json]
409
456
  lane start <ISSUE> --key KEY --title TEXT --kind KIND --side SIDE
410
457
  # --key names the lane; the positional is then its issue
411
458
  lane step <key> --side SIDE --start|--done|--block <step> [--reason TEXT]
412
- # --block --reason on a blocked step records its new reason
459
+ # --block --reason on a blocked step records its new reason. A step blocked
460
+ # on an open issue that no live lane holds is not blocked: ask for leeway
461
+ # with lane leeway instead of ending BLOCKED (MW1-12.6, DEC-0486)
413
462
  lane step <key> --side SIDE --done <step> --review REVIEW.json
414
463
  # records the review (as lane review) first, then marks the step done
415
464
  lane step <key> --side SIDE --not-applicable gather --reason-code pre_harness_lane [--note TEXT]
@@ -447,7 +496,13 @@ Usage: nodii-dev <command> [options] [--json]
447
496
  # send the lane records queued while Dev was down (MW1-64); --discard drops
448
497
  # one Dev refuses for good, with a note on its lane
449
498
  lane ready <key> --withdraw --reason TEXT # take READY back without closing the PR; a newer done check posts it again
450
- lane done-check <key> --evidence TEXT|URL # the done check is met; a launched run that exits after it ends finished
499
+ lane done-check <key> --evidence TEXT|URL # the done check is met; a launched run that exits after it ends finished,
500
+ # and a clean exit also records the lane finished with this evidence,
501
+ # unless the lane still has an open wait or a blocked step
502
+ lane finish <key> --reason TEXT --evidence TEXT|URL
503
+ # the lane's own agent marks the lane finished (MW1-28.2): why, and what it
504
+ # delivered and where its branch and commits went. The lane keeps its status
505
+ # and slot; its coordinator's lane close needs this record (LANE_NOT_FINISHED)
451
506
  lane subagent-quota <key> <n> # coordinator assigns 0-100 subagent slots
452
507
  lane cap <machine> <n> [--confirm-raise --reason TEXT]
453
508
  # coordinator declares the machine's lane cap, at least every 60 minutes;
@@ -459,7 +514,63 @@ Usage: nodii-dev <command> [options] [--json]
459
514
  # catalog_publish and worker_ready checks (DEV_CHECK_REQUIRED, DEV_CHECK_FAILED)
460
515
  lane heartbeat <key> --note "BLOCKED: ..."|"WAITING: ..."
461
516
  # a note starting BLOCKED or WAITING: (capitals) marks the lane blocked:
462
- # an exit then ends its run blocked and never counts as a death
517
+ # an exit then ends its run blocked and never counts as a death. When the
518
+ # note names an open issue no live lane holds, Dev answers with the
519
+ # lane leeway command to run and the heartbeat prints it: the lane is then
520
+ # not blocked, and the Stop gate and the supervisor continue its session
521
+ lane leeway <key> --blocker ISSUE [--repo NAME] --reason TEXT
522
+ # MW1-12.6 (DEC-0486): a lane blocked on an open issue no live lane holds asks
523
+ # its machine coordinator for leeway to fix it, instead of ending BLOCKED. Dev
524
+ # claims the issue for the lane (MW1-21.1); LEEWAY_BLOCKER_HELD names the lane
525
+ # that already holds it and records a wait on it. --repo names the repository
526
+ # of the fix when the lane does not work in it. The lane keeps working
527
+ # what is not blocked and starts the fix only after the grant's Delta gather
528
+ lane leeway grant <id> [--note TEXT] [--source PATH] [--worktree PATH]
529
+ lane leeway refuse <id> [--note TEXT]
530
+ # the lane's machine coordinator (or staff). The coordinator's grant is
531
+ # enough: no operator approval and no TOTP code (MW1-12.7, DEC-0486). A grant
532
+ # widens the lane's contract to exactly that issue and repository, as an
533
+ # amendment the lane acknowledges with lane gather --delta. For a repository the lane lacks, the CLI sends Dev
534
+ # the worktree path, then creates the worktree on fix/<lane key> from
535
+ # origin/main as lane launch does (--source is that repository's checkout,
536
+ # by default the one beside the lane's first repository; --worktree
537
+ # overrides <source>/.claude/worktrees/<lane key>). The fix is its own PR,
538
+ # merged by the repository's steward where it has one; the lane rebases its
539
+ # own PR after the fix merges. Leeway never reaches Prod, a locked
540
+ # component or lock change, a Figma publish, a steward's merge, another
541
+ # lane's in-flight branch, or credentials; chains stop at depth 2 and a lane
542
+ # holds at most 2 open leeways (MW1-12.8). Refusal codes: see "Refusals" below
543
+ lane leeway withdraw <id> # the lane takes its ask back
544
+ lane ask <key> --question TEXT [--options a,b]
545
+ # OFF unless NODII_DEV_LANE_ASKS=1 (MW1-37.2: lane asks ship off by default):
546
+ # lane ask, lane answer and lane asks then refuse LANE_ASKS_OFF and call
547
+ # nothing, lane defer takes its id as a leeway, and the coordinator's count,
548
+ # coordinator items and the gate leave questions out. On:
549
+ # MW1-12.9: a lane asks its machine coordinator a question. The answer
550
+ # reaches it as an amendment it acknowledges with lane gather --delta;
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
567
+ lane answer <ask id> --text TEXT # the coordinator (or staff) answers; Dev delivers it as that amendment
568
+ lane defer <ask or leeway id> --reason TEXT [--minutes N] [--leeway]
569
+ # the coordinator puts an ask or a leeway off, with a reason, for N minutes
570
+ # (default 60, at most 240); it counts again after that. The id is tried as
571
+ # an ask, then as a leeway; --leeway goes straight to the leeway
572
+ lane asks [--machine M] [--state S] [--lane KEY] [--cursor C] [--limit N]
573
+ lane leeway list [--machine M] [--state S] [--lane KEY] [--cursor C] [--limit N] | lane leeway show <id>
463
574
  lane heartbeat <key> --waiting-on LANE|owner/repo#n|Q-nnn|DEC-nnnn|release:PKG|launch-day [...]
464
575
  # repeatable; replaces the lane's waits (a WAITING note's lane keys and
465
576
  # repo#n count too; a note that is no wait clears them). A wait on another
@@ -476,6 +587,25 @@ Usage: nodii-dev <command> [options] [--json]
476
587
  # account's band doesn't admit the class (ACCOUNT_BAND_REFUSED). The lane keeps its
477
588
  # key, branch, worktree, slot and history. A lane stopped by two deaths moves off
478
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
479
609
  lane resume --host-lost [--min-free-gb N] [--stagger-seconds N]
480
610
  # coordinator, after a reboot: resume every host_lost lane on this machine
481
611
  # in priority order under its own key, agent, worktree and branch. No
@@ -595,6 +725,42 @@ notification-registry, skills, open-questions, decisions, drift, requests,
595
725
  rulebook, ad-decisions, domains, standardizations, archive, harness, utils,
596
726
  runs, releases, and operate.
597
727
 
728
+ Refusals of leeway, lane questions, the coordinator's items, lane finish, lane resume, the managed hooks and the docs check
729
+ (each line: the code, what it means, and what to do next):
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
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
732
+ LEEWAY_CYCLE The lane that holds this blocker is itself waiting on you. Next: land your own work first, or ask the coordinator in an issue comment or a heartbeat note
733
+ LEEWAY_PROD Leeway never reaches Prod (MW1-12.8). Next: raise the operator item
734
+ LEEWAY_LOCKED_COMPONENT The blocker touches a locked component or a lock change (U07-34). Next: raise the operator item
735
+ LEEWAY_FIGMA_PUBLISH A Figma publish stays with the operator. Next: raise the operator item
736
+ LEEWAY_CREDENTIALS An issue of kind credential or operator prerequisite is not fixed by leeway (MW1-38.8). Next: raise the operator item
737
+ LEEWAY_DEPTH Leeway chains stop at depth 2. Next: ask the coordinator to launch a lane for the blocker
738
+ LEEWAY_LIMIT A lane holds at most 2 open leeways. Next: finish or withdraw one (lane leeway withdraw ID) first
739
+ LEEWAY_ISSUE_CLOSED The blocker issue is already done or closed, so there is nothing left to fix. Next: re-check what blocks the lane
740
+ LEEWAY_OWN_ISSUE The blocker is already this lane's own issue and needs no leeway. Next: fix it in the lane
741
+ LEEWAY_ALREADY_ASKED This lane already asked for leeway on this blocker; Dev names the ask. Next: read it with lane leeway show ID and wait for the coordinator
742
+ LEEWAY_DECIDED The leeway is already granted, refused or withdrawn. Next: read it with lane leeway show ID
743
+ LEEWAY_NOT_FOUND Dev has no leeway with this id. Next: list them with lane leeway list
744
+ LEEWAY_WORKTREE_REQUIRED The grant names a repository the lane does not work in and carries no worktree for it. Next: run lane leeway grant from a current CLI, which creates the worktree, or pass --worktree PATH
745
+ LEEWAY_SOURCE_REQUIRED The grant needs a local clone of the leeway's repository to create the worktree from, and found none; nothing was granted. Next: pass --source PATH, the repository's clone
746
+ LEEWAY_WORKTREE_FAILED The leeway is granted, but its worktree could not be created. Next: create it with the worktree command the refusal prints, then tell the lane
747
+ REPO_NOT_GRANTED The lane's agent has no grant for the repository the leeway adds. Next: grant the agent the repository, then grant the leeway again
748
+ LANE_WORKTREE_TAKEN Another lane already records the worktree path the grant names. Next: pass another --worktree PATH
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)
750
+ MACHINE_REQUIRED The caller coordinates no machine, so Dev cannot tell whose items or asks to list. Next: pass --machine NAME|ID
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
755
+ ASK_NOT_FOUND Dev has no lane ask with this id. Next: list them with lane asks
756
+ ASK_DECIDED The ask is already answered or withdrawn. Next: read it with lane asks --lane KEY
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
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
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
761
+ HARNESS_SETTINGS_INVALID .claude/settings.json or .codex/hooks.json is not valid JSON. Next: repair the file, then run harness update
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
763
+
598
764
  Run a command with --help or see the package README for all flags.`;
599
765
 
600
766
  // Verbs of the local-stack CLI, which shared this name until it became
@@ -623,7 +789,14 @@ function stdinText() {
623
789
  }
624
790
  const bodyFlag = async (f, name = "body") =>
625
791
  f[`${name}-file`] ? readFile(f[`${name}-file`], "utf8") : f[name];
792
+ /** MW1-37.2: what lanes wait on this coordinator for, first and on stderr, so JSON stdout stays parseable. */
793
+ function laneItemsNotice() {
794
+ const line = takeLaneItemsLine();
795
+ if (line) process.stderr.write(`${line}\n`);
796
+ }
797
+
626
798
  function emit(payload, json, human) {
799
+ laneItemsNotice();
627
800
  if (json) console.log(JSON.stringify(payload));
628
801
  else
629
802
  console.log(
@@ -671,6 +844,28 @@ async function login(flags, json) {
671
844
  }
672
845
 
673
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
+ }
674
869
  if (action === "list") {
675
870
  const payload = await devRequest(
676
871
  "GET",
@@ -863,30 +1058,28 @@ export async function figmaFileAdd(value, flags, { request = devRequest } = {})
863
1058
  // blocks the lane: a blocked lane needs them to unblock itself (AGENT-HARNESS-14).
864
1059
  const readsHelp = (argv) => argv[0] === "help" || argv.some((token) => ["--help", "-h"].includes(token)) || (argv.length === 1 && ["--version", "-v"].includes(argv[0]));
865
1060
 
866
- // cli-134: the managed hooks run this backstop on every tool call (one lane read
867
- // both routes about once a second), yet a hook cannot enforce it: a hook exits 0
868
- // on anything but a SAFETY_ or Figma denial, and its banner is never claimed. So
869
- // a hook reuses an answer for 15 seconds. Every other command reads Dev fresh,
870
- // so it is blocked by an unacknowledged amendment (CTRL-CLI-34) and shows a
871
- // new Result (MW5-16) on its next call, exactly as before.
872
- 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);
873
1069
 
874
1070
  export async function main(argv = process.argv.slice(2)) {
875
1071
  // Ahead of every check that reaches Dev: a session the lane spawned gets
876
1072
  // nothing from these hooks. The safety hooks still run.
877
1073
  if (argv[0] === "hook" && LANE_RUN_HOOKS.has(argv[1]) && (await inSpawnedSession())) return;
1074
+ // MW1-37.2: a command prints what lanes wait on its coordinator for. A hook
1075
+ // and a supervisor write only their own answer.
1076
+ resetLaneItemsNotice();
1077
+ setLaneItemsObserver(argv[0] === "hook" || argv[0]?.startsWith("__") ? null : observeLaneItems);
878
1078
  // A lane's own exit reporter runs after its runtime ends (NODII-DEV-CLI-1).
879
1079
  if (argv[0] === "__lane-supervisor") return superviseLane();
880
- // Amendment acknowledgement is a lane-wide backstop for every other command.
881
- // A nudge hook is fail-open and writes only its own JSON: it cannot run a
882
- // Delta gather, and a waiting-results banner would corrupt its output.
883
- // surface-gen-pre runs in every session, lane or not, so it never reaches Dev.
884
- // The heartbeat hook fires on every tool call, so these checks would call Dev each
885
- // time past its rate limit, and a failed check would silently stop the heartbeat.
886
- if (argv[0] !== "__run-supervisor" && !readsHelp(argv) && !(argv[0] === "hook" && (argv[1]?.startsWith("nudge-") || argv[1] === "surface-gen-pre" || argv[1] === "lane-heartbeat"))) {
887
- const cache = backstopCache(argv);
888
- await amendmentGuard(argv, { cache });
889
- await showWaitingResults({ acknowledge: argv[0] !== "hook", cache });
1080
+ if (runsBackstop(argv)) {
1081
+ await amendmentGuard(argv);
1082
+ await showWaitingResults();
890
1083
  }
891
1084
  if (argv.length === 1 && ["--version", "-v"].includes(argv[0]))
892
1085
  return console.log(VERSION);
@@ -1054,6 +1247,7 @@ export async function main(argv = process.argv.slice(2)) {
1054
1247
  }
1055
1248
  return emitCommand(result);
1056
1249
  }
1250
+ if (command === "repo" && action === "docs-check") return emitCommand(await repoDocsCheckCommand(rest, f));
1057
1251
  if (command === "repo" && ["policy", "lint"].includes(action)) return emitCommand(await repoCommand(action, rest, f));
1058
1252
  if (command === "test") return emitCommand(await testCommand(action, rest, f, { readPolicy }));
1059
1253
  if (command === "watchdog") {
@@ -1120,10 +1314,21 @@ export async function main(argv = process.argv.slice(2)) {
1120
1314
  if (command === "chrome") return emitCommand(await (await import("./chrome.js")).chromeCommand(action, rest, f));
1121
1315
  if (command === "coordinator" && ["board", "watch"].includes(action))
1122
1316
  return emitCommand(await (await import("./coordinator-watch.js")).coordinatorWatchCommand(action, rest, f));
1317
+ if (command === "coordinator" && action === "items") {
1318
+ if (rest.length) throw new CliError("USAGE", "coordinator items [--machine NAME|ID]", 2);
1319
+ return emitCommand(await coordinatorItemsCommand(f));
1320
+ }
1123
1321
  if (command === "coordinator") return emitCommand(await coordinatorCommand(action, f, { installWatchdog }));
1124
1322
  if (command === "steward") return emitCommand(await stewardCommand(action, rest, f));
1125
1323
  if (command === "lane" && action === "launch") return emitCommand(await launchLaneCommand(rest[0], f));
1126
1324
  if (command === "lane" && action === "repo") return emitCommand(await laneRepoCommand(rest[0], rest.slice(1), f));
1325
+ if (command === "lane" && action === "leeway") return emitCommand(await laneLeewayCommand(rest, f));
1326
+ if (command === "lane" && action === "ask") return emitCommand(await laneAskCommand(rest, f));
1327
+ if (command === "lane" && action === "asks") return emitCommand(await laneAsksCommand(rest, f));
1328
+ if (command === "lane" && action === "answer") return emitCommand(await laneAnswerCommand(rest, f));
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));
1127
1332
  if (command === "lane" && action === "cap") return emitCommand(await laneCapCommand(rest, f));
1128
1333
  if (command === "lane" && action === "close") {
1129
1334
  const result = await laneClose(rest[0], f);
@@ -1669,60 +1874,23 @@ export async function main(argv = process.argv.slice(2)) {
1669
1874
  );
1670
1875
  }
1671
1876
  }
1672
- if (action === "safety-pre") {
1673
- let payload;
1674
- try {
1675
- payload = JSON.parse(await stdinText());
1676
- await recordHookFire(payload).catch(() => {});
1677
- const result = await safetyPreHook(payload);
1678
- const nudges = result.nudges ?? [];
1679
- // Both runtimes show the model a PreToolUse nudge only as additionalContext;
1680
- // Claude keeps plain stdout of an exit-0 hook out of the model's context.
1681
- if (nudges.length)
1682
- console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: nudges.join("\n") } }));
1683
- return;
1684
- } catch (error) {
1685
- // Only an evaluated safety rule may deny. Discovery, parsing, git,
1686
- // config and Dev errors fail open and produce no output.
1687
- if (!String(error?.code ?? "").startsWith("SAFETY_")) return;
1688
- if (payload && hookRuntime(payload) === "codex") {
1689
- console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: error?.message ?? String(error) } }));
1690
- return;
1691
- }
1692
- throw new CliError(
1693
- error?.code ?? "SAFETY_HOOK_FAILED",
1694
- error?.message ?? String(error),
1695
- 2,
1696
- error?.details,
1697
- );
1698
- }
1699
- }
1700
- if (action === "safety-post") {
1701
- let payload;
1702
- try {
1703
- payload = JSON.parse(await stdinText());
1704
- await recordHookFire(payload).catch(() => {});
1705
- await safetyPostHook(payload);
1706
- } 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;
1707
1884
  return;
1708
1885
  }
1709
- // Guideline nudges (AGENT-HARNESS-21) never block: any error, a payload
1710
- // they don't know or a session outside a lane ends in no output.
1711
- if (action === "nudge-pre") {
1886
+ // MW1-37.2: the coordinator gate, as its own hook. The managed dispatcher
1887
+ // runs the same check for a coordinator session; this is the direct form
1888
+ // (a deny on stdout, or context). It fails open: any error is no output.
1889
+ if (action === "coordinator-gate") {
1712
1890
  try {
1713
- const payload = JSON.parse(await stdinText());
1714
- await recordHookFire(payload).catch(() => {});
1715
- // Cite before you steer (MW1-95): a steward session, which is never a lane config.
1716
- if (!isLaneConfig() && steerAct(payload)) {
1717
- const config = await readConfig(false).catch(() => null);
1718
- const steward = await activeSteward(config?.agentId).catch(() => null);
1719
- const nudges = await stewardSteerNudges(payload, { steward });
1720
- if (nudges.length) console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: nudges.join("\n") } }));
1721
- if (steward) return;
1722
- }
1723
- if (!(await nudgeCandidate(payload))) return;
1724
- const nudges = await nudgePre(payload, await safetyContext(payload.cwd ?? process.cwd()));
1725
- if (nudges.length) console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: nudges.join("\n") } }));
1891
+ const verdict = await coordinatorGate(JSON.parse(await stdinText()));
1892
+ if (verdict?.deny) console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: verdict.deny } }));
1893
+ else if (verdict?.context) console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: verdict.context } }));
1726
1894
  } catch {}
1727
1895
  return;
1728
1896
  }
@@ -1750,7 +1918,10 @@ export async function main(argv = process.argv.slice(2)) {
1750
1918
  let payload = {};
1751
1919
  if (!process.stdin.isTTY) { try { payload = JSON.parse(await stdinText()); } catch {} }
1752
1920
  const result = await heartbeatFromHook(payload);
1753
- return emit(result, json, result.heartbeated ? `Heartbeat recorded for ${result.key}.` : `No heartbeat sent: ${result.reason}.`);
1921
+ // MW1-12.9: after a tool call, a lane that has not acknowledged an amendment is told so (a Stop takes no context).
1922
+ const pending = payload.hook_event_name === "PostToolUse" && isLaneConfig() ? await pendingAmendmentContext() : null;
1923
+ if (pending && !json) return console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: pending } }));
1924
+ return emit(pending ? { ...result, pendingAmendment: pending } : result, json, result.heartbeated ? `Heartbeat recorded for ${result.key}.` : `No heartbeat sent: ${result.reason}.`);
1754
1925
  } catch (error) {
1755
1926
  process.stderr.write(`nodii-dev lane heartbeat: ${error?.code ?? "ERROR"}: ${error?.message ?? String(error)}\n`);
1756
1927
  return;
@@ -1827,12 +1998,11 @@ export async function main(argv = process.argv.slice(2)) {
1827
1998
  }
1828
1999
 
1829
2000
  export function fail(error) {
2001
+ laneItemsNotice();
1830
2002
  const e =
1831
2003
  error instanceof CliError
1832
2004
  ? error
1833
2005
  : new CliError("UNEXPECTED", error?.message ?? String(error));
1834
- console.error(
1835
- `${e.code}: ${e.message}${e.details ? `\n${JSON.stringify(e.details)}` : ""}`,
1836
- );
2006
+ console.error(errorText(e));
1837
2007
  process.exitCode = e.exitCode ?? 1;
1838
2008
  }