peaks-loop 3.1.2 → 4.0.0-beta.2

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 (344) hide show
  1. package/.claude-plugin/marketplace.json +62 -12
  2. package/CHANGELOG.md +148 -116
  3. package/README-en.md +58 -240
  4. package/README.md +49 -325
  5. package/agents/karpathy-reviewer.md +3 -3
  6. package/dist/src/cli/cli-helpers.d.ts +18 -0
  7. package/dist/src/cli/cli-helpers.js +8 -0
  8. package/dist/src/cli/commands/adapter-commands.d.ts +30 -0
  9. package/dist/src/cli/commands/adapter-commands.js +35 -0
  10. package/dist/src/cli/commands/{solo-commands.d.ts → code-commands.d.ts} +25 -25
  11. package/dist/src/cli/commands/{solo-commands.js → code-commands.js} +82 -82
  12. package/dist/src/cli/commands/context-commands.d.ts +1 -1
  13. package/dist/src/cli/commands/context-commands.js +1 -1
  14. package/dist/src/cli/commands/contract-commands.d.ts +1 -1
  15. package/dist/src/cli/commands/contract-commands.js +1 -1
  16. package/dist/src/cli/commands/core/session-command.js +12 -0
  17. package/dist/src/cli/commands/core/skill-command.js +4 -4
  18. package/dist/src/cli/commands/dispatch-commands.js +2 -2
  19. package/dist/src/cli/commands/dispatch-from-dag.js +1 -1
  20. package/dist/src/cli/commands/hook-handle.js +7 -7
  21. package/dist/src/cli/commands/job-commands.js +7 -7
  22. package/dist/src/cli/commands/observability-commands.js +1 -1
  23. package/dist/src/cli/commands/perf-audit-commands.js +2 -2
  24. package/dist/src/cli/commands/security-audit-commands.js +2 -2
  25. package/dist/src/cli/commands/sediment-commands.d.ts +80 -0
  26. package/dist/src/cli/commands/sediment-commands.js +640 -0
  27. package/dist/src/cli/commands/session-auto-compact-hook-command.js +2 -2
  28. package/dist/src/cli/commands/session-migrate-skill-name.d.ts +17 -0
  29. package/dist/src/cli/commands/session-migrate-skill-name.js +41 -0
  30. package/dist/src/cli/commands/skill-visibility.d.ts +8 -0
  31. package/dist/src/cli/commands/skill-visibility.js +63 -0
  32. package/dist/src/cli/commands/slice-commands.js +2 -2
  33. package/dist/src/cli/commands/sub-agent-commands.d.ts +1 -1
  34. package/dist/src/cli/commands/sub-agent-commands.js +1 -1
  35. package/dist/src/cli/commands/sub-agent-shared.d.ts +1 -1
  36. package/dist/src/cli/commands/understand-commands.js +1 -1
  37. package/dist/src/cli/commands/upgrade-commands.d.ts +1 -1
  38. package/dist/src/cli/commands/upgrade-commands.js +3 -3
  39. package/dist/src/cli/commands/user-touchpoint-commands.d.ts +4 -4
  40. package/dist/src/cli/commands/user-touchpoint-commands.js +15 -15
  41. package/dist/src/cli/commands/verdict-aggregate-command.d.ts +1 -1
  42. package/dist/src/cli/commands/verdict-aggregate-command.js +2 -2
  43. package/dist/src/cli/commands/workflow-commands.js +23 -23
  44. package/dist/src/cli/commands/workspace/init-command.d.ts +3 -3
  45. package/dist/src/cli/commands/workspace/init-command.js +7 -7
  46. package/dist/src/cli/program.js +24 -7
  47. package/dist/src/services/adapter/adapter.d.ts +27 -0
  48. package/dist/src/services/adapter/adapter.js +5 -0
  49. package/dist/src/services/adapter/auto-adapter.d.ts +11 -0
  50. package/dist/src/services/adapter/auto-adapter.js +15 -0
  51. package/dist/src/services/adapter/claude-adapter.d.ts +14 -0
  52. package/dist/src/services/adapter/claude-adapter.js +40 -0
  53. package/dist/src/services/adapter/codex-adapter.d.ts +14 -0
  54. package/dist/src/services/adapter/codex-adapter.js +14 -0
  55. package/dist/src/services/adapter/copilot-adapter.d.ts +14 -0
  56. package/dist/src/services/adapter/copilot-adapter.js +14 -0
  57. package/dist/src/services/artifacts/repair-cycle-service.js +1 -1
  58. package/dist/src/services/audit/enforcers/active-skill-resolver.d.ts +1 -1
  59. package/dist/src/services/audit/enforcers/active-skill-resolver.js +1 -1
  60. package/dist/src/services/audit/enforcers/{solo-code-ban.d.ts → code-ban.d.ts} +6 -6
  61. package/dist/src/services/audit/enforcers/{solo-code-ban.js → code-ban.js} +6 -6
  62. package/dist/src/services/audit/red-line-catalog.d.ts +2 -2
  63. package/dist/src/services/audit/red-line-catalog.js +6 -6
  64. package/dist/src/services/audit/scanners/skills-tree-scanner.js +22 -0
  65. package/dist/src/services/audit/types.d.ts +2 -2
  66. package/dist/src/services/{solo → code}/auto-compact-orchestrator.d.ts +2 -2
  67. package/dist/src/services/{solo → code}/auto-compact-orchestrator.js +5 -5
  68. package/dist/src/services/{solo → code}/dag-orchestrator.d.ts +4 -4
  69. package/dist/src/services/{solo → code}/dag-orchestrator.js +5 -5
  70. package/dist/src/services/{solo → code}/emit-handoff.d.ts +1 -1
  71. package/dist/src/services/{solo → code}/emit-handoff.js +1 -1
  72. package/dist/src/services/{solo → code}/job-shape-decision.d.ts +1 -1
  73. package/dist/src/services/{solo → code}/job-shape-decision.js +5 -5
  74. package/dist/src/services/{solo → code}/mode-gate.d.ts +11 -11
  75. package/dist/src/services/{solo → code}/mode-gate.js +5 -5
  76. package/dist/src/services/{solo → code}/post-compact-detector.d.ts +3 -3
  77. package/dist/src/services/{solo → code}/post-compact-detector.js +6 -6
  78. package/dist/src/services/{solo → code}/status-line-renderer.d.ts +4 -4
  79. package/dist/src/services/{solo → code}/step-08-gate.d.ts +4 -4
  80. package/dist/src/services/{solo → code}/step-08-gate.js +4 -4
  81. package/dist/src/services/{solo → code}/user-touchpoint-classifier.d.ts +1 -1
  82. package/dist/src/services/{solo → code}/user-touchpoint-classifier.js +1 -1
  83. package/dist/src/services/context/auto-compact-dispatcher.d.ts +3 -3
  84. package/dist/src/services/context/auto-compact-dispatcher.js +2 -2
  85. package/dist/src/services/context/auto-compact-types.d.ts +1 -1
  86. package/dist/src/services/dispatch/batch-counter.js +1 -1
  87. package/dist/src/services/dispatch/leak-detector.js +1 -1
  88. package/dist/src/services/dispatch/slice-dag.d.ts +2 -2
  89. package/dist/src/services/dispatch/test-tool-detection.d.ts +1 -1
  90. package/dist/src/services/dispatch/test-tool-detection.js +1 -1
  91. package/dist/src/services/doctor/doctor-service.js +2 -2
  92. package/dist/src/services/feedback/feedback-promotion-service.js +2 -2
  93. package/dist/src/services/job/job-progress-store.d.ts +1 -1
  94. package/dist/src/services/job/job-progress-store.js +1 -1
  95. package/dist/src/services/job/job-resource-snapshot.js +29 -1
  96. package/dist/src/services/memory/project-memory-service.js +1 -1
  97. package/dist/src/services/migrate-skill-name/migrate.d.ts +17 -0
  98. package/dist/src/services/migrate-skill-name/migrate.js +152 -0
  99. package/dist/src/services/migrate-skill-name/schema.d.ts +42 -0
  100. package/dist/src/services/migrate-skill-name/schema.js +25 -0
  101. package/dist/src/services/observability/aggregation.d.ts +1 -1
  102. package/dist/src/services/observability/aggregation.js +1 -1
  103. package/dist/src/services/perf/perf-baseline-service.d.ts +1 -1
  104. package/dist/src/services/perf/perf-baseline-service.js +1 -1
  105. package/dist/src/services/prd/handoff-types.d.ts +1 -1
  106. package/dist/src/services/prd/handoff-types.js +1 -1
  107. package/dist/src/services/preferences/preferences-service.d.ts +1 -1
  108. package/dist/src/services/preferences/preferences-types.d.ts +1 -1
  109. package/dist/src/services/progress/progress-service.d.ts +1 -1
  110. package/dist/src/services/progress/progress-service.js +1 -1
  111. package/dist/src/services/rd/standards-diagnostic.d.ts +1 -1
  112. package/dist/src/services/rd/standards-diagnostic.js +3 -3
  113. package/dist/src/services/recommendations/capability-seed-items.js +1 -1
  114. package/dist/src/services/recommendations/capability-seed-mappings.js +1 -1
  115. package/dist/src/services/recommendations/recommendation-service.js +1 -1
  116. package/dist/src/services/refactor/refactor-service.d.ts +1 -1
  117. package/dist/src/services/sc/sc-service.js +1 -1
  118. package/dist/src/services/sediment/dispose-confirm.d.ts +9 -0
  119. package/dist/src/services/sediment/dispose-confirm.js +5 -0
  120. package/dist/src/services/sediment/json-schema.d.ts +247 -0
  121. package/dist/src/services/sediment/json-schema.js +26 -0
  122. package/dist/src/services/sediment/manifest-lint.d.ts +13 -0
  123. package/dist/src/services/sediment/manifest-lint.js +11 -0
  124. package/dist/src/services/sediment/pool-paths.d.ts +22 -0
  125. package/dist/src/services/sediment/pool-paths.js +25 -0
  126. package/dist/src/services/sediment/pool-read.d.ts +20 -0
  127. package/dist/src/services/sediment/pool-read.js +73 -0
  128. package/dist/src/services/sediment/pool-rebuild-index.d.ts +15 -0
  129. package/dist/src/services/sediment/pool-rebuild-index.js +28 -0
  130. package/dist/src/services/sediment/pool-write.d.ts +14 -0
  131. package/dist/src/services/sediment/pool-write.js +25 -0
  132. package/dist/src/services/sediment/promotion-gate.d.ts +12 -0
  133. package/dist/src/services/sediment/promotion-gate.js +20 -0
  134. package/dist/src/services/sediment/types.d.ts +52 -0
  135. package/dist/src/services/sediment/types.js +1 -0
  136. package/dist/src/services/session/binding-store.d.ts +1 -1
  137. package/dist/src/services/session/binding-store.js +1 -1
  138. package/dist/src/services/session/caller-id-types.d.ts +1 -1
  139. package/dist/src/services/session/session-manager.d.ts +1 -1
  140. package/dist/src/services/session/session-manager.js +1 -1
  141. package/dist/src/services/signal/cancel-handler.js +3 -3
  142. package/dist/src/services/skill/resume-detector.js +2 -2
  143. package/dist/src/services/skill/skill-scheduler.d.ts +1 -1
  144. package/dist/src/services/skill/skill-scheduler.js +1 -1
  145. package/dist/src/services/skillhub/release-diff.d.ts +18 -0
  146. package/dist/src/services/skillhub/release-diff.js +38 -0
  147. package/dist/src/services/skillhub/release-export.d.ts +8 -0
  148. package/dist/src/services/skillhub/release-export.js +31 -0
  149. package/dist/src/services/skillhub/release-gc-blobs.d.ts +13 -0
  150. package/dist/src/services/skillhub/release-gc-blobs.js +32 -0
  151. package/dist/src/services/skillhub/release-import.d.ts +7 -0
  152. package/dist/src/services/skillhub/release-import.js +59 -0
  153. package/dist/src/services/skillhub/release-retain.d.ts +23 -0
  154. package/dist/src/services/skillhub/release-retain.js +89 -0
  155. package/dist/src/services/skillhub/sqlite-store.d.ts +22 -0
  156. package/dist/src/services/skillhub/sqlite-store.js +47 -0
  157. package/dist/src/services/skillhub/tar-runtime.d.ts +21 -0
  158. package/dist/src/services/skillhub/tar-runtime.js +91 -0
  159. package/dist/src/services/skillhub/types.d.ts +105 -0
  160. package/dist/src/services/skillhub/types.js +1 -0
  161. package/dist/src/services/skills/skill-conformance-service.js +8 -5
  162. package/dist/src/services/skills/skill-presence-service.d.ts +5 -5
  163. package/dist/src/services/skills/skill-presence-service.js +2 -2
  164. package/dist/src/services/skills/skill-registry.js +27 -0
  165. package/dist/src/services/skills/skill-runbook-service.js +2 -2
  166. package/dist/src/services/slice/slice-check-service.js +1 -1
  167. package/dist/src/services/slice/slice-check-types.d.ts +1 -1
  168. package/dist/src/services/slice/slice-check-types.js +1 -1
  169. package/dist/src/services/slice/slice-decompose-types.d.ts +1 -1
  170. package/dist/src/services/slice/slice-decompose-types.js +1 -1
  171. package/dist/src/services/standards/missing-standards-detector.d.ts +1 -1
  172. package/dist/src/services/standards/missing-standards-detector.js +1 -1
  173. package/dist/src/services/standards/project-standards-service.d.ts +1 -1
  174. package/dist/src/services/standards/project-standards-service.js +4 -4
  175. package/dist/src/services/understand/understand-types.d.ts +1 -1
  176. package/dist/src/services/upgrade/1x-detector-service.js +2 -2
  177. package/dist/src/services/upgrade/upgrade-service.d.ts +34 -0
  178. package/dist/src/services/upgrade/upgrade-service.js +52 -30
  179. package/dist/src/services/verdict/verdict-aggregator.d.ts +1 -1
  180. package/dist/src/services/workflow/pipeline-verify-service.d.ts +1 -1
  181. package/dist/src/services/workflow/pipeline-verify-service.js +3 -3
  182. package/dist/src/services/workflow/workflow-autonomous-service.d.ts +3 -3
  183. package/dist/src/services/workflow/workflow-autonomous-service.js +2 -2
  184. package/dist/src/services/workflow/workflow-router-service.d.ts +7 -7
  185. package/dist/src/services/workflow/workflow-router-service.js +33 -33
  186. package/dist/src/services/workspace/claude-settings-template.d.ts +2 -2
  187. package/dist/src/services/workspace/claude-settings-template.js +7 -7
  188. package/dist/src/services/workspace/workspace-claude-settings-materializer.d.ts +1 -1
  189. package/dist/src/services/workspace/workspace-claude-settings-materializer.js +1 -1
  190. package/dist/src/services/workspace/workspace-service.d.ts +4 -4
  191. package/dist/src/services/workspace/workspace-service.js +2 -2
  192. package/dist/src/shared/paths.d.ts +1 -1
  193. package/dist/src/shared/paths.js +1 -1
  194. package/dist/src/shared/version.d.ts +1 -1
  195. package/dist/src/shared/version.js +1 -1
  196. package/dist/src/skills/peaks-maker/index.d.ts +5 -0
  197. package/dist/src/skills/peaks-maker/index.js +32 -0
  198. package/output-styles/peaks-skill-swarm.md +3 -3
  199. package/package.json +8 -3
  200. package/scripts/install-skills.mjs +29 -4
  201. package/skills/{peaks-prd → bee/peaks-prd}/SKILL.md +8 -2
  202. package/skills/{peaks-prd → bee/peaks-prd}/references/workflow.md +1 -1
  203. package/skills/{peaks-qa → bee/peaks-qa}/SKILL.md +10 -4
  204. package/skills/{peaks-qa → bee/peaks-qa}/references/artifact-per-request.md +3 -3
  205. package/skills/{peaks-qa → bee/peaks-qa}/references/browser-validation-contracts.md +2 -2
  206. package/skills/{peaks-qa → bee/peaks-qa}/references/external-capability-guidance.md +1 -1
  207. package/skills/{peaks-qa → bee/peaks-qa}/references/qa-fanout-contract.md +3 -3
  208. package/skills/{peaks-qa → bee/peaks-qa}/references/qa-sub-agent-dispatch.md +7 -7
  209. package/skills/{peaks-rd → bee/peaks-rd}/SKILL.md +13 -6
  210. package/skills/{peaks-rd → bee/peaks-rd}/references/browser-self-test-contracts.md +1 -1
  211. package/skills/{peaks-rd → bee/peaks-rd}/references/mock-data-placement.md +1 -1
  212. package/skills/{peaks-rd → bee/peaks-rd}/references/parallel-review-fanout.md +1 -1
  213. package/skills/{peaks-rd → bee/peaks-rd}/references/rd-fanout-contracts.md +1 -1
  214. package/skills/{peaks-rd → bee/peaks-rd}/references/rd-runbook.md +2 -2
  215. package/skills/{peaks-rd → bee/peaks-rd}/references/rd-sub-agent-dispatch.md +13 -13
  216. package/skills/{peaks-rd → bee/peaks-rd}/references/rd-transition-gates.md +2 -2
  217. package/skills/{peaks-rd → bee/peaks-rd}/references/skill-presence-and-title.md +1 -1
  218. package/skills/{peaks-reviewer → bee/peaks-reviewer}/SKILL.md +2 -2
  219. package/skills/{peaks-sc → bee/peaks-sc}/SKILL.md +8 -2
  220. package/skills/{peaks-txt → bee/peaks-txt}/SKILL.md +11 -5
  221. package/skills/{peaks-ui → bee/peaks-ui}/SKILL.md +19 -13
  222. package/skills/peaks-audit/SKILL.md +1 -1
  223. package/skills/{peaks-solo → peaks-code}/SKILL.md +29 -29
  224. package/skills/{peaks-solo → peaks-code}/references/a2a-artifact-mapping.md +2 -2
  225. package/skills/{peaks-solo → peaks-code}/references/anchoring-and-session-info.md +6 -6
  226. package/skills/{peaks-solo → peaks-code}/references/artifact-contracts.md +3 -3
  227. package/skills/{peaks-solo → peaks-code}/references/boundaries.md +3 -3
  228. package/skills/{peaks-solo → peaks-code}/references/browser-workflow.md +1 -1
  229. package/skills/{peaks-solo → peaks-code}/references/codegraph-orchestration.md +1 -1
  230. package/skills/peaks-code/references/command-migration.md +3 -0
  231. package/skills/{peaks-solo → peaks-code}/references/completion-handoff.md +2 -2
  232. package/skills/{peaks-solo → peaks-code}/references/context-governance.md +2 -2
  233. package/skills/{peaks-solo → peaks-code}/references/dag-orchestrator.md +7 -7
  234. package/skills/{peaks-solo → peaks-code}/references/external-references.md +2 -2
  235. package/skills/{peaks-solo → peaks-code}/references/fanout-mandatory.md +3 -3
  236. package/skills/{peaks-solo → peaks-code}/references/fast-mode.md +2 -2
  237. package/skills/{peaks-solo → peaks-code}/references/frontend-only-mode.md +10 -10
  238. package/skills/{peaks-solo → peaks-code}/references/job-loop.md +1 -1
  239. package/skills/{peaks-solo → peaks-code}/references/local-artifact-workspace.md +3 -3
  240. package/skills/{peaks-solo → peaks-code}/references/micro-cycle.md +23 -23
  241. package/skills/{peaks-solo → peaks-code}/references/mode-selection-with-stale-presence.md +16 -16
  242. package/skills/{peaks-solo → peaks-code}/references/mode-selection.md +4 -4
  243. package/skills/{peaks-solo → peaks-code}/references/openspec-workflow.md +17 -17
  244. package/skills/{peaks-solo → peaks-code}/references/periodic-checkpoint.md +4 -4
  245. package/skills/{peaks-solo → peaks-code}/references/project-scan-checklist.md +1 -1
  246. package/skills/{peaks-solo → peaks-code}/references/quality-gate-cheatsheet.md +1 -1
  247. package/skills/{peaks-solo → peaks-code}/references/refactor-mode.md +2 -2
  248. package/skills/{peaks-solo → peaks-code}/references/resume-detection.md +1 -1
  249. package/skills/{peaks-solo → peaks-code}/references/runbook.md +20 -20
  250. package/skills/{peaks-solo → peaks-code}/references/skill-presence-and-title.md +3 -3
  251. package/skills/{peaks-solo → peaks-code}/references/standards-preflight.md +1 -1
  252. package/skills/{peaks-solo → peaks-code}/references/step-0-55-1x-detection.md +6 -6
  253. package/skills/{peaks-solo → peaks-code}/references/step-0-8-gate.md +11 -11
  254. package/skills/{peaks-solo → peaks-code}/references/sub-agent-dispatch.md +17 -17
  255. package/skills/{peaks-solo → peaks-code}/references/swarm-dispatch-contract.md +22 -22
  256. package/skills/{peaks-solo → peaks-code}/references/workflow-gates-and-types.md +4 -4
  257. package/skills/{peaks-solo → peaks-code}/references/workflow.md +5 -5
  258. package/skills/peaks-doctor/SKILL.md +1 -1
  259. package/skills/peaks-doctor/references/doctor-check-catalog.md +1 -1
  260. package/skills/peaks-final-review/SKILL.md +3 -3
  261. package/skills/peaks-final-review/references/4-dimensions.md +1 -1
  262. package/skills/peaks-ide/SKILL.md +1 -1
  263. package/skills/{peaks-solo-resume → peaks-resume}/SKILL.md +15 -15
  264. package/skills/peaks-sop/SKILL.md +1 -1
  265. package/skills/{peaks-solo-status → peaks-status}/SKILL.md +14 -14
  266. package/skills/{peaks-solo-test → peaks-test}/SKILL.md +12 -12
  267. package/skills/peaks-solo/references/command-migration.md +0 -3
  268. /package/dist/src/services/{solo → code}/batch-heartbeat-poller.d.ts +0 -0
  269. /package/dist/src/services/{solo → code}/batch-heartbeat-poller.js +0 -0
  270. /package/dist/src/services/{solo → code}/status-line-renderer.js +0 -0
  271. /package/skills/{peaks-perf-audit → bee/peaks-perf-audit}/SKILL.md +0 -0
  272. /package/skills/{peaks-perf-audit → bee/peaks-perf-audit}/references/audit-protocol.md +0 -0
  273. /package/skills/{peaks-prd → bee/peaks-prd}/references/artifact-contracts.md +0 -0
  274. /package/skills/{peaks-prd → bee/peaks-prd}/references/artifact-per-request.md +0 -0
  275. /package/skills/{peaks-prd → bee/peaks-prd}/references/command-migration.md +0 -0
  276. /package/skills/{peaks-prd → bee/peaks-prd}/references/prd-for-multi-pass.md +0 -0
  277. /package/skills/{peaks-qa → bee/peaks-qa}/references/artifact-contracts.md +0 -0
  278. /package/skills/{peaks-qa → bee/peaks-qa}/references/codegraph-regression-focus.md +0 -0
  279. /package/skills/{peaks-qa → bee/peaks-qa}/references/command-migration.md +0 -0
  280. /package/skills/{peaks-qa → bee/peaks-qa}/references/openspec-validation-gate.md +0 -0
  281. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-compact-handoff.md +0 -0
  282. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-context-governance.md +0 -0
  283. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-gstack-integration.md +0 -0
  284. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-local-artifacts.md +0 -0
  285. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-matt-pocock-integration.md +0 -0
  286. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-perf-test-plan.md +0 -0
  287. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-refactor-role.md +0 -0
  288. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-runbook.md +0 -0
  289. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-security-test-plan.md +0 -0
  290. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-skill-presence.md +0 -0
  291. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-standards-preflight.md +0 -0
  292. /package/skills/{peaks-qa → bee/peaks-qa}/references/qa-transition-gates.md +0 -0
  293. /package/skills/{peaks-qa → bee/peaks-qa}/references/reading-handoff-frontmatter.md +0 -0
  294. /package/skills/{peaks-qa → bee/peaks-qa}/references/regression-gates.md +0 -0
  295. /package/skills/{peaks-qa → bee/peaks-qa}/references/requirement-boundary-recheck.md +0 -0
  296. /package/skills/{peaks-qa → bee/peaks-qa}/references/test-case-generation.md +0 -0
  297. /package/skills/{peaks-qa → bee/peaks-qa}/references/test-report-output.md +0 -0
  298. /package/skills/{peaks-rd → bee/peaks-rd}/references/artifact-and-standards-output.md +0 -0
  299. /package/skills/{peaks-rd → bee/peaks-rd}/references/artifact-contracts.md +0 -0
  300. /package/skills/{peaks-rd → bee/peaks-rd}/references/artifact-per-request.md +0 -0
  301. /package/skills/{peaks-rd → bee/peaks-rd}/references/browser-action-wrapper.md +0 -0
  302. /package/skills/{peaks-rd → bee/peaks-rd}/references/code-reviewer-4dim-hint.md +0 -0
  303. /package/skills/{peaks-rd → bee/peaks-rd}/references/codegraph-project-analysis.md +0 -0
  304. /package/skills/{peaks-rd → bee/peaks-rd}/references/command-migration.md +0 -0
  305. /package/skills/{peaks-rd → bee/peaks-rd}/references/compact-handoff.md +0 -0
  306. /package/skills/{peaks-rd → bee/peaks-rd}/references/external-references.md +0 -0
  307. /package/skills/{peaks-rd → bee/peaks-rd}/references/frontend-project-generation.md +0 -0
  308. /package/skills/{peaks-rd → bee/peaks-rd}/references/karpathy-reviewer-prompt.md +0 -0
  309. /package/skills/{peaks-rd → bee/peaks-rd}/references/library-version-awareness.md +0 -0
  310. /package/skills/{peaks-rd → bee/peaks-rd}/references/mandatory-perf-baseline.md +0 -0
  311. /package/skills/{peaks-rd → bee/peaks-rd}/references/matt-pocock-integration.md +0 -0
  312. /package/skills/{peaks-rd → bee/peaks-rd}/references/ocr-integration.md +0 -0
  313. /package/skills/{peaks-rd → bee/peaks-rd}/references/openspec-cli.md +0 -0
  314. /package/skills/{peaks-rd → bee/peaks-rd}/references/rd-context-governance.md +0 -0
  315. /package/skills/{peaks-rd → bee/peaks-rd}/references/rd-gstack-integration.md +0 -0
  316. /package/skills/{peaks-rd → bee/peaks-rd}/references/rd-standards-preflight.md +0 -0
  317. /package/skills/{peaks-rd → bee/peaks-rd}/references/reading-v2-slice-results.md +0 -0
  318. /package/skills/{peaks-rd → bee/peaks-rd}/references/refactor-workflow.md +0 -0
  319. /package/skills/{peaks-rd → bee/peaks-rd}/references/v2-12-fanout-collapse.md +0 -0
  320. /package/skills/{peaks-rd → bee/peaks-rd}/references/writing-handoff-frontmatter.md +0 -0
  321. /package/skills/{peaks-reviewer → bee/peaks-reviewer}/references/reviewer-prompt.md +0 -0
  322. /package/skills/{peaks-reviewer → bee/peaks-reviewer}/references/reviewer-schema.md +0 -0
  323. /package/skills/{peaks-sc → bee/peaks-sc}/references/artifact-contracts.md +0 -0
  324. /package/skills/{peaks-sc → bee/peaks-sc}/references/artifact-retention.md +0 -0
  325. /package/skills/{peaks-sc → bee/peaks-sc}/references/command-migration.md +0 -0
  326. /package/skills/{peaks-sc → bee/peaks-sc}/references/openspec-commit-boundaries.md +0 -0
  327. /package/skills/{peaks-security-audit → bee/peaks-security-audit}/SKILL.md +0 -0
  328. /package/skills/{peaks-security-audit → bee/peaks-security-audit}/references/audit-protocol.md +0 -0
  329. /package/skills/{peaks-txt → bee/peaks-txt}/references/artifact-contracts.md +0 -0
  330. /package/skills/{peaks-txt → bee/peaks-txt}/references/command-migration.md +0 -0
  331. /package/skills/{peaks-txt → bee/peaks-txt}/references/context-capsule.md +0 -0
  332. /package/skills/{peaks-ui → bee/peaks-ui}/references/artifact-contracts.md +0 -0
  333. /package/skills/{peaks-ui → bee/peaks-ui}/references/artifact-per-request.md +0 -0
  334. /package/skills/{peaks-ui → bee/peaks-ui}/references/command-migration.md +0 -0
  335. /package/skills/{peaks-ui → bee/peaks-ui}/references/workflow.md +0 -0
  336. /package/skills/{peaks-solo → peaks-code}/references/checkpoint-resume.md +0 -0
  337. /package/skills/{peaks-solo → peaks-code}/references/cross-date-session-check.md +0 -0
  338. /package/skills/{peaks-solo → peaks-code}/references/envelope-contract.md +0 -0
  339. /package/skills/{peaks-solo → peaks-code}/references/existing-system-extraction.md +0 -0
  340. /package/skills/{peaks-solo → peaks-code}/references/external-skill-invocation.md +0 -0
  341. /package/skills/{peaks-solo → peaks-code}/references/gstack-integration.md +0 -0
  342. /package/skills/{peaks-solo → peaks-code}/references/headroom-integration.md +0 -0
  343. /package/skills/{peaks-solo → peaks-code}/references/playwright-mcp-multi-terminal.md +0 -0
  344. /package/skills/{peaks-solo → peaks-code}/references/project-memory-loading.md +0 -0
@@ -0,0 +1,20 @@
1
+ import type { IndexFile } from "./types.js";
2
+ export declare class POOL_READ_ERROR extends Error {
3
+ }
4
+ /** Pure read of the in-memory pool index (Critical #2 fix).
5
+ *
6
+ * CONTRACT: this function is a READ-ONLY computation. It MUST NOT
7
+ * write `index.json` (or any other file) as a side-effect. The
8
+ * "self-heal" property of rewriting index.json when it goes stale
9
+ * belongs to `rebuildIndexFromFs`, not here. List / search / recent /
10
+ * add-* verbs that need to mutate the on-disk cache should call
11
+ * `rebuildIndexFromFs` explicitly.
12
+ *
13
+ * Edge case: if the pool root does not yet exist, this returns an
14
+ * empty index WITHOUT creating the directory. Callers that need a
15
+ * materialized root should use `rebuildIndexFromFs` or `mkdirSync`
16
+ * themselves.
17
+ */
18
+ export declare function readPool({ home }: {
19
+ home: string;
20
+ }): IndexFile;
@@ -0,0 +1,73 @@
1
+ import { readdirSync, readFileSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { resolveUserBeesDir, resolveSegmentsDir } from "./pool-paths.js";
4
+ import { lintManifest } from "./manifest-lint.js";
5
+ export class POOL_READ_ERROR extends Error {
6
+ }
7
+ function readJsonIfExists(p) {
8
+ if (!existsSync(p))
9
+ return null;
10
+ return JSON.parse(readFileSync(p, "utf-8"));
11
+ }
12
+ function readBeeDir(home, name) {
13
+ const dir = join(resolveUserBeesDir({ home }), name);
14
+ const manifestPath = join(dir, "manifest.json");
15
+ const m = readJsonIfExists(manifestPath);
16
+ if (!m)
17
+ return null;
18
+ const r = lintManifest(m);
19
+ if (!r.ok)
20
+ return null;
21
+ return {
22
+ name: m.name,
23
+ kind: "bee",
24
+ path: `bees/${name}`,
25
+ source: m.source,
26
+ promotion_status: m.promotion_status,
27
+ segments: m.segments.map((s) => s.name),
28
+ };
29
+ }
30
+ function readSegmentDir(home, name) {
31
+ const dir = join(resolveSegmentsDir({ home }), name);
32
+ if (!existsSync(dir))
33
+ return null;
34
+ return {
35
+ name, kind: "segment", path: `segments/${name}`, source: "user", promotion_status: "stable",
36
+ };
37
+ }
38
+ /** Pure read of the in-memory pool index (Critical #2 fix).
39
+ *
40
+ * CONTRACT: this function is a READ-ONLY computation. It MUST NOT
41
+ * write `index.json` (or any other file) as a side-effect. The
42
+ * "self-heal" property of rewriting index.json when it goes stale
43
+ * belongs to `rebuildIndexFromFs`, not here. List / search / recent /
44
+ * add-* verbs that need to mutate the on-disk cache should call
45
+ * `rebuildIndexFromFs` explicitly.
46
+ *
47
+ * Edge case: if the pool root does not yet exist, this returns an
48
+ * empty index WITHOUT creating the directory. Callers that need a
49
+ * materialized root should use `rebuildIndexFromFs` or `mkdirSync`
50
+ * themselves.
51
+ */
52
+ export function readPool({ home }) {
53
+ const entries = [];
54
+ const beesDir = resolveUserBeesDir({ home });
55
+ if (existsSync(beesDir)) {
56
+ for (const ent of readdirSync(beesDir, { withFileTypes: true })) {
57
+ if (!ent.isDirectory())
58
+ continue;
59
+ entries.push(...[readBeeDir(home, ent.name)].filter((e) => e !== null));
60
+ }
61
+ }
62
+ const segsDir = resolveSegmentsDir({ home });
63
+ if (existsSync(segsDir)) {
64
+ for (const ent of readdirSync(segsDir, { withFileTypes: true })) {
65
+ if (!ent.isDirectory())
66
+ continue;
67
+ entries.push(...[readSegmentDir(home, ent.name)].filter((e) => e !== null));
68
+ }
69
+ }
70
+ const idx = { schemaVersion: "peaks.pool/1", generatedAt: new Date().toISOString(), entries };
71
+ // Note: NO writeFileSync here. See Critical #2 fix.
72
+ return idx;
73
+ }
@@ -0,0 +1,15 @@
1
+ import type { IndexFile } from "./types.js";
2
+ /**
3
+ * Rebuilds index.json from on-disk manifests/segments and writes the result.
4
+ *
5
+ * After the Critical #2 fix, `readPool` is a pure read (no filesystem
6
+ * side-effects). `rebuildIndexFromFs` is the single writer of
7
+ * `index.json`: it materializes the pool root if needed, walks the
8
+ * filesystem to build the in-memory index via `readPool`, and persists
9
+ * the result. Callers that need the on-disk cache up-to-date should
10
+ * call this function (or one of the add-* / rebuild-index CLI verbs
11
+ * which call it internally).
12
+ */
13
+ export declare function rebuildIndexFromFs({ home }: {
14
+ home: string;
15
+ }): IndexFile;
@@ -0,0 +1,28 @@
1
+ import { writeFileSync, mkdirSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { resolvePoolRoot } from "./pool-paths.js";
4
+ import { readPool } from "./pool-read.js";
5
+ /**
6
+ * Rebuilds index.json from on-disk manifests/segments and writes the result.
7
+ *
8
+ * After the Critical #2 fix, `readPool` is a pure read (no filesystem
9
+ * side-effects). `rebuildIndexFromFs` is the single writer of
10
+ * `index.json`: it materializes the pool root if needed, walks the
11
+ * filesystem to build the in-memory index via `readPool`, and persists
12
+ * the result. Callers that need the on-disk cache up-to-date should
13
+ * call this function (or one of the add-* / rebuild-index CLI verbs
14
+ * which call it internally).
15
+ */
16
+ export function rebuildIndexFromFs({ home }) {
17
+ const root = resolvePoolRoot({ home });
18
+ if (!existsSync(root))
19
+ mkdirSync(root, { recursive: true });
20
+ const idx = readPool({ home });
21
+ // Trailing newline: POSIX-friendly (`cat`, `git diff`, log tailers all
22
+ // expect a final \n). The Minor #14 review confirmed we keep the current
23
+ // behavior rather than drop it — both are JSON-valid but the trailing
24
+ // newline matches the convention used by every other peaks-*.json file
25
+ // in the project (manifest.json, segment.json, etc.).
26
+ writeFileSync(join(root, "index.json"), JSON.stringify(idx, null, 2) + "\n");
27
+ return idx;
28
+ }
@@ -0,0 +1,14 @@
1
+ import type { BeeManifest } from "./types.js";
2
+ /**
3
+ * Atomically writes a BeeManifest to <home>/.peaks/skills/bees/<name>/manifest.json.
4
+ *
5
+ * Defense in depth:
6
+ * - re-validates the manifest via lintManifestStrict (zod) before any FS work
7
+ * - refuses to write under any path segment equal to ".system" (soft-protection)
8
+ *
9
+ * Atomicity is achieved via write-to-tmp + renameSync so readers either see the
10
+ * old file or the fully-written new file, never a half-written one.
11
+ */
12
+ export declare function writeBeeManifest({ home }: {
13
+ home: string;
14
+ }, m: BeeManifest): void;
@@ -0,0 +1,25 @@
1
+ import { writeFileSync, mkdirSync, renameSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { assertNotSystemPath, resolveUserBeeDir } from "./pool-paths.js";
4
+ import { lintManifestStrict } from "./manifest-lint.js";
5
+ /**
6
+ * Atomically writes a BeeManifest to <home>/.peaks/skills/bees/<name>/manifest.json.
7
+ *
8
+ * Defense in depth:
9
+ * - re-validates the manifest via lintManifestStrict (zod) before any FS work
10
+ * - refuses to write under any path segment equal to ".system" (soft-protection)
11
+ *
12
+ * Atomicity is achieved via write-to-tmp + renameSync so readers either see the
13
+ * old file or the fully-written new file, never a half-written one.
14
+ */
15
+ export function writeBeeManifest({ home }, m) {
16
+ const validated = lintManifestStrict(m);
17
+ const dir = resolveUserBeeDir({ home }, validated.name);
18
+ assertNotSystemPath(dir);
19
+ mkdirSync(dir, { recursive: true });
20
+ const file = join(dir, "manifest.json");
21
+ assertNotSystemPath(file);
22
+ const tmp = file + ".tmp";
23
+ writeFileSync(tmp, JSON.stringify(validated, null, 2) + "\n");
24
+ renameSync(tmp, file);
25
+ }
@@ -0,0 +1,12 @@
1
+ import type { BeeManifest } from "./types.js";
2
+ export interface GateInputs {
3
+ humanApproved: boolean;
4
+ smokeTestPresent: boolean;
5
+ }
6
+ export interface GateResult {
7
+ ok: boolean;
8
+ failedSubconditions: string[];
9
+ }
10
+ export declare function evaluateGate({ home }: {
11
+ home: string;
12
+ }, m: BeeManifest, inputs: GateInputs): GateResult;
@@ -0,0 +1,20 @@
1
+ import { readFileSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { resolveUserBeeDir } from "./pool-paths.js";
4
+ export function evaluateGate({ home }, m, inputs) {
5
+ if (m.source === "system") {
6
+ return { ok: true, failedSubconditions: [] };
7
+ }
8
+ const failed = [];
9
+ const rsPath = join(resolveUserBeeDir({ home }, m.name), "run-state.json");
10
+ const cycles = existsSync(rsPath)
11
+ ? JSON.parse(readFileSync(rsPath, "utf-8")).cycles
12
+ : 0;
13
+ if (cycles < m.promotion.minCycles)
14
+ failed.push("minCycles");
15
+ if (inputs.smokeTestPresent !== m.promotion.requiresSmokeTest)
16
+ failed.push("smokeTest");
17
+ if (m.promotion.requiresHumanApproval && !inputs.humanApproved)
18
+ failed.push("humanApproval");
19
+ return { ok: failed.length === 0, failedSubconditions: failed };
20
+ }
@@ -0,0 +1,52 @@
1
+ export type Source = "system" | "user";
2
+ export type PromotionStatus = "candidate" | "stable" | "retired" | "system-stable";
3
+ export interface Param {
4
+ name: string;
5
+ type: "string" | "number" | "boolean" | "json";
6
+ required: boolean;
7
+ }
8
+ export interface SegmentRef {
9
+ name: string;
10
+ inputs: Param[];
11
+ outputs: Param[];
12
+ sideEffects: string[];
13
+ }
14
+ export interface SkillEnvelopeRef {
15
+ path: string;
16
+ kind: "file" | "dir" | "script";
17
+ }
18
+ export interface SkillEnvelope {
19
+ preamble: string;
20
+ refs: SkillEnvelopeRef[];
21
+ }
22
+ export interface PromotionGate {
23
+ minCycles: number;
24
+ requiresHumanApproval: boolean;
25
+ requiresSmokeTest: boolean;
26
+ retireOnMissesInRow?: number;
27
+ }
28
+ export interface BeeManifest {
29
+ schemaVersion: "peaks.bee/1";
30
+ name: string;
31
+ source: Source;
32
+ promotion_status: PromotionStatus;
33
+ description: string;
34
+ segments: SegmentRef[];
35
+ entrypoint: SkillEnvelope;
36
+ promotion: PromotionGate;
37
+ createdBy: "human" | "llm";
38
+ lastTouchedAt: string;
39
+ }
40
+ export interface IndexEntry {
41
+ name: string;
42
+ kind: "bee" | "segment";
43
+ path: string;
44
+ source: Source;
45
+ promotion_status: PromotionStatus;
46
+ segments?: string[];
47
+ }
48
+ export interface IndexFile {
49
+ schemaVersion: "peaks.pool/1";
50
+ generatedAt: string;
51
+ entries: IndexEntry[];
52
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -107,7 +107,7 @@ export declare function writeBinding(projectRoot: string, binding: Binding): voi
107
107
  * This is the D2 Claude-instance-level binding primitive — a single
108
108
  * Claude instance keeps one sid across multiple peaks-* skill
109
109
  * activations; binding.instances[<sid>].roles accumulates the skill
110
- * names (peaks-solo → peaks-rd → peaks-qa in the same Claude run).
110
+ * names (peaks-code → peaks-rd → peaks-qa in the same Claude run).
111
111
  *
112
112
  * The caller is responsible for actually creating the session dir via
113
113
  * `initWorkspace` and storing per-session meta via `setSessionMeta`.
@@ -192,7 +192,7 @@ export function writeBinding(projectRoot, binding) {
192
192
  * This is the D2 Claude-instance-level binding primitive — a single
193
193
  * Claude instance keeps one sid across multiple peaks-* skill
194
194
  * activations; binding.instances[<sid>].roles accumulates the skill
195
- * names (peaks-solo → peaks-rd → peaks-qa in the same Claude run).
195
+ * names (peaks-code → peaks-rd → peaks-qa in the same Claude run).
196
196
  *
197
197
  * The caller is responsible for actually creating the session dir via
198
198
  * `initWorkspace` and storing per-session meta via `setSessionMeta`.
@@ -28,7 +28,7 @@ export interface CallerBinding {
28
28
  createdAt: string;
29
29
  /** ISO 8601 timestamp; bumped on every `peaks <cmd>` that touches the binding. */
30
30
  lastActivityAt: string;
31
- /** Last skill that touched this binding, e.g. "peaks-solo". */
31
+ /** Last skill that touched this binding, e.g. "peaks-code". */
32
32
  skill: string;
33
33
  /** Last mode, e.g. "full-auto". */
34
34
  mode: string;
@@ -120,7 +120,7 @@ export declare function getSessionId(projectRoot: string): string | null;
120
120
  * caller is operating on a user-supplied `--project` flag
121
121
  * and the binding may have been written by a CLI invocation
122
122
  * that was running from inside the project dir (the common
123
- * peaks-solo / peaks-sop scenario). Other modules depend
123
+ * peaks-code / peaks-sop scenario). Other modules depend
124
124
  * on the strict-equality semantics of `getSessionId` (the
125
125
  * "no binding" fallback path is part of their contract),
126
126
  * so this variant is opt-in.
@@ -399,7 +399,7 @@ export function getSessionId(projectRoot) {
399
399
  * caller is operating on a user-supplied `--project` flag
400
400
  * and the binding may have been written by a CLI invocation
401
401
  * that was running from inside the project dir (the common
402
- * peaks-solo / peaks-sop scenario). Other modules depend
402
+ * peaks-code / peaks-sop scenario). Other modules depend
403
403
  * on the strict-equality semantics of `getSessionId` (the
404
404
  * "no binding" fallback path is part of their contract),
405
405
  * so this variant is opt-in.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Slice #009 / G5 RL-9 — user cancel must dispose in-flight dispatch records.
3
3
  *
4
- * When Solo's main loop receives SIGINT (Ctrl-C) or the user runs
4
+ * When Code's main loop receives SIGINT (Ctrl-C) or the user runs
5
5
  * `peaks workflow cancel --rid <rid>`, the loop MUST mark in-flight
6
6
  * dispatch records as `outcome: "cancelled"` + `disposed: true` +
7
7
  * `disposedAt: now()` BEFORE exiting.
@@ -10,8 +10,8 @@
10
10
  * `completedAt: null`. Those are the ones that the LLM got a toolCall
11
11
  * for but did not (yet) confirm completion.
12
12
  *
13
- * This module is the helper Solo calls. The wiring (signal listener,
14
- * cancel command side-effect) is the Solo main loop's responsibility;
13
+ * This module is the helper Code calls. The wiring (signal listener,
14
+ * cancel command side-effect) is the Code main loop's responsibility;
15
15
  * this module is the pure data operation.
16
16
  */
17
17
  import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Peaks-Loop Solo Step 0.7 — Resume-mode detector.
2
+ * Peaks-Loop Code Step 0.7 — Resume-mode detector.
3
3
  *
4
4
  * Mirrors the classification table in
5
- * `skills/peaks-solo/SKILL.md` "Peaks-Loop Step 0.7: Detect unfinished work
5
+ * `skills/peaks-code/SKILL.md` "Peaks-Loop Step 0.7: Detect unfinished work
6
6
  * and offer resume". The function is a pure read of session artifacts;
7
7
  * it performs no side effects and is safe to call from hooks, scripts,
8
8
  * and skills.
@@ -2,7 +2,7 @@
2
2
  * G6 — skill-level heartbeat scheduler config.
3
3
  *
4
4
  * Slice 2026-06-07-sub-agent-dispatch-decouple (G6): the SKILL.md front
5
- * matter for a Dispatcher (peaks-solo / peaks-rd / peaks-qa) can opt
5
+ * matter for a Dispatcher (peaks-code / peaks-rd / peaks-qa) can opt
6
6
  * into a non-default heartbeat interval by including a line like:
7
7
  *
8
8
  * heartbeatIntervalSec: 15
@@ -2,7 +2,7 @@
2
2
  * G6 — skill-level heartbeat scheduler config.
3
3
  *
4
4
  * Slice 2026-06-07-sub-agent-dispatch-decouple (G6): the SKILL.md front
5
- * matter for a Dispatcher (peaks-solo / peaks-rd / peaks-qa) can opt
5
+ * matter for a Dispatcher (peaks-code / peaks-rd / peaks-qa) can opt
6
6
  * into a non-default heartbeat interval by including a line like:
7
7
  *
8
8
  * heartbeatIntervalSec: 15
@@ -0,0 +1,18 @@
1
+ import type Database from "better-sqlite3";
2
+ export interface ReleaseDiff {
3
+ added: string[];
4
+ removed: string[];
5
+ modified: string[];
6
+ }
7
+ /**
8
+ * Compare two releases of the same bee and report which file paths were
9
+ * added, removed, or had their content (sha256) changed.
10
+ *
11
+ * Throws `VERSION_NOT_FOUND` if either (bee_name, version) tuple is missing.
12
+ */
13
+ export declare function releaseDiff({ db, beeName, fromVersion, toVersion, }: {
14
+ db: Database.Database;
15
+ beeName: string;
16
+ fromVersion: string;
17
+ toVersion: string;
18
+ }): ReleaseDiff;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Compare two releases of the same bee and report which file paths were
3
+ * added, removed, or had their content (sha256) changed.
4
+ *
5
+ * Throws `VERSION_NOT_FOUND` if either (bee_name, version) tuple is missing.
6
+ */
7
+ export function releaseDiff({ db, beeName, fromVersion, toVersion, }) {
8
+ const aRow = db
9
+ .prepare("SELECT id FROM bee_release WHERE bee_name = ? AND version = ?")
10
+ .get(beeName, fromVersion);
11
+ const bRow = db
12
+ .prepare("SELECT id FROM bee_release WHERE bee_name = ? AND version = ?")
13
+ .get(beeName, toVersion);
14
+ if (!aRow || !bRow)
15
+ throw new Error("VERSION_NOT_FOUND");
16
+ const a = aRow.id;
17
+ const b = bRow.id;
18
+ const aFiles = new Map(db
19
+ .prepare("SELECT path, sha256 FROM bee_file WHERE release_id = ?")
20
+ .all(a).map((r) => [r.path, r.sha256]));
21
+ const bFiles = new Map(db
22
+ .prepare("SELECT path, sha256 FROM bee_file WHERE release_id = ?")
23
+ .all(b).map((r) => [r.path, r.sha256]));
24
+ const added = [];
25
+ const removed = [];
26
+ const modified = [];
27
+ for (const [p, sha] of bFiles) {
28
+ if (!aFiles.has(p))
29
+ added.push(p);
30
+ else if (aFiles.get(p) !== sha)
31
+ modified.push(p);
32
+ }
33
+ for (const [p] of aFiles) {
34
+ if (!bFiles.has(p))
35
+ removed.push(p);
36
+ }
37
+ return { added, removed, modified };
38
+ }
@@ -0,0 +1,8 @@
1
+ import type Database from "better-sqlite3";
2
+ export declare function exportRelease({ db, blobsDir, beeName, version, outPath, }: {
3
+ db: Database.Database;
4
+ blobsDir: string;
5
+ beeName: string;
6
+ version: string;
7
+ outPath: string;
8
+ }): void;
@@ -0,0 +1,31 @@
1
+ import { mkdirSync, writeFileSync, readFileSync, rmSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { runTar } from "./tar-runtime.js";
4
+ export function exportRelease({ db, blobsDir, beeName, version, outPath, }) {
5
+ const id = db
6
+ .prepare("SELECT id FROM bee_release WHERE bee_name = ? AND version = ?")
7
+ .get(beeName, version)?.id;
8
+ if (!id)
9
+ throw new Error("VERSION_NOT_FOUND");
10
+ const manifestRows = db.prepare("SELECT * FROM bee_manifest WHERE release_id = ?").all(id);
11
+ const segRows = db.prepare("SELECT * FROM bee_segment_ref WHERE release_id = ?").all(id);
12
+ const fileRows = db
13
+ .prepare("SELECT * FROM bee_file WHERE release_id = ?")
14
+ .all(id);
15
+ const changeRows = db.prepare("SELECT * FROM bee_change WHERE release_id = ?").all(id);
16
+ const stageDir = join(outPath + ".stage");
17
+ mkdirSync(stageDir, { recursive: true });
18
+ writeFileSync(join(stageDir, "manifest.json"), JSON.stringify({ bee_name: beeName, version, manifestRows, segRows, fileRows, changeRows }, null, 2));
19
+ mkdirSync(join(stageDir, "blobs"), { recursive: true });
20
+ for (const f of fileRows) {
21
+ const src = join(blobsDir, f.sha256.slice(0, 2), f.sha256);
22
+ const dest = join(stageDir, "blobs", f.sha256);
23
+ writeFileSync(dest, readFileSync(src));
24
+ }
25
+ try {
26
+ runTar(["-czf", outPath, "-C", stageDir, "."]);
27
+ }
28
+ finally {
29
+ rmSync(stageDir, { recursive: true, force: true });
30
+ }
31
+ }
@@ -0,0 +1,13 @@
1
+ import type Database from "better-sqlite3";
2
+ /**
3
+ * Garbage-collect content-addressed blobs under `blobsDir/<aa>/<sha>` that
4
+ * no `bee_file` row currently references.
5
+ *
6
+ * @param dryRun if true, list removed SHAs without deleting files.
7
+ * @returns the list of removed SHA names.
8
+ */
9
+ export declare function gcBlobs({ db, blobsDir, dryRun, }: {
10
+ db: Database.Database;
11
+ blobsDir: string;
12
+ dryRun: boolean;
13
+ }): string[];
@@ -0,0 +1,32 @@
1
+ import { readdirSync, rmSync, existsSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ /**
4
+ * Garbage-collect content-addressed blobs under `blobsDir/<aa>/<sha>` that
5
+ * no `bee_file` row currently references.
6
+ *
7
+ * @param dryRun if true, list removed SHAs without deleting files.
8
+ * @returns the list of removed SHA names.
9
+ */
10
+ export function gcBlobs({ db, blobsDir, dryRun, }) {
11
+ const refs = new Set(db.prepare("SELECT DISTINCT sha256 FROM bee_file").all().map((r) => r.sha256));
12
+ const removed = [];
13
+ if (!existsSync(blobsDir))
14
+ return removed;
15
+ for (const sub of readdirSync(blobsDir)) {
16
+ const subDir = join(blobsDir, sub);
17
+ if (!statSync(subDir).isDirectory())
18
+ continue;
19
+ for (const sha of readdirSync(subDir)) {
20
+ if (refs.has(sha))
21
+ continue;
22
+ const p = join(subDir, sha);
23
+ if (dryRun) {
24
+ removed.push(sha);
25
+ continue;
26
+ }
27
+ rmSync(p);
28
+ removed.push(sha);
29
+ }
30
+ }
31
+ return removed;
32
+ }
@@ -0,0 +1,7 @@
1
+ import type Database from "better-sqlite3";
2
+ export declare function importRelease({ db, blobsDir, inPath, asName, }: {
3
+ db: Database.Database;
4
+ blobsDir: string;
5
+ inPath: string;
6
+ asName?: string;
7
+ }): void;
@@ -0,0 +1,59 @@
1
+ import { readFileSync, mkdirSync, writeFileSync, existsSync, rmSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { assertNotSystemPath } from "../sediment/pool-paths.js";
4
+ import { runTar } from "./tar-runtime.js";
5
+ export function importRelease({ db, blobsDir, inPath, asName, }) {
6
+ const stageDir = inPath + ".extract";
7
+ if (existsSync(stageDir))
8
+ rmSync(stageDir, { recursive: true, force: true });
9
+ mkdirSync(stageDir, { recursive: true });
10
+ let extractOk = false;
11
+ try {
12
+ runTar(["-xzf", inPath, "-C", stageDir]);
13
+ extractOk = true;
14
+ }
15
+ finally {
16
+ if (!extractOk)
17
+ rmSync(stageDir, { recursive: true, force: true });
18
+ }
19
+ // ExportPayload (defined in ./types.ts) is the structural contract
20
+ // shared with release-export.ts, which writes the same JSON shape
21
+ // into <stageDir>/manifest.json. Minor #13: replace the previous
22
+ // inline anonymous type so producer and consumer stay in lock-step.
23
+ const payload = JSON.parse(readFileSync(join(stageDir, "manifest.json"), "utf-8"));
24
+ const beeName = asName ?? payload.bee_name;
25
+ assertNotSystemPath(beeName);
26
+ // Always check collision (the asName path previously skipped it and
27
+ // fell through to a UNIQUE-constraint mid-INSERT failure). Whether
28
+ // the user gave an explicit asName or relied on payload.bee_name, a
29
+ // pre-existing row must be reported cleanly.
30
+ if (db.prepare("SELECT 1 FROM bee_release WHERE bee_name = ?").get(beeName)) {
31
+ throw new Error("IMPORT_NAME_COLLIDES");
32
+ }
33
+ // Copy blobs
34
+ for (const f of payload.fileRows) {
35
+ const dest = join(blobsDir, f.sha256.slice(0, 2));
36
+ mkdirSync(dest, { recursive: true });
37
+ writeFileSync(join(dest, f.sha256), readFileSync(join(stageDir, "blobs", f.sha256)));
38
+ }
39
+ // Re-insert rows: pick a new release id, mirror payload rows
40
+ const tx = db.transaction(() => {
41
+ const ins = db.prepare(`INSERT INTO bee_release (bee_name, version, source, archived_at, archived_by, user_intent_raw, description, parent_version, changelog) VALUES (?, ?, 'user', ?, 'user', ?, ?, ?, ?)`);
42
+ const id = ins.run(beeName, payload.version, new Date().toISOString(), null, null, null, null).lastInsertRowid;
43
+ db.prepare(`INSERT OR REPLACE INTO bee_release_pointer (bee_name, latest_version, released_at) VALUES (?, ?, ?)`).run(beeName, payload.version, new Date().toISOString());
44
+ for (const m of payload.manifestRows) {
45
+ db.prepare(`INSERT INTO bee_manifest (release_id, schema_version, description, segments_json, entrypoint_preamble, promotion, min_cycles, requires_human, requires_smoke, retire_on_misses) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, m.schema_version, m.description, m.segments_json, m.entrypoint_preamble, m.promotion, m.min_cycles, m.requires_human, m.requires_smoke, m.retire_on_misses);
46
+ }
47
+ for (const s of payload.segRows) {
48
+ db.prepare(`INSERT INTO bee_segment_ref (release_id, segment_name, inputs_json, outputs_json, side_effects) VALUES (?, ?, ?, ?, ?)`).run(id, s.segment_name, s.inputs_json, s.outputs_json, s.side_effects);
49
+ }
50
+ for (const f of payload.fileRows) {
51
+ db.prepare(`INSERT INTO bee_file (release_id, owner_kind, owner_name, path, kind, size_bytes, sha256, blob_path) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(id, f.owner_kind, beeName, f.path, f.kind, f.size_bytes, f.sha256, f.blob_path);
52
+ }
53
+ for (const c of payload.changeRows) {
54
+ db.prepare(`INSERT INTO bee_change (release_id, change_kind, target_kind, target_name, detail) VALUES (?, ?, ?, ?, ?)`).run(id, c.change_kind, c.target_kind, c.target_name, c.detail);
55
+ }
56
+ });
57
+ tx();
58
+ rmSync(stageDir, { recursive: true, force: true });
59
+ }
@@ -0,0 +1,23 @@
1
+ import type Database from "better-sqlite3";
2
+ import type { BeeManifest } from "../sediment/types.js";
3
+ /** Compute the sha256 hash and byte length of a single file. */
4
+ export declare function sha256OfFile(p: string): {
5
+ sha: string;
6
+ bytes: number;
7
+ };
8
+ /** Copy a file into the content-addressed blob store under `blobsDir/<aa>/<sha>`
9
+ * if not already present, and return the relative blob_path used by `bee_file`. */
10
+ export declare function ensureBlob(blobsDir: string, sha: string, srcPath: string): string;
11
+ export declare function walk(root: string, base?: string): Generator<{
12
+ abs: string;
13
+ rel: string;
14
+ }>;
15
+ export declare function retainRelease({ db, blobsDir, scratchDir, manifest, version: explicitVersion, parentVersion, changelog, }: {
16
+ db: Database.Database;
17
+ blobsDir: string;
18
+ scratchDir: string;
19
+ manifest: BeeManifest;
20
+ version?: string;
21
+ parentVersion?: string;
22
+ changelog?: string;
23
+ }): number;