@nclamvn/vibecode-cli 1.7.0 → 1.8.1
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/SESSION_NOTES.md +119 -0
- package/bin/vibecode.js +53 -0
- package/package.json +1 -1
- package/src/commands/ask.js +230 -0
- package/src/commands/docs.js +167 -0
- package/src/commands/git.js +103 -2
- package/src/commands/migrate.js +341 -0
- package/src/commands/refactor.js +205 -0
- package/src/commands/review.js +126 -1
- package/src/commands/security.js +229 -0
- package/src/commands/test.js +194 -0
- package/src/config/constants.js +5 -1
- package/src/index.js +8 -0
- package/docs-site/README.md +0 -41
- package/docs-site/blog/2019-05-28-first-blog-post.md +0 -12
- package/docs-site/blog/2019-05-29-long-blog-post.md +0 -44
- package/docs-site/blog/2021-08-01-mdx-blog-post.mdx +0 -24
- package/docs-site/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg +0 -0
- package/docs-site/blog/2021-08-26-welcome/index.md +0 -29
- package/docs-site/blog/authors.yml +0 -25
- package/docs-site/blog/tags.yml +0 -19
- package/docs-site/docs/commands/agent.md +0 -162
- package/docs-site/docs/commands/assist.md +0 -71
- package/docs-site/docs/commands/build.md +0 -53
- package/docs-site/docs/commands/config.md +0 -30
- package/docs-site/docs/commands/debug.md +0 -173
- package/docs-site/docs/commands/doctor.md +0 -34
- package/docs-site/docs/commands/go.md +0 -128
- package/docs-site/docs/commands/index.md +0 -79
- package/docs-site/docs/commands/init.md +0 -42
- package/docs-site/docs/commands/learn.md +0 -82
- package/docs-site/docs/commands/lock.md +0 -33
- package/docs-site/docs/commands/plan.md +0 -29
- package/docs-site/docs/commands/review.md +0 -31
- package/docs-site/docs/commands/snapshot.md +0 -34
- package/docs-site/docs/commands/start.md +0 -32
- package/docs-site/docs/commands/status.md +0 -37
- package/docs-site/docs/commands/undo.md +0 -83
- package/docs-site/docs/configuration.md +0 -72
- package/docs-site/docs/faq.md +0 -83
- package/docs-site/docs/getting-started.md +0 -119
- package/docs-site/docs/guides/agent-mode.md +0 -94
- package/docs-site/docs/guides/debug-mode.md +0 -83
- package/docs-site/docs/guides/magic-mode.md +0 -107
- package/docs-site/docs/installation.md +0 -98
- package/docs-site/docs/intro.md +0 -67
- package/docs-site/docusaurus.config.ts +0 -141
- package/docs-site/package-lock.json +0 -18039
- package/docs-site/package.json +0 -48
- package/docs-site/sidebars.ts +0 -70
- package/docs-site/src/components/HomepageFeatures/index.tsx +0 -72
- package/docs-site/src/components/HomepageFeatures/styles.module.css +0 -16
- package/docs-site/src/css/custom.css +0 -30
- package/docs-site/src/pages/index.module.css +0 -23
- package/docs-site/src/pages/index.tsx +0 -44
- package/docs-site/src/pages/markdown-page.md +0 -7
- package/docs-site/src/theme/Footer/index.tsx +0 -127
- package/docs-site/src/theme/Footer/styles.module.css +0 -285
- package/docs-site/static/.nojekyll +0 -0
- package/docs-site/static/img/docusaurus-social-card.jpg +0 -0
- package/docs-site/static/img/docusaurus.png +0 -0
- package/docs-site/static/img/favicon.ico +0 -0
- package/docs-site/static/img/logo.svg +0 -1
- package/docs-site/static/img/undraw_docusaurus_mountain.svg +0 -171
- package/docs-site/static/img/undraw_docusaurus_react.svg +0 -170
- package/docs-site/static/img/undraw_docusaurus_tree.svg +0 -40
- package/docs-site/tsconfig.json +0 -8
package/SESSION_NOTES.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# VIBECODE CLI - SESSION NOTES
|
|
2
|
+
> Cập nhật: 2025-12-22
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## 📍 TRẠNG THÁI HIỆN TẠI
|
|
7
|
+
|
|
8
|
+
### ✅ ĐÃ HOÀN THÀNH
|
|
9
|
+
|
|
10
|
+
1. **Landing Page** - Port design Notion + Anthropic style
|
|
11
|
+
- File: `docs-site/src/pages/index.tsx`
|
|
12
|
+
- Style: WHITE background (#FAFAFA), Be Vietnam Pro font
|
|
13
|
+
- Sections: Hero, Terminal, Process, Features, Philosophy, CTA
|
|
14
|
+
|
|
15
|
+
2. **i18n Vietnamese** - Đa ngôn ngữ EN/VI
|
|
16
|
+
- Translations: `docs-site/i18n/vi/`
|
|
17
|
+
- Docs tiếng Việt đầy đủ 26 commands
|
|
18
|
+
|
|
19
|
+
3. **GitHub Repos** (Private)
|
|
20
|
+
- CLI: https://github.com/nclamvn/vibecode-cli
|
|
21
|
+
- Docs: https://github.com/nclamvn/vibecode-docs
|
|
22
|
+
|
|
23
|
+
4. **NPM Package** - Deprecated (beta warning)
|
|
24
|
+
- Package: @nclamvn/vibecode-cli
|
|
25
|
+
- Status: Deprecated với message cảnh báo beta
|
|
26
|
+
|
|
27
|
+
5. **UI Fixes**
|
|
28
|
+
- Loại bỏ logo khủng long
|
|
29
|
+
- Footer màu đen đồng nhất (#0A0A0A)
|
|
30
|
+
- Theme toggle icon thu nhỏ 60%
|
|
31
|
+
- Default: Light mode
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🚧 ĐANG LÀM
|
|
36
|
+
|
|
37
|
+
### Deploy Render
|
|
38
|
+
- Repo: nclamvn/vibecode-docs
|
|
39
|
+
- File: render.yaml đã có
|
|
40
|
+
- **BƯỚC TIẾP THEO**: Điền `build` vào Publish Directory rồi click Deploy
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 📁 CẤU TRÚC PROJECT
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
/Users/mac/vibecode-cli/
|
|
48
|
+
├── src/ # CLI source (26 commands)
|
|
49
|
+
├── bin/vibecode.js # Entry point
|
|
50
|
+
├── package.json # v1.8.0
|
|
51
|
+
├── docs-site/ # Docusaurus site (separate git repo)
|
|
52
|
+
│ ├── src/pages/index.tsx # Landing page
|
|
53
|
+
│ ├── docs/ # English docs
|
|
54
|
+
│ ├── i18n/vi/ # Vietnamese docs
|
|
55
|
+
│ └── render.yaml # Render deploy config
|
|
56
|
+
└── SESSION_NOTES.md # File này
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🔧 COMMANDS THƯỜNG DÙNG
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Dev server
|
|
65
|
+
cd /Users/mac/vibecode-cli/docs-site
|
|
66
|
+
npm start
|
|
67
|
+
|
|
68
|
+
# Build
|
|
69
|
+
npm run build
|
|
70
|
+
|
|
71
|
+
# Push docs
|
|
72
|
+
cd /Users/mac/vibecode-cli/docs-site
|
|
73
|
+
git add . && git commit -m "message" && git push
|
|
74
|
+
|
|
75
|
+
# Push CLI
|
|
76
|
+
cd /Users/mac/vibecode-cli
|
|
77
|
+
git add . && git commit -m "message" && git push
|
|
78
|
+
|
|
79
|
+
# Bỏ deprecate npm khi sẵn sàng
|
|
80
|
+
npm deprecate @nclamvn/vibecode-cli ""
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 📊 THỐNG KÊ
|
|
86
|
+
|
|
87
|
+
| Metric | Value |
|
|
88
|
+
|--------|-------|
|
|
89
|
+
| CLI Commands | 26 |
|
|
90
|
+
| Lines of Code | 18,612 |
|
|
91
|
+
| JS Files | 167 |
|
|
92
|
+
| Docs Pages | 40+ (EN + VI) |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 🎯 VIỆC CẦN LÀM TIẾP
|
|
97
|
+
|
|
98
|
+
1. [ ] Hoàn thành deploy Render
|
|
99
|
+
2. [ ] Test site trên production URL
|
|
100
|
+
3. [ ] Phase L: Unit Tests & TypeScript (optional)
|
|
101
|
+
4. [ ] Khi sẵn sàng: Bỏ deprecate npm package
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 🔗 LINKS
|
|
106
|
+
|
|
107
|
+
- Landing EN: http://localhost:3000/
|
|
108
|
+
- Landing VI: http://localhost:3000/vi/
|
|
109
|
+
- GitHub CLI: https://github.com/nclamvn/vibecode-cli
|
|
110
|
+
- GitHub Docs: https://github.com/nclamvn/vibecode-docs
|
|
111
|
+
- NPM: https://www.npmjs.com/package/@nclamvn/vibecode-cli
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 💬 ĐỂ TIẾP TỤC
|
|
116
|
+
|
|
117
|
+
Chỉ cần nói: **"tiếp tục"** hoặc **"continue"**
|
|
118
|
+
|
|
119
|
+
Claude sẽ đọc file này và biết cần làm gì tiếp.
|
package/bin/vibecode.js
CHANGED
|
@@ -26,6 +26,13 @@ import {
|
|
|
26
26
|
gitCommand,
|
|
27
27
|
watchCommand,
|
|
28
28
|
shellCommand,
|
|
29
|
+
// Phase K Commands
|
|
30
|
+
testCommand,
|
|
31
|
+
docsCommand,
|
|
32
|
+
refactorCommand,
|
|
33
|
+
securityCommand,
|
|
34
|
+
askCommand,
|
|
35
|
+
migrateCommand,
|
|
29
36
|
VERSION
|
|
30
37
|
} from '../src/index.js';
|
|
31
38
|
|
|
@@ -98,6 +105,8 @@ program
|
|
|
98
105
|
.command('review')
|
|
99
106
|
.description('Review build against acceptance criteria')
|
|
100
107
|
.option('--skip-manual', 'Skip manual verification prompts')
|
|
108
|
+
.option('--ai', 'AI-powered code review')
|
|
109
|
+
.option('-p, --path <dir>', 'Specific path to review')
|
|
101
110
|
.action(reviewCommand);
|
|
102
111
|
|
|
103
112
|
program
|
|
@@ -217,6 +226,7 @@ program
|
|
|
217
226
|
.option('-a, --auto', 'Auto-stage all changes before commit')
|
|
218
227
|
.option('-m, --message <msg>', 'Commit message')
|
|
219
228
|
.option('--staged', 'Show only staged changes (for diff)')
|
|
229
|
+
.option('--review', 'AI-powered diff review')
|
|
220
230
|
.option('--count <n>', 'Number of commits to show (for log)', parseInt)
|
|
221
231
|
.option('--all', 'Include all files (for add)')
|
|
222
232
|
.action((subcommand, args, options) => {
|
|
@@ -250,6 +260,49 @@ program
|
|
|
250
260
|
.description('Interactive shell with vibecode context and AI assistance')
|
|
251
261
|
.action(shellCommand);
|
|
252
262
|
|
|
263
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
264
|
+
// Phase K Commands - Maximize Claude Code
|
|
265
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
266
|
+
|
|
267
|
+
program
|
|
268
|
+
.command('test [path]')
|
|
269
|
+
.description('🧪 Test generation and running')
|
|
270
|
+
.option('-g, --generate', 'Generate tests with AI')
|
|
271
|
+
.option('-r, --run', 'Run tests')
|
|
272
|
+
.option('-c, --coverage', 'Show coverage')
|
|
273
|
+
.action(testCommand);
|
|
274
|
+
|
|
275
|
+
program
|
|
276
|
+
.command('docs')
|
|
277
|
+
.description('📚 Generate documentation with AI')
|
|
278
|
+
.option('-g, --generate', 'Generate docs')
|
|
279
|
+
.option('-t, --type <type>', 'Doc type: readme, api, architecture, jsdoc, all')
|
|
280
|
+
.action(docsCommand);
|
|
281
|
+
|
|
282
|
+
program
|
|
283
|
+
.command('refactor [path]')
|
|
284
|
+
.description('🔄 AI-powered code refactoring')
|
|
285
|
+
.option('-t, --type <type>', 'Type: clean, dry, performance, architecture, modularize, modernize')
|
|
286
|
+
.option('-d, --description <desc>', 'Custom refactoring description')
|
|
287
|
+
.action(refactorCommand);
|
|
288
|
+
|
|
289
|
+
program
|
|
290
|
+
.command('security')
|
|
291
|
+
.description('🔒 Security audit with AI analysis')
|
|
292
|
+
.option('-f, --fix', 'Auto-fix security issues')
|
|
293
|
+
.action(securityCommand);
|
|
294
|
+
|
|
295
|
+
program
|
|
296
|
+
.command('ask [question...]')
|
|
297
|
+
.description('💬 Ask questions about your codebase')
|
|
298
|
+
.action(askCommand);
|
|
299
|
+
|
|
300
|
+
program
|
|
301
|
+
.command('migrate [description...]')
|
|
302
|
+
.description('🔄 AI-powered code migration')
|
|
303
|
+
.option('-p, --path <path>', 'Specific path to migrate')
|
|
304
|
+
.action(migrateCommand);
|
|
305
|
+
|
|
253
306
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
254
307
|
// Parse - If no command provided, show interactive wizard
|
|
255
308
|
// ─────────────────────────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// VIBECODE CLI - Ask Command
|
|
3
|
+
// Phase K6: Codebase Q&A
|
|
4
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
5
|
+
|
|
6
|
+
import { spawn } from 'child_process';
|
|
7
|
+
import fs from 'fs/promises';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import readline from 'readline';
|
|
11
|
+
|
|
12
|
+
export async function askCommand(question, options = {}) {
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
|
|
15
|
+
// If no question, enter interactive mode
|
|
16
|
+
if (!question || question.length === 0) {
|
|
17
|
+
return interactiveAsk(cwd);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const questionText = Array.isArray(question) ? question.join(' ') : question;
|
|
21
|
+
return answerQuestion(cwd, questionText);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function interactiveAsk(cwd) {
|
|
25
|
+
console.log(chalk.cyan(`
|
|
26
|
+
╭────────────────────────────────────────────────────────────────────╮
|
|
27
|
+
│ 💬 CODEBASE Q&A │
|
|
28
|
+
│ │
|
|
29
|
+
│ Ask anything about your codebase. │
|
|
30
|
+
│ Type 'exit' to quit. │
|
|
31
|
+
│ │
|
|
32
|
+
╰────────────────────────────────────────────────────────────────────╯
|
|
33
|
+
`));
|
|
34
|
+
|
|
35
|
+
const rl = readline.createInterface({
|
|
36
|
+
input: process.stdin,
|
|
37
|
+
output: process.stdout,
|
|
38
|
+
prompt: chalk.green('ask> ')
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
rl.prompt();
|
|
42
|
+
|
|
43
|
+
rl.on('line', async (line) => {
|
|
44
|
+
const input = line.trim();
|
|
45
|
+
|
|
46
|
+
if (!input) {
|
|
47
|
+
rl.prompt();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (input === 'exit' || input === 'quit' || input === 'q') {
|
|
52
|
+
console.log(chalk.cyan('\n👋 Goodbye!\n'));
|
|
53
|
+
rl.close();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await answerQuestion(cwd, input);
|
|
58
|
+
console.log('');
|
|
59
|
+
rl.prompt();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
rl.on('close', () => process.exit(0));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function answerQuestion(cwd, question) {
|
|
66
|
+
console.log(chalk.gray('\n Analyzing codebase...\n'));
|
|
67
|
+
|
|
68
|
+
// Build context
|
|
69
|
+
const projectInfo = await getProjectContext(cwd);
|
|
70
|
+
|
|
71
|
+
const prompt = `
|
|
72
|
+
# Codebase Question
|
|
73
|
+
|
|
74
|
+
## Project: ${path.basename(cwd)}
|
|
75
|
+
## Type: ${projectInfo.type}
|
|
76
|
+
|
|
77
|
+
## Project Structure:
|
|
78
|
+
${projectInfo.structure}
|
|
79
|
+
|
|
80
|
+
## Key Files:
|
|
81
|
+
${projectInfo.keyFiles.join('\n')}
|
|
82
|
+
|
|
83
|
+
## Question:
|
|
84
|
+
${question}
|
|
85
|
+
|
|
86
|
+
## Instructions:
|
|
87
|
+
1. Analyze the codebase to answer the question
|
|
88
|
+
2. Reference specific files and line numbers when applicable
|
|
89
|
+
3. Provide code examples if helpful
|
|
90
|
+
4. Be concise but thorough
|
|
91
|
+
5. If you need to look at specific files, do so
|
|
92
|
+
|
|
93
|
+
Answer the question now.
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
await runClaudeCode(prompt, cwd);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function getProjectContext(cwd) {
|
|
100
|
+
const context = {
|
|
101
|
+
type: 'unknown',
|
|
102
|
+
structure: '',
|
|
103
|
+
keyFiles: []
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Detect project type
|
|
107
|
+
try {
|
|
108
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
109
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf-8'));
|
|
110
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
111
|
+
|
|
112
|
+
if (deps.next) context.type = 'Next.js';
|
|
113
|
+
else if (deps.nuxt) context.type = 'Nuxt';
|
|
114
|
+
else if (deps['@angular/core']) context.type = 'Angular';
|
|
115
|
+
else if (deps.react) context.type = 'React';
|
|
116
|
+
else if (deps.vue) context.type = 'Vue';
|
|
117
|
+
else if (deps.svelte) context.type = 'Svelte';
|
|
118
|
+
else if (deps.express) context.type = 'Express';
|
|
119
|
+
else if (deps.fastify) context.type = 'Fastify';
|
|
120
|
+
else if (deps.koa) context.type = 'Koa';
|
|
121
|
+
else if (deps.nestjs || deps['@nestjs/core']) context.type = 'NestJS';
|
|
122
|
+
else context.type = 'Node.js';
|
|
123
|
+
} catch {
|
|
124
|
+
// Check for other project types
|
|
125
|
+
try {
|
|
126
|
+
await fs.access(path.join(cwd, 'Cargo.toml'));
|
|
127
|
+
context.type = 'Rust';
|
|
128
|
+
} catch {}
|
|
129
|
+
try {
|
|
130
|
+
await fs.access(path.join(cwd, 'go.mod'));
|
|
131
|
+
context.type = 'Go';
|
|
132
|
+
} catch {}
|
|
133
|
+
try {
|
|
134
|
+
await fs.access(path.join(cwd, 'requirements.txt'));
|
|
135
|
+
context.type = 'Python';
|
|
136
|
+
} catch {}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Get directory structure
|
|
140
|
+
context.structure = await getDirectoryTree(cwd, 3);
|
|
141
|
+
|
|
142
|
+
// Get key files
|
|
143
|
+
context.keyFiles = await findKeyFiles(cwd);
|
|
144
|
+
|
|
145
|
+
return context;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function getDirectoryTree(dir, depth, prefix = '') {
|
|
149
|
+
if (depth === 0) return '';
|
|
150
|
+
|
|
151
|
+
let result = '';
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
155
|
+
const filtered = entries.filter(e =>
|
|
156
|
+
!e.name.startsWith('.') &&
|
|
157
|
+
e.name !== 'node_modules' &&
|
|
158
|
+
e.name !== 'dist' &&
|
|
159
|
+
e.name !== 'build' &&
|
|
160
|
+
e.name !== '.next' &&
|
|
161
|
+
e.name !== 'coverage' &&
|
|
162
|
+
e.name !== '__pycache__'
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
for (const entry of filtered.slice(0, 15)) {
|
|
166
|
+
const icon = entry.isDirectory() ? '📁' : '📄';
|
|
167
|
+
result += `${prefix}${icon} ${entry.name}\n`;
|
|
168
|
+
|
|
169
|
+
if (entry.isDirectory() && depth > 1) {
|
|
170
|
+
result += await getDirectoryTree(
|
|
171
|
+
path.join(dir, entry.name),
|
|
172
|
+
depth - 1,
|
|
173
|
+
prefix + ' '
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (filtered.length > 15) {
|
|
179
|
+
result += `${prefix}... and ${filtered.length - 15} more\n`;
|
|
180
|
+
}
|
|
181
|
+
} catch {}
|
|
182
|
+
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function findKeyFiles(cwd) {
|
|
187
|
+
const keyFiles = [];
|
|
188
|
+
const importantFiles = [
|
|
189
|
+
'package.json',
|
|
190
|
+
'tsconfig.json',
|
|
191
|
+
'README.md',
|
|
192
|
+
'CLAUDE.md',
|
|
193
|
+
'.env.example',
|
|
194
|
+
'src/index.ts',
|
|
195
|
+
'src/index.js',
|
|
196
|
+
'src/main.ts',
|
|
197
|
+
'src/main.js',
|
|
198
|
+
'src/app.ts',
|
|
199
|
+
'src/app.js',
|
|
200
|
+
'app/page.tsx',
|
|
201
|
+
'app/layout.tsx',
|
|
202
|
+
'pages/index.tsx',
|
|
203
|
+
'pages/_app.tsx',
|
|
204
|
+
'prisma/schema.prisma',
|
|
205
|
+
'drizzle.config.ts',
|
|
206
|
+
'Dockerfile',
|
|
207
|
+
'docker-compose.yml'
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
for (const file of importantFiles) {
|
|
211
|
+
try {
|
|
212
|
+
await fs.access(path.join(cwd, file));
|
|
213
|
+
keyFiles.push(file);
|
|
214
|
+
} catch {}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return keyFiles;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function runClaudeCode(prompt, cwd) {
|
|
221
|
+
return new Promise((resolve) => {
|
|
222
|
+
const child = spawn('claude', ['-p', prompt, '--dangerously-skip-permissions'], {
|
|
223
|
+
cwd,
|
|
224
|
+
stdio: 'inherit'
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
child.on('close', resolve);
|
|
228
|
+
child.on('error', () => resolve());
|
|
229
|
+
});
|
|
230
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// VIBECODE CLI - Docs Command
|
|
3
|
+
// Phase K3: AI Documentation Generation
|
|
4
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
5
|
+
|
|
6
|
+
import { spawn } from 'child_process';
|
|
7
|
+
import fs from 'fs/promises';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import inquirer from 'inquirer';
|
|
11
|
+
|
|
12
|
+
export async function docsCommand(options = {}) {
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
|
|
15
|
+
if (options.generate || options.type) {
|
|
16
|
+
return generateDocs(cwd, options);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Interactive menu
|
|
20
|
+
const { action } = await inquirer.prompt([{
|
|
21
|
+
type: 'list',
|
|
22
|
+
name: 'action',
|
|
23
|
+
message: 'Documentation options:',
|
|
24
|
+
choices: [
|
|
25
|
+
{ name: '📝 Generate README.md', value: 'readme' },
|
|
26
|
+
{ name: '📚 Generate API docs', value: 'api' },
|
|
27
|
+
{ name: '🏗️ Generate Architecture docs', value: 'architecture' },
|
|
28
|
+
{ name: '💬 Add JSDoc comments', value: 'jsdoc' },
|
|
29
|
+
{ name: '📦 Generate all docs', value: 'all' },
|
|
30
|
+
{ name: '👋 Exit', value: 'exit' }
|
|
31
|
+
]
|
|
32
|
+
}]);
|
|
33
|
+
|
|
34
|
+
if (action === 'exit') return;
|
|
35
|
+
|
|
36
|
+
return generateDocs(cwd, { ...options, type: action });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function generateDocs(cwd, options) {
|
|
40
|
+
const docType = options.type || 'all';
|
|
41
|
+
|
|
42
|
+
console.log(chalk.cyan(`
|
|
43
|
+
╭────────────────────────────────────────────────────────────────────╮
|
|
44
|
+
│ 📚 DOCUMENTATION GENERATION │
|
|
45
|
+
│ │
|
|
46
|
+
│ Type: ${docType.padEnd(56)}│
|
|
47
|
+
│ │
|
|
48
|
+
╰────────────────────────────────────────────────────────────────────╯
|
|
49
|
+
`));
|
|
50
|
+
|
|
51
|
+
const prompts = {
|
|
52
|
+
readme: `
|
|
53
|
+
# Generate README.md
|
|
54
|
+
|
|
55
|
+
Analyze this project and generate a comprehensive README.md:
|
|
56
|
+
|
|
57
|
+
1. **Project Title & Description**: What does this project do?
|
|
58
|
+
2. **Features**: Key features list with brief descriptions
|
|
59
|
+
3. **Installation**: Step-by-step installation guide
|
|
60
|
+
4. **Usage**: Basic usage examples with code snippets
|
|
61
|
+
5. **API Reference**: Main functions/endpoints (brief overview)
|
|
62
|
+
6. **Configuration**: Environment variables, config files
|
|
63
|
+
7. **Contributing**: How to contribute
|
|
64
|
+
8. **License**: MIT or detected license
|
|
65
|
+
|
|
66
|
+
Make it professional, clear, and helpful. Include badges if appropriate.
|
|
67
|
+
`,
|
|
68
|
+
api: `
|
|
69
|
+
# Generate API Documentation
|
|
70
|
+
|
|
71
|
+
Analyze the codebase and generate API documentation:
|
|
72
|
+
|
|
73
|
+
1. For each public function/method:
|
|
74
|
+
- Name, description
|
|
75
|
+
- Parameters with types
|
|
76
|
+
- Return value
|
|
77
|
+
- Example usage
|
|
78
|
+
- Throws/errors
|
|
79
|
+
|
|
80
|
+
2. For REST endpoints (if any):
|
|
81
|
+
- Method, path
|
|
82
|
+
- Request body
|
|
83
|
+
- Response format
|
|
84
|
+
- Status codes
|
|
85
|
+
- Example requests/responses
|
|
86
|
+
|
|
87
|
+
3. For React components (if any):
|
|
88
|
+
- Props with types
|
|
89
|
+
- Usage examples
|
|
90
|
+
|
|
91
|
+
Output in Markdown format suitable for docs site.
|
|
92
|
+
Create docs/API.md
|
|
93
|
+
`,
|
|
94
|
+
architecture: `
|
|
95
|
+
# Generate Architecture Documentation
|
|
96
|
+
|
|
97
|
+
Analyze and document the architecture:
|
|
98
|
+
|
|
99
|
+
1. **System Overview**: High-level description
|
|
100
|
+
2. **Directory Structure**: Explain each folder's purpose
|
|
101
|
+
3. **Core Components**: Main modules and their responsibilities
|
|
102
|
+
4. **Data Flow**: How data moves through the system
|
|
103
|
+
5. **Dependencies**: Key dependencies and why they're used
|
|
104
|
+
6. **Diagrams**: Generate Mermaid diagrams for:
|
|
105
|
+
- Component diagram
|
|
106
|
+
- Sequence diagram for main flows
|
|
107
|
+
- Data model (if applicable)
|
|
108
|
+
|
|
109
|
+
Output in Markdown with Mermaid blocks.
|
|
110
|
+
Create docs/ARCHITECTURE.md
|
|
111
|
+
`,
|
|
112
|
+
jsdoc: `
|
|
113
|
+
# Add JSDoc Comments
|
|
114
|
+
|
|
115
|
+
For each function, class, and method in the codebase:
|
|
116
|
+
|
|
117
|
+
1. Add JSDoc comments with:
|
|
118
|
+
- @description - What it does
|
|
119
|
+
- @param for each parameter with type and description
|
|
120
|
+
- @returns - Return value with type
|
|
121
|
+
- @throws (if applicable)
|
|
122
|
+
- @example - Usage example
|
|
123
|
+
|
|
124
|
+
2. Add type annotations where missing
|
|
125
|
+
3. Don't modify function logic, only add comments
|
|
126
|
+
4. Use TypeScript types in JSDoc if .ts files
|
|
127
|
+
|
|
128
|
+
Apply to all .js/.ts files in src/
|
|
129
|
+
`,
|
|
130
|
+
all: `
|
|
131
|
+
# Generate Complete Documentation
|
|
132
|
+
|
|
133
|
+
Create comprehensive documentation:
|
|
134
|
+
|
|
135
|
+
1. **README.md** - Project overview, installation, usage
|
|
136
|
+
2. **docs/API.md** - API reference
|
|
137
|
+
3. **docs/ARCHITECTURE.md** - System architecture with diagrams
|
|
138
|
+
4. Add JSDoc comments to key source files
|
|
139
|
+
|
|
140
|
+
Make documentation professional and thorough.
|
|
141
|
+
`
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const prompt = prompts[docType] || prompts.all;
|
|
145
|
+
|
|
146
|
+
const promptFile = path.join(cwd, '.vibecode', 'docs-prompt.md');
|
|
147
|
+
await fs.mkdir(path.dirname(promptFile), { recursive: true });
|
|
148
|
+
await fs.writeFile(promptFile, prompt);
|
|
149
|
+
|
|
150
|
+
console.log(chalk.gray(' Generating documentation with Claude Code...\n'));
|
|
151
|
+
|
|
152
|
+
await runClaudeCode(prompt, cwd);
|
|
153
|
+
|
|
154
|
+
console.log(chalk.green('\n✅ Documentation generated!\n'));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function runClaudeCode(prompt, cwd) {
|
|
158
|
+
return new Promise((resolve) => {
|
|
159
|
+
const child = spawn('claude', ['-p', prompt, '--dangerously-skip-permissions'], {
|
|
160
|
+
cwd,
|
|
161
|
+
stdio: 'inherit'
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
child.on('close', resolve);
|
|
165
|
+
child.on('error', () => resolve());
|
|
166
|
+
});
|
|
167
|
+
}
|