viepilot 1.9.11 → 2.1.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 (60) hide show
  1. package/CHANGELOG.md +175 -2
  2. package/README.md +3 -3
  3. package/bin/viepilot.cjs +7 -5
  4. package/bin/vp-tools.cjs +193 -0
  5. package/dev-install.sh +34 -13
  6. package/docs/user/features/architect-design-mode.md +170 -0
  7. package/docs/user/features/hooks.md +93 -0
  8. package/docs/user/features/ui-direction.md +79 -3
  9. package/lib/adapters/claude-code.cjs +42 -0
  10. package/lib/adapters/cursor.cjs +31 -0
  11. package/lib/adapters/index.cjs +26 -0
  12. package/lib/hooks/brainstorm-staleness.cjs +231 -0
  13. package/lib/viepilot-config.cjs +103 -0
  14. package/lib/viepilot-install.cjs +128 -153
  15. package/package.json +1 -1
  16. package/skills/vp-audit/SKILL.md +21 -21
  17. package/skills/vp-auto/SKILL.md +21 -7
  18. package/skills/vp-brainstorm/SKILL.md +46 -35
  19. package/skills/vp-crystallize/SKILL.md +37 -25
  20. package/skills/vp-debug/SKILL.md +2 -2
  21. package/skills/vp-docs/SKILL.md +7 -7
  22. package/skills/vp-evolve/SKILL.md +25 -12
  23. package/skills/vp-info/SKILL.md +23 -23
  24. package/skills/vp-pause/SKILL.md +5 -5
  25. package/skills/vp-request/SKILL.md +12 -12
  26. package/skills/vp-resume/SKILL.md +4 -4
  27. package/skills/vp-rollback/SKILL.md +3 -3
  28. package/skills/vp-status/SKILL.md +4 -4
  29. package/skills/vp-task/SKILL.md +3 -3
  30. package/skills/vp-ui-components/SKILL.md +12 -12
  31. package/skills/vp-update/SKILL.md +17 -17
  32. package/templates/architect/apis.html +159 -0
  33. package/templates/architect/architect-actions.js +217 -0
  34. package/templates/architect/architecture.html +160 -0
  35. package/templates/architect/data-flow.html +109 -0
  36. package/templates/architect/decisions.html +96 -0
  37. package/templates/architect/deployment.html +184 -0
  38. package/templates/architect/erd.html +154 -0
  39. package/templates/architect/feature-map.html +113 -0
  40. package/templates/architect/index.html +108 -0
  41. package/templates/architect/sequence-diagram.html +133 -0
  42. package/templates/architect/style.css +365 -0
  43. package/templates/architect/tech-notes.html +89 -0
  44. package/templates/architect/tech-stack.html +114 -0
  45. package/templates/architect/user-use-cases.html +154 -0
  46. package/templates/project/AI-GUIDE.md +53 -54
  47. package/templates/project/PROJECT-CONTEXT.md +7 -11
  48. package/templates/project/README.md +43 -0
  49. package/templates/project/ROADMAP.md +1 -27
  50. package/workflows/audit.md +3 -3
  51. package/workflows/autonomous.md +38 -5
  52. package/workflows/brainstorm.md +575 -191
  53. package/workflows/crystallize.md +168 -58
  54. package/workflows/debug.md +9 -9
  55. package/workflows/documentation.md +5 -5
  56. package/workflows/evolve.md +44 -12
  57. package/workflows/pause-work.md +2 -2
  58. package/workflows/request.md +8 -8
  59. package/workflows/resume-work.md +1 -1
  60. package/workflows/rollback.md +1 -1
@@ -1,6 +1,6 @@
1
1
  <purpose>
2
- Interactive brainstorm session để thu thập ý tưởng, requirements, quyết định cho dự án.
3
- Cho phép research ngay trong cùng phiên brainstorm khi cần.
2
+ Interactive brainstorm session to gather ideas, requirements, and decisions for the project.
3
+ Allows research inline within the same brainstorm session when needed.
4
4
  </purpose>
5
5
 
6
6
  ## ViePilot Skill Scope Policy (BUG-004)
@@ -12,6 +12,17 @@ Cho phép research ngay trong cùng phiên brainstorm khi cần.
12
12
 
13
13
  <process>
14
14
 
15
+ <step name="detect_session_language">
16
+ ## 0. Detect Session Language (ENH-032)
17
+
18
+ Read `~/.viepilot/config.json` → set `BRAINSTORM_LANG`:
19
+ - `BRAINSTORM_LANG` = `language.document` from config (default: `en`)
20
+
21
+ Use `BRAINSTORM_LANG` for brainstorm file storage (filenames, generated content).
22
+ If the user writes in a different language during the session, that takes precedence over the config value.
23
+ If `~/.viepilot/config.json` is absent, default to `en` — do not fail.
24
+ </step>
25
+
15
26
  <step name="detect_sessions">
16
27
  ## 1. Detect Previous Sessions
17
28
 
@@ -27,38 +38,38 @@ Parse results to get list of existing sessions.
27
38
 
28
39
  **If previous sessions exist:**
29
40
  ```
30
- Tôi tìm thấy các phiên brainstorm trước đó:
41
+ I found previous brainstorm sessions:
31
42
  {list sessions with dates}
32
43
 
33
- Bạn muốn:
34
- 1. Tiếp tục phiên gần nhất
35
- 2. Xem lại một phiên cụ thể
36
- 3. Tạo mới phiên brainstorm
44
+ What would you like to do?
45
+ 1. Continue the most recent session
46
+ 2. Review a specific session
47
+ 3. Create a new brainstorm session
37
48
  ```
38
49
 
39
50
  **If no sessions:**
40
- Tự động tạo phiên mới.
51
+ Automatically create a new session.
41
52
  </step>
42
53
 
43
54
  <step name="load_context">
44
- ## 3. Load Context (nếu tiếp tục)
45
-
46
- Nếu user chọn tiếp tục:
47
- 1. Đọc file phiên trước đó
48
- 2. Tóm tắt nội dung đã thảo luận
49
- 3. Xác định các open questions / action items còn lại
50
- 4. Tiếp tục từ điểm dừng
51
- 5. Nếu session đã section **`## Product horizon`**: tóm tắt nhanh MVP / Post-MVP / Future hiện có; mọi cập nhật sau đó phải **merge** vào section đó (không xóa im lặng, không làm mất tier tags) trừ khi user chủ động yêu cầu thu hẹp/mở rộng scope.
55
+ ## 3. Load Context (if continuing)
56
+
57
+ If the user chooses to continue:
58
+ 1. Read the previous session file
59
+ 2. Summarize content already discussed
60
+ 3. Identify remaining open questions / action items
61
+ 4. Continue from the stopping point
62
+ 5. If the session already has a **`## Phases`** section: briefly summarize existing phases; all subsequent updates must **merge** into that section (no silent deletion) unless the user explicitly requests narrowing/expanding scope.
52
63
  </step>
53
64
 
54
65
  <step name="brainstorm_mode">
55
66
  ## 4. Brainstorm Mode
56
67
 
57
68
  ### Topics Template
58
- Gợi ý các topics để brainstorm:
69
+ Suggested topics to brainstorm:
59
70
 
60
71
  1. **Domain Analysis**
61
- - Mục tiêu dự án
72
+ - Project goals
62
73
  - User personas
63
74
  - Core use cases
64
75
 
@@ -88,143 +99,401 @@ Gợi ý các topics để brainstorm:
88
99
  - Monitoring
89
100
  - Scaling
90
101
 
91
- 6. **Product horizon (MVP vs Post-MVP vs Future)** — **bắt buộc duy trì trong session file** khi user thảo luận bất kỳ tính năng / milestone nào:
92
- - **Mục tiêu**: tách rõ phạm vi ship đầu tiên với tầm nhìn sau MVP để `/vp-crystallize` không “mất” ý tưởng dài hạn.
93
- - **Quy ước tag** (đặt ở cuối dòng bullet): `(MVP)` | `(Post-MVP)` | `(Future)`.
94
- - **Non-goals for MVP**: những gì cố tình *không* làm ở bản đầu (tránh hiểu nhầm là quên).
95
- - **Deferred capabilities**: tính năng đã thống nhất nhưng **lùi sau MVP** — ghi rõ để crystallize map vào roadmap horizon.
96
- - Nếu sản phẩm **single-release** (không có post-MVP): ghi một dòng explicit trong session, ví dụ: `**Scope**: single-release only — no deferred epics.`
102
+ 6. **Phase assignment (ENH-030):** during brainstorm, each feature/capability is assigned to a specific **phase**Phase 1, Phase 2, Phase 3... Do not use MVP/Post-MVP/Future tiers. If the user has not stated a phase, ask: “Which phase would you like to assign this feature to?”
97
103
 
98
104
  ### Interactive Q&A
99
- Cho mỗi topic:
100
- 1. Đặt câu hỏi cụ thể
101
- 2. Đợi user trả lời
102
- 3. Tổng hợp đặt follow-up questions
103
- 4. Đề xuất alternatives nếu cần
104
- 5. Ghi nhận decisions
105
-
106
- ### Landing Page Deep-Dive (kích hoạt theo ngữ cảnh)
107
- Nếu user brainstorm về landing page / homepage / marketing page:
108
-
109
- 1. Hỏi thêm để chốt bố cục:
110
- - Goal chính của landing page? (signup, booking demo, download, contact)
111
- - Audience chính?
112
- - Tone visual? (minimal, modern, bold, enterprise, playful)
113
- - CTA chính CTA phụ?
114
- 2. Đưa menu bố cục để user chọn:
105
+ For each topic:
106
+ 1. Ask specific questions
107
+ 2. Wait for user response
108
+ 3. Synthesize and ask follow-up questions
109
+ 4. Suggest alternatives if needed
110
+ 5. Record decisions
111
+
112
+ ### Landing Page Deep-Dive (activated contextually)
113
+ If the user is brainstorming a landing page / homepage / marketing page:
114
+
115
+ 1. Ask follow-up questions to finalize the layout:
116
+ - Main goal of the landing page? (signup, booking demo, download, contact)
117
+ - Primary audience?
118
+ - Visual tone? (minimal, modern, bold, enterprise, playful)
119
+ - Primary CTA and secondary CTA?
120
+ 2. Present a layout menu for the user to choose from:
115
121
  - Layout A: Hero centric + trust logos + features + CTA
116
122
  - Layout B: Problem/Solution + social proof + pricing + FAQ
117
123
  - Layout C: Product storytelling + screenshots + testimonials + final CTA
118
124
  - Layout D: SaaS conversion + integrations + comparison + onboarding steps
119
- 3. Tham khảo `https://21st.dev` để đề xuất section/components phù hợp với layout đã chọn.
120
- 4. Ghi trong session:
121
- - Layout user chọn
122
- - Component candidates từ 21st.dev
123
- - do chọn theo objective + audience
125
+ 3. Reference `https://21st.dev` to suggest sections/components suited to the chosen layout.
126
+ 4. Record clearly in the session:
127
+ - Layout the user chose
128
+ - Component candidates from 21st.dev
129
+ - Reason for choice based on objective + audience
124
130
 
125
131
  ### In-session Research Mode
126
- User thể yêu cầu research ngay trong brainstorm (không cần đổi skill):
127
- - Trigger phrases: "research cái này", "bạn research giúp", "cần research", "hãy tìm best practice"
128
- - Khi trigger:
129
- 1. Xác định scope research (1-3 câu)
130
- 2. Thu thập nhanh từ nguồn phù hợp (docs chính thức, reference sites, patterns)
131
- 3. Trả về tóm tắt ngắn: findings, trade-offs, recommendation
132
- 4. Quay lại topic brainstorm hiện tại với quyết định đề xuất
132
+ User can request research inline during brainstorm (no skill switch needed):
133
+ - Trigger phrases: "research this", "can you research", "need to research", "find best practice"
134
+ - When triggered:
135
+ 1. Define research scope (1-3 sentences)
136
+ 2. Quickly gather from appropriate sources (official docs, reference sites, patterns)
137
+ 3. Return a short summary: findings, trade-offs, recommendation
138
+ 4. Return to the current brainstorm topic with a proposed decision
133
139
 
134
- Nếu assistant nhận thấy topic độ hồ cao hoặc rủi ro quyết định sai, assistant nên chủ động đề xuất:
135
- `Mục này nên research nhanh trước khi chốt, bạn muốn mình research luôn trong phiên này không?`
140
+ If the assistant notices a topic has high ambiguity or risk of a wrong decision, the assistant should proactively suggest:
141
+ `This item should be researched quickly before locking in would you like me to research it now in this session?`
136
142
 
137
143
  ### UI Direction Mode (design-in-the-loop; FEAT-002 + FEAT-007)
138
- Nếu user đang brainstorm cho dự án UI/UX hoặc yêu cầu thiết kế trực quan:
144
+ If the user is brainstorming a project with UI/UX or requests a visual design:
145
+
146
+ **Layout — choose one:**
147
+
148
+ - **Legacy (single screen):** `.viepilot/ui-direction/{session-id}/index.html` + `style.css` + `notes.md`.
149
+ - **Multi-page (multiple screens):** same session directory, add `pages/{slug}.html` for each page; `index.html` is the **hub** (links to every page). `style.css` is shared.
150
+
151
+ **General rules**
152
+
153
+ 1. Create a direction workspace for the current session (minimum `style.css` + `notes.md`; HTML per chosen layout).
154
+ 2. Each time the user changes a requirement/layout/component:
155
+ - Update HTML/CSS direction directly
156
+ - Record decision + rationale in `notes.md` (single source of truth for design intent)
157
+
158
+ **Required hook (multi-page only)**
159
+
160
+ When the `pages/` directory exists or any `pages/*.html` is added / renamed / removed:
161
+
162
+ - Update the **hub** `index.html` (nav / list of links to all remaining pages).
163
+ - Immediately update the **`## Pages inventory`** section in `notes.md` (table: Slug | File | Title | Purpose | Key sections | Nav to) — must match 100% of the current `pages/*.html` file set.
164
+ - Do not end a topic / do not consider the UI session “synced” if the inventory diverges from files on disk.
139
165
 
140
- **Layout chọn một:**
166
+ 3. If the user sends references/components (including 21st.dev prompts/links), record clearly:
167
+ - reference source
168
+ - the UI area it applies to (page slug if multi-page)
169
+ - adjustments according to product objectives
170
+ 4. Keep the prototype at a directional description level; do not force production-ready code at the brainstorm stage.
141
171
 
142
- - **Legacy (một màn):** `.viepilot/ui-direction/{session-id}/index.html` + `style.css` + `notes.md`.
143
- - **Multi-page (nhiều màn):** cùng thư mục session, thêm `pages/{slug}.html` cho từng page; `index.html` là **hub** (liên kết tới mọi page). `style.css` shared.
172
+ ### Architect Design Mode (FEAT-011)
144
173
 
145
- **Quy tắc chung**
174
+ Brainstorm system architecture with live HTML generation — a visual workspace for the user to review, edit, and present before running `/vp-crystallize`.
146
175
 
147
- 1. Tạo workspace direction cho phiên hiện tại (tối thiểu `style.css` + `notes.md`; HTML theo layout đã chọn).
148
- 2. Mỗi lần user đổi requirement/layout/component:
149
- - Cập nhật trực tiếp HTML/CSS direction
150
- - Ghi decision + rationale vào `notes.md` (single source of truth cho design intent)
176
+ #### Activation
151
177
 
152
- **Hook bắt buộc (multi-page only)**
178
+ Activated when **any one** of the following conditions is met:
179
+
180
+ 1. **Explicit flag**: user uses `/vp-brainstorm --architect`
181
+ 2. **Auto-activate heuristic** (see below)
182
+ 3. **Architecture topic + complexity threshold**: user selects "Architecture" topic in the brainstorm menu AND (service count ≥3 OR ≥1 tech stack suggestion is made)
183
+
184
+ **Auto-activate heuristic**: during brainstorm, track:
185
+ - **Component/service mentions**: names matching the pattern `{capitalized} Service|API|Module|Layer|Server|Database` (e.g., "UserService", "Payment API", "Data Layer")
186
+ - **Stack mentions**: any keyword from the known stack list (React, Node.js, PostgreSQL, Redis, Kafka, AWS, Docker, etc.)
187
+
188
+ When **≥3 components** OR **≥1 stack suggestion** is mentioned → prompt:
189
+
190
+ ```
191
+ 🏗️ I noticed you are designing an architecture with multiple components.
192
+ Activate Architect Design Mode so I can create an HTML visualization?
193
+ 1. Yes — create workspace and generate initial HTML
194
+ 2. No — continue text-only
195
+ ```
196
+
197
+ - **Option 1 (Yes)**: create workspace (directory + files), generate initial HTML from content already discussed, continue in Architect Mode.
198
+ - **Option 2 (No)**: continue text-only brainstorm; heuristic will not prompt again in this session.
199
+
200
+ #### Workspace layout
201
+
202
+ ```
203
+ .viepilot/architect/{session-id}/
204
+ index.html # Hub: sidebar nav + tabs → to all sections
205
+ architecture.html # System diagram (graph TD / C4Context) + component descriptions
206
+ data-flow.html # High-level service/event flows (sequenceDiagram / flowchart LR)
207
+ decisions.html # ADR log: Date | Decision | Options | Chosen | Rationale | Status
208
+ tech-stack.html # Layer-by-layer: frontend, backend, infra, data, DevOps
209
+ tech-notes.html # 3 columns: Assumptions | Risks | Open Questions
210
+ feature-map.html # Features with tags: layer, phase, priority, status
211
+ erd.html # Database ERD: entities, attributes, relationships (erDiagram) — ENH-027
212
+ user-use-cases.html # User Stories / Use Cases / Actors (flowchart TD) — ENH-028
213
+ sequence-diagram.html # Per-scenario sequences (sequenceDiagram) — ENH-029
214
+ deployment.html # Infra, environments, CI/CD pipeline — ENH-029
215
+ apis.html # Service API listing & design decisions — ENH-029
216
+ style.css # Shared: dark/light CSS vars, .updated highlight, Mermaid container, responsive nav
217
+ notes.md # Machine-readable YAML (see schema below)
218
+ ```
153
219
 
154
- Khi thư mục `pages/` tồn tại hoặc bất kỳ `pages/*.html` nào được thêm / đổi tên / xóa:
220
+ **Mermaid.js** all diagrams use: `<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js">`
221
+ - `architecture.html` → `graph TD` or `C4Context`
222
+ - `data-flow.html` → `sequenceDiagram` or `flowchart LR`
223
+ - `feature-map.html` → `mindmap` or `quadrantChart`
224
+ - `erd.html` → `erDiagram` (entities, attributes, relationships)
225
+ - `user-use-cases.html` → `flowchart TD` (actors → use case bubbles)
226
+ - `sequence-diagram.html` → `sequenceDiagram` (per-scenario step-by-step)
227
+ - `deployment.html` → `graph TD` (infra) + `flowchart LR` (CI/CD pipeline)
228
+ - `apis.html` → no diagram; endpoint tables with HTTP method badges
155
229
 
156
- - Cập nhật **hub** `index.html` (nav / danh sách link tới mọi page còn lại).
157
- - Cập nhật ngay section **`## Pages inventory`** trong `notes.md` (bảng: Slug | File | Title | Purpose | Key sections | Nav to) — phải khớp 100% tập file `pages/*.html` hiện có.
158
- - Không kết thúc topic / không coi session UI đã “sync” nếu inventory lệch với file trên disk.
230
+ #### Page Boundary Rules (ENH-029)
159
231
 
160
- 3. Nếu user gửi references/components (bao gồm 21st.dev prompt/link), ghi rõ:
161
- - nguồn tham chiếu
162
- - phần UI áp dụng (page slug nếu multi-page)
163
- - điều chỉnh theo mục tiêu sản phẩm
164
- 4. Giữ prototype mức tả định hướng (directional), không ép build production-ready code ở bước brainstorm.
232
+ | Page | Use when... |
233
+ |------|------------|
234
+ | `data-flow.html` | High-level service/event flows which services talk to which |
235
+ | `sequence-diagram.html` | Per-scenario step-by-step interactions with exact message order |
236
+ | `architecture.html` | Component structure + C4 system context + external integrations |
237
+ | `deployment.html` | Infrastructure, environments, ops concerns, CI/CD pipeline |
238
+ | `apis.html` | API endpoint design, HTTP methods, request/response contracts |
239
+
240
+ #### Sequence trigger keywords (ENH-029)
241
+ When the user mentions: `scenario`, `step by step`, `login flow`, `checkout flow`, `detailed interaction`, `sequence`, `interaction diagram` → update `sequence-diagram.html` + update `notes.md ## sequences` section.
242
+
243
+ #### Deployment trigger keywords (ENH-029)
244
+ When the user mentions: `deploy`, `deployment`, `infrastructure`, `infra`, `environment`, `staging`, `production`, `prod`, `AWS`, `GCP`, `Azure`, `Docker`, `Kubernetes`, `k8s`, `CI/CD`, `pipeline`, `server`, `hosting`, `cloud` → update `deployment.html` + update `notes.md ## deployment` section.
245
+
246
+ #### APIs trigger keywords (ENH-029)
247
+ When the user mentions: `endpoint`, `API`, `REST`, `GraphQL`, `gRPC`, `route`, `HTTP`, `POST`, `GET`, `PUT`, `DELETE`, `PATCH`, `request`, `response`, `payload`, `auth header` → update `apis.html` + update `notes.md ## apis` section.
248
+
249
+ #### ERD trigger keywords (ENH-027)
250
+ When the user mentions any keyword: `database`, `entity`, `table`, `schema`, `relation`, `relationship`, `foreign key`, `primary key`, `ERD`, `data model`, `normalization` → update `erd.html` + update `notes.md ## erd` section.
251
+
252
+ #### Use Case trigger keywords (ENH-028)
253
+ When the user mentions: `user story`, `use case`, `actor`, `persona`, `as a user`, `user flow`, `workflow`, `journey`, `role`, `permission` → update `user-use-cases.html` + update `notes.md ## use_cases` section.
254
+
255
+ #### Dialogue cadence
256
+
257
+ 1. After each **major decision** (tech stack, service boundary, data model) → update the related HTML section + update `notes.md`.
258
+ 2. When the user **changes a decision** → **incremental update**: only edit the related section; keep all other sections unchanged. Add `data-updated="true"` attribute + class `.updated` CSS highlight (yellow left border + "updated" badge) to the changed element.
259
+ 3. **`/review-arch`** command → ViePilot outputs a summary table of all `decisions` (from `notes.md`) + list of `open_questions` with status; ask the user to confirm before continuing.
260
+
261
+ #### Incremental update rule
262
+
263
+ When a decision changes:
264
+ - Identify the **related HTML file** (e.g., tech stack change → only edit `tech-stack.html` + `architecture.html`).
265
+ - Do **not** regenerate the entire workspace.
266
+ - Add `data-updated="true"` to the changed `<section>` or `<tr>`.
267
+ - Update `notes.md` YAML (`updated` date + corresponding entry).
268
+ - Preserve `decisions.html` history — only add new rows or update the `status` field (do not delete history).
269
+
270
+ #### Architect Item Actions (ENH-033)
271
+
272
+ Each item in the Architect HTML workspace has a stable ID in the format `[ARCH:{page-slug}:{item-id}]`
273
+ (e.g., `[ARCH:decisions:D1]`, `[ARCH:erd:E2]`, `[ARCH:apis:A4]`).
274
+
275
+ Two buttons appear on hover next to each item in the HTML:
276
+ - **✅ Approve** — copies: `[ARCH:{slug}:{id}] APPROVE — "{title}" on {slug} page. No changes needed.`
277
+ - **✏️ Edit** — copies: `[ARCH:{slug}:{id}] EDIT — "{title}" on {slug} page. Current: "{excerpt}". What should I change?`
278
+
279
+ **When you receive an APPROVE prompt:**
280
+ - Confirm the item is accepted as-is.
281
+ - Do NOT touch any other item or page.
282
+ - Ask if the user wants to continue reviewing other items.
283
+
284
+ **When you receive an EDIT prompt:**
285
+ - Acknowledge the item by its full ID (`[ARCH:{slug}:{id}]`).
286
+ - State what the current content is.
287
+ - Ask the user what they want to change.
288
+ - Apply the change only to that specific item on that specific page.
289
+
290
+ **ISOLATION RULE — CRITICAL:**
291
+ Each action is **strictly scoped** to the named page and item.
292
+
293
+ - Approving `[ARCH:architecture:C2]` does **NOT** approve any item in `erd`, `apis`, `decisions`, or any other page.
294
+ - Editing `[ARCH:decisions:D1]` does **NOT** trigger updates to `architecture`, `erd`, or any other page unless the user explicitly asks for cross-page follow-up.
295
+ - **Never infer or cascade approval/edit across pages.** Each page is an independent artifact namespace.
296
+ - Cross-page impacts (e.g., "this decision affects the ERD") must come from a **separate, explicit** user prompt after the first action is complete.
297
+
298
+ #### notes.md YAML schema
299
+
300
+ ```yaml
301
+ ---
302
+ session_id: {id}
303
+ project: {name}
304
+ created: {date}
305
+ updated: {date}
306
+ ---
307
+ ## decisions
308
+ - id: D001
309
+ topic: Database choice
310
+ options: [PostgreSQL, MongoDB, DynamoDB]
311
+ chosen: PostgreSQL
312
+ rationale: ACID compliance needed for financial data
313
+ status: decided # decided | open | deferred
314
+
315
+ ## open_questions
316
+ - id: Q001
317
+ question: Caching layer Redis hay Memcached?
318
+ context: High read traffic expected
319
+ due: before crystallize
320
+
321
+ ## tech_stack
322
+ frontend: React + TypeScript
323
+ backend: Node.js + Express
324
+ database: PostgreSQL
325
+ infra: AWS ECS + RDS
326
+ devops: GitHub Actions + Terraform
327
+
328
+ ## erd
329
+ entities:
330
+ - name: User
331
+ attributes: [id, email, name, created_at]
332
+ primary_key: id
333
+ - name: Order
334
+ attributes: [id, user_id, total, status]
335
+ primary_key: id
336
+ foreign_keys:
337
+ - user_id → User.id
338
+ relationships:
339
+ - from: User
340
+ to: Order
341
+ type: one-to-many
342
+ label: places
343
+
344
+ ## use_cases
345
+ actors:
346
+ - name: Guest
347
+ role: Unauthenticated visitor
348
+ - name: User
349
+ role: Registered member
350
+ user_stories:
351
+ - id: US001
352
+ as_a: User
353
+ i_want: to register an account
354
+ so_that: I can access premium features
355
+ priority: must-have
356
+ status: open
357
+
358
+ ## apis
359
+ style: REST # REST | GraphQL | gRPC | WebSocket
360
+ services:
361
+ - name: "{Service 1}"
362
+ endpoints:
363
+ - method: GET
364
+ path: /api/resource
365
+ auth: true
366
+ notes: "{notes}"
367
+ - method: POST
368
+ path: /api/resource
369
+ auth: true
370
+ notes: "{notes}"
371
+ design_decisions:
372
+ - decision: Authentication
373
+ choice: "{JWT / Session / OAuth2 / API Key}"
374
+ rationale: "{rationale}"
375
+
376
+ ## architect_sync
377
+ - synced_at: "{ISO datetime}"
378
+ source_session: "{ui-direction session-id}"
379
+ trigger: "end-of-session | /sync-arch"
380
+ changes:
381
+ - page: "{slug}"
382
+ item_id: "{data-arch-id}"
383
+ action: "updated | added"
384
+ change: "{brief description, ≤80 chars}"
385
+ ```
386
+
387
+ ### Background UI Extraction (silent mode) — ENH-026
388
+
389
+ Runs **silently** in every brainstorm session (no `--ui` flag required). Does not interrupt the main conversation.
390
+
391
+ #### Signal keywords
392
+ When the assistant detects any keyword (case-insensitive, Vietnamese or English) in the user's message or session summary:
393
+
394
+ > `màu`, `màu sắc`, `color`, `layout`, `màn hình`, `screen`, `page`, `trang`, `button`, `nút`, `form`, `biểu mẫu`, `mobile`, `responsive`, `giao diện`, `UI`, `UX`, `design`, `dashboard`, `sidebar`, `header`, `footer`, `modal`, `popup`, `icon`, `theme`, `typography`, `font`, `spacing`, `grid`, `card`, `component`, `hero`, `banner`
395
+
396
+ #### Threshold & accumulation rule
397
+ - **Count unique keyword occurrences** during the ongoing session.
398
+ - When **≥3 unique signal occurrences** are reached: begin **silent accumulation** — record UI ideas into a `ui_idea_buffer[]` in the session context.
399
+ - **Non-blocking**: does not interrupt the main conversation, does not ask for user confirmation immediately.
400
+ - Each buffer entry records: keyword trigger, utterance context (short summary ≤20 words).
401
+
402
+ #### Surface triggers (when to ask the user)
403
+ Display a confirmation dialogue when any of the following conditions occur:
404
+ - (a) **Topic ends** — user types `/topic` to switch to a new topic or says "next"
405
+ - (b) **User types `/save` or `/review`**
406
+ - (c) **≥5 signals accumulated** in the buffer
407
+
408
+ #### Confirmation dialogue template
409
+ ```
410
+ 💡 I detected some UI ideas in this session:
411
+ - {idea 1 extracted from buffer}
412
+ - {idea 2 extracted from buffer}
413
+ ...
414
+
415
+ What would you like to do?
416
+ 1. Save to ui-direction/notes.md (background extraction)
417
+ 2. Save + activate UI Direction Mode to generate HTML direction
418
+ 3. Discard and continue brainstorming
419
+ ```
420
+
421
+ **Option 1**: Write `## Background extracted ideas` to `.viepilot/ui-direction/{session-id}/notes.md` (create file/directory if not yet present). Clear buffer. Continue.
422
+
423
+ **Option 2**: Write to notes.md (same as Option 1) **+ fully trigger the `### UI Direction Mode` workflow** (create `index.html`, `style.css`). Clear buffer. Continue in UI Direction Mode.
424
+
425
+ **Option 3**: Keep buffer unchanged (do not clear, do not write). Continue brainstorm. Re-surface at the next trigger.
426
+
427
+ #### Auto-write path (Option 1 + 2)
428
+ ```bash
429
+ mkdir -p .viepilot/ui-direction/{session-id}
430
+ # Append to notes.md (create if missing):
431
+ # ## Background extracted ideas
432
+ # - {idea from buffer, with source context}
433
+ ```
165
434
 
166
435
  ### UI Direction — UX walkthrough & upgrade (FEAT-010)
167
436
 
168
- Khi đang trong **`/vp-brainstorm --ui`** hoặc đã `.viepilot/ui-direction/{session-id}/` cho phiên hiện tại, user thể gọi:
437
+ When inside **`/vp-brainstorm --ui`** or a `.viepilot/ui-direction/{session-id}/` already exists for the current session, the user can invoke:
169
438
 
170
- - **`/research-ui`** — chạy đủ pipeline dưới đây
171
- - **`/research ui`** — **alias** của `/research-ui` (khoảng trắng sau `research`; không trùng `/research {chủ đề tự do}`)
439
+ - **`/research-ui`** — runs the full pipeline below
440
+ - **`/research ui`** — **alias** of `/research-ui` (space after `research`; does not conflict with `/research {free topic}`)
172
441
 
173
- User thể kèm ngữ cảnh một dòng (vd. tên sản phẩm **Trips**, persona, flow ưu tiên) — nhập vào cùng tin nhắn lệnh.
442
+ The user can include one line of context (e.g., product name **Trips**, persona, priority flow) — entered in the same message as the command.
174
443
 
175
- Áp dụng **các phase tuần tự** (assistant không bỏ qua phase trừ khi user explicitchỉ phase 1”):
444
+ Apply **the phases sequentially** (assistant does not skip a phase unless the user explicitly says “phase 1 only”):
176
445
 
177
- #### Phase 1 — phỏng người dùng cuối
446
+ #### Phase 1 — Simulate end user
178
447
 
179
- 1. Đóng vai **người dùng cuối** đang dùng prototype (lấy tên app / màn chính từ `notes.md`, HTML, hoặc prompt user).
180
- 2. Liệt **3–8 scenario** cụ thể (vd. lần đầu mở app, hoàn tất task chính, lỗi edge case) — ưu tiên đúng page nếu multi-page (`pages/*.html`).
181
- 3. Với từng scenario: tả **hành vi** (đọc/click tưởng tượng trên UI hiện tại) → ghi **pain**: hồ, thiếu phản hồi, quá nhiều bước, không khớp mental model, khả năng mobile/a11y, v.v.
182
- 4. Tổng hợp **Voice of pseudo-user** (bullet + mức độ **low / medium / high**).
183
- 5. **Stress nội dung & tràn layout (content stress pass)** — *bắt buộc trong mỗi lần `/research-ui`*: sau happy/edge hành vi, phỏng **dữ liệu biên** trên từng màn/page quan trọng (hoặc toàn hub nếu single-screen). Tối thiểu xét **3–6 loại** sau (chọn đúng ngữ cảnh sản phẩm; bỏ qua mục không áp dụng nhưng **ghi “N/A + lý do”**):
184
- - **Copy dài**: tiêu đề, subtitle, CTA, placeholder ô nhập, tooltip, breadcrumb, tên địa điểm/người dài (Unicode), email/URL dài.
185
- - **Khối lượng**: danh sách/grid **nhiều phần tử**, bảng nhiều cột/hàng, thẻ/tag/badge chồng, notification stack, lịch nhiều sự kiện.
186
- - **Số & định dạng**: số tiền rất lớn/nhỏ, đơn vị dài, múi giờ/ngôn ngữ (nếu product ).
187
- - **Trạng thái lỗi / validation**: message lỗi dài, nhiều lỗi cùng lúc, inline + banner.
188
- - **Empty vs cực đầy**: không dữ liệu vs max items; skeleton vs flash of long content.
189
- - **Viewport**: cùng stress trên **hẹp** (mobile) **rộng** (desktop) nếu prototype nhắm đa kích thước.
448
+ 1. Role-play as the **end user** using the prototype (get app name / main screen from `notes.md`, HTML, or user prompt).
449
+ 2. List **3–8 specific scenarios** (e.g., first app launch, completing the main task, edge case errors) — prioritize the correct page if multi-page (`pages/*.html`).
450
+ 3. For each scenario: describe **behavior** (imagined reading/clicking on the current UI) → record **pain**: ambiguity, missing feedback, too many steps, mismatch with mental model, mobile/a11y concerns, etc.
451
+ 4. Synthesize **Voice of pseudo-user** (bullets + severity **low / medium / high**).
452
+ 5. **Content stress & layout overflow pass (content stress pass)** — *required in every `/research-ui` run*: after happy/edge behavior, simulate **boundary data** on each key screen/page (or the full hub if single-screen). Consider at minimum **3–6 of the following categories** (choose those relevant to product context; skip inapplicable ones but **note “N/A + reason”**):
453
+ - **Long copy**: headline, subtitle, CTA, input placeholder, tooltip, breadcrumb, long place/person names (Unicode), long emails/URLs.
454
+ - **Volume**: lists/grids with **many elements**, multi-column/row tables, stacked tags/badges, notification stacks, calendars with many events.
455
+ - **Numbers & formats**: very large/small monetary values, long units, time zones/locales (if the product supports them).
456
+ - **Error / validation states**: long error messages, multiple simultaneous errors, inline + banner.
457
+ - **Empty vs fully packed**: no data vs max items; skeleton vs flash of long content.
458
+ - **Viewport**: same stress on **narrow** (mobile) and **wide** (desktop) if the prototype targets multiple screen sizes.
190
459
 
191
- **Stress recipes theo archetype (ENH-020)** — sau khi áp checklist trên, **chốt 1–2 archetype** khớp sản phẩm (từ `notes.md` / HTML / user) áp **ít nhất hai recipe** trong mỗi hàng đã chọn ( thể diễn đạt lại bằng ngôn ngữ session; **ghi archetype** trong Stress findings):
460
+ **Stress recipes by archetype (ENH-020)** — after applying the checklist above, **lock in 1–2 archetypes** that match the product (from `notes.md` / HTML / user) and apply **at least two recipes** from each selected row (may be rephrased in the session language; **note the archetype** in Stress findings):
192
461
 
193
- | Archetype | Ưu tiên stress (recipe gợi ý) | Ghi chú |
194
- |-----------|------------------------------|---------|
195
- | **Landing / marketing** | Hero **headline** cực ngắn vs cực dài; **pricing** 3–5 tier + feature list dài mỗi tier; **FAQ** 10–20 mục (accordion/stack); **logo / social proof** hàng 8–15 logo + tên dài | Sticky CTA vs nội dung dài; section order khi overflow |
196
- | **App shell / SaaS admin** | **Bảng** nhiều cột + nhiều hàng; **filter bar** chip + dropdown tràn; **sidebar** nhiều cấp; **notification** stack / toast chồng | Trạng thái dense vs comfortable; frozen column |
197
- | **Form-heavy / wizard** | **Label + hint** dài; **multi-step** 5–7 bước + breadcrumb dài; **lỗi** inline từng field + banner tổng; khối **optional fields** mở rộng | Tab order, submit disabled ambiguity |
198
- | **Content / reader** | **Bài** cực dài; **code block** rộng; **TOC** 20–40 heading; **related** 8–15 thẻ | Max line length, sidenote, mobile đọc |
199
- | **Commerce / booking / marketplace** | **Kết quả tìm** grid dày; **giá** + đơn vị + discount dài; **ngày giờ** + múi giờ + DST; **đặt chỗ** (ghế, phòng) + availability text dài | Giỏ / summary trên mobile |
462
+ | Archetype | Stress priorities (suggested recipes) | Notes |
463
+ |-----------|---------------------------------------|-------|
464
+ | **Landing / marketing** | Hero **headline** very short vs very long; **pricing** 3–5 tiers + long feature list per tier; **FAQ** 10–20 items (accordion/stack); **logo / social proof** row of 8–15 logos + long names | Sticky CTA vs long content; section order when overflow |
465
+ | **App shell / SaaS admin** | **Table** many columns + many rows; **filter bar** chip + dropdown overflow; **sidebar** multi-level; **notification** stack / toast overlap | Dense vs comfortable state; frozen column |
466
+ | **Form-heavy / wizard** | Long **label + hint**; **multi-step** 5–7 steps + long breadcrumb; **errors** inline per field + global banner; expandable **optional fields** block | Tab order, submit disabled ambiguity |
467
+ | **Content / reader** | Very long **article**; wide **code block**; **TOC** 20–40 headings; **related** 8–15 cards | Max line length, sidenote, mobile reading |
468
+ | **Commerce / booking / marketplace** | Dense search results **grid**; **price** + long unit + discount; **date/time** + time zone + DST; **seat/room booking** + long availability text | Cart / summary on mobile |
200
469
 
201
- Hybrid (vd. marketing + app): **gộp recipe** từ các hàng liên quan; tránh lặp cùng một stress nghĩa trên hai màn giống nhau.
470
+ Hybrid (e.g., marketing + app): **merge recipes** from relevant rows; avoid repeating the same meaningless stress on two identical screens.
202
471
 
203
- Với prototype chỉ nội dung mẫu ngắn: **không bắt buộc** sửa file ngay Phase 1 — hãy ** tả giả định** (“nếu title 120 tự thì…”) UI sẽ **tràn, ellipsis, scroll, overlap, wrap xấu** thế nào.
204
- 6. Tổng hợp thêm **Stress findings** (bullet: loại stress → quan sát → severity **low/medium/high**) merge vào tổng kết Phase 1 cho Phase 2.
472
+ For prototypes with only short sample content: **no requirement** to edit files immediately in Phase 1 — instead **describe assumptions** (“if the title is 120 characters…”) and how the UI would **overflow, ellipsis, scroll, overlap, wrap poorly**.
473
+ 6. Also synthesize **Stress findings** (bullets: stress type observation → severity **low/medium/high**) and merge into the Phase 1 summary for Phase 2.
205
474
 
206
475
  #### Phase 2 — UX designer + research
207
476
 
208
- 1. Đổi vai: **UX/UI designer** nhận feedback từ Phase 1 (**gồm cả Stress findings**).
209
- 2. Map pain → **nguyên nhân thiết kế** (heuristic ngắn, pattern thiếu/sai); **ưu tiên hóa** P0 / P1 / P2 — **ưu tiên P0** nếu stress nội dung gây **mất thông tin, click sai, hoặc không dùng được** (overflow che CTA, text cắt nghĩa, bảng tràn không đọc được).
210
- 3. **Web research**: khi cần benchmark hoặc pattern chuẩn ngành, chạy **1–3 truy vấn** (search) → tóm tắt nguồn, takeaway, trade-off.
211
- 4. **Đề xuất cải tiến** cụ thể (thành phần UI, copy, layout, luồng) gắn với file/page (`slug` nếu multi-page).
477
+ 1. Switch role: **UX/UI designer** receiving feedback from Phase 1 (**including Stress findings**).
478
+ 2. Map pain → **design root cause** (short heuristic, missing/incorrect pattern); **prioritize** P0 / P1 / P2 — **prioritize P0** if content stress causes **information loss, mis-clicks, or unusability** (overflow covering CTA, truncated meaningful text, table overflow unreadable).
479
+ 3. **Web research**: when benchmarking or industry-standard patterns are needed, run **1–3 queries** (search) → summarize source, takeaway, trade-off.
480
+ 4. **Propose specific improvements** (UI components, copy, layout, flow) tied to file/page (`slug` if multi-page).
212
481
 
213
- #### Phase 3 — Cập nhật artifact
482
+ #### Phase 3 — Update artifacts
214
483
 
215
- 1. Sửa **`index.html`**, **`pages/*.html`**, **`style.css`** theo P0 → P1 trong phạm vi phiên (prototype direction, không ép production).
216
- 2. Trong **`notes.md`**, thêm hoặc append section **`## UX walkthrough log`** (một entry mỗi lần chạy lệnh): ngày/scenario đã mô phỏng, pain chính, **Stress findings** (tóm tắt), link research (nếu ), **diff ý định** (bullet), file đã đổi. *Tùy chọn:* chỉnh HTML với **placeholder/copy dài** hoặc thêm **demo row** để minh họa stress đã bàn (ghi trong log).
217
- 3. **Multi-page**: sau chỉnh sửa page, giữ **`## Pages inventory`** **hub** khớp 100% file trong `pages/*` (hook FEAT-007).
484
+ 1. Edit **`index.html`**, **`pages/*.html`**, **`style.css`** per P0 → P1 within the session scope (prototype direction, no forcing production code).
485
+ 2. In **`notes.md`**, add or append a **`## UX walkthrough log`** section (one entry per command run): date/scenarios simulated, main pains, **Stress findings** (summary), research links (if any), **intent diff** (bullets), files changed. *Optional:* adjust HTML with **long placeholder/copy** or add a **demo row** to illustrate stress discussed (record in log).
486
+ 3. **Multi-page**: after editing a page, keep **`## Pages inventory`** and the **hub** matching 100% of files in `pages/*` (hook FEAT-007).
218
487
 
219
- **Quan hệ với `/research {topic}`**: lệnh **tự do** chỉ cần research ngắn quay lại topic; **`/research-ui`** bắt buộc **3 phase** + **ghi log** + **chỉnh HTML/CSS khi đề xuất hợp lý**.
488
+ **Relationship with `/research {topic}`**: the **free-form** command only needs a quick research and return to topic; **`/research-ui`** requires **3 phases** + **log entry** + **HTML/CSS edits when proposals are reasonable**.
220
489
 
221
- Tham chiếu user: `docs/user/features/ui-direction.md`.
490
+ User reference: `docs/user/features/ui-direction.md`.
222
491
 
223
- ### Kết thúc mỗi topic
224
- - Tóm tắt decisions
492
+ ### End of each topic
493
+ - Summarize decisions
225
494
  - List action items
226
495
  - Note open questions
227
- - Nếu topic thêm/sửa capability: cập nhật **`## Product horizon`** trong bản nháp session (hoặc nhắc user lưu `/save`) với tag tier phù hợp
496
+ - If the topic adds/changes a capability: update **`## Phases`** in the session draft (or remind the user to `/save`) with the appropriate phase
228
497
  </step>
229
498
 
230
499
  <step name="project_meta_intake">
@@ -234,51 +503,51 @@ Normative contract: **`docs/dev/global-profiles.md`** (`~/.viepilot/profiles/`,
234
503
 
235
504
  ### 5.1 When this step runs
236
505
 
237
- Chạy **trước** khi ghi session trạng thái **`Completed`** hoặc khi user **`/end`**, **nếu**:
506
+ Runs **before** saving the session in **`Completed`** status or when the user types **`/end`**, **if**:
238
507
 
239
- 1. **Scope locked**: `## Product horizon` trong bản nháp session đã nội dung thật (không chỉ placeholder) **hoặc** user vừa xác nhận bằng lời đã chốt scope MVP / horizon.
240
- 2. **Binding thiếu**: không tồn tại `.viepilot/META.md` **hoặc** frontmatter thiếu `viepilot_profile_id` hợp lệ (slug `kebab-case` theo contract).
508
+ 1. **Scope locked**: `## Phases` in the session draft already contains real content (all features assigned to a phase) **or** the user has just verbally confirmed scope is finalized.
509
+ 2. **Binding missing**: `.viepilot/META.md` does not exist **or** the frontmatter lacks a valid `viepilot_profile_id` (slug `kebab-case` per contract).
241
510
 
242
- **Bỏ qua mặc định** (skip intake) khi `.viepilot/META.md` đã `viepilot_profile_id` hợp lệ chỉ hỏi nhanh: *“Giữ profile `{id}`? Đổi profile?”*; nếu giữsang bước Save.
511
+ **Skip by default** (skip intake) when `.viepilot/META.md` already has a valid `viepilot_profile_id` — only ask quickly: *”Keep profile `{id}`? Change profile?”*; if keptproceed to Save step.
243
512
 
244
- ### 5.2 Chuẩn bị registry
513
+ ### 5.2 Prepare registry
245
514
 
246
- 1. `mkdir -p "$HOME/.viepilot/profiles"` nếu cần.
247
- 2. Đọc `~/.viepilot/profile-map.md` nếu để liệt profile hiện có (profile_id, display_name, org_tag).
515
+ 1. `mkdir -p "$HOME/.viepilot/profiles"` if needed.
516
+ 2. Read `~/.viepilot/profile-map.md` if present to list existing profiles (profile_id, display_name, org_tag).
248
517
 
249
- ### 5.3 Disambiguation (nhiều profile / nhiều org)
518
+ ### 5.3 Disambiguation (multiple profiles / multiple orgs)
250
519
 
251
- - Nếu brainstorm cho thấy **nhiều org/client** hoặc **≥2 dòng trong profile-map** khớp gợi ý (cùng `org_tag` hoặc tag): **bắt buộc** user chọn **một** `profile_id` **hoặc** chọn **Tạo profile mới** (slug mới, chưa tồn tại).
520
+ - If the brainstorm reveals **multiple orgs/clients** or **≥2 rows in profile-map** match the suggestion (same `org_tag` or tag): **require** the user to select **one** `profile_id` **or** choose **Create new profile** (new slug, not yet existing).
252
521
 
253
- ### 5.4 Q&A tuần tự (một câu mỗi lượt)
522
+ ### 5.4 Sequential Q&A (one question per turn)
254
523
 
255
- Với mỗi câu hỏi:
524
+ For each question:
256
525
 
257
- 1. Đưa **Proposal** ngắn (1–2 câu) suy ra từ session + Product horizon.
258
- 2. User trả lời **Accept proposal** / **Edit** (ghi nhận bản user).
259
- 3. Sang câu tiếp.
526
+ 1. Provide a short **Proposal** (1–2 sentences) inferred from the session + phase plan.
527
+ 2. User responds **Accept proposal** / **Edit** (record user's version).
528
+ 3. Move to the next question.
260
529
 
261
- **Tối thiểu** phải làm trước khi ghi file (khớp body sections trong global contract):
530
+ **At minimum** these must be clarified before writing the file (matches body sections in the global contract):
262
531
 
263
- | Thứ tự | Câu hỏi (gợi ý) | Map tới |
264
- |--------|------------------|---------|
265
- | 1 | Tên hiển thị org/client hoặccá nhân”? | `display_name` |
266
- | 2 | `org_tag` ngắn (vd. `acme`, `personal`)? | `org_tag` |
267
- | 3 | Branding / giọng văn (audience, tone)? | body `## Branding & voice` |
268
- | 4 | Legal / attribution công khai (nếu )? | body `## Legal & attribution` |
269
- | 5 | Website công khai (optional)? | frontmatter `website` |
532
+ | Order | Question (suggested) | Maps to |
533
+ |-------|----------------------|---------|
534
+ | 1 | Display name for org/client orpersonal”? | `display_name` |
535
+ | 2 | Short `org_tag` (e.g., `acme`, `personal`)? | `org_tag` |
536
+ | 3 | Branding / voice (audience, tone)? | body `## Branding & voice` |
537
+ | 4 | Public legal / attribution (if any)? | body `## Legal & attribution` |
538
+ | 5 | Public website (optional)? | frontmatter `website` |
270
539
 
271
- Sau đó: chốt **`profile_id`** = slug filename (`kebab-case`).
540
+ Then: finalize **`profile_id`** = slug filename (`kebab-case`).
272
541
 
273
- ### 5.5 Ghi artifact (machine + project)
542
+ ### 5.5 Write artifacts (machine + project)
274
543
 
275
- 1. **`~/.viepilot/profiles/<slug>.md`**: YAML frontmatter đủ key bắt buộc (`profile_id`, `display_name`, `org_tag`, `tags`, `last_updated`) + body sections đã thu thập. **Không** ghi secrets.
276
- 2. **`~/.viepilot/profile-map.md`**: thêm hoặc cập nhật dòng bảng (cột theo contract); cập nhật `last_used` = ngày hiện tại.
277
- 3. **`.viepilot/META.md`**: tạo/cập nhật từ `templates/project/VIEPILOT-META.md` với `viepilot_profile_id: <slug>`.
544
+ 1. **`~/.viepilot/profiles/<slug>.md`**: YAML frontmatter with all required keys (`profile_id`, `display_name`, `org_tag`, `tags`, `last_updated`) + body sections collected. Do **not** write secrets.
545
+ 2. **`~/.viepilot/profile-map.md`**: add or update a table row (columns per contract); update `last_used` = current date.
546
+ 3. **`.viepilot/META.md`**: create/update from `templates/project/VIEPILOT-META.md` with `viepilot_profile_id: <slug>`.
278
547
 
279
- ### 5.6 Ghi nhận trong session file
548
+ ### 5.6 Record in session file
280
549
 
281
- Trong bản nháp / file session, thêm section:
550
+ In the draft / session file, add section:
282
551
 
283
552
  ```markdown
284
553
  ## Project meta intake (FEAT-009)
@@ -288,17 +557,17 @@ Trong bản nháp / file session, thêm section:
288
557
  - **binding**: .viepilot/META.md
289
558
  ```
290
559
 
291
- Nếu skipped (hiếm): phải **`## Meta intake waiver`** trong cùng file session kèm **lý do** do user cung cấp.
560
+ If skipped (rare): must have a **`## Meta intake waiver`** in the same session file with the **reason** provided by the user.
292
561
 
293
- ### 5.7 Tiếp tục
562
+ ### 5.7 Continue
294
563
 
295
- Sau khi intake **completed** hoặc **hợp lệ skip** (META đã profile) → chuyển sang **bước 6 — Save Session**.
564
+ After intake is **completed** or a **valid skip** (META already has profile) → proceed to **step 6 — Save Session**.
296
565
  </step>
297
566
 
298
567
  <step name="save_session">
299
568
  ## 6. Save Session
300
569
 
301
- Tạo/cập nhật file: `docs/brainstorm/session-{YYYY-MM-DD}.md`
570
+ Create/update file: `docs/brainstorm/session-{YYYY-MM-DD}.md`
302
571
 
303
572
  ```markdown
304
573
  # Brainstorm Session - {YYYY-MM-DD}
@@ -308,29 +577,16 @@ Tạo/cập nhật file: `docs/brainstorm/session-{YYYY-MM-DD}.md`
308
577
  - **Participants**: User, Claude
309
578
  - **Status**: In Progress | Completed
310
579
 
311
- ## Product horizon
312
-
313
- > Single source for **MVP / Post-MVP / Future** scope. Bắt buộc giữ section này khi tiếp tục session; crystallize đọc để không bỏ sót post-MVP.
580
+ ## Phases
314
581
 
315
- ### MVP (ship first)
316
- - Capability / theme — `(MVP)`
317
- - ...
582
+ ### Phase 1
583
+ - {Feature / capability}
318
584
 
319
- ### Post-MVP (after first release)
320
- - Capability / theme — `(Post-MVP)`
321
- - ...
585
+ ### Phase 2
586
+ - {Feature / capability}
322
587
 
323
- ### Future / exploratory
324
- - Idea `(Future)`
325
- - ...
326
-
327
- ### Non-goals for MVP
328
- - ...
329
-
330
- ### Deferred capabilities (from MVP)
331
- - ...
332
-
333
- **Scope note (optional):** Nếu không có post-MVP: `Single-release product — no separate horizon epics.`
588
+ ### Phase 3 (and beyond)
589
+ - {Feature / capability}
334
590
 
335
591
  ## Project meta intake (FEAT-009)
336
592
 
@@ -339,9 +595,9 @@ Tạo/cập nhật file: `docs/brainstorm/session-{YYYY-MM-DD}.md`
339
595
  - **profile_path**:
340
596
  - **binding** (.viepilot/META.md):
341
597
 
342
- _(Điền sau bước 5 — Project meta intake; xem `docs/dev/global-profiles.md`.)_
598
+ _(Fill after step 5 — Project meta intake; see `docs/dev/global-profiles.md`.)_
343
599
 
344
- <!-- Nếu skipped: ## Meta intake waiver + do -->
600
+ <!-- If skipped: ## Meta intake waiver + reason -->
345
601
 
346
602
  ## Architecture diagram applicability inputs
347
603
 
@@ -388,15 +644,15 @@ _(Điền sau bước 5 — Project meta intake; xem `docs/dev/global-profiles.m
388
644
  - Session id: {session-id}
389
645
  - Layout: legacy (single `index.html`) | multi-page (`pages/*.html` + hub `index.html`)
390
646
  - Files:
391
- - `.viepilot/ui-direction/{session-id}/index.html` (hub hoặc single-screen)
647
+ - `.viepilot/ui-direction/{session-id}/index.html` (hub or single-screen)
392
648
  - `.viepilot/ui-direction/{session-id}/style.css`
393
649
  - `.viepilot/ui-direction/{session-id}/notes.md` (must include `## Pages inventory` when `pages/` exists)
394
650
  - `.viepilot/ui-direction/{session-id}/pages/*.html` (when multi-page)
395
651
  - Preview focus:
396
652
  - {layout/flow summary; list each page slug if multi-page}
397
653
 
398
- **UX walkthrough log** (optional; FEAT-010 + ENH-019 + ENH-020 — khi đã chạy `/research-ui`):
399
- - {YYYY-MM-DD}: scenarios exercised → top pains → **Stress findings** (tóm tắt) → research links → HTML/CSS edits summary
654
+ **UX walkthrough log** (optional; FEAT-010 + ENH-019 + ENH-020 — when `/research-ui` has been run):
655
+ - {YYYY-MM-DD}: scenarios exercised → top pains → **Stress findings** (summary) → research links → HTML/CSS edits summary
400
656
 
401
657
  ---
402
658
 
@@ -425,6 +681,129 @@ git push
425
681
  ```
426
682
  </step>
427
683
 
684
+ <step name="architect_delta_sync">
685
+ ## 6B. Architect Delta Sync (ENH-034)
686
+
687
+ Bridges the gap between UI Direction Mode and the Architect HTML workspace.
688
+ When a UI brainstorm session surfaces architect-relevant gaps or changes, those
689
+ deltas are parsed and written back to the relevant architect HTML template files.
690
+
691
+ ### Trigger conditions
692
+
693
+ Runs when **either** condition is met:
694
+
695
+ 1. **End of UI session** — `.viepilot/ui-direction/{session-id}/` exists for the current
696
+ session AND the session contains ≥1 architect keyword hit detected during UI discussion
697
+ (see keyword lists below).
698
+ 2. **Manual command** — user types `/sync-arch` at any point in a session.
699
+
700
+ > **Automatic mode (FEAT-012):** If the brainstorm staleness hook is installed
701
+ > (`vp-tools hooks install`), stale architect items are flagged automatically after
702
+ > **each AI response** — no need to type `/sync-arch`. The hook marks items
703
+ > `data-arch-stale="true"` (amber badge) without rewriting content. Install once per machine.
704
+ > See `docs/user/features/hooks.md` for setup.
705
+
706
+ When neither condition is met: skip silently.
707
+ When `/sync-arch` is used explicitly and no gaps are found: output
708
+ `✓ No architect gaps detected in this session.`
709
+
710
+ ### Step 1: Locate architect session
711
+
712
+ ```bash
713
+ ls .viepilot/architect/ 2>/dev/null
714
+ ```
715
+
716
+ - Find `.viepilot/architect/{session-id}/` matching the current session context
717
+ (same date, same project name, or most recent).
718
+ - If **no architect workspace exists**: skip with message:
719
+ `⚠ No architect workspace found. Run /vp-brainstorm --architect first to create one.`
720
+
721
+ ### Step 2: Gap detection — scan session for architect keywords by page
722
+
723
+ Use the **existing trigger keyword lists** from Architect Design Mode (defined above) to
724
+ identify which architect pages are affected:
725
+
726
+ | Page | Keywords (excerpt) |
727
+ |------|--------------------|
728
+ | `architecture.html` | service, component, module, layer, boundary, system, integration, C4 |
729
+ | `erd.html` | database, entity, table, schema, relation, foreign key, ERD, data model |
730
+ | `apis.html` | endpoint, API, REST, route, HTTP, POST, GET, PUT, DELETE, request, response |
731
+ | `deployment.html` | deploy, infrastructure, environment, staging, production, CI/CD, pipeline |
732
+ | `data-flow.html` | data flow, event flow, queue, webhook, async, pub/sub |
733
+ | `user-use-cases.html` | user story, use case, actor, persona, as a user, user flow, journey |
734
+ | `sequence-diagram.html` | sequence, step by step, login flow, checkout flow, interaction |
735
+
736
+ For each page where **≥1 keyword is found in the UI brainstorm session output**:
737
+ - Mark as **affected**.
738
+ - Extract the relevant sentences/paragraphs that describe the gap or change.
739
+
740
+ ### Step 3: Update HTML for each affected page
741
+
742
+ For each affected page:
743
+
744
+ 1. **Read** `.viepilot/architect/{session-id}/{page}.html`
745
+ 2. **Identify the target element(s)**:
746
+ - Match the gap context to the nearest `<tr data-arch-id="...">` row or
747
+ `<div class="card" data-arch-id="...">` by comparing gap keywords to the
748
+ item's `data-arch-title` or first cell content.
749
+ - If no exact match: add a **new row** to the relevant `<tbody>` (the most
750
+ appropriate table for the content type) with the gap information.
751
+ 3. **Update element content**:
752
+ - For existing rows: update the relevant `<td>` cell with the new/corrected
753
+ information from the brainstorm.
754
+ - For new rows: create `<tr data-arch-id="{PAGE-PREFIX-NEW{n}}"
755
+ data-updated="true" class="updated">` with content from the brainstorm.
756
+ 4. **Mark as updated**: add `data-updated="true"` and `class="updated"` to the
757
+ changed element (uses existing `.updated` CSS — yellow left border + badge).
758
+ 5. **Add sync note**: add `data-arch-sync-note="{brief reason, ≤60 chars}"` to the
759
+ changed element recording why it was updated.
760
+
761
+ **Do NOT**:
762
+ - Change elements that were NOT identified as gaps.
763
+ - Cascade updates across pages (isolation rule — ENH-033 applies here too).
764
+ - Remove existing data — only update or add.
765
+
766
+ ### Step 4: Record delta in notes.md
767
+
768
+ Append under `## architect_sync` section in `.viepilot/architect/{session-id}/notes.md`:
769
+
770
+ ```yaml
771
+ ## architect_sync
772
+ - synced_at: {ISO datetime}
773
+ source_session: {ui-direction session-id}
774
+ trigger: {end-of-session | /sync-arch}
775
+ changes:
776
+ - page: {slug}
777
+ item_id: {data-arch-id}
778
+ action: {updated | added}
779
+ change: "{brief description of what was updated, ≤80 chars}"
780
+ - page: {slug}
781
+ item_id: {data-arch-id}
782
+ action: updated
783
+ change: "{description}"
784
+ ```
785
+
786
+ ### Step 5: Output sync report
787
+
788
+ ```
789
+ 🔄 Architect Sync complete
790
+
791
+ Updated {N} items across {M} pages:
792
+ {page} {item-id} [{action}] — {change}
793
+ ...
794
+
795
+ Items marked with data-updated="true" in architect workspace.
796
+ Open .viepilot/architect/{session-id}/ to review changes.
797
+ ```
798
+
799
+ If only 1 item changed: single-line summary is sufficient.
800
+
801
+ ### notes.md schema update
802
+
803
+ The `## architect_sync` section is **appended** (not replaced) on each sync run.
804
+ Multiple sync entries can exist — each with its own `synced_at` timestamp.
805
+ </step>
806
+
428
807
  <step name="suggest_next">
429
808
  ## 7. Suggest Next Action
430
809
 
@@ -440,36 +819,41 @@ Next step: /vp-crystallize
440
819
  This will transform your brainstorm into:
441
820
  - Project structure
442
821
  - Architecture documents
443
- - Development roadmap (MVP phases + **Post-MVP / horizon** when documented above)
822
+ - Development roadmap (phases + tasks from `## Phases` section)
444
823
  ```
445
824
  </step>
446
825
 
447
826
  </process>
448
827
 
449
828
  <commands>
450
- User thể dùng các lệnh trong phiên brainstorm:
451
-
452
- - `/topic {name}` - Chuyển sang topic mới
453
- - `/summary` - Xem tóm tắt phiên hiện tại
454
- - `/save` - Lưu tiến độ ngay
455
- - `/end` - Kết thúc lưu phiên (sau **bước 5 — Project meta intake** khi binding thiếu; xem workflow)
456
- - `/questions` - Xem danh sách open questions
457
- - `/research {topic}` - Research nhanh ngay trong phiên quay lại topic hiện tại
458
- - `/research-ui` — UX walkthrough: phỏng user → designer + research → cập nhật UI direction + log (`notes.md`) — chỉ khi UI session (FEAT-010)
459
- - `/research ui` — alias của `/research-ui`
829
+ User can use the following commands during a brainstorm session:
830
+
831
+ - `/topic {name}` - Switch to a new topic
832
+ - `/summary` - View current session summary
833
+ - `/save` - Save progress immediately
834
+ - `/end` - End and save the session (after **step 5 — Project meta intake** when binding is missing; see workflow)
835
+ - `/questions` - View list of open questions
836
+ - `/research {topic}` - Quick research inline in the session and return to current topic
837
+ - `/research-ui` — UX walkthrough: simulate user → designer + research → update UI direction + log (`notes.md`) — only when a UI session exists (FEAT-010)
838
+ - `/research ui` — alias of `/research-ui`
839
+ - `/review-arch` — Architect Mode: output summary table of decisions + open_questions from `notes.md`, confirm before continuing (FEAT-011)
840
+ - `/sync-arch` — Architect Delta Sync (ENH-034): manually trigger architect HTML sync from current UI brainstorm session; scans session for architect gaps → updates relevant architect workspace pages
841
+ - `/hooks-install` — Install the brainstorm staleness hook (FEAT-012): runs `vp-tools hooks install`; one-time setup per machine; auto-marks stale architect items after each AI response
460
842
  </commands>
461
843
 
462
844
  <success_criteria>
463
- - [ ] Session file created với đầy đủ sections
464
- - [ ] `## Product horizon` present với MVP / Post-MVP / Future (hoặc explicit single-release statement)
465
- - [ ] Decisions rationale
845
+ - [ ] Session file created with all required sections
846
+ - [ ] `## Phases` present with at least Phase 1 containing real content
847
+ - [ ] Decisions include rationale
466
848
  - [ ] Open questions tracked
467
849
  - [ ] Action items captured
468
850
  - [ ] Landing page topics trigger layout follow-up questions
469
- - [ ] 21st.dev references được dùng khi thảo luận landing page
470
- - [ ] Research thể chạy ngay trong brainstorm session khi user yêu cầu
471
- - [ ] **FEAT-010 + ENH-019 + ENH-020**: Trong UI Direction, `/research-ui` (hoặc `/research ui`) chạy đủ 3 phase, gồm **content stress pass** + **archetype stress recipes** + **`## UX walkthrough log`** (Stress findings) khi chỉnh prototype
851
+ - [ ] 21st.dev references used when discussing landing pages
852
+ - [ ] Research can be run inline during the brainstorm session when the user requests it
853
+ - [ ] **FEAT-010 + ENH-019 + ENH-020**: In UI Direction, `/research-ui` (or `/research ui`) runs all 3 phases, including **content stress pass** + **archetype stress recipes** + **`## UX walkthrough log`** (Stress findings) when editing prototype
472
854
  - [ ] Git committed
473
- - [ ] **FEAT-009**: Nếu binding thiếu scope đã locked — đã chạy **Project meta intake** (bước 5) hoặc **`## Meta intake waiver`** do trước Completed
474
- - [ ] **`## Project meta intake (FEAT-009)`** trong session: `status` + `profile_id` khi completed (hoặc waiver nếu skipped)
855
+ - [ ] **FEAT-009**: If binding is missing and scope is locked — **Project meta intake** (step 5) has been run or a **`## Meta intake waiver`** with reason exists before Completed
856
+ - [ ] **`## Project meta intake (FEAT-009)`** in session: `status` + `profile_id` when completed (or waiver if skipped)
857
+ - [ ] **ENH-034**: If UI session surfaces architect gaps → `architect_delta_sync` step runs; architect HTML updated + `## architect_sync` appended to notes.md
858
+ - [ ] **FEAT-012**: If brainstorm staleness hook installed → stale architect items auto-flagged after each AI response (amber badge); `/hooks-install` sets this up once per machine
475
859
  </success_criteria>