yadflow 4.10.0 → 4.12.0

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.
Files changed (120) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/README.md +14 -3
  3. package/bin/commands.mjs +7 -1
  4. package/bin/yad.mjs +163 -16
  5. package/cli/agent-guard-worker.mjs +13 -0
  6. package/cli/agent-guard.mjs +1053 -57
  7. package/cli/agent-rules.mjs +59 -3
  8. package/cli/argv-flags.mjs +2 -2
  9. package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
  10. package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
  11. package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
  12. package/cli/brain/vendor/graphology-library.min.js +2 -0
  13. package/cli/brain/vendor/graphology.umd.min.js +2 -0
  14. package/cli/brain/vendor/sigma.min.js +1369 -0
  15. package/cli/brain/view/app.js +382 -0
  16. package/cli/brain/view/index.html +63 -0
  17. package/cli/brain/view/live.css +228 -0
  18. package/cli/brain/view/live.html +110 -0
  19. package/cli/brain/view/live.js +884 -0
  20. package/cli/brain/view/style.css +141 -0
  21. package/cli/brain-about.mjs +206 -0
  22. package/cli/brain-activity.mjs +285 -0
  23. package/cli/brain-skills.mjs +118 -0
  24. package/cli/brain-vendor.mjs +71 -0
  25. package/cli/brain-view.mjs +345 -0
  26. package/cli/brain.mjs +810 -0
  27. package/cli/brand-cmd.mjs +326 -0
  28. package/cli/brand.mjs +327 -0
  29. package/cli/ci-check.mjs +3 -3
  30. package/cli/doctor.mjs +145 -14
  31. package/cli/epic-state.mjs +93 -1
  32. package/cli/epic.mjs +15 -3
  33. package/cli/errors.mjs +2 -1
  34. package/cli/find-product.mjs +69 -15
  35. package/cli/foundation-publish.mjs +256 -0
  36. package/cli/gate.mjs +29 -3
  37. package/cli/git-read.mjs +38 -0
  38. package/cli/guard-stream.mjs +409 -0
  39. package/cli/guide.mjs +26 -3
  40. package/cli/hook.mjs +59 -9
  41. package/cli/issues-act.mjs +57 -13
  42. package/cli/issues-write.mjs +19 -6
  43. package/cli/issues.mjs +69 -24
  44. package/cli/lib.mjs +37 -2
  45. package/cli/local-page.mjs +138 -0
  46. package/cli/local-setup-record.mjs +71 -0
  47. package/cli/local-setup-steps.mjs +186 -0
  48. package/cli/local-setup.mjs +611 -0
  49. package/cli/machine.mjs +1 -1
  50. package/cli/manifest.mjs +55 -0
  51. package/cli/map/view/app.js +712 -0
  52. package/cli/map/view/index.html +50 -0
  53. package/cli/map/view/style.css +142 -0
  54. package/cli/map-view.mjs +190 -0
  55. package/cli/map.mjs +637 -0
  56. package/cli/members.mjs +9 -15
  57. package/cli/next.mjs +1 -1
  58. package/cli/openpr.mjs +2 -2
  59. package/cli/plain-text.mjs +22 -0
  60. package/cli/plan.mjs +310 -36
  61. package/cli/platform.mjs +5 -5
  62. package/cli/product-index.mjs +1 -1
  63. package/cli/protection.mjs +32 -0
  64. package/cli/reconcile.mjs +61 -13
  65. package/cli/report.mjs +9 -3
  66. package/cli/reports-dir.mjs +393 -0
  67. package/cli/reports.mjs +65 -0
  68. package/cli/run-checks.mjs +5 -2
  69. package/cli/scan.mjs +4 -6
  70. package/cli/secret-text.mjs +66 -0
  71. package/cli/setup.mjs +54 -8
  72. package/cli/standup.mjs +94 -72
  73. package/cli/status.mjs +6 -5
  74. package/cli/test-agents-file.mjs +614 -8
  75. package/cli/test-brain-activity.mjs +753 -0
  76. package/cli/test-brain-view.mjs +381 -0
  77. package/cli/test-brain.mjs +795 -0
  78. package/cli/test-brand.mjs +558 -0
  79. package/cli/test-guide.mjs +438 -0
  80. package/cli/test-local-setup.mjs +1188 -0
  81. package/cli/test-machine.mjs +59 -0
  82. package/cli/test-map.mjs +615 -0
  83. package/cli/test-reports.mjs +382 -0
  84. package/cli/test-run-checks.mjs +4 -0
  85. package/cli/test-worktree.mjs +24 -3
  86. package/cli/toolbox-connect.mjs +21 -6
  87. package/cli/toolbox.mjs +74 -5
  88. package/cli/update-commit.mjs +118 -9
  89. package/cli/usage.mjs +17 -7
  90. package/cli/workspace.mjs +11 -2
  91. package/package.json +8 -4
  92. package/skills/sdlc/module-help.csv +1 -0
  93. package/skills/yad-architecture/SKILL.md +22 -4
  94. package/skills/yad-brand/SKILL.md +69 -0
  95. package/skills/yad-change/SKILL.md +3 -1
  96. package/skills/yad-change/references/triage.md +2 -0
  97. package/skills/yad-checks/SKILL.md +2 -0
  98. package/skills/yad-checks/references/check-gates.md +8 -5
  99. package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
  100. package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
  101. package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
  102. package/skills/yad-checks/templates/github/yad-checks.yml +3 -2
  103. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +3 -2
  104. package/skills/yad-checks/templates/hooks/local-setup-notice.mjs +96 -0
  105. package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
  106. package/skills/yad-connect-repos/SKILL.md +14 -0
  107. package/skills/yad-discovery/SKILL.md +11 -0
  108. package/skills/yad-discovery/references/foundation-schema.md +11 -0
  109. package/skills/yad-docs/templates/app/package-lock.json +18 -10
  110. package/skills/yad-docs/templates/app/package.json +6 -1
  111. package/skills/yad-epic/SKILL.md +3 -0
  112. package/skills/yad-epic/references/state-schema.md +35 -1
  113. package/skills/yad-guide/SKILL.md +10 -7
  114. package/skills/yad-implement/SKILL.md +76 -15
  115. package/skills/yad-issues/SKILL.md +2 -1
  116. package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
  117. package/skills/yad-pr-template/templates/checks/pr-title.sh +8 -4
  118. package/skills/yad-spec/SKILL.md +19 -0
  119. package/skills/yad-stories/SKILL.md +22 -4
  120. package/skills/yad-stories/references/story-schema.md +1 -1
package/bin/yad.mjs CHANGED
@@ -135,15 +135,16 @@ ${c.bold('Team members')} ${c.dim('(identity only — no roles, no reviewers, no
135
135
 
136
136
  ${c.bold('Issues and work items')} ${c.dim('(read live from GitHub issues and GitLab issues, tasks and incidents)')}
137
137
  yad issues [list] Items of the Product and every registered repo, with priority,
138
- type, status and assignee. Filter with --priority --type --status
139
- --assignee --me --repo --since --until --date; order with --sort.
138
+ type, status, assignee and other labels. Filter with --priority
139
+ --type --status --label --assignee --me --repo --since --until
140
+ --date; order with --sort. Repeat --label to need every one.
140
141
  --format html writes a page you can sort and filter; titles are
141
142
  included, so check it before sharing it outside the team
142
143
  yad issues labels [--dry-run] Create the predefined priority, type and status labels each repo lacks
143
144
  yad scan file <f> --repo <r> File a scan's findings on the repo's tracker, by category and priority (the yad-scan skill runs it)
144
145
  yad issues new --title <t> [--body-file <f>] [--type <t>] [--priority P1] [--assignee <login>|--me] [--repo <r>]
145
146
  Open an issue / work item (in the Product repo unless --repo names one)
146
- yad issues assign <ref> <login>|--me|--none · label <ref> --priority P1 --type bug
147
+ yad issues assign <ref> <login>|--me|--none · label <ref> --priority P1 --type bug --add <l> --remove <l>
147
148
  yad issues edit <ref> [--title] [--body-file] · comment <ref> --body-file <f> · close <ref> · reopen <ref>
148
149
  yad issues sync [--dry-run] Update linked items: status and type labels, and close once every epic shipped
149
150
  yad issues show <ref> One item in full. <ref> is 12 (Product repo) or <repo>#12
@@ -162,10 +163,43 @@ ${c.bold('Daily standup')} ${c.dim('(derived live, read-only, facts only — no
162
163
  flags: --since <YYYY-MM-DD>|<N>h|<N>d, --tz <zone> (default UTC),
163
164
  --member <login> | --me, --format md|html, --out <file>, --json
164
165
 
166
+ ${c.bold('Progress map')} ${c.dim('(E181 — read-only; names as roles, no score, no ranking)')}
167
+ yad map [--open] The road to Production as one moving picture: epics, stories, tasks
168
+ and branches flowing through each repo's Development branch into
169
+ Production, with who owns, built, reviewed and approved each part.
170
+ A local page on 127.0.0.1 with a one-time key; Ctrl-C stops it
171
+ yad map --html [<file>] [--open] The same page as one file, saved in the local reports folder; it
172
+ lights what moved since the last saved map
173
+ yad map --live [--open] The page draws itself again when the ledger or a repo changes
174
+ flags: --anonymous (every person as "Person A…", for sharing
175
+ outside the team), --fetch (git fetch origin first; downloads
176
+ only), --json. The Production branch is "map.production" in
177
+ product.json, else guessed (and the page says so)
178
+
179
+ ${c.bold('Brand')} ${c.dim('(E184 — the look every page yad makes wears)')}
180
+ yad brand [show] [--json] The brand the pages wear: the Product's (.sdlc/brand.json) or
181
+ yadflow's, with its colours, fonts, logo and any problem
182
+ yad brand init [--from <DESIGN.md>] [--logo <file>] [--mark <file>] [--force]
183
+ Make .sdlc/brand.json from the Product's DESIGN.md (its YAML
184
+ front matter or :root block); says each colour it found and
185
+ each it did not. For prose, ask the agent (yad-brand skill)
186
+ yad brand check [--json] Is the brand file usable, readable (contrast) and current
187
+
188
+ ${c.bold('Saved reports')} ${c.dim('(E180 — on this machine only, never committed)')}
189
+ yad reports [list] [--json] Every report saved in the local reports folder, newest first, each
190
+ marked fresh or stale (the Product changed since it was made).
191
+ The folder is <product>--reports beside the Product, or
192
+ $YAD_REPORTS_DIR. Reports land there when no --out is given:
193
+ standup, usage, issues list --format, brain view --html
194
+ yad reports open <n|file> Open one in the browser
195
+ yad reports prune --older-than <days> | --missing [--apply]
196
+ Remove saved reports older than that, or with --missing only drop
197
+ catalog entries whose file is gone (a dry run without --apply)
198
+
165
199
  ${c.bold('Team usage (EM adoption & behavior report)')}
166
200
  yad usage Build a per-member report (HTML) from git + the SDLC ledgers
167
201
  (derived, read-only — writes no tracked state)
168
- flags: --out <path> (default ./usage-report.html),
202
+ flags: --out <path> (default: the local reports folder),
169
203
  --since <YYYY-MM-DD> --until <YYYY-MM-DD> | --all,
170
204
  --member <name>, --format html|json|md, --repos (code commits)
171
205
 
@@ -196,6 +230,7 @@ ${c.bold('Where am I / what next')}
196
230
  per product, before any epic — then the yad-discovery skill
197
231
  authors its sections. Refuses a second one, and a product still
198
232
  on the old epics/EP-discovery/ (yad migrate converts that)
233
+ yad foundation publish [--dry-run] After the Foundation review: one issue / work item per roadmap feature, a milestone per phase
199
234
  yad foundation status [--json] Which roadmap features are started: reads each proposed epic id
200
235
  in roadmap.md and reports planned / in-shape / in-build /
201
236
  shipped from the epic ledgers. Read-only — the roadmap's Status
@@ -236,7 +271,7 @@ ${c.bold('Where am I / what next')}
236
271
  command (pool skill first, yadflow's skill last). Binds nothing
237
272
  yad toolbox list [--json] [--dir <folder>]
238
273
  The external tools yadflow can use — core (offered at setup),
239
- recommended (skill pools, Docker MCP, Unity MCP), the connectors and
274
+ recommended (skill pools, Docker MCP, two Unity MCPs), the connectors and
240
275
  this project's own — whether each is found here, whether this
241
276
  project uses it, and what yadflow does without it. Installs nothing
242
277
  yad toolbox check [--json] The tools this project uses that are not ready here, each with
@@ -252,6 +287,19 @@ ${c.bold('Where am I / what next')}
252
287
  are yours, and the question to ask. Runs nothing. --verify
253
288
  checks it is found here, then records it as the team's choice;
254
289
  --replace when that replaces the team's current tool
290
+ yad local-setup [list] [--json] The local setup script (E185): the steps each team member's
291
+ machine needs (.sdlc/local-setup.json, shown in LOCAL-SETUP.md),
292
+ each with why and what it changes, and whether it is done here.
293
+ Runs only yad's own checks, never a step
294
+ yad local-setup done <id>… Record on this machine that you did these steps (a step yad can
295
+ check must pass its check first)
296
+ yad local-setup skip <id> --reason <text> Record that you said no to a step; it is asked again
297
+ only when the step changes. Both write inside .git, never a file
298
+ anyone commits
299
+ yad local-setup add --from <step.json> Add one of your team's steps (a JSON object: id, title,
300
+ purpose, impact, when, commands, and check, verify, person if
301
+ wanted) to the script and LOCAL-SETUP.md; commit both
302
+ yad local-setup remove <id> Take one of your team's steps out again
255
303
  yad detect [--json] [--dir <folder>] Which skills, agents, MCP servers and plugins are installed
256
304
  for the agents that work here — in this folder and in your
257
305
  home folder, and which agents read each place. Read-only;
@@ -432,6 +480,34 @@ ${c.bold('Build helpers')}
432
480
  yad history search <text> [filters] [--json]
433
481
  Match text in ids, titles, themes, types, repos, and in who
434
482
  closed or merged a step, its PR and its commit
483
+ yad brain build [--repo <name>] [--json]
484
+ The project brain (E176): run Graphify (local, no LLM) in each
485
+ connected code repo, then merge its code graph with the work items
486
+ (epics, stories, tasks, contract surfaces, ships) into
487
+ .sdlc/brain/graph.json — on this machine only, never committed
488
+ yad brain query <text> [--limit <n>] [--json]
489
+ The brain's nodes whose name holds <text>, each with its neighbours
490
+ yad brain file <repo>/<path> [--repo <name>] [--limit <n>] [--json]
491
+ One file (E179): the tasks and stories that declare it, the code it
492
+ defines, the files that use it and that it uses, its ships, and the
493
+ contract surfaces that reach it — what to know before editing it
494
+ yad brain story <story-id> [--limit <n>] [--json]
495
+ One story (E179): its epic, repos, tasks, every file they declare,
496
+ and its ships
497
+ yad brain status [--json] Is the brain current, and is each repo's code graph current
498
+ yad brain view [--open] Draw the brain in a browser (E177): a local page on 127.0.0.1 with a
499
+ one-time key, the code and the work in one graph — filter, search, a
500
+ node's neighbours. Ctrl-C stops it
501
+ yad brain view --html [<file>] [--open]
502
+ The same page as one file that needs no server and no network
503
+ (default: the local reports folder, never committed)
504
+ yad brain view --live [--open] Watch an agent work (E178): each file it reads, searches or edits and
505
+ each command it runs lights up the brain, with a Now card, Plan vs
506
+ reality and a timeline to replay. Needs "activity": true in the
507
+ Product config (then yad check --fix). Shows what, never why
508
+ yad brain view --html --live [<file>]
509
+ The recorded activity as an offline replay file
510
+ (default: the local reports folder, never committed)
435
511
  yad review trailer --repo <r> --pr <n> --body <text> Post the companion's 60-sec briefing to a code PR/MR
436
512
  yad review context --repo <r> --pr <n> Print the grounding bundle for cards/chat
437
513
  yad review walkthrough --repo <r> --pr <n> Bundle + ordered risk-tagged stops for the
@@ -517,7 +593,7 @@ ${c.bold('Environment')}
517
593
  YAD_PLATFORM_LOGIN=0 Name a record's author by git user.name; never ask gh/glab who is logged in`;
518
594
 
519
595
  const REPORT_USAGE = 'usage: yad report [-m <text>] [--kind bug|enhancement] [--json] | yad report -m <text> [--kind …] --post --confirm <value>';
520
- const ISSUES_USAGE = 'usage: yad issues new --title <t> [--body-file <f>] [--type <t>] [--priority P0-P3] [--assignee <login>|--me] [--repo <name>] | assign <ref> <login>|--me|--none | label <ref> [--priority P0-P3] [--type <t>] | edit <ref> [--title <t>] [--body-file <f>] | comment <ref> --body-file <f> | close <ref> | reopen <ref> | show <ref> | link <ref> <EP-id> | unlink <ref> <EP-id> | sync [--dry-run] | labels [--dry-run] | [list] [--priority P0,P1] [--type bug,feature,enhancement,security,tech-debt,suggestion] [--status todo,"in progress",done] [--assignee <login>|none|--me] [--repo <name>] [--since <date>] [--until <date>] [--date created|updated|due] [--sort priority|type|status|due|updated] [--closed-since <date>|<N>d] [--format md|html] [--out <file>] [--json] | yad issues labels [--dry-run] [--json]';
596
+ const ISSUES_USAGE = 'usage: yad issues new --title <t> [--body-file <f>] [--type <t>] [--priority P0-P3] [--assignee <login>|--me] [--repo <name>] | assign <ref> <login>|--me|--none | label <ref> [--priority P0-P3] [--type <t>] [--add <label>]... [--remove <label>]... | edit <ref> [--title <t>] [--body-file <f>] | comment <ref> --body-file <f> | close <ref> | reopen <ref> | show <ref> | link <ref> <EP-id> | unlink <ref> <EP-id> | sync [--dry-run] | labels [--dry-run] | [list] [--priority P0,P1] [--type bug,feature,enhancement,security,tech-debt,suggestion] [--status todo,"in progress",done] [--label <name>[,<name>]]... [--assignee <login>|none|--me] [--repo <name>] [--since <date>] [--until <date>] [--date created|updated|due] [--sort priority|type|status|due|updated] [--closed-since <date>|<N>d] [--format md|html] [--out <file>] [--json] | yad issues labels [--dry-run] [--json]';
521
597
  const STANDUP_USAGE = 'usage: yad standup [--since <YYYY-MM-DD>|<N>h|<N>d] [--tz <zone>] [--member <login>|--me] [--format md|html] [--out <file>] [--json]';
522
598
 
523
599
 
@@ -552,7 +628,12 @@ function parseArgs(argv) {
552
628
  else if (a === '--check') { const v = argv[i + 1]; o.check = (o._[0] === 'next' && v !== undefined && !v.startsWith('-')) ? argv[++i] : true; }
553
629
  else if (a === '--all') o.all = true;
554
630
  else if (a === '--brief') o.brief = true;
631
+ else if (a === '--missing') o.missing = true;
555
632
  else if (a === '--open') o.open = true;
633
+ else if (a === '--html') o.html = true;
634
+ else if (a === '--live') o.live = true;
635
+ else if (a === '--anonymous') o.anonymous = true;
636
+ else if (a === '--fetch') o.fetch = true;
556
637
  else if (a === '--done') o.done = true;
557
638
  else if (a === '--undo') o.undo = true;
558
639
  else if (a === '--debt') o.debt = true;
@@ -638,12 +719,13 @@ let runningCmd = null;
638
719
  // refusal of `yad gate frobnicate` names `gate`, not a command that does not exist.
639
720
  const ACTIONS = {
640
721
  epic: { known: ['new'] },
641
- foundation: { known: ['new', 'status'] },
722
+ foundation: { known: ['new', 'status', 'publish'] },
642
723
  skill: { known: ['list', 'bind', 'unbind', 'recommend'], default: 'list' },
643
724
  gate: { known: ['open', 'sync', 'comments', 'status', 'repair', 'reopen', 'review', 'walkthrough', 'trailer', 'ci', 'approve', 'comment', 'advance'] },
644
725
  review: { known: ['trailer', 'context', 'chat', 'cards', 'walkthrough', 'nudge', 'reconcile'] },
645
726
  tidy: { known: ['up'] },
646
727
  history: { known: ['list', 'show', 'search'], default: 'list' },
728
+ brain: { known: ['build', 'query', 'file', 'story', 'status', 'view'], default: 'status' },
647
729
  repo: { known: ['list', 'refresh', 'sync', 'clone', 'preview'], default: 'list' },
648
730
  'risk-map': { known: ['check', 'draft'], default: 'check' },
649
731
  codeowners: { known: ['check'], default: 'check' },
@@ -652,6 +734,7 @@ const ACTIONS = {
652
734
  reconcile: { known: ['check', 'refresh', 'wire'] },
653
735
  hook: { known: ['ledger-guard', 'agent-guard'] },
654
736
  toolbox: { known: ['list', 'check', 'add', 'remove', 'connect'], default: 'list' },
737
+ 'local-setup': { known: ['list', 'done', 'skip', 'add', 'remove'], default: 'list' },
655
738
  signing: { known: ['check'], default: 'check' },
656
739
  ci: { known: ['check'], default: 'check' },
657
740
  member: { known: ['add', 'list', 'remove'], default: 'list' },
@@ -660,6 +743,8 @@ const ACTIONS = {
660
743
  worktree: { known: ['add', 'list', 'remove'], default: 'list' },
661
744
  run: { known: ['checks'] },
662
745
  build: { known: ['start', 'step', 'trust', 'ship', 'merged', 'done', 'sync'] },
746
+ reports: { known: ['list', 'open', 'prune'], default: 'list' },
747
+ brand: { known: ['show', 'init', 'check'], default: 'show' },
663
748
  };
664
749
  // E80 — how each command finds its folder. A PRODUCT command works on the Product; a REPO command works
665
750
  // on the code repo it runs in and reads the Product beside it. The rest take their folder as given:
@@ -669,7 +754,7 @@ const PRODUCT_CMDS = new Set([
669
754
  'skip', 'unskip', 'defer', 'undefer', 'dial', 'mode', 'kill', 'unkill', 'unblock', 'gate', 'checkpoint',
670
755
  'capture', 'claims', 'assign', 'unassign', 'owners', 'fold', 'tidy', 'index', 'history', 'repo',
671
756
  'risk-map', 'codeowners', 'docs', 'thread', 'reconcile', 'member', 'standup', 'issues', 'scan', 'build', 'worktree', 'ci',
672
- 'story',
757
+ 'story', 'brain', 'reports', 'map', 'local-setup', 'brand',
673
758
  ]);
674
759
  // `status` reads the Product but must keep the folder it ran in: "here" is that checkout's task branch (#349).
675
760
  const REPO_CMDS = new Set(['commit', 'open-pr', 'ship', 'review', 'run', 'status', 'guide']);
@@ -682,8 +767,15 @@ function writesProduct(cmd, o) {
682
767
  // `build merged` only asks the platform, unless --ship records what it found.
683
768
  if (cmd === 'build') return action === 'sync' ? !o.dryRun : action !== 'merged' || !!o.ship;
684
769
  if (cmd === 'check') return !!o.fix;
770
+ // `brain build` writes the brain into the Product. `brain view --html` with no file named saves into the
771
+ // Product's local reports folder (E180), so it needs the Product found too: else the shared refusal.
772
+ if (cmd === 'brain') return action === 'build' || (action === 'view' && !!o.html);
685
773
  if (cmd === 'epic' || cmd === 'foundation') return action === 'new';
686
774
  if (cmd === 'skill') return action === 'bind' || action === 'unbind';
775
+ // `local-setup add|remove` write the Product's committed script (E185 part 3).
776
+ if (cmd === 'local-setup') return action === 'add' || action === 'remove';
777
+ // `brand init` writes the Product's .sdlc/brand.json: only into a Product found (review 1).
778
+ if (cmd === 'brand') return action === 'init';
687
779
  if (cmd === 'dial') return o.to !== undefined;
688
780
  if (cmd === 'member') return o._[1] === 'add' || o._[1] === 'remove';
689
781
  if (cmd === 'worktree') return o._[1] === 'add' || o._[1] === 'remove';
@@ -743,7 +835,7 @@ async function main() {
743
835
  // so it takes no --json (E1).
744
836
  if (inJSON()) return refuse('yad hook takes no --json — its output is the protocol the agent reads', 'run it without --json');
745
837
  // E158: the agent guard, before an agent's shell command.
746
- if (action === 'agent-guard') { runAgentGuardHook({ format: o.format ?? null }); return; }
838
+ if (action === 'agent-guard') { await runAgentGuardHook({ format: o.format ?? null }); return; }
747
839
  if (action !== 'ledger-guard') return refuse(`unknown hook: ${action ?? '(none)'} (ledger-guard, agent-guard)`);
748
840
  // `--staged` is the git pre-commit half (E48): the files come from the index, never from stdin.
749
841
  if (o.staged) { runStagedLedgerGuard(); return; }
@@ -790,14 +882,15 @@ async function main() {
790
882
  process.stderr.write(c.dim(`Product: ${shown(found.root)} (${found.worktree ? `${found.worktree}'s worktree` : found.via === 'workspace' ? `from ${commands.WORKSPACE_FILE}` : 'above this folder'})\n`));
791
883
  // Run from inside one code repo, the per-repo commands work on THAT repo, not on every one the
792
884
  // Product registers (they take the repo's name as their second word).
793
- // The CHECKOUT must be the registered repo (a worktree or nested repo inside it is another one).
885
+ // The CHECKOUT must be the registered repo's own: these commands work on `<Product>/<path>`, so from a
886
+ // worktree (on another branch) or a nested repo they cover every repo instead (E80 review 3, #515).
794
887
  if ((cmd === 'risk-map' || cmd === 'codeowners') && o._[2] === undefined) {
795
- const hit = commands.registryEntryFor(found.root, dirGiven ? o.dir : shellCwd());
888
+ const hit = commands.registeredCheckoutFor(found.root, dirGiven ? o.dir : shellCwd());
796
889
  if (typeof hit?.meta?.name === 'string') o._[2] = hit.meta.name;
797
890
  }
798
891
  // `yad ci check` the same way: that repo, unless --repo or --all says otherwise.
799
892
  if (cmd === 'ci' && o.repo === undefined && !o.all) {
800
- const hit = commands.registryEntryFor(found.root, dirGiven ? o.dir : shellCwd());
893
+ const hit = commands.registeredCheckoutFor(found.root, dirGiven ? o.dir : shellCwd());
801
894
  if (typeof hit?.meta?.name === 'string') o.repo = hit.meta.name;
802
895
  }
803
896
  }
@@ -882,7 +975,7 @@ async function main() {
882
975
  if (noProduct()) break;
883
976
  if (o.push && o.openPr) { refuse('--push and --open-pr publish the update two different ways — pick one', 'use --open-pr for a branch and a PR/MR per repo, or --push to push straight to each default branch'); break; }
884
977
  if (o.openPr && o.allowBranch) { refuse('--allow-branch does not apply to --open-pr: the update branch is cut from each repo\'s default branch', 'switch each repo to its default branch, then run it again'); break; }
885
- result = await commands.reconcile(o.dir, { fix: true, scope: 'changed', force: o.force, push: o.push, openPr: o.openPr, allowBranch: o.allowBranch, overwriteLocal: o.overwriteLocal, today, toolbox: toolboxAt });
978
+ result = await commands.reconcile(o.dir, { fix: true, scope: 'changed', force: o.force, push: o.push, openPr: o.openPr, allowBranch: o.allowBranch, overwriteLocal: o.overwriteLocal, today, toolbox: toolboxAt, invite: true });
886
979
  break;
887
980
  case 'doctor':
888
981
  result = await commands.runDoctor(o.dir, { json: o.json });
@@ -968,6 +1061,24 @@ async function main() {
968
1061
  : commands.runToolboxRemove(productRoot, { id, custom: o.custom, role: o.role, fallback: o.fallback, detect: o.detect, install: o.install, source: o.source, json: o.json });
969
1062
  break;
970
1063
  }
1064
+ case 'local-setup': {
1065
+ // E185. `list` reads the Product's committed script and runs yad's own checks for this machine. `done` and
1066
+ // `skip` write only this machine's answers, inside git's own folder (cli/local-setup-record.mjs).
1067
+ const [, action = 'list', ...words] = o._;
1068
+ const usage = 'usage: yad local-setup [list] [--json] | done <id>… | skip <id> --reason "<why>" | add --from <step.json> | remove <id> [--dir <the Product>]';
1069
+ if (!['list', 'done', 'skip', 'add', 'remove'].includes(action)) { refuse(`unknown local-setup action: ${action} (list, done, skip, add, remove)`, usage); break; }
1070
+ if (action === 'add' && words.length) { refuse(`yad local-setup add takes the step from --from <step.json>, not words (got: ${words.join(' ')})`, usage); break; }
1071
+ if (action !== 'add' && o.from !== undefined) { refuse('--from goes with yad local-setup add', usage); break; }
1072
+ if (action === 'list' && words.length) { refuse(`yad local-setup list takes no more words (got: ${words.join(' ')})`, usage); break; }
1073
+ if (action !== 'skip' && o.reason !== undefined) { refuse(`--reason goes with yad local-setup skip`, usage); break; }
1074
+ if (!commands.hasProduct(o.dir)) { refuse(`no Product here (${o.dir}) — the local setup script is the Product's .sdlc/local-setup.json`, 'run it from the Product, or from a repo it registers'); break; }
1075
+ result = action === 'list' ? commands.runLocalSetupList(o.dir, { json: o.json })
1076
+ : action === 'done' ? commands.runLocalSetupDone(o.dir, { ids: words, json: o.json })
1077
+ : action === 'skip' ? commands.runLocalSetupSkip(o.dir, { ids: words, reason: o.reason, json: o.json })
1078
+ : action === 'add' ? commands.runLocalSetupAdd(o.dir, { from: o.from, json: o.json })
1079
+ : commands.runLocalSetupRemove(o.dir, { ids: words, json: o.json });
1080
+ break;
1081
+ }
971
1082
  case 'detect': {
972
1083
  // E50. Reads the folder and the home folder; writes nothing.
973
1084
  const [, extra] = o._;
@@ -1021,8 +1132,10 @@ async function main() {
1021
1132
  case 'foundation': {
1022
1133
  const [, action] = o._;
1023
1134
  if (action === 'status') { result = await commands.runFoundationStatus(o.dir, { json: o.json }); break; }
1135
+ // E174: the approved roadmap becomes work items in the Product repo.
1136
+ if (action === 'publish') { if (noProduct()) break; result = await commands.runFoundationPublish(o.dir, { dryRun: !!o.dryRun, json: !!o.json }); break; }
1024
1137
  if (action !== 'new') {
1025
- refuse(`unknown foundation action: ${action ?? '(none)'} (new, status)`, 'usage: yad foundation new [--json] | yad foundation status [--json]');
1138
+ refuse(`unknown foundation action: ${action ?? '(none)'} (new, status, publish)`, 'usage: yad foundation new [--json] | yad foundation status [--json] | yad foundation publish [--dry-run] [--json]');
1026
1139
  break;
1027
1140
  }
1028
1141
  if (noProduct()) break;
@@ -1282,7 +1395,7 @@ async function main() {
1282
1395
  const common = { json: !!o.json };
1283
1396
  if (action === 'new') result = await commands.runIssuesNew(o.dir, { ...common, title: o.title, body: o.body ?? null, bodyFile: o['body-file'] ?? null, type: o.type ?? null, priority: o.priority ?? null, assignee: o.assignee ?? null, me: !!o.me, repo: o.repo ?? null });
1284
1397
  else if (action === 'assign') result = await commands.runIssuesAssign(o.dir, { ...common, ref: words[0], assignee: words[1] ?? null, me: !!o.me, none: !!o.none });
1285
- else if (action === 'label') result = await commands.runIssuesLabel(o.dir, { ...common, ref: words[0], priority: o.priority ?? null, type: o.type ?? null });
1398
+ else if (action === 'label') result = await commands.runIssuesLabel(o.dir, { ...common, ref: words[0], priority: o.priority ?? null, type: o.type ?? null, add: o.add ?? [], remove: o.remove ?? [] });
1286
1399
  else if (action === 'edit') result = await commands.runIssuesEdit(o.dir, { ...common, ref: words[0], title: o.title ?? null, body: o.body ?? null, bodyFile: o['body-file'] ?? null });
1287
1400
  else if (action === 'comment') result = await commands.runIssuesComment(o.dir, { ...common, ref: words[0], body: o.body ?? null, bodyFile: o['body-file'] ?? null });
1288
1401
  else result = await (action === 'close' ? commands.runIssuesClose : commands.runIssuesReopen)(o.dir, { ...common, ref: words[0] });
@@ -1302,7 +1415,7 @@ async function main() {
1302
1415
  if (action === 'sync') { result = await commands.runIssuesSync(o.dir, { dryRun: !!o.dryRun, json: !!o.json }); break; }
1303
1416
  if (action === 'labels') { result = await commands.runIssuesLabels(o.dir, { dryRun: !!o.dryRun, json: !!o.json }); break; }
1304
1417
  result = await commands.runIssuesList(o.dir, {
1305
- priority: o.priority ?? null, type: o.type ?? null, status: o.status ?? null, assignee: o.assignee ?? null, me: !!o.me, repo: o.repo ?? null,
1418
+ priority: o.priority ?? null, type: o.type ?? null, status: o.status ?? null, label: o.label ?? [], assignee: o.assignee ?? null, me: !!o.me, repo: o.repo ?? null,
1306
1419
  since: o.since ?? null, until: o.until ?? null, date: o.date ?? null, sort: o.sort ?? null, closedSince: o['closed-since'] ?? null,
1307
1420
  format: o.format ?? null, out: o.out ?? null, json: !!o.json,
1308
1421
  });
@@ -1329,6 +1442,28 @@ async function main() {
1329
1442
  });
1330
1443
  break;
1331
1444
  }
1445
+ case 'map': {
1446
+ // E181. Read-only, except --fetch (download only) and the file --html writes.
1447
+ const MAP_OWN = new Set(['--open', '--html', '--live', '--anonymous', '--fetch', '--json', '--dir']);
1448
+ const foreign = [...new Set(process.argv.slice(2).filter((t) => /^--./.test(t) || /^-[A-Za-z]$/.test(t)).map((t) => t.split('=')[0]).filter((f) => !MAP_OWN.has(f)))];
1449
+ if (foreign.length) { refuse(`yad map does not take ${foreign.join(', ')}`, commands.MAP_USAGE); break; }
1450
+ if (noProduct()) break;
1451
+ result = await commands.runMap(o.dir, { args: o._.slice(1), html: !!o.html, open: !!o.open, live: !!o.live, anonymous: !!o.anonymous, fetch: !!o.fetch, json: !!o.json });
1452
+ break;
1453
+ }
1454
+ case 'brand': {
1455
+ // E184. The Product's brand file; `init` writes it, the rest read.
1456
+ const [, action, ...args] = o._;
1457
+ if (noProduct()) break;
1458
+ result = await commands.runBrand(o.dir, { action: action || 'show', args, from: o.from ?? null, logo: o.logo ?? null, mark: o.mark ?? null, force: !!o.force, json: !!o.json });
1459
+ break;
1460
+ }
1461
+ case 'reports': {
1462
+ // E180. The local reports folder; nothing here touches the Product or any repo.
1463
+ const [, action, ...args] = o._;
1464
+ result = await commands.runReports(o.dir, { action: action || 'list', args, olderThan: o['older-than'] ?? null, missing: !!o.missing, apply: !!o.apply, json: !!o.json });
1465
+ break;
1466
+ }
1332
1467
  case 'claims': {
1333
1468
  // E46. Read from the capture branches; nothing is recorded here.
1334
1469
  const [, epic, extra] = o._;
@@ -1394,6 +1529,18 @@ async function main() {
1394
1529
  });
1395
1530
  break;
1396
1531
  }
1532
+ case 'brain': {
1533
+ const [, action, ...args] = o._;
1534
+ // As history does: a flag brain does not take is refused, read from the raw arguments — `parseArgs`
1535
+ // turns an unknown flag into a plain word, which `query` would take as search text.
1536
+ const BRAIN_OWN = new Set(commands.BRAIN_FLAGS);
1537
+ const unknownFlags = [...new Set(process.argv.slice(2)
1538
+ .filter((t) => /^--./.test(t) || /^-[A-Za-z]$/.test(t))
1539
+ .map((t) => t.split('=')[0])
1540
+ .filter((f) => !BRAIN_OWN.has(f)))];
1541
+ result = await commands.runBrain(o.dir, { action: action || 'status', args, repo: o.repo ?? null, limit: o.limit ?? null, json: !!o.json, open: !!o.open, html: !!o.html, live: !!o.live, unknownFlags });
1542
+ break;
1543
+ }
1397
1544
  case 'repo': {
1398
1545
  const [, action, name] = o._;
1399
1546
  // `yad repo preview <name> [<pattern>]` (#359): the one action with a third word.
@@ -0,0 +1,13 @@
1
+ // The agent guard's decision, run in a worker thread by `yad hook agent-guard` (cli/hook.mjs, #498). The worker
2
+ // has a memory cap and a time limit: a line that would run the guard out of memory, or past its time, ends the
3
+ // worker, not the hook, and the hook refuses the line. A crashed hook exits with a code the harness reads as
4
+ // "no answer", and the command runs.
5
+ import { parentPort, workerData } from 'node:worker_threads';
6
+ import { agentGuardDecision, agentGuardPreapproval } from './agent-guard.mjs';
7
+
8
+ const { command, preapproval } = workerData;
9
+ // The verdict first: pre-approval (E167) reads the same line again, under the same limits, and when it runs out
10
+ // of time the verdict stands, only not pre-approved.
11
+ const verdict = agentGuardDecision(command);
12
+ parentPort.postMessage({ verdict });
13
+ if (verdict.allow && preapproval) parentPort.postMessage({ pre: agentGuardPreapproval(command, preapproval) });