architecture-harness 0.25.0 → 0.26.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 (244) hide show
  1. package/package.json +3 -22
  2. package/src/cli/ask.mjs +42 -0
  3. package/src/cli/ask.test.mjs +40 -0
  4. package/src/cli/branch-sync.mjs +126 -0
  5. package/src/cli/branch-sync.test.mjs +428 -0
  6. package/src/cli/budget-guard.mjs +74 -5
  7. package/src/cli/budget-guard.test.mjs +185 -2
  8. package/src/cli/budget-report.mjs +85 -0
  9. package/src/cli/budget-report.test.mjs +173 -0
  10. package/src/cli/budget.mjs +8 -5
  11. package/src/cli/check-commands.mjs +123 -11
  12. package/src/cli/check-commands.test.mjs +360 -6
  13. package/src/cli/check-feature-switches.test.mjs +110 -0
  14. package/src/cli/check-full.test.mjs +152 -0
  15. package/src/cli/check-verdict.mjs +46 -0
  16. package/src/cli/check-verdict.test.mjs +32 -0
  17. package/src/cli/check.mjs +137 -4
  18. package/src/cli/check.test.mjs +45 -0
  19. package/src/cli/checkpoint.mjs +143 -0
  20. package/src/cli/checkpoint.test.mjs +146 -0
  21. package/src/cli/child-run.mjs +7 -2
  22. package/src/cli/child-run.test.mjs +17 -2
  23. package/src/cli/ci-failures.mjs +304 -0
  24. package/src/cli/ci-failures.test.mjs +615 -0
  25. package/src/cli/ci-preview.mjs +62 -0
  26. package/src/cli/ci-preview.test.mjs +85 -0
  27. package/src/cli/ci-state.mjs +25 -29
  28. package/src/cli/ci-state.test.mjs +174 -2
  29. package/src/cli/ci-template.test.mjs +86 -0
  30. package/src/cli/claude-core.test.mjs +37 -0
  31. package/src/cli/codex-implement.mjs +580 -47
  32. package/src/cli/codex-implement.test.mjs +1946 -29
  33. package/src/cli/codex-limit.mjs +85 -0
  34. package/src/cli/codex-limit.test.mjs +179 -0
  35. package/src/cli/codex-reset.mjs +78 -0
  36. package/src/cli/codex-reset.test.mjs +192 -0
  37. package/src/cli/codex-verify.mjs +230 -0
  38. package/src/cli/codex-verify.test.mjs +402 -0
  39. package/src/cli/comment-watch.mjs +391 -0
  40. package/src/cli/comment-watch.test.mjs +392 -0
  41. package/src/cli/commit-guard.mjs +219 -0
  42. package/src/cli/commit-guard.test.mjs +809 -0
  43. package/src/cli/context-budgets.mjs +47 -0
  44. package/src/cli/context-budgets.test.mjs +96 -0
  45. package/src/cli/context-watch.mjs +116 -0
  46. package/src/cli/context-watch.test.mjs +395 -0
  47. package/src/cli/contract-history.mjs +1 -1
  48. package/src/cli/controller-guard.mjs +38 -0
  49. package/src/cli/controller-guard.test.mjs +66 -2
  50. package/src/cli/cost-stop.mjs +5 -1
  51. package/src/cli/cost-stop.test.mjs +26 -0
  52. package/src/cli/diff-shape.mjs +162 -0
  53. package/src/cli/diff-shape.test.mjs +200 -0
  54. package/src/cli/direct-lane.mjs +32 -19
  55. package/src/cli/direct-lane.test.mjs +21 -3
  56. package/src/cli/dispatch-guard.mjs +11 -0
  57. package/src/cli/dispatch-guard.test.mjs +145 -10
  58. package/src/cli/dispatch-reminder.mjs +23 -10
  59. package/src/cli/dispatch-reminder.test.mjs +63 -11
  60. package/src/cli/dispatch-route.mjs +54 -0
  61. package/src/cli/dispatch-route.test.mjs +101 -0
  62. package/src/cli/dispatch-slot.mjs +2 -2
  63. package/src/cli/dispatch-slot.test.mjs +18 -19
  64. package/src/cli/dispatch.test.mjs +3 -3
  65. package/src/cli/e2e-affected.mjs +15 -0
  66. package/src/cli/e2e-affected.test.mjs +73 -0
  67. package/src/cli/fleet.mjs +180 -0
  68. package/src/cli/fleet.test.mjs +213 -0
  69. package/src/cli/gate-slot.mjs +2 -1
  70. package/src/cli/gh-merge-command.mjs +96 -31
  71. package/src/cli/gh-merge-command.test.mjs +74 -0
  72. package/src/cli/gh-run.mjs +64 -3
  73. package/src/cli/gh-run.test.mjs +66 -1
  74. package/src/cli/git-hooks.test.mjs +25 -3
  75. package/src/cli/git-read.mjs +2 -1
  76. package/src/cli/integrate-tree.mjs +47 -0
  77. package/src/cli/integrate.mjs +143 -40
  78. package/src/cli/integrate.test.mjs +347 -1
  79. package/src/cli/integration-lane.mjs +62 -0
  80. package/src/cli/integration-lane.test.mjs +213 -0
  81. package/src/cli/ledger.mjs +4 -2
  82. package/src/cli/ledger.test.mjs +12 -3
  83. package/src/cli/legs.mjs +53 -0
  84. package/src/cli/legs.test.mjs +70 -0
  85. package/src/cli/lint-changed.mjs +59 -10
  86. package/src/cli/lint-changed.test.mjs +112 -1
  87. package/src/cli/locked-tests.mjs +134 -0
  88. package/src/cli/locked-tests.test.mjs +188 -0
  89. package/src/cli/merge-guard.mjs +234 -62
  90. package/src/cli/merge-guard.test.mjs +768 -39
  91. package/src/cli/metrics.mjs +53 -0
  92. package/src/cli/metrics.test.mjs +73 -0
  93. package/src/cli/milestone.mjs +297 -0
  94. package/src/cli/milestone.test.mjs +294 -0
  95. package/src/cli/mutate.mjs +203 -0
  96. package/src/cli/mutate.test.mjs +134 -0
  97. package/src/cli/output-redaction.mjs +26 -0
  98. package/src/cli/output-redaction.test.mjs +117 -0
  99. package/src/cli/overview.mjs +131 -0
  100. package/src/cli/overview.test.mjs +137 -0
  101. package/src/cli/pause.mjs +93 -0
  102. package/src/cli/pause.test.mjs +109 -0
  103. package/src/cli/plan-check.mjs +84 -12
  104. package/src/cli/plan-check.test.mjs +152 -2
  105. package/src/cli/plan-stop.mjs +7 -4
  106. package/src/cli/plan-stop.test.mjs +87 -0
  107. package/src/cli/platform-risk.mjs +46 -0
  108. package/src/cli/platform-risk.test.mjs +38 -0
  109. package/src/cli/plugin-skills.test.mjs +25 -0
  110. package/src/cli/pr-guard.mjs +128 -0
  111. package/src/cli/pr-guard.test.mjs +154 -0
  112. package/src/cli/promotion-branch.mjs +2 -0
  113. package/src/cli/qc.mjs +160 -27
  114. package/src/cli/qc.test.mjs +93 -0
  115. package/src/cli/report-stop.mjs +5 -0
  116. package/src/cli/report-stop.test.mjs +23 -1
  117. package/src/cli/retry-failed.mjs +3 -1
  118. package/src/cli/review-gate.mjs +24 -6
  119. package/src/cli/review-gate.test.mjs +116 -0
  120. package/src/cli/review-promotion.mjs +107 -0
  121. package/src/cli/review-promotion.test.mjs +251 -0
  122. package/src/cli/role-budget.mjs +50 -0
  123. package/src/cli/role-budget.test.mjs +91 -0
  124. package/src/cli/run-log.mjs +73 -0
  125. package/src/cli/run-log.test.mjs +121 -0
  126. package/src/cli/secret-patterns.mjs +16 -0
  127. package/src/cli/secret-patterns.test.mjs +73 -0
  128. package/src/cli/setup-block.mjs +24 -0
  129. package/src/cli/setup-block.test.mjs +96 -0
  130. package/src/cli/setup-checks.mjs +65 -0
  131. package/src/cli/setup-checks.test.mjs +158 -0
  132. package/src/cli/setup-compaction.mjs +55 -0
  133. package/src/cli/setup-compaction.test.mjs +115 -0
  134. package/src/cli/setup-skills.mjs +65 -0
  135. package/src/cli/setup-skills.test.mjs +171 -0
  136. package/src/cli/setup.mjs +107 -0
  137. package/src/cli/setup.test.mjs +275 -0
  138. package/src/cli/skill-length.test.mjs +8 -0
  139. package/src/cli/spawn-command.mjs +47 -0
  140. package/src/cli/spawn-command.test.mjs +64 -0
  141. package/src/cli/task-gate-review.test.mjs +21 -2
  142. package/src/cli/task-gate.mjs +25 -12
  143. package/src/cli/task-gate.test.mjs +43 -5
  144. package/src/cli/tokens.mjs +46 -3
  145. package/src/cli/tokens.test.mjs +103 -3
  146. package/src/cli/tools.mjs +49 -0
  147. package/src/cli/tools.test.mjs +89 -0
  148. package/src/cli/transcript-usage.mjs +27 -0
  149. package/src/cli/transcript-usage.test.mjs +34 -0
  150. package/src/cli/user-config-package.mjs +1 -1
  151. package/src/cli/user-config-toml.mjs +63 -7
  152. package/src/cli/user-config.mjs +39 -7
  153. package/src/cli/user-config.test.mjs +238 -5
  154. package/src/cli/watch-arm.mjs +39 -0
  155. package/src/cli/watch-arm.test.mjs +87 -0
  156. package/src/cli/watch.mjs +80 -35
  157. package/src/cli/watch.test.mjs +233 -27
  158. package/src/cli/work-order-guard.mjs +2 -1
  159. package/src/cli/workflow-hooks.test.mjs +18 -4
  160. package/src/cli/workflow-settings.mjs +44 -8
  161. package/src/cli/workflow-settings.test.mjs +124 -1
  162. package/src/cli/worktree.mjs +14 -1
  163. package/src/cli/worktree.test.mjs +20 -1
  164. package/src/config.mjs +174 -7
  165. package/src/config.test.mjs +327 -5
  166. package/src/consumer-package.mjs +31 -0
  167. package/src/consumer-package.test.mjs +54 -0
  168. package/src/descriptions.mjs +2 -0
  169. package/src/eslint/index.mjs +12 -0
  170. package/src/eslint/jsx.mjs +20 -0
  171. package/src/eslint/preset.mjs +26 -2
  172. package/src/eslint/preset.test.mjs +104 -2
  173. package/src/eslint/rules/no-arbitrary-class-value.mjs +32 -0
  174. package/src/eslint/rules/no-literal-color.mjs +94 -0
  175. package/src/eslint/rules/no-static-inline-style.mjs +41 -0
  176. package/src/eslint/rules/one-component-per-file.mjs +70 -0
  177. package/src/eslint/rules/raw-element-in-primitive.mjs +31 -0
  178. package/src/eslint/rules/timeless-comment.mjs +92 -0
  179. package/src/eslint/rules.test.mjs +189 -0
  180. package/src/eslint/ui-regressions.test.mjs +39 -0
  181. package/src/gates/contract-operations.mjs +3 -3
  182. package/src/gates/contract-operations.test.mjs +28 -0
  183. package/src/gates/feature-switches.mjs +19 -0
  184. package/src/gates/feature-switches.test.mjs +55 -0
  185. package/src/gates/plain-language.mjs +396 -0
  186. package/src/gates/plain-language.test.mjs +210 -0
  187. package/src/gates/runtime-imports.test.mjs +114 -0
  188. package/src/gates/saga-key.test.mjs +1 -1
  189. package/src/global-skills.mjs +9 -0
  190. package/src/global-skills.test.mjs +53 -0
  191. package/src/plugin.test.mjs +3 -2
  192. package/src/ui/class-sites.mjs +38 -6
  193. package/src/ui/codemod.mjs +4 -1
  194. package/src/ui/codemod.test.mjs +52 -0
  195. package/src/ui/components.mjs +5 -3
  196. package/src/ui/components.test.mjs +8 -0
  197. package/src/ui/dupes.test.mjs +18 -0
  198. package/templates/docs/enforcement.md +12 -2
  199. package/templates/docs/ui.md +33 -0
  200. package/templates/githooks/pre-commit +1 -0
  201. package/templates/githooks/pre-push +11 -2
  202. package/templates/github/workflows/ci.yml +57 -3
  203. package/user-config/claude/CLAUDE.core.md +28 -0
  204. package/user-config/claude/settings.shared.json +41 -1
  205. package/src/cli/screens-discovery.mjs +0 -60
  206. package/src/cli/screens.mjs +0 -84
  207. package/src/cli/stack.mjs +0 -14
  208. package/src/cli/throwaway-db.mjs +0 -127
  209. package/src/cli/throwaway-db.test.mjs +0 -83
  210. package/src/screens/auth-context.test.mjs +0 -41
  211. package/src/screens/auth-run.test.mjs +0 -147
  212. package/src/screens/auth.mjs +0 -223
  213. package/src/screens/auth.test.mjs +0 -76
  214. package/src/screens/capture-idle.test.mjs +0 -27
  215. package/src/screens/capture.browser-test.mjs +0 -73
  216. package/src/screens/capture.mjs +0 -175
  217. package/src/screens/capture.test.mjs +0 -28
  218. package/src/screens/catalog.browser-test.mjs +0 -32
  219. package/src/screens/catalog.mjs +0 -72
  220. package/src/screens/catalog.test.mjs +0 -36
  221. package/src/screens/chrome.mjs +0 -21
  222. package/src/screens/compare.mjs +0 -40
  223. package/src/screens/compare.test.mjs +0 -30
  224. package/src/screens/discovery.browser-test.mjs +0 -29
  225. package/src/screens/discovery.mjs +0 -158
  226. package/src/screens/discovery.test.mjs +0 -27
  227. package/src/screens/inventory.mjs +0 -69
  228. package/src/screens/inventory.test.mjs +0 -10
  229. package/src/screens/map.mjs +0 -63
  230. package/src/screens/map.test.mjs +0 -35
  231. package/src/screens/open.browser-test.mjs +0 -50
  232. package/src/screens/regions.mjs +0 -137
  233. package/src/screens/regions.test.mjs +0 -38
  234. package/src/screens/session-files.mjs +0 -39
  235. package/src/screens/session-files.test.mjs +0 -39
  236. package/src/screens/setup.browser-test.mjs +0 -49
  237. package/src/screens/setup.mjs +0 -78
  238. package/src/screens/stack-auth.browser-test.mjs +0 -30
  239. package/src/screens/stack-auth.mjs +0 -106
  240. package/src/screens/stack-auth.test.mjs +0 -65
  241. package/src/screens/write-guard.mjs +0 -26
  242. package/src/stack/stack.mjs +0 -131
  243. package/src/stack/stack.test.mjs +0 -40
  244. package/src/stack/supervisor.mjs +0 -30
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env node
2
+ // The PreToolUse trigger that keeps each issue in one draft PR and checks its platform legs before readiness.
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { nestedCommand, programName } from "./bash-command-guard.mjs";
7
+ import { checkoutRootOf } from "./checkout-root.mjs";
8
+ import { branchAt, originOf, repoOfSpelling } from "./git-read.mjs";
9
+ import { runGh } from "./gh-run.mjs";
10
+ import { readyProblems } from "./legs.mjs";
11
+ import { cdTarget, commandEnv, commandWords, segmentsOf } from "./shell-command.mjs";
12
+
13
+ const deny = (reason) => ({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: reason } });
14
+ const settings = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => ["GH_REPO", "GH_HOST", "GH_CONFIG_DIR"].includes(name)));
15
+ const line = (value) => String(value).replace(/[\r\n]+/g, " ");
16
+
17
+ function optionsOf(words) {
18
+ const options = { positional: [] };
19
+ const names = { "-R": "repo", "--repo": "repo", "-b": "body", "--body": "body", "-F": "bodyFile", "--body-file": "bodyFile", "-H": "head", "--head": "head" };
20
+ const values = new Set(["--title", "-t", "--base", "-B", "--assignee", "-a", "--label", "-l", "--reviewer", "-r", "--project", "-p", "--milestone", "-m", "--template", "-T", "--recover"]);
21
+ for (let i = 0; i < words.length; i++) {
22
+ const word = words[i];
23
+ const at = word.startsWith("--") ? word.indexOf("=") : -1;
24
+ const flag = at < 0 ? word : word.slice(0, at);
25
+ if (names[flag] || values.has(flag)) {
26
+ const value = at < 0 ? words[++i] : word.slice(at + 1);
27
+ if (names[flag]) options[names[flag]] = value;
28
+ } else if (/^-[RbFH].+/.test(word)) options[names[word.slice(0, 2)]] = word.slice(2).replace(/^=/, "");
29
+ else if (word === "--draft" || word === "-d" || word === "--draft=true") options.draft = true;
30
+ else if (word === "--undo" || word === "--undo=true") options.undo = true;
31
+ else if (!word.startsWith("-")) options.positional.push(word);
32
+ }
33
+ return options;
34
+ }
35
+
36
+ function issuesOf(branch, body) {
37
+ const issues = new Set();
38
+ const branchIssue = /^[^/]+\/([1-9]\d*)-/.exec(branch ?? "")?.[1];
39
+ if (branchIssue) issues.add(branchIssue);
40
+ for (const match of String(body ?? "").matchAll(/\b(?:Refs|Fixes)\s+#([1-9]\d*)\b/gi)) issues.add(match[1]);
41
+ return issues;
42
+ }
43
+
44
+ function refusal(call, options, root, cwd, repo, env, gh, problems) {
45
+ const args = ["-R", repo];
46
+ if (options.verb === "create") {
47
+ if (call.agent_id != null) return "PR guard: push the sub-branch and let the controller run `qc integrate`.";
48
+ if (!options.draft) return "PR guard: create the pull request with `--draft`.";
49
+ let prs;
50
+ try {
51
+ prs = JSON.parse(gh(["pr", "list", "--state", "open", ...args, "--limit", "1000", "--json", "number,headRefName,body"], { cwd, env, timeoutMs: 5000 }));
52
+ if (!Array.isArray(prs) || prs.length >= 1000 || prs.some((pr) => !Number.isInteger(pr?.number) || typeof pr.body !== "string" || typeof pr.headRefName !== "string")) throw new Error("unreadable list");
53
+ } catch { return "PR guard: cannot list the open pull requests; retry when gh can read them."; }
54
+ let body = options.body ?? "";
55
+ if (options.bodyFile) {
56
+ try { body = readFileSync(path.resolve(cwd, options.bodyFile), "utf8"); }
57
+ catch { return "PR guard: cannot read the pull request body file."; }
58
+ }
59
+ const issues = issuesOf(options.head ?? branchAt(root), body);
60
+ for (const pr of prs) {
61
+ const duplicate = [...issuesOf(pr.headRefName, pr.body)].find((issue) => issues.has(issue));
62
+ if (duplicate) return `PR guard: issue #${duplicate} already has open pull request #${pr.number}; update that pull request.`;
63
+ }
64
+ return null;
65
+ }
66
+ if (options.undo) return null;
67
+ try {
68
+ const selector = options.positional[0];
69
+ const pr = JSON.parse(gh(["pr", "view", ...(selector ? [selector] : []), ...args, "--json", "headRefOid"], { cwd, env, timeoutMs: 5000 }));
70
+ if (!/^[0-9a-f]{40,64}$/i.test(pr?.headRefOid ?? "")) throw new Error("missing head");
71
+ const { missing, hits } = problems(root, pr.headRefOid);
72
+ if (!missing.length) return null;
73
+ const commands = missing.map((os) => `qc ci-preview --os ${os}`).join("; ");
74
+ const evidence = hits.slice(0, 3).map((hit) => line(`${hit.file}:${hit.line}: ${hit.reason}`)).join("; ");
75
+ return `PR guard: missing platform legs: ${missing.join(", ")}. Run ${commands}; then qc ready-check.` + (evidence ? `\n${evidence}` : "");
76
+ } catch { return "PR guard: cannot check the pull request head or its platform legs; run qc ready-check after gh can read the head."; }
77
+ }
78
+
79
+ export function decidePr(call, { gh = runGh, problems = readyProblems } = {}) {
80
+ if (call?.tool_name !== "Bash" || call.hook_event_name !== "PreToolUse") return null;
81
+ const command = call.tool_input?.command;
82
+ if (typeof command !== "string" || !/\bgh(?:\.exe)?\b/i.test(command)) return null;
83
+ function visit(text, cwd, inherited = {}, parse = segmentsOf) {
84
+ let env = { ...inherited };
85
+ for (const segment of parse(text)) {
86
+ const moved = cdTarget(segment);
87
+ if (moved) cwd = path.resolve(cwd, moved);
88
+ if (segment.words[0] === "export") {
89
+ for (const word of segment.words.slice(1)) {
90
+ const match = /^(GH_REPO|GH_HOST|GH_CONFIG_DIR)=(.*)$/s.exec(word);
91
+ if (match) env[match[1]] = match[2];
92
+ }
93
+ }
94
+ const nested = nestedCommand(segment);
95
+ if (nested) {
96
+ const answer = visit(nested.command, cwd, { ...env, ...settings(commandEnv(segment)) }, nested.parse);
97
+ if (answer) return answer;
98
+ }
99
+ const [program, ...words] = commandWords(segment);
100
+ if (programName(program) !== "gh") continue;
101
+ const group = words.indexOf("pr");
102
+ if (group < 0) continue;
103
+ let verbAt = group + 1;
104
+ while (/^(?:-R|--repo(?:=|$))/.test(words[verbAt] ?? "")) verbAt += ["-R", "--repo"].includes(words[verbAt]) ? 2 : 1;
105
+ if (!["create", "ready"].includes(words[verbAt])) continue;
106
+ const options = { ...optionsOf(words.filter((_, i) => i !== group && i !== verbAt)), verb: words[verbAt] };
107
+ const root = checkoutRootOf(cwd);
108
+ if (!root || !existsSync(path.join(root, "qc.config.json"))) continue;
109
+ const origin = originOf(root);
110
+ if (!origin) continue;
111
+ const ghEnv = { ...settings(process.env), ...env, ...settings(commandEnv(segment)) };
112
+ const urlRepo = /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/pull\/\d+/.exec(options.positional[0] ?? "")?.[1];
113
+ const target = urlRepo ?? options.repo ?? ghEnv.GH_REPO;
114
+ if (target && repoOfSpelling(target) !== origin) continue;
115
+ const message = refusal(call, options, root, cwd, origin, ghEnv, gh, problems);
116
+ if (message) return deny(message);
117
+ }
118
+ return null;
119
+ }
120
+ return visit(command, call.cwd ?? process.cwd());
121
+ }
122
+
123
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
124
+ let input = "";
125
+ for await (const chunk of process.stdin) input += chunk;
126
+ const output = decidePr(JSON.parse(input));
127
+ if (output) console.log(JSON.stringify(output));
128
+ }
@@ -0,0 +1,154 @@
1
+ import assert from "node:assert/strict";
2
+ import { execFileSync, spawnSync } from "node:child_process";
3
+ import { mkdtempSync, readFileSync, writeFileSync, rmSync } from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import test from "node:test";
8
+ import { decidePr } from "./pr-guard.mjs";
9
+ import { appendLeg } from "./legs.mjs";
10
+
11
+ function workspace(t) {
12
+ const cwd = mkdtempSync(path.join(os.tmpdir(), "qc-pr-guard-"));
13
+ t.after(() => rmSync(cwd, { recursive: true, force: true }));
14
+ const git = (...args) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: "pipe" }).trim();
15
+ git("init", "-q");
16
+ git("checkout", "-qb", "feat/206-pr-guard");
17
+ git("remote", "add", "origin", "https://github.com/o/r.git");
18
+ writeFileSync(path.join(cwd, "qc.config.json"), "{}");
19
+ return cwd;
20
+ }
21
+ const call = (cwd, command, extra = {}) => ({ cwd, tool_name: "Bash", hook_event_name: "PreToolUse", tool_input: { command }, ...extra });
22
+ const reason = (out) => out?.hookSpecificOutput?.permissionDecisionReason;
23
+ const emptyGh = () => "[]";
24
+
25
+ test("create requires the controller and a draft", (t) => {
26
+ const cwd = workspace(t);
27
+ assert.match(reason(decidePr(call(cwd, "gh pr create --draft", { agent_id: "a" }), { gh: emptyGh })), /sub-branch.*qc integrate/);
28
+ assert.match(reason(decidePr(call(cwd, "gh pr create"), { gh: emptyGh })), /--draft/);
29
+ assert.equal(decidePr(call(cwd, "gh pr create --draft"), { gh: emptyGh }), null);
30
+ });
31
+
32
+ test("only Bash PreToolUse in a configured origin checkout is guarded", (t) => {
33
+ const cwd = workspace(t);
34
+ for (const command of ["echo 'gh pr create'", "gh pr view", "gh pr create -R other/repo", "GH_REPO=other/repo gh pr create"]) {
35
+ assert.equal(decidePr(call(cwd, command), { gh: () => assert.fail("foreign call") }), null);
36
+ }
37
+ for (const extra of [{ tool_name: "Read" }, { hook_event_name: "PostToolUse" }]) assert.equal(decidePr(call(cwd, "gh pr create", extra)), null);
38
+ rmSync(path.join(cwd, "qc.config.json"));
39
+ assert.equal(decidePr(call(cwd, "gh pr create")), null);
40
+ });
41
+
42
+ test("open PR references match whole issue numbers from the branch or body", (t) => {
43
+ const cwd = workspace(t);
44
+ const gh = (args) => {
45
+ assert.deepEqual(args.slice(0, 3), ["pr", "list", "--state"]);
46
+ assert.ok(args.includes("o/r"));
47
+ return JSON.stringify([{ number: 9, headRefName: "feat/206-existing", body: "" }]);
48
+ };
49
+ assert.match(reason(decidePr(call(cwd, "gh pr create --draft"), { gh })), /#206.*#9/);
50
+ for (const body of ["Refs #207", "Fixes #207"]) {
51
+ assert.match(reason(decidePr(call(cwd, `gh pr create --draft --body '${body}'`), { gh: () => JSON.stringify([{ number: 8, body: "Refs #207", headRefName: "other" }]) })), /#207.*#8/);
52
+ }
53
+ assert.equal(decidePr(call(cwd, "gh pr create --draft"), { gh: () => JSON.stringify([{ number: 8, body: "Refs #2060", headRefName: "other" }]) }), null);
54
+ });
55
+
56
+ test("body files, explicit heads, and repository flags preserve issue checks", (t) => {
57
+ const cwd = workspace(t);
58
+ writeFileSync(path.join(cwd, "body.md"), "Fixes #207");
59
+ const gh = () => JSON.stringify([{ number: 8, body: "Refs #207", headRefName: "other" }]);
60
+ for (const command of ["gh pr create -d -F body.md", "gh -R o/r pr create --draft --head feat/207-new", "gh pr create --draft --body='Refs #207'", "gh pr --repo=o/r create -d -Fbody.md", "gh pr -Ro/r create -d -F body.md"]) {
61
+ assert.match(reason(decidePr(call(cwd, command), { gh })), /#207/);
62
+ }
63
+ });
64
+
65
+ test("failed or malformed open PR reads refuse in one line", (t) => {
66
+ const cwd = workspace(t);
67
+ for (const gh of [() => { throw new Error("offline\nsecret"); }, () => "{}", () => "bad"]) {
68
+ const message = reason(decidePr(call(cwd, "gh pr create --draft"), { gh }));
69
+ assert.match(message, /cannot list/i);
70
+ assert.equal(message.split("\n").length, 1);
71
+ }
72
+ });
73
+
74
+ test("ready checks the PR head and reports missing legs, three hits, and commands", (t) => {
75
+ const cwd = workspace(t);
76
+ const gh = (args) => {
77
+ assert.deepEqual(args, ["pr", "view", "12", "-R", "o/r", "--json", "headRefOid"]);
78
+ return JSON.stringify({ headRefOid: "a".repeat(40) });
79
+ };
80
+ const problems = (root, head) => {
81
+ assert.equal(root, cwd);
82
+ assert.equal(head, "a".repeat(40));
83
+ return { missing: ["linux", "windows"], hits: [1, 2, 3, 4].map((n) => ({ file: `f${n}`, line: n, reason: "risk" })) };
84
+ };
85
+ const message = reason(decidePr(call(cwd, "gh pr ready 12"), { gh, problems }));
86
+ assert.match(message, /linux.*windows/);
87
+ assert.match(message, /f1:1.*f2:2.*f3:3/);
88
+ assert.doesNotMatch(message, /f4/);
89
+ assert.match(message, /qc ci-preview --os linux/);
90
+ assert.match(message, /qc ci-preview --os windows/);
91
+ assert.ok(message.split("\n").length <= 2);
92
+ assert.equal(decidePr(call(cwd, "gh pr ready 12"), { gh, problems: () => ({ missing: [], hits: [] }) }), null);
93
+ assert.equal(decidePr(call(cwd, "gh pr ready 12 --undo"), { gh: () => assert.fail("undo") }), null);
94
+ });
95
+
96
+ test("ready uses the ledger for the PR head even when the checkout head differs", (t) => {
97
+ const cwd = workspace(t);
98
+ const git = (...args) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: "pipe" }).trim();
99
+ git("config", "user.name", "qc");
100
+ git("config", "user.email", "qc@example.com");
101
+ git("config", "commit.gpgsign", "false");
102
+ git("add", ".");
103
+ git("commit", "-qm", "base");
104
+ git("branch", "base");
105
+ writeFileSync(path.join(cwd, "qc.config.json"), JSON.stringify({ check: { base: "base" }, ready: { platforms: ["linux", "windows"] } }));
106
+ writeFileSync(path.join(cwd, "risk.mjs"), "process.platform;\n");
107
+ git("add", ".");
108
+ git("commit", "-qm", "risk");
109
+ const head = git("rev-parse", "HEAD");
110
+ git("checkout", "-q", "base");
111
+ writeFileSync(path.join(cwd, "qc.config.json"), JSON.stringify({ check: { base: "base" }, ready: { platforms: ["linux", "windows"] } }));
112
+ const gh = () => JSON.stringify({ headRefOid: head });
113
+ assert.match(reason(decidePr(call(cwd, "gh pr ready 12"), { gh })), /linux, windows/);
114
+ appendLeg(cwd, { head, os: "linux", source: "local" });
115
+ assert.match(reason(decidePr(call(cwd, "gh pr ready 12"), { gh })), /missing platform legs: windows/);
116
+ appendLeg(cwd, { head, os: "windows", source: "preview" });
117
+ assert.equal(decidePr(call(cwd, "gh pr ready 12"), { gh }), null);
118
+ });
119
+
120
+ test("wrappers, nested shells, changed directories, and multiple calls keep the guard", (t) => {
121
+ const cwd = workspace(t);
122
+ for (const command of ["env GH_REPO=o/r command gh pr create", "bash -lc 'gh pr create'", "gh pr view; gh pr create", "export GH_REPO=o/r; gh pr create", "gh pr create --title '--draft'", "gh pr create --draft=false"]) {
123
+ assert.match(reason(decidePr(call(cwd, command), { gh: emptyGh })), /--draft/);
124
+ }
125
+ const parent = path.dirname(cwd).replaceAll("\\", "/");
126
+ assert.match(reason(decidePr(call(parent, `cd '${cwd.replaceAll("\\", "/")}'; gh pr create`), { gh: emptyGh })), /--draft/);
127
+ assert.equal(decidePr(call(cwd, "gh pr ready https://github.com/foreign/repo/pull/1"), { gh: () => assert.fail("foreign PR") }), null);
128
+ assert.equal(decidePr(call(cwd, "gh pr ready https://github.com/foreign/repo/pull/1 -R o/r"), { gh: () => assert.fail("foreign URL takes precedence") }), null);
129
+ assert.match(reason(decidePr(call(cwd, "gh pr ready https://github.com/o/r/pull/1 -R foreign/repo"), {
130
+ gh: () => JSON.stringify({ headRefOid: "a".repeat(40) }),
131
+ problems: () => ({ missing: ["linux"], hits: [] }),
132
+ })), /missing platform legs: linux/);
133
+ });
134
+
135
+ test("the Bash PreToolUse hook runs the PR guard", () => {
136
+ const hooks = JSON.parse(readFileSync(new URL("../../../../hooks/hooks.json", import.meta.url), "utf8"));
137
+ const entry = hooks.hooks.PreToolUse.find((entry) => entry.hooks.some((hook) => hook.command.includes("/pr-guard.mjs")));
138
+ assert.equal(entry.matcher, "Bash");
139
+ assert.ok(entry.hooks.find((hook) => hook.command.includes("/pr-guard.mjs")).timeout >= 10);
140
+ });
141
+
142
+ test("ready fails closed when the head or legs cannot be read", (t) => {
143
+ const cwd = workspace(t);
144
+ for (const gh of [() => { throw new Error("offline"); }, () => "{}", () => '{"headRefOid":"bad"}']) {
145
+ assert.match(reason(decidePr(call(cwd, "gh pr ready"), { gh })), /cannot check/i);
146
+ }
147
+ });
148
+
149
+ test("the trigger reads stdin and emits a hook denial", (t) => {
150
+ const cwd = workspace(t);
151
+ const result = spawnSync(process.execPath, [fileURLToPath(new URL("./pr-guard.mjs", import.meta.url))], { input: JSON.stringify(call(cwd, "gh pr create")), encoding: "utf8" });
152
+ assert.equal(result.status, 0);
153
+ assert.match(reason(JSON.parse(result.stdout)), /--draft/);
154
+ });
@@ -0,0 +1,2 @@
1
+ /** The fragment that normalizes a promotion branch from the config or PR metadata. */
2
+ export const promotionBranchName = (branch) => branch?.replace(/^origin\//, "");
package/src/cli/qc.mjs CHANGED
@@ -10,18 +10,28 @@ import { checkFiles } from "./check-input.mjs";
10
10
 
11
11
  const USAGE = `qc — architecture gates
12
12
 
13
- qc check [file...] [--files-from <path|->]
13
+ qc check [file...] [--files-from <path|->] [--since-push]
14
14
  every structural gate; files given, or listed NUL-separated in a file or on stdin, take the fast path
15
+ qc check --affected [--base <ref>] gates and affected tests; records a clean host leg
16
+ qc check --full [--os <linux|windows>]
17
+ the gates and whole test suite; a clean pass records a platform leg
18
+ qc ci-preview [--os <linux|windows|both>]
19
+ dispatch CI for this head and record passing platform legs
20
+ qc ready-check print missing platform legs and up to three risk hits; silent on a pass
21
+ qc e2e the repository's e2e command with the changed files
15
22
  qc lint [--staged] [--base <ref>] [file...]
16
23
  ESLint on the changed lines only: a problem on an untouched line never fails
17
24
  qc typecheck the typecheck script, else tsc; writes no build output
18
25
  qc init [--full] scaffold the config, hooks and workflow; --full adds the reference architecture
19
26
  qc user-config apply|check|capture [--dry-run]
20
27
  synchronize the shared Claude and Codex user settings
28
+ qc setup [--dry-run] [--config <file>] [--model <id>]...
29
+ set up user compaction, the Claude core rules, and personal skills
21
30
  qc feature <name> scaffold a feature of the reference architecture; needs qc init --full
22
31
  qc run [name] drive one feature command headless; no name lists them
23
32
  qc install-hooks point git at the kit's pre-commit hook
24
33
  qc work-order-check refuse to commit on the wrong branch, per .claude/work-order.local.json
34
+ qc commit-guard refuse staged protected paths, secrets, and conflict markers
25
35
  qc lease status [path] who holds this worktree's lease, since when, and when it lapses
26
36
  qc lease release [path] remove it: --session <id> for your own, --force for another's
27
37
  qc pr-check in CI: the pull request names an issue that exists and predates it
@@ -30,18 +40,35 @@ const USAGE = `qc — architecture gates
30
40
  qc commit-msg <file> conventional (commitlint), English, and the trailer when attribution is on
31
41
  qc decisions [id] where decisions are cited; --squash closes the gaps
32
42
  qc ledger [--cost] [branch] the workflow ledger: dispatches, stops, verdicts, merges, issue updates; --cost totals tokens and tool calls
33
- qc codex-implement --brief <file> --worktree <path> --progress <file> [--log <file>] [--max-runs <n>]
43
+ qc metrics [--since <YYYY-MM-DD>] local Codex and CI run totals for the last seven days
44
+ qc overview modules, largest files, churn, CI failures, and debt; at most 60 lines
45
+ qc debt file <report> file unseen debt items as issues and reset the review watermark
46
+ qc debt due name the module due after 10 milestone merges; exit 1 when not due, 3 on error
47
+ qc ci-failures --run <id> | --rerun [--branch <branch>]
48
+ record a failed run, or rerun the open test files before a push
49
+ qc ask --issue <n> "<question>" label the issue needs-user and post the question
50
+ qc budget report each role's end context, peaks at handoffAt, and advice on its limit
51
+ qc codex-implement --brief <file> --worktree <path> --progress <file> [--log <file>] [--max-runs <n>] [--role <scout|tests|implement|review>] [--review] [--report <file>] [--resume <id>] [--effort <low|medium|high>] [--wait-reset] [--max-hours <n>] [--poll-minutes <n>]
34
52
  run a brief through codex exec as an implementer; done means the last non-empty progress line equals ALL TASKS DONE after trimming whitespace
35
53
  the runner supplies the marker; write it as the last line, alone, only when the exit criteria hold; never quote it elsewhere or wait for it; exit 2 on a Codex limit
54
+ --effort overrides the Codex config for every run; omitting it keeps the config value; exit 5 when paused
55
+ --wait-reset polls every 30 minutes without a model, then resumes the same brief; --poll-minutes sets the interval; --max-hours defaults to 6
56
+ qc codex-wait-reset --since <iso> [--max-hours <n>] [--poll-minutes <n>]
57
+ wait for a later Codex reset without a model; exit 0 on a reset, 1 at the bound; default 6 hours and 30 minutes between polls
58
+ qc codex status print whether Codex is free or limited, with the expiry time and its source
36
59
  qc gate-slot [--slots <n>] -- <command...>
37
60
  run a heavy local command in one of the machine's gate slots; --status lists them
38
- qc watch [--pr <n>]... [--codex <wrapper.log>]... [--run <workflow>@<branch>]... [--max <minutes>] [--repo <owner/name>] [--interval <seconds>]
39
- block until the first event among the items, print one EVENT line; exit 0 done, 4 bound (default 55 minutes), 5 failed, 6 queued past 15 minutes
61
+ qc fleet init --self <id> --nodes <id:weight:size,...> [--force]
62
+ qc fleet next [--repo <o/r>] [--all]
63
+ qc fleet status [--repo <o/r>]
64
+ qc watch [--pr <n>]... [--codex <wrapper.log>]... [--run <workflow>@<branch>[@<sha>]]... [--max <minutes>] [--repo <owner/name>] [--interval <seconds>]
65
+ block until the first event among the items, print one EVENT line; exit 0 done, 1 bad input, 4 bound (default 55 minutes), 5 failed, 6 queued past 15 minutes
40
66
  qc screens --map <json> --targets <left,right> --out <dir> [--only <names>] [--changed <target>]
41
67
  capture authenticated screen pairs, compare pixels, and write a static gallery
42
68
  qc stack up|down|status [names...] [--timeout <milliseconds>]
43
69
  run repository plugins from ~/.qc/stacks.json
44
70
  qc plan-check <plan.md> each task names files, a test step and a commit step, within the tool-call budget
71
+ qc review promotion <pr> write the scoped promotion brief for the configured integration and release branches
45
72
  qc tokens [--session <id>] [--project <dir>] [--claude-dir <dir>] [--json]
46
73
  one session's tokens and cache hit rate per agent type, from its transcripts
47
74
  qc throwaway-db [--port <n>|auto] -- <command...>
@@ -56,35 +83,64 @@ const USAGE = `qc — architecture gates
56
83
  refuse a dirty tree; delete it, then its branch once merged, pushed, or a merged PR head
57
84
  qc migrations renumber --onto <ref> [--branch <ref>]
58
85
  move this branch's migrations after the last one of <ref>, and rewrite references
86
+ qc branch sync <worktree> [--base <ref>] [--no-push]
87
+ merge the base, renumber migrations, regenerate, and push through a machine gate slot
88
+ qc milestone [--dry-run] [--drop <branch>] publish approved branches in one ready pull request
59
89
  qc integrate --issue <n> [--type <t>] [--slug <s>] [--from <ref>] <branch>...
60
90
  one <t>/<n>-<s> branch for a batch: merge, renumber, regenerate; stop on a conflict
61
91
  qc enforcement-map refresh the generated rule/gate table in docs/enforcement.md
92
+ qc pause [--reason <text>] | qc pause --status
93
+ pause branch changes and merges across all worktrees, or print the pause state
94
+ qc resume [--branch <branch>] clear the operator pause, or release one branch's CI hold
62
95
  qc doctor the hooks and the lockfile must run the same harness
63
96
  qc config print the resolved configuration
64
97
 
98
+ qc stack, qc screens and qc throwaway-db run from pinned GitHub commits on first use.
65
99
  Every gate reads qc.config.json. A key it does not set keeps the reference default.`;
66
100
 
67
101
  async function main() {
68
102
  const [command, ...rest] = process.argv.slice(2);
103
+ if (command === "overview" || command === "debt") {
104
+ const valid = command === "overview" ? rest.length === 0 :
105
+ (rest[0] === "file" && rest.length === 2) || (rest[0] === "due" && rest.length === 1);
106
+ if (!valid) { console.error("usage: qc overview | qc debt file <report> | qc debt due"); process.exitCode = 1; return; }
107
+ const { buildOverview, fileDebt, debtDue } = await import("./overview.mjs");
108
+ try {
109
+ if (command === "overview") process.stdout.write(await buildOverview(process.cwd()));
110
+ else if (rest[0] === "file") await fileDebt(process.cwd(), rest[1]);
111
+ else process.exitCode = await debtDue(process.cwd());
112
+ } catch (error) {
113
+ console.error(`qc ${command}: ${String(error.message).replace(/\s+/g, " ")}`);
114
+ process.exitCode = 3;
115
+ }
116
+ return;
117
+ }
69
118
  if (command === "user-config") {
70
119
  const { runUserConfig } = await import("./user-config.mjs");
71
120
  process.exit(await runUserConfig(rest));
72
121
  }
73
- if (command === "stack") {
74
- const { runStack } = await import("./stack.mjs");
75
- process.exit(await runStack(rest));
122
+ if (command === "setup") {
123
+ const { runSetup } = await import("./setup.mjs");
124
+ process.exit(await runSetup(rest));
76
125
  }
77
- if (command === "screens") {
78
- // The screen packages are optional peers: only this command needs them, so a repository installs them for it.
79
- try {
80
- const { runScreens } = await import("./screens.mjs");
81
- process.exit(await runScreens(rest));
82
- } catch (error) {
83
- const missing = /Cannot find package '(playwright|pixelmatch|pngjs)'/.exec(error?.message ?? "");
84
- if (error?.code !== "ERR_MODULE_NOT_FOUND" || !missing) throw error;
85
- console.error(`qc screens needs the ${missing[1]} package. Install the screen packages: pnpm add -D playwright pixelmatch pngjs`);
86
- process.exit(2);
87
- }
126
+ if (["stack", "screens", "throwaway-db"].includes(command)) {
127
+ const { runTool } = await import("./tools.mjs");
128
+ process.exit(await runTool(command, rest));
129
+ }
130
+ if (command === "pause" || command === "resume") {
131
+ const { runPause, runResume } = await import("./pause.mjs");
132
+ process.exitCode = (command === "pause" ? runPause : runResume)(process.cwd(), rest);
133
+ return;
134
+ }
135
+ if (command === "ask") {
136
+ const { runAsk } = await import("./ask.mjs");
137
+ process.exitCode = runAsk(rest);
138
+ return;
139
+ }
140
+ if (command === "ci-failures") {
141
+ const { runCiFailures } = await import("./ci-failures.mjs");
142
+ process.exitCode = runCiFailures(process.cwd(), rest);
143
+ return;
88
144
  }
89
145
  // A broken qc.config.json must not keep a lease in place, so the lease runs before the load.
90
146
  if (command === "lease") {
@@ -94,23 +150,84 @@ async function main() {
94
150
  // The runner reads no configuration, so it runs from any folder.
95
151
  if (command === "codex-implement") {
96
152
  const { runCodexImplement } = await import("./codex-implement.mjs");
97
- process.exit(await runCodexImplement(rest));
153
+ process.exitCode = await runCodexImplement(rest);
154
+ return;
155
+ }
156
+ if (command === "codex-wait-reset") {
157
+ const { runCodexWaitReset } = await import("./codex-reset.mjs");
158
+ process.exitCode = await runCodexWaitReset(rest);
159
+ return;
160
+ }
161
+ if (command === "codex") {
162
+ if (rest[0] === "status") {
163
+ const { runCodexStatus } = await import("./codex-limit.mjs");
164
+ process.exitCode = runCodexStatus(rest.slice(1));
165
+ return;
166
+ }
167
+ console.log(USAGE);
168
+ process.exit(1);
98
169
  }
99
170
  // The slots are machine-wide, so the runner reads no configuration.
100
171
  if (command === "gate-slot") {
101
172
  const { runGateSlot } = await import("./gate-slot.mjs");
102
173
  process.exit(await runGateSlot(rest));
103
174
  }
104
- // The watcher reads no configuration either.
175
+ if (command === "fleet") {
176
+ const { runFleet } = await import("./fleet.mjs");
177
+ process.exit(await runFleet(rest));
178
+ }
179
+ if (command === "metrics") {
180
+ const { runMetrics } = await import("./metrics.mjs");
181
+ process.exit(runMetrics(rest));
182
+ }
183
+ // The watcher handles unreadable configuration so the wait can continue.
105
184
  if (command === "watch") {
106
185
  const { runWatch } = await import("./watch.mjs");
107
186
  process.exit(await runWatch(rest));
108
187
  }
109
- const config = load(process.cwd());
188
+ let config;
189
+ try {
190
+ config = load(process.cwd());
191
+ } catch (error) {
192
+ if (!(error instanceof TypeError)) throw error;
193
+ console.error(`qc: invalid qc.config.json: ${error.message}`);
194
+ process.exitCode = 1;
195
+ return;
196
+ }
110
197
 
111
198
  switch (command) {
199
+ case "ci-preview": {
200
+ const { runCiPreview } = await import("./ci-preview.mjs");
201
+ process.exitCode = await runCiPreview(config.root, rest);
202
+ return;
203
+ }
204
+ case "ready-check": {
205
+ const { runReadyCheck } = await import("./legs.mjs");
206
+ process.exitCode = runReadyCheck(config.root);
207
+ return;
208
+ }
209
+ case "e2e": {
210
+ const { runE2e } = await import("./e2e-affected.mjs");
211
+ process.exitCode = await runE2e(config);
212
+ return;
213
+ }
112
214
  case "check": {
113
- const { files, listed } = await checkFiles(rest);
215
+ if (rest.includes("--affected") || rest.includes("--base")) {
216
+ const args = rest.filter((arg) => arg !== "--affected");
217
+ if (rest.filter((arg) => arg === "--affected").length !== 1 || !(args.length === 0 || (args.length === 2 && args[0] === "--base" && args[1] && !args[1].startsWith("-")))) {
218
+ console.error("qc check: --affected accepts only --base <ref>"); process.exitCode = 1; return;
219
+ }
220
+ const { runAffectedCheck } = await import("./check.mjs");
221
+ process.exitCode = await runAffectedCheck(config, { base: args[1] ?? config.check.base }, { write: console.error });
222
+ return;
223
+ }
224
+ if (rest.includes("--full")) {
225
+ const { runFullCheck } = await import("./check.mjs");
226
+ process.exitCode = await runFullCheck(config, rest.filter((arg) => arg !== "--full"));
227
+ return;
228
+ }
229
+ const sincePush = rest.includes("--since-push");
230
+ const { files, listed } = await checkFiles(rest.filter((arg) => arg !== "--since-push"));
114
231
  // An empty list means nothing staged to check, not the full check.
115
232
  const { problems, lines } = listed && files.length === 0
116
233
  ? { problems: [], lines: [] }
@@ -125,7 +242,7 @@ async function main() {
125
242
  }
126
243
  for (const line of lines) console.log(line);
127
244
  const { runCheckCommands } = await import("./check-commands.mjs");
128
- process.exitCode = await runCheckCommands(config);
245
+ process.exitCode = await runCheckCommands(config, { sincePush });
129
246
  return;
130
247
  }
131
248
  case "lint": {
@@ -159,6 +276,10 @@ async function main() {
159
276
  const { runWorkOrderCheck } = await import("./work-order-guard.mjs");
160
277
  process.exit(await runWorkOrderCheck(config.root));
161
278
  }
279
+ case "commit-guard": {
280
+ const { runCommitGuard } = await import("./commit-guard.mjs");
281
+ process.exit(runCommitGuard(config));
282
+ }
162
283
  case "pr-check": {
163
284
  const { runPrCheck } = await import("./pr-check.mjs");
164
285
  process.exit(await runPrCheck());
@@ -175,18 +296,22 @@ async function main() {
175
296
  const { runLedger } = await import("./ledger.mjs");
176
297
  process.exit(runLedger(config, rest));
177
298
  }
299
+ case "budget": {
300
+ const { runBudget } = await import("./budget-report.mjs");
301
+ process.exit(runBudget(config, rest));
302
+ }
178
303
  case "plan-check": {
179
304
  const { runPlanCheck } = await import("./plan-check.mjs");
180
305
  process.exit(runPlanCheck(config, rest));
181
306
  }
307
+ case "review": {
308
+ const { runReview } = await import("./review-promotion.mjs");
309
+ process.exit(runReview(config, rest));
310
+ }
182
311
  case "tokens": {
183
312
  const { runTokens } = await import("./tokens.mjs");
184
313
  process.exit(runTokens(config, rest));
185
314
  }
186
- case "throwaway-db": {
187
- const { runThrowawayDb } = await import("./throwaway-db.mjs");
188
- process.exit(await runThrowawayDb(config, rest));
189
- }
190
315
  case "retry-failed": {
191
316
  const { runRetryFailed } = await import("./retry-failed.mjs");
192
317
  process.exit(await runRetryFailed(rest));
@@ -204,6 +329,14 @@ async function main() {
204
329
  const { runMigrations } = await import("./migrations.mjs");
205
330
  process.exit(runMigrations(config, rest));
206
331
  }
332
+ case "branch": {
333
+ const { runBranch } = await import("./branch-sync.mjs");
334
+ process.exit(await runBranch(config, rest));
335
+ }
336
+ case "milestone": {
337
+ const { runMilestone } = await import("./milestone.mjs");
338
+ process.exit(await runMilestone(config, rest));
339
+ }
207
340
  case "integrate": {
208
341
  const { runIntegrate } = await import("./integrate.mjs");
209
342
  process.exit(await runIntegrate(config, rest));