@event4u/agent-config 14.20.0 → 14.22.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 (242) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/CHANGELOG.md +441 -0
  5. package/CREDITS.md +37 -0
  6. package/README.md +1 -1
  7. package/agents/templates/.ai-council.yml.example +10 -0
  8. package/dist/agent-src/commands/analyze/inbox.md +381 -6
  9. package/dist/agent-src/commands/analyze/{reference-repo.md → repo.md} +251 -34
  10. package/dist/agent-src/commands/analyze/roadmap-repos.md +129 -0
  11. package/dist/agent-src/commands/analyze.md +12 -7
  12. package/dist/agent-src/commands/feature/plan.md +55 -16
  13. package/dist/agent-src/commands/feature/refactor.md +8 -3
  14. package/dist/agent-src/commands/humanize.md +48 -4
  15. package/dist/agent-src/contexts/communication/rules-auto/token-efficiency-mechanics.md +69 -0
  16. package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +5 -5
  17. package/dist/agent-src/contexts/execution/contract-decision-sheet.md +22 -1
  18. package/dist/agent-src/contexts/execution/host-capability-manifest.md +4 -1
  19. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +35 -2
  20. package/dist/agent-src/contexts/execution/terminal-states.md +4 -1
  21. package/dist/agent-src/rules/evaluator-independence.md +4 -4
  22. package/dist/agent-src/rules/external-code-graph-interop.md +19 -14
  23. package/dist/agent-src/rules/external-reference-deep-dive.md +2 -2
  24. package/dist/agent-src/rules/token-efficiency.md +26 -3
  25. package/dist/agent-src/scripts/_cli_entry.ts +51 -0
  26. package/dist/agent-src/scripts/archive_completed_roadmaps.ts +14 -23
  27. package/dist/agent-src/scripts/roadmap_gates.ts +4 -20
  28. package/dist/agent-src/scripts/roadmap_set_step.ts +5 -2
  29. package/dist/agent-src/scripts/stubs_due.ts +4 -18
  30. package/dist/agent-src/scripts/update_roadmap_progress.ts +7 -24
  31. package/dist/agent-src/skills/code-intelligence/SKILL.md +25 -0
  32. package/dist/agent-src/skills/competitive-positioning/SKILL.md +2 -2
  33. package/dist/agent-src/skills/humanizer/references/anti-aiisms.md +27 -11
  34. package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +1 -1
  35. package/dist/agent-src/skills/markitdown/SKILL.md +1 -1
  36. package/dist/agent-src/skills/repomix-packer/SKILL.md +1 -1
  37. package/dist/agent-src/skills/roadmap-writing/SKILL.md +17 -0
  38. package/dist/agent-src/skills/technical-specification/SKILL.md +4 -0
  39. package/dist/agent-src/templates/agent-settings.md +0 -1
  40. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  41. package/dist/agent-src/templates/features.md +5 -0
  42. package/dist/agent-src/templates/roadmaps.md +15 -0
  43. package/dist/cli-delegate/_cli_entry.js +8 -0
  44. package/dist/cli-delegate/_lib/pin_resolver.js +170 -0
  45. package/dist/cli-delegate/archival_sweep.js +8 -0
  46. package/dist/cli-delegate/archive_completed_roadmaps.js +494 -0
  47. package/dist/cli-delegate/check_update_banner.js +923 -0
  48. package/dist/cli-delegate/{chunk-KPBWFOPZ.js → chunk-2FTMENJL.js} +194 -37
  49. package/dist/cli-delegate/{chunk-PI2GU3DP.js → chunk-2TAQ2K4V.js} +4 -1
  50. package/dist/cli-delegate/chunk-5EK5WQN6.js +28 -0
  51. package/dist/cli-delegate/chunk-7XGD2OEU.js +96 -0
  52. package/dist/cli-delegate/{chunk-C6IPZRDA.js → chunk-BIXEDQPZ.js} +7 -1
  53. package/dist/cli-delegate/chunk-DBH4AHDK.js +155 -0
  54. package/dist/cli-delegate/{chunk-NUMQHLS5.js → chunk-J3RFNKG4.js} +21 -2
  55. package/dist/cli-delegate/chunk-JO25G5H7.js +20 -0
  56. package/dist/cli-delegate/chunk-LTYVIY76.js +7961 -0
  57. package/dist/cli-delegate/chunk-QAJS5YWY.js +999 -0
  58. package/dist/cli-delegate/{chunk-ZVBOHSVF.js → chunk-TGIPZBCW.js} +1 -1
  59. package/dist/cli-delegate/{chunk-YS6XTLEK.js → chunk-TYSY33MD.js} +56 -6
  60. package/dist/cli-delegate/chunk-ULET4BYS.js +328 -0
  61. package/dist/cli-delegate/chunk-YDQSHTD7.js +187 -0
  62. package/dist/cli-delegate/chunk-YWVXLR44.js +48 -0
  63. package/dist/cli-delegate/chunk-ZZQBUHFK.js +273 -0
  64. package/dist/cli-delegate/cmd_conformance.js +19 -5
  65. package/dist/cli-delegate/cmd_doctor.js +3 -3
  66. package/dist/cli-delegate/cmd_export.js +2 -2
  67. package/dist/cli-delegate/cmd_handoff.js +27 -3
  68. package/dist/cli-delegate/cmd_prune.js +2 -2
  69. package/dist/cli-delegate/cmd_session_recycle.js +2 -2
  70. package/dist/cli-delegate/cmd_settings_migrate.js +2 -2
  71. package/dist/cli-delegate/cmd_sync.js +2 -2
  72. package/dist/cli-delegate/cmd_uninstall.js +2 -2
  73. package/dist/cli-delegate/cmd_validate.js +2 -2
  74. package/dist/cli-delegate/dashboard_mode.js +16 -0
  75. package/dist/cli-delegate/gate_budget.js +24 -0
  76. package/dist/cli-delegate/gate_execute.js +25 -0
  77. package/dist/cli-delegate/guarded_baseline.js +18 -0
  78. package/dist/cli-delegate/resume_probe.js +22 -0
  79. package/dist/cli-delegate/roadmap_gates.js +638 -0
  80. package/dist/cli-delegate/roadmap_set_step.js +173 -0
  81. package/dist/cli-delegate/stub_queue.js +47 -0
  82. package/dist/cli-delegate/stubs_due.js +38 -0
  83. package/dist/cli-delegate/ticket_bundles.js +59 -0
  84. package/dist/cli-delegate/update_roadmap_progress.js +60 -0
  85. package/dist/discovery/deprecation-report.md +1 -1
  86. package/dist/discovery/discovery-manifest.json +60 -29
  87. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  88. package/dist/discovery/discovery-manifest.summary.md +3 -3
  89. package/dist/discovery/dormancy-report.md +1 -1
  90. package/dist/discovery/orphan-report.md +1 -1
  91. package/dist/discovery/packs.json +7 -6
  92. package/dist/discovery/trust-report.md +2 -2
  93. package/dist/discovery/workspaces.json +6 -5
  94. package/dist/hooks/dispatch.js +1522 -1008
  95. package/dist/install/claudeLayerCarriage.js +237 -0
  96. package/dist/install/claudePathsPlan.js +79 -0
  97. package/dist/install/hostLayerFingerprint.js +1 -1
  98. package/dist/install/install.mjs +10 -1
  99. package/dist/install/partitionEligibility.js +231 -117
  100. package/dist/install/ruleLayerPartition.js +10 -7
  101. package/dist/mcp/registry-manifest.json +3 -3
  102. package/dist/mcp/server.json +2 -2
  103. package/dist/mcp/server.mjs +39376 -38902
  104. package/dist/scripts/ai_council/content_ceiling.js +63 -0
  105. package/dist/scripts/ai_council/seat_policy.js +106 -0
  106. package/dist/scripts/ai_council/transport_resolver.js +21 -0
  107. package/dist/scripts/condense.js +32 -25
  108. package/docs/MIGRATION.md +49 -1
  109. package/docs/contracts/settings-classes.md +1 -1
  110. package/docs/guidelines/agent-infra/minimal-safe-diff-mechanics.md +73 -0
  111. package/llms.txt +14 -14
  112. package/package.json +7 -4
  113. package/src/agent-src/scripts/_cli_entry.ts +51 -0
  114. package/src/agent-src/scripts/archive_completed_roadmaps.ts +14 -23
  115. package/src/agent-src/scripts/roadmap_gates.ts +4 -20
  116. package/src/agent-src/scripts/roadmap_set_step.ts +5 -2
  117. package/src/agent-src/scripts/stubs_due.ts +4 -18
  118. package/src/agent-src/scripts/update_roadmap_progress.ts +7 -24
  119. package/src/config/continuity-surface.json +509 -0
  120. package/src/config/estate-count-budget.json +1 -1
  121. package/src/config/gate-coverage.yml +29 -8
  122. package/src/config/gate-violation-baselines.json +8 -8
  123. package/src/config/gitignore-block.txt +19 -0
  124. package/src/config/host-injection-effect.json +73 -0
  125. package/src/config/packed-binary-manifest.json +33 -0
  126. package/src/config/preamble-payload-budget.json +112 -105
  127. package/src/config/publish-surface.json +4 -2
  128. package/src/config/release-gate-locality.yml +4 -3
  129. package/src/install/claudeLayerCarriage.ts +273 -0
  130. package/src/install/claudePathsPlan.ts +76 -0
  131. package/src/install/hostLayerFingerprint.ts +1 -1
  132. package/src/install/partitionEligibility.ts +261 -127
  133. package/src/install/ruleLayerPartition.ts +19 -23
  134. package/src/scripts/_dispatch.bash +77 -27
  135. package/src/scripts/_lib/auto_dispatch.ts +2 -2
  136. package/src/scripts/_lib/blocked_by_marker.ts +189 -0
  137. package/src/scripts/_lib/catalogue_layer_parity.ts +146 -0
  138. package/src/scripts/_lib/continuity_surface.ts +296 -0
  139. package/src/scripts/_lib/corpus_manifest.ts +26 -9
  140. package/src/scripts/_lib/hook_settings.ts +1 -1
  141. package/src/scripts/_lib/host_capability.ts +38 -1
  142. package/src/scripts/_lib/injection_effect.ts +151 -0
  143. package/src/scripts/_lib/layer_overlap_notice.ts +50 -6
  144. package/src/scripts/_lib/packed_binary_predicate.ts +225 -0
  145. package/src/scripts/_lib/pin_resolver.ts +13 -0
  146. package/src/scripts/_lib/regression_neighbourhood.ts +1 -1
  147. package/src/scripts/_lib/release_highlights.ts +19 -211
  148. package/src/scripts/_lib/release_material.ts +27 -77
  149. package/src/scripts/_lib/retired_status.ts +74 -0
  150. package/src/scripts/_lib/skill_catalogue.ts +156 -21
  151. package/src/scripts/_lib/structured_ask.ts +117 -0
  152. package/src/scripts/_lib/subagent_capsule.ts +117 -8
  153. package/src/scripts/_lib/tty_prompt.ts +76 -0
  154. package/src/scripts/ai_council/api_transport.ts +168 -0
  155. package/src/scripts/ai_council/clients.ts +58 -63
  156. package/src/scripts/ai_council/config.ts +13 -0
  157. package/src/scripts/ai_council/content_ceiling.ts +79 -0
  158. package/src/scripts/ai_council/deliberation_metrics.ts +353 -0
  159. package/src/scripts/ai_council/jury_aggregate.ts +178 -0
  160. package/src/scripts/ai_council/prompts.ts +9 -0
  161. package/src/scripts/ai_council/seat_policy.ts +137 -0
  162. package/src/scripts/ai_council/status_surface.ts +79 -0
  163. package/src/scripts/ai_council/synthesis_disagreement.ts +206 -0
  164. package/src/scripts/ai_council/transport_resolver.ts +59 -1
  165. package/src/scripts/ai_tells_rules.ts +446 -5
  166. package/src/scripts/ask_block_census.ts +499 -0
  167. package/src/scripts/bench_humanizer_eval.ts +264 -40
  168. package/src/scripts/bench_prose_tells_fp.ts +198 -0
  169. package/src/scripts/capture_skill_catalogue.ts +24 -11
  170. package/src/scripts/check_branch_work_committed.ts +234 -0
  171. package/src/scripts/check_candidate_lines.ts +499 -0
  172. package/src/scripts/check_continuity_surface.ts +475 -0
  173. package/src/scripts/check_dependency_floors.ts +13 -6
  174. package/src/scripts/check_estate_count.ts +40 -79
  175. package/src/scripts/check_pack_size.ts +263 -24
  176. package/src/scripts/check_release_highlights.ts +0 -157
  177. package/src/scripts/check_roadmap_trackable.ts +19 -16
  178. package/src/scripts/check_rule_layer_partition.ts +54 -34
  179. package/src/scripts/check_single_delivery.ts +97 -31
  180. package/src/scripts/check_update_banner.ts +13 -0
  181. package/src/scripts/code_graph/build.ts +138 -15
  182. package/src/scripts/code_graph/cli.ts +76 -8
  183. package/src/scripts/code_graph/extract.ts +11 -0
  184. package/src/scripts/code_graph/grammar_probe.ts +43 -0
  185. package/src/scripts/code_graph/loader.ts +88 -14
  186. package/src/scripts/code_graph/query.ts +121 -11
  187. package/src/scripts/code_graph/resolution_tiers.ts +238 -0
  188. package/src/scripts/code_graph/sqlite_store.ts +247 -6
  189. package/src/scripts/code_graph/types.ts +66 -1
  190. package/src/scripts/code_graph/validate.ts +23 -0
  191. package/src/scripts/condense.ts +34 -22
  192. package/src/scripts/corpus_manifest.ts +5 -5
  193. package/src/scripts/council_cli.ts +29 -39
  194. package/src/scripts/count_intent_disagreement.ts +426 -0
  195. package/src/scripts/detect_ai_tells.ts +142 -20
  196. package/src/scripts/handoff_context_hook.ts +79 -0
  197. package/src/scripts/harvest_reference_tokens.ts +698 -0
  198. package/src/scripts/hook_effect_doctor.ts +82 -1
  199. package/src/scripts/hook_manifest.json +1 -1
  200. package/src/scripts/hook_manifest.yaml +94 -12
  201. package/src/scripts/hooks/chain_nudge_hook.ts +282 -0
  202. package/src/scripts/hooks/code_graph_context_hook.ts +212 -0
  203. package/src/scripts/hooks/concern_registry.ts +6 -2
  204. package/src/scripts/hooks/delegation_nudge_hook.ts +45 -1
  205. package/src/scripts/hooks/host_semantics.ts +1 -1
  206. package/src/scripts/hooks/one_question_per_ask_hook.ts +191 -0
  207. package/src/scripts/hooks/orchestration_record_hook.ts +2 -2
  208. package/src/scripts/hooks/rule_inject_hook.ts +1 -1
  209. package/src/scripts/hooks/skill_route_hook.ts +11 -4
  210. package/src/scripts/inbox_source_census.ts +322 -0
  211. package/src/scripts/install-hooks.sh +134 -0
  212. package/src/scripts/{lint_carrier_integrity.ts → lint_deferral_integrity.ts} +60 -214
  213. package/src/scripts/lint_plan_risk_register.ts +13 -17
  214. package/src/scripts/lint_roadmap_blockers.ts +51 -1
  215. package/src/scripts/mcp_server/suggest_skill.ts +72 -0
  216. package/src/scripts/mcp_server/tools.ts +2 -56
  217. package/src/scripts/media/lib/adapter-contract.md +7 -2
  218. package/src/scripts/media/lib/fixtures/flux/asset-0001.png +0 -0
  219. package/src/scripts/media/lib/fixtures/gemini-image/asset-0001.png +0 -0
  220. package/src/scripts/media/lib/fixtures/ideogram/asset-0001.png +0 -0
  221. package/src/scripts/migrate_command_suggestions.ts +1 -1
  222. package/src/scripts/probe_unblocked_ask.ts +135 -2
  223. package/src/scripts/rdp_candidates_delta.ts +276 -0
  224. package/src/scripts/rdp_quality_eval.ts +217 -19
  225. package/src/scripts/release.ts +26 -71
  226. package/src/scripts/release_drill.ts +6 -10
  227. package/src/scripts/release_env.ts +1 -0
  228. package/src/scripts/release_mix_taxonomy.json +3 -2
  229. package/src/scripts/release_publication.ts +34 -29
  230. package/src/scripts/report_host_injection_effect.ts +189 -0
  231. package/src/scripts/report_layer_overlap.ts +41 -0
  232. package/src/scripts/report_skill_menu_census.ts +341 -0
  233. package/src/scripts/self_review_gate.ts +409 -15
  234. package/src/scripts/skill_tools/score_skill_relevance.ts +70 -6
  235. package/src/scripts/skill_tools/suggest_skill_for_task.ts +37 -3
  236. package/src/vendor/grammars/README.md +61 -0
  237. package/src/vendor/grammars/tree-sitter-javascript.wasm +0 -0
  238. package/src/vendor/grammars/tree-sitter-php.wasm +0 -0
  239. package/src/vendor/grammars/tree-sitter-typescript.wasm +0 -0
  240. package/src/scripts/_lib/carrier_status.ts +0 -118
  241. package/src/scripts/_lib/estate_carrier_cases.ts +0 -72
  242. package/src/scripts/hooks/code_graph_nudge_hook.ts +0 -191
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Refuse a push that leaves this branch's OWN work uncommitted.
3
+ *
4
+ * The defect, measured on 2026-09-07 in `fix/release-obligation-answerable`:
5
+ * a merge-reconciliation baseline was computed, written into
6
+ * `gate-violation-baselines.json` AFTER `git add`, and then committed with
7
+ * `git commit --no-edit` — which captured the STAGED side. The reconciled
8
+ * number stayed in the working tree, the push went out without it, and the
9
+ * pushed branch asserted a baseline the tree contradicted. The operator found
10
+ * it, not the pipeline.
11
+ *
12
+ * Nothing in CI can catch this class: CI checks out the pushed commit, where
13
+ * the working tree that holds the lost edit does not exist. The only place the
14
+ * evidence is available is the machine doing the push, which is why this gate
15
+ * is pre-push and local-only — the same reach `check_branch_freshness` has.
16
+ *
17
+ * The discriminator, whose work is it:
18
+ *
19
+ * A dirty tree at push time is not automatically a defect. Gate scripts write
20
+ * reports, a parallel session may touch a shared file, a test run leaves
21
+ * artifacts. Blocking on all of it would train the operator to set the skip
22
+ * variable, which is worse than no gate.
23
+ *
24
+ * So the split is by AUTHORSHIP, and it is decidable from git alone:
25
+ *
26
+ * 1. INDEX/WORKTREE DIVERGENCE (`MM`, `AM`, `RM`, …) — the file is staged
27
+ * AND changed again since. That is "edited after `git add`" as a fact, not
28
+ * an inference, and it is exactly the shape that produced the defect.
29
+ * 2. STAGED AT ALL — `git add` is a recorded intent to ship the file, and a
30
+ * push carries commits rather than the index, so a staged-but-uncommitted
31
+ * path is this branch's work being left behind by definition. No
32
+ * authorship inference is needed for this class.
33
+ * 3. A DIRTY FILE THIS BRANCH'S OWN COMMITS TOUCHED — the branch has been
34
+ * editing it deliberately, so an open change to it is this branch's
35
+ * unfinished work rather than someone else's noise.
36
+ * 4. EVERYTHING ELSE — a dirty file the branch never committed, or an
37
+ * untracked file. Reported by name, never blocking: this is where a
38
+ * parallel session's edit and a gate script's own report output land, and
39
+ * the branch has no claim on either.
40
+ *
41
+ * Class 4 is advisory, and the residual limit is stated rather than hidden: a
42
+ * file this branch created and has neither staged nor committed is
43
+ * indistinguishable from a foreign untracked file. Class 2 closes it at the
44
+ * first `git add` — which was itself a finding of testing this gate against the
45
+ * live tree, where its own source file sat in class 4 until the rule was
46
+ * widened.
47
+ */
48
+ import * as path from 'node:path';
49
+ import process from 'node:process';
50
+ import { spawnSync } from 'node:child_process';
51
+ import { fileURLToPath } from 'node:url';
52
+
53
+ import { reportScanned } from './_lib/scan_scope.js';
54
+
55
+ const _HERE = fileURLToPath(import.meta.url);
56
+ const REPO_ROOT = path.resolve(path.dirname(_HERE), '..', '..');
57
+
58
+ export interface WorkVerdict {
59
+ /** False when the push must be refused. */
60
+ ok: boolean;
61
+ /** Files that are this branch's own unfinished work, with the reason. */
62
+ blocking: { path: string; why: string }[];
63
+ /** Files that are dirty but not this branch's to answer for. */
64
+ advisory: string[];
65
+ }
66
+
67
+ /** One `git status --porcelain` row. */
68
+ interface StatusRow {
69
+ index: string;
70
+ worktree: string;
71
+ path: string;
72
+ }
73
+
74
+ export function parsePorcelain(porcelain: string): StatusRow[] {
75
+ const out: StatusRow[] = [];
76
+ for (const line of porcelain.split('\n')) {
77
+ if (line.length < 4) continue;
78
+ const index = line[0] as string;
79
+ const worktree = line[1] as string;
80
+ let p = line.slice(3);
81
+ // Renames read `R old -> new`; the new path is the one that matters.
82
+ const arrow = p.indexOf(' -> ');
83
+ if (arrow !== -1) p = p.slice(arrow + 4);
84
+ out.push({ index, worktree, path: p.replace(/^"|"$/gu, '') });
85
+ }
86
+ return out;
87
+ }
88
+
89
+ /**
90
+ * The verdict, as a pure function of the two git readings — so the rules are
91
+ * unit-testable without a repository, the shape `confirmGate` and
92
+ * `preflightPosition` already use in this pipeline.
93
+ */
94
+ export function classifyBranchWork(opts: {
95
+ porcelain: string;
96
+ /** Files this branch's own commits touched (`git diff --name-only base..HEAD`). */
97
+ branchFiles: readonly string[];
98
+ }): WorkVerdict {
99
+ const touched = new Set(opts.branchFiles);
100
+ const blocking: { path: string; why: string }[] = [];
101
+ const advisory: string[] = [];
102
+
103
+ for (const row of parsePorcelain(opts.porcelain)) {
104
+ const untracked = row.index === '?' && row.worktree === '?';
105
+ const staged = row.index !== ' ' && !untracked;
106
+ const dirty = row.worktree !== ' ' && !untracked;
107
+
108
+ if (staged && dirty) {
109
+ blocking.push({
110
+ path: row.path,
111
+ why: 'staged AND changed again since — edited after `git add`, so the commit would capture the stale side',
112
+ });
113
+ continue;
114
+ }
115
+ if (staged) {
116
+ blocking.push({
117
+ path: row.path,
118
+ why: 'staged but never committed — `git add` records the intent to ship it, and a push carries commits, not the index',
119
+ });
120
+ continue;
121
+ }
122
+ if (dirty && touched.has(row.path)) {
123
+ blocking.push({
124
+ path: row.path,
125
+ why: "this branch's own commits touch this file, so an open change to it is unfinished work from this branch",
126
+ });
127
+ continue;
128
+ }
129
+ advisory.push(row.path);
130
+ }
131
+ return { ok: blocking.length === 0, blocking, advisory };
132
+ }
133
+
134
+ function git(args: readonly string[]): string {
135
+ const r = spawnSync('git', args, { cwd: REPO_ROOT, encoding: 'utf-8' });
136
+ return r.status === 0 ? (r.stdout ?? '') : '';
137
+ }
138
+
139
+ /** Files this branch's commits touched, relative to where it left the base. */
140
+ export function branchOwnFiles(baseRef: string): string[] {
141
+ const base = git(['merge-base', baseRef, 'HEAD']).trim();
142
+ if (base === '') return [];
143
+ return git(['diff', '--name-only', `${base}..HEAD`])
144
+ .split('\n')
145
+ .filter((l) => l.trim() !== '');
146
+ }
147
+
148
+ export function main(argv: readonly string[]): number {
149
+ const quiet = argv.includes('--quiet');
150
+ let baseRef = 'origin/main';
151
+ const bi = argv.indexOf('--base');
152
+ if (bi !== -1 && argv[bi + 1]) baseRef = argv[bi + 1] as string;
153
+
154
+ const porcelain = git(['status', '--porcelain']);
155
+ const verdict = classifyBranchWork({ porcelain, branchFiles: branchOwnFiles(baseRef) });
156
+
157
+ // Through the shared reporter, not a hand-written line: `check_gate_coverage`
158
+ // reads the CALL, and a printed `scanned:` string satisfies the eye while
159
+ // leaving the gate unhardened (measured — this gate reded that ratchet on
160
+ // its first CI run for exactly that reason).
161
+ //
162
+ // Zero rows is the GOOD state here, which inverts the usual dead-scope
163
+ // reasoning: for every other gate an empty corpus may mean the root moved,
164
+ // while for this one it means the operator has nothing outstanding. The
165
+ // scope cannot go dead either — `git status` is the corpus, and a reading it
166
+ // could not produce comes back as an empty string from a non-zero exit,
167
+ // which is indistinguishable from clean and is why the reason below is
168
+ // stated rather than left implicit.
169
+ reportScanned({
170
+ gate: 'check_branch_work_committed',
171
+ scanned: parsePorcelain(porcelain).length,
172
+ units: 'dirty path(s)',
173
+ roots: ['git status --porcelain'],
174
+ allowEmpty:
175
+ 'EMPTY_VALID: a clean working tree is this gate\'s PASSING state, not a dead scope. ' +
176
+ 'The corpus is git\'s own status output over the whole repository, so there is no ' +
177
+ 'root to move; zero rows means the operator has committed everything, which is the ' +
178
+ 'outcome the gate exists to produce.',
179
+ });
180
+
181
+ if (verdict.ok) {
182
+ if (!quiet) {
183
+ process.stdout.write(
184
+ `✅ check_branch_work_committed: nothing of this branch's own work is uncommitted` +
185
+ (verdict.advisory.length > 0
186
+ ? ` (${String(verdict.advisory.length)} unrelated dirty path(s) left alone)\n`
187
+ : '\n'),
188
+ );
189
+ }
190
+ if (verdict.advisory.length > 0 && !quiet) {
191
+ for (const p of verdict.advisory) {
192
+ process.stdout.write(` · ${p} — not touched by this branch's commits\n`);
193
+ }
194
+ }
195
+ return 0;
196
+ }
197
+
198
+ process.stderr.write(
199
+ `❌ check_branch_work_committed: ${String(verdict.blocking.length)} file(s) carry this ` +
200
+ "branch's own uncommitted work:\n",
201
+ );
202
+ for (const b of verdict.blocking) {
203
+ process.stderr.write(` - ${b.path}\n ${b.why}\n`);
204
+ }
205
+ process.stderr.write(
206
+ ' A push that leaves them behind ships a branch whose tree contradicts its own\n' +
207
+ ' commits, and NO CI gate can see it — CI checks out the commit, never the tree\n' +
208
+ ' the edit is sitting in.\n' +
209
+ ' Commit them (or `git restore` what was not meant to land), then push again.\n' +
210
+ ' Genuinely foreign changes are reported without blocking; if one of these is\n' +
211
+ " truly a parallel session's, commit around it with an explicit pathspec.\n" +
212
+ ' WIP push: AGENT_CONFIG_SKIP_PREPUSH_WORKTREE=1.\n',
213
+ );
214
+ if (verdict.advisory.length > 0) {
215
+ process.stderr.write(
216
+ ` Left alone (${String(verdict.advisory.length)}): ${verdict.advisory.join(', ')}\n`,
217
+ );
218
+ }
219
+ return 1;
220
+ }
221
+
222
+ const _isMain = (() => {
223
+ const entry = process.argv[1];
224
+ if (!entry) return false;
225
+ try {
226
+ return path.resolve(entry) === path.resolve(_HERE);
227
+ } catch {
228
+ return false;
229
+ }
230
+ })();
231
+
232
+ if (_isMain) {
233
+ process.exit(main(process.argv.slice(2)));
234
+ }