peaks-cli 1.0.17 → 1.0.18

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 (36) hide show
  1. package/bin/peaks.js +0 -0
  2. package/dist/src/cli/commands/request-commands.js +109 -3
  3. package/dist/src/cli/commands/scan-commands.d.ts +3 -0
  4. package/dist/src/cli/commands/scan-commands.js +194 -0
  5. package/dist/src/cli/commands/workspace-commands.d.ts +3 -0
  6. package/dist/src/cli/commands/workspace-commands.js +32 -0
  7. package/dist/src/cli/program.js +4 -0
  8. package/dist/src/services/artifacts/artifact-lint-service.d.ts +23 -0
  9. package/dist/src/services/artifacts/artifact-lint-service.js +80 -0
  10. package/dist/src/services/artifacts/artifact-prerequisites.d.ts +28 -0
  11. package/dist/src/services/artifacts/artifact-prerequisites.js +77 -0
  12. package/dist/src/services/artifacts/repair-cycle-service.d.ts +23 -0
  13. package/dist/src/services/artifacts/repair-cycle-service.js +52 -0
  14. package/dist/src/services/artifacts/request-artifact-service.d.ts +14 -0
  15. package/dist/src/services/artifacts/request-artifact-service.js +73 -21
  16. package/dist/src/services/scan/acceptance-coverage-service.d.ts +42 -0
  17. package/dist/src/services/scan/acceptance-coverage-service.js +135 -0
  18. package/dist/src/services/scan/archetype-service.d.ts +5 -0
  19. package/dist/src/services/scan/archetype-service.js +253 -0
  20. package/dist/src/services/scan/diff-scope-service.d.ts +40 -0
  21. package/dist/src/services/scan/diff-scope-service.js +198 -0
  22. package/dist/src/services/scan/existing-system-service.d.ts +7 -0
  23. package/dist/src/services/scan/existing-system-service.js +300 -0
  24. package/dist/src/services/scan/scan-types.d.ts +59 -0
  25. package/dist/src/services/scan/scan-types.js +1 -0
  26. package/dist/src/services/scan/type-sanity-service.d.ts +23 -0
  27. package/dist/src/services/scan/type-sanity-service.js +108 -0
  28. package/dist/src/services/workspace/workspace-service.d.ts +16 -0
  29. package/dist/src/services/workspace/workspace-service.js +66 -0
  30. package/dist/src/shared/version.d.ts +1 -1
  31. package/dist/src/shared/version.js +1 -1
  32. package/package.json +1 -1
  33. package/skills/peaks-qa/SKILL.md +42 -0
  34. package/skills/peaks-rd/SKILL.md +65 -2
  35. package/skills/peaks-solo/SKILL.md +275 -57
  36. package/skills/peaks-solo/references/existing-system-extraction.md +78 -0
@@ -102,6 +102,12 @@ peaks mcp apply --capability playwright-mcp.browser-validation --yes --json
102
102
 
103
103
  # 8. write per-criterion acceptance results, regression matrix, security/performance findings,
104
104
  # and the final verdict into the QA request artifact. Mark state=verdict-issued.
105
+ # BEFORE the transition, run the QA quality-gate CLI checks (see Gate E/F):
106
+ peaks scan acceptance-coverage --rid <rid> --project <repo> --json
107
+ # → ok=false → BLOCKED. Some PRD acceptance items have no linked test case
108
+ # (or some test cases reference non-existent acceptance ids). Fix the test-cases file.
109
+ peaks request lint <rid> --role qa --project <repo> --json
110
+ # → ok=false → BLOCKED. The QA artifact body has unfilled <placeholders> or "..." stubs.
105
111
 
106
112
  # 9. on verdict=return-to-rd, route findings back through the request id; otherwise close.
107
113
  peaks request show <request-id> --role qa --project <repo> --json
@@ -115,6 +121,17 @@ Verdict `pass` is blocked until every applicable validation gate has evidence in
115
121
 
116
122
  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
123
 
124
+ > **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 ...`:
125
+ >
126
+ > | Type | qa:running requires | qa:verdict-issued also requires |
127
+ > |---|---|---|
128
+ > | feature / refactor | `qa/test-cases/<rid>.md` | `qa/test-reports/<rid>.md` + `qa/security-findings.md` + `qa/performance-findings.md` |
129
+ > | 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) |
130
+ > | config | (none) | `qa/security-findings.md` only |
131
+ > | docs / chore | (none) | (none) |
132
+ >
133
+ > 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.
134
+
118
135
  **Gate A — After test-case generation:**
119
136
  ```bash
120
137
  ls .peaks/<id>/qa/test-cases/<rid>.md
@@ -176,6 +193,26 @@ ls .peaks/<id>/qa/test-cases/<rid>.md \
176
193
  # An empty "N/A — skipped" file does NOT pass. Every file must contain findings.
177
194
  ```
178
195
 
196
+ **Gate E — Acceptance coverage (every PRD acceptance item has a linked test case):**
197
+ ```bash
198
+ peaks scan acceptance-coverage --rid <rid> --project <repo> --session-id <sid> --json
199
+ # Expected: ok=true. exit 0.
200
+ # uncovered[] non-empty → BLOCKED. List of acceptance items without test cases is in the output.
201
+ # Add `- **Acceptance:** A<N>` lines to the matching test cases in qa/test-cases/<rid>.md, then re-run.
202
+ # invalidReferences[] non-empty → BLOCKED. A test case references an acceptance id that does not exist.
203
+ # Fix the typo or remove the reference.
204
+ # unlinkedTestCases[] non-empty → WARNING (not blocking). These test cases have no Acceptance: field;
205
+ # either link them or add `- **Acceptance:** —` with rationale in the Evidence field.
206
+ ```
207
+
208
+ **Gate F — QA artifact body has no unfilled placeholders:**
209
+ ```bash
210
+ peaks request lint <rid> --role qa --project <repo> --session-id <sid> --json
211
+ # Expected: ok=true. exit 0.
212
+ # ok=false → BLOCKED. Lint output lists every <placeholder>, "- ..." stub, and TBD marker.
213
+ # Fill them in before issuing the verdict.
214
+ ```
215
+
179
216
  **Gate D — Frontend browser evidence (BLOCKING when frontend is in scope):**
180
217
  ```bash
181
218
  # Verify browser screenshots exist. Screenshots are the only acceptable evidence
@@ -240,6 +277,7 @@ QA must generate test cases, not merely inspect existing ones. Every QA invocati
240
277
  ## Test Case: <title>
241
278
  - **Category:** unit | integration | ui-regression
242
279
  - **Target:** <file-or-route>
280
+ - **Acceptance:** A1, A2 (comma-separated IDs from PRD `## Acceptance criteria`; see "Acceptance linkage" below)
243
281
  - **Preconditions:** <state-before>
244
282
  - **Steps:** 1. ... 2. ...
245
283
  - **Expected result:** <what-should-happen>
@@ -247,6 +285,8 @@ QA must generate test cases, not merely inspect existing ones. Every QA invocati
247
285
  - **Evidence:** <link-or-observation>
248
286
  ```
249
287
 
288
+ **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.
289
+
250
290
  **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
291
 
252
292
  ## Mandatory test-report output
@@ -277,6 +317,8 @@ QA cannot pass a change until the report contains evidence for every applicable
277
317
  6. **Security check** — run security review for the changed surface and dependency/config changes. Record findings, fixes, and unresolved risks.
278
318
  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
319
  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.
320
+ 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.
321
+ 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
322
 
281
323
  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
324
 
@@ -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