peaks-loop 4.1.3 → 4.1.5

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 (628) hide show
  1. package/.claude-plugin/marketplace.json +7 -2
  2. package/CHANGELOG.md +168 -0
  3. package/README-en.md +1 -1
  4. package/README.md +1 -1
  5. package/dist/cli/cli-helpers.d.ts +20 -0
  6. package/dist/cli/cli-helpers.js +34 -0
  7. package/dist/cli/commands/_register.js +2 -0
  8. package/dist/cli/commands/asset-command-shared.d.ts +12 -0
  9. package/dist/cli/commands/asset-command-shared.js +45 -0
  10. package/dist/cli/commands/asset-commands.d.ts +6 -1
  11. package/dist/cli/commands/asset-commands.js +11 -372
  12. package/dist/cli/commands/asset-crystallize-command.d.ts +3 -0
  13. package/dist/cli/commands/asset-crystallize-command.js +60 -0
  14. package/dist/cli/commands/asset-crystallize-payload.d.ts +47 -0
  15. package/dist/cli/commands/asset-crystallize-payload.js +85 -0
  16. package/dist/cli/commands/asset-crystallize-runner.d.ts +3 -0
  17. package/dist/cli/commands/asset-crystallize-runner.js +133 -0
  18. package/dist/cli/commands/asset-dispose-command.d.ts +3 -0
  19. package/dist/cli/commands/asset-dispose-command.js +99 -0
  20. package/dist/cli/commands/asset-status-command.d.ts +3 -0
  21. package/dist/cli/commands/asset-status-command.js +100 -0
  22. package/dist/cli/commands/baseline-audit-command.d.ts +3 -0
  23. package/dist/cli/commands/baseline-audit-command.js +64 -0
  24. package/dist/cli/commands/baseline-command-shared.d.ts +23 -0
  25. package/dist/cli/commands/baseline-command-shared.js +39 -0
  26. package/dist/cli/commands/baseline-commands.js +33 -313
  27. package/dist/cli/commands/baseline-freeze-commands.d.ts +4 -0
  28. package/dist/cli/commands/baseline-freeze-commands.js +81 -0
  29. package/dist/cli/commands/baseline-guard-command.d.ts +3 -0
  30. package/dist/cli/commands/baseline-guard-command.js +52 -0
  31. package/dist/cli/commands/baseline-read-commands.d.ts +5 -0
  32. package/dist/cli/commands/baseline-read-commands.js +72 -0
  33. package/dist/cli/commands/baseline-rollback-commands.d.ts +4 -0
  34. package/dist/cli/commands/baseline-rollback-commands.js +88 -0
  35. package/dist/cli/commands/classify-downgrade-command.d.ts +9 -0
  36. package/dist/cli/commands/classify-downgrade-command.js +21 -0
  37. package/dist/cli/commands/classify-run-command.d.ts +9 -0
  38. package/dist/cli/commands/classify-run-command.js +73 -0
  39. package/dist/cli/commands/classify-signals.d.ts +5 -0
  40. package/dist/cli/commands/classify-signals.js +104 -0
  41. package/dist/cli/commands/code-commands.d.ts +6 -4
  42. package/dist/cli/commands/code-commands.js +6 -4
  43. package/dist/cli/commands/code-emit-handoff-command.js +40 -3
  44. package/dist/cli/commands/code-gate-command.d.ts +5 -5
  45. package/dist/cli/commands/code-gate-command.js +49 -9
  46. package/dist/cli/commands/code-gate-step-08-command.js +25 -9
  47. package/dist/cli/commands/code-mode-gate-plan-command.d.ts +1 -1
  48. package/dist/cli/commands/code-mode-gate-plan-command.js +2 -2
  49. package/dist/cli/commands/codegraph-command-options.d.ts +22 -0
  50. package/dist/cli/commands/codegraph-command-options.js +22 -0
  51. package/dist/cli/commands/codegraph-commands.d.ts +2 -2
  52. package/dist/cli/commands/codegraph-commands.js +14 -397
  53. package/dist/cli/commands/codegraph-config-restore-command.d.ts +3 -0
  54. package/dist/cli/commands/codegraph-config-restore-command.js +200 -0
  55. package/dist/cli/commands/codegraph-proxy-commands.d.ts +10 -0
  56. package/dist/cli/commands/codegraph-proxy-commands.js +159 -0
  57. package/dist/cli/commands/codegraph-repair-commands.d.ts +3 -0
  58. package/dist/cli/commands/codegraph-repair-commands.js +94 -0
  59. package/dist/cli/commands/codegraph-status-command.d.ts +1 -1
  60. package/dist/cli/commands/codegraph-status-command.js +27 -214
  61. package/dist/cli/commands/codegraph-status-integrity.d.ts +44 -0
  62. package/dist/cli/commands/codegraph-status-integrity.js +121 -0
  63. package/dist/cli/commands/codegraph-status-json.d.ts +5 -0
  64. package/dist/cli/commands/codegraph-status-json.js +127 -0
  65. package/dist/cli/commands/container-command-shared.d.ts +60 -0
  66. package/dist/cli/commands/container-command-shared.js +52 -0
  67. package/dist/cli/commands/container-commands.d.ts +1 -1
  68. package/dist/cli/commands/container-commands.js +4 -216
  69. package/dist/cli/commands/container-release-command.d.ts +3 -0
  70. package/dist/cli/commands/container-release-command.js +105 -0
  71. package/dist/cli/commands/container-spawn-command.d.ts +3 -0
  72. package/dist/cli/commands/container-spawn-command.js +148 -0
  73. package/dist/cli/commands/context-check-command.d.ts +3 -0
  74. package/dist/cli/commands/context-check-command.js +81 -0
  75. package/dist/cli/commands/context-commands.d.ts +2 -7
  76. package/dist/cli/commands/context-commands.js +6 -276
  77. package/dist/cli/commands/context-layer-command.d.ts +3 -0
  78. package/dist/cli/commands/context-layer-command.js +34 -0
  79. package/dist/cli/commands/context-layer-fetchers.d.ts +15 -0
  80. package/dist/cli/commands/context-layer-fetchers.js +162 -0
  81. package/dist/cli/commands/context-status-command.d.ts +17 -0
  82. package/dist/cli/commands/context-status-command.js +41 -0
  83. package/dist/cli/commands/contract-write-command.d.ts +3 -0
  84. package/dist/cli/commands/contract-write-command.js +144 -0
  85. package/dist/cli/commands/core/doctor-bindings.d.ts +17 -0
  86. package/dist/cli/commands/core/doctor-bindings.js +30 -0
  87. package/dist/cli/commands/core/doctor-command.d.ts +4 -18
  88. package/dist/cli/commands/core/doctor-command.js +2 -323
  89. package/dist/cli/commands/core/doctor-logs.d.ts +8 -0
  90. package/dist/cli/commands/core/doctor-logs.js +32 -0
  91. package/dist/cli/commands/core/doctor-probes.d.ts +3 -0
  92. package/dist/cli/commands/core/doctor-probes.js +55 -0
  93. package/dist/cli/commands/core/doctor-run-command.d.ts +12 -0
  94. package/dist/cli/commands/core/doctor-run-command.js +172 -0
  95. package/dist/cli/commands/core/doctor-summary.d.ts +7 -0
  96. package/dist/cli/commands/core/doctor-summary.js +39 -0
  97. package/dist/cli/commands/core/memory-command-shared.d.ts +25 -0
  98. package/dist/cli/commands/core/memory-command-shared.js +20 -0
  99. package/dist/cli/commands/core/memory-command.d.ts +1 -1
  100. package/dist/cli/commands/core/memory-command.js +6 -227
  101. package/dist/cli/commands/core/memory-delegated-verbs.d.ts +4 -0
  102. package/dist/cli/commands/core/memory-delegated-verbs.js +178 -0
  103. package/dist/cli/commands/core/memory-extract-command.d.ts +3 -0
  104. package/dist/cli/commands/core/memory-extract-command.js +95 -0
  105. package/dist/cli/commands/core/memory-sync-command.d.ts +3 -0
  106. package/dist/cli/commands/core/memory-sync-command.js +38 -0
  107. package/dist/cli/commands/core/session-command.d.ts +1 -1
  108. package/dist/cli/commands/core/session-command.js +12 -206
  109. package/dist/cli/commands/core/session-info-command.d.ts +3 -0
  110. package/dist/cli/commands/core/session-info-command.js +142 -0
  111. package/dist/cli/commands/core/session-verb-commands.d.ts +5 -0
  112. package/dist/cli/commands/core/session-verb-commands.js +58 -0
  113. package/dist/cli/commands/core/standards-command.d.ts +1 -24
  114. package/dist/cli/commands/core/standards-command.js +33 -201
  115. package/dist/cli/commands/core/standards-init-command.d.ts +3 -0
  116. package/dist/cli/commands/core/standards-init-command.js +87 -0
  117. package/dist/cli/commands/core/standards-lint.d.ts +24 -0
  118. package/dist/cli/commands/core/standards-lint.js +57 -0
  119. package/dist/cli/commands/core/standards-migrate-command.d.ts +3 -0
  120. package/dist/cli/commands/core/standards-migrate-command.js +57 -0
  121. package/dist/cli/commands/cron-scheduler-commands.d.ts +5 -1
  122. package/dist/cli/commands/cron-scheduler-commands.js +36 -206
  123. package/dist/cli/commands/cron-scheduler-run-once-command.d.ts +7 -0
  124. package/dist/cli/commands/cron-scheduler-run-once-command.js +35 -0
  125. package/dist/cli/commands/cron-scheduler-shared.d.ts +6 -0
  126. package/dist/cli/commands/cron-scheduler-shared.js +48 -0
  127. package/dist/cli/commands/cron-scheduler-start-command.d.ts +7 -0
  128. package/dist/cli/commands/cron-scheduler-start-command.js +65 -0
  129. package/dist/cli/commands/cron-scheduler-status-command.d.ts +7 -0
  130. package/dist/cli/commands/cron-scheduler-status-command.js +46 -0
  131. package/dist/cli/commands/cron-scheduler-stop-command.d.ts +7 -0
  132. package/dist/cli/commands/cron-scheduler-stop-command.js +61 -0
  133. package/dist/cli/commands/dispatch-cli-invocation-check.d.ts +108 -0
  134. package/dist/cli/commands/dispatch-cli-invocation-check.js +87 -0
  135. package/dist/cli/commands/dispatch-cli-invocation-scan.d.ts +66 -0
  136. package/dist/cli/commands/dispatch-cli-invocation-scan.js +162 -0
  137. package/dist/cli/commands/dispatch-commands.js +12 -5
  138. package/dist/cli/commands/dispatch-dag-envelope.d.ts +41 -0
  139. package/dist/cli/commands/dispatch-dag-envelope.js +49 -0
  140. package/dist/cli/commands/dispatch-dag-failure.d.ts +18 -0
  141. package/dist/cli/commands/dispatch-dag-failure.js +16 -0
  142. package/dist/cli/commands/dispatch-dag-preflight.d.ts +51 -0
  143. package/dist/cli/commands/dispatch-dag-preflight.js +105 -0
  144. package/dist/cli/commands/dispatch-dag-runners.d.ts +48 -0
  145. package/dist/cli/commands/dispatch-dag-runners.js +73 -0
  146. package/dist/cli/commands/dispatch-from-dag.d.ts +27 -0
  147. package/dist/cli/commands/dispatch-from-dag.js +87 -257
  148. package/dist/cli/commands/dispatch-preflight.js +46 -0
  149. package/dist/cli/commands/dispatch-prompt-composition.d.ts +6 -0
  150. package/dist/cli/commands/dispatch-prompt-composition.js +29 -7
  151. package/dist/cli/commands/doc-commands.js +1 -1
  152. package/dist/cli/commands/feedback-commands-helpers.js +1 -1
  153. package/dist/cli/commands/final-review-command-envelopes.d.ts +44 -0
  154. package/dist/cli/commands/final-review-command-envelopes.js +100 -0
  155. package/dist/cli/commands/final-review-command-shared.d.ts +52 -0
  156. package/dist/cli/commands/final-review-command-shared.js +35 -0
  157. package/dist/cli/commands/final-review-commands.d.ts +7 -27
  158. package/dist/cli/commands/final-review-commands.js +13 -240
  159. package/dist/cli/commands/final-review-prepare-command.d.ts +3 -0
  160. package/dist/cli/commands/final-review-prepare-command.js +221 -0
  161. package/dist/cli/commands/gate-commands-enforce.js +3 -3
  162. package/dist/cli/commands/governance-classify-contract-commands.d.ts +23 -9
  163. package/dist/cli/commands/governance-classify-contract-commands.js +26 -269
  164. package/dist/cli/commands/hook-handle.js +41 -20
  165. package/dist/cli/commands/hooks-command-shared.d.ts +42 -0
  166. package/dist/cli/commands/hooks-command-shared.js +32 -0
  167. package/dist/cli/commands/hooks-commands.d.ts +20 -0
  168. package/dist/cli/commands/hooks-commands.js +75 -309
  169. package/dist/cli/commands/hooks-install-envelopes.d.ts +6 -0
  170. package/dist/cli/commands/hooks-install-envelopes.js +144 -0
  171. package/dist/cli/commands/hooks-status-command.d.ts +3 -0
  172. package/dist/cli/commands/hooks-status-command.js +93 -0
  173. package/dist/cli/commands/hooks-uninstall-command.d.ts +3 -0
  174. package/dist/cli/commands/hooks-uninstall-command.js +43 -0
  175. package/dist/cli/commands/lint-commands.js +3 -1
  176. package/dist/cli/commands/loop-command-shared.d.ts +31 -0
  177. package/dist/cli/commands/loop-command-shared.js +15 -0
  178. package/dist/cli/commands/loop-commands.d.ts +12 -17
  179. package/dist/cli/commands/loop-commands.js +56 -238
  180. package/dist/cli/commands/loop-eval-capture-index.js +2 -4
  181. package/dist/cli/commands/loop-export-command.d.ts +3 -0
  182. package/dist/cli/commands/loop-export-command.js +73 -0
  183. package/dist/cli/commands/loop-goal-compose-command.d.ts +3 -0
  184. package/dist/cli/commands/loop-goal-compose-command.js +36 -0
  185. package/dist/cli/commands/loop-import-command.d.ts +3 -0
  186. package/dist/cli/commands/loop-import-command.js +86 -0
  187. package/dist/cli/commands/loop-placeholder-commands.d.ts +3 -0
  188. package/dist/cli/commands/loop-placeholder-commands.js +52 -0
  189. package/dist/cli/commands/memory-command-shared.d.ts +59 -0
  190. package/dist/cli/commands/memory-command-shared.js +39 -0
  191. package/dist/cli/commands/memory-commands.d.ts +6 -79
  192. package/dist/cli/commands/memory-commands.js +19 -309
  193. package/dist/cli/commands/memory-ingest-command.d.ts +3 -0
  194. package/dist/cli/commands/memory-ingest-command.js +50 -0
  195. package/dist/cli/commands/memory-list-command.d.ts +16 -0
  196. package/dist/cli/commands/memory-list-command.js +129 -0
  197. package/dist/cli/commands/memory-reindex-command.d.ts +9 -0
  198. package/dist/cli/commands/memory-reindex-command.js +78 -0
  199. package/dist/cli/commands/memory-rotate-command.d.ts +3 -0
  200. package/dist/cli/commands/memory-rotate-command.js +55 -0
  201. package/dist/cli/commands/memory-search-command.d.ts +7 -0
  202. package/dist/cli/commands/memory-search-command.js +46 -0
  203. package/dist/cli/commands/openspec-archive-command.d.ts +3 -0
  204. package/dist/cli/commands/openspec-archive-command.js +55 -0
  205. package/dist/cli/commands/openspec-command-shared.d.ts +62 -0
  206. package/dist/cli/commands/openspec-command-shared.js +135 -0
  207. package/dist/cli/commands/openspec-commands.d.ts +1 -1
  208. package/dist/cli/commands/openspec-commands.js +33 -306
  209. package/dist/cli/commands/openspec-from-doctor-command.d.ts +3 -0
  210. package/dist/cli/commands/openspec-from-doctor-command.js +66 -0
  211. package/dist/cli/commands/openspec-init-command.d.ts +3 -0
  212. package/dist/cli/commands/openspec-init-command.js +49 -0
  213. package/dist/cli/commands/openspec-list-command.d.ts +3 -0
  214. package/dist/cli/commands/openspec-list-command.js +27 -0
  215. package/dist/cli/commands/openspec-render-command.d.ts +3 -0
  216. package/dist/cli/commands/openspec-render-command.js +33 -0
  217. package/dist/cli/commands/openspec-show-command.d.ts +3 -0
  218. package/dist/cli/commands/openspec-show-command.js +33 -0
  219. package/dist/cli/commands/openspec-to-rd-command.d.ts +3 -0
  220. package/dist/cli/commands/openspec-to-rd-command.js +33 -0
  221. package/dist/cli/commands/openspec-validate-command.d.ts +3 -0
  222. package/dist/cli/commands/openspec-validate-command.js +45 -0
  223. package/dist/cli/commands/perf-audit-commands.js +15 -5
  224. package/dist/cli/commands/playwright-browser-command.d.ts +8 -0
  225. package/dist/cli/commands/playwright-browser-command.js +61 -0
  226. package/dist/cli/commands/playwright-commands.d.ts +10 -62
  227. package/dist/cli/commands/playwright-commands.js +77 -400
  228. package/dist/cli/commands/playwright-envelope.d.ts +8 -0
  229. package/dist/cli/commands/playwright-envelope.js +29 -0
  230. package/dist/cli/commands/playwright-ls-stop-commands.d.ts +4 -0
  231. package/dist/cli/commands/playwright-ls-stop-commands.js +74 -0
  232. package/dist/cli/commands/playwright-session-store.d.ts +65 -0
  233. package/dist/cli/commands/playwright-session-store.js +189 -0
  234. package/dist/cli/commands/project-commands.d.ts +19 -0
  235. package/dist/cli/commands/project-commands.js +101 -259
  236. package/dist/cli/commands/project-context-command.d.ts +3 -0
  237. package/dist/cli/commands/project-context-command.js +44 -0
  238. package/dist/cli/commands/project-dashboard-command.d.ts +3 -0
  239. package/dist/cli/commands/project-dashboard-command.js +74 -0
  240. package/dist/cli/commands/project-knowledge-command.d.ts +3 -0
  241. package/dist/cli/commands/project-knowledge-command.js +48 -0
  242. package/dist/cli/commands/project-memories-show-command.d.ts +3 -0
  243. package/dist/cli/commands/project-memories-show-command.js +87 -0
  244. package/dist/cli/commands/project-memory-index-command.d.ts +3 -0
  245. package/dist/cli/commands/project-memory-index-command.js +31 -0
  246. package/dist/cli/commands/qa-archive-screenshots-command.d.ts +3 -0
  247. package/dist/cli/commands/qa-archive-screenshots-command.js +53 -0
  248. package/dist/cli/commands/qa-commands.d.ts +14 -87
  249. package/dist/cli/commands/qa-commands.js +17 -315
  250. package/dist/cli/commands/qa-context-prestep.d.ts +1 -0
  251. package/dist/cli/commands/qa-context-prestep.js +34 -0
  252. package/dist/cli/commands/qa-run-command.d.ts +3 -0
  253. package/dist/cli/commands/qa-run-command.js +105 -0
  254. package/dist/cli/commands/qa-run-options.d.ts +23 -0
  255. package/dist/cli/commands/qa-run-options.js +31 -0
  256. package/dist/cli/commands/qa-run-slice.d.ts +41 -0
  257. package/dist/cli/commands/qa-run-slice.js +145 -0
  258. package/dist/cli/commands/race-commands.d.ts +15 -0
  259. package/dist/cli/commands/race-commands.js +65 -0
  260. package/dist/cli/commands/race-pilot-gate-record-command.d.ts +3 -0
  261. package/dist/cli/commands/race-pilot-gate-record-command.js +81 -0
  262. package/dist/cli/commands/release-canary-command.d.ts +28 -0
  263. package/dist/cli/commands/release-canary-command.js +129 -0
  264. package/dist/cli/commands/release-command-shared.d.ts +13 -0
  265. package/dist/cli/commands/release-command-shared.js +18 -0
  266. package/dist/cli/commands/release-commands.d.ts +10 -18
  267. package/dist/cli/commands/release-commands.js +25 -298
  268. package/dist/cli/commands/release-done-command.d.ts +3 -0
  269. package/dist/cli/commands/release-done-command.js +64 -0
  270. package/dist/cli/commands/release-hotfix-command.d.ts +3 -0
  271. package/dist/cli/commands/release-hotfix-command.js +50 -0
  272. package/dist/cli/commands/release-plan-command.d.ts +3 -0
  273. package/dist/cli/commands/release-plan-command.js +33 -0
  274. package/dist/cli/commands/release-precheck-command.d.ts +3 -0
  275. package/dist/cli/commands/release-precheck-command.js +28 -0
  276. package/dist/cli/commands/release-promote-command.d.ts +3 -0
  277. package/dist/cli/commands/release-promote-command.js +34 -0
  278. package/dist/cli/commands/release-rollback-command.d.ts +3 -0
  279. package/dist/cli/commands/release-rollback-command.js +33 -0
  280. package/dist/cli/commands/release-watch-command.d.ts +3 -0
  281. package/dist/cli/commands/release-watch-command.js +44 -0
  282. package/dist/cli/commands/request-command-options.d.ts +8 -0
  283. package/dist/cli/commands/request-commands.js +2 -0
  284. package/dist/cli/commands/request-init-command.js +67 -12
  285. package/dist/cli/commands/request-retag-command.d.ts +3 -0
  286. package/dist/cli/commands/request-retag-command.js +50 -0
  287. package/dist/cli/commands/request-show-command.d.ts +8 -0
  288. package/dist/cli/commands/request-show-command.js +14 -1
  289. package/dist/cli/commands/request-transition-command.js +12 -4
  290. package/dist/cli/commands/request-transition-failures.d.ts +14 -0
  291. package/dist/cli/commands/request-transition-failures.js +45 -3
  292. package/dist/cli/commands/scan-scope-commands.js +2 -2
  293. package/dist/cli/commands/security-audit-commands.js +26 -6
  294. package/dist/cli/commands/sediment-argv-flags.d.ts +54 -0
  295. package/dist/cli/commands/sediment-argv-flags.js +116 -0
  296. package/dist/cli/commands/sediment-command-shared.d.ts +15 -0
  297. package/dist/cli/commands/sediment-command-shared.js +5 -0
  298. package/dist/cli/commands/sediment-commands.d.ts +35 -59
  299. package/dist/cli/commands/sediment-commands.js +36 -590
  300. package/dist/cli/commands/sediment-pool-commands.d.ts +9 -0
  301. package/dist/cli/commands/sediment-pool-commands.js +185 -0
  302. package/dist/cli/commands/sediment-query-commands.d.ts +4 -0
  303. package/dist/cli/commands/sediment-query-commands.js +94 -0
  304. package/dist/cli/commands/sediment-release-commands.d.ts +8 -0
  305. package/dist/cli/commands/sediment-release-commands.js +232 -0
  306. package/dist/cli/commands/sop-advance-command.d.ts +3 -0
  307. package/dist/cli/commands/sop-advance-command.js +160 -0
  308. package/dist/cli/commands/sop-check-command.d.ts +3 -0
  309. package/dist/cli/commands/sop-check-command.js +44 -0
  310. package/dist/cli/commands/sop-command-shared.d.ts +23 -0
  311. package/dist/cli/commands/sop-command-shared.js +18 -0
  312. package/dist/cli/commands/sop-commands.d.ts +15 -1
  313. package/dist/cli/commands/sop-commands.js +26 -240
  314. package/dist/cli/commands/sop-init-command.d.ts +3 -0
  315. package/dist/cli/commands/sop-init-command.js +51 -0
  316. package/dist/cli/commands/sop-lint-command.d.ts +3 -0
  317. package/dist/cli/commands/sop-lint-command.js +64 -0
  318. package/dist/cli/commands/sop-register-command.d.ts +3 -0
  319. package/dist/cli/commands/sop-register-command.js +48 -0
  320. package/dist/cli/commands/sop-registry-command.d.ts +3 -0
  321. package/dist/cli/commands/sop-registry-command.js +30 -0
  322. package/dist/cli/commands/statusline-command-shared.d.ts +73 -0
  323. package/dist/cli/commands/statusline-command-shared.js +90 -0
  324. package/dist/cli/commands/statusline-commands.d.ts +1 -19
  325. package/dist/cli/commands/statusline-commands.js +48 -287
  326. package/dist/cli/commands/statusline-compact-command.d.ts +4 -0
  327. package/dist/cli/commands/statusline-compact-command.js +54 -0
  328. package/dist/cli/commands/statusline-install-command.d.ts +3 -0
  329. package/dist/cli/commands/statusline-install-command.js +48 -0
  330. package/dist/cli/commands/statusline-render-command.d.ts +9 -0
  331. package/dist/cli/commands/statusline-render-command.js +55 -0
  332. package/dist/cli/commands/statusline-status-command.d.ts +3 -0
  333. package/dist/cli/commands/statusline-status-command.js +23 -0
  334. package/dist/cli/commands/statusline-uninstall-command.d.ts +3 -0
  335. package/dist/cli/commands/statusline-uninstall-command.js +23 -0
  336. package/dist/cli/commands/test-command-run-helpers.d.ts +27 -0
  337. package/dist/cli/commands/test-command-run-helpers.js +73 -0
  338. package/dist/cli/commands/test-command-runner-resolution.d.ts +57 -0
  339. package/dist/cli/commands/test-command-runner-resolution.js +183 -0
  340. package/dist/cli/commands/test-commands.d.ts +8 -56
  341. package/dist/cli/commands/test-commands.js +26 -249
  342. package/dist/cli/commands/vm-command-shared.d.ts +23 -0
  343. package/dist/cli/commands/vm-command-shared.js +23 -0
  344. package/dist/cli/commands/vm-commands.d.ts +1 -28
  345. package/dist/cli/commands/vm-commands.js +36 -270
  346. package/dist/cli/commands/vm-hypervisor-runtime.d.ts +15 -0
  347. package/dist/cli/commands/vm-hypervisor-runtime.js +64 -0
  348. package/dist/cli/commands/vm-release-command.d.ts +5 -0
  349. package/dist/cli/commands/vm-release-command.js +101 -0
  350. package/dist/cli/commands/vm-spawn-command.d.ts +5 -0
  351. package/dist/cli/commands/vm-spawn-command.js +177 -0
  352. package/dist/cli/commands/web-command-shared.d.ts +12 -0
  353. package/dist/cli/commands/web-command-shared.js +30 -0
  354. package/dist/cli/commands/web-commands.d.ts +7 -14
  355. package/dist/cli/commands/web-commands.js +6 -314
  356. package/dist/cli/commands/web-install-command.d.ts +10 -0
  357. package/dist/cli/commands/web-install-command.js +116 -0
  358. package/dist/cli/commands/web-lifecycle-commands.d.ts +9 -30
  359. package/dist/cli/commands/web-lifecycle-commands.js +14 -322
  360. package/dist/cli/commands/web-login-command.d.ts +14 -0
  361. package/dist/cli/commands/web-login-command.js +189 -0
  362. package/dist/cli/commands/web-op-payload.d.ts +22 -0
  363. package/dist/cli/commands/web-op-payload.js +89 -0
  364. package/dist/cli/commands/web-op-refusals.d.ts +37 -0
  365. package/dist/cli/commands/web-op-refusals.js +73 -0
  366. package/dist/cli/commands/web-op-runner.d.ts +14 -0
  367. package/dist/cli/commands/web-op-runner.js +166 -0
  368. package/dist/cli/commands/web-status-command.d.ts +4 -0
  369. package/dist/cli/commands/web-status-command.js +32 -0
  370. package/dist/cli/commands/web-stop-command.d.ts +10 -0
  371. package/dist/cli/commands/web-stop-command.js +59 -0
  372. package/dist/cli/commands/web-verb-specs.d.ts +18 -0
  373. package/dist/cli/commands/web-verb-specs.js +66 -0
  374. package/dist/cli/commands/workflow-command-shared.d.ts +102 -0
  375. package/dist/cli/commands/workflow-command-shared.js +74 -0
  376. package/dist/cli/commands/workflow-graph-commands.d.ts +3 -0
  377. package/dist/cli/commands/workflow-graph-commands.js +73 -0
  378. package/dist/cli/commands/workflow-init-command.d.ts +3 -0
  379. package/dist/cli/commands/workflow-init-command.js +68 -0
  380. package/dist/cli/commands/workflow-lifecycle-commands.d.ts +9 -59
  381. package/dist/cli/commands/workflow-lifecycle-commands.js +14 -348
  382. package/dist/cli/commands/workflow-node-commands.d.ts +3 -0
  383. package/dist/cli/commands/workflow-node-commands.js +154 -0
  384. package/dist/cli/commands/workflow-terminalize-command.d.ts +3 -0
  385. package/dist/cli/commands/workflow-terminalize-command.js +56 -0
  386. package/dist/cli/commands/worktree-lease-gc-command.js +1 -1
  387. package/dist/services/artifacts/artifact-contract-block.d.ts +53 -0
  388. package/dist/services/artifacts/artifact-contract-block.js +212 -0
  389. package/dist/services/artifacts/artifact-prerequisites.d.ts +27 -19
  390. package/dist/services/artifacts/artifact-prerequisites.js +63 -133
  391. package/dist/services/artifacts/artifact-templates.d.ts +1 -1
  392. package/dist/services/artifacts/artifact-templates.js +17 -10
  393. package/dist/services/artifacts/prerequisite-checks.d.ts +87 -0
  394. package/dist/services/artifacts/prerequisite-checks.js +198 -0
  395. package/dist/services/artifacts/prerequisite-transition-event.d.ts +20 -0
  396. package/dist/services/artifacts/prerequisite-transition-event.js +27 -0
  397. package/dist/services/artifacts/request-artifact-metadata.d.ts +31 -0
  398. package/dist/services/artifacts/request-artifact-metadata.js +44 -0
  399. package/dist/services/artifacts/request-artifact-service.d.ts +5 -0
  400. package/dist/services/artifacts/request-artifact-service.js +23 -51
  401. package/dist/services/artifacts/request-artifact-state-helpers.d.ts +12 -0
  402. package/dist/services/artifacts/request-artifact-state-helpers.js +28 -4
  403. package/dist/services/artifacts/request-retag-service.d.ts +68 -0
  404. package/dist/services/artifacts/request-retag-service.js +125 -0
  405. package/dist/services/artifacts/request-state-order.d.ts +38 -0
  406. package/dist/services/artifacts/request-state-order.js +99 -0
  407. package/dist/services/artifacts/request-type-demand.d.ts +44 -0
  408. package/dist/services/artifacts/request-type-demand.js +71 -0
  409. package/dist/services/audit/audit-goal-service.d.ts +7 -0
  410. package/dist/services/audit/enforcers/active-skill-resolver.d.ts +18 -0
  411. package/dist/services/audit/enforcers/active-skill-resolver.js +48 -1
  412. package/dist/services/audit/enforcers/code-ban.d.ts +11 -2
  413. package/dist/services/audit/enforcers/code-ban.js +21 -1
  414. package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.d.ts +17 -0
  415. package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.js +24 -7
  416. package/dist/services/audit-independent/handoff-missing-refusal.d.ts +26 -0
  417. package/dist/services/audit-independent/handoff-missing-refusal.js +109 -0
  418. package/dist/services/audit-independent/handoff-readers.d.ts +37 -0
  419. package/dist/services/audit-independent/handoff-readers.js +81 -0
  420. package/dist/services/audit-independent/index.d.ts +6 -1
  421. package/dist/services/audit-independent/index.js +6 -1
  422. package/dist/services/audit-independent/judged-declaration-build.d.ts +48 -0
  423. package/dist/services/audit-independent/judged-declaration-build.js +73 -0
  424. package/dist/services/audit-independent/judged-declaration-check.d.ts +79 -0
  425. package/dist/services/audit-independent/judged-declaration-check.js +155 -0
  426. package/dist/services/audit-independent/judged-declaration.d.ts +94 -0
  427. package/dist/services/audit-independent/judged-declaration.js +218 -0
  428. package/dist/services/audit-independent/perf-audit-service.js +12 -14
  429. package/dist/services/audit-independent/security-audit-artifact.d.ts +28 -0
  430. package/dist/services/audit-independent/security-audit-artifact.js +90 -0
  431. package/dist/services/audit-independent/security-audit-service.d.ts +6 -53
  432. package/dist/services/audit-independent/security-audit-service.js +34 -178
  433. package/dist/services/capability-guard-runner/contracts/J05.js +60 -14
  434. package/dist/services/code/auto-compact-artifacts.d.ts +54 -0
  435. package/dist/services/code/auto-compact-artifacts.js +135 -0
  436. package/dist/services/code/auto-compact-attempt.d.ts +46 -0
  437. package/dist/services/code/auto-compact-attempt.js +88 -0
  438. package/dist/services/code/auto-compact-decision.d.ts +74 -0
  439. package/dist/services/code/auto-compact-decision.js +149 -0
  440. package/dist/services/code/auto-compact-dispatch-gate.d.ts +36 -0
  441. package/dist/services/code/auto-compact-dispatch-gate.js +86 -0
  442. package/dist/services/code/auto-compact-envelopes.d.ts +33 -0
  443. package/dist/services/code/auto-compact-envelopes.js +134 -0
  444. package/dist/services/code/auto-compact-history.d.ts +46 -0
  445. package/dist/services/code/auto-compact-history.js +17 -0
  446. package/dist/services/code/auto-compact-orchestrator.d.ts +11 -240
  447. package/dist/services/code/auto-compact-orchestrator.js +165 -686
  448. package/dist/services/code/auto-compact-run-types.d.ts +123 -0
  449. package/dist/services/code/auto-compact-run-types.js +1 -0
  450. package/dist/services/code/emit-handoff.d.ts +35 -1
  451. package/dist/services/code/emit-handoff.js +128 -7
  452. package/dist/services/code/step-08-gate.d.ts +28 -19
  453. package/dist/services/code/step-08-gate.js +92 -35
  454. package/dist/services/codegraph/codegraph-index-integrity.js +2 -0
  455. package/dist/services/config/config-coercion.d.ts +7 -0
  456. package/dist/services/config/config-coercion.js +156 -0
  457. package/dist/services/config/config-file-io.d.ts +11 -0
  458. package/dist/services/config/config-file-io.js +61 -0
  459. package/dist/services/config/config-get.d.ts +2 -0
  460. package/dist/services/config/config-get.js +36 -0
  461. package/dist/services/config/config-global-loader.d.ts +15 -0
  462. package/dist/services/config/config-global-loader.js +111 -0
  463. package/dist/services/config/config-nested-path.d.ts +3 -0
  464. package/dist/services/config/config-nested-path.js +53 -0
  465. package/dist/services/config/config-primitives.d.ts +16 -0
  466. package/dist/services/config/config-primitives.js +24 -0
  467. package/dist/services/config/config-service.d.ts +9 -33
  468. package/dist/services/config/config-service.js +16 -665
  469. package/dist/services/config/config-validation.d.ts +19 -0
  470. package/dist/services/config/config-validation.js +152 -0
  471. package/dist/services/config/config-workspace.d.ts +10 -0
  472. package/dist/services/config/config-workspace.js +158 -0
  473. package/dist/services/context/build-dispatch-system-prompt.d.ts +3 -3
  474. package/dist/services/context/build-dispatch-system-prompt.js +7 -7
  475. package/dist/services/context/collector.js +5 -1
  476. package/dist/services/dispatch/active-dispatch-index.d.ts +36 -0
  477. package/dist/services/dispatch/active-dispatch-index.js +118 -0
  478. package/dist/services/dispatch/batch-counter.js +1 -2
  479. package/dist/services/dispatch/dispatch-record-writer.d.ts +29 -16
  480. package/dist/services/dispatch/dispatch-record-writer.js +58 -100
  481. package/dist/services/dispatch/dispatch-sub-agent.js +1 -1
  482. package/dist/services/dispatch/karpathy-block.d.ts +55 -0
  483. package/dist/services/dispatch/karpathy-block.js +101 -0
  484. package/dist/services/dispatch/ledger-reaper.d.ts +80 -0
  485. package/dist/services/dispatch/ledger-reaper.js +131 -0
  486. package/dist/services/evidence/evidence-generator.js +15 -8
  487. package/dist/services/feedback/feedback-promotion-service.d.ts +8 -11
  488. package/dist/services/feedback/feedback-promotion-service.js +30 -35
  489. package/dist/services/feedback/promotion-artifact-json-evidence.d.ts +18 -0
  490. package/dist/services/feedback/promotion-artifact-missing.d.ts +22 -0
  491. package/dist/services/feedback/promotion-artifact-missing.js +63 -0
  492. package/dist/services/final-review/final-review-contract.d.ts +95 -4
  493. package/dist/services/final-review/final-review-contract.js +64 -0
  494. package/dist/services/final-review/final-review-delivery.d.ts +13 -0
  495. package/dist/services/final-review/final-review-delivery.js +26 -12
  496. package/dist/services/final-review/final-review-evidence-collect.js +8 -53
  497. package/dist/services/final-review/final-review-evidence-records.d.ts +21 -0
  498. package/dist/services/final-review/final-review-evidence-records.js +67 -0
  499. package/dist/services/final-review/final-review-evidence-sources.d.ts +22 -0
  500. package/dist/services/final-review/final-review-evidence-sources.js +28 -4
  501. package/dist/services/final-review/final-review-prompt.js +19 -6
  502. package/dist/services/final-review/final-review-runner.js +5 -0
  503. package/dist/services/final-review/final-review-service.d.ts +2 -2
  504. package/dist/services/final-review/index.d.ts +1 -1
  505. package/dist/services/final-review/pre-post-diff.d.ts +2 -75
  506. package/dist/services/final-review/pre-post-diff.js +60 -59
  507. package/dist/services/hooks/pre-tool-code-gate.d.ts +7 -1
  508. package/dist/services/hooks/pre-tool-code-gate.js +21 -2
  509. package/dist/services/hooks/worktree-authorization-gate.js +6 -31
  510. package/dist/services/hooks/worktree-refusal-messages.d.ts +74 -0
  511. package/dist/services/hooks/worktree-refusal-messages.js +102 -0
  512. package/dist/services/lint/eslint-runner-support.d.ts +1 -1
  513. package/dist/services/lint/eslint-runner-support.js +2 -1
  514. package/dist/services/lint/eslint-runner-types.d.ts +8 -0
  515. package/dist/services/lint/eslint-runner.js +17 -4
  516. package/dist/services/llm/anthropic-runner.js +24 -7
  517. package/dist/services/loop/loop-observability.d.ts +39 -0
  518. package/dist/services/loop/loop-observability.js +55 -0
  519. package/dist/services/loop/monotonic-guard.js +6 -9
  520. package/dist/services/loop/monotonic-runner.js +8 -7
  521. package/dist/services/loop/run-driver.js +18 -22
  522. package/dist/services/memory/project-memory-service/index/kind-dispatch.js +14 -1
  523. package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.js +13 -2
  524. package/dist/services/memory/project-memory-service/index.d.ts +2 -2
  525. package/dist/services/memory/project-memory-service/index.js +1 -1
  526. package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.d.ts +36 -0
  527. package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.js +48 -2
  528. package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +23 -1
  529. package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +37 -0
  530. package/dist/services/memory/project-memory-service/types.d.ts +32 -0
  531. package/dist/services/observability/observability-service.d.ts +7 -0
  532. package/dist/services/observability/observability-service.js +2 -1
  533. package/dist/services/prd/gate-evidence-derivation.d.ts +4 -3
  534. package/dist/services/prd/gate-evidence-derivation.js +4 -3
  535. package/dist/services/qa/bdd-test-style-verifier.js +22 -8
  536. package/dist/services/race/gate2-evaluator.d.ts +58 -0
  537. package/dist/services/race/gate2-evaluator.js +111 -0
  538. package/dist/services/race/gate2-policy.d.ts +17 -0
  539. package/dist/services/race/gate2-policy.js +31 -0
  540. package/dist/services/race/lane-phase.d.ts +19 -0
  541. package/dist/services/race/lane-phase.js +113 -0
  542. package/dist/services/race/pilot-gate-store.d.ts +67 -0
  543. package/dist/services/race/pilot-gate-store.js +227 -0
  544. package/dist/services/scan/file-size-baseline.d.ts +26 -0
  545. package/dist/services/scan/file-size-baseline.js +150 -0
  546. package/dist/services/scan/file-size-scan.d.ts +42 -3
  547. package/dist/services/scan/file-size-scan.js +58 -42
  548. package/dist/services/scan/type-sanity-service.js +13 -3
  549. package/dist/services/skill/resume-detector.js +3 -3
  550. package/dist/services/skills/hooks-codegate-superpowers.d.ts +5 -6
  551. package/dist/services/skills/hooks-codegate-superpowers.js +7 -8
  552. package/dist/services/skills/hooks-settings-deny-list.d.ts +61 -0
  553. package/dist/services/skills/hooks-settings-deny-list.js +173 -0
  554. package/dist/services/skills/hooks-settings-envelopes.d.ts +20 -0
  555. package/dist/services/skills/hooks-settings-envelopes.js +79 -0
  556. package/dist/services/skills/hooks-settings-file-shape.d.ts +43 -0
  557. package/dist/services/skills/hooks-settings-file-shape.js +207 -0
  558. package/dist/services/skills/hooks-settings-paths.d.ts +34 -0
  559. package/dist/services/skills/hooks-settings-paths.js +75 -0
  560. package/dist/services/skills/hooks-settings-read-installed.d.ts +39 -0
  561. package/dist/services/skills/hooks-settings-read-installed.js +60 -0
  562. package/dist/services/skills/hooks-settings-service.d.ts +13 -213
  563. package/dist/services/skills/hooks-settings-service.js +72 -658
  564. package/dist/services/skills/hooks-settings-types.d.ts +139 -0
  565. package/dist/services/skills/hooks-settings-types.js +1 -0
  566. package/dist/services/skills/presence-lease-order.d.ts +13 -0
  567. package/dist/services/skills/presence-lease-order.js +24 -0
  568. package/dist/services/skills/skill-conformance-service.js +1 -0
  569. package/dist/services/skills/skill-statusline-service.js +4 -7
  570. package/dist/services/slice/slice-check-service.js +8 -8
  571. package/dist/services/workflow/pipeline-verify-gate-support.js +2 -1
  572. package/dist/services/workflow/pipeline-verify-service.js +1 -1
  573. package/dist/services/workflow/workflow-skip-service.d.ts +0 -20
  574. package/dist/services/workflow/workflow-skip-service.js +3 -4
  575. package/dist/services/workspace/claude-settings-retirements.d.ts +54 -0
  576. package/dist/services/workspace/claude-settings-retirements.js +112 -0
  577. package/dist/services/workspace/claude-settings-template-merge.d.ts +109 -0
  578. package/dist/services/workspace/claude-settings-template-merge.js +223 -0
  579. package/dist/services/workspace/claude-settings-template.d.ts +79 -87
  580. package/dist/services/workspace/claude-settings-template.js +80 -235
  581. package/dist/services/workspace/migrate-1-4-1-service.js +3 -0
  582. package/dist/services/workspace/reconcile-service.js +0 -1
  583. package/dist/shared/incrementing-number.d.ts +10 -0
  584. package/dist/shared/incrementing-number.js +27 -0
  585. package/package.json +5 -5
  586. package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
  587. package/skills/bee/peaks-prd/SKILL.md +1 -1
  588. package/skills/bee/peaks-qa/SKILL.md +1 -1
  589. package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
  590. package/skills/bee/peaks-qa/references/qa-transition-gates.md +1 -1
  591. package/skills/bee/peaks-rd/SKILL.md +2 -2
  592. package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +1 -1
  593. package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +8 -4
  594. package/skills/bee/peaks-rd/references/rd-transition-gates.md +3 -3
  595. package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +2 -2
  596. package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +1 -1
  597. package/skills/bee/peaks-reviewer/SKILL.md +1 -1
  598. package/skills/bee/peaks-sc/SKILL.md +1 -1
  599. package/skills/bee/peaks-security-audit/SKILL.md +10 -2
  600. package/skills/bee/peaks-txt/SKILL.md +4 -3
  601. package/skills/bee/peaks-ui/SKILL.md +3 -3
  602. package/skills/peaks-audit/SKILL.md +29 -1
  603. package/skills/peaks-code/SKILL.md +5 -2
  604. package/skills/peaks-code/references/fast-lane-norm.md +42 -0
  605. package/skills/peaks-code/references/fast-mode.md +3 -2
  606. package/skills/peaks-code/references/local-artifact-workspace.md +3 -3
  607. package/skills/peaks-code/references/micro-cycle.md +3 -3
  608. package/skills/peaks-code/references/resume-detection.md +1 -1
  609. package/skills/peaks-code/references/runbook.md +12 -6
  610. package/skills/peaks-code/references/step-11-memory-sediment.md +4 -0
  611. package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
  612. package/skills/peaks-code/references/swarm-dispatch-contract.md +40 -16
  613. package/skills/peaks-code/references/workflow-gates-and-types.md +6 -6
  614. package/skills/peaks-code/references/worktree-governance.md +4 -4
  615. package/skills/peaks-content/SKILL.md +1 -1
  616. package/skills/peaks-doctor/SKILL.md +1 -1
  617. package/skills/peaks-final-review/SKILL.md +31 -11
  618. package/skills/peaks-ide/SKILL.md +1 -1
  619. package/skills/peaks-issue-fix-orchestrator/SKILL.md +1 -1
  620. package/skills/peaks-race-code/SKILL.md +185 -0
  621. package/skills/peaks-resume/SKILL.md +1 -1
  622. package/skills/peaks-slice-decompose/SKILL.md +1 -1
  623. package/skills/peaks-solo/SKILL.md +1 -1
  624. package/skills/peaks-sop/SKILL.md +1 -1
  625. package/skills/peaks-status/SKILL.md +1 -1
  626. package/skills/peaks-test/SKILL.md +7 -4
  627. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +0 -23
  628. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +0 -64
@@ -39,7 +39,7 @@
39
39
  * - `dispatch-failed` — parent LLM threw before returning the audit envelope
40
40
  * - `envelope-malformed` — parent LLM returned a value that fails `isSecurityAuditEnvelope`
41
41
  */
42
- export type SecurityAuditDetectState = 'ready' | 'handoff-missing' | 'template-missing' | 'dispatch-failed' | 'envelope-malformed';
42
+ export type SecurityAuditDetectState = 'ready' | 'handoff-missing' | 'template-missing' | 'dispatch-failed' | 'envelope-malformed' | 'declaration-missing';
43
43
  export interface SecurityAuditDetectResult {
44
44
  readonly state: SecurityAuditDetectState;
45
45
  readonly handoffPresent: boolean;
@@ -65,35 +65,6 @@ export interface SecurityAuditEnvelope {
65
65
  * `isEccEnvelope` strict-shape pattern.
66
66
  */
67
67
  export declare function isSecurityAuditEnvelope(value: unknown): value is SecurityAuditEnvelope;
68
- /**
69
- * Handoff frontmatter — minimal projection of peaks-prd v2.11.0 handoff
70
- * frontmatter. We only need sha256 for verification; the rest of the
71
- * handoff body is consumed by the parent LLM, not by this service.
72
- */
73
- export interface HandoffFrontmatter {
74
- readonly sha256: string;
75
- readonly schemaVersion: number;
76
- }
77
- /**
78
- * Read the peaks-prd handoff frontmatter + body, verify sha256 matches
79
- * the body. Returns null on missing file or sha256 mismatch; otherwise
80
- * returns the parsed frontmatter + body string.
81
- *
82
- * Defensive: we read frontmatter via a 1-line regex match, not via
83
- * a YAML parser. The handoff service (`src/services/prd/handoff-service.ts`)
84
- * is the canonical writer; we only consume its output here.
85
- */
86
- export declare function readAndVerifyHandoff(handoffPath: string, projectRoot: string): {
87
- frontmatter: HandoffFrontmatter;
88
- body: string;
89
- } | null;
90
- /**
91
- * Read the project-level security-template.md. Returns the body
92
- * string (with frontmatter stripped) or null if the file is absent.
93
- * Does NOT validate the template content; the parent LLM validates
94
- * by reading.
95
- */
96
- export declare function readSecurityTemplate(projectRoot: string): string | null;
97
68
  /**
98
69
  * 5-state detector. The parent skill inspects the state and either
99
70
  * proceeds (when `ready`) or records a degradation note and falls
@@ -115,29 +86,6 @@ export declare function detectSecurityAudit(input: {
115
86
  readonly dispatchError?: unknown;
116
87
  readonly envelope?: unknown;
117
88
  }): SecurityAuditDetectResult;
118
- /**
119
- * Render a SecurityAuditEnvelope to the canonical audit artifact body
120
- * (markdown). Mirrors `adaptEccEnvelopeToRdCodeReview` in ecc-bridge.ts:
121
- * produce a markdown body with all required sections, ready to write
122
- * to `.peaks/_runtime/<sid>/audit/security-<rid>.md`.
123
- */
124
- export declare function renderSecurityAuditArtifact(env: SecurityAuditEnvelope, opts: {
125
- rid: string;
126
- handoffHash: string;
127
- generatedAt: string;
128
- }): {
129
- body: string;
130
- violationsCount: number;
131
- verdict: SecurityAuditVerdict;
132
- };
133
- /**
134
- * Write the rendered audit artifact to
135
- * `.peaks/_runtime/<sid>/audit/security-<rid>.md`.
136
- *
137
- * Atomic write (tmp + rename) to avoid partial writes on crash.
138
- * Returns the absolute path on success.
139
- */
140
- export declare function writeSecurityAuditArtifact(projectRoot: string, sessionId: string, rid: string, body: string): string;
141
89
  /**
142
90
  * Convenience: run `detectSecurityAudit` + `renderSecurityAuditArtifact`
143
91
  * + `writeSecurityAuditArtifact` in one call.
@@ -150,6 +98,11 @@ export declare function runSecurityAudit(input: {
150
98
  readonly sessionId: string;
151
99
  readonly rid: string;
152
100
  readonly generatedAt: string;
101
+ /** Project-relative paths this audit judged; written into the artifact as
102
+ * the declaration the transition gate reads back. Required — a path that
103
+ * cannot be hashed is refused, because a declaration naming a file that is
104
+ * not there cannot be checked later. */
105
+ readonly judgedPaths: readonly string[];
153
106
  readonly dispatchError?: unknown;
154
107
  readonly envelope?: unknown;
155
108
  }): {
@@ -30,11 +30,13 @@
30
30
  * - Output: `.peaks/_runtime/<sid>/audit/security-<rid>.md`
31
31
  * - Schema: `.peaks/project-scan/audit-output-schema.md` (schemaVersion: 1)
32
32
  */
33
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
34
- import { join, resolve, isAbsolute } from 'node:path';
35
- import { createHash } from 'node:crypto';
36
- import { REQUEST_ID_PATTERN } from '../artifacts/request-artifact-service.js';
33
+ import { existsSync } from 'node:fs';
34
+ import { join } from 'node:path';
37
35
  import { resolveHandoffPath } from '../prd/handoff-service.js';
36
+ import { handoffMissingRefusal } from './handoff-missing-refusal.js';
37
+ import { renderSecurityAuditArtifact, writeSecurityAuditArtifact } from './security-audit-artifact.js';
38
+ import { declarationMissingDetect, renderJudgedDeclaration } from './judged-declaration.js';
39
+ import { buildJudgedDeclarationFor } from './judged-declaration-build.js';
38
40
  /**
39
41
  * Validate a raw value as a SecurityAuditEnvelope. Mirrors the
40
42
  * `isEccEnvelope` strict-shape pattern.
@@ -75,70 +77,6 @@ export function isSecurityAuditEnvelope(value) {
75
77
  }
76
78
  return true;
77
79
  }
78
- /**
79
- * Read the peaks-prd handoff frontmatter + body, verify sha256 matches
80
- * the body. Returns null on missing file or sha256 mismatch; otherwise
81
- * returns the parsed frontmatter + body string.
82
- *
83
- * Defensive: we read frontmatter via a 1-line regex match, not via
84
- * a YAML parser. The handoff service (`src/services/prd/handoff-service.ts`)
85
- * is the canonical writer; we only consume its output here.
86
- */
87
- export function readAndVerifyHandoff(handoffPath, projectRoot) {
88
- if (!handoffPath || !isAbsolute(handoffPath)) {
89
- const absolutePath = resolve(projectRoot, handoffPath);
90
- if (!existsSync(absolutePath))
91
- return null;
92
- return readAndVerifyHandoff(absolutePath, projectRoot);
93
- }
94
- if (!existsSync(handoffPath))
95
- return null;
96
- let raw;
97
- try {
98
- raw = readFileSync(handoffPath, 'utf8');
99
- }
100
- catch {
101
- // TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
102
- return null;
103
- }
104
- // Frontmatter pattern: `---` line, then key: value pairs, then `---` line.
105
- const match = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
106
- if (match === null)
107
- return null;
108
- const frontmatterRaw = match[1];
109
- const body = match[2];
110
- const sha256Match = frontmatterRaw.match(/^sha256:\s*([a-f0-9]{64})\s*$/m);
111
- const schemaVersionMatch = frontmatterRaw.match(/^schemaVersion:\s*(\d+)\s*$/m);
112
- if (sha256Match === null || schemaVersionMatch === null)
113
- return null;
114
- const sha256Expected = sha256Match[1];
115
- const schemaVersion = parseInt(schemaVersionMatch[1], 10);
116
- const sha256Actual = createHash('sha256').update(body, 'utf8').digest('hex');
117
- if (sha256Expected !== sha256Actual)
118
- return null;
119
- return {
120
- frontmatter: { sha256: sha256Expected, schemaVersion },
121
- body
122
- };
123
- }
124
- /**
125
- * Read the project-level security-template.md. Returns the body
126
- * string (with frontmatter stripped) or null if the file is absent.
127
- * Does NOT validate the template content; the parent LLM validates
128
- * by reading.
129
- */
130
- export function readSecurityTemplate(projectRoot) {
131
- const templatePath = join(projectRoot, '.peaks', 'project-scan', 'security-template.md');
132
- if (!existsSync(templatePath))
133
- return null;
134
- try {
135
- return readFileSync(templatePath, 'utf8');
136
- }
137
- catch {
138
- // TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
139
- return null;
140
- }
141
- }
142
80
  /**
143
81
  * 5-state detector. The parent skill inspects the state and either
144
82
  * proceeds (when `ready`) or records a degradation note and falls
@@ -159,22 +97,20 @@ export function detectSecurityAudit(input) {
159
97
  const templatePath = join(input.projectRoot, '.peaks', 'project-scan', 'security-template.md');
160
98
  const templatePresent = existsSync(templatePath);
161
99
  if (!handoffPresent) {
100
+ const refusal = handoffMissingRefusal({
101
+ role: 'security',
102
+ projectRoot: input.projectRoot,
103
+ sessionId: input.sessionId,
104
+ ...(input.requestId !== undefined ? { requestId: input.requestId } : {}),
105
+ // Measured, not assumed: `detect` supplies no envelope at all.
106
+ envelopeValidated: input.envelope !== undefined && isSecurityAuditEnvelope(input.envelope)
107
+ });
162
108
  return {
163
109
  state: 'handoff-missing',
164
110
  handoffPresent: false,
165
111
  templatePresent,
166
- warnings: [
167
- `peaks-prd handoff not found under ${join(input.projectRoot, '.peaks', '_runtime', input.sessionId, 'prd')}`,
168
- ...(input.requestId === undefined
169
- ? [
170
- "No --rid was supplied, so only the pre-rid-scoping `prd/handoff.md` could be probed. Pass --rid to resolve this slice's `prd/handoff-<rid>.md`."
171
- ]
172
- : [])
173
- ],
174
- nextActions: [
175
- 'Run peaks-prd handoff init to produce a sha256-locked handoff before running peaks security-audit.',
176
- 'Until the handoff exists, peaks-security-audit cannot start (gate fail).'
177
- ]
112
+ warnings: refusal.warnings,
113
+ nextActions: refusal.nextActions
178
114
  };
179
115
  }
180
116
  if (!templatePresent) {
@@ -225,90 +161,6 @@ export function detectSecurityAudit(input) {
225
161
  nextActions
226
162
  };
227
163
  }
228
- /**
229
- * Render a SecurityAuditEnvelope to the canonical audit artifact body
230
- * (markdown). Mirrors `adaptEccEnvelopeToRdCodeReview` in ecc-bridge.ts:
231
- * produce a markdown body with all required sections, ready to write
232
- * to `.peaks/_runtime/<sid>/audit/security-<rid>.md`.
233
- */
234
- export function renderSecurityAuditArtifact(env, opts) {
235
- const counts = {};
236
- for (const v of env.violations) {
237
- counts[v.severity] = (counts[v.severity] ?? 0) + 1;
238
- }
239
- const criticalCount = counts['CRITICAL'] ?? 0;
240
- const findingsBullets = env.violations.length === 0
241
- ? '- (none)'
242
- : env.violations
243
- .map((v) => `- [${v.severity}] ${v.dimension} @ ${v.file}:${v.line} — ${v.hint}`)
244
- .join('\n');
245
- const requiredFixes = buildRequiredFixes(env);
246
- const body = [
247
- '## Summary',
248
- '',
249
- env.summary,
250
- '',
251
- '## Threat model coverage',
252
- '',
253
- `audited at: ${opts.generatedAt}`,
254
- `verdict: ${env.verdict}`,
255
- `handoffHash: ${opts.handoffHash}`,
256
- '',
257
- '## Findings',
258
- '',
259
- findingsBullets,
260
- '',
261
- requiredFixes,
262
- '## Verdict',
263
- '',
264
- `verdict: ${env.verdict}`,
265
- `CRITICAL: ${criticalCount}`,
266
- ''
267
- ]
268
- .filter((s) => s.length > 0)
269
- .join('\n');
270
- return {
271
- body,
272
- violationsCount: env.violations.length,
273
- verdict: env.verdict
274
- };
275
- }
276
- function buildRequiredFixes(env) {
277
- const requiredFixes = env.violations.length === 0
278
- ? ''
279
- : [
280
- '## Required fixes',
281
- '',
282
- ...env.violations.map((v) => `- [${v.severity}] ${v.file}:${v.line} — ${v.hint}`),
283
- ''
284
- ].join('\n');
285
- return requiredFixes;
286
- }
287
- /**
288
- * Write the rendered audit artifact to
289
- * `.peaks/_runtime/<sid>/audit/security-<rid>.md`.
290
- *
291
- * Atomic write (tmp + rename) to avoid partial writes on crash.
292
- * Returns the absolute path on success.
293
- */
294
- export function writeSecurityAuditArtifact(projectRoot, sessionId, rid, body) {
295
- // The rid is a filename below, and the write is tmp+rename, so an
296
- // unvalidated rid can OVERWRITE an arbitrary `.md` rather than merely create
297
- // one. Guarded here (not only at the CLI boundary) so no caller can skip it.
298
- if (!REQUEST_ID_PATTERN.test(rid)) {
299
- throw new Error(`Invalid request id: ${rid} (expected letters, digits, dots, underscores, or dashes)`);
300
- }
301
- const targetDir = join(projectRoot, '.peaks', '_runtime', sessionId, 'audit');
302
- mkdirSync(targetDir, { recursive: true });
303
- const targetPath = join(targetDir, `security-${rid}.md`);
304
- // tmp + rename for atomicity
305
- const tmpPath = `${targetPath}.tmp`;
306
- writeFileSync(tmpPath, body, 'utf8');
307
- // Sync rename: on Windows, fs.renameSync overwrites if target exists (Node 22+)
308
- const { renameSync } = require('node:fs');
309
- renameSync(tmpPath, targetPath);
310
- return targetPath;
311
- }
312
164
  /**
313
165
  * Convenience: run `detectSecurityAudit` + `renderSecurityAuditArtifact`
314
166
  * + `writeSecurityAuditArtifact` in one call.
@@ -324,24 +176,28 @@ export function runSecurityAudit(input) {
324
176
  ...(input.dispatchError !== undefined ? { dispatchError: input.dispatchError } : {}),
325
177
  ...(input.envelope !== undefined ? { envelope: input.envelope } : {})
326
178
  });
327
- if (detect.state !== 'ready' || input.envelope === undefined) {
328
- return { detect, artifactPath: null, violationsCount: 0, verdict: null };
179
+ // The stamp is built inside the producer, before anything is written, so a
180
+ // caller that reaches the service alone still cannot leave an unstamped
181
+ // artifact behind. Folding its failure into the probe's own verdict keeps the
182
+ // refusal on this function's single early-return rather than a second one.
183
+ const built = buildJudgedDeclarationFor(input);
184
+ // A probe that is already refusing keeps its own diagnosis: the declaration
185
+ // is what this run would write, not what stopped it earlier.
186
+ const probe = built.ok || detect.state !== 'ready' ? detect : declarationMissingDetect(detect, built);
187
+ if (probe.state !== 'ready' || input.envelope === undefined || !built.ok) {
188
+ return { detect: probe, artifactPath: null, violationsCount: 0, verdict: null };
329
189
  }
330
- // detect.state === 'ready' implies input.envelope passed isSecurityAuditEnvelope.
190
+ // probe.state === 'ready' implies input.envelope passed isSecurityAuditEnvelope.
331
191
  const env = input.envelope;
332
- const handoffPath = resolveHandoffPath({
333
- projectRoot: input.projectRoot,
334
- sessionId: input.sessionId,
335
- requestId: input.rid
336
- });
337
- const verified = handoffPath === null ? null : readAndVerifyHandoff(handoffPath, input.projectRoot);
338
- const handoffHash = verified?.frontmatter.sha256 ?? 'unknown';
339
- const rendered = renderSecurityAuditArtifact(env, {
192
+ const renderOpts = {
340
193
  rid: input.rid,
341
- handoffHash,
194
+ handoffHash: built.handoffHash,
342
195
  generatedAt: input.generatedAt
343
- });
344
- const artifactPath = writeSecurityAuditArtifact(input.projectRoot, input.sessionId, input.rid, rendered.body);
196
+ };
197
+ const rendered = renderSecurityAuditArtifact(env, renderOpts);
198
+ const declared = built.declaration;
199
+ const body = `${rendered.body}\n${renderJudgedDeclaration(declared)}`;
200
+ const artifactPath = writeSecurityAuditArtifact(input.projectRoot, input.sessionId, input.rid, body);
345
201
  return {
346
202
  detect,
347
203
  artifactPath,
@@ -12,27 +12,49 @@ const FOUR_DIMENSIONS = [
12
12
  ];
13
13
  const FIFTH_DIMENSION = 'capability-consistency';
14
14
  /**
15
- * One oversized, omitted source that backs `dimension`. `omitted` + over-cap +
16
- * zero delivered bytes is the structural case: nothing can ever deliver it.
15
+ * An oversized source that backs `dimension`, in whichever of the two states
16
+ * the allocator can leave it.
17
+ *
18
+ * F3 (review 2026-10-13) — this used to build the omitted shape behind an
19
+ * `as unknown as CollectedEvidence` cast that omitted `excerpt`, so a `found`
20
+ * over-cap source built here would have been reported as "no deliverable
21
+ * source" while a cap-sized head of it had been inlined. The cast is gone and
22
+ * `excerpt` is declared, so the state the report distinguishes cannot be
23
+ * expressed wrongly from this helper.
17
24
  */
18
- function undeliverableSource(dimension, totalBytes) {
25
+ function overCapSource(dimension, totalBytes, inlined) {
19
26
  return {
20
27
  source: {
21
28
  key: `k-${dimension}`,
22
29
  label: dimension,
23
30
  segments: [`${dimension}.md`],
31
+ // The fixture deliberately fabricates dimension names (the fifth one is
32
+ // not a `DimensionKind`), so this ONE field is asserted, not inferred —
33
+ // the rest of the record is fully typed.
24
34
  supports: [dimension],
25
35
  delivery: { kind: 'whole' }
26
36
  },
27
37
  relativePath: `${dimension}.md`,
28
38
  absolutePath: `/nonexistent/${dimension}.md`,
29
- status: 'omitted',
39
+ status: inlined ? 'found' : 'omitted',
30
40
  totalBytes,
31
- includedBytes: 0,
32
- content: '',
33
- reason: 'over-cap'
41
+ includedBytes: inlined ? MAX_EVIDENCE_BYTES_PER_FILE : 0,
42
+ excerpt: inlined,
43
+ content: inlined ? 'x'.repeat(MAX_EVIDENCE_BYTES_PER_FILE) : '',
44
+ reason: inlined ? '' : 'over-cap'
34
45
  };
35
46
  }
47
+ /**
48
+ * One oversized, omitted source that backs `dimension`. `omitted` + over-cap +
49
+ * zero delivered bytes is the structural case: nothing can ever deliver it.
50
+ */
51
+ function undeliverableSource(dimension, totalBytes) {
52
+ return overCapSource(dimension, totalBytes, false);
53
+ }
54
+ /** `dimension=excerpt|silent` per entry — what the report says ARRIVED. */
55
+ function excerptState(report) {
56
+ return report.map((r) => `${r.dimension}=${r.excerptDelivered ? 'excerpt' : 'silent'}`).join(',');
57
+ }
36
58
  function reviewJson(dimensions) {
37
59
  return JSON.stringify({
38
60
  rid: 'J05-fixture',
@@ -112,22 +134,46 @@ function probeOutputBudget() {
112
134
  }
113
135
  return { floor, ceiling, badOverrideThrows };
114
136
  }
137
+ /**
138
+ * The over-cap evidence states, as probes.
139
+ *
140
+ * F3 (review 2026-10-13) is the pair that matters: the SAME oversized source,
141
+ * once inlined and once not, has to be reported as two DIFFERENT things. Both
142
+ * are driven here so the report cannot answer "nothing arrived" about a source
143
+ * whose cap-sized head is in the reviewer's prompt.
144
+ *
145
+ * Extracted from `runJ05Contract` so that function stays inside the
146
+ * function-length rule.
147
+ */
148
+ function overCapEvidenceProbes() {
149
+ const reported = undeliverableDimensions(FOUR_DIMENSIONS.map((d) => undeliverableSource(d, MAX_EVIDENCE_BYTES_PER_FILE + 1000)));
150
+ const dimensions = reported.map((r) => r.dimension);
151
+ const fifthOnly = undeliverableDimensions([
152
+ undeliverableSource(FIFTH_DIMENSION, MAX_EVIDENCE_BYTES_PER_FILE + 1000)
153
+ ]);
154
+ const excerptOnly = undeliverableDimensions([
155
+ overCapSource(FOUR_DIMENSIONS[0], MAX_EVIDENCE_BYTES_PER_FILE + 1000, true)
156
+ ]);
157
+ return [
158
+ probe(dimensions.length === FOUR_DIMENSIONS.length &&
159
+ FOUR_DIMENSIONS.every((d) => dimensions.includes(d)), `the canonical dimension set is exactly the four baseline dimensions (reported: ${dimensions.join(',') || 'none'})`),
160
+ probe(fifthOnly.length === 0, `the fifth dimension is not part of the required set (reported: ${fifthOnly.length})`),
161
+ probe(excerptOnly.length === 1 &&
162
+ excerptOnly[0]?.excerptDelivered === true &&
163
+ excerptOnly[0]?.sources[0]?.excerptBytes === MAX_EVIDENCE_BYTES_PER_FILE, `an over-cap source that WAS inlined is reported as an excerpt, not as nothing arrived (reported: ${excerptState(excerptOnly)})`),
164
+ probe(reported.length === FOUR_DIMENSIONS.length && reported.every((r) => !r.excerptDelivered), `an over-cap source that was NOT inlined is reported as nothing arrived (reported: ${excerptState(reported)})`)
165
+ ];
166
+ }
115
167
  export async function runJ05Contract(ctx) {
116
168
  const row = requireBaselineRow(ctx);
117
169
  const missing = missingSourceFiles(ctx, row);
118
170
  const prepared = await probePrepareFinalReview();
119
- const oversized = FOUR_DIMENSIONS.map((d) => undeliverableSource(d, MAX_EVIDENCE_BYTES_PER_FILE + 1000));
120
- const reported = undeliverableDimensions(oversized).map((r) => r.dimension);
121
- const fifthOnly = undeliverableDimensions([
122
- undeliverableSource(FIFTH_DIMENSION, MAX_EVIDENCE_BYTES_PER_FILE + 1000)
123
- ]);
124
171
  const { floor, ceiling, badOverrideThrows } = probeOutputBudget();
125
172
  const result = combineProbes([
126
173
  probe(missing.length === 0, `baseline sourceFiles present (${row.sourceFiles.length})`),
127
174
  probe(prepared.rejected, `a three-dimension review is refused (${prepared.detail})`),
128
175
  probe(prepared.accepted, `a four-dimension review is accepted (${prepared.detail})`),
129
- probe(reported.length === 4 && FOUR_DIMENSIONS.every((d) => reported.includes(d)), `the canonical dimension set is exactly the four baseline dimensions (reported: ${reported.join(',') || 'none'})`),
130
- probe(fifthOnly.length === 0, `the fifth dimension is not part of the required set (reported: ${fifthOnly.length})`),
176
+ ...overCapEvidenceProbes(),
131
177
  probe(MAX_EVIDENCE_BYTES_PER_FILE === 10240, `per-file evidence cap divides the total by four (${String(MAX_EVIDENCE_BYTES_PER_FILE)})`),
132
178
  probe(floor === 15288 && ceiling === 32000, `output budget is clamped on both ends (${String(floor)} / ${String(ceiling)})`),
133
179
  probe(badOverrideThrows, 'a non-integer budget override throws instead of falling back silently')
@@ -0,0 +1,54 @@
1
+ import { type HarnessWindowSyncResult } from '../context/harness-window-config.js';
2
+ import type { ConvergencePlan } from '../context/auto-compact-types.js';
3
+ /**
4
+ * What the caller is told to do next. The harness-window notice rides along because
5
+ * the run also rewrites the harness's own settings, so it says so too: the user
6
+ * accepted that write on the condition 要告知, and a write only one of the two
7
+ * syncing commands reports is not a notice.
8
+ */
9
+ export declare function compactNextActions(isRedLine: boolean, harnessWindow: HarnessWindowSyncResult | null): readonly string[];
10
+ /**
11
+ * Append a one-row convergence decision to the LLM-readable log.
12
+ * The LLM reads this on the post-compact turn to pick up exactly
13
+ * where it left off (vs. blindly trusting the IDE's compressed
14
+ * transcript).
15
+ */
16
+ export declare function appendAutoDecisionLog(input: {
17
+ readonly projectRoot: string;
18
+ readonly sessionId: string;
19
+ readonly plan: ConvergencePlan;
20
+ }): void;
21
+ /**
22
+ * main-session compact intent so the main-session LLM picks it up on
23
+ * its next turn and fires `/compact` in-band. Without this file the
24
+ * orchestrator's "main-session compact" request is invisible to the
25
+ * main Claude Code window (defeats the whole point of auto-compact
26
+ * for the main context).
27
+ *
28
+ * The file is gitignored under `.peaks/_runtime/<sessionId>/txt/` and
29
+ * is one-shot: the LLM should `mv` it to `.consumed` after firing
30
+ * `/compact`. A re-run will overwrite.
31
+ *
32
+ * write survives, but nothing consumes the file, and its `nextAction` asks
33
+ * for a `/compact` the model cannot invoke (the Skill tool exposes only
34
+ * `/init` and `/security-review`; hooks can observe or veto, never initiate).
35
+ * Retained deliberately for the sibling A2 slice, which owns harness-side
36
+ * state re-injection. Not a capability peaks-loop has today.
37
+ */
38
+ export declare function writeMainSessionCompactIntent(input: {
39
+ readonly projectRoot: string;
40
+ readonly sessionId: string;
41
+ readonly ratio: number;
42
+ readonly redLine: boolean;
43
+ readonly now: Date;
44
+ }): void;
45
+ /**
46
+ * Write a pre-compact checkpoint. The shape mirrors `peaks session
47
+ * checkpoint` so D7's post-compact-detect picks it up unchanged.
48
+ */
49
+ export declare function writePreCompactCheckpoint(input: {
50
+ readonly projectRoot: string;
51
+ readonly sessionId: string;
52
+ readonly now: Date;
53
+ readonly redLine?: boolean;
54
+ }): string;
@@ -0,0 +1,135 @@
1
+ /**
2
+ * The files one auto-compact run writes: checkpoint, intent and decision log.
3
+ *
4
+ * Split out of `auto-compact-orchestrator.ts` (file-size cap campaign). The
5
+ * orchestrator re-exports every name declared here, so existing importers keep
6
+ * using `./auto-compact-orchestrator.js` unchanged.
7
+ */
8
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
9
+ import { join } from 'node:path';
10
+ import { getSessionDir } from '../session/getSessionDir.js';
11
+ import { describeHarnessWindowSync } from '../context/harness-window-config.js';
12
+ /**
13
+ * What the caller is told to do next. The harness-window notice rides along because
14
+ * the run also rewrites the harness's own settings, so it says so too: the user
15
+ * accepted that write on the condition 要告知, and a write only one of the two
16
+ * syncing commands reports is not a notice.
17
+ */
18
+ export function compactNextActions(isRedLine, harnessWindow) {
19
+ if (isRedLine) {
20
+ return [
21
+ 'RED-LINE: harness compact requested — sub-agent dispatch is NOT blocked; keep working',
22
+ 'Post-compact resume picks up the convergence plan from auto-decisions.md',
23
+ 'Next `peaks code context-now` probe will confirm the ratio dropped; if it keeps climbing and the harness has not compacted, report that to the user and hand control back',
24
+ describeHarnessWindowSync(harnessWindow)
25
+ ];
26
+ }
27
+ return [
28
+ 'Pre-compact dispatched — IDE compact in progress (async)',
29
+ 'Post-compact resume picks up the convergence plan from auto-decisions.md',
30
+ 'Next `peaks code auto-compact` probe will confirm ratio dropped below 0.85',
31
+ describeHarnessWindowSync(harnessWindow)
32
+ ];
33
+ }
34
+ const PRE_COMPACT_REASON = 'pre-compact-auto';
35
+ /**
36
+ * Append a one-row convergence decision to the LLM-readable log.
37
+ * The LLM reads this on the post-compact turn to pick up exactly
38
+ * where it left off (vs. blindly trusting the IDE's compressed
39
+ * transcript).
40
+ */
41
+ export function appendAutoDecisionLog(input) {
42
+ // Repair R6: same hand-rolled join as `writePreCompactCheckpoint`. All four
43
+ // session-scoped paths in this file now go through the axis builder; none
44
+ // composes the join itself, so none can resolve outside the project root.
45
+ const dir = join(getSessionDir(input.projectRoot, input.sessionId), 'txt');
46
+ if (!existsSync(dir))
47
+ mkdirSync(dir, { recursive: true });
48
+ const logPath = join(dir, 'auto-decisions.md');
49
+ const row = [
50
+ '',
51
+ `## Auto-compact decision — ${input.plan.createdAt}`,
52
+ `- ratio: ${(input.plan.ratio * 100).toFixed(1)}%`,
53
+ `- checkpoint: ${input.plan.checkpointPath}`,
54
+ `- next-actions: ${input.plan.nextActions.join(' | ')}`,
55
+ `- resume-hint: ${input.plan.resumeHint}`,
56
+ ''
57
+ ].join('\n');
58
+ if (!existsSync(logPath)) {
59
+ writeFileSync(logPath, `# peaks-code auto-decisions log\n${row}`, 'utf8');
60
+ return;
61
+ }
62
+ const existing = readFileSync(logPath, 'utf8');
63
+ writeFileSync(logPath, `${existing}${row}`, 'utf8');
64
+ }
65
+ /**
66
+ * main-session compact intent so the main-session LLM picks it up on
67
+ * its next turn and fires `/compact` in-band. Without this file the
68
+ * orchestrator's "main-session compact" request is invisible to the
69
+ * main Claude Code window (defeats the whole point of auto-compact
70
+ * for the main context).
71
+ *
72
+ * The file is gitignored under `.peaks/_runtime/<sessionId>/txt/` and
73
+ * is one-shot: the LLM should `mv` it to `.consumed` after firing
74
+ * `/compact`. A re-run will overwrite.
75
+ *
76
+ * write survives, but nothing consumes the file, and its `nextAction` asks
77
+ * for a `/compact` the model cannot invoke (the Skill tool exposes only
78
+ * `/init` and `/security-review`; hooks can observe or veto, never initiate).
79
+ * Retained deliberately for the sibling A2 slice, which owns harness-side
80
+ * state re-injection. Not a capability peaks-loop has today.
81
+ */
82
+ export function writeMainSessionCompactIntent(input) {
83
+ const dir = join(getSessionDir(input.projectRoot, input.sessionId), 'txt');
84
+ if (!existsSync(dir))
85
+ mkdirSync(dir, { recursive: true });
86
+ const path = join(dir, 'auto-compact-pending.json');
87
+ const payload = {
88
+ schemaVersion: 1,
89
+ pending: true,
90
+ target: 'main',
91
+ requestedAt: input.now.toISOString(),
92
+ ratio: input.ratio,
93
+ redLine: input.redLine,
94
+ nextAction: 'next LLM turn MUST fire `/compact` then `mv .peaks/_runtime/<sid>/txt/auto-compact-pending.json .peaks/_runtime/<sid>/txt/auto-compact-pending.consumed.json`'
95
+ };
96
+ writeFileSync(path, JSON.stringify(payload, null, 2), 'utf8');
97
+ }
98
+ /**
99
+ * Write a pre-compact checkpoint. The shape mirrors `peaks session
100
+ * checkpoint` so D7's post-compact-detect picks it up unchanged.
101
+ */
102
+ export function writePreCompactCheckpoint(input) {
103
+ // Repair R6: this used to hand-roll the session join, which is the one shape
104
+ // `getSessionDir`'s own header records as NOT covered by the guard — an
105
+ // unsafe id resolved outside the project root and the checkpoint was written
106
+ // there. The gate above now refuses an unresolvable id before this point, but
107
+ // `--force` outranks that gate, so this join has to hold on its own.
108
+ const dir = join(getSessionDir(input.projectRoot, input.sessionId), 'checkpoints');
109
+ if (!existsSync(dir))
110
+ mkdirSync(dir, { recursive: true });
111
+ const prefix = input.redLine === true ? 'red-line-' : 'pre-compact-';
112
+ const filename = `${prefix}${input.now.toISOString().replace(/[:.]/g, '-')}.json`;
113
+ const path = join(dir, filename);
114
+ const content = {
115
+ schemaVersion: 1,
116
+ reason: input.redLine === true ? 'pre-compact-red-line' : PRE_COMPACT_REASON,
117
+ sessionId: input.sessionId,
118
+ createdAt: input.now.toISOString(),
119
+ // D7 reads `mode`, `currentPlan`, `openQuestions`, `recentDecisions`
120
+ // out of this JSON. We seed empty arrays; the post-compact LLM
121
+ // rehydrates from the auto-decisions log + open question list.
122
+ mode: 'full-auto',
123
+ currentPlan: input.redLine === true
124
+ ? 'RED-LINE compact REQUESTED from the harness (not executed by peaks-loop); work continues'
125
+ : 'auto-compact in progress; resume from auto-decisions.md',
126
+ openQuestions: [],
127
+ recentDecisions: [],
128
+ recentArtifactPaths: [],
129
+ gitStatus: '',
130
+ skillsActive: ['peaks-code'],
131
+ todoState: []
132
+ };
133
+ writeFileSync(path, JSON.stringify(content, null, 2), 'utf8');
134
+ return path;
135
+ }