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
@@ -20,15 +20,17 @@ When the user invokes Peaks Solo without explicitly naming an execution profile,
20
20
  3. **Swarm** — Peaks maximizes safe parallel role/worker execution for larger RD or QA workloads while keeping reducer validation and artifact boundaries explicit.
21
21
  4. **Strict** — Peaks uses the most conservative gates: explicit confirmations, strict slice specs, coverage evidence, QA acceptance, and commit boundaries before continuing.
22
22
 
23
- Map the user's selection to the `--mode` flag value:
23
+ Map the user's selection to the `--mode` flag value (used by `peaks skill presence:set`; `presence:set --mode` accepts any string, so the name matches the user-facing label rather than overloading "solo" which is also the skill name):
24
24
 
25
25
  | User selects | `--mode` value |
26
26
  |---|---|
27
- | Full auto | `solo` |
27
+ | Full auto | `full-auto` |
28
28
  | Assisted | `assisted` |
29
29
  | Swarm | `swarm` |
30
30
  | Strict | `strict` |
31
31
 
32
+ > Note: `peaks workflow route --mode solo|team` is a **different** CLI dimension (solo developer vs team flow) and is unrelated to the profile choice here. Do not conflate them.
33
+
32
34
  If the user already names a profile in their invocation (e.g. `/peaks-solo --full-auto`, "用全自动模式"), skip this question and use the named profile directly.
33
35
 
34
36
  ### Step 2: Set skill presence
@@ -92,21 +94,28 @@ peaks workspace init --project <repo> --session-id <YYYY-MM-DD-<slug>> --json
92
94
  The workspace initialization creates this structure under `.peaks/<session-id>/`:
93
95
 
94
96
  ```
95
- prd/source/ # PRD source documents (Feishu exports, pasted content)
96
- prd/requests/ # PRD request artifacts (goals, non-goals, acceptance, frontend delta)
97
- ui/requests/ # UI request artifacts (visual direction, taste reports)
98
- rd/requests/ # RD request artifacts (slice specs, coverage, CR findings)
99
- qa/test-cases/ # QA test cases
97
+ prd/source/ # PRD source documents (Feishu exports, pasted content)
98
+ prd/requests/ # PRD request artifacts (goals, non-goals, acceptance, frontend delta)
99
+ ui/requests/ # UI request artifacts (visual direction, taste reports)
100
+ rd/requests/ # RD request artifacts (slice specs, coverage, CR findings)
101
+ qa/test-cases/ # QA test cases
100
102
  qa/test-reports/ # QA test reports (regression matrices, browser evidence)
101
- qa/requests/ # QA request artifacts
102
- sc/ # SC artifacts (change-control, impact, retention, boundary)
103
- txt/ # TXT artifacts (handoff capsules, lessons, memory extraction)
103
+ qa/requests/ # QA request artifacts
104
+ sc/ # SC artifacts (change-control, impact, retention, boundary)
105
+ txt/ # TXT artifacts (handoff capsules, lessons, memory extraction)
106
+ system/ # Existing-system extraction output (visual tokens, conventions)
104
107
  ```
105
108
 
106
- Role skills create these key files at the directory levels shown above:
107
- - `rd/project-scan.md` (Solo step 0.6), `rd/tech-doc.md` (RD planning step 3b)
108
- - `ui/design-draft.md` (UI step 3a)
109
- - Request-scoped files under each role's `requests/` subdirectory
109
+ Files written into these directories during the workflow (not pre-created — they appear as their step runs):
110
+
111
+ - `rd/project-scan.md` (Solo step 0.6)
112
+ - `rd/tech-doc.md` (feature/refactor planning; required by `rd → implemented` gate)
113
+ - `rd/bug-analysis.md` (bugfix planning; required by `rd → implemented` gate for `--type bugfix`)
114
+ - `rd/code-review.md`, `rd/security-review.md` (required by `rd → qa-handoff` gate for feature/bugfix/refactor; security-review only for config)
115
+ - `rd/mock-plan.md` (frontend-only mode)
116
+ - `ui/design-draft.md` (UI step)
117
+ - `system/existing-system.md` (Solo step 0.7; legacy projects only)
118
+ - `qa/test-cases/<rid>.md`, `qa/test-reports/<rid>.md`, `qa/security-findings.md`, `qa/performance-findings.md` (gated per `--type`)
110
119
 
111
120
  ### Root pollution prohibition (CRITICAL)
112
121
 
@@ -131,6 +140,27 @@ Do not default to git-backed storage or automatic commits for intermediate artif
131
140
 
132
141
  Before handing off to `peaks-rd`, scan the project and record findings to `.peaks/<session-id>/rd/project-scan.md`. RD and UI roles read this before starting work.
133
142
 
143
+ ### 0. Project archetype detection (MANDATORY — run FIRST, deterministic CLI)
144
+
145
+ Run the CLI; do NOT infer the archetype from prompts. Record the JSON output as `## Archetype` and `## Project mode` in `project-scan.md`. Later gates (frontend-only mode, visual system extraction, standards generation) read these fields.
146
+
147
+ ```bash
148
+ peaks scan archetype --project <repo> --json
149
+ ```
150
+
151
+ The command emits a stable JSON envelope with these fields you copy verbatim into `project-scan.md`:
152
+
153
+ - `archetype`: `greenfield | legacy-frontend | legacy-fullstack | frontend-monorepo | unknown`
154
+ - `confidence`: `high | medium | low`
155
+ - `frontendOnly`: `true | false`
156
+ - `frontendOnlyReason`: short string explaining the decision
157
+ - `signals[]`: each signal's name, matched flag, and detail (paste under `## Archetype → Signals matched`)
158
+ - `detected`: raw filesystem facts (package.json presence, backend frameworks, swagger paths, monorepo configs, src file count, lockfile age)
159
+
160
+ If `archetype` is `unknown`, STOP and surface to the user as an open question in the TXT handoff — do NOT guess. If `confidence` is `low`, note the uncertainty in `project-scan.md` and confirm the choice with the user before proceeding.
161
+
162
+ The CLI is the sole source of truth for archetype and frontend-only-mode decisions. Manual heuristics in older versions of this skill are superseded by the CLI output.
163
+
134
164
  ### 1. Build tool: inspect config files for the framework
135
165
 
136
166
  | Config file | Framework |
@@ -138,23 +168,35 @@ Before handing off to `peaks-rd`, scan the project and record findings to `.peak
138
168
  | `.umirc.ts`, `config/config.ts` | Umi (Ant Design Pro) |
139
169
  | `next.config.*` | Next.js |
140
170
  | `vite.config.*` | Vite |
171
+ | `rsbuild.config.*` | Rsbuild |
172
+ | `rspack.config.*` | Rspack |
173
+ | `farm.config.*` | Farm |
174
+ | `craco.config.*` | CRA + craco |
141
175
  | `webpack.config.*` | Webpack |
176
+ | `gulpfile.*` | Gulp (legacy) |
142
177
  | `angular.json` | Angular |
178
+ | Custom `build/` or `scripts/build.*` only | Bespoke pipeline — record as `custom` and capture entry script path |
179
+
180
+ If multiple build configs coexist (e.g. `webpack.config.js` + `vite.config.ts`), record ALL of them and mark `build.mixed: true`. Mixed builds are a constraint, not an error — do not silently pick one.
143
181
 
144
182
  ### 2. Component library: check `package.json` dependencies
145
183
 
146
184
  | Package | Library |
147
185
  |---|---|
148
- | `antd` | Ant Design |
186
+ | `antd` (capture major version: v3/v4/v5) | Ant Design |
187
+ | `@ant-design/pro-components`, `@ant-design/pro-*` | Ant Design Pro suite |
149
188
  | `@mui/material` | Material UI |
150
189
  | `tailwindcss` + `radix-ui` | shadcn/ui |
151
190
  | `element-plus` / `element-ui` | Element UI/Plus |
152
191
  | `@arco-design/web-react` | Arco Design |
153
192
  | `tdesign-react` / `tdesign-vue-next` | TDesign |
193
+ | `@douyinfe/semi-ui` | Semi Design |
154
194
  | `@nextui-org/react` | NextUI |
155
195
  | `@chakra-ui/react` | Chakra UI |
196
+ | `vant` | Vant (mobile) |
197
+ | Workspace package (`workspace:*`) or private-registry scope matching internal design system | In-house design system — record package name and entry path |
156
198
 
157
- **CRITICAL**: Never add a second component library to a project that already has one. Do not introduce shadcn/ui to an antd project or vice versa.
199
+ **CRITICAL**: Never add a second component library to a project that already has one. Do not introduce shadcn/ui to an antd project or vice versa. For antd, ALSO record the major version — v3 / v4 / v5 have incompatible APIs and tokens; mixing component code across majors is a blocker.
158
200
 
159
201
  ### 3. CSS framework: check for conflicts
160
202
 
@@ -171,20 +213,45 @@ State: `zustand`, `jotai`, `redux`/`@reduxjs/toolkit`, `valtio`, `mobx`, `hox`
171
213
  Routing: `react-router-dom`, `@umijs/max`, Next.js file-based, `vue-router`
172
214
  Data fetching: `@tanstack/react-query`, `swr`, `ahooks` (`useRequest`), `umi-request`
173
215
 
174
- ### 5. Project-scan artifact template
216
+ ### 5. Legacy signals (legacy-frontend / legacy-fullstack only)
217
+
218
+ Grep `src/` for outdated patterns and list them as constraints in `project-scan.md` under `## Legacy constraints`. RD must preserve these patterns for new code in the same file/module unless PRD explicitly authorizes modernization.
219
+
220
+ | Signal | Detection |
221
+ |---|---|
222
+ | Class components | `extends React.Component` / `extends Component` in `.tsx`/`.jsx` |
223
+ | `moment` instead of dayjs/date-fns | `package.json` dep |
224
+ | Enzyme test suite | `package.json` dep `enzyme*` |
225
+ | redux-saga / redux-thunk | `package.json` dep |
226
+ | HOC-heavy patterns | `withRouter`, `connect()`, `compose(` frequency in `src/` |
227
+ | Legacy lifecycle | `componentWillMount`/`componentWillReceiveProps` occurrences |
228
+ | jQuery / Backbone / Vue 2 | `package.json` dep |
229
+ | Inline styles dominant | `style={{` occurrences ≥ 50 |
230
+
231
+ ### 6. Project-scan artifact template
175
232
 
176
233
  ```markdown
177
234
  # Project Scan: <project-name>
178
235
  **Date:** YYYY-MM-DD
179
236
  **Session:** <session-id>
180
237
 
238
+ ## Archetype
239
+ - Type: <greenfield | legacy-frontend | legacy-fullstack | frontend-monorepo | unknown>
240
+ - Signals matched: <bullet list of signals that drove the decision>
241
+
242
+ ## Project mode
243
+ - Frontend-only: <true | false>
244
+ - Reason: <archetype-derived | user-stated | backend-detected>
245
+
181
246
  ## Build tool
182
247
  - Framework: <name> <version>
183
248
  - Config file: <path>
249
+ - Mixed builds: <true | false; list all configs if true>
184
250
 
185
251
  ## Component library
186
- - Library: <name> <version>
252
+ - Library: <name> <version (major matters for antd)>
187
253
  - Design-system packages: <list>
254
+ - In-house design system: <package name | none>
188
255
 
189
256
  ## CSS solution
190
257
  - Primary: <Less/Sass/CSS-in-JS/TailwindCSS/CSS Modules>
@@ -194,11 +261,25 @@ Data fetching: `@tanstack/react-query`, `swr`, `ahooks` (`useRequest`), `umi-req
194
261
  - State: <name>
195
262
  - Routing: <name>
196
263
  - Data fetching: <name>
264
+
265
+ ## Legacy constraints
266
+ - <bullet list of legacy signals from section 5; empty for greenfield>
197
267
  ```
198
268
 
199
269
  ## Frontend-only development mode
200
270
 
201
- When the project is a pure frontend repository without a live backend (no swagger.json, no API server), Solo must activate frontend-only mode. This is triggered when the user says "先 mock 数据", "没有后端", "前端仓", or similar.
271
+ When the project has no live backend (no swagger.json, no API server), Solo must activate frontend-only mode.
272
+
273
+ ### Mode determination (deterministic — CLI is the source of truth)
274
+
275
+ The CLI decision is authoritative. Read `frontendOnly` and `frontendOnlyReason` directly from the `peaks scan archetype --json` output and copy both into `project-scan.md` under `## Project mode`. Do NOT re-derive the decision from user phrasing.
276
+
277
+ User-stated intent is **only** consulted when it conflicts with the CLI result. The two conflict cases:
278
+
279
+ - **CLI says `frontendOnly=false` but the user says "前端项目 / 没有后端 / 先 mock 数据"**: STOP and `AskUserQuestion` to confirm whether to override the scan (the repo probably contains a backend folder the user wants to ignore). Record the override decision and reason in `project-scan.md`.
280
+ - **CLI says `frontendOnly=true` but the user says "需要做后端 / 加 API"**: STOP and `AskUserQuestion` to confirm whether the request actually targets the missing backend (the user may be confused about repo scope, or there is a separate backend repo Solo should switch to).
281
+
282
+ When there is no conflict, do not ask — the CLI value wins and the workflow proceeds.
202
283
 
203
284
  ### Mock data strategy selection
204
285
 
@@ -211,6 +292,9 @@ Solo records the chosen mock strategy in `.peaks/<session-id>/rd/tech-doc.md` un
211
292
  | `ahooks` `useRequest` + service functions | Service-layer mock: replace HTTP call with `Promise.resolve(mockData)` | Matches existing service-function pattern |
212
293
  | MSW (Mock Service Worker) already configured | Add new handlers to existing MSW setup | Consistent with project convention |
213
294
  | No existing pattern (greenfield) | Service-layer mock with a `mock/` directory and typed fixture files | Clean separation, easy to delete later |
295
+ | Existing `src/services/*` but no fetcher abstraction | Inline mock inside the service file; preserve the function signature | Keeps existing call-sites unchanged |
296
+ | Mixed data-fetching styles (e.g. react-query + raw fetch in legacy files) | Match the style of the most recently added code in the same module | Avoid introducing a third style |
297
+ | Cannot decide from scan alone | STOP and `AskUserQuestion` | Asking once beats picking differently on every run |
214
298
 
215
299
  **Mock data rules:**
216
300
 
@@ -218,6 +302,7 @@ Solo records the chosen mock strategy in `.peaks/<session-id>/rd/tech-doc.md` un
218
302
  2. Mock data should be realistic (not `"test"`, `"foo"`, `123`) — use plausible Chinese/English content that resembles production data.
219
303
  3. Each mock must export its TypeScript interface so RD implementation and QA test-cases can import the same types.
220
304
  4. Mark every mock file with a header comment: `// MOCK: Replace with real API call when swagger.json is available`.
305
+ 5. Before producing any mock file, register the plan in `.peaks/<session-id>/rd/mock-plan.md` with: chosen strategy (from the table above), planned file paths, and a one-line rationale per file. This file is the source of truth for mock locations across runs — RD must read it before writing code, QA must read it before writing test cases.
221
306
 
222
307
  ### API contract placeholder pattern
223
308
 
@@ -253,20 +338,38 @@ When the PRD source is a Feishu/Lark document that requires authentication:
253
338
 
254
339
  Never silently fall back to unauthenticated `fetch` or `WebFetch` for authenticated documents.
255
340
 
341
+ ## Request type classification (MANDATORY before `peaks request init`)
342
+
343
+ 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.
344
+
345
+ | `--type` | Pick this when the PRD says... | Pick something else when... |
346
+ |---|---|---|
347
+ | `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`. |
348
+ | `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`. |
349
+ | `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`. |
350
+ | `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). |
351
+ | `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. |
352
+ | `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`. |
353
+
354
+ **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.
355
+
356
+ 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.
357
+
256
358
  When Peaks Solo coordinates development in a code repository, keep this order explicit:
257
359
 
258
360
  0. **Snapshot** — `peaks doctor` + `peaks project dashboard` to capture baseline state before anything else;
259
361
  0.5. **Workspace initialization** — `.peaks/<session-id>/` created, directory structure verified;
260
- 0.6. **Project scan** — component library, CSS framework, build tool, state management, routing, data fetching detected and recorded to `.peaks/<session-id>/rd/project-scan.md`;
362
+ 0.6. **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`;
363
+ 0.7. **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;
261
364
  1. **Standards preflight** — `peaks standards init/update --dry-run`, must reference concrete project-scan findings (never emit generic templates);
262
365
  2. **PRD phase** — capture request as canonical artifact, extract scope and acceptance criteria:
263
366
  - Full-auto/Swarm: auto-transition to `confirmed-by-user` once the artifact is complete;
264
367
  - Assisted/Strict: pause with `AskUserQuestion` for explicit user confirmation before proceeding;
265
368
  3. **Swarm parallel phase** — after PRD confirmed, launch UI, RD(planning), QA(test-cases) simultaneously:
266
- 3a. UI design draft and visual direction (MANDATORY when request is frontend/user-visible);
267
- 3b. RD tech-doc (architecture planning, component tree, data flow, API contracts);
268
- 3c. QA test-case generation (unit, integration, UI-regression test cases);
269
- 4. **RD implementation** — consumes UI design-draft + RD tech-doc + QA test-cases + project-scan; includes unit tests for new/changed behavior (TDD);
369
+ 3a. UI design draft and visual direction (MANDATORY when request is frontend/user-visible; skipped for `--type docs|chore|config` or pure-backend requests);
370
+ 3b. RD planning artifact — `rd/tech-doc.md` for feature/refactor, `rd/bug-analysis.md` for bugfix, skipped for docs/chore/config;
371
+ 3c. QA test-case generation (skipped for docs/chore no acceptance surface to validate);
372
+ 4. **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;
270
373
  5. **Code review + security review** — CRITICAL/HIGH issues fixed before progression; marked-blocked issues only allow a blocked handoff;
271
374
  6. **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;
272
375
  7. **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;
@@ -284,32 +387,76 @@ You cannot declare a phase complete from memory. Each gate below is a `ls` comma
284
387
  ls .peaks/<id>/rd/project-scan.md
285
388
  # Expected output: .peaks/<id>/rd/project-scan.md
286
389
  # "No such file" → STOP, run project scan first
390
+ # File present but missing `## Archetype` or `## Project mode` sections → INCOMPLETE, rerun scan
391
+ ```
392
+
393
+ **Gate A.5 — Existing-system extraction (legacy projects only):**
394
+ ```bash
395
+ # If project-scan.md `## Archetype` is greenfield → skip this gate
396
+ # Otherwise:
397
+ ls .peaks/<id>/system/existing-system.md
398
+ # "No such file" → STOP, run existing-system extraction
399
+ # (see references/existing-system-extraction.md)
287
400
  ```
288
401
 
289
402
  **Gate B — After swarm convergence (UI + RD planning + QA test-cases):**
403
+
404
+ Gate B has two sub-checks: a HARD gate (blocks progression) and an INFORMATIONAL check (records degradation but does not block).
405
+
290
406
  ```bash
291
- ls .peaks/<id>/prd/requests/<rid>.md \
292
- .peaks/<id>/ui/design-draft.md \
293
- .peaks/<id>/rd/tech-doc.md \
294
- .peaks/<id>/qa/test-cases/<rid>.md
295
- # Every line must be a file path.
296
- # Frontend: ui/design-draft.md missing → apply swarm degradation rule 1 (do not block RD, note "ui-design-missing" in TXT)
297
- # Pure backend: ui/design-draft.md absent state skip reason, proceed
407
+ # B.hard — REQUIRED before continuing to RD implementation.
408
+ # Missing any of these → STOP, return to the role that owns the file.
409
+
410
+ # Always required (every type):
411
+ ls .peaks/<id>/prd/requests/<rid>.md
412
+
413
+ # Type-specific RD planning artifact:
414
+ # feature / refactor → ls .peaks/<id>/rd/tech-doc.md
415
+ # bugfix → ls .peaks/<id>/rd/bug-analysis.md
416
+ # config / docs / chore → (no RD planning artifact required)
417
+
418
+ # QA test-cases (skipped for docs/chore):
419
+ ls .peaks/<id>/qa/test-cases/<rid>.md
420
+ ```
421
+
422
+ ```bash
423
+ # B.info — NON-BLOCKING. Record degradation in TXT, then proceed.
424
+ ls .peaks/<id>/ui/design-draft.md 2>&1
425
+ # "No such file" + request affects user-visible UI → swarm degradation rule 1 fires:
426
+ # note "ui-design-missing" in TXT, RD continues with PRD visual descriptions.
427
+ # "No such file" + pure backend / docs / chore / config → state skip reason in TXT, proceed.
298
428
  ```
299
429
 
300
430
  **Gate C — After RD implementation (before QA handoff):**
431
+
432
+ 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.
433
+
301
434
  ```bash
302
- ls .peaks/<id>/rd/requests/<rid>.md \
303
- .peaks/<id>/rd/tech-doc.md
304
- # Both must exist. Missing either → BLOCKED, do not hand off to QA
435
+ # Always required
436
+ ls .peaks/<id>/rd/requests/<rid>.md
437
+
438
+ # Type-specific RD evidence (must match the type recorded in the artifact body)
439
+ # feature / refactor → ls rd/tech-doc.md rd/code-review.md rd/security-review.md
440
+ # bugfix → ls rd/bug-analysis.md rd/code-review.md rd/security-review.md
441
+ # config → ls rd/security-review.md
442
+ # docs / chore → (no extra evidence required)
443
+ # Missing any required file → DO NOT attempt the qa-handoff transition; CLI will reject with PREREQUISITES_MISSING.
305
444
  ```
306
445
 
307
446
  **Gate D — After QA validation:**
447
+
448
+ The CLI gate at `qa:verdict-issued` is the authoritative check; this `ls` lets you produce missing evidence before the CLI rejects the transition.
449
+
308
450
  ```bash
309
- ls .peaks/<id>/qa/test-cases/<rid>.md \
310
- .peaks/<id>/qa/test-reports/<rid>.md \
311
- .peaks/<id>/qa/requests/<rid>.md
312
- # All three must exist. Missing any → QA incomplete
451
+ # Always required
452
+ ls .peaks/<id>/qa/requests/<rid>.md
453
+
454
+ # Type-specific QA evidence
455
+ # feature / refactor → ls qa/test-cases/<rid>.md qa/test-reports/<rid>.md qa/security-findings.md qa/performance-findings.md
456
+ # bugfix → ls qa/test-cases/<rid>.md qa/test-reports/<rid>.md qa/security-findings.md
457
+ # config → ls qa/security-findings.md
458
+ # docs / chore → (no QA evidence files required)
459
+ # Missing required file → QA incomplete; do not transition to verdict-issued.
313
460
  ```
314
461
 
315
462
  **Gate E — Before declaring workflow complete:**
@@ -353,19 +500,41 @@ After PRD reaches `confirmed-by-user`, Solo launches peaks-ui, peaks-rd(planning
353
500
 
354
501
  ## Mandatory RD QA repair loop (AUTO-PROCEED)
355
502
 
503
+ > **CLI gate enforcement**: `peaks request transition` now refuses to move RD/QA to gated states when required artifacts are missing. The required files depend on `--type` chosen at `peaks request init` (default `feature`):
504
+ >
505
+ > - `feature` / `refactor`: full gates (tech-doc, code-review, security-review, test-cases, test-report, security-findings, performance-findings)
506
+ > - `bugfix`: lighter planning (`bug-analysis.md` instead of `tech-doc.md`); still requires code-review + security-review + regression test-cases + security-findings; performance-findings optional unless the bug is performance-related
507
+ > - `config`: only security-review (RD) and security-findings (QA)
508
+ > - `docs` / `chore`: no gates
509
+ >
510
+ > When PRD lands, classify the request type before running `peaks request init` for every role — pass `--type <type>` so the artifact records it and downstream transitions enforce the right gates. Misclassifying a feature as `docs` to skip gates is a workflow violation. If a transition fails with `code: PREREQUISITES_MISSING`, the response lists every missing path — produce them, then re-transition. For one-off exceptions, the escape hatch `--allow-incomplete --reason "<text>"` records the bypass in the artifact transition note.
511
+
356
512
  After `peaks-rd` finishes any implementation, repair, or code-output slice, Peaks Solo MUST automatically route the result to `peaks-qa` without waiting for user confirmation. This is not optional in full-auto mode. Solo must not declare the workflow complete, emit a TXT handoff, or stop at RD completion.
357
513
 
358
- **Full-auto auto-proceed rule**: In Solo (full-auto) profile, when RD transitions to `qa-handoff`, Solo immediately invokes `peaks-qa` with the same `<request-id>`. Do not pause, do not ask the user, do not summarize RD results as if they were final. The only valid reason to skip QA is when the request has zero code changes (documentation-only, standards-only).
514
+ **How Solo invokes another role skill (mechanism, not metaphor):**
515
+
516
+ Solo is itself a skill running in the current session. To "invoke peaks-rd" or "peaks-qa", Solo MUST use the `Skill` tool with the role's name (e.g. `Skill(skill="peaks-rd")` or `Skill(skill="peaks-qa")`), passing the `<request-id>` and `<session-id>` as arguments so the role reads the same artifacts Solo wrote. Do NOT re-implement the role's logic inline in Solo. Do NOT use the `Agent` tool with a sub-agent — role skills are skills, not agents. After the role skill returns, Solo reads the artifacts the role wrote (via the request artifact path or `peaks request show <rid> --role <role>`) to decide the next step.
517
+
518
+ **Full-auto auto-proceed rule**: In the `full-auto` profile, when RD transitions to `qa-handoff`, Solo immediately invokes `peaks-qa` via the Skill tool with the same `<request-id>`. Do not pause, do not ask the user, do not summarize RD results as if they were final. The only valid reason to skip QA is when `--type` is `docs` or `chore` (no acceptance surface).
359
519
 
360
520
  A QA report with any failing, blocked, missing, or unverified acceptance item is not a pass.
361
521
 
362
- When QA reports problems:
522
+ **How Solo routes QA findings back to RD (mechanism, not metaphor):**
523
+
524
+ When `peaks-qa` returns `verdict=return-to-rd`, Solo does NOT manually rewrite RD artifacts. Instead it follows this exact sequence:
363
525
 
364
- 1. send the QA findings, evidence paths, and failing acceptance items back to `peaks-rd`;
365
- 2. require RD to repair only the reported issues or explicitly mark a blocker;
366
- 3. run the relevant RD checks again;
367
- 4. run `peaks-qa` again on the repaired output;
368
- 5. repeat until QA reports all acceptance items passed, or emit a blocked TXT handoff.
526
+ 1. Read the QA verdict and findings via `peaks request show <rid> --role qa --project <repo> --json`. The findings live in the QA artifact body (failing acceptance items, evidence paths, severity).
527
+ 2. Transition the RD artifact back from `qa-handoff` to a working state and record the QA verdict in the transition note:
528
+ ```bash
529
+ peaks request transition <rid> --role rd --state spec-locked \
530
+ --reason "QA return-to-rd cycle <N>: <one-line summary of failing items; full findings in qa/test-reports/<rid>.md>" \
531
+ --project <repo> --json
532
+ ```
533
+ `spec-locked` is the canonical "needs more RD work" state. The reason is mandatory in repair cycles so the artifact history shows the loop.
534
+ 3. Invoke `peaks-rd` via the Skill tool. Pass the request id and the path to the QA findings; peaks-rd reads `qa/test-reports/<rid>.md` and the QA `requests/<rid>.md` for the verdict.
535
+ 4. peaks-rd fixes the reported issues only (red-line scope: do not modify unrelated surfaces), regenerates code-review and security-review evidence if changes touched reviewed surfaces, then transitions `rd → implemented → qa-handoff` again.
536
+ 5. Solo invokes `peaks-qa` again with the same `<request-id>` (the same Skill call as before). QA re-runs gates against the new diff.
537
+ 6. Repeat steps 1-5 until QA returns `verdict=pass`, or the cap below fires.
369
538
 
370
539
  **Repair cycle cap**: After 3 repair cycles without a passing QA verdict, emit a blocked TXT handoff regardless of remaining issues. Do not loop indefinitely. If a specific issue cannot be resolved within 3 cycles, mark it as a known blocker in the TXT handoff and proceed to the SC phase.
371
540
 
@@ -375,46 +544,81 @@ In full-auto mode, treat the RD↔QA repair loop as a built-in controller object
375
544
 
376
545
  > **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.
377
546
 
378
- The end-to-end CLI sequence for the Solo (full-auto) profile. Assisted/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.
547
+ 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.
379
548
 
380
549
  ```bash
381
- # 0. Snapshot + 0.5 Workspace + 0.6 Project scan
550
+ # 0. Snapshot + 0.5 Workspace + 0.6 Project scan + 0.7 Existing-system extraction
382
551
  peaks doctor --json
383
552
  peaks project dashboard --project <repo> --json
384
553
  peaks skill runbook peaks-solo --json
385
554
  peaks workspace init --project <repo> --session-id <YYYY-MM-DD-<slug>> --json
386
- # write .peaks/<session-id>/rd/project-scan.md (Gate A)
555
+ peaks scan archetype --project <repo> --json
556
+ # → copy archetype, frontendOnly, signals into .peaks/<session-id>/rd/project-scan.md (Gate A)
557
+ # → if archetype != greenfield AND archetype != unknown:
558
+ peaks scan existing-system --project <repo> --json
559
+ # → copy tokens, sources, conventions, inconsistencies into .peaks/<session-id>/system/existing-system.md (Gate A.5)
387
560
 
388
561
  # 1. Standards preflight
389
562
  peaks standards init --project <repo> --dry-run --json
390
563
  # or: peaks standards update --project <repo> --dry-run --json
391
564
 
392
565
  # 2. PRD (Assisted/Strict: [CONFIRM] before confirmed-by-user)
393
- peaks request init --role prd --id <rid> --project <repo> --apply --json
566
+ # Classify the request type from the PRD: feature | bugfix | refactor | docs | config | chore
567
+ # This drives RD/QA gate strictness — see "Mandatory RD QA repair loop" for the matrix.
568
+ peaks request init --role prd --id <rid> --project <repo> --apply --type <type> --json
569
+ # Cross-verify the chosen --type against the current git diff (only meaningful if RD has started writing code;
570
+ # safe to run early too, just expect "no changes" rationale until code lands).
571
+ peaks scan request-type-sanity --project <repo> --type <type> --json
572
+ # → consistent=false → re-classify before continuing. consistent=true → proceed.
573
+ # Lint the PRD artifact before transitioning out of draft.
574
+ peaks request lint <rid> --role prd --project <repo> --json
575
+ # → ok=false → fill in <placeholders>, then re-run.
394
576
  peaks request transition <rid> --role prd --state confirmed-by-user --project <repo> --json
395
577
  peaks request transition <rid> --role prd --state handed-off --project <repo> --json
396
578
 
397
579
  # 3. Swarm parallel — launch UI + RD(planning) + QA(test-cases) simultaneously
398
- peaks request init --role ui --id <rid> --project <repo> --apply --json
580
+ # Pass the same --type chosen for PRD so RD/QA gate matrix lines up.
581
+ peaks request init --role ui --id <rid> --project <repo> --apply --type <type> --json
399
582
  peaks request transition <rid> --role ui --state direction-locked --project <repo> --json
400
583
  peaks request transition <rid> --role ui --state handed-off --project <repo> --json
401
- peaks request init --role rd --id <rid> --project <repo> --apply --json
584
+ peaks request init --role rd --id <rid> --project <repo> --apply --type <type> --json
402
585
  peaks request transition <rid> --role rd --state spec-locked --project <repo> --json
403
- peaks request init --role qa --id <rid> --project <repo> --apply --json
586
+ peaks request init --role qa --id <rid> --project <repo> --apply --type <type> --json
404
587
  # → Gate B convergence check. Assisted/Strict: [CONFIRM]
405
588
 
406
- # 4. RD implementation (consumes design-draft + tech-doc + test-cases + project-scan)
589
+ # 4. RD planning artifact (the file required by the prerequisite gate)
590
+ # feature / refactor → write .peaks/<id>/rd/tech-doc.md
591
+ # bugfix → write .peaks/<id>/rd/bug-analysis.md
592
+ # config → no planning artifact required at this state
593
+ # docs / chore → no planning artifact required
407
594
  peaks request transition <rid> --role rd --state implemented --project <repo> --json
408
- peaks request transition <rid> --role rd --state qa-handoff --project <repo> --json
409
595
 
410
- # 5. Code review + security review (fix CRITICAL/HIGH before proceeding)
596
+ # 5. Code review + security review BEFORE qa-handoff transition.
597
+ # Produce the evidence files the CLI gate enforces:
598
+ # - .peaks/<id>/rd/code-review.md (CRITICAL/HIGH findings + fixes; required for feature/bugfix/refactor)
599
+ # - .peaks/<id>/rd/security-review.md (required for feature/bugfix/refactor/config)
600
+ # Then transition. If --type is docs/chore the gate is empty and the transition is unguarded.
601
+ peaks request transition <rid> --role rd --state qa-handoff --project <repo> --json
411
602
 
412
603
  # 6. QA validation (AUTO-PROCEED from RD in full-auto)
604
+ # Before each QA transition, produce the evidence files the CLI gate enforces:
605
+ # Before qa:running → .peaks/<id>/qa/test-cases/<rid>.md
413
606
  peaks request transition <rid> --role qa --state running --project <repo> --json
607
+ # Before qa:verdict-issued → .peaks/<id>/qa/test-reports/<rid>.md
608
+ # + .peaks/<id>/qa/security-findings.md
609
+ # + .peaks/<id>/qa/performance-findings.md (feature/refactor only)
414
610
  peaks request transition <rid> --role qa --state verdict-issued --project <repo> --json
415
611
  # → Gate D check. Assisted/Strict: [CONFIRM]
416
612
 
417
- # 7. RD↔QA repair loop — if verdict is return-to-rd, re-run 4 through 6 until QA passes or blocked TXT
613
+ # 7. RD↔QA repair loop — if verdict is return-to-rd, re-run 4 through 6 until QA passes or blocked TXT.
614
+ # Before invoking peaks-rd again, check the cycle count so you don't blow past the cap silently:
615
+ peaks request repair-status <rid> --project <repo> --json
616
+ # → atCap=true → STOP and emit a blocked TXT handoff. Do NOT enter another cycle.
617
+ # → remaining > 0 → safe to continue. The next transition's --reason must include "QA return-to-rd cycle N: ..."
618
+ # so this command keeps counting accurately.
619
+ # After RD finishes the repair, re-check that the diff is still consistent with the declared --type:
620
+ peaks scan request-type-sanity --project <repo> --type <type> --json
621
+ # → consistent=false → RD scope-creeped during repair; review before re-handoff.
418
622
 
419
623
  # 8. SC phase
420
624
  peaks sc impact --change-id <cid> --module <module> --file <path> --json
@@ -448,6 +652,8 @@ Use `standards init` for first-time creation and `standards update` for existing
448
652
 
449
653
  **CRITICAL — Standards must reflect the project scan.** When generating or updating `CLAUDE.md`, the content must reference concrete findings from `.peaks/<id>/rd/project-scan.md`: the detected component library (e.g. "This project uses antd 5.x"), CSS solution (e.g. "Uses Less via Umi"), build tool, state management, and routing. Never emit a generic template that says "read .claude/rules/..." without naming the actual project stack. If the project-scan has not been run yet, run it before standards init/update.
450
654
 
655
+ **Legacy projects additionally** — when archetype ∈ {legacy-frontend, legacy-fullstack, frontend-monorepo}, the `CLAUDE.md` Conventions section MUST extract concrete naming, directory, service-layer, and hooks conventions from `.peaks/<id>/system/existing-system.md` and record them as hard constraints for new code. It must also list the `## Legacy constraints` from `project-scan.md` (class components, moment, enzyme, etc.) and instruct that new code in the same module preserves those patterns unless PRD explicitly authorizes modernization. A `CLAUDE.md` for a legacy project that contains only generic rule pointers without naming the actual conventions is a blocking violation — regenerate it.
656
+
451
657
  Do not hand-write standards file mutations inside the skill.
452
658
 
453
659
  For project-analysis requests such as "分析项目", the handoff must include an explicit **Standards increment** section. Report the current `CLAUDE.md` and `.claude/rules/**` status from the dry-run output as incremental deltas, not just a generic preflight note:
@@ -475,6 +681,18 @@ It must enforce the shared refactor red lines:
475
681
  6. require 100% acceptance for each slice;
476
682
  7. require code changes and sanitized intermediate artifacts to be traceable in local `.peaks/<session-id>/` storage before the next slice; commit or sync sanitized artifacts only when explicitly authorized.
477
683
 
684
+ ## Quality-gate commands (CLI cheat sheet)
685
+
686
+ These commands harden the workflow against silent skips. Use them in the runbook at the points indicated; they all support `--json` and `--session-id`.
687
+
688
+ | Command | Purpose | When to run | Non-zero exit when |
689
+ |---|---|---|---|
690
+ | `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) |
691
+ | `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 |
692
+ | `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 |
693
+
694
+ 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.
695
+
478
696
  ## Completion handoff
479
697
 
480
698
  After final validation, refresh project-local standards via `peaks standards init/update` (never hand-write). Merge scan-backed changes incrementally; preserve hand-maintained content unless user confirms deletion.
@@ -491,4 +709,4 @@ Use Peaks TXT for the compact handoff capsule: mode, validated decisions, artifa
491
709
 
492
710
  **MCP lifecycle**: `list → plan → apply --yes → call → rollback`. `apply` backs up settings and refuses non-peaks entries unless `--claim` is passed.
493
711
 
494
- Detailed rules: `references/external-skill-invocation.md`, `references/openspec-mcp-workflow.md`, `references/workflow.md`.
712
+ Detailed rules: `references/external-skill-invocation.md`, `references/openspec-mcp-workflow.md`, `references/workflow.md`, `references/existing-system-extraction.md`.
@@ -0,0 +1,78 @@
1
+ # Existing visual & convention system extraction
2
+
3
+ Run this step when `project-scan.md` archetype is `legacy-frontend`, `legacy-fullstack`, or `frontend-monorepo`. Skip for `greenfield` and `unknown`.
4
+
5
+ Output: `.peaks/<session-id>/system/existing-system.md`. The path lives under `system/` (not `ui/`) because the file records both UI tokens AND code conventions (service-layer signatures, hooks, naming) that backend-only or legacy-fullstack work consumes. UI design-draft and RD implementation MUST read this file and treat extracted tokens/conventions as hard constraints. New tokens or conventions may only be introduced when PRD explicitly authorizes them.
6
+
7
+ ## Step 1 — Run the CLI (deterministic, source of truth)
8
+
9
+ ```bash
10
+ peaks scan existing-system --project <repo> --json
11
+ ```
12
+
13
+ The CLI emits stable JSON containing:
14
+
15
+ - `scanned`: `true | false` (skipped for greenfield / unknown archetypes; copy `scanSkippedReason` if false)
16
+ - `visualTokens`:
17
+ - `colors[]`, `spacing[]`, `typography[]`, `radii[]` — each entry is `{ name, value, source }` parsed deterministically from Less/Sass variables, CSS variables, and `tailwind.config.*` color blocks
18
+ - `sources[]` — every theme/style file the parser actually read (path + kind)
19
+ - `conventions`:
20
+ - `componentNaming`: `PascalCase | kebab-case | mixed | unknown` (decided from real file names under the component directory)
21
+ - `componentDir`, `serviceDir`, `hookDir` — first matching path found
22
+ - `samples[]` — up to 5 most-recently-modified files per kind
23
+ - `inconsistencies[]` — token names that have different values across sources
24
+
25
+ Copy these fields VERBATIM into `existing-system.md`. Do not re-classify tokens; do not invent additional samples.
26
+
27
+ ## Step 2 — Render the markdown
28
+
29
+ Use the template below. Every value must come from the CLI JSON; leave a section as `- (none detected)` when the CLI returned an empty array.
30
+
31
+ ```markdown
32
+ # Existing visual & convention system
33
+ **Project:** <name>
34
+ **Date:** YYYY-MM-DD
35
+ **CLI command:** peaks scan existing-system --project <repo> --json
36
+ **Source files inspected:** <paste visualTokens.sources[*].path>
37
+
38
+ ## Color tokens
39
+ <paste visualTokens.colors as "- {name}: {value} (source: {source})">
40
+
41
+ ## Typography
42
+ <paste visualTokens.typography>
43
+
44
+ ## Spacing
45
+ <paste visualTokens.spacing>
46
+
47
+ ## Radius
48
+ <paste visualTokens.radii>
49
+
50
+ ## Component conventions
51
+ - Naming: <conventions.componentNaming>
52
+ - Directory: <conventions.componentDir>
53
+ - Sample files: <conventions.samples filtered by kind=component>
54
+
55
+ ## Service layer convention
56
+ - Directory: <conventions.serviceDir>
57
+ - Sample files: <conventions.samples filtered by kind=service>
58
+
59
+ ## Hooks convention
60
+ - Directory: <conventions.hookDir>
61
+ - Sample files: <conventions.samples filtered by kind=hook>
62
+
63
+ ## Detected inconsistencies
64
+ <paste inconsistencies[*] verbatim; if empty, write "- (none)">
65
+ ```
66
+
67
+ ## Hard rules for downstream consumers
68
+
69
+ - **UI design-draft**: every color, font, radius, spacing value used in the draft MUST come from `visualTokens.*` above. New values require an explicit `## New tokens (requested)` section with PRD justification.
70
+ - **RD implementation**: new components must match `conventions.componentNaming` and live under `conventions.componentDir`. Service and hook code must match the recorded directory.
71
+ - **QA**: regression checks must verify that no new color/spacing values escaped the recorded token set; inconsistencies from the CLI become QA acceptance items (resolve or explicitly accept).
72
+
73
+ ## When the CLI returns empty results
74
+
75
+ If `scanned=true` but all token arrays are empty AND `conventions.componentDir` is null, the project has no detectable token system or component convention. Record this verbatim in `existing-system.md` under `## Detected inconsistencies → no theme system; values are hard-coded across files; no canonical component dir`. Surface it in the TXT handoff as a known risk. Do NOT invent a token system.
76
+
77
+ When `scanned=false` (archetype = greenfield or unknown), do not write `existing-system.md` at all — the greenfield path applies.
78
+