viepilot 2.23.0 → 2.41.0

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 (38) hide show
  1. package/CHANGELOG.md +195 -0
  2. package/README.md +6 -6
  3. package/bin/viepilot.cjs +108 -1
  4. package/bin/vp-tools.cjs +109 -0
  5. package/docs/brainstorm/session-2026-04-20.md +261 -0
  6. package/docs/skills-reference.md +22 -0
  7. package/docs/user/features/adapters.md +2 -2
  8. package/docs/user/features/scaffold-first.md +62 -0
  9. package/docs/user/features/skill-registry.md +125 -0
  10. package/lib/adapters/antigravity.cjs +5 -4
  11. package/lib/skill-installer.cjs +274 -0
  12. package/lib/skill-registry.cjs +212 -0
  13. package/lib/viepilot-update.cjs +113 -0
  14. package/package.json +1 -1
  15. package/skills/vp-audit/SKILL.md +57 -9
  16. package/skills/vp-auto/SKILL.md +44 -0
  17. package/skills/vp-brainstorm/SKILL.md +108 -1
  18. package/skills/vp-crystallize/SKILL.md +72 -0
  19. package/skills/vp-debug/SKILL.md +27 -0
  20. package/skills/vp-docs/SKILL.md +27 -0
  21. package/skills/vp-evolve/SKILL.md +59 -6
  22. package/skills/vp-info/SKILL.md +27 -0
  23. package/skills/vp-pause/SKILL.md +27 -0
  24. package/skills/vp-proposal/SKILL.md +27 -0
  25. package/skills/vp-request/SKILL.md +52 -6
  26. package/skills/vp-resume/SKILL.md +27 -0
  27. package/skills/vp-rollback/SKILL.md +27 -0
  28. package/skills/vp-skills/SKILL.md +301 -0
  29. package/skills/vp-status/SKILL.md +27 -0
  30. package/skills/vp-task/SKILL.md +27 -0
  31. package/skills/vp-ui-components/SKILL.md +27 -0
  32. package/skills/vp-update/SKILL.md +27 -0
  33. package/templates/phase/TASK.md +7 -0
  34. package/templates/project/PROJECT-CONTEXT.md +76 -0
  35. package/workflows/audit.md +131 -0
  36. package/workflows/autonomous.md +140 -0
  37. package/workflows/brainstorm.md +1025 -9
  38. package/workflows/crystallize.md +528 -3
@@ -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
 
@@ -895,6 +989,27 @@ The brainstorm session indicates this project has UI scope but `.viepilot/ui-dir
895
989
 
896
990
  If `ui_scope_detected = false` → skip gate; proceed normally.
897
991
 
992
+ **MANDATORY READ GATE (ENH-064) — if `.viepilot/ui-direction/` exists:**
993
+
994
+ Read ALL artifacts completely (no partial reads):
995
+ 1. `notes.md` — ALL sections: ui_idea_buffer[], background extracted ideas, Pages inventory, arch_to_ui_sync[], skills_used[], coverage[], admin (if present)
996
+ 2. If `pages/` directory exists: read EVERY `pages/*.html` file — do NOT skip any page
997
+ For each page: extract layout intent, component list, interactions, designer annotations
998
+ 3. Read `index.html` (hub) — verify nav links match pages/ file set
999
+ 4. Verify `## Pages inventory` in notes.md matches actual `pages/*.html` set on disk
1000
+ If mismatch detected → STOP:
1001
+ ```
1002
+ ⛔ UI Direction pages/ directory and notes.md Pages inventory are out of sync.
1003
+ Files on disk: {list}
1004
+ Inventory in notes.md: {list}
1005
+ Please sync brainstorm artifacts before continuing.
1006
+ 1. Return to /vp-brainstorm --ui to update inventory
1007
+ 2. Continue with disk files as source of truth (override notes.md)
1008
+ ```
1009
+ 5. Record: `ui_direction_read_complete: true` in crystallize working notes
1010
+
1011
+ Do NOT proceed to UI extraction until `ui_direction_read_complete: true`.
1012
+
898
1013
  ### Consume artifacts (when available)
899
1014
 
900
1015
  Check for direction artifacts:
@@ -917,6 +1032,69 @@ When available, for the selected/latest session:
917
1032
  - In architecture / UI plan output, **enumerate every page** from inventory (or state explicitly single-page legacy).
918
1033
 
919
1034
  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.
1035
+
1036
+ ---
1037
+
1038
+ ### Step 1A-i: Build UI Pages → Component Map (ENH-069 Gap 1)
1039
+
1040
+ After all `pages/*.html` files are read, build a binding table in crystallize working notes:
1041
+
1042
+ ```markdown
1043
+ ## UI Pages → Component Map
1044
+ | Prototype | Target component | Phase | Source | Status |
1045
+ |-----------|-----------------|-------|--------|--------|
1046
+ | pages/landing.html | resources/js/Pages/Home.vue | Phase 1 | page | pending |
1047
+ | pages/dashboard.html | resources/js/Pages/Dashboard.vue | Phase 2 | page | pending |
1048
+ ```
1049
+
1050
+ **Rules:**
1051
+ - One row per `pages/{slug}.html` found; derive target component from stack convention:
1052
+ - Inertia/Vue → `resources/js/Pages/{PascalName}.vue`
1053
+ - Next.js App Router → `app/{slug}/page.tsx`
1054
+ - Generic SPA → `src/pages/{PascalName}.{ext}`
1055
+ - Phase = best estimate from `phases_inventory` topic match or page content
1056
+ - Source = `page` (from pages/*.html), `arch_to_ui_sync` (added in Step 1D), `ux_walkthrough` (added below)
1057
+ - Status = `pending` (updated to `assigned` in Step 7 after ROADMAP cross-check)
1058
+
1059
+ This table is the **single source of truth** for UI→implementation tracing through Steps 1D, 1F, and Step 7.
1060
+
1061
+ ---
1062
+
1063
+ ### Step 1A-ii: Process `## UX walkthrough log` (ENH-069 Gap 9)
1064
+
1065
+ After building the component map, scan `notes.md → ## UX walkthrough log` (written by `/research-ui`):
1066
+
1067
+ - **P0 entries** (unusability, content loss, critical mis-clicks): add a UX-fix row to the component map:
1068
+ ```
1069
+ Source: ux_walkthrough
1070
+ Status: ux-fix-required
1071
+ Task hint: fix-ux-p0: {pain description} on {page}.html
1072
+ ```
1073
+ These become mandatory tasks in ROADMAP (Phase = same as the page's assigned phase).
1074
+
1075
+ - **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.
1076
+
1077
+ - **P2 entries** (minor polish): surface as non-blocking warnings only; do NOT add to component map.
1078
+
1079
+ - If `## UX walkthrough log` is absent or empty → no action.
1080
+
1081
+ ---
1082
+
1083
+ ### Step 1A-iii: `## Background extracted ideas` resolution gate (ENH-069 Gap 10)
1084
+
1085
+ After UX walkthrough processing, scan `notes.md → ## Background extracted ideas` (written by ENH-026 background extraction when user selects "notes only" — no prototype generated):
1086
+
1087
+ For each idea entry:
1088
+ 1. Check if the idea maps to an existing row in the UI Pages → Component Map OR a feature in `phases_inventory`
1089
+ 2. If NOT covered: add to a `## Unresolved Background Ideas` gate list
1090
+
1091
+ **This gate BLOCKS Step 7 (ROADMAP generation) until every entry in `## Unresolved Background Ideas` is resolved with one of:**
1092
+ - **(a) Promote to UI Direction** — user creates/updates `pages/*.html`; add to component map
1093
+ - **(b) Add as task-TBD** — create implementation task with `design-TBD` note
1094
+ - **(c) Descope** — mark as out-of-scope with reason logged in working notes
1095
+
1096
+ Record all resolutions in working notes before Step 7 runs.
1097
+
920
1098
  </step>
921
1099
 
922
1100
  <step name="research_stack_official">
@@ -980,6 +1158,44 @@ Also create project-local index for traceability:
980
1158
 
981
1159
  If `.viepilot/architect/` exists with at least one session directory:
982
1160
 
1161
+ **MANDATORY READ GATE (ENH-064) — if `.viepilot/architect/` exists:**
1162
+
1163
+ Before extracting any data, execute a full sequential read of ALL present files:
1164
+
1165
+ ```bash
1166
+ ls -la .viepilot/architect/{session-id}/
1167
+ ```
1168
+
1169
+ For each file present, READ COMPLETELY (no skimming):
1170
+ 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[]
1171
+ 2. `architecture.html` — components, C4 intent, external integrations
1172
+ 3. `data-flow.html` — service flows, async indicators, event queues
1173
+ 4. `decisions.html` — all ADR entries (supplement notes.md decisions[])
1174
+ 5. `tech-stack.html` — layer-by-layer stack (authoritative if conflicts with notes.md)
1175
+ 6. `tech-notes.html` — assumptions, risks, open questions (supplement notes.md open_questions[])
1176
+ 7. `feature-map.html` — features with phase/priority/status tags
1177
+ 8. `erd.html` — entities, relationships (if present)
1178
+ 9. `user-use-cases.html` — actors, use cases (if present)
1179
+ 10. `deployment.html` — infra, environments (if present)
1180
+ 11. `apis.html` — endpoints, service contracts (if present)
1181
+ 12. `admin.html` — admin capabilities (if present — ENH-063)
1182
+ 13. `content.html` — content types, lifecycle, media/SEO schema (if present — ENH-065)
1183
+ 14. `user-data.html` — user-owned data controls (if present — ENH-066)
1184
+ 15. `entity-mgmt.html` — admin entity CRUD matrix (if present — ENH-068)
1185
+ *(Skip: `sequence-diagram.html` — intentionally excluded per existing rule)*
1186
+
1187
+ **Failure rule**: if `notes.md` is missing or unreadable → STOP and surface:
1188
+ ```
1189
+ ⛔ Architect workspace found but notes.md is missing or unreadable.
1190
+ Path: .viepilot/architect/{session-id}/notes.md
1191
+ Please fix architect artifacts before running /vp-crystallize.
1192
+ 1. Return to /vp-brainstorm --architect to regenerate notes.md
1193
+ 2. Continue without architect data (not recommended)
1194
+ ```
1195
+
1196
+ **Completion record**: after all files read → set `architect_read_complete: true` in crystallize working notes.
1197
+ Do NOT proceed to data extraction until `architect_read_complete: true`.
1198
+
983
1199
  1. **Select most recent session** (by directory mtime or newest session-id).
984
1200
  2. **Read `notes.md`** → parse YAML frontmatter sections:
985
1201
  - **`decisions[]`** → append to `.viepilot/ARCHITECTURE.md` under:
@@ -1028,8 +1244,77 @@ If `.viepilot/architect/` exists with at least one session directory:
1028
1244
  | Decision | Choice | Rationale |
1029
1245
  ```
1030
1246
  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**:
1247
+ 7. **`admin.html` / `notes.md ## admin`** (if exists ENH-063) → append to `.viepilot/PROJECT-CONTEXT.md`:
1248
+ ```markdown
1249
+ ## Admin & Governance (from Architect Mode)
1250
+ | Capability | Required | Phase | Notes |
1251
+ |-----------|----------|-------|-------|
1252
+ | User management UI | yes | 2 | invite, deactivate, role assign |
1253
+ | Audit log | yes | 3 | all write operations, 90-day retention |
1254
+ | Monitoring dashboard | optional | 3 | error rate, latency, active users |
1255
+ | Billing management | no | — | not in scope |
1256
+
1257
+ ### Admin Personas
1258
+ | Persona | Key Capabilities |
1259
+ |---------|-----------------|
1260
+ | super_admin | user_management, billing, system_config, audit_log_view |
1261
+ | org_admin | invite_users, role_assign, reporting |
1262
+ ```
1263
+ 8. **`content.html` / `notes.md ## content`** (if exists — ENH-065) → append to `.viepilot/PROJECT-CONTEXT.md`:
1264
+ ```markdown
1265
+ ## Content Management (from Architect Mode)
1266
+ | Content Type | Created By | Lifecycle | Key Fields | Phase |
1267
+ |-------------|-----------|-----------|-----------|-------|
1268
+ | article | admin, author | draft → review → published → archived | title, body, slug, tags, seo_meta | 2 |
1269
+ | product | admin | draft → published → discontinued | name, description, price, images, category | 1 |
1270
+
1271
+ ### Media & Storage
1272
+ | Storage | CDN | Types | Max Size |
1273
+ |---------|-----|-------|----------|
1274
+ | S3 | CloudFront | image, pdf | 10 MB |
1275
+
1276
+ ### Localization
1277
+ | Locales | Fallback |
1278
+ |---------|---------|
1279
+ | en | en |
1280
+ ```
1281
+ 9. **`user-data.html` / `notes.md ## user_data`** (if exists — ENH-066) → append to `.viepilot/PROJECT-CONTEXT.md`:
1282
+ ```markdown
1283
+ ## User Data Management (from Architect Mode)
1284
+ | Capability | Supported | Notes |
1285
+ |-----------|----------|-------|
1286
+ | Profile edit (name/email/avatar) | yes | — |
1287
+ | Notification preferences | yes | email, push, in_app |
1288
+ | Data export (GDPR) | yes | CSV/JSON download |
1289
+ | Account deletion (right-to-erasure) | yes | 730-day retention |
1290
+ | Activity history | yes | login history, action log |
1291
+ | Connected accounts (OAuth) | yes | Google, GitHub |
1292
+ | Session/device management | yes | sign out all devices |
1293
+ | Two-factor authentication | yes | TOTP + backup codes |
1294
+ ```
1295
+ 10. **`entity-mgmt.html` / `notes.md ## entity_mgmt`** (if exists — ENH-068) → append to `.viepilot/PROJECT-CONTEXT.md`:
1296
+ ```markdown
1297
+ ## Admin Entity Management (from Architect Mode)
1298
+ | Entity | CRUD Ops | Soft Delete | Bulk Actions | Audit Trail | Scope |
1299
+ |--------|----------|-------------|--------------|-------------|-------|
1300
+ | — | — | — | — | — | — |
1301
+
1302
+ ### Import / Export
1303
+ | Direction | Entities |
1304
+ |-----------|----------|
1305
+ | CSV Import | — |
1306
+ | CSV Export | — |
1307
+ ```
1308
+ 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**:
1309
+
1310
+ For each discrepancy, record a resolution in `## Feature-Map Resolutions` working notes:
1311
+ - **(a) add-to-inventory** — add feature to phases_inventory; will generate a ROADMAP task
1312
+ - **(b) descoped** — mark feature as removed with reason
1313
+ - **(c) design-only** — design artifact only; no implementation task required
1314
+
1315
+ No silent continuation. The `## Feature-Map Resolutions` table must be complete before Step 7 runs.
1316
+
1317
+ 12. **Record in working notes**:
1033
1318
  - `architect_session_id`: {id}
1034
1319
  - `decisions_imported`: {count}
1035
1320
  - `open_questions_count`: {count of open questions}
@@ -1037,6 +1322,117 @@ If `.viepilot/architect/` exists with at least one session directory:
1037
1322
  - `use_cases_count`: {count if use_cases present, else "n/a"}
1038
1323
  - `deployment_imported`: {true/false}
1039
1324
  - `apis_imported`: {true/false}
1325
+ - `admin_imported`: {true/false}
1326
+ - `admin_capabilities_count`: {count if admin present, else "n/a"}
1327
+ - `content_imported`: {true/false}
1328
+ - `content_types_count`: {count if content present, else "n/a"}
1329
+ - `user_data_imported`: {true/false}
1330
+ - `user_data_capabilities_count`: {count if user_data present, else "n/a"}
1331
+ - `entity_mgmt_imported`: {true/false}
1332
+ - `entity_mgmt_entity_count`: {count if entity_mgmt present, else "n/a"}
1333
+ - `embedded_domain`: {true/false — from notes.md or PROJECT-CONTEXT.md}
1334
+ - `embedded_hw_topology_imported`: {true/false}
1335
+ - `embedded_peripheral_count`: {count if hw_topology present, else "n/a"}
1336
+
1337
+ 13. **Embedded Domain Export (ENH-071)**
1338
+
1339
+ If notes.md contains any of: `## hw_topology`, `## pin_map`, `## memory_layout`, `## protocols`, `## rtos_config`, `## embedded_toolchain`, `## power_budget`, `## safety_config`:
1340
+
1341
+ a. Set `embedded_export: true` in working notes.
1342
+
1343
+ b. Export to `ARCHITECTURE.md` (append in order, skip sections whose YAML is empty/absent):
1344
+
1345
+ - **`## Hardware Architecture`** ← from `## hw_topology`
1346
+ - MCU/SoC spec table: Family | Core | Flash (KB) | RAM (KB)
1347
+ - Mermaid `graph TD` block diagram (MCU → external ICs via labeled bus arrows)
1348
+ - External ICs + bus topology table: Part | Type | Interface | Bus Speed | Notes
1349
+ - Power rails table: Rail | Source | Voltage | Max current (mA)
1350
+
1351
+ - **`## Hardware Interface`** ← from `## pin_map`
1352
+ - Pin assignment table: Pin# | GPIO Name | Alt Function | Peripheral | Direction | Pull | Voltage | Notes
1353
+ - Conflicts list (if any)
1354
+
1355
+ - **`## Memory Map`** ← from `## memory_layout`
1356
+ - Flash regions table: Region | Start Address | Size (KB) | Usage | Notes
1357
+ - RAM regions table: Region | Start Address | Size (KB) | Usage | Notes
1358
+ - Linker constraints note
1359
+
1360
+ - **`## Communication Protocols`** ← from `## protocols`
1361
+ - Bus protocol matrix table: Protocol | Role | Speed | Topology | Connected Devices | Notes
1362
+ - Wireless/external connectivity table: Protocol | Role | Endpoint | Notes
1363
+ - Note: "See `## APIs` for HTTP REST endpoints (if applicable)"
1364
+
1365
+ - **`## RTOS & Task Model`** ← from `## rtos_config`
1366
+ - Execution model (bare-metal / RTOS name + version)
1367
+ - Task table: Task Name | Priority | Period/Event | Stack KB | Notes
1368
+ - ISR table: Interrupt | Handler | Priority | Shared Resources
1369
+ - Shared resource protection strategy
1370
+
1371
+ - **`## Toolchain & Build System`** ← from `## embedded_toolchain`
1372
+ - MCU family + toolchain + build system + debug interface (one-line summary)
1373
+ - SDK/HAL choice + flasher/debugger tool
1374
+
1375
+ - **`## Power Budget`** ← from `## power_budget`
1376
+ - Power supply summary
1377
+ - Power modes table: Mode | MCU state | Active peripherals | Typical current | Wake-up sources
1378
+ - Battery life estimate (if battery-powered)
1379
+
1380
+ - **`## Safety & Reliability`** ← from `## safety_config`
1381
+ - Safety standard (if any)
1382
+ - Watchdog configuration
1383
+ - Fault handler strategy
1384
+ - Safe state definition
1385
+
1386
+ c. Write to `.viepilot/PROJECT-CONTEXT.md`:
1387
+ ```
1388
+ ## Embedded Domain
1389
+ embedded: true
1390
+ target_mcu: {mcu.family from hw_topology, or "unknown"}
1391
+ toolchain: {toolchain from embedded_toolchain, or "unknown"}
1392
+ ```
1393
+ This flag is read by `vp-auto` at runtime: scaffold-first gate selects the correct embedded toolchain stack instead of web framework scaffolding.
1394
+
1395
+ d. **Hardware sections are READ-ONLY for `vp-auto`** (same protection as ui-direction artifacts).
1396
+ `vp-auto` MUST read hardware sections before implementing driver tasks — never overwrite them.
1397
+
1398
+ ---
1399
+
1400
+ ### Step 1D-a: arch_to_ui_sync noted items → UI Pages → Component Map (ENH-069 Gap 5)
1401
+
1402
+ After reading `notes.md → ## arch_to_ui_sync[]`, for each entry with `status: noted`:
1403
+
1404
+ 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)
1405
+ 2. If **NOT covered** → add a new row to the component map:
1406
+ ```
1407
+ | Prototype | Target component | Phase | Source | Status |
1408
+ | [no page yet — arch_to_ui_sync] | {inferred component} | {inferred phase} | arch_to_ui_sync | pending |
1409
+ ```
1410
+ 3. If already covered (matching page exists in Step 1A map) → no action
1411
+
1412
+ Note: entries with `status: addressed` are already reflected in pages/*.html — skip them.
1413
+
1414
+ ---
1415
+
1416
+ ### Step 1D-b: Design Staleness Check (ENH-069 Gap 8)
1417
+
1418
+ After reading `decisions[]` (Step 1D item 2) and having pages/*.html content from Step 1A:
1419
+
1420
+ For each decision in `decisions[]` that has a UI implication (check `arch_to_ui_sync[]` table for matching `decision_id`):
1421
+ 1. Check the relevant `pages/{slug}.html` for visible representation of the decision (keyword search in HTML content)
1422
+ 2. If **NOT represented**:
1423
+ ```
1424
+ ⚠️ Design Staleness Warning:
1425
+ Decision '{title}' (ui_implication: {text}) is not reflected in {page}.html.
1426
+ The prototype may have been created before this architectural decision was made.
1427
+
1428
+ → Adding pre-implementation task to UI Pages → Component Map:
1429
+ "update {page}.html to reflect {decision}"
1430
+ Phase: same as page implementation phase
1431
+ Source: design_staleness
1432
+ ```
1433
+ 3. This pre-implementation task must appear BEFORE the page's component implementation task in ROADMAP ordering
1434
+
1435
+
1040
1436
 
1041
1437
  If `.viepilot/architect/` does **not** exist but brainstorm shows complex architecture (≥5 services/components detected):
1042
1438
  - Suggest (soft prompt — not a hard block):
@@ -1057,6 +1453,77 @@ If `.viepilot/architect/` does **not** exist but brainstorm shows complex archit
1057
1453
  - User confirmation required before proceeding.
1058
1454
  </step>
1059
1455
 
1456
+ <step name="skill_decision_gate">
1457
+ ## Step 1E — Skill Decision Gate (FEAT-020)
1458
+
1459
+ **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`).
1460
+
1461
+ **Skip condition**: If no `## skills_used` found anywhere → silently skip this step (no error, no prompt).
1462
+
1463
+ **Step — Load skills_used:**
1464
+ Read `## skills_used` from the most recent session's `notes.md`. Extract each skill entry: `id`, `capabilities`, `best_practices_applied`.
1465
+
1466
+ **Step — AUQ confirm (Claude Code adapter — REQUIRED):**
1467
+
1468
+ > **Claude Code (terminal):** Call `AskUserQuestion` tool.
1469
+ > - question: "The following skills were used in this brainstorm. Mark each as required, optional, or exclude:"
1470
+ > - For each skill: show `id` + capabilities + `best_practices_applied[]`
1471
+ > - Options per skill: `required` | `optional` | `exclude`
1472
+
1473
+ > **Text fallback (other adapters):** Present numbered list with required / optional / exclude options per skill.
1474
+
1475
+ **Step — Write `## Skills` to `PROJECT-CONTEXT.md`:**
1476
+
1477
+ Append to `.viepilot/PROJECT-CONTEXT.md`:
1478
+
1479
+ ```markdown
1480
+ ## Skills
1481
+
1482
+ | Skill | Source | Required | Phases | Rationale |
1483
+ |-------|--------|----------|--------|-----------|
1484
+ | frontend-design | npm:@vp-skills/frontend-design | required | 1, 2 | UI-Direction HTML generation — design token best practices |
1485
+ ```
1486
+
1487
+ - `required` — skill best_practices injected by vp-auto for matching phases — **no re-asking**
1488
+ - `optional` — skill context available but not auto-injected
1489
+ - `exclude` — entry omitted from PROJECT-CONTEXT.md
1490
+
1491
+ **Lock semantics**: once written, `## Skills` is the authoritative skill decision for the project. `vp-auto` reads it and **never re-prompts**.
1492
+ </step>
1493
+
1494
+ <step name="cross_reference_gate">
1495
+ ## Step 1F: Cross-Reference Gate (ENH-064)
1496
+
1497
+ Run when BOTH `architect_read_complete: true` AND `ui_direction_read_complete: true` are set in working notes:
1498
+
1499
+ 1. Read `## Coverage` from architect notes.md (or ui-direction notes.md if present).
1500
+ 2. For each feature in coverage matrix:
1501
+ - Confirm architect page was read (in `architect_read_complete` set)
1502
+ - Confirm UI screen page was read (in `ui_direction_read_complete` set)
1503
+ 3. Features with "none yet" in BOTH architect AND UI columns → apply **ENH-069 Gap 6** split:
1504
+
1505
+ **Case A — Feature IS in `phases_inventory`** (scoped for implementation):
1506
+ ```
1507
+ ⛔ Coverage gap BLOCKED: Feature "{name}" is scoped to Phase {N} but has no design coverage.
1508
+ Step 7 (ROADMAP generation) is blocked until resolved. Choose one:
1509
+ (a) Add to UI Direction now → /vp-brainstorm --ui (Recommended)
1510
+ (b) Create implementation task with explicit 'design-TBD' note
1511
+ (c) Remove from scope with reason logged in working notes
1512
+ ```
1513
+ → **Step 7 is BLOCKED** until this feature's gap is resolved and logged.
1514
+
1515
+ **Case B — Feature is NOT in `phases_inventory`** (out-of-scope):
1516
+ ```
1517
+ ⚠️ Coverage gap (out-of-scope): Feature "{name}" has no design coverage — not in phases_inventory.
1518
+ Consider adding before proceeding — or dismiss to continue.
1519
+ ```
1520
+ → Non-blocking warning (unchanged behavior).
1521
+
1522
+ 4. Record: `cross_reference_complete: true`.
1523
+
1524
+ **Skip condition**: if only one workspace is present (not both) → silently skip Step 1F (single-workspace is valid).
1525
+ </step>
1526
+
1060
1527
  <step name="generate_ai_guide">
1061
1528
  ## Step 2: Generate AI-GUIDE.md
1062
1529
 
@@ -1162,6 +1629,13 @@ Create `.viepilot/architecture/` only when at least one `.mermaid` file will be
1162
1629
  Create `.viepilot/PROJECT-CONTEXT.md` using template:
1163
1630
  `@$HOME/.cursor/viepilot/templates/project/PROJECT-CONTEXT.md`
1164
1631
 
1632
+ **Version stamp (ENH-067):** Write the following as the **very first line** of the generated file (before the `#` title):
1633
+ ```
1634
+ <!-- crystallize_version: {viepilot_semver} -->
1635
+ ```
1636
+ where `{viepilot_semver}` is resolved from `node bin/vp-tools.cjs info` → `version` field.
1637
+ This stamp is used by `--upgrade` re-scan mode (Step 0-B) to detect delta on future crystallize runs.
1638
+
1165
1639
  Extract:
1166
1640
  - Domain knowledge
1167
1641
  - Key concepts
@@ -1225,6 +1699,50 @@ From brainstorm `phases_inventory`:
1225
1699
  3. Define dependencies between phases.
1226
1700
  4. Each phase: tasks, acceptance criteria, verification commands.
1227
1701
  5. No Post-MVP / horizon block needed — all work is already in phases.
1702
+
1703
+ ---
1704
+
1705
+ ### Step 7 — UI Pages → Component Map Completeness Check (ENH-069 Gap 2)
1706
+
1707
+ After generating all phase tasks from `phases_inventory`, run a mandatory UI coverage pass:
1708
+
1709
+ For each row in the `## UI Pages → Component Map` (built in Step 1A-i and updated in Steps 1D-a, 1D-b):
1710
+ 1. Check if a task exists in the generated ROADMAP that implements the `Target component`
1711
+ 2. If **no task found**:
1712
+ - Add a new task to the appropriate phase:
1713
+ ```
1714
+ Title: "Implement {target_component} from {prototype}"
1715
+ UI Prototype Reference: {path/to/pages/{slug}.html}
1716
+ Source: UI Pages → Component Map (auto-added by crystallize)
1717
+ ```
1718
+ - For `ux-fix-required` rows: add a separate task `fix-ux-p0: {pain description}` before the component task
1719
+ - For `design_staleness` rows: add `update {page}.html to reflect {decision}` before the component task
1720
+ 3. Update the row status in the component map: `pending` → `assigned (Phase N, Task N.X)`
1721
+
1722
+ 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.
1723
+
1724
+ Finally, write the finalized `## UI Pages → Component Map` to `.viepilot/PROJECT-CONTEXT.md` so `vp-auto` can read it at runtime.
1725
+
1726
+ ### Step 7 — Embedded Domain: Skip UI Coverage Gate + Apply Hardware Coverage Check (ENH-071)
1727
+
1728
+ If `PROJECT-CONTEXT.md` contains `## Embedded Domain` with `embedded: true`:
1729
+
1730
+ 1. **Skip** the UI Pages → Component Map Completeness Check above (no web UI components expected).
1731
+
1732
+ 2. **Apply Hardware Coverage Check instead** (non-blocking warning):
1733
+
1734
+ For each peripheral in `hw_topology.peripherals[]` and `hw_topology.external_ics[]`:
1735
+ - Check if a driver task exists in the generated ROADMAP (Phase 2: Driver Layer or equivalent)
1736
+ - If **no driver task found** for peripheral `{name}`:
1737
+ ```
1738
+ ⚠️ Hardware Coverage: no driver task found for peripheral "{name}" ({interface})
1739
+ Suggestion: Add "Implement {name} driver ({interface})" to Phase 2 (Driver Layer)
1740
+ ```
1741
+ - Warning is **non-blocking** — ROADMAP generation continues. User can dismiss or add the task.
1742
+
1743
+ 3. **Add Phase 1: Board Bring-Up task** if not already in ROADMAP and `embedded: true`:
1744
+ - Automatically include "Board Bring-Up verification" as Phase 1 Task 1 (clock config, GPIO init, UART console confirm, LED blink)
1745
+ - Only added if no equivalent task already exists.
1228
1746
  </step>
1229
1747
 
1230
1748
  <step name="generate_schemas">
@@ -1261,7 +1779,14 @@ Initialize:
1261
1779
  - Version info (0.1.0-alpha)
1262
1780
  - Next action
1263
1781
 
1264
- Create empty `.viepilot/HANDOFF.json`
1782
+ Create `.viepilot/HANDOFF.json` with initial fields including:
1783
+ ```json
1784
+ {
1785
+ "crystallize_version": "{viepilot_semver}",
1786
+ "crystallized_at": "{ISO-8601 timestamp}"
1787
+ }
1788
+ ```
1789
+ `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
1790
  </step>
1266
1791
 
1267
1792
  <step name="generate_phase_dirs">