peaks-cli 1.0.11 → 1.0.13

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 (94) hide show
  1. package/bin/peaks.js +0 -0
  2. package/dist/src/cli/commands/core-artifact-commands.js +23 -0
  3. package/dist/src/cli/commands/mcp-commands.d.ts +3 -0
  4. package/dist/src/cli/commands/mcp-commands.js +144 -0
  5. package/dist/src/cli/commands/openspec-commands.d.ts +3 -0
  6. package/dist/src/cli/commands/openspec-commands.js +169 -0
  7. package/dist/src/cli/commands/project-commands.d.ts +3 -0
  8. package/dist/src/cli/commands/project-commands.js +37 -0
  9. package/dist/src/cli/commands/request-commands.d.ts +3 -0
  10. package/dist/src/cli/commands/request-commands.js +140 -0
  11. package/dist/src/cli/commands/understand-commands.d.ts +3 -0
  12. package/dist/src/cli/commands/understand-commands.js +78 -0
  13. package/dist/src/cli/program.js +10 -0
  14. package/dist/src/services/artifacts/request-artifact-service.d.ts +58 -0
  15. package/dist/src/services/artifacts/request-artifact-service.js +432 -0
  16. package/dist/src/services/dashboard/project-dashboard-service.d.ts +64 -0
  17. package/dist/src/services/dashboard/project-dashboard-service.js +112 -0
  18. package/dist/src/services/doctor/doctor-service.d.ts +7 -0
  19. package/dist/src/services/doctor/doctor-service.js +139 -0
  20. package/dist/src/services/mcp/mcp-apply-service.d.ts +31 -0
  21. package/dist/src/services/mcp/mcp-apply-service.js +112 -0
  22. package/dist/src/services/mcp/mcp-call-service.d.ts +17 -0
  23. package/dist/src/services/mcp/mcp-call-service.js +34 -0
  24. package/dist/src/services/mcp/mcp-client-service.d.ts +14 -0
  25. package/dist/src/services/mcp/mcp-client-service.js +49 -0
  26. package/dist/src/services/mcp/mcp-install-registry.d.ts +11 -0
  27. package/dist/src/services/mcp/mcp-install-registry.js +38 -0
  28. package/dist/src/services/mcp/mcp-plan-service.d.ts +29 -0
  29. package/dist/src/services/mcp/mcp-plan-service.js +109 -0
  30. package/dist/src/services/mcp/mcp-protocol.d.ts +24 -0
  31. package/dist/src/services/mcp/mcp-protocol.js +41 -0
  32. package/dist/src/services/mcp/mcp-scan-service.d.ts +8 -0
  33. package/dist/src/services/mcp/mcp-scan-service.js +214 -0
  34. package/dist/src/services/mcp/mcp-stdio-transport.d.ts +10 -0
  35. package/dist/src/services/mcp/mcp-stdio-transport.js +50 -0
  36. package/dist/src/services/mcp/mcp-types.d.ts +31 -0
  37. package/dist/src/services/mcp/mcp-types.js +1 -0
  38. package/dist/src/services/openspec/openspec-archive-service.d.ts +12 -0
  39. package/dist/src/services/openspec/openspec-archive-service.js +28 -0
  40. package/dist/src/services/openspec/openspec-bridge-service.d.ts +16 -0
  41. package/dist/src/services/openspec/openspec-bridge-service.js +76 -0
  42. package/dist/src/services/openspec/openspec-render-service.d.ts +38 -0
  43. package/dist/src/services/openspec/openspec-render-service.js +130 -0
  44. package/dist/src/services/openspec/openspec-scan-service.d.ts +6 -0
  45. package/dist/src/services/openspec/openspec-scan-service.js +123 -0
  46. package/dist/src/services/openspec/openspec-types.d.ts +39 -0
  47. package/dist/src/services/openspec/openspec-types.js +1 -0
  48. package/dist/src/services/openspec/openspec-validate-service.d.ts +27 -0
  49. package/dist/src/services/openspec/openspec-validate-service.js +77 -0
  50. package/dist/src/services/recommendations/capability-seed-items.js +1 -0
  51. package/dist/src/services/skills/skill-runbook-service.d.ts +11 -0
  52. package/dist/src/services/skills/skill-runbook-service.js +60 -0
  53. package/dist/src/services/standards/project-standards-service.js +4 -9
  54. package/dist/src/services/understand/understand-scan-service.d.ts +28 -0
  55. package/dist/src/services/understand/understand-scan-service.js +157 -0
  56. package/dist/src/services/understand/understand-types.d.ts +24 -0
  57. package/dist/src/services/understand/understand-types.js +1 -0
  58. package/dist/src/shared/json-schema-mini.d.ts +10 -0
  59. package/dist/src/shared/json-schema-mini.js +113 -0
  60. package/dist/src/shared/paths.d.ts +1 -1
  61. package/dist/src/shared/paths.js +9 -1
  62. package/dist/src/shared/version.d.ts +1 -1
  63. package/dist/src/shared/version.js +1 -1
  64. package/package.json +1 -6
  65. package/schemas/doctor-report.schema.json +34 -0
  66. package/schemas/mcp-apply-result.schema.json +46 -0
  67. package/schemas/mcp-install-plan.schema.json +71 -0
  68. package/schemas/mcp-install-spec.schema.json +29 -0
  69. package/schemas/mcp-server.schema.json +29 -0
  70. package/schemas/openspec-change-summary.schema.json +68 -0
  71. package/schemas/openspec-render-request.schema.json +61 -0
  72. package/schemas/openspec-validation-result.schema.json +36 -0
  73. package/skills/peaks-prd/SKILL.md +59 -8
  74. package/skills/peaks-prd/references/artifact-per-request.md +78 -0
  75. package/skills/peaks-prd/references/workflow.md +7 -5
  76. package/skills/peaks-qa/SKILL.md +73 -7
  77. package/skills/peaks-qa/references/artifact-contracts.md +1 -1
  78. package/skills/peaks-qa/references/artifact-per-request.md +83 -0
  79. package/skills/peaks-qa/references/openspec-validation-gate.md +55 -0
  80. package/skills/peaks-qa/references/regression-gates.md +1 -1
  81. package/skills/peaks-rd/SKILL.md +94 -7
  82. package/skills/peaks-rd/references/artifact-per-request.md +90 -0
  83. package/skills/peaks-rd/references/openspec-mcp-cli.md +65 -0
  84. package/skills/peaks-sc/SKILL.md +44 -0
  85. package/skills/peaks-sc/references/openspec-commit-boundaries.md +33 -0
  86. package/skills/peaks-solo/SKILL.md +87 -4
  87. package/skills/peaks-solo/references/browser-workflow.md +114 -0
  88. package/skills/peaks-solo/references/external-skill-invocation.md +70 -0
  89. package/skills/peaks-solo/references/openspec-mcp-workflow.md +53 -0
  90. package/skills/peaks-solo/references/workflow.md +1 -1
  91. package/skills/peaks-txt/SKILL.md +42 -0
  92. package/skills/peaks-ui/SKILL.md +57 -33
  93. package/skills/peaks-ui/references/artifact-per-request.md +71 -0
  94. package/skills/peaks-ui/references/workflow.md +8 -11
@@ -0,0 +1,90 @@
1
+ # RD per-request artifact contract
2
+
3
+ Every RD invocation must leave one durable artifact under the workflow-local workspace so the engineering decisions and slice contracts are traceable later.
4
+
5
+ ## Required path
6
+
7
+ ```
8
+ .peaks/<session-id>/rd/requests/<request-id>.md
9
+ ```
10
+
11
+ Use the `<request-id>` PRD assigned (`YYYY-MM-DD-<kebab-slug>`). RD may also produce companion artifacts (task graph JSON, scan report, coverage evidence, slice spec, dry-run output) under the same `rd/` workspace and link to them from this file.
12
+
13
+ ## Required content
14
+
15
+ ```markdown
16
+ # RD Request <request-id>
17
+
18
+ - linked-prd: .peaks/<session-id>/prd/requests/<request-id>.md
19
+ - linked-ui: .peaks/<session-id>/ui/requests/<request-id>.md (when UI involved)
20
+ - type: feature | bug | refactor | clarification
21
+
22
+ ## Red-line scope
23
+
24
+ - in-scope files / routes / API paths / data models
25
+ - explicit out-of-scope surfaces (do not modify, mock, delete, or replace)
26
+
27
+ ## Standards preflight
28
+
29
+ - `peaks standards init/update --project <path> --dry-run` output paths and status
30
+ - planned application: apply | review-only | blocked
31
+
32
+ ## OpenSpec linkage (when openspec/ exists)
33
+
34
+ - change-id: <openspec change id>
35
+ - entry validate: `peaks openspec validate <change-id>` data.valid status
36
+ - to-rd projection: `peaks openspec to-rd <change-id>` artifact path
37
+ - exit validate (after implementation): status
38
+
39
+ ## Coverage status
40
+
41
+ - current total UT coverage: <percent>
42
+ - new/changed code coverage: <percent>
43
+ - gate verdict: pass | legacy-accepted | blocked
44
+
45
+ ## Slice contract
46
+
47
+ For each slice in this request:
48
+
49
+ - slice id
50
+ - functional boundary
51
+ - pre-refactor behavior summary
52
+ - target structure
53
+ - unit-test requirements
54
+ - acceptance checks (100% required per slice)
55
+ - rollback plan
56
+ - commit boundary (one per slice; aligned with OpenSpec tasks.md section when available)
57
+
58
+ ## Implementation evidence
59
+
60
+ - diff paths
61
+ - test commands + outputs
62
+ - code review findings + fixes
63
+ - security review findings + fixes
64
+ - dry-run output
65
+
66
+ ## MCP usage (when external docs lookup was used)
67
+
68
+ - capabilityId / tool / sanitized args
69
+ - artifact path of stored result
70
+ - no secrets, no full network bodies
71
+
72
+ ## Handoff
73
+
74
+ - to peaks-qa: <link to QA request artifact>
75
+ - to peaks-sc: <link to SC commit-boundary artifact>
76
+
77
+ ## Status
78
+
79
+ - created: <ISO timestamp>
80
+ - last update: <ISO timestamp>
81
+ - state: draft | spec-locked | implemented | qa-handoff | blocked
82
+ ```
83
+
84
+ ## Rules
85
+
86
+ - Do not skip the RD artifact for "trivial" fixes. Even a one-line bug fix needs the red-line scope and acceptance checks recorded.
87
+ - Refactor work requires UT coverage ≥ 95% before slicing begins; record the verdict in this artifact, not just in chat.
88
+ - Sanitize MCP/network/browser evidence before writing.
89
+ - Do not commit unless the user or active profile authorizes durable retention.
90
+ - Handoff to QA is blocked while state is `draft` or `spec-locked` without implementation evidence.
@@ -0,0 +1,65 @@
1
+ # OpenSpec and MCP CLI for Peaks RD
2
+
3
+ Peaks RD reads OpenSpec change packs and external MCP servers through the Peaks CLI rather than re-parsing markdown or spawning subprocesses by hand. The CLI returns the same stable envelope shape (`{ ok, command, data, warnings, nextActions }`) so RD can capture it as artifact JSON.
4
+
5
+ ## Loading an existing OpenSpec change as RD input
6
+
7
+ When the target repository already has `openspec/changes/<id>/`, project the change pack into the RD input shape before slicing:
8
+
9
+ ```bash
10
+ peaks openspec show <change-id> --project <repo> --json
11
+ peaks openspec to-rd <change-id> --project <repo> --json
12
+ ```
13
+
14
+ - `show` returns the parsed proposal sections, tasks progress, and detected `specs/<capability>/` capabilities.
15
+ - `to-rd` returns `{ changeId, acceptance, whatChanges, dependencies, risks, outOfScope, commitBoundaries[] }`. RD slice acceptance must be derived from `acceptance`; out-of-scope items from `outOfScope` must remain out of scope in the slice spec.
16
+
17
+ If the change does not exist, `to-rd` returns `OPENSPEC_CHANGE_NOT_FOUND`. Treat that as a blocker, not an excuse to free-form a slice spec.
18
+
19
+ ## Rendering a new OpenSpec change pack from RD work
20
+
21
+ When RD plans a non-trivial change in a repository that already uses `openspec/`, generate the change pack first (default dry-run), inspect the rendered markdown, and only then write it:
22
+
23
+ ```bash
24
+ peaks openspec render --request <jsonPath> --project <repo> --json
25
+ peaks openspec render --request <jsonPath> --project <repo> --apply --json
26
+ ```
27
+
28
+ The request JSON shape is:
29
+
30
+ ```json
31
+ {
32
+ "changeId": "<kebab-case>",
33
+ "why": "...",
34
+ "whatChanges": ["..."],
35
+ "outOfScope": ["..."],
36
+ "dependencies": ["..."],
37
+ "risks": ["..."],
38
+ "acceptanceCriteria": ["..."],
39
+ "tasks": [{ "heading": "1. <section>", "todos": ["..."], "doneItems": ["..."] }],
40
+ "design": "<raw markdown>"
41
+ }
42
+ ```
43
+
44
+ `render --apply` refuses to overwrite an existing change directory unless `--overwrite` is passed. Treat that refusal as intentional.
45
+
46
+ ## Calling MCP tools for research evidence
47
+
48
+ When RD needs external library or API docs, prefer a registered MCP server through Peaks instead of free-form web fetches:
49
+
50
+ ```bash
51
+ peaks mcp list --json
52
+ peaks mcp plan --capability context7.docs-lookup --json
53
+ peaks mcp apply --capability context7.docs-lookup --yes --json # one-time install
54
+ peaks mcp call --capability context7.docs-lookup --tool <toolName> --args-json '{...}' --json
55
+ ```
56
+
57
+ Rules:
58
+
59
+ - `plan` must be inspected before `apply`. `apply` is a real side effect; it backs up `~/.claude/settings.json` first.
60
+ - Required env vars must be present before `apply` and `call`; Peaks refuses to spawn a server with missing env.
61
+ - `call` results should be written into the RD artifact (e.g. `.peaks/<session-id>/rd/mcp-call-<ts>.json`) as the evidence link. Do not paste secrets or full network bodies into the RD handoff.
62
+
63
+ ## Boundary
64
+
65
+ Peaks RD must not hand-edit `openspec/changes/**` or `~/.claude/settings.json` directly. All writes go through the CLI commands above with dry-run preview, explicit confirmation, and Peaks-managed source labels.
@@ -31,6 +31,50 @@ Use gstack as a concrete source-control and release workflow reference for the `
31
31
 
32
32
  Project `.claude/memory` is the primary source for durable project memory. At approved checkpoints, use `peaks memory sync --project <path> --workspace <artifact-workspace> --apply` to back up the full project memory directory into the artifact repository workspace; do not treat the artifact backup as a second writable memory source.
33
33
 
34
+ ## OpenSpec-derived commit boundaries
35
+
36
+ When `openspec/changes/<id>/tasks.md` exists, derive commit boundaries from it through the Peaks CLI instead of redesigning them:
37
+
38
+ - `peaks openspec to-rd <id> --project <repo> --json` returns `commitBoundaries[]`, one entry per tasks.md heading.
39
+ - Default to one commit per heading. Each commit message references the change-id and the section heading.
40
+ - If implementation produces diffs outside any todo, surface that as out-of-scope before closing SC.
41
+
42
+ Concrete rules: `references/openspec-commit-boundaries.md`.
43
+
44
+ ## Default runbook
45
+
46
+ Use this sequence when SC owns the change-control pass for a refactor or release slice. SC never edits code or tests; it only records boundary evidence through the Peaks CLI.
47
+
48
+ ```bash
49
+ # 0. Confirm SC's own runbook integrity before recording boundary evidence
50
+ peaks skill runbook peaks-sc --json
51
+
52
+ # 1. Derive commit boundaries from OpenSpec when openspec/ exists
53
+ peaks openspec to-rd <change-id> --project <repo> --json
54
+
55
+ # 2. Inventory artifacts already produced by other roles for this session
56
+ peaks artifacts status --project <repo> --json
57
+ peaks artifacts workspace --workspace <session-id> --json
58
+
59
+ # 3. Record change impact for the slice
60
+ peaks sc impact --change-id <change-id> --module <module> --file <path> --json
61
+
62
+ # 4. Record retention evidence linking PRD / RD / QA / coverage / review artifacts
63
+ peaks sc retention --slice-id <slice-id> --prd <prd-path> --rd <rd-path> --qa <qa-path> --json
64
+
65
+ # 5. Validate retention completeness
66
+ peaks sc validate --slice-id <slice-id> --json
67
+
68
+ # 6. Record the commit boundary for the slice
69
+ peaks sc boundary --slice-id <slice-id> --artifact <artifact-path> --code <code-file> --json
70
+
71
+ # 7. Sync memory and artifacts only when the user or active profile authorizes durable writes
72
+ peaks memory sync --project <repo> --workspace <workspace> --apply --json
73
+ peaks artifacts sync --workspace <workspace> --apply --json
74
+ ```
75
+
76
+ The final two `--apply` calls require explicit authorization. Without it, default to `--dry-run` or omit the sync calls entirely and keep the boundary evidence local under `.peaks/<session-id>/`.
77
+
34
78
  ## Boundaries
35
79
 
36
80
  Do not implement code or test logic. Do not create GitHub repositories directly from the skill body. Use the Peaks CLI artifact commands.
@@ -0,0 +1,33 @@
1
+ # OpenSpec-Derived Commit Boundaries for Peaks SC
2
+
3
+ Peaks SC owns commit boundaries and artifact retention. When the change pack lives in `openspec/changes/<id>/tasks.md`, SC must derive the commit boundaries from that file via the Peaks CLI rather than reinvent them.
4
+
5
+ ## Pulling commit boundary candidates
6
+
7
+ ```bash
8
+ peaks openspec to-rd <change-id> --project <repo> --json
9
+ ```
10
+
11
+ The response includes:
12
+
13
+ ```json
14
+ "commitBoundaries": [
15
+ { "heading": "1. Discovery", "todos": ["..."], "doneItems": ["..."] },
16
+ { "heading": "2. Implementation", "todos": ["..."], "doneItems": ["..."] }
17
+ ]
18
+ ```
19
+
20
+ Rules SC applies:
21
+
22
+ - One commit per `heading` is the default. Do not combine unrelated sections into a single commit.
23
+ - `todos[]` items are the in-scope work for that commit. If implementation produced diffs outside any todo description, surface that as an out-of-scope finding before SC closes.
24
+ - `doneItems[]` describes already-shipped sub-tasks; SC may close them out in the same commit only when the current diff actually touches the same surface.
25
+ - Each commit message should reference the change-id and the section heading (e.g. `feat: M3 implement <change-id> 2. Implementation`).
26
+
27
+ ## Wiring with RD slice contracts
28
+
29
+ When RD has split a change into multiple slices, SC must align each commit with one RD slice and one OpenSpec tasks section. The OpenSpec section heading is the canonical commit boundary name; the RD slice id is the internal reference. If they disagree, return to RD before committing.
30
+
31
+ ## Boundary
32
+
33
+ SC must not hand-edit `openspec/changes/**` or rewrite history to match a desired boundary. If the OpenSpec tasks list is wrong, raise it as an RD/QA issue and have RD regenerate the change pack through `peaks openspec render` before SC commits.
@@ -40,7 +40,9 @@ Use gstack as a concrete orchestration reference for the full `Think → Plan
40
40
  - map `/retro` to Peaks TXT final context and reusable lessons;
41
41
  - preserve Peaks confirmation gates, artifact workspace boundaries, and role separation instead of delegating orchestration to gstack commands.
42
42
 
43
- For frontend workflows, Peaks Solo must ensure RD self-test and QA validation use headed `gstack/browse/dist/browse` for real browser end-to-end validation. 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.
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.
44
+
45
+ Canonical browser workflow (URL allow-list, login handoff, tool mapping from the previous gstack/browse pattern): `references/browser-workflow.md`.
44
46
 
45
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.
46
48
 
@@ -61,7 +63,7 @@ When Peaks Solo coordinates development in a code repository, keep this order ex
61
63
  5. unit tests for new/changed behavior, with focused new-code coverage accepted for legacy low-coverage repos;
62
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;
63
65
  7. RD post-check dry-run;
64
- 8. QA validation, including API checks and headed `gstack/browse/dist/browse` browser E2E for frontend;
66
+ 8. QA validation, including API checks and Chrome DevTools MCP headed browser E2E for frontend;
65
67
  9. QA security and performance checks plus validation report;
66
68
  10. TXT final handoff capsule, including reusable skill-usage lessons when the workflow revealed new habits or preferences.
67
69
 
@@ -81,6 +83,70 @@ When QA reports problems:
81
83
 
82
84
  For full-auto or long-running workflows, prefer using Claude Code's `goal` command to encode this loop goal: "RD fixes until QA passes all acceptance items." Do not treat `goal` as a replacement for Peaks role artifacts; it is only the controller objective for the RD↔QA loop.
83
85
 
86
+ ## Default runbook
87
+
88
+ The default end-to-end sequence Peaks Solo orchestrates when a user supplies a request (feature / bug / refactor / product-doc link) and selects the Solo (full-auto) profile. Each role's own Default runbook owns the per-role detail; Solo's job is to drive the cross-role state transitions in order and confirm the artifact chain is complete before declaring the workflow done.
89
+
90
+ ```bash
91
+ # 0. snapshot the project before anything else
92
+ peaks doctor --json
93
+ peaks project dashboard --project <repo> --json # one-call cross-role status
94
+ peaks skill runbook peaks-solo --json # confirm Solo's own runbook is intact + apply-gated
95
+
96
+ # 1. PRD phase — capture the request as the canonical artifact
97
+ peaks request init --role prd --id <request-id> --project <repo> --apply --json
98
+ # (Solo executes peaks-prd Default runbook here, including authenticated
99
+ # document handling via Chrome DevTools MCP per peaks-solo/references/browser-workflow.md)
100
+ peaks request transition <request-id> --role prd --state confirmed-by-user --project <repo> --json
101
+ peaks request transition <request-id> --role prd --state handed-off --project <repo> --json
102
+
103
+ # 2. UI phase — only when the request affects user-visible behavior
104
+ peaks request init --role ui --id <request-id> --project <repo> --apply --json
105
+ # (Solo executes peaks-ui Default runbook here)
106
+ peaks request transition <request-id> --role ui --state direction-locked --project <repo> --json
107
+ peaks request transition <request-id> --role ui --state handed-off --project <repo> --json
108
+
109
+ # 3. RD phase — engineering planning + implementation
110
+ peaks request init --role rd --id <request-id> --project <repo> --apply --json
111
+ # (Solo executes peaks-rd Default runbook here: standards preflight + openspec entry gate +
112
+ # project-analysis evidence + implementation + openspec exit gate)
113
+ peaks request transition <request-id> --role rd --state spec-locked --project <repo> --json
114
+ peaks request transition <request-id> --role rd --state implemented --project <repo> --json
115
+ peaks request transition <request-id> --role rd --state qa-handoff --project <repo> --json
116
+
117
+ # 4. QA phase — verification with the mandatory gates
118
+ peaks request init --role qa --id <request-id> --project <repo> --apply --json
119
+ # (Solo executes peaks-qa Default runbook here, including Chrome DevTools MCP frontend
120
+ # validation when frontend is in scope)
121
+ peaks request transition <request-id> --role qa --state running --project <repo> --json
122
+ peaks request transition <request-id> --role qa --state verdict-issued --project <repo> --json
123
+
124
+ # 5. SC phase — record change-control evidence after QA passes
125
+ # (Solo executes peaks-sc Default runbook here for the full sequence)
126
+ peaks sc impact --change-id <change-id> --module <module> --file <path> --json
127
+ peaks sc retention --slice-id <request-id> --prd <prd> --rd <rd> --qa <qa> --json
128
+ peaks sc validate --slice-id <request-id> --json
129
+ peaks sc boundary --slice-id <request-id> --artifact <artifact> --code <file> --json
130
+
131
+ # 6. close the loop — final verification and optional OpenSpec archive
132
+ peaks request list --project <repo> --json # every artifact reached its terminal state?
133
+ peaks request show <request-id> --role qa --project <repo> --json # QA verdict is pass?
134
+ peaks openspec validate <change-id> --project <repo> --json # exit gate (when openspec/ exists)
135
+ peaks openspec archive <change-id> --project <repo> --apply --json # only after QA verdict=pass
136
+
137
+ # 7. TXT phase — compact handoff capsule
138
+ # (Solo executes peaks-txt Default runbook here; durable extraction requires authorization)
139
+ peaks memory extract --project <repo> --artifact <qa-artifact> --dry-run --json
140
+
141
+ # 8. final snapshot to confirm the workflow really closed
142
+ peaks project dashboard --project <repo> --json
143
+ peaks skill doctor --json # all 7 required skills still healthy?
144
+ ```
145
+
146
+ Solo's RD↔QA repair loop (`## Mandatory RD QA repair loop` above) applies if QA's verdict is `return-to-rd`. In that case, Solo re-runs phase 3 + phase 4 against the same `<request-id>` instead of starting a new one; the previous artifacts get appended with new transition notes via `--reason` rather than rewritten.
147
+
148
+ For Assisted, Swarm, or Strict profiles, Solo pauses at the transition boundaries to confirm the next phase rather than running the chain straight through. The CLI sequence is the same; only the confirmation gate cadence differs.
149
+
84
150
  ## Mode selection
85
151
 
86
152
  When the user invokes Peaks Solo without explicitly selecting an execution profile, use `AskUserQuestion` before orchestration starts. Present the recommended full-auto path as the first/default option, and give every option a practical description so users can choose quickly.
@@ -96,8 +162,6 @@ If the user already names a profile, do not ask again unless the request crosses
96
162
 
97
163
  ## Project standards preflight
98
164
 
99
- Peaks Solo must ensure generated project-local `CLAUDE.md` and `.claude/rules/**` treat `https://github.com/SquabbyZ/andrej-karpathy-skills` code quality guidance and strict file-size limits as red lines, not optional preferences. Oversized single-file implementations block RD/QA completion.
100
-
101
165
  Before orchestrating an end-to-end code repository workflow, gather the project standards preflight status from RD and QA by calling the Peaks CLI:
102
166
 
103
167
  - `peaks standards init --project <path> --dry-run`
@@ -142,6 +206,25 @@ Codegraph is an optional project-analysis enhancement for role handoff. Solo may
142
206
 
143
207
  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.
144
208
 
209
+ ## External skill invocation audit
210
+
211
+ 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.
212
+
213
+ 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.
214
+
215
+ 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.
216
+
217
+ Canonical pattern and audit/repair recipe: `references/external-skill-invocation.md`.
218
+
219
+ ## OpenSpec and MCP lifecycle
220
+
221
+ 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.
222
+
223
+ - 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`.
224
+ - 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.
225
+
226
+ Concrete rules and integration recipes: `references/openspec-mcp-workflow.md`.
227
+
145
228
  ## Optional capabilities
146
229
 
147
230
  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.
@@ -0,0 +1,114 @@
1
+ # Headed browser workflow for Peaks skills
2
+
3
+ Peaks skills standardize on **Playwright MCP** as the controlled headed-browser surface for opening a browser on demand (PRD authenticated docs, UI design inspection, QA E2E validation). Chrome DevTools MCP is a secondary surface that **connects to an existing Chrome instance launched with `--remote-debugging-port=9222`** — it does not launch a browser on its own. Picking the right tool for the right job is critical:
4
+
5
+ | Need | Tool | Why |
6
+ |---|---|---|
7
+ | Open a controlled browser when the user supplies a URL | **Playwright MCP** | Spawns its own browser instance per session; no prerequisite. |
8
+ | Drive console/network/performance inspection on a Chrome the user already has open | Chrome DevTools MCP | Connects via CDP to an existing Chrome on `:9222`. |
9
+ | Frontend E2E validation that needs to start, navigate, capture, close | **Playwright MCP** | Headed mode, full lifecycle in one tool. |
10
+ | Live page debugging where the user wants to keep their own Chrome session in front | Chrome DevTools MCP | Stays attached without disrupting the user's tabs. |
11
+
12
+ > **Bug history**: an earlier version of this document recommended Chrome DevTools MCP for "open a headed browser when peaks-solo gets a product document link." Dogfood testing in 2026-05 revealed the tool requires a pre-running Chrome with remote debugging enabled — it does NOT launch its own browser. Playwright MCP is the correct tool for the "open on demand" case.
13
+
14
+ ## When to open the headed browser
15
+
16
+ Open a controlled browser when:
17
+
18
+ - PRD source is an authenticated product document (Feishu/Lark, Notion, internal wiki) and the URL passes the allow-list check.
19
+ - UI design or full-auto frontend work needs visible regression observation.
20
+ - QA needs E2E validation on a frontend, including console / network / accessibility / performance inspection.
21
+
22
+ Never open a browser to bypass authentication, run arbitrary URLs the user has not approved, or interact with payment / delete / authenticated mutation flows without explicit user confirmation.
23
+
24
+ ## Install the Playwright MCP server (one-time)
25
+
26
+ Capability discovery exposes `playwright-mcp.browser-validation`. Install through the Peaks CLI rather than hand-editing settings.json so the peaks-managed marker and backup flow apply:
27
+
28
+ ```bash
29
+ peaks mcp list --json
30
+ peaks mcp plan --capability playwright-mcp.browser-validation --json
31
+ peaks mcp apply --capability playwright-mcp.browser-validation --yes --json
32
+ ```
33
+
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
+
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.
37
+
38
+ ## Optional: install Chrome DevTools MCP for CDP inspection
39
+
40
+ When inspecting an already-running Chrome (e.g., the user's own browser session opened with `chrome --remote-debugging-port=9222`), additionally install Chrome DevTools MCP:
41
+
42
+ ```bash
43
+ peaks mcp plan --capability chrome-devtools-mcp.browser-debug --json
44
+ peaks mcp apply --capability chrome-devtools-mcp.browser-debug --yes --json
45
+ ```
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.
48
+
49
+ ## Tool mapping for the "open a browser on demand" path (Playwright MCP)
50
+
51
+ | Verb | Playwright MCP tool | Notes |
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. |
62
+
63
+ ## Tool mapping for the "connect to running Chrome" path (Chrome DevTools MCP, optional)
64
+
65
+ | Verb | Chrome DevTools MCP tool | Notes |
66
+ |---|---|---|
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` | |
73
+
74
+ 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
+
76
+ ## URL allow-list (always required before navigation)
77
+
78
+ Before calling `mcp__playwright__browser_navigate` (or any other navigation), verify:
79
+
80
+ 1. URL uses `https:` (reject `http:`, `file:`, `data:`, `javascript:`).
81
+ 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).
82
+ 3. Reject `localhost`, loopback, link-local, raw IP, and private IP unless the user explicitly approves a controlled local test target.
83
+ 4. Reject the navigation entirely if any check fails and surface the reason to the user. Do not silently downgrade to an unauthenticated fetch.
84
+
85
+ ## Login / CAPTCHA / SSO / MFA handoff
86
+
87
+ If the page redirects to a login challenge:
88
+
89
+ 1. Do not auto-fill credentials. Do not bypass authentication.
90
+ 2. The headed browser is already visible; surface that to the user and wait for explicit confirmation that they have completed authentication. Do not assume a state transition from any DOM signal alone.
91
+ 3. After the user confirms, resume with `browser_snapshot` / `browser_take_screenshot` / `browser_console_messages` / `browser_network_requests` as needed for the role artifact.
92
+ 4. If the user cannot complete authentication, mark the role artifact `blocked` with a sanitized reason category (`login-required`, `mfa-required`, `access-denied`) and the exact next user action.
93
+
94
+ ## Sensitive data sanitization
95
+
96
+ Never persist any of the following in `.peaks/<session-id>/**` artifacts:
97
+
98
+ - Login URLs, redirect URLs, OAuth callback URLs containing tokens or state.
99
+ - Cookies, request or response headers, session tokens, storage state, QR payloads.
100
+ - Raw network logs.
101
+ - Raw browser state, browser traces.
102
+ - Screenshots or logs containing PII, SSO challenge content, or MFA material.
103
+
104
+ Redact sensitive values before retention. Store evidence as sanitized observations (e.g., "user reached settings page; first 3 list items had a missing-image regression") rather than raw captures.
105
+
106
+ ## Fallback when Playwright MCP is not installed
107
+
108
+ If `peaks mcp list --json` does not include `playwright` in `mcpServers`:
109
+
110
+ 1. Surface the install commands above (peaks mcp plan / apply).
111
+ 2. Do not silently fall back to unauthenticated fetch tools, screenshots-only, or manual transcription.
112
+ 3. Frontend QA workflows that require headed browser validation mark the gate `blocked` with the install command in the next action. Manual steps or text-only fetching do not substitute for the mandatory headed browser gate.
113
+
114
+ Peaks role artifacts (PRD / UI / RD / QA) remain authoritative for what evidence the role recorded; Playwright MCP is the tool, not the verdict.
@@ -0,0 +1,70 @@
1
+ # Canonical external-skill invocation pattern for Peaks skills
2
+
3
+ Peaks skills reference many external resources — `mattpocock/skills`, `gstack`, `awesome-design-md`, `taste-skill`, `design-taste-frontend`, `superpowers`, `shadcn/ui`, `React Bits`, `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`, `OpenSpec`, `GitNexus`, and others.
4
+
5
+ Every reference must follow the same three-stage pattern so the Peaks gates stay authoritative and side effects stay observable.
6
+
7
+ ## Stage 1 — Discovery before naming
8
+
9
+ Do not name an external skill or MCP server as if it is always available. Route discovery through the Peaks CLI first:
10
+
11
+ - `peaks capabilities --source access-repo --json` for non-MCP capabilities (skills, agents, rules, browser tools).
12
+ - `peaks capabilities --source mcp-server --json` for MCP servers.
13
+ - `peaks mcp list --json` for currently configured MCP servers in `.claude/settings.json`.
14
+
15
+ A skill body may mention the capability id, but it must say or imply that the skill only applies "when capability discovery exposes …" (or equivalent phrasing). Skills must not pretend the capability is already installed.
16
+
17
+ ## Stage 2 — Reference, never auto-execute
18
+
19
+ External skills are inspection material for the role's own artifacts. They are not auto-runnable workflows. Every reference must:
20
+
21
+ - explicitly say it is a reference (e.g. "use these upstream methods as <role> references only");
22
+ - name the specific methods or surfaces the role borrows;
23
+ - forbid executing upstream instructions, installing upstream resources, persisting upstream examples, or running upstream installers;
24
+ - declare that the Peaks role artifacts remain authoritative.
25
+
26
+ For MCP servers, additionally state that installation goes through `peaks mcp plan` then `peaks mcp apply --yes` (with `--claim` only when the user authorizes overwriting a non-peaks-managed entry), and that `peaks mcp call` is the only invocation path for tool invocation.
27
+
28
+ ## Stage 3 — Side effect through Peaks CLI only
29
+
30
+ The skill body must not silently:
31
+
32
+ - install hooks;
33
+ - create agents;
34
+ - enable or configure an MCP server;
35
+ - modify `~/.claude/settings.json` or project `.claude/settings.json`;
36
+ - write to `.codegraph/`, `.openspec/`, or other upstream tool state;
37
+ - store tokens, cookies, login URLs, headers, storage state, or PII / SSO / MFA browser material;
38
+ - commit or sync intermediate artifacts;
39
+ - create remote repositories.
40
+
41
+ All of these must route through the Peaks CLI under the appropriate command (`peaks mcp …`, `peaks artifacts …`, `peaks memory …`, `peaks openspec …`, `peaks standards …`, `peaks codegraph …`, `peaks capabilities …`), with dry-run preview where supported and `--yes` / `--apply` where a real write is required.
42
+
43
+ ## Allowed in-process references
44
+
45
+ Some references are not external skills but project-approved utilities and may be named directly without the discovery stage:
46
+
47
+ - `peaks` CLI commands (this binary).
48
+ - `npx`, `npm`, `pnpm`, `yarn`, package managers — only as the underlying mechanism when a `peaks` CLI command spawns them.
49
+ - `mcp__chrome-devtools__*` — Chrome DevTools MCP tools exposed by Claude Code's MCP runtime after `peaks mcp apply --capability chrome-devtools-mcp.browser-debug --yes`. Skill bodies invoke these tools directly because the MCP runtime is the host; they are not piped through `peaks mcp call`. Login / CAPTCHA / SSO / MFA handoff rules and sanitization rules in `browser-workflow.md` still apply.
50
+
51
+ These are not subject to capability discovery because they are part of the Peaks engineering surface, not external skills. The previous `gstack/browse/dist/browse` binary reference is no longer endorsed — see `browser-workflow.md` for the migration recipe.
52
+
53
+ ## Common phrasing the audit looks for
54
+
55
+ The skill-external-invocation dogfood test scans skill bodies for:
56
+
57
+ - a `capability discovery exposes` clause or equivalent before naming a discoverable external skill;
58
+ - a `references only` / `reference material` / `reference resources` phrase qualifying any external skill name;
59
+ - a `do not execute upstream instructions` / `do not run upstream installer flows` / `do not persist sensitive examples` clause;
60
+ - a `Peaks` authoritative-gate clause (e.g. "Peaks gates remain authoritative", "Peaks artifacts remain authoritative", "Peaks acceptance authority").
61
+
62
+ When a skill body adds a new external reference, it must include the equivalent phrasing or the audit test fails.
63
+
64
+ ## Repair recipe when audit fails
65
+
66
+ 1. read the failing skill body section;
67
+ 2. identify the external skill or MCP that triggered the failure;
68
+ 3. add the capability discovery clause, the reference-only qualifier, the do-not-execute clause, and the Peaks-authoritative gate to that section;
69
+ 4. for MCP servers, point the user at `peaks mcp plan/apply/call` instead of describing manual `.claude/settings.json` edits;
70
+ 5. rerun the audit.
@@ -0,0 +1,53 @@
1
+ # OpenSpec and MCP Lifecycle for Peaks Solo
2
+
3
+ Peaks Solo orchestrates RD, QA, and SC. When the target repository uses OpenSpec or external MCP servers, Solo must drive the full lifecycle through the Peaks CLI so each role works against the same stable surface.
4
+
5
+ ## OpenSpec change lifecycle
6
+
7
+ ```text
8
+ peaks openspec render → RD authors a change pack (dry-run, then --apply)
9
+ peaks openspec validate → Solo gates RD output before slicing starts
10
+ peaks openspec show → any role reads parsed proposal/tasks state
11
+ peaks openspec to-rd → RD projects the pack into refactor slice input
12
+ SC projects it into commit boundary candidates
13
+ peaks openspec validate → QA gates the final state before sign-off
14
+ peaks openspec archive → Solo moves the change under changes/archive/<id>/
15
+ ```
16
+
17
+ Rules Solo applies:
18
+
19
+ - `render --apply` is the only Peaks-managed way to write a change pack. Other roles must not hand-edit `openspec/changes/**`.
20
+ - `validate` is run twice per change in a refactor flow: once before slicing (RD entry gate) and once before archive (QA exit gate). Both must end with `data.valid === true`.
21
+ - `archive --apply` is the lifecycle terminator; Solo only invokes it after QA acceptance and SC commit.
22
+
23
+ ## MCP capability lifecycle
24
+
25
+ ```text
26
+ peaks mcp list / scan → Solo inventories what is configured today
27
+ peaks mcp plan → Solo previews the install diff before any write
28
+ peaks mcp apply --yes → Solo authorizes the install (real side effect)
29
+ peaks mcp call → RD or QA invokes a tool on the installed server
30
+ peaks mcp rollback → Solo restores from a peaks-managed backup
31
+ ```
32
+
33
+ Rules Solo applies:
34
+
35
+ - `apply` is the first real side effect in the MCP track. It requires `--yes`, backs up `~/.claude/settings.json` first, and refuses to overwrite non-peaks-managed entries unless `--claim` is passed. Solo decides whether `--claim` is appropriate.
36
+ - Required env vars must be set in the runtime environment before `apply` or `call`. Peaks refuses to spawn a server with missing env, surfacing each missing key in `envCheck.missing`.
37
+ - `call` writes evidence into the RD or QA artifact. Solo never pastes secrets, full request/response bodies, or session tokens into the handoff capsule.
38
+ - `rollback` is the recovery action when an install or update made things worse. The backup path is the one Peaks reported during `apply`.
39
+
40
+ ## Refactor workflow wiring
41
+
42
+ For `peaks-solo refactor` runs against a repository with `openspec/`:
43
+
44
+ 1. RD entry gate — `peaks openspec validate <id>` must pass and `peaks openspec to-rd <id>` must return `acceptance.length > 0`.
45
+ 2. Each slice must reference one OpenSpec tasks section as its commit boundary (per `references/openspec-commit-boundaries.md` in peaks-sc).
46
+ 3. QA exit gate — re-run `peaks openspec validate <id>` after implementation; record the result in the QA validation report.
47
+ 4. Archive — `peaks openspec archive <id> --apply` only after QA passes the exit gate and SC closes the final commit.
48
+
49
+ If MCP servers are needed for docs lookup or research, Solo coordinates the one-time install before RD starts so RD does not block on capability resolution mid-slice.
50
+
51
+ ## Boundary
52
+
53
+ Solo must not write `openspec/changes/**` or `~/.claude/settings.json` directly. Every mutation goes through the CLI commands above. The CLI returns stable envelopes; Solo captures them as artifact links rather than re-explaining their content in the handoff.
@@ -21,7 +21,7 @@ A code workflow is not complete until Solo has linked or summarized:
21
21
  6. security-review evidence;
22
22
  7. RD post-check dry-run evidence;
23
23
  8. QA API validation when applicable;
24
- 9. sanitized QA headed `gstack/browse/dist/browse` browser E2E evidence for frontend projects, with mandatory visible-browser confirmation and without login URLs, cookies, headers, tokens, storage state, browser traces, or PII/SSO/MFA screenshots/logs;
24
+ 9. sanitized QA Playwright MCP browser E2E evidence for frontend projects (`mcp__playwright__browser_snapshot` / `take_screenshot` / `list_console_messages` / `list_network_requests`), with mandatory visible-browser confirmation and without login URLs, cookies, headers, tokens, storage state, browser traces, or PII/SSO/MFA screenshots/logs;
25
25
  10. QA security, performance, and validation report evidence;
26
26
  11. RD repair evidence for every failed, blocked, missing, or unverified QA item;
27
27
  12. final QA report showing all acceptance items passed, or a blocked TXT handoff;