peaks-loop 4.0.0-beta.9 → 4.0.1

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 (552) hide show
  1. package/CHANGELOG.md +910 -141
  2. package/README-en.md +26 -7
  3. package/README.md +75 -6
  4. package/agents/karpathy-reviewer.md +33 -0
  5. package/bin/peaks.js +0 -0
  6. package/dist/cli/cli-helpers.d.ts +31 -6
  7. package/dist/cli/cli-helpers.js +48 -25
  8. package/dist/cli/commands/_register.d.ts +3 -0
  9. package/dist/cli/commands/_register.js +139 -0
  10. package/dist/cli/commands/_super.d.ts +10 -0
  11. package/dist/cli/commands/_super.js +97 -0
  12. package/dist/cli/commands/adapter-commands-s2a.js +1 -1
  13. package/dist/cli/commands/asset-commands.js +33 -16
  14. package/dist/cli/commands/audit-commands.js +2 -2
  15. package/dist/cli/commands/autonomous-swarm-commands.d.ts +12 -0
  16. package/dist/cli/commands/autonomous-swarm-commands.js +120 -0
  17. package/dist/cli/commands/bee-commands.js +1 -1
  18. package/dist/cli/commands/capability-commands.js +1 -1
  19. package/dist/cli/commands/capability-worker-config-sc-commands.js +0 -2
  20. package/dist/cli/commands/changeset-commands.d.ts +13 -0
  21. package/dist/cli/commands/changeset-commands.js +46 -0
  22. package/dist/cli/commands/code-commands.d.ts +11 -1
  23. package/dist/cli/commands/code-commands.js +19 -699
  24. package/dist/cli/commands/code-job-shape-commands.d.ts +9 -0
  25. package/dist/cli/commands/code-job-shape-commands.js +164 -0
  26. package/dist/cli/commands/code-mode-gate-commands.d.ts +9 -0
  27. package/dist/cli/commands/code-mode-gate-commands.js +223 -0
  28. package/dist/cli/commands/code-review-commands.js +2 -2
  29. package/dist/cli/commands/code-run-command.d.ts +12 -0
  30. package/dist/cli/commands/code-run-command.js +68 -0
  31. package/dist/cli/commands/code-runtime-commands.d.ts +11 -0
  32. package/dist/cli/commands/code-runtime-commands.js +391 -0
  33. package/dist/cli/commands/codegraph-commands.js +1 -1
  34. package/dist/cli/commands/compact-command.js +53 -1
  35. package/dist/cli/commands/complexity-commands.js +1 -1
  36. package/dist/cli/commands/config-commands.js +4 -75
  37. package/dist/cli/commands/container-commands.d.ts +28 -0
  38. package/dist/cli/commands/container-commands.js +221 -0
  39. package/dist/cli/commands/context-commands.js +3 -2
  40. package/dist/cli/commands/core/artifacts-command.js +1 -1
  41. package/dist/cli/commands/core/binding-commands.js +1 -1
  42. package/dist/cli/commands/core/doctor-command.js +63 -3
  43. package/dist/cli/commands/core/memory-command.js +1 -1
  44. package/dist/cli/commands/core/profile-command.js +1 -1
  45. package/dist/cli/commands/core/proxy-command.js +1 -1
  46. package/dist/cli/commands/core/session-command.js +9 -7
  47. package/dist/cli/commands/core/skill-command.js +7 -4
  48. package/dist/cli/commands/core/standards-command.js +1 -1
  49. package/dist/cli/commands/cron-commands.d.ts +57 -0
  50. package/dist/cli/commands/cron-commands.js +257 -0
  51. package/dist/cli/commands/cron-scheduler-commands.d.ts +47 -0
  52. package/dist/cli/commands/cron-scheduler-commands.js +284 -0
  53. package/dist/cli/commands/dashboard-commands.d.ts +4 -0
  54. package/dist/cli/commands/dashboard-commands.js +10 -0
  55. package/dist/cli/commands/dashboard-long-run.d.ts +25 -0
  56. package/dist/cli/commands/dashboard-long-run.js +122 -0
  57. package/dist/cli/commands/dashboard-summary.d.ts +12 -0
  58. package/dist/cli/commands/dashboard-summary.js +58 -0
  59. package/dist/cli/commands/dispatch-commands.d.ts +0 -7
  60. package/dist/cli/commands/dispatch-commands.js +372 -8
  61. package/dist/cli/commands/dispatch-from-dag.js +4 -1
  62. package/dist/cli/commands/doc-commands.js +1 -1
  63. package/dist/cli/commands/ecc-commands.d.ts +30 -0
  64. package/dist/cli/commands/ecc-commands.js +119 -0
  65. package/dist/cli/commands/evolution-commands.js +1 -1
  66. package/dist/cli/commands/feedback-commands.js +1 -1
  67. package/dist/cli/commands/final-review-commands.js +1 -1
  68. package/dist/cli/commands/fixture-commands.js +1 -1
  69. package/dist/cli/commands/fork-commands.js +1 -1
  70. package/dist/cli/commands/gate-commands.js +128 -6
  71. package/dist/cli/commands/governance-classify-contract-commands.d.ts +21 -0
  72. package/dist/cli/commands/governance-classify-contract-commands.js +273 -0
  73. package/dist/cli/commands/heartbeat-commands.js +76 -5
  74. package/dist/cli/commands/heartbeat-watch-command.d.ts +31 -0
  75. package/dist/cli/commands/heartbeat-watch-command.js +146 -0
  76. package/dist/cli/commands/hook-handle.js +1 -1
  77. package/dist/cli/commands/hooks-commands.js +126 -10
  78. package/dist/cli/commands/ide-commands.js +1 -1
  79. package/dist/cli/commands/impact-commands.js +1 -1
  80. package/dist/cli/commands/job-commands.js +34 -1
  81. package/dist/cli/commands/lease-metrics-commands.d.ts +67 -0
  82. package/dist/cli/commands/lease-metrics-commands.js +231 -0
  83. package/dist/cli/commands/lease-stats-commands.d.ts +65 -0
  84. package/dist/cli/commands/lease-stats-commands.js +107 -0
  85. package/dist/cli/commands/legacy-commands.js +1 -1
  86. package/dist/cli/commands/log-commands.js +1 -1
  87. package/dist/cli/commands/loop-commands.js +1 -1
  88. package/dist/cli/commands/loop-eval-commands.js +1 -1
  89. package/dist/cli/commands/memory-commands.js +1 -1
  90. package/dist/cli/commands/migrate-1-4-1-command.js +1 -1
  91. package/dist/cli/commands/migrate-v2-10-to-v2-11-command.js +1 -1
  92. package/dist/cli/commands/mut-commands.d.ts +1 -1
  93. package/dist/cli/commands/mut-commands.js +1 -5
  94. package/dist/cli/commands/observability-commands.js +1 -1
  95. package/dist/cli/commands/openspec-commands.js +65 -4
  96. package/dist/cli/commands/perf-audit-commands.js +3 -3
  97. package/dist/cli/commands/perf-commands.js +1 -1
  98. package/dist/cli/commands/polyrepo-commands.js +1 -1
  99. package/dist/cli/commands/prd-blocks-commands.js +1 -1
  100. package/dist/cli/commands/prd-commands.js +4 -2
  101. package/dist/cli/commands/preferences-commands.js +23 -3
  102. package/dist/cli/commands/project-commands.js +1 -1
  103. package/dist/cli/commands/qa-business-review-commands.js +1 -1
  104. package/dist/cli/commands/qa-commands.d.ts +1 -1
  105. package/dist/cli/commands/qa-commands.js +39 -3
  106. package/dist/cli/commands/release-commands.d.ts +15 -0
  107. package/dist/cli/commands/release-commands.js +113 -21
  108. package/dist/cli/commands/request-commands.js +1 -1
  109. package/dist/cli/commands/retrospective-commands.js +1 -1
  110. package/dist/cli/commands/reviewer-commands.js +1 -1
  111. package/dist/cli/commands/role-commands.js +1 -1
  112. package/dist/cli/commands/runtime-commands-helpers.d.ts +7 -0
  113. package/dist/cli/commands/runtime-commands-helpers.js +24 -0
  114. package/dist/cli/commands/runtime-commands.js +1 -2
  115. package/dist/cli/commands/sc-commands.js +4 -2
  116. package/dist/cli/commands/scan-commands.js +1 -1
  117. package/dist/cli/commands/security-audit-commands.js +3 -3
  118. package/dist/cli/commands/sediment-commands.js +10 -1
  119. package/dist/cli/commands/session-24h-mode.d.ts +26 -0
  120. package/dist/cli/commands/session-24h-mode.js +196 -0
  121. package/dist/cli/commands/share-commands.d.ts +19 -0
  122. package/dist/cli/commands/share-commands.js +121 -2
  123. package/dist/cli/commands/skill-conformance-commands.js +1 -1
  124. package/dist/cli/commands/skill-loop-engineering-readiness-commands.js +1 -1
  125. package/dist/cli/commands/skill-search-commands.js +4 -1
  126. package/dist/cli/commands/slice-commands.js +1 -1
  127. package/dist/cli/commands/slice-integrate-commands.js +1 -1
  128. package/dist/cli/commands/slice-review-commands.js +1 -1
  129. package/dist/cli/commands/smoke-commands.js +1 -1
  130. package/dist/cli/commands/sop-commands.js +1 -1
  131. package/dist/cli/commands/spill-demo-command.d.ts +7 -0
  132. package/dist/cli/commands/spill-demo-command.js +29 -0
  133. package/dist/cli/commands/statusline-commands.d.ts +12 -0
  134. package/dist/cli/commands/statusline-commands.js +79 -17
  135. package/dist/cli/commands/sub-agent-commands.js +2 -1
  136. package/dist/cli/commands/sub-agent-shared.d.ts +10 -0
  137. package/dist/cli/commands/sub-agent-shared.js +24 -1
  138. package/dist/cli/commands/swarm-commands.d.ts +13 -0
  139. package/dist/cli/commands/swarm-commands.js +77 -0
  140. package/dist/cli/commands/tech-commands.d.ts +64 -0
  141. package/dist/cli/commands/tech-commands.js +195 -0
  142. package/dist/cli/commands/understand-commands.js +1 -1
  143. package/dist/cli/commands/upgrade-commands.d.ts +2 -0
  144. package/dist/cli/commands/upgrade-commands.js +40 -5
  145. package/dist/cli/commands/user-touchpoint-commands.js +1 -1
  146. package/dist/cli/commands/verdict-aggregate-command.js +1 -1
  147. package/dist/cli/commands/vm-commands.d.ts +31 -0
  148. package/dist/cli/commands/vm-commands.js +274 -0
  149. package/dist/cli/commands/workflow-commands.js +24 -1
  150. package/dist/cli/commands/workflow-plan-commands.js +1 -1
  151. package/dist/cli/commands/workspace/init-command.js +1 -1
  152. package/dist/cli/commands/workspace/migrate-command.js +1 -1
  153. package/dist/cli/commands/workspace/reconcile-command.js +1 -1
  154. package/dist/cli/commands/worktree-auth-commands.d.ts +29 -0
  155. package/dist/cli/commands/worktree-auth-commands.js +652 -0
  156. package/dist/cli/index.js +58 -13
  157. package/dist/cli/program.d.ts +2 -2
  158. package/dist/cli/program.js +86 -281
  159. package/dist/services/24h-mode/decider.d.ts +103 -0
  160. package/dist/services/24h-mode/decider.js +144 -0
  161. package/dist/services/24h-mode/index.d.ts +12 -0
  162. package/dist/services/24h-mode/index.js +12 -0
  163. package/dist/services/24h-mode/state.d.ts +48 -0
  164. package/dist/services/24h-mode/state.js +51 -0
  165. package/dist/services/24h-mode/store.d.ts +27 -0
  166. package/dist/services/24h-mode/store.js +119 -0
  167. package/dist/services/artifacts/artifact-prerequisites.js +1 -1
  168. package/dist/services/artifacts/request-artifact-service.js +1 -1
  169. package/dist/services/artifacts/workspace-service.js +1 -1
  170. package/dist/services/audit/enforcers/lint-bee-runtime-contract.d.ts +25 -0
  171. package/dist/services/audit/enforcers/lint-bee-runtime-contract.js +91 -0
  172. package/dist/services/audit/enforcers/lint-peaks-code-runtime.d.ts +16 -0
  173. package/dist/services/audit/enforcers/lint-peaks-code-runtime.js +31 -0
  174. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +23 -0
  175. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +59 -0
  176. package/dist/services/audit/enforcers/lint-peaks-ui-sc-txt-runtime.d.ts +28 -0
  177. package/dist/services/audit/enforcers/lint-peaks-ui-sc-txt-runtime.js +86 -0
  178. package/dist/services/audit/enforcers/lint-prd-artifact-handoff.d.ts +16 -0
  179. package/dist/services/audit/enforcers/lint-prd-artifact-handoff.js +41 -0
  180. package/dist/services/audit/enforcers/lint-prd-source-snapshot.d.ts +27 -0
  181. package/dist/services/audit/enforcers/lint-prd-source-snapshot.js +47 -0
  182. package/dist/services/audit/enforcers/lint-qa-gateguard-and-runtime.d.ts +19 -0
  183. package/dist/services/audit/enforcers/lint-qa-gateguard-and-runtime.js +47 -0
  184. package/dist/services/audit/enforcers/lint-rd-handoff-coverage.d.ts +18 -0
  185. package/dist/services/audit/enforcers/lint-rd-handoff-coverage.js +70 -0
  186. package/dist/services/audit/enforcers/lint-skill-presence-mandatory.d.ts +25 -0
  187. package/dist/services/audit/enforcers/lint-skill-presence-mandatory.js +53 -0
  188. package/dist/services/audit/red-line-catalog-p2-a.d.ts +0 -6
  189. package/dist/services/audit/red-line-catalog-p2-a.js +230 -1
  190. package/dist/services/audit/static-service.d.ts +32 -25
  191. package/dist/services/audit/static-service.js +30 -109
  192. package/dist/services/audit-independent/index.d.ts +2 -0
  193. package/dist/services/audit-independent/index.js +2 -0
  194. package/dist/services/autonomous-swarm/autonomous-swarm-service.d.ts +127 -0
  195. package/dist/services/autonomous-swarm/autonomous-swarm-service.js +446 -0
  196. package/dist/services/changeset/changeset-check-service.d.ts +22 -0
  197. package/dist/services/changeset/changeset-check-service.js +47 -0
  198. package/dist/services/code/auto-compact-modes.d.ts +30 -0
  199. package/dist/services/code/auto-compact-modes.js +38 -0
  200. package/dist/services/code/auto-compact-orchestrator.d.ts +43 -5
  201. package/dist/services/code/auto-compact-orchestrator.js +101 -21
  202. package/dist/services/code/dag-orchestrator.d.ts +30 -1
  203. package/dist/services/code/dag-orchestrator.js +106 -1
  204. package/dist/services/code/status-line-renderer.d.ts +2 -0
  205. package/dist/services/code/status-line-renderer.js +21 -3
  206. package/dist/services/code-review/ocr-service.d.ts +1 -1
  207. package/dist/services/code-review/ocr-service.js +6 -3
  208. package/dist/services/compact-history/compact-history-service.d.ts +41 -0
  209. package/dist/services/compact-history/compact-history-service.js +62 -0
  210. package/dist/services/compact-statusline/compact-statusline-service.d.ts +16 -0
  211. package/dist/services/compact-statusline/compact-statusline-service.js +83 -0
  212. package/dist/services/config/config-service.d.ts +1 -12
  213. package/dist/services/config/config-service.js +3 -72
  214. package/dist/services/config/config-types.d.ts +2 -4
  215. package/dist/services/config/config-types.js +1 -1
  216. package/dist/services/container/container-lease.d.ts +67 -0
  217. package/dist/services/container/container-lease.js +135 -0
  218. package/dist/services/context/auto-compact-dispatcher.d.ts +40 -5
  219. package/dist/services/context/auto-compact-dispatcher.js +32 -102
  220. package/dist/services/context/auto-compact-reader.js +1 -1
  221. package/dist/services/context/auto-compact-types.d.ts +27 -2
  222. package/dist/services/context/auto-compact-types.js +8 -1
  223. package/dist/services/context/build-dispatch-system-prompt.d.ts +75 -0
  224. package/dist/services/context/build-dispatch-system-prompt.js +117 -0
  225. package/dist/services/context/collector.d.ts +2 -2
  226. package/dist/services/context/context-builder.d.ts +4 -4
  227. package/dist/services/context/context-schema.d.ts +48 -48
  228. package/dist/services/context/ide-detect.d.ts +4 -0
  229. package/dist/services/context/ide-detect.js +24 -0
  230. package/dist/services/context/main-session-monitor.d.ts +1 -4
  231. package/dist/services/context/main-session-monitor.js +1 -24
  232. package/dist/services/context/memory-index-reader.d.ts +8 -0
  233. package/dist/services/context/memory-index-reader.js +57 -0
  234. package/dist/services/context/memory-lru-cache.d.ts +12 -0
  235. package/dist/services/context/memory-lru-cache.js +60 -0
  236. package/dist/services/context/memory-preflight-config.d.ts +19 -0
  237. package/dist/services/context/memory-preflight-config.js +25 -0
  238. package/dist/services/context/memory-preflight-service.d.ts +19 -0
  239. package/dist/services/context/memory-preflight-service.js +120 -0
  240. package/dist/services/context/spillover-store.d.ts +23 -0
  241. package/dist/services/context/spillover-store.js +155 -0
  242. package/dist/services/context/spillover-types.d.ts +18 -0
  243. package/dist/services/context/spillover-types.js +1 -0
  244. package/dist/services/crystallization/crystallization-service.d.ts +22 -5
  245. package/dist/services/crystallization/crystallization-service.js +8 -14
  246. package/dist/services/crystallization/crystallization-types.d.ts +6 -6
  247. package/dist/services/crystallization/evidence-brief-builder.d.ts +1 -1
  248. package/dist/services/crystallization/index.d.ts +13 -0
  249. package/dist/services/crystallization/index.js +13 -0
  250. package/dist/services/dashboard/project-dashboard-service.js +2 -2
  251. package/dist/services/dispatch/await-batch.d.ts +70 -0
  252. package/dist/services/dispatch/await-batch.js +272 -0
  253. package/dist/services/dispatch/batch-counter.js +1 -1
  254. package/dist/services/dispatch/dispatch-record-writer.d.ts +126 -4
  255. package/dist/services/dispatch/dispatch-record-writer.js +239 -9
  256. package/dist/services/dispatch/slice-dag.d.ts +46 -0
  257. package/dist/services/dispatch/slice-dag.js +6 -0
  258. package/dist/services/dispatch/stage-enum.d.ts +27 -0
  259. package/dist/services/dispatch/stage-enum.js +48 -0
  260. package/dist/services/dispatch/startup-timeout.d.ts +86 -0
  261. package/dist/services/dispatch/startup-timeout.js +97 -0
  262. package/dist/services/dispatch/sub-agent-dispatcher.js +40 -89
  263. package/dist/services/dispatch/test-tool-detection.d.ts +25 -1
  264. package/dist/services/dispatch/test-tool-detection.js +80 -0
  265. package/dist/services/doctor/doctor-service/checks/check-id-schema.d.ts +18 -0
  266. package/dist/services/doctor/doctor-service/checks/check-id-schema.js +64 -0
  267. package/dist/services/doctor/doctor-service/checks/codegraph-capability.d.ts +14 -0
  268. package/dist/services/doctor/doctor-service/checks/codegraph-capability.js +69 -0
  269. package/dist/services/doctor/doctor-service/checks/dist-source-version.d.ts +32 -0
  270. package/dist/services/doctor/doctor-service/checks/dist-source-version.js +110 -0
  271. package/dist/services/doctor/doctor-service/checks/gateguard-conflict.d.ts +24 -0
  272. package/dist/services/doctor/doctor-service/checks/gateguard-conflict.js +164 -0
  273. package/dist/services/doctor/doctor-service/checks/l3-memory-health.d.ts +16 -0
  274. package/dist/services/doctor/doctor-service/checks/l3-memory-health.js +57 -0
  275. package/dist/services/doctor/doctor-service/checks/l3-orphan-sessions.d.ts +19 -0
  276. package/dist/services/doctor/doctor-service/checks/l3-orphan-sessions.js +66 -0
  277. package/dist/services/doctor/doctor-service/checks/schema-validity.d.ts +10 -0
  278. package/dist/services/doctor/doctor-service/checks/schema-validity.js +33 -0
  279. package/dist/services/doctor/doctor-service/checks/skill-apply-note.d.ts +20 -0
  280. package/dist/services/doctor/doctor-service/checks/skill-apply-note.js +85 -0
  281. package/dist/services/doctor/doctor-service/checks/skill-existence.d.ts +13 -0
  282. package/dist/services/doctor/doctor-service/checks/skill-existence.js +30 -0
  283. package/dist/services/doctor/doctor-service/checks/skill-name-match.d.ts +10 -0
  284. package/dist/services/doctor/doctor-service/checks/skill-name-match.js +25 -0
  285. package/dist/services/doctor/doctor-service/checks/skill-parse.d.ts +10 -0
  286. package/dist/services/doctor/doctor-service/checks/skill-parse.js +19 -0
  287. package/dist/services/doctor/doctor-service/checks/skill-presence.d.ts +21 -0
  288. package/dist/services/doctor/doctor-service/checks/skill-presence.js +75 -0
  289. package/dist/services/doctor/doctor-service/checks/skill-runbook.d.ts +14 -0
  290. package/dist/services/doctor/doctor-service/checks/skill-runbook.js +47 -0
  291. package/dist/services/doctor/doctor-service/checks/statusline-install.d.ts +14 -0
  292. package/dist/services/doctor/doctor-service/checks/statusline-install.js +32 -0
  293. package/dist/services/doctor/doctor-service/checks/statusline-runtime.d.ts +13 -0
  294. package/dist/services/doctor/doctor-service/checks/statusline-runtime.js +30 -0
  295. package/dist/services/doctor/doctor-service/checks/user-config.d.ts +11 -0
  296. package/dist/services/doctor/doctor-service/checks/user-config.js +27 -0
  297. package/dist/services/doctor/doctor-service/checks/workspace-init.d.ts +16 -0
  298. package/dist/services/doctor/doctor-service/checks/workspace-init.js +34 -0
  299. package/dist/services/doctor/doctor-service/checks/workspace-layout.d.ts +33 -0
  300. package/dist/services/doctor/doctor-service/checks/workspace-layout.js +180 -0
  301. package/dist/services/doctor/doctor-service/index.d.ts +48 -0
  302. package/dist/services/doctor/doctor-service/index.js +254 -0
  303. package/dist/services/doctor/doctor-service/plugin-registry.d.ts +41 -0
  304. package/dist/services/doctor/doctor-service/plugin-registry.js +77 -0
  305. package/dist/services/doctor/doctor-service/report/final-summary.d.ts +20 -0
  306. package/dist/services/doctor/doctor-service/report/final-summary.js +29 -0
  307. package/dist/services/doctor/doctor-service/types.d.ts +245 -0
  308. package/dist/services/doctor/doctor-service/types.js +15 -0
  309. package/dist/services/doctor/doctor-service.d.ts +15 -146
  310. package/dist/services/doctor/doctor-service.js +22 -926
  311. package/dist/services/doctor/index.d.ts +22 -0
  312. package/dist/services/doctor/index.js +22 -0
  313. package/dist/services/env/shell-probe.d.ts +71 -0
  314. package/dist/services/env/shell-probe.js +161 -0
  315. package/dist/services/evolution/evolution-types.d.ts +39 -39
  316. package/dist/services/final-review/final-review-service.d.ts +11 -1
  317. package/dist/services/final-review/index.d.ts +2 -0
  318. package/dist/services/final-review/index.js +1 -0
  319. package/dist/services/hooks/auto-compact-hook-install.d.ts +4 -5
  320. package/dist/services/hooks/auto-compact-hook-install.js +4 -5
  321. package/dist/services/hooks/worktree-authorization-gate.d.ts +205 -0
  322. package/dist/services/hooks/worktree-authorization-gate.js +492 -0
  323. package/dist/services/ide/adapters/claude-code-adapter.js +2 -2
  324. package/dist/services/ide/adapters/qoder-adapter.d.ts +25 -0
  325. package/dist/services/ide/adapters/qoder-adapter.js +57 -0
  326. package/dist/services/ide/adapters/tongyi-lingma-adapter.d.ts +16 -0
  327. package/dist/services/ide/adapters/tongyi-lingma-adapter.js +45 -0
  328. package/dist/services/ide/ide-registry.js +6 -0
  329. package/dist/services/ide/ide-types.d.ts +1 -1
  330. package/dist/services/job/job-types.d.ts +56 -56
  331. package/dist/services/job-snapshot/index.d.ts +8 -0
  332. package/dist/services/job-snapshot/index.js +7 -0
  333. package/dist/services/{job/job-resource-snapshot.d.ts → job-snapshot/snapshot.d.ts} +1 -1
  334. package/dist/services/job-snapshot/types.d.ts +7 -0
  335. package/dist/services/job-snapshot/types.js +1 -0
  336. package/dist/services/karpathy-cost/karpathy-cost-check-service.d.ts +67 -0
  337. package/dist/services/karpathy-cost/karpathy-cost-check-service.js +108 -0
  338. package/dist/services/log/retention.d.ts +16 -0
  339. package/dist/services/log/retention.js +17 -0
  340. package/dist/services/loop/loop-bee-relation-types.d.ts +6 -6
  341. package/dist/services/loop/loop-release-types.d.ts +24 -24
  342. package/dist/services/loop/monotonic-runner.d.ts +17 -11
  343. package/dist/services/loop/monotonic-runner.js +118 -79
  344. package/dist/services/memory/project-memory-service/index/kind-dispatch.d.ts +8 -0
  345. package/dist/services/memory/project-memory-service/index/kind-dispatch.js +253 -0
  346. package/dist/services/memory/project-memory-service/index/ranking.d.ts +6 -0
  347. package/dist/services/memory/project-memory-service/index/ranking.js +171 -0
  348. package/dist/services/memory/project-memory-service/index/search.d.ts +34 -0
  349. package/dist/services/memory/project-memory-service/index/search.js +194 -0
  350. package/dist/services/memory/project-memory-service/index.d.ts +9 -0
  351. package/dist/services/memory/project-memory-service/index.js +24 -0
  352. package/dist/services/memory/project-memory-service/parsers/frontmatter.d.ts +9 -0
  353. package/dist/services/memory/project-memory-service/parsers/frontmatter.js +106 -0
  354. package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +7 -0
  355. package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +96 -0
  356. package/dist/services/memory/project-memory-service/store/atomic-write.d.ts +5 -0
  357. package/dist/services/memory/project-memory-service/store/atomic-write.js +56 -0
  358. package/dist/services/memory/project-memory-service/store/paths.d.ts +8 -0
  359. package/dist/services/memory/project-memory-service/store/paths.js +116 -0
  360. package/dist/services/memory/project-memory-service/types.d.ts +128 -0
  361. package/dist/services/memory/project-memory-service/types.js +9 -0
  362. package/dist/services/memory/project-memory-service.d.ts +1 -167
  363. package/dist/services/memory/project-memory-service.js +19 -816
  364. package/dist/services/migrate-skill-name/schema.d.ts +2 -2
  365. package/dist/services/observability/aggregation.d.ts +27 -0
  366. package/dist/services/observability/aggregation.js +72 -0
  367. package/dist/services/observability/observability-service.d.ts +73 -7
  368. package/dist/services/observability/observability-service.js +87 -1
  369. package/dist/services/openspec/artifact-boundary.d.ts +138 -0
  370. package/dist/services/openspec/artifact-boundary.js +150 -0
  371. package/dist/services/openspec/coverage-evidence-reader.d.ts +191 -0
  372. package/dist/services/openspec/coverage-evidence-reader.js +386 -0
  373. package/dist/services/openspec/openspec-archive-service.d.ts +70 -0
  374. package/dist/services/openspec/openspec-archive-service.js +320 -8
  375. package/dist/services/openspec/openspec-bridge-service.js +1 -1
  376. package/dist/services/openspec/openspec-init-service.js +1 -1
  377. package/dist/services/openspec/openspec-propose-from-doctor-service.js +1 -1
  378. package/dist/services/openspec/openspec-render-service.js +7 -4
  379. package/dist/services/openspec/openspec-scan-service.js +1 -1
  380. package/dist/services/openspec/openspec-validate-service.js +5 -4
  381. package/dist/services/preferences/preferences-service.js +10 -0
  382. package/dist/services/preferences/preferences-types.d.ts +13 -0
  383. package/dist/services/preferences/preferences-types.js +11 -0
  384. package/dist/services/qa/screenshot-archive-service.d.ts +51 -0
  385. package/dist/services/qa/screenshot-archive-service.js +134 -0
  386. package/dist/services/rd/rd-service.js +10 -11
  387. package/dist/services/rd/types.d.ts +32 -32
  388. package/dist/services/rd-swarm/rd-swarm-service.d.ts +60 -0
  389. package/dist/services/rd-swarm/rd-swarm-service.js +93 -0
  390. package/dist/services/recommendations/capability-seed-items.js +0 -1
  391. package/dist/services/recommendations/capability-seed-mappings.js +0 -1
  392. package/dist/services/recommendations/capability-seed-sources.js +0 -1
  393. package/dist/services/release/version-precheck-service.d.ts +51 -0
  394. package/dist/services/release/version-precheck-service.js +257 -0
  395. package/dist/services/scan/acceptance-coverage-service.js +1 -1
  396. package/dist/services/scan/archetype-service.js +1 -1
  397. package/dist/services/scan/existing-system-service.js +1 -1
  398. package/dist/services/scan/libraries-service.js +1 -1
  399. package/dist/services/sediment/json-schema.d.ts +40 -40
  400. package/dist/services/share/bundle-types.d.ts +12 -12
  401. package/dist/services/share/run-state-contract.d.ts +2 -2
  402. package/dist/services/skill/skill-search-service.d.ts +12 -7
  403. package/dist/services/skill/skill-search-service.js +8 -4
  404. package/dist/services/skillhub/migrations/001-initial.sql +71 -0
  405. package/dist/services/skillhub/migrations/002-loop-release.sql +32 -0
  406. package/dist/services/skillhub/migrations/003-loop-bee-relation.sql +35 -0
  407. package/dist/services/skillhub/migrations/004-loop-bee-extension.sql +65 -0
  408. package/dist/services/skillhub/migrations/005-evolution-evaluation.sql +81 -0
  409. package/dist/services/skillhub/migrations/006-crystallization-event.sql +92 -0
  410. package/dist/services/skills/hooks-settings-service.d.ts +75 -0
  411. package/dist/services/skills/hooks-settings-service.js +230 -2
  412. package/dist/services/skills/skill-registry.d.ts +1 -0
  413. package/dist/services/skills/skill-registry.js +6 -4
  414. package/dist/services/skills/skill-runbook-service.js +1 -1
  415. package/dist/services/slice/slice-check-service.js +1 -1
  416. package/dist/services/standards/main-session-monitor-ban-hook.d.ts +14 -0
  417. package/dist/services/standards/main-session-monitor-ban-hook.js +19 -0
  418. package/dist/services/standards/missing-standards-detector.d.ts +25 -0
  419. package/dist/services/standards/missing-standards-detector.js +43 -12
  420. package/dist/services/tech/tech-change-id-service.d.ts +82 -0
  421. package/dist/services/tech/tech-change-id-service.js +117 -0
  422. package/dist/services/understand/understand-hybrid-service.js +1 -1
  423. package/dist/services/understand/understand-scan-service.js +2 -2
  424. package/dist/services/upgrade/upgrade-service.js +4 -3
  425. package/dist/services/verdict/envelopes.d.ts +2 -2
  426. package/dist/services/verdict/envelopes.js +2 -2
  427. package/dist/services/verdict/verdict-aggregator.d.ts +3 -3
  428. package/dist/services/vm/vm-lease.d.ts +40 -0
  429. package/dist/services/vm/vm-lease.js +137 -0
  430. package/dist/services/workflow/autonomous-resume-writer.js +1 -1
  431. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +47 -0
  432. package/dist/services/workflow/pipeline-verify-gate-support.js +194 -0
  433. package/dist/services/workflow/pipeline-verify-service.d.ts +17 -81
  434. package/dist/services/workflow/pipeline-verify-service.js +42 -218
  435. package/dist/services/workflow/pipeline-verify-types.d.ts +90 -0
  436. package/dist/services/workflow/pipeline-verify-types.js +10 -0
  437. package/dist/services/workflow/plan-reader.d.ts +1 -1
  438. package/dist/services/workflow/plan-reader.js +1 -1
  439. package/dist/services/workflow/plan-refresher.d.ts +1 -1
  440. package/dist/services/workflow/plan-refresher.js +1 -1
  441. package/dist/services/workflow/plan-trigger-detector.d.ts +1 -1
  442. package/dist/services/workflow/plan-trigger-detector.js +1 -1
  443. package/dist/services/workflow/workflow-autonomous-resume-helpers.d.ts +1 -1
  444. package/dist/services/workflow/workflow-autonomous-service.d.ts +2 -98
  445. package/dist/services/workflow/workflow-autonomous-types.d.ts +114 -0
  446. package/dist/services/workflow/workflow-autonomous-types.js +21 -0
  447. package/dist/services/workflow/workflow-router-service.js +18 -16
  448. package/dist/services/workflow/workflow-spec-lint.d.ts +13 -0
  449. package/dist/services/workflow/workflow-spec-lint.js +75 -0
  450. package/dist/services/workflow/workflow-spec-types.d.ts +100 -0
  451. package/dist/services/workflow/workflow-spec-types.js +13 -0
  452. package/dist/services/workflow/workflow-spec-yaml.d.ts +17 -0
  453. package/dist/services/workflow/workflow-spec-yaml.js +88 -0
  454. package/dist/services/workflow/workflow-spec.d.ts +11 -91
  455. package/dist/services/workflow/workflow-spec.js +16 -145
  456. package/dist/services/workspace/migrate-service.js +1 -1
  457. package/dist/services/workspace/workspace-service.js +1 -1
  458. package/dist/services/worktree/worktree-lease.d.ts +170 -0
  459. package/dist/services/worktree/worktree-lease.js +242 -0
  460. package/package.json +47 -51
  461. package/scripts/clean-dist.mjs +31 -1
  462. package/scripts/copy-templates.mjs +16 -0
  463. package/scripts/sync-version.mjs +53 -2
  464. package/skills/bee/peaks-perf-audit/SKILL.md +17 -0
  465. package/skills/bee/peaks-prd/SKILL.md +16 -0
  466. package/skills/bee/peaks-prd/test-prompts.json +12 -0
  467. package/skills/bee/peaks-qa/SKILL.md +16 -1
  468. package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +22 -0
  469. package/skills/bee/peaks-qa/test-prompts.json +12 -0
  470. package/skills/bee/peaks-rd/SKILL.md +29 -20
  471. package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +39 -0
  472. package/skills/bee/peaks-rd/test-prompts.json +12 -0
  473. package/skills/bee/peaks-reviewer/SKILL.md +17 -0
  474. package/skills/bee/peaks-sc/SKILL.md +16 -0
  475. package/skills/bee/peaks-security-audit/SKILL.md +17 -0
  476. package/skills/bee/peaks-txt/SKILL.md +16 -0
  477. package/skills/bee/peaks-txt/test-prompts.json +12 -0
  478. package/skills/bee/peaks-ui/SKILL.md +49 -43
  479. package/skills/bee/peaks-ui/test-prompts.json +12 -0
  480. package/skills/peaks-code/SKILL.md +54 -109
  481. package/skills/peaks-code/references/boundaries.md +15 -1
  482. package/skills/peaks-code/references/cron-scheduler-deployment.md +313 -0
  483. package/skills/peaks-code/references/external-skill-invocation.md +27 -0
  484. package/skills/peaks-code/references/lease-dashboard.html +224 -0
  485. package/skills/peaks-code/references/lease-stats.sample.json +26 -0
  486. package/skills/peaks-code/references/peaks-worktree-l2-enforcers.md +208 -0
  487. package/skills/peaks-code/references/periodic-checkpoint.md +4 -4
  488. package/skills/peaks-code/references/runbook.md +63 -1
  489. package/skills/peaks-code/references/startup-sequence.md +110 -0
  490. package/skills/peaks-code/references/step-0-8-gate.md +1 -1
  491. package/skills/peaks-code/references/sub-agent-dispatch.md +92 -1
  492. package/skills/peaks-code/references/worktree-governance.md +123 -0
  493. package/skills/peaks-code/test-prompts.json +12 -0
  494. package/skills/peaks-doctor/SKILL.md +1 -1
  495. package/skills/peaks-ide/SKILL.md +1 -1
  496. package/skills/peaks-solo/SKILL.md +21 -0
  497. package/skills/peaks-solo/references/triage-decision-table.md +6 -0
  498. package/skills/peaks-sop/test-prompts.json +17 -0
  499. package/dist/cli/commands/agent-commands.d.ts +0 -20
  500. package/dist/cli/commands/agent-commands.js +0 -48
  501. package/dist/cli/commands/classify-classify-commands.d.ts +0 -19
  502. package/dist/cli/commands/classify-classify-commands.js +0 -151
  503. package/dist/cli/commands/contract-commands.d.ts +0 -26
  504. package/dist/cli/commands/contract-commands.js +0 -114
  505. package/dist/cli/commands/session-auto-compact-hook-command.d.ts +0 -37
  506. package/dist/cli/commands/session-auto-compact-hook-command.js +0 -127
  507. package/dist/cli/commands/worker-commands.d.ts +0 -3
  508. package/dist/cli/commands/worker-commands.js +0 -52
  509. package/dist/services/agent/ecc-agent-service.d.ts +0 -47
  510. package/dist/services/agent/ecc-agent-service.js +0 -143
  511. package/dist/services/config/provider-service.d.ts +0 -48
  512. package/dist/services/config/provider-service.js +0 -143
  513. package/dist/services/context/dispatch-context-guard.d.ts +0 -27
  514. package/dist/services/context/dispatch-context-guard.js +0 -192
  515. package/dist/services/context/shared-channel.d.ts +0 -93
  516. package/dist/services/context/shared-channel.js +0 -308
  517. package/dist/services/filesystem/file-lock.d.ts +0 -11
  518. package/dist/services/filesystem/file-lock.js +0 -152
  519. package/dist/services/mut/assert-scanner.d.ts +0 -6
  520. package/dist/services/mut/assert-scanner.js +0 -116
  521. package/dist/services/mut/index.d.ts +0 -8
  522. package/dist/services/mut/index.js +0 -7
  523. package/dist/services/mut/mut-runner.d.ts +0 -39
  524. package/dist/services/mut/mut-runner.js +0 -29
  525. package/dist/services/mut/production-stryker.d.ts +0 -2
  526. package/dist/services/mut/production-stryker.js +0 -75
  527. package/dist/services/mut/report-builder.d.ts +0 -11
  528. package/dist/services/mut/report-builder.js +0 -110
  529. package/dist/services/mut/report-loader.d.ts +0 -31
  530. package/dist/services/mut/report-loader.js +0 -78
  531. package/dist/services/mut/thresholds.d.ts +0 -21
  532. package/dist/services/mut/thresholds.js +0 -22
  533. package/dist/services/mut/types.d.ts +0 -336
  534. package/dist/services/mut/types.js +0 -59
  535. package/dist/services/providers/minimax-provider-service.d.ts +0 -24
  536. package/dist/services/providers/minimax-provider-service.js +0 -143
  537. package/dist/services/providers/minimax-worker-service.d.ts +0 -21
  538. package/dist/services/providers/minimax-worker-service.js +0 -83
  539. package/dist/shared/fs.d.ts +0 -4
  540. package/dist/shared/fs.js +0 -26
  541. package/dist/shared/paths.d.ts +0 -6
  542. package/dist/shared/paths.js +0 -50
  543. package/dist/shared/result.d.ts +0 -22
  544. package/dist/shared/result.js +0 -46
  545. package/dist/shared/version.d.ts +0 -1
  546. package/dist/shared/version.js +0 -1
  547. package/examples/video-demo/README.md +0 -142
  548. package/examples/video-demo/out/en-closing-960.png +0 -0
  549. package/examples/video-demo/out/zh-closing-960.png +0 -0
  550. package/examples/video-demo/preview/peaks-loop-demo-en.mp4 +0 -0
  551. package/examples/video-demo/preview/peaks-loop-demo.mp4 +0 -0
  552. /package/dist/services/{job/job-resource-snapshot.js → job-snapshot/snapshot.js} +0 -0
@@ -23,16 +23,16 @@ export declare const MigrateResultSchema: z.ZodObject<{
23
23
  skipped: z.ZodArray<z.ZodString, "many">;
24
24
  errors: z.ZodArray<z.ZodString, "many">;
25
25
  }, "strip", z.ZodTypeAny, {
26
- ok: boolean;
27
26
  skipped: string[];
27
+ ok: boolean;
28
28
  scannedFiles: number;
29
29
  modifiedFiles: number;
30
30
  keyValueReplacements: number;
31
31
  stringReplacements: number;
32
32
  errors: string[];
33
33
  }, {
34
- ok: boolean;
35
34
  skipped: string[];
35
+ ok: boolean;
36
36
  scannedFiles: number;
37
37
  modifiedFiles: number;
38
38
  keyValueReplacements: number;
@@ -62,3 +62,30 @@ export declare function periodStartIso(period: Period, now?: () => Date): string
62
62
  export declare function filterByPeriod(events: readonly ObservabilityEvent[], period: Period, now?: () => Date): ObservabilityEvent[];
63
63
  export declare function readAllSessionEvents(projectRoot: string): ObservabilityEvent[];
64
64
  export declare function readSessionEvents(projectRoot: string, sessionId: string): ObservabilityEvent[];
65
+ /**
66
+ * Cumulative 5-metric surface for the `peaks dashboard summary` CLI.
67
+ * All values are derived from raw observability events (per-event
68
+ * counting), not from state files — semantics differ from
69
+ * `peaks dashboard long-run`, which derives indicators from
70
+ * `.peaks/_runtime/<sid>/24h-state.json`.
71
+ */
72
+ export type DashboardMetrics = {
73
+ readonly cycleCount: number;
74
+ readonly tokenCount: number;
75
+ readonly dispatchCount: number;
76
+ readonly compactCount: number;
77
+ readonly monotonicTriggerCount: number;
78
+ };
79
+ /**
80
+ * Aggregate the 5 dashboard metric classes for a single session, filtered
81
+ * to events with `ts >= since`. Events with unparseable timestamps are
82
+ * counted (best-effort, mirrors `readObservabilityEvents` behavior). The
83
+ * `token-usage` total is summed from `detail.totalTokens` (falling back to
84
+ * `inputTokens + outputTokens` when the aggregate field is missing).
85
+ */
86
+ export declare function aggregateDashboardMetrics(projectRoot: string, sessionId: string, since: Date): DashboardMetrics;
87
+ /**
88
+ * Pure-function variant used by tests: counts across an already-loaded
89
+ * event list. `since` may be null to count everything.
90
+ */
91
+ export declare function aggregateDashboardMetricsFromEvents(events: readonly ObservabilityEvent[], since?: Date | null): DashboardMetrics;
@@ -215,3 +215,75 @@ export function readAllSessionEvents(projectRoot) {
215
215
  export function readSessionEvents(projectRoot, sessionId) {
216
216
  return readObservabilityEvents(projectRoot, sessionId);
217
217
  }
218
+ /**
219
+ * Aggregate the 5 dashboard metric classes for a single session, filtered
220
+ * to events with `ts >= since`. Events with unparseable timestamps are
221
+ * counted (best-effort, mirrors `readObservabilityEvents` behavior). The
222
+ * `token-usage` total is summed from `detail.totalTokens` (falling back to
223
+ * `inputTokens + outputTokens` when the aggregate field is missing).
224
+ */
225
+ export function aggregateDashboardMetrics(projectRoot, sessionId, since) {
226
+ const events = readObservabilityEvents(projectRoot, sessionId);
227
+ const cutoff = since.getTime();
228
+ let cycleCount = 0;
229
+ let tokenCount = 0;
230
+ let dispatchCount = 0;
231
+ let compactCount = 0;
232
+ let monotonicTriggerCount = 0;
233
+ for (const event of events) {
234
+ const ts = Date.parse(event.ts);
235
+ if (Number.isFinite(cutoff) && Number.isFinite(ts) && ts < cutoff)
236
+ continue;
237
+ if (event.category === 'cycle')
238
+ cycleCount += 1;
239
+ else if (event.category === 'token-usage') {
240
+ const detail = event.detail;
241
+ const t = typeof detail.totalTokens === 'number'
242
+ ? detail.totalTokens
243
+ : (typeof detail.inputTokens === 'number' ? detail.inputTokens : 0)
244
+ + (typeof detail.outputTokens === 'number' ? detail.outputTokens : 0);
245
+ tokenCount += t;
246
+ }
247
+ else if (event.category === 'dispatch')
248
+ dispatchCount += 1;
249
+ else if (event.category === 'post-compact')
250
+ compactCount += 1;
251
+ else if (event.category === 'monotonic-trigger')
252
+ monotonicTriggerCount += 1;
253
+ }
254
+ return { cycleCount, tokenCount, dispatchCount, compactCount, monotonicTriggerCount };
255
+ }
256
+ /**
257
+ * Pure-function variant used by tests: counts across an already-loaded
258
+ * event list. `since` may be null to count everything.
259
+ */
260
+ export function aggregateDashboardMetricsFromEvents(events, since = null) {
261
+ const cutoff = since?.getTime() ?? null;
262
+ let cycleCount = 0;
263
+ let tokenCount = 0;
264
+ let dispatchCount = 0;
265
+ let compactCount = 0;
266
+ let monotonicTriggerCount = 0;
267
+ for (const event of events) {
268
+ const ts = Date.parse(event.ts);
269
+ if (cutoff !== null && Number.isFinite(ts) && ts < cutoff)
270
+ continue;
271
+ if (event.category === 'cycle')
272
+ cycleCount += 1;
273
+ else if (event.category === 'token-usage') {
274
+ const detail = event.detail;
275
+ const t = typeof detail.totalTokens === 'number'
276
+ ? detail.totalTokens
277
+ : (typeof detail.inputTokens === 'number' ? detail.inputTokens : 0)
278
+ + (typeof detail.outputTokens === 'number' ? detail.outputTokens : 0);
279
+ tokenCount += t;
280
+ }
281
+ else if (event.category === 'dispatch')
282
+ dispatchCount += 1;
283
+ else if (event.category === 'post-compact')
284
+ compactCount += 1;
285
+ else if (event.category === 'monotonic-trigger')
286
+ monotonicTriggerCount += 1;
287
+ }
288
+ return { cycleCount, tokenCount, dispatchCount, compactCount, monotonicTriggerCount };
289
+ }
@@ -20,7 +20,7 @@
20
20
  */
21
21
  import { z } from 'zod';
22
22
  export declare const OBSERVABILITY_SCHEMA_VERSION: 1;
23
- export declare const OBSERVABILITY_CATEGORIES: readonly ["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact"];
23
+ export declare const OBSERVABILITY_CATEGORIES: readonly ["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact", "cycle", "token-usage", "monotonic-trigger", "lease"];
24
24
  export type ObservabilityCategory = typeof OBSERVABILITY_CATEGORIES[number];
25
25
  export declare const OBSERVABILITY_SUBAGENT_ROLES: readonly ["rd", "qa", "code-reviewer", "karpathy-reviewer", "peaks-security-audit", "peaks-perf-audit"];
26
26
  export type ObservabilitySubagentRole = typeof OBSERVABILITY_SUBAGENT_ROLES[number];
@@ -28,24 +28,24 @@ export declare const ObservabilityEventSchema: z.ZodObject<{
28
28
  schemaVersion: z.ZodLiteral<1>;
29
29
  ts: z.ZodString;
30
30
  sessionId: z.ZodString;
31
- category: z.ZodEnum<["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact"]>;
31
+ category: z.ZodEnum<["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact", "cycle", "token-usage", "monotonic-trigger", "lease"]>;
32
32
  sliceRid: z.ZodOptional<z.ZodString>;
33
33
  role: z.ZodOptional<z.ZodEnum<["rd", "qa", "code-reviewer", "karpathy-reviewer", "peaks-security-audit", "peaks-perf-audit"]>>;
34
34
  detail: z.ZodRecord<z.ZodString, z.ZodUnknown>;
35
35
  }, "strip", z.ZodTypeAny, {
36
36
  sessionId: string;
37
+ detail: Record<string, unknown>;
37
38
  schemaVersion: 1;
38
39
  ts: string;
39
- category: "slice-transition" | "dispatch" | "checkpoint" | "mode-gate" | "context-trigger" | "post-compact";
40
- detail: Record<string, unknown>;
40
+ category: "slice-transition" | "dispatch" | "checkpoint" | "mode-gate" | "context-trigger" | "post-compact" | "cycle" | "token-usage" | "monotonic-trigger" | "lease";
41
41
  role?: "qa" | "rd" | "code-reviewer" | "karpathy-reviewer" | "peaks-security-audit" | "peaks-perf-audit" | undefined;
42
42
  sliceRid?: string | undefined;
43
43
  }, {
44
44
  sessionId: string;
45
+ detail: Record<string, unknown>;
45
46
  schemaVersion: 1;
46
47
  ts: string;
47
- category: "slice-transition" | "dispatch" | "checkpoint" | "mode-gate" | "context-trigger" | "post-compact";
48
- detail: Record<string, unknown>;
48
+ category: "slice-transition" | "dispatch" | "checkpoint" | "mode-gate" | "context-trigger" | "post-compact" | "cycle" | "token-usage" | "monotonic-trigger" | "lease";
49
49
  role?: "qa" | "rd" | "code-reviewer" | "karpathy-reviewer" | "peaks-security-audit" | "peaks-perf-audit" | undefined;
50
50
  sliceRid?: string | undefined;
51
51
  }>;
@@ -90,6 +90,72 @@ export declare function readObservabilityEvents(projectRoot: string, sessionId:
90
90
  export declare function isCurrentSchemaVersion(record: unknown): record is ObservabilityEvent;
91
91
  export declare const OBSERVABILITY_CONSTANTS: {
92
92
  readonly SCHEMA_VERSION: 1;
93
- readonly CATEGORIES: readonly ["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact"];
93
+ readonly CATEGORIES: readonly ["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact", "cycle", "token-usage", "monotonic-trigger", "lease"];
94
94
  readonly SUBAGENT_ROLES: readonly ["rd", "qa", "code-reviewer", "karpathy-reviewer", "peaks-security-audit", "peaks-perf-audit"];
95
95
  };
96
+ /**
97
+ * Slice 2026-07-29-worktree-l2-extended Part 4.A: lease lifecycle
98
+ * observability. Each `peaks worktree spawn / renew / release /
99
+ * gc` CLI emits a `lease` event; the auto-release hook in
100
+ * dispatch finalization emits `autoRelease` (success) or
101
+ * `autoRelease-failed` (detached spawn failed). The
102
+ * `peaks lease metrics --json` reader aggregates these for the
103
+ * dashboard.
104
+ *
105
+ * Fire-and-forget by contract (mirrors emitCycleEvent /
106
+ * emitTokenUsageEvent): never throws, written=false on schema
107
+ * mismatch or IO failure. Callers do not inspect the result.
108
+ */
109
+ export type LeaseEventKind = 'spawn' | 'renew' | 'release' | 'gc' | 'autoRelease' | 'autoRelease-failed' | 'autoRelease-skipped';
110
+ export declare function emitLeaseEvent(opts: {
111
+ sessionId: string;
112
+ projectRoot: string;
113
+ kind: LeaseEventKind;
114
+ leaseId: string;
115
+ rid?: string;
116
+ role?: string;
117
+ /** Reason the autoRelease was skipped (e.g. "no-lease", "non-terminal-status"). */
118
+ reason?: string;
119
+ }): EmitResult;
120
+ /**
121
+ * rid-030 F-direction: per-cycle event (cycle started / completed / failed).
122
+ * Fire-and-forget; never throws. Tagging `kind` for downstream dashboards.
123
+ */
124
+ export declare function emitCycleEvent(opts: {
125
+ sessionId: string;
126
+ projectRoot: string;
127
+ cycle: number;
128
+ status: 'started' | 'completed' | 'failed';
129
+ }): EmitResult;
130
+ /**
131
+ * rid-030 F-direction: per-token-usage event. `totalTokens` is the
132
+ * sum the dashboard cares about; `inputTokens`/`outputTokens` are kept
133
+ * for downstream drill-down.
134
+ */
135
+ export declare function emitTokenUsageEvent(opts: {
136
+ sessionId: string;
137
+ projectRoot: string;
138
+ inputTokens: number;
139
+ outputTokens: number;
140
+ }): EmitResult;
141
+ /**
142
+ * rid-030 F-direction: per-monotonic-trigger event.
143
+ */
144
+ export declare function emitMonotonicTriggerEvent(opts: {
145
+ sessionId: string;
146
+ projectRoot: string;
147
+ report: 'pass' | 'warn' | 'block';
148
+ action: string;
149
+ }): EmitResult;
150
+ /**
151
+ * rid-030 F-direction: per-subagent-dispatch event. Reuses the
152
+ * existing `dispatch` category (rd/qa/reviewer/audit). Provides a
153
+ * canonical emit helper so dashboards don't have to hand-author the
154
+ * `ObservabilityEvent` envelope.
155
+ */
156
+ export declare function emitDispatchEvent(opts: {
157
+ sessionId: string;
158
+ projectRoot: string;
159
+ role: ObservabilitySubagentRole;
160
+ status?: 'queued' | 'running' | 'done' | 'failed';
161
+ }): EmitResult;
@@ -27,7 +27,17 @@ export const OBSERVABILITY_CATEGORIES = [
27
27
  'checkpoint',
28
28
  'mode-gate',
29
29
  'context-trigger',
30
- 'post-compact'
30
+ 'post-compact',
31
+ 'cycle',
32
+ 'token-usage',
33
+ 'monotonic-trigger',
34
+ // Slice 2026-07-29-worktree-l2-extended Part 4.A: lease lifecycle
35
+ // metrics. Emitted by `peaks worktree spawn / renew / release /
36
+ // gc` and by the auto-release hook in dispatch finalization (Part
37
+ // 3.A). Read by `peaks lease metrics`. The `detail.kind` field
38
+ // discriminates spawn / renew / release / gc / autoRelease /
39
+ // autoRelease-failed / autoRelease-skipped.
40
+ 'lease'
31
41
  ];
32
42
  // v2.12.0 fan-out collapse: `security-reviewer` (in-process RD slot)
33
43
  // moved out to the standalone `peaks-security-audit` skill; the matching
@@ -117,3 +127,79 @@ export const OBSERVABILITY_CONSTANTS = {
117
127
  CATEGORIES: OBSERVABILITY_CATEGORIES,
118
128
  SUBAGENT_ROLES: OBSERVABILITY_SUBAGENT_ROLES
119
129
  };
130
+ export function emitLeaseEvent(opts) {
131
+ const detail = { kind: opts.kind, leaseId: opts.leaseId };
132
+ if (opts.rid !== undefined)
133
+ detail['rid'] = opts.rid;
134
+ if (opts.role !== undefined)
135
+ detail['role'] = opts.role;
136
+ if (opts.reason !== undefined)
137
+ detail['reason'] = opts.reason;
138
+ return emitObservabilityEvent({
139
+ schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
140
+ ts: new Date().toISOString(),
141
+ sessionId: opts.sessionId,
142
+ category: 'lease',
143
+ detail
144
+ }, { projectRoot: opts.projectRoot });
145
+ }
146
+ /**
147
+ * rid-030 F-direction: per-cycle event (cycle started / completed / failed).
148
+ * Fire-and-forget; never throws. Tagging `kind` for downstream dashboards.
149
+ */
150
+ export function emitCycleEvent(opts) {
151
+ return emitObservabilityEvent({
152
+ schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
153
+ ts: new Date().toISOString(),
154
+ sessionId: opts.sessionId,
155
+ category: 'cycle',
156
+ detail: { cycle: opts.cycle, status: opts.status }
157
+ }, { projectRoot: opts.projectRoot });
158
+ }
159
+ /**
160
+ * rid-030 F-direction: per-token-usage event. `totalTokens` is the
161
+ * sum the dashboard cares about; `inputTokens`/`outputTokens` are kept
162
+ * for downstream drill-down.
163
+ */
164
+ export function emitTokenUsageEvent(opts) {
165
+ const totalTokens = Math.max(0, opts.inputTokens) + Math.max(0, opts.outputTokens);
166
+ return emitObservabilityEvent({
167
+ schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
168
+ ts: new Date().toISOString(),
169
+ sessionId: opts.sessionId,
170
+ category: 'token-usage',
171
+ detail: {
172
+ inputTokens: opts.inputTokens,
173
+ outputTokens: opts.outputTokens,
174
+ totalTokens
175
+ }
176
+ }, { projectRoot: opts.projectRoot });
177
+ }
178
+ /**
179
+ * rid-030 F-direction: per-monotonic-trigger event.
180
+ */
181
+ export function emitMonotonicTriggerEvent(opts) {
182
+ return emitObservabilityEvent({
183
+ schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
184
+ ts: new Date().toISOString(),
185
+ sessionId: opts.sessionId,
186
+ category: 'monotonic-trigger',
187
+ detail: { report: opts.report, action: opts.action }
188
+ }, { projectRoot: opts.projectRoot });
189
+ }
190
+ /**
191
+ * rid-030 F-direction: per-subagent-dispatch event. Reuses the
192
+ * existing `dispatch` category (rd/qa/reviewer/audit). Provides a
193
+ * canonical emit helper so dashboards don't have to hand-author the
194
+ * `ObservabilityEvent` envelope.
195
+ */
196
+ export function emitDispatchEvent(opts) {
197
+ return emitObservabilityEvent({
198
+ schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
199
+ ts: new Date().toISOString(),
200
+ sessionId: opts.sessionId,
201
+ category: 'dispatch',
202
+ role: opts.role,
203
+ detail: { status: opts.status ?? 'done' }
204
+ }, { projectRoot: opts.projectRoot });
205
+ }
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Artifact boundary helpers for peaks-loop.
3
+ *
4
+ * Slice rid-009:
5
+ * - sub-slice 1: change-id validation (`validateChangeId`).
6
+ * - sub-slice 2: artifact path planning (`planArtifactPath` + `isPathInsideArtifactRoot` re-export).
7
+ * - sub-slice 3: workspace-unavailable response (`buildWorkspaceUnavailable`).
8
+ *
9
+ * The colocated single-file layout avoids creating two competing path-safety
10
+ * layers — `src/shared/path-safety.ts` already owns the primitive
11
+ * `isPathInsideArtifactRoot` which we re-export unchanged.
12
+ *
13
+ * Conventions:
14
+ * - `Result<T, E>` is hand-rolled in this file (no `neverthrow` dep).
15
+ * - All errors are typed unions — no thrown exceptions for validation.
16
+ * - The change-id format mirrors the pre-existing
17
+ * `[A-Za-z0-9][A-Za-z0-9._-]*` regex used by
18
+ * `openspec-validate-service.ts` so the refactor (task 3) preserves
19
+ * the exact error message byte-for-byte.
20
+ * - Path planning uses `posix.normalize` to keep semantics stable across
21
+ * win32/posix runners; JSON output always uses `/`.
22
+ */
23
+ import { isPathInsideArtifactRoot as _isPathInsideArtifactRoot } from '../../shared/path-safety.js';
24
+ export type Result<T, E> = {
25
+ ok: true;
26
+ value: T;
27
+ } | {
28
+ ok: false;
29
+ error: E;
30
+ };
31
+ export declare function ok<T>(value: T): Result<T, never>;
32
+ export declare function err<E>(error: E): Result<never, E>;
33
+ export declare function isOk<T, E>(result: Result<T, E>): result is {
34
+ ok: true;
35
+ value: T;
36
+ };
37
+ export type ChangeIdError = {
38
+ code: 'change-id-empty';
39
+ message: string;
40
+ } | {
41
+ code: 'change-id-format';
42
+ message: string;
43
+ } | {
44
+ code: 'change-id-reserved';
45
+ message: string;
46
+ };
47
+ export type BoundaryError = ChangeIdError | {
48
+ code: 'workspace-unconfigured';
49
+ message: string;
50
+ } | {
51
+ code: 'path-outside-artifact-root';
52
+ path: string;
53
+ root: string;
54
+ message: string;
55
+ } | {
56
+ code: 'unsafe-path-input';
57
+ message: string;
58
+ };
59
+ /**
60
+ * Validate a change-id string. Returns a typed `Result`; the error code
61
+ * distinguishes "empty" / "format" / "reserved" so callers can branch on
62
+ * the cause without re-parsing the message.
63
+ *
64
+ * Acceptance contract (rid-009 §3.3.1, task 1):
65
+ * - accepts `[A-Za-z0-9][A-Za-z0-9._-]*` (existing regex semantics)
66
+ * - rejects empty string with `change-id-empty`
67
+ * - rejects `.` and `..` with `change-id-reserved`
68
+ * - rejects everything else that does not match the regex with
69
+ * `change-id-format`
70
+ *
71
+ * The format-error message is byte-for-byte identical to the pre-refactor
72
+ * string produced at `openspec-validate-service.ts:55` so existing
73
+ * `OpenSpecValidationIssue` consumers do not break.
74
+ */
75
+ export declare function validateChangeId(id: string): Result<{
76
+ changeId: string;
77
+ }, ChangeIdError>;
78
+ /**
79
+ * Re-export of `src/shared/path-safety.ts#isPathInsideArtifactRoot`.
80
+ *
81
+ * Single source of truth: the primitive is owned by `src/shared/path-safety.ts`;
82
+ * this module owns the *domain* helpers (change-id + path planner) that consume
83
+ * the primitive. Tests in `tests/unit/services/openspec/artifact-boundary.test.ts`
84
+ * exercise the RE-EXPORT wiring; the primitive's own correctness is covered by
85
+ * its native test file.
86
+ */
87
+ export { _isPathInsideArtifactRoot as isPathInsideArtifactRoot };
88
+ /**
89
+ * Input for `planArtifactPath`. The caller MUST supply `changeId`, `workspaceRoot`,
90
+ * `role`, and `requestId`. Exactly one of `absolutePath` or `relativePath` may be
91
+ * supplied; if neither is supplied, a default template `"<changeId>/<role>/<requestId>"`
92
+ * is used. `template` overrides the default placeholder substitution when both
93
+ * `absolutePath` and `relativePath` are absent.
94
+ */
95
+ export type PlanArtifactPathInput = {
96
+ changeId: string;
97
+ workspaceRoot: string;
98
+ role: string;
99
+ requestId: string;
100
+ absolutePath?: string;
101
+ relativePath?: string;
102
+ template?: string;
103
+ };
104
+ export type PlanArtifactPathOutput = {
105
+ absolutePath: string;
106
+ relativePath: string;
107
+ jsonSafeRelativePath: string;
108
+ };
109
+ /**
110
+ * Plan an artifact-relative path under the configured Peaks artifact workspace.
111
+ *
112
+ * Semantics (rid-009 §3.3.2, tasks 5–9):
113
+ * - Backslashes in the candidate path are normalized to forward slashes for
114
+ * JSON safety; empty segments (`foo//bar`) are collapsed by `posix.normalize`.
115
+ * - If the resolved absolute path is NOT contained under `workspaceRoot`
116
+ * (per `isPathInsideArtifactRoot`), returns
117
+ * `BoundaryError.path-outside-artifact-root` — NO silent fallback to cwd.
118
+ * - JSON output (`jsonSafeRelativePath`) ALWAYS uses `/` so it round-trips
119
+ * cleanly through `JSON.stringify` on Windows.
120
+ *
121
+ * Path math only — this helper never touches the filesystem, so it is fully
122
+ * hermetic and safe to call on paths that do not exist yet.
123
+ */
124
+ export declare function planArtifactPath(input: PlanArtifactPathInput): Result<PlanArtifactPathOutput, BoundaryError>;
125
+ export type WorkspaceUnavailableResponse = {
126
+ ok: false;
127
+ mode: 'preview-only' | 'blocked';
128
+ reason: 'artifact-workspace-unavailable';
129
+ nextActions: string[];
130
+ };
131
+ /**
132
+ * Build the explicit response used when no artifact workspace is configured.
133
+ * The next action is static natural language so callers can surface remediation
134
+ * without requiring the user to type a CLI command or hand-author data.
135
+ */
136
+ export declare function buildWorkspaceUnavailable(input: {
137
+ mode: WorkspaceUnavailableResponse['mode'];
138
+ }): WorkspaceUnavailableResponse;
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Artifact boundary helpers for peaks-loop.
3
+ *
4
+ * Slice rid-009:
5
+ * - sub-slice 1: change-id validation (`validateChangeId`).
6
+ * - sub-slice 2: artifact path planning (`planArtifactPath` + `isPathInsideArtifactRoot` re-export).
7
+ * - sub-slice 3: workspace-unavailable response (`buildWorkspaceUnavailable`).
8
+ *
9
+ * The colocated single-file layout avoids creating two competing path-safety
10
+ * layers — `src/shared/path-safety.ts` already owns the primitive
11
+ * `isPathInsideArtifactRoot` which we re-export unchanged.
12
+ *
13
+ * Conventions:
14
+ * - `Result<T, E>` is hand-rolled in this file (no `neverthrow` dep).
15
+ * - All errors are typed unions — no thrown exceptions for validation.
16
+ * - The change-id format mirrors the pre-existing
17
+ * `[A-Za-z0-9][A-Za-z0-9._-]*` regex used by
18
+ * `openspec-validate-service.ts` so the refactor (task 3) preserves
19
+ * the exact error message byte-for-byte.
20
+ * - Path planning uses `posix.normalize` to keep semantics stable across
21
+ * win32/posix runners; JSON output always uses `/`.
22
+ */
23
+ import { posix, relative, resolve, isAbsolute as nodeIsAbsolute } from 'node:path';
24
+ import { isPathInsideArtifactRoot as _isPathInsideArtifactRoot } from '../../shared/path-safety.js';
25
+ export function ok(value) {
26
+ return { ok: true, value };
27
+ }
28
+ export function err(error) {
29
+ return { ok: false, error };
30
+ }
31
+ export function isOk(result) {
32
+ return result.ok;
33
+ }
34
+ const CHANGE_ID_FORMAT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
35
+ /**
36
+ * Validate a change-id string. Returns a typed `Result`; the error code
37
+ * distinguishes "empty" / "format" / "reserved" so callers can branch on
38
+ * the cause without re-parsing the message.
39
+ *
40
+ * Acceptance contract (rid-009 §3.3.1, task 1):
41
+ * - accepts `[A-Za-z0-9][A-Za-z0-9._-]*` (existing regex semantics)
42
+ * - rejects empty string with `change-id-empty`
43
+ * - rejects `.` and `..` with `change-id-reserved`
44
+ * - rejects everything else that does not match the regex with
45
+ * `change-id-format`
46
+ *
47
+ * The format-error message is byte-for-byte identical to the pre-refactor
48
+ * string produced at `openspec-validate-service.ts:55` so existing
49
+ * `OpenSpecValidationIssue` consumers do not break.
50
+ */
51
+ export function validateChangeId(id) {
52
+ if (id === '') {
53
+ return err({ code: 'change-id-empty', message: 'changeId is empty' });
54
+ }
55
+ if (id === '.' || id === '..') {
56
+ return err({ code: 'change-id-reserved', message: `changeId ${id} is reserved` });
57
+ }
58
+ if (id.startsWith('.') || id.endsWith('.')) {
59
+ return err({
60
+ code: 'change-id-format',
61
+ message: `changeId ${id} does not match [A-Za-z0-9][A-Za-z0-9._-]*`
62
+ });
63
+ }
64
+ if (!CHANGE_ID_FORMAT_PATTERN.test(id)) {
65
+ return err({
66
+ code: 'change-id-format',
67
+ message: `changeId ${id} does not match [A-Za-z0-9][A-Za-z0-9._-]*`
68
+ });
69
+ }
70
+ return ok({ changeId: id });
71
+ }
72
+ /**
73
+ * Re-export of `src/shared/path-safety.ts#isPathInsideArtifactRoot`.
74
+ *
75
+ * Single source of truth: the primitive is owned by `src/shared/path-safety.ts`;
76
+ * this module owns the *domain* helpers (change-id + path planner) that consume
77
+ * the primitive. Tests in `tests/unit/services/openspec/artifact-boundary.test.ts`
78
+ * exercise the RE-EXPORT wiring; the primitive's own correctness is covered by
79
+ * its native test file.
80
+ */
81
+ export { _isPathInsideArtifactRoot as isPathInsideArtifactRoot };
82
+ const DEFAULT_TEMPLATE = '<changeId>/<role>/<requestId>';
83
+ function interpolateTemplate(template, changeId, role, requestId) {
84
+ return template
85
+ .replaceAll('<changeId>', changeId)
86
+ .replaceAll('<role>', role)
87
+ .replaceAll('<requestId>', requestId);
88
+ }
89
+ /**
90
+ * Plan an artifact-relative path under the configured Peaks artifact workspace.
91
+ *
92
+ * Semantics (rid-009 §3.3.2, tasks 5–9):
93
+ * - Backslashes in the candidate path are normalized to forward slashes for
94
+ * JSON safety; empty segments (`foo//bar`) are collapsed by `posix.normalize`.
95
+ * - If the resolved absolute path is NOT contained under `workspaceRoot`
96
+ * (per `isPathInsideArtifactRoot`), returns
97
+ * `BoundaryError.path-outside-artifact-root` — NO silent fallback to cwd.
98
+ * - JSON output (`jsonSafeRelativePath`) ALWAYS uses `/` so it round-trips
99
+ * cleanly through `JSON.stringify` on Windows.
100
+ *
101
+ * Path math only — this helper never touches the filesystem, so it is fully
102
+ * hermetic and safe to call on paths that do not exist yet.
103
+ */
104
+ export function planArtifactPath(input) {
105
+ const workspaceRoot = input.workspaceRoot;
106
+ const candidateRaw = input.absolutePath !== undefined
107
+ ? input.absolutePath
108
+ : input.relativePath !== undefined
109
+ ? input.relativePath
110
+ : interpolateTemplate(input.template ?? DEFAULT_TEMPLATE, input.changeId, input.role, input.requestId);
111
+ // Always normalize separators to forward-slashes for the JSON-safe output,
112
+ // then run posix.normalize so empty segments (foo//bar) and `..` segments
113
+ // collapse to canonical form.
114
+ const forwardSlashed = candidateRaw.replace(/\\/g, '/');
115
+ const normalized = posix.normalize(forwardSlashed);
116
+ // Resolve against workspaceRoot. If the candidate is already absolute,
117
+ // posix.normalize preserves the leading `/`; `resolve` keeps it absolute
118
+ // without prepending workspaceRoot (Node's path.resolve treats absolute
119
+ // candidates as already-resolved).
120
+ const absolutePath = nodeIsAbsolute(normalized)
121
+ ? resolve(normalized)
122
+ : resolve(workspaceRoot, normalized);
123
+ if (!_isPathInsideArtifactRoot(absolutePath, workspaceRoot)) {
124
+ return err({
125
+ code: 'path-outside-artifact-root',
126
+ path: absolutePath,
127
+ root: workspaceRoot,
128
+ message: `path "${absolutePath}" resolves outside artifact root "${workspaceRoot}"`
129
+ });
130
+ }
131
+ const relativePath = relative(workspaceRoot, absolutePath);
132
+ const jsonSafeRelativePath = relativePath.replace(/\\/g, '/');
133
+ return ok({ absolutePath, relativePath, jsonSafeRelativePath });
134
+ }
135
+ const WORKSPACE_UNAVAILABLE_NEXT_ACTIONS = [
136
+ 'Configure artifact workspace by describing where Peaks should store artifacts.'
137
+ ];
138
+ /**
139
+ * Build the explicit response used when no artifact workspace is configured.
140
+ * The next action is static natural language so callers can surface remediation
141
+ * without requiring the user to type a CLI command or hand-author data.
142
+ */
143
+ export function buildWorkspaceUnavailable(input) {
144
+ return {
145
+ ok: false,
146
+ mode: input.mode,
147
+ reason: 'artifact-workspace-unavailable',
148
+ nextActions: [...WORKSPACE_UNAVAILABLE_NEXT_ACTIONS]
149
+ };
150
+ }