@event4u/agent-config 16.5.0 → 17.0.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 (1026) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +2 -2
  4. package/.claude-plugin/skills/install-agent-config/SKILL.md +4 -4
  5. package/CHANGELOG.md +463 -498
  6. package/CONTRIBUTING.md +47 -0
  7. package/README.md +25 -25
  8. package/dist/agent-src/commands/{design.md → agent-design.md} +10 -6
  9. package/dist/agent-src/commands/agents/init.md +66 -3
  10. package/dist/agent-src/commands/agents/user/init.md +3 -0
  11. package/dist/agent-src/commands/{optimize/deep.md → analyze/and-optimize.md} +72 -33
  12. package/dist/agent-src/commands/analyze/inbox.md +168 -37
  13. package/dist/agent-src/commands/analyze/pr.md +144 -0
  14. package/dist/agent-src/commands/analyze/{repo.md → reference.md} +85 -14
  15. package/dist/agent-src/commands/analyze/roadmap-repos.md +19 -10
  16. package/dist/agent-src/commands/analyze.md +28 -12
  17. package/dist/agent-src/commands/audit.md +115 -0
  18. package/dist/agent-src/commands/brand/review.md +13 -2
  19. package/dist/agent-src/commands/brand/tokens.md +3 -3
  20. package/dist/agent-src/commands/brand/voice.md +8 -5
  21. package/dist/agent-src/commands/brand.md +2 -2
  22. package/dist/agent-src/commands/challenge-me/closure.md +25 -0
  23. package/dist/agent-src/commands/design-system/import.md +8 -3
  24. package/dist/agent-src/commands/design-system/sync.md +98 -0
  25. package/dist/agent-src/commands/design-system.md +6 -1
  26. package/dist/agent-src/commands/evals/analyze.json +44 -0
  27. package/dist/agent-src/commands/evals/audit.json +12 -0
  28. package/dist/agent-src/commands/evals/retro.json +12 -0
  29. package/dist/agent-src/commands/fix/ci.md +10 -8
  30. package/dist/agent-src/commands/ghostwriter/write.md +22 -0
  31. package/dist/agent-src/commands/memory/learn-low-impact.md +70 -83
  32. package/dist/agent-src/commands/memory/propose.md +12 -0
  33. package/dist/agent-src/commands/memory.md +1 -1
  34. package/dist/agent-src/commands/optimize.md +4 -3
  35. package/dist/agent-src/commands/post-as/me.md +18 -0
  36. package/dist/agent-src/commands/pr/create.md +17 -342
  37. package/dist/agent-src/commands/pr/merge.md +129 -368
  38. package/dist/agent-src/commands/retro.md +121 -0
  39. package/dist/agent-src/commands/review/routing.md +1 -1
  40. package/dist/agent-src/commands/roadmap/next.md +4 -1
  41. package/dist/agent-src/commands/roadmap/process-full.md +46 -333
  42. package/dist/agent-src/commands/roadmap/triage-parked.md +6 -2
  43. package/dist/agent-src/commands/team-knowledge/consolidate.md +2 -2
  44. package/dist/agent-src/commands/team-knowledge.md +1 -1
  45. package/dist/agent-src/commands/threat-model.md +1 -1
  46. package/dist/agent-src/commands/upstream-contribute.md +91 -101
  47. package/dist/agent-src/commands/worktree/cleanup.md +18 -11
  48. package/dist/agent-src/contexts/contracts/consumer-agents-md-guide.md +54 -0
  49. package/dist/agent-src/contexts/execution/analysis-loop.md +137 -0
  50. package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +3 -3
  51. package/dist/agent-src/contexts/execution/decision-closure-execution.md +1 -1
  52. package/dist/agent-src/contexts/execution/host-capability-manifest.md +6 -0
  53. package/dist/agent-src/contexts/execution/orchestration-telemetry.md +11 -4
  54. package/dist/agent-src/contexts/execution/pr-create-branches-content.md +250 -0
  55. package/dist/agent-src/contexts/execution/pr-create-branches-freshness.md +150 -0
  56. package/dist/agent-src/contexts/execution/pr-merge-queue.md +287 -0
  57. package/dist/agent-src/contexts/execution/pr-merge-sync.md +276 -0
  58. package/dist/agent-src/contexts/execution/pr-merge-trust-boundary.md +69 -0
  59. package/dist/agent-src/contexts/execution/process-full-all.md +233 -0
  60. package/dist/agent-src/contexts/execution/process-full-delivery.md +231 -0
  61. package/dist/agent-src/contexts/execution/roadmap-execution-contract-branches.md +42 -0
  62. package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +1 -35
  63. package/dist/agent-src/contexts/execution/roadmap-process-loop-close.md +235 -0
  64. package/dist/agent-src/contexts/execution/roadmap-process-loop-prescan.md +216 -0
  65. package/dist/agent-src/contexts/execution/roadmap-process-loop-run.md +253 -0
  66. package/dist/agent-src/contexts/execution/roadmap-process-loop-set.md +212 -0
  67. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +25 -864
  68. package/dist/agent-src/contexts/execution/subagent-spawn-contract.md +14 -2
  69. package/dist/agent-src/contexts/execution/subagent-steering.md +65 -8
  70. package/dist/agent-src/contexts/model-recommendations.md +5 -5
  71. package/dist/agent-src/contexts/subagent-configuration.md +1 -1
  72. package/dist/agent-src/guidelines/agent-infra/api-cost-levers.md +4 -3
  73. package/dist/agent-src/guidelines/agent-infra/model-recommendation.md +11 -5
  74. package/dist/agent-src/guidelines/agent-infra/rule-body-migration-inventory.md +1 -1
  75. package/dist/agent-src/guidelines/agent-infra/self-improvement-pipeline.md +47 -24
  76. package/dist/agent-src/guidelines/design-antipatterns.md +5 -0
  77. package/dist/agent-src/guidelines/design-asset-discipline.md +17 -0
  78. package/dist/agent-src/guidelines/design-fidelity-routing.md +1 -0
  79. package/dist/agent-src/guidelines/php/api-design.md +10 -1
  80. package/dist/agent-src/rules/brand-source-of-truth.md +7 -6
  81. package/dist/agent-src/rules/code-provenance.md +1 -1
  82. package/dist/agent-src/rules/context-hygiene.md +0 -1
  83. package/dist/agent-src/rules/design-fidelity.md +12 -13
  84. package/dist/agent-src/rules/external-reference-deep-dive.md +2 -2
  85. package/dist/agent-src/rules/fix-what-you-see.md +1 -1
  86. package/dist/agent-src/rules/low-impact-corpus-privacy-floor.md +14 -15
  87. package/dist/agent-src/rules/missing-skill-recovery.md +12 -11
  88. package/dist/agent-src/rules/neighbour-precedence.md +1 -1
  89. package/dist/agent-src/rules/recurring-criticism.md +1 -1
  90. package/dist/agent-src/rules/roadmap-ci-steps-policy.md +0 -2
  91. package/dist/agent-src/rules/self-repair-loop.md +2 -2
  92. package/dist/agent-src/rules/token-budget-discipline.md +1 -1
  93. package/dist/agent-src/scripts/dashboard_mode.ts +4 -1
  94. package/dist/agent-src/scripts/roadmap_age.ts +175 -0
  95. package/dist/agent-src/scripts/update_roadmap_progress.ts +10 -2
  96. package/dist/agent-src/skills/accessibility-auditor/SKILL.md +3 -3
  97. package/dist/agent-src/skills/agent-security-review/SKILL.md +2 -2
  98. package/dist/agent-src/skills/agents-md-thin-root/SKILL.md +12 -4
  99. package/dist/agent-src/skills/ai-code-blindspots/SKILL.md +7 -0
  100. package/dist/agent-src/skills/ai-council/references/advanced-modes.md +11 -1
  101. package/dist/agent-src/skills/ai-council/references/cost-and-redaction.md +7 -0
  102. package/dist/agent-src/skills/ai-council/references/execution-modes.md +7 -0
  103. package/dist/agent-src/skills/ai-council/references/output-and-synthesis.md +19 -0
  104. package/dist/agent-src/skills/ai-council/references/procedure.md +7 -0
  105. package/dist/agent-src/skills/api-design/SKILL.md +2 -2
  106. package/dist/agent-src/skills/api-endpoint/SKILL.md +2 -2
  107. package/dist/agent-src/skills/authz-review/SKILL.md +5 -3
  108. package/dist/agent-src/skills/blade-ui/SKILL.md +2 -2
  109. package/dist/agent-src/skills/brand/SKILL.md +7 -3
  110. package/dist/agent-src/skills/brand-asset-generation/SKILL.md +13 -6
  111. package/dist/agent-src/skills/brand-audit/SKILL.md +2 -1
  112. package/dist/agent-src/skills/brand-identity/SKILL.md +5 -4
  113. package/dist/agent-src/skills/brand-strategy/SKILL.md +5 -4
  114. package/dist/agent-src/skills/brand-to-tokens/SKILL.md +18 -39
  115. package/dist/agent-src/skills/brand-to-tokens/templates/marp-brand-deck.md.example +2 -2
  116. package/dist/agent-src/skills/brand-to-tokens/templates/reveal-brand-deck.yaml +2 -2
  117. package/dist/agent-src/skills/canvas-design/SKILL.md +12 -2
  118. package/dist/agent-src/skills/competitive-positioning/SKILL.md +2 -2
  119. package/dist/agent-src/skills/composer-packages/SKILL.md +18 -0
  120. package/dist/agent-src/skills/condense-memory/SKILL.md +1 -1
  121. package/dist/agent-src/skills/content-funnel-design/SKILL.md +8 -1
  122. package/dist/agent-src/skills/context-authoring/SKILL.md +1 -1
  123. package/dist/agent-src/skills/context-document/SKILL.md +2 -2
  124. package/dist/agent-src/skills/corpus-grounding/SKILL.md +6 -6
  125. package/dist/agent-src/skills/corpus-grounding/scripts/decision_engine.ts +13 -11
  126. package/dist/agent-src/skills/corpus-grounding/scripts/ground.mjs +1706 -0
  127. package/dist/agent-src/skills/corpus-grounding/scripts/schema_validator.ts +7 -1
  128. package/dist/agent-src/skills/dashboard-design/SKILL.md +1 -1
  129. package/dist/agent-src/skills/data-flow-mapper/SKILL.md +5 -2
  130. package/dist/agent-src/skills/database/SKILL.md +5 -4
  131. package/dist/agent-src/skills/decision-record/references/weighted-matrix.md +12 -0
  132. package/dist/agent-src/skills/deep-reading-analyst/SKILL.md +1 -1
  133. package/dist/agent-src/skills/dependency-upgrade/SKILL.md +61 -11
  134. package/dist/agent-src/skills/description-assist/SKILL.md +1 -1
  135. package/dist/agent-src/skills/design-intelligence/SKILL.md +1 -1
  136. package/dist/agent-src/skills/design-intelligence/data/landing.csv +1 -1
  137. package/dist/agent-src/skills/design-intelligence/references/context-and-registers.md +10 -2
  138. package/dist/agent-src/skills/design-intelligence/references/design-languages.md +1 -1
  139. package/dist/agent-src/skills/design-intelligence/references/design-rules-checklist.md +4 -3
  140. package/dist/agent-src/skills/design-intelligence/references/integration-mapping.md +14 -14
  141. package/dist/agent-src/skills/{wireframe → design-review}/references/story-beat-ledger.schema.json +1 -1
  142. package/dist/agent-src/skills/design-review/references/verification-automation.md +11 -3
  143. package/dist/agent-src/skills/design-system-capture/SKILL.md +15 -10
  144. package/dist/agent-src/skills/design-system-capture/references/design-system-json.md +20 -5
  145. package/dist/agent-src/skills/design-system-capture/references/import-procedure.md +2 -2
  146. package/dist/agent-src/skills/design-tokens/SKILL.md +23 -23
  147. package/dist/agent-src/skills/design-tokens/scripts/tokens.mjs +1037 -0
  148. package/dist/agent-src/skills/design-tokens/scripts/tokens.ts +336 -13
  149. package/dist/agent-src/skills/design-tokens/templates/design-tokens-starter.json +52 -53
  150. package/dist/agent-src/skills/docker/SKILL.md +1 -1
  151. package/dist/agent-src/skills/estimate-ticket/SKILL.md +1 -1
  152. package/dist/agent-src/skills/existing-ui-audit/SKILL.md +14 -276
  153. package/dist/agent-src/skills/existing-ui-audit/procedure.yaml +44 -0
  154. package/dist/agent-src/skills/existing-ui-audit/references/anti-slop-cross-reference.md +1 -1
  155. package/dist/agent-src/skills/existing-ui-audit/references/steps/00-inspect-stack-and-input.md +4 -0
  156. package/dist/agent-src/skills/existing-ui-audit/references/steps/01-enumerate-components.md +26 -0
  157. package/dist/agent-src/skills/existing-ui-audit/references/steps/01b-detect-component-taxonomy.md +7 -0
  158. package/dist/agent-src/skills/existing-ui-audit/references/steps/02-identify-design-system.md +12 -0
  159. package/dist/agent-src/skills/existing-ui-audit/references/steps/03-detect-design-tokens.md +35 -0
  160. package/dist/agent-src/skills/existing-ui-audit/references/steps/04-detect-shadcn-inventory.md +13 -0
  161. package/dist/agent-src/skills/existing-ui-audit/references/steps/04b-live-storybook-read.md +26 -0
  162. package/dist/agent-src/skills/existing-ui-audit/references/steps/05-list-reusable-patterns.md +14 -0
  163. package/dist/agent-src/skills/existing-ui-audit/references/steps/06-match-candidates.md +52 -0
  164. package/dist/agent-src/skills/existing-ui-audit/references/steps/07-greenfield-branch.md +29 -0
  165. package/dist/agent-src/skills/existing-ui-audit/references/steps/08-a11y-baseline.md +40 -0
  166. package/dist/agent-src/skills/existing-ui-audit/references/steps/09-validate-and-write.md +5 -0
  167. package/dist/agent-src/skills/experiment-loop/SKILL.md +1 -1
  168. package/dist/agent-src/skills/fe-design/references/design-patterns.md +16 -2
  169. package/dist/agent-src/skills/fe-design/references/design-read-and-memory.md +1 -1
  170. package/dist/agent-src/skills/fe-design/references/source-led-port.md +1 -1
  171. package/dist/agent-src/skills/finishing-a-development-branch/SKILL.md +6 -6
  172. package/dist/agent-src/skills/flux/SKILL.md +1 -1
  173. package/dist/agent-src/skills/form-handler/SKILL.md +15 -2
  174. package/dist/agent-src/skills/git-workflow/SKILL.md +2 -2
  175. package/dist/agent-src/skills/git-workflow/references/branch-update.md +7 -0
  176. package/dist/agent-src/skills/git-workflow/references/commit-subject.md +12 -0
  177. package/dist/agent-src/skills/git-workflow/references/push-closes-its-loop.md +10 -0
  178. package/dist/agent-src/skills/gtm-launch/SKILL.md +8 -1
  179. package/dist/agent-src/skills/html-deck/SKILL.md +7 -2
  180. package/dist/agent-src/skills/humanizer/SKILL.md +16 -3
  181. package/dist/agent-src/skills/humanizer/references/anti-aiisms.md +13 -1
  182. package/dist/agent-src/skills/humanizer/references/fixtures.md +8 -0
  183. package/dist/agent-src/skills/js-library-packaging/SKILL.md +5 -4
  184. package/dist/agent-src/skills/js-library-packaging/scripts/check_package_surface.mjs +197 -0
  185. package/dist/agent-src/skills/judge-artifact-completeness/SKILL.md +1 -1
  186. package/dist/agent-src/skills/judge-security-auditor/SKILL.md +2 -2
  187. package/dist/agent-src/skills/launch-readiness/SKILL.md +18 -22
  188. package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +5 -5
  189. package/dist/agent-src/skills/livewire/SKILL.md +1 -1
  190. package/dist/agent-src/skills/llm-provider-knowledge/SKILL.md +18 -0
  191. package/dist/agent-src/skills/logo-generation/SKILL.md +9 -3
  192. package/dist/agent-src/skills/market-entry-analysis/SKILL.md +6 -1
  193. package/dist/agent-src/skills/markitdown/SKILL.md +1 -1
  194. package/dist/agent-src/skills/memory-consolidation/SKILL.md +2 -2
  195. package/dist/agent-src/skills/messaging-architecture/SKILL.md +8 -1
  196. package/dist/agent-src/skills/motion-choreographer/SKILL.md +2 -2
  197. package/dist/agent-src/skills/playwright-testing/SKILL.md +2 -0
  198. package/dist/agent-src/skills/positioning-strategy/SKILL.md +10 -2
  199. package/dist/agent-src/skills/prediction-pool-optimizer/references/ev-fixtures.md +13 -0
  200. package/dist/agent-src/skills/prediction-pool-optimizer/references/odds-and-bonus.md +7 -0
  201. package/dist/agent-src/skills/project-analysis-core/SKILL.md +1 -1
  202. package/dist/agent-src/skills/project-analysis-hypothesis-driven/SKILL.md +1 -1
  203. package/dist/agent-src/skills/project-analyzer/SKILL.md +14 -75
  204. package/dist/agent-src/skills/project-analyzer/procedure.yaml +39 -0
  205. package/dist/agent-src/skills/project-analyzer/references/steps/01-project-overview.md +9 -0
  206. package/dist/agent-src/skills/project-analyzer/references/steps/02-architecture.md +7 -0
  207. package/dist/agent-src/skills/project-analyzer/references/steps/03-data-layer.md +6 -0
  208. package/dist/agent-src/skills/project-analyzer/references/steps/04-business-domains.md +7 -0
  209. package/dist/agent-src/skills/project-analyzer/references/steps/05-api-surface.md +6 -0
  210. package/dist/agent-src/skills/project-analyzer/references/steps/06-service-map.md +6 -0
  211. package/dist/agent-src/skills/project-analyzer/references/steps/07-module-inventory.md +6 -0
  212. package/dist/agent-src/skills/project-analyzer/references/steps/08-infrastructure-and-testing.md +5 -0
  213. package/dist/agent-src/skills/project-analyzer/references/steps/09-agent-docs-audit.md +6 -0
  214. package/dist/agent-src/skills/project-analyzer/references/steps/10-gap-analysis.md +6 -0
  215. package/dist/agent-src/skills/quality-tools/references/js-ts-tools.md +10 -0
  216. package/dist/agent-src/skills/quality-tools/references/php-tools.md +13 -0
  217. package/dist/agent-src/skills/quality-tools/references/python-tools.md +11 -0
  218. package/dist/agent-src/skills/react-native-setup/SKILL.md +7 -2
  219. package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +5 -1
  220. package/dist/agent-src/skills/react-shadcn-ui/references/registry.md +13 -0
  221. package/dist/agent-src/skills/react-shadcn-ui/scripts/shadcn_add.mjs +315 -0
  222. package/dist/agent-src/skills/react-shadcn-ui/scripts/shadcn_add.ts +6 -6
  223. package/dist/agent-src/skills/receiving-code-review/SKILL.md +1 -1
  224. package/dist/agent-src/skills/refine-ticket/SKILL.md +2 -2
  225. package/dist/agent-src/skills/release-comms/SKILL.md +2 -1
  226. package/dist/agent-src/skills/repomix-packer/SKILL.md +2 -2
  227. package/dist/agent-src/skills/requesting-code-review/SKILL.md +3 -3
  228. package/dist/agent-src/skills/roadmap-management/references/archival.md +3 -3
  229. package/dist/agent-src/skills/roadmap-management/references/authoring.md +9 -2
  230. package/dist/agent-src/skills/roadmap-management/references/dashboard.md +3 -3
  231. package/dist/agent-src/skills/roadmap-management/references/lifecycle.md +3 -3
  232. package/dist/agent-src/skills/roadmap-writing/SKILL.md +4 -4
  233. package/dist/agent-src/skills/rtk-output-filtering/SKILL.md +1 -1
  234. package/dist/agent-src/skills/rule-writing/SKILL.md +1 -2
  235. package/dist/agent-src/skills/security/SKILL.md +41 -5
  236. package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +5 -3
  237. package/dist/agent-src/skills/skill-reviewer/SKILL.md +1 -1
  238. package/dist/agent-src/skills/skill-writing/SKILL.md +23 -8
  239. package/dist/agent-src/skills/skill-writing/references/section-patterns.md +19 -1
  240. package/dist/agent-src/skills/source-discovery/SKILL.md +3 -3
  241. package/dist/agent-src/skills/sql-writing/SKILL.md +2 -2
  242. package/dist/agent-src/skills/standards-from-config/SKILL.md +2 -2
  243. package/dist/agent-src/skills/storybook-workshop/SKILL.md +5 -0
  244. package/dist/agent-src/skills/storybook-workshop/scripts/story_contrast_floor.mjs +99 -0
  245. package/dist/agent-src/skills/subagent-orchestration/SKILL.md +13 -13
  246. package/dist/agent-src/skills/subagent-orchestration/prompts/README.md +4 -3
  247. package/dist/agent-src/skills/svg-authoring/SKILL.md +7 -1
  248. package/dist/agent-src/skills/systematic-debugging/SKILL.md +2 -2
  249. package/dist/agent-src/skills/tailwind-engineer/SKILL.md +8 -3
  250. package/dist/agent-src/skills/tailwind-engineer/scripts/tailwind_config_gen.mjs +482 -0
  251. package/dist/agent-src/skills/test-case-discovery/SKILL.md +1 -1
  252. package/dist/agent-src/skills/threat-modeling/SKILL.md +8 -1
  253. package/dist/agent-src/skills/threat-modeling/data/manifest.json +5 -2
  254. package/dist/agent-src/skills/threat-modeling/data/reasoning.csv +10 -10
  255. package/dist/agent-src/skills/threat-modeling/data/surfaces.csv +11 -10
  256. package/dist/agent-src/skills/threat-modeling/data/threats.csv +34 -20
  257. package/dist/agent-src/skills/type-design/SKILL.md +196 -0
  258. package/dist/agent-src/skills/type-design/references/font-spec.md +90 -0
  259. package/dist/agent-src/skills/type-design/references/gates.md +113 -0
  260. package/dist/agent-src/skills/type-design/references/toolchain.md +66 -0
  261. package/dist/agent-src/skills/typography-system/SKILL.md +21 -11
  262. package/dist/agent-src/skills/typography-system/references/worked-scales.md +85 -0
  263. package/dist/agent-src/skills/ui-apply-generic/SKILL.md +1 -1
  264. package/dist/agent-src/skills/universal-project-analysis/SKILL.md +1 -1
  265. package/dist/agent-src/skills/upstream-contribute/SKILL.md +120 -125
  266. package/dist/agent-src/skills/using-git-worktrees/SKILL.md +1 -0
  267. package/dist/agent-src/skills/verify-repair-loop/SKILL.md +1 -1
  268. package/dist/agent-src/skills/voice-and-tone-design/SKILL.md +71 -2
  269. package/dist/agent-src/skills/worktree-lifecycle/SKILL.md +16 -14
  270. package/dist/agent-src/templates/AGENTS.md +1 -1
  271. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  272. package/dist/agent-src/templates/agents/proposal.example.md +1 -1
  273. package/dist/agent-src/templates/github-workflows/advisories-daily.yml +85 -0
  274. package/dist/agent-src/templates/roadmaps.md +39 -1
  275. package/dist/agent-src/templates/scripts/check_memory.ts +2 -2
  276. package/dist/agent-src/templates/scripts/historical-bug-patterns.example.yml +13 -1
  277. package/dist/agent-src/templates/scripts/work_engine/cli.ts +17 -0
  278. package/dist/agent-src/templates/scripts/work_engine/cli_args.ts +10 -0
  279. package/dist/agent-src/templates/scripts/work_engine/directives/ui/scaffold.ts +22 -13
  280. package/dist/agent-src/templates/scripts/work_engine/dispatcher.ts +18 -4
  281. package/dist/agent-src/templates/scripts/work_engine/procedure/checks.ts +283 -0
  282. package/dist/agent-src/templates/scripts/work_engine/procedure/run.ts +432 -0
  283. package/dist/agent-src/templates/scripts/work_engine/procedure/sidecar.ts +185 -0
  284. package/dist/agent-src/templates/scripts/work_engine/state.ts +3 -0
  285. package/dist/cli/commands/uiRender.js +72 -17
  286. package/dist/cli/commands/uiRenderAsset.js +10 -2
  287. package/dist/cli/commands/uiRenderAssetFonts.js +158 -0
  288. package/dist/cli/commands/uiRenderAssetTypes.js +8 -20
  289. package/dist/cli/initRouting.js +1 -1
  290. package/dist/cli/mcp/dispatch.js +31 -9
  291. package/dist/cli/python/knowledge_ingest.js +7 -39
  292. package/dist/cli/python/workspace_secrets.js +4 -177
  293. package/dist/cli/registry.js +4 -1
  294. package/dist/cli-delegate/archive_completed_roadmaps.js +3 -2
  295. package/dist/cli-delegate/check_update_banner.js +635 -266
  296. package/dist/cli-delegate/{chunk-TMWYUOK4.js → chunk-2CX7NWRB.js} +224 -437
  297. package/dist/cli-delegate/{chunk-F3QDG2GT.js → chunk-2SFOOFJJ.js} +259 -159
  298. package/dist/cli-delegate/chunk-2Y5AMLMY.js +136 -0
  299. package/dist/cli-delegate/{chunk-OKJUIAPS.js → chunk-4E2W63DA.js} +1 -62
  300. package/dist/cli-delegate/{chunk-6SRJTYJS.js → chunk-4SHNERBL.js} +37 -16
  301. package/dist/cli-delegate/chunk-5VO3RTMV.js +208 -0
  302. package/dist/cli-delegate/chunk-6E2LDY4F.js +27 -0
  303. package/dist/cli-delegate/{chunk-XQTPXKFA.js → chunk-6ZD2QZMN.js} +8 -17
  304. package/dist/cli-delegate/{chunk-6V5FMA3P.js → chunk-7CEI2YPS.js} +1 -1
  305. package/dist/cli-delegate/{chunk-DMSZHXZS.js → chunk-7DRWULEQ.js} +80 -7
  306. package/dist/cli-delegate/chunk-7NXCZSDL.js +54 -0
  307. package/dist/cli-delegate/chunk-AX3U3UWJ.js +328 -0
  308. package/dist/cli-delegate/{chunk-WOKWX5PL.js → chunk-BKALSTBZ.js} +18 -3
  309. package/dist/cli-delegate/chunk-BMGUGSY6.js +103 -0
  310. package/dist/cli-delegate/chunk-BYV46VRM.js +3309 -0
  311. package/dist/cli-delegate/{chunk-5GPULQBE.js → chunk-CAL76ADI.js} +4215 -682
  312. package/dist/cli-delegate/chunk-DSY6LLCQ.js +127 -0
  313. package/dist/cli-delegate/chunk-E6XNBVE4.js +581 -0
  314. package/dist/cli-delegate/{chunk-ZUZKZYCN.js → chunk-ESUNQ5XR.js} +46 -10
  315. package/dist/cli-delegate/{chunk-G5VVIZRC.js → chunk-F7HLSW6P.js} +1 -1
  316. package/dist/cli-delegate/chunk-FIEEOH5C.js +133 -0
  317. package/dist/cli-delegate/chunk-FKYZOWVD.js +719 -0
  318. package/dist/cli-delegate/chunk-GOMILC3O.js +918 -0
  319. package/dist/cli-delegate/chunk-I4KJYVPB.js +69 -0
  320. package/dist/cli-delegate/{chunk-JQOM7TTM.js → chunk-IDAOTDPE.js} +1 -100
  321. package/dist/cli-delegate/chunk-IROAQ77A.js +137 -0
  322. package/dist/cli-delegate/chunk-J2SJZICO.js +698 -0
  323. package/dist/cli-delegate/{chunk-6YQC2HLF.js → chunk-JHMMWNJ2.js} +54 -40
  324. package/dist/cli-delegate/{chunk-WQWXGIWB.js → chunk-M6CRG5O6.js} +165 -15
  325. package/dist/cli-delegate/{chunk-PHD7OOLE.js → chunk-MQ2UDEGV.js} +14 -3
  326. package/dist/cli-delegate/chunk-NTM7G2V4.js +220 -0
  327. package/dist/cli-delegate/chunk-PV7S5DPJ.js +175 -0
  328. package/dist/cli-delegate/{chunk-F7DQWYR5.js → chunk-RAXQOETZ.js} +6 -2
  329. package/dist/cli-delegate/{chunk-T7XSJSUQ.js → chunk-SIOMDAKL.js} +980 -784
  330. package/dist/cli-delegate/{chunk-KR6EM23A.js → chunk-TULVDQ4L.js} +3 -48
  331. package/dist/cli-delegate/chunk-UUYEKXKR.js +20 -0
  332. package/dist/cli-delegate/{chunk-7XGD2OEU.js → chunk-UXWHY6CQ.js} +2 -1
  333. package/dist/cli-delegate/{chunk-PWX7CKMD.js → chunk-VC3ECUEK.js} +1 -1
  334. package/dist/cli-delegate/{chunk-KXXWJTDO.js → chunk-WMNYVIYX.js} +1 -1
  335. package/dist/cli-delegate/chunk-XCY5KKUC.js +181 -0
  336. package/dist/cli-delegate/{chunk-H76PHZBI.js → chunk-XLY5G3CM.js} +14 -19
  337. package/dist/cli-delegate/cmd_adr_effective.js +41 -2
  338. package/dist/cli-delegate/cmd_analyze_session.js +7 -7
  339. package/dist/cli-delegate/cmd_brand_status.js +1287 -10
  340. package/dist/cli-delegate/cmd_ci_settle.js +330 -0
  341. package/dist/cli-delegate/cmd_conformance.js +483 -817
  342. package/dist/cli-delegate/cmd_doctor.js +26 -16
  343. package/dist/cli-delegate/cmd_doctor_neighbours.js +10 -7
  344. package/dist/cli-delegate/cmd_explain.js +9 -24
  345. package/dist/cli-delegate/cmd_export.js +14 -11
  346. package/dist/cli-delegate/cmd_fleet.js +5 -3
  347. package/dist/cli-delegate/cmd_git_convention.js +8 -4
  348. package/dist/cli-delegate/cmd_handoff.js +79 -242
  349. package/dist/cli-delegate/cmd_mcp_available.js +1 -1
  350. package/dist/cli-delegate/cmd_memory_get.js +4 -2
  351. package/dist/cli-delegate/cmd_migrate.js +2 -2
  352. package/dist/cli-delegate/cmd_packs_active.js +2 -2
  353. package/dist/cli-delegate/cmd_preflight.js +7 -5
  354. package/dist/cli-delegate/cmd_prune.js +16 -13
  355. package/dist/cli-delegate/cmd_route_audit.js +11 -8
  356. package/dist/cli-delegate/cmd_route_explain.js +649 -16
  357. package/dist/cli-delegate/cmd_session_recycle.js +15 -6
  358. package/dist/cli-delegate/cmd_settings_check.js +2 -2
  359. package/dist/cli-delegate/cmd_settings_get.js +1 -1
  360. package/dist/cli-delegate/cmd_settings_migrate.js +14 -11
  361. package/dist/cli-delegate/cmd_settings_set.js +1 -1
  362. package/dist/cli-delegate/cmd_sync.js +16 -13
  363. package/dist/cli-delegate/cmd_uninstall.js +185 -31
  364. package/dist/cli-delegate/cmd_update.js +67 -3
  365. package/dist/cli-delegate/cmd_upgrade.js +38 -7
  366. package/dist/cli-delegate/cmd_validate.js +16 -13
  367. package/dist/cli-delegate/cmd_versions.js +1 -1
  368. package/dist/cli-delegate/dashboard_mode.js +1 -1
  369. package/dist/cli-delegate/gate_execute.js +4 -3
  370. package/dist/cli-delegate/roadmap_age.js +22 -0
  371. package/dist/cli-delegate/roadmap_gates.js +4 -3
  372. package/dist/cli-delegate/update_roadmap_progress.js +3 -2
  373. package/dist/cli-delegate/upgrade_unattended-VVL6JLSX.js +541 -0
  374. package/dist/discovery/deprecation-report.md +1 -1
  375. package/dist/discovery/discovery-manifest.json +373 -190
  376. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  377. package/dist/discovery/discovery-manifest.summary.md +5 -5
  378. package/dist/discovery/dormancy-report.md +1 -1
  379. package/dist/discovery/orphan-report.md +1 -1
  380. package/dist/discovery/packs.json +21 -16
  381. package/dist/discovery/trust-report.md +3 -3
  382. package/dist/discovery/workspaces.json +16 -11
  383. package/dist/hooks/chat_history.chunk.cjs +6852 -0
  384. package/dist/hooks/chat_history.chunk.cjs.sha256 +1 -0
  385. package/dist/hooks/dispatch.js +17506 -18692
  386. package/dist/hooks/dispatch.sha256 +1 -1
  387. package/dist/hooks/egress_engine.chunk.cjs +915 -0
  388. package/dist/hooks/egress_engine.chunk.cjs.sha256 +1 -0
  389. package/dist/hooks/svg_rules.chunk.cjs +281 -49
  390. package/dist/hooks/svg_rules.chunk.cjs.sha256 +1 -1
  391. package/dist/install/conflict.js +36 -6
  392. package/dist/install/conflictTracker.js +81 -7
  393. package/dist/install/detect.js +3 -3
  394. package/dist/install/hostPermissionsAdapter.js +106 -0
  395. package/dist/install/install.mjs +3117 -1949
  396. package/dist/install/installThinLayer.js +1 -1
  397. package/dist/install/manifestFiles.js +21 -0
  398. package/dist/install/noGoDenyRows.js +300 -0
  399. package/dist/install/noGoRules.js +368 -0
  400. package/dist/install/ownershipLedger.js +133 -0
  401. package/dist/install/plan.js +1 -1
  402. package/dist/install/preflight.js +39 -8
  403. package/dist/install/preserve.js +74 -12
  404. package/dist/install/recordedOwnership.js +88 -5
  405. package/dist/install/rule_scope.js +20 -3
  406. package/dist/install/stagedRuntime.js +455 -0
  407. package/dist/install/toolsArg.js +19 -0
  408. package/dist/install/userPin.js +47 -0
  409. package/dist/install/wizard-plan.js +26 -4
  410. package/dist/mcp/awesome-mcp-servers.row.md +1 -1
  411. package/dist/mcp/mcp-cloudflare-catalogue.json +3 -2
  412. package/dist/mcp/registry-manifest.json +6 -5
  413. package/dist/mcp/server.json +3 -3
  414. package/dist/mcp/server.mjs +9831 -5546
  415. package/dist/router.json +1 -1
  416. package/dist/scripts/_lib/agent_settings.js +7 -12
  417. package/dist/scripts/_lib/asset_render_record.js +219 -0
  418. package/dist/scripts/_lib/claude_builtin_names.js +9 -4
  419. package/dist/scripts/_lib/claude_settings_hooks.js +102 -34
  420. package/dist/scripts/_lib/egress_rules.js +766 -0
  421. package/dist/scripts/_lib/environment_detector.js +24 -33
  422. package/dist/scripts/_lib/global_deploy_inventory.js +146 -9
  423. package/dist/scripts/_lib/guidelines_lane.js +10 -1
  424. package/dist/scripts/_lib/identifier_redaction.js +24 -0
  425. package/dist/scripts/_lib/installed_layer.js +17 -0
  426. package/dist/scripts/_lib/installed_layer_normalise.js +72 -0
  427. package/dist/scripts/_lib/lean_projection_mode.js +34 -152
  428. package/dist/scripts/_lib/project_tree_form.js +118 -0
  429. package/dist/scripts/_lib/scoped_projection.js +133 -3
  430. package/dist/scripts/_lib/settings_removed_keys.js +29 -0
  431. package/dist/scripts/_lib/settings_renamed_keys.js +17 -5
  432. package/dist/scripts/_lib/subagent_native_fields.js +35 -0
  433. package/dist/scripts/_lib/svg_filled_counter.js +285 -0
  434. package/dist/scripts/_lib/svg_rules.js +2 -0
  435. package/dist/scripts/_lib/ui_surface.js +19 -0
  436. package/dist/scripts/_lib/verification_command.js +364 -0
  437. package/dist/scripts/_lib/workspace_secrets.js +229 -0
  438. package/dist/scripts/ai_council/seat_policy.js +27 -0
  439. package/dist/scripts/ai_council/transport_resolver.js +9 -10
  440. package/dist/scripts/condense.js +25 -29
  441. package/dist/server/io/substituteTemplate.js +2 -2
  442. package/dist/server/io/yamlIO.js +2 -2
  443. package/dist/server/routes/install.js +5 -1
  444. package/dist/server/routes/settings.js +2 -2
  445. package/dist/server/routes/wizard.js +1 -1
  446. package/dist/server/schemas/settings.js +22 -16
  447. package/dist/server/serverInfo.js +1 -1
  448. package/dist/shared/brandTokenDocument.js +47 -0
  449. package/dist/shared/brandTokenPaths.js +43 -0
  450. package/dist/shared/settingsCarveOut.js +0 -7
  451. package/dist/shared/skillRanking.js +103 -5
  452. package/dist/shared/userMd/formAdapter.js +16 -0
  453. package/dist/shared/userMd/schema.js +17 -0
  454. package/dist/ui/assets/index-w70Ado09.js +23 -0
  455. package/dist/ui/index.html +1 -1
  456. package/docs/MIGRATION.md +89 -2
  457. package/docs/THIRD-PARTY-NOTICES.md +27 -0
  458. package/docs/contracts/settings-classes.md +27 -9
  459. package/docs/guidelines/agent-infra/api-cost-levers.md +4 -3
  460. package/docs/guidelines/agent-infra/model-recommendation.md +11 -5
  461. package/docs/guidelines/agent-infra/rule-body-migration-inventory.md +1 -1
  462. package/docs/guidelines/agent-infra/self-improvement-pipeline.md +47 -24
  463. package/docs/guidelines/design-antipatterns.md +5 -0
  464. package/docs/guidelines/design-asset-discipline.md +17 -0
  465. package/docs/guidelines/design-fidelity-routing.md +1 -0
  466. package/docs/guidelines/php/api-design.md +10 -1
  467. package/llms.txt +12 -10
  468. package/package.json +13 -4
  469. package/src/agent-src/scripts/dashboard_mode.ts +4 -1
  470. package/src/agent-src/scripts/roadmap_age.ts +175 -0
  471. package/src/agent-src/scripts/update_roadmap_progress.ts +10 -2
  472. package/src/agent-src/templates/AGENTS.md +1 -1
  473. package/src/agent-src/templates/scripts/check_memory.ts +2 -2
  474. package/src/agent-src/templates/scripts/historical-bug-patterns.example.yml +13 -1
  475. package/src/agent-src/templates/scripts/work_engine/cli.ts +17 -0
  476. package/src/agent-src/templates/scripts/work_engine/cli_args.ts +10 -0
  477. package/src/agent-src/templates/scripts/work_engine/directives/ui/scaffold.ts +22 -13
  478. package/src/agent-src/templates/scripts/work_engine/dispatcher.ts +18 -4
  479. package/src/agent-src/templates/scripts/work_engine/procedure/checks.ts +283 -0
  480. package/src/agent-src/templates/scripts/work_engine/procedure/run.ts +432 -0
  481. package/src/agent-src/templates/scripts/work_engine/procedure/sidecar.ts +185 -0
  482. package/src/agent-src/templates/scripts/work_engine/state.ts +3 -0
  483. package/src/config/agent-settings.template.yml +120 -57
  484. package/src/config/agents-paths.yml +13 -7
  485. package/src/config/ci-local-parity.yml +44 -0
  486. package/src/config/continuity-surface.json +51 -2
  487. package/src/config/depth-audit-samples.json +5 -0
  488. package/src/config/discovery/command-verbs.yml +1 -0
  489. package/src/config/dispatch-economy-metrics.json +1 -0
  490. package/src/config/egress-mutations/class-precedence-swapped.json +7 -0
  491. package/src/config/egress-mutations/credential-token-restores.json +7 -0
  492. package/src/config/egress-mutations/iban-checksum-disabled.json +7 -0
  493. package/src/config/egress-mutations/raw-value-in-the-count-record.json +7 -0
  494. package/src/config/evaluator-budgets.json +4 -4
  495. package/src/config/gate-coverage.yml +149 -3
  496. package/src/config/gate-reachability-exemptions.json +3 -5
  497. package/src/config/gate-violation-baselines.json +26 -22
  498. package/src/config/gitignore-block.txt +6 -3
  499. package/src/config/hook-bundle-budget.json +34 -3
  500. package/src/config/hook-carrier-probes.json +30 -0
  501. package/src/config/hook-latency-budget.json +4 -2
  502. package/src/config/host-injection-effect.json +8 -1
  503. package/src/config/host-skill-frontmatter-keys.json +56 -0
  504. package/src/config/layer-form-brakes.json +4 -0
  505. package/src/config/layer-form-comparison-corpus.json +42 -0
  506. package/src/config/loop-surfaces.yaml +28 -47
  507. package/src/config/memory-twin-verdicts.yml +9 -1
  508. package/src/config/metric-registry.yml +40 -3
  509. package/src/config/pack-size-budget.json +15 -0
  510. package/src/config/procedure-core-budget.json +21 -0
  511. package/src/config/profiles/minimal.ini +1 -1
  512. package/src/config/project-tree-form.json +24 -0
  513. package/src/config/reach-channels.yml +3 -3
  514. package/src/config/reach-prescriptions-intake.yml +1 -1
  515. package/src/config/roadmap-step-size-baseline.json +118 -0
  516. package/src/config/routing-coverage-seed.json +93 -2
  517. package/src/config/skill-body-budget.json +686 -0
  518. package/src/config/skill-fork-pilot.json +17 -0
  519. package/src/config/skill-lifecycle-probes-codex.json +57 -0
  520. package/src/config/skill-lifecycle-probes.json +57 -0
  521. package/src/config/skill-output-shape.json +316 -0
  522. package/src/config/step-depth-table.json +58 -0
  523. package/src/config/turnaround-budget.json +90 -0
  524. package/src/install/conflict.ts +38 -6
  525. package/src/install/conflictTracker.ts +126 -8
  526. package/src/install/detect.ts +3 -3
  527. package/src/install/hostPermissionsAdapter.ts +136 -0
  528. package/src/install/installThinLayer.ts +6 -1
  529. package/src/install/manifestFiles.ts +24 -0
  530. package/src/install/noGoDenyRows.ts +368 -0
  531. package/src/install/noGoRules.ts +438 -0
  532. package/src/install/ownershipLedger.ts +180 -0
  533. package/src/install/plan.ts +1 -1
  534. package/src/install/preflight.ts +42 -10
  535. package/src/install/preserve.ts +94 -12
  536. package/src/install/recordedOwnership.ts +121 -3
  537. package/src/install/rule_scope.ts +20 -3
  538. package/src/install/stagedRuntime.ts +528 -0
  539. package/src/install/toolsArg.ts +16 -0
  540. package/src/install/types.ts +23 -2
  541. package/src/install/userPin.ts +54 -0
  542. package/src/install/wizard-plan.ts +25 -4
  543. package/src/scripts/_cli/_doctor_emit.ts +24 -0
  544. package/src/scripts/_cli/cmd_brand_status.ts +223 -12
  545. package/src/scripts/_cli/cmd_ci_settle.ts +32 -0
  546. package/src/scripts/_cli/cmd_doctor.ts +23 -44
  547. package/src/scripts/_cli/cmd_route_explain.ts +176 -2
  548. package/src/scripts/_cli/cmd_uninstall.ts +270 -26
  549. package/src/scripts/_cli/cmd_update.ts +34 -1
  550. package/src/scripts/_cli/cmd_upgrade.ts +38 -2
  551. package/src/scripts/_cli/detection_report.ts +7 -0
  552. package/src/scripts/_cli/doctor_execution.ts +1 -2
  553. package/src/scripts/_cli/doctor_install_mode.ts +39 -0
  554. package/src/scripts/_cli/doctor_network_posture.ts +3 -3
  555. package/src/scripts/_cli/doctor_ownership_ledger.ts +126 -0
  556. package/src/scripts/_cli/doctor_update_verdict.ts +104 -0
  557. package/src/scripts/_cli/explain_last/scrubber.ts +9 -21
  558. package/src/scripts/_cli/upgrade_unattended.ts +548 -0
  559. package/src/scripts/_dispatch.bash +42 -9
  560. package/src/scripts/_lib/activation_ladder.ts +1 -1
  561. package/src/scripts/_lib/advisory_inventory.ts +405 -0
  562. package/src/scripts/_lib/advisory_notice.ts +270 -0
  563. package/src/scripts/_lib/advisory_sources.ts +752 -0
  564. package/src/scripts/_lib/advisory_verdicts.ts +363 -0
  565. package/src/scripts/_lib/agent_artifact_location.ts +177 -0
  566. package/src/scripts/_lib/agent_settings.ts +7 -12
  567. package/src/scripts/_lib/arrival_record.ts +217 -0
  568. package/src/scripts/_lib/asset_render_record.ts +247 -0
  569. package/src/scripts/_lib/billing_grant.ts +4 -2
  570. package/src/scripts/_lib/brand_voice_slot.ts +258 -0
  571. package/src/scripts/_lib/canary_status.ts +24 -0
  572. package/src/scripts/_lib/cc_transcript.ts +276 -0
  573. package/src/scripts/_lib/changelog_eras.ts +83 -0
  574. package/src/scripts/_lib/claim_phrases.ts +71 -0
  575. package/src/scripts/_lib/classify_update.ts +171 -0
  576. package/src/scripts/_lib/claude_builtin_names.ts +9 -4
  577. package/src/scripts/_lib/claude_hook_scope.ts +195 -0
  578. package/src/scripts/_lib/claude_settings_hooks.ts +118 -34
  579. package/src/scripts/_lib/codex_resident_set.ts +460 -0
  580. package/src/scripts/_lib/codex_skill_finder.ts +225 -0
  581. package/src/scripts/_lib/confusables.ts +19 -0
  582. package/src/scripts/_lib/consumer_impact.ts +199 -0
  583. package/src/scripts/_lib/content_class.ts +127 -0
  584. package/src/scripts/_lib/counted_probe.ts +68 -1
  585. package/src/scripts/_lib/credential_deny_rows.ts +151 -0
  586. package/src/scripts/_lib/credential_files.ts +367 -0
  587. package/src/scripts/_lib/delivery_arm_experiment.ts +2 -2
  588. package/src/scripts/_lib/depth_flip.ts +141 -0
  589. package/src/scripts/_lib/design_lock.ts +117 -0
  590. package/src/scripts/_lib/design_sync_ledger.ts +142 -0
  591. package/src/scripts/_lib/design_sync_plan.ts +177 -0
  592. package/src/scripts/_lib/design_sync_reconcile.ts +159 -0
  593. package/src/scripts/_lib/design_sync_verify.ts +99 -0
  594. package/src/scripts/_lib/design_system_claude_design.ts +323 -0
  595. package/src/scripts/_lib/design_system_import.ts +84 -6
  596. package/src/scripts/_lib/dispatch_import_closure.ts +42 -11
  597. package/src/scripts/_lib/egress_credential_env.ts +35 -0
  598. package/src/scripts/_lib/egress_engine.ts +22 -0
  599. package/src/scripts/_lib/egress_known_values.ts +223 -0
  600. package/src/scripts/_lib/egress_normalize.ts +67 -0
  601. package/src/scripts/_lib/egress_prefixes.ts +42 -0
  602. package/src/scripts/_lib/egress_rules.ts +896 -0
  603. package/src/scripts/_lib/egress_rules_linearity.ts +56 -0
  604. package/src/scripts/_lib/egress_sender_scan.ts +290 -0
  605. package/src/scripts/_lib/egress_session_table.ts +510 -0
  606. package/src/scripts/_lib/egress_text.ts +63 -0
  607. package/src/scripts/_lib/egress_token.ts +252 -0
  608. package/src/scripts/_lib/empty_cycles.ts +1 -1
  609. package/src/scripts/_lib/environment_detector.ts +45 -30
  610. package/src/scripts/_lib/exemption_shape.ts +75 -1
  611. package/src/scripts/_lib/floor_posture.ts +185 -0
  612. package/src/scripts/_lib/forge_protection.ts +140 -2
  613. package/src/scripts/_lib/global_deploy_inventory.ts +159 -6
  614. package/src/scripts/_lib/guidelines_lane.ts +12 -1
  615. package/src/scripts/_lib/hand_kinds.ts +65 -0
  616. package/src/scripts/_lib/headless_invocation.ts +3 -3
  617. package/src/scripts/_lib/host_capability.ts +34 -2
  618. package/src/scripts/_lib/host_env_write.ts +39 -18
  619. package/src/scripts/_lib/host_listing_model.ts +14 -7
  620. package/src/scripts/_lib/identifier_redaction.ts +26 -0
  621. package/src/scripts/_lib/impact_bump.ts +70 -0
  622. package/src/scripts/_lib/install_reach_checks.ts +53 -1
  623. package/src/scripts/_lib/installed_layer.ts +31 -0
  624. package/src/scripts/_lib/installed_layer_normalise.ts +75 -0
  625. package/src/scripts/_lib/instructions_loaded_classify.ts +75 -0
  626. package/src/scripts/_lib/instructions_loaded_event.ts +53 -0
  627. package/src/scripts/_lib/knowledge_global_redaction.ts +2 -2
  628. package/src/scripts/_lib/layer_form_corpus.ts +165 -0
  629. package/src/scripts/_lib/layer_form_decision.ts +248 -0
  630. package/src/scripts/_lib/layer_form_evidence.ts +112 -0
  631. package/src/scripts/_lib/lean_projection_mode.ts +32 -161
  632. package/src/scripts/_lib/llm_proposer_transport.ts +1 -0
  633. package/src/scripts/_lib/loop_guards.ts +8 -120
  634. package/src/scripts/_lib/major_surface.ts +207 -0
  635. package/src/scripts/_lib/mcp_bridge.ts +30 -69
  636. package/src/scripts/_lib/merge_clearance_record.ts +384 -0
  637. package/src/scripts/_lib/neighbour_census.ts +18 -1
  638. package/src/scripts/_lib/orchestration_record.ts +61 -0
  639. package/src/scripts/_lib/outcome_vocabularies.ts +15 -23
  640. package/src/scripts/_lib/pin_advice.ts +49 -0
  641. package/src/scripts/_lib/platform_anchor.ts +222 -0
  642. package/src/scripts/_lib/procedure_checks.ts +5 -0
  643. package/src/scripts/_lib/project_tree_form.ts +134 -0
  644. package/src/scripts/_lib/projection_key_migration.ts +122 -0
  645. package/src/scripts/_lib/prompt_shape.ts +13 -2
  646. package/src/scripts/_lib/provenance_verify.ts +272 -0
  647. package/src/scripts/_lib/quota_parked.ts +27 -1
  648. package/src/scripts/_lib/ratification_artifact.ts +64 -1
  649. package/src/scripts/_lib/ratification_subject.ts +508 -46
  650. package/src/scripts/_lib/release_findings_ingest.ts +52 -5
  651. package/src/scripts/_lib/release_highlights.ts +72 -2
  652. package/src/scripts/_lib/release_settings_surface.ts +392 -0
  653. package/src/scripts/_lib/review_round.ts +134 -0
  654. package/src/scripts/_lib/roadmap_checkboxes.ts +1 -1
  655. package/src/scripts/_lib/roadmap_slug_lock.ts +254 -0
  656. package/src/scripts/_lib/roadmap_step_size.ts +75 -0
  657. package/src/scripts/_lib/run_checkpoint.ts +60 -3
  658. package/src/scripts/_lib/runtime_wiring_checks.ts +15 -1
  659. package/src/scripts/_lib/scope_guard.sh +64 -5
  660. package/src/scripts/_lib/scoped_projection.ts +136 -3
  661. package/src/scripts/_lib/secret_detector.ts +24 -103
  662. package/src/scripts/_lib/security_fix.ts +429 -0
  663. package/src/scripts/_lib/security_fix_context.ts +133 -0
  664. package/src/scripts/_lib/self_repair.ts +69 -39
  665. package/src/scripts/_lib/self_repair_outgoing.ts +209 -0
  666. package/src/scripts/_lib/self_repair_payload.ts +86 -0
  667. package/src/scripts/_lib/session_eol.ts +3 -0
  668. package/src/scripts/_lib/session_pr_watch.ts +207 -0
  669. package/src/scripts/_lib/session_register.ts +51 -1
  670. package/src/scripts/_lib/session_tag.ts +51 -0
  671. package/src/scripts/_lib/settings_removed_keys.ts +30 -0
  672. package/src/scripts/_lib/settings_renamed_keys.ts +19 -5
  673. package/src/scripts/_lib/skill_catalogue.ts +66 -25
  674. package/src/scripts/_lib/skill_fork_pilot.ts +121 -0
  675. package/src/scripts/_lib/skill_leases.ts +203 -0
  676. package/src/scripts/_lib/skill_listing_overrides.ts +294 -0
  677. package/src/scripts/_lib/skill_materialisation.ts +388 -0
  678. package/src/scripts/_lib/skill_materialisation_gate.ts +210 -0
  679. package/src/scripts/_lib/skill_materialisation_lock.ts +149 -0
  680. package/src/scripts/_lib/skill_materialisation_triggers.ts +96 -0
  681. package/src/scripts/_lib/skill_origin.ts +21 -1
  682. package/src/scripts/_lib/skill_reach.ts +342 -0
  683. package/src/scripts/_lib/source_shape.ts +7 -2
  684. package/src/scripts/_lib/sqlite_guard.ts +1 -1
  685. package/src/scripts/_lib/step_anatomy.ts +330 -0
  686. package/src/scripts/_lib/subagent_capsule.ts +8 -2
  687. package/src/scripts/_lib/subagent_native_fields.ts +30 -0
  688. package/src/scripts/_lib/subagent_spawn.ts +36 -0
  689. package/src/scripts/_lib/subagent_steering.ts +367 -0
  690. package/src/scripts/_lib/svg_filled_counter.ts +287 -0
  691. package/src/scripts/_lib/svg_rules.ts +2 -0
  692. package/src/scripts/_lib/test_delta.ts +89 -6
  693. package/src/scripts/_lib/tier_downshift_verdict.ts +222 -0
  694. package/src/scripts/_lib/tool_result_census.ts +62 -0
  695. package/src/scripts/_lib/trigger_routers.ts +1 -0
  696. package/src/scripts/_lib/turnaround_throughput.ts +378 -0
  697. package/src/scripts/_lib/ui_surface.ts +22 -0
  698. package/src/scripts/_lib/unattended_gates.ts +100 -0
  699. package/src/scripts/_lib/undeployed_fixes.ts +34 -0
  700. package/src/scripts/_lib/update_check.ts +143 -12
  701. package/src/scripts/_lib/update_invite.ts +116 -0
  702. package/src/scripts/_lib/update_notice.ts +259 -0
  703. package/src/scripts/_lib/verify_clause.ts +4 -2
  704. package/src/scripts/_lib/version_order.ts +146 -0
  705. package/src/scripts/_lib/worker_reuse.ts +191 -0
  706. package/src/scripts/_lib/workspace_secrets.ts +273 -0
  707. package/src/scripts/_lib/worktree_git.ts +67 -0
  708. package/src/scripts/_lib/worktree_ignored.ts +116 -0
  709. package/src/scripts/adoption_status.ts +330 -3
  710. package/src/scripts/adr_cite_check.ts +93 -0
  711. package/src/scripts/advisories.ts +803 -0
  712. package/src/scripts/ai-image/adapters/flux.sh +1 -0
  713. package/src/scripts/ai-image/adapters/gemini-image.sh +1 -0
  714. package/src/scripts/ai-image/adapters/ideogram.sh +1 -0
  715. package/src/scripts/ai-image/adapters/recraft.sh +1 -0
  716. package/src/scripts/ai-video/adapters/comfyui.sh +1 -0
  717. package/src/scripts/ai-video/adapters/fal.sh +1 -0
  718. package/src/scripts/ai-video/adapters/gemini-veo.sh +1 -0
  719. package/src/scripts/ai-video/adapters/higgsfield.sh +1 -0
  720. package/src/scripts/ai-video/adapters/kling.sh +1 -0
  721. package/src/scripts/ai-video/adapters/musetalk.sh +1 -0
  722. package/src/scripts/ai-video/adapters/openai-images.sh +1 -0
  723. package/src/scripts/ai-video/adapters/replicate.sh +1 -0
  724. package/src/scripts/ai-video/adapters/sora.sh +1 -0
  725. package/src/scripts/ai-video/adapters/syncso.sh +1 -0
  726. package/src/scripts/ai-video/stitch.sh +115 -2
  727. package/src/scripts/ai_council/airgap.ts +1 -0
  728. package/src/scripts/ai_council/api_transport.ts +27 -4
  729. package/src/scripts/ai_council/budget_guard.ts +300 -11
  730. package/src/scripts/ai_council/bundler.ts +20 -29
  731. package/src/scripts/ai_council/chairman.ts +17 -2
  732. package/src/scripts/ai_council/cli_agency_bounds.ts +158 -0
  733. package/src/scripts/ai_council/cli_launch_env.ts +54 -0
  734. package/src/scripts/ai_council/cli_least_agency_canary.ts +18 -2
  735. package/src/scripts/ai_council/clients.ts +55 -73
  736. package/src/scripts/ai_council/config.ts +16 -22
  737. package/src/scripts/ai_council/council_egress.ts +167 -0
  738. package/src/scripts/ai_council/exposure_ledger.ts +117 -0
  739. package/src/scripts/ai_council/free_hand_shadow.ts +276 -0
  740. package/src/scripts/ai_council/free_route.ts +216 -0
  741. package/src/scripts/ai_council/free_route_catalog.ts +173 -0
  742. package/src/scripts/ai_council/free_route_client.ts +95 -0
  743. package/src/scripts/ai_council/free_rung.ts +61 -0
  744. package/src/scripts/ai_council/hand_payload.ts +230 -0
  745. package/src/scripts/ai_council/hand_schemas.ts +123 -0
  746. package/src/scripts/ai_council/jury_aggregate.ts +155 -1
  747. package/src/scripts/ai_council/kind_flip.ts +221 -0
  748. package/src/scripts/ai_council/kind_flip_state.ts +19 -0
  749. package/src/scripts/ai_council/learn_low_impact_preview.ts +50 -22
  750. package/src/scripts/ai_council/modification_review.ts +98 -5
  751. package/src/scripts/ai_council/necessity.ts +7 -0
  752. package/src/scripts/ai_council/orchestrator.ts +16 -16
  753. package/src/scripts/ai_council/pricing.ts +10 -0
  754. package/src/scripts/ai_council/redact_low_impact_entry.ts +5 -2
  755. package/src/scripts/ai_council/response_render.ts +27 -4
  756. package/src/scripts/ai_council/round_reservations.ts +119 -0
  757. package/src/scripts/ai_council/route_chooser.ts +161 -0
  758. package/src/scripts/ai_council/route_liveness.ts +152 -0
  759. package/src/scripts/ai_council/route_member.ts +52 -0
  760. package/src/scripts/ai_council/seat_policy.ts +40 -0
  761. package/src/scripts/ai_council/seat_resume.ts +40 -0
  762. package/src/scripts/ai_council/shadow_dispatch.ts +13 -3
  763. package/src/scripts/ai_council/spend_gate.ts +18 -2
  764. package/src/scripts/ai_council/status_surface.ts +37 -0
  765. package/src/scripts/ai_council/transport_resolver.ts +15 -18
  766. package/src/scripts/analysis_analysts.ts +226 -0
  767. package/src/scripts/analysis_anchors.ts +140 -0
  768. package/src/scripts/analysis_and_optimize.ts +44 -0
  769. package/src/scripts/analysis_emit.ts +150 -0
  770. package/src/scripts/analysis_exchange.ts +186 -0
  771. package/src/scripts/analysis_gate.ts +158 -0
  772. package/src/scripts/analysis_inbox_final.ts +173 -0
  773. package/src/scripts/analysis_ledger.ts +119 -0
  774. package/src/scripts/analysis_pr_optimize.ts +219 -0
  775. package/src/scripts/analysis_pr_review.ts +240 -0
  776. package/src/scripts/analysis_pr_target.ts +121 -0
  777. package/src/scripts/analysis_prompts.ts +130 -0
  778. package/src/scripts/analysis_publish.ts +358 -0
  779. package/src/scripts/analysis_questions.ts +78 -0
  780. package/src/scripts/analysis_run.ts +248 -0
  781. package/src/scripts/analysis_run_record.ts +210 -0
  782. package/src/scripts/analysis_target.ts +343 -0
  783. package/src/scripts/analysis_validate.ts +161 -0
  784. package/src/scripts/anchor_eval_falsify.ts +1 -1
  785. package/src/scripts/arrival_report.ts +115 -0
  786. package/src/scripts/ask_transport.ts +284 -35
  787. package/src/scripts/backfill_model_tier.ts +4 -5
  788. package/src/scripts/before_complete_hook.ts +48 -2
  789. package/src/scripts/bench_hook_latency.ts +3 -3
  790. package/src/scripts/bench_procedure_cursor.ts +440 -0
  791. package/src/scripts/bootstrap.sh +3 -3
  792. package/src/scripts/build_exit_code_register.ts +440 -0
  793. package/src/scripts/build_proof.ts +23 -1
  794. package/src/scripts/cache_realization_report.ts +155 -14
  795. package/src/scripts/canary_liveness.ts +117 -0
  796. package/src/scripts/chat_history.ts +12 -15
  797. package/src/scripts/check_account_surface.ts +318 -0
  798. package/src/scripts/check_agent_artifact_location.ts +17 -160
  799. package/src/scripts/check_bundle_path_leakage.ts +6 -0
  800. package/src/scripts/check_ci_local_parity.ts +21 -13
  801. package/src/scripts/check_claims.ts +77 -2
  802. package/src/scripts/check_completion_review.ts +34 -1
  803. package/src/scripts/check_concern_admissions.ts +41 -5
  804. package/src/scripts/check_consumer_scope_flip.ts +1 -1
  805. package/src/scripts/check_context_paths.ts +2 -0
  806. package/src/scripts/check_council_layout.ts +9 -0
  807. package/src/scripts/check_credential_spelling.ts +267 -0
  808. package/src/scripts/check_egress_mutations.ts +239 -0
  809. package/src/scripts/check_enforcement_coverage.ts +16 -3
  810. package/src/scripts/check_estate_count.ts +16 -1
  811. package/src/scripts/check_finding_dispositions.ts +147 -0
  812. package/src/scripts/check_gate_coverage.ts +123 -21
  813. package/src/scripts/check_gate_reachability.ts +16 -2
  814. package/src/scripts/check_generator_sync.ts +46 -0
  815. package/src/scripts/check_hook_bundle_composition.ts +139 -1
  816. package/src/scripts/check_host_docs_digest.ts +142 -5
  817. package/src/scripts/check_kernel_edit_ratified.ts +301 -76
  818. package/src/scripts/check_kernel_rule_bundle.ts +14 -10
  819. package/src/scripts/check_knowledge_cards.ts +83 -3
  820. package/src/scripts/check_memory.ts +13 -3
  821. package/src/scripts/check_pack_size.ts +1 -1
  822. package/src/scripts/check_permission_deny_syntax.ts +247 -0
  823. package/src/scripts/check_platform_anchor.ts +243 -0
  824. package/src/scripts/check_proposal.ts +183 -1
  825. package/src/scripts/check_reach_channels.ts +5 -3
  826. package/src/scripts/check_references.ts +5 -2
  827. package/src/scripts/check_release_manifest_content.ts +33 -0
  828. package/src/scripts/check_release_pr_shape.ts +5 -0
  829. package/src/scripts/check_rule_invariants.ts +9 -1
  830. package/src/scripts/check_skill_body_budget.ts +343 -0
  831. package/src/scripts/check_skill_requires.ts +137 -1
  832. package/src/scripts/check_step_receipts.ts +246 -0
  833. package/src/scripts/check_structural_breaking.ts +7 -1
  834. package/src/scripts/check_suppression_hygiene.ts +8 -0
  835. package/src/scripts/check_test_weakening.ts +14 -0
  836. package/src/scripts/check_token_quality_golden.ts +5 -1
  837. package/src/scripts/check_update_banner.ts +50 -3
  838. package/src/scripts/check_verify_expectation_delta.ts +2 -1
  839. package/src/scripts/check_voice_lexicon.ts +531 -0
  840. package/src/scripts/ci_os_attribution.ts +327 -0
  841. package/src/scripts/ci_platform_scope.ts +69 -0
  842. package/src/scripts/ci_settle.ts +4 -1
  843. package/src/scripts/ci_status.ts +0 -1
  844. package/src/scripts/ci_time_to_green.ts +748 -0
  845. package/src/scripts/classify_merge_risk.ts +407 -19
  846. package/src/scripts/code_graph/sqlite_store.ts +1 -1
  847. package/src/scripts/compile_trigger_evals.ts +353 -0
  848. package/src/scripts/condense.ts +25 -31
  849. package/src/scripts/consumer_matrix.ts +61 -3
  850. package/src/scripts/council_availability_hook.ts +12 -4
  851. package/src/scripts/council_cli.ts +48 -38
  852. package/src/scripts/cross_repo_retrieve.ts +9 -72
  853. package/src/scripts/design_lock.ts +106 -0
  854. package/src/scripts/design_slop_rules.ts +30 -0
  855. package/src/scripts/design_sync.ts +264 -0
  856. package/src/scripts/design_system_import.ts +30 -13
  857. package/src/scripts/dispatch_economy_report.ts +46 -1
  858. package/src/scripts/dispatch_r2_reviewer.ts +41 -5
  859. package/src/scripts/egress_canary.ts +166 -0
  860. package/src/scripts/egress_sender_census.ts +101 -0
  861. package/src/scripts/external_sources_denylist.json +94 -12
  862. package/src/scripts/generate_catalog.ts +6 -2
  863. package/src/scripts/generate_owned_digest.ts +163 -0
  864. package/src/scripts/generate_reference_toc.ts +143 -0
  865. package/src/scripts/generate_subagent_floor.ts +11 -1
  866. package/src/scripts/handoff_context_hook.ts +34 -0
  867. package/src/scripts/hook_carrier_census.ts +263 -0
  868. package/src/scripts/hook_chunks.d.mts +12 -0
  869. package/src/scripts/hook_chunks.mjs +114 -0
  870. package/src/scripts/hook_manifest.json +1 -1
  871. package/src/scripts/hook_manifest.yaml +65 -42
  872. package/src/scripts/hooks/block_config_weakening.ts +127 -3
  873. package/src/scripts/hooks/block_credential_reads.ts +165 -0
  874. package/src/scripts/hooks/block_no_verify.ts +47 -23
  875. package/src/scripts/hooks/block_speaking_inbox_dir.ts +38 -7
  876. package/src/scripts/hooks/category_a.ts +202 -25
  877. package/src/scripts/hooks/concern_failure_policy.ts +6 -6
  878. package/src/scripts/hooks/concern_registry.ts +31 -6
  879. package/src/scripts/hooks/concern_registry_types.ts +11 -0
  880. package/src/scripts/hooks/delegation_nudge_hook.ts +105 -15
  881. package/src/scripts/hooks/design_pass_hook.ts +42 -10
  882. package/src/scripts/hooks/dispatch_hook.ts +13 -12
  883. package/src/scripts/hooks/egress_engine_loader.ts +125 -0
  884. package/src/scripts/hooks/egress_stage.ts +440 -0
  885. package/src/scripts/hooks/hook_stdin.ts +29 -4
  886. package/src/scripts/hooks/host_docs_pages.ts +194 -0
  887. package/src/scripts/hooks/host_docs_pages.yaml +75 -0
  888. package/src/scripts/hooks/host_lowering.json +1 -1
  889. package/src/scripts/hooks/host_lowering.yaml +22 -21
  890. package/src/scripts/hooks/host_rate_marker_hook.ts +73 -0
  891. package/src/scripts/hooks/instructions_observer_hook.ts +170 -0
  892. package/src/scripts/hooks/interruption_ledger_hook.ts +1 -1
  893. package/src/scripts/hooks/lazy_concern.ts +148 -0
  894. package/src/scripts/hooks/orchestration_record_hook.ts +80 -2
  895. package/src/scripts/hooks/payload_stub.ts +16 -6
  896. package/src/scripts/hooks/permission_gate.ts +7 -7
  897. package/src/scripts/hooks/push_settle_hook.ts +32 -3
  898. package/src/scripts/hooks/replay_hook.ts +43 -0
  899. package/src/scripts/hooks/reread_guard_hook.ts +87 -10
  900. package/src/scripts/hooks/rtk_wrap_hook.ts +4 -3
  901. package/src/scripts/hooks/rule_inject_hook.ts +8 -1
  902. package/src/scripts/hooks/session_eol_hook.ts +48 -1
  903. package/src/scripts/hooks/source_first_gate_hook.ts +6 -8
  904. package/src/scripts/hooks/spawn_guard_shadow_hook.ts +203 -10
  905. package/src/scripts/hooks/state_io.ts +2 -2
  906. package/src/scripts/hooks/svg_obligation.ts +75 -19
  907. package/src/scripts/hooks/tool_result_bytes_hook.ts +14 -5
  908. package/src/scripts/hooks/turn_end_gate_hook.ts +1 -1
  909. package/src/scripts/hooks/ui_route_nudge_hook.ts +2 -12
  910. package/src/scripts/hooks_doctor.ts +31 -0
  911. package/src/scripts/hooks_status.ts +58 -3
  912. package/src/scripts/inbox_source_census.ts +74 -13
  913. package/src/scripts/install +25 -3
  914. package/src/scripts/install.ts +60 -91
  915. package/src/scripts/interruption_report.ts +11 -1
  916. package/src/scripts/layer_baseline_report.ts +267 -0
  917. package/src/scripts/learning_sidecar.ts +1 -1
  918. package/src/scripts/lint_agents_layout.ts +3 -0
  919. package/src/scripts/lint_blocker_citations.ts +104 -0
  920. package/src/scripts/lint_breaking_changes_index.ts +40 -7
  921. package/src/scripts/lint_consolidation_lineage.ts +144 -16
  922. package/src/scripts/lint_consumer_internal_refs.ts +90 -42
  923. package/src/scripts/lint_context_spine_usage.ts +21 -0
  924. package/src/scripts/lint_design_antipattern_parity.ts +39 -7
  925. package/src/scripts/lint_evidence_artifacts.ts +31 -0
  926. package/src/scripts/lint_example_fences.ts +11 -2
  927. package/src/scripts/lint_ghostwriter_source.ts +42 -10
  928. package/src/scripts/lint_hook_manifest.ts +94 -0
  929. package/src/scripts/lint_marketplace_install_completeness.ts +4 -0
  930. package/src/scripts/lint_mcp_config_security.ts +9 -11
  931. package/src/scripts/lint_plan_risk_register.ts +28 -1
  932. package/src/scripts/lint_positioning.ts +4 -4
  933. package/src/scripts/lint_provenance.ts +1 -0
  934. package/src/scripts/lint_roadmap_blockers.ts +65 -4
  935. package/src/scripts/lint_roadmap_complexity.ts +98 -0
  936. package/src/scripts/lint_skill_link_reach.ts +251 -9
  937. package/src/scripts/lint_skill_procedures.ts +252 -0
  938. package/src/scripts/lint_skill_scripts_readonly.ts +12 -1
  939. package/src/scripts/lint_subagent_determinism.ts +14 -1
  940. package/src/scripts/lint_ticked_unmet_criteria.ts +300 -21
  941. package/src/scripts/mcp_registry_submit.sh +2 -2
  942. package/src/scripts/mcp_server/consumer_tool_catalog.json +4 -4
  943. package/src/scripts/mcp_server/suggest_skill.ts +89 -4
  944. package/src/scripts/mcp_server/tools.ts +2 -33
  945. package/src/scripts/measure_skill_ranker_baseline.ts +203 -5
  946. package/src/scripts/measure_turn_end_gate.ts +61 -1
  947. package/src/scripts/merge_clearance.ts +225 -0
  948. package/src/scripts/migrate_command_suggestions.ts +1 -1
  949. package/src/scripts/network_sources.ts +236 -0
  950. package/src/scripts/no_go_deny_rows.ts +225 -0
  951. package/src/scripts/orchestration_record.ts +15 -2
  952. package/src/scripts/plan_test_shards.ts +103 -0
  953. package/src/scripts/pr_url_reminder_hook.ts +10 -0
  954. package/src/scripts/print_required_checks.ts +5 -5
  955. package/src/scripts/probe_depth_shadow.ts +406 -0
  956. package/src/scripts/probe_turnaround.ts +342 -10
  957. package/src/scripts/ratification_subject.ts +176 -0
  958. package/src/scripts/rdp_gate_classify.ts +1 -0
  959. package/src/scripts/rdp_quality_eval.ts +1 -0
  960. package/src/scripts/release.ts +26 -55
  961. package/src/scripts/release_drill.ts +52 -23
  962. package/src/scripts/release_env.ts +37 -0
  963. package/src/scripts/release_publication.ts +11 -1
  964. package/src/scripts/report_consumer_gate_reach.ts +233 -0
  965. package/src/scripts/report_merge_gate_load.ts +295 -0
  966. package/src/scripts/report_project_contract.ts +123 -0
  967. package/src/scripts/report_reducible_classes.ts +342 -0
  968. package/src/scripts/report_required_checks_drift.ts +5 -3
  969. package/src/scripts/report_skill_host_census.ts +199 -0
  970. package/src/scripts/report_standing_payload_by_host.ts +7 -7
  971. package/src/scripts/retro.ts +758 -0
  972. package/src/scripts/retro_facts.ts +575 -0
  973. package/src/scripts/retro_queue.ts +739 -0
  974. package/src/scripts/retro_session_facts.ts +218 -0
  975. package/src/scripts/retro_sweep.ts +493 -0
  976. package/src/scripts/retro_triage.ts +126 -0
  977. package/src/scripts/roadmap_context.ts +2 -2
  978. package/src/scripts/roadmap_drain_queue.ts +601 -0
  979. package/src/scripts/run_supervise.ts +24 -2
  980. package/src/scripts/schemas/agent-settings.schema.json +0 -16
  981. package/src/scripts/schemas/command.schema.json +3 -3
  982. package/src/scripts/schemas/review-findings.schema.json +8 -0
  983. package/src/scripts/schemas/skill.schema.json +7 -6
  984. package/src/scripts/schemas/subagent.schema.json +33 -2
  985. package/src/scripts/score_skill_selection.ts +5 -2
  986. package/src/scripts/second_brain_retrieval.ts +1 -0
  987. package/src/scripts/second_brain_run.ts +1 -0
  988. package/src/scripts/self_repair_cli.ts +563 -87
  989. package/src/scripts/self_review_gate.ts +59 -4
  990. package/src/scripts/session_register_hook.ts +91 -4
  991. package/src/scripts/sessions_cli.ts +100 -5
  992. package/src/scripts/skill_collision_clusters.ts +1 -1
  993. package/src/scripts/skill_tools/score_skill_relevance.ts +31 -2
  994. package/src/scripts/skill_trigger_eval.ts +4 -2
  995. package/src/scripts/source_adapters.ts +183 -0
  996. package/src/scripts/step_receipt.ts +100 -0
  997. package/src/scripts/sync_pr_branch.ts +4 -0
  998. package/src/scripts/test_council_qualification.ts +1 -1
  999. package/src/scripts/trigger_eval_grandfather.json +3 -49
  1000. package/src/scripts/trigger_eval_rotation.ts +31 -3
  1001. package/src/scripts/ui_conformance_probe.ts +405 -1
  1002. package/src/scripts/update_counts.ts +230 -11
  1003. package/src/scripts/update_invite_hook.ts +245 -0
  1004. package/src/scripts/update_notice_hook.ts +298 -0
  1005. package/src/scripts/validate_frontmatter.ts +85 -0
  1006. package/src/scripts/worker_reuse_shadow_report.ts +121 -0
  1007. package/src/scripts/worktree_cleanup_check.ts +915 -121
  1008. package/src/server/io/yamlIO.ts +2 -2
  1009. package/src/server/schemas/settings.ts +37 -23
  1010. package/src/shared/brandTokenDocument.ts +46 -0
  1011. package/src/shared/brandTokenPaths.ts +43 -0
  1012. package/src/shared/settingsCarveOut.ts +0 -8
  1013. package/src/shared/skillRanking.ts +106 -5
  1014. package/src/shared/userMd/formAdapter.ts +15 -1
  1015. package/src/shared/userMd/schema.ts +22 -0
  1016. package/src/templates/agent-user.md +4 -0
  1017. package/src/templates/agent-user.yml +4 -0
  1018. package/dist/cli-delegate/chunk-4DBG5K7M.js +0 -1123
  1019. package/dist/cli-delegate/chunk-523HCFYO.js +0 -90
  1020. package/dist/cli-delegate/chunk-AL3RZ22D.js +0 -74
  1021. package/dist/cli-delegate/chunk-KB5FZ655.js +0 -208
  1022. package/dist/cli-delegate/chunk-MDPPKQCQ.js +0 -875
  1023. package/dist/cli-delegate/chunk-OAFSJBHH.js +0 -272
  1024. package/dist/ui/assets/index-C3djEJah.js +0 -23
  1025. package/src/scripts/_lib/continuation_ladder.ts +0 -335
  1026. package/src/scripts/hooks/run_continuation_hook.ts +0 -1524
@@ -1,34 +1,39 @@
1
1
  import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
2
  import {
3
3
  THIN_ENTRY_MARKER,
4
+ TIER_TO_CLAUDE_MODEL,
4
5
  readRecentEntries
5
- } from "./chunk-6YQC2HLF.js";
6
+ } from "./chunk-JHMMWNJ2.js";
7
+ import "./chunk-LF2KKJ4Q.js";
6
8
  import {
7
9
  detectToolPresence
8
10
  } from "./chunk-A4QJ6ENT.js";
9
11
  import {
10
12
  NO_RED_EVIDENCE_REASON,
13
+ RENDER_REL,
11
14
  deriveSessionKey,
12
15
  describeRecordFinding,
13
16
  foldRefusal,
14
17
  foldShadow,
18
+ hasInstrumentGap,
15
19
  hasRedThenGreen,
16
- isAssetRenderCommand,
17
20
  isCiPoll,
21
+ isPureRender,
18
22
  isVacuousOutput,
19
23
  isVerificationAttempt,
20
24
  parseRecord,
21
25
  parseShadowRecord,
22
26
  pendingCount,
27
+ readAssetRenderRecords,
23
28
  readInstallBoundary,
24
29
  readRunEvidence,
25
30
  readTurnRunState,
31
+ recordedManifest,
26
32
  sessionRefusalFile,
27
33
  sessionShadowFile,
28
34
  shadowSetBy,
29
- statePathFor,
30
- validateAssumption
31
- } from "./chunk-TMWYUOK4.js";
35
+ statePathFor
36
+ } from "./chunk-2CX7NWRB.js";
32
37
  import {
33
38
  LexicalIndex,
34
39
  isSqliteAvailableSync,
@@ -43,7 +48,6 @@ import {
43
48
  _classify,
44
49
  _collect_manifest_entries,
45
50
  _foreign_records,
46
- _is_global_only_consumer,
47
51
  _jsonDumpsIndentAscii,
48
52
  _resolve_project_root,
49
53
  _run_checks,
@@ -52,25 +56,38 @@ import {
52
56
  censusRuleDir,
53
57
  comparePair,
54
58
  frontmatterPaths,
59
+ openRecordStats,
55
60
  proseEqual,
56
61
  resolveSessionRole,
57
62
  splitFrontmatter
58
- } from "./chunk-5GPULQBE.js";
59
- import "./chunk-FTAISGDQ.js";
60
- import "./chunk-6V6TA25H.js";
63
+ } from "./chunk-CAL76ADI.js";
64
+ import {
65
+ _is_global_only_consumer
66
+ } from "./chunk-2Y5AMLMY.js";
61
67
  import "./chunk-ROYYTEZU.js";
62
68
  import "./chunk-BTWUYDGN.js";
69
+ import "./chunk-UUYEKXKR.js";
70
+ import "./chunk-FTAISGDQ.js";
71
+ import "./chunk-5VO3RTMV.js";
72
+ import "./chunk-6V6TA25H.js";
73
+ import "./chunk-AX3U3UWJ.js";
63
74
  import {
64
75
  atomicAppendLine,
65
76
  probeHostCapabilities
66
- } from "./chunk-MDPPKQCQ.js";
67
- import "./chunk-DMSZHXZS.js";
77
+ } from "./chunk-GOMILC3O.js";
78
+ import "./chunk-7DRWULEQ.js";
68
79
  import "./chunk-ULQRUR23.js";
69
80
  import {
70
- hardenedSpawnEnv,
81
+ hardenedSpawnEnv
82
+ } from "./chunk-I4KJYVPB.js";
83
+ import {
84
+ EXIT_ALLOW,
85
+ EXIT_BLOCK,
86
+ EXIT_WARN,
71
87
  projectStoreSlug
72
- } from "./chunk-OAFSJBHH.js";
88
+ } from "./chunk-FKYZOWVD.js";
73
89
  import "./chunk-IAYTIIQW.js";
90
+ import "./chunk-PV7S5DPJ.js";
74
91
  import "./chunk-LQOCRFWT.js";
75
92
  import {
76
93
  atomic_write_json,
@@ -82,35 +99,42 @@ import {
82
99
  prune_stale_session_states,
83
100
  session_state_file
84
101
  } from "./chunk-7HKRE54K.js";
85
- import "./chunk-F3QDG2GT.js";
102
+ import {
103
+ load_agent_settings
104
+ } from "./chunk-XLY5G3CM.js";
105
+ import "./chunk-2SFOOFJJ.js";
106
+ import "./chunk-FIEEOH5C.js";
107
+ import "./chunk-E6XNBVE4.js";
108
+ import {
109
+ artefact_roots
110
+ } from "./chunk-YCU3TIXH.js";
86
111
  import "./chunk-DEIV7XP7.js";
112
+ import "./chunk-J2SJZICO.js";
87
113
  import {
88
114
  manifest_path,
89
115
  read_manifest
90
- } from "./chunk-OKJUIAPS.js";
91
- import "./chunk-WQWXGIWB.js";
92
- import "./chunk-KB5FZ655.js";
116
+ } from "./chunk-4E2W63DA.js";
117
+ import {
118
+ parseRouteFields,
119
+ resolveRouteTransport
120
+ } from "./chunk-M6CRG5O6.js";
93
121
  import "./chunk-MWRD5YOH.js";
94
- import "./chunk-JQOM7TTM.js";
122
+ import "./chunk-BMGUGSY6.js";
123
+ import {
124
+ readHookStdin
125
+ } from "./chunk-RAXQOETZ.js";
126
+ import "./chunk-IDAOTDPE.js";
95
127
  import {
96
128
  DeadScopeError,
97
129
  assertScanned,
98
130
  reportScanned
99
131
  } from "./chunk-I3EIN2YG.js";
100
- import {
101
- readHookStdin
102
- } from "./chunk-F7DQWYR5.js";
103
132
  import {
104
133
  require_dist
105
134
  } from "./chunk-OY53J6II.js";
106
- import "./chunk-LF2KKJ4Q.js";
107
135
  import {
108
- load_agent_settings
109
- } from "./chunk-H76PHZBI.js";
110
- import {
111
- artefact_roots
112
- } from "./chunk-YCU3TIXH.js";
113
- import "./chunk-T6BP34WI.js";
136
+ resolve_with_fallback
137
+ } from "./chunk-T6BP34WI.js";
114
138
  import {
115
139
  resolvePackageRoot
116
140
  } from "./chunk-MCJYCQPF.js";
@@ -120,12 +144,12 @@ import {
120
144
 
121
145
  // src/scripts/_cli/cmd_conformance.ts
122
146
  var YAML = __toESM(require_dist(), 1);
123
- import * as fs21 from "node:fs";
147
+ import * as fs22 from "node:fs";
124
148
  import * as os7 from "node:os";
125
149
  import * as path19 from "node:path";
126
150
  import process5 from "node:process";
127
151
  import { spawnSync as spawnSync4 } from "node:child_process";
128
- import { fileURLToPath as fileURLToPath14, pathToFileURL as pathToFileURL14 } from "node:url";
152
+ import { fileURLToPath as fileURLToPath13, pathToFileURL as pathToFileURL13 } from "node:url";
129
153
 
130
154
  // src/scripts/router_target_paths.mjs
131
155
  var ROUTE_TARGET_TEMPLATES = Object.freeze({
@@ -153,18 +177,18 @@ function routeTargetPathsPosix(target) {
153
177
  }
154
178
 
155
179
  // src/scripts/report_conformance_funnel.ts
156
- import * as fs20 from "node:fs";
180
+ import * as fs21 from "node:fs";
157
181
  import * as os6 from "node:os";
158
182
  import * as path18 from "node:path";
159
183
  import process4 from "node:process";
160
- import { fileURLToPath as fileURLToPath13, pathToFileURL as pathToFileURL13 } from "node:url";
184
+ import { fileURLToPath as fileURLToPath12, pathToFileURL as pathToFileURL12 } from "node:url";
161
185
 
162
186
  // src/scripts/conformance_scan.ts
163
- import { createHash as createHash5 } from "node:crypto";
164
- import fs16 from "node:fs";
187
+ import { createHash as createHash4 } from "node:crypto";
188
+ import fs17 from "node:fs";
165
189
  import os2 from "node:os";
166
190
  import path14 from "node:path";
167
- import { fileURLToPath as fileURLToPath9, pathToFileURL as pathToFileURL9 } from "node:url";
191
+ import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL8 } from "node:url";
168
192
 
169
193
  // src/scripts/_lib/transcript_entry.ts
170
194
  function _isObject(v) {
@@ -211,8 +235,9 @@ import { fileURLToPath, pathToFileURL } from "node:url";
211
235
  // src/scripts/_lib/prompt_shape.ts
212
236
  function isSyntheticPrompt(prompt) {
213
237
  const head = prompt.trimStart().slice(0, 400);
214
- return head.startsWith("[SYSTEM NOTIFICATION - NOT USER INPUT]") || head.startsWith("<task-notification>") || head.startsWith("<system-reminder>") || head.startsWith("<local-command-caveat>") || head.startsWith("<agent-message") || head.startsWith("Your claude.ai usage limit has reset") || /^\[SYSTEM NOTIFICATION\b/.test(head);
238
+ return head.startsWith("[SYSTEM NOTIFICATION - NOT USER INPUT]") || head.startsWith("<task-notification>") || head.startsWith("<system-reminder>") || head.startsWith("<local-command-caveat>") || head.startsWith("<agent-message") || head.startsWith("Your claude.ai usage limit has reset") || /^\[SYSTEM NOTIFICATION\b/.test(head) || AGENT_MESSAGE_FRAME.test(head);
215
239
  }
240
+ var AGENT_MESSAGE_FRAME = /^Another Claude session sent a message:\s*\n\s*<(?:agent-message|cross-session-message)\b/;
216
241
  var DOCUMENT_HEAD = /^\s*(#{1,6}\s|-{3,}\s*$|={3,}\s*$|<[A-Za-z][\w-]*>\s*$)/;
217
242
  function humanAuthoredLead(text) {
218
243
  const kept = [];
@@ -263,8 +288,8 @@ function stripInjectedRegions(text) {
263
288
  }
264
289
 
265
290
  // src/scripts/language_mirror_hook.ts
266
- var EXIT_ALLOW = 0;
267
- var EXIT_WARN = 2;
291
+ var EXIT_ALLOW2 = 0;
292
+ var EXIT_WARN2 = 2;
268
293
  var STATE_FILE = path.join("agents", "state", "language-mirror.json");
269
294
  var STATE_DIR = path.join("agents", "state", "language-mirror");
270
295
  var STATE_RETENTION_DAYS = 7;
@@ -464,24 +489,24 @@ function _clearPinLost(consumer_root, session_id) {
464
489
  }
465
490
  function _reEmitAfterCompaction(consumer_root, session_id, write_json = atomic_write_json) {
466
491
  if (!hasStableSessionId(session_id)) {
467
- return EXIT_ALLOW;
492
+ return EXIT_ALLOW2;
468
493
  }
469
494
  if (!_pinLost(consumer_root, session_id)) {
470
- return EXIT_ALLOW;
495
+ return EXIT_ALLOW2;
471
496
  }
472
- return _withToolWriteLock(consumer_root, session_id, EXIT_ALLOW, () => {
497
+ return _withToolWriteLock(consumer_root, session_id, EXIT_ALLOW2, () => {
473
498
  const previous = _loadState(path.join(consumer_root, statePathFor2(session_id)));
474
499
  const language = previous.language;
475
500
  const source = previous.source === "system-locale" ? "system-locale" : "prompt";
476
501
  _clearPinLost(consumer_root, session_id);
477
502
  if (language !== "de" && language !== "en") {
478
- return EXIT_ALLOW;
503
+ return EXIT_ALLOW2;
479
504
  }
480
505
  if (!_ownsPin(previous, session_id)) {
481
- return EXIT_ALLOW;
506
+ return EXIT_ALLOW2;
482
507
  }
483
508
  if (!_resetDistance(consumer_root, previous, session_id, write_json)) {
484
- return EXIT_ALLOW;
509
+ return EXIT_ALLOW2;
485
510
  }
486
511
  process.stdout.write(
487
512
  `${JSON.stringify({
@@ -491,7 +516,7 @@ function _reEmitAfterCompaction(consumer_root, session_id, write_json = atomic_w
491
516
  })}
492
517
  `
493
518
  );
494
- return EXIT_WARN;
519
+ return EXIT_WARN2;
495
520
  });
496
521
  }
497
522
  function _pruneLegacyState(consumer_root) {
@@ -571,19 +596,19 @@ function _resetDistance(consumer_root, expected, session_id, write_json = atomic
571
596
  }
572
597
  function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_write_json) {
573
598
  if (is_replay_mode()) {
574
- return EXIT_ALLOW;
599
+ return EXIT_ALLOW2;
575
600
  }
576
601
  if (!hasStableSessionId(session_id)) {
577
- return EXIT_ALLOW;
602
+ return EXIT_ALLOW2;
578
603
  }
579
- return _withToolWriteLock(consumer_root, session_id, EXIT_ALLOW, () => {
604
+ return _withToolWriteLock(consumer_root, session_id, EXIT_ALLOW2, () => {
580
605
  const previous = _loadState(path.join(consumer_root, statePathFor2(session_id)));
581
606
  const language = previous.language;
582
607
  if (language !== "de" && language !== "en") {
583
- return EXIT_ALLOW;
608
+ return EXIT_ALLOW2;
584
609
  }
585
610
  if (!_ownsPin(previous, session_id)) {
586
- return EXIT_ALLOW;
611
+ return EXIT_ALLOW2;
587
612
  }
588
613
  const seen = typeof previous.tool_calls_since_pin === "number" && previous.tool_calls_since_pin >= 0 ? previous.tool_calls_since_pin : 0;
589
614
  const advanced = seen + 1;
@@ -596,10 +621,10 @@ function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_wri
596
621
  write_json
597
622
  );
598
623
  if (!due) {
599
- return EXIT_ALLOW;
624
+ return EXIT_ALLOW2;
600
625
  }
601
626
  if (!written) {
602
- return EXIT_ALLOW;
627
+ return EXIT_ALLOW2;
603
628
  }
604
629
  const source = previous.source === "system-locale" ? "system-locale" : "prompt";
605
630
  process.stdout.write(
@@ -610,7 +635,7 @@ function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_wri
610
635
  })}
611
636
  `
612
637
  );
613
- return EXIT_WARN;
638
+ return EXIT_WARN2;
614
639
  });
615
640
  }
616
641
  function _onToolUse(consumer_root, session_id, write_json = atomic_write_json) {
@@ -628,24 +653,24 @@ function run(stdin_text, options) {
628
653
  envelope = decoded;
629
654
  }
630
655
  } catch {
631
- return EXIT_ALLOW;
656
+ return EXIT_ALLOW2;
632
657
  }
633
658
  }
634
659
  const payload = _isObject2(envelope["payload"]) ? envelope["payload"] : envelope;
635
660
  const event = typeof envelope["event"] === "string" ? envelope["event"] : "";
636
661
  if (event === "pre_compact") {
637
662
  _setPinLost(options.consumer_root, _sessionId(envelope));
638
- return EXIT_ALLOW;
663
+ return EXIT_ALLOW2;
639
664
  }
640
665
  if (event === "post_tool_use") {
641
666
  return _onToolUse(options.consumer_root, _sessionId(envelope), options.write_json);
642
667
  }
643
668
  const prompt = _extractPrompt(payload);
644
669
  if (!prompt) {
645
- return EXIT_ALLOW;
670
+ return EXIT_ALLOW2;
646
671
  }
647
672
  if (isSyntheticPrompt(prompt)) {
648
- return EXIT_ALLOW;
673
+ return EXIT_ALLOW2;
649
674
  }
650
675
  const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
651
676
  const stateful = hasStableSessionId(session_id);
@@ -683,9 +708,9 @@ function run(stdin_text, options) {
683
708
  `${JSON.stringify({ decision: "warn", reason: noticeText(effective, effectiveSource), additional_context: pinText(effective, effectiveSource) })}
684
709
  `
685
710
  );
686
- return EXIT_WARN;
711
+ return EXIT_WARN2;
687
712
  }
688
- return EXIT_ALLOW;
713
+ return EXIT_ALLOW2;
689
714
  }
690
715
  function _errText(err) {
691
716
  const t = err instanceof Error ? err.message : String(err);
@@ -872,7 +897,7 @@ function extractObjects(op, text) {
872
897
  }
873
898
 
874
899
  // src/scripts/git_authorization_hook.ts
875
- var EXIT_ALLOW2 = 0;
900
+ var EXIT_ALLOW3 = 0;
876
901
  var STATE_FILE2 = path2.join("agents", "state", "git-authorization.json");
877
902
  var STATE_DIR2 = path2.join("agents", "state", "git-authorization");
878
903
  var PENDING_DIR = path2.join("agents", "state", "git-authorization-pending");
@@ -1432,7 +1457,7 @@ function run2(stdin_text, options) {
1432
1457
  envelope = decoded;
1433
1458
  }
1434
1459
  } catch {
1435
- return EXIT_ALLOW2;
1460
+ return EXIT_ALLOW3;
1436
1461
  }
1437
1462
  }
1438
1463
  const payload = _isObject3(envelope["payload"]) ? envelope["payload"] : envelope;
@@ -1445,11 +1470,11 @@ function run2(stdin_text, options) {
1445
1470
  }
1446
1471
  }
1447
1472
  if (!prompt) {
1448
- return EXIT_ALLOW2;
1473
+ return EXIT_ALLOW3;
1449
1474
  }
1450
1475
  const session = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
1451
1476
  if (!humanTypedThisTurn(prompt)) {
1452
- return EXIT_ALLOW2;
1477
+ return EXIT_ALLOW3;
1453
1478
  }
1454
1479
  const { authorized, evidence } = classifyAuthorization(prompt);
1455
1480
  const pending = takePending(options.consumer_root, session, Date.now());
@@ -1490,7 +1515,7 @@ function run2(stdin_text, options) {
1490
1515
  `
1491
1516
  );
1492
1517
  }
1493
- return EXIT_ALLOW2;
1518
+ return EXIT_ALLOW3;
1494
1519
  }
1495
1520
  function main2(argv) {
1496
1521
  const args = argv ?? process.argv.slice(2);
@@ -1948,9 +1973,9 @@ var COMMAND_OBJECTS = {
1948
1973
  };
1949
1974
 
1950
1975
  // src/scripts/hooks/turn_end_gate_hook.ts
1951
- import * as fs13 from "node:fs";
1952
- import * as path11 from "node:path";
1953
- import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL6 } from "node:url";
1976
+ import * as fs12 from "node:fs";
1977
+ import * as path10 from "node:path";
1978
+ import { fileURLToPath as fileURLToPath5, pathToFileURL as pathToFileURL5 } from "node:url";
1954
1979
 
1955
1980
  // src/scripts/check_reply_consistency.ts
1956
1981
  import * as fs3 from "node:fs";
@@ -3284,7 +3309,6 @@ import * as crypto from "node:crypto";
3284
3309
  import * as fs8 from "node:fs";
3285
3310
  import * as path7 from "node:path";
3286
3311
  var EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
3287
- var RENDER_REL = path7.join("agents", "runtime", "state", "render");
3288
3312
  var PLANTED_PREFIXES = [
3289
3313
  "tests/design-artifacts/fixtures/",
3290
3314
  "tests/design-artifacts/scenarios/"
@@ -3339,6 +3363,22 @@ function dischargeFor(manifests, digest) {
3339
3363
  }
3340
3364
  return staticOnly ? "static-only" : null;
3341
3365
  }
3366
+ var TRANSCRIPT_FALLBACK_REASON = "transcript fallback: no readable `post_tool_use` render record exists for this turn \u2014 no live recorder on this host (`agent-config hooks:status`), or a render whose exit status the host did not report \u2014 so the manifest was read under the transcript rule \u2014 an omission check, not an attestation";
3367
+ function recordVerdict(root, abs, digest, records) {
3368
+ let changed = false;
3369
+ for (const r of records) {
3370
+ if (path7.resolve(root, r.file) !== abs || r.file_digest !== digest) continue;
3371
+ const read = recordedManifest(root, r);
3372
+ if (read === null) continue;
3373
+ if ("changed" in read) {
3374
+ changed = true;
3375
+ continue;
3376
+ }
3377
+ const kind = dischargeFor([read.manifest], digest);
3378
+ if (kind !== null) return kind;
3379
+ }
3380
+ return changed ? "the manifest the observed render left has changed since, so it is no longer the record of that render" : "no successful `ui:render --profile asset` of these bytes was observed by the hook this turn with a manifest that discharges them \u2014 a manifest written by any other route discharges nothing";
3381
+ }
3342
3382
  function readSvgObligations(root, inputs) {
3343
3383
  const open = [];
3344
3384
  const discharged = [];
@@ -3358,6 +3398,12 @@ function readSvgObligations(root, inputs) {
3358
3398
  continue;
3359
3399
  }
3360
3400
  const digest = crypto.createHash("sha256").update(bytes).digest("hex");
3401
+ if (Array.isArray(inputs.recorded)) {
3402
+ const verdict = recordVerdict(root, path7.resolve(root, abs), digest, inputs.recorded);
3403
+ if (verdict === "verified" || verdict === "static-only") discharged.push({ file: relPath, kind: verdict });
3404
+ else open.push({ file: relPath, reason: verdict });
3405
+ continue;
3406
+ }
3361
3407
  if (!renderNames(rendered, relPath)) {
3362
3408
  open.push({
3363
3409
  file: relPath,
@@ -3393,12 +3439,6 @@ function renderNames(commands, relPath) {
3393
3439
  return bounded(relPath) || bounded(base);
3394
3440
  });
3395
3441
  }
3396
- function isPureRender(command) {
3397
- if (!isAssetRenderCommand(command)) return false;
3398
- const [head, ...pipes] = command.replace(/^\s*cd\s+[^;&|<>`$\n]+&&\s*/, "").replace(/\s\d?>&\d\b/g, " ").replace(/\s2>\s*\/dev\/null\b/g, " ").split("|");
3399
- if (/[;&<>`\n]|\$\(/.test(head ?? "")) return false;
3400
- return pipes.every((p) => /^\s*(tail|head|grep|jq|cat|less|wc)\b[^;&<>`|]*$/.test(p) && !/\$\(/.test(p));
3401
- }
3402
3442
  function writesRenderDir(command) {
3403
3443
  if (isPureRender(command)) return false;
3404
3444
  const slashed = command.split(path7.sep).join("/");
@@ -3411,7 +3451,8 @@ function writesRenderDir(command) {
3411
3451
  function escapeRe(s) {
3412
3452
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3413
3453
  }
3414
- function openSvgObligation(workspaceRoot, toolCalls) {
3454
+ function openSvgObligation(workspaceRoot, toolCalls, recordedRaw = null) {
3455
+ const recordedRenders = recordedRaw === null || hasInstrumentGap(recordedRaw) ? null : recordedRaw;
3415
3456
  const lastEditOf = /* @__PURE__ */ new Map();
3416
3457
  for (let i = 0; i < toolCalls.length; i += 1) {
3417
3458
  const c = toolCalls[i];
@@ -3438,7 +3479,11 @@ function openSvgObligation(workspaceRoot, toolCalls) {
3438
3479
  });
3439
3480
  let reading;
3440
3481
  try {
3441
- reading = readSvgObligations(workspaceRoot, { edits, renderDirTampered });
3482
+ reading = readSvgObligations(workspaceRoot, {
3483
+ edits,
3484
+ renderDirTampered,
3485
+ recorded: recordedRenders === null ? null : readAssetRenderRecords(recordedRenders)
3486
+ });
3442
3487
  } catch {
3443
3488
  return null;
3444
3489
  }
@@ -3454,7 +3499,7 @@ function openSvgObligation(workspaceRoot, toolCalls) {
3454
3499
  detector: "verification",
3455
3500
  mode: "transcript",
3456
3501
  evidence: first.file,
3457
- reason: `this turn edited an .svg and no render describes it${more} \u2014 ${first.reason}. A bare \`ui:render --profile asset\` that rendered nothing, and a test or lint run over other files, both discharge nothing: the gate reads the render, never the call.`
3502
+ reason: `this turn edited an .svg and no render describes it${more} \u2014 ${first.reason}. A bare \`ui:render --profile asset\` that rendered nothing, and a test or lint run over other files, both discharge nothing: the gate reads the render, never the call.` + (recordedRenders === null ? ` (${TRANSCRIPT_FALLBACK_REASON})` : "")
3458
3503
  };
3459
3504
  }
3460
3505
 
@@ -3512,539 +3557,21 @@ function unwrap(stdin_text, default_platform = "generic") {
3512
3557
  ];
3513
3558
  }
3514
3559
 
3515
- // src/scripts/hooks/subagent_ledger_hook.ts
3516
- import * as crypto2 from "node:crypto";
3517
- import * as fs9 from "node:fs";
3518
- import * as path8 from "node:path";
3519
- import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "node:url";
3520
-
3521
- // src/scripts/_lib/subagent_response.ts
3522
- var MAX_SUMMARY_CHARS = 2e3;
3523
- var MAX_RESPONSE_LINE_CHARS = 240;
3524
- var MAX_RESPONSE_ENTRIES = 40;
3525
- var MAX_ARTIFACT_REF_CHARS = 200;
3526
- var MAX_ENVELOPE_CHARS = 12e3;
3527
- var CONFIDENCE = /* @__PURE__ */ new Set(["low", "medium", "high"]);
3528
- var RESPONSE_REQUIRED_FIELDS = [
3529
- "summary",
3530
- "handoff",
3531
- "confidence",
3532
- "findings",
3533
- "risks"
3534
- ];
3535
- function countContractFields(input) {
3536
- if (input === null || typeof input !== "object") return 0;
3537
- const r = input;
3538
- return RESPONSE_REQUIRED_FIELDS.filter((k) => Object.hasOwn(r, k)).length;
3539
- }
3540
- function validateResponse(input) {
3541
- const errors = [];
3542
- if (input === null || typeof input !== "object") {
3543
- return { valid: false, errors: ["response is not an object"] };
3544
- }
3545
- const r = input;
3546
- if (typeof r.summary !== "string") errors.push("summary missing or not a string");
3547
- if (typeof r.handoff !== "string") errors.push("handoff missing or not a string");
3548
- if (!CONFIDENCE.has(r.confidence)) errors.push(`confidence must be low|medium|high (got ${String(r.confidence)})`);
3549
- if (!Array.isArray(r.findings)) errors.push("findings missing or not an array");
3550
- if (!Array.isArray(r.risks)) errors.push("risks missing or not an array");
3551
- if (Array.isArray(r.findings)) {
3552
- for (const [i, f] of r.findings.entries()) {
3553
- if (!f || typeof f.title !== "string") errors.push(`finding[${i}] missing title`);
3554
- const refs = f?.evidence_refs;
3555
- if (refs && refs.some((x) => typeof x !== "string" || x.includes("\n"))) {
3556
- errors.push(`finding[${i}] evidence_refs must be ref tokens, not bodies`);
3557
- }
3558
- }
3559
- }
3560
- if (r.assumptions !== void 0) {
3561
- if (!Array.isArray(r.assumptions)) {
3562
- errors.push("assumptions must be an array of {statement, basis, epistemic_state}");
3563
- } else {
3564
- for (const [i, a] of r.assumptions.entries()) {
3565
- errors.push(...validateAssumption(a, `assumptions[${i}]`));
3566
- }
3567
- }
3568
- }
3569
- if (typeof r.summary === "string" && r.summary.length > MAX_SUMMARY_CHARS) {
3570
- errors.push(`summary is ${r.summary.length} chars (max ${MAX_SUMMARY_CHARS}) \u2014 the envelope carries a bounded summary; the full result belongs on disk (artifact_paths)`);
3571
- }
3572
- if (typeof r.handoff === "string" && r.handoff.length > MAX_RESPONSE_LINE_CHARS) {
3573
- errors.push(`handoff is ${r.handoff.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
3574
- }
3575
- for (const [key, arr] of [
3576
- ["findings", r.findings],
3577
- ["risks", r.risks],
3578
- ["artifact_paths", r.artifact_paths]
3579
- ]) {
3580
- if (Array.isArray(arr) && arr.length > MAX_RESPONSE_ENTRIES) {
3581
- errors.push(`${key} carries ${arr.length} entries (max ${MAX_RESPONSE_ENTRIES}) \u2014 an envelope is a handoff, not a transcript`);
3582
- }
3583
- }
3584
- if (Array.isArray(r.risks)) {
3585
- for (const [i, risk] of r.risks.entries()) {
3586
- if (typeof risk === "string" && risk.length > MAX_RESPONSE_LINE_CHARS) {
3587
- errors.push(`risks[${i}] is ${risk.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
3588
- }
3589
- }
3590
- }
3591
- if (Array.isArray(r.findings)) {
3592
- for (const [i, f] of r.findings.entries()) {
3593
- if (f && typeof f.title === "string" && f.title.length > MAX_RESPONSE_LINE_CHARS) {
3594
- errors.push(`finding[${i}] title is ${f.title.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
3595
- }
3596
- }
3597
- }
3598
- if (r.artifact_paths !== void 0) {
3599
- if (!Array.isArray(r.artifact_paths)) {
3600
- errors.push("artifact_paths must be an array of path ref tokens");
3601
- } else {
3602
- for (const [i, p] of r.artifact_paths.entries()) {
3603
- if (typeof p !== "string" || p.includes("\n") || p.length > MAX_ARTIFACT_REF_CHARS) {
3604
- errors.push(`artifact_paths[${i}] must be a single-line path ref \u2264 ${MAX_ARTIFACT_REF_CHARS} chars`);
3605
- }
3606
- }
3607
- }
3608
- }
3609
- try {
3610
- const serialized = JSON.stringify(input);
3611
- if (serialized.length > MAX_ENVELOPE_CHARS) {
3612
- errors.push(`envelope serializes to ${serialized.length} chars (max ${MAX_ENVELOPE_CHARS}) \u2014 move content to disk and reference it via artifact_paths`);
3613
- }
3614
- } catch {
3615
- errors.push("envelope is not JSON-serializable");
3616
- }
3617
- return { valid: errors.length === 0, errors };
3618
- }
3619
-
3620
- // src/scripts/hooks/exit_codes.ts
3621
- var EXIT_ALLOW3 = 0;
3622
- var EXIT_BLOCK = 1;
3623
- var EXIT_WARN2 = 2;
3624
- var EXIT_ERROR = 3;
3625
- var EXIT_CODES = Object.freeze([
3626
- Object.freeze({
3627
- code: EXIT_ALLOW3,
3628
- name: "allow",
3629
- meaning: "no objection; the dispatcher passes the call through",
3630
- owner: "every concern \u2014 the default verdict",
3631
- authorizedBy: "nothing; allowing needs no authority"
3632
- }),
3633
- Object.freeze({
3634
- code: EXIT_BLOCK,
3635
- name: "block",
3636
- meaning: "refuse the call; the dispatcher lowers this onto the host deny channel",
3637
- owner: "a concern declared `severity: blocking` in hook_manifest.yaml",
3638
- authorizedBy: "the manifest entry plus its row in the BLOCKING_ALLOWLIST of tests/hooks/concern_severity.test.ts \u2014 an advisory concern emitting this is downgraded to warn by dispatch_hook._is_advisory"
3639
- }),
3640
- Object.freeze({
3641
- code: EXIT_WARN2,
3642
- name: "warn",
3643
- meaning: "advisory; the dispatcher exits 0 and surfaces the reason",
3644
- owner: "any concern",
3645
- authorizedBy: "nothing; warning is the ceiling for an advisory concern and is always available to a blocking one"
3646
- }),
3647
- Object.freeze({
3648
- code: EXIT_ERROR,
3649
- name: "error",
3650
- meaning: "the concern crashed, timed out, or could not decide \u2014 any rc >= 3. The dispatcher resolves it by the concern`s declared severity, never by the number itself",
3651
- owner: "no concern emits this on purpose; the runtime does",
3652
- authorizedBy: "hook_manifest.yaml `severity` alone \u2014 blocking refuses, anything else fails open; `fail_closed` is no longer read on this branch. See docs/contracts/hook-architecture-v1.md \xA7 Exit-code semantics"
3653
- })
3654
- ]);
3655
-
3656
- // src/scripts/hooks/subagent_ledger_hook.ts
3657
- function isObject2(v) {
3658
- return typeof v === "object" && v !== null && !Array.isArray(v);
3659
- }
3660
- var LEDGER_DIR = path8.join("agents", "runtime", "state", "subagent-ledger");
3661
- var OPEN_SUBDIR = "open";
3662
- var OPEN_RECORD_TTL_MS = 24 * 60 * 60 * 1e3;
3663
- function refFor(agentId) {
3664
- return crypto2.createHash("sha256").update(agentId, "utf8").digest("hex").slice(0, 12);
3665
- }
3666
- function unwrapPayload(envelope) {
3667
- const inner = envelope["payload"];
3668
- return isObject2(inner) ? inner : envelope;
3669
- }
3670
- function str(payload, ...keys) {
3671
- for (const k of keys) {
3672
- const v = payload[k];
3673
- if (typeof v === "string" && v) return v;
3674
- }
3675
- return null;
3676
- }
3677
- function extractParentId(payload, ownId) {
3678
- const explicit = str(payload, "parent_agent_id", "parentAgentId");
3679
- if (explicit) return explicit;
3680
- const session = payload["session"];
3681
- if (isObject2(session)) {
3682
- const sessionAgent = str(session, "agent_id", "agentId");
3683
- if (sessionAgent && sessionAgent !== ownId) return sessionAgent;
3684
- }
3685
- return null;
3686
- }
3687
- function classifyEnvelope(message) {
3688
- if (message === null || !message.trim()) {
3689
- return { verdict: "no_message", error_count: 0, field_hits: 0 };
3690
- }
3691
- const candidates = _jsonObjectCandidates(message);
3692
- if (candidates.length === 0) return { verdict: "no_envelope", error_count: 0, field_hits: 0 };
3693
- let best = null;
3694
- for (const candidate of candidates) {
3695
- const result = validateResponse(candidate);
3696
- const fieldHits = countContractFields(candidate);
3697
- if (result.valid) return { verdict: "ok", error_count: 0, field_hits: fieldHits };
3698
- if (best === null || fieldHits > best.field_hits) {
3699
- best = {
3700
- verdict: fieldHits === 0 ? "foreign_object" : "fail",
3701
- error_count: result.errors.length,
3702
- field_hits: fieldHits
3703
- };
3704
- }
3705
- }
3706
- return best ?? { verdict: "no_envelope", error_count: 0, field_hits: 0 };
3707
- }
3708
- function _jsonObjectCandidates(message) {
3709
- const texts = [];
3710
- for (const match of message.matchAll(/^[ \t]*```[ \t]*(?:json)?[ \t]*\r?\n([\s\S]*?)^[ \t]*```/gm)) {
3711
- if (match[1]) texts.push(match[1]);
3712
- }
3713
- let depth = 0;
3714
- let start = -1;
3715
- let inString = false;
3716
- let escaped = false;
3717
- for (let i = 0; i < message.length; i++) {
3718
- const ch = message[i];
3719
- if (inString) {
3720
- if (escaped) escaped = false;
3721
- else if (ch === "\\") escaped = true;
3722
- else if (ch === '"') inString = false;
3723
- continue;
3724
- }
3725
- if (ch === '"') inString = true;
3726
- else if (ch === "{") {
3727
- if (depth === 0) start = i;
3728
- depth++;
3729
- } else if (ch === "}") {
3730
- if (depth > 0) {
3731
- depth--;
3732
- if (depth === 0 && start !== -1) {
3733
- texts.push(message.slice(start, i + 1));
3734
- start = -1;
3735
- }
3736
- }
3737
- }
3738
- }
3739
- const out = [];
3740
- for (const text of texts) {
3741
- try {
3742
- const parsed = JSON.parse(text.trim());
3743
- if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) out.push(parsed);
3744
- } catch {
3745
- }
3746
- }
3747
- return out;
3748
- }
3749
- function openDir(root) {
3750
- return path8.join(root, LEDGER_DIR, OPEN_SUBDIR);
3751
- }
3752
- function openFile(root, ref) {
3753
- return path8.join(openDir(root), `${ref}.json`);
3754
- }
3755
- var DEPTH_BASES = /* @__PURE__ */ new Set(["observed", "asserted-parent", "assumed-root"]);
3756
- function _asOpenRecord(value, expectedRef) {
3757
- if (!isObject2(value)) return null;
3758
- const ref = value["ref"];
3759
- if (typeof ref !== "string" || ref !== expectedRef) return null;
3760
- if (typeof value["started_at"] !== "string") return null;
3761
- if (typeof value["depth"] !== "number" || !Number.isFinite(value["depth"])) return null;
3762
- if (typeof value["depth_basis"] !== "string" || !DEPTH_BASES.has(value["depth_basis"])) return null;
3763
- const agentType = value["agent_type"];
3764
- const parentRef = value["parent_ref"];
3765
- const sessionId = value["session_id"];
3766
- return {
3767
- ref,
3768
- agent_type: typeof agentType === "string" ? agentType : null,
3769
- started_at: value["started_at"],
3770
- parent_ref: typeof parentRef === "string" ? parentRef : null,
3771
- depth: value["depth"],
3772
- depth_basis: value["depth_basis"],
3773
- session_id: typeof sessionId === "string" ? sessionId : null
3774
- };
3775
- }
3776
- function readOpenRecords(root) {
3777
- const out = /* @__PURE__ */ new Map();
3778
- let names;
3779
- try {
3780
- names = fs9.readdirSync(openDir(root));
3781
- } catch {
3782
- return out;
3783
- }
3784
- for (const name of names) {
3785
- if (!name.endsWith(".json")) continue;
3786
- const expectedRef = name.slice(0, -".json".length);
3787
- try {
3788
- const raw = fs9.readFileSync(path8.join(openDir(root), name), "utf8");
3789
- const rec = _asOpenRecord(JSON.parse(raw), expectedRef);
3790
- if (rec) out.set(rec.ref, rec);
3791
- } catch {
3792
- }
3793
- }
3794
- return out;
3795
- }
3796
- function resolveDepth(parentRef, open) {
3797
- if (parentRef === null) return { depth: 1, depth_basis: "assumed-root" };
3798
- const parent = open.get(parentRef);
3799
- if (!parent) return { depth: 2, depth_basis: "asserted-parent" };
3800
- return { depth: parent.depth + 1, depth_basis: "observed" };
3801
- }
3802
- function ledgerFileFor2(root, ts) {
3803
- return path8.join(root, LEDGER_DIR, `${ts.slice(0, 7)}.jsonl`);
3804
- }
3805
- function appendLedgerLine(root, ts, line) {
3806
- if (is_replay_mode()) return;
3807
- const file = ledgerFileFor2(root, ts);
3808
- fs9.mkdirSync(path8.dirname(file), { recursive: true });
3809
- fs9.appendFileSync(file, `${JSON.stringify(line)}
3810
- `, "utf8");
3811
- }
3812
- var WALL_CLOCK_ARMS_MS = [
3813
- { label: "5m", ms: 5 * 60 * 1e3 },
3814
- { label: "15m", ms: 15 * 60 * 1e3 },
3815
- { label: "30m", ms: 30 * 60 * 1e3 },
3816
- { label: "2h", ms: 2 * 60 * 60 * 1e3 }
3817
- ];
3818
- function armsExceeded(elapsedMs) {
3819
- if (elapsedMs === null || !Number.isFinite(elapsedMs)) return [];
3820
- return WALL_CLOCK_ARMS_MS.filter((a) => elapsedMs >= a.ms).map((a) => a.label);
3821
- }
3822
- function openRecordStats(root, nowMs = Date.now()) {
3823
- const ledgerPresent = fs9.existsSync(path8.join(root, LEDGER_DIR));
3824
- const open = readOpenRecords(root);
3825
- let maxDepth = 0;
3826
- let counted = 0;
3827
- let stale = 0;
3828
- for (const rec of open.values()) {
3829
- const started = Date.parse(rec.started_at);
3830
- const isStale = Number.isFinite(started) && nowMs - started >= OPEN_RECORD_TTL_MS;
3831
- if (isStale) {
3832
- stale++;
3833
- continue;
3834
- }
3835
- counted++;
3836
- if (rec.depth > maxDepth) maxDepth = rec.depth;
3837
- }
3838
- return {
3839
- open_count: counted,
3840
- max_depth: maxDepth,
3841
- stale_excluded: stale,
3842
- ledger_present: ledgerPresent
3843
- };
3844
- }
3845
- function writeOpenRecord(root, rec) {
3846
- atomic_write_json(openFile(root, rec.ref), rec);
3847
- }
3848
- function removeOpenRecord(root, ref) {
3849
- if (is_replay_mode()) return;
3850
- try {
3851
- fs9.unlinkSync(openFile(root, ref));
3852
- } catch {
3853
- }
3854
- }
3855
- function countOpen(root) {
3856
- try {
3857
- return fs9.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
3858
- } catch {
3859
- return 0;
3860
- }
3861
- }
3862
- function reapStaleOpenRecords(root, nowIso) {
3863
- const now = Date.parse(nowIso);
3864
- if (!Number.isFinite(now)) return 0;
3865
- let reaped = 0;
3866
- for (const rec of readOpenRecords(root).values()) {
3867
- const started = Date.parse(rec.started_at);
3868
- if (!Number.isFinite(started) || now - started < OPEN_RECORD_TTL_MS) continue;
3869
- removeOpenRecord(root, rec.ref);
3870
- reaped++;
3871
- appendLedgerLine(root, nowIso, {
3872
- event: "subagent_reaped",
3873
- ts: nowIso,
3874
- ref: rec.ref,
3875
- agent_type: rec.agent_type,
3876
- depth: rec.depth,
3877
- depth_basis: rec.depth_basis,
3878
- // R2 round 2, finding 5: the arm list is NOT repeated here. A reap
3879
- // fires only past OPEN_RECORD_TTL_MS (24 h), which exceeds every
3880
- // arm (largest: 2 h), so `stop_loss_arms_exceeded` would be a
3881
- // constant on this line — a field that cannot vary answers no
3882
- // question. `age_ms` carries strictly more information and is what
3883
- // a reader should aggregate over.
3884
- age_ms: now - started,
3885
- reason: "open record exceeded OPEN_RECORD_TTL_MS without a stop"
3886
- });
3887
- }
3888
- return reaped;
3889
- }
3890
- function appendUnidentified(root, event, nowIso, payload) {
3891
- appendLedgerLine(root, nowIso, {
3892
- event,
3893
- ts: nowIso,
3894
- ref: null,
3895
- unidentified: true,
3896
- // The agent TYPE is an id-shaped enum and may still be present; it is
3897
- // the only thing salvageable from a payload with no id.
3898
- agent_type: str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
3899
- reason: "payload carried no agent id \u2014 nothing to correlate start with stop"
3900
- });
3901
- }
3902
- function handleStart(root, payload, nowIso, sessionId) {
3903
- const agentId = str(payload, "agent_id", "agentId");
3904
- if (agentId === null) {
3905
- appendUnidentified(root, "subagent_start", nowIso, payload);
3906
- return;
3907
- }
3908
- const ref = refFor(agentId);
3909
- const parentId = extractParentId(payload, agentId);
3910
- const parentRef = parentId ? refFor(parentId) : null;
3911
- const { depth, depth_basis } = resolveDepth(parentRef, readOpenRecords(root));
3912
- const rec = {
3913
- ref,
3914
- agent_type: str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
3915
- started_at: nowIso,
3916
- parent_ref: parentRef,
3917
- depth,
3918
- depth_basis,
3919
- session_id: sessionId
3920
- };
3921
- writeOpenRecord(root, rec);
3922
- appendLedgerLine(root, nowIso, {
3923
- event: "subagent_start",
3924
- ts: nowIso,
3925
- ref,
3926
- // Phase 1 Step 4 correction (b): without this the dispatch denominator
3927
- // is not per-session. Three sessions share one ledger file, so a rate
3928
- // computed over the file aggregates strangers — the measured window
3929
- // held 7 starts against 25 stops, one of them an agent type this
3930
- // session never dispatched. The open record already carried it; the
3931
- // appended line did not, and the line is what a rate is computed from.
3932
- session_id: sessionId,
3933
- agent_type: rec.agent_type,
3934
- parent_ref: parentRef,
3935
- depth,
3936
- depth_basis,
3937
- concurrent_open: countOpen(root)
3938
- });
3939
- }
3940
- function handleStop(root, payload, nowIso, sessionId) {
3941
- const agentId = str(payload, "agent_id", "agentId");
3942
- if (agentId === null) {
3943
- appendUnidentified(root, "subagent_stop", nowIso, payload);
3944
- return;
3945
- }
3946
- const ref = refFor(agentId);
3947
- const rec = readOpenRecords(root).get(ref) ?? null;
3948
- let durationMs = null;
3949
- if (rec) {
3950
- const started = Date.parse(rec.started_at);
3951
- if (Number.isFinite(started)) durationMs = Math.max(0, Date.parse(nowIso) - started);
3952
- }
3953
- const parse2 = classifyEnvelope(str(payload, "last_assistant_message", "lastAssistantMessage"));
3954
- removeOpenRecord(root, ref);
3955
- appendLedgerLine(root, nowIso, {
3956
- event: "subagent_stop",
3957
- ts: nowIso,
3958
- ref,
3959
- // The session this stop was OBSERVED in, read from the same envelope
3960
- // position as the start's — never back-filled from `rec`, which would
3961
- // relabel a cross-session stop as belonging to the dispatching session
3962
- // and hide exactly the mismatch this field exists to expose.
3963
- session_id: sessionId,
3964
- agent_type: rec?.agent_type ?? str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
3965
- depth: rec?.depth ?? null,
3966
- depth_basis: rec?.depth_basis ?? null,
3967
- // `null` = the matching start was never seen. That is a finding about
3968
- // the instrument's own coverage and is recorded as such, not as 0.
3969
- duration_ms: durationMs,
3970
- // Phase 3 Step 3, shadow: which wall-clock arms this dispatch would
3971
- // have tripped. Recorded, never acted on.
3972
- stop_loss_arms_exceeded: armsExceeded(durationMs),
3973
- start_seen: rec !== null,
3974
- envelope_parse: parse2.verdict,
3975
- envelope_error_count: parse2.error_count,
3976
- // Beside the count, never instead of it: the count says how wrong the
3977
- // candidate was, this says whether it was aimed at the envelope.
3978
- envelope_field_hits: parse2.field_hits,
3979
- concurrent_open: countOpen(root)
3980
- });
3981
- }
3982
- function processEnvelope(envelope, consumerRoot) {
3983
- try {
3984
- if (!isObject2(envelope)) return EXIT_ALLOW3;
3985
- const event = envelope["event"];
3986
- if (event !== "subagent_start" && event !== "subagent_stop") return EXIT_ALLOW3;
3987
- const payload = unwrapPayload(envelope);
3988
- const nowIso = (/* @__PURE__ */ new Date()).toISOString();
3989
- const sessionId = str(payload, "session_id", "sessionId") ?? str(envelope, "session_id", "sessionId");
3990
- reapStaleOpenRecords(consumerRoot, nowIso);
3991
- if (event === "subagent_start") handleStart(consumerRoot, payload, nowIso, sessionId);
3992
- else handleStop(consumerRoot, payload, nowIso, sessionId);
3993
- } catch {
3994
- return EXIT_ALLOW3;
3995
- }
3996
- return EXIT_ALLOW3;
3997
- }
3998
- function resolveConsumerRoot(envelope) {
3999
- if (isObject2(envelope)) {
4000
- const pr = str(envelope, "workspace_root", "project_root");
4001
- if (pr) return pr;
4002
- const payload = unwrapPayload(envelope);
4003
- const cwd = str(payload, "cwd");
4004
- if (cwd) return cwd;
4005
- }
4006
- return process.cwd();
4007
- }
4008
- function main4() {
4009
- const raw = readHookStdin();
4010
- let envelope = {};
4011
- try {
4012
- envelope = raw.trim() ? JSON.parse(raw) : {};
4013
- } catch {
4014
- return EXIT_ALLOW3;
4015
- }
4016
- return processEnvelope(envelope, resolveConsumerRoot(envelope));
4017
- }
4018
- function _isCliEntry4() {
4019
- if (true) {
4020
- return false;
4021
- }
4022
- if (process.argv[1] === void 0) return false;
4023
- const argvUrl = pathToFileURL4(path8.resolve(process.argv[1])).href;
4024
- if (import.meta.url === argvUrl) return true;
4025
- try {
4026
- return fs9.realpathSync(fileURLToPath4(import.meta.url)) === fs9.realpathSync(path8.resolve(process.argv[1]));
4027
- } catch {
4028
- return false;
4029
- }
4030
- }
4031
- if (_isCliEntry4()) process.exit(main4());
4032
-
4033
3560
  // src/scripts/_lib/turn_end_transcript.ts
4034
- import * as fs12 from "node:fs";
3561
+ import * as fs11 from "node:fs";
4035
3562
 
4036
3563
  // src/scripts/hooks/end_review_nudge_hook.ts
4037
3564
  import { spawnSync as spawnSync2 } from "node:child_process";
4038
- import * as crypto3 from "node:crypto";
4039
- import * as fs11 from "node:fs";
3565
+ import * as crypto2 from "node:crypto";
3566
+ import * as fs10 from "node:fs";
4040
3567
  import * as os from "node:os";
4041
- import * as path10 from "node:path";
4042
- import { fileURLToPath as fileURLToPath5, pathToFileURL as pathToFileURL5 } from "node:url";
3568
+ import * as path9 from "node:path";
3569
+ import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "node:url";
4043
3570
 
4044
3571
  // src/scripts/_lib/review_baseline.ts
4045
3572
  import { spawnSync } from "node:child_process";
4046
- import * as fs10 from "node:fs";
4047
- import * as path9 from "node:path";
3573
+ import * as fs9 from "node:fs";
3574
+ import * as path8 from "node:path";
4048
3575
  function currentHeadSha(cwd) {
4049
3576
  try {
4050
3577
  const r = spawnSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" });
@@ -4055,12 +3582,12 @@ function currentHeadSha(cwd) {
4055
3582
  return null;
4056
3583
  }
4057
3584
  }
4058
- var BASELINE_STATE_REL = path9.join("agents", "runtime", "state", "review-baseline");
3585
+ var BASELINE_STATE_REL = path8.join("agents", "runtime", "state", "review-baseline");
4059
3586
  function baselineStateDir(workspaceRoot) {
4060
- return path9.join(workspaceRoot, BASELINE_STATE_REL);
3587
+ return path8.join(workspaceRoot, BASELINE_STATE_REL);
4061
3588
  }
4062
3589
  function baselineStateFile(workspaceRoot, sessionKey) {
4063
- return path9.join(baselineStateDir(workspaceRoot), `${sessionKey}.json`);
3590
+ return path8.join(baselineStateDir(workspaceRoot), `${sessionKey}.json`);
4064
3591
  }
4065
3592
  function parseBaseline(raw) {
4066
3593
  let decoded;
@@ -4088,7 +3615,7 @@ function readBaseline(workspaceRoot, sessionKey) {
4088
3615
  const file = baselineStateFile(workspaceRoot, sessionKey);
4089
3616
  let raw;
4090
3617
  try {
4091
- raw = fs10.readFileSync(file, "utf-8");
3618
+ raw = fs9.readFileSync(file, "utf-8");
4092
3619
  } catch (exc) {
4093
3620
  const code = exc?.code;
4094
3621
  return code === "ENOENT" ? "absent" : "unreadable";
@@ -4198,13 +3725,13 @@ function isSafeTranscriptPath(rawPath, opts = {}) {
4198
3725
  const homeDir = opts.homeDir ?? os.homedir();
4199
3726
  const maxBytes = opts.maxBytes ?? TRANSCRIPT_SCAN_MAX_BYTES;
4200
3727
  try {
4201
- const realHome = fs11.realpathSync(homeDir);
4202
- const realPath = fs11.realpathSync(rawPath);
4203
- const relative6 = path10.relative(realHome, realPath);
4204
- if (relative6 === "" || relative6.startsWith("..") || path10.isAbsolute(relative6)) {
3728
+ const realHome = fs10.realpathSync(homeDir);
3729
+ const realPath = fs10.realpathSync(rawPath);
3730
+ const relative6 = path9.relative(realHome, realPath);
3731
+ if (relative6 === "" || relative6.startsWith("..") || path9.isAbsolute(relative6)) {
4205
3732
  return false;
4206
3733
  }
4207
- const { size } = fs11.statSync(realPath);
3734
+ const { size } = fs10.statSync(realPath);
4208
3735
  return size <= maxBytes;
4209
3736
  } catch {
4210
3737
  return false;
@@ -4262,13 +3789,13 @@ var BINARY_PROBE_BYTES = 8e3;
4262
3789
  var UNTRACKED_FILE_READ_CAP_BYTES = 8 * 1024 * 1024;
4263
3790
  function untrackedFileLineCount(cwd, relPath) {
4264
3791
  try {
4265
- const abs = path10.resolve(cwd, relPath);
4266
- const size = fs11.statSync(abs).size;
3792
+ const abs = path9.resolve(cwd, relPath);
3793
+ const size = fs10.statSync(abs).size;
4267
3794
  if (size === 0) return 0;
4268
3795
  if (size > UNTRACKED_FILE_READ_CAP_BYTES) {
4269
3796
  return MUTATION_LINE_THRESHOLD + 1;
4270
3797
  }
4271
- const buf = fs11.readFileSync(abs);
3798
+ const buf = fs10.readFileSync(abs);
4272
3799
  if (buf.length === 0) return 0;
4273
3800
  const probe = buf.subarray(0, Math.min(buf.length, BINARY_PROBE_BYTES));
4274
3801
  if (probe.includes(0)) return 0;
@@ -4294,10 +3821,10 @@ function totalNonDocMutatedLinesWithMeasure(cwd) {
4294
3821
  );
4295
3822
  return { lines: trackedLines + untrackedLines, measure: "exact" };
4296
3823
  }
4297
- function isObject3(v) {
3824
+ function isObject2(v) {
4298
3825
  return typeof v === "object" && v !== null && !Array.isArray(v);
4299
3826
  }
4300
- function str2(v) {
3827
+ function str(v) {
4301
3828
  return typeof v === "string" ? v : "";
4302
3829
  }
4303
3830
  var DISPATCH_TOOL_RE = /^(agent|task)$/i;
@@ -4314,28 +3841,28 @@ function scanTranscriptForReviewer(transcriptText) {
4314
3841
  } catch {
4315
3842
  continue;
4316
3843
  }
4317
- if (!isObject3(obj) || obj["type"] !== "assistant") continue;
3844
+ if (!isObject2(obj) || obj["type"] !== "assistant") continue;
4318
3845
  const msg = obj["message"];
4319
- if (!isObject3(msg)) continue;
3846
+ if (!isObject2(msg)) continue;
4320
3847
  const content = msg["content"];
4321
3848
  if (!Array.isArray(content)) continue;
4322
3849
  for (const blk of content) {
4323
- if (!isObject3(blk) || blk["type"] !== "tool_use") continue;
4324
- const name = str2(blk["name"]);
3850
+ if (!isObject2(blk) || blk["type"] !== "tool_use") continue;
3851
+ const name = str(blk["name"]);
4325
3852
  const input = blk["input"];
4326
- const inputObj = isObject3(input) ? input : {};
3853
+ const inputObj = isObject2(input) ? input : {};
4327
3854
  if (DISPATCH_TOOL_RE.test(name)) {
4328
3855
  const label = [
4329
- str2(inputObj["description"]),
4330
- str2(inputObj["subagent_type"])
3856
+ str(inputObj["description"]),
3857
+ str(inputObj["subagent_type"])
4331
3858
  ].filter(Boolean).join(" ");
4332
3859
  if (REVIEW_SHAPED_LABEL_RE.test(label)) return true;
4333
- const prompt = str2(inputObj["prompt"]);
3860
+ const prompt = str(inputObj["prompt"]);
4334
3861
  if (REVIEW_SHAPED_PROMPT_RE.test(prompt)) return true;
4335
3862
  continue;
4336
3863
  }
4337
3864
  if (/^skill$/i.test(name)) {
4338
- const skillName = str2(inputObj["skill"]) || str2(inputObj["name"]) || str2(inputObj["command"]);
3865
+ const skillName = str(inputObj["skill"]) || str(inputObj["name"]) || str(inputObj["command"]);
4339
3866
  if (REVIEW_SKILL_NAME_RE.test(skillName)) return true;
4340
3867
  continue;
4341
3868
  }
@@ -4354,33 +3881,33 @@ function appendReviewSkippedTelemetry(workspaceRoot, diffLines, mutationMeasure,
4354
3881
  diff_lines: diffLines,
4355
3882
  mutation_measure: mutationMeasure,
4356
3883
  ts,
4357
- id: crypto3.randomUUID(),
3884
+ id: crypto2.randomUUID(),
4358
3885
  baseline
4359
3886
  });
4360
3887
  if (errors.length || line === null) return;
4361
3888
  try {
4362
- const dir = path10.join(workspaceRoot, "agents", "runtime", "state", "audit");
4363
- fs11.mkdirSync(dir, { recursive: true });
4364
- const file = path10.join(dir, `${ts.slice(0, 7)}.jsonl`);
4365
- fs11.appendFileSync(file, `${JSON.stringify(line)}
3889
+ const dir = path9.join(workspaceRoot, "agents", "runtime", "state", "audit");
3890
+ fs10.mkdirSync(dir, { recursive: true });
3891
+ const file = path9.join(dir, `${ts.slice(0, 7)}.jsonl`);
3892
+ fs10.appendFileSync(file, `${JSON.stringify(line)}
4366
3893
  `, "utf8");
4367
3894
  } catch {
4368
3895
  }
4369
3896
  }
4370
3897
  function sessionStateDir(workspaceRoot) {
4371
- return path10.join(workspaceRoot, "agents", "runtime", "state", "end-review-nudge");
3898
+ return path9.join(workspaceRoot, "agents", "runtime", "state", "end-review-nudge");
4372
3899
  }
4373
3900
  function sessionStateFile(workspaceRoot, sessionKey) {
4374
- return path10.join(sessionStateDir(workspaceRoot), `${sessionKey}.json`);
3901
+ return path9.join(sessionStateDir(workspaceRoot), `${sessionKey}.json`);
4375
3902
  }
4376
3903
  function deriveSessionKey2(envelope, payload) {
4377
- const raw = str2(envelope["session_id"]) || str2(payload["transcript_path"] ?? payload["transcriptPath"]);
3904
+ const raw = str(envelope["session_id"]) || str(payload["transcript_path"] ?? payload["transcriptPath"]);
4378
3905
  const material = raw || "unknown-session";
4379
- return crypto3.createHash("sha256").update(material).digest("hex");
3906
+ return crypto2.createHash("sha256").update(material).digest("hex");
4380
3907
  }
4381
3908
  function hasFiredThisSession(workspaceRoot, sessionKey) {
4382
3909
  try {
4383
- return fs11.existsSync(sessionStateFile(workspaceRoot, sessionKey));
3910
+ return fs10.existsSync(sessionStateFile(workspaceRoot, sessionKey));
4384
3911
  } catch {
4385
3912
  return false;
4386
3913
  }
@@ -4400,7 +3927,7 @@ var FALLBACK_TO_TELEMETRY = {
4400
3927
  "head-moved": "head_moved",
4401
3928
  "mixed-measure": "mixed_measure"
4402
3929
  };
4403
- function main5() {
3930
+ function main4() {
4404
3931
  const [envelope, payload] = unwrap(_read_stdin(), "claude");
4405
3932
  const event = String(envelope["event"] ?? "");
4406
3933
  if (event !== "" && event !== "stop") {
@@ -4436,13 +3963,13 @@ function main5() {
4436
3963
  if (hasFiredThisSession(workspace_root, sessionKey)) {
4437
3964
  return 0;
4438
3965
  }
4439
- const transcriptPath = str2(
3966
+ const transcriptPath = str(
4440
3967
  payload["transcript_path"] ?? payload["transcriptPath"]
4441
3968
  ).trim();
4442
3969
  let reviewerRan = false;
4443
3970
  if (transcriptPath && isSafeTranscriptPath(transcriptPath)) {
4444
3971
  try {
4445
- reviewerRan = scanTranscriptForReviewer(fs11.readFileSync(transcriptPath, "utf-8"));
3972
+ reviewerRan = scanTranscriptForReviewer(fs10.readFileSync(transcriptPath, "utf-8"));
4446
3973
  } catch {
4447
3974
  reviewerRan = false;
4448
3975
  }
@@ -4468,29 +3995,29 @@ function main5() {
4468
3995
  })}
4469
3996
  `
4470
3997
  );
4471
- return EXIT_WARN2;
3998
+ return EXIT_WARN;
4472
3999
  }
4473
- function _isCliEntry5() {
4000
+ function _isCliEntry4() {
4474
4001
  if (true) {
4475
4002
  return false;
4476
4003
  }
4477
4004
  if (process.argv[1] === void 0) {
4478
4005
  return false;
4479
4006
  }
4480
- const argvUrl = pathToFileURL5(path10.resolve(process.argv[1])).href;
4007
+ const argvUrl = pathToFileURL4(path9.resolve(process.argv[1])).href;
4481
4008
  if (import.meta.url === argvUrl) {
4482
4009
  return true;
4483
4010
  }
4484
4011
  try {
4485
- const here = fs11.realpathSync(fileURLToPath5(import.meta.url));
4486
- const argv = fs11.realpathSync(path10.resolve(process.argv[1]));
4012
+ const here = fs10.realpathSync(fileURLToPath4(import.meta.url));
4013
+ const argv = fs10.realpathSync(path9.resolve(process.argv[1]));
4487
4014
  return here === argv;
4488
4015
  } catch {
4489
4016
  return false;
4490
4017
  }
4491
4018
  }
4492
- if (_isCliEntry5()) {
4493
- process.exit(main5());
4019
+ if (_isCliEntry4()) {
4020
+ process.exit(main4());
4494
4021
  }
4495
4022
 
4496
4023
  // src/scripts/_lib/turn_end_transcript.ts
@@ -4504,10 +4031,10 @@ function readTranscriptTail(transcriptPath, opts = {}) {
4504
4031
  if (!transcriptPath || !isSafeTranscriptPath(transcriptPath, opts)) return empty;
4505
4032
  let lines;
4506
4033
  try {
4507
- if (opts.maxBytes !== void 0 && fs12.statSync(transcriptPath).size > opts.maxBytes) {
4034
+ if (opts.maxBytes !== void 0 && fs11.statSync(transcriptPath).size > opts.maxBytes) {
4508
4035
  return empty;
4509
4036
  }
4510
- lines = fs12.readFileSync(transcriptPath, "utf-8").split("\n");
4037
+ lines = fs11.readFileSync(transcriptPath, "utf-8").split("\n");
4511
4038
  } catch {
4512
4039
  return empty;
4513
4040
  }
@@ -4694,7 +4221,7 @@ function detectPromissory(reply) {
4694
4221
  function readCiSettled(workspaceRoot, session_id) {
4695
4222
  if (!hasStableSessionId(session_id)) return { seen: false, settled: false };
4696
4223
  try {
4697
- const raw = fs13.readFileSync(path11.join(workspaceRoot, statePathFor(session_id)), "utf-8");
4224
+ const raw = fs12.readFileSync(path10.join(workspaceRoot, statePathFor(session_id)), "utf-8");
4698
4225
  const decoded = JSON.parse(raw);
4699
4226
  if (!owns_session_state(decoded, session_id)) return { seen: false, settled: false };
4700
4227
  if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
@@ -4730,8 +4257,8 @@ function detectCompletionClaim(reply, ci) {
4730
4257
  function readLanguagePin(workspaceRoot, session_id) {
4731
4258
  if (!hasStableSessionId(session_id)) return "und";
4732
4259
  try {
4733
- const raw = fs13.readFileSync(
4734
- path11.join(workspaceRoot, statePathFor2(session_id)),
4260
+ const raw = fs12.readFileSync(
4261
+ path10.join(workspaceRoot, statePathFor2(session_id)),
4735
4262
  "utf-8"
4736
4263
  );
4737
4264
  const decoded = JSON.parse(raw);
@@ -4840,7 +4367,7 @@ function sessionStateFile2(workspaceRoot, sessionKey) {
4840
4367
  }
4841
4368
  function alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal) {
4842
4369
  try {
4843
- const raw = fs13.readFileSync(sessionStateFile2(workspaceRoot, sessionKey), "utf-8");
4370
+ const raw = fs12.readFileSync(sessionStateFile2(workspaceRoot, sessionKey), "utf-8");
4844
4371
  const decoded = JSON.parse(raw);
4845
4372
  if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
4846
4373
  return decoded["refused_turn"] === turnOrdinal;
@@ -4854,7 +4381,7 @@ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors, prom
4854
4381
  const file = sessionStateFile2(workspaceRoot, sessionKey);
4855
4382
  let prev = null;
4856
4383
  try {
4857
- prev = parseRecord(fs13.readFileSync(file, "utf-8"));
4384
+ prev = parseRecord(fs12.readFileSync(file, "utf-8"));
4858
4385
  } catch {
4859
4386
  }
4860
4387
  let version;
@@ -4877,17 +4404,17 @@ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors, prom
4877
4404
  } catch {
4878
4405
  }
4879
4406
  }
4880
- function str3(v) {
4407
+ function str2(v) {
4881
4408
  return typeof v === "string" ? v : "";
4882
4409
  }
4883
4410
  function assembleDetectorInputs(envelope, payload) {
4884
- const workspaceRoot = str3(envelope["workspace_root"]) || process.cwd();
4411
+ const workspaceRoot = str2(envelope["workspace_root"]) || process.cwd();
4885
4412
  let dispatchOpen = false;
4886
4413
  try {
4887
4414
  dispatchOpen = openRecordStats(workspaceRoot).open_count > 0;
4888
4415
  } catch {
4889
4416
  }
4890
- const transcriptPath = str3(
4417
+ const transcriptPath = str2(
4891
4418
  payload["transcript_path"] ?? payload["transcriptPath"]
4892
4419
  );
4893
4420
  const { lastAssistant, turnOrdinal, toolCalls, assistantTurnTexts } = readTranscriptTail(
@@ -4895,13 +4422,13 @@ function assembleDetectorInputs(envelope, payload) {
4895
4422
  { maxBytes: TRANSCRIPT_READ_MAX_BYTES }
4896
4423
  );
4897
4424
  if (!lastAssistant) return null;
4898
- const payloadClosing = str3(
4425
+ const payloadClosing = str2(
4899
4426
  payload["last_assistant_message"] ?? payload["lastAssistantMessage"]
4900
4427
  );
4901
4428
  const closingFromPayload = payloadClosing !== "" && !assistantTurnTexts.includes(payloadClosing);
4902
4429
  const turnTexts = closingFromPayload ? [...assistantTurnTexts, payloadClosing] : assistantTurnTexts;
4903
- const promptId = str3(payload["prompt_id"] ?? payload["promptId"]);
4904
- const rawSessionId = str3(envelope["session_id"]) || "";
4430
+ const promptId = str2(payload["prompt_id"] ?? payload["promptId"]);
4431
+ const rawSessionId = str2(envelope["session_id"]) || "";
4905
4432
  const sessionKey = deriveSessionKey(rawSessionId || "unknown-session");
4906
4433
  const runState = readTurnRunState(workspaceRoot, rawSessionId);
4907
4434
  return {
@@ -4951,7 +4478,7 @@ function runDetectors(inputs) {
4951
4478
  // on a completion CLAIM, and a turn waiting on a subagent has not
4952
4479
  // finished — so its closing is not the claim F is about. Same slot,
4953
4480
  // opposite trigger, opposite treatment of `dispatchOpen`.
4954
- openSvgObligation(workspaceRoot, toolCalls),
4481
+ openSvgObligation(workspaceRoot, toolCalls, runState?.asset_renders ?? null),
4955
4482
  dispatchOpen ? null : detectUntestedChange(lastAssistant, toolCalls, runState)
4956
4483
  ]) {
4957
4484
  if (f) findings.push(f);
@@ -4996,7 +4523,7 @@ function recordShadow(inputs, layer) {
4996
4523
  const file = sessionShadowFile(inputs.workspaceRoot, inputs.sessionKey);
4997
4524
  let prev = null;
4998
4525
  try {
4999
- prev = parseShadowRecord(fs13.readFileSync(file, "utf-8"));
4526
+ prev = parseShadowRecord(fs12.readFileSync(file, "utf-8"));
5000
4527
  } catch {
5001
4528
  }
5002
4529
  atomic_write_json(
@@ -5012,13 +4539,13 @@ function recordShadow(inputs, layer) {
5012
4539
  } catch {
5013
4540
  }
5014
4541
  }
5015
- function main6() {
4542
+ function main5() {
5016
4543
  let envelope;
5017
4544
  let payload;
5018
4545
  try {
5019
4546
  [envelope, payload] = unwrap(readHookStdin(), "claude");
5020
4547
  } catch {
5021
- return EXIT_ALLOW3;
4548
+ return EXIT_ALLOW;
5022
4549
  }
5023
4550
  if (payload["stop_hook_active"] === true) {
5024
4551
  try {
@@ -5026,17 +4553,17 @@ function main6() {
5026
4553
  if (retryInputs !== null) recordShadow(retryInputs, "stop_hook_active");
5027
4554
  } catch {
5028
4555
  }
5029
- return EXIT_ALLOW3;
4556
+ return EXIT_ALLOW;
5030
4557
  }
5031
4558
  const inputs = assembleDetectorInputs(envelope, payload);
5032
- if (inputs === null) return EXIT_ALLOW3;
4559
+ if (inputs === null) return EXIT_ALLOW;
5033
4560
  if (alreadyRefusedTurn(inputs.workspaceRoot, inputs.sessionKey, inputs.turnOrdinal)) {
5034
4561
  recordShadow(inputs, "refused_turn");
5035
- return EXIT_ALLOW3;
4562
+ return EXIT_ALLOW;
5036
4563
  }
5037
4564
  const findings = runDetectors(inputs);
5038
4565
  recordGraphFeeder(inputs, findings, "live");
5039
- if (findings.length === 0) return EXIT_ALLOW3;
4566
+ if (findings.length === 0) return EXIT_ALLOW;
5040
4567
  markRefusedTurn(
5041
4568
  inputs.workspaceRoot,
5042
4569
  inputs.sessionKey,
@@ -5057,35 +4584,35 @@ ${lines.join("\n")}
5057
4584
  );
5058
4585
  return EXIT_BLOCK;
5059
4586
  }
5060
- function _isCliEntry6() {
4587
+ function _isCliEntry5() {
5061
4588
  if (true) {
5062
4589
  return false;
5063
4590
  }
5064
4591
  if (process.argv[1] === void 0) {
5065
4592
  return false;
5066
4593
  }
5067
- const argvUrl = pathToFileURL6(path11.resolve(process.argv[1])).href;
4594
+ const argvUrl = pathToFileURL5(path10.resolve(process.argv[1])).href;
5068
4595
  if (import.meta.url === argvUrl) {
5069
4596
  return true;
5070
4597
  }
5071
4598
  try {
5072
- const here = fs13.realpathSync(fileURLToPath6(import.meta.url));
5073
- const argv = fs13.realpathSync(path11.resolve(process.argv[1]));
4599
+ const here = fs12.realpathSync(fileURLToPath5(import.meta.url));
4600
+ const argv = fs12.realpathSync(path10.resolve(process.argv[1]));
5074
4601
  return here === argv;
5075
4602
  } catch {
5076
4603
  return false;
5077
4604
  }
5078
4605
  }
5079
- if (_isCliEntry6()) {
5080
- process.exit(main6());
4606
+ if (_isCliEntry5()) {
4607
+ process.exit(main5());
5081
4608
  }
5082
4609
 
5083
4610
  // src/scripts/hooks/evidence_independence.ts
5084
4611
  import { spawnSync as spawnSync3 } from "node:child_process";
5085
- import crypto4 from "node:crypto";
5086
- import fs14 from "node:fs";
5087
- import path12 from "node:path";
5088
- import { fileURLToPath as fileURLToPath7, pathToFileURL as pathToFileURL7 } from "node:url";
4612
+ import crypto3 from "node:crypto";
4613
+ import fs13 from "node:fs";
4614
+ import path11 from "node:path";
4615
+ import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL6 } from "node:url";
5089
4616
 
5090
4617
  // src/scripts/_lib/test_delta.ts
5091
4618
  function isCodePath(p) {
@@ -5103,7 +4630,7 @@ function isTestPath(p) {
5103
4630
  }
5104
4631
 
5105
4632
  // src/scripts/hooks/evidence_independence.ts
5106
- var STATE_FILE3 = path12.join("agents", "state", "evidence-dispatch.json");
4633
+ var STATE_FILE3 = path11.join("agents", "state", "evidence-dispatch.json");
5107
4634
  function _isObject5(v) {
5108
4635
  return typeof v === "object" && v !== null && !Array.isArray(v);
5109
4636
  }
@@ -5171,8 +4698,8 @@ function extractDispatch(envelope) {
5171
4698
  }
5172
4699
  function _ledgerStamp(consumer_root, session_id) {
5173
4700
  try {
5174
- const raw = fs14.readFileSync(
5175
- path12.join(consumer_root, ledgerFileFor(session_id)),
4701
+ const raw = fs13.readFileSync(
4702
+ path11.join(consumer_root, ledgerFileFor(session_id)),
5176
4703
  "utf8"
5177
4704
  );
5178
4705
  const d = JSON.parse(raw);
@@ -5183,7 +4710,7 @@ function _ledgerStamp(consumer_root, session_id) {
5183
4710
  }
5184
4711
  function _load(target) {
5185
4712
  try {
5186
- const decoded = JSON.parse(fs14.readFileSync(target, "utf8"));
4713
+ const decoded = JSON.parse(fs13.readFileSync(target, "utf8"));
5187
4714
  if (_isObject5(decoded) && Array.isArray(decoded["evaluations"])) {
5188
4715
  return decoded;
5189
4716
  }
@@ -5194,7 +4721,7 @@ function _load(target) {
5194
4721
  var WARN_TEXT = "First evaluation dispatch this turn. Two shapes fabricated a binding honest-null in the audited sessions \u2014 check your prompt for both before it goes out: (1) a verdict pre-loaded into the prompt, and (2) a scope narrowed to files you chose. A review you commissioned on your own work is admissible as gate evidence only when the prompt is recorded alongside the verdict.";
5195
4722
  function decide(tool, prompt, priorEvaluations) {
5196
4723
  if (!isDispatchTool(tool) || !isEvaluationPrompt(prompt)) {
5197
- return { exit: EXIT_ALLOW3, stdout: "", stderr: "", evaluations: priorEvaluations };
4724
+ return { exit: EXIT_ALLOW, stdout: "", stderr: "", evaluations: priorEvaluations };
5198
4725
  }
5199
4726
  const preloaded = preloadedVerdict(prompt);
5200
4727
  if (preloaded !== null) {
@@ -5207,11 +4734,11 @@ function decide(tool, prompt, priorEvaluations) {
5207
4734
  };
5208
4735
  }
5209
4736
  if (!isSelfScoped(prompt)) {
5210
- return { exit: EXIT_ALLOW3, stdout: "", stderr: "", evaluations: priorEvaluations };
4737
+ return { exit: EXIT_ALLOW, stdout: "", stderr: "", evaluations: priorEvaluations };
5211
4738
  }
5212
4739
  if (priorEvaluations >= 1) {
5213
4740
  return {
5214
- exit: EXIT_ALLOW3,
4741
+ exit: EXIT_ALLOW,
5215
4742
  stdout: `${JSON.stringify({
5216
4743
  decision: "warn",
5217
4744
  reason: `Second evaluation dispatch of your own work in this turn. If both passes judge the SAME subject, that is verdict shopping \u2014 commissioning another with a different prompt or scope selects the answer instead of measuring it. Report what the first pass returned, then re-plan. If this is an implementation fan-out rather than a second review, carry on: this check reads prose and cannot tell the two apart with certainty.`
@@ -5222,7 +4749,7 @@ function decide(tool, prompt, priorEvaluations) {
5222
4749
  };
5223
4750
  }
5224
4751
  return {
5225
- exit: EXIT_ALLOW3,
4752
+ exit: EXIT_ALLOW,
5226
4753
  stdout: `${JSON.stringify({ decision: "warn", reason: WARN_TEXT })}
5227
4754
  `,
5228
4755
  stderr: "",
@@ -5264,10 +4791,10 @@ function run3(stdin_text, options) {
5264
4791
  envelope = decoded;
5265
4792
  }
5266
4793
  } catch {
5267
- return EXIT_ALLOW3;
4794
+ return EXIT_ALLOW;
5268
4795
  }
5269
4796
  }
5270
- const target = path12.join(options.consumer_root, STATE_FILE3);
4797
+ const target = path11.join(options.consumer_root, STATE_FILE3);
5271
4798
  const state = _load(target);
5272
4799
  const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
5273
4800
  const turnMarker = `${session_id}:${_ledgerStamp(options.consumer_root, session_id)}`;
@@ -5283,14 +4810,14 @@ function run3(stdin_text, options) {
5283
4810
  if (staged !== null && touchesTestAndCode(staged)) {
5284
4811
  process.stdout.write(`${JSON.stringify({ decision: "warn", reason: flag })}
5285
4812
  `);
5286
- return EXIT_ALLOW3;
4813
+ return EXIT_ALLOW;
5287
4814
  }
5288
4815
  }
5289
4816
  const decision = decide(tool, prompt, state.evaluations.length);
5290
4817
  if (decision.evaluations > state.evaluations.length) {
5291
4818
  state.evaluations.push({
5292
4819
  at: (/* @__PURE__ */ new Date()).toISOString(),
5293
- digest: crypto4.createHash("sha256").update(prompt).digest("hex").slice(0, 16),
4820
+ digest: crypto3.createHash("sha256").update(prompt).digest("hex").slice(0, 16),
5294
4821
  prompt_chars: prompt.length
5295
4822
  });
5296
4823
  try {
@@ -5314,7 +4841,7 @@ function _errText3(err) {
5314
4841
  const t = err instanceof Error ? err.message : String(err);
5315
4842
  return t.replace(/\s+/g, " ").trim().slice(0, 200);
5316
4843
  }
5317
- function main7(argv) {
4844
+ function main6(argv) {
5318
4845
  const args = argv ?? process.argv.slice(2);
5319
4846
  let consumer_root = process.cwd();
5320
4847
  for (let i = 0; i < args.length; i += 1) {
@@ -5328,33 +4855,33 @@ function main7(argv) {
5328
4855
  }
5329
4856
  return run3(readHookStdin(), { consumer_root });
5330
4857
  }
5331
- function _isCliEntry7() {
4858
+ function _isCliEntry6() {
5332
4859
  if (true) {
5333
4860
  return false;
5334
4861
  }
5335
4862
  if (process.argv[1] === void 0) {
5336
4863
  return false;
5337
4864
  }
5338
- const argvUrl = pathToFileURL7(path12.resolve(process.argv[1])).href;
4865
+ const argvUrl = pathToFileURL6(path11.resolve(process.argv[1])).href;
5339
4866
  if (import.meta.url === argvUrl) {
5340
4867
  return true;
5341
4868
  }
5342
4869
  try {
5343
- const here = fs14.realpathSync(fileURLToPath7(import.meta.url));
5344
- const argv = fs14.realpathSync(path12.resolve(process.argv[1]));
4870
+ const here = fs13.realpathSync(fileURLToPath6(import.meta.url));
4871
+ const argv = fs13.realpathSync(path11.resolve(process.argv[1]));
5345
4872
  return here === argv;
5346
4873
  } catch {
5347
4874
  return false;
5348
4875
  }
5349
4876
  }
5350
- if (_isCliEntry7()) {
5351
- process.exit(main7());
4877
+ if (_isCliEntry6()) {
4878
+ process.exit(main6());
5352
4879
  }
5353
4880
 
5354
4881
  // src/scripts/hooks/delegation_nudge_hook.ts
5355
- import fs15 from "node:fs";
4882
+ import fs16 from "node:fs";
5356
4883
  import path13 from "node:path";
5357
- import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL8 } from "node:url";
4884
+ import { fileURLToPath as fileURLToPath7, pathToFileURL as pathToFileURL7 } from "node:url";
5358
4885
 
5359
4886
  // src/scripts/_lib/auto_dispatch.ts
5360
4887
  var SIZE_FLOOR = 1;
@@ -5424,6 +4951,29 @@ function classifyLookup(taskText, opts = {}) {
5424
4951
  reason: "not lookup-shaped \u2014 regular classification path (never down-guessed)"
5425
4952
  };
5426
4953
  }
4954
+ function inferSliceTier(signals) {
4955
+ const guard = signals.exceeds_mechanical_envelope === true;
4956
+ switch (signals.slice_type) {
4957
+ case "read-only-fanout":
4958
+ case "mechanical-covered": {
4959
+ if (guard) {
4960
+ return {
4961
+ tier: "medium",
4962
+ tier_source: "inferred",
4963
+ reason: `${signals.slice_type} slice, but scope exceeds the mechanical envelope \u2014 lite candidacy revoked`
4964
+ };
4965
+ }
4966
+ const cascade = signals.slice_type === "mechanical-covered" ? " (verify-fail escalates to medium)" : "";
4967
+ return { tier: "lite", tier_source: "inferred", reason: `${signals.slice_type} slice${cascade}` };
4968
+ }
4969
+ case "mutating-uncovered":
4970
+ return { tier: "medium", tier_source: "inferred", reason: "mutating slice without test coverage" };
4971
+ case "synthesis":
4972
+ return { tier: "medium", tier_source: "inferred", reason: "synthesis/judgment slice \u2014 judge one tier up" };
4973
+ default:
4974
+ return { tier: "inherit", tier_source: "inherit", reason: "unknown/ambiguous slice type \u2014 session tier, never guess down" };
4975
+ }
4976
+ }
5427
4977
 
5428
4978
  // src/scripts/_lib/judgment_ladder.ts
5429
4979
  var RENAME_RE = /\brename\s+\S+\s+to\s+\S+\b/i;
@@ -5633,6 +5183,86 @@ function resolveSubagentRouting(inp) {
5633
5183
  };
5634
5184
  }
5635
5185
 
5186
+ // src/scripts/_lib/hand_kinds.ts
5187
+ var HAND_KINDS = [
5188
+ "classify",
5189
+ "extract",
5190
+ "summarise-given-text",
5191
+ "draft-candidate",
5192
+ "test-candidates",
5193
+ "finding-proposal"
5194
+ ];
5195
+ var HEAD_ONLY_KINDS = ["plan", "decide", "chair", "final-review", "write"];
5196
+ var _KINDS = new Set(HAND_KINDS);
5197
+ var _HEAD_ONLY = new Set(HEAD_ONLY_KINDS);
5198
+ var KIND_FROM_PROMPT = [
5199
+ [/^\s*(?:propose|suggest|draft|write)\s+(?:unit\s+)?test(?:s|\s+cases?|\s+candidates?)?\b/i, "test-candidates"],
5200
+ [/^\s*(?:propose|list)\s+(?:review\s+)?findings?\b/i, "finding-proposal"],
5201
+ [/^\s*(?:classify|categori[sz]e|label)\b/i, "classify"],
5202
+ [/^\s*extract\b/i, "extract"],
5203
+ [/^\s*summari[sz]e\b/i, "summarise-given-text"],
5204
+ [/^\s*draft\b/i, "draft-candidate"]
5205
+ ];
5206
+ function handKindFromPrompt(text) {
5207
+ for (const [re, kind] of KIND_FROM_PROMPT) if (re.test(text)) return kind;
5208
+ return null;
5209
+ }
5210
+
5211
+ // src/scripts/ai_council/free_rung.ts
5212
+ var import_yaml = __toESM(require_dist(), 1);
5213
+ import * as fs15 from "node:fs";
5214
+
5215
+ // src/scripts/ai_council/kind_flip_state.ts
5216
+ import * as fs14 from "node:fs";
5217
+ import * as path12 from "node:path";
5218
+ var KIND_FLIPS_RELPATH = path12.join("agents", "runtime", "state", "hand-kind-flips.json");
5219
+ function isKindFlipped(stateRoot, kind) {
5220
+ try {
5221
+ const raw = JSON.parse(fs14.readFileSync(path12.join(stateRoot, KIND_FLIPS_RELPATH), "utf8"));
5222
+ return raw.kinds?.[kind]?.route === "free";
5223
+ } catch {
5224
+ return false;
5225
+ }
5226
+ }
5227
+
5228
+ // src/scripts/ai_council/free_rung.ts
5229
+ var COUNCIL_CONFIG_ENV = "AI_COUNCIL_CONFIG";
5230
+ var COUNCIL_CONFIG_REL = "settings/.ai-council.yml";
5231
+ function keyPresent(ref) {
5232
+ if (ref === void 0 || ref === null) return true;
5233
+ if (typeof ref !== "string" || !ref.startsWith("env:")) return false;
5234
+ return (process.env[ref.slice(4)] ?? "") !== "";
5235
+ }
5236
+ function freeRouteAvailable(configPath) {
5237
+ let raw;
5238
+ try {
5239
+ raw = (0, import_yaml.parse)(fs15.readFileSync(configPath, "utf-8"), { version: "1.1" });
5240
+ } catch {
5241
+ return false;
5242
+ }
5243
+ const members = raw?.members;
5244
+ if (members === null || typeof members !== "object") return false;
5245
+ for (const [name, value] of Object.entries(members)) {
5246
+ if (value === null || typeof value !== "object") continue;
5247
+ const cfg = value;
5248
+ if (cfg["enabled"] !== true) continue;
5249
+ const parsed = parseRouteFields(name, cfg, false);
5250
+ if ("error" in parsed || parsed.route === null) continue;
5251
+ const model = typeof cfg["model"] === "string" ? cfg["model"] : "";
5252
+ const t = resolveRouteTransport({ name, route: parsed.route, model, contentClass: "public-artifact", keyPresent: keyPresent(cfg["api_key_ref"]) });
5253
+ if (t.available && t.billing !== "per-token") return true;
5254
+ }
5255
+ return false;
5256
+ }
5257
+ function councilConfigPath() {
5258
+ const override = process.env[COUNCIL_CONFIG_ENV];
5259
+ if (override) return override.startsWith("~/") ? `${process.env["HOME"] ?? ""}${override.slice(1)}` : override;
5260
+ return resolve_with_fallback(COUNCIL_CONFIG_REL, { env: null });
5261
+ }
5262
+ function freeRungFor(stateRoot, kind, configPath) {
5263
+ return isKindFlipped(stateRoot, kind) && configPath !== null && freeRouteAvailable(configPath);
5264
+ }
5265
+
5636
5266
  // src/scripts/hooks/delegation_nudge_hook.ts
5637
5267
  function _isObject6(v) {
5638
5268
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -5725,10 +5355,10 @@ function resolveActivation(workspace_root, hostId) {
5725
5355
  agentTeams: host_manifest.agent_teams
5726
5356
  };
5727
5357
  }
5728
- function recommendSliceTier(downshift, separate_quota_pool) {
5358
+ function recommendSliceTier(downshift, separate_quota_pool, sliceKind = "unknown") {
5729
5359
  const decision = resolveSubagentRouting({
5730
- task_tier: "lite",
5731
- session_tier: "high",
5360
+ task_tier: inferSliceTier({ slice_type: sliceKind }).tier,
5361
+ session_tier: "inherit",
5732
5362
  downshift,
5733
5363
  quota_arbitrage: false,
5734
5364
  model_map: {},
@@ -5736,9 +5366,18 @@ function recommendSliceTier(downshift, separate_quota_pool) {
5736
5366
  });
5737
5367
  return decision.tier;
5738
5368
  }
5739
- function buildNudgeLine(rung, classification, sliceCount, tier) {
5369
+ var READ_ONLY_FANOUT_RE = /\b(find|locate|search|grep|list|inventor(?:y|ise|ize)|enumerate|count|which files|where (?:is|are)|finde|suche|liste|z(?:ä|ae)hle|wo (?:ist|sind))\b/i;
5370
+ var MUTATING_RE = /\b(fix|implement|edit|write|refactor|change|add|create|remove|delete|update|rename|migrate|build|move|replace|mach|bau|implementier\w*|(?:ä|ae)nder\w*|erstell\w*|l(?:ö|oe)sch\w*|f(?:ü|ue)g\w*|schreib\w*)\b/i;
5371
+ function sliceKindFromPrompt(prompt) {
5372
+ return READ_ONLY_FANOUT_RE.test(prompt) && !MUTATING_RE.test(prompt) ? "read-only-fanout" : "unknown";
5373
+ }
5374
+ var LEG_COLD_START_UNCACHED_TOKENS = 182257;
5375
+ function buildNudgeLine(rung, classification, sliceCount, tier, sliceKind, handKind) {
5740
5376
  const unit = sliceCount === 1 ? "slice" : "slices";
5741
5377
  const rungLabel = rung === null ? "rung-?" : `rung-${rung}`;
5378
+ if (rung === 0.5 && handKind !== void 0) {
5379
+ return `<delegation-nudge>rung-0.5: free rung. This slice is a typed \`${handKind}\` task and an unpaid route is admissible \u2014 you may send it as ONE call via \`./scripts-run src/scripts/ask_transport --kind ${handKind} --content-class public-artifact "<slice>"\` (public-artifact text only; project content stays on a paid route). The return is a proposal: verify it before acting on it. Nothing was sent for you \u2014 ${classification.reason}.</delegation-nudge>`;
5380
+ }
5742
5381
  if (rung === 0.5) {
5743
5382
  return `<delegation-nudge>rung-0.5: ask, est. <1k tokens. This is a single bounded question \u2014 answer it via ONE completion (\`./scripts-run src/scripts/ask_transport "<question>"\`) instead of a subagent spawn (measured spawn floor: ~251k tokens) \u2014 ${classification.reason}.</delegation-nudge>`;
5744
5383
  }
@@ -5749,9 +5388,12 @@ function buildNudgeLine(rung, classification, sliceCount, tier) {
5749
5388
  return `<delegation-nudge>rung-3: team. These slices must see each other's state during the run, so a set of independent subagent spawns cannot express it \u2014 use the host teams primitive, or fall back to \`./scripts-run src/scripts/ask_transport "<question>"\` for a bounded sub-question. Not a spawn, and not run for you \u2014 ${classification.reason}.</delegation-nudge>`;
5750
5389
  }
5751
5390
  const modeLabel = classification.mode ?? "single-slice";
5752
- return `<delegation-nudge>${rungLabel}: dispatch ${modeLabel} (${sliceCount} ${unit}, ${tier} tier recommended). Consider dispatching via subagent-orchestration instead of doing every slice in-session \u2014 ${classification.reason}.</delegation-nudge>`;
5391
+ const coldStart = rung === 1 ? ` A leg starts cold (~${Math.round(LEG_COLD_START_UNCACHED_TOKENS / 1e3)}k uncached tokens): a slice of one to three direct reads does not amortise it.` : "";
5392
+ const model = tier === "lite" && sliceKind !== void 0 && sliceKind !== "unknown" ? TIER_TO_CLAUDE_MODEL[tier] : void 0;
5393
+ const carrier = model ? ` Pass \`model: "${model}"\` on each Agent call (${sliceKind} slices earn lite).` : "";
5394
+ return `<delegation-nudge>${rungLabel}: dispatch ${modeLabel} (${sliceCount} ${unit}, ${tier} tier recommended). Consider dispatching via subagent-orchestration instead of doing every slice in-session \u2014 ${classification.reason}.${carrier}${coldStart}</delegation-nudge>`;
5753
5395
  }
5754
- function classifyPrompt(prompt, workspace_root, hostId) {
5396
+ function classifyPrompt(prompt, workspace_root, hostId, opts = {}) {
5755
5397
  try {
5756
5398
  const { signals, sliceCountForLine } = extractTaskSignals(prompt);
5757
5399
  const { activation, downshift, separate_quota_pool, agentTeams } = resolveActivation(
@@ -5771,13 +5413,28 @@ function classifyPrompt(prompt, workspace_root, hostId) {
5771
5413
  classification: { delegable: false, action: "ask", mode: null, reason: ladder.reason },
5772
5414
  sliceCount: 0,
5773
5415
  tier: recommendSliceTier(downshift, separate_quota_pool),
5416
+ sliceKind: "unknown",
5774
5417
  rung: ladder.rung
5775
5418
  };
5776
5419
  }
5420
+ if (ladder.rung === 0.5 && opts.freeRouteAdmissible !== void 0) {
5421
+ const handKind = handKindFromPrompt(prompt);
5422
+ if (handKind !== null && opts.freeRouteAdmissible(handKind)) {
5423
+ return {
5424
+ classification: { delegable: false, action: "ask", mode: null, reason: ladder.reason },
5425
+ sliceCount: 0,
5426
+ tier: recommendSliceTier(downshift, separate_quota_pool),
5427
+ sliceKind: "unknown",
5428
+ rung: ladder.rung,
5429
+ handKind
5430
+ };
5431
+ }
5432
+ }
5777
5433
  if (ladder.verdict !== "subagent") {
5778
5434
  return null;
5779
5435
  }
5780
- const tier = recommendSliceTier(downshift, separate_quota_pool);
5436
+ const sliceKind = sliceKindFromPrompt(prompt);
5437
+ const tier = recommendSliceTier(downshift, separate_quota_pool, sliceKind);
5781
5438
  const sliceCount = ladder.rung === 1 ? 1 : sliceCountForLine;
5782
5439
  const classification = {
5783
5440
  delegable: true,
@@ -5785,7 +5442,7 @@ function classifyPrompt(prompt, workspace_root, hostId) {
5785
5442
  mode: ladder.mode ?? null,
5786
5443
  reason: ladder.reason
5787
5444
  };
5788
- return { classification, sliceCount, tier, rung: ladder.rung };
5445
+ return { classification, sliceCount, tier, sliceKind, rung: ladder.rung };
5789
5446
  } catch {
5790
5447
  return null;
5791
5448
  }
@@ -5806,70 +5463,79 @@ function _workspaceRoot(envelope) {
5806
5463
  }
5807
5464
  return process.cwd();
5808
5465
  }
5809
- function main8() {
5466
+ function main7() {
5810
5467
  let envelope = {};
5811
5468
  try {
5812
5469
  const raw = readHookStdin();
5813
5470
  envelope = raw.trim() ? JSON.parse(raw) : {};
5814
5471
  } catch {
5815
- return EXIT_ALLOW3;
5472
+ return EXIT_ALLOW;
5816
5473
  }
5817
5474
  const env = _isObject6(envelope) ? envelope : {};
5818
5475
  const event = env["event"];
5819
5476
  const slot = typeof event === "string" && event !== "" ? event : "user_prompt_submit";
5820
5477
  if (slot !== "user_prompt_submit") {
5821
- return EXIT_ALLOW3;
5478
+ return EXIT_ALLOW;
5822
5479
  }
5823
5480
  const payload = _isObject6(env["payload"]) ? env["payload"] : env;
5824
5481
  const prompt = _extractPrompt2(payload);
5825
5482
  if (!prompt) {
5826
- return EXIT_ALLOW3;
5483
+ return EXIT_ALLOW;
5827
5484
  }
5828
5485
  if (isSyntheticPrompt(prompt)) {
5829
- return EXIT_ALLOW3;
5486
+ return EXIT_ALLOW;
5830
5487
  }
5831
5488
  const root = _workspaceRoot(env);
5832
5489
  const platform = env["platform"];
5833
5490
  const hostId = typeof platform === "string" && platform ? platform : null;
5834
- const result = classifyPrompt(prompt, root, hostId);
5491
+ const result = classifyPrompt(prompt, root, hostId, {
5492
+ freeRouteAdmissible: (kind) => freeRungFor(root, kind, councilConfigPath())
5493
+ });
5835
5494
  if (!result) {
5836
- return EXIT_ALLOW3;
5495
+ return EXIT_ALLOW;
5837
5496
  }
5838
5497
  process.stdout.write(
5839
5498
  `${JSON.stringify({
5840
5499
  decision: "warn",
5841
5500
  reason: `delegation-nudge: rung-${result.rung} verdict (${result.sliceCount} slices, ${result.tier} tier)`,
5842
- additional_context: buildNudgeLine(result.rung, result.classification, result.sliceCount, result.tier)
5501
+ additional_context: buildNudgeLine(
5502
+ result.rung,
5503
+ result.classification,
5504
+ result.sliceCount,
5505
+ result.tier,
5506
+ result.sliceKind,
5507
+ result.handKind
5508
+ )
5843
5509
  })}
5844
5510
  `
5845
5511
  );
5846
- return EXIT_WARN2;
5512
+ return EXIT_WARN;
5847
5513
  }
5848
- function _isCliEntry8() {
5514
+ function _isCliEntry7() {
5849
5515
  if (true) {
5850
5516
  return false;
5851
5517
  }
5852
5518
  if (process.argv[1] === void 0) {
5853
5519
  return false;
5854
5520
  }
5855
- const argvUrl = pathToFileURL8(path13.resolve(process.argv[1])).href;
5521
+ const argvUrl = pathToFileURL7(path13.resolve(process.argv[1])).href;
5856
5522
  if (import.meta.url === argvUrl) {
5857
5523
  return true;
5858
5524
  }
5859
5525
  try {
5860
- const here = fs15.realpathSync(fileURLToPath8(import.meta.url));
5861
- const argv = fs15.realpathSync(path13.resolve(process.argv[1]));
5526
+ const here = fs16.realpathSync(fileURLToPath7(import.meta.url));
5527
+ const argv = fs16.realpathSync(path13.resolve(process.argv[1]));
5862
5528
  return here === argv;
5863
5529
  } catch {
5864
5530
  return false;
5865
5531
  }
5866
5532
  }
5867
- if (_isCliEntry8()) {
5868
- process.exit(main8());
5533
+ if (_isCliEntry7()) {
5534
+ process.exit(main7());
5869
5535
  }
5870
5536
 
5871
5537
  // src/scripts/conformance_scan.ts
5872
- var REPO_ROOT = path14.resolve(path14.dirname(fileURLToPath9(import.meta.url)), "..", "..");
5538
+ var REPO_ROOT = path14.resolve(path14.dirname(fileURLToPath8(import.meta.url)), "..", "..");
5873
5539
  var OBSERVED_BAND = { low: 9.1, high: 39.2 };
5874
5540
  var BAND_MIN_TURNS = 1978;
5875
5541
  var CARRIER_CHANGES = [
@@ -6255,13 +5921,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
6255
5921
  return {
6256
5922
  project: {
6257
5923
  dir: projectRulesDir,
6258
- present: fs16.existsSync(projectRulesDir),
5924
+ present: fs17.existsSync(projectRulesDir),
6259
5925
  files: p.files,
6260
5926
  tokens: _tokens(p.chars)
6261
5927
  },
6262
5928
  global: {
6263
5929
  dir: globalRulesDir,
6264
- present: fs16.existsSync(globalRulesDir),
5930
+ present: fs17.existsSync(globalRulesDir),
6265
5931
  files: g.files,
6266
5932
  tokens: _tokens(g.chars)
6267
5933
  },
@@ -6269,13 +5935,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
6269
5935
  };
6270
5936
  }
6271
5937
  function storeKey(store) {
6272
- return createHash5("sha256").update(path14.resolve(store)).digest("hex").slice(0, 12);
5938
+ return createHash4("sha256").update(path14.resolve(store)).digest("hex").slice(0, 12);
6273
5939
  }
6274
5940
  function scanStore(store, limit) {
6275
- const files = fs16.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, m: fs16.statSync(path14.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.f);
5941
+ const files = fs17.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, m: fs17.statSync(path14.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.f);
6276
5942
  const per_session = [];
6277
5943
  for (const f of files) {
6278
- const lines = fs16.readFileSync(path14.join(store, f), "utf8").split("\n");
5944
+ const lines = fs17.readFileSync(path14.join(store, f), "utf8").split("\n");
6279
5945
  const r = scanSession(f.replace(/\.jsonl$/, "").slice(0, 8), lines);
6280
5946
  if (r.assistant_turns > 0) {
6281
5947
  per_session.push(r);
@@ -6336,8 +6002,8 @@ function scanStore(store, limit) {
6336
6002
  };
6337
6003
  }
6338
6004
  function recordRate(file, scanned_at, rate) {
6339
- fs16.mkdirSync(path14.dirname(file), { recursive: true });
6340
- fs16.appendFileSync(file, `${JSON.stringify({ measured_at: scanned_at, ...rate })}
6005
+ fs17.mkdirSync(path14.dirname(file), { recursive: true });
6006
+ fs17.appendFileSync(file, `${JSON.stringify({ measured_at: scanned_at, ...rate })}
6341
6007
  `, "utf8");
6342
6008
  }
6343
6009
  function render(report) {
@@ -6436,7 +6102,7 @@ function render(report) {
6436
6102
  lines.push(" checkbox batching \u2014 measured NOWHERE. ~5 low-severity findings.");
6437
6103
  return lines.join("\n");
6438
6104
  }
6439
- function main9(argv) {
6105
+ function main8(argv) {
6440
6106
  const args = argv ?? process.argv.slice(2);
6441
6107
  let store = null;
6442
6108
  let limit = 30;
@@ -6468,14 +6134,14 @@ function main9(argv) {
6468
6134
  return 2;
6469
6135
  }
6470
6136
  const resolved = store ?? defaultStore(process.cwd());
6471
- if (!fs16.existsSync(resolved)) {
6137
+ if (!fs17.existsSync(resolved)) {
6472
6138
  process.stderr.write(`conformance:behavior: no transcript store at ${resolved}
6473
6139
  `);
6474
6140
  return 1;
6475
6141
  }
6476
6142
  const report = scanStore(resolved, Number.isFinite(limit) && limit > 0 ? limit : 30);
6477
6143
  if (out) {
6478
- fs16.writeFileSync(out, `${JSON.stringify(report, null, 2)}
6144
+ fs17.writeFileSync(out, `${JSON.stringify(report, null, 2)}
6479
6145
  `, "utf8");
6480
6146
  }
6481
6147
  if (record) {
@@ -6483,7 +6149,7 @@ function main9(argv) {
6483
6149
  }
6484
6150
  if (why !== null) {
6485
6151
  const id = why;
6486
- fs16.writeSync(
6152
+ fs17.writeSync(
6487
6153
  1,
6488
6154
  json ? `${JSON.stringify(
6489
6155
  {
@@ -6503,48 +6169,48 @@ function main9(argv) {
6503
6169
  );
6504
6170
  return 0;
6505
6171
  }
6506
- fs16.writeSync(1, json ? `${JSON.stringify(report, null, 2)}
6172
+ fs17.writeSync(1, json ? `${JSON.stringify(report, null, 2)}
6507
6173
  ` : `${render(report)}
6508
6174
  `);
6509
6175
  return 0;
6510
6176
  }
6511
- function _isCliEntry9() {
6177
+ function _isCliEntry8() {
6512
6178
  if (true) {
6513
6179
  return false;
6514
6180
  }
6515
6181
  if (process.argv[1] === void 0) {
6516
6182
  return false;
6517
6183
  }
6518
- const argvUrl = pathToFileURL9(path14.resolve(process.argv[1])).href;
6184
+ const argvUrl = pathToFileURL8(path14.resolve(process.argv[1])).href;
6519
6185
  if (import.meta.url === argvUrl) {
6520
6186
  return true;
6521
6187
  }
6522
6188
  try {
6523
- const here = fs16.realpathSync(fileURLToPath9(import.meta.url));
6524
- const argv = fs16.realpathSync(path14.resolve(process.argv[1]));
6189
+ const here = fs17.realpathSync(fileURLToPath8(import.meta.url));
6190
+ const argv = fs17.realpathSync(path14.resolve(process.argv[1]));
6525
6191
  return here === argv;
6526
6192
  } catch {
6527
6193
  return false;
6528
6194
  }
6529
6195
  }
6530
- if (_isCliEntry9()) {
6531
- process.exit(main9());
6196
+ if (_isCliEntry8()) {
6197
+ process.exit(main8());
6532
6198
  }
6533
6199
 
6534
6200
  // src/scripts/report_carrier_divergence.ts
6535
- import * as fs17 from "node:fs";
6201
+ import * as fs18 from "node:fs";
6536
6202
  import * as os3 from "node:os";
6537
6203
  import * as path15 from "node:path";
6538
6204
  import process2 from "node:process";
6539
- import { fileURLToPath as fileURLToPath10, pathToFileURL as pathToFileURL10 } from "node:url";
6540
- var _HERE2 = fileURLToPath10(import.meta.url);
6205
+ import { fileURLToPath as fileURLToPath9, pathToFileURL as pathToFileURL9 } from "node:url";
6206
+ var _HERE2 = fileURLToPath9(import.meta.url);
6541
6207
  var REPO_ROOT2 = path15.resolve(path15.dirname(_HERE2), "..", "..");
6542
6208
  var PROJECT_RULES = path15.join(".claude", "rules");
6543
6209
  var PROJECTION_SOURCE = path15.join("dist", "agent-src", "rules");
6544
6210
  var GLOBAL_RULES = path15.join(".claude", "rules");
6545
6211
  function _listRules(dir) {
6546
6212
  try {
6547
- return fs17.readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
6213
+ return fs18.readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
6548
6214
  } catch {
6549
6215
  return [];
6550
6216
  }
@@ -6552,7 +6218,7 @@ function _listRules(dir) {
6552
6218
  function _ruleType(file) {
6553
6219
  let text;
6554
6220
  try {
6555
- text = fs17.readFileSync(file, "utf-8");
6221
+ text = fs18.readFileSync(file, "utf-8");
6556
6222
  } catch {
6557
6223
  return "";
6558
6224
  }
@@ -6563,8 +6229,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
6563
6229
  const out = {
6564
6230
  projectDir,
6565
6231
  globalDir,
6566
- globalPresent: fs17.existsSync(globalDir),
6567
- projectPresent: fs17.existsSync(projectDir),
6232
+ globalPresent: fs18.existsSync(globalDir),
6233
+ projectPresent: fs18.existsSync(projectDir),
6568
6234
  shared: 0,
6569
6235
  identical: [],
6570
6236
  provenanceOnly: [],
@@ -6597,8 +6263,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
6597
6263
  let projectCopy;
6598
6264
  let globalCopy;
6599
6265
  try {
6600
- projectCopy = fs17.readFileSync(path15.join(projectDir, rule));
6601
- globalCopy = fs17.readFileSync(path15.join(globalDir, rule));
6266
+ projectCopy = fs18.readFileSync(path15.join(projectDir, rule));
6267
+ globalCopy = fs18.readFileSync(path15.join(globalDir, rule));
6602
6268
  verdict = comparePair(projectCopy, globalCopy);
6603
6269
  } catch {
6604
6270
  out.shared -= 1;
@@ -6743,7 +6409,7 @@ function render2(d) {
6743
6409
  }
6744
6410
  return lines.join("\n");
6745
6411
  }
6746
- function main10(argv) {
6412
+ function main9(argv) {
6747
6413
  const args = argv ?? process2.argv.slice(2);
6748
6414
  let projectDir = path15.join(REPO_ROOT2, PROJECT_RULES);
6749
6415
  let globalDir = path15.join(os3.homedir(), GLOBAL_RULES);
@@ -6781,25 +6447,25 @@ function main10(argv) {
6781
6447
  `);
6782
6448
  return 0;
6783
6449
  }
6784
- function _isCliEntry10() {
6450
+ function _isCliEntry9() {
6785
6451
  if (process2.argv[1] === void 0) return false;
6786
- if (import.meta.url === pathToFileURL10(path15.resolve(process2.argv[1])).href) return true;
6452
+ if (import.meta.url === pathToFileURL9(path15.resolve(process2.argv[1])).href) return true;
6787
6453
  try {
6788
- return fs17.realpathSync(_HERE2) === fs17.realpathSync(path15.resolve(process2.argv[1]));
6454
+ return fs18.realpathSync(_HERE2) === fs18.realpathSync(path15.resolve(process2.argv[1]));
6789
6455
  } catch {
6790
6456
  return false;
6791
6457
  }
6792
6458
  }
6793
- if (_isCliEntry10()) {
6794
- process2.exit(main10());
6459
+ if (_isCliEntry9()) {
6460
+ process2.exit(main9());
6795
6461
  }
6796
6462
 
6797
6463
  // src/scripts/report_skill_activation.ts
6798
- import * as fs18 from "node:fs";
6464
+ import * as fs19 from "node:fs";
6799
6465
  import * as os4 from "node:os";
6800
6466
  import * as path16 from "node:path";
6801
- import { fileURLToPath as fileURLToPath11, pathToFileURL as pathToFileURL11 } from "node:url";
6802
- var _HERE3 = fileURLToPath11(import.meta.url);
6467
+ import { fileURLToPath as fileURLToPath10, pathToFileURL as pathToFileURL10 } from "node:url";
6468
+ var _HERE3 = fileURLToPath10(import.meta.url);
6803
6469
  var REPO_ROOT3 = path16.resolve(path16.dirname(_HERE3), "..", "..");
6804
6470
  var SKILLS_ROOT = "src/skills";
6805
6471
  var TRIGGER_KEYS = ["triggers:", "trigger_description:", "file_pattern:", "path_prefix:"];
@@ -6811,25 +6477,25 @@ function censusSkills(root) {
6811
6477
  withTriggerCorpus: [],
6812
6478
  withDeterministicObligation: []
6813
6479
  };
6814
- if (!fs18.existsSync(root)) {
6480
+ if (!fs19.existsSync(root)) {
6815
6481
  return out;
6816
6482
  }
6817
- for (const entry of fs18.readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
6483
+ for (const entry of fs19.readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
6818
6484
  if (!entry.isDirectory()) {
6819
6485
  continue;
6820
6486
  }
6821
6487
  const file = path16.join(root, entry.name, "SKILL.md");
6822
- if (!fs18.existsSync(file)) {
6488
+ if (!fs19.existsSync(file)) {
6823
6489
  continue;
6824
6490
  }
6825
6491
  out.total += 1;
6826
- const text = fs18.readFileSync(file, "utf8");
6492
+ const text = fs19.readFileSync(file, "utf8");
6827
6493
  const fmEnd = text.startsWith("---") ? text.indexOf("\n---", 3) : -1;
6828
6494
  const fm = fmEnd === -1 ? "" : text.slice(0, fmEnd);
6829
6495
  if (TRIGGER_KEYS.some((k) => new RegExp(`^${k}`, "m").test(fm))) {
6830
6496
  out.withTriggerKey.push(entry.name);
6831
6497
  }
6832
- if (fs18.existsSync(path16.join(root, entry.name, "evals", "triggers.json"))) {
6498
+ if (fs19.existsSync(path16.join(root, entry.name, "evals", "triggers.json"))) {
6833
6499
  out.withTriggerCorpus.push(entry.name);
6834
6500
  }
6835
6501
  const body = fmEnd === -1 ? text : text.slice(fmEnd + 4);
@@ -6844,13 +6510,13 @@ function defaultStore2(cwd) {
6844
6510
  }
6845
6511
  function measureUsage(store, limit) {
6846
6512
  const rep = { store, sessions: 0, assistantTurns: 0, invocations: 0, bySkill: {} };
6847
- if (!fs18.existsSync(store)) {
6513
+ if (!fs19.existsSync(store)) {
6848
6514
  return rep;
6849
6515
  }
6850
- const files = fs18.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => path16.join(store, f)).sort((a, b) => fs18.statSync(b).mtimeMs - fs18.statSync(a).mtimeMs).slice(0, limit);
6516
+ const files = fs19.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => path16.join(store, f)).sort((a, b) => fs19.statSync(b).mtimeMs - fs19.statSync(a).mtimeMs).slice(0, limit);
6851
6517
  rep.sessions = files.length;
6852
6518
  for (const file of files) {
6853
- for (const line of fs18.readFileSync(file, "utf8").split("\n")) {
6519
+ for (const line of fs19.readFileSync(file, "utf8").split("\n")) {
6854
6520
  if (!line.trim()) {
6855
6521
  continue;
6856
6522
  }
@@ -6928,10 +6594,10 @@ function buildRecord(census, usage, today) {
6928
6594
  }
6929
6595
  function readRecord(repoRoot) {
6930
6596
  const file = path16.join(repoRoot, RECORD_PATH);
6931
- if (!fs18.existsSync(file)) {
6597
+ if (!fs19.existsSync(file)) {
6932
6598
  return null;
6933
6599
  }
6934
- return JSON.parse(fs18.readFileSync(file, "utf8"));
6600
+ return JSON.parse(fs19.readFileSync(file, "utf8"));
6935
6601
  }
6936
6602
  function render3(census, usage, published = null) {
6937
6603
  const lines = [];
@@ -7037,7 +6703,7 @@ function render3(census, usage, published = null) {
7037
6703
  return lines.join("\n");
7038
6704
  }
7039
6705
  var USAGE2 = "usage: report_skill_activation [--root DIR] [--limit N] [--store PATH]... [--emit] [--allow-empty-store]\n";
7040
- function main11(argv) {
6706
+ function main10(argv) {
7041
6707
  let limit = 30;
7042
6708
  let emit = false;
7043
6709
  let allowEmpty = false;
@@ -7092,25 +6758,25 @@ function main11(argv) {
7092
6758
  }
7093
6759
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
7094
6760
  const file = path16.join(root, RECORD_PATH);
7095
- fs18.mkdirSync(path16.dirname(file), { recursive: true });
7096
- fs18.writeFileSync(file, `${JSON.stringify(buildRecord(census, usage, today), null, 2)}
6761
+ fs19.mkdirSync(path16.dirname(file), { recursive: true });
6762
+ fs19.writeFileSync(file, `${JSON.stringify(buildRecord(census, usage, today), null, 2)}
7097
6763
  `);
7098
6764
  process.stdout.write(`
7099
6765
  wrote ${RECORD_PATH} (measured ${today})
7100
6766
  `);
7101
6767
  return 0;
7102
6768
  }
7103
- if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL11(path16.resolve(process.argv[1])).href) {
7104
- process.exit(main11(process.argv.slice(2)));
6769
+ if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL10(path16.resolve(process.argv[1])).href) {
6770
+ process.exit(main10(process.argv.slice(2)));
7105
6771
  }
7106
6772
 
7107
6773
  // src/scripts/report_skill_obligation_violations.ts
7108
- import * as fs19 from "node:fs";
6774
+ import * as fs20 from "node:fs";
7109
6775
  import * as os5 from "node:os";
7110
6776
  import * as path17 from "node:path";
7111
6777
  import process3 from "node:process";
7112
- import { fileURLToPath as fileURLToPath12, pathToFileURL as pathToFileURL12 } from "node:url";
7113
- var _HERE4 = fileURLToPath12(import.meta.url);
6778
+ import { fileURLToPath as fileURLToPath11, pathToFileURL as pathToFileURL11 } from "node:url";
6779
+ var _HERE4 = fileURLToPath11(import.meta.url);
7114
6780
  var REPO_ROOT4 = path17.resolve(path17.dirname(_HERE4), "..", "..");
7115
6781
  var OBLIGATION_LINE_RE = new RegExp(`${DETERMINISTIC_RE.source}.*`, "gm");
7116
6782
  var PATH_RE = /`([A-Za-z0-9_./-]*\/[A-Za-z0-9_.-]+\.[a-z]{2,6})`/g;
@@ -7163,7 +6829,7 @@ function extractObligations(repoRoot) {
7163
6829
  for (const skill of census.withDeterministicObligation) {
7164
6830
  let text;
7165
6831
  try {
7166
- text = fs19.readFileSync(path17.join(skillsRoot, skill, "SKILL.md"), "utf-8");
6832
+ text = fs20.readFileSync(path17.join(skillsRoot, skill, "SKILL.md"), "utf-8");
7167
6833
  } catch {
7168
6834
  continue;
7169
6835
  }
@@ -7292,13 +6958,13 @@ function scanStore2(repoRoot, store, limit) {
7292
6958
  };
7293
6959
  let files;
7294
6960
  try {
7295
- files = fs19.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ p: path17.join(store, f), m: fs19.statSync(path17.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.p);
6961
+ files = fs20.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ p: path17.join(store, f), m: fs20.statSync(path17.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.p);
7296
6962
  } catch {
7297
6963
  return report;
7298
6964
  }
7299
6965
  report.sessions = files.length;
7300
6966
  for (const file of files) {
7301
- const lines = fs19.readFileSync(file, "utf-8").split("\n");
6967
+ const lines = fs20.readFileSync(file, "utf-8").split("\n");
7302
6968
  const id = path17.basename(file).replace(/\.jsonl$/, "").slice(0, 8);
7303
6969
  const entries = _parseSession(lines);
7304
6970
  if (loadedSkillsFrom(entries).size > 0) report.sessionsWithASkill += 1;
@@ -7369,7 +7035,7 @@ function render4(r) {
7369
7035
  lines.push(" ships as detection-only, and this one says so.");
7370
7036
  return lines.join("\n");
7371
7037
  }
7372
- function main12(argv) {
7038
+ function main11(argv) {
7373
7039
  const args = argv ?? process3.argv.slice(2);
7374
7040
  let limit = 30;
7375
7041
  let json = false;
@@ -7422,21 +7088,21 @@ function main12(argv) {
7422
7088
  }
7423
7089
  return 0;
7424
7090
  }
7425
- function _isCliEntry11() {
7091
+ function _isCliEntry10() {
7426
7092
  if (process3.argv[1] === void 0) return false;
7427
- if (import.meta.url === pathToFileURL12(path17.resolve(process3.argv[1])).href) return true;
7093
+ if (import.meta.url === pathToFileURL11(path17.resolve(process3.argv[1])).href) return true;
7428
7094
  try {
7429
- return fs19.realpathSync(_HERE4) === fs19.realpathSync(path17.resolve(process3.argv[1]));
7095
+ return fs20.realpathSync(_HERE4) === fs20.realpathSync(path17.resolve(process3.argv[1]));
7430
7096
  } catch {
7431
7097
  return false;
7432
7098
  }
7433
7099
  }
7434
- if (_isCliEntry11()) {
7435
- process3.exit(main12());
7100
+ if (_isCliEntry10()) {
7101
+ process3.exit(main11());
7436
7102
  }
7437
7103
 
7438
7104
  // src/scripts/report_conformance_funnel.ts
7439
- var _HERE5 = fileURLToPath13(import.meta.url);
7105
+ var _HERE5 = fileURLToPath12(import.meta.url);
7440
7106
  var REPO_ROOT5 = path18.resolve(path18.dirname(_HERE5), "..", "..");
7441
7107
  function buildFunnel(opts = {}) {
7442
7108
  const repoRoot = opts.repoRoot ?? REPO_ROOT5;
@@ -7450,7 +7116,7 @@ function buildFunnel(opts = {}) {
7450
7116
  divergence: compareCarriers(projectRulesDir, globalRulesDir, sourceDir),
7451
7117
  skills: censusSkills(path18.join(repoRoot, SKILLS_ROOT)),
7452
7118
  usage: measureUsage(store, limit),
7453
- storePresent: fs20.existsSync(store),
7119
+ storePresent: fs21.existsSync(store),
7454
7120
  sk2: scanStore2(repoRoot, store, limit)
7455
7121
  };
7456
7122
  }
@@ -7575,7 +7241,7 @@ function render5(r) {
7575
7241
  lines.push("workflow without a measured false-positive rate first (locked policy).");
7576
7242
  return lines.join("\n");
7577
7243
  }
7578
- function main13(argv) {
7244
+ function main12(argv) {
7579
7245
  const args = argv ?? process4.argv.slice(2);
7580
7246
  const opts = {};
7581
7247
  const value = (i) => {
@@ -7621,21 +7287,21 @@ function main13(argv) {
7621
7287
  `);
7622
7288
  return 0;
7623
7289
  }
7624
- function _isCliEntry12() {
7290
+ function _isCliEntry11() {
7625
7291
  if (process4.argv[1] === void 0) return false;
7626
- if (import.meta.url === pathToFileURL13(path18.resolve(process4.argv[1])).href) return true;
7292
+ if (import.meta.url === pathToFileURL12(path18.resolve(process4.argv[1])).href) return true;
7627
7293
  try {
7628
- return fs20.realpathSync(_HERE5) === fs20.realpathSync(path18.resolve(process4.argv[1]));
7294
+ return fs21.realpathSync(_HERE5) === fs21.realpathSync(path18.resolve(process4.argv[1]));
7629
7295
  } catch {
7630
7296
  return false;
7631
7297
  }
7632
7298
  }
7633
- if (_isCliEntry12()) {
7634
- process4.exit(main13());
7299
+ if (_isCliEntry11()) {
7300
+ process4.exit(main12());
7635
7301
  }
7636
7302
 
7637
7303
  // src/scripts/_cli/cmd_conformance.ts
7638
- var _HERE6 = fileURLToPath14(import.meta.url);
7304
+ var _HERE6 = fileURLToPath13(import.meta.url);
7639
7305
  var PACKAGE_ROOT = resolvePackageRoot(import.meta.url);
7640
7306
  var CONFORMANCE_CHECK_IDS = [
7641
7307
  "txlog-clean",
@@ -7672,10 +7338,10 @@ function installLogPath() {
7672
7338
  return path19.join(os7.homedir(), ".event4u", "agent-config", "install-log.jsonl");
7673
7339
  }
7674
7340
  function _installLogExpected(projectRoot) {
7675
- return fs21.existsSync(manifest_path(projectRoot));
7341
+ return fs22.existsSync(manifest_path(projectRoot));
7676
7342
  }
7677
7343
  function _check_txlog_clean(logPath = installLogPath(), projectRoot = null) {
7678
- const entries = fs21.existsSync(logPath) ? readRecentEntries(logPath) : [];
7344
+ const entries = fs22.existsSync(logPath) ? readRecentEntries(logPath) : [];
7679
7345
  if (entries.length === 0) {
7680
7346
  if (projectRoot !== null && _installLogExpected(projectRoot)) {
7681
7347
  return {
@@ -7713,7 +7379,7 @@ function routeTargetPaths(target) {
7713
7379
  }
7714
7380
  function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
7715
7381
  const routerPath = path19.join(packageRoot, "dist", "router.json");
7716
- if (!fs21.existsSync(routerPath)) {
7382
+ if (!fs22.existsSync(routerPath)) {
7717
7383
  return {
7718
7384
  id: "router-pointers",
7719
7385
  status: "fail",
@@ -7723,7 +7389,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
7723
7389
  }
7724
7390
  let router;
7725
7391
  try {
7726
- router = JSON.parse(fs21.readFileSync(routerPath, "utf8"));
7392
+ router = JSON.parse(fs22.readFileSync(routerPath, "utf8"));
7727
7393
  } catch (exc) {
7728
7394
  return {
7729
7395
  id: "router-pointers",
@@ -7738,7 +7404,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
7738
7404
  let targets = 0;
7739
7405
  for (const kernelId of router["kernel"] ?? []) {
7740
7406
  ids += 1;
7741
- if (!fs21.existsSync(path19.join(rulesDir, `${kernelId}.md`))) {
7407
+ if (!fs22.existsSync(path19.join(rulesDir, `${kernelId}.md`))) {
7742
7408
  broken.push(`kernel:${kernelId} \u2192 rules/${kernelId}.md missing`);
7743
7409
  }
7744
7410
  }
@@ -7746,7 +7412,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
7746
7412
  for (const entry of router[tier] ?? []) {
7747
7413
  const ruleId = String(entry["id"] ?? "");
7748
7414
  ids += 1;
7749
- if (!fs21.existsSync(path19.join(rulesDir, `${ruleId}.md`))) {
7415
+ if (!fs22.existsSync(path19.join(rulesDir, `${ruleId}.md`))) {
7750
7416
  broken.push(`${tier}:${ruleId} \u2192 rules/${ruleId}.md missing`);
7751
7417
  }
7752
7418
  for (const target of entry["routes_to"] ?? []) {
@@ -7756,7 +7422,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
7756
7422
  broken.push(`${ruleId} \u2192 unparseable routes_to ${JSON.stringify(target)}`);
7757
7423
  continue;
7758
7424
  }
7759
- if (!candidates.some((rel2) => fs21.existsSync(path19.join(packageRoot, rel2)))) {
7425
+ if (!candidates.some((rel2) => fs22.existsSync(path19.join(packageRoot, rel2)))) {
7760
7426
  broken.push(`${ruleId} \u2192 ${target} (${candidates[0]} missing)`);
7761
7427
  }
7762
7428
  }
@@ -7790,7 +7456,7 @@ function detectSmokePlatform(projectRoot) {
7790
7456
  function dispatcherRunner(packageRoot) {
7791
7457
  const localTsx = path19.join(packageRoot, "node_modules", ".bin", "tsx");
7792
7458
  const script = path19.join(packageRoot, "src", "scripts", "hooks", "dispatch_hook.ts");
7793
- if (fs21.existsSync(localTsx)) {
7459
+ if (fs22.existsSync(localTsx)) {
7794
7460
  return [localTsx, script];
7795
7461
  }
7796
7462
  return ["npx", "tsx", script];
@@ -7841,11 +7507,11 @@ function _check_hook_dispatcher(projectRoot, packageRoot = PACKAGE_ROOT, opts =
7841
7507
  }
7842
7508
  function readSettingsMode(projectRoot) {
7843
7509
  const settingsPath = path19.join(projectRoot, ".agent-settings.yml");
7844
- if (!fs21.existsSync(settingsPath)) {
7510
+ if (!fs22.existsSync(settingsPath)) {
7845
7511
  return "eager-all";
7846
7512
  }
7847
7513
  try {
7848
- const parsed = YAML.parse(fs21.readFileSync(settingsPath, "utf8"));
7514
+ const parsed = YAML.parse(fs22.readFileSync(settingsPath, "utf8"));
7849
7515
  const lean = parsed?.["lean_projection"] ?? null;
7850
7516
  const mode = lean?.["mode"];
7851
7517
  return typeof mode === "string" && mode.length > 0 ? mode : "eager-all";
@@ -7856,7 +7522,7 @@ function readSettingsMode(projectRoot) {
7856
7522
  function kernelIdsFromRouter(packageRoot) {
7857
7523
  try {
7858
7524
  const router = JSON.parse(
7859
- fs21.readFileSync(path19.join(packageRoot, "dist", "router.json"), "utf8")
7525
+ fs22.readFileSync(path19.join(packageRoot, "dist", "router.json"), "utf8")
7860
7526
  );
7861
7527
  return new Set((router["kernel"] ?? []).map(String));
7862
7528
  } catch {
@@ -7874,7 +7540,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
7874
7540
  };
7875
7541
  }
7876
7542
  const rulesDir = projectedRulesDir ?? path19.join(projectRoot, ".augment", "rules");
7877
- if (!fs21.existsSync(rulesDir)) {
7543
+ if (!fs22.existsSync(rulesDir)) {
7878
7544
  return {
7879
7545
  id: "lean-projection",
7880
7546
  status: "skipped",
@@ -7883,7 +7549,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
7883
7549
  };
7884
7550
  }
7885
7551
  const kernel = kernelIdsFromRouter(packageRoot);
7886
- const files = fs21.readdirSync(rulesDir).filter((f) => f.endsWith(".md") && f !== "INDEX.md").sort();
7552
+ const files = fs22.readdirSync(rulesDir).filter((f) => f.endsWith(".md") && f !== "INDEX.md").sort();
7887
7553
  const nonKernel = files.filter((f) => !kernel.has(f.replace(/\.md$/, "")));
7888
7554
  if (nonKernel.length === 0) {
7889
7555
  return {
@@ -7897,7 +7563,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
7897
7563
  for (const f of nonKernel) {
7898
7564
  let text = "";
7899
7565
  try {
7900
- text = fs21.readFileSync(path19.join(rulesDir, f), "utf8");
7566
+ text = fs22.readFileSync(path19.join(rulesDir, f), "utf8");
7901
7567
  } catch {
7902
7568
  continue;
7903
7569
  }
@@ -7929,7 +7595,7 @@ function _check_host_manifest(projectRoot) {
7929
7595
  const detected = Object.entries(detectToolPresence(projectRoot)).filter(([, v]) => v === true).map(([k]) => k);
7930
7596
  const detectedNote = detected.length > 0 ? `detected surfaces: ${detected.join(", ")}` : "no surfaces detected";
7931
7597
  const settingsPath = path19.join(projectRoot, ".agent-settings.yml");
7932
- if (!fs21.existsSync(settingsPath)) {
7598
+ if (!fs22.existsSync(settingsPath)) {
7933
7599
  return {
7934
7600
  id: "host-manifest",
7935
7601
  status: "ok",
@@ -7939,7 +7605,7 @@ function _check_host_manifest(projectRoot) {
7939
7605
  }
7940
7606
  let parsed = null;
7941
7607
  try {
7942
- parsed = YAML.parse(fs21.readFileSync(settingsPath, "utf8"));
7608
+ parsed = YAML.parse(fs22.readFileSync(settingsPath, "utf8"));
7943
7609
  } catch (exc) {
7944
7610
  return {
7945
7611
  id: "host-manifest",
@@ -8038,7 +7704,7 @@ function _parse(argv) {
8038
7704
  }
8039
7705
  return opts;
8040
7706
  }
8041
- function main14(argv = null) {
7707
+ function main13(argv = null) {
8042
7708
  const opts = _parse(argv !== null ? Array.from(argv) : process5.argv.slice(2));
8043
7709
  if (opts.funnel) {
8044
7710
  print(render5(buildFunnel()));
@@ -8109,25 +7775,25 @@ function main14(argv = null) {
8109
7775
  }
8110
7776
  return failed ? 1 : 0;
8111
7777
  }
8112
- function _isCliEntry13() {
7778
+ function _isCliEntry12() {
8113
7779
  if (process5.argv[1] === void 0) {
8114
7780
  return false;
8115
7781
  }
8116
- const argvUrl = pathToFileURL14(path19.resolve(process5.argv[1])).href;
7782
+ const argvUrl = pathToFileURL13(path19.resolve(process5.argv[1])).href;
8117
7783
  if (import.meta.url === argvUrl) {
8118
7784
  return true;
8119
7785
  }
8120
7786
  try {
8121
- const here = fs21.realpathSync(fileURLToPath14(import.meta.url));
8122
- const argv = fs21.realpathSync(path19.resolve(process5.argv[1]));
7787
+ const here = fs22.realpathSync(fileURLToPath13(import.meta.url));
7788
+ const argv = fs22.realpathSync(path19.resolve(process5.argv[1]));
8123
7789
  return here === argv;
8124
7790
  } catch {
8125
7791
  return false;
8126
7792
  }
8127
7793
  }
8128
- if (_isCliEntry13() || process5.argv[1] === _HERE6) {
7794
+ if (_isCliEntry12() || process5.argv[1] === _HERE6) {
8129
7795
  try {
8130
- process5.exitCode = main14(process5.argv.slice(2));
7796
+ process5.exitCode = main13(process5.argv.slice(2));
8131
7797
  } catch (e) {
8132
7798
  if (e instanceof ArgparseExit) {
8133
7799
  process5.exitCode = e.code;
@@ -8151,7 +7817,7 @@ export {
8151
7817
  conformanceLogPath,
8152
7818
  detectSmokePlatform,
8153
7819
  installLogPath,
8154
- main14 as main,
7820
+ main13 as main,
8155
7821
  routeTargetPaths,
8156
7822
  runConformanceChecks
8157
7823
  };