peaks-cli 1.2.4 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/bin/peaks.js +0 -0
  2. package/dist/src/cli/commands/openspec-commands.js +31 -0
  3. package/dist/src/cli/commands/workspace-commands.js +50 -4
  4. package/dist/src/services/config/config-safety.d.ts +26 -0
  5. package/dist/src/services/config/config-safety.js +76 -0
  6. package/dist/src/services/config/config-service.d.ts +1 -1
  7. package/dist/src/services/config/config-service.js +2 -2
  8. package/dist/src/services/memory/project-memory-service.d.ts +18 -0
  9. package/dist/src/services/memory/project-memory-service.js +131 -13
  10. package/dist/src/services/openspec/openspec-init-service.d.ts +23 -0
  11. package/dist/src/services/openspec/openspec-init-service.js +122 -0
  12. package/dist/src/services/session/index.d.ts +1 -1
  13. package/dist/src/services/session/index.js +1 -1
  14. package/dist/src/services/session/session-manager.d.ts +11 -0
  15. package/dist/src/services/session/session-manager.js +19 -0
  16. package/dist/src/services/skills/skill-presence-service.js +11 -0
  17. package/dist/src/services/workspace/workspace-service.d.ts +15 -0
  18. package/dist/src/services/workspace/workspace-service.js +60 -1
  19. package/dist/src/shared/version.d.ts +1 -1
  20. package/dist/src/shared/version.js +1 -1
  21. package/package.json +1 -1
  22. package/skills/peaks-prd/SKILL.md +36 -0
  23. package/skills/peaks-qa/SKILL.md +91 -2
  24. package/skills/peaks-rd/SKILL.md +69 -2
  25. package/skills/peaks-solo/SKILL.md +249 -41
  26. package/skills/peaks-solo/references/a2a-artifact-mapping.md +115 -0
  27. package/skills/peaks-solo/references/swarm-dispatch-contract.md +186 -0
  28. package/skills/peaks-txt/SKILL.md +16 -0
  29. package/skills/peaks-ui/SKILL.md +61 -2
@@ -0,0 +1,186 @@
1
+ # Swarm dispatch contract
2
+
3
+ > Reference for `peaks-solo` Swarm phase and the role sub-agents (`peaks-ui` / `peaks-rd` planning / `peaks-qa` test-cases). Defines the **mechanism** of fan-out: how Solo launches sub-agents, what the sub-agent prompt must contain, what the sub-agent must return, and how Solo reduces the result.
4
+
5
+ ## 1. Why this exists
6
+
7
+ The previous "Swarm" used `Skill(skill="peaks-rd")` calls. That is **single-stack and blocking** — there is no concurrency. Three sequential `Skill` calls run in order on the same main loop, not in parallel. The "parallel Agent calls" wording in the old SKILL.md was a v1.x illusion.
8
+
9
+ This contract moves the Swarm to the `Task` tool with `subagent_type="general-purpose"`, which is the only Claude Code mechanism that gives real concurrent fan-out. Solo launches all sub-agents in a single message; the platform schedules them concurrently.
10
+
11
+ ## 2. When to swarm (decision)
12
+
13
+ Solo runs the swarm only after `peaks request show <rid> --role prd` is in state `confirmed-by-user` or `handed-off`. Before that, there is nothing for the sub-agents to derive from.
14
+
15
+ Solo computes the **swarm plan** from three signals (see "Swarm gate" in the main SKILL.md):
16
+
17
+ 1. `--type` from `peaks request init` (already on the PRD artefact).
18
+ 2. `frontendOnly` from `.peaks/<session-id>/rd/project-scan.md` `## Project mode`.
19
+ 3. Frontend keyword scan over the PRD body.
20
+
21
+ The plan is written to `.peaks/<session-id>/sc/swarm-plan.json` before any Task call, so SC and TXT can audit what was launched. Solo updates `.peaks/.active-skill.json` to `gate=swarm-fan-out` at this point.
22
+
23
+ | `--type` | Frontend signal | Plan |
24
+ |---|---|---|
25
+ | `feature` / `refactor` / `bugfix` | keyword hit OR `frontendOnly=true` | `[ui, rd-planning, qa-test-cases]` |
26
+ | `feature` / `refactor` / `bugfix` | no keyword hit AND `frontendOnly=false` | `[rd-planning, qa-test-cases]` |
27
+ | `config` / `docs` / `chore` | (any) | `[]` (swarm skipped, recorded in plan) |
28
+
29
+ In `assisted` and `strict` modes, Solo replaces signal (3) with a three-option `AskUserQuestion` (see "Mode-driven fan-out shape" in the main SKILL.md) and uses the user's choice as the plan.
30
+
31
+ ## 3. Sub-agent invocation template
32
+
33
+ Solo emits one Task call per sub-agent in the plan, all in the same message:
34
+
35
+ ```js
36
+ Task({
37
+ subagent_type: "general-purpose",
38
+ description: "<role> for rid=<rid>",
39
+ prompt: <see role-specific sections below>
40
+ })
41
+ ```
42
+
43
+ ### 3.1 Common prompt header (all sub-agents)
44
+
45
+ ```
46
+ You are a sub-agent invoked by peaks-solo. You are NOT the main Claude session.
47
+ Your job: execute ONE role from the peaks skill family and write its artefact(s).
48
+ Return a compact JSON envelope — do not write prose.
49
+
50
+ ## Hard prohibitions
51
+ - Do NOT call Skill(skill="..."). You are the role.
52
+ - Do NOT call `peaks skill presence:set` — the main loop owns .peaks/.active-skill.json.
53
+ If you need to record state, write to .peaks/<session-id>/system/sub-agent-<role>.json.
54
+ - Do NOT commit, push, install hooks, or apply settings.json mutations.
55
+ - Do NOT ask the user interactive questions. If you need clarification, return
56
+ {"status":"blocked","blockedReason":"<text>"} and let the main loop handle it.
57
+
58
+ ## Runtime arguments (provided by Solo)
59
+ - project: <repo> (git repo root, NOT a sub-package)
60
+ - session-id: <sid> (from .peaks/.active-skill.json or .peaks/.session.json)
61
+ - request-id: <rid> (PRD id)
62
+ - type: <type> (feature | bugfix | refactor | config | docs | chore)
63
+ - mode: <mode> (full-auto | swarm | assisted | strict)
64
+ - project-scan-path: <path> (read this for component library / CSS / build tool)
65
+ - existing-system-path: <path> (legacy projects only)
66
+ - frontendOnly: <bool> (from project-scan)
67
+ - frontendKeywordHit: <bool> (Solo's PRD scan result)
68
+ ```
69
+
70
+ ### 3.2 peaks-ui sub-agent prompt
71
+
72
+ Append after the common header:
73
+
74
+ ```
75
+ ## Role: UI design direction
76
+ You are running peaks-ui. Produce design direction, not code. RD will implement.
77
+
78
+ Steps:
79
+ 1. peaks request init --role ui --id <rid> --project <repo> --apply --type <type> --json
80
+ 2. peaks request show <rid> --role prd --project <repo> --json
81
+ 3. Read <project-scan-path> for component library / CSS framework.
82
+ 4. Run the prototype fidelity gate: Figma file? PRD visuals? Headed browser?
83
+ 5. Write TWO artefacts:
84
+ - .peaks/<sid>/ui/design-draft.md
85
+ - .peaks/<sid>/ui/requests/<rid>.md
86
+ 6. Return:
87
+ {
88
+ "role": "ui",
89
+ "rid": "<rid>",
90
+ "status": "ok" | "blocked" | "skipped",
91
+ "artefacts": [".peaks/<sid>/ui/design-draft.md", ".peaks/<sid>/ui/requests/<rid>.md"],
92
+ "warnings": [],
93
+ "blockedReason": null
94
+ }
95
+
96
+ If you determine the request is non-visual (no UI surface, no design impact),
97
+ return {"status":"skipped","reason":"non-frontend-request"} so Solo can record
98
+ the misfire in sc/swarm-plan.json.
99
+ ```
100
+
101
+ ### 3.3 peaks-rd (planning) sub-agent prompt
102
+
103
+ ```
104
+ ## Role: RD planning
105
+ You are running peaks-rd's planning step. Produce the planning artefact, not code.
106
+ Code is written in a later sub-agent or inline run.
107
+
108
+ Steps:
109
+ 1. peaks request init --role rd --id <rid> --project <repo> --apply --type <type> --json
110
+ 2. peaks request show <rid> --role prd --project <repo> --json
111
+ 3. peaks request show <rid> --role ui --project <repo> --json (if ui in plan)
112
+ 4. Read <project-scan-path>. If absent and Solo did not pre-create it, create it
113
+ by running `peaks scan archetype --project <repo> --json` and copying the JSON
114
+ into rd/project-scan.md.
115
+ 5. Read <existing-system-path> if archetype is legacy-*.
116
+ 6. Write the type-appropriate planning artefact:
117
+ - feature | refactor → .peaks/<sid>/rd/tech-doc.md
118
+ - bugfix → .peaks/<sid>/rd/bug-analysis.md
119
+ - config | docs | chore → no planning artefact required. Return skipped.
120
+ 7. Return:
121
+ {
122
+ "role": "rd-planning",
123
+ "rid": "<rid>",
124
+ "status": "ok" | "blocked" | "skipped",
125
+ "artefacts": [".peaks/<sid>/rd/tech-doc.md"], // or [] when skipped
126
+ "warnings": [],
127
+ "blockedReason": null
128
+ }
129
+ ```
130
+
131
+ ### 3.4 peaks-qa (test-cases) sub-agent prompt
132
+
133
+ ```
134
+ ## Role: QA test-case generation (planning, not execution)
135
+ You are running peaks-qa's planning step. Produce test cases, do NOT execute them.
136
+ The execution step runs after RD implementation in a separate sub-agent.
137
+
138
+ Steps:
139
+ 1. peaks request init --role qa --id <rid> --project <repo> --apply --type <type> --json
140
+ 2. peaks request show <rid> --role prd --project <repo> --json
141
+ 3. peaks request show <rid> --role rd --project <repo> --json
142
+ 4. Read <project-scan-path>.
143
+ 5. Write .peaks/<sid>/qa/test-cases/<rid>.md with test cases linked to PRD
144
+ acceptance items (use **Acceptance:** A1, A2 style).
145
+ 6. Return:
146
+ {
147
+ "role": "qa-test-cases",
148
+ "rid": "<rid>",
149
+ "status": "ok" | "blocked" | "skipped",
150
+ "artefacts": [".peaks/<sid>/qa/test-cases/<rid>.md"],
151
+ "warnings": [],
152
+ "blockedReason": null
153
+ }
154
+
155
+ If --type is docs|chore, return {"status":"skipped","reason":"type=<type>"} —
156
+ no acceptance surface to plan tests for.
157
+ ```
158
+
159
+ ## 4. Reducer (Solo side)
160
+
161
+ After all sub-agent Tasks return, Solo:
162
+
163
+ 1. Restores presence ONCE (not per-agent):
164
+ ```
165
+ peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-converged
166
+ ```
167
+ 2. Runs `ls` checks against `sc/swarm-plan.json` — every promised artefact must exist (Gate B hard). If any are missing, apply the degradation rules in "Degradation when swarm roles fail or are absent" (main SKILL.md).
168
+ 3. Updates `sc/swarm-plan.json` with the final status of each sub-agent (ok / blocked / skipped / error).
169
+ 4. Advances to step 4 (RD implementation) with all the artefacts in hand.
170
+
171
+ ## 5. Presence restoration (single-shot)
172
+
173
+ Sub-agents are explicitly forbidden from calling `peaks skill presence:set`. That means `.peaks/.active-skill.json` does not move during the fan-out. Solo sets it to `gate=swarm-fan-out` before fan-out and to `gate=swarm-converged` once after all Tasks return. The status header (the `Peaks-Cli Skill: peaks-solo | Peaks-Cli Gate: <gate>` line) therefore reads consistently across the fan-out window.
174
+
175
+ If a sub-agent is misbehaving and writes to `.peaks/.active-skill.json` anyway, the next Solo presence-set (after fan-out) overwrites it — the bug self-heals on the next gate advance, but the swarm-phase display may be off. The hard prohibition is there to prevent this; Solo should still treat the file as a single-writer resource.
176
+
177
+ ## 6. Why not a `peaks-swarm` skill?
178
+
179
+ A skill cannot itself trigger sub-agents — the Skill tool runs in the main loop. The orchestrator (peaks-solo) has to be in the main loop and has to use the Task tool directly. Putting swarm logic into a separate skill would either re-introduce the "single-stack blocking" anti-pattern or require a custom slash command that bypasses the Skill tool. The current design keeps swarm control in peaks-solo where it belongs.
180
+
181
+ ## 7. Tests / dogfood
182
+
183
+ - `peaks scan archetype --project <repo> --json` must keep emitting `frontendOnly` and `frontendOnlyReason`. Both fields are read here and by the existing pre-RD scan contract.
184
+ - `peaks request show <rid> --role prd --json` must surface the `--type` chosen at `peaks request init`. Sub-agents pass it through unchanged.
185
+ - `peaks skill presence:set` must remain single-writer-friendly (the sub-agents do not call it).
186
+ - Smoke test: a full-auto peaks-solo run on a `legacy-frontend` project with a UI-affecting PRD should produce `sc/swarm-plan.json` containing all three sub-agents and three corresponding artefacts in `ui/`, `rd/`, `qa/`.
@@ -207,12 +207,28 @@ peaks capabilities --json
207
207
 
208
208
  # 6. Memory extraction — --apply is REQUIRED to write .peaks/memory
209
209
  # (without --apply the command only previews; the directory will NOT be created)
210
+ # You MUST scan the handoff capsule for embedded memory blocks FIRST. If none
211
+ # are present, the step is a no-op (the command succeeds with extractedCount=0
212
+ # and writes nothing). If blocks are present, --apply writes them and the
213
+ # index is regenerated.
214
+ grep -c "peaks-memory:start" .peaks/<id>/txt/handoff.md || true # skill-side scan; do NOT add a new CLI
210
215
  peaks memory extract --project <repo> --artifact .peaks/<id>/txt/handoff.md --apply --json
211
216
  peaks skill presence:clear --project <repo> # handoff capsule complete, remove presence indicator
212
217
  ```
213
218
 
214
219
  `peaks memory extract --apply` writes to `.peaks/memory` (without `--apply` it only previews). The handoff capsule `.peaks/<id>/txt/handoff.md` is the primary artifact for extraction — embed `<!-- peaks-memory:start -->` blocks in it for stable project facts before running extract.
215
220
 
221
+ ### Memory block embedding rule (BLOCKING — read before writing the handoff)
222
+
223
+ Every handoff capsule you emit **MUST** include the scan for stable facts. The minimum acceptable is:
224
+
225
+ - Run `grep -c 'peaks-memory:start' .peaks/<id>/txt/handoff.md` after writing the capsule body.
226
+ - If the count is 0 AND this session surfaced a stable project fact (an architectural decision, a stack constraint, a naming convention, a refactor approved by the user, an API pattern, a hard rule from RD/QA review), you MUST go back and embed at least one `<!-- peaks-memory:start -->` block before declaring TXT complete. Skipping the block is a workflow violation.
227
+ - If the count is 0 AND no stable fact was surfaced (pure analysis, no code touched, all transient), it is acceptable to skip embedding — but you MUST still run `peaks memory extract --apply` so the artefact state stays consistent (the command will be a no-op write, that's fine).
228
+ - If the count is ≥ 1, the `--apply` extract will write one markdown per block to `.peaks/memory/` and regenerate `index.json`. The user sees the durable persistence; that is the entire point of this step.
229
+
230
+ This rule is the skill-side half of the **Skill is primary, CLI is auxiliary** contract: the LLM is responsible for embedding blocks (skill prompt, no CLI can decide what is stable), and the CLI is responsible for atomic persistence (`peaks memory extract --apply`, single shot, structured JSON envelope).
231
+
216
232
  ### Transition verification gates (MANDATORY — run the command, see the output)
217
233
 
218
234
  You cannot declare TXT complete from memory. Each gate below is a `ls` command you **MUST run** and whose output you **MUST see** before proceeding.
@@ -7,9 +7,68 @@ description: UI and experience skill for Peaks. Use when a workflow touches UI/U
7
7
 
8
8
  Peaks-Cli UI handles experience, interaction, visual direction, and UI-specific refactor artifacts.
9
9
 
10
- ## Skill presence (MANDATORY first action)
10
+ ## Hard contracts for browser inspection (BLOCKING read before any browser_take_screenshot / login flow)
11
11
 
12
- Before any analysis or tool call, immediately run:
12
+ UI's headed-browser work (visual inspection, regression seed capture, Figma / live-page cross-check) follows the same two contracts as `peaks-qa` and `peaks-rd`. The contracts are defined in full in `peaks-qa` ("Hard contracts for browser validation"); UI inherits them.
13
+
14
+ ### Contract 1 — Inspection screenshots must land under .peaks/<sid>/qa/screenshots/
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:
17
+
18
+ ```bash
19
+ ls .peaks/<sid>/qa/screenshots/*.png 2>&1
20
+ find . -maxdepth 1 -name '*.png' 2>&1
21
+ ```
22
+
23
+ `find` must be empty; any project-root `.png` is a leak and must be moved into the screenshots directory before completing this skill.
24
+
25
+ ### Contract 2 — Login / CAPTCHA / SSO / MFA wall is a hard block, not a skip
26
+
27
+ UI's headed-browser inspection hits the same auth walls. The flow is identical to QA: `AskUserQuestion` with three options (logged in / skip / cancel); no silent downgrade to static screenshots, no inferring login from DOM state. The full hard-block contract is defined in `peaks-qa`; UI inherits it.
28
+
29
+ ## Sub-agent dispatch (when launched by peaks-solo swarm)
30
+
31
+ When this skill is launched as a sub-agent via `Task(subagent_type="general-purpose", ...)` from `peaks-solo`, the following sections of THIS skill are **suspended** for the sub-agent run:
32
+
33
+ - **Skill presence (MANDATORY first action)** — do NOT call `peaks skill presence:set peaks-ui`. The sub-agent must not overwrite `.peaks/.active-skill.json`; the main Solo loop owns that file. If you need to mark your own state, write a marker file at `.peaks/<session-id>/system/sub-agent-ui.json` and only that.
34
+ - **Workspace initialization** — Solo has already run `peaks workspace init` before fan-out. Do not re-run it.
35
+ - **Mode selection** — Solo has already chosen the mode.
36
+ - **Statusline install** — already done by Solo at session startup.
37
+
38
+ What the sub-agent **MUST** still do:
39
+
40
+ 0. **Do NOT call `peaks request init`** — Solo has already initialised the request artefact slot in the main loop before fan-out. The sub-agent reads it via `peaks request show <rid> --role ui --project <repo> --json` if it needs to.
41
+ 2. `peaks request show <rid> --role prd --project <repo> --json` to read the PRD scope.
42
+ 3. Read project-scan (`rd/project-scan.md`) for component library, CSS framework, design-system context.
43
+ 4. Run the prototype fidelity check (Figma / PRD visuals / headed browser).
44
+ 5. Write the two artefacts: `.peaks/<session-id>/ui/design-draft.md` and `.peaks/<session-id>/ui/requests/<rid>.md`.
45
+ 6. Return only a compact JSON envelope:
46
+
47
+ ```json
48
+ {
49
+ "role": "ui",
50
+ "rid": "<rid>",
51
+ "status": "ok" | "blocked" | "skipped",
52
+ "artefacts": [".peaks/<sid>/ui/design-draft.md", ".peaks/<sid>/ui/requests/<rid>.md"],
53
+ "warnings": [],
54
+ "blockedReason": null
55
+ }
56
+ ```
57
+
58
+ **Hard prohibitions** (sub-agent context):
59
+
60
+ - Do NOT call `Skill(skill="...")`.
61
+ - Do NOT call `peaks skill presence:set` — Solo owns the active-skill file.
62
+ - Do NOT modify application code. UI is design-direction only; the actual frontend code is written in the RD implementation phase.
63
+ - Do NOT install MCP servers. If `peaks mcp list` shows playwright-mcp missing and the headed browser is required, return `{"status":"blocked","blockedReason":"playwright-mcp-unavailable"}` and let Solo escalate to the user.
64
+ - Do NOT commit, push, install hooks, or apply settings.json mutations.
65
+ - Do NOT ask the user interactive questions. If you need clarification, return `{"status":"blocked","blockedReason":"<text>"}`.
66
+
67
+ If the request does not affect user-visible behavior (no frontend keyword hit, `frontendOnly=false`), the swarm plan should not include UI at all — Solo will not launch this sub-agent. But if it does launch you and you determine the work is non-visual, return `{"status":"skipped","reason":"non-frontend-request"}` so Solo can record the misfire.
68
+
69
+ ## Skill presence (MANDATORY first action — main-loop context only)
70
+
71
+ When this skill is running in the main Claude session (not as a sub-agent), before any analysis or tool call, immediately run:
13
72
 
14
73
  ```bash
15
74
  peaks skill presence:set peaks-ui --project <repo> --mode <mode> --gate startup