viepilot 1.0.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.
- package/CHANGELOG.md +230 -0
- package/LICENSE +23 -0
- package/README.md +550 -0
- package/bin/viepilot.cjs +222 -0
- package/bin/vp-tools.cjs +912 -0
- package/dev-install.sh +109 -0
- package/docs/README.md +125 -0
- package/docs/advanced-usage.md +366 -0
- package/docs/api/README.md +12 -0
- package/docs/api/graphql-schema.md +5 -0
- package/docs/api/kafka-events.md +5 -0
- package/docs/api/rest-api.md +19 -0
- package/docs/api/websocket-api.md +5 -0
- package/docs/dev/architecture.md +226 -0
- package/docs/dev/cli-reference.md +324 -0
- package/docs/dev/contributing.md +195 -0
- package/docs/dev/deployment.md +204 -0
- package/docs/dev/getting-started.md +16 -0
- package/docs/dev/testing.md +171 -0
- package/docs/dev/ui-components-library.md +36 -0
- package/docs/getting-started.md +163 -0
- package/docs/skills-reference.md +399 -0
- package/docs/troubleshooting.md +297 -0
- package/docs/user/faq.md +117 -0
- package/docs/user/features/autonomous-mode.md +111 -0
- package/docs/user/features/checkpoint-recovery.md +76 -0
- package/docs/user/features/debug-mode.md +77 -0
- package/docs/user/features/ui-direction.md +29 -0
- package/docs/user/quick-start.md +157 -0
- package/docs/videos/01-installation.md +113 -0
- package/docs/videos/02-first-project.md +132 -0
- package/docs/videos/03-autonomous-mode.md +147 -0
- package/install.sh +144 -0
- package/lib/cli-shared.cjs +108 -0
- package/package.json +78 -0
- package/skills/vp-audit/SKILL.md +140 -0
- package/skills/vp-auto/SKILL.md +204 -0
- package/skills/vp-brainstorm/SKILL.md +75 -0
- package/skills/vp-crystallize/SKILL.md +175 -0
- package/skills/vp-debug/SKILL.md +96 -0
- package/skills/vp-docs/SKILL.md +258 -0
- package/skills/vp-evolve/SKILL.md +165 -0
- package/skills/vp-pause/SKILL.md +150 -0
- package/skills/vp-request/SKILL.md +250 -0
- package/skills/vp-resume/SKILL.md +141 -0
- package/skills/vp-rollback/SKILL.md +116 -0
- package/skills/vp-status/SKILL.md +137 -0
- package/skills/vp-task/SKILL.md +139 -0
- package/skills/vp-ui-components/SKILL.md +64 -0
- package/templates/phase/PHASE-STATE.md +35 -0
- package/templates/phase/SPEC.md +40 -0
- package/templates/phase/SUMMARY.md +67 -0
- package/templates/phase/TASK.md +101 -0
- package/templates/phase/VERIFICATION.md +49 -0
- package/templates/project/AI-GUIDE.md +114 -0
- package/templates/project/ARCHITECTURE.md +70 -0
- package/templates/project/CHANGELOG.md +36 -0
- package/templates/project/CONTRIBUTING.md +154 -0
- package/templates/project/CONTRIBUTORS.md +41 -0
- package/templates/project/PROJECT-CONTEXT.md +74 -0
- package/templates/project/PROJECT-META.md +133 -0
- package/templates/project/README.md +197 -0
- package/templates/project/ROADMAP.md +56 -0
- package/templates/project/SYSTEM-RULES.md +368 -0
- package/templates/project/TRACKER.md +50 -0
- package/ui-components/INDEX.md +9 -0
- package/ui-components/base/button/README.md +8 -0
- package/ui-components/base/button/metadata.json +8 -0
- package/ui-components/base/card/README.md +8 -0
- package/ui-components/base/card/metadata.json +8 -0
- package/ui-components/base/input/README.md +8 -0
- package/ui-components/base/input/metadata.json +8 -0
- package/workflows/audit.md +549 -0
- package/workflows/autonomous.md +425 -0
- package/workflows/brainstorm.md +257 -0
- package/workflows/crystallize.md +418 -0
- package/workflows/debug.md +241 -0
- package/workflows/documentation.md +587 -0
- package/workflows/evolve.md +258 -0
- package/workflows/pause-work.md +255 -0
- package/workflows/request.md +534 -0
- package/workflows/resume-work.md +226 -0
- package/workflows/rollback.md +202 -0
- package/workflows/ui-components.md +109 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Contributing to ViePilot
|
|
2
|
+
|
|
3
|
+
Hướng dẫn đóng góp cho ViePilot framework.
|
|
4
|
+
|
|
5
|
+
## Development Workflow
|
|
6
|
+
|
|
7
|
+
1. Fork repository trên GitHub
|
|
8
|
+
2. Clone fork của bạn:
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/0-CODE/viepilot
|
|
11
|
+
cd viepilot
|
|
12
|
+
```
|
|
13
|
+
3. Cài đặt development mode:
|
|
14
|
+
```bash
|
|
15
|
+
./dev-install.sh
|
|
16
|
+
```
|
|
17
|
+
4. Tạo branch cho feature/fix:
|
|
18
|
+
```bash
|
|
19
|
+
git checkout -b feat/my-new-skill
|
|
20
|
+
# hoặc
|
|
21
|
+
git checkout -b fix/cli-validation-bug
|
|
22
|
+
```
|
|
23
|
+
5. Implement changes
|
|
24
|
+
6. Chạy tests:
|
|
25
|
+
```bash
|
|
26
|
+
npm test
|
|
27
|
+
```
|
|
28
|
+
7. Commit theo Conventional Commits
|
|
29
|
+
8. Submit Pull Request
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Branching Strategy
|
|
34
|
+
|
|
35
|
+
| Branch | Purpose |
|
|
36
|
+
|--------|---------|
|
|
37
|
+
| `main` | Stable releases |
|
|
38
|
+
| `develop` | Integration branch |
|
|
39
|
+
| `feat/{name}` | New features |
|
|
40
|
+
| `fix/{name}` | Bug fixes |
|
|
41
|
+
| `docs/{name}` | Documentation |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Commit Message Format
|
|
46
|
+
|
|
47
|
+
ViePilot dùng **Conventional Commits**:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
{type}({scope}): {description}
|
|
51
|
+
|
|
52
|
+
[optional body]
|
|
53
|
+
|
|
54
|
+
[optional footer]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Types
|
|
58
|
+
|
|
59
|
+
| Type | When to Use |
|
|
60
|
+
|------|-------------|
|
|
61
|
+
| `feat` | New skill, workflow, command, template |
|
|
62
|
+
| `fix` | Bug fix |
|
|
63
|
+
| `docs` | Documentation only |
|
|
64
|
+
| `style` | Formatting, no code change |
|
|
65
|
+
| `refactor` | Code change, no new feature/fix |
|
|
66
|
+
| `test` | Adding or updating tests |
|
|
67
|
+
| `chore` | Maintenance (CI, deps, etc.) |
|
|
68
|
+
|
|
69
|
+
### Scopes
|
|
70
|
+
|
|
71
|
+
| Scope | For |
|
|
72
|
+
|-------|-----|
|
|
73
|
+
| `skill` | `skills/` changes |
|
|
74
|
+
| `workflow` | `workflows/` changes |
|
|
75
|
+
| `template` | `templates/` changes |
|
|
76
|
+
| `cli` | `bin/` changes |
|
|
77
|
+
| `docs` | `docs/` changes |
|
|
78
|
+
| `test` | `tests/` changes |
|
|
79
|
+
| `ci` | `.github/` changes |
|
|
80
|
+
|
|
81
|
+
### Examples
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
feat(skill): add vp-notify for Slack notifications
|
|
85
|
+
fix(workflow): correct state tracking in autonomous mode
|
|
86
|
+
docs(readme): update installation instructions
|
|
87
|
+
test(cli): add unit tests for version command
|
|
88
|
+
chore(ci): add Node 22 to test matrix
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Adding a New Skill
|
|
94
|
+
|
|
95
|
+
1. Bắt đầu từ template:
|
|
96
|
+
```bash
|
|
97
|
+
cp -r templates/skill-template skills/vp-myskill
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
2. Edit `skills/vp-myskill/SKILL.md`:
|
|
101
|
+
```yaml
|
|
102
|
+
---
|
|
103
|
+
name: vp-myskill
|
|
104
|
+
description: "Short description"
|
|
105
|
+
version: 0.1.0
|
|
106
|
+
---
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
3. Tạo workflow tương ứng:
|
|
110
|
+
```bash
|
|
111
|
+
cp templates/workflow-template.md workflows/myskill.md
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
4. Cập nhật `ARCHITECTURE.md` với skill mới
|
|
115
|
+
|
|
116
|
+
5. Chạy audit để verify:
|
|
117
|
+
```
|
|
118
|
+
/vp-audit
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
6. Viết tests trong `tests/unit/ai-provider-compat.test.js` sẽ tự động pick up skill mới
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Adding a CLI Command
|
|
126
|
+
|
|
127
|
+
1. Mở `bin/vp-tools.cjs`
|
|
128
|
+
|
|
129
|
+
2. Thêm command vào `commands` object:
|
|
130
|
+
```javascript
|
|
131
|
+
mycommand: (args) => {
|
|
132
|
+
const projectCheck = validators.requireProjectRoot();
|
|
133
|
+
validateArgs([projectCheck]);
|
|
134
|
+
// implementation
|
|
135
|
+
console.log(formatSuccess('Done'));
|
|
136
|
+
console.log(JSON.stringify({ result: 'value' }));
|
|
137
|
+
},
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
3. Thêm help entry vào `commandHelp` object trong `commands.help`
|
|
141
|
+
|
|
142
|
+
4. Viết unit tests trong `tests/unit/validators.test.js`
|
|
143
|
+
|
|
144
|
+
5. Cập nhật `ARCHITECTURE.md` CLI count
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Code Standards
|
|
149
|
+
|
|
150
|
+
### File Structure Rules
|
|
151
|
+
|
|
152
|
+
- Skills: YAML frontmatter + XML-like tags (xem [architecture.md](architecture.md))
|
|
153
|
+
- Workflows: `<purpose>`, `<process>`, `<step name="...">`, `<success_criteria>`
|
|
154
|
+
- Templates: `{{PLACEHOLDER}}` format (ALL_CAPS)
|
|
155
|
+
- CLI: CommonJS, no external dependencies
|
|
156
|
+
|
|
157
|
+
### Comment Standards
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
// ✅ DO: Explain WHY
|
|
161
|
+
// Prevents race condition when multiple workers claim same job
|
|
162
|
+
async function claimJob(jobId) { ... }
|
|
163
|
+
|
|
164
|
+
// ❌ DON'T: State the obvious
|
|
165
|
+
const count = 0; // Initialize count to zero
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Quality Gates
|
|
169
|
+
|
|
170
|
+
Trước khi commit:
|
|
171
|
+
- [ ] No syntax errors (`node --check bin/vp-tools.cjs`)
|
|
172
|
+
- [ ] Tests pass (`npm test`)
|
|
173
|
+
- [ ] Follows file structure rules
|
|
174
|
+
- [ ] ARCHITECTURE.md updated nếu thêm skill/workflow/command
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Pull Request Process
|
|
179
|
+
|
|
180
|
+
1. Ensure tests pass: `npm test`
|
|
181
|
+
2. Update `CHANGELOG.md` nếu có feature/fix mới
|
|
182
|
+
3. Bump version nếu cần: `vp-tools version bump minor`
|
|
183
|
+
4. Submit PR với description rõ ràng
|
|
184
|
+
5. CI sẽ chạy tự động (Node 18/20/22 matrix)
|
|
185
|
+
6. Một reviewer sẽ review trong 48h
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Testing Requirements
|
|
190
|
+
|
|
191
|
+
- Unit tests cho mọi CLI command mới
|
|
192
|
+
- AI compatibility tests tự động chạy cho skills mới
|
|
193
|
+
- Coverage phải ≥ 80%
|
|
194
|
+
|
|
195
|
+
Xem [testing.md](testing.md) để biết chi tiết.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Deployment Guide
|
|
2
|
+
|
|
3
|
+
ViePilot là một local framework — không có server để deploy. "Deployment" ở đây nghĩa là **distribution**: đưa ViePilot đến máy của users.
|
|
4
|
+
|
|
5
|
+
## Distribution Methods
|
|
6
|
+
|
|
7
|
+
### Method 1: npm distribution (recommended for users)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @0/viepilot install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Direct target mode:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @0/viepilot install --target cursor-agent --yes
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Method 2: Git Clone + Install Script (maintainers/dev)
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
git clone https://github.com/0-CODE/viepilot
|
|
23
|
+
cd viepilot
|
|
24
|
+
./install.sh
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`install.sh` copies:
|
|
28
|
+
- `skills/vp-*/` → `~/.cursor/skills/`
|
|
29
|
+
- `workflows/` → `~/.cursor/viepilot/workflows/`
|
|
30
|
+
- `templates/` → `~/.cursor/viepilot/templates/`
|
|
31
|
+
- `bin/vp-tools.cjs` → `~/.local/bin/vp-tools`
|
|
32
|
+
|
|
33
|
+
### Method 3: Development Mode
|
|
34
|
+
|
|
35
|
+
Dùng khi đang develop ViePilot itself — symlinks thay vì copy:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
./dev-install.sh
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Changes to `skills/`, `workflows/`, `bin/` phản ánh ngay lập tức mà không cần reinstall.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Environments
|
|
46
|
+
|
|
47
|
+
| Environment | Purpose | Notes |
|
|
48
|
+
|-------------|---------|-------|
|
|
49
|
+
| Local dev | Developing ViePilot | Use `dev-install.sh` |
|
|
50
|
+
| User machine | Using ViePilot | Use `install.sh` |
|
|
51
|
+
| CI | Running tests | `npm ci && npm test` |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Versioning
|
|
56
|
+
|
|
57
|
+
ViePilot dùng SemVer, tracked trong `TRACKER.md`:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Check current version
|
|
61
|
+
vp-tools version get
|
|
62
|
+
|
|
63
|
+
# Bump for new features
|
|
64
|
+
vp-tools version bump minor
|
|
65
|
+
|
|
66
|
+
# Bump for bug fixes
|
|
67
|
+
vp-tools version bump patch
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Release tags (use current framework version from `vp-tools version get`):
|
|
71
|
+
```bash
|
|
72
|
+
git tag v0.8.2
|
|
73
|
+
git push origin v0.8.2
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## npm Publish Workflow
|
|
79
|
+
|
|
80
|
+
### Preflight Checklist
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm run release:checklist
|
|
84
|
+
npm run verify:release
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This verifies:
|
|
88
|
+
- CLI syntax (`vp-tools.cjs`, `viepilot.cjs`)
|
|
89
|
+
- test suite pass
|
|
90
|
+
- publish tarball preview (`npm pack --dry-run`)
|
|
91
|
+
|
|
92
|
+
### Manual Publish
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm publish --access public
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Required:
|
|
99
|
+
- npm account with publish permission for package `viepilot`
|
|
100
|
+
- `NPM_TOKEN` configured (for CI publish)
|
|
101
|
+
|
|
102
|
+
### CI Publish (GitHub Actions)
|
|
103
|
+
|
|
104
|
+
Workflow file: `.github/workflows/release-npm.yml`
|
|
105
|
+
|
|
106
|
+
Triggers:
|
|
107
|
+
- release published
|
|
108
|
+
- manual workflow dispatch
|
|
109
|
+
|
|
110
|
+
Secret required:
|
|
111
|
+
- `NPM_TOKEN` (repository secret)
|
|
112
|
+
|
|
113
|
+
### Post-publish Smoke Verification
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm run smoke:published
|
|
117
|
+
# or explicitly:
|
|
118
|
+
npx viepilot --help
|
|
119
|
+
npx @0/viepilot install --help
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Optional version pin:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
NPM_VERSION=1.0.0 npm run smoke:published
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Rollback / Mitigation
|
|
129
|
+
|
|
130
|
+
If a bad release is published:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Deprecate bad version
|
|
134
|
+
npm deprecate viepilot@<bad_version> "Deprecated due to release issue; use latest stable version"
|
|
135
|
+
|
|
136
|
+
# Publish hotfix version after fix
|
|
137
|
+
npm version patch
|
|
138
|
+
npm publish --access public
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
For dist-tag mitigation:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm dist-tag add viepilot@<stable_version> latest
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Updating ViePilot
|
|
150
|
+
|
|
151
|
+
Users cập nhật bằng cách pull và reinstall:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
cd /path/to/viepilot
|
|
155
|
+
git pull
|
|
156
|
+
./install.sh
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## CI/CD Pipeline
|
|
162
|
+
|
|
163
|
+
GitHub Actions tại `.github/workflows/ci.yml`:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
Push/PR → test (Node 18/20/22) → coverage → lint
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Jobs**:
|
|
170
|
+
1. **test**: Runs unit + integration tests on 3 Node versions
|
|
171
|
+
2. **coverage**: Generates lcov report, enforces >80% threshold
|
|
172
|
+
3. **lint**: Syntax check for CLI and test files
|
|
173
|
+
|
|
174
|
+
**Artifacts**: Coverage report (7-day retention)
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Makefile Targets
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
make help # Show available targets
|
|
182
|
+
make test # Run test suite
|
|
183
|
+
make install # Install to ~/.cursor/
|
|
184
|
+
make dev # Development mode install
|
|
185
|
+
make clean # Remove installed files
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Monitoring
|
|
191
|
+
|
|
192
|
+
ViePilot không có runtime monitoring. "Health" được kiểm tra bằng:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Check installation
|
|
196
|
+
vp-tools help
|
|
197
|
+
|
|
198
|
+
# Check project state
|
|
199
|
+
vp-tools init
|
|
200
|
+
vp-tools progress
|
|
201
|
+
|
|
202
|
+
# Check documentation sync
|
|
203
|
+
/vp-audit
|
|
204
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Getting Started (Developer)
|
|
2
|
+
|
|
3
|
+
The canonical **install + first-run** guide lives here:
|
|
4
|
+
|
|
5
|
+
➜ **[Getting Started](../getting-started.md)**
|
|
6
|
+
|
|
7
|
+
That guide covers clone, `./install.sh`, `/vp-brainstorm`, `/vp-crystallize`, and `/vp-auto`.
|
|
8
|
+
|
|
9
|
+
**Repository:** [https://github.com/0-CODE/viepilot](https://github.com/0-CODE/viepilot)
|
|
10
|
+
|
|
11
|
+
Once you are set up, continue with:
|
|
12
|
+
|
|
13
|
+
- [Architecture](architecture.md)
|
|
14
|
+
- [CLI Reference](cli-reference.md)
|
|
15
|
+
- [Contributing](contributing.md)
|
|
16
|
+
- [Testing](testing.md)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Testing Guide
|
|
2
|
+
|
|
3
|
+
ViePilot có 3 loại tests, tổng cộng **194 tests**.
|
|
4
|
+
|
|
5
|
+
## Test Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
tests/
|
|
9
|
+
├── unit/
|
|
10
|
+
│ ├── validators.test.js # 30 tests — CLI command behavior
|
|
11
|
+
│ └── ai-provider-compat.test.js # 142 tests — Skill/workflow structure
|
|
12
|
+
└── integration/
|
|
13
|
+
└── workflow.test.js # 22 tests — End-to-end workflows
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Running Tests
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# All tests
|
|
20
|
+
npm test
|
|
21
|
+
|
|
22
|
+
# With coverage report
|
|
23
|
+
npm run test:coverage
|
|
24
|
+
|
|
25
|
+
# Watch mode (re-runs on file change)
|
|
26
|
+
npm run test:watch
|
|
27
|
+
|
|
28
|
+
# Specific suite
|
|
29
|
+
npx jest tests/unit/validators.test.js
|
|
30
|
+
npx jest tests/integration/workflow.test.js
|
|
31
|
+
|
|
32
|
+
# Verbose output
|
|
33
|
+
npx jest --verbose
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Test Suites
|
|
37
|
+
|
|
38
|
+
### Unit Tests — `tests/unit/validators.test.js`
|
|
39
|
+
|
|
40
|
+
Tests CLI commands via subprocess spawning (black-box approach).
|
|
41
|
+
|
|
42
|
+
**Covers**:
|
|
43
|
+
- `current-timestamp` — all formats, `--raw` flag, invalid format rejection
|
|
44
|
+
- `task-status` — all valid statuses, invalid input rejection
|
|
45
|
+
- `commit` — message validation, `--files` flag
|
|
46
|
+
- `version` — get, bump (patch/minor/major), invalid type rejection
|
|
47
|
+
- `help` — general and command-specific help
|
|
48
|
+
- `init` — project root detection, failure outside project
|
|
49
|
+
- `progress` — phase data structure
|
|
50
|
+
- `clean --dry-run` — non-destructive behavior
|
|
51
|
+
- Unknown command — Levenshtein suggestion
|
|
52
|
+
|
|
53
|
+
**Helper**: `extractJson(stdout)` — strips ANSI codes, finds last JSON block
|
|
54
|
+
|
|
55
|
+
### AI Provider Compatibility — `tests/unit/ai-provider-compat.test.js`
|
|
56
|
+
|
|
57
|
+
Validates skill and workflow files conform to structure required by AI providers.
|
|
58
|
+
|
|
59
|
+
**Covers**:
|
|
60
|
+
- All 13 skill files have required XML-like sections
|
|
61
|
+
- `<cursor_skill_adapter>` with Skill Invocation + Tool Usage
|
|
62
|
+
- `<execution_context>` or inline `<process>` (both valid)
|
|
63
|
+
- Referenced workflows exist on disk
|
|
64
|
+
- `<success_criteria>` has at least one checkbox
|
|
65
|
+
- All 11 workflow files have `<purpose>`, `<process>`, named `<step>`, `<success_criteria>`
|
|
66
|
+
- Steps are properly closed (open count == close count)
|
|
67
|
+
- UTF-8 validity, no binary content
|
|
68
|
+
- Naming conventions (vp-{name}, kebab-case)
|
|
69
|
+
- Portable paths (no hardcoded `/Users/` in execution_context)
|
|
70
|
+
- Template `{{PLACEHOLDER}}` format
|
|
71
|
+
|
|
72
|
+
### Integration Tests — `tests/integration/workflow.test.js`
|
|
73
|
+
|
|
74
|
+
End-to-end tests using isolated temp project directories.
|
|
75
|
+
|
|
76
|
+
**Covers**:
|
|
77
|
+
- Project initialization workflow
|
|
78
|
+
- Task lifecycle: `not_started → in_progress → done`
|
|
79
|
+
- Version management sequence
|
|
80
|
+
- Commit command structure
|
|
81
|
+
- Timestamp consistency across formats
|
|
82
|
+
- `save-state` persistence (HANDOFF.json updated)
|
|
83
|
+
- `clean --dry-run` safety
|
|
84
|
+
- Error handling and graceful failures
|
|
85
|
+
|
|
86
|
+
**Setup**: Each test suite creates a fresh temp dir with minimal `.viepilot/` structure.
|
|
87
|
+
|
|
88
|
+
## Writing New Tests
|
|
89
|
+
|
|
90
|
+
### Unit Test Pattern
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
const { spawnSync } = require('child_process');
|
|
94
|
+
const CLI = path.join(__dirname, '../../bin/vp-tools.cjs');
|
|
95
|
+
|
|
96
|
+
function run(args, cwd = PROJECT_ROOT) {
|
|
97
|
+
return spawnSync('node', [CLI, ...args], {
|
|
98
|
+
cwd,
|
|
99
|
+
encoding: 'utf8',
|
|
100
|
+
env: { ...process.env, NO_COLOR: '1' },
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
test('my command returns expected output', () => {
|
|
105
|
+
const { stdout, code } = run(['my-command', 'arg']);
|
|
106
|
+
expect(code).toBe(0);
|
|
107
|
+
const data = extractJson(stdout);
|
|
108
|
+
expect(data.field).toBe('expected');
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Integration Test Pattern
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
function createTempProject() {
|
|
116
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'vp-test-'));
|
|
117
|
+
// Create minimal .viepilot/ structure
|
|
118
|
+
fs.mkdirSync(path.join(dir, '.viepilot'), { recursive: true });
|
|
119
|
+
// Write TRACKER.md, ROADMAP.md, HANDOFF.json
|
|
120
|
+
return dir;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
describe('My workflow', () => {
|
|
124
|
+
let projectDir;
|
|
125
|
+
beforeAll(() => { projectDir = createTempProject(); });
|
|
126
|
+
afterAll(() => { fs.rmSync(projectDir, { recursive: true }); });
|
|
127
|
+
|
|
128
|
+
test('workflow step works', () => {
|
|
129
|
+
const { stdout, code } = run(['command'], projectDir);
|
|
130
|
+
expect(code).toBe(0);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### AI Compatibility Test Pattern
|
|
136
|
+
|
|
137
|
+
New skills are automatically picked up by `getSkillFiles()` — no test changes needed. The existing test suite validates all `skills/vp-*/SKILL.md` files.
|
|
138
|
+
|
|
139
|
+
## Coverage
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm run test:coverage
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Coverage is collected from `bin/vp-tools.cjs`.
|
|
146
|
+
|
|
147
|
+
**Threshold**: ≥ 80% line coverage (enforced in CI).
|
|
148
|
+
|
|
149
|
+
**Report formats**: text (console) + lcov (HTML, uploaded as CI artifact).
|
|
150
|
+
|
|
151
|
+
## CI Integration
|
|
152
|
+
|
|
153
|
+
Tests run automatically on every push and PR via GitHub Actions:
|
|
154
|
+
|
|
155
|
+
```yaml
|
|
156
|
+
# .github/workflows/ci.yml
|
|
157
|
+
jobs:
|
|
158
|
+
test:
|
|
159
|
+
strategy:
|
|
160
|
+
matrix:
|
|
161
|
+
node-version: [18, 20, 22]
|
|
162
|
+
steps:
|
|
163
|
+
- run: npx jest tests/unit/ --no-coverage
|
|
164
|
+
- run: npx jest tests/integration/ --no-coverage
|
|
165
|
+
|
|
166
|
+
coverage:
|
|
167
|
+
steps:
|
|
168
|
+
- run: npx jest --coverage
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Coverage artifact is available for 7 days after each run.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# UI Components Library
|
|
2
|
+
|
|
3
|
+
Workflow curation UI components để tái sử dụng xuyên dự án.
|
|
4
|
+
|
|
5
|
+
## Stores
|
|
6
|
+
- Global: `~/.viepilot/ui-components/`
|
|
7
|
+
- Local project: `.viepilot/ui-components/`
|
|
8
|
+
|
|
9
|
+
## Skill
|
|
10
|
+
Sử dụng `/vp-ui-components` để:
|
|
11
|
+
- ingest component references (21st.dev prompt/link/snippet)
|
|
12
|
+
- phân loại taxonomy
|
|
13
|
+
- lưu artifacts chuẩn hóa
|
|
14
|
+
- cập nhật index cho tìm kiếm lại
|
|
15
|
+
|
|
16
|
+
## Artifact contract
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
{store}/{category}/{component-id}/
|
|
20
|
+
README.md
|
|
21
|
+
SOURCE.md
|
|
22
|
+
component.html
|
|
23
|
+
component.css
|
|
24
|
+
metadata.json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## metadata.json tối thiểu
|
|
28
|
+
- `id`
|
|
29
|
+
- `category`
|
|
30
|
+
- `source`
|
|
31
|
+
- `tags`
|
|
32
|
+
- `stack_notes`
|
|
33
|
+
- `status` (`raw`, `adapted`, `approved`)
|
|
34
|
+
|
|
35
|
+
## Stock components
|
|
36
|
+
ViePilot cài sẵn stock set trong `ui-components/` để dùng làm nguyên liệu thô ban đầu.
|