peaks-cli 1.3.8 → 1.4.0

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 (130) hide show
  1. package/dist/src/cli/commands/core-artifact-commands.js +27 -0
  2. package/dist/src/cli/commands/project-commands.js +58 -1
  3. package/dist/src/cli/commands/request-commands.js +93 -3
  4. package/dist/src/cli/commands/retrospective-commands.d.ts +3 -0
  5. package/dist/src/cli/commands/retrospective-commands.js +113 -0
  6. package/dist/src/cli/commands/skill-scope-commands.d.ts +49 -0
  7. package/dist/src/cli/commands/skill-scope-commands.js +305 -0
  8. package/dist/src/cli/commands/workflow-commands.js +1 -1
  9. package/dist/src/cli/commands/workflow-plan-commands.d.ts +39 -0
  10. package/dist/src/cli/commands/workflow-plan-commands.js +163 -0
  11. package/dist/src/cli/program.js +8 -0
  12. package/dist/src/services/doctor/doctor-service.d.ts +40 -0
  13. package/dist/src/services/doctor/doctor-service.js +160 -0
  14. package/dist/src/services/hooks/presence-marker-detector.d.ts +16 -0
  15. package/dist/src/services/hooks/presence-marker-detector.js +105 -0
  16. package/dist/src/services/memory/project-memory-service.d.ts +19 -0
  17. package/dist/src/services/memory/project-memory-service.js +33 -0
  18. package/dist/src/services/retrospective/migrate-from-md.d.ts +37 -0
  19. package/dist/src/services/retrospective/migrate-from-md.js +528 -0
  20. package/dist/src/services/retrospective/retrospective-index.d.ts +37 -0
  21. package/dist/src/services/retrospective/retrospective-index.js +110 -0
  22. package/dist/src/services/retrospective/retrospective-show.d.ts +40 -0
  23. package/dist/src/services/retrospective/retrospective-show.js +109 -0
  24. package/dist/src/services/skill-scope/adapters/_stub-helper.d.ts +39 -0
  25. package/dist/src/services/skill-scope/adapters/_stub-helper.js +98 -0
  26. package/dist/src/services/skill-scope/adapters/claude-code.d.ts +59 -0
  27. package/dist/src/services/skill-scope/adapters/claude-code.js +304 -0
  28. package/dist/src/services/skill-scope/adapters/codex.d.ts +2 -0
  29. package/dist/src/services/skill-scope/adapters/codex.js +12 -0
  30. package/dist/src/services/skill-scope/adapters/cursor.d.ts +2 -0
  31. package/dist/src/services/skill-scope/adapters/cursor.js +13 -0
  32. package/dist/src/services/skill-scope/adapters/qoder.d.ts +2 -0
  33. package/dist/src/services/skill-scope/adapters/qoder.js +13 -0
  34. package/dist/src/services/skill-scope/adapters/tongyi.d.ts +2 -0
  35. package/dist/src/services/skill-scope/adapters/tongyi.js +13 -0
  36. package/dist/src/services/skill-scope/adapters/trae.d.ts +2 -0
  37. package/dist/src/services/skill-scope/adapters/trae.js +12 -0
  38. package/dist/src/services/skill-scope/detect.d.ts +75 -0
  39. package/dist/src/services/skill-scope/detect.js +480 -0
  40. package/dist/src/services/skill-scope/registry.d.ts +41 -0
  41. package/dist/src/services/skill-scope/registry.js +83 -0
  42. package/dist/src/services/skill-scope/source-of-truth.d.ts +44 -0
  43. package/dist/src/services/skill-scope/source-of-truth.js +118 -0
  44. package/dist/src/services/skill-scope/types.d.ts +176 -0
  45. package/dist/src/services/skill-scope/types.js +74 -0
  46. package/dist/src/services/standards/migrate-service.d.ts +63 -0
  47. package/dist/src/services/standards/migrate-service.js +193 -0
  48. package/dist/src/services/standards/project-standards-service.js +1 -23
  49. package/dist/src/services/workflow/artifact-paths.d.ts +59 -0
  50. package/dist/src/services/workflow/artifact-paths.js +127 -0
  51. package/dist/src/services/workflow/pipeline-verify-service.d.ts +6 -0
  52. package/dist/src/services/workflow/pipeline-verify-service.js +49 -4
  53. package/dist/src/services/workflow/plan-reader.d.ts +29 -0
  54. package/dist/src/services/workflow/plan-reader.js +158 -0
  55. package/dist/src/services/workflow/plan-refresher.d.ts +32 -0
  56. package/dist/src/services/workflow/plan-refresher.js +353 -0
  57. package/dist/src/services/workflow/plan-trigger-detector.d.ts +55 -0
  58. package/dist/src/services/workflow/plan-trigger-detector.js +142 -0
  59. package/dist/src/shared/format-md-compact.d.ts +32 -0
  60. package/dist/src/shared/format-md-compact.js +297 -0
  61. package/dist/src/shared/stale-policy.d.ts +67 -0
  62. package/dist/src/shared/stale-policy.js +85 -0
  63. package/dist/src/shared/version.d.ts +1 -1
  64. package/dist/src/shared/version.js +1 -1
  65. package/package.json +3 -2
  66. package/schemas/doctor-report.schema.json +2 -2
  67. package/skills/peaks-qa/SKILL.md +103 -507
  68. package/skills/peaks-qa/references/artifact-per-request.md +7 -79
  69. package/skills/peaks-qa/references/browser-validation-contracts.md +51 -0
  70. package/skills/peaks-qa/references/codegraph-regression-focus.md +5 -0
  71. package/skills/peaks-qa/references/external-capability-guidance.md +9 -0
  72. package/skills/peaks-qa/references/qa-compact-handoff.md +3 -0
  73. package/skills/peaks-qa/references/qa-context-governance.md +24 -0
  74. package/skills/peaks-qa/references/qa-fanout-contract.md +8 -0
  75. package/skills/peaks-qa/references/qa-gstack-integration.md +7 -0
  76. package/skills/peaks-qa/references/qa-local-artifacts.md +3 -0
  77. package/skills/peaks-qa/references/qa-matt-pocock-integration.md +9 -0
  78. package/skills/peaks-qa/references/qa-perf-test-plan.md +67 -0
  79. package/skills/peaks-qa/references/qa-refactor-role.md +3 -0
  80. package/skills/peaks-qa/references/qa-runbook.md +74 -0
  81. package/skills/peaks-qa/references/qa-security-test-plan.md +73 -0
  82. package/skills/peaks-qa/references/qa-skill-presence.md +22 -0
  83. package/skills/peaks-qa/references/qa-standards-preflight.md +8 -0
  84. package/skills/peaks-qa/references/qa-sub-agent-dispatch.md +38 -0
  85. package/skills/peaks-qa/references/qa-transition-gates.md +83 -0
  86. package/skills/peaks-qa/references/requirement-boundary-recheck.md +9 -0
  87. package/skills/peaks-qa/references/test-case-generation.md +27 -0
  88. package/skills/peaks-qa/references/test-report-output.md +14 -0
  89. package/skills/peaks-rd/SKILL.md +85 -612
  90. package/skills/peaks-rd/references/artifact-and-standards-output.md +9 -0
  91. package/skills/peaks-rd/references/artifact-per-request.md +20 -0
  92. package/skills/peaks-rd/references/browser-self-test-contracts.md +29 -0
  93. package/skills/peaks-rd/references/codegraph-project-analysis.md +5 -0
  94. package/skills/peaks-rd/references/compact-handoff.md +3 -0
  95. package/skills/peaks-rd/references/external-references.md +11 -0
  96. package/skills/peaks-rd/references/frontend-project-generation.md +11 -0
  97. package/skills/peaks-rd/references/library-version-awareness.md +30 -0
  98. package/skills/peaks-rd/references/mandatory-perf-baseline.md +42 -0
  99. package/skills/peaks-rd/references/mandatory-tech-doc.md +18 -0
  100. package/skills/peaks-rd/references/matt-pocock-integration.md +11 -0
  101. package/skills/peaks-rd/references/mock-data-placement.md +40 -0
  102. package/skills/peaks-rd/references/parallel-review-fanout.md +81 -0
  103. package/skills/peaks-rd/references/rd-context-governance.md +36 -0
  104. package/skills/peaks-rd/references/rd-gstack-integration.md +16 -0
  105. package/skills/peaks-rd/references/rd-runbook.md +125 -0
  106. package/skills/peaks-rd/references/rd-standards-preflight.md +8 -0
  107. package/skills/peaks-rd/references/rd-sub-agent-dispatch.md +39 -0
  108. package/skills/peaks-rd/references/rd-transition-gates.md +1 -1
  109. package/skills/peaks-rd/references/skill-presence-and-title.md +22 -0
  110. package/skills/peaks-solo/SKILL.md +87 -595
  111. package/skills/peaks-solo/references/anchoring-and-session-info.md +25 -0
  112. package/skills/peaks-solo/references/boundaries.md +21 -0
  113. package/skills/peaks-solo/references/codegraph-orchestration.md +5 -0
  114. package/skills/peaks-solo/references/completion-handoff.md +16 -0
  115. package/skills/peaks-solo/references/context-governance.md +51 -0
  116. package/skills/peaks-solo/references/external-references.md +17 -0
  117. package/skills/peaks-solo/references/frontend-only-mode.md +14 -0
  118. package/skills/peaks-solo/references/gstack-integration.md +7 -0
  119. package/skills/peaks-solo/references/local-artifact-workspace.md +79 -0
  120. package/skills/peaks-solo/references/micro-cycle.md +68 -0
  121. package/skills/peaks-solo/references/mode-selection.md +21 -0
  122. package/skills/peaks-solo/references/openspec-workflow.md +43 -0
  123. package/skills/peaks-solo/references/project-memory-loading.md +17 -0
  124. package/skills/peaks-solo/references/quality-gate-cheatsheet.md +13 -0
  125. package/skills/peaks-solo/references/resume-detection.md +63 -0
  126. package/skills/peaks-solo/references/runbook.md +1 -1
  127. package/skills/peaks-solo/references/skill-presence-and-title.md +31 -0
  128. package/skills/peaks-solo/references/standards-preflight.md +23 -0
  129. package/skills/peaks-solo/references/sub-agent-dispatch.md +46 -0
  130. package/skills/peaks-solo/references/swarm-dispatch-contract.md +56 -0
@@ -0,0 +1,25 @@
1
+ # Step 0 — Anchor the workflow
2
+
3
+ > Body of `### Peaks-Cli Step 0: Anchor the workflow`. The instant Peaks-Cli Solo is invoked, **before** the mode-selection question, before any analysis, and before you decide whether the request "needs" the full pipeline, you MUST run these two commands and see their output:
4
+
5
+ ```bash
6
+ # Session ID is auto-generated when omitted; the command returns it in the JSON output.
7
+ # Do NOT pass --session-id manually — the CLI is the single source of truth for the
8
+ # project session binding. To look up the active session id from a skill / sub-agent,
9
+ # use `peaks session info --active --json` (read-only, no side effects). To avoid
10
+ # the "two sessions in .peaks/" confusion that bites Solo, always omit --session-id
11
+ # here and let the CLI auto-generate.
12
+ peaks workspace init --project <repo> --json
13
+ peaks skill presence:set peaks-solo --project <repo> --gate startup
14
+ ```
15
+
16
+ > `<repo>` is the **git project root** (the directory containing `.git`). In a monorepo / single-repo-multi-package layout, this is the repo root, NOT a sub-package — `.peaks/` lives at the repo root so every package shares one workspace. If unsure, run `git rev-parse --show-toplevel` and use that path. Never let `.peaks/` land inside a sub-package directory.
17
+
18
+ **There is no request too lightweight to skip this.** "分析下这个项目", "看一下代码", "分析项目", "解释一下架构", a one-line question — all of them still create the workspace and set presence first. The workspace is cheap; a missing `.peaks/` is the #1 reported failure.
19
+
20
+ **Anti-bail-out rule (BLOCKING):** You MUST NOT exit the peaks-solo workflow, hand control back, or produce a final answer before Step 0 has run. If you catch yourself thinking "this is just analysis, I don't need the workflow" — STOP. Run Step 0, set presence, then continue. A pure-analysis request runs the **lightweight analysis branch** (project scan + standards dry-run + handoff with a Standards-increment section), but it still anchors the workspace and keeps presence active. Declining to anchor is a workflow violation.
21
+
22
+ **Session conflict resolution (read once, internalise):** If `peaks workspace init` returns `code: "CONFLICTING_SESSION"` with a body like
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
+
25
+ `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,21 @@
1
+ # Boundaries
2
+
3
+ > Body of `## Boundaries`. Peaks-Cli Solo may:
4
+
5
+ - identify scenarios such as refactor, bugfix, QA hardening, release validation, and incident response;
6
+ - recommend Solo, Assisted, Swarm, or Strict profiles;
7
+ - coordinate Peaks-Cli role skills through artifacts;
8
+ - coordinate project memory extraction from stable skill artifact sections;
9
+ - request user confirmation at risk and commit boundaries;
10
+ - read CLI doctor/profile/artifact reports.
11
+
12
+ Peaks-Cli Solo must not silently:
13
+
14
+ - install hooks;
15
+ - create agents;
16
+ - enable MCP servers;
17
+ - modify Claude settings;
18
+ - create GitHub repositories;
19
+ - bypass role-skill artifacts.
20
+
21
+ Use the Peaks-Cli CLI for runtime side effects.
@@ -0,0 +1,5 @@
1
+ # Codegraph orchestration context
2
+
3
+ > Body of `## Codegraph orchestration context`. Solo treats `peaks codegraph affected --project <path> <changed-files...> --json` as an optional project-analysis enhancement that informs the role handoff between PRD, RD, and QA. The output is untrusted supporting evidence — Solo must not treat codegraph output as approval for scope, design, or QA verdict.
4
+
5
+ Do not run upstream installer flows, mutate agent settings, or commit `.codegraph/` artifacts into git. Peaks-Cli gates remain authoritative; codegraph context is a hint, never a substitute for role-skill output.
@@ -0,0 +1,16 @@
1
+ # Completion handoff
2
+
3
+ > Body of `## Peaks-Cli Completion handoff` + `### Workflow completion (no auto-exit)`.
4
+
5
+ After final validation, refresh project-local standards via `peaks standards init/update` (never hand-write). Merge scan-backed changes incrementally; preserve hand-maintained content unless user confirms deletion.
6
+
7
+ Use Peaks-Cli TXT for the compact handoff capsule: mode, validated decisions, artifact paths, standards deltas (`CLAUDE.md` and `.claude/rules/**` statuses), open questions, next action. Do not restate the full workflow log.
8
+
9
+ ## Workflow completion (no auto-exit)
10
+
11
+ Do NOT call `peaks skill presence:clear --project <repo>` at workflow end. The presence file and header remain active so the user stays inside the workflow context. The user can continue with follow-up requirements naturally — no need to re-invoke `/peaks-solo`. The header continues to display the active skill and current gate.
12
+
13
+ Before ending, extract durable memories from this session:
14
+ ```bash
15
+ peaks project memories:extract --session-id <session-id> --project <repo> --json
16
+ ```
@@ -142,3 +142,54 @@ PROTOCOL (mandatory):
142
142
 
143
143
  - AC-38..AC-43 (G7) + AC-44..AC-46 (G7.7) + AC-47..AC-49 (G8) + AC-50..AC-65 (G9)
144
144
  - See PRD §Acceptance criteria.
145
+
146
+ ---
147
+
148
+ ### G7 — sub-agent context minimal-occupation (metadata-only + 按需 Read)
149
+
150
+ > Body of `### G7`. Sub-agent artifacts (rd/tech-doc.md, qa/test-cases/&lt;rid&gt;.md, ui/design-draft.md) MUST NOT be inlined into dispatch records and fed back to the main LLM during reduce.
151
+
152
+ - Sub-agent writes artifact to disk at a known path (path convention: `.peaks/_sub_agents/<sessionId>/artifacts/<rid>-<role>-<idx>.<ext>`).
153
+ - Sub-agent calls `peaks sub-agent dispatch --write-artifact <path>` (or via dispatch CLI flag). The CLI computes sha256 + size + writes `ArtifactMeta` to record.
154
+ - Main LLM reduces the batch and sees ONLY the metadata view (~200 chars per sub-agent, vs ~1MB if content were inlined) — a 3000-5000× reduction.
155
+ - Main LLM decides whether to `Read <path>` for full content (LLM tool call, NOT via peaks CLI).
156
+
157
+ Main LLM view format (G7.4.e):
158
+ ```
159
+ [peaks-solo] batch 3/3 done in 47.3s
160
+ - rd → .peaks/_sub_agents/2026-06-06-session-5b1095/artifacts/003-rd-001.md (12KB, sha256:abc123) summary: "wrote RD tech-doc with 4 sub-roles"
161
+ - qa-business → .../artifacts/003-qa-business-001.md (8KB, sha256:def456) summary: "wrote 12 API test cases"
162
+ - qa-perf → .../artifacts/003-qa-perf-001.md (5KB, sha256:ghi789) summary: "p95 latency target ≤ 200ms"
163
+ ```
164
+
165
+ ### G7.7 — headroom-ai integration (opt-in compression)
166
+
167
+ > Body of `### G7.7`. If a sub-agent prompt is too large even after G7 metadata-only (e.g. 1MB artifact description, 5MB mid-prompt analysis), use `--use-headroom`:
168
+ - Default `false` (G7 remains default).
169
+ - Modes: `balanced` (default) | `aggressive` | `conservative`.
170
+ - Failure: `HEADROOM_UNAVAILABLE` warning + G7 metadata-only fallback (NOT blocking).
171
+
172
+ ### G8 — cross sub-agent shared channel (dispatcher-mediated indirect signal)
173
+
174
+ > Body of `### G8`. Sub-agent A's completion **immediately** writes a shared entry; sub-agent B (still in flight) can read shared entries from sibling sub-agents. **This is NOT peer-to-peer messaging.** The dispatcher stores, the sub-agents read/write; A and B never directly talk.
175
+
176
+ - Path: `.peaks/_sub_agents/<sessionId>/shared/<batchId>.json`.
177
+ - Two new CLI atoms (NO new top-level CLI): `peaks sub-agent share` + `peaks sub-agent shared-read`.
178
+ - RL-23 strong constraint: when sub-agent calls `peaks sub-agent heartbeat --status done`, it MUST also call `peaks sub-agent share --key "<role>.completed" --value <artifact-meta>`.
179
+
180
+ ### G9 — forced compression gate (CLI 兜底 + hook double-guard)
181
+
182
+ > Body of `### G9`. Threshold table (256K default context capacity):
183
+
184
+ | Threshold | Prompt size | Behavior |
185
+ |---|---|---|
186
+ | 50% (early warn) | ≥ 128KB | Soft warning, suggest `--use-headroom` |
187
+ | **75% (user red line)** | ≥ 192KB | Soft warn + `warnings: ["CONTEXT_NEAR_LIMIT"]` |
188
+ | **80% (hard reject)** | ≥ 204KB | Hard reject `code: "PROMPT_TOO_LARGE"`; `--force` allowed at CLI |
189
+ | 90% (emergency) | ≥ 230KB | Hard reject + `contextWarning: 'high'` |
190
+
191
+ Two layers:
192
+ - **CLI 兜底** — `peaks sub-agent dispatch` validates prompt size; `--force` allowed.
193
+ - **PreToolUse hook** — `peaks sub-agent-dispatch-guard` re-validates; **NO `--force`** at hook layer (RL-30 strict).
194
+
195
+ The sub-agent prompt template (G8.6 + G9 self-check) is in `references/context-governance.md`.
@@ -0,0 +1,17 @@
1
+ # External references and lifecycle
2
+
3
+ > Body of `## Peaks-Cli External references and lifecycle`.
4
+
5
+ **Codegraph**: Optional project-analysis before RD handoff. Use `peaks codegraph affected --project <path> <changed-files...> --json` for regression-surface hints. Output as untrusted supporting evidence only; never commit `.codegraph/` artifacts.
6
+
7
+ Solo treats `peaks codegraph affected --project <path> <changed-files...> --json` as an optional project-analysis enhancement that informs the role handoff between PRD, RD, and QA. The output is untrusted supporting evidence — Solo must not treat codegraph output as approval for scope, design, or QA verdict.
8
+
9
+ Do not run upstream installer flows, mutate agent settings, or commit `.codegraph/` artifacts into git. Peaks-Cli gates remain authoritative; codegraph context is a hint, never a substitute for role-skill output.
10
+
11
+ **External skills**: All external skill references (`mattpocock/skills`, `awesome-design-md`, `taste-skill`, `shadcn/ui`, `Chrome DevTools MCP`, `Figma Context MCP`, `Context7`, etc.) follow the three-stage pattern: capability discovery via `peaks capabilities` before naming, references only (no execute/install/persist), Peaks-Cli CLI for all side effects. Do not execute upstream installers, do not install upstream resources, do not persist sensitive examples — Peaks-Cli gates remain authoritative. External skills inform, they do not approve.
12
+
13
+ **OpenSpec lifecycle**: `render → validate → show → to-rd → validate → archive`. Solo's default runbook handles the exit gate (validate → archive after QA pass). Entry-gate validation (to-rd before slicing) is available when `openspec/` exists pre-workflow; Solo delegates it to `peaks-rd` during implementation.
14
+
15
+ **MCP lifecycle**: `list → plan → apply --yes → call → rollback`. `apply` backs up settings and refuses non-peaks entries unless `--claim` is passed.
16
+
17
+ Detailed rules: `references/external-skill-invocation.md`, `references/openspec-mcp-workflow.md`, `references/workflow.md`, `references/existing-system-extraction.md`. For an informational mapping of peaks artefact paths to the A2A (Agent2Agent) protocol's Task / Artifact / Part / Message / AgentCard vocabulary (no A2A implementation, just a shared naming layer), see `references/a2a-artifact-mapping.md`.
@@ -71,3 +71,17 @@ When the PRD source is a Feishu/Lark document that requires authentication:
71
71
  4. **Fallback C (none of the above)**: Mark PRD as `blocked` with reason `doc-inaccessible`, list the exact next steps for the user, and pause the workflow.
72
72
 
73
73
  Never silently fall back to unauthenticated `fetch` or `WebFetch` for authenticated documents.
74
+
75
+ ---
76
+
77
+ ### Frontend-only trigger pre-flight
78
+
79
+ > Body of `### Frontend-only trigger pre-flight`. Before computing the swarm plan, Solo runs the keyword scan deterministically:
80
+
81
+ 1. Read `.peaks/_runtime/<sessionId>/prd/requests/<rid>.md` body.
82
+ 2. Lowercase + strip markdown; check regex `\b(页面|组件|表单|弹窗|表格|样式|布局|交互|UI|UX|page|component|form|modal|table|styling|layout|interaction|frontend|前端)\b`.
83
+ 3. If match count ≥ 1 → `frontendKeywordHit=true`.
84
+ 4. If `frontendOnly` (from project-scan) is `true` and no keyword hit → UI joins anyway (frontend-only project, even non-visual changes may need visual sanity for regressions).
85
+ 5. If `frontendOnly` is `false` and no keyword hit → UI skipped.
86
+
87
+ Solo records the pre-flight result in `sc/swarm-plan.json` so the audit trail shows why UI was or was not included.
@@ -0,0 +1,7 @@
1
+ # Peaks-Cli GStack integration
2
+
3
+ > Body of `## Peaks-Cli GStack integration`.
4
+
5
+ Map gstack stages to Peaks-Cli role artifacts; preserve Peaks-Cli confirmation gates. Do not delegate orchestration to gstack commands.
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-cli 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`.
@@ -0,0 +1,79 @@
1
+ # Local intermediate artifact workspace
2
+
3
+ > Body of `## Peaks-Cli Local intermediate artifact workspace` plus all sub-sections (workspace initialization gate, root pollution prohibition, git and sync policy).
4
+
5
+ ## Workspace initialization gate
6
+
7
+ The workspace is created in Step 0 (Startup sequence) as a mandatory first action — before any analysis, role handoff, or artifact write, and regardless of how lightweight the request is. Session IDs are now **auto-generated** with the format `YYYY-MM-DD-session-<6位hex>` (e.g. `2026-05-26-session-a3f8b1`). The user does not provide a session ID — the system creates and persists it in `.peaks/_runtime/session.json` (the canonical home as of slice `2026-06-05-peaks-runtime-layer`; the legacy `.peaks/.session.json` is read-only back-compat for one minor release).
8
+
9
+ When `peaks workspace init` is run without `--session-id`, it automatically generates a new session ID using today's date and a random hex suffix. If a valid session binding exists at `.peaks/_runtime/session.json` (the canonical home, slice 2026-06-05-peaks-runtime-layer; the legacy `.peaks/.session.json` is read-only back-compat for one minor release), the existing session is reused. To read the active session id from a skill or sub-agent, use the `peaks session info --active --json` primitive — never `cat` the on-disk file directly (the path is internal).
10
+
11
+ **Existing old-session cleanup**: If `.peaks/` contains numeric-only or generic session directories from prior runs (e.g. `2026-05-25-auth-system`), create the new correctly-named session, migrate any reusable artifacts into it, and note the migration in the TXT handoff. Delete empty old-session directories.
12
+
13
+ ```bash
14
+ peaks workspace init --project <repo> --json
15
+ ```
16
+
17
+ The workspace initialization creates this structure under `.peaks/`:
18
+
19
+ ```
20
+ # Canonical home for all per-project ephemeral state (active-skill
21
+ # marker, session binding, sop-state). All writes go here; reads also
22
+ # tolerate the legacy paths (`.peaks/.active-skill.json`,
23
+ # `.peaks/.session.json` — read-only back-compat for one minor release,
24
+ # `.peaks/sop-state/`) for one minor release so a fresh upgrade does
25
+ # not break in-flight workflows. Older trees are auto-migrated by
26
+ # `peaks workspace reconcile --apply`. Skills and sub-agents MUST
27
+ # NOT `cat` any of these files directly — use `peaks session info
28
+ # --active --json` (and the matching read-only primitives for the
29
+ # other two) to discover session-id / active-skill / sop-state.
30
+ .peaks/_runtime/
31
+ ├── active-skill.json # orchestrator presence marker (peaks-solo / -rd / -qa / -ui / -sc / -sop / -txt)
32
+ ├── session.json # project → session binding (the only single-session source of truth)
33
+ └── sop-state/ # current phase + history; definitions live globally in ~/.peaks
34
+
35
+ # Per-slice artifact dirs (auto-generated, one per session). Files
36
+ # inside ARE tracked by the 提交中间产物 convention.
37
+ .peaks/_runtime/<sessionId>/
38
+ prd/source/ # PRD source documents (Feishu exports, pasted content)
39
+ prd/requests/ # PRD request artifacts (goals, non-goals, acceptance, frontend delta)
40
+ ui/requests/ # UI request artifacts (visual direction, taste reports)
41
+ rd/requests/ # RD request artifacts (slice specs, coverage, CR findings)
42
+ rd/project-scan.md # Project scan (session-scoped singleton, generated once per session)
43
+ qa/test-cases/ # QA test cases
44
+ qa/test-reports/ # QA test reports (regression matrices, browser evidence)
45
+ qa/requests/ # QA request artifacts
46
+ sc/ # SC artifacts (change-control, impact, retention, boundary)
47
+ txt/ # TXT artifacts (handoff capsules, lessons, memory extraction)
48
+ system/ # Existing-system extraction output (visual tokens, conventions)
49
+ ```
50
+
51
+ Files written into these directories during the workflow (not pre-created — they appear as their step runs):
52
+
53
+ - `rd/project-scan.md` (Solo step 0.6)
54
+ - `rd/tech-doc.md` (feature/refactor planning; required by `rd → implemented` gate)
55
+ - `rd/bug-analysis.md` (bugfix planning; required by `rd → implemented` gate for `--type bugfix`)
56
+ - `rd/code-review.md`, `rd/security-review.md` (required by `rd → qa-handoff` gate for feature/bugfix/refactor; security-review only for config)
57
+ - `rd/mock-plan.md` (frontend-only mode)
58
+ - `ui/design-draft.md` (UI step)
59
+ - `system/existing-system.md` (Solo step 0.7; legacy projects only)
60
+ - `qa/test-cases/<rid>.md`, `qa/test-reports/<rid>.md`, `qa/security-findings.md`, `qa/performance-findings.md` (gated per `--type`)
61
+
62
+ ## Root pollution prohibition (CRITICAL)
63
+
64
+ **NEVER write Peaks-Cli intermediate artifacts to the project root directory.** Specifically prohibited at root level:
65
+
66
+ - PRD snapshots, document extracts, or requirement notes (`feishu-doc-*.md`, `*-snapshot.md`, etc.)
67
+ - RD tech docs, scan reports, slice specs, or architecture notes
68
+ - QA screenshots, browser evidence, test reports, or validation logs (`.png`, `.jpg`)
69
+ - QA test helper files, mock servers, or fixture scripts (`qa-server.js`, etc.)
70
+ - UI design drafts, taste reports, or visual direction notes
71
+ - TXT handoff capsules or lesson files
72
+
73
+ Legitimate source files (e.g. `jest-setup.ts`, `tailwind.config.js`) belong at root — do not move them.
74
+
75
+ If you are about to Write/Edit an intermediate artifact in the project root, STOP. Create the `.peaks/_runtime/<sessionId>/` workspace first and write to the correct role subdirectory. If existing root-level artifacts from a prior run are discovered, move them into `.peaks/_runtime/<sessionId>/` and note the migration in the TXT handoff.
76
+
77
+ ## Git and sync policy
78
+
79
+ Do not default to git-backed storage or automatic commits for intermediate artifacts. Git inclusion or sync requires explicit user confirmation or an active profile that authorizes it.
@@ -155,3 +155,71 @@ verdict=return-to-rd → RD 修 (new slice 内部走 micro-cycle)
155
155
  - peaks-qa 接管 = 边界 + `verdict != pass` 时的下一轮
156
156
 
157
157
  完整流程见 SKILL.md。
158
+
159
+ ---
160
+
161
+ # Mandatory RD QA repair loop (AUTO-PROCEED)
162
+
163
+ > Body of `## Peaks-Cli Mandatory RD QA repair loop`.
164
+
165
+ > **CLI gate enforcement**: `peaks request transition` now refuses to move RD/QA to gated states when required artifacts are missing. The required files depend on `--type` chosen at `peaks request init` (default `feature`):
166
+ >
167
+ > - `feature` / `refactor`: full gates (tech-doc, code-review, security-review, test-cases, test-report, security-findings, performance-findings)
168
+ > - `bugfix`: lighter planning (`bug-analysis.md` instead of `tech-doc.md`); still requires code-review + security-review + regression test-cases + security-findings; performance-findings optional unless the bug is performance-related
169
+ > - `config`: only security-review (RD) and security-findings (QA)
170
+ > - `docs` / `chore`: no gates
171
+ >
172
+ > When PRD lands, classify the request type before running `peaks request init` for every role — pass `--type <type>` so the artifact records it and downstream transitions enforce the right gates. Misclassifying a feature as `docs` to skip gates is a workflow violation. If a transition fails with `code: PREREQUISITES_MISSING`, the response lists every missing path — produce them, then re-transition. For one-off exceptions, the escape hatch `--allow-incomplete --reason "<text>"` records the bypass in the artifact transition note.
173
+
174
+ After `peaks-rd` finishes any implementation, repair, or code-output slice, Peaks-Cli Solo MUST automatically route the result to `peaks-qa` without waiting for user confirmation. This is not optional in full-auto mode. Solo must not declare the workflow complete, emit a TXT handoff, or stop at RD completion.
175
+
176
+ **How Solo invokes another role (mechanism, not metaphor):**
177
+
178
+ Solo is itself a skill running in the current session. There are **two distinct mechanisms** in this skill, and they MUST NOT be confused:
179
+
180
+ 1. **Swarm fan-out (planning side, after PRD confirmed)** — uses `peaks sub-agent dispatch <role>` to launch real concurrent sub-agents. The CLI returns a per-IDE tool-call descriptor that the LLM executes in its environment. See "Peaks-Cli Swarm parallel phase" above for the full contract. Sub-agents do NOT call Skill(...) back into the role; they execute the role's instructions inline from the prompt.
181
+ 2. **Sequential handoff (execution side, RD↔QA repair loop)** — Solo is the only loop, and after RD or QA finishes (whether as a sub-agent or directly), Solo drives the next step from the orchestrator seat. Do NOT use the `Skill` tool to "reactivate" peaks-rd or peaks-qa in the main loop; doing so is the v1.x anti-pattern that masqueraded as "calling the role" but actually just re-prompted the same session. From v1.3 onward, the main loop drives roles via the CLI gate (`peaks request transition`) and reads back artefacts (`peaks request show ... --json`); the actual RD/QA work is either done inline by Solo (when Solo has just been re-invoked by the user) or by a Task sub-agent (in swarm mode).
182
+
183
+ After RD completes (whether inline or sub-agent), Solo 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
+
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`. Solo does NOT need to track three separate RD-side sub-runs; the RD role owns the fan-out lifecycle end-to-end. Solo's presence restoration after the swarm converges is the only coordination point.
186
+
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 Solo 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
+
189
+ ```bash
190
+ peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate <current-gate>
191
+ ```
192
+
193
+ This keeps the CLAUDE.md status header accurate (`Peaks-Cli Skill: peaks-solo`) instead of showing a stale role name. Use the current mode and gate values; the gate may have advanced since startup. Skipping this step causes the header to display the last-known gate permanently.
194
+
195
+ **Full-auto auto-proceed rule**: In the `full-auto` profile, when RD transitions to `qa-handoff`, Solo immediately drives QA — by launching a `peaks sub-agent dispatch qa` sub-agent carrying the `peaks-qa` body (swarm path), then executing the returned toolCall, or by running QA inline in the main loop (assisted/strict path). Do not pause, do not ask the user, do not summarize RD results as if they were final. The only valid reason to skip QA is when `--type` is `docs` or `chore` (no acceptance surface).
196
+
197
+ A QA report with any failing, blocked, missing, or unverified acceptance item is not a pass.
198
+
199
+ **How Solo routes QA findings back to RD (mechanism, not metaphor):**
200
+
201
+ When `peaks-qa` returns `verdict=return-to-rd`, Solo does NOT manually rewrite RD artifacts. Instead it follows this exact sequence:
202
+
203
+ 1. Read the QA verdict and findings via `peaks request show <rid> --role qa --project <repo> --json`. The findings live in the QA artifact body (failing acceptance items, evidence paths, severity).
204
+ 2. Transition the RD artifact back from `qa-handoff` to a working state and record the QA verdict in the transition note:
205
+ ```bash
206
+ peaks request transition <rid> --role rd --state spec-locked \
207
+ --reason "QA return-to-rd cycle <N>: <one-line summary of failing items; full findings in qa/test-reports/<rid>.md>" \
208
+ --project <repo> --json
209
+ ```
210
+ `spec-locked` is the canonical "needs more RD work" state. The reason is mandatory in repair cycles so the artifact history shows the loop.
211
+ 3. Re-launch `peaks-rd` work. Two paths, mode-driven:
212
+ - **Swarm / full-auto**: launch a fresh `peaks sub-agent dispatch rd` sub-agent (then execute the returned toolCall) with the same `peaks-rd` body used in the Swarm phase, plus the QA findings path so it can read the failure list. Solo restores presence after the sub-agent returns.
213
+ - **Assisted / strict / inline-fallback**: Solo executes the RD repair steps directly in the main loop, since there is no concurrent fan-out to coordinate.
214
+ In both paths, pass the QA findings path so the repair sees what failed.
215
+ 4. peaks-rd fixes the reported issues only (red-line scope: do not modify unrelated surfaces), regenerates code-review and security-review evidence if changes touched reviewed surfaces, then transitions `rd → implemented → qa-handoff` again.
216
+ 5. Solo re-runs QA (sub-agent Task in swarm/full-auto, inline in assisted/strict) with the same `<request-id>`. QA re-runs gates against the new diff.
217
+ 6. Repeat steps 1-5 until QA returns `verdict=pass`, or the cap below fires.
218
+ **After each repair iteration** (after peaks-rd and peaks-qa both return), Solo MUST restore presence:
219
+ ```bash
220
+ peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate repair-cycle-<N>
221
+ ```
222
+
223
+ **Repair cycle cap**: After 3 repair cycles without a passing QA verdict, emit a blocked TXT handoff regardless of remaining issues. Do not loop indefinitely. If a specific issue cannot be resolved within 3 cycles, mark it as a known blocker in the TXT handoff and proceed to the SC phase.
224
+
225
+ In full-auto mode, treat the RD↔QA repair loop as a built-in controller objective: loop through RD→QA until all acceptance items pass (max 3 cycles). Do not exit the loop on a non-passing QA verdict unless the TXT handoff marks the workflow as blocked.
@@ -0,0 +1,21 @@
1
+ # Step 1 — Mode selection
2
+
3
+ > Body of `### Peaks-Cli Step 1`. After Step 0 has anchored the workspace and presence, when the user invokes Peaks-Cli Solo without explicitly naming an execution profile, use `AskUserQuestion` to pick the profile. Present the recommended full-auto path as the first/default option with a practical description for each:
4
+
5
+ 1. **Full auto (Recommended)** — Peaks-Cli handles planning, role coordination, validation, and compact handoff end-to-end while preserving required confirmation gates for risky or shared-state actions.
6
+ 2. **Assisted** — Peaks-Cli proposes plans, artifacts, and checks, then pauses for user decisions at major workflow boundaries.
7
+ 3. **Swarm** — Peaks-Cli maximizes safe parallel role/worker execution for larger RD or QA workloads while keeping reducer validation and artifact boundaries explicit.
8
+ 4. **Strict** — Peaks-Cli uses the most conservative gates: explicit confirmations, strict slice specs, coverage evidence, QA acceptance, and commit boundaries before continuing.
9
+
10
+ Map the user's selection to the `--mode` flag value (used by `peaks skill presence:set`; `presence:set --mode` accepts any string, so the name matches the user-facing label rather than overloading "solo" which is also the skill name):
11
+
12
+ | User selects | `--mode` value |
13
+ |---|---|
14
+ | Full auto | `full-auto` |
15
+ | Assisted | `assisted` |
16
+ | Swarm | `swarm` |
17
+ | Strict | `strict` |
18
+
19
+ > Note: `peaks workflow route --mode solo|team` is a **different** CLI dimension (solo developer vs team flow) and is unrelated to the profile choice here. Do not conflate them.
20
+
21
+ If the user already names a profile in their invocation (e.g. `/peaks-solo --full-auto`, "用全自动模式"), skip this question and use the named profile directly.
@@ -36,3 +36,46 @@ If the consuming LLM needs an MCP server for docs lookup or research (e.g. Conte
36
36
  ## Boundary
37
37
 
38
38
  Solo must not write `openspec/changes/**` or `~/.claude/settings.json` directly. Every mutation goes through the CLI commands above. The CLI returns stable envelopes; Solo captures them as artifact links rather than re-explaining their content in the handoff.
39
+
40
+ ---
41
+
42
+ # Step 0.5 — OpenSpec first-run opt-in (conditional)
43
+
44
+ > Body of `### Peaks-Cli Step 0.5`. After the workspace is anchored, before project scan, Solo checks whether
45
+ the project already has an `openspec/` directory. The lifecycle
46
+ (`render → validate → show → to-rd → validate → archive`) only applies
47
+ when `openspec/` exists; without it, RD/QA/SC silently skip the
48
+ openspec-aware paths and you lose change-proposal tracking, commit
49
+ boundaries from `tasks.md`, and the historical archive.
50
+
51
+ To make that opt-in visible instead of silent, Solo runs:
52
+
53
+ ```bash
54
+ # 1. Detect whether the project already has openspec/.
55
+ ls <repo>/openspec/changes 2>&1
56
+ # 2. If absent, ask the user once — only on the first Solo run in this
57
+ # project. The decision is sticky: write it to .peaks/.peaks-openspec-opt-in.json
58
+ # so subsequent Solo invocations do not re-ask.
59
+ test -f <repo>/.peaks/.peaks-openspec-opt-in.json || \
60
+ echo "{\"enabled\": <bool>}" > <repo>/.peaks/.peaks-openspec-opt-in.json
61
+ ```
62
+
63
+ **AskUserQuestion** (only when `openspec/` is absent and the opt-in
64
+ file is missing):
65
+
66
+ | Option | What it does |
67
+ |---|---|
68
+ | Enable OpenSpec for this project (Recommended) | Run `peaks openspec init --project <repo> --apply`. After that, every Solo run uses the change-proposal lifecycle for the same project. |
69
+ | Skip for now | Do nothing. Solo proceeds without openspec; the question is re-asked on the next first-run detection. |
70
+ | Never ask again for this project | Write `{enabled: false, sticky: true}`. Solo stops asking. The user can re-enable later by removing `.peaks/.peaks-openspec-opt-in.json` and re-running. |
71
+
72
+ The first option is the recommended default because it gives Solo the
73
+ full change-proposal lifecycle (proposal / tasks / design / specs
74
+ deltas, archive on ship, commit boundaries from `tasks.md`). It costs
75
+ only a single scaffolded directory and pays back the first time the
76
+ project needs a real review trail.
77
+
78
+ If the user picks "Enable", the only required follow-up is to make
79
+ sure `openspec/changes/` is added to git (it is part of the project
80
+ repo, not a tool-managed artefact). Solo does not run `git add` for
81
+ the user; that is the user's commit boundary.
@@ -0,0 +1,17 @@
1
+ # Step 2.3 — Load project memory
2
+
3
+ > Body of `### Peaks-Cli Step 2.3`. Before planning any work, read the project's persistent memory — durable memories that survive across sessions:
4
+
5
+ ```bash
6
+ peaks project memories --project <repo> --json
7
+ ```
8
+
9
+ This returns durable memories from `.peaks/memory`, grouped by kind:
10
+ - **module** — code areas touched, with risk and rationale captured by past sessions
11
+ - **decision** — architectural choices, why they were made, what they affect
12
+ - **convention** — discovered project patterns (code style, naming, tooling)
13
+ - **rule** / **reference** / **project** — standing constraints, external pointers, and project context
14
+
15
+ Filter with `--kind <decision|convention|module|rule|reference|project|lesson>` when you only need one slice. Use this to understand what exists, what was decided, and what to avoid re-litigating. Memories are LLM-authored at approved checkpoints via `peaks memory extract`. The `lesson` kind is for LLM-discovered runtime lessons (e.g. "this project's antv6 Drawer uses `size` not `width`"); write them as `<!-- peaks-memory:start kind=lesson -->` blocks in the RD handoff or TXT handoff.
16
+
17
+ `.peaks/PROJECT.md` is a human-readable session timeline only — do NOT use it for LLM context.
@@ -0,0 +1,13 @@
1
+ # Quality-gate commands (CLI cheat sheet)
2
+
3
+ > Body of `## Peaks-Cli Quality-gate commands`. These commands harden the workflow against silent skips. Use them in the runbook at the points indicated; they all support `--json` and `--session-id`.
4
+
5
+ | Command | Purpose | When to run | Non-zero exit when |
6
+ |---|---|---|---|
7
+ | `peaks request lint <rid> --role <role> --project <path>` | Scan artifact body for unfilled `<placeholder>`, bare `- ...` bullets, TBD/TODO markers | Before every transition out of `draft` / before role handoff | Any `error`-severity finding (unfilled placeholder, bare-dot bullet) |
8
+ | `peaks request repair-status <rid> --project <path>` | Count RD↔QA repair cycles from `--reason` transition notes ("QA cycle N: ...") | Before every RD repair iteration in step 7 | Cycle count reached the 3-cycle cap |
9
+ | `peaks scan request-type-sanity --project <path> --type <type>` | Cross-verify declared `--type` against the actual `git diff` file mix (catches "feature mis-declared as docs" workflow violations) | After PRD type lock-in AND after each RD repair iteration | Declared type disagrees with the file mix |
10
+ | `peaks scan libraries --project <path>` | Enumerate every dependency + devDependency + peerDependency + optionalDependency with parsed major version; output goes to `## Library versions` in `rd/project-scan.md`. Read-only. | At Solo step 0.6 (alongside `peaks scan archetype`) | Always exits 0 (warnings in JSON envelope; never blocks) |
11
+ | `peaks slice check [--rid <rid>] [--project <path>]` | 4-stage slice 边界 check (typecheck + unit-tests + review-fanout + gate-verify-pipeline). Aggregate pass/fail; non-zero exit if any stage fails. See "Slice 边界 check" below for usage rules (boundary only, never inside a micro-cycle). | At slice 边界(post-micro-cycle, pre-peaks-qa)| Any stage fails |
12
+
13
+ Together with `peaks request transition` (which already CLI-enforces per-type artifact prerequisites), these five commands form the runtime quality net. SKILL.md prose is descriptive; the CLI is what physically blocks bad workflows.
@@ -0,0 +1,63 @@
1
+ # Step 0.7 — Detect unfinished work and offer resume
2
+
3
+ > Body of `### Peaks-Cli Step 0.7`. After Step 0 has anchored the workspace and presence, before Step 1 mode selection, run the resume-detection probe. If the current session has in-flight slice artifacts, the user is most likely "continuing" — surface resume options instead of starting a fresh PRD.
4
+
5
+ **Why this is a separate step** (per `feedback_peaks_solo_natural_language_primary` — a high-frequency request shape, see also the user's "继续完成刚才为完成的" pattern from session `2026-06-04-session-b60252`): the LLM was previously re-reading 3-5 artifact files to determine workflow state, wasting 3-5k tokens per resume request. This step replaces that work with a single deterministic read.
6
+
7
+ **Detection logic** (all read-only, no side effects; uses only existing CLIs):
8
+
9
+ ```bash
10
+ # 1. Confirm the current session id via the read-only CLI primitive
11
+ # (the on-disk binding file is internal — never `cat` it directly)
12
+ sid=$(peaks session info --active --project "$(git rev-parse --show-toplevel)" --json | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['sessionId'])")
13
+
14
+ # 2. Enumerate the session's artifact tree (one `find` call, no new CLI)
15
+ find ".peaks/$sid/" -type f 2>/dev/null | sort
16
+
17
+ # 3. For each role request artifact present, read its `state:` field
18
+ # (one-pass grep; only files that exist)
19
+ for f in .peaks/$sid/prd/requests/*.md .peaks/$sid/rd/requests/*.md .peaks/$sid/qa/requests/*.md; do
20
+ [ -f "$f" ] && echo "$f: $(grep -m1 '^state:' "$f" | awk '{print $2}')"
21
+ done
22
+
23
+ # 4. Compute "deepest completed gate" by file-presence + state mapping
24
+ # (see classification table below)
25
+ ```
26
+
27
+ **Classification table** (file-presence + state → "deepest completed gate"):
28
+
29
+ | Files present | State | Deepest completed gate | Resume point (if any) |
30
+ |---|---|---|---|
31
+ | only `.peaks/$sid/.session.json` | (no slice) | (none) | fresh — skip to Step 1 |
32
+ | `prd/requests/<rid>.md` | `state: handed-off` | Gate B (swarm converged) | resume at Step 3 (swarm) — but if swarm already ran and produced `rd/tech-doc.md` / `qa/test-cases/<rid>.md`, drop to deepest |
33
+ | `rd/requests/<rid>.md` | `state: qa-handoff` | Gate C (RD done) | resume at Step 6 (QA validation) |
34
+ | `qa/requests/<rid>.md` | `state: verdict-issued` | Gate D (QA done) | resume at Step 10 (TXT handoff) |
35
+ | `txt/handoff.md` | (any) | Gate E (workflow complete) | this session is closed — user is starting new work |
36
+
37
+ **Other resume triggers** (file-presence, no state read needed):
38
+
39
+ | Missing file | Resume at |
40
+ |---|---|
41
+ | `rd/tech-doc.md` (for `feature`/`refactor`) or `rd/bug-analysis.md` (for `bugfix`) | Step 3b (RD planning) |
42
+ | `rd/code-review.md` or `rd/security-review.md` | Step 5 (RD review fan-out) |
43
+ | `rd/perf-baseline.md` (for `feature`/`refactor`) | Step 5 (perf baseline) |
44
+ | `qa/test-cases/<rid>.md` | Step 6 (QA test-case generation) |
45
+ | `qa/test-reports/<rid>.md` or `qa/security-findings.md` or `qa/performance-findings.md` | Step 6 (QA execution) |
46
+ | `txt/handoff.md` | Step 10 (TXT handoff) |
47
+
48
+ **AskUserQuestion** (only if a resume is detected; default option is "Resume from the deepest missing gate"):
49
+
50
+ | Option | What it does |
51
+ |---|---|
52
+ | Resume from `<gate>` (Recommended) | Skip ahead to the matching step, preserving all existing artifacts. The LLM does NOT re-read the existing artifacts — it trusts the classification and proceeds. |
53
+ | Start a fresh slice | Keep the workspace, treat the current user request as a new slice (new rid). Existing artifacts are preserved but not auto-resumed. |
54
+ | Abandon the in-flight slice | Mark the in-flight slice as `deferred` (`peaks request transition … --state deferred`); start a new one. |
55
+
56
+ **Hard rule: never silently auto-resume.** Resume detection is the discovery; AskUserQuestion is the confirmation. Even if the user's request is "继续完成刚才为完成的" (continue the unfinished work), the skill must run this detection, surface the options, and wait for user confirmation before skipping ahead.
57
+
58
+ **Hard rule: never auto-resume a slice that is mid-implementation.** Resume only when the deepest completed gate is in {B, C, D, E}. For mid-implementation states (RD `state: implemented`, RD `state: running`, RD `state: spec-locked`, QA `state: running`, QA `state: blocked`), the slice is still in flight — the only valid option is "Resume from in-flight gate" (the user must confirm).
59
+
60
+ **Strict quality guarantee (per user's hard rule: "严格要保证不能比当前的效果差")**:
61
+ - 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.
62
+ - 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).
63
+ - The dogfood test in `tests/unit/skill-resume-mode.test.ts` (8 cases, bash-fixture shim — the legacy interface used by `skills/peaks-solo-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.
@@ -8,7 +8,7 @@
8
8
  > - `peaks skill runbook peaks-solo` (CLI) reads the `## Default runbook` section in either SKILL.md or `references/runbook.md` (whichever has the bash code).
9
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.
10
10
 
11
- ## Default runbook
11
+ ## Default runbook — CLI sequence
12
12
 
13
13
  The end-to-end CLI sequence for the `full-auto` profile. `assisted` and `strict` profiles pause at `[CONFIRM]` markers below. `full-auto` and `swarm` auto-proceed through all gates. See Transition Gates for artifact verification at each stage.
14
14
 
@@ -0,0 +1,31 @@
1
+ # Step 2 + 2.5 — Skill presence and session title
2
+
3
+ > Combined body for `### Peaks-Cli Step 2: Re-set skill presence with the chosen mode` and `### Peaks-Cli Step 2.5: Set session title`.
4
+
5
+ ## Step 2 — Re-set skill presence
6
+
7
+ Step 0 already set presence with no mode. Now that the mode is known (user selected or explicitly named), re-run presence:set so the header/status line shows the profile:
8
+
9
+ ```bash
10
+ peaks skill presence:set peaks-solo --project <repo> --mode <mode-value> --gate startup
11
+ ```
12
+
13
+ On the first presence:set in a project, ensure the out-of-band status bar is installed so the user can see at a glance that Peaks is orchestrating — it renders the active skill in Claude Code's terminal status line, independent of model output:
14
+
15
+ ```bash
16
+ peaks statusline install --project <repo> # idempotent; skips if already installed
17
+ ```
18
+
19
+ Then display the compact status header: `Peaks-Cli Skill: peaks-solo | Peaks-Cli Gate: startup | Next: <one short action>`. Display this header on EVERY turn while the skill is active.
20
+
21
+ Update with `peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate <gate>` when gates change. The presence file persists across the full workflow lifecycle — do NOT clear it at workflow end.
22
+
23
+ ## Step 2.5 — Set session title
24
+
25
+ Extract a short (8-20 Chinese characters, or 4-10 English words) descriptive title from the user's first request. The title should capture the core task — e.g. "修复登录页OAuth回调异常", "添加暗色模式开关", "搭建项目基础架构". Then run:
26
+
27
+ ```bash
28
+ peaks session title $(peaks session info --active --project "$(git rev-parse --show-toplevel)" --json | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['sessionId'])") "<title>"
29
+ ```
30
+
31
+ If the session directory already has a title (check via `peaks session list --json`), skip this step — the title is already set.
@@ -0,0 +1,23 @@
1
+ # Project standards preflight
2
+
3
+ > Body of `## Peaks-Cli Project standards preflight`. Before orchestrating an end-to-end code repository workflow, gather the project standards preflight status from RD and QA by calling the Peaks-Cli CLI:
4
+
5
+ - `peaks standards init --project <path> --dry-run`
6
+ - `peaks standards update --project <path> --dry-run`
7
+
8
+ Use `standards init` for first-time creation and `standards update` for existing `CLAUDE.md` append/review behavior. In `full-auto` and `swarm` profiles, `--apply` runs automatically after `--dry-run` succeeds — these files live inside the target project, are required for downstream skill preflight, and producing them is part of finishing the workflow (Peaks-Cli Gate G enforces this). `assisted` and `strict` profiles pause for explicit user confirmation between dry-run and apply.
9
+
10
+ **CRITICAL — Standards must reflect the project scan.** When generating or updating `CLAUDE.md`, the content must reference concrete findings from `.peaks/<changeId>/rd/project-scan.md`: the detected component library (e.g. "This project uses antd 5.x"), CSS solution (e.g. "Uses Less via Umi"), build tool, state management, and routing. Never emit a generic template that says "read .claude/rules/..." without naming the actual project stack. If the project-scan has not been run yet, run it before standards init/update.
11
+
12
+ **Legacy projects additionally** — when archetype ∈ {legacy-frontend, legacy-fullstack, frontend-monorepo}, the `CLAUDE.md` Conventions section MUST extract concrete naming, directory, service-layer, and hooks conventions from `.peaks/<changeId>/system/existing-system.md` and record them as hard constraints for new code. It must also list the `## Legacy constraints` from `project-scan.md` (class components, moment, enzyme, etc.) and instruct that new code in the same module preserves those patterns unless PRD explicitly authorizes modernization. A `CLAUDE.md` for a legacy project that contains only generic rule pointers without naming the actual conventions is a blocking violation — regenerate it.
13
+
14
+ Do not hand-write standards file mutations inside the skill.
15
+
16
+ For project-analysis requests such as "分析项目" / "分析下这个项目", Step 0 still applies: the workspace is initialized and `peaks-solo` presence is set before any analysis output. These requests run the lightweight analysis branch (project scan + standards dry-run) rather than the full RD/QA pipeline, but they never skip workspace anchoring or exit the workflow. The handoff must include an explicit **Standards increment** section. Report the current `CLAUDE.md` and `.claude/rules/**` status from the dry-run output as incremental deltas, not just a generic preflight note:
17
+
18
+ - whether `CLAUDE.md` is missing, existing, planned, skipped, appended, or review-only;
19
+ - which `.claude/rules/**` files are planned, existing, skipped, appended, or review-only;
20
+ - whether writes were applied or intentionally left as dry-run because authorization or scope was absent;
21
+ - the exact next action if standards should be applied later.
22
+
23
+ If the dry-run output lacks enough detail to explain those deltas, say that the standards increment is unknown and keep standards application blocked until another `peaks standards init/update --dry-run` provides evidence.