viepilot 2.23.0 → 2.45.2

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 (52) hide show
  1. package/CHANGELOG.md +288 -0
  2. package/README.md +6 -6
  3. package/bin/viepilot.cjs +140 -1
  4. package/bin/vp-tools.cjs +204 -0
  5. package/docs/brainstorm/session-2026-04-20.md +261 -0
  6. package/docs/brainstorm/session-2026-04-24.md +131 -0
  7. package/docs/brainstorm/session-2026-04-25.md +109 -0
  8. package/docs/skills-reference.md +22 -0
  9. package/docs/user/features/adapters.md +2 -2
  10. package/docs/user/features/scaffold-first.md +62 -0
  11. package/docs/user/features/skill-registry.md +125 -0
  12. package/lib/adapters/antigravity.cjs +5 -4
  13. package/lib/domain-packs/ai-product.json +33 -0
  14. package/lib/domain-packs/data-science.json +33 -0
  15. package/lib/domain-packs/devops.json +33 -0
  16. package/lib/domain-packs/mobile.json +33 -0
  17. package/lib/domain-packs/web-saas.json +33 -0
  18. package/lib/skill-installer.cjs +274 -0
  19. package/lib/skill-registry.cjs +212 -0
  20. package/lib/viepilot-calibrate.cjs +279 -0
  21. package/lib/viepilot-persona.cjs +446 -0
  22. package/lib/viepilot-update.cjs +113 -0
  23. package/package.json +1 -1
  24. package/skills/vp-audit/SKILL.md +67 -9
  25. package/skills/vp-auto/SKILL.md +54 -0
  26. package/skills/vp-brainstorm/SKILL.md +124 -2
  27. package/skills/vp-crystallize/SKILL.md +82 -0
  28. package/skills/vp-debug/SKILL.md +37 -0
  29. package/skills/vp-design/SKILL.md +219 -0
  30. package/skills/vp-docs/SKILL.md +37 -0
  31. package/skills/vp-evolve/SKILL.md +69 -6
  32. package/skills/vp-info/SKILL.md +37 -0
  33. package/skills/vp-pause/SKILL.md +37 -0
  34. package/skills/vp-persona/SKILL.md +207 -0
  35. package/skills/vp-proposal/SKILL.md +37 -0
  36. package/skills/vp-request/SKILL.md +62 -6
  37. package/skills/vp-resume/SKILL.md +37 -0
  38. package/skills/vp-rollback/SKILL.md +61 -1
  39. package/skills/vp-skills/SKILL.md +311 -0
  40. package/skills/vp-status/SKILL.md +37 -0
  41. package/skills/vp-task/SKILL.md +37 -0
  42. package/skills/vp-ui-components/SKILL.md +37 -0
  43. package/skills/vp-update/SKILL.md +37 -0
  44. package/templates/phase/TASK.md +7 -0
  45. package/templates/project/PROJECT-CONTEXT.md +76 -0
  46. package/workflows/audit.md +131 -0
  47. package/workflows/autonomous.md +199 -0
  48. package/workflows/brainstorm.md +1172 -9
  49. package/workflows/crystallize.md +639 -3
  50. package/workflows/design.md +601 -0
  51. package/workflows/evolve.md +9 -0
  52. package/workflows/rollback.md +79 -10
@@ -33,6 +33,100 @@ Use `COMMUNICATION_LANG` for all prompts and confirmation messages in this sessi
33
33
  If `~/.viepilot/config.json` is absent, use defaults (en/en) — do not fail.
34
34
  </step>
35
35
 
36
+ <step name="upgrade_rescan">
37
+ ## Step 0-B: Upgrade Re-scan Mode (ENH-067)
38
+
39
+ **Activated by:** `--upgrade` flag OR auto-detect (see below).
40
+
41
+ ### Auto-detect trigger
42
+
43
+ 1. Read `.viepilot/PROJECT-CONTEXT.md` first line → extract `<!-- crystallize_version: {semver} -->`.
44
+ 2. Fallback: read `.viepilot/HANDOFF.json` → `crystallize_version` field.
45
+ 3. If neither is present: treat as `crystallize_version = "0.0.0"` (legacy project, never stamped).
46
+ 4. Compare against current ViePilot version (`node bin/vp-tools.cjs info` → `version`).
47
+ 5. **If `crystallize_version` < current version AND gaps exist (see below): activate upgrade mode.**
48
+ 6. If `--upgrade` flag is explicitly passed: always activate, even if no gaps detected (allows forced re-scan).
49
+
50
+ ### Delta computation — version threshold table
51
+
52
+ | Introduced in | Missing artifact section | Detection check |
53
+ |--------------|--------------------------|-----------------|
54
+ | v2.32.0 | `## Admin & Governance` in PROJECT-CONTEXT.md | section absent AND `admin_imported` not in HANDOFF.json |
55
+ | v2.33.0 | `## Content Management` in PROJECT-CONTEXT.md | section absent AND `content_imported` not in HANDOFF.json |
56
+ | v2.34.0 | `## User Data Management` in PROJECT-CONTEXT.md | section absent AND `user_data_imported` not in HANDOFF.json |
57
+
58
+ Cross-check: confirm section is actually absent from current `PROJECT-CONTEXT.md` before listing
59
+ as a gap — avoids false positives for projects that have the content already.
60
+
61
+ ### Upgrade menu
62
+
63
+ **Claude Code (terminal) — REQUIRED:**
64
+ ```
65
+ question: "🔄 Crystallize upgrade available (v{old} → v{new}).\nDetected gaps: {comma-separated list}.\nHow would you like to proceed?"
66
+ header: "Upgrade"
67
+ options:
68
+ - label: "Patch — append missing sections (Recommended)"
69
+ description: "Non-destructive: reads architect notes.md YAML → appends missing sections only; re-stamps crystallize_version"
70
+ - label: "Full re-generate"
71
+ description: "Backup .viepilot/ to .viepilot/backup-pre-regen-{timestamp}/ then regenerate all artifacts from scratch"
72
+ - label: "Skip"
73
+ description: "Proceed with current artifacts; skip upgrade for now"
74
+ ```
75
+
76
+ **Text fallback (Cursor / Codex / other):**
77
+ ```
78
+ 🔄 Crystallize upgrade available (v{old} → v{new})
79
+ Gaps: {list}
80
+
81
+ 1. Patch — append missing sections only (Recommended)
82
+ 2. Full re-generate (backup first)
83
+ 3. Skip
84
+ ```
85
+
86
+ ### Patch mode
87
+
88
+ For each missing section, run only the corresponding Step 1D export item:
89
+ - `## Admin & Governance` → Step 1D item 7 (ENH-063)
90
+ - `## Content Management` → Step 1D item 8 (ENH-065)
91
+ - `## User Data Management` → Step 1D item 9 (ENH-066)
92
+
93
+ For each item:
94
+ 1. Check if architect `notes.md` has the corresponding YAML section (`## admin`, `## content`,
95
+ `## user_data`). If missing: soft warn —
96
+ > ⚠️ `notes.md ## {section}` not found — appending placeholder table instead.
97
+ Non-blocking: append the placeholder table from `templates/project/PROJECT-CONTEXT.md`.
98
+ 2. Check if latest brainstorm session has `## Upgrade supplement` with the relevant topic Q&A.
99
+ If yes: fold supplement content into the export (treat as first-class session data).
100
+ 3. Append section to `.viepilot/PROJECT-CONTEXT.md` (never overwrite existing content).
101
+ 4. After all missing sections appended: update `<!-- crystallize_version: {new} -->` comment.
102
+ 5. Update `crystallize_version` in `.viepilot/HANDOFF.json`.
103
+ 6. Commit: `chore: crystallize patch v{old} → v{new} (ENH-067)`
104
+
105
+ **Brainstorm supplement check (for both Patch and Full re-generate):**
106
+ Before extracting, check if the latest brainstorm session has pending `## Upgrade supplement`
107
+ sections that haven't been incorporated yet. If brainstorm `upgrade_supplement_version < current`
108
+ but supplement Q&A is present: include it automatically. If supplement Q&A is absent but gaps
109
+ exist in brainstorm coverage: soft warn —
110
+ > ⚠️ Brainstorm session missing Topic {N} coverage — run `/vp-brainstorm --continue` first
111
+ > to fill gaps before crystallizing. Proceeding with placeholder tables.
112
+ Non-blocking.
113
+
114
+ ### Full re-generate mode
115
+
116
+ 1. **Backup:** `cp -r .viepilot/ .viepilot/backup-pre-regen-{timestamp}/` — preserve existing artifacts
117
+ 2. **Pre-fill Step 0 metadata** from existing `.viepilot/PROJECT-META.md` (skip interactive Q&A for fields
118
+ that already have values — only ask about changed or missing fields)
119
+ 3. **Run full crystallize flow** from Step 0 onward using existing brainstorm session(s) + architect
120
+ artifacts as source
121
+ 4. Overwrite all `.viepilot/` artifacts (backup already taken in step 1)
122
+ 5. Commit: `chore: crystallize full re-generate v{old} → v{new} (ENH-067)`
123
+
124
+ ### Skip
125
+
126
+ Proceed to Step 0 (Collect Project Metadata) as a normal crystallize run.
127
+ `crystallize_version` is NOT updated until a successful patch or re-generate.
128
+ </step>
129
+
36
130
  <step name="collect_metadata">
37
131
  ## Step 0: Collect Project Metadata
38
132
 
@@ -813,6 +907,20 @@ When `IS_BROWNFIELD=true`, the following table governs which steps execute:
813
907
  </step>
814
908
 
815
909
  <step name="analyze_brainstorm">
910
+ ## Step 0C: Persona output_style adaptation (ENH-073)
911
+
912
+ Read active persona via:
913
+ ```bash
914
+ node "$HOME/.claude/viepilot/bin/vp-tools.cjs" persona get
915
+ ```
916
+
917
+ Apply `output_style` to document generation in Steps 1D and 1E:
918
+ - `lean` → concise docs: summary sections, skip boilerplate headers, short descriptions
919
+ - `balanced` → standard docs (default if persona unavailable)
920
+ - `enterprise` → full docs: compliance sections, decision rationale appendix, detailed risk notes
921
+
922
+ Silent if persona unavailable → use `balanced` default.
923
+
816
924
  ## Step 1: Analyze Brainstorm
817
925
 
818
926
  ```bash
@@ -895,6 +1003,27 @@ The brainstorm session indicates this project has UI scope but `.viepilot/ui-dir
895
1003
 
896
1004
  If `ui_scope_detected = false` → skip gate; proceed normally.
897
1005
 
1006
+ **MANDATORY READ GATE (ENH-064) — if `.viepilot/ui-direction/` exists:**
1007
+
1008
+ Read ALL artifacts completely (no partial reads):
1009
+ 1. `notes.md` — ALL sections: ui_idea_buffer[], background extracted ideas, Pages inventory, arch_to_ui_sync[], skills_used[], coverage[], admin (if present)
1010
+ 2. If `pages/` directory exists: read EVERY `pages/*.html` file — do NOT skip any page
1011
+ For each page: extract layout intent, component list, interactions, designer annotations
1012
+ 3. Read `index.html` (hub) — verify nav links match pages/ file set
1013
+ 4. Verify `## Pages inventory` in notes.md matches actual `pages/*.html` set on disk
1014
+ If mismatch detected → STOP:
1015
+ ```
1016
+ ⛔ UI Direction pages/ directory and notes.md Pages inventory are out of sync.
1017
+ Files on disk: {list}
1018
+ Inventory in notes.md: {list}
1019
+ Please sync brainstorm artifacts before continuing.
1020
+ 1. Return to /vp-brainstorm --ui to update inventory
1021
+ 2. Continue with disk files as source of truth (override notes.md)
1022
+ ```
1023
+ 5. Record: `ui_direction_read_complete: true` in crystallize working notes
1024
+
1025
+ Do NOT proceed to UI extraction until `ui_direction_read_complete: true`.
1026
+
898
1027
  ### Consume artifacts (when available)
899
1028
 
900
1029
  Check for direction artifacts:
@@ -917,6 +1046,69 @@ When available, for the selected/latest session:
917
1046
  - In architecture / UI plan output, **enumerate every page** from inventory (or state explicitly single-page legacy).
918
1047
 
919
1048
  If `notes.md` exists but has no `## Pages inventory` section and brainstorm shows multi-page scope → warn user and request fix or assumptions before proceeding.
1049
+
1050
+ ---
1051
+
1052
+ ### Step 1A-i: Build UI Pages → Component Map (ENH-069 Gap 1)
1053
+
1054
+ After all `pages/*.html` files are read, build a binding table in crystallize working notes:
1055
+
1056
+ ```markdown
1057
+ ## UI Pages → Component Map
1058
+ | Prototype | Target component | Phase | Source | Status |
1059
+ |-----------|-----------------|-------|--------|--------|
1060
+ | pages/landing.html | resources/js/Pages/Home.vue | Phase 1 | page | pending |
1061
+ | pages/dashboard.html | resources/js/Pages/Dashboard.vue | Phase 2 | page | pending |
1062
+ ```
1063
+
1064
+ **Rules:**
1065
+ - One row per `pages/{slug}.html` found; derive target component from stack convention:
1066
+ - Inertia/Vue → `resources/js/Pages/{PascalName}.vue`
1067
+ - Next.js App Router → `app/{slug}/page.tsx`
1068
+ - Generic SPA → `src/pages/{PascalName}.{ext}`
1069
+ - Phase = best estimate from `phases_inventory` topic match or page content
1070
+ - Source = `page` (from pages/*.html), `arch_to_ui_sync` (added in Step 1D), `ux_walkthrough` (added below)
1071
+ - Status = `pending` (updated to `assigned` in Step 7 after ROADMAP cross-check)
1072
+
1073
+ This table is the **single source of truth** for UI→implementation tracing through Steps 1D, 1F, and Step 7.
1074
+
1075
+ ---
1076
+
1077
+ ### Step 1A-ii: Process `## UX walkthrough log` (ENH-069 Gap 9)
1078
+
1079
+ After building the component map, scan `notes.md → ## UX walkthrough log` (written by `/research-ui`):
1080
+
1081
+ - **P0 entries** (unusability, content loss, critical mis-clicks): add a UX-fix row to the component map:
1082
+ ```
1083
+ Source: ux_walkthrough
1084
+ Status: ux-fix-required
1085
+ Task hint: fix-ux-p0: {pain description} on {page}.html
1086
+ ```
1087
+ These become mandatory tasks in ROADMAP (Phase = same as the page's assigned phase).
1088
+
1089
+ - **P1 entries** (significant friction, degraded experience): add to component map with `Status: ux-fix-p1`. Generate task hint; include in ROADMAP as same-phase tasks.
1090
+
1091
+ - **P2 entries** (minor polish): surface as non-blocking warnings only; do NOT add to component map.
1092
+
1093
+ - If `## UX walkthrough log` is absent or empty → no action.
1094
+
1095
+ ---
1096
+
1097
+ ### Step 1A-iii: `## Background extracted ideas` resolution gate (ENH-069 Gap 10)
1098
+
1099
+ After UX walkthrough processing, scan `notes.md → ## Background extracted ideas` (written by ENH-026 background extraction when user selects "notes only" — no prototype generated):
1100
+
1101
+ For each idea entry:
1102
+ 1. Check if the idea maps to an existing row in the UI Pages → Component Map OR a feature in `phases_inventory`
1103
+ 2. If NOT covered: add to a `## Unresolved Background Ideas` gate list
1104
+
1105
+ **This gate BLOCKS Step 7 (ROADMAP generation) until every entry in `## Unresolved Background Ideas` is resolved with one of:**
1106
+ - **(a) Promote to UI Direction** — user creates/updates `pages/*.html`; add to component map
1107
+ - **(b) Add as task-TBD** — create implementation task with `design-TBD` note
1108
+ - **(c) Descope** — mark as out-of-scope with reason logged in working notes
1109
+
1110
+ Record all resolutions in working notes before Step 7 runs.
1111
+
920
1112
  </step>
921
1113
 
922
1114
  <step name="research_stack_official">
@@ -980,6 +1172,44 @@ Also create project-local index for traceability:
980
1172
 
981
1173
  If `.viepilot/architect/` exists with at least one session directory:
982
1174
 
1175
+ **MANDATORY READ GATE (ENH-064) — if `.viepilot/architect/` exists:**
1176
+
1177
+ Before extracting any data, execute a full sequential read of ALL present files:
1178
+
1179
+ ```bash
1180
+ ls -la .viepilot/architect/{session-id}/
1181
+ ```
1182
+
1183
+ For each file present, READ COMPLETELY (no skimming):
1184
+ 1. `notes.md` — ALL sections: decisions[], tech_stack{}, open_questions[], erd, use_cases, apis, deployment, feature_map, arch_to_ui_sync[], coverage[], admin (ENH-063), skills_used[]
1185
+ 2. `architecture.html` — components, C4 intent, external integrations
1186
+ 3. `data-flow.html` — service flows, async indicators, event queues
1187
+ 4. `decisions.html` — all ADR entries (supplement notes.md decisions[])
1188
+ 5. `tech-stack.html` — layer-by-layer stack (authoritative if conflicts with notes.md)
1189
+ 6. `tech-notes.html` — assumptions, risks, open questions (supplement notes.md open_questions[])
1190
+ 7. `feature-map.html` — features with phase/priority/status tags
1191
+ 8. `erd.html` — entities, relationships (if present)
1192
+ 9. `user-use-cases.html` — actors, use cases (if present)
1193
+ 10. `deployment.html` — infra, environments (if present)
1194
+ 11. `apis.html` — endpoints, service contracts (if present)
1195
+ 12. `admin.html` — admin capabilities (if present — ENH-063)
1196
+ 13. `content.html` — content types, lifecycle, media/SEO schema (if present — ENH-065)
1197
+ 14. `user-data.html` — user-owned data controls (if present — ENH-066)
1198
+ 15. `entity-mgmt.html` — admin entity CRUD matrix (if present — ENH-068)
1199
+ *(Skip: `sequence-diagram.html` — intentionally excluded per existing rule)*
1200
+
1201
+ **Failure rule**: if `notes.md` is missing or unreadable → STOP and surface:
1202
+ ```
1203
+ ⛔ Architect workspace found but notes.md is missing or unreadable.
1204
+ Path: .viepilot/architect/{session-id}/notes.md
1205
+ Please fix architect artifacts before running /vp-crystallize.
1206
+ 1. Return to /vp-brainstorm --architect to regenerate notes.md
1207
+ 2. Continue without architect data (not recommended)
1208
+ ```
1209
+
1210
+ **Completion record**: after all files read → set `architect_read_complete: true` in crystallize working notes.
1211
+ Do NOT proceed to data extraction until `architect_read_complete: true`.
1212
+
983
1213
  1. **Select most recent session** (by directory mtime or newest session-id).
984
1214
  2. **Read `notes.md`** → parse YAML frontmatter sections:
985
1215
  - **`decisions[]`** → append to `.viepilot/ARCHITECTURE.md` under:
@@ -1028,8 +1258,77 @@ If `.viepilot/architect/` exists with at least one session directory:
1028
1258
  | Decision | Choice | Rationale |
1029
1259
  ```
1030
1260
  Note: `sequence-diagram.html` is intentionally excluded from crystallize extraction — per-scenario diagrams are not architecture artifacts (they live in Architect Mode workspace only).
1031
- 7. **`feature-map.html`** cross-reference Phase badges with `phases_inventory`; if discrepancies found (feature in HTML not in inventory, or vice versa) → list them for user to confirm.
1032
- 8. **Record in working notes**:
1261
+ 7. **`admin.html` / `notes.md ## admin`** (if exists ENH-063) → append to `.viepilot/PROJECT-CONTEXT.md`:
1262
+ ```markdown
1263
+ ## Admin & Governance (from Architect Mode)
1264
+ | Capability | Required | Phase | Notes |
1265
+ |-----------|----------|-------|-------|
1266
+ | User management UI | yes | 2 | invite, deactivate, role assign |
1267
+ | Audit log | yes | 3 | all write operations, 90-day retention |
1268
+ | Monitoring dashboard | optional | 3 | error rate, latency, active users |
1269
+ | Billing management | no | — | not in scope |
1270
+
1271
+ ### Admin Personas
1272
+ | Persona | Key Capabilities |
1273
+ |---------|-----------------|
1274
+ | super_admin | user_management, billing, system_config, audit_log_view |
1275
+ | org_admin | invite_users, role_assign, reporting |
1276
+ ```
1277
+ 8. **`content.html` / `notes.md ## content`** (if exists — ENH-065) → append to `.viepilot/PROJECT-CONTEXT.md`:
1278
+ ```markdown
1279
+ ## Content Management (from Architect Mode)
1280
+ | Content Type | Created By | Lifecycle | Key Fields | Phase |
1281
+ |-------------|-----------|-----------|-----------|-------|
1282
+ | article | admin, author | draft → review → published → archived | title, body, slug, tags, seo_meta | 2 |
1283
+ | product | admin | draft → published → discontinued | name, description, price, images, category | 1 |
1284
+
1285
+ ### Media & Storage
1286
+ | Storage | CDN | Types | Max Size |
1287
+ |---------|-----|-------|----------|
1288
+ | S3 | CloudFront | image, pdf | 10 MB |
1289
+
1290
+ ### Localization
1291
+ | Locales | Fallback |
1292
+ |---------|---------|
1293
+ | en | en |
1294
+ ```
1295
+ 9. **`user-data.html` / `notes.md ## user_data`** (if exists — ENH-066) → append to `.viepilot/PROJECT-CONTEXT.md`:
1296
+ ```markdown
1297
+ ## User Data Management (from Architect Mode)
1298
+ | Capability | Supported | Notes |
1299
+ |-----------|----------|-------|
1300
+ | Profile edit (name/email/avatar) | yes | — |
1301
+ | Notification preferences | yes | email, push, in_app |
1302
+ | Data export (GDPR) | yes | CSV/JSON download |
1303
+ | Account deletion (right-to-erasure) | yes | 730-day retention |
1304
+ | Activity history | yes | login history, action log |
1305
+ | Connected accounts (OAuth) | yes | Google, GitHub |
1306
+ | Session/device management | yes | sign out all devices |
1307
+ | Two-factor authentication | yes | TOTP + backup codes |
1308
+ ```
1309
+ 10. **`entity-mgmt.html` / `notes.md ## entity_mgmt`** (if exists — ENH-068) → append to `.viepilot/PROJECT-CONTEXT.md`:
1310
+ ```markdown
1311
+ ## Admin Entity Management (from Architect Mode)
1312
+ | Entity | CRUD Ops | Soft Delete | Bulk Actions | Audit Trail | Scope |
1313
+ |--------|----------|-------------|--------------|-------------|-------|
1314
+ | — | — | — | — | — | — |
1315
+
1316
+ ### Import / Export
1317
+ | Direction | Entities |
1318
+ |-----------|----------|
1319
+ | CSV Import | — |
1320
+ | CSV Export | — |
1321
+ ```
1322
+ 11. **`feature-map.html`** — (ENH-069 Gap 7) cross-reference Phase badges with `phases_inventory`; if discrepancies found (feature in HTML not in inventory, or vice versa) → **BLOCKED: Step 7 cannot run until every discrepancy is explicitly resolved**:
1323
+
1324
+ For each discrepancy, record a resolution in `## Feature-Map Resolutions` working notes:
1325
+ - **(a) add-to-inventory** — add feature to phases_inventory; will generate a ROADMAP task
1326
+ - **(b) descoped** — mark feature as removed with reason
1327
+ - **(c) design-only** — design artifact only; no implementation task required
1328
+
1329
+ No silent continuation. The `## Feature-Map Resolutions` table must be complete before Step 7 runs.
1330
+
1331
+ 12. **Record in working notes**:
1033
1332
  - `architect_session_id`: {id}
1034
1333
  - `decisions_imported`: {count}
1035
1334
  - `open_questions_count`: {count of open questions}
@@ -1037,6 +1336,214 @@ If `.viepilot/architect/` exists with at least one session directory:
1037
1336
  - `use_cases_count`: {count if use_cases present, else "n/a"}
1038
1337
  - `deployment_imported`: {true/false}
1039
1338
  - `apis_imported`: {true/false}
1339
+ - `admin_imported`: {true/false}
1340
+ - `admin_capabilities_count`: {count if admin present, else "n/a"}
1341
+ - `content_imported`: {true/false}
1342
+ - `content_types_count`: {count if content present, else "n/a"}
1343
+ - `user_data_imported`: {true/false}
1344
+ - `user_data_capabilities_count`: {count if user_data present, else "n/a"}
1345
+ - `entity_mgmt_imported`: {true/false}
1346
+ - `entity_mgmt_entity_count`: {count if entity_mgmt present, else "n/a"}
1347
+ - `embedded_domain`: {true/false — from notes.md or PROJECT-CONTEXT.md}
1348
+ - `embedded_hw_topology_imported`: {true/false}
1349
+ - `embedded_peripheral_count`: {count if hw_topology present, else "n/a"}
1350
+
1351
+ 13. **Embedded Domain Export (ENH-071)**
1352
+
1353
+ If notes.md contains any of: `## hw_topology`, `## pin_map`, `## memory_layout`, `## protocols`, `## rtos_config`, `## embedded_toolchain`, `## power_budget`, `## safety_config`:
1354
+
1355
+ a. Set `embedded_export: true` in working notes.
1356
+
1357
+ b. Export to `ARCHITECTURE.md` (append in order, skip sections whose YAML is empty/absent):
1358
+
1359
+ - **`## Hardware Architecture`** ← from `## hw_topology`
1360
+ - MCU/SoC spec table: Family | Core | Flash (KB) | RAM (KB)
1361
+ - Mermaid `graph TD` block diagram (MCU → external ICs via labeled bus arrows)
1362
+ - External ICs + bus topology table: Part | Type | Interface | Bus Speed | Notes
1363
+ - Power rails table: Rail | Source | Voltage | Max current (mA)
1364
+
1365
+ - **`## Hardware Interface`** ← from `## pin_map`
1366
+ - Pin assignment table: Pin# | GPIO Name | Alt Function | Peripheral | Direction | Pull | Voltage | Notes
1367
+ - Conflicts list (if any)
1368
+
1369
+ - **`## Memory Map`** ← from `## memory_layout`
1370
+ - Flash regions table: Region | Start Address | Size (KB) | Usage | Notes
1371
+ - RAM regions table: Region | Start Address | Size (KB) | Usage | Notes
1372
+ - Linker constraints note
1373
+
1374
+ - **`## Communication Protocols`** ← from `## protocols`
1375
+ - Bus protocol matrix table: Protocol | Role | Speed | Topology | Connected Devices | Notes
1376
+ - Wireless/external connectivity table: Protocol | Role | Endpoint | Notes
1377
+ - Note: "See `## APIs` for HTTP REST endpoints (if applicable)"
1378
+
1379
+ - **`## RTOS & Task Model`** ← from `## rtos_config`
1380
+ - Execution model (bare-metal / RTOS name + version)
1381
+ - Task table: Task Name | Priority | Period/Event | Stack KB | Notes
1382
+ - ISR table: Interrupt | Handler | Priority | Shared Resources
1383
+ - Shared resource protection strategy
1384
+
1385
+ - **`## Toolchain & Build System`** ← from `## embedded_toolchain`
1386
+ - MCU family + toolchain + build system + debug interface (one-line summary)
1387
+ - SDK/HAL choice + flasher/debugger tool
1388
+
1389
+ - **`## Power Budget`** ← from `## power_budget`
1390
+ - Power supply summary
1391
+ - Power modes table: Mode | MCU state | Active peripherals | Typical current | Wake-up sources
1392
+ - Battery life estimate (if battery-powered)
1393
+
1394
+ - **`## Safety & Reliability`** ← from `## safety_config`
1395
+ - Safety standard (if any)
1396
+ - Watchdog configuration
1397
+ - Fault handler strategy
1398
+ - Safe state definition
1399
+
1400
+ c. Write to `.viepilot/PROJECT-CONTEXT.md`:
1401
+ ```
1402
+ ## Embedded Domain
1403
+ embedded: true
1404
+ target_mcu: {mcu.family from hw_topology, or "unknown"}
1405
+ toolchain: {toolchain from embedded_toolchain, or "unknown"}
1406
+ ```
1407
+ This flag is read by `vp-auto` at runtime: scaffold-first gate selects the correct embedded toolchain stack instead of web framework scaffolding.
1408
+
1409
+ d. **Hardware sections are READ-ONLY for `vp-auto`** (same protection as ui-direction artifacts).
1410
+ `vp-auto` MUST read hardware sections before implementing driver tasks — never overwrite them.
1411
+
1412
+ ---
1413
+
1414
+ ### Step 1D.14 — Design.MD Export (ENH-076)
1415
+
1416
+ **Trigger (gate fires when ANY of):**
1417
+ - `design.md` exists in `.viepilot/ui-direction/{session-id}/`
1418
+ - `notes.md` contains `## design_tokens` section
1419
+ - Brainstorm session text contains ≥3 design keywords: `color` / `font` / `brand` / `spacing` / `typography` / `palette` / `theme` / `rounded` / `style`
1420
+
1421
+ **Skip conditions (gate does NOT fire when ANY of):**
1422
+ - `notes.md` has `design_md_status: skipped` (idempotent — user already skipped this session)
1423
+ - `notes.md` has `design_md_status: exported` (already exported this session)
1424
+ - Session has no UI components and no design keywords
1425
+
1426
+ **Gate — AUQ (mandatory-acknowledge — user must select one option):**
1427
+
1428
+ > **Claude Code (terminal) — REQUIRED:** Call `AskUserQuestion`:
1429
+ > - question: "Design tokens found in this session. What would you like to do with design.md?"
1430
+ > - header: "design.md"
1431
+ > - options:
1432
+ > - label: "Export to project root" (Recommended)
1433
+ > description: "Copy design.md, update ARCHITECTURE.md + PROJECT-CONTEXT.md"
1434
+ > - label: "Finalize & export"
1435
+ > description: "Complete any missing tokens via Q&A, then export"
1436
+ > - label: "Skip this time"
1437
+ > description: "Note: vp-auto will not apply brand tokens to UI tasks"
1438
+ > **Cursor / Codex / Antigravity / Copilot:** present as plain numbered list.
1439
+
1440
+ **Export pipeline (options 1 + 2):**
1441
+
1442
+ 1. **Source:** `.viepilot/ui-direction/{session-id}/design.md`
1443
+ 2. **Destination:** `{project-root}/design.md`
1444
+ - If `design.md` already exists at project root → AUQ (or plain numbered list on non-terminal):
1445
+ Override with new tokens / Merge (new fills gaps, existing takes precedence) / Keep existing / View diff
1446
+ 3. **Update `ARCHITECTURE.md`** — append `## Design System` section:
1447
+ ```markdown
1448
+ ## Design System
1449
+
1450
+ > Generated from Design.MD spec (v1)
1451
+ > Source: `.viepilot/ui-direction/{session-id}/design.md`
1452
+ > Last updated: {crystallize-date}
1453
+
1454
+ | Category | Token | Value |
1455
+ |----------|-------|-------|
1456
+ | Colors | primary | {hex} |
1457
+ | Colors | surface | {hex} |
1458
+ | Typography | fontFamily | {font} |
1459
+ | Spacing | base | {n}px |
1460
+
1461
+ **Full spec:** See `design.md` at project root.
1462
+ ```
1463
+ 4. **Update `PROJECT-CONTEXT.md`** — add field:
1464
+ ```
1465
+ design_md: true
1466
+ ```
1467
+ 5. **Update `notes.md`** — set:
1468
+ ```yaml
1469
+ design_md_status: exported
1470
+ design_md_exported_at: {timestamp}
1471
+ ```
1472
+
1473
+ **Skip pipeline (option 3):**
1474
+ - Write to `notes.md`:
1475
+ ```yaml
1476
+ design_md_status: skipped
1477
+ design_md_skipped_at: {timestamp}
1478
+ ```
1479
+ - Show warning: `⚠️ design.md skipped — vp-auto will not apply brand tokens to UI tasks`
1480
+
1481
+ **Post-Export Handoff: vp-design --sync (ENH-077)**
1482
+
1483
+ After **successful export** (export pipeline steps 1–5 complete), offer sync handoff:
1484
+
1485
+ **Skip condition:** If no stylesheet target detected (no `tailwind.config.js`, no `.css`, no `.scss` files in project) → skip AUQ silently. Print:
1486
+ > `Note: no stylesheet target detected. Run /vp-design --sync after adding your stylesheets.`
1487
+
1488
+ Otherwise:
1489
+
1490
+ > **Claude Code (terminal) — REQUIRED:** Call `AskUserQuestion`:
1491
+ > - question: "design.md exported to project root. Sync design tokens to your stylesheets now?"
1492
+ > - header: "Sync tokens?"
1493
+ > - options:
1494
+ > - label: "Run /vp-design --sync now (Recommended)"
1495
+ > description: "Auto-applies tokens to Tailwind / CSS vars / SCSS — stack auto-detected"
1496
+ > - label: "Skip — run manually later"
1497
+ > description: "Run /vp-design --sync yourself when ready"
1498
+ >
1499
+ > **Cursor / Codex / Antigravity / Copilot:** Text fallback:
1500
+ > ```
1501
+ > design.md exported. Next step:
1502
+ > /vp-design --sync Apply tokens to Tailwind / CSS / SCSS
1503
+ > ```
1504
+
1505
+ **On selection:**
1506
+ - "Run /vp-design --sync now" → invoke `/vp-design --sync` skill
1507
+ - "Skip" → print: `Tip: run /vp-design --sync to apply design tokens to your stylesheets.`
1508
+
1509
+ ---
1510
+
1511
+ ### Step 1D-a: arch_to_ui_sync noted items → UI Pages → Component Map (ENH-069 Gap 5)
1512
+
1513
+ After reading `notes.md → ## arch_to_ui_sync[]`, for each entry with `status: noted`:
1514
+
1515
+ 1. Check if the referenced `ui_implication` (screen/state/component) is already covered by a row in the `## UI Pages → Component Map` (built in Step 1A-i)
1516
+ 2. If **NOT covered** → add a new row to the component map:
1517
+ ```
1518
+ | Prototype | Target component | Phase | Source | Status |
1519
+ | [no page yet — arch_to_ui_sync] | {inferred component} | {inferred phase} | arch_to_ui_sync | pending |
1520
+ ```
1521
+ 3. If already covered (matching page exists in Step 1A map) → no action
1522
+
1523
+ Note: entries with `status: addressed` are already reflected in pages/*.html — skip them.
1524
+
1525
+ ---
1526
+
1527
+ ### Step 1D-b: Design Staleness Check (ENH-069 Gap 8)
1528
+
1529
+ After reading `decisions[]` (Step 1D item 2) and having pages/*.html content from Step 1A:
1530
+
1531
+ For each decision in `decisions[]` that has a UI implication (check `arch_to_ui_sync[]` table for matching `decision_id`):
1532
+ 1. Check the relevant `pages/{slug}.html` for visible representation of the decision (keyword search in HTML content)
1533
+ 2. If **NOT represented**:
1534
+ ```
1535
+ ⚠️ Design Staleness Warning:
1536
+ Decision '{title}' (ui_implication: {text}) is not reflected in {page}.html.
1537
+ The prototype may have been created before this architectural decision was made.
1538
+
1539
+ → Adding pre-implementation task to UI Pages → Component Map:
1540
+ "update {page}.html to reflect {decision}"
1541
+ Phase: same as page implementation phase
1542
+ Source: design_staleness
1543
+ ```
1544
+ 3. This pre-implementation task must appear BEFORE the page's component implementation task in ROADMAP ordering
1545
+
1546
+
1040
1547
 
1041
1548
  If `.viepilot/architect/` does **not** exist but brainstorm shows complex architecture (≥5 services/components detected):
1042
1549
  - Suggest (soft prompt — not a hard block):
@@ -1057,6 +1564,77 @@ If `.viepilot/architect/` does **not** exist but brainstorm shows complex archit
1057
1564
  - User confirmation required before proceeding.
1058
1565
  </step>
1059
1566
 
1567
+ <step name="skill_decision_gate">
1568
+ ## Step 1E — Skill Decision Gate (FEAT-020)
1569
+
1570
+ **Trigger**: `## skills_used` section exists in the brainstorm session's `notes.md` (`.viepilot/ui-direction/{session-id}/notes.md` or `.viepilot/architect/{session-id}/notes.md`).
1571
+
1572
+ **Skip condition**: If no `## skills_used` found anywhere → silently skip this step (no error, no prompt).
1573
+
1574
+ **Step — Load skills_used:**
1575
+ Read `## skills_used` from the most recent session's `notes.md`. Extract each skill entry: `id`, `capabilities`, `best_practices_applied`.
1576
+
1577
+ **Step — AUQ confirm (Claude Code adapter — REQUIRED):**
1578
+
1579
+ > **Claude Code (terminal):** Call `AskUserQuestion` tool.
1580
+ > - question: "The following skills were used in this brainstorm. Mark each as required, optional, or exclude:"
1581
+ > - For each skill: show `id` + capabilities + `best_practices_applied[]`
1582
+ > - Options per skill: `required` | `optional` | `exclude`
1583
+
1584
+ > **Text fallback (other adapters):** Present numbered list with required / optional / exclude options per skill.
1585
+
1586
+ **Step — Write `## Skills` to `PROJECT-CONTEXT.md`:**
1587
+
1588
+ Append to `.viepilot/PROJECT-CONTEXT.md`:
1589
+
1590
+ ```markdown
1591
+ ## Skills
1592
+
1593
+ | Skill | Source | Required | Phases | Rationale |
1594
+ |-------|--------|----------|--------|-----------|
1595
+ | frontend-design | npm:@vp-skills/frontend-design | required | 1, 2 | UI-Direction HTML generation — design token best practices |
1596
+ ```
1597
+
1598
+ - `required` — skill best_practices injected by vp-auto for matching phases — **no re-asking**
1599
+ - `optional` — skill context available but not auto-injected
1600
+ - `exclude` — entry omitted from PROJECT-CONTEXT.md
1601
+
1602
+ **Lock semantics**: once written, `## Skills` is the authoritative skill decision for the project. `vp-auto` reads it and **never re-prompts**.
1603
+ </step>
1604
+
1605
+ <step name="cross_reference_gate">
1606
+ ## Step 1F: Cross-Reference Gate (ENH-064)
1607
+
1608
+ Run when BOTH `architect_read_complete: true` AND `ui_direction_read_complete: true` are set in working notes:
1609
+
1610
+ 1. Read `## Coverage` from architect notes.md (or ui-direction notes.md if present).
1611
+ 2. For each feature in coverage matrix:
1612
+ - Confirm architect page was read (in `architect_read_complete` set)
1613
+ - Confirm UI screen page was read (in `ui_direction_read_complete` set)
1614
+ 3. Features with "none yet" in BOTH architect AND UI columns → apply **ENH-069 Gap 6** split:
1615
+
1616
+ **Case A — Feature IS in `phases_inventory`** (scoped for implementation):
1617
+ ```
1618
+ ⛔ Coverage gap BLOCKED: Feature "{name}" is scoped to Phase {N} but has no design coverage.
1619
+ Step 7 (ROADMAP generation) is blocked until resolved. Choose one:
1620
+ (a) Add to UI Direction now → /vp-brainstorm --ui (Recommended)
1621
+ (b) Create implementation task with explicit 'design-TBD' note
1622
+ (c) Remove from scope with reason logged in working notes
1623
+ ```
1624
+ → **Step 7 is BLOCKED** until this feature's gap is resolved and logged.
1625
+
1626
+ **Case B — Feature is NOT in `phases_inventory`** (out-of-scope):
1627
+ ```
1628
+ ⚠️ Coverage gap (out-of-scope): Feature "{name}" has no design coverage — not in phases_inventory.
1629
+ Consider adding before proceeding — or dismiss to continue.
1630
+ ```
1631
+ → Non-blocking warning (unchanged behavior).
1632
+
1633
+ 4. Record: `cross_reference_complete: true`.
1634
+
1635
+ **Skip condition**: if only one workspace is present (not both) → silently skip Step 1F (single-workspace is valid).
1636
+ </step>
1637
+
1060
1638
  <step name="generate_ai_guide">
1061
1639
  ## Step 2: Generate AI-GUIDE.md
1062
1640
 
@@ -1162,6 +1740,13 @@ Create `.viepilot/architecture/` only when at least one `.mermaid` file will be
1162
1740
  Create `.viepilot/PROJECT-CONTEXT.md` using template:
1163
1741
  `@$HOME/.cursor/viepilot/templates/project/PROJECT-CONTEXT.md`
1164
1742
 
1743
+ **Version stamp (ENH-067):** Write the following as the **very first line** of the generated file (before the `#` title):
1744
+ ```
1745
+ <!-- crystallize_version: {viepilot_semver} -->
1746
+ ```
1747
+ where `{viepilot_semver}` is resolved from `node bin/vp-tools.cjs info` → `version` field.
1748
+ This stamp is used by `--upgrade` re-scan mode (Step 0-B) to detect delta on future crystallize runs.
1749
+
1165
1750
  Extract:
1166
1751
  - Domain knowledge
1167
1752
  - Key concepts
@@ -1225,6 +1810,50 @@ From brainstorm `phases_inventory`:
1225
1810
  3. Define dependencies between phases.
1226
1811
  4. Each phase: tasks, acceptance criteria, verification commands.
1227
1812
  5. No Post-MVP / horizon block needed — all work is already in phases.
1813
+
1814
+ ---
1815
+
1816
+ ### Step 7 — UI Pages → Component Map Completeness Check (ENH-069 Gap 2)
1817
+
1818
+ After generating all phase tasks from `phases_inventory`, run a mandatory UI coverage pass:
1819
+
1820
+ For each row in the `## UI Pages → Component Map` (built in Step 1A-i and updated in Steps 1D-a, 1D-b):
1821
+ 1. Check if a task exists in the generated ROADMAP that implements the `Target component`
1822
+ 2. If **no task found**:
1823
+ - Add a new task to the appropriate phase:
1824
+ ```
1825
+ Title: "Implement {target_component} from {prototype}"
1826
+ UI Prototype Reference: {path/to/pages/{slug}.html}
1827
+ Source: UI Pages → Component Map (auto-added by crystallize)
1828
+ ```
1829
+ - For `ux-fix-required` rows: add a separate task `fix-ux-p0: {pain description}` before the component task
1830
+ - For `design_staleness` rows: add `update {page}.html to reflect {decision}` before the component task
1831
+ 3. Update the row status in the component map: `pending` → `assigned (Phase N, Task N.X)`
1832
+
1833
+ After the completeness check, **all rows must have `status != pending`**. If any rows remain `pending` after exhausting existing phases, create a new `Phase N+1: UI Implementation` and assign them there.
1834
+
1835
+ Finally, write the finalized `## UI Pages → Component Map` to `.viepilot/PROJECT-CONTEXT.md` so `vp-auto` can read it at runtime.
1836
+
1837
+ ### Step 7 — Embedded Domain: Skip UI Coverage Gate + Apply Hardware Coverage Check (ENH-071)
1838
+
1839
+ If `PROJECT-CONTEXT.md` contains `## Embedded Domain` with `embedded: true`:
1840
+
1841
+ 1. **Skip** the UI Pages → Component Map Completeness Check above (no web UI components expected).
1842
+
1843
+ 2. **Apply Hardware Coverage Check instead** (non-blocking warning):
1844
+
1845
+ For each peripheral in `hw_topology.peripherals[]` and `hw_topology.external_ics[]`:
1846
+ - Check if a driver task exists in the generated ROADMAP (Phase 2: Driver Layer or equivalent)
1847
+ - If **no driver task found** for peripheral `{name}`:
1848
+ ```
1849
+ ⚠️ Hardware Coverage: no driver task found for peripheral "{name}" ({interface})
1850
+ Suggestion: Add "Implement {name} driver ({interface})" to Phase 2 (Driver Layer)
1851
+ ```
1852
+ - Warning is **non-blocking** — ROADMAP generation continues. User can dismiss or add the task.
1853
+
1854
+ 3. **Add Phase 1: Board Bring-Up task** if not already in ROADMAP and `embedded: true`:
1855
+ - Automatically include "Board Bring-Up verification" as Phase 1 Task 1 (clock config, GPIO init, UART console confirm, LED blink)
1856
+ - Only added if no equivalent task already exists.
1228
1857
  </step>
1229
1858
 
1230
1859
  <step name="generate_schemas">
@@ -1261,7 +1890,14 @@ Initialize:
1261
1890
  - Version info (0.1.0-alpha)
1262
1891
  - Next action
1263
1892
 
1264
- Create empty `.viepilot/HANDOFF.json`
1893
+ Create `.viepilot/HANDOFF.json` with initial fields including:
1894
+ ```json
1895
+ {
1896
+ "crystallize_version": "{viepilot_semver}",
1897
+ "crystallized_at": "{ISO-8601 timestamp}"
1898
+ }
1899
+ ```
1900
+ `crystallize_version` mirrors the stamp written to `PROJECT-CONTEXT.md` (ENH-067). Used by `--upgrade` re-scan as a fallback when `PROJECT-CONTEXT.md` header comment is absent.
1265
1901
  </step>
1266
1902
 
1267
1903
  <step name="generate_phase_dirs">