peaks-loop 4.0.54 → 4.1.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 (1028) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README-en.md +16 -1
  3. package/README.md +15 -1
  4. package/config/eslint/.peaks-rules.cjs +158 -13
  5. package/config/eslint/tsconfig.lint.json +47 -0
  6. package/dist/cli/cli-envelope.d.ts +114 -0
  7. package/dist/cli/cli-envelope.js +85 -0
  8. package/dist/cli/cli-helpers.d.ts +1 -1
  9. package/dist/cli/cli-helpers.js +8 -4
  10. package/dist/cli/commands/_cli-error-envelope.js +1 -1
  11. package/dist/cli/commands/_register.js +85 -38
  12. package/dist/cli/commands/_super.js +40 -7
  13. package/dist/cli/commands/adapter-commands-s2a.js +8 -7
  14. package/dist/cli/commands/adapter-commands.d.ts +2 -2
  15. package/dist/cli/commands/adapter-commands.js +7 -8
  16. package/dist/cli/commands/api-diff-commands.js +5 -4
  17. package/dist/cli/commands/asset-commands.d.ts +2 -2
  18. package/dist/cli/commands/asset-commands.js +135 -132
  19. package/dist/cli/commands/audit-commands.d.ts +1 -1
  20. package/dist/cli/commands/audit-commands.js +75 -32
  21. package/dist/cli/commands/autonomous-swarm-commands.d.ts +1 -1
  22. package/dist/cli/commands/autonomous-swarm-commands.js +14 -8
  23. package/dist/cli/commands/baseline-commands.js +34 -9
  24. package/dist/cli/commands/bee-commands.d.ts +1 -1
  25. package/dist/cli/commands/bee-commands.js +18 -21
  26. package/dist/cli/commands/best-practice-scan-command.js +6 -34
  27. package/dist/cli/commands/best-practice-scan-helpers.d.ts +12 -0
  28. package/dist/cli/commands/best-practice-scan-helpers.js +37 -0
  29. package/dist/cli/commands/capability-commands.d.ts +1 -1
  30. package/dist/cli/commands/capability-commands.js +14 -4
  31. package/dist/cli/commands/capability-worker-config-sc-commands.d.ts +1 -1
  32. package/dist/cli/commands/changeset-commands.js +21 -18
  33. package/dist/cli/commands/code-gate-command.js +9 -2
  34. package/dist/cli/commands/code-job-shape-commands-read-job-shape.d.ts +15 -0
  35. package/dist/cli/commands/code-job-shape-commands-read-job-shape.js +70 -0
  36. package/dist/cli/commands/code-job-shape-commands.js +21 -45
  37. package/dist/cli/commands/code-mode-gate-commands.d.ts +15 -1
  38. package/dist/cli/commands/code-mode-gate-commands.js +19 -199
  39. package/dist/cli/commands/code-mode-gate-plan-command.d.ts +14 -0
  40. package/dist/cli/commands/code-mode-gate-plan-command.js +23 -0
  41. package/dist/cli/commands/code-mode-gate-should-pause-command.d.ts +24 -0
  42. package/dist/cli/commands/code-mode-gate-should-pause-command.js +137 -0
  43. package/dist/cli/commands/code-mode-gate-should-pause-envelope.d.ts +59 -0
  44. package/dist/cli/commands/code-mode-gate-should-pause-envelope.js +144 -0
  45. package/dist/cli/commands/code-orchestrator-can-do.js +4 -4
  46. package/dist/cli/commands/code-review-commands.js +18 -3
  47. package/dist/cli/commands/code-run-command.js +44 -7
  48. package/dist/cli/commands/code-runtime-commands.d.ts +17 -0
  49. package/dist/cli/commands/code-runtime-commands.js +105 -73
  50. package/dist/cli/commands/codegraph-commands.js +11 -6
  51. package/dist/cli/commands/codegraph-status-command.js +6 -2
  52. package/dist/cli/commands/compact-command.js +52 -26
  53. package/dist/cli/commands/complexity-commands.js +6 -7
  54. package/dist/cli/commands/config-commands.d.ts +1 -1
  55. package/dist/cli/commands/config-commands.js +33 -9
  56. package/dist/cli/commands/container-commands.js +39 -15
  57. package/dist/cli/commands/context-commands.d.ts +1 -1
  58. package/dist/cli/commands/context-commands.js +40 -13
  59. package/dist/cli/commands/core/artifacts-command.js +11 -3
  60. package/dist/cli/commands/core/binding-commands.js +9 -6
  61. package/dist/cli/commands/core/doctor-command.js +7 -4
  62. package/dist/cli/commands/core/memory-command.js +47 -21
  63. package/dist/cli/commands/core/proxy-command.js +3 -1
  64. package/dist/cli/commands/core/session-command.js +16 -8
  65. package/dist/cli/commands/core/skill-command.js +31 -16
  66. package/dist/cli/commands/core/standards-command.js +55 -13
  67. package/dist/cli/commands/cron-commands-actions.d.ts +43 -0
  68. package/dist/cli/commands/cron-commands-actions.js +128 -0
  69. package/dist/cli/commands/cron-commands-schedule.d.ts +86 -0
  70. package/dist/cli/commands/cron-commands-schedule.js +151 -0
  71. package/dist/cli/commands/cron-commands.d.ts +35 -32
  72. package/dist/cli/commands/cron-commands.js +167 -211
  73. package/dist/cli/commands/cron-scheduler-commands.js +40 -20
  74. package/dist/cli/commands/cron-scheduler-persist.d.ts +110 -0
  75. package/dist/cli/commands/cron-scheduler-persist.js +171 -0
  76. package/dist/cli/commands/dashboard-long-run.js +45 -14
  77. package/dist/cli/commands/dashboard-summary.js +15 -5
  78. package/dist/cli/commands/dispatch-commands.js +65 -32
  79. package/dist/cli/commands/dispatch-from-dag.js +9 -10
  80. package/dist/cli/commands/doc-commands.js +8 -9
  81. package/dist/cli/commands/doctor/invoke-from-code.js +1 -1
  82. package/dist/cli/commands/e2e-verify-env.d.ts +19 -0
  83. package/dist/cli/commands/e2e-verify-env.js +19 -0
  84. package/dist/cli/commands/e2e-verify.d.ts +3 -14
  85. package/dist/cli/commands/e2e-verify.js +49 -29
  86. package/dist/cli/commands/ecc-commands.d.ts +1 -1
  87. package/dist/cli/commands/ecc-commands.js +8 -17
  88. package/dist/cli/commands/evidence-commands.js +10 -6
  89. package/dist/cli/commands/evolution-commands.d.ts +2 -2
  90. package/dist/cli/commands/evolution-commands.js +109 -115
  91. package/dist/cli/commands/feedback-commands-helpers.d.ts +22 -0
  92. package/dist/cli/commands/feedback-commands-helpers.js +33 -0
  93. package/dist/cli/commands/feedback-commands.js +15 -38
  94. package/dist/cli/commands/final-review-commands.d.ts +1 -1
  95. package/dist/cli/commands/final-review-commands.js +24 -22
  96. package/dist/cli/commands/fixture-commands.d.ts +1 -1
  97. package/dist/cli/commands/fixture-commands.js +17 -6
  98. package/dist/cli/commands/fork-commands-sync-verify.d.ts +12 -0
  99. package/dist/cli/commands/fork-commands-sync-verify.js +72 -0
  100. package/dist/cli/commands/fork-commands.js +19 -51
  101. package/dist/cli/commands/fresh-context-commands.js +3 -1
  102. package/dist/cli/commands/gate-commands-enforce.d.ts +82 -0
  103. package/dist/cli/commands/gate-commands-enforce.js +210 -0
  104. package/dist/cli/commands/gate-commands.d.ts +1 -1
  105. package/dist/cli/commands/gate-commands.js +85 -205
  106. package/dist/cli/commands/governance-classify-contract-commands.d.ts +1 -1
  107. package/dist/cli/commands/governance-classify-contract-commands.js +28 -17
  108. package/dist/cli/commands/heartbeat-commands-action.d.ts +7 -0
  109. package/dist/cli/commands/heartbeat-commands-action.js +192 -0
  110. package/dist/cli/commands/heartbeat-commands-validation.d.ts +57 -0
  111. package/dist/cli/commands/heartbeat-commands-validation.js +120 -0
  112. package/dist/cli/commands/heartbeat-commands.d.ts +27 -6
  113. package/dist/cli/commands/heartbeat-commands.js +19 -198
  114. package/dist/cli/commands/hook-handle.d.ts +1 -1
  115. package/dist/cli/commands/hook-handle.js +46 -13
  116. package/dist/cli/commands/hooks-commands.d.ts +1 -1
  117. package/dist/cli/commands/hooks-commands.js +18 -6
  118. package/dist/cli/commands/ide-commands.d.ts +1 -1
  119. package/dist/cli/commands/ide-commands.js +5 -3
  120. package/dist/cli/commands/impact-commands.js +8 -2
  121. package/dist/cli/commands/job-add-slice-command.d.ts +43 -0
  122. package/dist/cli/commands/job-add-slice-command.js +151 -0
  123. package/dist/cli/commands/job-commands.d.ts +64 -0
  124. package/dist/cli/commands/job-commands.js +134 -63
  125. package/dist/cli/commands/lease-metrics-commands-support.d.ts +73 -0
  126. package/dist/cli/commands/lease-metrics-commands-support.js +67 -0
  127. package/dist/cli/commands/lease-metrics-commands.d.ts +3 -44
  128. package/dist/cli/commands/lease-metrics-commands.js +21 -61
  129. package/dist/cli/commands/lease-stats-commands.d.ts +1 -1
  130. package/dist/cli/commands/lease-stats-commands.js +9 -6
  131. package/dist/cli/commands/lint-commands.d.ts +9 -3
  132. package/dist/cli/commands/lint-commands.js +15 -8
  133. package/dist/cli/commands/log-commands.d.ts +1 -1
  134. package/dist/cli/commands/log-commands.js +8 -6
  135. package/dist/cli/commands/loop-commands.d.ts +1 -1
  136. package/dist/cli/commands/loop-commands.js +50 -50
  137. package/dist/cli/commands/loop-eval-commands.d.ts +1 -1
  138. package/dist/cli/commands/loop-eval-commands.js +101 -30
  139. package/dist/cli/commands/memory-commands.js +21 -13
  140. package/dist/cli/commands/migrate-1-4-1-command.js +1 -1
  141. package/dist/cli/commands/migrate-v2-10-to-v2-11-command.js +2 -2
  142. package/dist/cli/commands/mut-commands-helpers.d.ts +30 -0
  143. package/dist/cli/commands/mut-commands-helpers.js +43 -0
  144. package/dist/cli/commands/mut-commands.js +16 -58
  145. package/dist/cli/commands/observability-commands-queries.d.ts +37 -0
  146. package/dist/cli/commands/observability-commands-queries.js +113 -0
  147. package/dist/cli/commands/observability-commands.d.ts +1 -1
  148. package/dist/cli/commands/observability-commands.js +7 -92
  149. package/dist/cli/commands/openspec-commands.d.ts +1 -1
  150. package/dist/cli/commands/openspec-commands.js +20 -8
  151. package/dist/cli/commands/outer-cache-commands.js +18 -7
  152. package/dist/cli/commands/perf-audit-commands.d.ts +1 -1
  153. package/dist/cli/commands/perf-audit-commands.js +12 -7
  154. package/dist/cli/commands/perf-commands.d.ts +1 -1
  155. package/dist/cli/commands/perf-commands.js +5 -5
  156. package/dist/cli/commands/playwright-commands.d.ts +1 -1
  157. package/dist/cli/commands/playwright-commands.js +20 -8
  158. package/dist/cli/commands/polyrepo-commands.js +21 -19
  159. package/dist/cli/commands/prd-blocks-commands.js +1 -3
  160. package/dist/cli/commands/prd-commands.d.ts +1 -1
  161. package/dist/cli/commands/prd-commands.js +8 -4
  162. package/dist/cli/commands/preferences-commands.js +13 -12
  163. package/dist/cli/commands/primer-command.js +5 -5
  164. package/dist/cli/commands/project-commands.d.ts +1 -1
  165. package/dist/cli/commands/project-commands.js +33 -9
  166. package/dist/cli/commands/qa-business-review-commands.js +16 -12
  167. package/dist/cli/commands/qa-commands.d.ts +1 -1
  168. package/dist/cli/commands/qa-commands.js +3 -5
  169. package/dist/cli/commands/release-commands.d.ts +3 -1
  170. package/dist/cli/commands/release-commands.js +33 -22
  171. package/dist/cli/commands/request-commands.js +47 -30
  172. package/dist/cli/commands/request-format-helpers.js +1 -1
  173. package/dist/cli/commands/retrospective-commands.d.ts +18 -11
  174. package/dist/cli/commands/retrospective-commands.js +24 -173
  175. package/dist/cli/commands/retrospective-index-command.d.ts +26 -0
  176. package/dist/cli/commands/retrospective-index-command.js +99 -0
  177. package/dist/cli/commands/retrospective-project-root.d.ts +9 -0
  178. package/dist/cli/commands/retrospective-project-root.js +15 -0
  179. package/dist/cli/commands/retrospective-search-command.d.ts +27 -0
  180. package/dist/cli/commands/retrospective-search-command.js +97 -0
  181. package/dist/cli/commands/retrospective-show-command.d.ts +23 -0
  182. package/dist/cli/commands/retrospective-show-command.js +80 -0
  183. package/dist/cli/commands/reviewer-commands.d.ts +1 -1
  184. package/dist/cli/commands/role-commands.js +14 -9
  185. package/dist/cli/commands/runtime-commands.js +14 -7
  186. package/dist/cli/commands/sc-commands.d.ts +1 -1
  187. package/dist/cli/commands/sc-commands.js +39 -6
  188. package/dist/cli/commands/scan-commands.js +36 -13
  189. package/dist/cli/commands/security-audit-commands.d.ts +1 -1
  190. package/dist/cli/commands/security-audit-commands.js +12 -7
  191. package/dist/cli/commands/sediment-commands.d.ts +2 -2
  192. package/dist/cli/commands/sediment-commands.js +146 -139
  193. package/dist/cli/commands/session-24h-mode.js +15 -2
  194. package/dist/cli/commands/session-checkpoint-command.js +1 -1
  195. package/dist/cli/commands/session-migrate-skill-name.js +1 -1
  196. package/dist/cli/commands/shadcn-commands.d.ts +1 -1
  197. package/dist/cli/commands/shadcn-commands.js +3 -1
  198. package/dist/cli/commands/share-commands.js +38 -39
  199. package/dist/cli/commands/skill-conformance-commands.d.ts +1 -1
  200. package/dist/cli/commands/skill-conformance-commands.js +1 -1
  201. package/dist/cli/commands/skill-loop-engineering-readiness-commands.js +16 -17
  202. package/dist/cli/commands/skill-visibility.js +2 -2
  203. package/dist/cli/commands/slice-commands.d.ts +1 -1
  204. package/dist/cli/commands/slice-commands.js +36 -12
  205. package/dist/cli/commands/slice-integrate-commands.js +6 -7
  206. package/dist/cli/commands/slice-review-commands-helpers.d.ts +26 -0
  207. package/dist/cli/commands/slice-review-commands-helpers.js +26 -0
  208. package/dist/cli/commands/slice-review-commands.js +16 -24
  209. package/dist/cli/commands/smoke-commands-add-path.d.ts +14 -0
  210. package/dist/cli/commands/smoke-commands-add-path.js +39 -0
  211. package/dist/cli/commands/smoke-commands-define.d.ts +18 -0
  212. package/dist/cli/commands/smoke-commands-define.js +97 -0
  213. package/dist/cli/commands/smoke-commands-run.d.ts +18 -0
  214. package/dist/cli/commands/smoke-commands-run.js +119 -0
  215. package/dist/cli/commands/smoke-commands.d.ts +10 -1
  216. package/dist/cli/commands/smoke-commands.js +17 -179
  217. package/dist/cli/commands/sop-commands.d.ts +1 -1
  218. package/dist/cli/commands/sop-commands.js +38 -10
  219. package/dist/cli/commands/statusline-commands.d.ts +1 -1
  220. package/dist/cli/commands/statusline-commands.js +21 -10
  221. package/dist/cli/commands/sub-agent/detached.js +3 -3
  222. package/dist/cli/commands/sub-agent-dispatch-guard.d.ts +1 -1
  223. package/dist/cli/commands/sub-agent-shared.js +1 -1
  224. package/dist/cli/commands/sub-agent-shutdown-commands.js +17 -9
  225. package/dist/cli/commands/swarm-commands.d.ts +1 -1
  226. package/dist/cli/commands/swarm-commands.js +13 -6
  227. package/dist/cli/commands/tech-commands-helpers.d.ts +37 -0
  228. package/dist/cli/commands/tech-commands-helpers.js +24 -0
  229. package/dist/cli/commands/tech-commands.d.ts +2 -29
  230. package/dist/cli/commands/tech-commands.js +15 -28
  231. package/dist/cli/commands/test-commands.js +27 -7
  232. package/dist/cli/commands/upgrade-commands.d.ts +1 -1
  233. package/dist/cli/commands/user-touchpoint-commands.js +1 -3
  234. package/dist/cli/commands/verdict-aggregate-command.d.ts +1 -1
  235. package/dist/cli/commands/verdict-aggregate-command.js +20 -7
  236. package/dist/cli/commands/vm-commands.js +48 -19
  237. package/dist/cli/commands/wave-plan-commands.js +5 -2
  238. package/dist/cli/commands/web-commands.js +14 -4
  239. package/dist/cli/commands/web-lifecycle-commands.js +5 -3
  240. package/dist/cli/commands/workflow-commands.d.ts +1 -1
  241. package/dist/cli/commands/workflow-commands.js +64 -29
  242. package/dist/cli/commands/workflow-lifecycle-commands.js +19 -17
  243. package/dist/cli/commands/workflow-plan-commands-actions.d.ts +20 -0
  244. package/dist/cli/commands/workflow-plan-commands-actions.js +115 -0
  245. package/dist/cli/commands/workflow-plan-commands-session.d.ts +17 -0
  246. package/dist/cli/commands/workflow-plan-commands-session.js +59 -0
  247. package/dist/cli/commands/workflow-plan-commands.d.ts +10 -21
  248. package/dist/cli/commands/workflow-plan-commands.js +15 -141
  249. package/dist/cli/commands/workspace/clean-command.js +4 -1
  250. package/dist/cli/commands/workspace/helpers.js +2 -1
  251. package/dist/cli/commands/workspace/init-command.js +80 -20
  252. package/dist/cli/commands/workspace/reconcile-command.js +3 -1
  253. package/dist/cli/commands/workspace-commands.d.ts +1 -1
  254. package/dist/cli/commands/workspace-commands.js +1 -1
  255. package/dist/cli/commands/worktree-auth-commands.d.ts +1 -1
  256. package/dist/cli/commands/worktree-auth-commands.js +16 -169
  257. package/dist/cli/commands/worktree-auth-grant-command.d.ts +14 -0
  258. package/dist/cli/commands/worktree-auth-grant-command.js +118 -0
  259. package/dist/cli/commands/worktree-auth-manage-commands.d.ts +17 -0
  260. package/dist/cli/commands/worktree-auth-manage-commands.js +128 -0
  261. package/dist/cli/commands/worktree-lease-commands.d.ts +1 -1
  262. package/dist/cli/commands/worktree-lease-commands.js +65 -37
  263. package/dist/cli/index.js +6 -2
  264. package/dist/cli/program.js +6 -3
  265. package/dist/hooks/pre-tool-use-sub-agent.js +1 -6
  266. package/dist/reporters/bdd-reporter.js +9 -3
  267. package/dist/services/24h-mode/auto-engage.d.ts +19 -0
  268. package/dist/services/24h-mode/auto-engage.js +35 -0
  269. package/dist/services/24h-mode/decider.js +5 -1
  270. package/dist/services/24h-mode/store.js +4 -2
  271. package/dist/services/adapter/adapter-registry.js +20 -8
  272. package/dist/services/adapter/adapter.d.ts +2 -2
  273. package/dist/services/adapter/auto-adapter.d.ts +2 -2
  274. package/dist/services/adapter/auto-adapter.js +1 -1
  275. package/dist/services/adapter/claude-adapter.d.ts +1 -1
  276. package/dist/services/adapter/claude-adapter.js +8 -8
  277. package/dist/services/adapter/codex-adapter.d.ts +2 -2
  278. package/dist/services/adapter/codex-adapter.js +20 -8
  279. package/dist/services/adapter/copilot-adapter.d.ts +2 -2
  280. package/dist/services/adapter/copilot-adapter.js +20 -8
  281. package/dist/services/artifacts/artifact-prerequisites.js +10 -8
  282. package/dist/services/artifacts/artifact-service.js +3 -1
  283. package/dist/services/artifacts/artifact-template-bodies.d.ts +12 -0
  284. package/dist/services/artifacts/artifact-template-bodies.js +165 -0
  285. package/dist/services/artifacts/artifact-templates.js +26 -168
  286. package/dist/services/artifacts/request-artifact-service.js +14 -7
  287. package/dist/services/artifacts/request-artifact-state-helpers.d.ts +3 -2
  288. package/dist/services/artifacts/request-artifact-state-helpers.js +3 -5
  289. package/dist/services/artifacts/workspace-artifact-helpers.d.ts +28 -0
  290. package/dist/services/artifacts/workspace-artifact-helpers.js +54 -0
  291. package/dist/services/artifacts/workspace-service.d.ts +3 -22
  292. package/dist/services/artifacts/workspace-service.js +10 -60
  293. package/dist/services/audit/artifact-writer.js +21 -21
  294. package/dist/services/audit/audit-goal-service.js +2 -2
  295. package/dist/services/audit/backing-detector.js +7 -4
  296. package/dist/services/audit/classifier.js +3 -3
  297. package/dist/services/audit/decision-writer.js +13 -9
  298. package/dist/services/audit/enforcers/active-skill-resolver.js +15 -7
  299. package/dist/services/audit/enforcers/design-draft-confirm.js +4 -4
  300. package/dist/services/audit/enforcers/lint-audit-regression.js +10 -5
  301. package/dist/services/audit/enforcers/lint-bee-runtime-contract.js +16 -8
  302. package/dist/services/audit/enforcers/lint-catalog-governance.js +8 -4
  303. package/dist/services/audit/enforcers/lint-output-style.js +4 -2
  304. package/dist/services/audit/enforcers/lint-peaks-code-runtime.js +8 -3
  305. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +8 -3
  306. package/dist/services/audit/enforcers/lint-peaks-ui-sc-txt-runtime.js +20 -20
  307. package/dist/services/audit/enforcers/lint-prd-artifact-handoff.js +5 -5
  308. package/dist/services/audit/enforcers/lint-prd-source-snapshot.d.ts +1 -1
  309. package/dist/services/audit/enforcers/lint-prd-source-snapshot.js +5 -5
  310. package/dist/services/audit/enforcers/lint-qa-gateguard-and-runtime.js +10 -10
  311. package/dist/services/audit/enforcers/lint-rd-handoff-coverage.js +10 -8
  312. package/dist/services/audit/enforcers/lint-reference-shape.js +50 -18
  313. package/dist/services/audit/enforcers/lint-skill-presence-mandatory.js +5 -5
  314. package/dist/services/audit/enforcers/lint-style.js +44 -11
  315. package/dist/services/audit/enforcers/lint-workflow-shape.js +4 -2
  316. package/dist/services/audit/enforcers/login-gate.js +2 -6
  317. package/dist/services/audit/enforcers/mock-placement.js +2 -2
  318. package/dist/services/audit/enforcers/no-root-pollution.js +38 -9
  319. package/dist/services/audit/enforcers/pre-rd-scan.js +1 -1
  320. package/dist/services/audit/enforcers/prototype-fidelity.js +1 -1
  321. package/dist/services/audit/enforcers/resume-detection.js +5 -4
  322. package/dist/services/audit/prose-ratio-calculator.js +1 -1
  323. package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.d.ts +39 -0
  324. package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.js +205 -0
  325. package/dist/services/audit/red-line-catalog-p2-a-lint-style.d.ts +52 -0
  326. package/dist/services/audit/red-line-catalog-p2-a-lint-style.js +205 -0
  327. package/dist/services/audit/red-line-catalog-p2-a.js +3 -374
  328. package/dist/services/audit/red-line-catalog-p2-b.js +26 -26
  329. package/dist/services/audit/red-line-catalog.js +26 -38
  330. package/dist/services/audit/red-lines-service.js +64 -49
  331. package/dist/services/audit/scanners/openspec-scanner.js +2 -2
  332. package/dist/services/audit/scanners/rules-tree-scanner.js +2 -2
  333. package/dist/services/audit/scanners/skills-tree-scanner.js +2 -2
  334. package/dist/services/audit/static-service.js +3 -3
  335. package/dist/services/audit-independent/index.d.ts +2 -2
  336. package/dist/services/audit-independent/index.js +2 -2
  337. package/dist/services/audit-independent/perf-audit-service.js +19 -8
  338. package/dist/services/audit-independent/security-audit-service.js +31 -16
  339. package/dist/services/autonomous-swarm/autonomous-swarm-service.js +75 -46
  340. package/dist/services/best-practice/output-formatter.js +7 -1
  341. package/dist/services/capability-audit-service/cross-check.js +11 -5
  342. package/dist/services/capability-audit-service/runner.js +15 -7
  343. package/dist/services/capability-baseline/store.js +16 -4
  344. package/dist/services/capability-baseline/types.js +15 -3
  345. package/dist/services/capability-baseline/validator.js +43 -7
  346. package/dist/services/capability-guard-runner/contracts/J02.js +36 -6
  347. package/dist/services/capability-guard-runner/contracts/J03.js +20 -11
  348. package/dist/services/capability-guard-runner/contracts/J04.js +24 -15
  349. package/dist/services/capability-guard-runner/contracts/J05.js +26 -10
  350. package/dist/services/capability-guard-runner/contracts/J07.js +8 -2
  351. package/dist/services/capability-guard-runner/contracts/J08.js +22 -5
  352. package/dist/services/capability-guard-runner/contracts/J10.js +6 -2
  353. package/dist/services/capability-guard-runner/contracts/J11.d.ts +5 -0
  354. package/dist/services/capability-guard-runner/contracts/J11.js +14 -2
  355. package/dist/services/capability-guard-runner/contracts/J12.js +12 -3
  356. package/dist/services/capability-guard-runner/diff.js +1 -5
  357. package/dist/services/changeset/changeset-check-service.js +1 -3
  358. package/dist/services/classify/classify-service.js +20 -8
  359. package/dist/services/classify/classify-types.js +22 -9
  360. package/dist/services/code/auto-compact-lifecycle.js +62 -39
  361. package/dist/services/code/auto-compact-modes.js +2 -2
  362. package/dist/services/code/auto-compact-orchestrator.js +14 -9
  363. package/dist/services/code/batch-heartbeat-poller.d.ts +10 -0
  364. package/dist/services/code/batch-heartbeat-poller.js +17 -1
  365. package/dist/services/code/compact-event-settle-types.d.ts +80 -0
  366. package/dist/services/code/compact-event-settle-types.js +20 -0
  367. package/dist/services/code/compact-event-settle.d.ts +3 -68
  368. package/dist/services/code/compact-event-settle.js +14 -10
  369. package/dist/services/code/dag-orchestrator.js +32 -26
  370. package/dist/services/code/job-shape-decision.js +3 -1
  371. package/dist/services/code/mode-gate-types.d.ts +57 -0
  372. package/dist/services/code/mode-gate-types.js +67 -0
  373. package/dist/services/code/mode-gate.d.ts +4 -58
  374. package/dist/services/code/mode-gate.js +24 -60
  375. package/dist/services/code/orchestrator-can-do-advisories.d.ts +30 -0
  376. package/dist/services/code/orchestrator-can-do-advisories.js +81 -0
  377. package/dist/services/code/orchestrator-can-do-probes.d.ts +30 -0
  378. package/dist/services/code/orchestrator-can-do-probes.js +77 -0
  379. package/dist/services/code/orchestrator-can-do.d.ts +11 -22
  380. package/dist/services/code/orchestrator-can-do.js +37 -137
  381. package/dist/services/code/post-compact-checkpoint.d.ts +28 -0
  382. package/dist/services/code/post-compact-checkpoint.js +57 -0
  383. package/dist/services/code/post-compact-detector.js +16 -48
  384. package/dist/services/code/step-08-gate.d.ts +4 -3
  385. package/dist/services/code/step-08-gate.js +21 -9
  386. package/dist/services/code-review/ecc-bridge.js +23 -23
  387. package/dist/services/codegraph/codegraph-autorefresh.js +56 -39
  388. package/dist/services/codegraph/codegraph-config-repair-writer.js +4 -1
  389. package/dist/services/codegraph/codegraph-exclude-integrity.js +4 -1
  390. package/dist/services/codegraph/codegraph-exclude-repair.js +1 -2
  391. package/dist/services/codegraph/codegraph-index-integrity.js +1 -1
  392. package/dist/services/codegraph/codegraph-preflight-service.d.ts +3 -26
  393. package/dist/services/codegraph/codegraph-preflight-service.js +16 -37
  394. package/dist/services/codegraph/codegraph-preflight-structure.d.ts +32 -0
  395. package/dist/services/codegraph/codegraph-preflight-structure.js +33 -0
  396. package/dist/services/codegraph/codegraph-process-runner.js +12 -1
  397. package/dist/services/codegraph/codegraph-service.js +9 -1
  398. package/dist/services/compact/request-transition-hook.js +2 -1
  399. package/dist/services/compact/suggest-service.d.ts +3 -61
  400. package/dist/services/compact/suggest-service.js +9 -12
  401. package/dist/services/compact/suggest-types.d.ts +76 -0
  402. package/dist/services/compact/suggest-types.js +10 -0
  403. package/dist/services/compact-history/compact-history-service.js +2 -2
  404. package/dist/services/compact-statusline/compact-lifecycle-store.d.ts +2 -32
  405. package/dist/services/compact-statusline/compact-lifecycle-store.js +7 -12
  406. package/dist/services/compact-statusline/compact-lifecycle-types.d.ts +32 -0
  407. package/dist/services/compact-statusline/compact-lifecycle-types.js +8 -0
  408. package/dist/services/compact-statusline/compact-statusline-cell-table.d.ts +42 -0
  409. package/dist/services/compact-statusline/compact-statusline-cell-table.js +63 -0
  410. package/dist/services/compact-statusline/compact-statusline-service.d.ts +4 -21
  411. package/dist/services/compact-statusline/compact-statusline-service.js +9 -101
  412. package/dist/services/compact-statusline/compact-statusline-state.d.ts +4 -0
  413. package/dist/services/compact-statusline/compact-statusline-state.js +50 -0
  414. package/dist/services/config/config-migration.js +2 -2
  415. package/dist/services/config/config-restore.js +1 -1
  416. package/dist/services/config/config-rollback.js +1 -1
  417. package/dist/services/config/config-safety.js +28 -10
  418. package/dist/services/config/config-service.js +114 -31
  419. package/dist/services/config/model-routing.js +5 -2
  420. package/dist/services/config/proxy-service.js +6 -1
  421. package/dist/services/config/workspace-state-service.js +17 -5
  422. package/dist/services/context/auto-compact-dispatcher-input.d.ts +38 -0
  423. package/dist/services/context/auto-compact-dispatcher-input.js +9 -0
  424. package/dist/services/context/auto-compact-dispatcher.d.ts +2 -30
  425. package/dist/services/context/auto-compact-reader-input.d.ts +30 -0
  426. package/dist/services/context/auto-compact-reader-input.js +8 -0
  427. package/dist/services/context/auto-compact-reader.d.ts +2 -24
  428. package/dist/services/context/auto-compact-reader.js +4 -1
  429. package/dist/services/context/auto-compact-thresholds.d.ts +54 -0
  430. package/dist/services/context/auto-compact-thresholds.js +19 -0
  431. package/dist/services/context/auto-compact-types.d.ts +2 -46
  432. package/dist/services/context/auto-compact-types.js +1 -11
  433. package/dist/services/context/build-dispatch-system-prompt.js +2 -2
  434. package/dist/services/context/collector.js +8 -10
  435. package/dist/services/context/context-audit-hint.js +7 -5
  436. package/dist/services/context/context-audit-keys.d.ts +15 -0
  437. package/dist/services/context/context-audit-keys.js +77 -0
  438. package/dist/services/context/context-audit-limits.d.ts +20 -0
  439. package/dist/services/context/context-audit-limits.js +31 -0
  440. package/dist/services/context/context-audit-scan.d.ts +19 -0
  441. package/dist/services/context/context-audit-scan.js +246 -0
  442. package/dist/services/context/context-audit-types.d.ts +65 -0
  443. package/dist/services/context/context-audit-types.js +10 -0
  444. package/dist/services/context/context-audit.d.ts +13 -59
  445. package/dist/services/context/context-audit.js +38 -254
  446. package/dist/services/context/context-builder.js +4 -4
  447. package/dist/services/context/context-schema.d.ts +1 -1
  448. package/dist/services/context/context-schema.js +13 -13
  449. package/dist/services/context/doc-retriever.js +2 -2
  450. package/dist/services/context/harness-context-witness.js +43 -24
  451. package/dist/services/context/harness-window-config.js +27 -7
  452. package/dist/services/context/ide-detect.js +2 -1
  453. package/dist/services/context/index.d.ts +1 -1
  454. package/dist/services/context/memory-index-reader.js +3 -9
  455. package/dist/services/context/memory-preflight-config.js +3 -5
  456. package/dist/services/context/memory-preflight-service.d.ts +2 -20
  457. package/dist/services/context/memory-preflight-service.js +37 -68
  458. package/dist/services/context/memory-preflight-support.d.ts +48 -0
  459. package/dist/services/context/memory-preflight-support.js +56 -0
  460. package/dist/services/context/post-compact-reinjection.js +3 -3
  461. package/dist/services/context/renderer.js +7 -3
  462. package/dist/services/context/spillover-store.js +3 -1
  463. package/dist/services/context/summary-view.js +1 -1
  464. package/dist/services/context/threshold.js +2 -2
  465. package/dist/services/context/tokenizer.js +3 -3
  466. package/dist/services/crystallization/crystallization-brief-schema.d.ts +80 -0
  467. package/dist/services/crystallization/crystallization-brief-schema.js +159 -0
  468. package/dist/services/crystallization/crystallization-service.d.ts +7 -7
  469. package/dist/services/crystallization/crystallization-service.js +56 -55
  470. package/dist/services/crystallization/crystallization-store.d.ts +2 -2
  471. package/dist/services/crystallization/crystallization-store.js +37 -20
  472. package/dist/services/crystallization/crystallization-types.d.ts +4 -56
  473. package/dist/services/crystallization/crystallization-types.js +31 -184
  474. package/dist/services/crystallization/evidence-brief-builder.d.ts +3 -3
  475. package/dist/services/crystallization/evidence-brief-builder.js +32 -38
  476. package/dist/services/crystallization/index.d.ts +4 -4
  477. package/dist/services/crystallization/index.js +4 -4
  478. package/dist/services/dashboard/project-dashboard-service.js +7 -1
  479. package/dist/services/dispatch/await-batch-helpers.d.ts +55 -0
  480. package/dist/services/dispatch/await-batch-helpers.js +206 -0
  481. package/dist/services/dispatch/await-batch.d.ts +50 -7
  482. package/dist/services/dispatch/await-batch.js +97 -194
  483. package/dist/services/dispatch/batch-counter.js +2 -1
  484. package/dist/services/dispatch/conflict-replay.js +2 -2
  485. package/dist/services/dispatch/contract-store.js +5 -2
  486. package/dist/services/dispatch/dispatch-record-input-types.d.ts +81 -0
  487. package/dist/services/dispatch/dispatch-record-input-types.js +1 -0
  488. package/dist/services/dispatch/dispatch-record-types.d.ts +6 -73
  489. package/dist/services/dispatch/dispatch-record-upgrade-fields.d.ts +72 -0
  490. package/dist/services/dispatch/dispatch-record-upgrade-fields.js +242 -0
  491. package/dist/services/dispatch/dispatch-record-upgrade-guards.d.ts +15 -0
  492. package/dist/services/dispatch/dispatch-record-upgrade-guards.js +55 -0
  493. package/dist/services/dispatch/dispatch-record-upgrade.d.ts +2 -4
  494. package/dist/services/dispatch/dispatch-record-upgrade.js +21 -213
  495. package/dist/services/dispatch/dispatch-record-writer.js +54 -26
  496. package/dist/services/dispatch/dispatch-sub-agent.js +7 -2
  497. package/dist/services/dispatch/e2e-fixtures.js +1 -1
  498. package/dist/services/dispatch/isolation-lease.js +39 -17
  499. package/dist/services/dispatch/merge-back-runner.js +51 -11
  500. package/dist/services/dispatch/service-shutdown.js +4 -1
  501. package/dist/services/dispatch/slice-dag-types.d.ts +116 -0
  502. package/dist/services/dispatch/slice-dag-types.js +41 -0
  503. package/dist/services/dispatch/slice-dag.d.ts +3 -109
  504. package/dist/services/dispatch/slice-dag.js +13 -36
  505. package/dist/services/dispatch/sub-agent-batch-await.d.ts +47 -0
  506. package/dist/services/dispatch/sub-agent-batch-await.js +73 -0
  507. package/dist/services/dispatch/sub-agent-dispatcher-types.d.ts +122 -0
  508. package/dist/services/dispatch/sub-agent-dispatcher-types.js +12 -0
  509. package/dist/services/dispatch/sub-agent-dispatcher.d.ts +3 -145
  510. package/dist/services/dispatch/sub-agent-dispatcher.js +14 -70
  511. package/dist/services/dispatch/test-tool-detection.js +12 -1
  512. package/dist/services/doc/doc-generator.js +19 -4
  513. package/dist/services/doctor/doctor-service/checks/check-id-schema.js +16 -8
  514. package/dist/services/doctor/doctor-service/checks/codegraph-capability.d.ts +7 -2
  515. package/dist/services/doctor/doctor-service/checks/codegraph-capability.js +26 -8
  516. package/dist/services/doctor/doctor-service/checks/codegraph-exclude-integrity.js +16 -8
  517. package/dist/services/doctor/doctor-service/checks/codegraph-index-integrity.js +16 -8
  518. package/dist/services/doctor/doctor-service/checks/dist-source-version.js +18 -9
  519. package/dist/services/doctor/doctor-service/checks/ecc-hooks-schema-drift.js +20 -10
  520. package/dist/services/doctor/doctor-service/checks/gateguard-conflict.js +18 -9
  521. package/dist/services/doctor/doctor-service/checks/l3-memory-health.js +25 -11
  522. package/dist/services/doctor/doctor-service/checks/l3-orphan-sessions.js +12 -6
  523. package/dist/services/doctor/doctor-service/checks/multi-binary-drift.d.ts +7 -16
  524. package/dist/services/doctor/doctor-service/checks/multi-binary-drift.js +50 -70
  525. package/dist/services/doctor/doctor-service/checks/schema-validity.js +5 -1
  526. package/dist/services/doctor/doctor-service/checks/skill-presence.js +4 -2
  527. package/dist/services/doctor/doctor-service/checks/statusline-install.js +8 -4
  528. package/dist/services/doctor/doctor-service/checks/statusline-runtime.js +8 -4
  529. package/dist/services/doctor/doctor-service/checks/user-config.js +4 -2
  530. package/dist/services/doctor/doctor-service/checks/workspace-init.js +8 -4
  531. package/dist/services/doctor/doctor-service/checks/workspace-layout.js +19 -11
  532. package/dist/services/doctor/doctor-service/index.js +4 -2
  533. package/dist/services/doctor/doctor-service/multi-binary-drift-helpers.d.ts +40 -0
  534. package/dist/services/doctor/doctor-service/multi-binary-drift-helpers.js +49 -0
  535. package/dist/services/doctor/doctor-service/plugin-registry.js +1 -1
  536. package/dist/services/doctor/doctor-service/probe-types.d.ts +210 -0
  537. package/dist/services/doctor/doctor-service/probe-types.js +14 -0
  538. package/dist/services/doctor/doctor-service/types.d.ts +7 -197
  539. package/dist/services/doctor/index.d.ts +1 -1
  540. package/dist/services/doctor/index.js +1 -1
  541. package/dist/services/env/shell-probe.js +8 -2
  542. package/dist/services/evidence/evidence-body-builders.d.ts +23 -0
  543. package/dist/services/evidence/evidence-body-builders.js +197 -0
  544. package/dist/services/evidence/evidence-generator.js +6 -187
  545. package/dist/services/evolution/evolution-constraints.d.ts +43 -0
  546. package/dist/services/evolution/evolution-constraints.js +54 -0
  547. package/dist/services/evolution/evolution-evaluation-schema.d.ts +43 -0
  548. package/dist/services/evolution/evolution-evaluation-schema.js +43 -0
  549. package/dist/services/evolution/evolution-service.d.ts +6 -6
  550. package/dist/services/evolution/evolution-service.js +58 -58
  551. package/dist/services/evolution/evolution-store.d.ts +2 -2
  552. package/dist/services/evolution/evolution-store.js +37 -51
  553. package/dist/services/evolution/evolution-types.d.ts +2 -22
  554. package/dist/services/evolution/evolution-types.js +41 -101
  555. package/dist/services/evolution/independent-evaluator-runner.d.ts +3 -3
  556. package/dist/services/evolution/independent-evaluator-runner.js +20 -22
  557. package/dist/services/evolution/regression-skeptic-runner.d.ts +2 -2
  558. package/dist/services/evolution/regression-skeptic-runner.js +18 -18
  559. package/dist/services/feedback/feedback-promotion-service.js +48 -12
  560. package/dist/services/feedback/promotion-artifact-evidence.d.ts +2 -16
  561. package/dist/services/feedback/promotion-artifact-evidence.js +6 -83
  562. package/dist/services/feedback/promotion-artifact-json-evidence.d.ts +29 -0
  563. package/dist/services/feedback/promotion-artifact-json-evidence.js +39 -0
  564. package/dist/services/feedback/promotion-source-comments.d.ts +47 -0
  565. package/dist/services/feedback/promotion-source-comments.js +61 -0
  566. package/dist/services/final-review/final-review-contract.d.ts +26 -0
  567. package/dist/services/final-review/final-review-contract.js +14 -0
  568. package/dist/services/final-review/final-review-delivery.d.ts +63 -0
  569. package/dist/services/final-review/final-review-delivery.js +124 -0
  570. package/dist/services/final-review/final-review-evidence-budget.d.ts +125 -0
  571. package/dist/services/final-review/final-review-evidence-budget.js +218 -0
  572. package/dist/services/final-review/final-review-evidence-collect.d.ts +4 -0
  573. package/dist/services/final-review/final-review-evidence-collect.js +230 -0
  574. package/dist/services/final-review/final-review-evidence-sources.d.ts +138 -0
  575. package/dist/services/final-review/final-review-evidence-sources.js +139 -0
  576. package/dist/services/final-review/final-review-fifth-dim.d.ts +8 -0
  577. package/dist/services/final-review/final-review-fifth-dim.js +20 -0
  578. package/dist/services/final-review/final-review-gates.d.ts +119 -0
  579. package/dist/services/final-review/final-review-gates.js +214 -0
  580. package/dist/services/final-review/final-review-output-budget.d.ts +88 -0
  581. package/dist/services/final-review/final-review-output-budget.js +161 -0
  582. package/dist/services/final-review/final-review-prompt.d.ts +35 -0
  583. package/dist/services/final-review/final-review-prompt.js +112 -0
  584. package/dist/services/final-review/final-review-reviewer.d.ts +57 -0
  585. package/dist/services/final-review/final-review-reviewer.js +95 -0
  586. package/dist/services/final-review/final-review-runner.d.ts +3 -0
  587. package/dist/services/final-review/final-review-runner.js +158 -0
  588. package/dist/services/final-review/final-review-service.d.ts +119 -373
  589. package/dist/services/final-review/final-review-service.js +48 -1380
  590. package/dist/services/final-review/final-review-verdicts.d.ts +60 -0
  591. package/dist/services/final-review/final-review-verdicts.js +91 -0
  592. package/dist/services/final-review/index.d.ts +3 -3
  593. package/dist/services/final-review/index.js +2 -2
  594. package/dist/services/final-review/pre-post-diff.js +32 -29
  595. package/dist/services/fixture/fixture-capture-service.js +14 -6
  596. package/dist/services/fresh-context/trigger-scan.js +13 -2
  597. package/dist/services/fuzzy-matching/fuzzy-match-service.js +1 -1
  598. package/dist/services/fuzzy-matching/fzf-pick-service.js +6 -1
  599. package/dist/services/hooks/pre-tool-code-gate.js +2 -2
  600. package/dist/services/hooks/presence-marker-detector.js +12 -2
  601. package/dist/services/hooks/worktree-authorization-gate.js +21 -7
  602. package/dist/services/ide/adapters/claude-code-adapter.js +30 -17
  603. package/dist/services/ide/adapters/codex-adapter.js +3 -5
  604. package/dist/services/ide/adapters/cursor-adapter.js +3 -5
  605. package/dist/services/ide/adapters/hermes-adapter.js +2 -4
  606. package/dist/services/ide/adapters/openclaw-adapter.js +2 -4
  607. package/dist/services/ide/adapters/qoder-adapter.js +2 -4
  608. package/dist/services/ide/adapters/tongyi-lingma-adapter.js +1 -1
  609. package/dist/services/ide/adapters/trae-adapter.js +3 -5
  610. package/dist/services/ide/adapters/zcode-adapter.js +8 -7
  611. package/dist/services/ide/current-model-detector.js +2 -1
  612. package/dist/services/ide/ide-compact-types.d.ts +153 -0
  613. package/dist/services/ide/ide-compact-types.js +1 -0
  614. package/dist/services/ide/ide-registry.js +1 -1
  615. package/dist/services/ide/ide-types.d.ts +7 -145
  616. package/dist/services/ide/resource-profile.js +1 -1
  617. package/dist/services/ide/shared/atomic-json.js +2 -1
  618. package/dist/services/impact/impact-scan-service.js +12 -5
  619. package/dist/services/job/job-commit-verification.d.ts +73 -0
  620. package/dist/services/job/job-commit-verification.js +72 -0
  621. package/dist/services/job/job-orchestrator.d.ts +42 -0
  622. package/dist/services/job/job-orchestrator.js +110 -10
  623. package/dist/services/job/job-progress-store.d.ts +75 -5
  624. package/dist/services/job/job-progress-store.js +83 -6
  625. package/dist/services/job/job-rotation.d.ts +1 -1
  626. package/dist/services/job/job-rotation.js +5 -1
  627. package/dist/services/job/job-state-store.js +2 -2
  628. package/dist/services/job/job-types.js +49 -20
  629. package/dist/services/job/subagent-job-wrapper.d.ts +1 -1
  630. package/dist/services/job/subagent-job-wrapper.js +5 -1
  631. package/dist/services/job-snapshot/snapshot.js +2 -2
  632. package/dist/services/karpathy-cost/karpathy-cost-check-service.js +23 -13
  633. package/dist/services/legacy/legacy-detector.js +51 -5
  634. package/dist/services/lint/detect-eslint.js +10 -4
  635. package/dist/services/lint/detect-ocr-18.js +11 -3
  636. package/dist/services/lint/eslint-runner-support.d.ts +22 -0
  637. package/dist/services/lint/eslint-runner-support.js +185 -0
  638. package/dist/services/lint/eslint-runner-types.d.ts +69 -0
  639. package/dist/services/lint/eslint-runner-types.js +11 -0
  640. package/dist/services/lint/eslint-runner.d.ts +4 -56
  641. package/dist/services/lint/eslint-runner.js +24 -178
  642. package/dist/services/lint/npx-resolver.js +1 -3
  643. package/dist/services/lint/ocr-18-acquire.js +15 -4
  644. package/dist/services/lint/ocr-multilang-adapter.js +4 -5
  645. package/dist/services/llm/anthropic-runner.js +4 -1
  646. package/dist/services/log/log-commands-service.js +2 -6
  647. package/dist/services/log/logger.js +15 -12
  648. package/dist/services/log/retention.js +3 -2
  649. package/dist/services/loop/evaluator-dispatcher.js +78 -42
  650. package/dist/services/loop/loop-bee-relation-service.d.ts +4 -4
  651. package/dist/services/loop/loop-bee-relation-service.js +36 -40
  652. package/dist/services/loop/loop-bee-relation-store.d.ts +3 -3
  653. package/dist/services/loop/loop-bee-relation-store.js +9 -11
  654. package/dist/services/loop/loop-bee-relation-types.d.ts +1 -1
  655. package/dist/services/loop/loop-bee-relation-types.js +14 -25
  656. package/dist/services/loop/loop-release-service.d.ts +2 -2
  657. package/dist/services/loop/loop-release-service.js +3 -3
  658. package/dist/services/loop/loop-release-store.d.ts +2 -2
  659. package/dist/services/loop/loop-release-store.js +4 -6
  660. package/dist/services/loop/loop-release-types.d.ts +1 -1
  661. package/dist/services/loop/loop-release-types.js +21 -31
  662. package/dist/services/loop/monotonic-guard-types.d.ts +51 -0
  663. package/dist/services/loop/monotonic-guard-types.js +9 -0
  664. package/dist/services/loop/monotonic-guard.d.ts +2 -43
  665. package/dist/services/loop/monotonic-runner-types.d.ts +63 -0
  666. package/dist/services/loop/monotonic-runner-types.js +17 -0
  667. package/dist/services/loop/monotonic-runner.d.ts +3 -34
  668. package/dist/services/loop/monotonic-runner.js +10 -20
  669. package/dist/services/loop/run-driver.js +16 -8
  670. package/dist/services/loop/spec-service.d.ts +0 -5
  671. package/dist/services/loop/spec-service.js +49 -9
  672. package/dist/services/memory/llm-reranker-core.d.ts +108 -0
  673. package/dist/services/memory/llm-reranker-core.js +105 -0
  674. package/dist/services/memory/llm-reranker.d.ts +3 -94
  675. package/dist/services/memory/llm-reranker.js +13 -102
  676. package/dist/services/memory/memory-ingest-service.d.ts +1 -22
  677. package/dist/services/memory/memory-ingest-service.js +29 -76
  678. package/dist/services/memory/memory-ingest-support.d.ts +23 -0
  679. package/dist/services/memory/memory-ingest-support.js +81 -0
  680. package/dist/services/memory/memory-rotate-service.js +41 -8
  681. package/dist/services/memory/memory-search-service.js +8 -4
  682. package/dist/services/memory/project-context-service.js +26 -5
  683. package/dist/services/memory/project-memory-service/index/kind-dispatch.d.ts +2 -7
  684. package/dist/services/memory/project-memory-service/index/kind-dispatch.js +17 -136
  685. package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.d.ts +7 -0
  686. package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.js +150 -0
  687. package/dist/services/memory/project-memory-service/index/ranking.js +6 -3
  688. package/dist/services/memory/project-memory-service/index/reindex.js +14 -5
  689. package/dist/services/memory/project-memory-service/memory-kinds.d.ts +31 -0
  690. package/dist/services/memory/project-memory-service/memory-kinds.js +87 -0
  691. package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.d.ts +24 -0
  692. package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.js +104 -0
  693. package/dist/services/memory/project-memory-service/parsers/frontmatter.d.ts +2 -24
  694. package/dist/services/memory/project-memory-service/parsers/frontmatter.js +28 -79
  695. package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +15 -3
  696. package/dist/services/memory/project-memory-service/store/atomic-write.js +34 -22
  697. package/dist/services/memory/project-memory-service/store/paths.js +2 -1
  698. package/dist/services/memory/project-memory-service/types.d.ts +3 -31
  699. package/dist/services/memory/project-memory-service/types.js +1 -76
  700. package/dist/services/migrate-skill-name/migrate.js +1 -1
  701. package/dist/services/migrate-skill-name/schema.js +1 -1
  702. package/dist/services/mode/mode-enforcement.js +4 -2
  703. package/dist/services/mode/mode-status-service.d.ts +27 -9
  704. package/dist/services/mode/mode-status-service.js +64 -12
  705. package/dist/services/observability/aggregation-helpers.d.ts +22 -0
  706. package/dist/services/observability/aggregation-helpers.js +65 -0
  707. package/dist/services/observability/aggregation-types.d.ts +66 -0
  708. package/dist/services/observability/aggregation-types.js +34 -0
  709. package/dist/services/observability/aggregation.d.ts +5 -53
  710. package/dist/services/observability/aggregation.js +17 -80
  711. package/dist/services/observability/jsonl-store.js +2 -1
  712. package/dist/services/observability/observability-schema.d.ts +71 -0
  713. package/dist/services/observability/observability-schema.js +64 -0
  714. package/dist/services/observability/observability-service.d.ts +3 -56
  715. package/dist/services/observability/observability-service.js +9 -49
  716. package/dist/services/openspec/coverage-evidence-reader.js +18 -11
  717. package/dist/services/openspec/openspec-archive-service.js +31 -24
  718. package/dist/services/openspec/openspec-init-service.js +8 -2
  719. package/dist/services/openspec/openspec-propose-from-doctor-service.js +1 -1
  720. package/dist/services/openspec/openspec-scan-service.js +4 -1
  721. package/dist/services/openspec/openspec-validate-service.js +26 -5
  722. package/dist/services/perf/perf-baseline-service.js +2 -6
  723. package/dist/services/polyrepo/polyrepo-dispatcher.js +2 -1
  724. package/dist/services/polyrepo/polyrepo-scanner.js +4 -1
  725. package/dist/services/prd/handoff-frontmatter-shape.d.ts +42 -0
  726. package/dist/services/prd/handoff-frontmatter-shape.js +67 -0
  727. package/dist/services/prd/handoff-frontmatter.js +1 -1
  728. package/dist/services/prd/handoff-path-resolution.d.ts +37 -0
  729. package/dist/services/prd/handoff-path-resolution.js +101 -0
  730. package/dist/services/prd/handoff-service.d.ts +1 -37
  731. package/dist/services/prd/handoff-service.js +16 -148
  732. package/dist/services/prd/prd-blocks-checker.js +28 -8
  733. package/dist/services/prd/project-scan-bootstrap-service.js +1 -5
  734. package/dist/services/prd/project-scan-reader.js +1 -4
  735. package/dist/services/prd/project-scan-sediment.js +1 -4
  736. package/dist/services/preferences/preferences-service.js +6 -8
  737. package/dist/services/preferences/preferences-types.js +4 -4
  738. package/dist/services/qa/bdd-test-style-contract.d.ts +41 -0
  739. package/dist/services/qa/bdd-test-style-contract.js +37 -0
  740. package/dist/services/qa/bdd-test-style-verifier.d.ts +2 -24
  741. package/dist/services/qa/bdd-test-style-verifier.js +5 -31
  742. package/dist/services/qa/browser-event-logger.js +2 -1
  743. package/dist/services/qa/qa-business-review-state.js +20 -5
  744. package/dist/services/qa/screenshot-archive-service.js +1 -3
  745. package/dist/services/rd/ast-gate.js +2 -2
  746. package/dist/services/rd/impl.js +1 -1
  747. package/dist/services/rd/rd-service.js +117 -43
  748. package/dist/services/rd/reviewer-dispatch-policy.js +4 -7
  749. package/dist/services/rd/standards-diagnostic.js +4 -1
  750. package/dist/services/rd/strategy.js +10 -3
  751. package/dist/services/rd/tactical-stage.js +2 -2
  752. package/dist/services/rd/types.js +9 -7
  753. package/dist/services/rd-swarm/rd-swarm-service.d.ts +2 -45
  754. package/dist/services/rd-swarm/rd-swarm-service.js +140 -21
  755. package/dist/services/rd-swarm/rd-swarm-types.d.ts +54 -0
  756. package/dist/services/rd-swarm/rd-swarm-types.js +10 -0
  757. package/dist/services/recommendations/capability-map-service.js +10 -2
  758. package/dist/services/recommendations/capability-seed-items.js +81 -14
  759. package/dist/services/recommendations/capability-seed-mappings.js +420 -48
  760. package/dist/services/recommendations/capability-seed-sources-mcp-server.d.ts +9 -0
  761. package/dist/services/recommendations/capability-seed-sources-mcp-server.js +233 -0
  762. package/dist/services/recommendations/capability-seed-sources.js +127 -32
  763. package/dist/services/release/release-state.d.ts +2 -2
  764. package/dist/services/release/release-state.js +44 -15
  765. package/dist/services/release/version-precheck-layer-changeset.d.ts +2 -0
  766. package/dist/services/release/version-precheck-layer-changeset.js +43 -0
  767. package/dist/services/release/version-precheck-service.d.ts +11 -36
  768. package/dist/services/release/version-precheck-service.js +20 -104
  769. package/dist/services/release/version-precheck-support.d.ts +53 -0
  770. package/dist/services/release/version-precheck-support.js +64 -0
  771. package/dist/services/retrospective/retrospective-index.js +17 -3
  772. package/dist/services/retrospective/retrospective-search-service.js +6 -2
  773. package/dist/services/retrospective/retrospective-show.js +4 -1
  774. package/dist/services/reviewer/model-family.js +7 -1
  775. package/dist/services/reviewer/providers/anthropic.d.ts +5 -0
  776. package/dist/services/reviewer/providers/anthropic.js +10 -1
  777. package/dist/services/reviewer/providers/openai.d.ts +5 -0
  778. package/dist/services/reviewer/providers/openai.js +10 -1
  779. package/dist/services/reviewer/reviewer-config.js +4 -2
  780. package/dist/services/reviewer/reviewer-service.d.ts +2 -36
  781. package/dist/services/reviewer/reviewer-service.js +2 -1
  782. package/dist/services/reviewer/reviewer-types.d.ts +43 -0
  783. package/dist/services/reviewer/reviewer-types.js +1 -0
  784. package/dist/services/role/role-registry.js +9 -1
  785. package/dist/services/runtime/runtime-detector.js +4 -1
  786. package/dist/services/runtime/vendors/claude-code.js +14 -6
  787. package/dist/services/runtime/vendors/codex.js +11 -3
  788. package/dist/services/runtime/vendors/copilot.js +11 -3
  789. package/dist/services/sc/sc-service.js +28 -15
  790. package/dist/services/scan/acceptance-coverage-service.js +4 -1
  791. package/dist/services/scan/api-diff-openapi-schema-read.d.ts +67 -0
  792. package/dist/services/scan/api-diff-openapi-schema-read.js +154 -0
  793. package/dist/services/scan/api-diff-openapi.d.ts +16 -2
  794. package/dist/services/scan/api-diff-openapi.js +19 -123
  795. package/dist/services/scan/api-diff-recorded.js +16 -3
  796. package/dist/services/scan/api-diff-service.js +49 -16
  797. package/dist/services/scan/api-diff-types.js +12 -3
  798. package/dist/services/scan/api-surface-helpers.d.ts +13 -0
  799. package/dist/services/scan/api-surface-helpers.js +31 -0
  800. package/dist/services/scan/api-surface-service.d.ts +2 -45
  801. package/dist/services/scan/api-surface-service.js +15 -26
  802. package/dist/services/scan/api-surface-types.d.ts +54 -0
  803. package/dist/services/scan/api-surface-types.js +10 -0
  804. package/dist/services/scan/archetype-detection.d.ts +37 -0
  805. package/dist/services/scan/archetype-detection.js +142 -0
  806. package/dist/services/scan/archetype-service.js +36 -125
  807. package/dist/services/scan/diff-scope-service.js +35 -15
  808. package/dist/services/scan/existing-system-service.js +16 -99
  809. package/dist/services/scan/existing-system-visual-tokens.d.ts +20 -0
  810. package/dist/services/scan/existing-system-visual-tokens.js +123 -0
  811. package/dist/services/scan/file-size-policy.d.ts +86 -0
  812. package/dist/services/scan/file-size-policy.js +184 -0
  813. package/dist/services/scan/file-size-scan.d.ts +30 -3
  814. package/dist/services/scan/file-size-scan.js +47 -9
  815. package/dist/services/scan/karpathy-service.js +6 -1
  816. package/dist/services/scan/orphan-service.js +86 -20
  817. package/dist/services/scan/type-sanity-service.js +104 -10
  818. package/dist/services/sediment/dispose-confirm.d.ts +2 -2
  819. package/dist/services/sediment/dispose-confirm.js +2 -2
  820. package/dist/services/sediment/json-schema.d.ts +1 -1
  821. package/dist/services/sediment/json-schema.js +25 -13
  822. package/dist/services/sediment/manifest-lint.d.ts +1 -12
  823. package/dist/services/sediment/manifest-lint.js +1 -7
  824. package/dist/services/sediment/pool-paths.js +13 -9
  825. package/dist/services/sediment/pool-read.d.ts +1 -1
  826. package/dist/services/sediment/pool-read.js +42 -18
  827. package/dist/services/sediment/pool-rebuild-index.d.ts +1 -1
  828. package/dist/services/sediment/pool-rebuild-index.js +5 -5
  829. package/dist/services/sediment/pool-write.d.ts +1 -1
  830. package/dist/services/sediment/pool-write.js +7 -7
  831. package/dist/services/sediment/promotion-gate.d.ts +1 -1
  832. package/dist/services/sediment/promotion-gate.js +9 -9
  833. package/dist/services/sediment/types.d.ts +8 -8
  834. package/dist/services/session/binding-status-service.js +14 -4
  835. package/dist/services/session/caller-binding-service.js +2 -1
  836. package/dist/services/session/getSessionDir.js +4 -1
  837. package/dist/services/session/index.d.ts +1 -1
  838. package/dist/services/session/index.js +1 -1
  839. package/dist/services/session/resolve-caller-id.js +7 -5
  840. package/dist/services/session/session-binding-bridge.js +26 -25
  841. package/dist/services/session/session-checkpoint-service.js +1 -1
  842. package/dist/services/session/session-file-schema.d.ts +70 -0
  843. package/dist/services/session/session-file-schema.js +68 -0
  844. package/dist/services/session/session-manager.d.ts +6 -6
  845. package/dist/services/session/session-manager.js +30 -29
  846. package/dist/services/session/session-resume-service.js +2 -1
  847. package/dist/services/share/bundle-format-constants.d.ts +85 -0
  848. package/dist/services/share/bundle-format-constants.js +100 -0
  849. package/dist/services/share/bundle-reader.d.ts +3 -3
  850. package/dist/services/share/bundle-reader.js +75 -68
  851. package/dist/services/share/bundle-types.d.ts +3 -70
  852. package/dist/services/share/bundle-types.js +38 -107
  853. package/dist/services/share/bundle-writer.d.ts +3 -3
  854. package/dist/services/share/bundle-writer.js +101 -91
  855. package/dist/services/share/run-state-contract.d.ts +1 -1
  856. package/dist/services/share/run-state-contract.js +7 -13
  857. package/dist/services/signal/cancel-handler.js +2 -1
  858. package/dist/services/skill/resume-detector.js +6 -4
  859. package/dist/services/skill/skill-scheduler.js +3 -1
  860. package/dist/services/skill/skill-search-service.js +4 -4
  861. package/dist/services/skillhub/release-diff.d.ts +2 -2
  862. package/dist/services/skillhub/release-diff.js +6 -10
  863. package/dist/services/skillhub/release-export.d.ts +2 -2
  864. package/dist/services/skillhub/release-export.js +15 -17
  865. package/dist/services/skillhub/release-gc-blobs.d.ts +2 -2
  866. package/dist/services/skillhub/release-gc-blobs.js +4 -4
  867. package/dist/services/skillhub/release-import.d.ts +2 -2
  868. package/dist/services/skillhub/release-import.js +13 -12
  869. package/dist/services/skillhub/release-retain.d.ts +3 -3
  870. package/dist/services/skillhub/release-retain.js +22 -22
  871. package/dist/services/skillhub/sqlite-store.d.ts +1 -1
  872. package/dist/services/skillhub/sqlite-store.js +12 -11
  873. package/dist/services/skillhub/tar-runtime.js +15 -15
  874. package/dist/services/skillhub/types.d.ts +4 -4
  875. package/dist/services/skills/hooks-codegate-superpowers.js +16 -7
  876. package/dist/services/skills/hooks-settings-service.js +61 -19
  877. package/dist/services/skills/presence-lease-service.js +26 -16
  878. package/dist/services/skills/presence-lease-types.d.ts +1 -1
  879. package/dist/services/skills/presence-lease-types.js +1 -1
  880. package/dist/services/skills/skill-conformance-service.js +40 -8
  881. package/dist/services/skills/skill-presence-service.js +16 -14
  882. package/dist/services/skills/skill-runbook-service.js +2 -1
  883. package/dist/services/skills/skill-statusline-model.d.ts +128 -0
  884. package/dist/services/skills/skill-statusline-model.js +163 -0
  885. package/dist/services/skills/skill-statusline-renderer.js +4 -3
  886. package/dist/services/skills/skill-statusline-service.d.ts +3 -100
  887. package/dist/services/skills/skill-statusline-service.js +56 -163
  888. package/dist/services/skills/statusline-palette.js +11 -6
  889. package/dist/services/skills/statusline-settings-service.js +2 -1
  890. package/dist/services/skills/sync-service-support.d.ts +65 -0
  891. package/dist/services/skills/sync-service-support.js +50 -0
  892. package/dist/services/skills/sync-service.d.ts +3 -66
  893. package/dist/services/skills/sync-service.js +15 -53
  894. package/dist/services/slice/calibration-store.js +8 -2
  895. package/dist/services/slice/cross-pass-edge-merger.d.ts +3 -28
  896. package/dist/services/slice/cross-pass-edge-merger.js +13 -63
  897. package/dist/services/slice/cross-pass-edge-static-scan-support.d.ts +69 -0
  898. package/dist/services/slice/cross-pass-edge-static-scan-support.js +74 -0
  899. package/dist/services/slice/granularity-decider.js +2 -2
  900. package/dist/services/slice/slice-archive-service.js +8 -3
  901. package/dist/services/slice/slice-check-service.js +19 -8
  902. package/dist/services/slice/slice-decompose-runners.js +61 -23
  903. package/dist/services/slice/slice-decompose-service.js +4 -4
  904. package/dist/services/slice/slice-review-state.js +8 -2
  905. package/dist/services/smoke/smoke-paths-state.js +9 -2
  906. package/dist/services/sop/gate-enforce-service.js +9 -2
  907. package/dist/services/sop/sop-advance-service.js +14 -2
  908. package/dist/services/sop/sop-check-service.js +16 -4
  909. package/dist/services/sop/sop-paths.js +3 -1
  910. package/dist/services/sop/sop-registry-service.js +5 -1
  911. package/dist/services/sop/sop-service.js +29 -7
  912. package/dist/services/sop/sop-types.js +5 -1
  913. package/dist/services/standards/ide-aware-standards-service.js +2 -2
  914. package/dist/services/standards/loop-engineering-lint.js +12 -5
  915. package/dist/services/standards/loop-engineering-readiness-lint.js +5 -5
  916. package/dist/services/standards/migrate-claude-rules-service.js +9 -7
  917. package/dist/services/standards/missing-standards-detector.js +1 -3
  918. package/dist/services/standards/project-context-support.d.ts +50 -0
  919. package/dist/services/standards/project-context-support.js +244 -0
  920. package/dist/services/standards/project-context-types.d.ts +30 -0
  921. package/dist/services/standards/project-context-types.js +11 -0
  922. package/dist/services/standards/project-context.d.ts +10 -22
  923. package/dist/services/standards/project-context.js +27 -214
  924. package/dist/services/standards/project-standards-service.js +43 -12
  925. package/dist/services/standards/standards-render-common.d.ts +15 -0
  926. package/dist/services/standards/standards-render-common.js +49 -0
  927. package/dist/services/standards/standards-render.d.ts +1 -2
  928. package/dist/services/standards/standards-render.js +31 -58
  929. package/dist/services/standards/ui-library-dispatch-block.js +1 -1
  930. package/dist/services/tech/tech-change-id-service.js +7 -7
  931. package/dist/services/tech/tech-service.js +73 -26
  932. package/dist/services/test-cache/test-cache-service.js +8 -3
  933. package/dist/services/upgrade/1x-detector-service.js +5 -3
  934. package/dist/services/upgrade/gitignore-migrate-service.js +5 -5
  935. package/dist/services/upgrade/upgrade-service.js +36 -13
  936. package/dist/services/verdict/envelope-parsers.d.ts +84 -0
  937. package/dist/services/verdict/envelope-parsers.js +146 -0
  938. package/dist/services/verdict/envelopes.d.ts +50 -60
  939. package/dist/services/verdict/envelopes.js +18 -156
  940. package/dist/services/verdict/verdict-aggregator.js +27 -3
  941. package/dist/services/vm/vm-lease.js +15 -3
  942. package/dist/services/web/aria-node.d.ts +27 -0
  943. package/dist/services/web/aria-node.js +1 -0
  944. package/dist/services/web/browser-acquire.js +3 -1
  945. package/dist/services/web/browser-cache-probe.d.ts +18 -0
  946. package/dist/services/web/browser-cache-probe.js +110 -0
  947. package/dist/services/web/browser-session-manager.js +6 -2
  948. package/dist/services/web/daemon-registry.js +4 -1
  949. package/dist/services/web/playwright-loader.d.ts +2 -70
  950. package/dist/services/web/playwright-types.d.ts +75 -0
  951. package/dist/services/web/playwright-types.js +1 -0
  952. package/dist/services/web/snapshot-pruner.d.ts +2 -23
  953. package/dist/services/web/snapshot-pruner.js +8 -3
  954. package/dist/services/web/web-daemon-service.js +1 -3
  955. package/dist/services/web/web-install-service.d.ts +3 -32
  956. package/dist/services/web/web-install-service.js +21 -100
  957. package/dist/services/web/web-install-types.d.ts +31 -0
  958. package/dist/services/web/web-install-types.js +13 -0
  959. package/dist/services/web/web-login-profile.js +7 -5
  960. package/dist/services/web/web-protocol.js +3 -1
  961. package/dist/services/workflow/pipeline-verify-gate-support.js +63 -17
  962. package/dist/services/workflow/pipeline-verify-service.js +17 -6
  963. package/dist/services/workflow/plan-reader.js +5 -1
  964. package/dist/services/workflow/plan-refresher.js +20 -6
  965. package/dist/services/workflow/plan-trigger-detector.js +31 -8
  966. package/dist/services/workflow/provision-dispatch-node.js +8 -3
  967. package/dist/services/workflow/workflow-autonomous-resume-helpers.d.ts +3 -1
  968. package/dist/services/workflow/workflow-autonomous-resume-helpers.js +35 -144
  969. package/dist/services/workflow/workflow-autonomous-resume-validation.d.ts +16 -0
  970. package/dist/services/workflow/workflow-autonomous-resume-validation.js +155 -0
  971. package/dist/services/workflow/workflow-autonomous-service.js +25 -13
  972. package/dist/services/workflow/workflow-graph-store-helpers.d.ts +51 -0
  973. package/dist/services/workflow/workflow-graph-store-helpers.js +111 -0
  974. package/dist/services/workflow/workflow-graph-store.d.ts +2 -35
  975. package/dist/services/workflow/workflow-graph-store.js +30 -107
  976. package/dist/services/workflow/workflow-graph-types.js +3 -3
  977. package/dist/services/workflow/workflow-inflight-probe.js +14 -7
  978. package/dist/services/workflow/workflow-loader.js +5 -1
  979. package/dist/services/workflow/workflow-node-lifecycle.js +22 -21
  980. package/dist/services/workflow/workflow-presence-lifecycle-types.d.ts +50 -0
  981. package/dist/services/workflow/workflow-presence-lifecycle-types.js +1 -0
  982. package/dist/services/workflow/workflow-presence-lifecycle.d.ts +2 -42
  983. package/dist/services/workflow/workflow-presence-lifecycle.js +19 -21
  984. package/dist/services/workflow/workflow-router-service.js +169 -27
  985. package/dist/services/workflow/workflow-skip-service.js +14 -4
  986. package/dist/services/workflow/workflow-spec-builders.d.ts +15 -0
  987. package/dist/services/workflow/workflow-spec-builders.js +121 -0
  988. package/dist/services/workflow/workflow-spec.d.ts +7 -6
  989. package/dist/services/workflow/workflow-spec.js +22 -116
  990. package/dist/services/workflow/workflow-state-store.js +2 -1
  991. package/dist/services/workspace/migrate-1-4-1-service.js +80 -14
  992. package/dist/services/workspace/migrate-service.js +66 -16
  993. package/dist/services/workspace/reconcile-migrate.js +6 -2
  994. package/dist/services/workspace/reconcile-service.js +37 -16
  995. package/dist/services/workspace/workspace-claude-settings-materializer.js +7 -5
  996. package/dist/services/workspace/workspace-clean-service.js +4 -1
  997. package/dist/services/workspace/workspace-service.js +11 -3
  998. package/dist/services/workspace/workspace-state-service.js +1 -1
  999. package/dist/services/worktree/git-worktree-parser.js +13 -3
  1000. package/dist/services/worktree/host-worktree-reconciler.js +8 -4
  1001. package/dist/services/worktree/long-path-cleanup.js +23 -6
  1002. package/dist/services/worktree/worktree-gc-guard.js +3 -1
  1003. package/dist/services/worktree/worktree-lease-types.d.ts +53 -0
  1004. package/dist/services/worktree/worktree-lease-types.js +10 -0
  1005. package/dist/services/worktree/worktree-lease.d.ts +2 -44
  1006. package/dist/shared/array-guards.d.ts +30 -0
  1007. package/dist/shared/array-guards.js +32 -0
  1008. package/dist/shared/format-md-compact-internals.d.ts +26 -0
  1009. package/dist/shared/format-md-compact-internals.js +125 -0
  1010. package/dist/shared/format-md-compact.js +1 -117
  1011. package/dist/shared/fs-utils.js +2 -1
  1012. package/dist/shared/incrementing-number.js +3 -3
  1013. package/dist/shared/json-parse.d.ts +71 -0
  1014. package/dist/shared/json-parse.js +32 -0
  1015. package/dist/shared/json-schema-mini.js +3 -1
  1016. package/dist/shared/path-safety.js +3 -1
  1017. package/dist/shared/path-utils.d.ts +20 -0
  1018. package/dist/shared/path-utils.js +26 -0
  1019. package/dist/shared/planner-response.js +3 -3
  1020. package/dist/shared/stale-policy.js +1 -3
  1021. package/dist/skills/peaks-maker/index.js +11 -11
  1022. package/package.json +31 -8
  1023. package/scripts/clean-dist.mjs +1 -2
  1024. package/scripts/copy-templates.mjs +2 -4
  1025. package/scripts/install-skills.mjs +305 -125
  1026. package/scripts/sync-version.mjs +25 -8
  1027. package/scripts/watch.mjs +8 -2
  1028. package/skills/peaks-code/SKILL.md +1 -1
@@ -0,0 +1,161 @@
1
+ // src/services/final-review/final-review-output-budget.ts
2
+ //
3
+ // D1 layer 3: the output ceiling that must sit opposite the evidence
4
+ // inlined into the prompt. Hoisted verbatim from final-review-service.ts
5
+ // (C wave 7 file-size split).
6
+ //
7
+ // One deliberate respell: 12 * 1024 is written as 12_288 (same value,
8
+ // pinned by the existing tests) so this module carries no
9
+ // no-magic-numbers finding; see final-review-evidence-budget.ts.
10
+ // The 263-307 block comment is kept intact including the 4 * 1024 /
11
+ // 12 * 1024 arithmetic it narrates — it documents the decision, not
12
+ // the expression that shipped it.
13
+ /* ------------------------------------------------------------------ *
14
+ * D1 layer 3 — the OUTPUT budget.
15
+ *
16
+ * The input side above was raised (32 KiB then, 40 KiB today) but the
17
+ * output ceiling stayed hard-coded at 3000 tokens. Measured on this repo's own
18
+ * run (rid `2026-09-12-codegraph-exclude-integrity`, 9 sources, 32 KiB
19
+ * inlined, real anthropic provider): 3/3 attempts failed — 2x
20
+ * INCOMPLETE_FINAL_REVIEW with the JSON cut off mid-string, 1x a reply with no
21
+ * text block. A 4-dimension envelope (4 x `summary` + `evidence[]` +
22
+ * `confidence`, plus `overallSummary`) does not fit in 3000 tokens once the
23
+ * model has ~8k tokens of evidence it is required to cite.
24
+ *
25
+ * N4 — the first fix of this layer derived the ceiling as "3000 + bytes/8" and
26
+ * called 8192 "a backstop only: it does not bind today", citing a 4775-token
27
+ * measurement. Both claims were falsified by re-measurement on the SAME
28
+ * machine the gate ships on (`deepseek-flash[1M]` via
29
+ * `api.deepseek.com/anthropic`, 2026-09-12, QA run 3/3 red + orchestrator
30
+ * re-run 3/3 red, rid `2026-09-12-codegraph-exclude-integrity`, byte-identical
31
+ * prompt):
32
+ *
33
+ * max_tokens=7096 (what the old formula produced for the 32 KiB pack)
34
+ * -> TRUNCATED. `output_tokens=7096`, 14078 characters.
35
+ * max_tokens=8192 -> TRUNCATED, `output_tokens=8192`, 574 characters.
36
+ * max_tokens=16000 -> COMPLETE, `output_tokens=10108`.
37
+ * max_tokens=32000 -> COMPLETE, `output_tokens=8883`.
38
+ *
39
+ * So 8192 WAS the binding constraint and was BELOW the requirement: a gate
40
+ * whose budget is short is worse than a red gate, because it releases the
41
+ * envelope only when the model happens to be terse.
42
+ *
43
+ * The 8:1 bytes-per-token term prices the VISIBLE envelope against the evidence
44
+ * the model must cite, but it was never the whole cost. On a reasoning model
45
+ * `max_tokens` also caps the hidden reasoning that precedes the first character
46
+ * of output, and that cost is invisible to a bytes-per-token formula (the
47
+ * 574-character run above is exactly that: the whole budget consumed before the
48
+ * envelope began). `REASONING_HEADROOM_TOKENS` below is that missing term.
49
+ *
50
+ * A 16384 ceiling with 6144 of headroom (derived 13240) was then measured on
51
+ * the SAME machine and shown to be too thin too: 10 real-machine runs, 2
52
+ * failures, BOTH genuine truncation — and the second one reported BOTH signals
53
+ * at once ("reply ends mid-structure AND provider-reported output reached the
54
+ * ceiling") with `maxTokens=13240`. The requirement is therefore not "derived
55
+ * >= the one 10108 sample" but "derived comfortably above every observed
56
+ * truncation point", which is what the constants below are now sized for.
57
+ * ------------------------------------------------------------------ */
58
+ /**
59
+ * Floor — also the value that shipped before this fix, so no evidence set can
60
+ * end up with a smaller budget than it had. ~3000 tokens is enough for the
61
+ * envelope skeleton plus a short paragraph per dimension.
62
+ */
63
+ export const MIN_OUTPUT_TOKENS = 3_000;
64
+ /**
65
+ * Headroom for the part of the reply that is not the envelope.
66
+ *
67
+ * A Messages-API-compatible endpoint applies `max_tokens` to the WHOLE
68
+ * response, and a reasoning model spends it on hidden reasoning before it
69
+ * emits a single character of the 4-dim envelope. Measured on this repo's own
70
+ * machine (2026-09-12, rid `2026-09-12-codegraph-exclude-integrity`,
71
+ * `deepseek-flash[1M]` via `api.deepseek.com/anthropic`): `max_tokens=8192`
72
+ * came back with `output_tokens=8192` and only **574** visible characters —
73
+ * the entire budget went to reasoning. A bytes-per-token estimate of the
74
+ * visible output cannot see that cost, which is why the previous formula
75
+ * budgeted 7096 for a reply that needs 10108 — and why a 13240 budget still
76
+ * truncated on 2 of 10 real runs.
77
+ *
78
+ * 12288 (12 KiB) is sized so the largest evidence pack the input caps allow
79
+ * lands at 25528 (see the formula below; the input cap is 40 KiB as of the
80
+ * F-BLOCK re-evaluation, and this floor was checked against the raised cap, not
81
+ * against the 32 KiB the measurements above were taken at — a 12 KiB headroom
82
+ * under a bigger cap is the conservative direction) — about 1.9x the largest
83
+ * value ever OBSERVED to truncate (13240), which is the margin the observed
84
+ * variance asks for. The numbers are in the block comment above.
85
+ */
86
+ export const REASONING_HEADROOM_TOKENS = 12_288;
87
+ /**
88
+ * Ceiling, 32_000: the value a real run on this machine was forced to in order
89
+ * to complete the envelope at all, and the largest this endpoint was observed
90
+ * to accept. 16384 was tried first and truncated 2/10 — a ceiling that is
91
+ * merely "above the last successful measurement" is not above the requirement,
92
+ * because the requirement moves with the model's reasoning spend.
93
+ *
94
+ * A model that caps output at 8192 will refuse this. That is still strictly
95
+ * better than shipping a budget measured to be too small, and the env lever
96
+ * below lets an operator pull it down without a code change.
97
+ */
98
+ export const MAX_OUTPUT_TOKENS = 32_000;
99
+ /**
100
+ * Environment lever. The old failure message told the operator to "raise the
101
+ * budget" while the budget was a module constant with no CLI flag and no env
102
+ * var — an instruction that could not be carried out from any surface the
103
+ * operator has. This is that lever.
104
+ *
105
+ * The value is the output ceiling in tokens; it OVERRIDES the derivation below
106
+ * (it is not a bonus added to it). Unset/invalid/out-of-range handling is in
107
+ * `resolveOutputBudget`.
108
+ */
109
+ export const MAX_OUTPUT_TOKENS_ENV = 'PEAKS_FINAL_REVIEW_MAX_OUTPUT_TOKENS';
110
+ /**
111
+ * Absolute upper bound the env lever may reach. An endpoint that accepts
112
+ * `max_tokens` at all accepts this; anything above it is a typo (a stray extra
113
+ * digit), not an intent, and clamping is safer than sending it.
114
+ */
115
+ export const HARD_MAX_OUTPUT_TOKENS = 64_000;
116
+ /**
117
+ * Inlined bytes that buy one extra output token — 4:1.
118
+ *
119
+ * This term prices the visible envelope (4 x `summary` + `evidence[]` +
120
+ * `confidence` + `overallSummary`) against the evidence the model is required
121
+ * to cite. It was 8:1, which put the 32 KiB pack at 4096 tokens of visible
122
+ * output; the same pack has been observed to complete at 10108 and to truncate
123
+ * at 13240, so 8:1 was pricing the visible side BELOW its own measurement.
124
+ * 4:1 doubles it to 8192. It is still not treated as the whole budget — see
125
+ * `REASONING_HEADROOM_TOKENS`.
126
+ */
127
+ export const EVIDENCE_BYTES_PER_OUTPUT_TOKEN = 4;
128
+ /**
129
+ * Output ceiling for a call whose prompt carries `includedEvidenceBytes` bytes
130
+ * of inlined evidence. Pure, total, and clamped on both ends — the same
131
+ * evidence pack always yields the same budget.
132
+ */
133
+ export function outputBudgetForEvidence(includedEvidenceBytes) {
134
+ const scaled = MIN_OUTPUT_TOKENS +
135
+ REASONING_HEADROOM_TOKENS +
136
+ Math.ceil(Math.max(0, includedEvidenceBytes) / EVIDENCE_BYTES_PER_OUTPUT_TOKEN);
137
+ return Math.min(MAX_OUTPUT_TOKENS, Math.max(MIN_OUTPUT_TOKENS, scaled));
138
+ }
139
+ /**
140
+ * The budget the call actually uses: the derived one, unless
141
+ * `PEAKS_FINAL_REVIEW_MAX_OUTPUT_TOKENS` overrides it.
142
+ *
143
+ * An override that is not a positive integer THROWS rather than being ignored:
144
+ * a silent fallback would leave an operator who passed a bad value with the
145
+ * exact experience this lever exists to remove — a budget they cannot move.
146
+ * Out-of-range values are clamped, not rejected, so a model needing more than
147
+ * `HARD_MAX_OUTPUT_TOKENS` (or a model needing less than `MIN_OUTPUT_TOKENS`)
148
+ * still gets a call made.
149
+ */
150
+ export function resolveOutputBudget(includedEvidenceBytes, env = process.env) {
151
+ const derived = outputBudgetForEvidence(includedEvidenceBytes);
152
+ const raw = env[MAX_OUTPUT_TOKENS_ENV];
153
+ if (raw === undefined || raw.trim() === '')
154
+ return derived;
155
+ const parsed = Number.parseInt(raw.trim(), 10);
156
+ if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw.trim()) {
157
+ throw new Error(`${MAX_OUTPUT_TOKENS_ENV} must be a positive integer number of output tokens (got "${raw}"); ` +
158
+ `unset it to use the derived budget of ${String(derived)} tokens.`);
159
+ }
160
+ return Math.min(HARD_MAX_OUTPUT_TOKENS, Math.max(MIN_OUTPUT_TOKENS, parsed));
161
+ }
@@ -0,0 +1,35 @@
1
+ import type { PrePostDiffResult } from './pre-post-diff.js';
2
+ import type { UndeliverableDimensionEvidence } from './final-review-delivery.js';
3
+ import type { CollectedEvidence } from './final-review-evidence-sources.js';
4
+ export declare function renderEvidenceSection(collected: readonly CollectedEvidence[]): string;
5
+ /**
6
+ * The producer's own status, told to the reviewer in as many words.
7
+ *
8
+ * It exists because the artifact's ABSENCE is not self-explanatory: a reviewer
9
+ * shown nothing about `existing-functionality-intact` beyond two design-intent
10
+ * documents cannot tell "the diff was clean" from "no diff was ever computed",
11
+ * and the pre-fix run resolved that ambiguity by quietly returning
12
+ * `inconclusive` forever. Naming the reason is what makes the unavailable case
13
+ * a stated fact instead of an invisible one.
14
+ *
15
+ * Kept short on purpose: it rides inside the same prompt that is byte-capped at
16
+ * `MAX_EVIDENCE_BYTES_TOTAL` + scaffolding.
17
+ *
18
+ * F-BLOCK: this block may only say COMPUTED when the artifact it names was
19
+ * actually inlined. Saying "computed — cite it" one line above a source block
20
+ * reading `STATUS: MISSING (omitted)` told the reviewer to cite evidence it had
21
+ * not been given, and that contradiction is what let a `pass` survive a
22
+ * baseline nobody saw.
23
+ */
24
+ export declare function renderPrePostDiffStatus(prePostDiff: PrePostDiffResult, delivered: boolean): string;
25
+ export declare const EVIDENCE_RULES = "## Binding rules for the four verdicts\n1. A dimension may be \"pass\" ONLY if at least one source in its SUPPORTS list has STATUS: FOUND above, and that source's content actually supports the verdict. The service re-checks this: a \"pass\" whose supporting sources are all missing/empty/omitted is downgraded to \"inconclusive\" before any human sees it.\n2. If the evidence a dimension needs is MISSING, EMPTY, or OMITTED, return \"inconclusive\" with confidence \"low\". Do not guess \"pass\".\n3. Absence of evidence is not evidence of absence: \"no problem found in what I was given\" is \"inconclusive\", never \"pass\".\n4. Cite the bracketed source numbers (e.g. \"[1]\", \"[5]\") you relied on in each dimension's \"evidence[].description\"; use an empty list when the verdict is \"inconclusive\".\n5. \"allPass\" may be true only when all four verdicts are \"pass\", and every non-\"pass\" dimension must be listed in \"needsAttention\".\n6. \"existing-functionality-intact\" may be \"pass\" ONLY when the pre/post baseline diff block above shows STATUS: FOUND. A design-intent document (RD tech doc, PRD handoff) states what was INTENDED; it is not a before/after comparison of the test surface or the public API surface, and a \"pass\" resting on one is downgraded to \"inconclusive\" by the service before any human sees it.\n7. An \"inconclusive\" verdict cannot be confident: report it with confidence \"low\" (or \"medium\" when the reviewer is sure the evidence is merely incomplete). \"high\" on \"inconclusive\" is a contradiction and the service clamps it.\n8. \"functional-completeness\" may be \"pass\" ONLY when the approved-scope contract block (prd-handoff, the source carrying the approved scope and non-goals) is present above with its WHOLE byte count \u2014 a STATUS line reading \"FOUND at ... \u2014 N bytes\", not a truncated or an omitted one. A passing test report shows that something was built; only the contract shows that what was built IS the approved scope. The service re-checks this: it downgrades a \"pass\" on this dimension whenever that contract exists for the run but was not delivered in full.";
26
+ /**
27
+ * H2 — tell the reviewer, in the prompt, that a dimension has no deliverable
28
+ * source at all. Emitted only when there is something to say, so the byte
29
+ * budget is not spent on an empty section every run.
30
+ *
31
+ * It reads like `renderPrePostDiffStatus` on purpose: the reviewer is told the
32
+ * FACT and what to answer with, so a permanently red dimension arrives at the
33
+ * human with its cause attached instead of as an unexplained `inconclusive`.
34
+ */
35
+ export declare function renderDeliveryReachabilityStatus(report: readonly UndeliverableDimensionEvidence[]): string;
@@ -0,0 +1,112 @@
1
+ // src/services/final-review/final-review-prompt.ts
2
+ //
3
+ // The prompt-side rendering: evidence blocks, the producer status block,
4
+ // the binding verdict rules, and the delivery-reachability statement.
5
+ // Hoisted verbatim from final-review-service.ts (C wave 7 file-size
6
+ // split). renderEvidenceSection prints the STATUS line from the literal
7
+ // 'found' alone — the delivery decision is not made here, so guard C's
8
+ // render-only exemption applies to its moved text.
9
+ import { MAX_EVIDENCE_BYTES_PER_FILE } from './final-review-evidence-budget.js';
10
+ export function renderEvidenceSection(collected) {
11
+ return collected
12
+ .map((item, index) => {
13
+ const heading = `### [${index + 1}] ${item.source.key} — ${item.source.label}`;
14
+ const supports = `SUPPORTS: ${item.source.supports.join(', ')}`;
15
+ if (item.status === 'found') {
16
+ const status = item.includedBytes < item.totalBytes
17
+ ? `FOUND at ${item.relativePath} — TRUNCATED, showing the first ${item.includedBytes} of ${item.totalBytes} bytes`
18
+ : `FOUND at ${item.relativePath} — ${item.totalBytes} bytes`;
19
+ return `${heading}\n${supports}\nSTATUS: ${status}\n<<<EVIDENCE\n${item.content}\n>>>EVIDENCE`;
20
+ }
21
+ if (item.status === 'unreadable') {
22
+ // F4 — NOT "missing". The reviewer is told the file is there and the
23
+ // read failed, which is a different instruction to a human than "this
24
+ // run had no PRD phase": one is a fact about the run, the other is a
25
+ // fact about the machine, and only the second is fixable.
26
+ return `${heading}\n${supports}\nSTATUS: UNREADABLE — no evidence available from ${item.relativePath}: ${item.reason}`;
27
+ }
28
+ return `${heading}\n${supports}\nSTATUS: MISSING (${item.status}) — no evidence available from ${item.relativePath}: ${item.reason}`;
29
+ })
30
+ .join('\n\n');
31
+ }
32
+ /**
33
+ * The producer's own status, told to the reviewer in as many words.
34
+ *
35
+ * It exists because the artifact's ABSENCE is not self-explanatory: a reviewer
36
+ * shown nothing about `existing-functionality-intact` beyond two design-intent
37
+ * documents cannot tell "the diff was clean" from "no diff was ever computed",
38
+ * and the pre-fix run resolved that ambiguity by quietly returning
39
+ * `inconclusive` forever. Naming the reason is what makes the unavailable case
40
+ * a stated fact instead of an invisible one.
41
+ *
42
+ * Kept short on purpose: it rides inside the same prompt that is byte-capped at
43
+ * `MAX_EVIDENCE_BYTES_TOTAL` + scaffolding.
44
+ *
45
+ * F-BLOCK: this block may only say COMPUTED when the artifact it names was
46
+ * actually inlined. Saying "computed — cite it" one line above a source block
47
+ * reading `STATUS: MISSING (omitted)` told the reviewer to cite evidence it had
48
+ * not been given, and that contradiction is what let a `pass` survive a
49
+ * baseline nobody saw.
50
+ */
51
+ export function renderPrePostDiffStatus(prePostDiff, delivered) {
52
+ const heading = '## Pre/post baseline diff producer (existing-functionality-intact)';
53
+ if (prePostDiff.status === 'computed' && delivered) {
54
+ return [
55
+ heading,
56
+ `STATUS: COMPUTED — ${prePostDiff.summary}`,
57
+ `Artifact: ${prePostDiff.relativePath} (the next source block). Cite it with evidence kind "pre-post-diff"; it is the structural before/after comparison this dimension's definition asks for.`
58
+ ].join('\n');
59
+ }
60
+ if (prePostDiff.status === 'computed') {
61
+ return [
62
+ heading,
63
+ `STATUS: COMPUTED ON DISK, NOT DELIVERED — the baseline was produced at ${prePostDiff.relativePath}, but its source block could not be inlined into this prompt (the evidence budget omitted it), so it is NOT among the evidence above and you have NOT seen it.`,
64
+ 'Report "existing-functionality-intact" as "inconclusive" and name this in its summary. Do NOT report "pass": the service downgrades a "pass" on this dimension whenever the comparison was not delivered, and a comparison you were not shown is not a comparison that came back clean.'
65
+ ].join('\n');
66
+ }
67
+ const consequence = prePostDiff.inGitWorkTree
68
+ ? 'This project IS a git work tree, so a baseline was expected to be computable: the service treats its absence as a tooling failure and downgrades a "pass" on this dimension to "inconclusive" before any human sees it.'
69
+ : 'This project is not a git work tree, so no baseline can be computed at all. The service downgrades a "pass" on this dimension to "inconclusive" here TOO: "this project keeps no baseline" explains why the evidence is absent, and the absence of a comparison is not a comparison that came back clean.';
70
+ return [
71
+ heading,
72
+ `STATUS: UNAVAILABLE — ${prePostDiff.reason}.`,
73
+ `No pre/post baseline diff exists for this run. Report "existing-functionality-intact" as "inconclusive" with confidence "low" and name the reason above in its summary. Do NOT report "pass": a missing baseline is not evidence of no drift. ${consequence}`
74
+ ].join('\n');
75
+ }
76
+ export const EVIDENCE_RULES = `## Binding rules for the four verdicts
77
+ 1. A dimension may be "pass" ONLY if at least one source in its SUPPORTS list has STATUS: FOUND above, and that source's content actually supports the verdict. The service re-checks this: a "pass" whose supporting sources are all missing/empty/omitted is downgraded to "inconclusive" before any human sees it.
78
+ 2. If the evidence a dimension needs is MISSING, EMPTY, or OMITTED, return "inconclusive" with confidence "low". Do not guess "pass".
79
+ 3. Absence of evidence is not evidence of absence: "no problem found in what I was given" is "inconclusive", never "pass".
80
+ 4. Cite the bracketed source numbers (e.g. "[1]", "[5]") you relied on in each dimension's "evidence[].description"; use an empty list when the verdict is "inconclusive".
81
+ 5. "allPass" may be true only when all four verdicts are "pass", and every non-"pass" dimension must be listed in "needsAttention".
82
+ 6. "existing-functionality-intact" may be "pass" ONLY when the pre/post baseline diff block above shows STATUS: FOUND. A design-intent document (RD tech doc, PRD handoff) states what was INTENDED; it is not a before/after comparison of the test surface or the public API surface, and a "pass" resting on one is downgraded to "inconclusive" by the service before any human sees it.
83
+ 7. An "inconclusive" verdict cannot be confident: report it with confidence "low" (or "medium" when the reviewer is sure the evidence is merely incomplete). "high" on "inconclusive" is a contradiction and the service clamps it.
84
+ 8. "functional-completeness" may be "pass" ONLY when the approved-scope contract block (prd-handoff, the source carrying the approved scope and non-goals) is present above with its WHOLE byte count — a STATUS line reading "FOUND at ... — N bytes", not a truncated or an omitted one. A passing test report shows that something was built; only the contract shows that what was built IS the approved scope. The service re-checks this: it downgrades a "pass" on this dimension whenever that contract exists for the run but was not delivered in full.`;
85
+ /**
86
+ * H2 — tell the reviewer, in the prompt, that a dimension has no deliverable
87
+ * source at all. Emitted only when there is something to say, so the byte
88
+ * budget is not spent on an empty section every run.
89
+ *
90
+ * It reads like `renderPrePostDiffStatus` on purpose: the reviewer is told the
91
+ * FACT and what to answer with, so a permanently red dimension arrives at the
92
+ * human with its cause attached instead of as an unexplained `inconclusive`.
93
+ */
94
+ export function renderDeliveryReachabilityStatus(report) {
95
+ if (report.length === 0)
96
+ return '';
97
+ // Kept to one line per source and one line per dimension: this block rides
98
+ // inside the same byte-capped prompt as the evidence it describes, and the
99
+ // evidence blocks above already carry each source's path and status.
100
+ const lines = report.map((entry) => {
101
+ const sources = entry.sources
102
+ .map((item) => `${item.key} (${String(item.totalBytes)} bytes)`)
103
+ .join(', ');
104
+ return ` - ${entry.dimension}: NO deliverable source. ${sources} exceeds the per-file cap of ${String(MAX_EVIDENCE_BYTES_PER_FILE)} bytes, and a source is inlined WHOLE or not at all.`;
105
+ });
106
+ return [
107
+ '## Evidence delivery reachability (structural)',
108
+ `The allocator inlines at most ${String(MAX_EVIDENCE_BYTES_PER_FILE)} bytes of any one source, WHOLE or not at all, and a source delivered under the "whole" rule is delivered only when the reviewer received ALL of it. For the dimension(s) below, every source on disk that supports it is larger than that cap, so no source CAN be delivered — not on this run and not on any run, whatever the budget.`,
109
+ ...lines,
110
+ 'Report each of them as "inconclusive" with confidence "low" and name this reason in its summary. Do NOT report "pass": the service re-checks it, and a "pass" here is downgraded. This is a STRUCTURAL impossibility, not a judgement you are being asked to make — say so rather than reporting an unexplained "inconclusive".'
111
+ ].join('\n');
112
+ }
@@ -0,0 +1,57 @@
1
+ import type { LlmRunner } from './final-review-contract.js';
2
+ /**
3
+ * N4 — the reply carried no text block at all.
4
+ *
5
+ * Measured 2/3 on this repo's own machine, and it is NOT truncation: the
6
+ * provider answered with a response whose `content` has no `text` block (a
7
+ * reasoning-only turn, a refusal, or a content filter), so there is no JSON to
8
+ * parse and no budget to raise — an operator sent to "raise the budget" for
9
+ * this failure would be sent the wrong way. It gets its own class, its own
10
+ * `code`, and a message that says so, so it is diagnosable instead of being
11
+ * flattened into "not valid JSON".
12
+ */
13
+ export declare class EmptyReviewReplyError extends Error {
14
+ readonly code: "EMPTY_FINAL_REVIEW_REPLY";
15
+ constructor(message: string);
16
+ }
17
+ /**
18
+ * How many times an empty reply is retried before it is reported. The failure
19
+ * was 2/3 on the observed machine — intermittent, not systematic — so a small
20
+ * bounded retry converts most of it into a completed review, while 3 attempts
21
+ * keeps a genuinely broken provider from being hammered.
22
+ */
23
+ export declare const MAX_EMPTY_REPLY_ATTEMPTS = 3;
24
+ /** The facts an operator needs to tell a budget problem from a format problem. */
25
+ export declare function describeOutputBudget(maxTokens: number, outputTokens: number, characters: number): string;
26
+ /**
27
+ * N4 — say WHICH signal diagnosed the truncation, and flag the provider's usage
28
+ * numbers when they are the only thing pointing at the ceiling. Measured on
29
+ * this repo's machine: `input_tokens: 150` for a ~32 KiB prompt, so a reporter
30
+ * that cannot count the input should not be trusted to count the output.
31
+ */
32
+ export declare function describeTruncationSignal(structurallyCut: boolean, ceilingReached: boolean): string;
33
+ /**
34
+ * N4 — call the reviewer, retrying an EMPTY reply a bounded number of times.
35
+ *
36
+ * The empty reply is a separate failure mode from truncation and was measured
37
+ * at 2/3 on this repo's machine. It is intermittent, so a bounded retry turns
38
+ * most occurrences back into a completed review; when it does not, the caller
39
+ * gets `EmptyReviewReplyError` — classified and diagnosable — instead of a
40
+ * truncation message that sends the operator to raise a budget that was never
41
+ * the problem.
42
+ *
43
+ * The classification reads the runner's message because `LlmRunner` is a
44
+ * structural interface here (this module deliberately does not depend on the
45
+ * concrete provider module); "no text block" is the runner's own fixed wording
46
+ * for a response with no text content.
47
+ */
48
+ export declare function callReviewer(runner: LlmRunner, userPrompt: string, budget: {
49
+ readonly maxTokens: number;
50
+ readonly derivedMaxTokens: number;
51
+ }): Promise<{
52
+ output: string;
53
+ tokens: {
54
+ input: number;
55
+ output: number;
56
+ };
57
+ }>;
@@ -0,0 +1,95 @@
1
+ // src/services/final-review/final-review-reviewer.ts
2
+ //
3
+ // The reviewer call itself: the system prompt, the empty-reply retry
4
+ // classification and the output-budget diagnostics that turn a truncated
5
+ // reply into a diagnosable error. Hoisted verbatim from
6
+ // final-review-service.ts (C wave 7 file-size split).
7
+ const SYSTEM_PROMPT = `You are preparing a 4-dimension business review for human acceptance. Produce a JSON response with EXACTLY these fields:
8
+ - rid (string)
9
+ - generatedAt (ISO timestamp)
10
+ - dimensions (array of EXACTLY 4 objects, one per dimension: functional-completeness, problem-resolution, no-new-bugs, existing-functionality-intact; each with dimension, verdict (pass | fail | inconclusive), summary, evidence (list of {kind, description, [artifact], [link]}), confidence (high | medium | low))
11
+ - overallSummary (one paragraph)
12
+ - allPass (boolean)
13
+ - needsAttention (list of dimension names that need human attention)
14
+
15
+ Output ONLY valid JSON, no prose.`;
16
+ /**
17
+ * N4 — the reply carried no text block at all.
18
+ *
19
+ * Measured 2/3 on this repo's own machine, and it is NOT truncation: the
20
+ * provider answered with a response whose `content` has no `text` block (a
21
+ * reasoning-only turn, a refusal, or a content filter), so there is no JSON to
22
+ * parse and no budget to raise — an operator sent to "raise the budget" for
23
+ * this failure would be sent the wrong way. It gets its own class, its own
24
+ * `code`, and a message that says so, so it is diagnosable instead of being
25
+ * flattened into "not valid JSON".
26
+ */
27
+ export class EmptyReviewReplyError extends Error {
28
+ code = 'EMPTY_FINAL_REVIEW_REPLY';
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = 'EmptyReviewReplyError';
32
+ }
33
+ }
34
+ /**
35
+ * How many times an empty reply is retried before it is reported. The failure
36
+ * was 2/3 on the observed machine — intermittent, not systematic — so a small
37
+ * bounded retry converts most of it into a completed review, while 3 attempts
38
+ * keeps a genuinely broken provider from being hammered.
39
+ */
40
+ export const MAX_EMPTY_REPLY_ATTEMPTS = 3;
41
+ /** The runner's own wording for "the response had no text block to return". */
42
+ function isEmptyReplyError(error) {
43
+ return error instanceof Error && /no text block/i.test(error.message);
44
+ }
45
+ function errorText(error) {
46
+ return error instanceof Error ? error.message : String(error);
47
+ }
48
+ /** The facts an operator needs to tell a budget problem from a format problem. */
49
+ export function describeOutputBudget(maxTokens, outputTokens, characters) {
50
+ return `output budget: maxTokens=${maxTokens}, provider-reported output tokens=${outputTokens}, characters returned=${characters}`;
51
+ }
52
+ /**
53
+ * N4 — say WHICH signal diagnosed the truncation, and flag the provider's usage
54
+ * numbers when they are the only thing pointing at the ceiling. Measured on
55
+ * this repo's machine: `input_tokens: 150` for a ~32 KiB prompt, so a reporter
56
+ * that cannot count the input should not be trusted to count the output.
57
+ */
58
+ export function describeTruncationSignal(structurallyCut, ceilingReached) {
59
+ if (structurallyCut && ceilingReached) {
60
+ return 'reply ends mid-structure AND provider-reported output reached the ceiling';
61
+ }
62
+ if (structurallyCut) {
63
+ return 'reply ends mid-structure (structural)';
64
+ }
65
+ return 'provider-reported output reached the ceiling only — the provider’s usage reporting is not trustworthy on its own, so verify before raising anything';
66
+ }
67
+ /**
68
+ * N4 — call the reviewer, retrying an EMPTY reply a bounded number of times.
69
+ *
70
+ * The empty reply is a separate failure mode from truncation and was measured
71
+ * at 2/3 on this repo's machine. It is intermittent, so a bounded retry turns
72
+ * most occurrences back into a completed review; when it does not, the caller
73
+ * gets `EmptyReviewReplyError` — classified and diagnosable — instead of a
74
+ * truncation message that sends the operator to raise a budget that was never
75
+ * the problem.
76
+ *
77
+ * The classification reads the runner's message because `LlmRunner` is a
78
+ * structural interface here (this module deliberately does not depend on the
79
+ * concrete provider module); "no text block" is the runner's own fixed wording
80
+ * for a response with no text content.
81
+ */
82
+ export async function callReviewer(runner, userPrompt, budget) {
83
+ let lastError;
84
+ for (let attempt = 1; attempt <= MAX_EMPTY_REPLY_ATTEMPTS; attempt += 1) {
85
+ try {
86
+ return await runner.call(SYSTEM_PROMPT, userPrompt, { maxTokens: budget.maxTokens });
87
+ }
88
+ catch (error) {
89
+ if (!isEmptyReplyError(error))
90
+ throw error;
91
+ lastError = error;
92
+ }
93
+ }
94
+ throw new EmptyReviewReplyError(`The provider returned NO TEXT BLOCK on ${String(MAX_EMPTY_REPLY_ATTEMPTS)}/${String(MAX_EMPTY_REPLY_ATTEMPTS)} attempts — this is an EMPTY-REPLY failure, NOT an output-budget truncation: the response carried no text content (a reasoning-only turn, a refusal, or a content filter), so there was no JSON to parse and raising the budget would not have helped. ${describeOutputBudget(budget.maxTokens, 0, 0)}. Last provider error: ${errorText(lastError)}`);
95
+ }
@@ -0,0 +1,3 @@
1
+ import { type PrepareFinalReviewOptions } from './final-review-contract.js';
2
+ import type { FinalReviewOutput } from './final-review-types.js';
3
+ export declare function prepareFinalReview(rid: string, opts: PrepareFinalReviewOptions): Promise<FinalReviewOutput>;
@@ -0,0 +1,158 @@
1
+ // src/services/final-review/final-review-runner.ts
2
+ //
3
+ // The orchestration of prepareFinalReview. Hoisted from
4
+ // final-review-service.ts (C wave 7 file-size split): the body is
5
+ // HEAD-verbatim with the goal read, the prompt assembly, the reply
6
+ // parsing, the dimension-presence check and the gate chain each lifted
7
+ // into a named step so every function stays under the repo
8
+ // function-length rule. The service module re-exports prepareFinalReview
9
+ // so no importer changed; the gates it calls are the service module's
10
+ // own (guard C keeps them there), which is why this file imports the
11
+ // service module back.
12
+ import { readFileSync } from 'node:fs';
13
+ import { join } from 'node:path';
14
+ import { classifyPrePostDiffVerdict, producePrePostDiff } from './pre-post-diff.js';
15
+ import { collectEvidence } from './final-review-evidence-collect.js';
16
+ import { PRE_POST_DIFF_SOURCE_KEY } from './final-review-evidence-sources.js';
17
+ import { MAX_OUTPUT_TOKENS_ENV, outputBudgetForEvidence, resolveOutputBudget } from './final-review-output-budget.js';
18
+ import { EVIDENCE_RULES, renderDeliveryReachabilityStatus, renderEvidenceSection, renderPrePostDiffStatus } from './final-review-prompt.js';
19
+ import { callReviewer, describeOutputBudget, describeTruncationSignal } from './final-review-reviewer.js';
20
+ import { clampInconclusiveConfidence, enforceEvidenceBackedVerdicts } from './final-review-gates.js';
21
+ import { enforceDeliveryReachability, undeliverableDimensions } from './final-review-delivery.js';
22
+ import { REQUIRED_DIMENSIONS } from './final-review-evidence-budget.js';
23
+ import { enforceStructuralDriftAttention, summarizeVerdicts } from './final-review-verdicts.js';
24
+ import { IncompleteFinalReviewError } from './final-review-contract.js';
25
+ import { dimensionsWithEvidence, enforcePrePostDiffAvailability, enforceScopeContractDelivery, attachPrePostDiffEvidence, looksTruncated, prePostDiffDelivered } from './final-review-service.js';
26
+ function readApprovedGoal(opts, rid) {
27
+ const auditGoalPath = join(opts.projectRoot, '.peaks', '_runtime', opts.sessionId, 'audit-goal', `${rid}.json`);
28
+ try {
29
+ return JSON.parse(readFileSync(auditGoalPath, 'utf8'));
30
+ }
31
+ catch (err) {
32
+ throw new Error(`Cannot read approved goal from ${auditGoalPath}: ${err.message}`);
33
+ }
34
+ }
35
+ function assembleUserPrompt(args) {
36
+ const { approvedGoal, evidence, ppdDelivered, prePostDiff, reachabilityStatus } = args;
37
+ return [
38
+ `Approved goal's success criteria: ${JSON.stringify(approvedGoal.successCriteria)}`,
39
+ '',
40
+ '## On-disk evidence',
41
+ 'You have NO tools and NO filesystem access — the blocks below are ALL the evidence that exists for this review. They were collected read-only by the service; nothing was executed.',
42
+ '',
43
+ renderEvidenceSection(evidence),
44
+ '',
45
+ renderPrePostDiffStatus(prePostDiff, ppdDelivered),
46
+ '',
47
+ ...(reachabilityStatus === '' ? [] : [reachabilityStatus, '']),
48
+ EVIDENCE_RULES,
49
+ '',
50
+ 'Prepare the 4-dim review evidence.'
51
+ ].join('\n');
52
+ }
53
+ function parseReviewerReply(response, maxTokens) {
54
+ let parsed;
55
+ try {
56
+ parsed = JSON.parse(response.output);
57
+ }
58
+ catch (err) {
59
+ const budget = describeOutputBudget(maxTokens, response.tokens.output, response.output.length);
60
+ // N4 — the STRUCTURAL judgement is primary: `looksTruncated()` reads the
61
+ // reply itself and needs no cooperation from the provider. The
62
+ // `output_tokens >= maxTokens` comparison is kept as a corroborating
63
+ // signal, but it cannot be the only one: this endpoint reported
64
+ // `input_tokens: 150` for a ~32 KiB prompt, so its usage numbers are not
65
+ // trustworthy on their own, and a provider that under-reports a truncated
66
+ // reply would otherwise have it filed below as "not valid JSON" — sending
67
+ // an operator to look for a schema bug that does not exist. Which signal
68
+ // fired is reported, so the diagnosis is auditable rather than inferred.
69
+ const structurallyCut = looksTruncated(response.output);
70
+ const ceilingReached = response.tokens.output >= maxTokens;
71
+ if (structurallyCut || ceilingReached) {
72
+ throw new IncompleteFinalReviewError(`LLM output was TRUNCATED by the output budget before the 4-dim envelope was complete — this is an OUTPUT-BUDGET failure, not a malformed reply. Raise the budget: it scales with inlined evidence bytes, and ${MAX_OUTPUT_TOKENS_ENV} overrides it outright for this run. Signal: ${describeTruncationSignal(structurallyCut, ceilingReached)}. ${budget}. Parser said: ${err.message}`);
73
+ }
74
+ throw new IncompleteFinalReviewError(`LLM output is not valid JSON: ${err.message} (${budget})`);
75
+ }
76
+ return parsed;
77
+ }
78
+ function ensureRequiredDimensions(output, response, maxTokens) {
79
+ const presentDimensions = new Set(output.dimensions.map((d) => d.dimension));
80
+ const missing = REQUIRED_DIMENSIONS.filter((d) => !presentDimensions.has(d));
81
+ if (missing.length > 0) {
82
+ // A reply that stopped at the ceiling and still parsed is still a budget
83
+ // problem, so the same diagnosis is attached here. N4: the structural
84
+ // reading counts too — a reply cut off mid-array parses only because the
85
+ // envelope it produced happened to be closed early.
86
+ const budgetExhausted = response.tokens.output >= maxTokens || looksTruncated(response.output);
87
+ throw new IncompleteFinalReviewError(`Missing required dimensions: ${missing.join(', ')}${budgetExhausted
88
+ ? ` — the provider hit the output budget and the reply was cut short (${describeOutputBudget(maxTokens, response.tokens.output, response.output.length)}); raise the budget instead of retrying blindly.`
89
+ : ''}`);
90
+ }
91
+ }
92
+ function applyVerdictGates(args) {
93
+ const { dimensions, evidence, prePostDiff, undeliverable } = args;
94
+ return attachPrePostDiffEvidence(enforceDeliveryReachability(enforceScopeContractDelivery(enforcePrePostDiffAvailability(enforceEvidenceBackedVerdicts(clampInconclusiveConfidence(dimensions), dimensionsWithEvidence(evidence)), prePostDiff, evidence), evidence), undeliverable), prePostDiff, evidence);
95
+ }
96
+ export async function prepareFinalReview(rid, opts) {
97
+ const approvedGoal = readApprovedGoal(opts, rid);
98
+ // The pre/post baseline diff is produced BEFORE the read phase: it is the one
99
+ // step in this service that runs a command (`git`, read-only) and writes a
100
+ // file, and it has to finish first because its artifact is also an evidence
101
+ // source below. Everything after this line is still pure file reading.
102
+ const prePostDiff = producePrePostDiff({
103
+ projectRoot: opts.projectRoot,
104
+ sessionId: opts.sessionId,
105
+ ...(opts.baseRef === undefined ? {} : { baseRef: opts.baseRef })
106
+ });
107
+ const evidence = collectEvidence(opts.projectRoot, opts.sessionId, rid, prePostDiff.status === 'computed');
108
+ // F-BLOCK: the fourth dimension needs the baseline to have been DELIVERED,
109
+ // not merely computed, so the delivery fact is measured on the collected
110
+ // evidence (what the prompt carries) rather than read off the producer's
111
+ // status (what exists on disk).
112
+ const ppdDelivered = prePostDiffDelivered(evidence);
113
+ // H2: a dimension whose every on-disk source is structurally undeliverable is
114
+ // a fact about the EVIDENCE, so it is measured where the evidence is and
115
+ // stated in both the prompt and the envelope — an always-red dimension that
116
+ // explains itself is a finding; one that does not is noise.
117
+ const undeliverable = undeliverableDimensions(evidence);
118
+ const reachabilityStatus = renderDeliveryReachabilityStatus(undeliverable);
119
+ const userPrompt = assembleUserPrompt({
120
+ approvedGoal,
121
+ evidence,
122
+ prePostDiff,
123
+ ppdDelivered,
124
+ reachabilityStatus
125
+ });
126
+ // D1 layer 3: the ceiling follows the evidence actually inlined, so the two
127
+ // sides of the call cannot drift apart again. N4 adds the env lever on top.
128
+ const includedEvidenceBytes = evidence.reduce((sum, item) => sum + item.includedBytes, 0);
129
+ const derivedMaxTokens = outputBudgetForEvidence(includedEvidenceBytes);
130
+ const maxTokens = resolveOutputBudget(includedEvidenceBytes);
131
+ const response = await callReviewer(opts.llmRunner, userPrompt, { maxTokens, derivedMaxTokens });
132
+ const output = parseReviewerReply(response, maxTokens);
133
+ ensureRequiredDimensions(output, response, maxTokens);
134
+ // F2: what the DELIVERED conclusion says. Read before the verdicts are
135
+ // assembled, because a detected drift has to reach `needsAttention` whatever
136
+ // the reviewer answered. `null` — nothing delivered — is NOT
137
+ // `indeterminate`: see `enforceStructuralDriftAttention`.
138
+ const ppdBlock = evidence.find((item) => item.source.key === PRE_POST_DIFF_SOURCE_KEY);
139
+ const ppdConclusion = ppdBlock !== undefined && ppdDelivered ? classifyPrePostDiffVerdict(ppdBlock.content) : null;
140
+ // D1: the verdicts must rest on evidence that actually existed, and the
141
+ // derived summary flags must match the verdicts — see the helpers above.
142
+ const gated = enforceStructuralDriftAttention(output.dimensions, ppdConclusion);
143
+ const dimensions = applyVerdictGates({
144
+ dimensions: gated.dimensions,
145
+ evidence,
146
+ prePostDiff,
147
+ undeliverable
148
+ });
149
+ // H2 adds nothing to `mustAttend` on purpose: `enforceDeliveryReachability`
150
+ // has already made every undeliverable dimension non-`pass`, so it is in
151
+ // `needsAttention` (and `allPass` is false) through the verdict route. A
152
+ // second flag for the same dimension would be a check whose result nothing
153
+ // reads — the shape this primitive exists to catch.
154
+ const { allPass, needsAttention } = summarizeVerdicts(dimensions, output, [
155
+ ...(gated.mustAttend ? ['existing-functionality-intact'] : [])
156
+ ]);
157
+ return { ...output, dimensions, allPass, needsAttention };
158
+ }