@nclamvn/vibecode-cli 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vibecode/learning/fixes.json +1 -0
- package/.vibecode/learning/preferences.json +1 -0
- package/README.md +310 -49
- package/SESSION_NOTES.md +154 -0
- package/bin/vibecode.js +212 -2
- package/package.json +5 -2
- package/src/agent/decomposition.js +476 -0
- package/src/agent/index.js +391 -0
- package/src/agent/memory.js +542 -0
- package/src/agent/orchestrator.js +917 -0
- package/src/agent/self-healing.js +516 -0
- package/src/commands/agent.js +349 -0
- package/src/commands/ask.js +230 -0
- package/src/commands/assist.js +413 -0
- package/src/commands/build.js +345 -4
- package/src/commands/debug.js +565 -0
- package/src/commands/docs.js +167 -0
- package/src/commands/git.js +1024 -0
- package/src/commands/go.js +387 -0
- package/src/commands/learn.js +294 -0
- package/src/commands/migrate.js +341 -0
- package/src/commands/plan.js +8 -2
- package/src/commands/refactor.js +205 -0
- package/src/commands/review.js +126 -1
- package/src/commands/security.js +229 -0
- package/src/commands/shell.js +486 -0
- package/src/commands/test.js +194 -0
- package/src/commands/undo.js +281 -0
- package/src/commands/watch.js +556 -0
- package/src/commands/wizard.js +322 -0
- package/src/config/constants.js +5 -1
- package/src/config/templates.js +146 -15
- package/src/core/backup.js +325 -0
- package/src/core/error-analyzer.js +237 -0
- package/src/core/fix-generator.js +195 -0
- package/src/core/iteration.js +226 -0
- package/src/core/learning.js +295 -0
- package/src/core/session.js +18 -2
- package/src/core/test-runner.js +281 -0
- package/src/debug/analyzer.js +329 -0
- package/src/debug/evidence.js +228 -0
- package/src/debug/fixer.js +348 -0
- package/src/debug/image-analyzer.js +304 -0
- package/src/debug/index.js +378 -0
- package/src/debug/verifier.js +346 -0
- package/src/index.js +89 -0
- package/src/providers/claude-code.js +12 -7
- package/src/ui/__tests__/error-translator.test.js +390 -0
- package/src/ui/dashboard.js +364 -0
- package/src/ui/error-translator.js +775 -0
- package/src/utils/image.js +222 -0
|
@@ -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
|
+
}
|