viepilot 1.14.0 → 2.4.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 (58) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/README.md +27 -17
  3. package/bin/viepilot.cjs +19 -9
  4. package/bin/vp-tools.cjs +193 -0
  5. package/docs/user/features/adapters.md +74 -0
  6. package/docs/user/features/hooks.md +93 -0
  7. package/lib/adapters/antigravity.cjs +33 -0
  8. package/lib/adapters/claude-code.cjs +42 -0
  9. package/lib/adapters/codex.cjs +34 -0
  10. package/lib/adapters/cursor.cjs +32 -0
  11. package/lib/adapters/index.cjs +28 -0
  12. package/lib/hooks/brainstorm-staleness.cjs +231 -0
  13. package/lib/viepilot-config.cjs +103 -0
  14. package/lib/viepilot-install.cjs +125 -152
  15. package/package.json +1 -3
  16. package/skills/vp-audit/SKILL.md +23 -23
  17. package/skills/vp-auto/SKILL.md +23 -9
  18. package/skills/vp-brainstorm/SKILL.md +44 -38
  19. package/skills/vp-crystallize/SKILL.md +25 -19
  20. package/skills/vp-debug/SKILL.md +4 -4
  21. package/skills/vp-docs/SKILL.md +8 -8
  22. package/skills/vp-evolve/SKILL.md +26 -13
  23. package/skills/vp-info/SKILL.md +24 -24
  24. package/skills/vp-pause/SKILL.md +7 -7
  25. package/skills/vp-request/SKILL.md +14 -14
  26. package/skills/vp-resume/SKILL.md +6 -6
  27. package/skills/vp-rollback/SKILL.md +4 -4
  28. package/skills/vp-status/SKILL.md +4 -4
  29. package/skills/vp-task/SKILL.md +2 -2
  30. package/skills/vp-ui-components/SKILL.md +14 -14
  31. package/skills/vp-update/SKILL.md +18 -18
  32. package/templates/architect/apis.html +11 -10
  33. package/templates/architect/architect-actions.js +217 -0
  34. package/templates/architect/architecture.html +8 -7
  35. package/templates/architect/data-flow.html +5 -4
  36. package/templates/architect/decisions.html +4 -3
  37. package/templates/architect/deployment.html +10 -9
  38. package/templates/architect/erd.html +7 -6
  39. package/templates/architect/feature-map.html +5 -4
  40. package/templates/architect/sequence-diagram.html +6 -5
  41. package/templates/architect/style.css +146 -0
  42. package/templates/architect/tech-notes.html +3 -2
  43. package/templates/architect/tech-stack.html +8 -7
  44. package/templates/architect/user-use-cases.html +8 -7
  45. package/templates/project/AI-GUIDE.md +49 -49
  46. package/workflows/audit.md +3 -3
  47. package/workflows/autonomous.md +70 -5
  48. package/workflows/brainstorm.md +398 -222
  49. package/workflows/crystallize.md +51 -33
  50. package/workflows/debug.md +9 -9
  51. package/workflows/documentation.md +5 -5
  52. package/workflows/evolve.md +46 -12
  53. package/workflows/pause-work.md +2 -2
  54. package/workflows/request.md +8 -8
  55. package/workflows/resume-work.md +1 -1
  56. package/workflows/rollback.md +1 -1
  57. package/dev-install.sh +0 -150
  58. package/install.sh +0 -125
@@ -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 **`## Phases`**: tóm tắt nhanh các phase hiện có; mọi cập nhật sau đó phải **merge** vào section đó (không xóa im lặng) 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,128 +99,128 @@ Gợi ý các topics để brainstorm:
88
99
  - Monitoring
89
100
  - Scaling
90
101
 
91
- 6. **Phase assignment (ENH-030):** trong quá trình brainstorm, mỗi feature/capability được gán vào một **phase** cụ thể — Phase 1, Phase 2, Phase 3... Không dùng tier MVP/Post-MVP/Future. Nếu user chưa nêu phase, hỏi: “Feature này bạn muốn đưa vào Phase mấy?”
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?”
92
103
 
93
104
  ### Interactive Q&A
94
- Cho mỗi topic:
95
- 1. Đặt câu hỏi cụ thể
96
- 2. Đợi user trả lời
97
- 3. Tổng hợp đặt follow-up questions
98
- 4. Đề xuất alternatives nếu cần
99
- 5. Ghi nhận decisions
100
-
101
- ### Landing Page Deep-Dive (kích hoạt theo ngữ cảnh)
102
- Nếu user brainstorm về landing page / homepage / marketing page:
103
-
104
- 1. Hỏi thêm để chốt bố cục:
105
- - Goal chính của landing page? (signup, booking demo, download, contact)
106
- - Audience chính?
107
- - Tone visual? (minimal, modern, bold, enterprise, playful)
108
- - CTA chính CTA phụ?
109
- 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:
110
121
  - Layout A: Hero centric + trust logos + features + CTA
111
122
  - Layout B: Problem/Solution + social proof + pricing + FAQ
112
123
  - Layout C: Product storytelling + screenshots + testimonials + final CTA
113
124
  - Layout D: SaaS conversion + integrations + comparison + onboarding steps
114
- 3. Tham khảo `https://21st.dev` để đề xuất section/components phù hợp với layout đã chọn.
115
- 4. Ghi trong session:
116
- - Layout user chọn
117
- - Component candidates từ 21st.dev
118
- - 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
119
130
 
120
131
  ### In-session Research Mode
121
- User thể yêu cầu research ngay trong brainstorm (không cần đổi skill):
122
- - Trigger phrases: "research cái này", "bạn research giúp", "cần research", "hãy tìm best practice"
123
- - Khi trigger:
124
- 1. Xác định scope research (1-3 câu)
125
- 2. Thu thập nhanh từ nguồn phù hợp (docs chính thức, reference sites, patterns)
126
- 3. Trả về tóm tắt ngắn: findings, trade-offs, recommendation
127
- 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
128
139
 
129
- 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:
130
- `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?`
131
142
 
132
143
  ### UI Direction Mode (design-in-the-loop; FEAT-002 + FEAT-007)
133
- 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:
134
145
 
135
- **Layout — chọn một:**
146
+ **Layout — choose one:**
136
147
 
137
- - **Legacy (một màn):** `.viepilot/ui-direction/{session-id}/index.html` + `style.css` + `notes.md`.
138
- - **Multi-page (nhiều màn):** cùng thư mục session, thêm `pages/{slug}.html` cho từng page; `index.html` **hub** (liên kết tới mọi page). `style.css` shared.
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.
139
150
 
140
- **Quy tắc chung**
151
+ **General rules**
141
152
 
142
- 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).
143
- 2. Mỗi lần user đổi requirement/layout/component:
144
- - Cập nhật trực tiếp HTML/CSS direction
145
- - Ghi decision + rationale vào `notes.md` (single source of truth cho design intent)
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)
146
157
 
147
- **Hook bắt buộc (multi-page only)**
158
+ **Required hook (multi-page only)**
148
159
 
149
- 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:
160
+ When the `pages/` directory exists or any `pages/*.html` is added / renamed / removed:
150
161
 
151
- - Cập nhật **hub** `index.html` (nav / danh sách link tới mọi page còn lại).
152
- - 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ó.
153
- - Không kết thúc topic / không coi session UI đãsyncnếu inventory lệch với file trên disk.
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 sessionsyncedif the inventory diverges from files on disk.
154
165
 
155
- 3. Nếu user gửi references/components (bao gồm 21st.dev prompt/link), ghi rõ:
156
- - nguồn tham chiếu
157
- - phần UI áp dụng (page slug nếu multi-page)
158
- - điều chỉnh theo mục tiêu sản phẩm
159
- 4. Giữ prototype mức tả định hướng (directional), không ép build production-ready code bước brainstorm.
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.
160
171
 
161
172
  ### Architect Design Mode (FEAT-011)
162
173
 
163
- Brainstorm kiến trúc hệ thống với live HTML generation — workspace trực quan cho user review, chỉnh sửa, trình bày trước khi chạy `/vp-crystallize`.
174
+ Brainstorm system architecture with live HTML generation — a visual workspace for the user to review, edit, and present before running `/vp-crystallize`.
164
175
 
165
176
  #### Activation
166
177
 
167
- Kích hoạt khi **một trong** các điều kiện sau:
178
+ Activated when **any one** of the following conditions is met:
168
179
 
169
- 1. **Flag explicit**: user dùng `/vp-brainstorm --architect`
170
- 2. **Auto-activate heuristic** (xem dưới)
171
- 3. **Topic Architecture + complexity threshold**: user chọn topic "Architecture" trong brainstorm menu (service count ≥3 HOẶC ≥1 tech stack được đề xuất)
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)
172
183
 
173
- **Auto-activate heuristic**: trong quá trình brainstorm, theo dõi:
174
- - **Component/service mentions**: các tên pattern `{capitalized} Service|API|Module|Layer|Server|Database` (vd. "UserService", "Payment API", "Data Layer")
175
- - **Stack mentions**: bất kỳ keyword từ danh sách stack biết (React, Node.js, PostgreSQL, Redis, Kafka, AWS, Docker, v.v.)
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.)
176
187
 
177
- Khi **≥3 components** HOẶC **≥1 stack suggestion** được nhắc đến → prompt:
188
+ When **≥3 components** OR **≥1 stack suggestion** is mentioned → prompt:
178
189
 
179
190
  ```
180
- 🏗️ Tôi nhận thấy bạn đang thiết kế kiến trúc với nhiều components.
181
- Kích hoạt Architect Design Mode để tôi tạo HTML visualization không?
182
- 1. tạo workspace generate initial HTML
183
- 2. Khôngtiếp tục text-only
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. Yescreate workspace and generate initial HTML
194
+ 2. Nocontinue text-only
184
195
  ```
185
196
 
186
- - **Option 1 (Yes)**: tạo workspace (thư mục + files), generate initial HTML từ nội dung đã thảo luận, tiếp tục trong Architect Mode.
187
- - **Option 2 (No)**: tiếp tục brainstorm text-only; heuristic không prompt lại trong phiên này.
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.
188
199
 
189
200
  #### Workspace layout
190
201
 
191
202
  ```
192
203
  .viepilot/architect/{session-id}/
193
- index.html # Hub: sidebar nav + tabs → tới tất cả sections
204
+ index.html # Hub: sidebar nav + tabs → to all sections
194
205
  architecture.html # System diagram (graph TD / C4Context) + component descriptions
195
206
  data-flow.html # High-level service/event flows (sequenceDiagram / flowchart LR)
196
207
  decisions.html # ADR log: Date | Decision | Options | Chosen | Rationale | Status
197
208
  tech-stack.html # Layer-by-layer: frontend, backend, infra, data, DevOps
198
209
  tech-notes.html # 3 columns: Assumptions | Risks | Open Questions
199
- feature-map.html # Features với tags: layer, phase, priority, status
210
+ feature-map.html # Features with tags: layer, phase, priority, status
200
211
  erd.html # Database ERD: entities, attributes, relationships (erDiagram) — ENH-027
201
212
  user-use-cases.html # User Stories / Use Cases / Actors (flowchart TD) — ENH-028
202
213
  sequence-diagram.html # Per-scenario sequences (sequenceDiagram) — ENH-029
203
214
  deployment.html # Infra, environments, CI/CD pipeline — ENH-029
204
215
  apis.html # Service API listing & design decisions — ENH-029
205
216
  style.css # Shared: dark/light CSS vars, .updated highlight, Mermaid container, responsive nav
206
- notes.md # Machine-readable YAML (xem schema bên dưới)
217
+ notes.md # Machine-readable YAML (see schema below)
207
218
  ```
208
219
 
209
- **Mermaid.js** — tất cả diagrams dùng: `<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js">`
210
- - `architecture.html` → `graph TD` hoặc `C4Context`
211
- - `data-flow.html` → `sequenceDiagram` hoặc `flowchart LR`
212
- - `feature-map.html` → `mindmap` hoặc `quadrantChart`
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`
213
224
  - `erd.html` → `erDiagram` (entities, attributes, relationships)
214
225
  - `user-use-cases.html` → `flowchart TD` (actors → use case bubbles)
215
226
  - `sequence-diagram.html` → `sequenceDiagram` (per-scenario step-by-step)
@@ -227,34 +238,62 @@ Kích hoạt Architect Design Mode để tôi tạo HTML visualization không?
227
238
  | `apis.html` | API endpoint design, HTTP methods, request/response contracts |
228
239
 
229
240
  #### Sequence trigger keywords (ENH-029)
230
- Khi user nhắc đến: `scenario`, `step by step`, `login flow`, `checkout flow`, `detailed interaction`, `sequence`, `interaction diagram` → update `sequence-diagram.html` + update `notes.md ## sequences` section.
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.
231
242
 
232
243
  #### Deployment trigger keywords (ENH-029)
233
- Khi user nhắc đến: `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.
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.
234
245
 
235
246
  #### APIs trigger keywords (ENH-029)
236
- Khi user nhắc đến: `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.
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.
237
248
 
238
249
  #### ERD trigger keywords (ENH-027)
239
- Khi user nhắc đến bất kỳ keyword: `database`, `entity`, `table`, `schema`, `relation`, `relationship`, `foreign key`, `primary key`, `ERD`, `data model`, `normalization` → update `erd.html` + update `notes.md ## erd` section.
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.
240
251
 
241
252
  #### Use Case trigger keywords (ENH-028)
242
- Khi user nhắc đến: `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.
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.
243
254
 
244
255
  #### Dialogue cadence
245
256
 
246
- 1. Sau mỗi **major decision** (tech stack, service boundary, data model) → update HTML section liên quan + update `notes.md`.
247
- 2. Khi user **thay đổi quyết định** → **incremental update**: chỉ sửa section liên quan; giữ nguyên tất cả sections khác. Thêm `data-updated="true"` attribute + class `.updated` CSS highlight (yellow left border + "updated" badge) vào element vừa đổi.
248
- 3. **`/review-arch`** command → ViePilot output bảng tóm tắt tất cả `decisions` (từ `notes.md`) + danh sách `open_questions` với status; hỏi user confirm trước khi tiếp tục.
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.
249
260
 
250
261
  #### Incremental update rule
251
262
 
252
- Khi một quyết định thay đổi:
253
- - Xác định **file HTML liên quan** ( dụ: tech stack thay đổi chỉ sửa `tech-stack.html` + `architecture.html`).
254
- - **Không** tái tạo toàn bộ workspace.
255
- - Thêm `data-updated="true"` vào `<section>` hoặc `<tr>` đã thay đổi.
256
- - Update `notes.md` YAML (`updated` date + entry tương ứng).
257
- - Giữ nguyên `decisions.html` history — chỉ thêm dòng mới hoặc update `status` field (không xóa lịch sử).
263
+ When a decision changes:
264
+ - Identify the **related HTML file** (e.g., tech stack changeonly 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.
258
297
 
259
298
  #### notes.md YAML schema
260
299
 
@@ -333,47 +372,57 @@ design_decisions:
333
372
  - decision: Authentication
334
373
  choice: "{JWT / Session / OAuth2 / API Key}"
335
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}"
336
385
  ```
337
386
 
338
387
  ### Background UI Extraction (silent mode) — ENH-026
339
388
 
340
- Chạy **ngầm** trong mọi phiên brainstorm (không cần `--ui` flag). Không ngắt hội thoại chính.
389
+ Runs **silently** in every brainstorm session (no `--ui` flag required). Does not interrupt the main conversation.
341
390
 
342
391
  #### Signal keywords
343
- Khi assistant nhận thấy bất kỳ keyword nào (case-insensitive, tiếng Việt hoặc tiếng Anh) trong tin nhắn user hoặc phần tóm tắt session:
392
+ When the assistant detects any keyword (case-insensitive, Vietnamese or English) in the user's message or session summary:
344
393
 
345
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`
346
395
 
347
396
  #### Threshold & accumulation rule
348
- - **Đếm số lần xuất hiện unique keyword** trong session đang diễn ra.
349
- - Khi đạt **≥3 unique signal occurrences**: bắt đầu **silent accumulation** — ghi nhận ý tưởng UI vào buffer `ui_idea_buffer[]` trong context session.
350
- - **Non-blocking**: không interrupt hội thoại chính, không yêu cầu user xác nhận ngay.
351
- - Mỗi entry trong buffer ghi: keyword trigger, ngữ cảnh câu nói (tóm tắt ngắn ≤20 từ).
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).
352
401
 
353
- #### Surface triggers (khi nào hỏi user)
354
- Hiển thị confirmation dialogue khi xảy ra một trong các điều kiện sau:
355
- - (a) **Topic kết thúc** — user `/topic` để chuyển sang topic mới hoặc nói "tiếp theo"
356
- - (b) **User `/save` hoặc `/review`**
357
- - (c) **≥5 signals accumulated** trong buffer
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
358
407
 
359
408
  #### Confirmation dialogue template
360
409
  ```
361
- 💡 Tôi phát hiện một số ý tưởng UI trong phiên này:
410
+ 💡 I detected some UI ideas in this session:
362
411
  - {idea 1 extracted from buffer}
363
412
  - {idea 2 extracted from buffer}
364
413
  ...
365
414
 
366
- Bạn muốn:
367
- 1. Lưu vào ui-direction/notes.md (background extraction)
368
- 2. Lưu + kích hoạt UI Direction Mode để generate HTML direction
369
- 3. Bỏ qua, tiếp tục brainstorm
415
+ What would you like to do?
416
+ 1. Save to .viepilot/ui-direction/{session-id}/notes.md (background extraction)
417
+ 2. Save + activate UI Direction Mode to generate HTML direction
418
+ 3. Discard and continue brainstorming
370
419
  ```
371
420
 
372
- **Option 1**: Ghi `## Background extracted ideas` vào `.viepilot/ui-direction/{session-id}/notes.md` (tạo file/thư mục nếu chưa ). Xóa buffer. Tiếp tục.
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.
373
422
 
374
- **Option 2**: Ghi vào notes.md (như Option 1) **+ trigger đầy đủ workflow `### UI Direction Mode`** (tạo `index.html`, `style.css`). Xóa buffer. Tiếp tục trong UI Direction Mode.
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.
375
424
 
376
- **Option 3**: Giữ nguyên buffer (không xóa, không ghi). Tiếp tục brainstorm. Re-surface tại trigger tiếp theo.
425
+ **Option 3**: Keep buffer unchanged (do not clear, do not write). Continue brainstorm. Re-surface at the next trigger.
377
426
 
378
427
  #### Auto-write path (Option 1 + 2)
379
428
  ```bash
@@ -385,66 +434,66 @@ mkdir -p .viepilot/ui-direction/{session-id}
385
434
 
386
435
  ### UI Direction — UX walkthrough & upgrade (FEAT-010)
387
436
 
388
- 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:
389
438
 
390
- - **`/research-ui`** — chạy đủ pipeline dưới đây
391
- - **`/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}`)
392
441
 
393
- 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.
394
443
 
395
- Á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”):
396
445
 
397
- #### Phase 1 — phỏng người dùng cuối
446
+ #### Phase 1 — Simulate end user
398
447
 
399
- 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).
400
- 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`).
401
- 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.
402
- 4. Tổng hợp **Voice of pseudo-user** (bullet + mức độ **low / medium / high**).
403
- 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”**):
404
- - **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.
405
- - **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.
406
- - **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 ).
407
- - **Trạng thái lỗi / validation**: message lỗi dài, nhiều lỗi cùng lúc, inline + banner.
408
- - **Empty vs cực đầy**: không dữ liệu vs max items; skeleton vs flash of long content.
409
- - **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.
410
459
 
411
- **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):
412
461
 
413
- | Archetype | Ưu tiên stress (recipe gợi ý) | Ghi chú |
414
- |-----------|------------------------------|---------|
415
- | **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 |
416
- | **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 |
417
- | **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 |
418
- | **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 |
419
- | **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 |
420
469
 
421
- 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.
422
471
 
423
- 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.
424
- 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.
425
474
 
426
475
  #### Phase 2 — UX designer + research
427
476
 
428
- 1. Đổi vai: **UX/UI designer** nhận feedback từ Phase 1 (**gồm cả Stress findings**).
429
- 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).
430
- 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.
431
- 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).
432
481
 
433
- #### Phase 3 — Cập nhật artifact
482
+ #### Phase 3 — Update artifacts
434
483
 
435
- 1. Sửa **`index.html`**, **`pages/*.html`**, **`style.css`** theo P0 → P1 trong phạm vi phiên (prototype direction, không ép production).
436
- 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).
437
- 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).
438
487
 
439
- **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**.
440
489
 
441
- Tham chiếu user: `docs/user/features/ui-direction.md`.
490
+ User reference: `docs/user/features/ui-direction.md`.
442
491
 
443
- ### Kết thúc mỗi topic
444
- - Tóm tắt decisions
492
+ ### End of each topic
493
+ - Summarize decisions
445
494
  - List action items
446
495
  - Note open questions
447
- - Nếu topic thêm/sửa capability: cập nhật **`## Phases`** trong bản nháp session (hoặc nhắc user lưu `/save`) với phase 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
448
497
  </step>
449
498
 
450
499
  <step name="project_meta_intake">
@@ -454,51 +503,51 @@ Normative contract: **`docs/dev/global-profiles.md`** (`~/.viepilot/profiles/`,
454
503
 
455
504
  ### 5.1 When this step runs
456
505
 
457
- 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**:
458
507
 
459
- 1. **Scope locked**: `## Phases` trong bản nháp session đã nội dung thật (tất cả features đã được gán phase) **hoặc** user vừa xác nhận bằng lời đã chốt scope.
460
- 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).
461
510
 
462
- **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.
463
512
 
464
- ### 5.2 Chuẩn bị registry
513
+ ### 5.2 Prepare registry
465
514
 
466
- 1. `mkdir -p "$HOME/.viepilot/profiles"` nếu cần.
467
- 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).
468
517
 
469
- ### 5.3 Disambiguation (nhiều profile / nhiều org)
518
+ ### 5.3 Disambiguation (multiple profiles / multiple orgs)
470
519
 
471
- - 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).
472
521
 
473
- ### 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)
474
523
 
475
- Với mỗi câu hỏi:
524
+ For each question:
476
525
 
477
- 1. Đưa **Proposal** ngắn (1–2 câu) suy ra từ session + phase plan.
478
- 2. User trả lời **Accept proposal** / **Edit** (ghi nhận bản user).
479
- 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.
480
529
 
481
- **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):
482
531
 
483
- | Thứ tự | Câu hỏi (gợi ý) | Map tới |
484
- |--------|------------------|---------|
485
- | 1 | Tên hiển thị org/client hoặccá nhân”? | `display_name` |
486
- | 2 | `org_tag` ngắn (vd. `acme`, `personal`)? | `org_tag` |
487
- | 3 | Branding / giọng văn (audience, tone)? | body `## Branding & voice` |
488
- | 4 | Legal / attribution công khai (nếu )? | body `## Legal & attribution` |
489
- | 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` |
490
539
 
491
- Sau đó: chốt **`profile_id`** = slug filename (`kebab-case`).
540
+ Then: finalize **`profile_id`** = slug filename (`kebab-case`).
492
541
 
493
- ### 5.5 Ghi artifact (machine + project)
542
+ ### 5.5 Write artifacts (machine + project)
494
543
 
495
- 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.
496
- 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.
497
- 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>`.
498
547
 
499
- ### 5.6 Ghi nhận trong session file
548
+ ### 5.6 Record in session file
500
549
 
501
- Trong bản nháp / file session, thêm section:
550
+ In the draft / session file, add section:
502
551
 
503
552
  ```markdown
504
553
  ## Project meta intake (FEAT-009)
@@ -508,17 +557,17 @@ Trong bản nháp / file session, thêm section:
508
557
  - **binding**: .viepilot/META.md
509
558
  ```
510
559
 
511
- 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.
512
561
 
513
- ### 5.7 Tiếp tục
562
+ ### 5.7 Continue
514
563
 
515
- 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**.
516
565
  </step>
517
566
 
518
567
  <step name="save_session">
519
568
  ## 6. Save Session
520
569
 
521
- 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`
522
571
 
523
572
  ```markdown
524
573
  # Brainstorm Session - {YYYY-MM-DD}
@@ -536,7 +585,7 @@ Tạo/cập nhật file: `docs/brainstorm/session-{YYYY-MM-DD}.md`
536
585
  ### Phase 2
537
586
  - {Feature / capability}
538
587
 
539
- ### Phase 3 ( tiếp theo)
588
+ ### Phase 3 (and beyond)
540
589
  - {Feature / capability}
541
590
 
542
591
  ## Project meta intake (FEAT-009)
@@ -546,9 +595,9 @@ Tạo/cập nhật file: `docs/brainstorm/session-{YYYY-MM-DD}.md`
546
595
  - **profile_path**:
547
596
  - **binding** (.viepilot/META.md):
548
597
 
549
- _(Đ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`.)_
550
599
 
551
- <!-- Nếu skipped: ## Meta intake waiver + do -->
600
+ <!-- If skipped: ## Meta intake waiver + reason -->
552
601
 
553
602
  ## Architecture diagram applicability inputs
554
603
 
@@ -595,15 +644,15 @@ _(Điền sau bước 5 — Project meta intake; xem `docs/dev/global-profiles.m
595
644
  - Session id: {session-id}
596
645
  - Layout: legacy (single `index.html`) | multi-page (`pages/*.html` + hub `index.html`)
597
646
  - Files:
598
- - `.viepilot/ui-direction/{session-id}/index.html` (hub hoặc single-screen)
647
+ - `.viepilot/ui-direction/{session-id}/index.html` (hub or single-screen)
599
648
  - `.viepilot/ui-direction/{session-id}/style.css`
600
649
  - `.viepilot/ui-direction/{session-id}/notes.md` (must include `## Pages inventory` when `pages/` exists)
601
650
  - `.viepilot/ui-direction/{session-id}/pages/*.html` (when multi-page)
602
651
  - Preview focus:
603
652
  - {layout/flow summary; list each page slug if multi-page}
604
653
 
605
- **UX walkthrough log** (optional; FEAT-010 + ENH-019 + ENH-020 — khi đã chạy `/research-ui`):
606
- - {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
607
656
 
608
657
  ---
609
658
 
@@ -632,6 +681,129 @@ git push
632
681
  ```
633
682
  </step>
634
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
+
635
807
  <step name="suggest_next">
636
808
  ## 7. Suggest Next Action
637
809
 
@@ -654,30 +826,34 @@ This will transform your brainstorm into:
654
826
  </process>
655
827
 
656
828
  <commands>
657
- User thể dùng các lệnh trong phiên brainstorm:
658
-
659
- - `/topic {name}` - Chuyển sang topic mới
660
- - `/summary` - Xem tóm tắt phiên hiện tại
661
- - `/save` - Lưu tiến độ ngay
662
- - `/end` - Kết thúc lưu phiên (sau **bước 5 — Project meta intake** khi binding thiếu; xem workflow)
663
- - `/questions` - Xem danh sách open questions
664
- - `/research {topic}` - Research nhanh ngay trong phiên quay lại topic hiện tại
665
- - `/research-ui` — UX walkthrough: phỏng user → designer + research → cập nhật UI direction + log (`notes.md`) — chỉ khi UI session (FEAT-010)
666
- - `/research ui` — alias của `/research-ui`
667
- - `/review-arch` — Architect Mode: output bảng tóm tắt decisions + open_questions từ `notes.md`, confirm trước khi tiếp tục (FEAT-011)
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
668
842
  </commands>
669
843
 
670
844
  <success_criteria>
671
- - [ ] Session file created với đầy đủ sections
672
- - [ ] `## Phases` present với ít nhất Phase 1 nội dung thật
673
- - [ ] 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
674
848
  - [ ] Open questions tracked
675
849
  - [ ] Action items captured
676
850
  - [ ] Landing page topics trigger layout follow-up questions
677
- - [ ] 21st.dev references được dùng khi thảo luận landing page
678
- - [ ] Research thể chạy ngay trong brainstorm session khi user yêu cầu
679
- - [ ] **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
680
854
  - [ ] Git committed
681
- - [ ] **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
682
- - [ ] **`## 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
683
859
  </success_criteria>