peaks-cli 1.3.3 → 1.3.5

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 (61) hide show
  1. package/dist/src/cli/commands/core-artifact-commands.js +6 -3
  2. package/dist/src/cli/commands/hook-handle.d.ts +2 -2
  3. package/dist/src/cli/commands/hook-handle.js +5 -10
  4. package/dist/src/cli/commands/hooks-commands.js +44 -29
  5. package/dist/src/cli/commands/project-commands.js +15 -5
  6. package/dist/src/cli/commands/workflow-commands.js +2 -1
  7. package/dist/src/cli/commands/workspace-commands.js +1 -2
  8. package/dist/src/cli/program.js +3 -2
  9. package/dist/src/services/dashboard/project-dashboard-service.d.ts +23 -0
  10. package/dist/src/services/dashboard/project-dashboard-service.js +21 -0
  11. package/dist/src/services/dispatch/sub-agent-dispatcher.d.ts +45 -40
  12. package/dist/src/services/dispatch/sub-agent-dispatcher.js +25 -20
  13. package/dist/src/services/ide/adapters/claude-code-adapter.js +27 -2
  14. package/dist/src/services/ide/adapters/trae-adapter.d.ts +19 -11
  15. package/dist/src/services/ide/adapters/trae-adapter.js +45 -19
  16. package/dist/src/services/ide/hook-protocol.d.ts +7 -4
  17. package/dist/src/services/ide/hook-protocol.js +7 -4
  18. package/dist/src/services/ide/ide-types.d.ts +61 -16
  19. package/dist/src/services/ide/resource-profile.d.ts +52 -0
  20. package/dist/src/services/ide/resource-profile.js +33 -0
  21. package/dist/src/services/memory/project-context-service.js +2 -1
  22. package/dist/src/services/memory/project-memory-service.js +4 -3
  23. package/dist/src/services/perf/perf-baseline-service.js +2 -1
  24. package/dist/src/services/progress/progress-service.d.ts +23 -103
  25. package/dist/src/services/progress/progress-service.js +24 -137
  26. package/dist/src/services/scan/file-size-scan.d.ts +4 -0
  27. package/dist/src/services/scan/file-size-scan.js +32 -3
  28. package/dist/src/services/session/getSessionDir.d.ts +1 -0
  29. package/dist/src/services/session/getSessionDir.js +27 -0
  30. package/dist/src/services/session/index.d.ts +1 -0
  31. package/dist/src/services/session/index.js +1 -0
  32. package/dist/src/services/skills/hooks-settings-service.d.ts +57 -5
  33. package/dist/src/services/skills/hooks-settings-service.js +153 -28
  34. package/dist/src/services/standards/ide-aware-standards-service.d.ts +94 -0
  35. package/dist/src/services/standards/ide-aware-standards-service.js +89 -0
  36. package/dist/src/services/standards/project-standards-service.d.ts +1 -2
  37. package/dist/src/shared/incrementing-number.d.ts +0 -8
  38. package/dist/src/shared/incrementing-number.js +11 -1
  39. package/dist/src/shared/version.d.ts +1 -1
  40. package/dist/src/shared/version.js +1 -1
  41. package/package.json +1 -1
  42. package/scripts/install-skills.mjs +112 -2
  43. package/skills/peaks-ide/SKILL.md +1 -1
  44. package/skills/peaks-ide/references/audit-log-helper.md +52 -0
  45. package/skills/peaks-qa/SKILL.md +104 -62
  46. package/skills/peaks-qa/references/qa-fanout-contract.md +6 -6
  47. package/skills/peaks-rd/SKILL.md +88 -73
  48. package/skills/peaks-solo/SKILL.md +52 -22
  49. package/skills/peaks-solo/references/browser-workflow.md +22 -20
  50. package/skills/peaks-solo/references/runbook.md +21 -21
  51. package/skills/peaks-solo/references/sub-agent-dispatch.md +44 -1
  52. package/skills/peaks-solo/references/swarm-dispatch-contract.md +9 -9
  53. package/skills/peaks-ui/SKILL.md +18 -9
  54. package/dist/src/cli/commands/progress-close-kill.d.ts +0 -51
  55. package/dist/src/cli/commands/progress-close-kill.js +0 -152
  56. package/dist/src/cli/commands/progress-commands.d.ts +0 -3
  57. package/dist/src/cli/commands/progress-commands.js +0 -379
  58. package/dist/src/cli/commands/progress-start-spawn.d.ts +0 -59
  59. package/dist/src/cli/commands/progress-start-spawn.js +0 -140
  60. package/dist/src/cli/commands/progress-watch-render.d.ts +0 -80
  61. package/dist/src/cli/commands/progress-watch-render.js +0 -308
@@ -3,6 +3,36 @@ name: peaks-solo
3
3
  description: Full-auto orchestration facade for the Peaks-Cli skill family. Use when the user asks Peaks-Cli 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
+ ## Two-axis naming convention
7
+
8
+ > **Read once at the top of this file; the rest of the skill is written against it.**
9
+
10
+ The `.peaks/` workspace is partitioned by **two orthogonal axes**. Every path in this SKILL.md uses one of them; mixing them is the original `.peaks/<sid>/` / `.peaks/_runtime/<sid>/` bug class this slice corrects.
11
+
12
+ | Axis | Path root | Holds | When to use |
13
+ |---|---|---|---|
14
+ | **change-id axis** (reviewable artifacts) | `.peaks/<changeId>/...` | PRD, RD plan, code-review, security-review, test-cases, handoff capsules, gate targets | The artifact should be reviewable on its own and survives across sessions for the same change. Change-id is the unit of work. |
15
+ | **session-id axis** (ephemeral state) | `.peaks/_runtime/<sessionId>/...` | Session bindings (`.peaks/_runtime/session.json`), live in-flight state, the per-session project-scan and tech-doc scaffold while the session is open | The artifact is session-scoped and only meaningful while the parent session is live. |
16
+ | **sub-agent axis** | `.peaks/_sub_agents/<sessionId>/...` | Sub-agent dispatch records, sub-agent heartbeats, per-sub-agent shared channel entries, sub-agent artifact outputs | A sub-agent ran in a parent session. The axis nests under the parent session-id; sub-agent outputs are flushed into the change-id root on commit. |
17
+
18
+ **Which CLI commands operate on which axis:**
19
+
20
+ - **change-id axis** (reviewable artifacts): `peaks request init`, `peaks request transition`, `peaks request show`, `peaks request lint`, `peaks request repair-status`, `peaks scan diff-vs-scope`, `peaks scan acceptance-coverage`. Inputs reference `.peaks/<changeId>/...`.
21
+ - **session-id axis** (ephemeral state): `peaks session info`, `peaks session start`, `peaks session finish`, `peaks session list`. Reads/writes `.peaks/_runtime/<sessionId>/session.json`.
22
+ - **sub-agent axis** (under parent session-id): `peaks sub-agent dispatch`, `peaks sub-agent heartbeat`, `peaks sub-agent share`, `peaks sub-agent shared-read`. All output paths are under `.peaks/_sub_agents/<sessionId>/...`.
23
+
24
+ **Placeholder convention used in this file:**
25
+
26
+ - `<changeId>` / `<change-id>` — the change-id axis. Use when describing a path that lives at `.peaks/<changeId>/...` (root-level, NOT inside `_runtime/`).
27
+ - `<sessionId>` / `<session-id>` — the session-id axis. Use when describing a path that lives at `.peaks/_runtime/<sessionId>/...` or `.peaks/_sub_agents/<sessionId>/...`. The long form `<session-id>` is used inside bash / shell examples where `<sessionId>` would break parsing.
28
+ - The bare `<sid>` placeholder is **forbidden** in new content — it is ambiguous between the two axes. Legacy occurrences are replaced by this convention; new content must use the right axis label.
29
+
30
+ **Cross-references:**
31
+
32
+ - Slice `2026-06-05-change-id-as-unit-of-work` (commits `48958fc` + `928eb53`) — established the change-id axis as the canonical root for reviewable artifacts (`src/shared/change-id.ts:131,335`, `src/services/scan/acceptance-coverage-service.ts:155`).
33
+ - Slice `005-session-runtime-dir-regression` (commit `178a47e`) — added the `getSessionDir()` resolver at `src/services/session/getSessionDir.ts` and routed 4 stragglers that were constructing `.peaks/${sessionId}` (no `_runtime/`) through the canonical resolver. Defense-in-depth scan: `tests/unit/services/session/session-dir-canonical.test.ts`.
34
+ - Slice `006-5th-writer-changeid-path` (this slice) — disambiguates the SKILL.md placeholders and adds the regression test `tests/unit/skills/skills-skill-md-naming.test.ts` that mechanically enforces (a) zero bare `<sid>`, (b) every `.peaks/<X>/` reference has an axis label, (c) the "Two-axis naming convention" callout is present in `peaks-solo`, `peaks-rd`, `peaks-qa`.
35
+
6
36
  # Peaks-Cli Solo
7
37
 
8
38
  Peaks-Cli Solo is the orchestration facade for the Peaks-Cli short skill family.
@@ -192,7 +222,7 @@ done
192
222
  **Strict quality guarantee (per user's hard rule: "严格要保证不能比当前的效果差")**:
193
223
  - 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.
194
224
  - 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).
195
- - 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/<sid>/` path fallback, and (f) determinism across two invocations on the same fixture.
225
+ - 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.
196
226
 
197
227
  ### Peaks-Cli Step 1: Mode selection
198
228
 
@@ -294,7 +324,7 @@ Use the Peaks-Cli CLI for runtime side effects.
294
324
 
295
325
  Map gstack stages to Peaks-Cli role artifacts; preserve Peaks-Cli confirmation gates. Do not delegate orchestration to gstack commands.
296
326
 
297
- For frontend workflows, RD and QA must use Playwright MCP (`mcp__playwright__` tool namespace) for real browser E2E (`peaks mcp plan/apply --capability playwright-mcp.browser-validation --yes`). 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`.
327
+ For frontend workflows, RD and QA must use Playwright MCP for real browser E2E. The skill body never bakes in the `mcp__playwright__` prefix; it uses the peaks mcp plan/apply/call pattern (`peaks mcp plan --capability playwright-mcp.browser-validation --json` then `peaks mcp apply --capability playwright-mcp.browser-validation --yes --json` then `peaks mcp call --capability playwright-mcp.browser-validation --tool <toolName> --args-json '<args>' --json`). 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`.
298
328
 
299
329
  ## Peaks-Cli Local intermediate artifact workspace (MANDATORY)
300
330
 
@@ -326,7 +356,7 @@ The workspace initialization creates this structure under `.peaks/`:
326
356
 
327
357
  # Per-slice artifact dirs (auto-generated, one per session). Files
328
358
  # inside ARE tracked by the 提交中间产物 convention.
329
- .peaks/<session-id>/
359
+ .peaks/_runtime/<sessionId>/
330
360
  prd/source/ # PRD source documents (Feishu exports, pasted content)
331
361
  prd/requests/ # PRD request artifacts (goals, non-goals, acceptance, frontend delta)
332
362
  ui/requests/ # UI request artifacts (visual direction, taste reports)
@@ -364,7 +394,7 @@ Files written into these directories during the workflow (not pre-created — th
364
394
 
365
395
  Legitimate source files (e.g. `jest-setup.ts`, `tailwind.config.js`) belong at root — do not move them.
366
396
 
367
- 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.
397
+ 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.
368
398
 
369
399
  ### Git and sync policy
370
400
 
@@ -372,7 +402,7 @@ Do not default to git-backed storage or automatic commits for intermediate artif
372
402
 
373
403
  ## Peaks-Cli Pre-RD project scan checklist (MANDATORY)
374
404
 
375
- Before handing off to `peaks-rd`, scan the project and record findings to `.peaks/<session-id>/rd/project-scan.md`. RD and UI roles read this before starting work. **project-scan.md is a session-scoped singleton** — check if it already exists before regenerating (e.g. via `ls .peaks/<session-id>/rd/project-scan.md`). If it exists and is complete (has `## Archetype` and `## Project mode` sections), reuse it. Only regenerate if missing or incomplete.
405
+ Before handing off to `peaks-rd`, scan the project and record findings to `.peaks/_runtime/<sessionId>/rd/project-scan.md`. RD and UI roles read this before starting work. **project-scan.md is a session-scoped singleton** — check if it already exists before regenerating (e.g. via `ls .peaks/_runtime/<sessionId>/rd/project-scan.md`). If it exists and is complete (has `## Archetype` and `## Project mode` sections), reuse it. Only regenerate if missing or incomplete.
376
406
 
377
407
  ### 0. Project archetype detection (MANDATORY — run FIRST, deterministic CLI)
378
408
 
@@ -522,7 +552,7 @@ When there is no conflict, do not ask — the CLI value wins and the workflow pr
522
552
 
523
553
  ### Mock data strategy selection
524
554
 
525
- 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:
555
+ Solo records the chosen mock strategy in `.peaks/_runtime/<sessionId>/rd/tech-doc.md` under a `## Mock Data Strategy` section. The choice depends on the project scan results:
526
556
 
527
557
  | Project data-fetching pattern | Recommended mock approach | Rationale |
528
558
  |---|---|---|
@@ -541,7 +571,7 @@ Solo records the chosen mock strategy in `.peaks/<session-id>/rd/tech-doc.md` un
541
571
  2. Mock data should be realistic (not `"test"`, `"foo"`, `123`) — use plausible Chinese/English content that resembles production data.
542
572
  3. Each mock must export its TypeScript interface so RD implementation and QA test-cases can import the same types.
543
573
  4. Mark every mock file with a header comment: `// MOCK: Replace with real API call when swagger.json is available`.
544
- 5. Before producing any mock file, register the plan in `.peaks/<session-id>/rd/mock-plan.md` with: chosen strategy (from the table above), planned file paths, and a one-line rationale per file. This file is the source of truth for mock locations across runs — RD must read it before writing code, QA must read it before writing test cases.
574
+ 5. Before producing any mock file, register the plan in `.peaks/_runtime/<sessionId>/rd/mock-plan.md` with: chosen strategy (from the table above), planned file paths, and a one-line rationale per file. This file is the source of truth for mock locations across runs — RD must read it before writing code, QA must read it before writing test cases.
545
575
 
546
576
  ### API contract placeholder pattern
547
577
 
@@ -572,7 +602,7 @@ When the PRD source is a Feishu/Lark document that requires authentication:
572
602
 
573
603
  1. **Primary path**: Playwright MCP headed browser → user completes login → Solo reads document content via `browser_snapshot`.
574
604
  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.
575
- 3. **Fallback B (user provides export)**: User drops a `.md` or `.pdf` export into `.peaks/<session-id>/prd/source/`. Solo reads and processes it.
605
+ 3. **Fallback B (user provides export)**: User drops a `.md` or `.pdf` export into `.peaks/_runtime/<sessionId>/prd/source/`. Solo reads and processes it.
576
606
  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.
577
607
 
578
608
  Never silently fall back to unauthenticated `fetch` or `WebFetch` for authenticated documents.
@@ -595,11 +625,11 @@ Before launching any sub-agent, Solo must compute the **swarm plan** from three
595
625
  - `feature` / `refactor` / `bugfix` → RD(planning) and QA(test-cases) are always in the swarm
596
626
  - `config` / `docs` / `chore` → no swarm. RD/QA artefacts are not required by Gates B/C/D for these types. Skip the Swarm phase entirely and proceed to step 4 (RD implementation) with only the PRD in hand.
597
627
  3. **Frontend touch** — does the request affect user-visible behavior? This is decided by:
598
- - Reading `.peaks/<session-id>/rd/project-scan.md` `## Project mode` for `frontendOnly` (project-shape signal)
628
+ - Reading `.peaks/_runtime/<sessionId>/rd/project-scan.md` `## Project mode` for `frontendOnly` (project-shape signal)
599
629
  - **AND** scanning the PRD body for frontend keywords: 页面 / 组件 / 表单 / 弹窗 / 表格 / 样式 / 布局 / 交互 / UI / UX / page / component / form / modal / table / styling / layout / interaction
600
630
  - UI joins the swarm when (a) is `true` OR (b) matches. Both signals required `false` to skip UI.
601
631
 
602
- Solo records the swarm plan in `.peaks/<session-id>/sc/swarm-plan.json` so SC and TXT can audit what was launched:
632
+ Solo records the swarm plan in `.peaks/_runtime/<sessionId>/sc/swarm-plan.json` so SC and TXT can audit what was launched:
603
633
 
604
634
  ```json
605
635
  {
@@ -633,13 +663,13 @@ Each sub-agent dispatch call looks like:
633
663
  ```
634
664
  peaks sub-agent dispatch <role> \
635
665
  --prompt "<paste peaks-<role>/SKILL.md body, minus the self-presence / Step 0 blocks,
636
- plus the runtime arguments: project=<repo>, session-id=<sid>, request-id=<rid>, mode=<mode>,
666
+ plus the runtime arguments: project=<repo>, session-id=<session-id>, request-id=<rid>, mode=<mode>,
637
667
  plus the explicit output contract: 'Write your artefacts to the paths listed below and
638
668
  return only the list of paths. Do not call Skill(...). Do not set presence. Do not
639
669
  hand back prose.', plus the heartbeat instruction: 'While running, call
640
670
  peaks sub-agent heartbeat --record <dispatchRecordPath> --status <state> --progress <pct> --note \"<text>\"
641
671
  at least every 30 seconds.'>" \
642
- --request-id <rid> --session-id <sid> --project <repo> --json
672
+ --request-id <rid> --session-id <session-id> --project <repo> --json
643
673
  ```
644
674
 
645
675
  Then the LLM takes `data.toolCall` from the envelope (a `{name, args}` descriptor), looks up the tool by `name` in its environment, and invokes it with `args` — IDE-private, no SKILL.md hardcoding.
@@ -648,16 +678,16 @@ The role's required artefact paths (also see peaks-ui/rd/qa SKILL.md and `refere
648
678
 
649
679
  | Role | Writes | Reads (PRD-side) |
650
680
  |---|---|---|
651
- | `ui` | `.peaks/<sid>/ui/design-draft.md`, `.peaks/<sid>/ui/requests/<rid>.md` | PRD body, project-scan, archetype |
652
- | `rd-planning` | `.peaks/<sid>/rd/tech-doc.md` (feature/refactor) or `.peaks/<sid>/rd/bug-analysis.md` (bugfix) | PRD body, project-scan, existing-system, codegraph |
653
- | `qa-test-cases` | `.peaks/<sid>/qa/test-cases/<rid>.md` | PRD body, RD planning artefact, project-scan, codegraph |
681
+ | `ui` | `.peaks/_runtime/<sessionId>/ui/design-draft.md`, `.peaks/_runtime/<sessionId>/ui/requests/<rid>.md` | PRD body, project-scan, archetype |
682
+ | `rd-planning` | `.peaks/_runtime/<sessionId>/rd/tech-doc.md` (feature/refactor) or `.peaks/_runtime/<sessionId>/rd/bug-analysis.md` (bugfix) | PRD body, project-scan, existing-system, codegraph |
683
+ | `qa-test-cases` | `.peaks/_runtime/<sessionId>/qa/test-cases/<rid>.md` | PRD body, RD planning artefact, project-scan, codegraph |
654
684
 
655
685
  **Solo launches all sub-agents in the swarm plan in a single message (multiple `peaks sub-agent dispatch` calls in parallel, each followed by execution of the returned toolCall)** — this is what gives real concurrency. Do not sequentialize them. The CLI returns N toolCall descriptors; the LLM fires all N in the same message; the IDE dispatches them concurrently; Solo then waits for all to return, runs `ls` checks against the paths above (Peaks-Cli Gate B), and only then advances to RD implementation.
656
686
 
657
687
  **Hard prohibitions on sub-agents** (also passed in each dispatch prompt):
658
688
 
659
689
  - Do NOT call `Skill(skill="...")` — sub-agents must not recursively activate skills, that defeats the fan-out.
660
- - Do NOT call `peaks skill presence:set` — only the main Solo loop owns `.peaks/.active-skill.json`. Sub-agents write to a per-agent marker file `.peaks/<sid>/system/sub-agent-<role>.json` if they need to record state, but never the main presence file.
690
+ - Do NOT call `peaks skill presence:set` — only the main Solo loop owns `.peaks/.active-skill.json`. Sub-agents write to a per-agent marker file `.peaks/_runtime/<sessionId>/system/sub-agent-<role>.json` if they need to record state, but never the main presence file.
661
691
  - Do NOT open interactive user prompts. If a sub-agent needs clarification, it must return a `blocked` verdict in its return string and let Solo handle the user message.
662
692
  - Do NOT commit, push, install hooks, or apply settings.json mutations. Only Solo holds those permissions.
663
693
  - **Do write heartbeats** — call `peaks sub-agent heartbeat --record <dispatchRecordPath> --status running --progress <pct> --note "<text>"` at least every 30s (see `references/sub-agent-dispatch.md` §G6 for the full contract). The parent Dispatcher uses these to render the live status line during the wait.
@@ -684,7 +714,7 @@ Skipping the entire swarm (when `--type` is `config|docs|chore`) is not a degrad
684
714
 
685
715
  Before computing the swarm plan, Solo runs the keyword scan deterministically:
686
716
 
687
- 1. Read `.peaks/<session-id>/prd/requests/<rid>.md` body.
717
+ 1. Read `.peaks/_runtime/<sessionId>/prd/requests/<rid>.md` body.
688
718
  2. Lowercase + strip markdown; check regex `\b(页面|组件|表单|弹窗|表格|样式|布局|交互|UI|UX|page|component|form|modal|table|styling|layout|interaction|frontend|前端)\b`.
689
719
  3. If match count ≥ 1 → `frontendKeywordHit=true`.
690
720
  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).
@@ -782,9 +812,9 @@ Before orchestrating an end-to-end code repository workflow, gather the project
782
812
 
783
813
  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.
784
814
 
785
- **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.
815
+ **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.
786
816
 
787
- **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/<id>/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.
817
+ **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.
788
818
 
789
819
  Do not hand-write standards file mutations inside the skill.
790
820
 
@@ -811,7 +841,7 @@ It must enforce the shared refactor red lines:
811
841
  4. split broad refactors into minimal functional slices;
812
842
  5. require strict verifiable specs before each slice;
813
843
  6. require 100% acceptance for each slice;
814
- 7. require code changes and sanitized intermediate artifacts to be traceable in local `.peaks/<session-id>/` storage before the next slice; commit or sync sanitized artifacts only when explicitly authorized.
844
+ 7. require code changes and sanitized intermediate artifacts to be traceable in local `.peaks/_runtime/<sessionId>/` storage before the next slice; commit or sync sanitized artifacts only when explicitly authorized.
815
845
 
816
846
  ## Peaks-Cli Quality-gate commands (CLI cheat sheet)
817
847
 
@@ -868,7 +898,7 @@ Detailed rules: `references/external-skill-invocation.md`, `references/openspec-
868
898
 
869
899
  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.
870
900
 
871
- - Sub-agent writes artifact to disk at a known path (path convention: `.peaks/_sub_agents/<sid>/artifacts/<rid>-<role>-<idx>.<ext>`).
901
+ - Sub-agent writes artifact to disk at a known path (path convention: `.peaks/_sub_agents/<sessionId>/artifacts/<rid>-<role>-<idx>.<ext>`).
872
902
  - Sub-agent calls `peaks sub-agent dispatch --write-artifact <path>` (or via dispatch CLI flag). The CLI computes sha256 + size + writes `ArtifactMeta` to record.
873
903
  - 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.
874
904
  - Main LLM decides whether to `Read <path>` for full content (LLM tool call, NOT via peaks CLI).
@@ -892,7 +922,7 @@ If a sub-agent prompt is too large even after G7 metadata-only (e.g. 1MB artifac
892
922
 
893
923
  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.
894
924
 
895
- - Path: `.peaks/_sub_agents/<sid>/shared/<batchId>.json`.
925
+ - Path: `.peaks/_sub_agents/<sessionId>/shared/<batchId>.json`.
896
926
  - Two new CLI atoms (NO new top-level CLI): `peaks sub-agent share` + `peaks sub-agent shared-read`.
897
927
  - 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>`.
898
928
 
@@ -33,7 +33,7 @@ peaks mcp apply --capability playwright-mcp.browser-validation --yes --json
33
33
 
34
34
  If a non-peaks-managed Playwright MCP entry already exists in `.claude/settings.json`, `apply` will refuse unless `--claim` is passed. Discuss with the user before claiming.
35
35
 
36
- After install, Claude Code's MCP runtime exposes the tools under the `mcp__playwright__*` namespace. Peaks skills reference these tools directly; they are not invoked through `peaks mcp call` because Claude Code is the host that calls them.
36
+ After install, Claude Code's MCP runtime exposes the tools under the `mcp__playwright__*` namespace. Peaks skill bodies reference these tools via the `peaks mcp call` primitive (the skill body never bakes in the `mcp__playwright__` prefix; the prefix is owned by Claude Code's runtime, and `peaks mcp call` is the load-bearing fallback for sub-agents and non-Claude IDEs). The 4-step plan apply → call pattern is the contract.
37
37
 
38
38
  ## Optional: install Chrome DevTools MCP for CDP inspection
39
39
 
@@ -44,38 +44,40 @@ peaks mcp plan --capability chrome-devtools-mcp.browser-debug --json
44
44
  peaks mcp apply --capability chrome-devtools-mcp.browser-debug --yes --json
45
45
  ```
46
46
 
47
- Tools become available under `mcp__chrome-devtools__*`. They fail with "Could not connect to Chrome" if no Chrome is running on `:9222`; that is by design.
47
+ Tools become available under `mcp__chrome-devtools__*` in the LLM runtime. Peaks skill bodies invoke them via `peaks mcp call --capability chrome-devtools-mcp.browser-debug --tool <name> --args-json '<args>' --json` (the skill body never bakes in the `mcp__chrome-devtools__` prefix). They fail with "Could not connect to Chrome" if no Chrome is running on `:9222`; that is by design.
48
48
 
49
49
  ## Tool mapping for the "open a browser on demand" path (Playwright MCP)
50
50
 
51
- | Verb | Playwright MCP tool | Notes |
51
+ | Verb | peaks mcp call invocation | Notes |
52
52
  |---|---|---|
53
- | Open visible browser and navigate | `mcp__playwright__browser_navigate` with `url` | Spawns a headed browser if none open; navigates in the existing context otherwise. |
54
- | Confirm visible browser opened | `mcp__playwright__browser_take_screenshot` | Screenshot is the visible-browser confirmation. |
55
- | Read structured page (text + a11y) | `mcp__playwright__browser_snapshot` | Accessibility tree with element refs. |
56
- | Click / fill / press key | `mcp__playwright__browser_click`, `browser_fill`, `browser_press_key` | Drive the page after navigation. |
57
- | Inspect console errors | `mcp__playwright__browser_console_messages` | Pass `level` to filter (`error`, `warning`). |
58
- | Inspect network failures | `mcp__playwright__browser_network_requests` | Pass `filter` regex when the page has many requests. |
59
- | Resize viewport for responsive checks | `mcp__playwright__browser_resize` | |
60
- | Capture a full-page screenshot | `mcp__playwright__browser_take_screenshot` with `fullPage: true` | Sanitize before retention. |
61
- | Close the session cleanly | `mcp__playwright__browser_close` | End-of-task. |
53
+ | Open visible browser and navigate | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_navigate --args-json '{"url":"<url>"}' --json` | Spawns a headed browser if none open; navigates in the existing context otherwise. |
54
+ | Confirm visible browser opened | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_take_screenshot --args-json '{"filename":"<abs-path>"}' --json` | Screenshot is the visible-browser confirmation. |
55
+ | Read structured page (text + a11y) | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_snapshot --args-json '{}' --json` | Accessibility tree with element refs. |
56
+ | Click / fill / press key | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_click --args-json '<args>' --json` (and `browser_fill`, `browser_press_key`) | Drive the page after navigation. |
57
+ | Inspect console errors | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_console_messages --args-json '{"level":"error"}' --json` | Pass `level` to filter (`error`, `warning`). |
58
+ | Inspect network failures | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_network_requests --args-json '{"filter":"<regex>"}' --json` | Pass `filter` regex when the page has many requests. |
59
+ | Resize viewport for responsive checks | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_resize --args-json '<args>' --json` | |
60
+ | Capture a full-page screenshot | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_take_screenshot --args-json '{"filename":"<abs-path>","fullPage":true}' --json` | Sanitize before retention. |
61
+ | Close the session cleanly | `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_close --args-json '{}' --json` | End-of-task. |
62
+ | **Reference (runtime prefix, do not bake into skills)** | `mcp__playwright__<toolName>` | The Claude Code runtime prefix; the LLM resolves this from the registered server. The skill body uses `peaks mcp call` exclusively. |
62
63
 
63
64
  ## Tool mapping for the "connect to running Chrome" path (Chrome DevTools MCP, optional)
64
65
 
65
- | Verb | Chrome DevTools MCP tool | Notes |
66
+ | Verb | peaks mcp call invocation | Notes |
66
67
  |---|---|---|
67
- | List pages in user's Chrome | `mcp__chrome-devtools__list_pages` | Requires Chrome already running with `--remote-debugging-port=9222`. |
68
- | Bring a tab to front | `mcp__chrome-devtools__select_page` with `bringToFront: true` | Useful when the user navigated themselves. |
69
- | Screenshot the visible viewport | `mcp__chrome-devtools__take_screenshot` | |
70
- | Read structured page | `mcp__chrome-devtools__take_snapshot` | |
71
- | Performance trace | `mcp__chrome-devtools__performance_start_trace` then `performance_stop_trace` | |
72
- | Lighthouse audit | `mcp__chrome-devtools__lighthouse_audit` with `mode: snapshot` | |
68
+ | List pages in user's Chrome | `peaks mcp call --capability chrome-devtools-mcp.browser-debug --tool list_pages --args-json '{}' --json` | Requires Chrome already running with `--remote-debugging-port=9222`. |
69
+ | Bring a tab to front | `peaks mcp call --capability chrome-devtools-mcp.browser-debug --tool select_page --args-json '{"bringToFront":true}' --json` | Useful when the user navigated themselves. |
70
+ | Screenshot the visible viewport | `peaks mcp call --capability chrome-devtools-mcp.browser-debug --tool take_screenshot --args-json '<args>' --json` | |
71
+ | Read structured page | `peaks mcp call --capability chrome-devtools-mcp.browser-debug --tool take_snapshot --args-json '{}' --json` | |
72
+ | Performance trace | `peaks mcp call --capability chrome-devtools-mcp.browser-debug --tool performance_start_trace --args-json '<args>' --json` then `performance_stop_trace` (each via `peaks mcp call`) | |
73
+ | Lighthouse audit | `peaks mcp call --capability chrome-devtools-mcp.browser-debug --tool lighthouse_audit --args-json '{"mode":"snapshot"}' --json` | |
74
+ | **Reference (runtime prefix, do not bake into skills)** | `mcp__chrome-devtools__<toolName>` | The Claude Code runtime prefix; the LLM resolves this from the registered server. The skill body uses `peaks mcp call` exclusively. |
73
75
 
74
76
  If Chrome is not running on `:9222`, every Chrome DevTools MCP tool fails. The skill must surface that as a blocked precondition, not silently fall back.
75
77
 
76
78
  ## URL allow-list (always required before navigation)
77
79
 
78
- Before calling `mcp__playwright__browser_navigate` (or any other navigation), verify:
80
+ Before calling `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_navigate --args-json '{"url":"<url>"}' --json` (or any other navigation), verify:
79
81
 
80
82
  1. URL uses `https:` (reject `http:`, `file:`, `data:`, `javascript:`).
81
83
  2. Host belongs to an approved domain for the role (Feishu/Lark tenant for PRD product docs, the user-approved app target for UI/QA validation).
@@ -20,12 +20,12 @@ peaks skill runbook peaks-solo --json
20
20
  peaks workspace init --project <repo> --json
21
21
  peaks workspace reconcile --project <repo> --json
22
22
  peaks scan archetype --project <repo> --json
23
- # → copy archetype, frontendOnly, signals into .peaks/<session-id>/rd/project-scan.md (Peaks-Cli Gate A)
24
- # → copy libraries[] into .peaks/<session-id>/rd/project-scan.md under `## Library versions`
23
+ # → copy archetype, frontendOnly, signals into .peaks/_runtime/<session-id>/rd/project-scan.md (Peaks-Cli Gate A)
24
+ # → copy libraries[] into .peaks/_runtime/<session-id>/rd/project-scan.md under `## Library versions`
25
25
  peaks scan libraries --project <repo> --json
26
26
  # → if archetype != greenfield AND archetype != unknown:
27
27
  peaks scan existing-system --project <repo> --json
28
- # → copy tokens, sources, conventions, inconsistencies into .peaks/<session-id>/system/existing-system.md (Peaks-Cli Gate A.5)
28
+ # → copy tokens, sources, conventions, inconsistencies into .peaks/_runtime/<session-id>/system/existing-system.md (Peaks-Cli Gate A.5)
29
29
 
30
30
  # 1. Peaks-Cli Standards preflight + apply
31
31
  # Run dry-run first to inspect deltas, then APPLY. In full-auto and swarm modes,
@@ -55,7 +55,7 @@ peaks request transition <rid> --role prd --state handed-off --project <repo> --
55
55
 
56
56
  # 3. Peaks-Cli Swarm parallel — sub-agent fan-out (peaks sub-agent dispatch, NOT Skill tool)
57
57
  # Solo computes the swarm plan from --type + frontendOnly + frontend-keyword scan,
58
- # writes it to .peaks/<sid>/sc/swarm-plan.json, then launches one
58
+ # writes it to .peaks/_runtime/<sid>/sc/swarm-plan.json, then launches one
59
59
  # `peaks sub-agent dispatch <role>` call per sub-agent in the same message.
60
60
  # See "Peaks-Cli Swarm parallel phase" above for the full decision table and the
61
61
  # prompt template; the role's required artefact paths are listed there.
@@ -80,36 +80,36 @@ peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-
80
80
  # Step 0 / presence, plus the runtime args (rid / sid / mode / type / paths).
81
81
  # 3c. After fan-out, Solo restores presence once and runs Gate B (ls checks):
82
82
  peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-converged
83
- ls .peaks/<sid>/prd/requests/<rid>.md # PRD artefact must exist (Gate B hard)
84
- # feature / refactor → ls .peaks/<sid>/rd/tech-doc.md
85
- # bugfix → ls .peaks/<sid>/rd/bug-analysis.md
86
- ls .peaks/<sid>/qa/test-cases/<rid>.md # QA test-cases (skipped for docs|chore)
83
+ ls .peaks/_runtime/<sid>/prd/requests/<rid>.md # PRD artefact must exist (Gate B hard)
84
+ # feature / refactor → ls .peaks/_runtime/<sid>/rd/tech-doc.md
85
+ # bugfix → ls .peaks/_runtime/<sid>/rd/bug-analysis.md
86
+ ls .peaks/_runtime/<sid>/qa/test-cases/<rid>.md # QA test-cases (skipped for docs|chore)
87
87
  # ui (only when in plan):
88
- ls .peaks/<sid>/ui/design-draft.md 2>&1 # non-blocking (Gate B info)
88
+ ls .peaks/_runtime/<sid>/ui/design-draft.md 2>&1 # non-blocking (Gate B info)
89
89
  # Apply the degradation rules in the main SKILL.md if any artefact is missing.
90
90
  # → Peaks-Cli Gate B convergence check. Assisted/Strict: [CONFIRM]
91
91
 
92
92
  # 4. Peaks-Cli RD planning artifact (the file required by the prerequisite gate)
93
- # feature / refactor → write .peaks/<id>/rd/tech-doc.md
94
- # bugfix → write .peaks/<id>/rd/bug-analysis.md
93
+ # feature / refactor → write .peaks/_runtime/<id>/rd/tech-doc.md
94
+ # bugfix → write .peaks/_runtime/<id>/rd/bug-analysis.md
95
95
  # config → no planning artifact required at this state
96
96
  # docs / chore → no planning artifact required
97
97
  peaks request transition <rid> --role rd --state implemented --project <repo> --json
98
98
 
99
99
  # 5. Peaks-Cli Code review + security review BEFORE qa-handoff transition.
100
100
  # Produce the evidence files the CLI gate enforces:
101
- # - .peaks/<id>/rd/code-review.md (CRITICAL/HIGH findings + fixes; required for feature/bugfix/refactor)
102
- # - .peaks/<id>/rd/security-review.md (required for feature/bugfix/refactor/config)
101
+ # - .peaks/_runtime/<id>/rd/code-review.md (CRITICAL/HIGH findings + fixes; required for feature/bugfix/refactor)
102
+ # - .peaks/_runtime/<id>/rd/security-review.md (required for feature/bugfix/refactor/config)
103
103
  # Then transition. If --type is docs/chore the gate is empty and the transition is unguarded.
104
104
  peaks request transition <rid> --role rd --state qa-handoff --project <repo> --json
105
105
 
106
106
  # 6. Peaks-Cli QA validation (AUTO-PROCEED from RD in full-auto)
107
107
  # Before each QA transition, produce the evidence files the CLI gate enforces:
108
- # Before qa:running → .peaks/<id>/qa/test-cases/<rid>.md
108
+ # Before qa:running → .peaks/_runtime/<id>/qa/test-cases/<rid>.md
109
109
  peaks request transition <rid> --role qa --state running --project <repo> --json
110
- # Before qa:verdict-issued → .peaks/<id>/qa/test-reports/<rid>.md
111
- # + .peaks/<id>/qa/security-findings.md
112
- # + .peaks/<id>/qa/performance-findings.md (feature/refactor only)
110
+ # Before qa:verdict-issued → .peaks/_runtime/<id>/qa/test-reports/<rid>.md
111
+ # + .peaks/_runtime/<id>/qa/security-findings.md
112
+ # + .peaks/_runtime/<id>/qa/performance-findings.md (feature/refactor only)
113
113
  peaks request transition <rid> --role qa --state verdict-issued --project <repo> --json
114
114
  # → Peaks-Cli Gate D check. Assisted/Strict: [CONFIRM]
115
115
 
@@ -135,12 +135,12 @@ peaks openspec archive <cid> --project <repo> --apply --json
135
135
  peaks workspace reconcile --project <repo> --apply --older-than 7
136
136
 
137
137
  # 10. Peaks-Cli TXT handoff — invoke peaks-txt which embeds memory markers and extracts
138
- # peaks-txt writes the handoff capsule to .peaks/<id>/txt/handoff.md. Inside the
138
+ # peaks-txt writes the handoff capsule to .peaks/_runtime/<id>/txt/handoff.md. Inside the
139
139
  # capsule body, peaks-txt embeds <!-- peaks-memory:start --> blocks for every
140
140
  # stable project fact surfaced this session.
141
141
  #
142
142
  # 10a. Skill-side scan (do this BEFORE the AskUserQuestion below):
143
- # grep -n "peaks-memory:start" .peaks/<id>/txt/handoff.md
143
+ # grep -n "peaks-memory:start" .peaks/_runtime/<id>/txt/handoff.md
144
144
  # Record the count. This is the skill doing the work, not a CLI command —
145
145
  # we deliberately do not ship a `peaks memory scan` because the LLM is
146
146
  # the only consumer and the LLM has grep.
@@ -148,7 +148,7 @@ peaks workspace reconcile --project <repo> --apply --older-than 7
148
148
  # 10b. AskUserQuestion (only if 10a returned count >= 1):
149
149
  # "The TXT handoff has N peaks-memory:start blocks. Persist to .peaks/memory/?
150
150
  # (a) Apply all — `peaks memory extract --project <repo>
151
- # --artifact .peaks/<id>/txt/handoff.md --apply --json`
151
+ # --artifact .peaks/_runtime/<id>/txt/handoff.md --apply --json`
152
152
  # (b) Apply selectively — re-edit handoff.md first, then re-apply
153
153
  # (c) Skip for now — blocks stay in the handoff only, no .peaks/memory/ write"
154
154
  # If 10a returned 0 AND the session surfaced a stable project fact
@@ -156,7 +156,7 @@ peaks workspace reconcile --project <repo> --apply --older-than 7
156
156
  # back and embed at least one block before Solo can advance.
157
157
 
158
158
  # 10c. After the user picks (a) or (b), run:
159
- peaks memory extract --project <repo> --artifact .peaks/<id>/txt/handoff.md --apply --json
159
+ peaks memory extract --project <repo> --artifact .peaks/_runtime/<id>/txt/handoff.md --apply --json
160
160
  # --apply is REQUIRED to write .peaks/memory/; without it the command only
161
161
  # previews. The extract regenerates index.json in the same call.
162
162
 
@@ -127,7 +127,7 @@ system is dead. G6 is the rule that says: **no**.
127
127
  | **Dispatcher reads** | peaks-solo main loop, during the batch-sync wait | In-process async poller (`BatchHeartbeatPoller`) reads `heartbeats[]` + `lastBeatAt` from each record, emits a single-line status per G6.5 | 10 s (offset from 30 s to avoid jitter) |
128
128
  | **User / CLI reads** | Anyone, anytime | `peaks sub-agent list --session-id <sid> --json` (G5 RL-10, future slice) | manual |
129
129
 
130
- ### Sub-agent prompt template (heartbeat-aware)
130
+ ### Sub-agent prompt template (heartbeat-aware + MCP-decoupled)
131
131
 
132
132
  Every sub-agent prompt dispatched via `peaks sub-agent dispatch` should
133
133
  include the heartbeat instruction so the LLM knows when and how to
@@ -143,6 +143,49 @@ While running, call `peaks sub-agent heartbeat --record <dispatchRecordPath>
143
143
  to keep the user informed during the wait.
144
144
  ```
145
145
 
146
+ **Slice #007-007-2026-06-07-mcp-decouple (G3 prompt template addition)**:
147
+ when the sub-agent is dispatched into a non-Claude IDE (Trae, Cursor,
148
+ Codex, Qoder, Tongyi, ...) or into a Claude Code environment where the
149
+ LLM cannot directly invoke the `mcp__<server>__*` tool prefix, the
150
+ sub-agent prompt must additionally include the MCP-decouple instruction
151
+ below. Without it, the sub-agent would either fall back to direct
152
+ `mcp__` invocations (which fail in non-Claude IDEs) or skip MCP
153
+ operations entirely (which breaks RD/QA/UI flows that depend on the
154
+ Playwright, Chrome DevTools, Figma, or Context7 servers).
155
+
156
+ ```
157
+ When you need to use an MCP server (playwright, chrome-devtools, figma, or
158
+ context7), do NOT invoke the `mcp__<server>__*` tool prefix directly. The
159
+ canonical path is `peaks mcp call`:
160
+
161
+ peaks mcp call --capability <capabilityId> --tool <toolName> --args-json '<argsObject>' --json
162
+
163
+ where `<capabilityId>` is one of:
164
+ - playwright-mcp.browser-validation (headed browser, primary E2E surface)
165
+ - chrome-devtools-mcp.browser-debug (CDP to running Chrome on :9222, secondary)
166
+ - figma-context-mcp.design-context (Figma design data, requires FIGMA_API_KEY)
167
+ - context7.docs-lookup (library docs, requires CONTEXT7_API_KEY)
168
+
169
+ For install / plan / detect, use:
170
+ peaks mcp list --json
171
+ peaks mcp plan --capability <capabilityId> --json
172
+ peaks mcp apply --capability <capabilityId> --yes --json
173
+
174
+ The `peaks mcp plan` envelope's `envCheck.missing` field is the source of
175
+ truth for required env vars. Do not bake the `mcp__<server>__*` prefix
176
+ into any artifact or message; the prefix is owned by the LLM runtime, not
177
+ by the skill. On Trae, `capabilities.mcpInstall` is `false`; do not
178
+ attempt `peaks mcp apply` on Trae — surface the manual install path
179
+ instead.
180
+ ```
181
+
182
+ The MCP-decouple paragraph is required for any sub-agent dispatched
183
+ into a non-Claude environment or any sub-agent that needs an MCP
184
+ capability. The CLI auto-generates it for `role in (rd, qa, ui, txt)`
185
+ when the active IDE is not `claude-code`; for `role = general-purpose`
186
+ or unknown roles, the caller (the SKILL.md heart of the Dispatcher) must
187
+ add it explicitly.
188
+
146
189
  `heartbeatIntervalSec` is overridable per SKILL.md (5..600). Default 30.
147
190
 
148
191
  ### Status line shape (G6.5)
@@ -16,7 +16,7 @@ Return a compact JSON envelope — do not write prose.
16
16
  ## Hard prohibitions
17
17
  - Do NOT call Skill(skill="..."). You are the role.
18
18
  - Do NOT call `peaks skill presence:set` — the main loop owns .peaks/.active-skill.json.
19
- If you need to record state, write to .peaks/<session-id>/system/sub-agent-<role>.json.
19
+ If you need to record state, write to .peaks/_runtime/<session-id>/system/sub-agent-<role>.json.
20
20
  - Do NOT commit, push, install hooks, or apply settings.json mutations.
21
21
  - Do NOT ask the user interactive questions. If you need clarification, return
22
22
  {"status":"blocked","blockedReason":"<text>"} and let the main loop handle it.
@@ -47,14 +47,14 @@ Steps:
47
47
  3. Read <project-scan-path> for component library / CSS framework.
48
48
  4. Run the prototype fidelity gate: Figma file? PRD visuals? Headed browser?
49
49
  5. Write TWO artefacts:
50
- - .peaks/<sid>/ui/design-draft.md
51
- - .peaks/<sid>/ui/requests/<rid>.md
50
+ - .peaks/_runtime/<sid>/ui/design-draft.md
51
+ - .peaks/_runtime/<sid>/ui/requests/<rid>.md
52
52
  6. Return:
53
53
  {
54
54
  "role": "ui",
55
55
  "rid": "<rid>",
56
56
  "status": "ok" | "blocked" | "skipped",
57
- "artefacts": [".peaks/<sid>/ui/design-draft.md", ".peaks/<sid>/ui/requests/<rid>.md"],
57
+ "artefacts": [".peaks/_runtime/<sid>/ui/design-draft.md", ".peaks/_runtime/<sid>/ui/requests/<rid>.md"],
58
58
  "warnings": [],
59
59
  "blockedReason": null
60
60
  }
@@ -80,15 +80,15 @@ Steps:
80
80
  into rd/project-scan.md.
81
81
  5. Read <existing-system-path> if archetype is legacy-*.
82
82
  6. Write the type-appropriate planning artefact:
83
- - feature | refactor → .peaks/<sid>/rd/tech-doc.md
84
- - bugfix → .peaks/<sid>/rd/bug-analysis.md
83
+ - feature | refactor → .peaks/_runtime/<sid>/rd/tech-doc.md
84
+ - bugfix → .peaks/_runtime/<sid>/rd/bug-analysis.md
85
85
  - config | docs | chore → no planning artefact required. Return skipped.
86
86
  7. Return:
87
87
  {
88
88
  "role": "rd-planning",
89
89
  "rid": "<rid>",
90
90
  "status": "ok" | "blocked" | "skipped",
91
- "artefacts": [".peaks/<sid>/rd/tech-doc.md"], // or [] when skipped
91
+ "artefacts": [".peaks/_runtime/<sid>/rd/tech-doc.md"], // or [] when skipped
92
92
  "warnings": [],
93
93
  "blockedReason": null
94
94
  }
@@ -106,14 +106,14 @@ Steps:
106
106
  2. peaks request show <rid> --role prd --project <repo> --json
107
107
  3. peaks request show <rid> --role rd --project <repo> --json
108
108
  4. Read <project-scan-path>.
109
- 5. Write .peaks/<sid>/qa/test-cases/<rid>.md with test cases linked to PRD
109
+ 5. Write .peaks/_runtime/<sid>/qa/test-cases/<rid>.md with test cases linked to PRD
110
110
  acceptance items (use **Acceptance:** A1, A2 style).
111
111
  6. Return:
112
112
  {
113
113
  "role": "qa-test-cases",
114
114
  "rid": "<rid>",
115
115
  "status": "ok" | "blocked" | "skipped",
116
- "artefacts": [".peaks/<sid>/qa/test-cases/<rid>.md"],
116
+ "artefacts": [".peaks/_runtime/<sid>/qa/test-cases/<rid>.md"],
117
117
  "warnings": [],
118
118
  "blockedReason": null
119
119
  }
@@ -13,7 +13,7 @@ UI's headed-browser work (visual inspection, regression seed capture, Figma / li
13
13
 
14
14
  ### Contract 1 — Inspection screenshots must land under .peaks/<sid>/qa/screenshots/
15
15
 
16
- Every `mcp__playwright__browser_take_screenshot` call **MUST** pass `filename` inside `.peaks/<session-id>/qa/screenshots/`, named after the inspection target (e.g. `home-after-cta.png`, `empty-state-v2.png`). Do not let Playwright fall back to the project root. After every batch, run:
16
+ Every Playwright screenshot tool call (via `peaks mcp call --capability playwright-mcp.browser-validation --tool browser_take_screenshot --args-json '<args>' --json`) **MUST** pass `filename` (in the args object) inside `.peaks/<session-id>/qa/screenshots/`, named after the inspection target (e.g. `home-after-cta.png`, `empty-state-v2.png`). Do not let Playwright fall back to the project root. After every batch, run:
17
17
 
18
18
  ```bash
19
19
  ls .peaks/<sid>/qa/screenshots/*.png 2>&1
@@ -152,7 +152,8 @@ peaks mcp apply --capability playwright-mcp.browser-validation --yes --json
152
152
 
153
153
  # 5. drive the running page or prototype through Claude Code MCP tools
154
154
  # (these are not Peaks-Cli CLI commands; they are invoked by the host MCP runtime)
155
- # mcp__playwright__browser_navigate → URL (after allow-list check), launches headed browser
155
+ # peaks mcp call --capability playwright-mcp.browser-validation --tool browser_navigate --args-json '{"url":"<url>"}' --json
156
+ # → URL (after allow-list check), launches headed browser
156
157
  #
157
158
  # LOGIN GATE (MANDATORY checkpoint):
158
159
  # After browser_navigate, check for login/CAPTCHA/SSO/MFA redirect.
@@ -161,11 +162,19 @@ peaks mcp apply --capability playwright-mcp.browser-validation --yes --json
161
162
  # If user does not confirm within reasonable time → pause and ask.
162
163
  # Only after user confirmation, continue to:
163
164
  #
164
- # mcp__playwright__browser_take_screenshot → visible-browser confirmation
165
- # mcp__playwright__browser_snapshot accessibility tree for regression seeds
166
- # mcp__playwright__browser_console_messages console errors
167
- # mcp__playwright__browser_network_requests failed network
168
- # mcp__playwright__browser_close → end the session cleanly
165
+ # peaks mcp call --capability playwright-mcp.browser-validation --tool browser_take_screenshot --args-json '{"filename":"<abs-path>"}' --json
166
+ # → visible-browser confirmation
167
+ # peaks mcp call --capability playwright-mcp.browser-validation --tool browser_snapshot --args-json '{}' --json
168
+ # → accessibility tree for regression seeds
169
+ # peaks mcp call --capability playwright-mcp.browser-validation --tool browser_console_messages --args-json '{}' --json
170
+ # → console errors
171
+ # peaks mcp call --capability playwright-mcp.browser-validation --tool browser_network_requests --args-json '{}' --json
172
+ # → failed network
173
+ # peaks mcp call --capability playwright-mcp.browser-validation --tool browser_close --args-json '{}' --json
174
+ # → end the session cleanly
175
+ # The skill body NEVER bakes in the `mcp__playwright__` prefix; the LLM's runtime
176
+ # resolves the tool name from the registered server. The capability id
177
+ # `playwright-mcp.browser-validation` is the contract; the registry is the source of truth.
169
178
 
170
179
  # 5. write design-draft artifact to .peaks/<session-id>/ui/design-draft.md
171
180
 
@@ -229,7 +238,7 @@ Use gstack as a concrete design-review workflow reference for the `Plan → Revi
229
238
  - map browser walkthrough concepts to UI regression seeds when runtime validation is approved;
230
239
  - keep accessibility, performance, and product-specific visual direction as Peaks-Cli UI acceptance inputs.
231
240
 
232
- For frontend work, especially full-auto mode, use Playwright MCP (`mcp__playwright__browser_navigate` / `browser_snapshot` / `browser_take_screenshot` / `browser_console_messages` / `browser_network_requests` / `browser_close`) to inspect the running page or prototype before accepting the UI direction. Playwright MCP launches a headed browser on demand; if `peaks mcp list --json` does not include `playwright`, install it through `peaks mcp plan/apply --capability playwright-mcp.browser-validation --yes` before attempting to inspect. (Chrome DevTools MCP is a secondary surface that connects to an already-running Chrome via `--remote-debugging-port=9222`; it does NOT launch a browser on its own.) If login, CAPTCHA, SSO, or MFA appears, the visible browser is already open; wait for the user to complete login and explicitly confirm completion before continuing. Capture only sanitized visible regressions, weak hierarchy, generic template patterns, console errors, and interaction problems as UI feedback that should return to design/RD before handing off to QA; do not retain login URLs, cookies, headers, tokens, storage state, browser traces, or screenshots/logs containing PII or SSO/MFA material. Canonical browser workflow: `peaks-solo/references/browser-workflow.md`.
241
+ For frontend work, especially full-auto mode, use Playwright MCP to inspect the running page or prototype before accepting the UI direction. The skill body never bakes in the `mcp__playwright__` prefix; it uses `peaks mcp call --capability playwright-mcp.browser-validation --tool <name> --args-json '<args>' --json` for every browser operation (browser_navigate / browser_snapshot / browser_take_screenshot / browser_console_messages / browser_network_requests / browser_close). Playwright MCP launches a headed browser on demand; if `peaks mcp list --json` does not include `playwright`, install it through `peaks mcp plan --capability playwright-mcp.browser-validation --json` then `peaks mcp apply --capability playwright-mcp.browser-validation --yes --json` before attempting to inspect. (Chrome DevTools MCP is a secondary surface that connects to an already-running Chrome via `--remote-debugging-port=9222`; it does NOT launch a browser on its own.) If login, CAPTCHA, SSO, or MFA appears, the visible browser is already open; wait for the user to complete login and explicitly confirm completion before continuing. Capture only sanitized visible regressions, weak hierarchy, generic template patterns, console errors, and interaction problems as UI feedback that should return to design/RD before handing off to QA; do not retain login URLs, cookies, headers, tokens, storage state, browser traces, or screenshots/logs containing PII or SSO/MFA material. Canonical browser workflow: `peaks-solo/references/browser-workflow.md`.
233
242
 
234
243
  ## Prototype fidelity gate (MANDATORY — check BEFORE any design work)
235
244
 
@@ -239,7 +248,7 @@ For frontend work, especially full-auto mode, use Playwright MCP (`mcp__playwrig
239
248
 
240
249
  Check these sources in order:
241
250
 
242
- 1. **Figma design file** — If the PRD links to a Figma file, use `mcp__Figma_AI_Bridge__get_figma_data` to fetch the design. The Figma data IS the design. Replicate layout, spacing, colors, typography, and component choices exactly as specified.
251
+ 1. **Figma design file** — If the PRD links to a Figma file, use `peaks mcp call --capability figma-context-mcp.design-context --tool get_figma_data --args-json '{"fileKey":"<key>"}' --json` to fetch the design (the skill body never bakes in the `mcp__Figma_AI_Bridge__` prefix; the prefix is owned by the LLM runtime, and `FIGMA_API_KEY` must be set in the env before `peaks mcp apply` — the plan envelope's `envCheck.missing` field is the source of truth). The Figma data IS the design. Replicate layout, spacing, colors, typography, and component choices exactly as specified.
243
252
  2. **PRD document screenshots** — If the PRD source (Feishu/Lark doc) contains screenshots or mockups, those ARE the visual target. Check `.peaks/<id>/prd/source/` for saved screenshots.
244
253
  3. **PRD visual descriptions** — If the PRD explicitly describes layout, component placement, or visual behavior, those descriptions are constraints, not suggestions.
245
254
  4. **Existing application pages** — If modifying an existing app, the existing visual language (component library, spacing patterns, color usage) is the fidelity baseline. New pages must match existing conventions.