peaks-cli 1.3.7 → 1.3.9

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 (98) hide show
  1. package/dist/src/cli/commands/core-artifact-commands.js +119 -14
  2. package/dist/src/cli/commands/project-commands.js +58 -1
  3. package/dist/src/cli/commands/request-commands.js +124 -4
  4. package/dist/src/cli/commands/retrospective-commands.d.ts +3 -0
  5. package/dist/src/cli/commands/retrospective-commands.js +113 -0
  6. package/dist/src/cli/program.js +2 -0
  7. package/dist/src/services/artifacts/request-artifact-service.d.ts +16 -0
  8. package/dist/src/services/artifacts/request-artifact-service.js +18 -2
  9. package/dist/src/services/memory/project-memory-service.d.ts +19 -0
  10. package/dist/src/services/memory/project-memory-service.js +33 -0
  11. package/dist/src/services/retrospective/migrate-from-md.d.ts +37 -0
  12. package/dist/src/services/retrospective/migrate-from-md.js +528 -0
  13. package/dist/src/services/retrospective/retrospective-index.d.ts +37 -0
  14. package/dist/src/services/retrospective/retrospective-index.js +110 -0
  15. package/dist/src/services/retrospective/retrospective-show.d.ts +40 -0
  16. package/dist/src/services/retrospective/retrospective-show.js +109 -0
  17. package/dist/src/services/session/caller-binding-service.d.ts +70 -0
  18. package/dist/src/services/session/caller-binding-service.js +148 -0
  19. package/dist/src/services/session/caller-id-types.d.ts +77 -0
  20. package/dist/src/services/session/caller-id-types.js +46 -0
  21. package/dist/src/services/session/index.d.ts +4 -0
  22. package/dist/src/services/session/index.js +5 -0
  23. package/dist/src/services/session/platform-fallbacks.d.ts +31 -0
  24. package/dist/src/services/session/platform-fallbacks.js +35 -0
  25. package/dist/src/services/session/resolve-caller-id.d.ts +57 -0
  26. package/dist/src/services/session/resolve-caller-id.js +88 -0
  27. package/dist/src/services/skills/skill-presence-service.d.ts +11 -0
  28. package/dist/src/services/skills/skill-presence-service.js +59 -0
  29. package/dist/src/shared/format-md-compact.d.ts +32 -0
  30. package/dist/src/shared/format-md-compact.js +297 -0
  31. package/dist/src/shared/stale-policy.d.ts +67 -0
  32. package/dist/src/shared/stale-policy.js +85 -0
  33. package/dist/src/shared/version.d.ts +1 -1
  34. package/dist/src/shared/version.js +1 -1
  35. package/package.json +1 -1
  36. package/skills/peaks-qa/SKILL.md +86 -515
  37. package/skills/peaks-qa/references/artifact-per-request.md +7 -79
  38. package/skills/peaks-qa/references/browser-validation-contracts.md +51 -0
  39. package/skills/peaks-qa/references/codegraph-regression-focus.md +5 -0
  40. package/skills/peaks-qa/references/external-capability-guidance.md +9 -0
  41. package/skills/peaks-qa/references/qa-compact-handoff.md +3 -0
  42. package/skills/peaks-qa/references/qa-context-governance.md +24 -0
  43. package/skills/peaks-qa/references/qa-fanout-contract.md +8 -0
  44. package/skills/peaks-qa/references/qa-gstack-integration.md +7 -0
  45. package/skills/peaks-qa/references/qa-local-artifacts.md +3 -0
  46. package/skills/peaks-qa/references/qa-matt-pocock-integration.md +9 -0
  47. package/skills/peaks-qa/references/qa-refactor-role.md +3 -0
  48. package/skills/peaks-qa/references/qa-runbook.md +74 -0
  49. package/skills/peaks-qa/references/qa-skill-presence.md +22 -0
  50. package/skills/peaks-qa/references/qa-standards-preflight.md +8 -0
  51. package/skills/peaks-qa/references/qa-sub-agent-dispatch.md +38 -0
  52. package/skills/peaks-qa/references/qa-transition-gates.md +79 -0
  53. package/skills/peaks-qa/references/requirement-boundary-recheck.md +9 -0
  54. package/skills/peaks-qa/references/test-case-generation.md +27 -0
  55. package/skills/peaks-qa/references/test-report-output.md +14 -0
  56. package/skills/peaks-rd/SKILL.md +85 -732
  57. package/skills/peaks-rd/references/artifact-and-standards-output.md +9 -0
  58. package/skills/peaks-rd/references/artifact-per-request.md +20 -0
  59. package/skills/peaks-rd/references/browser-self-test-contracts.md +29 -0
  60. package/skills/peaks-rd/references/codegraph-project-analysis.md +5 -0
  61. package/skills/peaks-rd/references/compact-handoff.md +3 -0
  62. package/skills/peaks-rd/references/external-references.md +11 -0
  63. package/skills/peaks-rd/references/frontend-project-generation.md +11 -0
  64. package/skills/peaks-rd/references/library-version-awareness.md +30 -0
  65. package/skills/peaks-rd/references/mandatory-perf-baseline.md +40 -0
  66. package/skills/peaks-rd/references/mandatory-tech-doc.md +18 -0
  67. package/skills/peaks-rd/references/matt-pocock-integration.md +11 -0
  68. package/skills/peaks-rd/references/mock-data-placement.md +40 -0
  69. package/skills/peaks-rd/references/parallel-review-fanout.md +81 -0
  70. package/skills/peaks-rd/references/rd-context-governance.md +36 -0
  71. package/skills/peaks-rd/references/rd-gstack-integration.md +16 -0
  72. package/skills/peaks-rd/references/rd-runbook.md +125 -0
  73. package/skills/peaks-rd/references/rd-standards-preflight.md +8 -0
  74. package/skills/peaks-rd/references/rd-sub-agent-dispatch.md +39 -0
  75. package/skills/peaks-rd/references/rd-transition-gates.md +148 -0
  76. package/skills/peaks-rd/references/skill-presence-and-title.md +22 -0
  77. package/skills/peaks-solo/SKILL.md +87 -786
  78. package/skills/peaks-solo/references/anchoring-and-session-info.md +25 -0
  79. package/skills/peaks-solo/references/boundaries.md +21 -0
  80. package/skills/peaks-solo/references/codegraph-orchestration.md +5 -0
  81. package/skills/peaks-solo/references/completion-handoff.md +16 -0
  82. package/skills/peaks-solo/references/context-governance.md +51 -0
  83. package/skills/peaks-solo/references/external-references.md +17 -0
  84. package/skills/peaks-solo/references/frontend-only-mode.md +87 -0
  85. package/skills/peaks-solo/references/gstack-integration.md +7 -0
  86. package/skills/peaks-solo/references/local-artifact-workspace.md +79 -0
  87. package/skills/peaks-solo/references/micro-cycle.md +68 -0
  88. package/skills/peaks-solo/references/mode-selection.md +21 -0
  89. package/skills/peaks-solo/references/openspec-workflow.md +43 -0
  90. package/skills/peaks-solo/references/project-memory-loading.md +17 -0
  91. package/skills/peaks-solo/references/project-scan-checklist.md +136 -0
  92. package/skills/peaks-solo/references/quality-gate-cheatsheet.md +13 -0
  93. package/skills/peaks-solo/references/resume-detection.md +63 -0
  94. package/skills/peaks-solo/references/runbook.md +1 -1
  95. package/skills/peaks-solo/references/skill-presence-and-title.md +31 -0
  96. package/skills/peaks-solo/references/standards-preflight.md +23 -0
  97. package/skills/peaks-solo/references/sub-agent-dispatch.md +46 -0
  98. package/skills/peaks-solo/references/swarm-dispatch-contract.md +56 -0
@@ -0,0 +1,136 @@
1
+ # Peaks-Cli Pre-RD project scan checklist
2
+
3
+ > Extracted from `skills/peaks-solo/SKILL.md` on 2026-06-09 (slice 019 — slim skill files to references) to keep SKILL.md under the 800-line cap from `common/coding-style.md`. The content below is the verbatim Pre-RD project scan checklist that was previously inline; nothing was paraphrased, just relocated.
4
+
5
+ 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.
6
+
7
+ ### 0. Project archetype detection (MANDATORY — run FIRST, deterministic CLI)
8
+
9
+ Run the CLI; do NOT infer the archetype from prompts. Record the JSON output as `## Archetype` and `## Project mode` in `project-scan.md`. Later gates (frontend-only mode, visual system extraction, standards generation) read these fields.
10
+
11
+ ```bash
12
+ peaks scan archetype --project <repo> --json
13
+ ```
14
+
15
+ The command emits a stable JSON envelope with these fields you copy verbatim into `project-scan.md`:
16
+
17
+ - `archetype`: `greenfield | legacy-frontend | legacy-fullstack | frontend-monorepo | unknown`
18
+ - `confidence`: `high | medium | low`
19
+ - `frontendOnly`: `true | false`
20
+ - `frontendOnlyReason`: short string explaining the decision
21
+ - `signals[]`: each signal's name, matched flag, and detail (paste under `## Archetype → Signals matched`)
22
+ - `detected`: raw filesystem facts (package.json presence, backend frameworks, swagger paths, monorepo configs, src file count, lockfile age)
23
+
24
+ If `archetype` is `unknown`, STOP and surface to the user as an open question in the TXT handoff — do NOT guess. If `confidence` is `low`, note the uncertainty in `project-scan.md` and confirm the choice with the user before proceeding.
25
+
26
+ The CLI is the sole source of truth for archetype and frontend-only-mode decisions. Manual heuristics in older versions of this skill are superseded by the CLI output.
27
+
28
+ ### 1. Build tool: inspect config files for the framework
29
+
30
+ | Config file | Framework |
31
+ |---|---|
32
+ | `.umirc.ts`, `config/config.ts` | Umi (Ant Design Pro) |
33
+ | `next.config.*` | Next.js |
34
+ | `vite.config.*` | Vite |
35
+ | `rsbuild.config.*` | Rsbuild |
36
+ | `rspack.config.*` | Rspack |
37
+ | `farm.config.*` | Farm |
38
+ | `craco.config.*` | CRA + craco |
39
+ | `webpack.config.*` | Webpack |
40
+ | `gulpfile.*` | Gulp (legacy) |
41
+ | `angular.json` | Angular |
42
+ | Custom `build/` or `scripts/build.*` only | Bespoke pipeline — record as `custom` and capture entry script path |
43
+
44
+ If multiple build configs coexist (e.g. `webpack.config.js` + `vite.config.ts`), record ALL of them and mark `build.mixed: true`. Mixed builds are a constraint, not an error — do not silently pick one.
45
+
46
+ ### 2. Component library: check `package.json` dependencies
47
+
48
+ | Package | Library |
49
+ |---|---|
50
+ | `antd` (capture major version: v3/v4/v5) | Ant Design |
51
+ | `@ant-design/pro-components`, `@ant-design/pro-*` | Ant Design Pro suite |
52
+ | `@mui/material` | Material UI |
53
+ | `tailwindcss` + `radix-ui` | shadcn/ui |
54
+ | `element-plus` / `element-ui` | Element UI/Plus |
55
+ | `@arco-design/web-react` | Arco Design |
56
+ | `tdesign-react` / `tdesign-vue-next` | TDesign |
57
+ | `@douyinfe/semi-ui` | Semi Design |
58
+ | `@nextui-org/react` | NextUI |
59
+ | `@chakra-ui/react` | Chakra UI |
60
+ | `vant` | Vant (mobile) |
61
+ | Workspace package (`workspace:*`) or private-registry scope matching internal design system | In-house design system — record package name and entry path |
62
+
63
+ **CRITICAL**: Never add a second component library to a project that already has one. Do not introduce shadcn/ui to an antd project or vice versa. For antd, ALSO record the major version — v3 / v4 / v5 have incompatible APIs and tokens; mixing component code across majors is a blocker.
64
+
65
+ ### 3. CSS framework: check for conflicts
66
+
67
+ - **antd + TailwindCSS**: High conflict risk (preflight reset overrides base styles). Resolution:
68
+ - Both already in `package.json` → coexist; use Tailwind for layout, antd for components.
69
+ - Tailwind breaks antd styles → add `corePlugins: { preflight: false }` or `important: '#root'`.
70
+ - Only antd, user wants Tailwind → **Block**; propose antd `ConfigProvider` tokens or CSS Modules.
71
+ - **Less/Sass**: Standard for Umi+antd projects; compatible with CSS Modules.
72
+ - **CSS-in-JS (@emotion, styled-components)**: Check if component library already uses one internally; don't add competing solutions.
73
+
74
+ ### 4. State management, routing, data fetching: detect from `package.json`
75
+
76
+ State: `zustand`, `jotai`, `redux`/`@reduxjs/toolkit`, `valtio`, `mobx`, `hox`
77
+ Routing: `react-router-dom`, `@umijs/max`, Next.js file-based, `vue-router`
78
+ Data fetching: `@tanstack/react-query`, `swr`, `ahooks` (`useRequest`), `umi-request`
79
+
80
+ ### 5. Legacy signals (legacy-frontend / legacy-fullstack only)
81
+
82
+ Grep `src/` for outdated patterns and list them as constraints in `project-scan.md` under `## Legacy constraints`. RD must preserve these patterns for new code in the same file/module unless PRD explicitly authorizes modernization.
83
+
84
+ | Signal | Detection |
85
+ |---|---|
86
+ | Class components | `extends React.Component` / `extends Component` in `.tsx`/`.jsx` |
87
+ | `moment` instead of dayjs/date-fns | `package.json` dep |
88
+ | Enzyme test suite | `package.json` dep `enzyme*` |
89
+ | redux-saga / redux-thunk | `package.json` dep |
90
+ | HOC-heavy patterns | `withRouter`, `connect()`, `compose(` frequency in `src/` |
91
+ | Legacy lifecycle | `componentWillMount`/`componentWillReceiveProps` occurrences |
92
+ | jQuery / Backbone / Vue 2 | `package.json` dep |
93
+ | Inline styles dominant | `style={{` occurrences ≥ 50 |
94
+
95
+ ### 6. Project-scan artifact template
96
+
97
+ ```markdown
98
+ # Project Scan: <project-name>
99
+ **Date:** YYYY-MM-DD
100
+ **Session:** <session-id>
101
+
102
+ ## Archetype
103
+ - Type: <greenfield | legacy-frontend | legacy-fullstack | frontend-monorepo | unknown>
104
+ - Signals matched: <bullet list of signals that drove the decision>
105
+
106
+ ## Project mode
107
+ - Frontend-only: <true | false>
108
+ - Reason: <archetype-derived | user-stated | backend-detected>
109
+
110
+ ## Build tool
111
+ - Framework: <name> <version>
112
+ - Config file: <path>
113
+ - Mixed builds: <true | false; list all configs if true>
114
+
115
+ ## Component library
116
+ - Library: <name> <version (major matters for antd)>
117
+ - Design-system packages: <list>
118
+ - In-house design system: <package name | none>
119
+
120
+ ## CSS solution
121
+ - Primary: <Less/Sass/CSS-in-JS/TailwindCSS/CSS Modules>
122
+ - Conflicts detected: <none | description and recommendation>
123
+
124
+ ## State management, routing, data fetching
125
+ - State: <name>
126
+ - Routing: <name>
127
+ - Data fetching: <name>
128
+
129
+ ## Library versions
130
+ - Source: output of `peaks scan libraries --project <repo> --json` (see Gate A; cross-check diff imports against `schemas/library-breaking-changes.data.json` in `peaks-rd` preflight)
131
+ - Total: <count from scan.libraries.totalCount>
132
+ - Notable: <bullet list of libraries with major >= a known breaking change in `schemas/library-breaking-changes.data.json`; e.g. "- antd@^5.18.0 (major=5) — see breaking-change rule for antd v4→v5 if any code uses Drawer.width">
133
+
134
+ ## Legacy constraints
135
+ - <bullet list of legacy signals from section 5; empty for greenfield>
136
+ ```
@@ -0,0 +1,13 @@
1
+ # Quality-gate commands (CLI cheat sheet)
2
+
3
+ > Body of `## Peaks-Cli Quality-gate commands`. These commands harden the workflow against silent skips. Use them in the runbook at the points indicated; they all support `--json` and `--session-id`.
4
+
5
+ | Command | Purpose | When to run | Non-zero exit when |
6
+ |---|---|---|---|
7
+ | `peaks request lint <rid> --role <role> --project <path>` | Scan artifact body for unfilled `<placeholder>`, bare `- ...` bullets, TBD/TODO markers | Before every transition out of `draft` / before role handoff | Any `error`-severity finding (unfilled placeholder, bare-dot bullet) |
8
+ | `peaks request repair-status <rid> --project <path>` | Count RD↔QA repair cycles from `--reason` transition notes ("QA cycle N: ...") | Before every RD repair iteration in step 7 | Cycle count reached the 3-cycle cap |
9
+ | `peaks scan request-type-sanity --project <path> --type <type>` | Cross-verify declared `--type` against the actual `git diff` file mix (catches "feature mis-declared as docs" workflow violations) | After PRD type lock-in AND after each RD repair iteration | Declared type disagrees with the file mix |
10
+ | `peaks scan libraries --project <path>` | Enumerate every dependency + devDependency + peerDependency + optionalDependency with parsed major version; output goes to `## Library versions` in `rd/project-scan.md`. Read-only. | At Solo step 0.6 (alongside `peaks scan archetype`) | Always exits 0 (warnings in JSON envelope; never blocks) |
11
+ | `peaks slice check [--rid <rid>] [--project <path>]` | 4-stage slice 边界 check (typecheck + unit-tests + review-fanout + gate-verify-pipeline). Aggregate pass/fail; non-zero exit if any stage fails. See "Slice 边界 check" below for usage rules (boundary only, never inside a micro-cycle). | At slice 边界(post-micro-cycle, pre-peaks-qa)| Any stage fails |
12
+
13
+ Together with `peaks request transition` (which already CLI-enforces per-type artifact prerequisites), these five commands form the runtime quality net. SKILL.md prose is descriptive; the CLI is what physically blocks bad workflows.
@@ -0,0 +1,63 @@
1
+ # Step 0.7 — Detect unfinished work and offer resume
2
+
3
+ > Body of `### Peaks-Cli Step 0.7`. After Step 0 has anchored the workspace and presence, before Step 1 mode selection, run the resume-detection probe. If the current session has in-flight slice artifacts, the user is most likely "continuing" — surface resume options instead of starting a fresh PRD.
4
+
5
+ **Why this is a separate step** (per `feedback_peaks_solo_natural_language_primary` — a high-frequency request shape, see also the user's "继续完成刚才为完成的" pattern from session `2026-06-04-session-b60252`): the LLM was previously re-reading 3-5 artifact files to determine workflow state, wasting 3-5k tokens per resume request. This step replaces that work with a single deterministic read.
6
+
7
+ **Detection logic** (all read-only, no side effects; uses only existing CLIs):
8
+
9
+ ```bash
10
+ # 1. Confirm the current session id via the read-only CLI primitive
11
+ # (the on-disk binding file is internal — never `cat` it directly)
12
+ sid=$(peaks session info --active --project "$(git rev-parse --show-toplevel)" --json | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['sessionId'])")
13
+
14
+ # 2. Enumerate the session's artifact tree (one `find` call, no new CLI)
15
+ find ".peaks/$sid/" -type f 2>/dev/null | sort
16
+
17
+ # 3. For each role request artifact present, read its `state:` field
18
+ # (one-pass grep; only files that exist)
19
+ for f in .peaks/$sid/prd/requests/*.md .peaks/$sid/rd/requests/*.md .peaks/$sid/qa/requests/*.md; do
20
+ [ -f "$f" ] && echo "$f: $(grep -m1 '^state:' "$f" | awk '{print $2}')"
21
+ done
22
+
23
+ # 4. Compute "deepest completed gate" by file-presence + state mapping
24
+ # (see classification table below)
25
+ ```
26
+
27
+ **Classification table** (file-presence + state → "deepest completed gate"):
28
+
29
+ | Files present | State | Deepest completed gate | Resume point (if any) |
30
+ |---|---|---|---|
31
+ | only `.peaks/$sid/.session.json` | (no slice) | (none) | fresh — skip to Step 1 |
32
+ | `prd/requests/<rid>.md` | `state: handed-off` | Gate B (swarm converged) | resume at Step 3 (swarm) — but if swarm already ran and produced `rd/tech-doc.md` / `qa/test-cases/<rid>.md`, drop to deepest |
33
+ | `rd/requests/<rid>.md` | `state: qa-handoff` | Gate C (RD done) | resume at Step 6 (QA validation) |
34
+ | `qa/requests/<rid>.md` | `state: verdict-issued` | Gate D (QA done) | resume at Step 10 (TXT handoff) |
35
+ | `txt/handoff.md` | (any) | Gate E (workflow complete) | this session is closed — user is starting new work |
36
+
37
+ **Other resume triggers** (file-presence, no state read needed):
38
+
39
+ | Missing file | Resume at |
40
+ |---|---|
41
+ | `rd/tech-doc.md` (for `feature`/`refactor`) or `rd/bug-analysis.md` (for `bugfix`) | Step 3b (RD planning) |
42
+ | `rd/code-review.md` or `rd/security-review.md` | Step 5 (RD review fan-out) |
43
+ | `rd/perf-baseline.md` (for `feature`/`refactor`) | Step 5 (perf baseline) |
44
+ | `qa/test-cases/<rid>.md` | Step 6 (QA test-case generation) |
45
+ | `qa/test-reports/<rid>.md` or `qa/security-findings.md` or `qa/performance-findings.md` | Step 6 (QA execution) |
46
+ | `txt/handoff.md` | Step 10 (TXT handoff) |
47
+
48
+ **AskUserQuestion** (only if a resume is detected; default option is "Resume from the deepest missing gate"):
49
+
50
+ | Option | What it does |
51
+ |---|---|
52
+ | Resume from `<gate>` (Recommended) | Skip ahead to the matching step, preserving all existing artifacts. The LLM does NOT re-read the existing artifacts — it trusts the classification and proceeds. |
53
+ | Start a fresh slice | Keep the workspace, treat the current user request as a new slice (new rid). Existing artifacts are preserved but not auto-resumed. |
54
+ | Abandon the in-flight slice | Mark the in-flight slice as `deferred` (`peaks request transition … --state deferred`); start a new one. |
55
+
56
+ **Hard rule: never silently auto-resume.** Resume detection is the discovery; AskUserQuestion is the confirmation. Even if the user's request is "继续完成刚才为完成的" (continue the unfinished work), the skill must run this detection, surface the options, and wait for user confirmation before skipping ahead.
57
+
58
+ **Hard rule: never auto-resume a slice that is mid-implementation.** Resume only when the deepest completed gate is in {B, C, D, E}. For mid-implementation states (RD `state: implemented`, RD `state: running`, RD `state: spec-locked`, QA `state: running`, QA `state: blocked`), the slice is still in flight — the only valid option is "Resume from in-flight gate" (the user must confirm).
59
+
60
+ **Strict quality guarantee (per user's hard rule: "严格要保证不能比当前的效果差")**:
61
+ - 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.
62
+ - 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).
63
+ - 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.
@@ -8,7 +8,7 @@
8
8
  > - `peaks skill runbook peaks-solo` (CLI) reads the `## Default runbook` section in either SKILL.md or `references/runbook.md` (whichever has the bash code).
9
9
  > - The test in `tests/unit/skill-default-runbook.test.ts` looks for `## Default runbook` in SKILL.md first, then falls back to `references/runbook.md` here.
10
10
 
11
- ## Default runbook
11
+ ## Default runbook — CLI sequence
12
12
 
13
13
  The end-to-end CLI sequence for the `full-auto` profile. `assisted` and `strict` profiles pause at `[CONFIRM]` markers below. `full-auto` and `swarm` auto-proceed through all gates. See Transition Gates for artifact verification at each stage.
14
14
 
@@ -0,0 +1,31 @@
1
+ # Step 2 + 2.5 — Skill presence and session title
2
+
3
+ > Combined body for `### Peaks-Cli Step 2: Re-set skill presence with the chosen mode` and `### Peaks-Cli Step 2.5: Set session title`.
4
+
5
+ ## Step 2 — Re-set skill presence
6
+
7
+ Step 0 already set presence with no mode. Now that the mode is known (user selected or explicitly named), re-run presence:set so the header/status line shows the profile:
8
+
9
+ ```bash
10
+ peaks skill presence:set peaks-solo --project <repo> --mode <mode-value> --gate startup
11
+ ```
12
+
13
+ On the first presence:set in a project, ensure the out-of-band status bar is installed so the user can see at a glance that Peaks is orchestrating — it renders the active skill in Claude Code's terminal status line, independent of model output:
14
+
15
+ ```bash
16
+ peaks statusline install --project <repo> # idempotent; skips if already installed
17
+ ```
18
+
19
+ Then display the compact status header: `Peaks-Cli Skill: peaks-solo | Peaks-Cli Gate: startup | Next: <one short action>`. Display this header on EVERY turn while the skill is active.
20
+
21
+ Update with `peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate <gate>` when gates change. The presence file persists across the full workflow lifecycle — do NOT clear it at workflow end.
22
+
23
+ ## Step 2.5 — Set session title
24
+
25
+ Extract a short (8-20 Chinese characters, or 4-10 English words) descriptive title from the user's first request. The title should capture the core task — e.g. "修复登录页OAuth回调异常", "添加暗色模式开关", "搭建项目基础架构". Then run:
26
+
27
+ ```bash
28
+ peaks session title $(peaks session info --active --project "$(git rev-parse --show-toplevel)" --json | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['sessionId'])") "<title>"
29
+ ```
30
+
31
+ If the session directory already has a title (check via `peaks session list --json`), skip this step — the title is already set.
@@ -0,0 +1,23 @@
1
+ # Project standards preflight
2
+
3
+ > Body of `## Peaks-Cli Project standards preflight`. Before orchestrating an end-to-end code repository workflow, gather the project standards preflight status from RD and QA by calling the Peaks-Cli CLI:
4
+
5
+ - `peaks standards init --project <path> --dry-run`
6
+ - `peaks standards update --project <path> --dry-run`
7
+
8
+ 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.
9
+
10
+ **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.
11
+
12
+ **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.
13
+
14
+ Do not hand-write standards file mutations inside the skill.
15
+
16
+ For project-analysis requests such as "分析项目" / "分析下这个项目", Step 0 still applies: the workspace is initialized and `peaks-solo` presence is set before any analysis output. These requests run the lightweight analysis branch (project scan + standards dry-run) rather than the full RD/QA pipeline, but they never skip workspace anchoring or exit the workflow. The handoff must include an explicit **Standards increment** section. Report the current `CLAUDE.md` and `.claude/rules/**` status from the dry-run output as incremental deltas, not just a generic preflight note:
17
+
18
+ - whether `CLAUDE.md` is missing, existing, planned, skipped, appended, or review-only;
19
+ - which `.claude/rules/**` files are planned, existing, skipped, appended, or review-only;
20
+ - whether writes were applied or intentionally left as dry-run because authorization or scope was absent;
21
+ - the exact next action if standards should be applied later.
22
+
23
+ If the dry-run output lacks enough detail to explain those deltas, say that the standards increment is unknown and keep standards application blocked until another `peaks standards init/update --dry-run` provides evidence.
@@ -240,3 +240,49 @@ When writing a SKILL.md that fans out sub-agents:
240
240
  - `.peaks/memory/sub-agent-heartbeat-progress-red-line.md` (G6 red line)
241
241
  - `skills/peaks-solo/references/swarm-dispatch-contract.md` (predecessor contract)
242
242
  - `skills/peaks-qa/references/qa-fanout-contract.md` (QA-specific fan-out)
243
+
244
+ ---
245
+
246
+ ### Sub-agent mechanism (IDE-agnostic dispatch, NOT Skill tool)
247
+
248
+ > Body of `### Sub-agent mechanism`. **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.
249
+
250
+ Each sub-agent dispatch call looks like:
251
+
252
+ ```
253
+ peaks sub-agent dispatch <role> \
254
+ --prompt "<paste peaks-<role>/SKILL.md body, minus the self-presence / Step 0 blocks,
255
+ plus the runtime arguments: project=<repo>, session-id=<session-id>, request-id=<rid>, mode=<mode>,
256
+ plus the explicit output contract: 'Write your artefacts to the paths listed below and
257
+ return only the list of paths. Do not call Skill(...). Do not set presence. Do not
258
+ hand back prose.', plus the heartbeat instruction: 'While running, call
259
+ peaks sub-agent heartbeat --record <dispatchRecordPath> --status <state> --progress <pct> --note \"<text>\"
260
+ at least every 30 seconds.'>" \
261
+ --request-id <rid> --session-id <session-id> --project <repo> --json
262
+ ```
263
+
264
+ 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.
265
+
266
+ The role's required artefact paths (also see peaks-ui/rd/qa SKILL.md and `references/swarm-dispatch-contract.md`):
267
+
268
+ | Role | Writes | Reads (PRD-side) |
269
+ |---|---|---|
270
+ | `ui` | `.peaks/_runtime/<sessionId>/ui/design-draft.md`, `.peaks/_runtime/<sessionId>/ui/requests/<rid>.md` | PRD body, project-scan, archetype |
271
+ | `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 |
272
+ | `qa-test-cases` | `.peaks/_runtime/<sessionId>/qa/test-cases/<rid>.md` | PRD body, RD planning artefact, project-scan, codegraph |
273
+
274
+ **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.
275
+
276
+ **Hard prohibitions on sub-agents** (also passed in each dispatch prompt):
277
+
278
+ - Do NOT call `Skill(skill="...")` — sub-agents must not recursively activate skills, that defeats the fan-out.
279
+ - 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.
280
+ - 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.
281
+ - Do NOT commit, push, install hooks, or apply settings.json mutations. Only Solo holds those permissions.
282
+ - **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.
283
+
284
+ After every sub-agent dispatch returns, Solo **restores presence** once (not per-agent), then continues to Gate B verification:
285
+
286
+ ```bash
287
+ peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-converged
288
+ ```
@@ -150,3 +150,59 @@ A skill cannot itself trigger sub-agents — the Skill tool runs in the main loo
150
150
  - `peaks request show <rid> --role prd --json` must surface the `--type` chosen at `peaks request init`. Sub-agents pass it through unchanged.
151
151
  - `peaks skill presence:set` must remain single-writer-friendly (the sub-agents do not call it).
152
152
  - 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/`.
153
+
154
+ ---
155
+
156
+ ### Swarm gate (decide BEFORE fan-out)
157
+
158
+ > Body of `### Swarm gate`. Before launching any sub-agent, Solo must compute the **swarm plan** from three signals:
159
+
160
+ 1. **PRD state** — `prd/requests/<rid>.md` must be in state `confirmed-by-user` or `handed-off`. If not, STOP. The Swarm is downstream of PRD, not a substitute for it.
161
+ 2. **Request type** (`--type` from `peaks request init`):
162
+ - `feature` / `refactor` / `bugfix` → RD(planning) and QA(test-cases) are always in the swarm
163
+ - `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.
164
+ 3. **Frontend touch** — does the request affect user-visible behavior? This is decided by:
165
+ - Reading `.peaks/_runtime/<sessionId>/rd/project-scan.md` `## Project mode` for `frontendOnly` (project-shape signal)
166
+ - **AND** scanning the PRD body for frontend keywords: 页面 / 组件 / 表单 / 弹窗 / 表格 / 样式 / 布局 / 交互 / UI / UX / page / component / form / modal / table / styling / layout / interaction
167
+ - UI joins the swarm when (a) is `true` OR (b) matches. Both signals required `false` to skip UI.
168
+
169
+ Solo records the swarm plan in `.peaks/_runtime/<sessionId>/sc/swarm-plan.json` so SC and TXT can audit what was launched:
170
+
171
+ ```json
172
+ {
173
+ "rid": "<rid>",
174
+ "type": "feature",
175
+ "frontendOnly": true,
176
+ "frontendKeywordHit": true,
177
+ "subAgents": ["ui", "rd-planning", "qa-test-cases"]
178
+ }
179
+ ```
180
+
181
+ Sub-agent presence in this list = Solo launched a Task for it. Absence = the role was skipped with documented reason.
182
+
183
+ ### Mode-driven fan-out shape
184
+
185
+ > Body of `### Mode-driven fan-out shape`.
186
+
187
+ | Mode | How the swarm plan is decided | What Solo does |
188
+ |---|---|---|
189
+ | `full-auto` | Compute plan from signals above, no question to user | Auto-launch all sub-agents in the plan in parallel |
190
+ | `swarm` | Same as `full-auto` | Same as `full-auto` (this profile name is historical — behavior is identical) |
191
+ | `assisted` | `AskUserQuestion` with three options: (a) Full — UI + RD(planning) + QA(test-cases); (b) Backend-only — RD(planning) + QA(test-cases); (c) Sequential — run RD first, then QA, skip UI | Use the user's choice as the plan |
192
+ | `strict` | Same as `assisted` (the question is informational; strict still enforces confirmation gates later) | Same as `assisted` |
193
+
194
+ 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.
195
+
196
+ ### Degradation when swarm roles fail or are absent
197
+
198
+ > Body of `### Degradation when swarm roles fail or are absent`.
199
+
200
+ | Condition | Solo action | TXT handoff note |
201
+ |---|---|---|
202
+ | UI sub-agent returns blocked/error | RD continues with PRD visual descriptions | `ui-design-missing` |
203
+ | RD planning sub-agent returns blocked/error | RD continues with PRD-derived planning | `tech-doc-missing` |
204
+ | QA test-cases sub-agent returns blocked/error | RD continues; QA backfills test cases before verdict | `qa-test-cases-missing` |
205
+ | Two or more of the above | Fall back to sequential: `peaks request transition rd → spec-locked` then inline RD run, then QA | `swarm-degraded-to-sequential` |
206
+ | All three fail | Pause workflow; surface to user; request confirmation to continue | `swarm-aborted` |
207
+
208
+ Skipping the entire swarm (when `--type` is `config|docs|chore`) is not a degradation — record `swarm-skipped: type=<type>` and proceed.