viepilot 1.3.1 → 1.8.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.
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Plan and run `npm` upgrade for the viepilot package (FEAT-008 / vp-tools update).
3
+ */
4
+
5
+ const path = require('path');
6
+ const { spawnSync, execFileSync } = require('child_process');
7
+ const viepilotInfo = require('./viepilot-info.cjs');
8
+
9
+ /**
10
+ * @returns {string|null} absolute path to global .../node_modules/viepilot
11
+ */
12
+ function tryGetNpmGlobalViepilotPath() {
13
+ try {
14
+ const root = execFileSync('npm', ['root', '-g'], {
15
+ encoding: 'utf8',
16
+ timeout: 10000,
17
+ windowsHide: true,
18
+ }).trim();
19
+ if (!root) return null;
20
+ return path.resolve(root, 'viepilot');
21
+ } catch (_e) {
22
+ return null;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * @param {string} viepilotPackageRoot
28
+ * @param {boolean} forceGlobal
29
+ * @param {string|null} globalViepilotPath
30
+ */
31
+ function classifyInstall(viepilotPackageRoot, forceGlobal, globalViepilotPath) {
32
+ if (forceGlobal) {
33
+ return {
34
+ mode: 'global',
35
+ cwd: undefined,
36
+ npmArgs: ['install', '-g', 'viepilot@latest'],
37
+ ambiguous: false,
38
+ };
39
+ }
40
+ const r = path.resolve(viepilotPackageRoot);
41
+ if (globalViepilotPath) {
42
+ const g = path.resolve(globalViepilotPath);
43
+ if (r === g) {
44
+ return {
45
+ mode: 'global',
46
+ cwd: undefined,
47
+ npmArgs: ['install', '-g', 'viepilot@latest'],
48
+ ambiguous: false,
49
+ };
50
+ }
51
+ }
52
+ const localSuffix = path.join('node_modules', 'viepilot');
53
+ if (r.endsWith(localSuffix)) {
54
+ const projectRoot = path.resolve(viepilotPackageRoot, '..', '..');
55
+ return {
56
+ mode: 'local',
57
+ cwd: projectRoot,
58
+ npmArgs: ['install', 'viepilot@latest'],
59
+ ambiguous: false,
60
+ };
61
+ }
62
+ return {
63
+ mode: 'global',
64
+ cwd: undefined,
65
+ npmArgs: ['install', '-g', 'viepilot@latest'],
66
+ ambiguous: true,
67
+ };
68
+ }
69
+
70
+ /**
71
+ * Rough semver compare for x.y.z (numeric segments only).
72
+ * @returns {-1|0|1|null} null if either side empty
73
+ */
74
+ function compareSemver(a, b) {
75
+ if (a == null || b == null || a === '' || b === '') return null;
76
+ const pa = String(a).split(/[.+]/).map((x) => parseInt(x, 10) || 0);
77
+ const pb = String(b).split(/[.+]/).map((x) => parseInt(x, 10) || 0);
78
+ const len = Math.max(pa.length, pb.length);
79
+ for (let i = 0; i < len; i++) {
80
+ const da = pa[i] || 0;
81
+ const db = pb[i] || 0;
82
+ if (da < db) return -1;
83
+ if (da > db) return 1;
84
+ }
85
+ return 0;
86
+ }
87
+
88
+ /**
89
+ * @param {{ startDir: string, forceGlobal?: boolean }} opts
90
+ */
91
+ function buildUpdatePlan(opts) {
92
+ const startDir = opts.startDir;
93
+ const forceGlobal = Boolean(opts.forceGlobal);
94
+ const root = viepilotInfo.resolveViepilotPackageRoot(startDir);
95
+ if (!root) {
96
+ return { ok: false, error: 'Could not locate viepilot package root' };
97
+ }
98
+
99
+ const installed = viepilotInfo.readInstalledVersion(root);
100
+ const latestResult = viepilotInfo.fetchLatestNpmVersion();
101
+
102
+ if (latestResult.ok && installed && compareSemver(installed, latestResult.version) >= 0) {
103
+ return {
104
+ ok: true,
105
+ alreadyLatest: true,
106
+ installedVersion: installed,
107
+ latestVersion: latestResult.version,
108
+ viepilotRoot: root,
109
+ };
110
+ }
111
+
112
+ const globalViepilotPath = tryGetNpmGlobalViepilotPath();
113
+ const layout = classifyInstall(root, forceGlobal, globalViepilotPath);
114
+ const displayCommand = layout.cwd
115
+ ? `(cwd ${layout.cwd}) npm ${layout.npmArgs.join(' ')}`
116
+ : `npm ${layout.npmArgs.join(' ')}`;
117
+
118
+ return {
119
+ ok: true,
120
+ alreadyLatest: false,
121
+ installedVersion: installed,
122
+ latestVersion: latestResult.ok ? latestResult.version : null,
123
+ latestNpmError: latestResult.ok ? null : latestResult.error,
124
+ viepilotRoot: root,
125
+ mode: layout.mode,
126
+ cwd: layout.cwd,
127
+ npmArgs: layout.npmArgs,
128
+ ambiguous: layout.ambiguous,
129
+ displayCommand,
130
+ };
131
+ }
132
+
133
+ /**
134
+ * @param {object} plan - from buildUpdatePlan (not alreadyLatest)
135
+ * @returns {{ ok: boolean, code?: number }}
136
+ */
137
+ function runNpmUpdate(plan) {
138
+ const r = spawnSync('npm', plan.npmArgs, {
139
+ cwd: plan.cwd,
140
+ stdio: 'inherit',
141
+ shell: false,
142
+ windowsHide: true,
143
+ });
144
+ if (r.status === 0) {
145
+ return { ok: true };
146
+ }
147
+ return { ok: false, code: r.status == null ? 1 : r.status };
148
+ }
149
+
150
+ module.exports = {
151
+ tryGetNpmGlobalViepilotPath,
152
+ classifyInstall,
153
+ compareSemver,
154
+ buildUpdatePlan,
155
+ runNpmUpdate,
156
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viepilot",
3
- "version": "1.3.1",
3
+ "version": "1.8.0",
4
4
  "description": "**Autonomous Vibe Coding Framework / Bộ khung phát triển tự động có kiểm soát**",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -16,6 +16,7 @@
16
16
  "test:watch": "jest --watch",
17
17
  "readme:sync": "node scripts/sync-readme-metrics.cjs",
18
18
  "lint:cli": "node --check bin/vp-tools.cjs && node --check bin/viepilot.cjs",
19
+ "verify:ui-direction": "node scripts/verify-ui-direction-pages.cjs",
19
20
  "verify:release": "npm run lint:cli && npm test && npm pack --dry-run",
20
21
  "prepublishOnly": "npm run verify:release",
21
22
  "smoke:published": "node scripts/smoke-published.cjs",
@@ -32,6 +32,10 @@ Auto-detect nếu đang chạy trong viepilot framework repo để thêm framewo
32
32
  - `CHANGELOG.md` vs recent git commits
33
33
  - Placeholder URLs trong `docs/` (`your-org`, `YOUR_USERNAME`, v.v.)
34
34
  - Features mới (từ phases gần đây) chưa có documentation
35
+ - `ARCHITECTURE.md` diagram applicability matrix consistency:
36
+ - `required` diagrams must have Mermaid content
37
+ - `optional` diagrams may be omitted/merged with explicit note
38
+ - `N/A` diagrams must have rationale line
35
39
 
36
40
  **Tier 3 — Stack Best Practices + Code Quality (mọi project, theo stack detect được):**
37
41
  - Detect stacks liên quan từ context/project manifests
@@ -66,7 +70,8 @@ Optional flags:
66
70
  - `--silent` : Only output if issues found
67
71
  - `--tier1` : Run Tier 1 (state consistency) only
68
72
  - `--tier2` : Run Tier 2 (docs drift) only
69
- - `--tier3` : Run Tier 3 (framework integrity) only
73
+ - `--tier3` : Run Tier 3 (stack best-practice) only
74
+ - `--tier4` : Run Tier 4 (framework integrity) only
70
75
  </context>
71
76
 
72
77
  <process>
@@ -90,6 +95,7 @@ Execute workflow from `@$HOME/.cursor/viepilot/workflows/audit.md`
90
95
  # README.md version mention
91
96
  # CHANGELOG.md vs recent commits
92
97
  # Placeholder URLs in docs/
98
+ # ARCHITECTURE.md diagram matrix consistency (required|optional|N/A)
93
99
  ```
94
100
 
95
101
  **Step 3 — Tier 3**: Stack Best Practices + Code Quality
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: vp-brainstorm
3
3
  description: "Brainstorm session để thu thập ý tưởng, quyết định cho dự án"
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  ---
6
6
 
7
7
  <cursor_skill_adapter>
@@ -25,7 +25,8 @@ Hỗ trợ:
25
25
  - Xem lại session trước đó
26
26
  - Landing page layout discovery (hỏi thêm để chốt bố cục)
27
27
  - In-session research (research ngay trong phiên brainstorm theo yêu cầu)
28
- - UI Direction mode: tạo/cập nhật HTML prototype + notes trong `.viepilot/ui-direction/{session-id}/`
28
+ - UI Direction mode: tạo/cập nhật HTML prototype + notes trong `.viepilot/ui-direction/{session-id}/` — hỗ trợ **multi-page** (`pages/{slug}.html` + hub `index.html`) và hook **`## Pages inventory`** trong `notes.md` khi có `pages/` (FEAT-007)
29
+ - **Product horizon (ENH-014):** mọi session phải duy trì **`## Product horizon`** khi thảo luận capability/milestone — tier tags `(MVP)` / `(Post-MVP)` / `(Future)`, non-goals, deferred capabilities; hoặc ghi rõ **single-release / no deferred epics** (contract: `workflows/brainstorm.md`)
29
30
 
30
31
  **Creates/Updates:**
31
32
  - `docs/brainstorm/session-{YYYY-MM-DD}.md`
@@ -56,10 +57,11 @@ Key steps:
56
57
  3. Load context if continuing
57
58
  4. Run interactive Q&A với topic-based structure
58
59
  5. Nếu topic là landing page: hỏi thêm bố cục + tham khảo `21st.dev` để đề xuất section/components
59
- 6. Nếu topic cần UI/UX: tạo/cập nhật UI Direction artifacts (`index.html`, `style.css`, `notes.md`) trong `.viepilot/ui-direction/{session-id}/`
60
+ 6. Nếu topic cần UI/UX: tạo/cập nhật UI Direction artifacts trong `.viepilot/ui-direction/{session-id}/` — legacy: `index.html` + `style.css` + `notes.md`; multi-page: thêm `pages/*.html`, `index.html` làm hub, và sau mỗi thay đổi page cập nhật **`## Pages inventory`** trong `notes.md` (xem `docs/user/features/ui-direction.md`)
60
61
  7. Nếu user yêu cầu research hoặc cần làm rõ quyết định: research ngay trong session và quay lại topic
61
- 8. Save session with structured format (bao gồm research notes + UI direction references khi )
62
- 9. Suggest next action: `/vp-crystallize`
62
+ 8. Khi topic thêm/sửa capability hoặc release scope: cập nhật **`## Product horizon`** trong session (merge, không xóa tier tags im lặng) theo `workflows/brainstorm.md`
63
+ 9. Save session with structured format (bao gồm research notes + UI direction references + **Product horizon** khi có)
64
+ 10. Suggest next action: `/vp-crystallize`
63
65
  </process>
64
66
 
65
67
  <success_criteria>
@@ -71,5 +73,7 @@ Key steps:
71
73
  - [ ] 21st.dev references included when relevant
72
74
  - [ ] Research can be executed inside the same brainstorm session
73
75
  - [ ] UI Direction artifacts created/updated when UI mode is active
76
+ - [ ] Multi-page sessions: hub links + `## Pages inventory` stay in sync with `pages/*.html`
77
+ - [ ] `## Product horizon` present với MVP / Post-MVP / Future (hoặc explicit single-release statement) khi scope được thảo luận
74
78
  - [ ] Next steps suggested
75
79
  </success_criteria>
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: vp-crystallize
3
3
  description: "Chuyển đổi brainstorm thành executable artifacts"
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  ---
6
6
 
7
7
  <cursor_skill_adapter>
@@ -25,9 +25,9 @@ Chuyển đổi brainstorm sessions thành structured artifacts để AI có th
25
25
  ├── AI-GUIDE.md # Navigation cho AI
26
26
  ├── PROJECT-META.md # Metadata dự án
27
27
  ├── ARCHITECTURE.md # System design
28
- ├── PROJECT-CONTEXT.md # Domain knowledge
28
+ ├── PROJECT-CONTEXT.md # Domain knowledge + `<product_vision>` (phased scope)
29
29
  ├── SYSTEM-RULES.md # Coding rules & standards
30
- ├── ROADMAP.md # Phases & tasks
30
+ ├── ROADMAP.md # MVP phases & tasks + **Post-MVP / Product horizon** block (mandatory)
31
31
  ├── TRACKER.md # Progress tracking
32
32
  ├── HANDOFF.json # Machine-readable state
33
33
  └── schemas/ # Database, API, Kafka schemas
@@ -75,12 +75,15 @@ Ask user for:
75
75
  - Load all brainstorm sessions
76
76
  - Extract: decisions, architecture, schemas, features
77
77
  - Extract selected tech stacks
78
- - Validate completeness
78
+ - **Product horizon (ENH-014):** parse each session **`## Product horizon`**; build consolidated **horizon inventory**; record **single-release** mode when stated; run **validation gate** (missing section vs multi-release discussion → stop and ask; tier conflicts → stop) — full contract: `workflows/crystallize.md` Step 1
79
+ - Validate completeness (tech stack, features, schema/API clarity, **horizon gate**)
79
80
 
80
81
  ### Step 1A: Consume UI direction (if present)
81
- - Read `.viepilot/ui-direction/{session-id}/notes.md`, `index.html`, `style.css`
82
- - Carry approved layout/component decisions into architecture + roadmap artifacts
83
- - Mark assumptions explicitly if direction artifacts are missing
82
+ - Read `.viepilot/ui-direction/{session-id}/notes.md` first, then `style.css`, then HTML:
83
+ - **Multi-page:** if `pages/*.html` exists require `## Pages inventory` in `notes.md`, validate it lists every page file, read each `pages/*.html` plus hub `index.html` for navigation.
84
+ - **Legacy:** no `pages/` read `index.html` + `style.css` as before.
85
+ - Carry approved layout/component decisions into architecture + roadmap artifacts; **architecture must reference all pages** from inventory when multi-page.
86
+ - Mark assumptions explicitly if direction artifacts are missing or inventory/files mismatch.
84
87
 
85
88
  ### Step 1B: Official stack research (mandatory)
86
89
  - For every selected stack, research official docs and authoritative sources
@@ -113,12 +116,20 @@ Ask user for:
113
116
  - Services definitions
114
117
  - Data flow
115
118
  - Technology decisions
119
+ - Build **diagram applicability matrix** for:
120
+ - `system-overview`, `data-flow`, `event-flows`, `module-dependencies`, `deployment`, `user-use-case`
121
+ - For each type assign status: `required` | `optional` | `N/A`
122
+ - Apply generation policy:
123
+ - `required` => include concrete Mermaid block
124
+ - `optional` => allow lightweight/merged representation
125
+ - `N/A` => keep section heading + one-line rationale
116
126
 
117
127
  ### Step 5: Generate PROJECT-CONTEXT.md
118
128
  - Domain knowledge
119
129
  - Business rules
120
130
  - Conventions
121
131
  - Constraints
132
+ - Fill **`<product_vision>`** from template (`templates/project/PROJECT-CONTEXT.md`): MVP boundary, Post-MVP / Future themes, anti-goals — aligned with brainstorm horizon + Step 1 inventory
122
133
 
123
134
  ### Step 6: Generate SYSTEM-RULES.md
124
135
  - Architecture rules
@@ -131,10 +142,9 @@ Ask user for:
131
142
  - Stack-specific rules from cache
132
143
 
133
144
  ### Step 7: Generate ROADMAP.md
134
- - Break into phases
135
- - Define tasks per phase
136
- - Set acceptance criteria
137
- - Add verification checkpoints
145
+ - Use `templates/project/ROADMAP.md` — **executable MVP phases** first (tasks, criteria, verification)
146
+ - **Mandatory `## Post-MVP / Product horizon`:** epic-level deferred work from horizon inventory **or** explicit single-release statement (no silent omission)
147
+ - **Self-check before finalize:** non-empty horizon inventory must appear in ROADMAP; if mismatch → stop and ask user — see `workflows/crystallize.md` Step 7
138
148
 
139
149
  ### Step 8: Generate schemas/
140
150
  - database-schema.sql
@@ -168,8 +178,11 @@ Ask user for:
168
178
  - [ ] All artifacts created in .viepilot/
169
179
  - [ ] PROJECT-META.md has complete metadata
170
180
  - [ ] SYSTEM-RULES.md has all standards
171
- - [ ] ROADMAP.md has phases with tasks
181
+ - [ ] Step 1 horizon extracted or explicit single-release recorded; validation gate satisfied
182
+ - [ ] PROJECT-CONTEXT.md includes populated **`<product_vision>`** (template placeholders filled from brainstorm)
183
+ - [ ] ROADMAP.md has MVP phases with tasks **and** mandatory Post-MVP / horizon block (or explicit single-release statement)
172
184
  - [ ] TRACKER.md initialized
173
185
  - [ ] Project files created
174
186
  - [ ] Git committed
187
+ - [ ] ARCHITECTURE diagram matrix is present and consistent (`required|optional|N/A`)
175
188
  </success_criteria>
@@ -28,6 +28,12 @@ Systematic debugging với persistent state tracking. Giúp track vấn đề qu
28
28
  - `continue` - Continue current session
29
29
  - `list` - List all sessions
30
30
  - `close` - Close current session with resolution
31
+
32
+ **Architecture diagram intake (ENH-018):**
33
+ - If `.viepilot/ARCHITECTURE.md` has diagram applicability matrix, consume it before deep debugging.
34
+ - Prioritize investigation context from diagrams marked `required`.
35
+ - For `optional` diagrams: use when available; do not block debug flow if missing.
36
+ - For `N/A` diagrams: respect rationale and avoid forcing diagram creation during debug.
31
37
  </objective>
32
38
 
33
39
  <execution_context>
@@ -79,11 +85,12 @@ Execute workflow from `@$HOME/.cursor/viepilot/workflows/debug.md`
79
85
 
80
86
  ### Key Steps
81
87
  1. **Start Session**: Gather problem description
82
- 2. **Hypothesize**: Generate possible causes
83
- 3. **Test**: Run tests to confirm/reject hypotheses
84
- 4. **Track**: Log all findings
85
- 5. **Resolve**: Document fix and root cause
86
- 6. **Close**: Mark session complete
88
+ 2. **Load Architecture Context**: Read `.viepilot/ARCHITECTURE.md` matrix status (`required|optional|N/A`) and relevant Mermaid diagrams if present
89
+ 3. **Hypothesize**: Generate possible causes
90
+ 4. **Test**: Run tests to confirm/reject hypotheses
91
+ 5. **Track**: Log all findings
92
+ 6. **Resolve**: Document fix and root cause
93
+ 7. **Close**: Mark session complete
87
94
  </process>
88
95
 
89
96
  <success_criteria>
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: vp-info
3
+ description: "Hiển thị phiên bản ViePilot, npm latest, danh sách skills/workflows qua vp-tools"
4
+ version: 0.1.0
5
+ ---
6
+
7
+ <cursor_skill_adapter>
8
+ ## A. Skill Invocation
9
+ - Skill được gọi khi user mention `vp-info`, `/vp-info`, "viepilot version", "phiên bản viepilot", "skills list bundle"
10
+ - Treat all user text after the skill mention as `{{VP_ARGS}}`
11
+
12
+ ## B. Tool Usage
13
+ Use Cursor tools: `Shell`, `ReadFile`, `Glob`, `rg`, `ApplyPatch`, `WebSearch`, `WebFetch`, `Subagent`
14
+ </cursor_skill_adapter>
15
+
16
+ <objective>
17
+ Chạy **`vp-tools info`** để lấy metadata bundle ViePilot (không cần `.viepilot/` trong project đích).
18
+
19
+ **Output hữu ích cho agent:**
20
+ - `installedVersion`, `packageName`, `packageRoot`
21
+ - `latestNpm` (ok + version hoặc lỗi mạng/registry)
22
+ - `gitHead` (nếu clone có git)
23
+ - `skills[]`: `id`, `version`, `relativePath`
24
+ - `workflows[]`: `id`, `relativePath`, `note`
25
+
26
+ Dùng **`vp-tools info --json`** khi cần parse hoặc so sánh phiên bản trong script.
27
+ </objective>
28
+
29
+ <execution_context>
30
+ @$HOME/.cursor/viepilot/bin/vp-tools.cjs
31
+ </execution_context>
32
+
33
+ <process>
34
+
35
+ ### Step 1: Resolve CLI
36
+ Ưu tiên theo thứ tự:
37
+ 1. `vp-tools info` — khi ViePilot đã có trên `PATH` (npm global hoặc shim).
38
+ 2. `node <viepilot-package>/bin/vp-tools.cjs info` — từ repo clone hoặc `node_modules/viepilot`.
39
+
40
+ ### Step 2: Chạy lệnh
41
+ ```bash
42
+ vp-tools info
43
+ # hoặc
44
+ vp-tools info --json
45
+ ```
46
+
47
+ ### Step 3: Diễn giải JSON (khi dùng `--json`)
48
+ - **`packageRoot`**: gốc package `viepilot` CLI đang resolve được.
49
+ - **`installedVersion`**: semver trong `package.json` của bundle đó.
50
+ - **`latestNpm`**: `{ ok, version }` hoặc `{ ok: false, error }`.
51
+ - **`skills`**: inventory skill trong `skills/*/SKILL.md` (version từ frontmatter).
52
+ - **`workflows`**: file `workflows/*.md`.
53
+
54
+ ### Step 4: Lỗi thường gặp
55
+ Nếu báo không tìm thấy package root: cài global (`npm i -g viepilot`), hoặc chạy từ project có dependency `viepilot`, hoặc trỏ thẳng tới `bin/vp-tools.cjs` trong clone.
56
+ </process>
57
+
58
+ <success_criteria>
59
+ - [ ] Đã gọi đúng subcommand `info` (hoặc `--json` khi cần parse)
60
+ - [ ] Nêu rõ `installedVersion` và (nếu có) `latestNpm.version`
61
+ - [ ] Khi user hỏi “có những skill nào trong bundle”, tóm tắt từ `skills[]` hoặc output bảng CLI
62
+ </success_criteria>
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: vp-update
3
+ description: "Nâng cấp package viepilot qua npm (dry-run, --yes, --global) qua vp-tools"
4
+ version: 0.1.0
5
+ ---
6
+
7
+ <cursor_skill_adapter>
8
+ ## A. Skill Invocation
9
+ - Skill được gọi khi user mention `vp-update`, `/vp-update`, "upgrade viepilot", "cập nhật viepilot npm"
10
+ - Treat all user text after the skill mention as `{{VP_ARGS}}`
11
+
12
+ ## B. Tool Usage
13
+ Use Cursor tools: `Shell`, `ReadFile`, `Glob`, `rg`, `ApplyPatch`, `WebSearch`, `WebFetch`, `Subagent`
14
+ </cursor_skill_adapter>
15
+
16
+ <objective>
17
+ Chạy **`vp-tools update`** để lên kế hoạch và (khi được xác nhận) thực thi `npm` nâng cấp `viepilot`.
18
+
19
+ **Ràng buộc an toàn:**
20
+ - **Non-interactive** (CI, agent không TTY): bắt buộc **`--dry-run`** hoặc **`--yes`**; nếu không sẽ exit lỗi.
21
+ - Luôn ưu tiên **`--dry-run`** trước khi apply, trừ khi user đã yêu cầu rõ apply.
22
+
23
+ **Phân biệt target:** trong repo **không phải** ViePilot nhưng có `node_modules/viepilot`, lệnh có thể cập nhật **local dependency**. Muốn chỉ nâng **global**, thêm **`--global`**.
24
+ </objective>
25
+
26
+ <execution_context>
27
+ @$HOME/.cursor/viepilot/bin/vp-tools.cjs
28
+ </execution_context>
29
+
30
+ <process>
31
+
32
+ ### Step 1: Dry run (mặc định khi tự động)
33
+ ```bash
34
+ vp-tools update --dry-run
35
+ ```
36
+ Đọc output: planned npm command, phiên bản hiện tại vs latest, cảnh báo ambiguous/global.
37
+
38
+ ### Step 2: Apply (sau khi user đồng ý hoặc đã yêu cầu rõ)
39
+ ```bash
40
+ vp-tools update --yes
41
+ ```
42
+ Hoặc ép global:
43
+ ```bash
44
+ vp-tools update --global --dry-run
45
+ vp-tools update --global --yes
46
+ ```
47
+
48
+ ### Step 3: Interactive
49
+ Nếu terminal tương tác và **không** có `--yes`, CLI có thể hỏi xác nhận trước khi chạy npm.
50
+
51
+ ### Step 4: Rollback gợi ý
52
+ Output dry-run/update thường gợi ý `npm install -g viepilot@<previous>` — giữ phiên bản cũ từ `vp-tools info` nếu cần hoàn tác.
53
+ </process>
54
+
55
+ <success_criteria>
56
+ - [ ] Không chạy apply trong non-interactive mà thiếu `--yes`
57
+ - [ ] Nêu rõ target (local vs global) khi user đang ở project lạ
58
+ - [ ] Ghi nhận khi đã `already up to date` (no-op thành công)
59
+ </success_criteria>
@@ -8,6 +8,8 @@
8
8
  | Tôi cần... | Đọc file | Section |
9
9
  |------------|----------|---------|
10
10
  | Hiểu project làm gì | `PROJECT-CONTEXT.md` | `<domain_knowledge>` |
11
+ | Tầm nhìn & scope theo pha (MVP / Post-MVP / Future) | `PROJECT-CONTEXT.md` | `<product_vision>` |
12
+ | Roadmap sau MVP & horizon (không chỉ task hiện tại) | `ROADMAP.md` | Sections Post-MVP / Future / product horizon |
11
13
  | Biết tech stack | `ARCHITECTURE.md` | `## Technology Decisions` |
12
14
  | Xem service nào làm gì | `ARCHITECTURE.md` | `## Services` |
13
15
  | Biết đang ở phase nào | `TRACKER.md` | `## Current State` |
@@ -36,20 +38,28 @@ Chỉ đọc:
36
38
  Đọc theo thứ tự:
37
39
  1. AI-GUIDE.md (file này)
38
40
  2. TRACKER.md → biết đang ở đâu
39
- 3. ROADMAP.md → task hiện tại
40
- 4. SYSTEM-RULES.md → coding rules
41
- 5. Schema file nếu cần
41
+ 3. PROJECT-CONTEXT.md → <product_vision> + phased scope (đọc TRƯỚC khi khóa thiết kế chi tiết)
42
+ 4. ROADMAP.md → skim Post-MVP / Future / horizon, rồi task hiện tại
43
+ 5. SYSTEM-RULES.md coding rules
44
+ 6. Schema file nếu cần
42
45
  ```
43
46
 
44
47
  ### Full Context (cho architecture decisions)
45
48
  ```
46
- Đọc thêm:
47
- 1. Standard Context +
48
- 2. ARCHITECTURE.md
49
- 3. PROJECT-CONTEXT.md
50
- 4. Brainstorm session gốc (nếu cần rationale)
49
+ Đọc theo thứ tự:
50
+ 1. AI-GUIDE.md + TRACKER.md
51
+ 2. PROJECT-CONTEXT.md → domain + <product_vision> (đầy đủ)
52
+ 3. ROADMAP.md → MVP phases + Post-MVP / horizon blocks
53
+ 4. ARCHITECTURE.md
54
+ 5. SYSTEM-RULES.md
55
+ 6. Brainstorm session gốc (nếu cần rationale chi tiết, đặc biệt cho deferred capabilities)
51
56
  ```
52
57
 
58
+ ### Product vision & roadmap horizon (trước khi “lock” architecture)
59
+
60
+ - **Không** để post-MVP chỉ tồn tại trong file brainstorm: sau `/vp-crystallize`, horizon phải nằm trong `ROADMAP.md` và vision theo pha trong `PROJECT-CONTEXT.md`.
61
+ - Trước task implementation sâu hoặc quyết định kiến trúc lớn: đọc `<product_vision>` và các section horizon trong `ROADMAP.md` **cùng lúc** với task hiện tại — tránh code MVP làm bế tắc bản sau hoặc bỏ sót ràng buộc đã thống nhất.
62
+
53
63
  ## File Relationships
54
64
 
55
65
  ```
@@ -58,7 +68,10 @@ AI-GUIDE.md (đọc đầu tiên)
58
68
  ├── TRACKER.md (state hiện tại)
59
69
  │ └── points to → current phase in ROADMAP.md
60
70
 
61
- ├── ROADMAP.md (what to do)
71
+ ├── PROJECT-CONTEXT.md (domain + <product_vision> / phased scope)
72
+ │ └── read early with → ROADMAP.md horizon blocks
73
+
74
+ ├── ROADMAP.md (what to do + Post-MVP / Future)
62
75
  │ └── tasks reference → schemas/
63
76
 
64
77
  ├── SYSTEM-RULES.md (how to code)
@@ -67,8 +80,7 @@ AI-GUIDE.md (đọc đầu tiên)
67
80
  ├── ARCHITECTURE.md (system design)
68
81
  │ └── decisions from → PROJECT-CONTEXT.md
69
82
 
70
- └── PROJECT-CONTEXT.md (domain knowledge)
71
- └── extracted from → docs/brainstorm/
83
+ └── docs/brainstorm/ (session rationale; horizon đã mirror vào ROADMAP + PROJECT-CONTEXT)
72
84
  ```
73
85
 
74
86
  ## When Creating New Files
@@ -8,6 +8,26 @@
8
8
  {{SYSTEM_DIAGRAM}}
9
9
  ```
10
10
 
11
+ ## Architecture Diagram Applicability
12
+
13
+ > Decide diagram depth from brainstorm complexity signals. Do not force all six as detailed by default.
14
+
15
+ - **Complexity**: {{ARCH_COMPLEXITY_LEVEL}} <!-- simple | moderate | complex -->
16
+ - **Services/Modules signal**: {{ARCH_SIGNAL_SERVICES}}
17
+ - **Event-driven signal**: {{ARCH_SIGNAL_EVENTS}}
18
+ - **Deployment signal**: {{ARCH_SIGNAL_DEPLOYMENT}}
19
+ - **User-flow signal**: {{ARCH_SIGNAL_USER_FLOWS}}
20
+ - **Integration signal**: {{ARCH_SIGNAL_INTEGRATIONS}}
21
+
22
+ | Diagram type | Status (`required|optional|N/A`) | Reason |
23
+ |--------------|----------------------------------|--------|
24
+ | system-overview | {{DIAGRAM_STATUS_SYSTEM_OVERVIEW}} | {{DIAGRAM_REASON_SYSTEM_OVERVIEW}} |
25
+ | data-flow | {{DIAGRAM_STATUS_DATA_FLOW}} | {{DIAGRAM_REASON_DATA_FLOW}} |
26
+ | event-flows | {{DIAGRAM_STATUS_EVENT_FLOWS}} | {{DIAGRAM_REASON_EVENT_FLOWS}} |
27
+ | module-dependencies | {{DIAGRAM_STATUS_MODULE_DEPENDENCIES}} | {{DIAGRAM_REASON_MODULE_DEPENDENCIES}} |
28
+ | deployment | {{DIAGRAM_STATUS_DEPLOYMENT}} | {{DIAGRAM_REASON_DEPLOYMENT}} |
29
+ | user-use-case | {{DIAGRAM_STATUS_USER_USE_CASE}} | {{DIAGRAM_REASON_USER_USE_CASE}} |
30
+
11
31
  ## Services
12
32
 
13
33
  {{#SERVICES}}
@@ -26,6 +46,36 @@
26
46
  {{DATA_FLOW_DIAGRAM}}
27
47
  ```
28
48
 
49
+ ### Event Flows
50
+
51
+ - **Status**: {{DIAGRAM_STATUS_EVENT_FLOWS}}
52
+ - **Not applicable rationale**: {{DIAGRAM_NA_EVENT_FLOWS}}
53
+
54
+ ```mermaid
55
+ flowchart LR
56
+ EventSource --> EventBus --> Consumer
57
+ ```
58
+
59
+ ### Module Dependencies
60
+
61
+ - **Status**: {{DIAGRAM_STATUS_MODULE_DEPENDENCIES}}
62
+ - **Not applicable rationale**: {{DIAGRAM_NA_MODULE_DEPENDENCIES}}
63
+
64
+ ```mermaid
65
+ flowchart LR
66
+ UI --> Service --> Repository
67
+ ```
68
+
69
+ ### User Use-Case Flows
70
+
71
+ - **Status**: {{DIAGRAM_STATUS_USER_USE_CASE}}
72
+ - **Not applicable rationale**: {{DIAGRAM_NA_USER_USE_CASE}}
73
+
74
+ ```mermaid
75
+ flowchart TD
76
+ User --> Action --> Outcome
77
+ ```
78
+
29
79
  ## Integration Points
30
80
 
31
81
  | Service A | Service B | Protocol | Endpoint/Topic |
@@ -62,6 +112,9 @@
62
112
  {{DEPLOYMENT_DIAGRAM}}
63
113
  ```
64
114
 
115
+ - **Status**: {{DIAGRAM_STATUS_DEPLOYMENT}}
116
+ - **Not applicable rationale**: {{DIAGRAM_NA_DEPLOYMENT}}
117
+
65
118
  ## Monitoring & Observability
66
119
 
67
120
  - **Logging**: {{LOGGING_SOLUTION}}
@@ -20,6 +20,28 @@
20
20
  {{DATA_RELATIONSHIPS}}
21
21
  </domain_knowledge>
22
22
 
23
+ <product_vision>
24
+ ## Product vision & phased scope
25
+
26
+ > Aligns with **`ROADMAP.md` → Post-MVP / Product horizon** and brainstorm tier tags `(MVP)` / `(Post-MVP)` / `(Future)`.
27
+
28
+ ### MVP boundary (ship first)
29
+
30
+ {{MVP_BOUNDARY}}
31
+
32
+ ### Post-MVP themes
33
+
34
+ {{POST_MVP_VISION}}
35
+
36
+ ### Future / exploratory north star
37
+
38
+ {{FUTURE_VISION}}
39
+
40
+ ### Anti-goals & explicit non-scope
41
+
42
+ {{VISION_NON_GOALS}}
43
+ </product_vision>
44
+
23
45
  <conventions>
24
46
  ## Naming Conventions
25
47