peaks-cli 1.0.17 → 1.0.19

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 (39) hide show
  1. package/dist/src/cli/commands/request-commands.js +109 -3
  2. package/dist/src/cli/commands/scan-commands.d.ts +3 -0
  3. package/dist/src/cli/commands/scan-commands.js +194 -0
  4. package/dist/src/cli/commands/workspace-commands.d.ts +3 -0
  5. package/dist/src/cli/commands/workspace-commands.js +32 -0
  6. package/dist/src/cli/program.js +4 -0
  7. package/dist/src/services/artifacts/artifact-lint-service.d.ts +23 -0
  8. package/dist/src/services/artifacts/artifact-lint-service.js +80 -0
  9. package/dist/src/services/artifacts/artifact-prerequisites.d.ts +28 -0
  10. package/dist/src/services/artifacts/artifact-prerequisites.js +77 -0
  11. package/dist/src/services/artifacts/repair-cycle-service.d.ts +23 -0
  12. package/dist/src/services/artifacts/repair-cycle-service.js +52 -0
  13. package/dist/src/services/artifacts/request-artifact-service.d.ts +14 -0
  14. package/dist/src/services/artifacts/request-artifact-service.js +73 -21
  15. package/dist/src/services/scan/acceptance-coverage-service.d.ts +42 -0
  16. package/dist/src/services/scan/acceptance-coverage-service.js +135 -0
  17. package/dist/src/services/scan/archetype-service.d.ts +5 -0
  18. package/dist/src/services/scan/archetype-service.js +253 -0
  19. package/dist/src/services/scan/diff-scope-service.d.ts +40 -0
  20. package/dist/src/services/scan/diff-scope-service.js +198 -0
  21. package/dist/src/services/scan/existing-system-service.d.ts +7 -0
  22. package/dist/src/services/scan/existing-system-service.js +300 -0
  23. package/dist/src/services/scan/scan-types.d.ts +59 -0
  24. package/dist/src/services/scan/scan-types.js +1 -0
  25. package/dist/src/services/scan/type-sanity-service.d.ts +23 -0
  26. package/dist/src/services/scan/type-sanity-service.js +108 -0
  27. package/dist/src/services/standards/project-context.d.ts +24 -0
  28. package/dist/src/services/standards/project-context.js +318 -0
  29. package/dist/src/services/standards/project-standards-service.js +145 -40
  30. package/dist/src/services/workspace/workspace-service.d.ts +16 -0
  31. package/dist/src/services/workspace/workspace-service.js +66 -0
  32. package/dist/src/shared/version.d.ts +1 -1
  33. package/dist/src/shared/version.js +1 -1
  34. package/package.json +1 -1
  35. package/skills/peaks-qa/SKILL.md +56 -0
  36. package/skills/peaks-rd/SKILL.md +65 -2
  37. package/skills/peaks-solo/SKILL.md +307 -61
  38. package/skills/peaks-solo/references/existing-system-extraction.md +78 -0
  39. package/skills/peaks-ui/SKILL.md +9 -1
@@ -85,6 +85,16 @@ peaks openspec validate <change-id> --project <repo> --prefer-external --json
85
85
  peaks mcp list --json
86
86
  peaks mcp plan --capability playwright-mcp.browser-validation --json
87
87
  peaks mcp apply --capability playwright-mcp.browser-validation --yes --json
88
+ # DEV-SERVER REQUIREMENT (BLOCKING): a running dev server is REQUIRED for browser E2E.
89
+ # Start the dev server (npm run dev / pnpm dev / umi dev / etc) and capture the actual
90
+ # advertised URL from its stdout (do NOT hard-code localhost:8000). If the dev server
91
+ # fails to start, hangs, or times out (e.g. tailwindcss/plugin slowness, port conflict,
92
+ # missing env), this is a BLOCKER — NOT a reason to skip browser E2E. You MUST:
93
+ # 1. Record the failure and root cause in qa/test-reports/<rid>.md;
94
+ # 2. Return verdict=blocked (or return-to-rd if the root cause is implementation-related);
95
+ # 3. NEVER substitute a production build (`umi build` / `vite build` / `next build`) for
96
+ # browser E2E. A successful production build proves compilation, not runtime behavior,
97
+ # and does NOT satisfy Gate D. Treating prod build as a fallback is a workflow violation.
88
98
  # Playwright MCP MUST simulate real user operations — not just take static screenshots.
89
99
  # The minimum interaction sequence for every frontend page/flow:
90
100
  # mcp__playwright__browser_navigate → URL (after allow-list), launches headed browser
@@ -102,6 +112,12 @@ peaks mcp apply --capability playwright-mcp.browser-validation --yes --json
102
112
 
103
113
  # 8. write per-criterion acceptance results, regression matrix, security/performance findings,
104
114
  # and the final verdict into the QA request artifact. Mark state=verdict-issued.
115
+ # BEFORE the transition, run the QA quality-gate CLI checks (see Gate E/F):
116
+ peaks scan acceptance-coverage --rid <rid> --project <repo> --json
117
+ # → ok=false → BLOCKED. Some PRD acceptance items have no linked test case
118
+ # (or some test cases reference non-existent acceptance ids). Fix the test-cases file.
119
+ peaks request lint <rid> --role qa --project <repo> --json
120
+ # → ok=false → BLOCKED. The QA artifact body has unfilled <placeholders> or "..." stubs.
105
121
 
106
122
  # 9. on verdict=return-to-rd, route findings back through the request id; otherwise close.
107
123
  peaks request show <request-id> --role qa --project <repo> --json
@@ -115,6 +131,17 @@ Verdict `pass` is blocked until every applicable validation gate has evidence in
115
131
 
116
132
  You cannot declare a phase complete from memory. Each gate below is a `ls` or `grep` command you **MUST run** and whose output you **MUST see** before proceeding. If any file shows "No such file" or any command returns empty, the phase is incomplete.
117
133
 
134
+ > **CLI enforcement (NEW)**: the gates below are now ALSO enforced by `peaks request transition`. The CLI checks the same files before allowing the transition and fails with `code: PREREQUISITES_MISSING` if any are absent. Required files depend on the request type recorded at `peaks request init --type ...`:
135
+ >
136
+ > | Type | qa:running requires | qa:verdict-issued also requires |
137
+ > |---|---|---|
138
+ > | feature / refactor | `qa/test-cases/<rid>.md` | `qa/test-reports/<rid>.md` + `qa/security-findings.md` + `qa/performance-findings.md` |
139
+ > | bugfix | `qa/test-cases/<rid>.md` (MUST include the regression test) | `qa/test-reports/<rid>.md` + `qa/security-findings.md` (perf optional unless the bug is performance-related) |
140
+ > | config | (none) | `qa/security-findings.md` only |
141
+ > | docs / chore | (none) | (none) |
142
+ >
143
+ > For feature / refactor, `security-findings.md` and `performance-findings.md` MUST exist — record `"no findings"` inside if truly clean rather than skipping the file. The escape hatch `--allow-incomplete --reason "<justification>"` is recorded in the artifact transition note.
144
+
118
145
  **Gate A — After test-case generation:**
119
146
  ```bash
120
147
  ls .peaks/<id>/qa/test-cases/<rid>.md
@@ -176,6 +203,26 @@ ls .peaks/<id>/qa/test-cases/<rid>.md \
176
203
  # An empty "N/A — skipped" file does NOT pass. Every file must contain findings.
177
204
  ```
178
205
 
206
+ **Gate E — Acceptance coverage (every PRD acceptance item has a linked test case):**
207
+ ```bash
208
+ peaks scan acceptance-coverage --rid <rid> --project <repo> --session-id <sid> --json
209
+ # Expected: ok=true. exit 0.
210
+ # uncovered[] non-empty → BLOCKED. List of acceptance items without test cases is in the output.
211
+ # Add `- **Acceptance:** A<N>` lines to the matching test cases in qa/test-cases/<rid>.md, then re-run.
212
+ # invalidReferences[] non-empty → BLOCKED. A test case references an acceptance id that does not exist.
213
+ # Fix the typo or remove the reference.
214
+ # unlinkedTestCases[] non-empty → WARNING (not blocking). These test cases have no Acceptance: field;
215
+ # either link them or add `- **Acceptance:** —` with rationale in the Evidence field.
216
+ ```
217
+
218
+ **Gate F — QA artifact body has no unfilled placeholders:**
219
+ ```bash
220
+ peaks request lint <rid> --role qa --project <repo> --session-id <sid> --json
221
+ # Expected: ok=true. exit 0.
222
+ # ok=false → BLOCKED. Lint output lists every <placeholder>, "- ..." stub, and TBD marker.
223
+ # Fill them in before issuing the verdict.
224
+ ```
225
+
179
226
  **Gate D — Frontend browser evidence (BLOCKING when frontend is in scope):**
180
227
  ```bash
181
228
  # Verify browser screenshots exist. Screenshots are the only acceptable evidence
@@ -184,6 +231,10 @@ ls .peaks/<id>/qa/screenshots/*.png 2>&1
184
231
  # Expected: one or more .png files
185
232
  # "No such file" → BLOCKED. Playwright MCP was not used or screenshots not saved.
186
233
  # Screenshots, logs, manual steps, or other tools must NOT substitute for this gate.
234
+ # A successful production build (`umi build` / `vite build` / `next build` exit 0) does
235
+ # NOT substitute for this gate. Compilation success ≠ runtime behavior.
236
+ # If the dev server cannot start, verdict MUST be `blocked` (or `return-to-rd`),
237
+ # NOT `pass`. Record the dev-server failure root cause in the test report.
187
238
  # Re-run frontend browser validation (step 7 in runbook) and save screenshots.
188
239
  ```
189
240
  ```bash
@@ -240,6 +291,7 @@ QA must generate test cases, not merely inspect existing ones. Every QA invocati
240
291
  ## Test Case: <title>
241
292
  - **Category:** unit | integration | ui-regression
242
293
  - **Target:** <file-or-route>
294
+ - **Acceptance:** A1, A2 (comma-separated IDs from PRD `## Acceptance criteria`; see "Acceptance linkage" below)
243
295
  - **Preconditions:** <state-before>
244
296
  - **Steps:** 1. ... 2. ...
245
297
  - **Expected result:** <what-should-happen>
@@ -247,6 +299,8 @@ QA must generate test cases, not merely inspect existing ones. Every QA invocati
247
299
  - **Evidence:** <link-or-observation>
248
300
  ```
249
301
 
302
+ **Acceptance linkage (MANDATORY)** — every test case MUST have an `**Acceptance:**` field that references one or more acceptance items from the PRD by their position-based IDs (A1 = first bullet, A2 = second, …). The `peaks scan acceptance-coverage --rid <rid> --project <repo>` command parses both the PRD and this file, builds the coverage map, and fails the QA `verdict-issued` gate if any acceptance item has zero linked test cases. Test cases that genuinely have no acceptance owner (e.g. defense-in-depth regressions) should still include `- **Acceptance:** —` and explain in the **Evidence** field; the coverage report flags these as `unlinkedTestCases` for review without auto-blocking.
303
+
250
304
  **Test-case execution**: Run the project's test command and record results against each generated test case. If the project uses Jest, run `npx jest --coverage` and link the coverage report. If the project uses Vitest, run `npx vitest run --coverage`. Record the coverage percentage for changed files in the test report.
251
305
 
252
306
  ## Mandatory test-report output
@@ -277,6 +331,8 @@ QA cannot pass a change until the report contains evidence for every applicable
277
331
  6. **Security check** — run security review for the changed surface and dependency/config changes. Record findings, fixes, and unresolved risks.
278
332
  7. **Performance check** — run the project’s available performance check, build-size check, Lighthouse-equivalent check, or browser performance inspection appropriate to the change. Record baseline/after numbers when available.
279
333
  8. **Validation report** — write or link a report containing scope, environment, commands, sanitized browser evidence, security/performance results, pass/fail summary, residual risks, and next action.
334
+ 9. **Acceptance coverage** — every PRD acceptance item has at least one linked QA test case (`peaks scan acceptance-coverage --rid <rid>`). **→ verified by Gate E**. This is the deterministic check that no requirement was forgotten between PRD and verdict.
335
+ 10. **QA artifact lint** — the QA request artifact body has no unfilled placeholders (`peaks request lint <rid> --role qa`). **→ verified by Gate F**. Catches the "wrote the template, forgot to fill it" failure mode that template-style reports invite.
280
336
 
281
337
  If Playwright MCP is unavailable (not installed and the user has not authorized installation), mark the gate blocked with the missing capability. Screenshots, logs, manual steps, or other tools must not substitute for the mandatory frontend browser gate. Do not silently downgrade frontend validation to API-only testing.
282
338
 
@@ -119,6 +119,15 @@ peaks mcp call --capability context7.docs-lookup --tool <name> --args-json '{...
119
119
  # Gate B2: unit tests exist and pass → npx vitest run (or project equivalent)
120
120
  # Gate B3: code review evidence → .peaks/<id>/rd/code-review.md
121
121
  # Gate B4: security review evidence → .peaks/<id>/rd/security-review.md
122
+ # Gate B5 (NEW): RD artifact body has no unfilled placeholders.
123
+ peaks request lint <rid> --role rd --project <repo> --session-id <sid> --json
124
+ # Gate B6 (NEW): declared --type still matches the actual diff after implementation.
125
+ peaks scan request-type-sanity --project <repo> --type <type> --json
126
+ # Gate B7 (NEW, repair cycles only): we have not exceeded the 3-cycle cap.
127
+ peaks request repair-status <rid> --project <repo> --session-id <sid> --json
128
+ # Gate B8 (NEW): every changed file matches the RD red-line scope (no out-of-bounds writes).
129
+ peaks scan diff-vs-scope --rid <rid> --project <repo> --session-id <sid> --json
130
+ # All six non-zero → BLOCKED. Fix and re-check before attempting the qa-handoff transition.
122
131
 
123
132
  # 7. self-validate before QA handoff
124
133
  peaks openspec validate <change-id> --project <repo> --json # exit gate (re-run)
@@ -135,6 +144,17 @@ For refactor work, the coverage ≥ 95% gate in `Refactor hard gates` still appl
135
144
 
136
145
  You cannot declare a phase complete from memory. Each gate below is a `ls` or `grep` command you **MUST run** and whose output you **MUST see** before proceeding. If any file shows "No such file" or any command returns empty, the phase is incomplete.
137
146
 
147
+ > **CLI enforcement (NEW)**: the gates below are now ALSO enforced by `peaks request transition`. The CLI checks the same files before allowing the transition and fails with `code: PREREQUISITES_MISSING` if any are absent. The exact required files depend on the request type chosen at `peaks request init --type <feature|bugfix|refactor|docs|config|chore>` (default `feature`):
148
+ >
149
+ > | Type | rd:implemented requires | rd:qa-handoff also requires |
150
+ > |---|---|---|
151
+ > | feature / refactor | `rd/tech-doc.md` | `rd/code-review.md` + `rd/security-review.md` |
152
+ > | bugfix | `rd/bug-analysis.md` (lighter than tech-doc; root cause + fix + regression test plan) | `rd/code-review.md` + `rd/security-review.md` |
153
+ > | config | (none) | `rd/security-review.md` only |
154
+ > | docs / chore | (none) | (none) |
155
+ >
156
+ > The escape hatch `--allow-incomplete --reason "<text>"` still exists for one-off exceptions; the bypass is recorded in the artifact transition note.
157
+
138
158
  **Gate A — After project-scan read (before any implementation):**
139
159
  ```bash
140
160
  ls .peaks/<id>/rd/project-scan.md
@@ -195,6 +215,45 @@ ls .peaks/<id>/rd/security-review.md 2>&1
195
215
  # fix CRITICAL/HIGH issues, record findings, then re-check.
196
216
  ```
197
217
 
218
+ **Gate B5 — RD artifact body has no unfilled placeholders:**
219
+ ```bash
220
+ peaks request lint <rid> --role rd --project <repo> --session-id <sid> --json
221
+ # Expected: ok=true. exit 0.
222
+ # ok=false → BLOCKED. The lint output lists every <placeholder>, "- ..." stub,
223
+ # and TBD/TODO marker with line numbers. Fill them in before attempting handoff.
224
+ ```
225
+
226
+ **Gate B6 — Declared --type matches the actual diff:**
227
+ ```bash
228
+ peaks scan request-type-sanity --project <repo> --type <type> --json
229
+ # Expected: consistent=true. exit 0.
230
+ # consistent=false → BLOCKED. Either the implementation scope-creeped beyond what
231
+ # the declared type covers, or the type was mis-classified at PRD time. Re-classify
232
+ # (`peaks request init` with the corrected --type) or trim the scope.
233
+ ```
234
+
235
+ **Gate B7 — Repair cycle cap (only relevant during RD↔QA repair loop):**
236
+ ```bash
237
+ peaks request repair-status <rid> --project <repo> --session-id <sid> --json
238
+ # Expected: atCap=false. exit 0.
239
+ # atCap=true → BLOCKED. Three repair cycles already attempted; emit a blocked TXT
240
+ # handoff via Solo rather than entering a fourth cycle.
241
+ ```
242
+
243
+ **Gate B8 — Diff stays inside the declared red-line scope:**
244
+ ```bash
245
+ peaks scan diff-vs-scope --rid <rid> --project <repo> --session-id <sid> --json
246
+ # Expected: ok=true. exit 0.
247
+ # violations[] non-empty → BLOCKED. A changed file matches an explicit out-of-scope
248
+ # pattern. Revert it, or — only with PRD approval — expand the RD red-line scope.
249
+ # unclassified[] non-empty → BLOCKED. A changed file does not match any declared
250
+ # in-scope pattern. Either add it to the in-scope list (intentional widening, requires
251
+ # PRD approval) or revert the change.
252
+ # patternsDeclared=false → BLOCKED. The RD artifact's `## Red-line scope` section has
253
+ # no concrete path or glob patterns. Fill it in with paths like `src/services/login/**`
254
+ # before re-running. Auto-allowed paths (test files, .peaks/, __mocks__/) never need a pattern.
255
+ ```
256
+
198
257
  ## Project standards preflight
199
258
 
200
259
  Before RD planning or implementation work in a code repository, call the Peaks CLI:
@@ -225,11 +284,11 @@ When Peaks RD produces or changes code, dry-run repeatedly instead of only durin
225
284
 
226
285
  Before every code or mock change, RD must write and then enforce a red-line scope check in the RD artifact:
227
286
 
228
- 1. name the exact product requirement, route, UI surface, API path, data model, and files that are in scope;
287
+ 1. name the exact product requirement, route, UI surface, API path, data model, and **path/glob patterns** that are in scope. Write them under the RD artifact's `## Red-line scope` section as bullets. Use `In-scope:` / `Out-of-scope:` subheaders when both lists are non-trivial, or wrap paths in backticks for clarity (e.g. `` `src/services/login/**` ``);
229
288
  2. name adjacent surfaces that are explicitly out of scope, especially list pages, delete/update flows, unrelated API endpoints, existing data records, authentication, permissions, and shared runtime configuration;
230
289
  3. reject any implementation that modifies, deletes, mocks, or replaces out-of-scope behavior just to make validation pass;
231
290
  4. for API/mock work, mock only the exact request path and method required by the approved slice, and do not override broader collection/list endpoints unless the requirement explicitly includes them;
232
- 5. before handoff, inspect the diff against the red-line checklist and record pass/fail evidence. Any unexplained out-of-scope file, endpoint, deletion, or behavior change blocks RD completion.
291
+ 5. before handoff, run `peaks scan diff-vs-scope --rid <rid> --project <repo>` to deterministically verify the diff against the declared patterns (this is **Gate B8**). The CLI auto-allows test files and `.peaks/` artifacts; any other unclassified or out-of-scope file blocks RD completion until the diff is trimmed OR the scope is widened with PRD approval.
233
292
 
234
293
  ## Mandatory tech-doc output
235
294
 
@@ -265,6 +324,10 @@ RD cannot mark a development slice complete until all of these are true. Each ga
265
324
  6. security review has been performed for the changed surface, with CRITICAL/HIGH issues fixed before progression and particular attention to user input, file system access, external calls, auth, secrets, and dependency changes; **→ verified by Gate B4** — evidence file must exist at `.peaks/<id>/rd/security-review.md`
266
325
  7. the post-check dry-run has passed and is linked in the handoff;
267
326
  8. the tech-doc artifact (`.peaks/<session-id>/rd/tech-doc.md`) is written and linked from the request artifact. **→ verified by Gate B**
327
+ 9. the RD request artifact body has no unfilled placeholders, TBD markers, or bare-bullet stubs (`peaks request lint <rid> --role rd`). **→ verified by Gate B5**
328
+ 10. the declared `--type` is still consistent with the actual git diff (`peaks scan request-type-sanity --type <type>`). **→ verified by Gate B6**
329
+ 11. the repair-cycle counter is below the cap before a repeat handoff (`peaks request repair-status <rid>`). **→ verified by Gate B7**
330
+ 12. every changed file matches the RD red-line scope (no out-of-bounds writes); auto-allowed files (tests, .peaks artifacts) don't need an explicit pattern (`peaks scan diff-vs-scope --rid <rid>`). **→ verified by Gate B8**
268
331
 
269
332
  If any gate fails, return to development for fixes or hand off as blocked. Do not describe the work as done, shippable, or ready for QA.
270
333