peaks-cli 1.3.2 → 1.3.4
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.
- package/README.md +6 -2
- package/dist/src/cli/commands/core-artifact-commands.js +6 -3
- package/dist/src/cli/commands/gate-commands.js +28 -19
- package/dist/src/cli/commands/hook-handle.d.ts +17 -0
- package/dist/src/cli/commands/hook-handle.js +111 -0
- package/dist/src/cli/commands/hooks-commands.js +72 -21
- package/dist/src/cli/commands/progress-commands.js +9 -2
- package/dist/src/cli/commands/progress-start-spawn.js +30 -4
- package/dist/src/cli/commands/project-commands.js +8 -4
- package/dist/src/cli/commands/statusline-commands.js +75 -17
- package/dist/src/cli/commands/sub-agent-commands.d.ts +5 -0
- package/dist/src/cli/commands/sub-agent-commands.js +488 -0
- package/dist/src/cli/commands/sub-agent-dispatch-guard.d.ts +55 -0
- package/dist/src/cli/commands/sub-agent-dispatch-guard.js +57 -0
- package/dist/src/cli/commands/workflow-commands.js +2 -1
- package/dist/src/cli/commands/workspace-commands.js +3 -0
- package/dist/src/cli/program.js +9 -0
- package/dist/src/hooks/pre-tool-use-sub-agent.d.ts +28 -0
- package/dist/src/hooks/pre-tool-use-sub-agent.js +105 -0
- package/dist/src/services/config/config-types.d.ts +1 -1
- package/dist/src/services/context/artifact-meta.d.ts +72 -0
- package/dist/src/services/context/artifact-meta.js +105 -0
- package/dist/src/services/context/context-guard.d.ts +49 -0
- package/dist/src/services/context/context-guard.js +91 -0
- package/dist/src/services/context/dispatch-context-guard.d.ts +27 -0
- package/dist/src/services/context/dispatch-context-guard.js +192 -0
- package/dist/src/services/context/headroom-client.d.ts +34 -0
- package/dist/src/services/context/headroom-client.js +117 -0
- package/dist/src/services/context/shared-channel.d.ts +92 -0
- package/dist/src/services/context/shared-channel.js +285 -0
- package/dist/src/services/context/threshold.d.ts +35 -0
- package/dist/src/services/context/threshold.js +76 -0
- package/dist/src/services/dashboard/project-dashboard-service.d.ts +23 -0
- package/dist/src/services/dashboard/project-dashboard-service.js +21 -0
- package/dist/src/services/dispatch/batch-counter.d.ts +27 -0
- package/dist/src/services/dispatch/batch-counter.js +85 -0
- package/dist/src/services/dispatch/dispatch-record-writer.d.ts +93 -0
- package/dist/src/services/dispatch/dispatch-record-writer.js +261 -0
- package/dist/src/services/dispatch/heartbeat-truncator.d.ts +26 -0
- package/dist/src/services/dispatch/heartbeat-truncator.js +13 -0
- package/dist/src/services/dispatch/leak-detector.d.ts +11 -0
- package/dist/src/services/dispatch/leak-detector.js +72 -0
- package/dist/src/services/dispatch/sub-agent-dispatcher.d.ts +127 -0
- package/dist/src/services/dispatch/sub-agent-dispatcher.js +98 -0
- package/dist/src/services/ide/adapters/claude-code-adapter.d.ts +18 -0
- package/dist/src/services/ide/adapters/claude-code-adapter.js +80 -0
- package/dist/src/services/ide/adapters/trae-adapter.d.ts +42 -0
- package/dist/src/services/ide/adapters/trae-adapter.js +98 -0
- package/dist/src/services/ide/hook-protocol.d.ts +47 -0
- package/dist/src/services/ide/hook-protocol.js +74 -0
- package/dist/src/services/ide/hook-translator.d.ts +72 -0
- package/dist/src/services/ide/hook-translator.js +128 -0
- package/dist/src/services/ide/ide-detector.d.ts +10 -0
- package/dist/src/services/ide/ide-detector.js +19 -0
- package/dist/src/services/ide/ide-registry.d.ts +14 -0
- package/dist/src/services/ide/ide-registry.js +45 -0
- package/dist/src/services/ide/ide-types.d.ts +180 -0
- package/dist/src/services/ide/ide-types.js +2 -0
- package/dist/src/services/ide/resource-profile.d.ts +52 -0
- package/dist/src/services/ide/resource-profile.js +33 -0
- package/dist/src/services/ide/shared/atomic-json.d.ts +15 -0
- package/dist/src/services/ide/shared/atomic-json.js +58 -0
- package/dist/src/services/ide/shared/safe-path.d.ts +11 -0
- package/dist/src/services/ide/shared/safe-path.js +29 -0
- package/dist/src/services/memory/project-context-service.js +2 -1
- package/dist/src/services/memory/project-memory-service.js +4 -3
- package/dist/src/services/perf/perf-baseline-service.js +2 -1
- package/dist/src/services/progress/progress-service.d.ts +1 -1
- package/dist/src/services/progress/progress-service.js +18 -14
- package/dist/src/services/security/safe-settings-path.d.ts +12 -0
- package/dist/src/services/security/safe-settings-path.js +104 -0
- package/dist/src/services/session/getSessionDir.d.ts +1 -0
- package/dist/src/services/session/getSessionDir.js +27 -0
- package/dist/src/services/session/index.d.ts +1 -0
- package/dist/src/services/session/index.js +1 -0
- package/dist/src/services/signal/cancel-handler.d.ts +14 -0
- package/dist/src/services/signal/cancel-handler.js +76 -0
- package/dist/src/services/skill/resume-detector.d.ts +54 -0
- package/dist/src/services/skill/resume-detector.js +334 -0
- package/dist/src/services/skill/skill-scheduler.d.ts +40 -0
- package/dist/src/services/skill/skill-scheduler.js +53 -0
- package/dist/src/services/skills/hooks-settings-service.d.ts +47 -29
- package/dist/src/services/skills/hooks-settings-service.js +190 -144
- package/dist/src/services/skills/statusline-settings-service.d.ts +33 -6
- package/dist/src/services/skills/statusline-settings-service.js +31 -34
- package/dist/src/services/slice/slice-archive-service.d.ts +20 -0
- package/dist/src/services/slice/slice-archive-service.js +111 -0
- package/dist/src/services/solo/batch-heartbeat-poller.d.ts +51 -0
- package/dist/src/services/solo/batch-heartbeat-poller.js +88 -0
- package/dist/src/services/solo/status-line-renderer.d.ts +34 -0
- package/dist/src/services/solo/status-line-renderer.js +55 -0
- package/dist/src/services/standards/ide-aware-standards-service.d.ts +94 -0
- package/dist/src/services/standards/ide-aware-standards-service.js +89 -0
- package/dist/src/services/standards/project-standards-service.d.ts +1 -2
- package/dist/src/services/workspace/reconcile-service.d.ts +36 -0
- package/dist/src/services/workspace/reconcile-service.js +107 -6
- package/dist/src/services/workspace/reconcile-types.d.ts +12 -0
- package/dist/src/shared/version.d.ts +1 -1
- package/dist/src/shared/version.js +1 -1
- package/package.json +2 -1
- package/scripts/install-skills.mjs +112 -2
- package/skills/peaks-ide/SKILL.md +159 -0
- package/skills/peaks-ide/references/audit-log-helper.md +52 -0
- package/skills/peaks-qa/SKILL.md +153 -55
- package/skills/peaks-qa/references/qa-fanout-contract.md +150 -0
- package/skills/peaks-rd/SKILL.md +134 -62
- package/skills/peaks-solo/SKILL.md +124 -37
- package/skills/peaks-solo/references/browser-workflow.md +22 -20
- package/skills/peaks-solo/references/context-governance.md +144 -0
- package/skills/peaks-solo/references/headroom-integration.md +107 -0
- package/skills/peaks-solo/references/runbook.md +3 -3
- package/skills/peaks-solo/references/sub-agent-dispatch.md +261 -0
- package/skills/peaks-solo/references/swarm-dispatch-contract.md +3 -37
- package/skills/peaks-txt/SKILL.md +17 -0
- package/skills/peaks-ui/SKILL.md +45 -10
|
@@ -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.
|
|
@@ -44,7 +74,7 @@ peaks-solo (orchestrate only)
|
|
|
44
74
|
|
|
45
75
|
| Mode | Swarm side (after PRD) | Repair loop side (RD↔QA) |
|
|
46
76
|
|---|---|---|
|
|
47
|
-
| `full-auto` / `swarm` | `
|
|
77
|
+
| `full-auto` / `swarm` | `peaks sub-agent dispatch <role>` — IDE-agnostic dispatch primitive; CLI returns a tool-call descriptor the LLM executes in its own environment | `peaks sub-agent dispatch <role>` per cycle |
|
|
48
78
|
| `assisted` / `strict` / inline-fallback | Solo executes the role steps inline in the main loop (the `peaks-solo` skill IS the role's owner) | Solo executes inline |
|
|
49
79
|
|
|
50
80
|
In all modes, the work itself follows the same `peaks-rd` and `peaks-qa` contracts. The only difference is whether the role's body is being read by a sub-agent Task prompt or by Solo's own main loop. **Never bypass the role contracts regardless of which path runs.**
|
|
@@ -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` (
|
|
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
|
|
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/<
|
|
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/<
|
|
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/<
|
|
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/<
|
|
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/<
|
|
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/<
|
|
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/<
|
|
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/<
|
|
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
|
{
|
|
@@ -624,42 +654,45 @@ Sub-agent presence in this list = Solo launched a Task for it. Absence = the rol
|
|
|
624
654
|
|
|
625
655
|
In all modes, **the plan must be written to `sc/swarm-plan.json` before any Task call.** Solo updates `.peaks/.active-skill.json` to `gate=swarm-fan-out` at this point.
|
|
626
656
|
|
|
627
|
-
### Sub-agent mechanism (
|
|
657
|
+
### Sub-agent mechanism (IDE-agnostic dispatch, NOT Skill tool)
|
|
628
658
|
|
|
629
|
-
**Solo is itself a skill running in the current session. To invoke a role in the Swarm, Solo MUST
|
|
659
|
+
**Solo is itself a skill running in the current session. To invoke a role in the Swarm, Solo MUST call the IDE-agnostic dispatch primitive `peaks sub-agent dispatch <role>` — NOT the `Skill` tool, NOT any IDE-private sub-agent literal.** The `Skill` tool is single-stack and blocking; using it for "parallel" work was the v1.x illusion of concurrency. The dispatch CLI is the only mechanism that keeps SKILL.md free of IDE-private tool names and lets the same prompt work on every registered IDE.
|
|
630
660
|
|
|
631
|
-
Each sub-agent
|
|
661
|
+
Each sub-agent dispatch call looks like:
|
|
632
662
|
|
|
633
663
|
```
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
664
|
+
peaks sub-agent dispatch <role> \
|
|
665
|
+
--prompt "<paste peaks-<role>/SKILL.md body, minus the self-presence / Step 0 blocks,
|
|
666
|
+
plus the runtime arguments: project=<repo>, session-id=<session-id>, request-id=<rid>, mode=<mode>,
|
|
667
|
+
plus the explicit output contract: 'Write your artefacts to the paths listed below and
|
|
668
|
+
return only the list of paths. Do not call Skill(...). Do not set presence. Do not
|
|
669
|
+
hand back prose.', plus the heartbeat instruction: 'While running, call
|
|
670
|
+
peaks sub-agent heartbeat --record <dispatchRecordPath> --status <state> --progress <pct> --note \"<text>\"
|
|
671
|
+
at least every 30 seconds.'>" \
|
|
672
|
+
--request-id <rid> --session-id <session-id> --project <repo> --json
|
|
643
673
|
```
|
|
644
674
|
|
|
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.
|
|
676
|
+
|
|
645
677
|
The role's required artefact paths (also see peaks-ui/rd/qa SKILL.md and `references/swarm-dispatch-contract.md`):
|
|
646
678
|
|
|
647
679
|
| Role | Writes | Reads (PRD-side) |
|
|
648
680
|
|---|---|---|
|
|
649
|
-
| `ui` | `.peaks/<
|
|
650
|
-
| `rd-planning` | `.peaks/<
|
|
651
|
-
| `qa-test-cases` | `.peaks/<
|
|
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 |
|
|
652
684
|
|
|
653
|
-
**Solo launches all sub-agents in the swarm plan in a single message (multiple
|
|
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.
|
|
654
686
|
|
|
655
|
-
**Hard prohibitions on sub-agents** (also passed in each
|
|
687
|
+
**Hard prohibitions on sub-agents** (also passed in each dispatch prompt):
|
|
656
688
|
|
|
657
689
|
- Do NOT call `Skill(skill="...")` — sub-agents must not recursively activate skills, that defeats the fan-out.
|
|
658
|
-
- 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/<
|
|
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.
|
|
659
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.
|
|
660
692
|
- Do NOT commit, push, install hooks, or apply settings.json mutations. Only Solo holds those permissions.
|
|
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.
|
|
661
694
|
|
|
662
|
-
After every sub-agent
|
|
695
|
+
After every sub-agent dispatch returns, Solo **restores presence** once (not per-agent), then continues to Gate B verification:
|
|
663
696
|
|
|
664
697
|
```bash
|
|
665
698
|
peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-converged
|
|
@@ -681,7 +714,7 @@ Skipping the entire swarm (when `--type` is `config|docs|chore`) is not a degrad
|
|
|
681
714
|
|
|
682
715
|
Before computing the swarm plan, Solo runs the keyword scan deterministically:
|
|
683
716
|
|
|
684
|
-
1. Read `.peaks/<
|
|
717
|
+
1. Read `.peaks/_runtime/<sessionId>/prd/requests/<rid>.md` body.
|
|
685
718
|
2. Lowercase + strip markdown; check regex `\b(页面|组件|表单|弹窗|表格|样式|布局|交互|UI|UX|page|component|form|modal|table|styling|layout|interaction|frontend|前端)\b`.
|
|
686
719
|
3. If match count ≥ 1 → `frontendKeywordHit=true`.
|
|
687
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).
|
|
@@ -706,7 +739,7 @@ After `peaks-rd` finishes any implementation, repair, or code-output slice, Peak
|
|
|
706
739
|
|
|
707
740
|
Solo is itself a skill running in the current session. There are **two distinct mechanisms** in this skill, and they MUST NOT be confused:
|
|
708
741
|
|
|
709
|
-
1. **Swarm fan-out (planning side, after PRD confirmed)** — uses
|
|
742
|
+
1. **Swarm fan-out (planning side, after PRD confirmed)** — uses `peaks sub-agent dispatch <role>` to launch real concurrent sub-agents. The CLI returns a per-IDE tool-call descriptor that the LLM executes in its environment. See "Peaks-Cli Swarm parallel phase" above for the full contract. Sub-agents do NOT call Skill(...) back into the role; they execute the role's instructions inline from the prompt.
|
|
710
743
|
2. **Sequential handoff (execution side, RD↔QA repair loop)** — Solo is the only loop, and after RD or QA finishes (whether as a sub-agent or directly), Solo drives the next step from the orchestrator seat. Do NOT use the `Skill` tool to "reactivate" peaks-rd or peaks-qa in the main loop; doing so is the v1.x anti-pattern that masqueraded as "calling the role" but actually just re-prompted the same session. From v1.3 onward, the main loop drives roles via the CLI gate (`peaks request transition`) and reads back artefacts (`peaks request show ... --json`); the actual RD/QA work is either done inline by Solo (when Solo has just been re-invoked by the user) or by a Task sub-agent (in swarm mode).
|
|
711
744
|
|
|
712
745
|
After RD completes (whether inline or sub-agent), Solo does not stop — it must advance to QA. There is no "RD done, ask the user" state in full-auto mode. The only valid stops are: (a) QA verdict=pass, (b) repair cap hit, (c) explicit user cancel.
|
|
@@ -721,7 +754,7 @@ peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate <curre
|
|
|
721
754
|
|
|
722
755
|
This keeps the CLAUDE.md status header accurate (`Peaks-Cli Skill: peaks-solo`) instead of showing a stale role name. Use the current mode and gate values; the gate may have advanced since startup. Skipping this step causes the header to display the last-known gate permanently.
|
|
723
756
|
|
|
724
|
-
**Full-auto auto-proceed rule**: In the `full-auto` profile, when RD transitions to `qa-handoff`, Solo immediately drives QA — by launching a `
|
|
757
|
+
**Full-auto auto-proceed rule**: In the `full-auto` profile, when RD transitions to `qa-handoff`, Solo immediately drives QA — by launching a `peaks sub-agent dispatch qa` sub-agent carrying the `peaks-qa` body (swarm path), then executing the returned toolCall, or by running QA inline in the main loop (assisted/strict path). Do not pause, do not ask the user, do not summarize RD results as if they were final. The only valid reason to skip QA is when `--type` is `docs` or `chore` (no acceptance surface).
|
|
725
758
|
|
|
726
759
|
A QA report with any failing, blocked, missing, or unverified acceptance item is not a pass.
|
|
727
760
|
|
|
@@ -738,7 +771,7 @@ When `peaks-qa` returns `verdict=return-to-rd`, Solo does NOT manually rewrite R
|
|
|
738
771
|
```
|
|
739
772
|
`spec-locked` is the canonical "needs more RD work" state. The reason is mandatory in repair cycles so the artifact history shows the loop.
|
|
740
773
|
3. Re-launch `peaks-rd` work. Two paths, mode-driven:
|
|
741
|
-
- **Swarm / full-auto**: launch a fresh `
|
|
774
|
+
- **Swarm / full-auto**: launch a fresh `peaks sub-agent dispatch rd` sub-agent (then execute the returned toolCall) with the same `peaks-rd` body used in the Swarm phase, plus the QA findings path so it can read the failure list. Solo restores presence after the sub-agent returns.
|
|
742
775
|
- **Assisted / strict / inline-fallback**: Solo executes the RD repair steps directly in the main loop, since there is no concurrent fan-out to coordinate.
|
|
743
776
|
In both paths, pass the QA findings path so the repair sees what failed.
|
|
744
777
|
4. peaks-rd fixes the reported issues only (red-line scope: do not modify unrelated surfaces), regenerates code-review and security-review evidence if changes touched reviewed surfaces, then transitions `rd → implemented → qa-handoff` again.
|
|
@@ -779,9 +812,9 @@ Before orchestrating an end-to-end code repository workflow, gather the project
|
|
|
779
812
|
|
|
780
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.
|
|
781
814
|
|
|
782
|
-
**CRITICAL — Standards must reflect the project scan.** When generating or updating `CLAUDE.md`, the content must reference concrete findings from `.peaks/<
|
|
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.
|
|
783
816
|
|
|
784
|
-
**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/<
|
|
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.
|
|
785
818
|
|
|
786
819
|
Do not hand-write standards file mutations inside the skill.
|
|
787
820
|
|
|
@@ -808,7 +841,7 @@ It must enforce the shared refactor red lines:
|
|
|
808
841
|
4. split broad refactors into minimal functional slices;
|
|
809
842
|
5. require strict verifiable specs before each slice;
|
|
810
843
|
6. require 100% acceptance for each slice;
|
|
811
|
-
7. require code changes and sanitized intermediate artifacts to be traceable in local `.peaks/<
|
|
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.
|
|
812
845
|
|
|
813
846
|
## Peaks-Cli Quality-gate commands (CLI cheat sheet)
|
|
814
847
|
|
|
@@ -856,3 +889,57 @@ Do not run upstream installer flows, mutate agent settings, or commit `.codegrap
|
|
|
856
889
|
**MCP lifecycle**: `list → plan → apply --yes → call → rollback`. `apply` backs up settings and refuses non-peaks entries unless `--claim` is passed.
|
|
857
890
|
|
|
858
891
|
Detailed rules: `references/external-skill-invocation.md`, `references/openspec-mcp-workflow.md`, `references/workflow.md`, `references/existing-system-extraction.md`. For an informational mapping of peaks artefact paths to the A2A (Agent2Agent) protocol's Task / Artifact / Part / Message / AgentCard vocabulary (no A2A implementation, just a shared naming layer), see `references/a2a-artifact-mapping.md`.
|
|
892
|
+
|
|
893
|
+
## Sub-agent context governance (G7 + G7.7 + G8 + G9 — slice #010)
|
|
894
|
+
|
|
895
|
+
> Slice #010 adds the **layer 3.5** context-governance push to the slice #009 sub-agent dispatch primitives. This section is the MANDATORY reference for the main LLM reducer. Detailed protocol: `references/context-governance.md` + `references/headroom-integration.md`.
|
|
896
|
+
|
|
897
|
+
### G7 — sub-agent context minimal-occupation (metadata-only + 按需 Read)
|
|
898
|
+
|
|
899
|
+
Sub-agent artifacts (rd/tech-doc.md, qa/test-cases/<rid>.md, ui/design-draft.md) MUST NOT be inlined into dispatch records and fed back to the main LLM during reduce.
|
|
900
|
+
|
|
901
|
+
- Sub-agent writes artifact to disk at a known path (path convention: `.peaks/_sub_agents/<sessionId>/artifacts/<rid>-<role>-<idx>.<ext>`).
|
|
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.
|
|
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.
|
|
904
|
+
- Main LLM decides whether to `Read <path>` for full content (LLM tool call, NOT via peaks CLI).
|
|
905
|
+
|
|
906
|
+
Main LLM view format (G7.4.e):
|
|
907
|
+
```
|
|
908
|
+
[peaks-solo] batch 3/3 done in 47.3s
|
|
909
|
+
- rd → .peaks/_sub_agents/2026-06-06-session-5b1095/artifacts/003-rd-001.md (12KB, sha256:abc123) summary: "wrote RD tech-doc with 4 sub-roles"
|
|
910
|
+
- qa-business → .../artifacts/003-qa-business-001.md (8KB, sha256:def456) summary: "wrote 12 API test cases"
|
|
911
|
+
- qa-perf → .../artifacts/003-qa-perf-001.md (5KB, sha256:ghi789) summary: "p95 latency target ≤ 200ms"
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
### G7.7 — headroom-ai integration (opt-in compression)
|
|
915
|
+
|
|
916
|
+
If a sub-agent prompt is too large even after G7 metadata-only (e.g. 1MB artifact description, 5MB mid-prompt analysis), use `--use-headroom`:
|
|
917
|
+
- Default `false` (G7 remains default).
|
|
918
|
+
- Modes: `balanced` (default) | `aggressive` | `conservative`.
|
|
919
|
+
- Failure: `HEADROOM_UNAVAILABLE` warning + G7 metadata-only fallback (NOT blocking).
|
|
920
|
+
|
|
921
|
+
### G8 — cross sub-agent shared channel (dispatcher-mediated indirect signal)
|
|
922
|
+
|
|
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.
|
|
924
|
+
|
|
925
|
+
- Path: `.peaks/_sub_agents/<sessionId>/shared/<batchId>.json`.
|
|
926
|
+
- Two new CLI atoms (NO new top-level CLI): `peaks sub-agent share` + `peaks sub-agent shared-read`.
|
|
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>`.
|
|
928
|
+
|
|
929
|
+
### G9 — forced compression gate (CLI 兜底 + hook double-guard)
|
|
930
|
+
|
|
931
|
+
Threshold table (256K default context capacity):
|
|
932
|
+
|
|
933
|
+
| Threshold | Prompt size | Behavior |
|
|
934
|
+
|---|---|---|
|
|
935
|
+
| 50% (early warn) | ≥ 128KB | Soft warning, suggest `--use-headroom` |
|
|
936
|
+
| **75% (user red line)** | ≥ 192KB | Soft warn + `warnings: ["CONTEXT_NEAR_LIMIT"]` |
|
|
937
|
+
| **80% (hard reject)** | ≥ 204KB | Hard reject `code: "PROMPT_TOO_LARGE"`; `--force` allowed at CLI |
|
|
938
|
+
| 90% (emergency) | ≥ 230KB | Hard reject + `contextWarning: 'high'` |
|
|
939
|
+
|
|
940
|
+
Two layers:
|
|
941
|
+
- **CLI 兜底** — `peaks sub-agent dispatch` validates prompt size; `--force` allowed.
|
|
942
|
+
- **PreToolUse hook** — `peaks sub-agent-dispatch-guard` re-validates; **NO `--force`** at hook layer (RL-30 strict).
|
|
943
|
+
|
|
944
|
+
The sub-agent prompt template (G8.6 + G9 self-check) is in `references/context-governance.md`.
|
|
945
|
+
|
|
@@ -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
|
|
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__
|
|
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 |
|
|
51
|
+
| Verb | peaks mcp call invocation | Notes |
|
|
52
52
|
|---|---|---|
|
|
53
|
-
| Open visible browser and navigate | `
|
|
54
|
-
| Confirm visible browser opened | `
|
|
55
|
-
| Read structured page (text + a11y) | `
|
|
56
|
-
| Click / fill / press key | `
|
|
57
|
-
| Inspect console errors | `
|
|
58
|
-
| Inspect network failures | `
|
|
59
|
-
| Resize viewport for responsive checks | `
|
|
60
|
-
| Capture a full-page screenshot | `
|
|
61
|
-
| Close the session cleanly | `
|
|
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 |
|
|
66
|
+
| Verb | peaks mcp call invocation | Notes |
|
|
66
67
|
|---|---|---|
|
|
67
|
-
| List pages in user's Chrome | `
|
|
68
|
-
| Bring a tab to front | `
|
|
69
|
-
| Screenshot the visible viewport | `
|
|
70
|
-
| Read structured page | `
|
|
71
|
-
| Performance trace | `
|
|
72
|
-
| Lighthouse audit | `
|
|
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 `
|
|
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).
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Context Governance — G7 + G7.7 + G8 + G9 protocol details
|
|
2
|
+
|
|
3
|
+
> Slice #010 (G7 + G7.7 + G8 + G9 context-governance push).
|
|
4
|
+
> See: `.peaks/memory/sub-agent-context-minimal-occupation.md` + `sub-agent-shared-channel-cross-completion.md` + `sub-agent-headroom-forced-compression-gate.md` for the red lines.
|
|
5
|
+
|
|
6
|
+
## G7 — sub-agent context minimal-occupation (metadata-only + 按需 Read)
|
|
7
|
+
|
|
8
|
+
### Path convention
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
.peaks/_sub_agents/<sid>/artifacts/<rid>-<role>-<idx>.<ext>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### ArtifactMeta schema
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
interface ArtifactMeta {
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly size: number;
|
|
20
|
+
readonly sha256: string;
|
|
21
|
+
readonly status: 'created' | 'finalized' | 'partial' | 'failed';
|
|
22
|
+
readonly contentInlined: false; // mandatory literal
|
|
23
|
+
readonly summary: string | null; // ≤ 200 chars
|
|
24
|
+
readonly writtenAt: string;
|
|
25
|
+
readonly rid: string;
|
|
26
|
+
readonly role: string;
|
|
27
|
+
readonly idx: number;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Sub-agent completion protocol (G3 + G7.4.g)
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
On completion:
|
|
35
|
+
1. Write artifact to .peaks/_sub_agents/<sid>/artifacts/<rid>-<role>-<idx>.<ext>
|
|
36
|
+
2. Call `peaks sub-agent dispatch --write-artifact <path>` (or via --write-artifact on dispatch)
|
|
37
|
+
→ CLI computes sha256 + size + writes ArtifactMeta to record
|
|
38
|
+
3. Call `peaks sub-agent share --key "<role>.completed" --value <artifact-meta>` (G8.6)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Main LLM reducer view (G7.4.e)
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
[peaks-solo] batch 3/3 done in 47.3s
|
|
45
|
+
- rd → .peaks/_sub_agents/2026-06-06-session-5b1095/artifacts/003-rd-001.md (12KB, sha256:abc123) summary: "wrote RD tech-doc with 4 sub-roles and dispatcher interface"
|
|
46
|
+
- qa-business → .../artifacts/003-qa-business-001.md (8KB, sha256:def456) summary: "wrote 12 API test cases covering happy + 3 error paths"
|
|
47
|
+
- qa-perf → .../artifacts/003-qa-perf-001.md (5KB, sha256:ghi789) summary: "wrote perf baseline; p95 latency target ≤ 200ms"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Numerical budget
|
|
51
|
+
|
|
52
|
+
| 方案 | Per sub-agent | 3-sub-agent batch | 6-sub-agent batch |
|
|
53
|
+
|---|---|---|---|
|
|
54
|
+
| Old: inline full content | 1MB typical | 3MB | 6MB |
|
|
55
|
+
| **G7 metadata-only (this slice)** | ~200 chars | **600 chars** | **1.2KB** |
|
|
56
|
+
|
|
57
|
+
3000-5000× improvement. Main LLM full-slice context net increase: < 10KB for 5 batches × 6 sub-agents.
|
|
58
|
+
|
|
59
|
+
## G7.7 — headroom-ai integration (opt-in)
|
|
60
|
+
|
|
61
|
+
### `--use-headroom` flag
|
|
62
|
+
|
|
63
|
+
Opt-in flag on `peaks sub-agent dispatch`. Default `false` (G7 metadata-only remains the default).
|
|
64
|
+
|
|
65
|
+
### Mode table
|
|
66
|
+
|
|
67
|
+
| Mode | tokenBudget | Use case |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `balanced` (default) | promptSize * 0.40 / 4 | General sub-agent dispatch |
|
|
70
|
+
| `aggressive` | promptSize * 0.20 / 4 | Last-resort large prompt |
|
|
71
|
+
| `conservative` | promptSize * 0.70 / 4 | Sensitive code analysis |
|
|
72
|
+
|
|
73
|
+
### Failure mode (RL-22d / RL-32)
|
|
74
|
+
|
|
75
|
+
- headroom daemon dead / proxy unreachable / times out
|
|
76
|
+
- → `code: "HEADROOM_UNAVAILABLE"` warning + G7 metadata-only fallback
|
|
77
|
+
- → NOT blocking (warn, then continue dispatch)
|
|
78
|
+
|
|
79
|
+
## G8 — cross sub-agent shared channel
|
|
80
|
+
|
|
81
|
+
### Path convention
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
.peaks/_sub_agents/<sid>/shared/<rid>-<batchId>.json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Two new CLI atoms
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
peaks sub-agent share --batch <batchId> --key <k> --value <json> --json
|
|
91
|
+
Writes a shared entry. Last-write-wins by key. value ≤ 1KB soft warn, ≥ 64KB rejected.
|
|
92
|
+
|
|
93
|
+
peaks sub-agent shared-read --batch <batchId> [--since <iso>] [--key <pattern>] --json
|
|
94
|
+
Reads entries. --key is a glob pattern with * wildcard.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Sub-agent prompt template (G8.6)
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
You are sub-agent role <role>, batch <batchId>.
|
|
101
|
+
|
|
102
|
+
PROTOCOL (mandatory):
|
|
103
|
+
1. On start: peek at shared channel: `peaks sub-agent shared-read --batch <batchId> --json`
|
|
104
|
+
to see what other sub-agents in this batch have shared so far.
|
|
105
|
+
2. While running: if you find a blocker or partial work, write share entry
|
|
106
|
+
`peaks sub-agent share --key "<role>.found-blocker" --value {"reason": "..."}`
|
|
107
|
+
so other in-flight sub-agents can avoid duplicating effort.
|
|
108
|
+
3. On completion: write share entry
|
|
109
|
+
`peaks sub-agent share --key "<role>.completed" --value <artifact-meta>`
|
|
110
|
+
BEFORE the final `peaks sub-agent heartbeat --status done` heartbeat.
|
|
111
|
+
4. The shared channel is your only visibility into sibling sub-agents.
|
|
112
|
+
Do NOT attempt to read other sub-agents' dispatch records directly.
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### RL-23 completion-time mandatory write
|
|
116
|
+
|
|
117
|
+
- When sub-agent calls `peaks sub-agent heartbeat --status done`, it MUST also call `peaks sub-agent share --key "<role>.completed" --value <artifact-meta>`.
|
|
118
|
+
- If sub-agent omits the share, heartbeat still succeeds but emit warning `code: "COMPLETED_WITHOUT_SHARE"`.
|
|
119
|
+
|
|
120
|
+
## G9 — forced compression gate
|
|
121
|
+
|
|
122
|
+
### Threshold table (256K default context capacity)
|
|
123
|
+
|
|
124
|
+
| Threshold | Prompt size | Behavior |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| 50% (early warn) | ≥ 128KB | Soft warning, suggest `--use-headroom` |
|
|
127
|
+
| **75% (user red line)** | ≥ 192KB | Soft warn + mandatory suggest `--use-headroom`; `warnings: ["CONTEXT_NEAR_LIMIT"]` |
|
|
128
|
+
| **80% (hard reject)** | ≥ 204KB | Hard reject `code: "PROMPT_TOO_LARGE"`; `--force` allowed at CLI |
|
|
129
|
+
| 90% (emergency) | ≥ 230KB | Hard reject + `contextWarning: 'high'` |
|
|
130
|
+
|
|
131
|
+
### Two-layer enforcement (G9.2)
|
|
132
|
+
|
|
133
|
+
- **CLI 兜底** — `peaks sub-agent dispatch` validates prompt size; `--force` allowed.
|
|
134
|
+
- **PreToolUse hook** — `peaks sub-agent-dispatch-guard` re-validates; **NO `--force`** allowed at hook layer (RL-30 strict).
|
|
135
|
+
|
|
136
|
+
### `--force` semantics
|
|
137
|
+
|
|
138
|
+
- At CLI: `--force` allowed; emits `code: "FORCED_OVER_THRESHOLD"` warning + records `forcedAt: ISO8601`.
|
|
139
|
+
- At PreToolUse hook: `--force` is REJECTED (RL-30 strict). The hook's CLI does not declare a `--force` flag; the override path is physically not available.
|
|
140
|
+
|
|
141
|
+
## AC mapping
|
|
142
|
+
|
|
143
|
+
- AC-38..AC-43 (G7) + AC-44..AC-46 (G7.7) + AC-47..AC-49 (G8) + AC-50..AC-65 (G9)
|
|
144
|
+
- See PRD §Acceptance criteria.
|