forgedock 1.53.0 → 1.54.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 (185) hide show
  1. package/.claude-plugin/marketplace.json +51 -0
  2. package/README.md +8 -2
  3. package/bin/auth/app-manifest.mjs +89 -0
  4. package/bin/auth/app-manifest.test.mjs +75 -0
  5. package/bin/auth/app-token.mjs +256 -0
  6. package/bin/auth/app-token.test.mjs +232 -0
  7. package/bin/brand.mjs +7 -0
  8. package/bin/config-history.mjs +151 -0
  9. package/bin/config-schema.mjs +115 -0
  10. package/bin/demo.mjs +65 -11
  11. package/bin/engine/outcome-codes.mjs +6 -3
  12. package/bin/engine/telemetry-seam.mjs +8 -2
  13. package/bin/engine/telemetry-seam.test.mjs +17 -0
  14. package/bin/engine-cli.mjs +57 -20
  15. package/bin/first-run.mjs +122 -0
  16. package/bin/forgedock.mjs +128 -146
  17. package/bin/help-text.mjs +144 -0
  18. package/bin/hooks/pre-tool-use.mjs +7 -0
  19. package/bin/journey.mjs +82 -83
  20. package/bin/lean/acceptance.mjs +313 -0
  21. package/bin/lean/acceptance.test.mjs +215 -0
  22. package/bin/lean/activation.mjs +18 -0
  23. package/bin/lean/activation.test.mjs +23 -1
  24. package/bin/lean/batch-health.mjs +74 -1
  25. package/bin/lean/batch-health.test.mjs +54 -1
  26. package/bin/lean/batch.test.mjs +11 -9
  27. package/bin/lean/branchlock.mjs +54 -0
  28. package/bin/lean/branchlock.test.mjs +49 -0
  29. package/bin/lean/ceiling.mjs +72 -0
  30. package/bin/lean/ceiling.test.mjs +54 -0
  31. package/bin/lean/ci-budget.mjs +366 -0
  32. package/bin/lean/ci-budget.test.mjs +167 -0
  33. package/bin/lean/conformance.e2e.test.mjs +7 -0
  34. package/bin/lean/conformance.mjs +77 -19
  35. package/bin/lean/conformance.test.mjs +129 -3
  36. package/bin/lean/context.mjs +35 -6
  37. package/bin/lean/context.test.mjs +27 -1
  38. package/bin/lean/depcache.mjs +25 -1
  39. package/bin/lean/depcache.test.mjs +26 -0
  40. package/bin/lean/e2e.mjs +18 -2
  41. package/bin/lean/e2e.test.mjs +26 -1
  42. package/bin/lean/effects.mjs +40 -11
  43. package/bin/lean/execution.test.mjs +24 -0
  44. package/bin/lean/facts.mjs +3 -3
  45. package/bin/lean/facts.test.mjs +5 -0
  46. package/bin/lean/fixround.mjs +14 -0
  47. package/bin/lean/fixround.test.mjs +25 -2
  48. package/bin/lean/gh-assoc.test.mjs +2 -1
  49. package/bin/lean/integration.mjs +100 -9
  50. package/bin/lean/integration.test.mjs +98 -0
  51. package/bin/lean/issuewatch-parity.mjs +64 -0
  52. package/bin/lean/issuewatch-parity.test.mjs +127 -0
  53. package/bin/lean/issuewatch-release.test.mjs +1 -1
  54. package/bin/lean/issuewatch.mjs +34 -5
  55. package/bin/lean/issuewatch.test.mjs +3 -2
  56. package/bin/lean/lean.mjs +316 -74
  57. package/bin/lean/lean.test.mjs +397 -24
  58. package/bin/lean/mechfix.mjs +124 -0
  59. package/bin/lean/mechfix.test.mjs +75 -0
  60. package/bin/lean/orchestrate.mjs +20 -2
  61. package/bin/lean/phaseledger.mjs +47 -5
  62. package/bin/lean/phaseledger.test.mjs +30 -1
  63. package/bin/lean/precheck.mjs +23 -4
  64. package/bin/lean/precheck.test.mjs +14 -1
  65. package/bin/lean/prereq.mjs +28 -0
  66. package/bin/lean/prereq.test.mjs +20 -0
  67. package/bin/lean/probe.mjs +4 -2
  68. package/bin/lean/prodparity.mjs +52 -0
  69. package/bin/lean/prodparity.test.mjs +67 -0
  70. package/bin/lean/prompts.mjs +69 -12
  71. package/bin/lean/recovery.test.mjs +1 -1
  72. package/bin/lean/release-io.test.mjs +42 -0
  73. package/bin/lean/release-postmerge.mjs +6 -0
  74. package/bin/lean/release-preflight.mjs +58 -0
  75. package/bin/lean/release-preflight.test.mjs +114 -0
  76. package/bin/lean/release-rehearsal.mjs +8 -7
  77. package/bin/lean/release-review.mjs +67 -11
  78. package/bin/lean/release-review.test.mjs +128 -1
  79. package/bin/lean/release-snapshot.mjs +188 -0
  80. package/bin/lean/release-snapshot.test.mjs +190 -0
  81. package/bin/lean/release.mjs +80 -12
  82. package/bin/lean/release.test.mjs +95 -0
  83. package/bin/lean/render.mjs +1 -1
  84. package/bin/lean/replan.mjs +184 -0
  85. package/bin/lean/replan.test.mjs +110 -0
  86. package/bin/lean/resume.mjs +9 -7
  87. package/bin/lean/resume.test.mjs +16 -0
  88. package/bin/lean/schedd.mjs +34 -1
  89. package/bin/lean/schedd.test.mjs +21 -1
  90. package/bin/lean/selfreview.mjs +94 -0
  91. package/bin/lean/selfreview.test.mjs +58 -1
  92. package/bin/lean/selftest-gate.mjs +22 -0
  93. package/bin/lean/selftest-gate.test.mjs +18 -1
  94. package/bin/lean/selftest-journey.mjs +234 -0
  95. package/bin/lean/selftest-journey.test.mjs +130 -0
  96. package/bin/lean/selftest-live.mjs +2 -1
  97. package/bin/lean/seqlease.mjs +35 -1
  98. package/bin/lean/seqlease.test.mjs +15 -0
  99. package/bin/lean/seqreserve.e2e.test.mjs +135 -0
  100. package/bin/lean/seqreserve.mjs +73 -0
  101. package/bin/lean/seqreserve.test.mjs +134 -0
  102. package/bin/lean/sequence.mjs +35 -6
  103. package/bin/lean/seqversioned.mjs +147 -0
  104. package/bin/lean/stagestamp.mjs +28 -0
  105. package/bin/lean/stagestamp.test.mjs +32 -0
  106. package/bin/lean/surfaces.mjs +75 -0
  107. package/bin/lean/surfaces.test.mjs +59 -0
  108. package/bin/lean/toolplace.mjs +28 -0
  109. package/bin/lean/toolplace.test.mjs +24 -0
  110. package/bin/lean/toolstats.mjs +3 -1
  111. package/bin/lean/toolstats.test.mjs +11 -0
  112. package/bin/lean/validatebest.mjs +28 -0
  113. package/bin/lean/validatebest.test.mjs +27 -0
  114. package/bin/pool/agent.mjs +9 -0
  115. package/bin/pool/docker.mjs +5 -0
  116. package/bin/pool/router.mjs +8 -4
  117. package/bin/prereqs.mjs +111 -0
  118. package/bin/replay-timelapse.mjs +149 -0
  119. package/bin/review-staging.mjs +100 -16
  120. package/bin/review-staging.test.mjs +18 -0
  121. package/bin/runner.mjs +43 -6
  122. package/bin/splash-install.mjs +157 -0
  123. package/bin/stats/aggregate.mjs +8 -1
  124. package/bin/stats/conformance-outcomes.mjs +100 -19
  125. package/bin/stats/conformance-outcomes.test.mjs +87 -1
  126. package/bin/stats/depth.mjs +88 -31
  127. package/bin/stats/depth.test.mjs +63 -38
  128. package/bin/stats/efficiency.mjs +26 -5
  129. package/bin/stats/efficiency.test.mjs +45 -1
  130. package/bin/stats/first-review.mjs +77 -0
  131. package/bin/stats/first-review.test.mjs +36 -0
  132. package/bin/stats/firstmerge.mjs +40 -0
  133. package/bin/stats/firstmerge.test.mjs +41 -0
  134. package/bin/stats/github-source.mjs +51 -13
  135. package/bin/stats/index.mjs +91 -15
  136. package/bin/stats/local-source.mjs +1 -0
  137. package/bin/stats/origin.mjs +80 -0
  138. package/bin/stats/origin.test.mjs +58 -0
  139. package/bin/stats/render.mjs +3 -1
  140. package/bin/stats/scoreboard.mjs +137 -0
  141. package/bin/stats/scoreboard.test.mjs +87 -0
  142. package/bin/stats/stats.test.mjs +80 -0
  143. package/bin/tui.mjs +3 -2
  144. package/commands/bootstrap.md +15 -14
  145. package/commands/deploy-pr.md +18 -3
  146. package/commands/forge-stats.md +1 -1
  147. package/commands/forgedock-ci-setup.md +28 -0
  148. package/commands/forgedock-init.md +4 -5
  149. package/commands/issue.md +2 -0
  150. package/commands/milestone.md +9 -1
  151. package/commands/replay.md +2 -0
  152. package/commands/review-pr-staging.md +4 -1
  153. package/commands/work-on/close.md +8 -0
  154. package/docs/CONFIG.md +105 -10
  155. package/docs/ISSUE-WATCH.md +23 -0
  156. package/docs/OUTCOME-CODES.md +1 -0
  157. package/docs/REPLAY.md +9 -0
  158. package/docs/SELFTEST.md +11 -0
  159. package/docs/STATS.md +19 -2
  160. package/docs/eval/README.md +6 -0
  161. package/docs/eval/adversarial-bench.md +68 -0
  162. package/docs/eval/corpus/adversarial-v1.json +285 -0
  163. package/docs/eval/feature-bench.md +42 -0
  164. package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
  165. package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
  166. package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
  167. package/docs/site/start-a-new-project.md +2 -1
  168. package/package.json +5 -2
  169. package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
  170. package/plugins/forgedock-splash/README.md +27 -0
  171. package/plugins/forgedock-splash/hooks/hooks.json +1 -0
  172. package/plugins/forgedock-splash/hooks/register.tsx +74 -0
  173. package/plugins/forgedock-splash/hooks/scene.ts +222 -0
  174. package/plugins/forgedock-splash/types/index.d.ts +10 -0
  175. package/scripts/bench-adversarial.mjs +216 -0
  176. package/scripts/bench-feature.mjs +170 -0
  177. package/scripts/bench-lightlane.mjs +2 -2
  178. package/scripts/bootstrap-create.mjs +2 -2
  179. package/scripts/bootstrap-validate.mjs +35 -2
  180. package/scripts/check-spec-size.sh +4 -3
  181. package/scripts/check-spec-size.test.sh +3 -0
  182. package/scripts/plan-validate-live.mjs +40 -6
  183. package/scripts/review-pr-staging-scope.test.sh +1 -1
  184. package/scripts/review-staging-post.sh +23 -0
  185. package/scripts/review-staging-post.test.sh +8 -0
package/bin/forgedock.mjs CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  findMarkdownFiles,
29
29
  parseInstallTier,
30
30
  writeForgeYaml,
31
- backupExisting,
31
+ backupForgeYaml,
32
32
  backfillForgeYaml,
33
33
  manualLowConfidenceKeys,
34
34
  isEphemeralCachePath,
@@ -38,6 +38,7 @@ import {
38
38
  resolveClaudeConfigDir,
39
39
  setupAfterRead,
40
40
  } from "./journey.mjs";
41
+ import { SPLASH_PLUGIN, splashState, uninstallSplash } from "./splash-install.mjs";
41
42
  import {
42
43
  deriveWorkflowLabels,
43
44
  FINDINGS_LANE_LABEL,
@@ -66,11 +67,12 @@ import {
66
67
  getInstalledCommandsDriftStatus,
67
68
  } from "./registry.mjs";
68
69
  import { renderMark, ember } from "./cinema.mjs";
70
+ import { checkPrereqs, offerInstall } from "./prereqs.mjs";
69
71
  import { guideText, guideWidth, useAnsi } from "./guide.mjs";
72
+ import { topLevelHelp, fullHelp } from "./help-text.mjs";
70
73
  import {
71
74
  renderLogo,
72
75
  getLogoTagline,
73
- box,
74
76
  table,
75
77
  input,
76
78
  confirm,
@@ -88,7 +90,10 @@ import {
88
90
  } from "./tui.mjs";
89
91
  import { buildMinimalForgeYaml } from "./init-detect.mjs";
90
92
  import { checkContext, refreshContextFlow } from "./review-context.mjs";
93
+ import { runConfigCommand } from "./config-history.mjs";
94
+ import { validateForgeYaml } from "./config-schema.mjs";
91
95
  import { botTokenStatus } from "./bot-token-status.mjs";
96
+ import { applyAuthEnv, startAuthRefresh, doctorAppAuth } from "./auth/app-token.mjs";
92
97
  import {
93
98
  parseNameStatusDiff,
94
99
  classifyCommandChanges,
@@ -250,13 +255,14 @@ function isOwnedLinkTarget(dest, src, kind, rel) {
250
255
  // --minimal is init-only. Subcommands with their own flag parsing (run,
251
256
  // run-issue, demo) receive restArgs — everything after the command token.
252
257
  const rawArgs = process.argv.slice(2);
253
- const FLAGS = new Set(["--fast", "--manual", "--verbose", "--minimal", "--extras", "--refresh-context"]);
258
+ const FLAGS = new Set(["--fast", "--manual", "--verbose", "--minimal", "--extras", "--refresh-context", "--no-splash"]);
254
259
  const flags = rawArgs.filter((a) => FLAGS.has(a));
255
260
  // --global is stripped from positionals/restArgs for backward compatibility
256
261
  // with existing invocations, but is otherwise a no-op — see the install-mode
257
262
  // path resolution block above (global is now the only install location).
258
263
  const positional = rawArgs.filter((a) => !FLAGS.has(a) && a !== "--global");
259
- const command = positional[0] || "install";
264
+ // `setup` is the plain-language name of the guided install (#5303).
265
+ const command = !positional[0] || positional[0] === "setup" ? "install" : positional[0];
260
266
  const cmdIdx = rawArgs.findIndex((a) => !FLAGS.has(a) && a !== "--global");
261
267
  const restArgs = cmdIdx === -1 ? [] : rawArgs.slice(cmdIdx + 1).filter((a) => a !== "--global");
262
268
 
@@ -1084,7 +1090,7 @@ async function initFlow(c) {
1084
1090
  return refreshContextFlow({
1085
1091
  cwd: c.cwd,
1086
1092
  out: c.stdout,
1087
- deps: { interactive: process.stdin.isTTY === true, confirm, backup: backupExisting, write: atomicWriteFile },
1093
+ deps: { interactive: process.stdin.isTTY === true, confirm, backup: (p) => backupForgeYaml(p, "refresh-context"), write: atomicWriteFile },
1088
1094
  });
1089
1095
  }
1090
1096
  const hasExisting = existsSync(outputPath);
@@ -1120,12 +1126,12 @@ async function initFlow(c) {
1120
1126
  // Hard-fail on unresolved identity placeholders when overwriting an
1121
1127
  // existing config (forge#1850 spec item 4) — never destroy a working
1122
1128
  // forge.yaml in favor of one that can't address a repo.
1123
- if (hasExisting && (draft.project.owner.value === "your-github-org" || draft.project.repo.value === "your-repo-name")) {
1129
+ if ((draft.project.owner.value === "your-github-org" || draft.project.repo.value === "your-repo-name")) {
1124
1130
  c.stdout.write("\n Could not determine the GitHub owner/repo for this project.\n");
1125
1131
  c.stdout.write(" Run this inside the target git repository, or use interactive init (npx forgedock init) to edit those fields.\n");
1126
1132
  return 1;
1127
1133
  }
1128
- const backup = backupExisting(outputPath);
1134
+ const backup = backupForgeYaml(outputPath, "init (minimal)");
1129
1135
  if (backup) c.stdout.write(` Backed up: forge.yaml → ${backup.backupName}\n`);
1130
1136
  const content = buildMinimalForgeYaml({
1131
1137
  projectName: draft.project.name.value,
@@ -1159,12 +1165,12 @@ async function initFlow(c) {
1159
1165
  };
1160
1166
  // Checked on the FINAL accepted values (post-prompt), not the draft —
1161
1167
  // the user may have typed over a placeholder default.
1162
- if (hasExisting && (v.owner === "your-github-org" || v.repo === "your-repo-name")) {
1168
+ if ((v.owner === "your-github-org" || v.repo === "your-repo-name")) {
1163
1169
  c.stdout.write("\n Could not determine the GitHub owner/repo for this project.\n");
1164
1170
  c.stdout.write(" Enter real values, or run this inside the target git repository.\n");
1165
1171
  return 1;
1166
1172
  }
1167
- const backup = backupExisting(outputPath);
1173
+ const backup = backupForgeYaml(outputPath, "init");
1168
1174
  if (backup) c.stdout.write(` Backed up: forge.yaml → ${backup.backupName}\n`);
1169
1175
  const lowKeys = manualLowConfidenceKeys(draft, description, v);
1170
1176
  const { todoCount } = writeForgeYaml(v, lowKeys, outputPath);
@@ -1176,7 +1182,7 @@ async function initFlow(c) {
1176
1182
  const { draft, description } = await setupAfterRead(c, await read(c));
1177
1183
  const reviewed = await review(c, draft, description);
1178
1184
  if (!reviewed.aborted) ensureToolStateIgnored(c);
1179
- celebrate(c, reviewed);
1185
+ if (!reviewed.aborted) celebrate(c, reviewed);
1180
1186
  if (!reviewed.aborted) await maybeOfferDemo(c);
1181
1187
  return reviewed.aborted ? 1 : 0;
1182
1188
  }
@@ -1436,6 +1442,9 @@ async function uninstall() {
1436
1442
  }
1437
1443
  console.log("");
1438
1444
 
1445
+ // Startup splash plugin + the local marketplace setup added (#5312).
1446
+ for (const line of uninstallSplash({ home: HOME }).lines) console.log(` ${GREEN}✔${RESET} ${line}`);
1447
+
1439
1448
  console.log(`${GREEN}ForgeDock uninstalled.${RESET} No residue remains from this directory.`);
1440
1449
  console.log(` Re-install at any time with: ${CYAN}npx forgedock${RESET}`);
1441
1450
  console.log("");
@@ -2366,7 +2375,13 @@ async function labelsSetup(repo, domainLabels = []) {
2366
2375
  * Returns 0 if all checks pass (warnings allowed), 1 if any hard check fails.
2367
2376
  * @param {boolean} [fix] - When true, auto-apply deterministic remediations.
2368
2377
  */
2369
- async function doctor(fix = false) {
2378
+ // Internal/legacy doctor warnings, shown only with `doctor --verbose` (#5302).
2379
+ const INTERNAL_WARNINGS = new Set([
2380
+ "FORGE_HOME env var", "Playwright MCP", "Version-gated features", "CLAUDE.md legacy block",
2381
+ "Resource hygiene", "Persisted toolset home (~/.forge)",
2382
+ ]);
2383
+
2384
+ async function doctor(fix = false, verbose = false) {
2370
2385
  console.log("");
2371
2386
  console.log(`${BOLD}ForgeDock Doctor${RESET} — Installation Health Check`);
2372
2387
  console.log("");
@@ -2412,6 +2427,7 @@ async function doctor(fix = false) {
2412
2427
  * @param {string} hint
2413
2428
  */
2414
2429
  function warn(label, hint) {
2430
+ if (!verbose && (INTERNAL_WARNINGS.has(label) || label.startsWith("Restarts:"))) return;
2415
2431
  warnings++;
2416
2432
  console.log(` ${YELLOW}⚠${RESET} ${label}`);
2417
2433
  console.log(` Note: ${hint}`);
@@ -2621,35 +2637,22 @@ async function doctor(fix = false) {
2621
2637
  }
2622
2638
  }
2623
2639
 
2624
- // ── Check 2: gh CLI installed + authenticated ──────────────────────────────
2640
+ // ── Check 2: prerequisites (Node, git, Claude Code, gh, yq) ───────────────
2641
+ // The same list setup runs (prereqs.mjs, #5302); --fix offers to install what can be installed, with consent.
2625
2642
  let ghAvailable = false;
2626
2643
  {
2627
- let ghInstalled = false;
2628
- let ghAuthed = false;
2629
- try {
2630
- execSync("gh --version", { stdio: ["ignore", "pipe", "ignore"] });
2631
- ghInstalled = true;
2632
- } catch {
2633
- // gh not installed
2644
+ const quietExec = (cmd, args) => execFileSync(cmd, args, { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 10000 }).trim();
2645
+ const probe = () => checkPrereqs({ exec: quietExec, nodeVersion: process.versions.node, claudeDir: GLOBAL_CLAUDE_DIR });
2646
+ let results = probe();
2647
+ if (fix && (await offerInstall(results.filter((r) => r.auto), { confirmFn: confirm, write: (t) => process.stdout.write(t) })).length > 0) {
2648
+ fixesApplied++;
2649
+ results = probe();
2634
2650
  }
2635
-
2636
- if (!ghInstalled) {
2637
- fail("gh CLI", "Install the GitHub CLI: https://cli.github.com/");
2638
- } else {
2639
- try {
2640
- execSync("gh auth status", { stdio: ["ignore", "pipe", "ignore"] });
2641
- ghAuthed = true;
2642
- } catch {
2643
- // Not authenticated
2644
- }
2645
-
2646
- if (ghAuthed) {
2647
- pass("gh CLI", "installed and authenticated");
2648
- ghAvailable = true;
2649
- } else {
2650
- fail("gh CLI", "Run: gh auth login");
2651
- }
2651
+ for (const r of results) {
2652
+ if (r.ok) pass(r.label, r.detail);
2653
+ else fail(r.label, `${r.detail}. ${(r.fix ?? []).join(" or ")}`.trim());
2652
2654
  }
2655
+ ghAvailable = results.find((r) => r.id === "gh")?.ok === true;
2653
2656
  }
2654
2657
 
2655
2658
  // ── Check 3: git configured ────────────────────────────────────────────────
@@ -2764,6 +2767,8 @@ async function doctor(fix = false) {
2764
2767
  }
2765
2768
  } catch { /* advisory check: never fail doctor */ }
2766
2769
 
2770
+ for (const f of validateForgeYaml(content)) (f.level === "error" ? fail : warn)(`forge.yaml ${f.code}`, f.message);
2771
+
2767
2772
  const defaultMatch = content.match(/^\s+default:\s+"([^"]*)"/m);
2768
2773
  const stagingMatch = content.match(/^\s+staging:\s+"([^"]*)"/m);
2769
2774
  if (
@@ -3129,6 +3134,9 @@ async function doctor(fix = false) {
3129
3134
  }
3130
3135
  }
3131
3136
 
3137
+ // ── Startup splash plugin (informational, #5312): never a failure ─────────
3138
+ pass("Startup splash", splashState({ home: HOME }) + ` (${SPLASH_PLUGIN}; install: npx forgedock, skip: --no-splash)`);
3139
+
3132
3140
  // ── Check 8: FORGE_HOME environment variable (informational) ──────────────
3133
3141
  // The journey-based install never exports FORGE_HOME — it isn't required
3134
3142
  // for the pipeline to run. It only affects orchestrate's legacy
@@ -3209,32 +3217,6 @@ async function doctor(fix = false) {
3209
3217
  }
3210
3218
  }
3211
3219
 
3212
- // ── Check 10: yq installed ────────────────────────────────────────────────
3213
- // yq is a hard dependency: pipeline commands (work-on, review-pr, orchestrate)
3214
- // read forge.yaml via yq. Without it, those commands fail. Fixed literal
3215
- // command — no interpolation, so no injection surface (cf. #663/#789/#807).
3216
- {
3217
- let yqVersion = "";
3218
- try {
3219
- yqVersion = execSync("yq --version", {
3220
- stdio: ["ignore", "pipe", "ignore"],
3221
- encoding: "utf-8",
3222
- timeout: 5000,
3223
- }).trim();
3224
- } catch {
3225
- // yq not installed or not on PATH
3226
- }
3227
-
3228
- if (yqVersion) {
3229
- pass("yq", yqVersion);
3230
- } else {
3231
- fail(
3232
- "yq",
3233
- "Install the YAML processor (used to read forge.yaml): https://github.com/mikefarah/yq#install",
3234
- );
3235
- }
3236
- }
3237
-
3238
3220
  // ── Check 11: Claude Code installed + version compatible ───────────────────
3239
3221
  // The compatibility floor is the @anthropic-ai/claude-code peerDependency in
3240
3222
  // package.json (read dynamically so it never drifts from the declared floor).
@@ -3318,7 +3300,11 @@ async function doctor(fix = false) {
3318
3300
  // token) — this check exists so that state is surfaced instead of silent.
3319
3301
  // See docs/CONFIG.md "GitHub App Install" and forge#1890.
3320
3302
  const botTok = botTokenStatus(); // #4662: lifetime from the refresh stamp; no stamp means no refresher is installed
3321
- if (botTok.configured) {
3303
+ const appAuth = await doctorAppAuth(); // #5301: broker/BYO App login: identity, source, rate limit
3304
+ if (appAuth.configured) {
3305
+ if (appAuth.status === "pass") pass("GitHub App / bot token", appAuth.detail);
3306
+ else warn("GitHub App / bot token", appAuth.detail);
3307
+ } else if (botTok.configured) {
3322
3308
  const min = (ms) => Math.round(ms / 60000);
3323
3309
  const detail = botTok.remainingMs != null ? `${min(botTok.remainingMs)} min left, refreshed ${min(botTok.ageMs)} min ago (${botTok.refreshedAt})` : botTok.reason;
3324
3310
  if (botTok.ok) pass("GitHub App / bot token", detail);
@@ -3385,84 +3371,11 @@ async function doctor(fix = false) {
3385
3371
  return failures > 0 ? 1 : 0;
3386
3372
  }
3387
3373
 
3388
- function help() {
3389
- // splash() already rendered the logo to stderr — the command table itself
3390
- // goes to stdout (help output is the requested artifact).
3391
- const commands = [
3392
- ["Command", "Description"],
3393
- ["npx forgedock", "Guided setup: install commands + configure repo (default)"],
3394
- ["npx forgedock guide", "How the workflow fits together: core commands, issue -> staging -> main, where a run ends, how to resume"],
3395
- ["npx forgedock install", "Install commands to ~/.claude/"],
3396
- ["npx forgedock init", "Generate forge.yaml config for your project"],
3397
- ["npx forgedock init --minimal", "Generate a minimal forge.yaml (required sections only)"],
3398
- ["npx forgedock enable [dir]", "Activate ForgeDock in a directory"],
3399
- ["npx forgedock disable [dir]", "Opt a directory out of ForgeDock"],
3400
- ["npx forgedock fix-close-reasons <owner/repo> [--milestone <m>] [--apply]", "Re-close issues that were closed not planned but carry workflow:merged or workflow:decomposed (delivered, not dropped) as completed, with a comment; dry run unless --apply; workflow:invalid issues are never touched"],
3401
- ["npx forgedock status [dir]", "Show ForgeDock state for a directory"],
3402
- ["npx forgedock run <cmd> [args]", "Run a command headlessly (local claude CLI or Anthropic API)"],
3403
- ["npx forgedock bootstrap <idea|docs> [--dry-run] [--spike <path>] | --plan <plan.json> [--dry-run]", "Headless /bootstrap: idea to orchestrate-ready backlog (--dry-run previews milestones, titles, DAG and estimated agent cost without GitHub writes); --plan validates and creates (or previews) a plan, and re-running resumes from GitHub"],
3404
- ["npx forgedock run-issue <issue> [--lane <lane>] [--lane-override] [--path core|full] [--retry] [--wait-lease]", "Run the lean core work-on on one issue (default; --path full = legacy multi-phase pipeline; the lane comes from the issue: milestone → milestone/<slug>, else staging; --lane is an assertion, never the default branch) (--retry reopens an engine-error run, or a needs-human run once the label is cleared; --wait-lease waits for a held lease; exit 75 = deferred, lease held)"],
3405
- ["npx forgedock plan validate --live [--repo owner/repo] [--json]", "Re-run the bootstrap dependency-order rules on live GitHub state: each cross-milestone Depends-on edge is ok, held or invalid (exit 1 on invalid)"],
3406
- ["npx forgedock orchestrate <issue...> [--parallel K] [--lane L]", "Run core work-on on several issues with bounded concurrency and Depends-on ordering; each issue on its own lane, cross-lane dependencies reported"],
3407
- ["npx forgedock orchestrate --resume <id> [N...] | --set-parallel <id> K | --set-max-remote <id> N | --set-placement <id> remote|hybrid|local | --add <id> N... | --requeue <id> N... [--reason \"...\"] | --cancel <id> | --hold <id> N... | --release <id> N... | --show-env <id> | --set-env <id> KEY=VAL | --unset-env <id> KEY", "Reattach to a batch hosted by the schedd daemon (a finished one replays its report, an orphaned one is resumed with live lanes re-adopted), change its concurrency live, change its max_remote or placement mode live (remote/hybrid need a batch started with a remote provider; running lanes are not stopped), add issues to a running (or held) batch under its K and DAG, requeue a terminal issue (and the dependents skipped behind it) after an operator decision (refused while it is labelled needs-human or closed; a finished batch is reopened), or stop one batch without stopping schedd (running lanes torn down with their work saved, the rest held for --resume), or hold/release single issues of a batch (a held issue is not admitted until released or named by --resume), or print (secrets redacted), set or unset a batch's pinned lane env (applies to newly launched lanes)"],
3408
- ["npx forgedock triage <issue...> [--lane L] [--dry-run]", "Already-fixed pre-filter: close issues a merged PR or green CI already resolved; print the rest"],
3409
- ["npx forgedock probe [issue...] [--dry-run]", "Run declared acceptance probes for closed issues whose fix is on the default branch; a fail reopens the issue"],
3410
- ["npx forgedock check [--base REF] [--json]", "Run the lane's frozen validate commands and change-scoped pre-PR checks locally in this worktree, as the engine will (no GitHub, no Actions)"],
3411
- ["npx forgedock milestone train <slug...> [--parallel-milestones N] | --resume <id> | --insert <id> <slug> [--before s|--after s] | --show <id>", "Unattended multi-milestone train: one durable state file (order, active set, lifecycle), typed STOP reasons, resumable; never edits forge.yaml"],
3412
- ["npx forgedock guards list [--path p] [--json] | backfill --since <date> [--dry-run]", "Fix guards: list the FORGE:GUARD records (test files + protected hunks of merged fixes) covering a path, or build them for already-merged lean lanes"],
3413
- ["npx forgedock issue-watch run [--name <w>] [--repo owner/repo] [--once] [--dry-run] | status [--name <w>]", "Named, scoped, capped watches (forge.yaml issue_watch.watches) that claim matching open issues into lanes or one long-lived orchestrate batch, or (mode: release) pool them and cut themed releases; see docs/ISSUE-WATCH.md"],
3414
- ["npx forgedock selftest [--static] | --live --repo <owner/sandbox> [--lang node|python] [--pr <N>]", "Live contract harness: drives the real gh, git and orchestrate through a disposable sandbox repo (steps create, add, body, resume, merge, remote, cleanup) plus a static check of every gh --json field list; exits non-zero naming the failed step; --pr posts the FORGE:SELFTEST result the staging->main review requires; see docs/SELFTEST.md"],
3415
- ["npx forgedock prod-watch run [--repo owner/repo] [--once] [--interval <s>] [--dry-run] | status", "Production-side watcher (forge.yaml prod_watch): read-only signal sources -> triage -> governor -> issues, kill-switch file, owner digest; see docs/PROD-WATCH.md"],
3416
- ["npx forgedock limits show | clear <id>|--all", "Show or clear per-account usage-limit holds shared by orchestrate batches"],
3417
- ["npx forgedock decisions list [--stale] [--refresh]", "List anchored decisions (FORGE:DECISION); --stale shows those with an anchor missing on the base"],
3418
- ["npx forgedock sched show | cap <N>|--clear | weight <owner/repo> <N>|--clear", "Show the host lane registry, set the host-wide lane cap shared by orchestrate batches, or set a repo's share of slots within a priority (default equal)"],
3419
- ["npx forgedock schedd [status | watchdog]", "Host scheduler daemon hosting every orchestrate batch (auto-spawned by orchestrate; run in the foreground for a systemd-user unit); status shows its pid, batches and last tick; watchdog restarts a stalled daemon"],
3420
- ["npx forgedock pool router [install] | enroll [--cpus N --mem GB] | status | upgrade [agent] | remove <agent>", "Built-in remote compute pool: run the router (foreground, or install it as a user service), print the one-time install command for a host, list agents, upgrade or remove them"],
3421
- ["npx forgedock gc [--apply] [--older-than 6h] [--docker] [--worktrees] [--branches] [--tmp] [--processes] [--sandboxes]", "Report (dry-run default) and reclaim ForgeDock-owned leftovers: stale lane ledgers, forgedock-labelled containers/volumes, lean-*/agent-* worktrees, abandoned lane branches, ~/.forge/tmp scratch, orphaned lane processes, orphaned lane sandboxes; unowned resources and unpushed work are only reported"],
3422
- ["npx forgedock resume-stalled [--dry-run]", "Fleet stall recovery — re-dispatch expired-lease issues"],
3423
- ["npx forgedock demo", "Set up a risk-free demo repo and print next steps"],
3424
- ["npx forgedock labels [setup] [--repo owner/repo] [--domain a,b,c]", "Bootstrap ForgeDock-managed labels on a GitHub repo, plus optional per-repo domain labels (idempotent)"],
3425
- ["npx forgedock config migrate [dir]", "Backfill missing optional sections into an existing forge.yaml (idempotent)"],
3426
- ["npx forgedock watch [--repo owner/repo]", "Live per-agent orchestration view (Ctrl+C to exit)"],
3427
- ["npx forgedock report [--days 30] [--md] [--json]", "30-day pipeline impact receipts for your repo"],
3428
- ["npx forgedock review-staging [<PR>] [--thorough] [--json]", "Staging->main review pre-dispatch: route marker, open-finding gate, scope, prepare, roster; writes one reviewer brief per domain"],
3429
- ["npx forgedock review-staging [<PR>] --finalize --test-gate-output <file>", "Staging->main review post-dispatch: delivery, test-gate verdict, extract/classify/file-prepare; prints the findings to file"],
3430
- ["npx forgedock review-staging [<PR>] --summary [--filed <N>]...", "Staging->main review Phase 8: verdict and summary comment with the FORGE:GATE_PASS / FORGE:GATE_FAILURE marker"],
3431
- ["npx forgedock release [--repo owner/repo] [--merge] [--watch] [--resume <id>]", "Staging->default release as one resumable job: preflight, release PR, review, fixes, promotion (stops at GATE_PASS unless --merge or release.auto_merge), post-merge"],
3432
- ["npx forgedock stats [--since <ver|date>] [--repo owner/repo] [--json] [--refresh]", "Version-over-version cost/time/flow/review/gate report from GitHub telemetry (no model)"],
3433
- ["npx forgedock stats --self-filed [--repo R] [--since D]", "Share of new issues the pipeline filed itself, by kind, against the 15% target (#5207)"],
3434
- ["npx forgedock stats --conformance-outcomes [--repo owner/repo] [--since <date>] [--window-days 7]", "Read-only: do conformance blocks predict post-merge defects (2x2 per repo and failure kind)"],
3435
- ["npx forgedock stats --depth [--since <ver|date>] [--min-n N] [--offline] [--repo owner/repo] [--json]", "Light-eligible vs ineligible lane outcomes, by reason/signal, and the #5052 light-lane promotion verdict"],
3436
- ["npx forgedock doctor", "Check installation health"],
3437
- ["npx forgedock doctor --fix", "Auto-fix deterministic issues (symlinks, hook, labels, legacy block) and reclaim ForgeDock-owned leftovers (forge.yaml hygiene TTLs)"],
3438
- ["npx forgedock doctor --lanes", "Lane preflight: pool token, pool agent version, PATH shim loops, gh --json fields; prints every check pass/fail"],
3439
- ["npx forgedock update", "Pull latest & reinstall"],
3440
- ["npx forgedock uninstall", "Remove commands"],
3441
- ["npx forgedock opencode install", "Install token-efficient native OpenCode commands"],
3442
- ["npx forgedock opencode status", "Check the OpenCode adapter"],
3443
- ["npx forgedock opencode uninstall", "Remove ForgeDock-owned OpenCode files"],
3444
- ["npx forgedock version", "Print the installed version and check for updates"],
3445
- ["npx forgedock help", "Show this help"],
3446
- ];
3447
- const flagRows = [
3448
- ["Flag", "Description"],
3449
- ["--fast", "Skip animation/motion"],
3450
- ["--manual", "Plain text prompts instead of the review screen (init)"],
3451
- ["--verbose", "Show detection sources for every field (init)"],
3452
- ["--minimal", "Generate a minimal forge.yaml with required sections only (init)"],
3453
- ["--refresh-context", "Regenerate review.context/tech_stack from manifests and show a diff for approval (init)"],
3454
- ["--version, -v", "Print the installed version and check for updates"],
3455
- ];
3456
-
3457
- // Fit the terminal (100 columns when stdout is not a TTY: CI logs, pipes); the box adds 4.
3458
- const maxWidth = guideWidth(process.stdout) - 4;
3459
- process.stdout.write("New to ForgeDock? npx forgedock guide explains the workflow in one screen.\n\n");
3460
- process.stdout.write(
3461
- box(table(commands, { header: true, maxWidth }), { title: "Usage" }) + "\n",
3462
- );
3463
- process.stdout.write(
3464
- box(table(flagRows, { header: true, maxWidth }), { title: "Flags" }) + "\n",
3465
- );
3374
+ function help(all = false) {
3375
+ // splash() already rendered the logo to stderr; the help text itself goes to stdout (it is the requested artifact).
3376
+ // Fit the terminal (100 columns when stdout is not a TTY: CI logs, pipes).
3377
+ const width = guideWidth(process.stdout);
3378
+ process.stdout.write((all ? fullHelp({ width }) : topLevelHelp({ width })) + "\n");
3466
3379
  }
3467
3380
 
3468
3381
  /**
@@ -4004,15 +3917,19 @@ async function watch() {
4004
3917
  // The journey-routed commands render their own branded marks (hero/compact);
4005
3918
  // splash() would double-brand them. Engine-surface commands, help, and
4006
3919
  // unknown-command output keep the logo.
4007
- const SPLASH_COMMANDS = new Set(["run", "bootstrap", "run-issue", "orchestrate", "triage", "probe", "gc", "resume-stalled", "demo", "doctor", "watch", "help", "--help", "-h"]);
3920
+ const SPLASH_COMMANDS = new Set(["run", "bootstrap", "run-issue", "orchestrate", "triage", "probe", "gc", "resume-stalled", "demo", "first-run", "doctor", "watch", "help", "--help", "-h"]);
4008
3921
  const KNOWN_COMMANDS = new Set([
4009
3922
  "install", "init", "enable", "disable", "status", "uninstall", "update",
4010
- "run", "bootstrap", "backend-check", "run-issue", "orchestrate", "milestone", "milestone-sync", "fix-close-reasons", "guards", "triage", "probe", "review-staging", "release", "gc", "resume-stalled", "demo", "doctor", "watch", "issue-watch", "prod-watch", "selftest", "labels", "config", "stats", "limits", "decisions", "sched", "schedd", "pool", "check", "guide", "help", "--help", "-h",
3923
+ "run", "bootstrap", "backend-check", "run-issue", "orchestrate", "milestone", "milestone-sync", "fix-close-reasons", "guards", "triage", "probe", "acceptance", "review-staging", "release", "gc", "resume-stalled", "demo", "first-run", "doctor", "auth", "watch", "issue-watch", "prod-watch", "selftest", "labels", "config", "stats", "limits", "decisions", "sched", "schedd", "pool", "check", "guide", "help", "--help", "-h",
4011
3924
  "version", "--version", "-v",
4012
3925
  ]);
4013
3926
  if (SPLASH_COMMANDS.has(command) || !KNOWN_COMMANDS.has(command)) splash(command);
4014
3927
 
4015
3928
  let exitCode = 0;
3929
+ // #5301: an App login puts a scoped installation token in this process's env (GH_TOKEN) for child gh calls; no login, no change.
3930
+ if (command !== "auth") await applyAuthEnv();
3931
+ // #5381: installation tokens live 1h; long-running commands re-resolve before expiry so later gh calls and lanes inherit a fresh one.
3932
+ if (["orchestrate", "schedd", "watch", "issue-watch", "prod-watch"].includes(command)) startAuthRefresh();
4016
3933
  switch (command) {
4017
3934
  case "install": {
4018
3935
  const c = ctx();
@@ -4419,6 +4336,39 @@ switch (command) {
4419
4336
  }
4420
4337
  break;
4421
4338
  }
4339
+ case "ci": {
4340
+ // Actions-minutes budget and CI placement policy (#5278): `forgedock ci budget`.
4341
+ const { ciFromCli } = await import("./lean/ci-budget.mjs");
4342
+ try {
4343
+ exitCode = await ciFromCli(restArgs);
4344
+ } catch (err) {
4345
+ process.stderr.write(`${RED}${err.message}${RESET}\n`);
4346
+ exitCode = 1;
4347
+ }
4348
+ break;
4349
+ }
4350
+ case "acceptance": {
4351
+ // Feature-level acceptance (#5336): `forgedock acceptance check|run|gate`.
4352
+ const { acceptanceFromCli } = await import("./lean/acceptance.mjs");
4353
+ try {
4354
+ exitCode = await acceptanceFromCli(restArgs);
4355
+ } catch (err) {
4356
+ process.stderr.write(`${RED}${err.message}${RESET}\n`);
4357
+ exitCode = 1;
4358
+ }
4359
+ break;
4360
+ }
4361
+ case "replan": {
4362
+ // Re-plan loop (#5342): `forgedock replan apply --amendment N --repo owner/repo`.
4363
+ const { replanFromCli } = await import("./lean/replan.mjs");
4364
+ try {
4365
+ exitCode = await replanFromCli(restArgs);
4366
+ } catch (err) {
4367
+ process.stderr.write(`${RED}${err.message}${RESET}\n`);
4368
+ exitCode = 1;
4369
+ }
4370
+ break;
4371
+ }
4422
4372
  case "probe": {
4423
4373
  const { probeFromCli } = await import("./engine-cli.mjs");
4424
4374
  try {
@@ -4440,9 +4390,38 @@ switch (command) {
4440
4390
  }
4441
4391
  break;
4442
4392
  }
4393
+ case "replay": {
4394
+ const { replayFromCli } = await import("./replay-timelapse.mjs");
4395
+ try {
4396
+ exitCode = await replayFromCli(restArgs);
4397
+ } catch (err) {
4398
+ process.stderr.write(`${RED}${err.message}${RESET}\n`);
4399
+ exitCode = 1;
4400
+ }
4401
+ break;
4402
+ }
4443
4403
  case "demo":
4444
4404
  await demo();
4445
4405
  break;
4406
+ case "first-run": {
4407
+ // #5290: propose/file small issues on this repo and run one to a PR
4408
+ const { runFirstRun } = await import("./first-run.mjs");
4409
+ const { execFileSync } = await import("node:child_process");
4410
+ const { confirm } = await import("./tui.mjs");
4411
+ const { runFromCli } = await import("./engine-cli.mjs");
4412
+ const r = await runFirstRun({
4413
+ exec: (cmd, args) => execFileSync(cmd, args, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"], timeout: 30000 }).trim(),
4414
+ confirmFn: confirm,
4415
+ runIssueFn: (n) => runFromCli([String(n)]),
4416
+ });
4417
+ if (r.status === "error") exitCode = 1;
4418
+ break;
4419
+ }
4420
+ case "auth": {
4421
+ const { authFromCli } = await import("./auth/app-token.mjs");
4422
+ exitCode = await authFromCli(restArgs);
4423
+ break;
4424
+ }
4446
4425
  case "doctor":
4447
4426
  if (restArgs.includes("--lanes")) {
4448
4427
  // #4866: the lane preflight on demand: every check with pass/fail; exit 1 when any fails
@@ -4453,7 +4432,7 @@ switch (command) {
4453
4432
  exitCode = checks.every((c) => c.ok) ? 0 : 1;
4454
4433
  break;
4455
4434
  }
4456
- exitCode = await doctor(restArgs.includes("--fix"));
4435
+ exitCode = await doctor(restArgs.includes("--fix"), restArgs.includes("--verbose"));
4457
4436
  break;
4458
4437
  case "report": {
4459
4438
  const { runReport } = await import("./report.mjs");
@@ -4517,11 +4496,14 @@ switch (command) {
4517
4496
  console.log(`\n Sections already present (unchanged): ${result.alreadyPresent.join(", ") || "none"}`);
4518
4497
  console.log(`\n All added sections are commented out — edit forge.yaml to enable the ones you need.`);
4519
4498
  }
4499
+ } else if (["history", "diff", "rollback", "record", "import-bak"].includes(subcommand)) {
4500
+ exitCode = runConfigCommand(subcommand, restArgs.slice(1), { cwd: process.cwd() });
4520
4501
  } else {
4521
4502
  console.log(`${RED}Unknown config subcommand: ${subcommand ?? "(none)"}${RESET}`);
4522
4503
  console.log(
4523
4504
  `Usage: ${CYAN}npx forgedock config migrate [dir]${RESET}\n` +
4524
- ` Backfills any of the 16 optional forge.yaml sections missing from an existing config (idempotent).`,
4505
+ ` Backfills any of the 16 optional forge.yaml sections missing from an existing config (idempotent).\n` +
4506
+ ` ${CYAN}npx forgedock config history | diff <n> | rollback <n> | record [reason] | import-bak [--delete]${RESET}`,
4525
4507
  );
4526
4508
  exitCode = 1;
4527
4509
  }
@@ -4589,7 +4571,7 @@ switch (command) {
4589
4571
  case "help":
4590
4572
  case "--help":
4591
4573
  case "-h":
4592
- help();
4574
+ help(positional.includes("--all") || process.argv.includes("--all"));
4593
4575
  break;
4594
4576
  case "guide":
4595
4577
  process.stdout.write(guideText({ width: guideWidth(process.stdout), ansi: useAnsi(process.stdout) }) + "\n");
@@ -0,0 +1,144 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ /**
4
+ * Help text and user-facing error wording (#5303). Pure functions so the text is unit-testable (bin/forgedock.mjs runs
5
+ * its router on import). `topLevelHelp` is what `forgedock --help` prints: at most 10 everyday commands in plain
6
+ * language, one screen. `fullHelp` is `forgedock help --all`: every command, grouped by purpose.
7
+ */
8
+ import { TAGLINE } from "./brand.mjs";
9
+ import { wrap } from "./guide.mjs";
10
+
11
+ /** The everyday commands, in plain language. Keep to 10 or fewer. */
12
+ export const EVERYDAY_COMMANDS = [
13
+ ["setup", "Guided setup: install ForgeDock and configure this repo"],
14
+ ["run-issue <issue>", "Turn one GitHub issue into a reviewed, merged pull request"],
15
+ ["orchestrate <issue...>", "Work on several issues at once, in dependency order"],
16
+ ["watch", "Live view of what each agent is doing"],
17
+ ["status", "Show ForgeDock state for this directory"],
18
+ ["release", "Promote staging to your main branch as one reviewed release"],
19
+ ["stats", "Cost, time and quality report from your GitHub history"],
20
+ ["doctor", "Check the installation and fix what it can"],
21
+ ["guide", "How the workflow fits together, in one screen"],
22
+ ["uninstall", "Remove ForgeDock commands"],
23
+ ];
24
+
25
+ /** `npx forgedock setup` is the same as bare `npx forgedock`; the router maps it (see bin/forgedock.mjs). */
26
+ export function topLevelHelp({ width = 100 } = {}) {
27
+ const pad = Math.max(...EVERYDAY_COMMANDS.map(([c]) => c.length)) + 2;
28
+ const lines = [`ForgeDock: ${TAGLINE}`, "", "Usage: npx forgedock <command>", "", "Everyday commands"];
29
+ for (const [cmd, desc] of EVERYDAY_COMMANDS) {
30
+ const wrapped = wrap(desc, Math.max(20, width - 2 - pad), " ".repeat(2 + pad));
31
+ lines.push(` ${cmd.padEnd(pad)}${wrapped.join("\n")}`);
32
+ }
33
+ lines.push("", "More:", " npx forgedock help --all every command, grouped by purpose", " npx forgedock guide how the workflow fits together");
34
+ return lines.join("\n");
35
+ }
36
+
37
+ export const FULL_COMMAND_GROUPS = [
38
+ ["Set up", [
39
+ ["npx forgedock", "Guided setup: install commands + configure repo (default)"],
40
+ ["npx forgedock guide", "How the workflow fits together: core commands, issue -> staging -> main, where a run ends, how to resume"],
41
+ ["npx forgedock install", "Install commands to ~/.claude/"],
42
+ ["npx forgedock init", "Generate forge.yaml config for your project"],
43
+ ["npx forgedock init --minimal", "Generate a minimal forge.yaml (required sections only)"],
44
+ ["npx forgedock enable [dir]", "Activate ForgeDock in a directory"],
45
+ ["npx forgedock disable [dir]", "Opt a directory out of ForgeDock"],
46
+ ["npx forgedock demo", "Set up a risk-free demo repo and print next steps"],
47
+ ["npx forgedock first-run", "On this repo: propose 3 small issues, file them on approval, run one to a PR (stats --first-merge reports time to first merged PR)"],
48
+ ["npx forgedock labels [setup] [--repo owner/repo] [--domain a,b,c]", "Bootstrap ForgeDock-managed labels on a GitHub repo, plus optional per-repo domain labels (idempotent)"],
49
+ ["npx forgedock config migrate [dir]", "Backfill missing optional sections into an existing forge.yaml (idempotent)"],
50
+ ["npx forgedock config history | diff <n> | rollback <n> | record [reason] | import-bak [--delete]", "Versioned forge.yaml: list its saved versions, diff or roll back to one, record the current one, import old .bak files"],
51
+ ["npx forgedock auth login [--byo] [--broker-url URL] [--client-id ID] [--installation N] [--org ORG] | status | logout", "Sign in as a GitHub App so pipeline calls use a short-lived installation token instead of your own gh auth (the broker URL must be https)"],
52
+ ["npx forgedock doctor", "Check installation health"],
53
+ ["npx forgedock doctor --fix", "Auto-fix deterministic issues (symlinks, hook, labels, legacy block) and reclaim ForgeDock-owned leftovers (forge.yaml hygiene TTLs)"],
54
+ ["npx forgedock doctor --verbose", "Also show internal and legacy checks (FORGE_HOME, Playwright MCP, version-gated features, resource hygiene)"],
55
+ ["npx forgedock doctor --lanes", "Lane preflight: pool token, pool agent version, PATH shim loops, gh --json fields; prints every check pass/fail"],
56
+ ["npx forgedock update", "Pull latest & reinstall"],
57
+ ["npx forgedock uninstall", "Remove commands"],
58
+ ["npx forgedock opencode install", "Install token-efficient native OpenCode commands"],
59
+ ["npx forgedock opencode status", "Check the OpenCode adapter"],
60
+ ["npx forgedock opencode uninstall", "Remove ForgeDock-owned OpenCode files"],
61
+ ["npx forgedock version", "Print the installed version and check for updates"],
62
+ ["npx forgedock help", "Show this help"],
63
+ ]],
64
+ ["Run work", [
65
+ ["npx forgedock run <cmd> [args]", "Run a command headlessly (local claude CLI or Anthropic API)"],
66
+ ["npx forgedock bootstrap <idea|docs> [--dry-run] [--spike <path>] | --plan <plan.json> [--dry-run]", "Headless /bootstrap: idea to orchestrate-ready backlog (--dry-run previews milestones, titles, DAG and estimated agent cost without GitHub writes); --plan validates and creates (or previews) a plan, and re-running resumes from GitHub"],
67
+ ["npx forgedock run-issue <issue> [--lane <lane>] [--lane-override] [--path core|full] [--retry] [--wait-lease]", "Work one issue from claim to merge (the lane comes from the issue: its milestone, else staging; --lane only asserts it). --retry reopens a failed run, or one needing a human once the label is cleared; --wait-lease waits for another holder of the issue; exit status 75 means deferred, nothing was lost"],
68
+ ["npx forgedock plan validate --live [--repo owner/repo] [--json]", "Re-run the bootstrap dependency-order rules on live GitHub state: each cross-milestone Depends-on edge is ok, held or invalid (fails on invalid)"],
69
+ ["npx forgedock orchestrate <issue...> [--parallel K] [--lane L]", "Work on several issues with bounded concurrency and Depends-on ordering; each issue on its own lane, cross-lane dependencies reported"],
70
+ ["npx forgedock orchestrate --resume <id> [N...] | --set-parallel <id> K | --set-max-remote <id> N | --set-placement <id> remote|hybrid|local | --add <id> N... | --requeue <id> N... [--reason \"...\"] | --cancel <id> | --hold <id> N... | --release <id> N... | --show-env <id> | --set-env <id> KEY=VAL | --unset-env <id> KEY", "Reattach to a running or finished batch (a finished one replays its report, an interrupted one resumes), change its concurrency or placement live, add, requeue, hold or release single issues, stop one batch without stopping the background scheduler, or print, set or unset the batch environment (secrets redacted; applies to newly started lanes)"],
71
+ ["npx forgedock triage <issue...> [--lane L] [--dry-run]", "Already-fixed pre-filter: close issues a merged PR or green CI already resolved; print the rest"],
72
+ ["npx forgedock probe [issue...] [--dry-run]", "Run declared acceptance probes for closed issues whose fix is on the default branch; a fail reopens the issue"],
73
+ ["npx forgedock acceptance check|run|gate", "Feature-level acceptance: validate an epic's journeys, run them on the milestone branch, gate ship/close on a green run"],
74
+ ["npx forgedock check [--base REF] [--json]", "Run the lane's frozen validate commands and change-scoped pre-PR checks locally in this worktree, as the engine will (no GitHub, no Actions)"],
75
+ ["npx forgedock milestone train <slug...> [--parallel-milestones N] | --resume <id> | --insert <id> <slug> [--before s|--after s] | --show <id>", "Unattended multi-milestone train: one durable state file (order, active set, lifecycle), typed STOP reasons, resumable; never edits forge.yaml"],
76
+ ["npx forgedock issue-watch run [--name <w>] [--repo owner/repo] [--once] [--dry-run] | status [--name <w>]", "Named, scoped, capped watches (forge.yaml issue_watch.watches) that claim matching open issues into lanes or one long-lived orchestrate batch, or (mode: release) pool them and cut themed releases; see docs/ISSUE-WATCH.md"],
77
+ ["npx forgedock prod-watch run [--repo owner/repo] [--once] [--interval <s>] [--dry-run] | status", "Production-side watcher (forge.yaml prod_watch): read-only signal sources -> triage -> governor -> issues, kill-switch file, owner digest; see docs/PROD-WATCH.md"],
78
+ ["npx forgedock ci budget [--repo owner/repo] [--json] [--digest] [--propose [--base REF]] [--set-mode MODE] [--budget MINUTES] [--reserve PCT] [--plan PLAN]", "Actions-minutes budget: month-to-date usage, projection and where CI runs (remote or local-first); sets the mode and budget"],
79
+ ["npx forgedock replan apply --amendment N --repo owner/repo", "After an amendment merged, re-evaluate the open sibling issues held behind it"],
80
+ ["npx forgedock resume-stalled [--dry-run]", "Fleet stall recovery: re-dispatch issues whose run stopped holding its claim"],
81
+ ]],
82
+ ["Watch and report", [
83
+ ["npx forgedock status [dir]", "Show ForgeDock state for a directory"],
84
+ ["npx forgedock guards list [--path p] [--json] | backfill --since <date> [--dry-run]", "Fix guards: list the records (test files + protected hunks of merged fixes) covering a path, or build them for already-merged runs"],
85
+ ["npx forgedock limits show | clear <id>|--all", "Show or clear per-account usage-limit holds shared by orchestrate batches"],
86
+ ["npx forgedock decisions list [--stale] [--refresh]", "List anchored decisions (FORGE:DECISION); --stale shows those with an anchor missing on the base"],
87
+ ["npx forgedock watch [--repo owner/repo]", "Live per-agent orchestration view (Ctrl+C to exit)"],
88
+ ["npx forgedock report [--days 30] [--md] [--json]", "30-day pipeline impact receipts for your repo"],
89
+ ["npx forgedock stats [--since <ver|date>] [--repo owner/repo] [--json] [--refresh]", "Version-over-version cost/time/flow/review/gate report from GitHub telemetry (no model)"],
90
+ ["npx forgedock stats --self-filed [--repo R] [--since D]", "Share of new issues the pipeline filed itself, by kind, against the 15% target (#5207)"],
91
+ ["npx forgedock stats --conformance-outcomes [--repo owner/repo] [--since <date>] [--window-days 7] [--replay <pr,...> --enforce-domains <list>]", "Read-only: do conformance blocks predict post-merge defects (2x2 per repo, failure kind and risk surface; --replay a PR list against an enforce config)"],
92
+ ["npx forgedock stats --depth [--since <ver|date>] [--min-n N] [--offline] [--repo owner/repo] [--json]", "Light-eligible vs ineligible lane outcomes, by reason/signal, and the #5052 light-lane promotion verdict"],
93
+ ["npx forgedock stats --first-merge [--repo owner/repo]", "Setup start to first merged PR for a first-run repo, against the 15 min target (#5290)"],
94
+ ["npx forgedock replay --timelapse <batch|epic> [--repo owner/repo] [--out dir] [--format gif|mp4] [--duration 30-90]", "Read-only 30-90 s time-lapse (frames, vhs tape, GIF/MP4 when vhs is installed) of a recorded batch or epic from the lifecycle event log"],
95
+ ["npx forgedock stats --origin [--repo R] [--since D] [--json]", "Requested vs pipeline-generated issues by origin, how pipeline-found ones closed, and their cost share (#5294)"],
96
+ ]],
97
+ ["Release", [
98
+ ["npx forgedock selftest [--static] | --live --repo <owner/sandbox> [--lang node|python] [--pr <N>] | --journey [--repo <owner/sandbox>] [--pr <N>] [--update-snapshots]", "Live contract harness: drives the real gh, git and orchestrate through a disposable sandbox repo (steps create, add, body, resume, merge, remote, cleanup) plus a static check of every gh --json field list; exits non-zero naming the failed step; --pr posts the FORGE:SELFTEST result the staging->main review requires; --journey runs the packed CLI as a new user (clean environment, then a sandbox repo to a merged PR) and posts FORGE:JOURNEY; see docs/SELFTEST.md"],
99
+ ["npx forgedock review-staging [<PR>] [--thorough] [--json]", "Staging->main review pre-dispatch: route marker, open-finding gate, scope, prepare, roster; writes one reviewer brief per domain"],
100
+ ["npx forgedock review-staging [<PR>] --finalize --test-gate-output <file>", "Staging->main review post-dispatch: delivery, test-gate verdict, extract/classify/file-prepare; prints the findings to file"],
101
+ ["npx forgedock review-staging [<PR>] --summary [--filed <N>]...", "Staging->main review Phase 8: verdict and summary comment with the FORGE:GATE_PASS / FORGE:GATE_FAILURE marker"],
102
+ ["npx forgedock release [--repo owner/repo] [--merge] [--watch] [--resume <id>] | release verify <sha> [--repo owner/repo]", "Staging->default release as one resumable job: preflight, release PR, review, fixes, promotion (stops at GATE_PASS unless --merge or release.auto_merge), post-merge; release.mode: snapshot cuts release/<id> from staging (lanes keep merging, fixes are cherry-picked, FORGE:RELEASE records them); verify checks a release head against that record"],
103
+ ]],
104
+ ["Maintenance and hosting", [
105
+ ["npx forgedock fix-close-reasons <owner/repo> [--milestone <m>] [--apply]", "Re-close issues that were closed not planned but carry workflow:merged or workflow:decomposed (delivered, not dropped) as completed, with a comment; dry run unless --apply; workflow:invalid issues are never touched"],
106
+ ["npx forgedock sched show | cap <N>|--clear | weight <owner/repo> <N>|--clear", "Show the host lane registry, set the host-wide lane cap shared by orchestrate batches, or set a repo's share of slots within a priority (default equal)"],
107
+ ["npx forgedock schedd [status | watchdog]", "Host scheduler daemon hosting every orchestrate batch (auto-spawned by orchestrate; run in the foreground for a systemd-user unit); status shows its pid, batches and last tick; watchdog restarts a stalled daemon"],
108
+ ["npx forgedock pool router [install] | enroll [--cpus N --mem GB] | status | upgrade [agent] | remove <agent>", "Built-in remote compute pool: run the router (foreground, or install it as a user service), print the one-time install command for a host, list agents, upgrade or remove them"],
109
+ ["npx forgedock gc [--apply] [--older-than 6h] [--docker] [--worktrees] [--branches] [--tmp] [--processes] [--sandboxes]", "Report (dry-run default) and reclaim ForgeDock-owned leftovers: stale run ledgers, labelled containers/volumes, agent worktrees, abandoned branches, scratch files, orphaned processes and sandboxes; unowned resources and unpushed work are only reported"],
110
+ ]],
111
+ ];
112
+
113
+ export const FLAG_ROWS = [
114
+ ["--fast", "Skip animation/motion"],
115
+ ["--manual", "Plain text prompts instead of the review screen (init)"],
116
+ ["--verbose", "Show detection sources for every field (init)"],
117
+ ["--minimal", "Generate a minimal forge.yaml with required sections only (init)"],
118
+ ["--refresh-context", "Regenerate review.context/tech_stack from manifests and show a diff for approval (init)"],
119
+ ["--no-splash", "Skip installing the startup splash plugin during setup (or set FORGEDOCK_NO_SPLASH=1)"],
120
+ ["--version, -v", "Print the installed version and check for updates"],
121
+ ];
122
+
123
+ /** Every command, grouped by purpose (`forgedock help --all`). */
124
+ export function fullHelp({ width = 100 } = {}) {
125
+ const lines = [`ForgeDock: ${TAGLINE}`, "", "Usage: npx forgedock <command> (npx forgedock help for the everyday commands)"];
126
+ for (const [name, rows] of FULL_COMMAND_GROUPS) {
127
+ lines.push("", name);
128
+ for (const [cmd, desc] of rows) {
129
+ lines.push(` ${cmd}`, ...wrap(desc, width - 6, " ").map((l, i) => (i === 0 ? " " + l : l)));
130
+ }
131
+ }
132
+ lines.push("", "Flags");
133
+ for (const [flag, desc] of FLAG_ROWS) lines.push(` ${flag.padEnd(20)}${desc}`);
134
+ return lines.join("\n");
135
+ }
136
+
137
+ /** User-facing run-issue errors: what happened, why, and the one command that fixes it. No engine terms. */
138
+ export const USER_ERRORS = {
139
+ noRepoOrchestrate: "Can't tell which GitHub repository this is, because this directory has no GitHub remote. Run it inside a clone of the repository, or add --repo owner/name.",
140
+ recoverUnsupported: "--recover only works with the default pipeline. Drop --recover, or drop --path full.",
141
+ noRepo: "Can't tell which GitHub repository this is, because this directory has no GitHub remote. Run it inside a clone of the repository, or add --repo owner/name.",
142
+ retryUnsupported: "That option only works with the legacy pipeline. A normal rerun already resumes from the open pull request or pushed branch, so drop the option, or add --path full to use it.",
143
+ laneRequired: "--lane is required with --path full, so a run never targets production by accident. Add --lane staging (or --lane milestone/<slug>).",
144
+ };