peaks-loop 4.0.49 → 4.0.51

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 (179) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README-en.md +1 -1
  3. package/README.md +1 -1
  4. package/dist/cli/commands/audit-commands.js +1 -0
  5. package/dist/cli/commands/baseline-commands.js +163 -25
  6. package/dist/cli/commands/core/skill-command.js +53 -4
  7. package/dist/cli/commands/core/standards-command.d.ts +24 -0
  8. package/dist/cli/commands/core/standards-command.js +74 -0
  9. package/dist/cli/commands/hooks-commands.js +55 -38
  10. package/dist/cli/commands/share-commands.js +113 -20
  11. package/dist/cli/commands/web-commands.js +8 -1
  12. package/dist/cli/commands/workflow-lifecycle-commands.d.ts +6 -0
  13. package/dist/cli/commands/workflow-lifecycle-commands.js +64 -3
  14. package/dist/services/adapter/adapter.d.ts +30 -0
  15. package/dist/services/adapter/auto-adapter.d.ts +13 -0
  16. package/dist/services/adapter/claude-adapter.js +12 -0
  17. package/dist/services/adapter/codex-adapter.d.ts +12 -0
  18. package/dist/services/adapter/codex-adapter.js +12 -0
  19. package/dist/services/adapter/copilot-adapter.d.ts +12 -0
  20. package/dist/services/adapter/copilot-adapter.js +12 -0
  21. package/dist/services/audit/backing-detector.d.ts +25 -7
  22. package/dist/services/audit/backing-detector.js +33 -17
  23. package/dist/services/audit/enforcer-liveness.d.ts +12 -0
  24. package/dist/services/audit/enforcer-liveness.js +100 -0
  25. package/dist/services/audit/enforcers/lint-catalog-governance.d.ts +23 -11
  26. package/dist/services/audit/enforcers/lint-catalog-governance.js +10 -14
  27. package/dist/services/audit/enforcers/lint-rd-handoff-coverage.d.ts +5 -15
  28. package/dist/services/audit/enforcers/lint-rd-handoff-coverage.js +94 -25
  29. package/dist/services/audit/enforcers/lint-style.d.ts +9 -1
  30. package/dist/services/audit/enforcers/lint-style.js +38 -2
  31. package/dist/services/audit/prose-ratio-calculator.d.ts +28 -17
  32. package/dist/services/audit/prose-ratio-calculator.js +25 -18
  33. package/dist/services/audit/red-line-catalog-p2-a.js +1 -1
  34. package/dist/services/audit/red-lines-service.js +51 -7
  35. package/dist/services/capability-audit-service/independent-checker.d.ts +15 -0
  36. package/dist/services/capability-audit-service/independent-checker.js +140 -0
  37. package/dist/services/capability-audit-service/index.d.ts +3 -1
  38. package/dist/services/capability-audit-service/index.js +1 -0
  39. package/dist/services/capability-audit-service/runner.d.ts +17 -13
  40. package/dist/services/capability-audit-service/runner.js +76 -15
  41. package/dist/services/capability-audit-service/types.d.ts +48 -0
  42. package/dist/services/capability-guard-runner/contracts/J01.js +21 -22
  43. package/dist/services/capability-guard-runner/contracts/J02.d.ts +1 -1
  44. package/dist/services/capability-guard-runner/contracts/J02.js +114 -28
  45. package/dist/services/capability-guard-runner/contracts/J03.d.ts +13 -0
  46. package/dist/services/capability-guard-runner/contracts/J03.js +72 -21
  47. package/dist/services/capability-guard-runner/contracts/J04.d.ts +6 -0
  48. package/dist/services/capability-guard-runner/contracts/J04.js +65 -32
  49. package/dist/services/capability-guard-runner/contracts/J05.js +118 -16
  50. package/dist/services/capability-guard-runner/contracts/J06.d.ts +14 -0
  51. package/dist/services/capability-guard-runner/contracts/J06.js +57 -39
  52. package/dist/services/capability-guard-runner/contracts/J07.d.ts +9 -0
  53. package/dist/services/capability-guard-runner/contracts/J07.js +76 -47
  54. package/dist/services/capability-guard-runner/contracts/J08.d.ts +11 -0
  55. package/dist/services/capability-guard-runner/contracts/J08.js +66 -39
  56. package/dist/services/capability-guard-runner/contracts/J09.d.ts +13 -0
  57. package/dist/services/capability-guard-runner/contracts/J09.js +95 -39
  58. package/dist/services/capability-guard-runner/contracts/J10.d.ts +12 -0
  59. package/dist/services/capability-guard-runner/contracts/J10.js +69 -35
  60. package/dist/services/capability-guard-runner/contracts/J11.d.ts +8 -0
  61. package/dist/services/capability-guard-runner/contracts/J11.js +73 -33
  62. package/dist/services/capability-guard-runner/contracts/J12.d.ts +12 -0
  63. package/dist/services/capability-guard-runner/contracts/J12.js +66 -30
  64. package/dist/services/capability-guard-runner/contracts/J13.d.ts +11 -0
  65. package/dist/services/capability-guard-runner/contracts/J13.js +62 -40
  66. package/dist/services/capability-guard-runner/contracts/J14.d.ts +11 -0
  67. package/dist/services/capability-guard-runner/contracts/J14.js +60 -31
  68. package/dist/services/capability-guard-runner/contracts/J15.d.ts +11 -0
  69. package/dist/services/capability-guard-runner/contracts/J15.js +70 -35
  70. package/dist/services/capability-guard-runner/contracts/_shared.d.ts +24 -0
  71. package/dist/services/capability-guard-runner/contracts/_shared.js +67 -0
  72. package/dist/services/capability-guard-runner/registry.d.ts +5 -0
  73. package/dist/services/capability-guard-runner/registry.js +140 -0
  74. package/dist/services/capability-guard-runner/runner.d.ts +26 -0
  75. package/dist/services/capability-guard-runner/runner.js +63 -6
  76. package/dist/services/code/auto-compact-modes.d.ts +13 -2
  77. package/dist/services/code/auto-compact-modes.js +20 -4
  78. package/dist/services/code/post-compact-detector.js +20 -11
  79. package/dist/services/code/step-08-gate.js +21 -6
  80. package/dist/services/config/config-safety.js +11 -9
  81. package/dist/services/dispatch/sub-agent-dispatcher.d.ts +11 -30
  82. package/dist/services/dispatch/sub-agent-dispatcher.js +5 -48
  83. package/dist/services/final-review/pre-post-diff.js +10 -2
  84. package/dist/services/ide/adapters/claude-code-adapter.js +0 -1
  85. package/dist/services/ide/adapters/codex-adapter.js +1 -2
  86. package/dist/services/ide/adapters/cursor-adapter.js +1 -2
  87. package/dist/services/ide/adapters/hermes-adapter.js +1 -2
  88. package/dist/services/ide/adapters/openclaw-adapter.js +1 -2
  89. package/dist/services/ide/adapters/qoder-adapter.js +1 -2
  90. package/dist/services/ide/adapters/tongyi-lingma-adapter.js +1 -2
  91. package/dist/services/ide/adapters/trae-adapter.js +1 -2
  92. package/dist/services/ide/adapters/zcode-adapter.js +0 -1
  93. package/dist/services/ide/ide-types.d.ts +0 -2
  94. package/dist/services/observability/observability-service.d.ts +1 -1
  95. package/dist/services/scan/api-diff-types.js +20 -2
  96. package/dist/services/security/safe-settings-path.js +19 -1
  97. package/dist/services/skill/skill-search-service.d.ts +3 -3
  98. package/dist/services/standards/loop-engineering-lint.d.ts +1 -1
  99. package/dist/services/standards/loop-engineering-lint.js +6 -0
  100. package/dist/services/web/daemon-registry.js +27 -2
  101. package/dist/services/workspace/claude-settings-template.d.ts +53 -37
  102. package/dist/services/workspace/claude-settings-template.js +105 -83
  103. package/dist/services/workspace/generated-artifacts-stamp.d.ts +119 -0
  104. package/dist/services/workspace/generated-artifacts-stamp.js +167 -0
  105. package/dist/services/workspace/workspace-claude-settings-materializer.d.ts +8 -0
  106. package/dist/services/workspace/workspace-claude-settings-materializer.js +38 -3
  107. package/dist/services/workspace/workspace-service.js +11 -1
  108. package/dist/shared/fs-utils.d.ts +26 -0
  109. package/dist/shared/fs-utils.js +35 -0
  110. package/package.json +9 -7
  111. package/scripts/copy-templates.mjs +0 -12
  112. package/scripts/install-skills.mjs +154 -53
  113. package/skills/bee/peaks-perf-audit/SKILL.md +2 -2
  114. package/skills/bee/peaks-perf-audit/references/audit-protocol.md +1 -1
  115. package/skills/bee/peaks-prd/SKILL.md +3 -3
  116. package/skills/bee/peaks-prd/references/prd-for-multi-pass.md +1 -1
  117. package/skills/bee/peaks-prd/references/workflow.md +1 -1
  118. package/skills/bee/peaks-qa/SKILL.md +6 -7
  119. package/skills/bee/peaks-qa/references/external-capability-guidance.md +1 -1
  120. package/skills/bee/peaks-qa/references/qa-fanout-contract.md +1 -1
  121. package/skills/bee/peaks-qa/references/reading-handoff-frontmatter.md +2 -2
  122. package/skills/bee/peaks-rd/SKILL.md +2 -3
  123. package/skills/bee/peaks-rd/references/code-reviewer-4dim-hint.md +1 -1
  124. package/skills/bee/peaks-rd/references/external-references.md +1 -1
  125. package/skills/bee/peaks-rd/references/mandatory-perf-baseline.md +1 -1
  126. package/skills/bee/peaks-rd/references/ocr-multilang-1.8.md +2 -2
  127. package/skills/bee/peaks-rd/references/parallel-review-fanout.md +2 -2
  128. package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +11 -8
  129. package/skills/bee/peaks-rd/references/rd-runbook.md +1 -1
  130. package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +7 -7
  131. package/skills/bee/peaks-rd/references/rd-transition-gates.md +1 -1
  132. package/skills/bee/peaks-rd/references/reading-v2-slice-results.md +1 -1
  133. package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +7 -5
  134. package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +3 -3
  135. package/skills/bee/peaks-reviewer/SKILL.md +1 -1
  136. package/skills/bee/peaks-security-audit/SKILL.md +3 -3
  137. package/skills/bee/peaks-security-audit/references/audit-protocol.md +1 -1
  138. package/skills/bee/peaks-txt/references/context-capsule.md +1 -1
  139. package/skills/bee/peaks-ui/SKILL.md +1 -1
  140. package/skills/peaks-audit/SKILL.md +1 -1
  141. package/skills/peaks-code/SKILL.md +20 -18
  142. package/skills/peaks-code/references/context-governance.md +1 -1
  143. package/skills/peaks-code/references/dag-orchestrator.md +3 -4
  144. package/skills/peaks-code/references/external-references.md +1 -1
  145. package/skills/peaks-code/references/external-skill-invocation.md +2 -2
  146. package/skills/peaks-code/references/fanout-mandatory.md +3 -3
  147. package/skills/peaks-code/references/frontend-only-mode.md +2 -2
  148. package/skills/peaks-code/references/gstack-integration.md +1 -1
  149. package/skills/peaks-code/references/micro-cycle.md +1 -1
  150. package/skills/peaks-code/references/periodic-checkpoint.md +4 -4
  151. package/skills/peaks-code/references/project-scan-checklist.md +1 -1
  152. package/skills/peaks-code/references/resume-detection.md +1 -1
  153. package/skills/peaks-code/references/runbook.md +6 -3
  154. package/skills/peaks-code/references/session-overload-signal-index.md +6 -4
  155. package/skills/peaks-code/references/startup-sequence.md +17 -17
  156. package/skills/peaks-code/references/step-0-8-gate.md +1 -1
  157. package/skills/peaks-code/references/step-11-memory-sediment.md +2 -2
  158. package/skills/peaks-code/references/sub-agent-dispatch.md +26 -25
  159. package/skills/peaks-code/references/swarm-dispatch-contract.md +1 -1
  160. package/skills/peaks-code/references/workflow-gates-and-types.md +3 -3
  161. package/skills/peaks-code/references/worktree-governance.md +1 -1
  162. package/skills/peaks-final-review/SKILL.md +3 -3
  163. package/skills/peaks-ide/references/audit-log-helper.md +5 -4
  164. package/skills/peaks-resume/SKILL.md +1 -1
  165. package/skills/peaks-slice-decompose/SKILL.md +4 -4
  166. package/skills/peaks-slice-decompose/references/cross-pass-edge-interpretation.md +1 -1
  167. package/skills/peaks-slice-decompose/references/granularity-decision.md +1 -1
  168. package/skills/peaks-slice-decompose/references/v2-schema.md +2 -2
  169. package/skills/peaks-solo/SKILL.md +1 -2
  170. package/dist/cli/commands/context-builder-commands.d.ts +0 -11
  171. package/dist/cli/commands/context-builder-commands.js +0 -85
  172. package/dist/services/hooks/write-gate.js +0 -111
  173. package/skills/bee/peaks-prd/references/command-migration.md +0 -3
  174. package/skills/bee/peaks-qa/references/command-migration.md +0 -3
  175. package/skills/bee/peaks-rd/references/command-migration.md +0 -3
  176. package/skills/bee/peaks-sc/references/command-migration.md +0 -3
  177. package/skills/bee/peaks-txt/references/command-migration.md +0 -3
  178. package/skills/bee/peaks-ui/references/command-migration.md +0 -3
  179. package/skills/peaks-code/references/command-migration.md +0 -3
@@ -4,4 +4,4 @@
4
4
 
5
5
  Map gstack stages to Peaks-Loop role artifacts; preserve Peaks-Loop confirmation gates. Do not delegate orchestration to gstack commands.
6
6
 
7
- For frontend workflows, RD and QA must use Playwright MCP for real browser E2E. The consuming LLM detects the MCP from its own tool list: any Playwright MCP entry in the LLM tool list means the MCP is installed; absent means the user needs to install (`claude mcp add playwright -- npx @playwright/mcp@latest` in Claude Code; other IDEs have their own MCP install path). The LLM invokes the tool directly (browser_navigate / browser_click / browser_snapshot / browser_take_screenshot / browser_console_messages / browser_network_requests / browser_close) by name — there is no peaks-loop indirection. Chrome DevTools MCP is a secondary CDP surface only. Sanitize browser artifacts before retention (no login URLs, cookies, tokens, PII). See `references/browser-workflow.md`.
7
+ For frontend workflows, RD and QA must use Playwright MCP for real browser E2E. The consuming LLM detects the MCP from its own tool list: any Playwright MCP entry in the LLM tool list means the MCP is installed; absent means the user needs to install (`claude mcp add playwright -- npx @playwright/mcp@latest` in Claude Code; other IDEs have their own MCP install path). The LLM invokes the tool directly (browser_navigate / browser_click / browser_snapshot / browser_take_screenshot / browser_console_messages / browser_network_requests / browser_close) by name — there is no peaks-loop indirection. Chrome DevTools MCP is a secondary CDP surface only. Sanitize browser artifacts before retention (no login URLs, cookies, tokens, PII). See `browser-workflow.md`.
@@ -182,7 +182,7 @@ Code is itself a skill running in the current session. There are **two distinct
182
182
 
183
183
  After RD completes (whether inline or sub-agent), Code does not stop — it must advance to QA. There is no "RD done, ask the user" state in full-auto mode. The only valid stops are: (a) QA verdict=pass, (b) repair cap hit, (c) explicit user cancel.
184
184
 
185
- **RD's internal reviews are already parallelized.** When RD finishes implementation, it issues a 3-way sub-agent fan-out (code-review + security-review + perf-baseline, see `skills/peaks-rd/SKILL.md` "Parallel review fan-out") and waits for all to return before transitioning to `qa-handoff`. Code does NOT need to track three separate RD-side sub-runs; the RD role owns the fan-out lifecycle end-to-end. Code's presence restoration after the swarm converges is the only coordination point.
185
+ **RD's internal reviews are already parallelized.** When RD finishes implementation, it issues a 3-way sub-agent fan-out (code-review + security-review + perf-baseline, see `skills/bee/peaks-rd/SKILL.md` "Parallel review fan-out") and waits for all to return before transitioning to `qa-handoff`. Code does NOT need to track three separate RD-side sub-runs; the RD role owns the fan-out lifecycle end-to-end. Code's presence restoration after the swarm converges is the only coordination point.
186
186
 
187
187
  **Presence restoration after RD/QA work returns (MANDATORY):** In v1.x, role skills called `peaks skill presence:set <role>` internally and stomped on `.peaks/.active-skill.json`. From v1.3 onward, sub-agents in the Swarm path are forbidden from calling `peaks skill presence:set` (see "Sub-agent dispatch" in each role's SKILL.md), so the main loop's presence file is preserved across the fan-out window by construction. The one place Code still has to actively restore presence is **once after the fan-out returns** (gate=swarm-converged) and again **after each RD↔QA repair iteration** (gate=repair-cycle-<N>). Use the same command from Step 2 with the current mode and the gate that has just advanced:
188
188
 
@@ -26,8 +26,8 @@ checkpoint as often as it wants.
26
26
  > (i.e. on each 20-call mark, not "approximately every 20"). The CLI
27
27
  > does **not** expose a `--periodic-every <n>` override flag — the
28
28
  > cadence is owned by the skill, not the CLI. Any patch that relaxes
29
- > this must update both files in lockstep or fail the
30
- > `tests/unit/code/checkpoint-periodic-frequency.test.ts` guard.
29
+ > this must update both files in lockstep; no guard fails on the drift
30
+ > — the test that pinned the cadence was deleted in `f17aa377`.
31
31
 
32
32
  ## Checkpoint CLI contract
33
33
 
@@ -72,10 +72,10 @@ This step is strictly IDE-agnostic. The LLM calls the peaks CLI; no IDE-specific
72
72
 
73
73
  ## Companion surface — auto-compact (zero-pause)
74
74
 
75
- When the runner crosses the v2.13.0 auto-compact thresholds (0.85 pre-compact / 0.95 red-line), `peaks session checkpoint` is NOT enough on its own — the LLM must also fire `peaks code auto-compact` (or wait for the in-band PreToolUse hook at ratio ≥ 0.95 to compact the runner itself). See:
75
+ When the runner crosses the v2.13.0 auto-compact thresholds (0.80 auto-fire / 0.85 pre-compact / 0.95 red-line), `peaks session checkpoint` is NOT enough on its own — the LLM must also fire `peaks code auto-compact` (or wait for the in-band PreToolUse hook at ratio ≥ 0.95 to compact the runner itself). See:
76
76
 
77
77
  - `peaks code auto-compact` — orchestrator that writes the convergence plan + dispatches the compact pathway
78
78
  - `peaks code auto-compact` — the PreToolUse hook entrypoint fired by `.claude/settings.local.json` (slice 2026-07-02-auto-compact-zero-pause)
79
79
  - `.peaks/memory/2026-06-27-auto-compact-design.md` — zero-human-intervention design rationale
80
80
 
81
- The two surfaces compose: `peaks session checkpoint` persists the context state, `peaks code auto-compact` collapses the runner's window. The LLM fires both in the 0.85–0.95 zone; the hook fires alone at ≥ 0.95.
81
+ The two surfaces compose: `peaks session checkpoint` persists the context state, `peaks code auto-compact` collapses the runner's window. The LLM fires both from the 0.80 auto-fire line up (that is the tier `peaks skill presence` reports first); the 0.85–0.95 band is the "already fired" zone, and the hook fires alone at ≥ 0.95.
@@ -1,6 +1,6 @@
1
1
  # Peaks-Loop Pre-RD project scan checklist
2
2
 
3
- > Extracted from `skills/peaks-code/SKILL.md` on 2026-06-09 (slice 019 — slim skill files to references) to keep SKILL.md under the 800-line cap from `common/coding-style.md`. The content below is the verbatim Pre-RD project scan checklist that was previously inline; nothing was paraphrased, just relocated.
3
+ > Extracted from `skills/peaks-code/SKILL.md` on 2026-06-09 (slice 019 — slim skill files to references) to keep SKILL.md under the 800-line cap from `.peaks/standards/common/coding-style.md`. The content below is the verbatim Pre-RD project scan checklist that was previously inline; nothing was paraphrased, just relocated.
4
4
 
5
5
  Before handing off to `peaks-rd`, scan the project and record findings to `.peaks/project-scan/project-scan.md` (project-level, git-tracked; sibling of `.peaks/PROJECT.md`). RD and UI roles read this before starting work. **project-scan.md is a project-scoped singleton** — check if it already exists before regenerating (e.g. via `ls .peaks/project-scan/project-scan.md`). If it exists and is complete (has `## Archetype` and `## Project mode` sections), reuse it. Only regenerate if missing or incomplete.
6
6
 
@@ -66,4 +66,4 @@ done
66
66
  **Strict quality guarantee (per user's hard rule: "严格要保证不能比当前的效果差")**:
67
67
  - If no in-flight slice is detected, this step is a no-op: zero extra commands beyond the existing Step 0 probe, zero extra token cost.
68
68
  - If an in-flight slice is detected, the cost is one `find` + one `grep` loop (sub-millisecond) + one `AskUserQuestion` (one round-trip). The savings are 3-5k tokens (the cost of manually re-reading 3-5 artifact files).
69
- - The dogfood test in `tests/unit/skill-resume-mode.test.ts` (8 cases, bash-fixture shim — the legacy interface used by `skills/peaks-resume`) and `tests/unit/services/skill/resume-detector.test.ts` (24 cases, the canonical TypeScript classifier at `src/services/skill/resume-detector.ts`) together cover: (a) fresh / complete / resume:rd-planning / resume:qa-validation / resume:txt-handoff state-based classifications, (b) the "Other resume triggers" overrides (missing `rd/tech-doc.md` → `rd-planning`; missing `rd/code-review.md` or `rd/security-review.md` → `rd-review-fanout`; missing `qa/test-reports/<rid>.md` → `qa-execution`), (c) the mid-implementation distinction (`spec-locked` / `implemented` / `running` / `blocked` all return `in-flight:<state>`), (d) the primary-vs-abandoned filter (multiple RDs → spec-locked wins; single blocked RD stays primary; 2+ all-abandoned → fresh), (e) the legacy `.peaks/_runtime/<sessionId>/` path fallback, and (f) determinism across two invocations on the same fixture.
69
+ - The canonical classifier is `src/services/skill/resume-detector.ts`; the legacy bash-fixture shim used by `skills/peaks-resume` is `tests/fixtures/skill-resume-mode-detect.sh`. No unit test pins either today — the two suites that did (8 dogfood cases + 24 classifier cases) were deleted in `f17aa377`. The behaviours they covered were: (a) fresh / complete / resume:rd-planning / resume:qa-validation / resume:txt-handoff state-based classifications, (b) the "Other resume triggers" overrides (missing `rd/tech-doc.md` → `rd-planning`; missing `rd/code-review.md` or `rd/security-review.md` → `rd-review-fanout`; missing `qa/test-reports/<rid>.md` → `qa-execution`), (c) the mid-implementation distinction (`spec-locked` / `implemented` / `running` / `blocked` all return `in-flight:<state>`), (d) the primary-vs-abandoned filter (multiple RDs → spec-locked wins; single blocked RD stays primary; 2+ all-abandoned → fresh), (e) the legacy `.peaks/_runtime/<sessionId>/` path fallback, and (f) determinism across two invocations on the same fixture.
@@ -2,11 +2,11 @@
2
2
 
3
3
  > **Maintenance**: The numbered workflow list in `skills/peaks-code/SKILL.md` (steps 0-11) is the canonical phase sequence. This runbook is the executable CLI transcription. When updating, keep both in lockstep — a change to one must be reflected in the other.
4
4
  >
5
- > **Why this is a reference, not inline**: the runbook is a stable, copy-pasteable shell (~150 lines of bash) that does not change between skill runs. Inlining it bloats the orchestrator skill body past the 800-line cap (per `common/coding-style.md`). Extracting it here keeps SKILL.md focused on flow / decisions / contracts, while the runbook stays as the canonical place for the CLI sequence.
5
+ > **Why this is a reference, not inline**: the runbook is a stable, copy-pasteable shell (~150 lines of bash) that does not change between skill runs. Inlining it bloats the orchestrator skill body past the 800-line cap (per `.peaks/standards/common/coding-style.md`). Extracting it here keeps SKILL.md focused on flow / decisions / contracts, while the runbook stays as the canonical place for the CLI sequence.
6
6
  >
7
7
  > **How peaks-loop tooling reads this file**:
8
- > - `peaks skill runbook peaks-code` (CLI) reads the `## Default runbook` section in either SKILL.md or `references/runbook.md` (whichever has the bash code).
9
- > - The test in `tests/unit/skill-default-runbook.test.ts` looks for `## Default runbook` in SKILL.md first, then falls back to `references/runbook.md` here.
8
+ > - `peaks skill runbook peaks-code` (CLI) reads the `## Default runbook` section in either SKILL.md or `runbook.md` (whichever has the bash code).
9
+ > - The CLI applies the same fallback: `## Default runbook` in SKILL.md first, then `runbook.md` here. The test that asserted this was deleted in `f17aa377`.
10
10
 
11
11
  ## Default runbook — CLI sequence
12
12
 
@@ -299,6 +299,9 @@ peaks code emit-handoff --project <repo> --job-id <jid> --json
299
299
 
300
300
  # v3.1.2 forced auto-compact: when --enforce-job-mode is set OR
301
301
  # job-shape.json says isJob=true, ≥0.85 is MANDATORY auto-compact.
302
+ # The trigger line is actually 0.80, not 0.85: `peaks skill presence`
303
+ # reports action='auto-fire' from ≥0.80 and that tier is already mandatory
304
+ # in every mode, so context-now's 0.85 is the *second* line to arrive.
302
305
  # Code MUST call this without confirmation under Job mode.
303
306
  peaks code context-now --project <repo> --enforce-job-mode --json
304
307
  peaks code auto-compact --project <repo> --json
@@ -8,15 +8,15 @@
8
8
  When the LLM senses context pressure, it must consult these 7 signals before
9
9
  deciding to (a) auto-compact, (b) refuse the next slice, or (c) ask the user to
10
10
  open a new session. The contract is: **LLM never re-asks the user about
11
- cost/length/context** (red line #2 of `references/job-loop.md`). This index is
11
+ cost/length/context** (red line #2 of `job-loop.md`). This index is
12
12
  the lookup table the LLM must consult in lieu of intuition.
13
13
 
14
14
  ## The 7 signals
15
15
 
16
16
  | # | Signal source | Threshold | File / CLI | LLM action |
17
17
  |---|---|---|---|---|
18
- | 1 | prompt size (main session) | 50% / 75% / 80% / 90% | `src/services/context/threshold.ts`; probe via `peaks code context-now` | soft-warn at 50%; consider compact at 75%; MUST NOT auto-compact mid-batch (D6.e); Job mode ≥ 0.85 ⇒ MANDATORY `peaks code auto-compact` |
19
- | 2 | auto-compact zone | 0.85 pre-compact / 0.95 red-line | `src/services/code/auto-compact-orchestrator.ts`; `--enforce-job-mode` flag | Auto-fires `peaks code auto-compact`; LLM MUST NOT prompt user to compact (zero-pause contract v2.13.0) |
18
+ | 1 | prompt size (main session) | 50% / 75% / 80% / 90% | `src/services/context/threshold.ts`; probe via `peaks code context-now` | soft-warn at 50%; consider compact at 75%; MUST NOT auto-compact mid-batch (D6.e); ≥ 0.80 (`auto-fire`) ⇒ MANDATORY `peaks code auto-compact` |
19
+ | 2 | auto-compact zone | 0.80 auto-fire / 0.85 pre-compact / 0.95 red-line | `src/services/code/auto-compact-orchestrator.ts`; `--enforce-job-mode` flag | Auto-fires `peaks code auto-compact`; the 0.80 `auto-fire` tier is the one that fires first (`peaks skill presence` reports it); LLM MUST NOT prompt user to compact (zero-pause contract v2.13.0) |
20
20
  | 3 | sub-agent dispatch prompt size | 50% / 75% / 80% | `src/services/context/context-guard.ts`; `peaks sub-agent-dispatch-guard` PreToolUse hook | soft-warn at 50%; CONTEXT_NEAR_LIMIT at 75%; hard-reject at 80% (CLI + hook double-guard) |
21
21
  | 4 | statusline compact bar | visual | `src/services/compact-statusline/compact-statusline-service.ts` | ambient UI; surfaces queued/preparing/compacting/verifying/completed/failed/stalled |
22
22
  | 5 | in-flight batch deferral | D6.e | `src/services/code/auto-compact-modes.ts` | defer compact until batch lands (NOT "new session") |
@@ -25,7 +25,7 @@ the lookup table the LLM must consult in lieu of intuition.
25
25
 
26
26
  ## Hard rules
27
27
 
28
- - peaks-code SKILL.md red line #2 (see `references/job-loop.md`):
28
+ - peaks-code SKILL.md red line #2 (see `job-loop.md`):
29
29
  **Re-ask the user about cost / length / context is forbidden**.
30
30
  The LLM MUST NOT prompt the user to open a new session based on overload
31
31
  intuition alone; it MUST consult the 7 signals above and prefer auto-compact /
@@ -44,6 +44,8 @@ LLM senses context pressure
44
44
  │ ├─ 0.75 ≤ ratio < 0.85 → compact-zone candidate
45
45
  │ │ ├─ Job mode → MUST auto-compact now
46
46
  │ │ └─ non-Job → wait for next idle turn, then compact
47
+ │ ├─ 0.80 ≤ ratio < 0.85 → auto-fire zone; `peaks skill presence` reports
48
+ │ │ `action: 'auto-fire'` → auto-compact MUST fire (do NOT wait for 0.85)
47
49
  │ ├─ 0.85 ≤ ratio < 0.95 → pre-compact zone; auto-compact MUST fire
48
50
  │ └─ ratio ≥ 0.95 → red-line; compact REQUESTED, dispatch NOT blocked (Karpathy §4)
49
51
  │ keep working, re-probe, do not stall
@@ -11,47 +11,47 @@ description: peaks-code startup sequence Steps 0 / 0.5-0.87 / 1 / 2 / 2.3 / 2.5
11
11
 
12
12
  ### Peaks-Loop Slice 011 — workspace consolidate + session checkpoint/resume
13
13
 
14
- `peaks workspace consolidate` is the slice-011 umbrella primitive. `peaks session checkpoint` (context-overflow defense) and `peaks session resume` surface as Step 0.75 + Step N. See `references/cross-date-session-check.md`.
14
+ `peaks workspace consolidate` is the slice-011 umbrella primitive. `peaks session checkpoint` (context-overflow defense) and `peaks session resume` surface as Step 0.75 + Step N. See `cross-date-session-check.md`.
15
15
 
16
16
  ### Peaks-Loop Step 0.75: Resume from checkpoint (BLOCKING on same-day re-invocation)
17
17
 
18
- When a NEW conversation opens on a session whose `lastActivity` is from today AND `.peaks/_runtime/<sessionId>/checkpoints/` has `*.json`, surface via `peaks session info --active --json` + `peaks session resume --from <path> --project <repo>`. Prompt via `AskUserQuestion` (resume / fresh); if "resume", prepend the block. Step 0.75 is no-op on precondition fail. See `references/checkpoint-resume.md`.
18
+ When a NEW conversation opens on a session whose `lastActivity` is from today AND `.peaks/_runtime/<sessionId>/checkpoints/` has `*.json`, surface via `peaks session info --active --json` + `peaks session resume --from <path> --project <repo>`. Prompt via `AskUserQuestion` (resume / fresh); if "resume", prepend the block. Step 0.75 is no-op on precondition fail. See `checkpoint-resume.md`.
19
19
 
20
20
  ### Peaks-Loop Step N: Periodic checkpoint (auto-fire, no user action)
21
21
 
22
- Proactive context-overflow defense. CLI: `peaks session checkpoint [--reason <r>] [...flags]`. Fire `--reason periodic` every 20 tool calls (G1 hard-coded), `--reason artifact-written` per PRD/RD/QA/TXT write. See `references/periodic-checkpoint.md` (otherwise `tests/unit/code/checkpoint-periodic-frequency.test.ts` fails).
22
+ Proactive context-overflow defense. CLI: `peaks session checkpoint [--reason <r>] [...flags]`. Fire `--reason periodic` every 20 tool calls (G1 hard-coded), `--reason artifact-written` per PRD/RD/QA/TXT write. See `periodic-checkpoint.md` (no guard fails on a missed cadence — the test that did was deleted in `f17aa377`).
23
23
 
24
24
  ### Peaks-Loop Step 0.6: Audit + Goal (NEW)
25
25
 
26
- Invoke peaks-audit after need expressed; store approved goal at `.peaks/_runtime/<sessionId>/audit-goal/<rid>.json`. **All autonomous work requires approved goal.** → `references/audit-goal-gate.md`.
26
+ Invoke peaks-audit after need expressed; store approved goal at `.peaks/_runtime/<sessionId>/audit-goal/<rid>.json`. **All autonomous work requires approved goal.** → `skills/peaks-audit/SKILL.md`.
27
27
 
28
28
  ### Peaks-Loop Step N+1: Final Review (NEW)
29
29
 
30
- After autonomous work (RD, QA, security, perf), invoke peaks-final-review for 4-dim evidence. All 4 pass → final delivery; else loop back. See `references/final-review-gate.md`.
30
+ After autonomous work (RD, QA, security, perf), invoke peaks-final-review for 4-dim evidence. All 4 pass → final delivery; else loop back. See `skills/peaks-final-review/SKILL.md`.
31
31
 
32
32
  ### Peaks-Loop Step N+2: Main-session context monitor (D6 + slice 2026-07-02)
33
33
 
34
- After every 4th tool call, probe via `peaks code context-now --project <repo> --json`. Thresholds: 50% / **0.85 pre-compact / 0.95 red-line** (v2.13.0). **In Job mode ≥ 0.85 is MANDATORY auto-compact** (`peaks code auto-compact`). Pass `--enforce-job-mode` for single-rid. **≥ 0.95** red line: next Bash/Task fires `peaks code auto-compact`. **Karpathy §4 exception**: compact red line keeps runner alive — zero-intervention wins; LLM MUST NOT ask user to run `/compact`. Honor `--in-flight-batch` (D6.e).
34
+ After every 4th tool call, probe via `peaks code context-now --project <repo> --json`. Thresholds: 50% / **0.80 auto-fire / 0.85 pre-compact / 0.95 red-line** (v2.13.0). **At ≥ 0.80 (`auto-fire`, the tier `peaks skill presence` reports every turn) auto-compact is MANDATORY in every mode** (`peaks code auto-compact`). Pass `--enforce-job-mode` for single-rid. **≥ 0.95** red line: next Bash/Task fires `peaks code auto-compact`. **Karpathy §4 exception**: compact red line keeps runner alive — zero-intervention wins; LLM MUST NOT ask user to run `/compact`. Honor `--in-flight-batch` (D6.e).
35
35
 
36
36
  ### Peaks-Loop Step 0: Anchor the workflow (MANDATORY FIRST ACTIONS — no bail-out)
37
37
 
38
38
  Run `peaks workspace init` + `peaks skill presence:set peaks-code` BEFORE any analysis, role handoff, or mode-selection question. Even "分析下这个项目" / "看一下代码" / one-line questions anchor first.
39
39
 
40
- → see `references/anchoring-and-session-info.md` for the full Step 0 contract + session-conflict resolution.
40
+ → see `anchoring-and-session-info.md` for the full Step 0 contract + session-conflict resolution.
41
41
 
42
42
  #### Step 0 bypass — Claude Code [Fact-Forcing Gate] (slice 2.0.1-bug3)
43
43
 
44
44
  `peaks workspace init` materializes `.claude/settings.local.json` (a PreToolUse hook allow-list for `.peaks/**` paths and `peaks <subcommand>` Bash) so the [Fact-Forcing Gate] does not block Step 0. Pass `--no-claude-hooks` to opt out.
45
45
 
46
- → see `references/anchoring-and-session-info.md` for the full bypass contract, recovery flow, and anti-bail-out rule.
46
+ → see `anchoring-and-session-info.md` for the full bypass contract, recovery flow, and anti-bail-out rule.
47
47
 
48
48
  ### Peaks-Loop Step 0.7: Detect unfinished work and offer resume (BLOCKING on first invocation per session)
49
49
 
50
- After Step 0, run the resume-detection probe; surface via `AskUserQuestion` if a slice is in flight. **v3.1.2 resume rule:** if `.peaks/_runtime/<sessionId>/job/<jid>/progress.json` exists, read FIRST and surface `Next: slice #N of M`. **v2.11.0 D7 override:** if user just `/compact`ed, run `peaks code post-compact-detect --project <repo> --json` FIRST; `shouldAutoResume: true` skips AskUserQuestion. → `references/resume-detection.md`.
50
+ After Step 0, run the resume-detection probe; surface via `AskUserQuestion` if a slice is in flight. **v3.1.2 resume rule:** if `.peaks/_runtime/<sessionId>/job/<jid>/progress.json` exists, read FIRST and surface `Next: slice #N of M`. **v2.11.0 D7 override:** if user just `/compact`ed, run `peaks code post-compact-detect --project <repo> --json` FIRST; `shouldAutoResume: true` skips AskUserQuestion. → `resume-detection.md`.
51
51
 
52
52
  ### Peaks-Loop Step 0.55: 1.x → 2.0 detection (BLOCKING on first invocation per session, when the project is not on a 2.0 layout)
53
53
 
54
- After Step 0.7 returns "fresh", run `peaks upgrade --detect-1x --project <root> --json`. If `isOneX: true`, surface `AskUserQuestion`. → `references/step-0-55-1x-detection.md`.
54
+ After Step 0.7 returns "fresh", run `peaks upgrade --detect-1x --project <root> --json`. If `isOneX: true`, surface `AskUserQuestion`. → `step-0-55-1x-detection.md`.
55
55
 
56
56
  ### Peaks-Loop Step 0.8 — Job 启动 (BLOCKING on LLM judgement — v3.1.1 patch + v3.1.2 mechanical gates)
57
57
 
@@ -65,7 +65,7 @@ The CLI is a **recorder + gate** for job-shape (the LLM judges). LLM calls `peak
65
65
 
66
66
  **v3.1.2 mechanical gates** (recorder-only was bypassed twice):
67
67
 
68
- PreToolUse hook on `peaks code gate-step-08`; size-fear ban on `peaks code emit-handoff`; forced auto-compact at ≥ 0.85 in Job mode; on-disk slice progress via `peaks job checkpoint` (canonical reader `peaks job progress --job-id <jid>`). Full mechanics (judgement criteria, hook table, backup-regex rationale, hook wiring) at `references/step-0-8-gate.md`.
68
+ PreToolUse hook on `peaks code gate-step-08`; size-fear ban on `peaks code emit-handoff`; forced auto-compact from ≥ 0.80 (`auto-fire`, every mode); on-disk slice progress via `peaks job checkpoint` (canonical reader `peaks job progress --job-id <jid>`). Full mechanics (judgement criteria, hook table, backup-regex rationale, hook wiring) at `step-0-8-gate.md`.
69
69
 
70
70
  ### Peaks-Loop Step 0.81 — per-slice 收尾
71
71
 
@@ -83,23 +83,23 @@ Active in rotating mode; fires every `rotateEvery` slices or via `peaks job rota
83
83
 
84
84
  After every `peaks sub-agent dispatch --batch-id <id>` inside a Job, BEFORE next slice checkpoint: `peaks job subagent-cleanup --job-id <jid> --batch-id <id> --force`. Non-zero → block.
85
85
 
86
- → see `references/job-loop.md` for state machine, visibility, rotation cadence, cross-day recovery, 9 red lines.
86
+ → see `job-loop.md` for state machine, visibility, rotation cadence, cross-day recovery, 9 red lines.
87
87
 
88
88
  ### Peaks-Loop Step 1: Mode selection
89
89
 
90
- Use `AskUserQuestion` with `Full auto (Recommended)` first when user did not name a profile OR skill presence is stale (run `peaks skill presence:check-stale --project <path> --json` first; `stale: true` ⇒ re-ask). → `references/mode-selection.md`, `references/fast-mode.md`, `references/mode-selection-with-stale-presence.md`.
90
+ Use `AskUserQuestion` with `Full auto (Recommended)` first when user did not name a profile OR skill presence is stale (run `peaks skill presence:check-stale --project <path> --json` first; `stale: true` ⇒ re-ask). → `mode-selection.md`, `fast-mode.md`, `mode-selection-with-stale-presence.md`.
91
91
 
92
92
  ### Peaks-Loop Step 2: Re-set skill presence with the chosen mode
93
93
 
94
- Re-run `peaks skill presence:set peaks-code --mode <mode-value> --gate startup`. Install statusline on first run (`peaks statusline install`). → `references/skill-presence-and-title.md`.
94
+ Re-run `peaks skill presence:set peaks-code --mode <mode-value> --gate startup`. Install statusline on first run (`peaks statusline install`). → `skill-presence-and-title.md`.
95
95
 
96
96
  ### Peaks-Loop Step 2.3: Load project memory (durable, LLM-authored memories)
97
97
 
98
- Run `peaks project memories --project <repo> --json` to read decisions / conventions / modules / rules / lessons from `.peaks/memory`. → `references/project-memory-loading.md`.
98
+ Run `peaks project memories --project <repo> --json` to read decisions / conventions / modules / rules / lessons from `.peaks/memory`. → `project-memory-loading.md`.
99
99
 
100
100
  ### Peaks-Loop Step 2.5: Set session title
101
101
 
102
- Extract a short title from the user's first request (8-20 Chinese chars or 4-10 English words). Run `peaks session title <sessionId> "<title>" --json`. Skip if a title is already set. → `references/skill-presence-and-title.md` (same file as Step 2). D-002: sid is positional, NOT `--session-id` flag (rejected with `error: unknown option`).
102
+ Extract a short title from the user's first request (8-20 Chinese chars or 4-10 English words). Run `peaks session title <sessionId> "<title>" --json`. Skip if a title is already set. → `skill-presence-and-title.md` (same file as Step 2). D-002: sid is positional, NOT `--session-id` flag (rejected with `error: unknown option`).
103
103
 
104
104
  ## Sub-agent session sharing (MANDATORY — one conversation = one sid)
105
105
 
@@ -107,4 +107,4 @@ When peaks-code dispatches a sub-agent (peaks-rd, peaks-qa, peaks-ui, peaks-txt,
107
107
 
108
108
  ## Boundaries
109
109
 
110
- Peaks-Loop Code may identify scenarios, recommend profiles, coordinate role skills via artifacts, coordinate project memory extraction, request user confirmation at risk/commit boundaries. MUST NOT silently install hooks / create agents / enable MCP / modify Claude settings / create GitHub repos / bypass role-skill artifacts. → `references/boundaries.md`.
110
+ Peaks-Loop Code may identify scenarios, recommend profiles, coordinate role skills via artifacts, coordinate project memory extraction, request user confirmation at risk/commit boundaries. MUST NOT silently install hooks / create agents / enable MCP / modify Claude settings / create GitHub repos / bypass role-skill artifacts. → `boundaries.md`.
@@ -45,7 +45,7 @@ Refuses to emit a final handoff while `remaining > 0` under Job mode. Pass `--fo
45
45
 
46
46
  ### 3. Forced auto-compact — `--enforce-job-mode`
47
47
 
48
- `peaks code context-now --enforce-job-mode` (auto-enabled when `job-shape.json` says `isJob=true`) returns `action: 'auto-compact-now'` at ≥ 0.85; Code MUST call `peaks code auto-compact` without confirmation.
48
+ `peaks code context-now --enforce-job-mode` (auto-enabled when `job-shape.json` says `isJob=true`) returns `action: 'auto-compact-now'` at ≥ 0.85; Code MUST call `peaks code auto-compact` without confirmation. Note the earlier line: `peaks skill presence` reports `auto-fire` from ≥ 0.80, and that tier is already mandatory — the 0.80 line, not 0.85, is the one that fires first.
49
49
 
50
50
  ### 4. On-disk slice progress — `progress.json`
51
51
 
@@ -87,5 +87,5 @@ The artifact-scoped extract is canonical; the batch-scoped sibling is for non-ha
87
87
 
88
88
  ## Related
89
89
 
90
- - `references/runbook.md` §Step 11 — full bash + flow.
91
- - `references/project-memory-loading.md` — Step 2.3 memory loading (read-side).
90
+ - `runbook.md` §Step 11 — full bash + flow.
91
+ - `project-memory-loading.md` — Step 2.3 memory loading (read-side).
@@ -39,22 +39,22 @@ stays IDE-agnostic.
39
39
  **Command**:
40
40
 
41
41
  ```
42
- peaks sub-agent dispatch <role> --prompt <text> --graph-node <nid> [--workflow-id <wid>] [--request-id <rid>] [--session-id <sid>] [--project <repo>] [--batch-id <uuid>] --json
42
+ peaks sub-agent dispatch <role> --prompt <text> [--graph-node <nid>] [--workflow-id <wid>] [--request-id <rid>] [--session-id <sid>] [--project <repo>] [--batch-id <uuid>] --json
43
43
  ```
44
44
 
45
- > **`--graph-node` is REQUIRED (RD §4 D4c, effective 4.0.8).** Every
46
- > single dispatch must bind to a prepared workflow graph node. Prepare
47
- > one first:
45
+ > **`--graph-node` is OPTIONAL (relaxed from the 4.0.8 RD §4 D4c requirement).**
46
+ > Slice 4.0.8 made it a `.requiredOption`; `provisionDispatchNode`
47
+ > (`src/services/workflow/provision-dispatch-node.ts`) relaxed it because the
48
+ > requirement was enforced but never validated and the recovery it prescribed
49
+ > was unwalkable: `peaks workflow node prepare` never calls `writeGraph`, so
50
+ > the node it reports is never persisted, and no CLI verb created the graph it
51
+ > reads. Its only observable effect was to block dispatch in every project
52
+ > without graph infrastructure.
48
53
  >
49
- > ```
50
- > peaks workflow init --skill peaks-code # → returns <wid>
51
- > peaks workflow node prepare --workflow <wid> --node <nid> --kind dispatch
52
- > ```
53
- >
54
- > then dispatch with `--graph-node <nid> --workflow-id <wid>`. Omitting
55
- > `--graph-node` rejects with `PEAKS_GRAPH_NODE_REQUIRED`; a node that is
56
- > not prepared (or has the wrong kind) rejects with
57
- > `PEAKS_GRAPH_NODE_NOT_PREPARED` / `PEAKS_GRAPH_NODE_KIND_INVALID`.
54
+ > Omitting both flags now provisions a `dispatch-<role>-<stamp>` node and the
55
+ > graph on demand, so **plain `peaks sub-agent dispatch rd --prompt '<task>' --request-id <rid> --project . --json` succeeds**. Passing
56
+ > `--graph-node <nid> --workflow-id <wid>` binds to a node you control and
57
+ > persists it into `graphs/<wid>.json`.
58
58
 
59
59
  **Envelope** (AC-8) — **2.1.0** (slice 2026-06-23-audit-4th #E1):
60
60
 
@@ -315,9 +315,10 @@ reply. The two surfaces are not redundant — the field is for
315
315
  downstream tooling, the prose is for the human. Same payload,
316
316
  different readers.
317
317
 
318
- **Regression guard**: `tests/unit/dispatch/dispatch-fanout-mandatory.test.ts`
319
- parses the same SKILL.md text and asserts the G11.5 paragraph is
320
- present; do not delete the heading without also updating the guard.
318
+ **Regression guard**: none. The unit test that parsed the same SKILL.md
319
+ text and asserted the G11.5 paragraph is present was deleted in
320
+ `f17aa377`; do not delete the heading — convention is the only thing
321
+ holding it now.
321
322
 
322
323
  ---
323
324
 
@@ -356,13 +357,13 @@ grown unboundedly without this fix).
356
357
  When writing a SKILL.md that fans out sub-agents:
357
358
 
358
359
  1. Use `peaks sub-agent dispatch <role>` (never `Task(...)`).
359
- 2. Prepare the graph node first (RD §4 D4c — `--graph-node` is required):
360
- `peaks workflow init --skill peaks-code`, then
361
- `peaks workflow node prepare --workflow <wid> --node <nid> --kind dispatch`.
360
+ 2. Graph binding is OPTIONAL — omit `--graph-node` and the CLI provisions a
361
+ node on demand. Pass `--graph-node <nid> --workflow-id <wid>` only when you
362
+ need the dispatch bound to a node you control (and note the node is
363
+ persisted by `provisionDispatchNode`, not by `peaks workflow node prepare`).
362
364
  3. Issue all dispatches in a single message; the LLM will fire all
363
365
  returned toolCalls in parallel.
364
- 4. Pass `--graph-node <nid> --workflow-id <wid>` on every dispatch, plus
365
- `--request-id` and `--session-id` (or omit and let the CLI resolve the
366
+ 4. Pass `--request-id` and `--session-id` (or omit and let the CLI resolve the
366
367
  active session).
367
368
  5. The sub-agent prompt **must** include the heartbeat instruction
368
369
  (30 s cadence; override via `heartbeatIntervalSec` if needed).
@@ -379,7 +380,7 @@ When writing a SKILL.md that fans out sub-agents:
379
380
  - `.peaks/memory/sub-agent-resource-lifecycle-red-line.md` (G5 red line)
380
381
  - `.peaks/memory/sub-agent-heartbeat-progress-red-line.md` (G6 red line)
381
382
  - `skills/peaks-code/references/swarm-dispatch-contract.md` (predecessor contract)
382
- - `skills/peaks-qa/references/qa-fanout-contract.md` (QA-specific fan-out)
383
+ - `skills/bee/peaks-qa/references/qa-fanout-contract.md` (QA-specific fan-out)
383
384
 
384
385
  ---
385
386
 
@@ -404,7 +405,7 @@ peaks sub-agent dispatch <role> \
404
405
 
405
406
  Then the LLM takes `data.toolCall` from the envelope (a `{name, args}` descriptor), looks up the tool by `name` in its environment, and invokes it with `args` — IDE-private, no SKILL.md hardcoding.
406
407
 
407
- The role's required artefact paths (also see peaks-ui/rd/qa SKILL.md and `references/swarm-dispatch-contract.md`):
408
+ The role's required artefact paths (also see peaks-ui/rd/qa SKILL.md and `swarm-dispatch-contract.md`):
408
409
 
409
410
  | Role | Writes | Reads (PRD-side) |
410
411
  |---|---|---|
@@ -433,7 +434,7 @@ The role's required artefact paths (also see peaks-ui/rd/qa SKILL.md and `refere
433
434
  `verdict: blocked-by-orchestrator-policy` and explain. Do NOT commit
434
435
  yourself even in emergencies.
435
436
  ```
436
- - **Do write heartbeats** — call `peaks sub-agent heartbeat --record <dispatchRecordPath> --status running --progress <pct> --note "<text>"` at least every 30s (see `references/sub-agent-dispatch.md` §G6 for the full contract). The parent Dispatcher uses these to render the live status line during the wait.
437
+ - **Do write heartbeats** — call `peaks sub-agent heartbeat --record <dispatchRecordPath> --status running --progress <pct> --note "<text>"` at least every 30s (see `sub-agent-dispatch.md` §G6 for the full contract). The parent Dispatcher uses these to render the live status line during the wait.
437
438
 
438
439
  After every sub-agent dispatch returns, Code **restores presence** once (not per-agent), then continues to Gate B verification:
439
440
 
@@ -445,7 +446,7 @@ peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate swarm-
445
446
 
446
447
  ## Detached Mode (Phase A, slice 2026-08-10)
447
448
 
448
- `peaks sub-agent dispatch <role> --prompt <text> --graph-node <nid> --workflow-id <wid> --request-id <rid> --mode detached --vendor claude|codex|copilot [--no-throttle --max-concurrent <N>] --json` spawns a real OS process independent of the orchestrator IDE session. `--graph-node` remains required here (RD §4 D4c).
449
+ `peaks sub-agent dispatch <role> --prompt <text> --graph-node <nid> --workflow-id <wid> --request-id <rid> --mode detached --vendor claude|codex|copilot [--no-throttle --max-concurrent <N>] --json` spawns a real OS process independent of the orchestrator IDE session. `--graph-node` is optional here too — the relaxation is on the shared option table, not on the in-process path only.
449
450
 
450
451
  - **Cross-platform spawn**: Windows uses `DETACHED_PROCESS` + `CREATE_NEW_PROCESS_GROUP`; POSIX uses `setsid` + `nohup`. Implementation: `packages/peaks-loop-internal-runtime/src/process-supervisor.ts`.
451
452
  - **Minimum-context prompt**: `PromptBuilder` emits a 5–8KB slice `{rid, role, vendor, files, refs}` plus the verbatim `<peaks-auto-compact>` marker. The forbidden marker `@@@ORCHESTRATOR_SESSION_HISTORY_BOUNDARY@@@` MUST NOT appear in any prompt (unit-tested; regression fails vitest).
@@ -15,7 +15,7 @@
15
15
  > rules. As of 2.8.4 the `'serial'` opt-out was removed by user
16
16
  > direction — single-sub-agent dispatch is no longer permitted when
17
17
  > ≥ 2 leaves exist at one topological level (see
18
- > `references/fanout-mandatory.md`).
18
+ > `fanout-mandatory.md`).
19
19
 
20
20
  The Swarm phase is the **default** for any DAG with ≥ 2 leaves at
21
21
  the same topological level. Code derives the fan-out set from the
@@ -2,11 +2,11 @@
2
2
 
3
3
  > **Maintenance**: This reference holds the canonical contract for (a) how Code sequences the 11 workflow steps, (b) which `--type` to pass to `peaks request init` for which slice shape, and (c) the executable `ls` / `grep` gate commands that physically block progression. SKILL.md keeps the narrative ("what peaks-code does"); this file keeps the contract.
4
4
  >
5
- > **Why extracted from SKILL.md**: this content is 165 lines of mostly-tabular + bash-block contract — reference data, not orchestration prose. Inlining it bloats SKILL.md past the 800-line cap (per `common/coding-style.md`). The numbers, gate command shapes, and type-classification rules change rarely; the SKILL.md prose around them (orchestration flow, repair-loop intent, swarm fan-out shape) changes more often.
5
+ > **Why extracted from SKILL.md**: this content is 165 lines of mostly-tabular + bash-block contract — reference data, not orchestration prose. Inlining it bloats SKILL.md past the 800-line cap (per `.peaks/standards/common/coding-style.md`). The numbers, gate command shapes, and type-classification rules change rarely; the SKILL.md prose around them (orchestration flow, repair-loop intent, swarm fan-out shape) changes more often.
6
6
  >
7
7
  > **How peaks-loop tooling reads this file**:
8
8
  > - `peaks skill runbook peaks-code` (CLI) and the in-line LLM reading the SKILL.md should reference this file when the gate-machine or type-classification contract is in play.
9
- > - The test `tests/unit/skill-default-runbook.test.ts` does NOT check this file (it only checks the runbook). Future tests can add a similar fallback for the gates-and-types contract.
9
+ > - No test reads this file, so nothing detects drift between it and the SKILL.md prose. The test that once checked the runbook fallback was deleted in `f17aa377`.
10
10
 
11
11
  ## Peaks-Loop Request type classification (MANDATORY before `peaks request init`)
12
12
 
@@ -30,7 +30,7 @@ When Peaks-Loop Code coordinates development in a code repository, keep this ord
30
30
  0. **Peaks-Loop Snapshot** — `peaks doctor` + `peaks project dashboard` to capture baseline state before anything else;
31
31
  0.5. **Peaks-Loop Workspace initialization** — `.peaks/_runtime/<session-id>/` created, directory structure verified;
32
32
  0.6. **Peaks-Loop Project scan** — archetype, component library, CSS framework, build tool, state management, routing, data fetching, legacy signals detected and recorded to `.peaks/project-scan/project-scan.md`;
33
- 0.7. **Peaks-Loop Existing-system extraction** (MANDATORY when archetype ∈ {legacy-frontend, legacy-fullstack, frontend-monorepo}; SKIP for greenfield) — extract visual tokens and code conventions from the live codebase to `.peaks/_runtime/<session-id>/system/existing-system.md`. The path lives under `system/` (not `ui/`) because the file also records non-UI conventions (service-layer signatures, hooks, naming) that backend-only or legacy-fullstack work consumes. See `references/existing-system-extraction.md`. UI design-draft and RD implementation MUST treat the extracted tokens and conventions as hard constraints;
33
+ 0.7. **Peaks-Loop Existing-system extraction** (MANDATORY when archetype ∈ {legacy-frontend, legacy-fullstack, frontend-monorepo}; SKIP for greenfield) — extract visual tokens and code conventions from the live codebase to `.peaks/_runtime/<session-id>/system/existing-system.md`. The path lives under `system/` (not `ui/`) because the file also records non-UI conventions (service-layer signatures, hooks, naming) that backend-only or legacy-fullstack work consumes. See `existing-system-extraction.md`. UI design-draft and RD implementation MUST treat the extracted tokens and conventions as hard constraints;
34
34
  1. **Peaks-Loop Standards preflight** — `peaks standards init/update --dry-run`, must reference concrete project-scan findings (never emit generic templates);
35
35
  2. **Peaks-Loop PRD phase** — capture request as canonical artifact, extract scope and acceptance criteria:
36
36
  - Full-auto/Swarm: auto-transition to `confirmed-by-user` once the artifact is complete;
@@ -23,7 +23,7 @@ The 3 layers stack. L3 is the strongest because it operates BELOW the LLM's tool
23
23
  ## L1 — Sub-agent system prompt
24
24
 
25
25
  The explicit `MUST NOT` block lives in:
26
- - `peaks-rd/references/rd-sub-agent-dispatch.md`
26
+ - `../../bee/peaks-rd/references/rd-sub-agent-dispatch.md`
27
27
  - `peaks-qa/...`
28
28
  - `peaks-ui/...`
29
29
  - `peaks sub-agent dispatch` CLI prompt template
@@ -41,7 +41,7 @@ denied again after a long pause. That is the gate resetting, not you regressing.
41
41
 
42
42
  > **Read once at the top of this file; the rest of the skill is written against it.**
43
43
 
44
- The `.peaks/` workspace is partitioned by a **single scope axis** (session-id, at `.peaks/_runtime/<sessionId>/...`) with a nested **sub-agent axis** under `.peaks/_sub_agents/<sessionId>/...`. Use `<sessionId>` placeholders (NEVER bare `<sid>`). The peaks-loop change-id axis was removed in slice `2026-06-29-change-id-root-removal`; reviewable artifacts now live under `.peaks/_runtime/<sessionId>/<role>/...` only. OpenSpec's independent `openspec/changes/<change-id>/` vocabulary (L4) is preserved untouched. CLI mapping: session-id → `peaks session *`; sub-agent → `peaks sub-agent *`. Regression test `tests/unit/skills/skills-skill-md-naming.test.ts` enforces (a) zero bare `<sid>`, (b) every `.peaks/_runtime/<X>/` has an axis label, (c) this callout is present.
44
+ The `.peaks/` workspace is partitioned by a **single scope axis** (session-id, at `.peaks/_runtime/<sessionId>/...`) with a nested **sub-agent axis** under `.peaks/_sub_agents/<sessionId>/...`. Use `<sessionId>` placeholders (NEVER bare `<sid>`). The peaks-loop change-id axis was removed in slice `2026-06-29-change-id-root-removal`; reviewable artifacts now live under `.peaks/_runtime/<sessionId>/<role>/...` only. OpenSpec's independent `openspec/changes/<change-id>/` vocabulary (L4) is preserved untouched. CLI mapping: session-id → `peaks session *`; sub-agent → `peaks sub-agent *`. Normative by documentation only — the guard that once asserted (a) zero bare `<sid>`, (b) an axis label on every runtime path, and (c) this callout's presence was deleted in `457b9a87`. Comply by convention.
45
45
 
46
46
  # Peaks-Loop Final Review
47
47
 
@@ -80,7 +80,7 @@ The service is the **gate primitive** that closes the 10% human / 90% LLM loop.
80
80
  All of the following MUST be true before invoking this skill:
81
81
 
82
82
  - **RD complete** — implementation merged and the slice boundary recorded at `.peaks/sc/slice-decomposition/<rid>.json` (or `peaks slice check --rid <rid> --json` returns `pass`).
83
- - **QA complete** — `test-cases` + `test-reports` + `security-findings` + `performance-findings` present under `.peaks/_runtime/<sessionId>/qa/...` and all applicable gates A/A2/A3/A4/B/C/E/F satisfied (per `skills/peaks-qa/references/qa-transition-gates.md`).
83
+ - **QA complete** — `test-cases` + `test-reports` + `security-findings` + `performance-findings` present under `.peaks/_runtime/<sessionId>/qa/...` and all applicable gates A/A2/A3/A4/B/C/E/F satisfied (per `skills/bee/peaks-qa/references/qa-transition-gates.md`).
84
84
  - **Security check complete** — slice 025 project-level security test plan executed; no open CRITICAL/HIGH findings.
85
85
  - **Performance baseline complete** — slice 025 project-level perf baseline recorded; no regression beyond the agreed threshold.
86
86
  - **Approved audit-goal on disk** — `.peaks/_runtime/<sessionId>/audit-goal/<rid>.json` exists and contains `successCriteria` (the service feeds these into the LLM user prompt verbatim).
@@ -231,5 +231,5 @@ When handing off, emit: rid, `allPass`, `needsAttention[]`, output path, source
231
231
  | `src/services/audit/audit-goal-service.ts:16` | Line of evidence that `LlmRunner` is reusable across audit + final-review (service-level integration). |
232
232
  | `tests/unit/final-review/final-review-service.test.ts` | Service-level unit tests (8 cases: evidence inlining, the no-evidence⇒no-`pass` gate, prompt bounds, plus contract guards). |
233
233
  | `docs/superpowers/plans/2026-06-25-slice-topology-multipass-phase-4.md:127` | Phase-4 plan prose (Task 14). |
234
- | `skills/peaks-qa/SKILL.md` | Upstream QA skill — 4-dim review is downstream of all QA gates. |
234
+ | `skills/bee/peaks-qa/SKILL.md` | Upstream QA skill — 4-dim review is downstream of all QA gates. |
235
235
  | `skills/peaks-audit/SKILL.md` | Sibling skill — produces the `audit-goal` JSON that this skill consumes. |
@@ -44,9 +44,10 @@ node scripts/peaks-ide-audit-log.mjs --project <repo> --event <name> --adapter <
44
44
  The log file path is `<projectRoot>/.peaks/audit/peaks-ide-<UTC-date>.log`
45
45
  and is gitignored per the repo root `.gitignore` (`.peaks/audit/`).
46
46
 
47
- ## Contract pinned by tests
47
+ ## Contract
48
48
 
49
- `tests/unit/skills/peaks-ide/audit-log-helper.test.ts` pins 4 sub-cases
50
- (per AC-5): helper is at the documented path, write emits one JSONL line
51
- with `timestamp + event + adapter + ok`, the log path is in `.gitignore`,
49
+ No test pins this — the suite that asserted the 4 sub-cases below (per
50
+ AC-5) was deleted in `f17aa377`. They remain the contract: helper is at
51
+ the documented path, write emits one JSONL line with
52
+ `timestamp + event + adapter + ok`, the log path is in `.gitignore`,
52
53
  and `--dry-run` returns the would-be line without writing.
@@ -110,6 +110,6 @@ Then tell the user: "Resuming from `<gate>`. The main peaks-code skill will take
110
110
 
111
111
  ## Cross-references
112
112
 
113
- - The detection logic is canonical at `tests/fixtures/skill-resume-mode-detect.sh` (added in slice 003). The 8 vitest cases in `tests/unit/skill-resume-mode.test.ts` cover all classification outcomes.
113
+ - The detection logic is canonical at `tests/fixtures/skill-resume-mode-detect.sh` (added in slice 003). Nothing covers the classification outcomes in unit tests today — the 8-case suite was deleted in `f17aa377`.
114
114
  - The SKILL.md prose at `skills/peaks-code/SKILL.md` Step 0.7 (added in slice 003) is the same logic, written for LLM consumption. This wrapper reuses the same script — there is no parallel implementation.
115
115
  - The "drives a CLI on the user's behalf" pattern (mirror of `peaks-sop`) is the closest existing precedent for this wrapper.
@@ -41,7 +41,7 @@ denied again after a long pause. That is the gate resetting, not you regressing.
41
41
 
42
42
  > **Read once at the top of this file; the rest of the skill is written against it.**
43
43
 
44
- The `.peaks/` workspace is partitioned by a **single scope axis** (session-id, at `.peaks/_runtime/<sessionId>/...`) with a nested **sub-agent axis** under `.peaks/_sub_agents/<sessionId>/...`. Use `<sessionId>` placeholders (NEVER bare `<sid>`). The peaks-loop change-id axis was removed in slice `2026-06-29-change-id-root-removal`; reviewable artifacts now live under `.peaks/_runtime/<sessionId>/<role>/...` only. OpenSpec's independent `openspec/changes/<change-id>/` vocabulary (L4) is preserved untouched. CLI mapping: session-id → `peaks session *`; sub-agent → `peaks sub-agent *`. Regression test `tests/unit/skills/skills-skill-md-naming.test.ts` enforces (a) zero bare `<sid>`, (b) every `.peaks/_runtime/<X>/` has an axis label, (c) this callout is present.
44
+ The `.peaks/` workspace is partitioned by a **single scope axis** (session-id, at `.peaks/_runtime/<sessionId>/...`) with a nested **sub-agent axis** under `.peaks/_sub_agents/<sessionId>/...`. Use `<sessionId>` placeholders (NEVER bare `<sid>`). The peaks-loop change-id axis was removed in slice `2026-06-29-change-id-root-removal`; reviewable artifacts now live under `.peaks/_runtime/<sessionId>/<role>/...` only. OpenSpec's independent `openspec/changes/<change-id>/` vocabulary (L4) is preserved untouched. CLI mapping: session-id → `peaks session *`; sub-agent → `peaks sub-agent *`. Normative by documentation only — the guard that once asserted (a) zero bare `<sid>`, (b) an axis label on every runtime path, and (c) this callout's presence was deleted in `457b9a87`. Comply by convention.
45
45
 
46
46
  ## Read via `SchemaRouter.readResult()` — never parse the file directly
47
47
 
@@ -164,7 +164,7 @@ Why: RID-003 SC §3.5 originally specified the CJS guard for `scripts/install-sk
164
164
 
165
165
  ### Rule 2 — Whitelist fixture sync is NOT collateral (D-009a)
166
166
 
167
- When a slice adds a new entry to a **whitelist fixture** (e.g. `tests/unit/ide/ide-registry.test.ts` asserting `expect(adapters).toHaveLength(7)` after adding the 8th adapter), that fixture sync is a **primary task**, not a "by the way" footnote.
167
+ When a slice adds a new entry to a **whitelist fixture** (a test that asserts an exact set size, e.g. `expect(adapters).toHaveLength(7)`, and must be bumped when the 8th adapter is added), that fixture sync is a **primary task**, not a "by the way" footnote.
168
168
 
169
169
  Mandatory structure for any slice that adds to a known set:
170
170
 
@@ -175,8 +175,8 @@ Mandatory structure for any slice that adds to a known set:
175
175
  |---|---|---|
176
176
  | T-1 | `src/services/ide/ide-types.ts` | Add `'zcode'` to IdeId |
177
177
  | T-2 | `src/services/ide/ide-registry.ts` | Register ZCODE_ADAPTER |
178
- | T-3 | `tests/unit/ide/ide-registry.test.ts` | Update whitelist: 7 → 8 adapters, add 'zcode' |
179
- | T-4 | `tests/unit/install-skills-script.test.ts` | Update whitelist: 5 → 6 platforms, add 'zcode' |
178
+ | T-3 | the adapter-registry whitelist fixture | Update whitelist: 7 → 8 adapters, add 'zcode' |
179
+ | T-4 | the install-skills platform whitelist fixture | Update whitelist: 5 → 6 platforms, add 'zcode' |
180
180
  ```
181
181
 
182
182
  If you find a whitelist fixture during execution but didn't pre-list it as a task, treat it as a **NEW TASK** and run the SC ↔ QA repair loop, not as "necessary collateral". Pre-listing prevents surprises at Gate 1.
@@ -1,6 +1,6 @@
1
1
  # Cross-pass edge interpretation
2
2
 
3
- Source of truth: `src/services/slice/cross-pass-edge-merger.ts` (`merge` function) + `src/services/slice/llm-arbitrator.ts` (`arbitrate`). Read this together with `references/v2-schema.md` for the field-level definitions.
3
+ Source of truth: `src/services/slice/cross-pass-edge-merger.ts` (`merge` function) + `src/services/slice/llm-arbitrator.ts` (`arbitrate`). Read this together with `v2-schema.md` for the field-level definitions.
4
4
 
5
5
  ## What is a `CrossPassEdge`
6
6
 
@@ -61,7 +61,7 @@ The function returns one of three branches:
61
61
 
62
62
  ### Tie-break behavior
63
63
 
64
- `auto` mode does NOT itself consult the LLM — the `'tie-break'` branch only signals that the workUnit is borderline. The actual LLM call happens during cross-pass edge detection in `cross-pass-edge-merger.ts` (see `references/cross-pass-edge-interpretation.md`). The merge step may add an `llm-arbitrated` edge even when the parent was subdivided as `'tie-break'`.
64
+ `auto` mode does NOT itself consult the LLM — the `'tie-break'` branch only signals that the workUnit is borderline. The actual LLM call happens during cross-pass edge detection in `cross-pass-edge-merger.ts` (see `cross-pass-edge-interpretation.md`). The merge step may add an `llm-arbitrated` edge even when the parent was subdivided as `'tie-break'`.
65
65
 
66
66
  ## `auto` decision tree
67
67
 
@@ -76,7 +76,7 @@ The CLI serialises via `SchemaRouter.writeResult()` → `JSON.stringify(result,
76
76
  | `toPass` | `PassNumber` | The lower (finer) pass number. Always `fromPass < toPass`. |
77
77
  | `fromSliceId` | `string` | Slice id in `fromPass`. |
78
78
  | `toSliceId` | `string` | Slice id in `toPass`. |
79
- | `kind` | `CrossPassEdgeKind` (`'type-shares' \| 'fixture-shares' \| 'import-re-export' \| 'llm-arbitrated'`) | See `references/cross-pass-edge-interpretation.md`. |
79
+ | `kind` | `CrossPassEdgeKind` (`'type-shares' \| 'fixture-shares' \| 'import-re-export' \| 'llm-arbitrated'`) | See `cross-pass-edge-interpretation.md`. |
80
80
  | `confidence` | `EdgeConfidence \| 'llm'` | `'llm'` only when `kind === 'llm-arbitrated'`. Structural detectors emit `'structural'`. |
81
81
  | `evidence` | `string` | Human-readable: the import line, the shared fixture id, or `llm:<callId>: <reason>` for LLM edges. |
82
82
  | `arbitratedBy` | `string \| null` | The `LlmArbitration.callId` that produced this edge, or `null` for static-detected edges. |
@@ -140,6 +140,6 @@ Any future schema change MUST:
140
140
  2. Extend `SchemaRouter.readResult()` to accept and dispatch it.
141
141
  3. Bump `DecompositionResultV3.schemaVersion: 'v3'`.
142
142
  4. Keep the v2 reader path intact (no in-place rewrite of v2 files).
143
- 5. Update this reference + add a `references/v3-schema.md`.
143
+ 5. Update this reference + add a sibling v3 schema reference next to it.
144
144
 
145
145
  In-place edits to v1/v2 fields are forbidden: any consumer that already wrote a v2 file expects its schema to remain stable.
@@ -247,6 +247,5 @@ peaks-solo 是 dispatcher,**不**是 orchestrator,**不**是 implementer。下
247
247
  - `references/triage-decision-table.md` — 关键词 → leaf skill 完整映射表(≥ 10 行)
248
248
  - `references/fallback-tool-inventory.md` — 自规划允许 + 禁止工具清单
249
249
  - `references/sediment-prompt-template.md` — 4-option AskUserQuestion 沉淀模板
250
- - spec: `docs/superpowers/specs/2026-07-08-peaks-solo-dispatcher-design.md` §3.1, §3.3, §3.4, §3.5
251
- - plan: `docs/superpowers/plans/2026-07-08-peaks-solo-dispatcher/s1-peaks-solo-skill.md`
250
+ - spec / plan: the `2026-07-08-peaks-solo-dispatcher` design + plan docs were retired in `e6e35842`; the surviving record of that slice is `.peaks/memory/2026-07-08-peaks-solo-dogfood.md` and the decision memo below.
252
251
  - decision memo: `.peaks/memory/user-decision-2026-07-08-revive-peaks-solo-as-dispatcher.md`
@@ -1,11 +0,0 @@
1
- /**
2
- * `peaks context <sub>` — CLI surface for the ContextBuilder.
3
- * Per spec §4.1 — these commands are the only sanctioned entry point;
4
- * peaks-rd / peaks-qa / peaks-mut invoke them programmatically.
5
- */
6
- import { Command } from 'commander';
7
- import type { DocFetcher } from '../../services/context/doc-retriever.js';
8
- export interface ContextCommandsOptions {
9
- readonly fetcher: DocFetcher;
10
- }
11
- export declare function createContextCommands(options: ContextCommandsOptions): Command;