codebakers 2.0.1 ā 2.0.3
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/dist/index.js +1088 -131
- package/package.json +1 -1
- package/src/commands/advisors.ts +699 -0
- package/src/commands/prd.ts +419 -0
- package/src/index.ts +23 -0
- package/src/utils/config.ts +93 -1
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import * as fs from 'fs-extra';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
6
|
+
import { Config } from '../utils/config.js';
|
|
7
|
+
|
|
8
|
+
interface PRDSection {
|
|
9
|
+
title: string;
|
|
10
|
+
content: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ParsedPRD {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
features: string[];
|
|
17
|
+
pages: string[];
|
|
18
|
+
database: string[];
|
|
19
|
+
integrations: string[];
|
|
20
|
+
design: {
|
|
21
|
+
profile?: string;
|
|
22
|
+
brandColor?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function prdCommand(filePath?: string): Promise<void> {
|
|
27
|
+
const config = new Config();
|
|
28
|
+
|
|
29
|
+
if (!config.isConfigured()) {
|
|
30
|
+
p.log.error('Please run `codebakers setup` first.');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
p.intro(chalk.bgCyan.black(' Build from PRD '));
|
|
35
|
+
|
|
36
|
+
// Get PRD file
|
|
37
|
+
let prdPath = filePath;
|
|
38
|
+
if (!prdPath) {
|
|
39
|
+
const file = await p.text({
|
|
40
|
+
message: 'Path to PRD file:',
|
|
41
|
+
placeholder: './PRD.md or paste URL',
|
|
42
|
+
validate: (v) => !v ? 'File path required' : undefined,
|
|
43
|
+
});
|
|
44
|
+
if (p.isCancel(file)) return;
|
|
45
|
+
prdPath = file as string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Read PRD
|
|
49
|
+
const spinner = p.spinner();
|
|
50
|
+
spinner.start('Reading PRD...');
|
|
51
|
+
|
|
52
|
+
let prdContent: string;
|
|
53
|
+
try {
|
|
54
|
+
if (prdPath.startsWith('http')) {
|
|
55
|
+
const response = await fetch(prdPath);
|
|
56
|
+
prdContent = await response.text();
|
|
57
|
+
} else {
|
|
58
|
+
prdContent = await fs.readFile(prdPath, 'utf-8');
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
spinner.stop('Error');
|
|
62
|
+
p.log.error(`Could not read PRD: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
spinner.stop('PRD loaded');
|
|
67
|
+
|
|
68
|
+
// Parse PRD with AI
|
|
69
|
+
spinner.start('Analyzing PRD...');
|
|
70
|
+
|
|
71
|
+
const anthropicCreds = config.getCredentials('anthropic');
|
|
72
|
+
if (!anthropicCreds?.apiKey) {
|
|
73
|
+
spinner.stop('Error');
|
|
74
|
+
p.log.error('Anthropic API key not configured.');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const anthropic = new Anthropic({ apiKey: anthropicCreds.apiKey });
|
|
79
|
+
|
|
80
|
+
const parsed = await parsePRD(anthropic, prdContent);
|
|
81
|
+
spinner.stop('PRD analyzed');
|
|
82
|
+
|
|
83
|
+
// Show what was extracted
|
|
84
|
+
console.log(chalk.bold('\nš Extracted from PRD:\n'));
|
|
85
|
+
console.log(` ${chalk.cyan('Name:')} ${parsed.name}`);
|
|
86
|
+
console.log(` ${chalk.cyan('Description:')} ${parsed.description}`);
|
|
87
|
+
console.log(` ${chalk.cyan('Features:')} ${parsed.features.length} features`);
|
|
88
|
+
console.log(` ${chalk.cyan('Pages:')} ${parsed.pages.join(', ') || 'Auto-detect'}`);
|
|
89
|
+
console.log(` ${chalk.cyan('Database:')} ${parsed.database.length} tables`);
|
|
90
|
+
console.log(` ${chalk.cyan('Integrations:')} ${parsed.integrations.join(', ') || 'None'}`);
|
|
91
|
+
console.log('');
|
|
92
|
+
|
|
93
|
+
// Show features
|
|
94
|
+
if (parsed.features.length > 0) {
|
|
95
|
+
console.log(chalk.bold('Features to build:'));
|
|
96
|
+
parsed.features.slice(0, 10).forEach((f, i) => {
|
|
97
|
+
console.log(chalk.dim(` ${i + 1}. ${f}`));
|
|
98
|
+
});
|
|
99
|
+
if (parsed.features.length > 10) {
|
|
100
|
+
console.log(chalk.dim(` ... and ${parsed.features.length - 10} more`));
|
|
101
|
+
}
|
|
102
|
+
console.log('');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Confirm
|
|
106
|
+
const proceed = await p.confirm({
|
|
107
|
+
message: 'Build this project?',
|
|
108
|
+
initialValue: true,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (!proceed || p.isCancel(proceed)) {
|
|
112
|
+
p.cancel('Cancelled');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Build options
|
|
117
|
+
const options = await p.group({
|
|
118
|
+
createInfra: () => p.confirm({
|
|
119
|
+
message: 'Create GitHub + Vercel + Supabase?',
|
|
120
|
+
initialValue: true,
|
|
121
|
+
}),
|
|
122
|
+
designProfile: () => p.select({
|
|
123
|
+
message: 'Design profile:',
|
|
124
|
+
options: [
|
|
125
|
+
{ value: 'minimal', label: 'Minimal (Linear, Notion)' },
|
|
126
|
+
{ value: 'bold', label: 'Bold (Stripe, Ramp)' },
|
|
127
|
+
{ value: 'editorial', label: 'Editorial (Medium, Substack)' },
|
|
128
|
+
{ value: 'playful', label: 'Playful (Figma, Slack)' },
|
|
129
|
+
{ value: 'premium', label: 'Premium (Apple, Porsche)' },
|
|
130
|
+
{ value: 'dashboard', label: 'Dashboard (Datadog, Linear)' },
|
|
131
|
+
],
|
|
132
|
+
initialValue: parsed.design.profile || 'minimal',
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
if (p.isCancel(options)) return;
|
|
137
|
+
|
|
138
|
+
// Build the project
|
|
139
|
+
await buildFromPRD(parsed, options, anthropic, config);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function parsePRD(anthropic: Anthropic, content: string): Promise<ParsedPRD> {
|
|
143
|
+
const response = await anthropic.messages.create({
|
|
144
|
+
model: 'claude-sonnet-4-20250514',
|
|
145
|
+
max_tokens: 4096,
|
|
146
|
+
messages: [{
|
|
147
|
+
role: 'user',
|
|
148
|
+
content: `Analyze this PRD and extract structured information. Return JSON only, no explanation.
|
|
149
|
+
|
|
150
|
+
PRD:
|
|
151
|
+
${content}
|
|
152
|
+
|
|
153
|
+
Return this exact JSON structure:
|
|
154
|
+
{
|
|
155
|
+
"name": "project name (lowercase, hyphenated)",
|
|
156
|
+
"description": "one sentence description",
|
|
157
|
+
"features": ["feature 1", "feature 2", ...],
|
|
158
|
+
"pages": ["page1", "page2", ...],
|
|
159
|
+
"database": ["table1", "table2", ...],
|
|
160
|
+
"integrations": ["stripe", "supabase", ...],
|
|
161
|
+
"design": {
|
|
162
|
+
"profile": "minimal|bold|editorial|playful|premium|dashboard or null",
|
|
163
|
+
"brandColor": "#hexcolor or null"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
Extract ALL features mentioned. Include auth, payments, dashboards, etc.
|
|
168
|
+
For pages, list actual pages/routes needed.
|
|
169
|
+
For database, list tables/entities needed.
|
|
170
|
+
For integrations, list third-party services mentioned.`
|
|
171
|
+
}],
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const text = response.content[0].type === 'text' ? response.content[0].text : '';
|
|
175
|
+
|
|
176
|
+
// Extract JSON from response
|
|
177
|
+
const jsonMatch = text.match(/\{[\s\S]*\}/);
|
|
178
|
+
if (!jsonMatch) {
|
|
179
|
+
throw new Error('Could not parse PRD');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return JSON.parse(jsonMatch[0]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function buildFromPRD(
|
|
186
|
+
prd: ParsedPRD,
|
|
187
|
+
options: { createInfra: boolean; designProfile: string },
|
|
188
|
+
anthropic: Anthropic,
|
|
189
|
+
config: Config
|
|
190
|
+
): Promise<void> {
|
|
191
|
+
const spinner = p.spinner();
|
|
192
|
+
const projectPath = path.join(process.cwd(), prd.name);
|
|
193
|
+
|
|
194
|
+
// Step 1: Create project structure
|
|
195
|
+
spinner.start('Creating project structure...');
|
|
196
|
+
await fs.ensureDir(projectPath);
|
|
197
|
+
await fs.ensureDir(path.join(projectPath, '.codebakers'));
|
|
198
|
+
await fs.ensureDir(path.join(projectPath, 'src', 'app'));
|
|
199
|
+
await fs.ensureDir(path.join(projectPath, 'src', 'components'));
|
|
200
|
+
await fs.ensureDir(path.join(projectPath, 'src', 'lib'));
|
|
201
|
+
spinner.stop('Project structure created');
|
|
202
|
+
|
|
203
|
+
// Step 2: Save PRD to project
|
|
204
|
+
spinner.start('Saving PRD...');
|
|
205
|
+
await fs.writeFile(path.join(projectPath, 'PRD.md'), await fs.readFile(process.cwd(), 'utf-8').catch(() => JSON.stringify(prd, null, 2)));
|
|
206
|
+
await fs.writeJson(path.join(projectPath, '.codebakers', 'prd.json'), prd, { spaces: 2 });
|
|
207
|
+
await fs.writeJson(path.join(projectPath, '.codebakers', 'design.json'), {
|
|
208
|
+
profile: options.designProfile,
|
|
209
|
+
colors: prd.design.brandColor ? { brand: prd.design.brandColor } : undefined,
|
|
210
|
+
}, { spaces: 2 });
|
|
211
|
+
spinner.stop('PRD saved');
|
|
212
|
+
|
|
213
|
+
// Step 3: Generate build plan
|
|
214
|
+
spinner.start('Generating build plan...');
|
|
215
|
+
const buildPlan = await generateBuildPlan(anthropic, prd, options.designProfile);
|
|
216
|
+
await fs.writeJson(path.join(projectPath, '.codebakers', 'build-plan.json'), buildPlan, { spaces: 2 });
|
|
217
|
+
spinner.stop('Build plan generated');
|
|
218
|
+
|
|
219
|
+
// Show build plan
|
|
220
|
+
console.log(chalk.bold('\nšļø Build Plan:\n'));
|
|
221
|
+
buildPlan.phases.forEach((phase: any, i: number) => {
|
|
222
|
+
console.log(chalk.cyan(`Phase ${i + 1}: ${phase.name}`));
|
|
223
|
+
phase.tasks.forEach((task: string) => {
|
|
224
|
+
console.log(chalk.dim(` ⢠${task}`));
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
console.log('');
|
|
228
|
+
|
|
229
|
+
// Step 4: Execute build plan
|
|
230
|
+
const startBuild = await p.confirm({
|
|
231
|
+
message: 'Start building?',
|
|
232
|
+
initialValue: true,
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
if (!startBuild || p.isCancel(startBuild)) {
|
|
236
|
+
p.log.info(`Build plan saved to ${prd.name}/.codebakers/build-plan.json`);
|
|
237
|
+
p.log.info(`Run \`cd ${prd.name} && codebakers code\` to continue building.`);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Execute each phase
|
|
242
|
+
for (let i = 0; i < buildPlan.phases.length; i++) {
|
|
243
|
+
const phase = buildPlan.phases[i];
|
|
244
|
+
console.log(chalk.bold(`\nš¦ Phase ${i + 1}: ${phase.name}\n`));
|
|
245
|
+
|
|
246
|
+
for (const task of phase.tasks) {
|
|
247
|
+
spinner.start(task);
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
await executeTask(anthropic, projectPath, task, prd, options.designProfile);
|
|
251
|
+
spinner.stop(`ā ${task}`);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
spinner.stop(`ā ${task}`);
|
|
254
|
+
p.log.error(error instanceof Error ? error.message : 'Task failed');
|
|
255
|
+
|
|
256
|
+
const continueBuilding = await p.confirm({
|
|
257
|
+
message: 'Continue with next task?',
|
|
258
|
+
initialValue: true,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
if (!continueBuilding || p.isCancel(continueBuilding)) {
|
|
262
|
+
p.log.info('Build paused. Run `codebakers code` to continue.');
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Step 5: Infrastructure (if selected)
|
|
270
|
+
if (options.createInfra) {
|
|
271
|
+
console.log(chalk.bold('\nš Setting up infrastructure...\n'));
|
|
272
|
+
|
|
273
|
+
spinner.start('Creating GitHub repository...');
|
|
274
|
+
// Would call GitHub service
|
|
275
|
+
spinner.stop('GitHub repository created');
|
|
276
|
+
|
|
277
|
+
spinner.start('Creating Supabase project...');
|
|
278
|
+
// Would call Supabase service
|
|
279
|
+
spinner.stop('Supabase project created');
|
|
280
|
+
|
|
281
|
+
spinner.start('Creating Vercel project...');
|
|
282
|
+
// Would call Vercel service
|
|
283
|
+
spinner.stop('Vercel project created');
|
|
284
|
+
|
|
285
|
+
spinner.start('Deploying...');
|
|
286
|
+
// Would deploy
|
|
287
|
+
spinner.stop('Deployed!');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Done!
|
|
291
|
+
p.outro(chalk.green(`
|
|
292
|
+
ā Project built from PRD!
|
|
293
|
+
|
|
294
|
+
${chalk.bold('Your project:')}
|
|
295
|
+
${chalk.cyan(`cd ${prd.name}`)}
|
|
296
|
+
${chalk.cyan('npm run dev')}
|
|
297
|
+
|
|
298
|
+
${chalk.bold('Continue building:')}
|
|
299
|
+
${chalk.cyan('codebakers code')} ā AI agent
|
|
300
|
+
${chalk.cyan('codebakers check')} ā Verify patterns
|
|
301
|
+
${chalk.cyan('codebakers deploy')} ā Deploy changes
|
|
302
|
+
`));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async function generateBuildPlan(
|
|
306
|
+
anthropic: Anthropic,
|
|
307
|
+
prd: ParsedPRD,
|
|
308
|
+
designProfile: string
|
|
309
|
+
): Promise<{ phases: Array<{ name: string; tasks: string[] }> }> {
|
|
310
|
+
const response = await anthropic.messages.create({
|
|
311
|
+
model: 'claude-sonnet-4-20250514',
|
|
312
|
+
max_tokens: 4096,
|
|
313
|
+
messages: [{
|
|
314
|
+
role: 'user',
|
|
315
|
+
content: `Create a build plan for this project. Return JSON only.
|
|
316
|
+
|
|
317
|
+
Project: ${prd.name}
|
|
318
|
+
Description: ${prd.description}
|
|
319
|
+
Features: ${prd.features.join(', ')}
|
|
320
|
+
Pages: ${prd.pages.join(', ')}
|
|
321
|
+
Database tables: ${prd.database.join(', ')}
|
|
322
|
+
Integrations: ${prd.integrations.join(', ')}
|
|
323
|
+
Design: ${designProfile}
|
|
324
|
+
|
|
325
|
+
Return this structure:
|
|
326
|
+
{
|
|
327
|
+
"phases": [
|
|
328
|
+
{
|
|
329
|
+
"name": "Phase name",
|
|
330
|
+
"tasks": ["task 1", "task 2", ...]
|
|
331
|
+
}
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
Phases should be:
|
|
336
|
+
1. Setup (package.json, config, base files)
|
|
337
|
+
2. Database (schema, migrations, types)
|
|
338
|
+
3. Auth (if needed)
|
|
339
|
+
4. Core Features (main functionality)
|
|
340
|
+
5. UI/Pages (frontend)
|
|
341
|
+
6. Integrations (third-party services)
|
|
342
|
+
7. Polish (loading states, error handling, empty states)
|
|
343
|
+
|
|
344
|
+
Keep tasks specific and actionable.`
|
|
345
|
+
}],
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
const text = response.content[0].type === 'text' ? response.content[0].text : '';
|
|
349
|
+
const jsonMatch = text.match(/\{[\s\S]*\}/);
|
|
350
|
+
if (!jsonMatch) {
|
|
351
|
+
throw new Error('Could not generate build plan');
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return JSON.parse(jsonMatch[0]);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async function executeTask(
|
|
358
|
+
anthropic: Anthropic,
|
|
359
|
+
projectPath: string,
|
|
360
|
+
task: string,
|
|
361
|
+
prd: ParsedPRD,
|
|
362
|
+
designProfile: string
|
|
363
|
+
): Promise<void> {
|
|
364
|
+
const response = await anthropic.messages.create({
|
|
365
|
+
model: 'claude-sonnet-4-20250514',
|
|
366
|
+
max_tokens: 8192,
|
|
367
|
+
messages: [{
|
|
368
|
+
role: 'user',
|
|
369
|
+
content: `Execute this task for the project.
|
|
370
|
+
|
|
371
|
+
Project: ${prd.name}
|
|
372
|
+
Task: ${task}
|
|
373
|
+
Design Profile: ${designProfile}
|
|
374
|
+
|
|
375
|
+
Context:
|
|
376
|
+
- Features: ${prd.features.join(', ')}
|
|
377
|
+
- Database: ${prd.database.join(', ')}
|
|
378
|
+
|
|
379
|
+
Output files in this format:
|
|
380
|
+
|
|
381
|
+
<<<FILE: path/to/file.ts>>>
|
|
382
|
+
file content here
|
|
383
|
+
<<<END_FILE>>>
|
|
384
|
+
|
|
385
|
+
<<<FILE: another/file.tsx>>>
|
|
386
|
+
file content here
|
|
387
|
+
<<<END_FILE>>>
|
|
388
|
+
|
|
389
|
+
Follow these rules:
|
|
390
|
+
- Use TypeScript
|
|
391
|
+
- Use Next.js App Router
|
|
392
|
+
- Use Tailwind CSS
|
|
393
|
+
- Use shadcn/ui components
|
|
394
|
+
- Every button needs onClick handler
|
|
395
|
+
- Every form needs Zod validation
|
|
396
|
+
- Every async operation needs loading/error states
|
|
397
|
+
- Every list needs empty state
|
|
398
|
+
- No generic gradient heroes
|
|
399
|
+
- No icon spam
|
|
400
|
+
- Generous spacing (py-16 or larger for sections)
|
|
401
|
+
|
|
402
|
+
Generate ALL files needed for this task.`
|
|
403
|
+
}],
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
const text = response.content[0].type === 'text' ? response.content[0].text : '';
|
|
407
|
+
|
|
408
|
+
// Parse and write files
|
|
409
|
+
const fileRegex = /<<<FILE:\s*(.+?)>>>([\s\S]*?)<<<END_FILE>>>/g;
|
|
410
|
+
let match;
|
|
411
|
+
|
|
412
|
+
while ((match = fileRegex.exec(text)) !== null) {
|
|
413
|
+
const filePath = path.join(projectPath, match[1].trim());
|
|
414
|
+
const content = match[2].trim();
|
|
415
|
+
|
|
416
|
+
await fs.ensureDir(path.dirname(filePath));
|
|
417
|
+
await fs.writeFile(filePath, content);
|
|
418
|
+
}
|
|
419
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,8 @@ import { securityCommand } from './commands/security.js';
|
|
|
20
20
|
import { generateCommand } from './commands/generate.js';
|
|
21
21
|
import { fixCommand } from './commands/fix.js';
|
|
22
22
|
import { designCommand } from './commands/design.js';
|
|
23
|
+
import { prdCommand } from './commands/prd.js';
|
|
24
|
+
import { advisorsCommand } from './commands/advisors.js';
|
|
23
25
|
|
|
24
26
|
const VERSION = '1.0.0';
|
|
25
27
|
|
|
@@ -73,10 +75,14 @@ async function showMainMenu(): Promise<void> {
|
|
|
73
75
|
{ value: 'design', label: 'šØ Design system', hint: 'set profile, colors' },
|
|
74
76
|
{ value: 'separator2', label: 'āāāāāāāāāāāāāāāāāāāāāāāāā' },
|
|
75
77
|
{ value: 'new', label: 'š Create new project' },
|
|
78
|
+
{ value: 'prd', label: 'š Build from PRD', hint: 'upload a PRD document' },
|
|
79
|
+
{ value: 'advisors', label: 'š Dream Team Advisors', hint: 'consult with experts' },
|
|
76
80
|
{ value: 'settings', label: 'āļø Settings' },
|
|
77
81
|
{ value: 'help', label: 'ā Help' },
|
|
78
82
|
] : [
|
|
79
83
|
{ value: 'new', label: 'š Create new project' },
|
|
84
|
+
{ value: 'prd', label: 'š Build from PRD', hint: 'upload a PRD document' },
|
|
85
|
+
{ value: 'advisors', label: 'š Dream Team Advisors', hint: 'consult with experts' },
|
|
80
86
|
{ value: 'open', label: 'š Open existing project' },
|
|
81
87
|
{ value: 'status', label: 'š View all projects' },
|
|
82
88
|
{ value: 'separator1', label: 'āāāāāāāāāāāāāāāāāāāāāāāāā' },
|
|
@@ -131,6 +137,12 @@ async function showMainMenu(): Promise<void> {
|
|
|
131
137
|
case 'new':
|
|
132
138
|
await initCommand();
|
|
133
139
|
break;
|
|
140
|
+
case 'prd':
|
|
141
|
+
await prdCommand();
|
|
142
|
+
break;
|
|
143
|
+
case 'advisors':
|
|
144
|
+
await advisorsCommand();
|
|
145
|
+
break;
|
|
134
146
|
case 'settings':
|
|
135
147
|
await setupCommand();
|
|
136
148
|
break;
|
|
@@ -264,6 +276,17 @@ program
|
|
|
264
276
|
.description('Manage design system (profile, palette, check)')
|
|
265
277
|
.action(designCommand);
|
|
266
278
|
|
|
279
|
+
program
|
|
280
|
+
.command('prd [file]')
|
|
281
|
+
.description('Build entire project from a PRD document')
|
|
282
|
+
.action(prdCommand);
|
|
283
|
+
|
|
284
|
+
program
|
|
285
|
+
.command('advisors')
|
|
286
|
+
.alias('dream-team')
|
|
287
|
+
.description('Consult with the CodeBakers Dream Team advisory board')
|
|
288
|
+
.action(advisorsCommand);
|
|
289
|
+
|
|
267
290
|
// Parse args or show menu
|
|
268
291
|
const args = process.argv.slice(2);
|
|
269
292
|
|
package/src/utils/config.ts
CHANGED
|
@@ -141,7 +141,99 @@ export class Config {
|
|
|
141
141
|
const cwd = process.cwd();
|
|
142
142
|
const codebakersDir = path.join(cwd, '.codebakers');
|
|
143
143
|
const claudeFile = path.join(cwd, 'CLAUDE.md');
|
|
144
|
-
|
|
144
|
+
|
|
145
|
+
// Already a CodeBakers project
|
|
146
|
+
if (fs.existsSync(codebakersDir) || fs.existsSync(claudeFile)) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Auto-detect existing projects by common files
|
|
151
|
+
const projectIndicators = [
|
|
152
|
+
'package.json',
|
|
153
|
+
'next.config.js',
|
|
154
|
+
'next.config.mjs',
|
|
155
|
+
'next.config.ts',
|
|
156
|
+
'vite.config.ts',
|
|
157
|
+
'vite.config.js',
|
|
158
|
+
'remix.config.js',
|
|
159
|
+
'astro.config.mjs',
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
const hasProjectFile = projectIndicators.some(file =>
|
|
163
|
+
fs.existsSync(path.join(cwd, file))
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// If it's a project but no .codebakers, auto-initialize
|
|
167
|
+
if (hasProjectFile) {
|
|
168
|
+
this.autoInitExisting(cwd);
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Auto-initialize CodeBakers in an existing project
|
|
176
|
+
private autoInitExisting(cwd: string): void {
|
|
177
|
+
try {
|
|
178
|
+
// Detect framework
|
|
179
|
+
let framework = 'unknown';
|
|
180
|
+
let ui = 'unknown';
|
|
181
|
+
|
|
182
|
+
if (fs.existsSync(path.join(cwd, 'next.config.js')) ||
|
|
183
|
+
fs.existsSync(path.join(cwd, 'next.config.mjs')) ||
|
|
184
|
+
fs.existsSync(path.join(cwd, 'next.config.ts'))) {
|
|
185
|
+
framework = 'nextjs';
|
|
186
|
+
} else if (fs.existsSync(path.join(cwd, 'vite.config.ts')) ||
|
|
187
|
+
fs.existsSync(path.join(cwd, 'vite.config.js'))) {
|
|
188
|
+
framework = 'vite';
|
|
189
|
+
} else if (fs.existsSync(path.join(cwd, 'remix.config.js'))) {
|
|
190
|
+
framework = 'remix';
|
|
191
|
+
} else if (fs.existsSync(path.join(cwd, 'astro.config.mjs'))) {
|
|
192
|
+
framework = 'astro';
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Check for UI libraries in package.json
|
|
196
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
197
|
+
if (fs.existsSync(pkgPath)) {
|
|
198
|
+
const pkg = fs.readJsonSync(pkgPath);
|
|
199
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
200
|
+
|
|
201
|
+
if (deps['@shadcn/ui'] || deps['class-variance-authority']) {
|
|
202
|
+
ui = 'shadcn';
|
|
203
|
+
} else if (deps['@chakra-ui/react']) {
|
|
204
|
+
ui = 'chakra';
|
|
205
|
+
} else if (deps['@mantine/core']) {
|
|
206
|
+
ui = 'mantine';
|
|
207
|
+
} else if (deps['@mui/material']) {
|
|
208
|
+
ui = 'mui';
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Create .codebakers config
|
|
213
|
+
const configDir = path.join(cwd, '.codebakers');
|
|
214
|
+
fs.ensureDirSync(configDir);
|
|
215
|
+
|
|
216
|
+
const config = {
|
|
217
|
+
name: path.basename(cwd),
|
|
218
|
+
framework,
|
|
219
|
+
ui,
|
|
220
|
+
createdAt: new Date().toISOString(),
|
|
221
|
+
autoDetected: true,
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
fs.writeJsonSync(path.join(configDir, 'config.json'), config, { spaces: 2 });
|
|
225
|
+
|
|
226
|
+
// Add to .gitignore if exists
|
|
227
|
+
const gitignorePath = path.join(cwd, '.gitignore');
|
|
228
|
+
if (fs.existsSync(gitignorePath)) {
|
|
229
|
+
const gitignore = fs.readFileSync(gitignorePath, 'utf-8');
|
|
230
|
+
if (!gitignore.includes('.codebakers')) {
|
|
231
|
+
fs.appendFileSync(gitignorePath, '\n# CodeBakers\n.codebakers/\n');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
} catch {
|
|
235
|
+
// Silent fail - don't block if auto-init fails
|
|
236
|
+
}
|
|
145
237
|
}
|
|
146
238
|
|
|
147
239
|
// Get current project config
|