peaks-cli 1.4.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/.claude-plugin/marketplace.json +51 -0
  2. package/CHANGELOG.md +279 -0
  3. package/README-en.md +226 -0
  4. package/README.md +152 -122
  5. package/dist/src/cli/commands/agent-commands.d.ts +20 -0
  6. package/dist/src/cli/commands/agent-commands.js +48 -0
  7. package/dist/src/cli/commands/audit-commands.d.ts +18 -0
  8. package/dist/src/cli/commands/audit-commands.js +138 -0
  9. package/dist/src/cli/commands/capability-commands.js +2 -1
  10. package/dist/src/cli/commands/classify-classify-commands.d.ts +19 -0
  11. package/dist/src/cli/commands/classify-classify-commands.js +151 -0
  12. package/dist/src/cli/commands/code-review-commands.d.ts +34 -0
  13. package/dist/src/cli/commands/code-review-commands.js +83 -0
  14. package/dist/src/cli/commands/config-commands.js +90 -0
  15. package/dist/src/cli/commands/context-commands.d.ts +21 -0
  16. package/dist/src/cli/commands/context-commands.js +167 -0
  17. package/dist/src/cli/commands/core-artifact-commands.js +60 -2
  18. package/dist/src/cli/commands/hook-handle.js +50 -0
  19. package/dist/src/cli/commands/loop-commands.d.ts +21 -0
  20. package/dist/src/cli/commands/loop-commands.js +128 -0
  21. package/dist/src/cli/commands/openspec-commands.js +37 -0
  22. package/dist/src/cli/commands/preferences-commands.d.ts +2 -0
  23. package/dist/src/cli/commands/preferences-commands.js +147 -0
  24. package/dist/src/cli/commands/skill-conformance-commands.d.ts +9 -0
  25. package/dist/src/cli/commands/skill-conformance-commands.js +39 -0
  26. package/dist/src/cli/commands/understand-commands.js +34 -0
  27. package/dist/src/cli/commands/upgrade-commands.d.ts +23 -0
  28. package/dist/src/cli/commands/upgrade-commands.js +57 -0
  29. package/dist/src/cli/commands/workflow-commands.js +70 -0
  30. package/dist/src/cli/commands/workspace-commands.js +117 -2
  31. package/dist/src/cli/program.js +30 -0
  32. package/dist/src/lib/render/message-renderer.d.ts +20 -0
  33. package/dist/src/lib/render/message-renderer.js +80 -0
  34. package/dist/src/services/agent/ecc-agent-service.d.ts +47 -0
  35. package/dist/src/services/agent/ecc-agent-service.js +143 -0
  36. package/dist/src/services/artifacts/request-artifact-service.js +14 -0
  37. package/dist/src/services/audit/backing-detector.d.ts +24 -0
  38. package/dist/src/services/audit/backing-detector.js +59 -0
  39. package/dist/src/services/audit/classifier.d.ts +38 -0
  40. package/dist/src/services/audit/classifier.js +127 -0
  41. package/dist/src/services/audit/enforcers/active-skill-resolver.d.ts +29 -0
  42. package/dist/src/services/audit/enforcers/active-skill-resolver.js +71 -0
  43. package/dist/src/services/audit/enforcers/design-draft-confirm.d.ts +25 -0
  44. package/dist/src/services/audit/enforcers/design-draft-confirm.js +54 -0
  45. package/dist/src/services/audit/enforcers/lint-audit-regression.d.ts +21 -0
  46. package/dist/src/services/audit/enforcers/lint-audit-regression.js +86 -0
  47. package/dist/src/services/audit/enforcers/lint-catalog-governance.d.ts +27 -0
  48. package/dist/src/services/audit/enforcers/lint-catalog-governance.js +38 -0
  49. package/dist/src/services/audit/enforcers/lint-cli-back.d.ts +16 -0
  50. package/dist/src/services/audit/enforcers/lint-cli-back.js +35 -0
  51. package/dist/src/services/audit/enforcers/lint-output-style.d.ts +11 -0
  52. package/dist/src/services/audit/enforcers/lint-output-style.js +94 -0
  53. package/dist/src/services/audit/enforcers/lint-reference-integrity.d.ts +6 -0
  54. package/dist/src/services/audit/enforcers/lint-reference-integrity.js +83 -0
  55. package/dist/src/services/audit/enforcers/lint-reference-shape.d.ts +30 -0
  56. package/dist/src/services/audit/enforcers/lint-reference-shape.js +272 -0
  57. package/dist/src/services/audit/enforcers/lint-style.d.ts +49 -0
  58. package/dist/src/services/audit/enforcers/lint-style.js +173 -0
  59. package/dist/src/services/audit/enforcers/lint-workflow-shape.d.ts +5 -0
  60. package/dist/src/services/audit/enforcers/lint-workflow-shape.js +141 -0
  61. package/dist/src/services/audit/enforcers/login-gate.d.ts +23 -0
  62. package/dist/src/services/audit/enforcers/login-gate.js +40 -0
  63. package/dist/src/services/audit/enforcers/mock-placement.d.ts +25 -0
  64. package/dist/src/services/audit/enforcers/mock-placement.js +48 -0
  65. package/dist/src/services/audit/enforcers/no-root-pollution.d.ts +21 -0
  66. package/dist/src/services/audit/enforcers/no-root-pollution.js +56 -0
  67. package/dist/src/services/audit/enforcers/pre-rd-scan.d.ts +22 -0
  68. package/dist/src/services/audit/enforcers/pre-rd-scan.js +23 -0
  69. package/dist/src/services/audit/enforcers/prototype-fidelity.d.ts +25 -0
  70. package/dist/src/services/audit/enforcers/prototype-fidelity.js +75 -0
  71. package/dist/src/services/audit/enforcers/resume-detection.d.ts +21 -0
  72. package/dist/src/services/audit/enforcers/resume-detection.js +52 -0
  73. package/dist/src/services/audit/enforcers/solo-code-ban.d.ts +23 -0
  74. package/dist/src/services/audit/enforcers/solo-code-ban.js +27 -0
  75. package/dist/src/services/audit/enforcers/sub-agent-sid.d.ts +25 -0
  76. package/dist/src/services/audit/enforcers/sub-agent-sid.js +63 -0
  77. package/dist/src/services/audit/enforcers/tech-doc-presence.d.ts +28 -0
  78. package/dist/src/services/audit/enforcers/tech-doc-presence.js +35 -0
  79. package/dist/src/services/audit/red-line-catalog-p2-a.d.ts +21 -0
  80. package/dist/src/services/audit/red-line-catalog-p2-a.js +233 -0
  81. package/dist/src/services/audit/red-line-catalog-p2-b.d.ts +19 -0
  82. package/dist/src/services/audit/red-line-catalog-p2-b.js +225 -0
  83. package/dist/src/services/audit/red-line-catalog.d.ts +51 -0
  84. package/dist/src/services/audit/red-line-catalog.js +210 -0
  85. package/dist/src/services/audit/red-lines-service.d.ts +23 -0
  86. package/dist/src/services/audit/red-lines-service.js +486 -0
  87. package/dist/src/services/audit/scanners/openspec-scanner.d.ts +15 -0
  88. package/dist/src/services/audit/scanners/openspec-scanner.js +55 -0
  89. package/dist/src/services/audit/scanners/rules-tree-scanner.d.ts +16 -0
  90. package/dist/src/services/audit/scanners/rules-tree-scanner.js +56 -0
  91. package/dist/src/services/audit/scanners/skills-tree-scanner.d.ts +17 -0
  92. package/dist/src/services/audit/scanners/skills-tree-scanner.js +46 -0
  93. package/dist/src/services/audit/static-service.d.ts +57 -0
  94. package/dist/src/services/audit/static-service.js +125 -0
  95. package/dist/src/services/audit/types.d.ts +69 -0
  96. package/dist/src/services/audit/types.js +13 -0
  97. package/dist/src/services/classify/classify-service.d.ts +42 -0
  98. package/dist/src/services/classify/classify-service.js +122 -0
  99. package/dist/src/services/classify/classify-types.d.ts +79 -0
  100. package/dist/src/services/classify/classify-types.js +90 -0
  101. package/dist/src/services/code-review/ocr-service.d.ts +129 -0
  102. package/dist/src/services/code-review/ocr-service.js +362 -0
  103. package/dist/src/services/config/config-migration.d.ts +32 -0
  104. package/dist/src/services/config/config-migration.js +111 -0
  105. package/dist/src/services/config/config-restore.d.ts +10 -0
  106. package/dist/src/services/config/config-restore.js +47 -0
  107. package/dist/src/services/config/config-rollback.d.ts +13 -0
  108. package/dist/src/services/config/config-rollback.js +26 -0
  109. package/dist/src/services/config/config-service.d.ts +36 -2
  110. package/dist/src/services/config/config-service.js +105 -0
  111. package/dist/src/services/config/config-types.d.ts +73 -0
  112. package/dist/src/services/config/config-types.js +28 -13
  113. package/dist/src/services/config/model-routing.js +5 -3
  114. package/dist/src/services/doctor/doctor-service.js +96 -0
  115. package/dist/src/services/ide/adapters/hermes-adapter.d.ts +21 -0
  116. package/dist/src/services/ide/adapters/hermes-adapter.js +51 -0
  117. package/dist/src/services/ide/adapters/openclaw-adapter.d.ts +14 -0
  118. package/dist/src/services/ide/adapters/openclaw-adapter.js +42 -0
  119. package/dist/src/services/ide/ide-registry.js +7 -0
  120. package/dist/src/services/ide/ide-types.d.ts +1 -1
  121. package/dist/src/services/openspec/openspec-propose-from-doctor-service.d.ts +31 -0
  122. package/dist/src/services/openspec/openspec-propose-from-doctor-service.js +95 -0
  123. package/dist/src/services/preferences/preferences-service.d.ts +6 -0
  124. package/dist/src/services/preferences/preferences-service.js +43 -0
  125. package/dist/src/services/preferences/preferences-types.d.ts +90 -0
  126. package/dist/src/services/preferences/preferences-types.js +38 -0
  127. package/dist/src/services/rd/rd-service.js +29 -1
  128. package/dist/src/services/skills/skill-conformance-service.d.ts +40 -0
  129. package/dist/src/services/skills/skill-conformance-service.js +136 -0
  130. package/dist/src/services/skills/skill-runbook-service.js +44 -10
  131. package/dist/src/services/skills/sync-service.d.ts +86 -0
  132. package/dist/src/services/skills/sync-service.js +271 -0
  133. package/dist/src/services/slice/slice-check-service.js +166 -13
  134. package/dist/src/services/slice/slice-check-types.d.ts +1 -1
  135. package/dist/src/services/standards/migrate-claude-rules-service.d.ts +19 -0
  136. package/dist/src/services/standards/migrate-claude-rules-service.js +193 -0
  137. package/dist/src/services/understand/understand-scan-service.js +15 -2
  138. package/dist/src/services/understand/understand-types.d.ts +26 -0
  139. package/dist/src/services/upgrade/1x-detector-service.d.ts +7 -0
  140. package/dist/src/services/upgrade/1x-detector-service.js +94 -0
  141. package/dist/src/services/upgrade/gitignore-migrate-service.d.ts +56 -0
  142. package/dist/src/services/upgrade/gitignore-migrate-service.js +170 -0
  143. package/dist/src/services/upgrade/upgrade-service.d.ts +47 -0
  144. package/dist/src/services/upgrade/upgrade-service.js +381 -0
  145. package/dist/src/services/workflow/workflow-router-service.js +15 -4
  146. package/dist/src/services/workspace/claude-settings-template.d.ts +53 -0
  147. package/dist/src/services/workspace/claude-settings-template.js +133 -0
  148. package/dist/src/services/workspace/sid-naming-guard.d.ts +14 -0
  149. package/dist/src/services/workspace/sid-naming-guard.js +31 -0
  150. package/dist/src/services/workspace/workspace-archive-service.d.ts +19 -0
  151. package/dist/src/services/workspace/workspace-archive-service.js +32 -0
  152. package/dist/src/services/workspace/workspace-clean-service.d.ts +41 -0
  153. package/dist/src/services/workspace/workspace-clean-service.js +86 -0
  154. package/dist/src/services/workspace/workspace-service.d.ts +24 -0
  155. package/dist/src/services/workspace/workspace-service.js +124 -2
  156. package/dist/src/services/workspace/workspace-state-service.d.ts +7 -0
  157. package/dist/src/services/workspace/workspace-state-service.js +43 -0
  158. package/dist/src/shared/change-id.js +4 -1
  159. package/dist/src/shared/version.d.ts +1 -1
  160. package/dist/src/shared/version.js +1 -1
  161. package/package.json +8 -2
  162. package/schemas/doctor-report.schema.json +1 -1
  163. package/scripts/install-skills.mjs +296 -12
  164. package/skills/peaks-doctor/SKILL.md +59 -0
  165. package/skills/peaks-doctor/references/doctor-check-catalog.md +31 -0
  166. package/skills/peaks-doctor/references/from-doctor-flow.md +64 -0
  167. package/skills/peaks-doctor/test_prompts.json +17 -0
  168. package/skills/peaks-ide/SKILL.md +2 -0
  169. package/skills/peaks-qa/SKILL.md +9 -7
  170. package/skills/peaks-qa/references/artifact-per-request.md +19 -5
  171. package/skills/peaks-qa/references/qa-perf-test-plan.md +6 -6
  172. package/skills/peaks-qa/references/qa-runbook.md +1 -1
  173. package/skills/peaks-rd/SKILL.md +25 -10
  174. package/skills/peaks-rd/references/ocr-integration.md +214 -0
  175. package/skills/peaks-rd/references/rd-fanout-contracts.md +70 -0
  176. package/skills/peaks-rd/references/rd-runbook.md +1 -1
  177. package/skills/peaks-solo/SKILL.md +16 -4
  178. package/skills/peaks-solo/references/anchoring-and-session-info.md +9 -0
  179. package/skills/peaks-solo/references/step-0-55-1x-detection.md +82 -0
  180. package/skills/peaks-solo/references/workflow-gates-and-types.md +9 -0
@@ -7,14 +7,14 @@
7
7
  > `qa/performance-findings-<rid>.md` references this baseline by path +
8
8
  > hash.
9
9
 
10
- ## Location
10
+ ## File location
11
11
 
12
12
  `.peaks/_runtime/<sessionId>/qa/perf-baseline.md`. The CLI is
13
13
  `peaks workflow plan read perf --project <repo> --json` /
14
14
  `peaks workflow plan refresh perf --project <repo> --apply` /
15
15
  `peaks workflow plan detect-trigger --project <repo> --rid <rid> --json`.
16
16
 
17
- ## Generation workflow
17
+ ## Perf generation workflow
18
18
 
19
19
  1. `peaks workflow plan read perf --project <repo> --json` — return the
20
20
  existing baseline envelope. When missing, proceed to step 2.
@@ -30,7 +30,7 @@
30
30
  (lighthouse / k6 / autocannon output) — see peaks-rd's
31
31
  `mandatory-perf-baseline.md` for the RD-side measurement workflow.
32
32
 
33
- ## Content schema (deterministic — body is normalized before hashing)
33
+ ## Perf content schema (deterministic)
34
34
 
35
35
  - `## CLI Command Inventory` — auto-enumerated from
36
36
  `src/cli/commands/*-commands.ts`. Sorted alphabetically.
@@ -39,7 +39,7 @@
39
39
  actual numbers (CLI does not call measurement tools).
40
40
  - `## Thresholds` — placeholder; RD fills per-route thresholds.
41
41
 
42
- ## Refresh trigger table (shared with security plan)
42
+ ## Perf refresh trigger table (shared with security plan)
43
43
 
44
44
  | Signal | Reason string | Re-generates the baseline? |
45
45
  |---|---|---|
@@ -51,7 +51,7 @@
51
51
  | devDependencies change only | (none) | no — locked Q1 default |
52
52
  | Pure text edits to `rd/*` or `qa/test-cases/*` | (none) | no |
53
53
 
54
- ## Back-compat (1 minor release)
54
+ ## Perf back-compat (1 minor release)
55
55
 
56
56
  The pre-slice-025 non-suffixed `qa/performance-findings.md` is still
57
57
  accepted by `peaks workflow verify-pipeline` Gate C during the
@@ -59,7 +59,7 @@ accepted by `peaks workflow verify-pipeline` Gate C during the
59
59
  (`src/services/workflow/artifact-paths.ts`) handles the fallback and
60
60
  emits a `legacy-redirect` warning.
61
61
 
62
- ## CLI surface recap
62
+ ## Perf CLI surface recap
63
63
 
64
64
  | Command | Returns | JSON shape |
65
65
  |---|---|---|
@@ -1,4 +1,4 @@
1
- # Default runbook (QA)
1
+ ## Default runbook (QA)
2
2
 
3
3
  > Body of `## Default runbook` + numbered runbook steps #0–#9. The default sequence the QA skill should execute. Do not skip the boundary check, the unit test gate, the validation report, or — when frontend is in scope — the Playwright MCP browser gate.
4
4
 
@@ -15,9 +15,9 @@ Peaks-Cli RD owns engineering analysis, implementation planning, and refactor ex
15
15
 
16
16
  ## Hard contracts for browser self-test (BLOCKING — read before any browser_take_screenshot / login flow)
17
17
 
18
- For frontend or UI-affecting slices, RD's self-test uses the Playwright MCP headed browser. Two contracts (1) self-test screenshots land under `.peaks/_runtime/<sessionId>/qa/screenshots/`, (2) login / CAPTCHA / SSO / MFA is a hard block — surface with `AskUserQuestion` and pick one of three paths. The full contract is identical in spirit to `peaks-qa`'s; RD and QA share the headed-browser path.
18
+ For frontend / UI-affecting slices, RD's self-test uses the Playwright MCP headed browser. LLM checks its own tool list for the Playwright MCP entry; if absent, surface the install command (`claude mcp add playwright -- npx @playwright/mcp@latest`) and report the gate blocked. Do not silently downgrade to screenshots-only, manual steps, or chrome-devtools-mcp. Two contracts: (1) self-test screenshots land under `.peaks/_runtime/<sessionId>/qa/screenshots/`, (2) login / CAPTCHA / SSO / MFA is a hard block — surface with `AskUserQuestion`. Same in spirit as `peaks-qa`'s; RD and QA share the headed-browser path.
19
19
 
20
- → see `references/browser-self-test-contracts.md` for the full contract + AskUserQuestion options.
20
+ → see `references/browser-self-test-contracts.md`.
21
21
 
22
22
  ## Sub-agent dispatch (when launched by peaks-solo swarm)
23
23
 
@@ -44,15 +44,13 @@ When this skill is running in the main Claude session (not as a sub-agent — i.
44
44
 
45
45
  ## Mandatory per-request artifact
46
46
 
47
- Every RD invocation — feature, bug, refactor, clarification — must write a durable artifact at `.peaks/_runtime/<sessionId>/rd/requests/<request-id>.md`. This is the canonical engineering record for that request; handoff to QA/SC is blocked while the artifact is missing or its state is `draft` or `spec-locked` without implementation evidence.
47
+ Every RD invocation — feature, bug, refactor, clarification — must write a durable artifact at `.peaks/<session-id>/rd/requests/<request-id>.md` (the canonical placeholder form: `<session-id>` is the active session id at runtime, `<request-id>` follows the `YYYY-MM-DD-<kebab-slug>` format; the runtime path is `.peaks/_runtime/<session-id>/rd/requests/<request-id>.md`). This is the canonical engineering record for that request; handoff to QA/SC is blocked while the artifact is missing or its state is `draft` or `spec-locked` without implementation evidence. Codegraph context lives at `.peaks/<session-id>/rd/codegraph-context.md`.
48
48
 
49
49
  → see `references/artifact-per-request.md` for the template + the "two RD artifact files" rule (per-slice vs per-session scope).
50
50
 
51
51
  ## Default runbook
52
52
 
53
- The default sequence the RD skill should execute for a code-touching request. Skip steps that do not apply to the request type; do not skip the artifact, coverage gate, or red-line scope steps. The full 9-step runbook (steps #0–#8) with every CLI invocation, project-scan BLOCKING rule, component-library detection, CSS framework conflict check, and 6 transition gates is in the references file.
54
-
55
- → see `references/rd-runbook.md` for the full runbook.
53
+ See `references/rd-runbook.md` for the full 9-step runbook (steps #0–#8) with every CLI invocation, project-scan BLOCKING rule, component-library detection, CSS framework conflict check, and 6 transition gates.
56
54
 
57
55
  ## RD gate index
58
56
 
@@ -108,11 +106,22 @@ RD cannot mark a development slice complete until all of these are true. Each ga
108
106
 
109
107
  If any gate fails, return to development for fixes or hand off as blocked. Do not describe the work as done, shippable, or ready for QA.
110
108
 
111
- ## Parallel review fan-out (code-review + security-review + perf-baseline + qa-test-cases)
109
+ ## Parallel review fan-out (code-reviewer + security-reviewer + perf-baseline-reviewer + qa-test-cases-writer)
110
+
111
+ **When RD reaches the end of implementation, the four review activities run in parallel via `peaks sub-agent dispatch <role>`, not sequentially.** This is the same fan-out pattern peaks-solo uses for the post-PRD swarm. The four sub-agents are `code-reviewer` (code-review evidence), `security-reviewer` (security-review evidence), `perf-baseline-reviewer` (perf-baseline measurement), and `qa-test-cases-writer` (qa/test-cases/<rid>.md). Feature / refactor: all four. Bugfix: code-reviewer + security-reviewer + qa-test-cases-writer always; perf-baseline-reviewer only when perf-shaped. Config / docs / chore: no fan-out. B3 augmentation: ocr (user-owned LLM config at `peaksConfig.ocr.llm`, injected as env vars) → `peaks code-review run-ocr --json` → merge into `code-review.md`; → `references/ocr-integration.md`.
112
+
113
+ ### Peaks-Cli Gate C — type-specific RD evidence
114
+
115
+ The CLI gate at `rd:qa-handoff` is the authoritative check. Missing any required file → DO NOT attempt the qa-handoff transition; CLI will reject with `PREREQUISITES_MISSING`.
112
116
 
113
- **When RD reaches the end of implementation, the four review activities run in parallel via `peaks sub-agent dispatch <role>`, not sequentially.** This is the same fan-out pattern peaks-solo uses for the post-PRD swarm. Feature / refactor: all four. Bugfix: code-review + security-review + qa-test-cases always; perf-baseline only when perf-shaped. Config / docs / chore: no fan-out.
117
+ | Request type | Required RD evidence (under `.peaks/<id>/`) |
118
+ |---|---|
119
+ | feature / refactor | `rd/tech-doc.md` + `rd/code-review.md` + `rd/security-review.md` + `rd/perf-baseline.md` + `qa/test-cases/<rid>.md` |
120
+ | bugfix | `rd/bug-analysis.md` + `rd/code-review.md` + `rd/security-review.md` + `qa/test-cases/<rid>.md` (rd/perf-baseline.md only when perf-shaped) |
121
+ | config | `rd/security-review.md` |
122
+ | docs / chore | (no extra evidence required) |
114
123
 
115
- → see `references/parallel-review-fanout.md` for the dispatch template + the 4 sub-agents' contracts + aggregation + degradation.
124
+ → see `references/rd-fanout-contracts.md` for the 4 sub-agents' contracts + hard prohibitions + aggregation + degradation.
116
125
 
117
126
  ## Refactor hard gates
118
127
 
@@ -162,7 +171,13 @@ Before RD work stops, finishes, blocks, or hands off to another role, emit a sho
162
171
 
163
172
  ## External references
164
173
 
165
- Matt Pocock skills (diagnose / triage / tdd / improve-codebase-architecture / prototype): engineering references only. Inspect before applying; Peaks-Cli RD gates remain authoritative. Understand Anything: `peaks understand status/show --json`. Codegraph: local analysis only, never commit `.codegraph/` artifacts. Other external resources: `peaks capabilities --source access-repo/mcp-server --json` for capability discovery.
174
+ ## Codegraph project analysis
175
+
176
+ Codegraph is local project-analysis evidence, scoped to red-line scope boundaries (changed files / symbols) and read via `peaks codegraph affected --project <path> <changed-files...> --json`. Peaks-Cli RD gates remain authoritative; codegraph is untrusted supporting evidence. Do not let codegraph output drive scope, design, or QA verdict decisions, and never mutate agent settings, Claude settings, or hooks from codegraph. Do not commit `.codegraph/` artifacts or persist generated `.codegraph/` databases into git. Codegraph context is written to `.peaks/<session-id>/rd/codegraph-context.md` for handoff to QA / TXT.
177
+
178
+ ## Matt Pocock skills integration
179
+
180
+ Matt Pocock skills (`diagnose` / `triage` / `tdd` / `improve-codebase-architecture` / `prototype`): engineering references only. Inspect before applying; Peaks-Cli RD gates remain authoritative. Understand Anything: `peaks understand status/show --json`. Codegraph: local analysis only, never commit `.codegraph/` artifacts. Other external resources: `peaks capabilities --source access-repo/mcp-server --json` for capability discovery.
166
181
 
167
182
  → see `references/external-references.md` + `references/matt-pocock-integration.md` + `references/codegraph-project-analysis.md`.
168
183
 
@@ -0,0 +1,214 @@
1
+ # OCR (Open Code Review) integration
2
+
3
+ > Soft-optional second-opinion code review for peaks-rd Gate B3.
4
+ > Mirrors the ECC 64-agents pattern (spec §7.2): peaks-cli ships
5
+ > `@alibaba-group/open-code-review` as a **required dependency** and
6
+ > reads the LLM endpoint config from `peaksConfig.ocr.llm` in the
7
+ > user's `~/.peaks/config.json` (single source of truth, user-managed).
8
+ > When present + configured, the wrapper turns the output into
9
+ > structured `code-review.md` evidence.
10
+
11
+ ## What ocr is
12
+
13
+ [Open Code Review](https://github.com/alibaba/open-code-review) is
14
+ an AI-powered code review CLI from Alibaba. It reads git diffs,
15
+ sends the changed files to a **user-configured LLM endpoint**
16
+ (OpenAI- or Anthropic-compatible), and emits structured
17
+ line-precise review comments. It is NOT a hosted service —
18
+ all LLM traffic goes to the user's own configured endpoint.
19
+
20
+ Distribution: npm `@alibaba-group/open-code-review` (Go binary
21
+ inside; the npm postinstall downloads the platform-specific
22
+ binary from GitHub Releases).
23
+
24
+ ## Why peaks-rd uses it (soft-optional)
25
+
26
+ The default peaks-rd code-review evidence is produced by the
27
+ main RD LLM (or the `code-reviewer` sub-agent in the parallel
28
+ fan-out). That's one pair of eyes. When ocr is available, the
29
+ wrapper adds a **second pair** — an independent LLM tuned for
30
+ code review — and the two reviews are merged into the same
31
+ `code-review.md` file. Soft-optional: if ocr isn't installed or
32
+ configured, RD proceeds with the LLM-only review and the slice
33
+ ships without the second opinion.
34
+
35
+ ## Install
36
+
37
+ `@alibaba-group/open-code-review` is a **required `dependency`** of
38
+ peaks-cli 2.0.1+. `npm i -g peaks-cli` pulls it automatically and
39
+ downloads the platform binary in the postinstall step. Verify with:
40
+
41
+ ```bash
42
+ peaks code-review detect-ocr --json
43
+ ```
44
+
45
+ Five possible states:
46
+
47
+ | state | Meaning | Recovery |
48
+ |---|---|---|
49
+ | `ready` | Installed + binary downloaded + peaks-cli's `peaksConfig.ocr.llm` valid | Nothing — `run-ocr` will work. |
50
+ | `package-missing` | npm dep not installed (corrupt node_modules, or user removed it) | `npm i -g @alibaba-group/open-code-review` (peaks-cli 2.0.1+ does this automatically; this state is rare) |
51
+ | `binary-missing` | npm dep present but Go binary did not download | `pnpm approve-builds @alibaba-group/open-code-review`, OR run `node node_modules/@alibaba-group/open-code-review/scripts/install.js`, OR manually fetch from https://github.com/alibaba/open-code-review/releases and place the binary at the path shown in `nextActions[2]`. |
52
+ | `config-missing` | binary present but `peaksConfig.ocr.llm` is empty or partial | See "Configure" below. |
53
+ | `detection-failed` | Unexpected error during detection | Inspect stderr; re-run probe. |
54
+
55
+ ## Configure (one-time, per user) — peaks-cli does NOT auto-configure
56
+
57
+ The LLM endpoint config is **user-maintained inside peaks-cli's own
58
+ config** at `~/.peaks/config.json` under the `ocr.llm` key. The user
59
+ is the only party that touches their LLM token / URL / model. peaks-cli
60
+ never auto-writes the config and never writes `~/.opencodereview/config.json`.
61
+
62
+ ```bash
63
+ # 1) Print the JSON snippet to paste (read-only, no side effects):
64
+ peaks code-review config-template --json
65
+
66
+ # 2) Paste the snippet into ~/.peaks/config.json under "ocr.llm",
67
+ # replace <your-api-key> with your real key. Alternatively,
68
+ # set keys one at a time:
69
+ peaks config set --key ocr.llm.url --value 'https://api.example.com/v1/messages'
70
+ peaks config set --key ocr.llm.authToken --value '<your-key>'
71
+ peaks config set --key ocr.llm.model --value 'claude-3-5-sonnet-latest'
72
+ peaks config set --key ocr.llm.useAnthropic --value 'true'
73
+ peaks config set --key ocr.llm.authHeader --value 'x-api-key'
74
+
75
+ # 3) Verify readiness (peaks-rd also runs this automatically):
76
+ peaks code-review detect-ocr --json
77
+ ```
78
+
79
+ ### Field map: `peaksConfig.ocr.llm` ↔ ocr subprocess env vars
80
+
81
+ peaks-rd calls ocr with the `peaksConfig.ocr.llm` values **injected as
82
+ env vars** (ocr's highest-priority config path). The mapping is:
83
+
84
+ | `peaksConfig.ocr.llm.*` | Spawn env var | Notes |
85
+ |---|---|---|
86
+ | `url` | `OCR_LLM_URL` | HTTPS endpoint, no embedded credentials |
87
+ | `authToken` | `OCR_LLM_TOKEN` | Sensitive — stored only in the user-layer `~/.peaks/config.json`; `peaks config get` redacts this field |
88
+ | `model` | `OCR_LLM_MODEL` | e.g. `claude-3-5-sonnet-latest` |
89
+ | `useAnthropic` | `OCR_USE_ANTHROPIC` | Boolean; serialised as `"true"` / `"false"` |
90
+ | `authHeader` | `OCR_LLM_AUTH_HEADER` | One of `authorization` (default Bearer), `x-api-key` (for `sk-ant-*` keys), or `bearer` |
91
+
92
+ The `~/.opencodereview/config.json` file the user might have set up
93
+ for 2.0.0 is no longer consulted by peaks-cli. The user may delete it
94
+ at their discretion — the ocr subprocess ignores the file when peaks-
95
+ cli's env vars are present (and the env-var surface is highest priority).
96
+
97
+ ### Required vs optional fields
98
+
99
+ The minimum for `state == "ready"` is the **url + authToken + model**
100
+ triple. `useAnthropic` and `authHeader` are optional; `authHeader`
101
+ defaults to `authorization` (Bearer) inside the ocr subprocess, but
102
+ `sk-ant-*` keys require `authHeader: "x-api-key"`.
103
+
104
+ When the user has not yet populated the config, `detect-ocr` returns
105
+ `state: "config-missing"` with `missingKeys: ["ocr.llm.url",
106
+ "ocr.llm.authToken", "ocr.llm.model"]` and a templated
107
+ `nextActions[1]` payload that includes the JSON snippet to paste.
108
+
109
+ ## Use from peaks-rd (LLM workflow)
110
+
111
+ In Gate B3 (code review evidence), before writing
112
+ `.peaks/_runtime/<sid>/rd/code-review.md`, the code-reviewer
113
+ sub-agent runs:
114
+
115
+ ```bash
116
+ # 1. Detect
117
+ peaks code-review detect-ocr --json
118
+ # 2. If state == "ready", run the review
119
+ peaks code-review run-ocr --json --project . --from origin/main --to HEAD
120
+ ```
121
+
122
+ The `run-ocr` envelope is:
123
+
124
+ ```jsonc
125
+ {
126
+ "ok": true,
127
+ "command": "code-review.run-ocr",
128
+ "data": {
129
+ "spawned": true,
130
+ "state": "ready",
131
+ "exitCode": 0,
132
+ "stdout": "...",
133
+ "stderr": "",
134
+ "durationMs": 12345,
135
+ "parsed": {
136
+ "findings": [
137
+ { "file": "src/foo.ts", "line": 42, "severity": "minor", "message": "..." }
138
+ ]
139
+ },
140
+ "warnings": [],
141
+ "nextActions": []
142
+ },
143
+ ...
144
+ }
145
+ ```
146
+
147
+ Merge `data.parsed.findings` into `code-review.md` under
148
+ `## Second opinion (ocr)`. Cite each finding by file + line.
149
+ Reconcile disagreements with the LLM-only review explicitly
150
+ (don't silently drop one source).
151
+
152
+ ## Soft-fail policy
153
+
154
+ `peaks code-review run-ocr` **never** sets a non-zero exit code,
155
+ even when ocr is not ready or the subprocess fails. The envelope
156
+ `ok` field carries the success signal; the caller (peaks-rd) is
157
+ expected to pattern-match on `data.state` and proceed without the
158
+ second opinion if needed. This matches the ECC 64-agents
159
+ soft-fail policy and the peaks-cli "minimal user operation"
160
+ tenet — missing ocr should never block a slice.
161
+
162
+ ## Security
163
+
164
+ - ocr sends your changed files to whatever LLM endpoint you
165
+ configure. Treat this the same as any external code-review
166
+ tool you opt into: don't point it at a free public endpoint
167
+ for proprietary code; use a vendor / self-hosted endpoint with
168
+ appropriate data controls.
169
+ - peaks-cli does NOT auto-configure ocr. Your `ocr.llm.authToken`
170
+ is yours. Rotate as needed. The token is stored only in the
171
+ user-layer `~/.peaks/config.json` (project layer rejects writes
172
+ to any key matching `isSensitiveConfigPath`), and
173
+ `peaks config get` redacts it as `***`.
174
+ - peaks-cli's wrapper records ocr's `stdout` verbatim in the
175
+ envelope (and in `code-review.md` when peaks-rd merges
176
+ findings). Don't put secrets in your code being reviewed.
177
+ - The `peaks code-review config-template` snippet embeds the
178
+ placeholder string `<your-api-key>`; the user is expected to
179
+ replace it before pasting.
180
+
181
+ ## Failure modes (real)
182
+
183
+ These are the actual failure modes the wrapper has been
184
+ dogfooded against:
185
+
186
+ 1. **Network blocked from GitHub Releases** during postinstall →
187
+ `binary-missing`. peaks-cli still runs cleanly because ocr
188
+ is detected as not-ready; user manually fetches the binary
189
+ and places it at `nextActions[2]`'s path.
190
+ 2. **pnpm-installed peaks-cli** → ocr postinstall blocked by
191
+ pnpm's safe-by-default policy → `binary-missing`. Recover
192
+ with `pnpm approve-builds @alibaba-group/open-code-review`.
193
+ 3. **No / partial LLM config** → `config-missing` with
194
+ `missingKeys` listing the unpopulated fields. Recover by
195
+ pasting the `peaks code-review config-template` output into
196
+ `~/.peaks/config.json` (or by `peaks config set` per-key).
197
+ 4. **Wrong key / wrong endpoint** → ocr subprocess exits non-zero;
198
+ wrapper soft-fails (`ok: false`, `warnings[0]` includes the
199
+ exit code, `stderr` carries ocr's own error message).
200
+ 5. **User 2.0.0 → 2.0.1 migration** — they configured
201
+ `~/.opencodereview/config.json` for 2.0.0; peaks-cli 2.0.1
202
+ no longer reads that file. They paste the same values into
203
+ `~/.peaks/config.json` under `ocr.llm` (peaks-cli handles the
204
+ camelCase conversion in the template).
205
+
206
+ ## See also
207
+
208
+ - ocr upstream: https://github.com/alibaba/open-code-review
209
+ - peaks-cli source: `src/services/code-review/ocr-service.ts`,
210
+ `src/cli/commands/code-review-commands.ts`
211
+ - peaks-cli config schema: `src/services/config/config-types.ts`
212
+ (`OcrLlmConfig`, `OcrConfig`, `PeaksConfig.ocr?`)
213
+ - ECC 64-agents soft-optional pattern (mirrored):
214
+ `src/services/agent/ecc-agent-service.ts`
@@ -0,0 +1,70 @@
1
+ # peaks-rd 4-way parallel fan-out (slice 004)
2
+
3
+ The Parallel review fan-out is the canonical RD-side review pattern: at the
4
+ end of implementation, RD fires 4 sub-agents in parallel via
5
+ `peaks sub-agent dispatch <role>` instead of running them sequentially.
6
+
7
+ ## The 4 sub-agents
8
+
9
+ - **Sub-agent 1 — code-reviewer** runs `code-review` against the diff and
10
+ writes `rd/code-review.md`.
11
+ - **Sub-agent 2 — security-reviewer** runs `security-review` against the
12
+ changed surface and writes `rd/security-review.md`.
13
+ - **Sub-agent 3 — perf-baseline-reviewer** measures the perf surface
14
+ (slice 025) and writes `rd/perf-baseline.md`. Skipped when the slice
15
+ has no perf surface (e.g. config / docs / chore) or when the bugfix
16
+ is not perf-shaped.
17
+ - **Sub-agent 4 — qa-test-cases-writer** drafts the QA test plan and
18
+ writes `qa/test-cases/<rid>.md`. The test plan is the deliverable —
19
+ these test cases do NOT need to be executed by this sub-agent (the
20
+ QA reviewer executes them in Gate D). Do NOT write to `tests/`; the
21
+ writer's only write target is `qa/test-cases/<rid>.md`.
22
+
23
+ ## Hard prohibitions on all 4 sub-agents (single block)
24
+
25
+ - Sub-agents are spawned via `Skill(skill="...")` and run in their own
26
+ conversation context. They MUST NOT mutate parent settings
27
+ (`peaks skill presence:set`, hooks install, `.claude/settings.json`).
28
+ - Sub-agents MUST NOT call `peaks workflow verify-pipeline` — that is
29
+ Solo's responsibility.
30
+ - Sub-agents MUST NOT modify the request artifact body — they only
31
+ write their respective review artifact.
32
+ - Sub-agents MUST NOT install or persist external material (no
33
+ `npm install` of unapproved packages, no Playwright MCP install).
34
+ - Sub-agents return a compact JSON envelope
35
+ (`{ ok, artifact, blockers, notes }`) to the parent RD loop; the
36
+ parent aggregates into the final qa-handoff.
37
+
38
+ ## Aggregation
39
+
40
+ The parent RD loop receives the 4 envelopes, runs `peaks request lint`
41
+ on the produced artifacts, and only then attempts
42
+ `peaks request transition --state qa-handoff`. The aggregation step
43
+ runs 4 ls checks: Gate B3 (code-review file), Gate B4 (security-review
44
+ file), Gate B9 (perf-baseline file, when the slice has a perf
45
+ surface), and the `qa-test-cases` pre-draft (the 4th sub-agent's
46
+ deliverable). A failure in any of the 4 sub-agents → blocked, no
47
+ auto-downgrade.
48
+
49
+ ## Degradation
50
+
51
+ When the `qa-test-cases-writer` sub-agent fails, the parent RD loop
52
+ records the failure as `qa-test-cases-subagent-degraded-to-inline-qa-draft`
53
+ in the request artifact and proceeds; the QA main loop falls back to
54
+ drafting the test plan inline at Gate D. The other 3 sub-agents
55
+ (code-reviewer, security-reviewer, perf-baseline-reviewer) are NOT
56
+ degradeable — their failure blocks qa-handoff.
57
+
58
+ ## Gate C evidence (RD-side, type-specific)
59
+
60
+ | Request type | Required RD evidence (under `.peaks/<id>/`) |
61
+ |---|---|
62
+ | feature / refactor | `rd/tech-doc.md` + `rd/code-review.md` + `rd/security-review.md` + `rd/perf-baseline.md` + `qa/test-cases/<rid>.md` |
63
+ | bugfix | `rd/bug-analysis.md` + `rd/code-review.md` + `rd/security-review.md` + `qa/test-cases/<rid>.md` (rd/perf-baseline.md only when perf-shaped) |
64
+ | config | `rd/security-review.md` |
65
+ | docs / chore | (no extra evidence required) |
66
+
67
+ Always required (in addition to the type-specific row):
68
+ `ls .peaks/<id>/rd/requests/<rid>.md`. Missing any required file →
69
+ DO NOT attempt the qa-handoff transition; CLI will reject with
70
+ `PREREQUISITES_MISSING`.
@@ -1,4 +1,4 @@
1
- # Default runbook (RD)
1
+ ## Default runbook (RD)
2
2
 
3
3
  > Body of `## Default runbook` + numbered runbook steps #0–#8. The default sequence the RD skill should execute for a code-touching request. Skip steps that do not apply to the request type; do not skip the artifact, coverage gate, or red-line scope steps.
4
4
 
@@ -66,12 +66,24 @@ Run `peaks workspace init` + `peaks skill presence:set peaks-solo` BEFORE any an
66
66
 
67
67
  → see `references/anchoring-and-session-info.md` for the full Step 0 contract + session-conflict resolution.
68
68
 
69
+ #### Step 0 bypass — Claude Code [Fact-Forcing Gate] (slice 2.0.1-bug3)
70
+
71
+ `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.
72
+
73
+ → see `references/anchoring-and-session-info.md` for the full bypass contract, recovery flow, and anti-bail-out rule.
74
+
69
75
  ### Peaks-Cli Step 0.7: Detect unfinished work and offer resume (BLOCKING on first invocation per session)
70
76
 
71
77
  After Step 0 anchored the workspace, run the resume-detection probe (one `find` + one `grep` + classification table). Surface resume options via `AskUserQuestion` if a slice is in flight. Never silently auto-resume.
72
78
 
73
79
  → see `references/resume-detection.md` for the full detection algorithm + classification table.
74
80
 
81
+ ### Peaks-Cli Step 0.55: 1.x → 2.0 detection (BLOCKING on first invocation per session, when the project is not on a 2.0 layout)
82
+
83
+ Per the "one-key completion" tenet (2026-06-11), peaks-cli 2.0 should detect a 1.x consumer project and prompt the user to upgrade. After Step 0.7 returns "fresh" (no in-flight slice), run the 1.x detection probe: `peaks upgrade --detect-1x --project <root> --json`. If the result is `isOneX: true`, surface an `AskUserQuestion` with the upgrade prompt. Persist the decision to `.peaks/preferences.json` (key: `autoUpgradePrompt` with values `opt-in` / `skip-this-session` / `skip-forever`) so subsequent runs in the same project don't re-ask.
84
+
85
+ → see `references/step-0-55-1x-detection.md` for the full detection algorithm + AskUserQuestion options + persistence contract.
86
+
75
87
  ### Peaks-Cli Step 1: Mode selection
76
88
 
77
89
  When the user did not name a profile (`full-auto` / `assisted` / `swarm` / `strict`), use `AskUserQuestion` with `Full auto (Recommended)` as the first option. Map the choice to `--mode` value.
@@ -191,15 +203,15 @@ After final validation, refresh project-local standards via `peaks standards ini
191
203
 
192
204
  ## Peaks-Cli External references and lifecycle
193
205
 
194
- Inventory of 3rd-party integrations (codegraph, mattpocock/skills, shadcn/ui, MCPs, Context7). Three-stage pattern: capability discovery via `peaks capabilities` → references only → Peaks-Cli CLI for side effects.
206
+ Inventory of 3rd-party integrations (codegraph, mattpocock/skills, shadcn/ui, MCPs, Context7). Three-stage pattern: capability discovery via `peaks capabilities` → references only → Peaks-Cli CLI for side effects. Peaks-Cli artifacts and Peaks-Cli acceptance criteria remain authoritative; do not execute upstream installer scripts; MCP servers (Playwright MCP, Chrome DevTools MCP, Figma Context MCP) are not managed by peaks-cli — the LLM checks its own tool list for `mcp__<server>__*` entries; if absent, the user installs via the IDE-native install command (e.g. `claude mcp add playwright -- npx @playwright/mcp@latest` for Claude Code).
195
207
 
196
- → see `references/external-references.md` for the full inventory + lifecycle rules.
208
+ → see `references/external-references.md` for the full inventory + lifecycle rules, and `references/external-skill-invocation.md` for the three-stage (Discovery → Reference → Side effect through Peaks CLI only) contract + the do-not-execute / do-not-persist / tool-list self-check rules.
197
209
 
198
210
  ## Codegraph orchestration context
199
211
 
200
- Solo treats `peaks codegraph affected --project <path> <changed-files...> --json` as optional project-analysis enhancement. Output is untrusted supporting evidence — never treat as approval for scope, design, or QA verdict.
212
+ Solo treats `peaks codegraph affected --project <path> <changed-files...> --json` as optional project-analysis enhancement. Output is untrusted supporting evidence — never treat as approval for scope, design, or QA verdict. Solo must not treat codegraph output as approval; never mutate agent settings, Claude settings, or hooks from codegraph; do not commit `.codegraph/` artifacts or persist generated `.codegraph/` databases into git. Solo coordinates codegraph context across the role handoff between RD (writes `.peaks/<session-id>/rd/codegraph-context.md`) and QA / TXT (consume the same envelope).
201
213
 
202
- → see `references/codegraph-orchestration.md` for the full contract.
214
+ → see `references/codegraph-orchestration.md` for the full contract (including the agent-settings / settings-mutation prohibition, the no-`.codegraph/` commit rule, and the role-handoff envelope).
203
215
 
204
216
  ## Sub-agent context governance (G7 + G7.7 + G8 + G9 — slice #010)
205
217
 
@@ -22,4 +22,13 @@ peaks skill presence:set peaks-solo --project <repo> --gate startup
22
22
  **Session conflict resolution (read once, internalise):** If `peaks workspace init` returns `code: "CONFLICTING_SESSION"` with a body like
23
23
  `{"existingSessionId":"<Y>","requestedSessionId":"<X>"}`, the project is already bound to a different in-flight session `<Y>` (the one you or a prior run was working on). The fix is **NOT** to pass `--allow-session-rebind` to clobber `<Y>` — that destroys an active session's data. Instead: finish or abandon `<Y>` first (use `peaks session list --json` to see what it is, then `peaks session finish --id <Y>` or `peaks session abandon --id <Y>` — see your session command's help for the exact verbs). Only after `<Y>` is closed should you re-run `peaks workspace init`. The same rule applies to `peaks workspace init --session-id "<manually-forged>"` — do not pre-forge session ids; the CLI's auto-generated value is the binding.
24
24
 
25
+ **Fact-Forcing Gate bypass (slice 2.0.1-bug3):** Claude Code's [Fact-Forcing Gate] fires in two shapes inside peaks-solo Step 0: (1) Bash-side "Quote the user's current instruction verbatim. Then retry the same operation." and (2) Write-side 4-facts prompt. Both block the very first Write to `.peaks/_runtime/<sid>/session.json` and the first `peaks skill presence:set peaks-solo` invocation. The default `peaks workspace init` (no flag) materializes `.claude/settings.local.json` in the consumer project root with a PreToolUse hook allow-list that exits 0 for tool calls inside `.peaks/**` and for `peaks <whitelisted-subcommand>` Bash commands. The hook bypasses the gate before it fires.
26
+
27
+ If the bypass is not in effect (e.g. `.claude/` was read-only, or the user passed `--no-claude-hooks`, or the consumer manually deleted the file), the recovery flow is:
28
+
29
+ 1. Re-run `peaks workspace init --project <repo> --json` **without** `--no-claude-hooks`. The next-action list will say "Materialized .claude/settings.local.json (action: written/refreshed)". Restart Claude Code so the hook takes effect.
30
+ 2. If `.claude/` cannot be written (read-only mount, container with no write access, etc.), drop the contents of `.peaks/.claude-settings-template.json` into `.claude/settings.local.json` manually. The peaks-cli init always writes the offline template copy (regardless of `--no-claude-hooks`) so the user has a known source-of-truth on disk. After copying, restart Claude Code.
31
+
32
+ **Anti-bail-out rule for the gate:** Do NOT skip Step 0 because the gate fired. The gate is a Claude Code core feature that peaks-cli cannot modify directly; peaks-cli can only sidestep it via the hook allow-list. If the gate still blocks Step 0 after the bypass is in effect, the user has a misconfigured `.claude/settings.json` upstream — surface that as a separate `AskUserQuestion` ("Your `.claude/settings.json` is overriding the local allow-list. May peaks-cli delete the local file and regenerate it?") rather than skipping Step 0.
33
+
25
34
  `presence:set` accepts no `--mode` here on purpose — mode is unknown until Step 1. It is re-run with the selected mode in Step 2. Setting presence early guarantees the status header/line shows `peaks-solo` from the very first turn even if the user never reaches mode selection.
@@ -0,0 +1,82 @@
1
+ # Step 0.55 — 1.x → 2.0 detection reference
2
+
3
+ > Body of `### Peaks-Cli Step 0.55`. Slice: 2026-06-12-solo-step-0-55-1x-detection.
4
+
5
+ ## Why this step exists
6
+
7
+ The peaks-cli 1.x → 2.0 closeout ships:
8
+
9
+ 1. A postinstall that auto-detects 1.x state and dispatches the upgrade (slice 1, commit `b6e34e6`).
10
+ 2. A standards-migrate path that thins `.claude/rules/**/*.md` and scaffolds `.peaks/standards/` (slice 2, commit `33dd392`).
11
+ 3. **THIS STEP** — a peaks-solo startup sequence probe that detects 1.x state when the user invokes `/peaks-solo` directly in a 1.x consumer project, and prompts the user to upgrade.
12
+
13
+ The 1.x user experience is: "I just typed /peaks-solo. Why is it not working in 2.0 mode?" Step 0.55 catches this case and surfaces an `AskUserQuestion` with a one-click upgrade.
14
+
15
+ ## Detection algorithm
16
+
17
+ ```bash
18
+ # 1. Read-only probe via the umbrella CLI
19
+ peaks upgrade --detect-1x --project <root> --json
20
+ ```
21
+
22
+ The CLI returns:
23
+ ```json
24
+ {
25
+ "ok": true,
26
+ "command": "upgrade.detect-1x",
27
+ "data": {
28
+ "isOneX": true,
29
+ "signals": [
30
+ "<path> has schema_version 1.0.0, expected '2.0.0'",
31
+ "..."
32
+ ],
33
+ "projectRoot": "/path/to/project",
34
+ "configPath": null
35
+ },
36
+ "warnings": [],
37
+ "nextActions": [
38
+ "Detected 1.x state. peaks-solo Step 0.55 should present an AskUserQuestion to invoke `peaks upgrade --to 2.0 --auto --project /path/to/project`."
39
+ ]
40
+ }
41
+ ```
42
+
43
+ The detection logic mirrors `scripts/install-skills.mjs:detect1xProjectState` (canonical implementation) — it walks up to find `.peaks/_runtime/`, then sniffs:
44
+
45
+ 1. `~/.peaks/config.json` for `version: 1.x`
46
+ 2. `<projectRoot>/.claude/rules/common/dev-preference.md` for "peaks progress"
47
+ 3. `<projectRoot>/.peaks/preferences.json` for missing or non-`2.0.0` `schema_version`
48
+
49
+ The TS mirror in `src/services/upgrade/1x-detector-service.ts` is the canonical entrypoint for the skill; the postinstall `.mjs` version is the canonical entrypoint for the npm-install flow. The two implementations MUST stay in parity (a parity test is in the slice's test suite).
50
+
51
+ ## AskUserQuestion (only when `isOneX: true`)
52
+
53
+ | Option | What it does |
54
+ |---|---|
55
+ | Run `peaks upgrade --to 2.0 --auto --project <root>` (Recommended) | Invokes the umbrella. The user sees the 6 sub-step results in the terminal. After the upgrade, re-run peaks-solo with the standing 2.0 layout. Persist `autoUpgradePrompt: opt-in` to `.peaks/preferences.json`. |
56
+ | Skip for this session | Continue with the standing 1.x layout. Persist `autoUpgradePrompt: skip-this-session` to `.peaks/preferences.json`. The next time the user invokes peaks-solo in this project, the question re-asks. |
57
+ | Never ask again for this project | Persist `autoUpgradePrompt: skip-forever` to `.peaks/preferences.json`. Step 0.55 becomes a no-op for this project from now on. The user can re-enable later by removing the `autoUpgradePrompt` key from preferences.json. |
58
+
59
+ ## Persistence contract
60
+
61
+ The decision is persisted via `peaks preferences set --project <root> --key autoUpgradePrompt --value <opt-in|skip-this-session|skip-forever> --apply`. Subsequent Step 0.55 invocations read the value first:
62
+
63
+ - If `opt-in` (and Step 0.55 is the first invocation in the session), the user has already opted in; auto-run the umbrella without re-asking.
64
+ - If `skip-this-session`, the user already said no this session; skip without re-asking (but re-ask next session).
65
+ - If `skip-forever`, the user said no permanently; skip without re-asking.
66
+ - If the key is absent, present the AskUserQuestion.
67
+
68
+ ## What is NOT in this step
69
+
70
+ - The auto-upgrade execution itself: the umbrella is invoked via the AskUserQuestion's recommended option. The umbrella's behavior (6 sub-commands + write-upgrade-record) is documented in the umbrella's own help text.
71
+ - The postinstall auto-dispatch: that's `scripts/install-skills.mjs:autoUpgrade1xProjectIfPresent`, which fires fire-and-forget on `npm i -g peaks-cli@2.0`. Step 0.55 is the user-invoked path.
72
+ - Re-authoring the 1.x detector heuristics: the implementation is a 1:1 mirror of the canonical `.mjs` version. Drift is prevented by the parity test.
73
+
74
+ ## How this integrates with the rest of the workflow
75
+
76
+ - Step 0.5 (OpenSpec opt-in) — runs first if `openspec/` is missing.
77
+ - Step 0 (anchor) — runs always.
78
+ - Step 0.7 (resume detection) — runs after Step 0.
79
+ - **Step 0.55 (1.x detection) — runs after Step 0.7, only when the project is not on a 2.0 layout.**
80
+ - Step 1 (mode selection) — runs after Step 0.55.
81
+
82
+ The 1.x detection is intentionally placed AFTER Step 0.7 because the user might already have a 1.x-converted in-flight slice; the resume flow takes precedence over the upgrade prompt.
@@ -102,6 +102,15 @@ ls .peaks/<id>/ui/design-draft.md 2>&1
102
102
 
103
103
  The CLI gate (`peaks request transition --state qa-handoff`) is the authoritative check; running this `ls` first lets you produce missing files before the CLI rejects the transition.
104
104
 
105
+ | Request type | Required RD evidence (under `.peaks/<id>/`) |
106
+ |---|---|
107
+ | `feature` / `refactor` | `rd/tech-doc.md` + `rd/code-review.md` + `rd/security-review.md` + `rd/perf-baseline.md` + `qa/test-cases/<rid>.md` (qa/test-cases pre-drafted by the 4th sub-agent in peaks-rd's parallel fan-out — slice 004) |
108
+ | `bugfix` | `rd/bug-analysis.md` + `rd/code-review.md` + `rd/security-review.md` + `qa/test-cases/<rid>.md` (rd/perf-baseline.md only when the bug is performance-shaped) |
109
+ | `config` | `rd/security-review.md` |
110
+ | `docs` / `chore` | (no extra evidence required) |
111
+
112
+ Always required (in addition to the type-specific row): `ls .peaks/<id>/rd/requests/<rid>.md`. Missing any required file → DO NOT attempt the qa-handoff transition; CLI will reject with PREREQUISITES_MISSING.
113
+
105
114
  ```bash
106
115
  # Always required
107
116
  ls .peaks/<id>/rd/requests/<rid>.md