peaks-cli 1.2.7 → 1.2.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 (54) hide show
  1. package/README.md +12 -0
  2. package/dist/src/cli/commands/core-artifact-commands.js +36 -1
  3. package/dist/src/cli/commands/perf-commands.d.ts +3 -0
  4. package/dist/src/cli/commands/perf-commands.js +41 -0
  5. package/dist/src/cli/commands/progress-close-kill.d.ts +51 -0
  6. package/dist/src/cli/commands/progress-close-kill.js +152 -0
  7. package/dist/src/cli/commands/progress-commands.d.ts +3 -0
  8. package/dist/src/cli/commands/progress-commands.js +348 -0
  9. package/dist/src/cli/commands/progress-start-spawn.d.ts +59 -0
  10. package/dist/src/cli/commands/progress-start-spawn.js +114 -0
  11. package/dist/src/cli/commands/progress-watch-render.d.ts +80 -0
  12. package/dist/src/cli/commands/progress-watch-render.js +308 -0
  13. package/dist/src/cli/commands/project-commands.js +1 -1
  14. package/dist/src/cli/commands/scan-commands.js +22 -0
  15. package/dist/src/cli/program.js +4 -0
  16. package/dist/src/services/config/config-types.d.ts +20 -0
  17. package/dist/src/services/config/config-types.js +5 -1
  18. package/dist/src/services/memory/project-memory-service.d.ts +1 -1
  19. package/dist/src/services/memory/project-memory-service.js +52 -23
  20. package/dist/src/services/perf/perf-baseline-service.d.ts +70 -0
  21. package/dist/src/services/perf/perf-baseline-service.js +213 -0
  22. package/dist/src/services/progress/progress-service.d.ts +179 -0
  23. package/dist/src/services/progress/progress-service.js +276 -0
  24. package/dist/src/services/scan/libraries-service.d.ts +24 -0
  25. package/dist/src/services/scan/libraries-service.js +419 -0
  26. package/dist/src/services/scan/libraries-types.d.ts +59 -0
  27. package/dist/src/services/scan/libraries-types.js +9 -0
  28. package/dist/src/services/session/index.d.ts +1 -1
  29. package/dist/src/services/session/index.js +1 -1
  30. package/dist/src/services/session/session-manager.d.ts +53 -8
  31. package/dist/src/services/session/session-manager.js +150 -3
  32. package/dist/src/services/skills/skill-presence-service.d.ts +27 -1
  33. package/dist/src/services/skills/skill-presence-service.js +112 -9
  34. package/dist/src/services/skills/skill-runbook-service.js +34 -1
  35. package/dist/src/services/workflow/autonomous-resume-writer.js +7 -7
  36. package/dist/src/shared/change-id.d.ts +30 -0
  37. package/dist/src/shared/change-id.js +40 -6
  38. package/dist/src/shared/paths.d.ts +1 -1
  39. package/dist/src/shared/paths.js +2 -1
  40. package/dist/src/shared/version.d.ts +1 -1
  41. package/dist/src/shared/version.js +1 -1
  42. package/package.json +6 -2
  43. package/schemas/library-breaking-changes.data.json +141 -0
  44. package/schemas/library-breaking-changes.meta.json +6 -0
  45. package/schemas/library-breaking-changes.schema.json +50 -0
  46. package/skills/peaks-qa/SKILL.md +25 -0
  47. package/skills/peaks-rd/SKILL.md +221 -2
  48. package/skills/peaks-solo/SKILL.md +76 -316
  49. package/skills/peaks-solo/references/runbook.md +166 -0
  50. package/skills/peaks-solo/references/workflow-gates-and-types.md +177 -0
  51. package/skills/peaks-solo-resume/SKILL.md +81 -0
  52. package/skills/peaks-solo-status/SKILL.md +120 -0
  53. package/skills/peaks-solo-test/SKILL.md +84 -0
  54. package/skills/peaks-txt/SKILL.md +8 -5
@@ -131,6 +131,69 @@ peaks skill presence:set peaks-solo --project <repo> --gate startup
131
131
 
132
132
  `presence:set` accepts no `--mode` here on purpose — mode is unknown until Step 1. It is re-run with the selected mode in Step 2. Setting presence early guarantees the status header/line shows `peaks-solo` from the very first turn even if the user never reaches mode selection.
133
133
 
134
+ ### Peaks-Cli Step 0.7: Detect unfinished work and offer resume (BLOCKING on first invocation per session)
135
+
136
+ 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.
137
+
138
+ **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.
139
+
140
+ **Detection logic** (all read-only, no side effects; uses only existing CLIs):
141
+
142
+ ```bash
143
+ # 1. Confirm the current session id
144
+ sid=$(cat .peaks/.session.json | python3 -c "import sys,json; print(json.load(sys.stdin)['sessionId'])")
145
+
146
+ # 2. Enumerate the session's artifact tree (one `find` call, no new CLI)
147
+ find ".peaks/$sid/" -type f 2>/dev/null | sort
148
+
149
+ # 3. For each role request artifact present, read its `state:` field
150
+ # (one-pass grep; only files that exist)
151
+ for f in .peaks/$sid/prd/requests/*.md .peaks/$sid/rd/requests/*.md .peaks/$sid/qa/requests/*.md; do
152
+ [ -f "$f" ] && echo "$f: $(grep -m1 '^state:' "$f" | awk '{print $2}')"
153
+ done
154
+
155
+ # 4. Compute "deepest completed gate" by file-presence + state mapping
156
+ # (see classification table below)
157
+ ```
158
+
159
+ **Classification table** (file-presence + state → "deepest completed gate"):
160
+
161
+ | Files present | State | Deepest completed gate | Resume point (if any) |
162
+ |---|---|---|---|
163
+ | only `.peaks/$sid/.session.json` | (no slice) | (none) | fresh — skip to Step 1 |
164
+ | `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 |
165
+ | `rd/requests/<rid>.md` | `state: qa-handoff` | Gate C (RD done) | resume at Step 6 (QA validation) |
166
+ | `qa/requests/<rid>.md` | `state: verdict-issued` | Gate D (QA done) | resume at Step 10 (TXT handoff) |
167
+ | `txt/handoff.md` | (any) | Gate E (workflow complete) | this session is closed — user is starting new work |
168
+
169
+ **Other resume triggers** (file-presence, no state read needed):
170
+
171
+ | Missing file | Resume at |
172
+ |---|---|
173
+ | `rd/tech-doc.md` (for `feature`/`refactor`) or `rd/bug-analysis.md` (for `bugfix`) | Step 3b (RD planning) |
174
+ | `rd/code-review.md` or `rd/security-review.md` | Step 5 (RD review fan-out) |
175
+ | `rd/perf-baseline.md` (for `feature`/`refactor`) | Step 5 (perf baseline) |
176
+ | `qa/test-cases/<rid>.md` | Step 6 (QA test-case generation) |
177
+ | `qa/test-reports/<rid>.md` or `qa/security-findings.md` or `qa/performance-findings.md` | Step 6 (QA execution) |
178
+ | `txt/handoff.md` | Step 10 (TXT handoff) |
179
+
180
+ **AskUserQuestion** (only if a resume is detected; default option is "Resume from the deepest missing gate"):
181
+
182
+ | Option | What it does |
183
+ |---|---|
184
+ | 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. |
185
+ | 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. |
186
+ | Abandon the in-flight slice | Mark the in-flight slice as `deferred` (`peaks request transition … --state deferred`); start a new one. |
187
+
188
+ **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.
189
+
190
+ **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).
191
+
192
+ **Strict quality guarantee (per user's hard rule: "严格要保证不能比当前的效果差")**:
193
+ - 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
+ - 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` (added in this slice) asserts: (a) fresh-session classification returns "no resume", (b) in-flight slice classification returns the right gate, (c) the classification is deterministic across two invocations on the same fixture.
196
+
134
197
  ### Peaks-Cli Step 1: Mode selection
135
198
 
136
199
  After Step 0 has anchored the workspace and presence, when the user invokes Peaks-Cli Solo without explicitly naming an execution profile, use `AskUserQuestion` to pick the profile. Present the recommended full-auto path as the first/default option with a practical description for each:
@@ -185,7 +248,7 @@ This returns durable memories from `.peaks/memory`, grouped by kind:
185
248
  - **convention** — discovered project patterns (code style, naming, tooling)
186
249
  - **rule** / **reference** / **project** — standing constraints, external pointers, and project context
187
250
 
188
- Filter with `--kind <decision|convention|module|rule|reference|project>` when you only need one slice. Use this to understand what exists, what was decided, and what to avoid re-litigating. Memories are LLM-authored at approved checkpoints via `peaks memory extract`.
251
+ Filter with `--kind <decision|convention|module|rule|reference|project|lesson>` when you only need one slice. Use this to understand what exists, what was decided, and what to avoid re-litigating. Memories are LLM-authored at approved checkpoints via `peaks memory extract`. The `lesson` kind is for LLM-discovered runtime lessons (e.g. "this project's antv6 Drawer uses `size` not `width`"); write them as `<!-- peaks-memory:start kind=lesson -->` blocks in the RD handoff or TXT handoff.
189
252
 
190
253
  `.peaks/PROJECT.md` is a human-readable session timeline only — do NOT use it for LLM context.
191
254
 
@@ -413,6 +476,11 @@ Grep `src/` for outdated patterns and list them as constraints in `project-scan.
413
476
  - Routing: <name>
414
477
  - Data fetching: <name>
415
478
 
479
+ ## Library versions
480
+ - 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)
481
+ - Total: <count from scan.libraries.totalCount>
482
+ - 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">
483
+
416
484
  ## Legacy constraints
417
485
  - <bullet list of legacy signals from section 5; empty for greenfield>
418
486
  ```
@@ -489,171 +557,9 @@ When the PRD source is a Feishu/Lark document that requires authentication:
489
557
 
490
558
  Never silently fall back to unauthenticated `fetch` or `WebFetch` for authenticated documents.
491
559
 
492
- ## Peaks-Cli Request type classification (MANDATORY before `peaks request init`)
493
-
494
- Before initializing any role artifact, classify the request into exactly one of six types. The choice drives RD/QA gate strictness (see "Mandatory RD QA repair loop"). Pick the **primary intent** — if a request could fit two types, the higher-strictness one wins.
495
-
496
- | `--type` | Pick this when the PRD says... | Pick something else when... |
497
- |---|---|---|
498
- | `feature` | Add new capability, new page/component/route/API path, new user-facing behavior. Includes "extend X to support Y" when Y is a new code path. | The PRD is fixing an existing broken behavior → `bugfix`. The PRD is reshaping existing code without changing user-visible behavior → `refactor`. |
499
- | `bugfix` | Fix a specific broken behavior; PRD includes reproduction steps or a defect description; success = "the broken thing now works as it was supposed to". | The "fix" actually adds new capability (validation that didn't exist, a missing field) → `feature`. The "fix" is purely cosmetic and has zero risk → still `bugfix`; do NOT downgrade to `chore`. |
500
- | `refactor` | Restructure code without changing user-visible behavior. Examples: rename modules, extract shared utilities, migrate a library version with no API surface change, split a monolithic file. PRD mentions coverage targets or "no behavior change". | The refactor incidentally adds or changes user-visible behavior → split into `refactor` + `feature` or pick `feature`. The change is one-line formatting → `chore`. |
501
- | `config` | Modify config / infrastructure files only: `tsconfig.json`, `eslint`, CI YAML, `package.json` scripts, env defaults, CORS/CSP rules, build config, Docker, deployment manifests. No application source-code changes. | The config change is paired with code changes that consume the new config → `feature` or `refactor` (whichever the code change is). |
502
- | `docs` | Modify only `*.md` / docs site / inline JSDoc / README. No `.ts` / `.tsx` / `.js` / `.css` / config-file changes. | Any source code change is included → use the type matching the code change. Adding a code example to docs that requires the example to compile → still `docs` if the example is illustrative only. |
503
- | `chore` | Pure mechanical hygiene: formatter run, lint fix, dependency version bump with no API surface change, dead-code removal of unused files identified by tooling. | The bump changes API behavior or requires consumer migration → `refactor` (or `feature` if it adds capability). Any logic edit → `bugfix` or `refactor`. |
504
-
505
- **Self-check before locking the type**: read the PRD scope and answer "what is the smallest gate set that still protects users from regression?" — that is the right type. Picking `docs` or `chore` to skip gates when source code is actually changing is a workflow violation and the SC phase will reject it.
506
-
507
- For ambiguous cases (e.g. "improve login flow"), ask the user to clarify before initializing. The cost of one `AskUserQuestion` round is much lower than running the wrong gate matrix for the whole workflow.
508
-
509
- When Peaks-Cli Solo coordinates development in a code repository, keep this order explicit:
510
-
511
- 0. **Peaks-Cli Snapshot** — `peaks doctor` + `peaks project dashboard` to capture baseline state before anything else;
512
- 0.5. **Peaks-Cli Workspace initialization** — `.peaks/<session-id>/` created, directory structure verified;
513
- 0.6. **Peaks-Cli Project scan** — archetype, component library, CSS framework, build tool, state management, routing, data fetching, legacy signals detected and recorded to `.peaks/<session-id>/rd/project-scan.md`;
514
- 0.7. **Peaks-Cli Existing-system extraction** (MANDATORY when archetype ∈ {legacy-frontend, legacy-fullstack, frontend-monorepo}; SKIP for greenfield) — extract visual tokens and code conventions from the live codebase to `.peaks/<session-id>/system/existing-system.md`. The path lives under `system/` (not `ui/`) because the file also records non-UI conventions (service-layer signatures, hooks, naming) that backend-only or legacy-fullstack work consumes. See `references/existing-system-extraction.md`. UI design-draft and RD implementation MUST treat the extracted tokens and conventions as hard constraints;
515
- 1. **Peaks-Cli Standards preflight** — `peaks standards init/update --dry-run`, must reference concrete project-scan findings (never emit generic templates);
516
- 2. **Peaks-Cli PRD phase** — capture request as canonical artifact, extract scope and acceptance criteria:
517
- - Full-auto/Swarm: auto-transition to `confirmed-by-user` once the artifact is complete;
518
- - Assisted/Strict: pause with `AskUserQuestion` for explicit user confirmation before proceeding;
519
- 3. **Peaks-Cli Swarm parallel phase** — after PRD confirmed, launch UI, RD(planning), QA(test-cases) simultaneously:
520
- 3a. UI design draft and visual direction (MANDATORY when request is frontend/user-visible; skipped for `--type docs|chore|config` or pure-backend requests);
521
- 3b. RD planning artifact — `rd/tech-doc.md` for feature/refactor, `rd/bug-analysis.md` for bugfix, skipped for docs/chore/config;
522
- 3c. QA test-case generation (skipped for docs/chore — no acceptance surface to validate);
523
- 4. **Peaks-Cli RD implementation** — consumes the type-appropriate inputs: project-scan + standards + (if UI involved) UI design-draft + RD planning artifact + QA test-cases. Includes unit tests for new/changed behavior (TDD) unless `--type` is docs/chore;
524
- 5. **Peaks-Cli Code review + security review** — CRITICAL/HIGH issues fixed before progression; marked-blocked issues only allow a blocked handoff;
525
- 6. **Peaks-Cli QA validation** (auto-proceed from RD in full-auto) — execute test cases + API checks + Playwright MCP headed browser E2E for frontend + security/perf checks + test report;
526
- 7. **Peaks-Cli RD↔QA repair loop** — if QA verdict is `return-to-rd`, loop back to step 4 (RD implementation) and re-run through QA; max 3 repair cycles, then emit blocked TXT regardless;
527
- 8. **Peaks-Cli SC phase** — change-control evidence: impact, retention, validate, boundary;
528
- 9. **Peaks-Cli OpenSpec archive** — exit gate: validate → archive only after QA verdict=pass (when `openspec/` exists);
529
- 10. **Peaks-Cli TXT handoff capsule** — mode, validated decisions, artifact paths, standards deltas, open questions, next action;
530
- 11. **Peaks-Cli Final snapshot** — `peaks project dashboard` + `peaks skill doctor` to confirm the workflow closed cleanly.
531
-
532
- ### Peaks-Cli Transition verification gates (MANDATORY — run the command, see the output)
533
-
534
- You cannot declare a phase complete from memory. Each gate below is a `ls` command you **MUST run** and whose output you **MUST see** before proceeding. If any file shows "No such file", the phase is incomplete.
535
-
536
- **Peaks-Cli Gate A — After workspace init + project scan:**
537
- ```bash
538
- ls .peaks/<id>/rd/project-scan.md
539
- # Expected output: .peaks/<id>/rd/project-scan.md
540
- # "No such file" → STOP, run project scan first
541
- # File present but missing `## Archetype` or `## Project mode` sections → INCOMPLETE, rerun scan
542
- # File present and complete → reuse (project-scan is a session-scoped singleton)
543
- ```
544
-
545
- **Peaks-Cli Gate A.5 — Existing-system extraction (legacy projects only):**
546
- ```bash
547
- # If project-scan.md `## Archetype` is greenfield → skip this gate
548
- # Otherwise:
549
- ls .peaks/<id>/system/existing-system.md
550
- # "No such file" → STOP, run existing-system extraction
551
- # (see references/existing-system-extraction.md)
552
- ```
553
-
554
- **Peaks-Cli Gate B — After swarm convergence (UI + RD planning + QA test-cases):**
555
-
556
- Peaks-Cli Gate B has two sub-checks: a HARD gate (blocks progression) and an INFORMATIONAL check (records degradation but does not block).
557
-
558
- ```bash
559
- # B.hard — REQUIRED before continuing to RD implementation.
560
- # Missing any of these → STOP, return to the role that owns the file.
561
-
562
- # Always required (every type):
563
- ls .peaks/<id>/prd/requests/<rid>.md
564
-
565
- # Type-specific RD planning artifact:
566
- # feature / refactor → ls .peaks/<id>/rd/tech-doc.md
567
- # bugfix → ls .peaks/<id>/rd/bug-analysis.md
568
- # config / docs / chore → (no RD planning artifact required)
569
-
570
- # QA test-cases (skipped for docs/chore):
571
- ls .peaks/<id>/qa/test-cases/<rid>.md
572
- ```
573
-
574
- ```bash
575
- # B.info — NON-BLOCKING. Record degradation in TXT, then proceed.
576
- ls .peaks/<id>/ui/design-draft.md 2>&1
577
- # "No such file" + request affects user-visible UI → swarm degradation rule 1 fires:
578
- # note "ui-design-missing" in TXT, RD continues with PRD visual descriptions.
579
- # "No such file" + pure backend / docs / chore / config → state skip reason in TXT, proceed.
580
- ```
581
-
582
- **Peaks-Cli Gate C — After RD implementation (before QA handoff):**
560
+ ## Peaks-Cli Request type classification + Workflow order + Transition verification gates
583
561
 
584
- The CLI gate (`peaks request transition --state qa-handoff`) is the authoritative check; running this `ls` first lets you produce missing files before the CLI rejects the transition.
585
-
586
- ```bash
587
- # Always required
588
- ls .peaks/<id>/rd/requests/<rid>.md
589
-
590
- # Type-specific RD evidence (must match the type recorded in the artifact body)
591
- # feature / refactor → ls rd/tech-doc.md rd/code-review.md rd/security-review.md
592
- # bugfix → ls rd/bug-analysis.md rd/code-review.md rd/security-review.md
593
- # config → ls rd/security-review.md
594
- # docs / chore → (no extra evidence required)
595
- # Missing any required file → DO NOT attempt the qa-handoff transition; CLI will reject with PREREQUISITES_MISSING.
596
- ```
597
-
598
- **Peaks-Cli Gate D — After QA validation:**
599
-
600
- The CLI gate at `qa:verdict-issued` is the authoritative check; this `ls` lets you produce missing evidence before the CLI rejects the transition.
601
-
602
- ```bash
603
- # Always required
604
- ls .peaks/<id>/qa/requests/<rid>.md
605
-
606
- # Type-specific QA evidence
607
- # feature / refactor → ls qa/test-cases/<rid>.md qa/test-reports/<rid>.md qa/security-findings.md qa/performance-findings.md
608
- # bugfix → ls qa/test-cases/<rid>.md qa/test-reports/<rid>.md qa/security-findings.md
609
- # config → ls qa/security-findings.md
610
- # docs / chore → (no QA evidence files required)
611
- # Missing required file → QA incomplete; do not transition to verdict-issued.
612
- ```
613
-
614
- **Peaks-Cli Gate E — Before declaring workflow complete:**
615
- ```bash
616
- find .peaks/<id>/ -type f | sort
617
- # Verify: files from gates A-D all appear in this list.
618
- # Any mandatory file missing → NOT complete. Do not emit TXT.
619
- # Peaks-Cli Gate G (CLAUDE.md + .claude/rules/**) must ALSO pass before TXT is emitted.
620
- ```
621
-
622
- **Peaks-Cli Gate F — Root pollution check (BLOCKING before completion):**
623
- ```bash
624
- # Verify no Peaks-Cli intermediate artifacts leaked to project root.
625
- ls feishu-doc-*.md *-snapshot.md qa-server.js 2>&1
626
- # Expected: "No such file or directory" for ALL patterns.
627
- # Any file found → ROOT POLLUTION. Move it to .peaks/<id>/prd/source/
628
- # (for doc snapshots) or .peaks/<id>/qa/ (for QA artifacts).
629
- # Note the migration in TXT handoff. Do NOT complete the workflow
630
- # with intermediate artifacts in the project root.
631
- ```
632
- ```bash
633
- # Extended check for common leak patterns
634
- find . -maxdepth 1 -name "*.png" -o -name "*.jpg" -o -name "qa-*.js" -o -name "mock-server.*" 2>&1
635
- # Any Peaks-Cli QA/UI intermediate files here → ROOT POLLUTION. Move and note.
636
- # Legitimate project files (e.g. favicon.png) are fine — only move Peaks-Cli artifacts.
637
- ```
638
-
639
- **Peaks-Cli Gate G — Project standards present (BLOCKING before workflow completion):**
640
- ```bash
641
- # After `peaks standards init/update --apply`, verify the files actually landed
642
- # at the project root. The CLAUDE.md and rules files are required so that
643
- # subsequent peaks-rd / peaks-qa / peaks-solo runs perform the project-local
644
- # preflight described in CLAUDE.md (read coding-style.md, code-review.md, security.md).
645
- ls <repo>/CLAUDE.md
646
- # "No such file" → BLOCKED. Run `peaks standards init --project <repo> --apply --json`
647
- # (first time) or `peaks standards update --project <repo> --apply --json` (existing).
648
- ls <repo>/.claude/rules/common/coding-style.md \
649
- <repo>/.claude/rules/common/code-review.md \
650
- <repo>/.claude/rules/common/security.md
651
- # Any "No such file" → BLOCKED. The standards apply step did not complete; re-run
652
- # standards init/update with --apply and re-verify.
653
- # Skipping Peaks-Cli Gate G (e.g. because the user did not explicitly authorize writes) is
654
- # only acceptable in `assisted`/`strict` modes where the user actively declined; in
655
- # `full-auto`/`swarm` the absence of these files is a workflow violation.
656
- ```
562
+ The full contract for the 6-type classification table, the 11-step workflow order, and the 7 transition verification gates (A through G with their `ls` / `grep` shell snippets) lives in `references/workflow-gates-and-types.md`. The peaks-solo narrative in this SKILL.md references those gate numbers (Gate A through Gate G) — keep both files in lockstep when adding or renaming a gate. The reference file is the canonical contract; SKILL.md keeps the prose.
657
563
 
658
564
 
659
565
  ## Peaks-Cli Swarm parallel phase (sub-agent fan-out, conditional)
@@ -785,6 +691,8 @@ Solo is itself a skill running in the current session. There are **two distinct
785
691
 
786
692
  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.
787
693
 
694
+ **RD's internal reviews are already parallelized.** When RD finishes implementation, it issues a 3-way sub-agent fan-out (code-review + security-review + perf-baseline, see `skills/peaks-rd/SKILL.md` "Parallel review fan-out") and waits for all to return before transitioning to `qa-handoff`. Solo does NOT need to track three separate RD-side sub-runs; the RD role owns the fan-out lifecycle end-to-end. Solo's presence restoration after the swarm converges is the only coordination point.
695
+
788
696
  **Presence restoration after RD/QA work returns (MANDATORY):** In v1.x, role skills called `peaks skill presence:set <role>` internally and stomped on `.peaks/.active-skill.json`. From v1.3 onward, sub-agents in the Swarm path are forbidden from calling `peaks skill presence:set` (see "Sub-agent dispatch" in each role's SKILL.md), so the main loop's presence file is preserved across the fan-out window by construction. The one place Solo still has to actively restore presence is **once after the fan-out returns** (gate=swarm-converged) and again **after each RD↔QA repair iteration** (gate=repair-cycle-<N>). Use the same command from Step 2 with the current mode and the gate that has just advanced:
789
697
 
790
698
  ```bash
@@ -827,158 +735,9 @@ In full-auto mode, treat the RD↔QA repair loop as a built-in controller object
827
735
 
828
736
  ## Default runbook
829
737
 
830
- > **Maintenance**: The numbered workflow list above (steps 0-11) is the canonical phase sequence. This runbook is the executable CLI transcription. When updating this skill, keep both in lockstep a change to one must be reflected in the other.
738
+ The end-to-end CLI sequence for the `full-auto` profile lives in `references/runbook.md` (extracted from this file to keep SKILL.md under the 800-line cap from `common/coding-style.md`). `assisted` and `strict` profiles pause at `[CONFIRM]` markers in the runbook; `full-auto` and `swarm` auto-proceed through all gates. See Transition Gates for artifact verification at each stage. The numbered workflow list (steps 0-11) earlier in this SKILL.md is the canonical phase sequence; the runbook is the executable CLI transcription keep both in lockstep when updating.
831
739
 
832
- 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.
833
-
834
- ```bash
835
- # 0. Peaks-Cli Snapshot + 0.5 Peaks-Cli Workspace + 0.6 Peaks-Cli Project scan + 0.7 Peaks-Cli Existing-system extraction
836
- peaks doctor --json
837
- peaks project dashboard --project <repo> --json
838
- peaks skill runbook peaks-solo --json
839
- peaks workspace init --project <repo> --json
840
- peaks scan archetype --project <repo> --json
841
- # → copy archetype, frontendOnly, signals into .peaks/<session-id>/rd/project-scan.md (Peaks-Cli Gate A)
842
- # → if archetype != greenfield AND archetype != unknown:
843
- peaks scan existing-system --project <repo> --json
844
- # → copy tokens, sources, conventions, inconsistencies into .peaks/<session-id>/system/existing-system.md (Peaks-Cli Gate A.5)
845
-
846
- # 1. Peaks-Cli Standards preflight + apply
847
- # Run dry-run first to inspect deltas, then APPLY. In full-auto and swarm modes,
848
- # --apply is the default — Standards files (CLAUDE.md, .claude/rules/**) live INSIDE
849
- # the target project and are required for downstream skill preflight, so producing
850
- # them is part of completing the workflow. Assisted/Strict modes pause for [CONFIRM]
851
- # between dry-run and apply.
852
- peaks standards init --project <repo> --dry-run --json
853
- # or: peaks standards update --project <repo> --dry-run --json
854
- peaks standards init --project <repo> --apply --json
855
- # or: peaks standards update --project <repo> --apply --json
856
- # After apply, verify the files actually exist on disk (see Peaks-Cli Gate G).
857
-
858
- # 2. Peaks-Cli PRD (Assisted/Strict: [CONFIRM] before confirmed-by-user)
859
- # Classify the request type from the PRD: feature | bugfix | refactor | docs | config | chore
860
- # This drives RD/QA gate strictness — see "Mandatory RD QA repair loop" for the matrix.
861
- peaks request init --role prd --id <rid> --project <repo> --apply --type <type> --json
862
- # Cross-verify the chosen --type against the current git diff (only meaningful if RD has started writing code;
863
- # safe to run early too, just expect "no changes" rationale until code lands).
864
- peaks scan request-type-sanity --project <repo> --type <type> --json
865
- # → consistent=false → re-classify before continuing. consistent=true → proceed.
866
- # Lint the PRD artifact before transitioning out of draft.
867
- peaks request lint <rid> --role prd --project <repo> --json
868
- # → ok=false → fill in <placeholders>, then re-run.
869
- peaks request transition <rid> --role prd --state confirmed-by-user --project <repo> --json
870
- peaks request transition <rid> --role prd --state handed-off --project <repo> --json
871
-
872
- # 3. Peaks-Cli Swarm parallel — sub-agent fan-out (Task tool, NOT Skill tool)
873
- # Solo computes the swarm plan from --type + frontendOnly + frontend-keyword scan,
874
- # writes it to .peaks/<sid>/sc/swarm-plan.json, then launches one
875
- # Task(subagent_type="general-purpose", ...) call per sub-agent in the same message.
876
- # See "Peaks-Cli Swarm parallel phase" above for the full decision table and the
877
- # prompt template; the role's required artefact paths are listed there.
878
- # Hard rule: do NOT call Skill(skill="peaks-rd" | "peaks-qa" | "peaks-ui") from
879
- # the Swarm phase — that's the v1.x anti-pattern.
880
- #
881
- # 3a. Pre-fan-out: Solo initialises every role's request artefact slot in the main
882
- # loop so sub-agents find a stable rid <-> artefact binding. Each role's
883
- # sub-agent may also call peaks request init itself (idempotent on the same rid);
884
- # Solo's call here is the source of truth. Only init roles that are in the
885
- # swarm plan — roles not in the plan do not get a slot yet.
886
- peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-fan-out
887
- # for each role in swarm-plan.subAgents:
888
- # peaks request init --role ui --id <rid> --project <repo> --apply --type <type> --json
889
- # peaks request init --role rd --id <rid> --project <repo> --apply --type <type> --json
890
- # peaks request init --role qa --id <rid> --project <repo> --apply --type <type> --json
891
- # e.g. if plan = [ui, rd, qa]: run init for ui, rd, qa.
892
- # If plan = [rd, qa]: run for rd, qa only.
893
- # If plan = [] (config|docs|chore skip): no inits here, jump to step 4 directly.
894
- # 3b. Solo issues N Task(subagent_type="general-purpose", ...) calls in ONE message
895
- # (N = len(swarm-plan.subAgents)). Each prompt embeds the role's body minus
896
- # Step 0 / presence, plus the runtime args (rid / sid / mode / type / paths).
897
- # 3c. After fan-out, Solo restores presence once and runs Gate B (ls checks):
898
- peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-converged
899
- ls .peaks/<sid>/prd/requests/<rid>.md # PRD artefact must exist (Gate B hard)
900
- # feature / refactor → ls .peaks/<sid>/rd/tech-doc.md
901
- # bugfix → ls .peaks/<sid>/rd/bug-analysis.md
902
- ls .peaks/<sid>/qa/test-cases/<rid>.md # QA test-cases (skipped for docs|chore)
903
- # ui (only when in plan):
904
- ls .peaks/<sid>/ui/design-draft.md 2>&1 # non-blocking (Gate B info)
905
- # Apply the degradation rules in the main SKILL.md if any artefact is missing.
906
- # → Peaks-Cli Gate B convergence check. Assisted/Strict: [CONFIRM]
907
-
908
- # 4. Peaks-Cli RD planning artifact (the file required by the prerequisite gate)
909
- # feature / refactor → write .peaks/<id>/rd/tech-doc.md
910
- # bugfix → write .peaks/<id>/rd/bug-analysis.md
911
- # config → no planning artifact required at this state
912
- # docs / chore → no planning artifact required
913
- peaks request transition <rid> --role rd --state implemented --project <repo> --json
914
-
915
- # 5. Peaks-Cli Code review + security review BEFORE qa-handoff transition.
916
- # Produce the evidence files the CLI gate enforces:
917
- # - .peaks/<id>/rd/code-review.md (CRITICAL/HIGH findings + fixes; required for feature/bugfix/refactor)
918
- # - .peaks/<id>/rd/security-review.md (required for feature/bugfix/refactor/config)
919
- # Then transition. If --type is docs/chore the gate is empty and the transition is unguarded.
920
- peaks request transition <rid> --role rd --state qa-handoff --project <repo> --json
921
-
922
- # 6. Peaks-Cli QA validation (AUTO-PROCEED from RD in full-auto)
923
- # Before each QA transition, produce the evidence files the CLI gate enforces:
924
- # Before qa:running → .peaks/<id>/qa/test-cases/<rid>.md
925
- peaks request transition <rid> --role qa --state running --project <repo> --json
926
- # Before qa:verdict-issued → .peaks/<id>/qa/test-reports/<rid>.md
927
- # + .peaks/<id>/qa/security-findings.md
928
- # + .peaks/<id>/qa/performance-findings.md (feature/refactor only)
929
- peaks request transition <rid> --role qa --state verdict-issued --project <repo> --json
930
- # → Peaks-Cli Gate D check. Assisted/Strict: [CONFIRM]
931
-
932
- # 7. Peaks-Cli RD↔QA repair loop — if verdict is return-to-rd, re-run 4 through 6 until QA passes or blocked TXT.
933
- # Before invoking peaks-rd again, check the cycle count so you don't blow past the cap silently:
934
- peaks request repair-status <rid> --project <repo> --json
935
- # → atCap=true → STOP and emit a blocked TXT handoff. Do NOT enter another cycle.
936
- # → remaining > 0 → safe to continue. The next transition's --reason must include "QA return-to-rd cycle N: ..."
937
- # so this command keeps counting accurately.
938
- # After RD finishes the repair, re-check that the diff is still consistent with the declared --type:
939
- peaks scan request-type-sanity --project <repo> --type <type> --json
940
- # → consistent=false → RD scope-creeped during repair; review before re-handoff.
941
-
942
- # 8. Peaks-Cli SC phase
943
- peaks sc impact --change-id <cid> --module <module> --file <path> --json
944
- peaks sc retention --slice-id <rid> --prd <prd> --rd <rd> --qa <qa> --json
945
- peaks sc validate --slice-id <rid> --json
946
- peaks sc boundary --slice-id <rid> --artifact <artifact> --code <file> --json
947
-
948
- # 9. Peaks-Cli OpenSpec archive (exit gate; only after QA pass, when openspec/ exists)
949
- peaks openspec validate <cid> --project <repo> --json
950
- peaks openspec archive <cid> --project <repo> --apply --json
951
-
952
- # 10. Peaks-Cli TXT handoff — invoke peaks-txt which embeds memory markers and extracts
953
- # peaks-txt writes the handoff capsule to .peaks/<id>/txt/handoff.md. Inside the
954
- # capsule body, peaks-txt embeds <!-- peaks-memory:start --> blocks for every
955
- # stable project fact surfaced this session.
956
- #
957
- # 10a. Skill-side scan (do this BEFORE the AskUserQuestion below):
958
- # grep -n "peaks-memory:start" .peaks/<id>/txt/handoff.md
959
- # Record the count. This is the skill doing the work, not a CLI command —
960
- # we deliberately do not ship a `peaks memory scan` because the LLM is
961
- # the only consumer and the LLM has grep.
962
-
963
- # 10b. AskUserQuestion (only if 10a returned count >= 1):
964
- # "The TXT handoff has N peaks-memory:start blocks. Persist to .peaks/memory/?
965
- # (a) Apply all — `peaks memory extract --project <repo>
966
- # --artifact .peaks/<id>/txt/handoff.md --apply --json`
967
- # (b) Apply selectively — re-edit handoff.md first, then re-apply
968
- # (c) Skip for now — blocks stay in the handoff only, no .peaks/memory/ write"
969
- # If 10a returned 0 AND the session surfaced a stable project fact
970
- # (decision / convention / approved refactor), STOP — peaks-txt must go
971
- # back and embed at least one block before Solo can advance.
972
-
973
- # 10c. After the user picks (a) or (b), run:
974
- peaks memory extract --project <repo> --artifact .peaks/<id>/txt/handoff.md --apply --json
975
- # --apply is REQUIRED to write .peaks/memory/; without it the command only
976
- # previews. The extract regenerates index.json in the same call.
977
-
978
- # 11. Peaks-Cli Final snapshot
979
- peaks project dashboard --project <repo> --json
980
- peaks skill doctor --json
981
- ```
740
+ Maintenance: when adding new CLI commands to the runbook, mirror them into both `references/runbook.md` and the test in `tests/unit/skill-default-runbook.test.ts` (the test falls back to `references/runbook.md` when the SKILL.md section is a pointer).
982
741
 
983
742
  Repair loop details: see `## Mandatory RD QA repair loop` above for the full 5-step procedure and the 3-cycle cap. Append transition notes via `--reason` rather than rewriting artifacts during repair cycles.
984
743
 
@@ -1031,6 +790,7 @@ These commands harden the workflow against silent skips. Use them in the runbook
1031
790
  | `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) |
1032
791
  | `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 |
1033
792
  | `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 |
793
+ | `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) |
1034
794
 
1035
795
  Together with `peaks request transition` (which already CLI-enforces per-type artifact prerequisites), these four commands form the runtime quality net. SKILL.md prose is descriptive; the CLI is what physically blocks bad workflows.
1036
796
 
@@ -0,0 +1,166 @@
1
+ # Peaks-Cli Default Runbook (orchestrator, full-auto profile)
2
+
3
+ > **Maintenance**: The numbered workflow list in `skills/peaks-solo/SKILL.md` (steps 0-11) is the canonical phase sequence. This runbook is the executable CLI transcription. When updating, keep both in lockstep — a change to one must be reflected in the other.
4
+ >
5
+ > **Why this is a reference, not inline**: the runbook is a stable, copy-pasteable shell (~150 lines of bash) that does not change between skill runs. Inlining it bloats the orchestrator skill body past the 800-line cap (per `common/coding-style.md`). Extracting it here keeps SKILL.md focused on flow / decisions / contracts, while the runbook stays as the canonical place for the CLI sequence.
6
+ >
7
+ > **How peaks-cli tooling reads this file**:
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
+ > - 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
+
11
+ ## Default runbook
12
+
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
+
15
+ ```bash
16
+ # 0. Peaks-Cli Snapshot + 0.5 Peaks-Cli Workspace + 0.6 Peaks-Cli Project scan + 0.7 Peaks-Cli Existing-system extraction
17
+ peaks doctor --json
18
+ peaks project dashboard --project <repo> --json
19
+ peaks skill runbook peaks-solo --json
20
+ peaks workspace init --project <repo> --json
21
+ peaks scan archetype --project <repo> --json
22
+ # → copy archetype, frontendOnly, signals into .peaks/<session-id>/rd/project-scan.md (Peaks-Cli Gate A)
23
+ # → copy libraries[] into .peaks/<session-id>/rd/project-scan.md under `## Library versions`
24
+ peaks scan libraries --project <repo> --json
25
+ # → if archetype != greenfield AND archetype != unknown:
26
+ peaks scan existing-system --project <repo> --json
27
+ # → copy tokens, sources, conventions, inconsistencies into .peaks/<session-id>/system/existing-system.md (Peaks-Cli Gate A.5)
28
+
29
+ # 1. Peaks-Cli Standards preflight + apply
30
+ # Run dry-run first to inspect deltas, then APPLY. In full-auto and swarm modes,
31
+ # --apply is the default — Standards files (CLAUDE.md, .claude/rules/**) live INSIDE
32
+ # the target project and are required for downstream skill preflight, so producing
33
+ # them is part of completing the workflow. Assisted/Strict modes pause for [CONFIRM]
34
+ # between dry-run and apply.
35
+ peaks standards init --project <repo> --dry-run --json
36
+ # or: peaks standards update --project <repo> --dry-run --json
37
+ peaks standards init --project <repo> --apply --json
38
+ # or: peaks standards update --project <repo> --apply --json
39
+ # After apply, verify the files actually exist on disk (see Peaks-Cli Gate G).
40
+
41
+ # 2. Peaks-Cli PRD (Assisted/Strict: [CONFIRM] before confirmed-by-user)
42
+ # Classify the request type from the PRD: feature | bugfix | refactor | docs | config | chore
43
+ # This drives RD/QA gate strictness — see "Mandatory RD QA repair loop" for the matrix.
44
+ peaks request init --role prd --id <rid> --project <repo> --apply --type <type> --json
45
+ # Cross-verify the chosen --type against the current git diff (only meaningful if RD has started writing code;
46
+ # safe to run early too, just expect "no changes" rationale until code lands).
47
+ peaks scan request-type-sanity --project <repo> --type <type> --json
48
+ # → consistent=false → re-classify before continuing. consistent=true → proceed.
49
+ # Lint the PRD artifact before transitioning out of draft.
50
+ peaks request lint <rid> --role prd --project <repo> --json
51
+ # → ok=false → fill in <placeholders>, then re-run.
52
+ peaks request transition <rid> --role prd --state confirmed-by-user --project <repo> --json
53
+ peaks request transition <rid> --role prd --state handed-off --project <repo> --json
54
+
55
+ # 3. Peaks-Cli Swarm parallel — sub-agent fan-out (Task tool, NOT Skill tool)
56
+ # Solo computes the swarm plan from --type + frontendOnly + frontend-keyword scan,
57
+ # writes it to .peaks/<sid>/sc/swarm-plan.json, then launches one
58
+ # Task(subagent_type="general-purpose", ...) call per sub-agent in the same message.
59
+ # See "Peaks-Cli Swarm parallel phase" above for the full decision table and the
60
+ # prompt template; the role's required artefact paths are listed there.
61
+ # Hard rule: do NOT call Skill(skill="peaks-rd" | "peaks-qa" | "peaks-ui") from
62
+ # the Swarm phase — that's the v1.x anti-pattern.
63
+ #
64
+ # 3a. Pre-fan-out: Solo initialises every role's request artefact slot in the main
65
+ # loop so sub-agents find a stable rid <-> artefact binding. Each role's
66
+ # sub-agent may also call peaks request init itself (idempotent on the same rid);
67
+ # Solo's call here is the source of truth. Only init roles that are in the
68
+ # swarm plan — roles not in the plan do not get a slot yet.
69
+ peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-fan-out
70
+ # for each role in swarm-plan.subAgents:
71
+ # peaks request init --role ui --id <rid> --project <repo> --apply --type <type> --json
72
+ # peaks request init --role rd --id <rid> --project <repo> --apply --type <type> --json
73
+ # peaks request init --role qa --id <rid> --project <repo> --apply --type <type> --json
74
+ # e.g. if plan = [ui, rd, qa]: run init for ui, rd, qa.
75
+ # If plan = [rd, qa]: run for rd, qa only.
76
+ # If plan = [] (config|docs|chore skip): no inits here, jump to step 4 directly.
77
+ # 3b. Solo issues N Task(subagent_type="general-purpose", ...) calls in ONE message
78
+ # (N = len(swarm-plan.subAgents)). Each prompt embeds the role's body minus
79
+ # Step 0 / presence, plus the runtime args (rid / sid / mode / type / paths).
80
+ # 3c. After fan-out, Solo restores presence once and runs Gate B (ls checks):
81
+ peaks skill presence:set peaks-solo --project <repo> --mode <mode> --gate swarm-converged
82
+ ls .peaks/<sid>/prd/requests/<rid>.md # PRD artefact must exist (Gate B hard)
83
+ # feature / refactor → ls .peaks/<sid>/rd/tech-doc.md
84
+ # bugfix → ls .peaks/<sid>/rd/bug-analysis.md
85
+ ls .peaks/<sid>/qa/test-cases/<rid>.md # QA test-cases (skipped for docs|chore)
86
+ # ui (only when in plan):
87
+ ls .peaks/<sid>/ui/design-draft.md 2>&1 # non-blocking (Gate B info)
88
+ # Apply the degradation rules in the main SKILL.md if any artefact is missing.
89
+ # → Peaks-Cli Gate B convergence check. Assisted/Strict: [CONFIRM]
90
+
91
+ # 4. Peaks-Cli RD planning artifact (the file required by the prerequisite gate)
92
+ # feature / refactor → write .peaks/<id>/rd/tech-doc.md
93
+ # bugfix → write .peaks/<id>/rd/bug-analysis.md
94
+ # config → no planning artifact required at this state
95
+ # docs / chore → no planning artifact required
96
+ peaks request transition <rid> --role rd --state implemented --project <repo> --json
97
+
98
+ # 5. Peaks-Cli Code review + security review BEFORE qa-handoff transition.
99
+ # Produce the evidence files the CLI gate enforces:
100
+ # - .peaks/<id>/rd/code-review.md (CRITICAL/HIGH findings + fixes; required for feature/bugfix/refactor)
101
+ # - .peaks/<id>/rd/security-review.md (required for feature/bugfix/refactor/config)
102
+ # Then transition. If --type is docs/chore the gate is empty and the transition is unguarded.
103
+ peaks request transition <rid> --role rd --state qa-handoff --project <repo> --json
104
+
105
+ # 6. Peaks-Cli QA validation (AUTO-PROCEED from RD in full-auto)
106
+ # Before each QA transition, produce the evidence files the CLI gate enforces:
107
+ # Before qa:running → .peaks/<id>/qa/test-cases/<rid>.md
108
+ peaks request transition <rid> --role qa --state running --project <repo> --json
109
+ # Before qa:verdict-issued → .peaks/<id>/qa/test-reports/<rid>.md
110
+ # + .peaks/<id>/qa/security-findings.md
111
+ # + .peaks/<id>/qa/performance-findings.md (feature/refactor only)
112
+ peaks request transition <rid> --role qa --state verdict-issued --project <repo> --json
113
+ # → Peaks-Cli Gate D check. Assisted/Strict: [CONFIRM]
114
+
115
+ # 7. Peaks-Cli RD↔QA repair loop — if verdict is return-to-rd, re-run 4 through 6 until QA passes or blocked TXT.
116
+ # Before invoking peaks-rd again, check the cycle count so you don't blow past the cap silently:
117
+ peaks request repair-status <rid> --project <repo> --json
118
+ # → atCap=true → STOP and emit a blocked TXT handoff. Do NOT enter another cycle.
119
+ # → remaining > 0 → safe to continue. The next transition's --reason must include "QA return-to-rd cycle N: ..."
120
+ # so this command keeps counting accurately.
121
+ # After RD finishes the repair, re-check that the diff is still consistent with the declared --type:
122
+ peaks scan request-type-sanity --project <repo> --type <type> --json
123
+ # → consistent=false → RD scope-creeped during repair; review before re-handoff.
124
+
125
+ # 8. Peaks-Cli SC phase
126
+ peaks sc impact --change-id <cid> --module <module> --file <path> --json
127
+ peaks sc retention --slice-id <rid> --prd <prd> --rd <rd> --qa <qa> --json
128
+ peaks sc validate --slice-id <rid> --json
129
+ peaks sc boundary --slice-id <rid> --artifact <artifact> --code <file> --json
130
+
131
+ # 9. Peaks-Cli OpenSpec archive (exit gate; only after QA pass, when openspec/ exists)
132
+ peaks openspec validate <cid> --project <repo> --json
133
+ peaks openspec archive <cid> --project <repo> --apply --json
134
+
135
+ # 10. Peaks-Cli TXT handoff — invoke peaks-txt which embeds memory markers and extracts
136
+ # peaks-txt writes the handoff capsule to .peaks/<id>/txt/handoff.md. Inside the
137
+ # capsule body, peaks-txt embeds <!-- peaks-memory:start --> blocks for every
138
+ # stable project fact surfaced this session.
139
+ #
140
+ # 10a. Skill-side scan (do this BEFORE the AskUserQuestion below):
141
+ # grep -n "peaks-memory:start" .peaks/<id>/txt/handoff.md
142
+ # Record the count. This is the skill doing the work, not a CLI command —
143
+ # we deliberately do not ship a `peaks memory scan` because the LLM is
144
+ # the only consumer and the LLM has grep.
145
+
146
+ # 10b. AskUserQuestion (only if 10a returned count >= 1):
147
+ # "The TXT handoff has N peaks-memory:start blocks. Persist to .peaks/memory/?
148
+ # (a) Apply all — `peaks memory extract --project <repo>
149
+ # --artifact .peaks/<id>/txt/handoff.md --apply --json`
150
+ # (b) Apply selectively — re-edit handoff.md first, then re-apply
151
+ # (c) Skip for now — blocks stay in the handoff only, no .peaks/memory/ write"
152
+ # If 10a returned 0 AND the session surfaced a stable project fact
153
+ # (decision / convention / approved refactor), STOP — peaks-txt must go
154
+ # back and embed at least one block before Solo can advance.
155
+
156
+ # 10c. After the user picks (a) or (b), run:
157
+ peaks memory extract --project <repo> --artifact .peaks/<id>/txt/handoff.md --apply --json
158
+ # --apply is REQUIRED to write .peaks/memory/; without it the command only
159
+ # previews. The extract regenerates index.json in the same call.
160
+
161
+ # 11. Peaks-Cli Final snapshot
162
+ peaks project dashboard --project <repo> --json
163
+ peaks skill doctor --json
164
+ ```
165
+
166
+ Repair loop details: see `## Mandatory RD QA repair loop` in SKILL.md for the full 5-step procedure and the 3-cycle cap. Append transition notes via `--reason` rather than rewriting artifacts during repair cycles.