peaks-cli 1.0.14 → 1.0.16

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 (29) hide show
  1. package/bin/peaks.js +0 -0
  2. package/dist/src/cli/commands/project-commands.js +5 -0
  3. package/dist/src/cli/commands/request-commands.js +1 -1
  4. package/dist/src/cli/commands/workflow-commands.js +38 -0
  5. package/dist/src/services/artifacts/request-artifact-service.d.ts +2 -2
  6. package/dist/src/services/artifacts/request-artifact-service.js +60 -5
  7. package/dist/src/services/config/config-safety.d.ts +14 -0
  8. package/dist/src/services/config/config-safety.js +275 -0
  9. package/dist/src/services/config/config-service.d.ts +1 -1
  10. package/dist/src/services/config/config-service.js +5 -274
  11. package/dist/src/services/dashboard/project-dashboard-service.d.ts +11 -0
  12. package/dist/src/services/dashboard/project-dashboard-service.js +21 -2
  13. package/dist/src/services/doctor/doctor-service.d.ts +3 -0
  14. package/dist/src/services/doctor/doctor-service.js +58 -0
  15. package/dist/src/services/workflow/autonomous-resume-writer.d.ts +16 -0
  16. package/dist/src/services/workflow/autonomous-resume-writer.js +156 -0
  17. package/dist/src/shared/version.d.ts +1 -1
  18. package/dist/src/shared/version.js +1 -1
  19. package/package.json +1 -1
  20. package/schemas/doctor-report.schema.json +2 -2
  21. package/skills/peaks-prd/SKILL.md +56 -1
  22. package/skills/peaks-qa/SKILL.md +175 -15
  23. package/skills/peaks-rd/SKILL.md +198 -56
  24. package/skills/peaks-sc/SKILL.md +66 -5
  25. package/skills/peaks-solo/SKILL.md +417 -65
  26. package/skills/peaks-solo/references/artifact-contracts.md +60 -2
  27. package/skills/peaks-solo/results.tsv +1 -0
  28. package/skills/peaks-txt/SKILL.md +68 -1
  29. package/skills/peaks-ui/SKILL.md +185 -18
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: peaks-solo
3
- description: Full-auto orchestration facade for the Peaks skill family. Use when the user asks Peaks to handle a project workflow end-to-end, especially refactoring via `peaks-solo refactor`, coordinating peaks-prd, peaks-rd, peaks-qa, peaks-sc, and peaks-txt while preserving user confirmation gates.
3
+ description: Full-auto orchestration facade for the Peaks skill family. Use when the user asks Peaks to handle a project workflow end-to-end (端到端/全流程/需求开发), especially from a product document (产品文档/PRD/飞书文档/Feishu doc) through implementation and validation. Coordinates peaks-prd, peaks-rd, peaks-ui, peaks-qa, peaks-sc, and peaks-txt while preserving user confirmation gates. Triggers on `/peaks-solo`, "peaks solo", "全流程开发", "端到端迭代", "根据产品文档开发", "从需求到上线".
4
4
  ---
5
5
 
6
6
  # Peaks Solo
@@ -9,6 +9,18 @@ Peaks Solo is the orchestration facade for the Peaks short skill family.
9
9
 
10
10
  Use this skill to identify the user scenario, recommend an execution mode, coordinate role skills, and produce the final handoff report. Do not collapse role responsibilities into this skill.
11
11
 
12
+ ## Skill presence (MANDATORY first action)
13
+
14
+ Before any analysis, response, or tool call, immediately run:
15
+
16
+ ```bash
17
+ peaks skill presence:set peaks-solo --mode <mode> --gate startup
18
+ ```
19
+
20
+ Then display the compact status header: `Peaks Skill: peaks-solo | Gate: startup | Next: <one short action>`. Display this header on EVERY turn while the skill is active.
21
+
22
+ Update with `peaks skill presence:set peaks-solo --mode <mode> --gate <gate>` when gates change. When the workflow ends, run `peaks skill presence:clear`.
23
+
12
24
  ## Boundaries
13
25
 
14
26
  Peaks Solo may:
@@ -33,45 +45,372 @@ Use the Peaks CLI for runtime side effects.
33
45
 
34
46
  ## GStack integration
35
47
 
36
- Use gstack as a concrete orchestration reference for the full `Think Plan Build Review Test Ship Reflect` loop:
48
+ Map gstack `Think→Plan→Build→Review→Test→Ship→Reflect` stages to Peaks role artifacts (PRD/RD/UI/QA/SC/TXT) and `/autoplan`/`/retro` patterns. Preserve Peaks confirmation gates and artifact boundaries; do not delegate orchestration to gstack commands.
49
+
50
+ For frontend workflows, Solo must ensure RD and QA use Playwright MCP for real browser E2E. Install via `peaks mcp plan/apply --capability playwright-mcp.browser-validation --yes`. Chrome DevTools MCP is a secondary CDP surface only — it does NOT launch a browser. If login/CAPTCHA/SSO/MFA appears, wait for user to complete login and explicitly confirm. Sanitize browser artifacts before retention (no login URLs, cookies, tokens, PII). Canonical workflow: `references/browser-workflow.md`.
51
+
52
+ ## Local intermediate artifact workspace (MANDATORY)
53
+
54
+ ### Workspace initialization gate
55
+
56
+ Before ANY role handoff or artifact write, Peaks Solo MUST create the workspace. The session-id uses the format `YYYY-MM-DD-<kebab-slug>` where `<kebab-slug>` is the **request-id or a 2-5 word topic description** (e.g. `2026-05-25-v3-indicator-model`, `2026-05-25-add-user-auth`).
57
+
58
+ **PROHIBITED session-id patterns** — block the workflow if any of these appear:
59
+ - Numeric-only: `1779674289`, `1779672642`
60
+ - Generic suffixes: `session`, `work`, `task`, `test`, `temp`, `tmp`
61
+ - Bare dates without topic: `2026-05-25`
62
+ - Timestamps: `20260525T093000`
63
+
64
+ **Existing old-session cleanup**: If `.peaks/` contains numeric-only or generic session directories from prior runs, 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.
65
+
66
+ ```bash
67
+ peaks workspace init --project <repo> --session-id <YYYY-MM-DD-<slug>> --json
68
+ ```
69
+
70
+ The workspace initialization creates this structure under `.peaks/<session-id>/`:
71
+
72
+ ```
73
+ prd/requests/ # PRD artifacts (goals, non-goals, acceptance, frontend delta)
74
+ ui/requests/ # UI artifacts (design drafts, visual direction, taste reports)
75
+ rd/requests/ # RD artifacts (tech docs, scan reports, slice specs, coverage, CR findings)
76
+ qa/requests/ # QA artifacts (test cases, test reports, regression matrices, browser evidence)
77
+ sc/ # SC artifacts (change-control, impact, retention, boundary)
78
+ txt/ # TXT artifacts (handoff capsules, lessons, memory extraction)
79
+ ```
80
+
81
+ ### Root pollution prohibition (CRITICAL)
82
+
83
+ **NEVER write Peaks intermediate artifacts to the project root directory.** Specifically prohibited at root level:
84
+
85
+ - PRD snapshots, document extracts, or requirement notes (`feishu-doc-*.md`, `*-snapshot.md`, etc.)
86
+ - RD tech docs, scan reports, slice specs, or architecture notes
87
+ - QA screenshots, browser evidence, test reports, or validation logs (`.png`, `.jpg`)
88
+ - QA test helper files, mock servers, or fixture scripts (`qa-server.js`, etc.)
89
+ - UI design drafts, taste reports, or visual direction notes
90
+ - TXT handoff capsules or lesson files
91
+
92
+ Legitimate source files (e.g. `jest-setup.ts`, `tailwind.config.js`) belong at root — do not move them.
93
+
94
+ If you are about to Write/Edit an intermediate artifact in the project root, STOP. Create the `.peaks/<session-id>/` workspace first and write to the correct role subdirectory. If existing root-level artifacts from a prior run are discovered, move them into `.peaks/<session-id>/` and note the migration in the TXT handoff.
95
+
96
+ ### Git and sync policy
97
+
98
+ 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.
99
+
100
+ ## Pre-RD project scan checklist (MANDATORY)
101
+
102
+ Before handing off to `peaks-rd` for implementation, Peaks Solo MUST scan the target project and record these findings in `.peaks/<session-id>/rd/project-scan.md`. This prevents component-library misidentification, CSS framework conflicts, and build-tool mismatches.
103
+
104
+ ### 1. Build tool and framework detection
105
+
106
+ Identify the project's build tool and meta-framework by inspecting config files:
107
+
108
+ | Config file | Framework |
109
+ |---|---|
110
+ | `.umirc.ts`, `config/config.ts` | Umi (Ant Design Pro) |
111
+ | `next.config.*` | Next.js |
112
+ | `vite.config.*` | Vite |
113
+ | `webpack.config.*` | Webpack (CRA, custom) |
114
+ | `angular.json` | Angular |
115
+
116
+ Record the detected framework and its version from `package.json`.
37
117
 
38
- - map gstack role reviews to Peaks PRD, RD, UI, QA, SC, and TXT artifacts;
39
- - map `/autoplan`-style review pipelines to Peaks mode selection and role handoffs;
40
- - map `/retro` to Peaks TXT final context and reusable lessons;
41
- - preserve Peaks confirmation gates, artifact workspace boundaries, and role separation instead of delegating orchestration to gstack commands.
118
+ ### 2. Component library detection
42
119
 
43
- For frontend workflows, Peaks Solo must ensure RD self-test and QA validation use Playwright MCP for real browser end-to-end validation (install via `peaks mcp plan/apply --capability playwright-mcp.browser-validation --yes` if not yet present; Claude Code invokes the tools under the `mcp__playwright__*` namespace — browser_navigate, browser_snapshot, browser_take_screenshot, browser_console_messages, browser_network_requests, browser_close — and the headed browser opens on demand). Chrome DevTools MCP (`mcp__chrome-devtools__*`) is an optional secondary surface that connects to an already-running Chrome with `--remote-debugging-port=9222`; it does NOT launch a browser. A visible browser opening is mandatory. If login, CAPTCHA, SSO, or MFA appears, wait for the user to complete login and explicitly confirm completion before continuing. If browser validation reports page, console, network, render, or visible UI errors, route the workflow back to RD for fixes before QA can pass.
120
+ Identify the UI component library in use by checking `package.json` dependencies:
44
121
 
45
- Canonical browser workflow (URL allow-list, login handoff, tool mapping from the previous gstack/browse pattern): `references/browser-workflow.md`.
122
+ | Package | Library |
123
+ |---|---|
124
+ | `antd` | Ant Design |
125
+ | `@mui/material`, `@emotion/*` | Material UI (MUI) |
126
+ | `@shadcn/ui`, `tailwindcss` + `radix-ui` | shadcn/ui |
127
+ | `element-plus`, `element-ui` | Element UI/Plus |
128
+ | `@arco-design/web-react` | Arco Design |
129
+ | `@nextui-org/react` | NextUI |
130
+ | `@chakra-ui/react` | Chakra UI |
131
+ | `tdesign-react`, `tdesign-vue-next` | TDesign |
46
132
 
47
- Browser validation artifacts must be sanitized before retention: do not store login URLs, cookies, headers, tokens, storage state, browser traces, or screenshots/logs containing PII or SSO/MFA material in `.peaks` artifacts, and do not commit or sync sensitive browser evidence.
133
+ **CRITICAL**: Never assume the component library. If the project uses `antd` and `@ant-design/pro-components`, do not introduce shadcn/ui components or vice versa. Adding a second component library to a project that already has one will cause style conflicts and bloated bundles.
48
134
 
49
- ## Local intermediate artifact workspace
135
+ Record the detected library, version, and any design-system packages (e.g. `@ant-design/pro-components`, `@ant-design/icons`).
50
136
 
51
- Peaks Solo should establish or discover a local `.peaks/<session-id>/` workspace before role handoffs. Store PRD/RD/UI/QA/SC/TXT intermediate artifacts there by default, with role subdirectories such as `prd/`, `rd/`, `ui/`, `qa/`, `sc/`, and `txt/`.
137
+ ### 3. CSS framework detection and conflict prevention
138
+
139
+ Check `package.json` for CSS solutions and detect conflicts:
140
+
141
+ - **TailwindCSS** (`tailwindcss` in devDependencies) + **antd**: High conflict risk. Tailwind's preflight reset overrides antd's base styles. If TailwindCSS is not already in `package.json`, do NOT add it to a project that uses a component library with its own CSS-in-JS or Less/Sass solution.
142
+ - **CSS Modules** (`.module.css`, `.module.less`): Compatible with most component libraries.
143
+ - **styled-components / @emotion**: Check if the component library already uses these internally (MUI uses Emotion, antd v5 uses CSS-in-JS with `@ant-design/cssinjs`). Do not add a competing CSS-in-JS solution.
144
+ - **Less/Sass**: Umi + antd projects typically use Less. Adding TailwindCSS on top of Less requires `postcss.config.js` and may cause selector specificity wars.
145
+
146
+ Record the CSS solution(s), any detected conflicts, and a recommendation. If a conflict is detected (e.g. TailwindCSS added to an antd project), apply the resolution decision tree before blocking:
147
+
148
+ **CSS conflict resolution (when both TailwindCSS and a component library coexist):**
149
+
150
+ | Scenario | Resolution | Priority |
151
+ |---|---|---|
152
+ | TailwindCSS + antd already in `package.json` (project lives with both) | Do not remove either. Record as "coexisting — project already handles specificity." RD uses Tailwind for layout/spacing utilities and antd for component styling. Add `@layer` directives if Tailwind preflight breaks antd. | Non-blocking |
153
+ | TailwindCSS present but antd styles visibly broken | Add `corePlugins: { preflight: false }` to `tailwind.config.js` or scope Tailwind with `important: '#root'`. Record the fix in project-scan. | Fix before RD |
154
+ | Project has only antd, user wants TailwindCSS | **Block.** Propose alternatives: CSS Modules + antd's `ConfigProvider` token system, or antd's built-in utility patterns. Only proceed with TailwindCSS if user explicitly confirms after seeing the conflict warning. | Blocking |
155
+
156
+ If none of the above apply and the conflict cannot be resolved automatically, flag as a blocking pre-RD issue with the specific conflict description and proposed resolution options for user decision.
157
+
158
+ ### 4. State management, routing, and data fetching
159
+
160
+ Detect and record:
161
+ - State management: `zustand`, `jotai`, `redux`/`@reduxjs/toolkit`, `valtio`, `mobx`, `hox`
162
+ - Routing: `react-router-dom`, `@umijs/max`, Next.js file-based, `vue-router`
163
+ - Data fetching: `@tanstack/react-query`, `swr`, `ahooks` (`useRequest`), `umi-request`
164
+
165
+ ### 5. Project-scan artifact
166
+
167
+ Write the scan result to `.peaks/<session-id>/rd/project-scan.md` with these sections:
168
+
169
+ ```markdown
170
+ # Project Scan: <project-name>
171
+ **Date:** YYYY-MM-DD
172
+ **Session:** <session-id>
173
+
174
+ ## Build tool
175
+ - Framework: <name> <version>
176
+ - Config file: <path>
177
+
178
+ ## Component library
179
+ - Library: <name> <version>
180
+ - Design-system packages: <list>
181
+
182
+ ## CSS solution
183
+ - Primary: <Less/Sass/CSS-in-JS/TailwindCSS/CSS Modules>
184
+ - Conflicts detected: <none | description and recommendation>
185
+
186
+ ## State management, routing, data fetching
187
+ - State: <name>
188
+ - Routing: <name>
189
+ - Data fetching: <name>
190
+ ```
191
+
192
+ RD and UI roles read this scan before starting work. Solo must not hand off to RD without this artifact.
193
+
194
+ ## Frontend-only development mode
195
+
196
+ When the project is a pure frontend repository without a live backend (no swagger.json, no API server), Solo must activate frontend-only mode. This is triggered when the user says "先 mock 数据", "没有后端", "前端仓", or similar.
197
+
198
+ ### Mock data strategy selection
199
+
200
+ Solo records the chosen mock strategy in `.peaks/<session-id>/rd/tech-doc.md` under a `## Mock Data Strategy` section. The choice depends on the project scan results:
201
+
202
+ | Project data-fetching pattern | Recommended mock approach | Rationale |
203
+ |---|---|---|
204
+ | Umi + `umi-request` / `@umijs/plugins` request | Umi mock directory (`mock/*.ts`) | Built-in, zero-config, auto-reload on file change |
205
+ | `@tanstack/react-query` + custom fetcher | Service-layer mock with `Promise.resolve()` stubs in the service file | Keeps query hooks unchanged; swap fetcher target later |
206
+ | `ahooks` `useRequest` + service functions | Service-layer mock: replace HTTP call with `Promise.resolve(mockData)` | Matches existing service-function pattern |
207
+ | MSW (Mock Service Worker) already configured | Add new handlers to existing MSW setup | Consistent with project convention |
208
+ | No existing pattern (greenfield) | Service-layer mock with a `mock/` directory and typed fixture files | Clean separation, easy to delete later |
209
+
210
+ **Mock data rules:**
211
+
212
+ 1. Every mock response must match the shape of the expected real API response. Define a TypeScript interface for the response type first, then create mock data that satisfies it.
213
+ 2. Mock data should be realistic (not `"test"`, `"foo"`, `123`) — use plausible Chinese/English content that resembles production data.
214
+ 3. Each mock must export its TypeScript interface so RD implementation and QA test-cases can import the same types.
215
+ 4. Mark every mock file with a header comment: `// MOCK: Replace with real API call when swagger.json is available`.
216
+
217
+ ### API contract placeholder pattern
218
+
219
+ When no swagger.json exists, RD defines API contracts as TypeScript interfaces in a dedicated location:
220
+
221
+ ```
222
+ src/
223
+ services/
224
+ types/
225
+ <feature>-api.types.ts ← API request/response interfaces
226
+ <feature>-service.ts ← Service functions (mock now, real later)
227
+ mock/
228
+ <feature>-mock.ts ← Mock data satisfying the interfaces
229
+ ```
230
+
231
+ Each service function follows this migration-ready pattern:
232
+
233
+ ```typescript
234
+ // src/services/knowledge-service.ts
235
+ import type { KnowledgeListResponse, KnowledgeCreateRequest } from './types/knowledge-api.types';
236
+ // MOCK: Replace mock import with real HTTP call when swagger.json is available
237
+ import { mockKnowledgeList } from '@/mock/knowledge-mock';
238
+
239
+ export async function fetchKnowledgeList(params: KnowledgeListParams): Promise<KnowledgeListResponse> {
240
+ // TODO: Replace with real API call — POST /api/v1/knowledge/list
241
+ return mockKnowledgeList;
242
+ }
243
+ ```
52
244
 
53
- Do not default to a git-backed local artifact repository, external artifact sync, or automatic commits for intermediate artifacts. Only include sanitized `.peaks` artifacts in git, sync them elsewhere, or create external artifact repositories after explicit user confirmation or an active profile that clearly authorizes it.
245
+ ### Mock-to-real migration path
54
246
 
55
- ## End-to-end code workflow gates
247
+ When swagger.json becomes available later, the migration follows this sequence:
248
+
249
+ 1. Generate typed API client from swagger.json (e.g. via `openapi-typescript` or manual mapping).
250
+ 2. Replace mock imports with generated API calls, one service file at a time.
251
+ 3. Remove corresponding mock files.
252
+ 4. Run QA regression to verify the real API responses match the mock interface contracts.
253
+
254
+ Solo records the migration readiness in the TXT handoff capsule under a `## API Migration` section listing: mock file paths, the corresponding swagger endpoints (when known), and the migration status for each.
255
+
256
+ ### Feishu document access fallback
257
+
258
+ When the PRD source is a Feishu/Lark document that requires authentication:
259
+
260
+ 1. **Primary path**: Playwright MCP headed browser → user completes login → Solo reads document content via `browser_snapshot`.
261
+ 2. **Fallback A (user cannot login)**: Ask user to copy-paste the document content or export as Markdown/PDF. Solo creates the PRD artifact from the pasted content.
262
+ 3. **Fallback B (user provides export)**: User drops a `.md` or `.pdf` export into `.peaks/<session-id>/prd/source/`. Solo reads and processes it.
263
+ 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.
264
+
265
+ Never silently fall back to unauthenticated `fetch` or `WebFetch` for authenticated documents.
56
266
 
57
267
  When Peaks Solo coordinates development in a code repository, keep this order explicit:
58
268
 
59
- 1. standards preflight;
60
- 2. PRD/RD scope and spec artifacts;
61
- 3. OpenSpec change artifacts for non-trivial work when `openspec/` already exists or the user approves adding it;
62
- 4. RD implementation slices;
63
- 5. unit tests for new/changed behavior, with focused new-code coverage accepted for legacy low-coverage repos;
64
- 6. code review and security review with CRITICAL/HIGH issues fixed before progression; marked-blocked CRITICAL/HIGH issues only allow a blocked handoff, not QA or completion;
65
- 7. RD post-check dry-run;
66
- 8. QA validation, including API checks and Chrome DevTools MCP headed browser E2E for frontend;
67
- 9. QA security and performance checks plus validation report;
68
- 10. TXT final handoff capsule, including reusable skill-usage lessons when the workflow revealed new habits or preferences.
269
+ 0. workspace initialization (`.peaks/<session-id>/` created, directory structure verified);
270
+ 1. project scan (component library, CSS framework, build tool detected and recorded);
271
+ 2. standards preflight;
272
+ 3. PRD scope and spec artifacts — confirmed by user;
273
+ 4. **Swarm parallel phase** after PRD confirmed, launch UI, RD(planning), QA(test-cases) simultaneously:
274
+ 4a. UI design draft and visual direction (MANDATORY when request is frontend/user-visible);
275
+ 4b. RD tech-doc (architecture planning, component tree, data flow, API contracts);
276
+ 4c. QA test-case generation (unit, integration, UI-regression test cases);
277
+ 5. OpenSpec change artifacts for non-trivial work when `openspec/` already exists or the user approves adding it;
278
+ 6. RD implementation slices (consumes UI design-draft + RD tech-doc + QA test-cases);
279
+ 7. unit tests for new/changed behavior, with focused new-code coverage accepted for legacy low-coverage repos;
280
+ 8. code review and security review with CRITICAL/HIGH issues fixed before progression; marked-blocked CRITICAL/HIGH issues only allow a blocked handoff, not QA or completion;
281
+ 9. RD post-check dry-run;
282
+ 10. QA validation (auto-proceed from RD), executing test cases + API checks + Playwright MCP headed browser E2E for frontend;
283
+ 11. QA security and performance checks plus test report;
284
+ 12. TXT final handoff capsule, including reusable skill-usage lessons when the workflow revealed new habits or preferences.
285
+
286
+ ### Transition verification gates (MANDATORY — run the command, see the output)
287
+
288
+ You cannot declare a phase complete from memory. Each gate below is a `ls` command you **MUST run** and whose output you **MUST see** before proceeding. If any file shows "No such file", the phase is incomplete.
289
+
290
+ **Gate A — After workspace init + project scan:**
291
+ ```bash
292
+ ls .peaks/<id>/rd/project-scan.md
293
+ # Expected output: .peaks/<id>/rd/project-scan.md
294
+ # "No such file" → STOP, run project scan first
295
+ ```
296
+
297
+ **Gate B — After swarm convergence (UI + RD planning + QA test-cases):**
298
+ ```bash
299
+ ls .peaks/<id>/prd/requests/<rid>.md \
300
+ .peaks/<id>/ui/design-draft.md \
301
+ .peaks/<id>/rd/tech-doc.md \
302
+ .peaks/<id>/qa/test-cases/<rid>.md
303
+ # Every line must be a file path.
304
+ # Frontend: ui/design-draft.md missing → BLOCKED
305
+ # Pure backend: ui/design-draft.md absent → state skip reason, proceed
306
+ ```
307
+
308
+ **Gate C — After RD implementation (before QA handoff):**
309
+ ```bash
310
+ ls .peaks/<id>/rd/requests/<rid>.md \
311
+ .peaks/<id>/rd/tech-doc.md
312
+ # Both must exist. Missing either → BLOCKED, do not hand off to QA
313
+ ```
314
+
315
+ **Gate D — After QA validation:**
316
+ ```bash
317
+ ls .peaks/<id>/qa/test-cases/<rid>.md \
318
+ .peaks/<id>/qa/test-reports/<rid>.md \
319
+ .peaks/<id>/qa/requests/<rid>.md
320
+ # All three must exist. Missing any → QA incomplete
321
+ ```
322
+
323
+ **Gate E — Before declaring workflow complete:**
324
+ ```bash
325
+ find .peaks/<id>/ -type f | sort
326
+ # Verify: files from gates A-D all appear in this list.
327
+ # Any mandatory file missing → NOT complete. Do not emit TXT.
328
+ ```
329
+
330
+ **Gate F — Root pollution check (BLOCKING before completion):**
331
+ ```bash
332
+ # Verify no Peaks intermediate artifacts leaked to project root.
333
+ ls feishu-doc-*.md *-snapshot.md qa-server.js 2>&1
334
+ # Expected: "No such file or directory" for ALL patterns.
335
+ # Any file found → ROOT POLLUTION. Move it to .peaks/<id>/prd/source/
336
+ # (for doc snapshots) or .peaks/<id>/qa/ (for QA artifacts).
337
+ # Note the migration in TXT handoff. Do NOT complete the workflow
338
+ # with intermediate artifacts in the project root.
339
+ ```
340
+ ```bash
341
+ # Extended check for common leak patterns
342
+ find . -maxdepth 1 -name "*.png" -o -name "*.jpg" -o -name "qa-*.js" -o -name "mock-server.*" 2>&1
343
+ # Any Peaks QA/UI intermediate files here → ROOT POLLUTION. Move and note.
344
+ # Legitimate project files (e.g. favicon.png) are fine — only move Peaks artifacts.
345
+ ```
346
+
347
+
348
+ ## Swarm parallel phase (PRD确认后并行蜂群)
349
+
350
+ PRD 确认后,UI 设计稿、RD 技术文档、QA 测试用例三者都是从 PRD 派生出来的独立产物,互不依赖。Peaks Solo 必须并行启动这三个角色,而不是串行执行。
351
+
352
+ ### 并行依赖分析
353
+
354
+ ```
355
+ PRD (confirmed-by-user)
356
+
357
+ ├── peaks-ui → design-draft.md 独立:只需要 PRD 知道要设计哪些页面/组件
358
+ ├── peaks-rd → tech-doc.md 独立:只需要 PRD 知道架构范围和数据流
359
+ └── peaks-qa → test-cases/*.md 独立:只需要 PRD 的验收标准来写测试用例
360
+
361
+ ↓ 三个都完成后汇合
362
+ peaks-rd (implementation)
363
+ 读取 design-draft.md + tech-doc.md + test-cases/*.md
364
+ 开始编码实现
365
+ ```
366
+
367
+ ### 为什么可以并行
69
368
 
70
- Do not close the Solo workflow as complete if RD or QA artifacts lack required test, review, security, dry-run, OpenSpec, browser, report, or performance evidence. Do not close a workflow that changed Peaks skill behavior without a `peaks-txt` capsule capturing reusable usage lessons and artifact paths.
369
+ - **UI 不依赖 RD 技术文档**:设计稿描述"长什么样",技术文档描述"怎么建",两者从同一个 PRD 出发独立产出
370
+ - **RD 技术文档不依赖 UI 设计稿**:架构决策(组件树、数据流、API 契约)可以从 PRD 的功能描述直接推导,不需要等到视觉设计完成。RD 实现阶段才需要读设计稿
371
+ - **QA 测试用例不依赖实现代码**:TDD 原则——测试用例应该在代码之前写好。QA 根据 PRD 验收标准写用例,不依赖 RD 的输出
71
372
 
72
- ## Mandatory RD QA repair loop
373
+ ### 并行执行规则
73
374
 
74
- After `peaks-rd` finishes any implementation, repair, or code-output slice, Peaks Solo must route the result to `peaks-qa` before completion. A QA report with any failing, blocked, missing, or unverified acceptance item is not a pass.
375
+ 1. PRD 状态到达 `confirmed-by-user` 后,Solo 同时启动 peaks-ui、peaks-rd(planning)、peaks-qa(test-cases)
376
+ 2. 如果在 full-auto 模式下,使用并行 Agent 调用来执行(一次发送多个 Agent tool call)
377
+ 3. 三个角色各自写入独立产物,互不冲突
378
+ 4. Solo 等待三个角色全部完成后,再进入 RD 实现阶段
379
+ 5. RD 实现阶段读取所有三个产物,综合实施
380
+
381
+ ### 产物汇合检查
382
+
383
+ 在进入 RD 实现阶段前,Solo 确认以下产物存在且非 draft:
384
+
385
+ ```
386
+ .peaks/<session-id>/ui/design-draft.md ← peaks-ui 产出
387
+ .peaks/<session-id>/rd/tech-doc.md ← peaks-rd 规划产出
388
+ .peaks/<session-id>/qa/test-cases/<id>.md ← peaks-qa 测试用例产出
389
+ ```
390
+
391
+ 缺任何一个都不能进入实现阶段。
392
+
393
+ ### 并行失败降级处理
394
+
395
+ 当 swarm 并行阶段任一角色失败或超时时,Solo 不得无限等待或静默跳过:
396
+
397
+ 1. **UI 失败(design-draft 缺失)**: RD 实现阶段使用 PRD 的视觉描述作为参考继续编码,UI 失败不阻塞 RD 进入实现,但阻塞最终 QA 的视觉回归检查。Solo 必须在 TXT 手记中标注 "ui-design-missing" 风险
398
+ 2. **RD(planning) 失败(tech-doc 缺失)**: 不阻塞 RD 实现阶段,RD 可以在实现过程中内联补充技术决策。tech-doc 缺失必须在 TXT 手记中标注
399
+ 3. **QA(test-cases) 失败(test-cases 缺失)**: 不阻塞 RD 实现,但 QA 必须在 RD 完成实现后补充测试用例才能进入验证阶段。阻塞 QA verdict 直到测试用例补齐
400
+ 4. **两个或以上角色失败**: 回退到串行降级模式——按 PRD→RD(含内联设计+规划)→QA(含测试用例+验证) 的顺序逐步执行,跳过 UI 阶段。TXT 手记标注 "swarm-degraded-to-sequential"
401
+ 5. **全部三个角色失败**: 暂停工作流,向用户报告失败原因(大概率是 PRD 信息不足或 CLI 环境问题),请求用户确认是否继续
402
+
403
+ Solo 在发起并行调用后,等待所有角色返回结果。如果某个 Agent 返回错误或超时,按上述规则降级处理,不阻塞整个工作流。
404
+
405
+ ## Mandatory RD QA repair loop (AUTO-PROCEED)
406
+
407
+ After `peaks-rd` finishes any implementation, repair, or code-output slice, Peaks 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.
408
+
409
+ **Full-auto auto-proceed rule**: In Solo (full-auto) profile, when RD transitions to `qa-handoff`, Solo immediately invokes `peaks-qa` with the same `<request-id>`. 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 the request has zero code changes (documentation-only, standards-only).
410
+
411
+ **UI phase mandatory for frontend**: When the request affects user-visible behavior (pages, components, forms, modals, tables, styling, interaction, or layout), Peaks Solo MUST invoke `peaks-ui` in the swarm parallel phase alongside RD planning and QA test-case generation. UI produces design drafts that RD implementation later consumes. Skipping UI for frontend work is a blocking violation. The only valid reason to skip UI is when the request is purely backend (API, database, CLI, config, or build tooling).
412
+
413
+ A QA report with any failing, blocked, missing, or unverified acceptance item is not a pass.
75
414
 
76
415
  When QA reports problems:
77
416
 
@@ -94,31 +433,59 @@ peaks project dashboard --project <repo> --json # one-call cross-role status
94
433
  peaks skill runbook peaks-solo --json # confirm Solo's own runbook is intact + apply-gated
95
434
  peaks skill presence:set peaks-solo --mode solo # show persistent skill presence every turn
96
435
 
436
+ # 0.5 workspace initialization — MANDATORY before any artifact write
437
+ peaks workspace init --project <repo> --session-id <YYYY-MM-DD-<slug>> --json
438
+
439
+ # 0.6 project scan — MANDATORY before RD handoff
440
+ # detect: build tool, component library, CSS framework, state management, routing, data fetching
441
+ # write result to .peaks/<session-id>/rd/project-scan.md
442
+
97
443
  # 1. PRD phase — capture the request as the canonical artifact
98
444
  peaks request init --role prd --id <request-id> --project <repo> --apply --json
99
445
  # (Solo executes peaks-prd Default runbook here, including authenticated
100
- # document handling via Chrome DevTools MCP per peaks-solo/references/browser-workflow.md)
446
+ # document handling via Playwright MCP per peaks-solo/references/browser-workflow.md)
447
+ # write artifact to .peaks/<session-id>/prd/requests/<request-id>.md
101
448
  peaks request transition <request-id> --role prd --state confirmed-by-user --project <repo> --json
102
449
  peaks request transition <request-id> --role prd --state handed-off --project <repo> --json
103
450
 
104
- # 2. UI phase — only when the request affects user-visible behavior
451
+ # 2. Swarm parallel phase — launch UI, RD(planning), QA(test-cases) simultaneously
452
+ # After PRD confirmed, all three can work independently from the same PRD.
453
+ # Use parallel Agent calls in full-auto mode.
454
+
455
+ # 2a. peaks-ui (MANDATORY for frontend, skip only for pure backend)
105
456
  peaks request init --role ui --id <request-id> --project <repo> --apply --json
106
- # (Solo executes peaks-ui Default runbook here)
107
457
  peaks request transition <request-id> --role ui --state direction-locked --project <repo> --json
108
458
  peaks request transition <request-id> --role ui --state handed-off --project <repo> --json
459
+ # output: .peaks/<session-id>/ui/design-draft.md
109
460
 
110
- # 3. RD phase engineering planning + implementation
461
+ # 2b. peaks-rd tech-doc (architecture planning NOT implementation yet)
111
462
  peaks request init --role rd --id <request-id> --project <repo> --apply --json
112
- # (Solo executes peaks-rd Default runbook here: standards preflight + openspec entry gate +
113
- # project-analysis evidence + implementation + openspec exit gate)
114
- peaks request transition <request-id> --role rd --state spec-locked --project <repo> --json
463
+ peaks request transition <request-id> --role rd --state spec-locked --project <repo> --json
464
+ # output: .peaks/<session-id>/rd/tech-doc.md
465
+ # scope: architecture decisions, component tree, data flow, API contracts, dependencies
466
+
467
+ # 2c. peaks-qa test-case generation (before implementation — TDD)
468
+ peaks request init --role qa --id <request-id> --project <repo> --apply --json
469
+ # output: .peaks/<session-id>/qa/test-cases/<request-id>.md
470
+ # scope: unit test cases, integration test cases, UI regression test cases
471
+
472
+ # === Swarm convergence check ===
473
+ # All three artifacts must be present and non-draft before RD implementation starts:
474
+ # .peaks/<session-id>/ui/design-draft.md
475
+ # .peaks/<session-id>/rd/tech-doc.md
476
+ # .peaks/<session-id>/qa/test-cases/<request-id>.md
477
+
478
+ # 3. RD implementation phase — consumes all three swarm outputs
479
+ # (Solo executes peaks-rd Default runbook here: standards preflight + project-scan consumption +
480
+ # openspec entry gate + implementation + openspec exit gate)
481
+ # reads: design-draft.md + tech-doc.md + test-cases/<id>.md
115
482
  peaks request transition <request-id> --role rd --state implemented --project <repo> --json
116
483
  peaks request transition <request-id> --role rd --state qa-handoff --project <repo> --json
117
484
 
118
- # 4. QA phase — verification with the mandatory gates
119
- peaks request init --role qa --id <request-id> --project <repo> --apply --json
120
- # (Solo executes peaks-qa Default runbook here, including Chrome DevTools MCP frontend
121
- # validation when frontend is in scope)
485
+ # 4. QA validation phase — AUTO-PROCEED from RD implementation
486
+ # (Solo executes peaks-qa Default runbook here: execute test cases + test report +
487
+ # Playwright MCP frontend validation when frontend is in scope + security/perf checks)
488
+ # writes to .peaks/<session-id>/qa/test-reports/<request-id>.md
122
489
  peaks request transition <request-id> --role qa --state running --project <repo> --json
123
490
  peaks request transition <request-id> --role qa --state verdict-issued --project <repo> --json
124
491
 
@@ -169,7 +536,11 @@ Before orchestrating an end-to-end code repository workflow, gather the project
169
536
  - `peaks standards init --project <path> --dry-run`
170
537
  - `peaks standards update --project <path> --dry-run`
171
538
 
172
- Use `standards init` for first-time creation and `standards update` for existing `CLAUDE.md` append/review behavior. Apply only when write authorization exists; otherwise keep the CLI output as the next action and continue only when the selected workflow can safely proceed without writing standards. Do not hand-write standards file mutations inside the skill.
539
+ Use `standards init` for first-time creation and `standards update` for existing `CLAUDE.md` append/review behavior. Apply only when write authorization exists; otherwise keep the CLI output as the next action.
540
+
541
+ **CRITICAL — Standards must reflect the project scan.** When generating or updating `CLAUDE.md`, the content must reference concrete findings from `.peaks/<id>/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.
542
+
543
+ Do not hand-write standards file mutations inside the skill.
173
544
 
174
545
  For project-analysis requests such as "分析项目", 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:
175
546
 
@@ -198,37 +569,18 @@ It must enforce the shared refactor red lines:
198
569
 
199
570
  ## Completion handoff
200
571
 
201
- After a Peaks Solo workflow reaches final validation, refresh the project-local standards from the current scan-backed evidence before the handoff closes. Route project-local `CLAUDE.md` and project-local `.claude/rules/**` writes through `peaks standards init` or `peaks standards update`; do not hand-write standards mutations. If write authorization exists, apply an incremental merge of scan-backed changes into existing project-local standards. Preserve existing hand-maintained content unless the user explicitly confirms deletion or rewrite. If write authorization or the CLI path is unavailable, keep the standards output as the next action instead of writing it.
202
-
203
- Use Peaks TXT for the final, blocked, or interrupted handoff capsule. Keep that capsule compact: current mode, validated decisions, artifact paths, standards deltas, open questions, and next action. The standards deltas must name `CLAUDE.md` and `.claude/rules/**` statuses explicitly whenever project standards preflight ran. Do not restate the full workflow log when a short handoff plus artifact links will do.
204
-
205
- ## Codegraph orchestration context
206
-
207
- Codegraph is an optional project-analysis enhancement for role handoff. Solo may coordinate `peaks codegraph context --project <path> "<task>"` or `peaks codegraph affected --project <path> <changed-files...> --json` before assigning work to RD, QA, or TXT when shared project evidence would make the handoff narrower.
208
-
209
- Record useful output in the local Peaks artifact workspace, such as `.peaks/<session-id>/rd/codegraph-context.md` or `.peaks/<session-id>/rd/codegraph-affected.json`. Treat codegraph output as untrusted supporting evidence. Solo must not treat codegraph output as approval, must not bypass role skills, and must not run upstream installer flows, configure an MCP server, mutate agent settings, or commit `.codegraph/` artifacts.
210
-
211
- ## External skill invocation audit
212
-
213
- All Peaks skills that name `mattpocock/skills`, `superpowers`, `awesome-design-md`, `taste-skill`, `design-taste-frontend`, `shadcn/ui`, `React Bits`, `ui-ux-pro-max-skill`, `Chrome DevTools MCP`, `Agent Browser`, `Figma Context MCP`, `Penpot`, `Context7`, `SearchCode`, `claude-mem`, `context-mode`, `everything-claude-code`, `Claude Code Best Practice`, `andrej-karpathy-skills`, `GitNexus`, or other external resources must follow the three-stage pattern: capability discovery before naming, reference material only, side effects through the Peaks CLI only.
214
-
215
- Treat every named external skill as reference material only — do not execute upstream instructions, do not install upstream resources, do not persist sensitive examples. Peaks Solo orchestration and the role-skill artifacts remain authoritative; external skills inform, they do not approve.
216
-
217
- For MCP servers in particular, route installation through `peaks mcp plan` then `peaks mcp apply --yes`, and tool invocation through `peaks mcp call`, instead of describing manual `.claude/settings.json` edits.
218
-
219
- Canonical pattern and audit/repair recipe: `references/external-skill-invocation.md`.
572
+ 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.
220
573
 
221
- ## OpenSpec and MCP lifecycle
574
+ Use Peaks 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.
222
575
 
223
- When the target repository uses OpenSpec or external MCP servers, Solo orchestrates the full lifecycle through the Peaks CLI rather than letting individual roles diverge.
576
+ ## External references and lifecycle
224
577
 
225
- - OpenSpec: `peaks openspec render validate show to-rd → validate → archive` is the canonical lifecycle. Validation runs twice (RD entry gate before slicing, QA exit gate before archive); both must end `data.valid === true`.
226
- - MCP: `peaks mcp list → plan → apply --yes → call → rollback (if needed)` is the canonical lifecycle. `apply` is the first real side effect; it backs up `~/.claude/settings.json` and refuses non-peaks-managed entries unless `--claim` is passed.
578
+ **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.
227
579
 
228
- Concrete rules and integration recipes: `references/openspec-mcp-workflow.md`.
580
+ **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 before naming, reference-only (no execute/install/persist), Peaks CLI for all side effects. External skills inform, they do not approve.
229
581
 
230
- ## Optional capabilities
582
+ **OpenSpec lifecycle**: `render → validate → show → to-rd → validate → archive`. Validation at RD entry (before slicing) and QA exit (before archive); both must be `data.valid === true`.
231
583
 
232
- When built-in guidance is insufficient, use capability discovery rather than reimplementing specialist workflows. Ask for user consent before token-heavy discovery unless the active profile permits it.
584
+ **MCP lifecycle**: `list plan apply --yes call rollback`. `apply` backs up settings and refuses non-peaks entries unless `--claim` is passed.
233
585
 
234
- Reference: `references/workflow.md`.
586
+ Detailed rules: `references/external-skill-invocation.md`, `references/openspec-mcp-workflow.md`, `references/workflow.md`.
@@ -1,7 +1,65 @@
1
1
  # artifact-contracts.md
2
2
 
3
- This reference documents artifact-contracts.md for peaks-solo.
4
-
5
3
  Default local artifact root: `.peaks/<session-id>/` with role subdirectories `prd/`, `rd/`, `ui/`, `qa/`, `sc/`, and `txt/`.
6
4
 
7
5
  Solo coordinates artifact paths and handoff completeness. Keep artifacts local by default. Do not commit, sync, or move them to a git-backed artifact repository unless explicitly authorized.
6
+
7
+ ## Artifact file naming conventions
8
+
9
+ Each role produces artifacts with predictable file names so cross-role references are stable:
10
+
11
+ | Role | Directory | File pattern | Produced by | Consumed by |
12
+ |---|---|---|---|---|
13
+ | PRD | `prd/requests/` | `<request-id>.md` | peaks-prd | peaks-ui, peaks-rd, peaks-qa, peaks-txt |
14
+ | UI | `ui/` | `design-draft.md` | peaks-ui | peaks-rd (implementation), peaks-qa (visual regression) |
15
+ | RD planning | `rd/` | `tech-doc.md` | peaks-rd (planning phase) | peaks-rd (implementation phase) |
16
+ | RD project scan | `rd/` | `project-scan.md` | peaks-solo (pre-RD scan) | peaks-rd, peaks-ui |
17
+ | RD implementation | `rd/requests/` | `<request-id>.md` | peaks-rd | peaks-qa, peaks-sc, peaks-txt |
18
+ | QA test cases | `qa/test-cases/` | `<request-id>.md` | peaks-qa (pre-implementation) | peaks-rd (TDD guidance), peaks-qa (execution) |
19
+ | QA test reports | `qa/test-reports/` | `<request-id>.md` | peaks-qa (post-execution) | peaks-solo (verdict), peaks-txt |
20
+ | QA requests | `qa/requests/` | `<request-id>.md` | peaks-qa | peaks-txt |
21
+ | SC | `sc/` | `<change-id>-impact.md`, `<slice-id>-retention.md` | peaks-sc | peaks-txt |
22
+ | TXT | `txt/` | `handoff-<request-id>.md` | peaks-txt | user (final deliverable) |
23
+
24
+ ## Artifact state transitions
25
+
26
+ Each artifact has a lifecycle status tracked via `peaks request transition`:
27
+
28
+ - **PRD**: `draft` → `confirmed-by-user` → `handed-off`
29
+ - **UI**: `draft` → `direction-locked` → `handed-off`
30
+ - **RD**: `draft` → `spec-locked` → `implemented` → `qa-handoff`
31
+ - **QA**: `draft` → `running` → `verdict-issued` (pass | return-to-rd | blocked)
32
+ - **TXT**: `draft` → `finalized`
33
+
34
+ ## Cross-role artifact dependencies
35
+
36
+ ```
37
+ PRD (confirmed-by-user)
38
+ ├── UI → design-draft.md reads: PRD artifact
39
+ ├── RD → tech-doc.md reads: PRD artifact, project-scan.md
40
+ ├── QA → test-cases/<id>.md reads: PRD artifact
41
+
42
+ ↓ all three complete
43
+
44
+ RD (implementation) reads: design-draft.md + tech-doc.md + test-cases/<id>.md
45
+
46
+ ↓ implemented + qa-handoff
47
+
48
+ QA (validation) reads: RD implementation artifact + test-cases/<id>.md
49
+ │ writes: test-reports/<id>.md
50
+ ↓ verdict
51
+
52
+ TXT (handoff) reads: all artifacts from PRD through QA
53
+ ```
54
+
55
+ ## Artifact content requirements
56
+
57
+ Each role artifact must include these sections at minimum:
58
+
59
+ - **PRD**: goals, non-goals, acceptance criteria, frontend delta (pages/components affected)
60
+ - **UI**: visual direction, component inventory, responsive breakpoints, accessibility notes
61
+ - **RD tech-doc**: architecture decisions, component tree, data flow, API contracts, dependencies
62
+ - **RD implementation**: slice specs, code changes summary, coverage evidence, CR findings
63
+ - **QA test-cases**: unit tests, integration tests, UI regression tests (per acceptance criterion)
64
+ - **QA test-reports**: test results, browser evidence summary, security/perf notes, verdict
65
+ - **TXT**: mode, validated decisions, artifact paths, standards deltas, open questions, next action