@nclamvn/vibecode-cli 1.2.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nclamvn/vibecode-cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Build software with discipline - AI coding with guardrails",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -487,11 +487,12 @@ Starting build-test-fix loop...`;
487
487
  );
488
488
  await writeSessionFile('build_report.md', reportContent);
489
489
 
490
- // Update state
491
- stateData.build_completed = endTime;
492
- stateData.iterations = iterationState.currentIteration;
493
- stateData.iteration_result = loopResult.success ? 'success' : 'failed';
494
- await saveState(stateData);
490
+ // Update state - RELOAD to get current state (after BUILD_IN_PROGRESS transition)
491
+ const finalStateData = await loadState();
492
+ finalStateData.build_completed = endTime;
493
+ finalStateData.iterations = iterationState.currentIteration;
494
+ finalStateData.iteration_result = loopResult.success ? 'success' : 'failed';
495
+ await saveState(finalStateData);
495
496
 
496
497
  console.log();
497
498
  console.log(chalk.cyan('─'.repeat(60)));
@@ -45,7 +45,7 @@ export async function planCommand(options = {}) {
45
45
  const sessionPath = await getCurrentSessionPath();
46
46
  const specHash = await getSpecHash();
47
47
 
48
- // Read contract and blueprint
48
+ // Read contract, blueprint, and intake
49
49
  spinner.text = 'Reading contract...';
50
50
  const contractContent = await readSessionFile('contract.md');
51
51
 
@@ -54,6 +54,11 @@ export async function planCommand(options = {}) {
54
54
  blueprintContent = await readSessionFile('blueprint.md');
55
55
  }
56
56
 
57
+ let intakeContent = '';
58
+ if (await sessionFileExists('intake.md')) {
59
+ intakeContent = await readSessionFile('intake.md');
60
+ }
61
+
57
62
  // Generate plan
58
63
  spinner.text = 'Generating plan...';
59
64
  const planContent = getPlanTemplate(projectName, sessionId, specHash, contractContent);
@@ -66,7 +71,8 @@ export async function planCommand(options = {}) {
66
71
  sessionId,
67
72
  specHash,
68
73
  contractContent,
69
- blueprintContent
74
+ blueprintContent,
75
+ intakeContent
70
76
  );
71
77
  await writeSessionFile('coder_pack.md', coderPackContent);
72
78
 
@@ -124,11 +124,39 @@ src/
124
124
  }
125
125
 
126
126
  /**
127
- * Get contract template
127
+ * Get contract template with content extracted from intake and blueprint
128
128
  */
129
- export function getContractTemplate(projectName, sessionId) {
129
+ export function getContractTemplate(projectName, sessionId, intakeContent = '', blueprintContent = '') {
130
130
  const timestamp = new Date().toISOString();
131
131
 
132
+ // Extract goal from intake (look for "Mô tả dự án" section)
133
+ let goal = extractSection(intakeContent, '## 🎯 Mô tả dự án', '---') ||
134
+ extractSection(intakeContent, '## Mô tả dự án', '---') ||
135
+ '[Define your clear, specific goal here]';
136
+
137
+ // Extract tech stack from blueprint
138
+ let techStack = extractSection(blueprintContent, '## 💻 Tech Stack', '---') || '';
139
+
140
+ // Extract architecture from blueprint
141
+ let architecture = extractSection(blueprintContent, '## 📐 Architecture', '---') || '';
142
+
143
+ // Extract file structure from blueprint
144
+ let fileStructure = extractSection(blueprintContent, '## 📁 File Structure', '---') || '';
145
+
146
+ // Generate deliverables from goal and architecture
147
+ const deliverables = generateDeliverablesFromContent(goal, techStack, architecture);
148
+
149
+ // Generate acceptance criteria from deliverables
150
+ const acceptanceCriteria = generateAcceptanceCriteria(deliverables);
151
+
152
+ // Generate in-scope items
153
+ const inScopeItems = deliverables.map(d => `- [ ] ${d.item}`).join('\n');
154
+
155
+ // Generate deliverables table
156
+ const deliverablesTable = deliverables.map((d, i) =>
157
+ `| ${i + 1} | ${d.item} | ${d.description} | ⬜ |`
158
+ ).join('\n');
159
+
132
160
  return `# 📜 CONTRACT: ${projectName}
133
161
 
134
162
  ## Session: ${sessionId}
@@ -140,22 +168,21 @@ export function getContractTemplate(projectName, sessionId) {
140
168
 
141
169
  ## 🎯 Goal
142
170
 
143
- [Define your clear, specific goal here]
171
+ ${goal.trim()}
144
172
 
145
173
  ---
146
174
 
147
175
  ## ✅ In-Scope
148
176
 
149
- - [ ] [Deliverable 1]
150
- - [ ] [Deliverable 2]
151
- - [ ] [Deliverable 3]
177
+ ${inScopeItems || '- [ ] [Deliverable 1]\n- [ ] [Deliverable 2]\n- [ ] [Deliverable 3]'}
152
178
 
153
179
  ---
154
180
 
155
181
  ## ❌ Out-of-Scope
156
182
 
157
- - [What is NOT included]
158
- - [Explicitly excluded items]
183
+ - Features not mentioned in goal
184
+ - Additional integrations not specified
185
+ - Performance optimization beyond MVP
159
186
 
160
187
  ---
161
188
 
@@ -163,14 +190,13 @@ export function getContractTemplate(projectName, sessionId) {
163
190
 
164
191
  | # | Item | Description | Status |
165
192
  |---|------|-------------|--------|
166
- | 1 | [Item] | [Description] | ⬜ |
193
+ ${deliverablesTable || '| 1 | [Item] | [Description] | ⬜ |'}
167
194
 
168
195
  ---
169
196
 
170
197
  ## ✔️ Acceptance Criteria
171
198
 
172
- - [ ] [Criterion 1]
173
- - [ ] [Criterion 2]
199
+ ${acceptanceCriteria || '- [ ] [Criterion 1]\n- [ ] [Criterion 2]'}
174
200
 
175
201
  ---
176
202
 
@@ -178,13 +204,17 @@ export function getContractTemplate(projectName, sessionId) {
178
204
 
179
205
  | Risk | Mitigation |
180
206
  |------|------------|
181
- | [Risk] | [Mitigation] |
207
+ | Dependencies unavailable | Use alternative packages |
208
+ | Scope creep | Strict contract adherence |
182
209
 
183
210
  ---
184
211
 
185
212
  ## 🔙 Rollback Plan
186
213
 
187
- [Define rollback strategy]
214
+ If build fails:
215
+ 1. Revert to last stable commit
216
+ 2. Review contract requirements
217
+ 3. Rebuild with corrections
188
218
 
189
219
  ---
190
220
 
@@ -193,6 +223,91 @@ export function getContractTemplate(projectName, sessionId) {
193
223
  `;
194
224
  }
195
225
 
226
+ /**
227
+ * Extract a section from markdown content
228
+ */
229
+ function extractSection(content, startMarker, endMarker) {
230
+ if (!content) return null;
231
+
232
+ const startIndex = content.indexOf(startMarker);
233
+ if (startIndex === -1) return null;
234
+
235
+ const contentStart = startIndex + startMarker.length;
236
+ const endIndex = content.indexOf(endMarker, contentStart);
237
+
238
+ if (endIndex === -1) {
239
+ return content.substring(contentStart).trim();
240
+ }
241
+
242
+ return content.substring(contentStart, endIndex).trim();
243
+ }
244
+
245
+ /**
246
+ * Generate deliverables from content analysis
247
+ */
248
+ function generateDeliverablesFromContent(goal, techStack, architecture) {
249
+ const deliverables = [];
250
+
251
+ // Parse goal for keywords to generate deliverables
252
+ const goalLower = goal.toLowerCase();
253
+
254
+ // Common patterns
255
+ if (goalLower.includes('landing page') || goalLower.includes('website')) {
256
+ deliverables.push({ item: 'Landing Page', description: 'Main landing page with hero section' });
257
+ deliverables.push({ item: 'Responsive Design', description: 'Mobile-friendly layout' });
258
+ }
259
+
260
+ if (goalLower.includes('cli') || goalLower.includes('command')) {
261
+ deliverables.push({ item: 'CLI Commands', description: 'Core command implementations' });
262
+ deliverables.push({ item: 'Help System', description: 'Command help and documentation' });
263
+ }
264
+
265
+ if (goalLower.includes('api') || goalLower.includes('backend')) {
266
+ deliverables.push({ item: 'API Endpoints', description: 'REST/GraphQL endpoints' });
267
+ deliverables.push({ item: 'Data Models', description: 'Database models and schemas' });
268
+ }
269
+
270
+ if (goalLower.includes('auth') || goalLower.includes('login')) {
271
+ deliverables.push({ item: 'Authentication', description: 'User login/logout flow' });
272
+ }
273
+
274
+ if (goalLower.includes('dashboard') || goalLower.includes('admin')) {
275
+ deliverables.push({ item: 'Dashboard UI', description: 'Admin dashboard interface' });
276
+ }
277
+
278
+ // Always include core deliverables if none detected
279
+ if (deliverables.length === 0) {
280
+ deliverables.push({ item: 'Core Implementation', description: 'Main functionality as described' });
281
+ deliverables.push({ item: 'UI/UX', description: 'User interface implementation' });
282
+ deliverables.push({ item: 'Documentation', description: 'Usage documentation' });
283
+ }
284
+
285
+ // Add testing if not already included
286
+ if (!deliverables.some(d => d.item.toLowerCase().includes('test'))) {
287
+ deliverables.push({ item: 'Testing', description: 'Basic functionality tests' });
288
+ }
289
+
290
+ return deliverables;
291
+ }
292
+
293
+ /**
294
+ * Generate acceptance criteria from deliverables
295
+ */
296
+ function generateAcceptanceCriteria(deliverables) {
297
+ if (!deliverables || deliverables.length === 0) {
298
+ return '- [ ] All features work as expected\n- [ ] No console errors\n- [ ] Documentation complete';
299
+ }
300
+
301
+ const criteria = deliverables.map(d =>
302
+ `- [ ] ${d.item} is complete and functional`
303
+ );
304
+
305
+ criteria.push('- [ ] No console errors or warnings');
306
+ criteria.push('- [ ] Code is clean and documented');
307
+
308
+ return criteria.join('\n');
309
+ }
310
+
196
311
  /**
197
312
  * Get plan template
198
313
  */
@@ -260,9 +375,13 @@ ${deliverables}
260
375
  /**
261
376
  * Get coder pack template - instructions for AI coder
262
377
  */
263
- export function getCoderPackTemplate(projectName, sessionId, specHash, contractContent, blueprintContent) {
378
+ export function getCoderPackTemplate(projectName, sessionId, specHash, contractContent, blueprintContent, intakeContent = '') {
264
379
  const timestamp = new Date().toISOString();
265
380
 
381
+ // Extract the goal from intake for quick reference
382
+ const goalMatch = intakeContent.match(/## 🎯 Mô tả dự án\s*([\s\S]*?)(?=---|##|$)/);
383
+ const projectGoal = goalMatch ? goalMatch[1].trim() : 'See contract for details';
384
+
266
385
  return `# 🏗️ CODER PACK: ${projectName}
267
386
 
268
387
  ## Session: ${sessionId}
@@ -283,6 +402,12 @@ You are the **Thợ (Builder)**. Your job is to execute the locked contract exac
283
402
 
284
403
  ---
285
404
 
405
+ ## 🎯 PROJECT GOAL (Quick Reference)
406
+
407
+ ${projectGoal}
408
+
409
+ ---
410
+
286
411
  ## 📜 CONTRACT (LOCKED)
287
412
 
288
413
  ${contractContent}
@@ -291,7 +416,13 @@ ${contractContent}
291
416
 
292
417
  ## 📘 BLUEPRINT REFERENCE
293
418
 
294
- ${blueprintContent}
419
+ ${blueprintContent || '[No blueprint provided - follow contract specifications]'}
420
+
421
+ ---
422
+
423
+ ## 📥 ORIGINAL INTAKE
424
+
425
+ ${intakeContent || '[No intake provided]'}
295
426
 
296
427
  ---
297
428
 
@@ -114,9 +114,25 @@ export async function createBlueprint(projectName, sessionId) {
114
114
  }
115
115
 
116
116
  /**
117
- * Create contract file
117
+ * Create contract file from intake and blueprint
118
118
  */
119
119
  export async function createContract(projectName, sessionId) {
120
- const template = getContractTemplate(projectName, sessionId);
120
+ // Read intake and blueprint to extract real content
121
+ let intakeContent = '';
122
+ let blueprintContent = '';
123
+
124
+ try {
125
+ intakeContent = await readSessionFile('intake.md');
126
+ } catch (e) {
127
+ // Intake not found, use empty
128
+ }
129
+
130
+ try {
131
+ blueprintContent = await readSessionFile('blueprint.md');
132
+ } catch (e) {
133
+ // Blueprint not found, use empty
134
+ }
135
+
136
+ const template = getContractTemplate(projectName, sessionId, intakeContent, blueprintContent);
121
137
  await writeSessionFile('contract.md', template);
122
138
  }
@@ -15,6 +15,7 @@ export const CLAUDE_CODE_CONFIG = {
15
15
  command: 'claude',
16
16
  flags: [
17
17
  '--dangerously-skip-permissions', // Trust the AI - Contract đã locked
18
+ '--print', // Non-interactive mode (no TTY required)
18
19
  ],
19
20
  timeout: 30 * 60 * 1000, // 30 minutes max
20
21
  };
@@ -61,18 +62,22 @@ export async function spawnClaudeCode(prompt, options = {}) {
61
62
  await fs.default.writeFile(promptFile, prompt, 'utf-8');
62
63
 
63
64
  return new Promise((resolve, reject) => {
64
- // Use cat to pipe the prompt file content to claude
65
- const command = `cat "${promptFile}" | claude ${CLAUDE_CODE_CONFIG.flags.join(' ')}`;
65
+ // Build command with --print mode and -p for prompt file
66
+ const args = [
67
+ ...CLAUDE_CODE_CONFIG.flags,
68
+ '-p', promptFile
69
+ ];
70
+ const command = `claude ${args.map(a => `"${a}"`).join(' ')}`;
66
71
 
67
72
  // Log the command being run
68
73
  if (logPath) {
69
- appendToFile(logPath, `\n[${new Date().toISOString()}] Running: claude with prompt from ${promptFile}\n`);
74
+ appendToFile(logPath, `\n[${new Date().toISOString()}] Running: claude --print -p ${promptFile}\n`);
70
75
  }
71
76
 
72
- const proc = spawn(command, [], {
77
+ const proc = spawn('claude', args, {
73
78
  cwd: cwd || process.cwd(),
74
79
  stdio: 'inherit', // Stream directly to terminal
75
- shell: true,
80
+ shell: false, // No shell needed, safer
76
81
  });
77
82
 
78
83
  let timeoutId = setTimeout(() => {
@@ -153,7 +158,7 @@ export function getProviderInfo() {
153
158
  return {
154
159
  name: 'Claude Code',
155
160
  command: CLAUDE_CODE_CONFIG.command,
156
- mode: '--dangerously-skip-permissions',
157
- description: 'AI coding with guardrails disabled (contract-approved)'
161
+ mode: '--dangerously-skip-permissions --print',
162
+ description: 'AI coding in non-interactive mode (contract-approved)'
158
163
  };
159
164
  }