codebakers 2.5.3 → 3.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.
Files changed (60) hide show
  1. package/README.md +54 -255
  2. package/dist/chunk-HOWR3YTF.js +146 -0
  3. package/dist/index.d.ts +0 -3
  4. package/dist/index.js +10489 -7994
  5. package/dist/terminal-6ZQVP6R7.js +10 -0
  6. package/package.json +26 -41
  7. package/AUDIT_REPORT.md +0 -138
  8. package/dist/advisors-RWRTSJRR.js +0 -7
  9. package/dist/chunk-ASIJIQYC.js +0 -320
  10. package/dist/chunk-D44U3IEA.js +0 -565
  11. package/dist/chunk-LANM5XQW.js +0 -326
  12. package/dist/prd-RYITSL6Q.js +0 -7
  13. package/install.bat +0 -9
  14. package/installers/CodeBakers-Install.bat +0 -207
  15. package/installers/CodeBakers-Install.command +0 -232
  16. package/installers/README.md +0 -157
  17. package/installers/mac/assets/README.txt +0 -31
  18. package/installers/mac/build-mac-installer.sh +0 -240
  19. package/installers/windows/CodeBakers.iss +0 -256
  20. package/installers/windows/assets/README.txt +0 -16
  21. package/installers/windows/scripts/post-install.bat +0 -15
  22. package/src/channels/discord.ts +0 -5
  23. package/src/channels/slack.ts +0 -5
  24. package/src/channels/sms.ts +0 -4
  25. package/src/channels/telegram.ts +0 -5
  26. package/src/channels/whatsapp.ts +0 -7
  27. package/src/commands/advisors.ts +0 -699
  28. package/src/commands/build.ts +0 -1025
  29. package/src/commands/check.ts +0 -365
  30. package/src/commands/code.ts +0 -806
  31. package/src/commands/connect.ts +0 -12
  32. package/src/commands/deploy.ts +0 -448
  33. package/src/commands/design.ts +0 -298
  34. package/src/commands/fix.ts +0 -20
  35. package/src/commands/gateway.ts +0 -604
  36. package/src/commands/generate.ts +0 -178
  37. package/src/commands/init.ts +0 -634
  38. package/src/commands/integrate.ts +0 -884
  39. package/src/commands/learn.ts +0 -36
  40. package/src/commands/migrate.ts +0 -419
  41. package/src/commands/prd-maker.ts +0 -588
  42. package/src/commands/prd.ts +0 -419
  43. package/src/commands/security.ts +0 -102
  44. package/src/commands/setup.ts +0 -600
  45. package/src/commands/status.ts +0 -56
  46. package/src/commands/website.ts +0 -741
  47. package/src/index.ts +0 -627
  48. package/src/patterns/loader.ts +0 -337
  49. package/src/services/github.ts +0 -61
  50. package/src/services/supabase.ts +0 -147
  51. package/src/services/vercel.ts +0 -61
  52. package/src/utils/claude-md.ts +0 -287
  53. package/src/utils/config.ts +0 -375
  54. package/src/utils/display.ts +0 -338
  55. package/src/utils/files.ts +0 -418
  56. package/src/utils/nlp.ts +0 -312
  57. package/src/utils/ui.ts +0 -441
  58. package/src/utils/updates.ts +0 -8
  59. package/src/utils/voice.ts +0 -323
  60. package/tsconfig.json +0 -26
@@ -1,12 +0,0 @@
1
- // src/commands/connect.ts
2
- import * as p from '@clack/prompts';
3
- import chalk from 'chalk';
4
- import { Config } from '../utils/config.js';
5
- import { setupCommand } from './setup.js';
6
-
7
- export async function connectCommand(service?: string): Promise<void> {
8
- const config = new Config();
9
-
10
- // Delegate to setup for now
11
- await setupCommand();
12
- }
@@ -1,448 +0,0 @@
1
- import * as p from '@clack/prompts';
2
- import chalk from 'chalk';
3
- import { execa } from 'execa';
4
- import fs from 'fs-extra';
5
- import * as path from 'path';
6
- import Anthropic from '@anthropic-ai/sdk';
7
- import { Config } from '../utils/config.js';
8
- import { VercelService } from '../services/vercel.js';
9
- import { runPatternCheck } from './check.js';
10
-
11
- interface DeployOptions {
12
- preview?: boolean;
13
- check?: boolean;
14
- }
15
-
16
- export async function deployCommand(options: DeployOptions = {}): Promise<void> {
17
- const config = new Config();
18
-
19
- if (!config.isInProject()) {
20
- console.log(chalk.yellow(`
21
- ⚠️ You're not in a CodeBakers project.
22
-
23
- Navigate to your project first:
24
- ${chalk.cyan('cd my-project')}
25
-
26
- Or create a new one:
27
- ${chalk.cyan('codebakers init')}
28
- `));
29
- return;
30
- }
31
-
32
- // Check for Vercel credentials
33
- const vercelCreds = config.getCredentials('vercel');
34
- if (!vercelCreds?.token) {
35
- console.log(chalk.yellow(`
36
- ⚠️ Vercel isn't connected.
37
-
38
- CodeBakers deploys to Vercel by default.
39
-
40
- Run this to connect:
41
- ${chalk.cyan('codebakers setup')}
42
-
43
- Or deploy manually:
44
- ${chalk.cyan('npx vercel')}
45
- `));
46
- return;
47
- }
48
-
49
- p.intro(chalk.bgCyan.black(' Deploy to Production '));
50
-
51
- const spinner = p.spinner();
52
-
53
- // Step 1: Run pattern check (unless skipped)
54
- if (options.check !== false) {
55
- spinner.start('Running CodeBakers check...');
56
- const checkResult = await runPatternCheck(false);
57
-
58
- if (!checkResult.passed) {
59
- spinner.stop('');
60
- const errors = checkResult.violations.filter(v => v.severity === 'error');
61
-
62
- if (errors.length > 0) {
63
- p.log.error(`${errors.length} pattern violations found. Fix before deploying.`);
64
-
65
- const showViolations = await p.confirm({
66
- message: 'Show violations?',
67
- initialValue: true,
68
- });
69
-
70
- if (showViolations && !p.isCancel(showViolations)) {
71
- for (const v of errors) {
72
- console.log(chalk.red(` ✗ ${v.file}:${v.line} - ${v.message}`));
73
- }
74
- }
75
-
76
- const autoFix = await p.confirm({
77
- message: 'Attempt auto-fix with AI?',
78
- initialValue: true,
79
- });
80
-
81
- if (!autoFix || p.isCancel(autoFix)) {
82
- p.outro(chalk.red('Deploy cancelled.'));
83
- return;
84
- }
85
-
86
- // Auto-fix with AI
87
- spinner.start('Auto-fixing with AI...');
88
- await autoFixWithAI(config, errors);
89
- spinner.stop('Auto-fix complete');
90
-
91
- // Re-run check
92
- const recheck = await runPatternCheck(false);
93
- if (!recheck.passed) {
94
- p.log.error('Some violations remain. Manual fix required.');
95
- p.outro(chalk.red('Deploy cancelled.'));
96
- return;
97
- }
98
- }
99
- }
100
- spinner.stop('Pattern check passed');
101
- }
102
-
103
- // Step 2: Run TypeScript check
104
- spinner.start('Running TypeScript check...');
105
- try {
106
- await execa('npx', ['tsc', '--noEmit'], { cwd: process.cwd() });
107
- spinner.stop('TypeScript check passed');
108
- } catch (error) {
109
- spinner.stop('');
110
- p.log.error('TypeScript errors found.');
111
-
112
- const fix = await p.confirm({
113
- message: 'Attempt to fix TypeScript errors?',
114
- initialValue: true,
115
- });
116
-
117
- if (fix && !p.isCancel(fix)) {
118
- spinner.start('Fixing TypeScript errors...');
119
- const fixed = await fixTypeScriptErrors(config);
120
- spinner.stop(fixed ? 'TypeScript errors fixed' : 'Could not auto-fix all errors');
121
-
122
- if (!fixed) {
123
- p.outro(chalk.red('Deploy cancelled.'));
124
- return;
125
- }
126
- } else {
127
- p.outro(chalk.red('Deploy cancelled.'));
128
- return;
129
- }
130
- }
131
-
132
- // Step 3: Run build
133
- spinner.start('Building project...');
134
- try {
135
- // Try npm first, fall back to pnpm or yarn
136
- try {
137
- await execa('npm', ['run', 'build'], { cwd: process.cwd() });
138
- } catch {
139
- try {
140
- await execa('pnpm', ['build'], { cwd: process.cwd() });
141
- } catch {
142
- await execa('yarn', ['build'], { cwd: process.cwd() });
143
- }
144
- }
145
- spinner.stop('Build successful');
146
- } catch (error) {
147
- spinner.stop('');
148
- p.log.error('Build failed.');
149
-
150
- const errorOutput = error instanceof Error ? error.message : 'Unknown error';
151
- console.log(chalk.dim(errorOutput));
152
-
153
- const fix = await p.confirm({
154
- message: 'Attempt to fix build errors with AI?',
155
- initialValue: true,
156
- });
157
-
158
- if (fix && !p.isCancel(fix)) {
159
- spinner.start('Fixing build errors...');
160
- const fixed = await fixBuildErrors(config, errorOutput);
161
- spinner.stop(fixed ? 'Build errors fixed' : 'Could not auto-fix');
162
-
163
- if (fixed) {
164
- // Retry build
165
- spinner.start('Retrying build...');
166
- try {
167
- await execa('pnpm', ['build'], { cwd: process.cwd() });
168
- spinner.stop('Build successful');
169
- } catch {
170
- spinner.stop('Build still failing');
171
- p.outro(chalk.red('Deploy cancelled.'));
172
- return;
173
- }
174
- } else {
175
- p.outro(chalk.red('Deploy cancelled.'));
176
- return;
177
- }
178
- } else {
179
- p.outro(chalk.red('Deploy cancelled.'));
180
- return;
181
- }
182
- }
183
-
184
- // Step 4: Git commit if there are changes
185
- spinner.start('Checking for uncommitted changes...');
186
- const { stdout: gitStatus } = await execa('git', ['status', '--porcelain'], { cwd: process.cwd() });
187
-
188
- if (gitStatus.trim()) {
189
- spinner.stop('');
190
- const commit = await p.confirm({
191
- message: 'You have uncommitted changes. Commit before deploying?',
192
- initialValue: true,
193
- });
194
-
195
- if (commit && !p.isCancel(commit)) {
196
- const message = await p.text({
197
- message: 'Commit message:',
198
- placeholder: 'Pre-deploy changes',
199
- initialValue: 'Pre-deploy changes',
200
- });
201
-
202
- if (!p.isCancel(message)) {
203
- await execa('git', ['add', '.'], { cwd: process.cwd() });
204
- await execa('git', ['commit', '-m', message as string], { cwd: process.cwd() });
205
-
206
- spinner.start('Pushing to GitHub...');
207
- await execa('git', ['push'], { cwd: process.cwd() });
208
- spinner.stop('Pushed to GitHub');
209
- }
210
- }
211
- } else {
212
- spinner.stop('No uncommitted changes');
213
- }
214
-
215
- // Step 5: Deploy to Vercel
216
- const deployType = options.preview ? 'preview' : 'production';
217
- spinner.start(`Deploying to ${deployType}...`);
218
-
219
- try {
220
- const vercel = new VercelService(config);
221
- const deployment = await vercel.deploy(process.cwd(), !options.preview);
222
-
223
- spinner.stop('Deployment complete!');
224
-
225
- console.log(boxedOutput(`
226
- ${chalk.green('✓')} Deployed successfully!
227
-
228
- ${chalk.bold('URL:')} ${deployment.url}
229
- ${chalk.bold('Type:')} ${deployType}
230
- ${chalk.bold('Time:')} ${new Date().toLocaleTimeString()}
231
-
232
- ${chalk.dim('View in Vercel Dashboard:')}
233
- ${chalk.dim('https://vercel.com/dashboard')}
234
- `));
235
-
236
- } catch (error) {
237
- spinner.stop('');
238
- const errorMsg = error instanceof Error ? error.message : 'Unknown error';
239
- p.log.error(`Deployment failed: ${errorMsg}`);
240
-
241
- // Check if it's a build error from Vercel
242
- if (errorMsg.includes('Build failed')) {
243
- const retry = await p.confirm({
244
- message: 'Attempt to fix and retry?',
245
- initialValue: true,
246
- });
247
-
248
- if (retry && !p.isCancel(retry)) {
249
- spinner.start('Analyzing Vercel build error...');
250
- // Would fetch Vercel logs and auto-fix
251
- spinner.stop('Fix attempted');
252
- }
253
- }
254
-
255
- p.outro(chalk.red('Deploy failed.'));
256
- }
257
- }
258
-
259
- async function autoFixWithAI(
260
- config: Config,
261
- violations: Array<{ file: string; line: number; rule: string; message: string }>
262
- ): Promise<void> {
263
- const anthropicCreds = config.getCredentials('anthropic');
264
- if (!anthropicCreds?.apiKey) {
265
- throw new Error('Anthropic API key not configured');
266
- }
267
-
268
- const anthropic = new Anthropic({
269
- apiKey: anthropicCreds.apiKey,
270
- });
271
-
272
- // Group by file
273
- const byFile = new Map<string, typeof violations>();
274
- for (const v of violations) {
275
- if (!byFile.has(v.file)) {
276
- byFile.set(v.file, []);
277
- }
278
- byFile.get(v.file)!.push(v);
279
- }
280
-
281
- for (const [file, fileViolations] of byFile) {
282
- const filePath = path.join(process.cwd(), file);
283
- const content = await fs.readFile(filePath, 'utf-8');
284
-
285
- const prompt = `Fix these CodeBakers pattern violations in this file:
286
-
287
- Violations:
288
- ${fileViolations.map(v => `- Line ${v.line}: ${v.rule} - ${v.message}`).join('\n')}
289
-
290
- Current file content:
291
- \`\`\`typescript
292
- ${content}
293
- \`\`\`
294
-
295
- Output ONLY the corrected file content, no explanations. Keep all existing functionality.`;
296
-
297
- const response = await anthropic.messages.create({
298
- model: 'claude-sonnet-4-5-20250929',
299
- max_tokens: 8192,
300
- messages: [{ role: 'user', content: prompt }],
301
- });
302
-
303
- let fixed = response.content[0].type === 'text' ? response.content[0].text : '';
304
-
305
- // Extract code from markdown if present
306
- const codeMatch = fixed.match(/```(?:typescript|tsx?)?\n([\s\S]+?)\n```/);
307
- if (codeMatch) {
308
- fixed = codeMatch[1];
309
- }
310
-
311
- await fs.writeFile(filePath, fixed);
312
- }
313
- }
314
-
315
- async function fixTypeScriptErrors(config: Config): Promise<boolean> {
316
- try {
317
- // Get TypeScript errors
318
- const { stderr } = await execa('npx', ['tsc', '--noEmit'], {
319
- cwd: process.cwd(),
320
- reject: false,
321
- });
322
-
323
- if (!stderr) return true;
324
-
325
- const anthropicCreds = config.getCredentials('anthropic');
326
- if (!anthropicCreds?.apiKey) {
327
- return false;
328
- }
329
-
330
- const anthropic = new Anthropic({
331
- apiKey: anthropicCreds.apiKey,
332
- });
333
-
334
- // Parse error locations
335
- const errorLines = stderr.split('\n').filter(line => line.includes('error TS'));
336
-
337
- for (const errorLine of errorLines.slice(0, 10)) { // Limit to 10 errors
338
- const match = errorLine.match(/^(.+?)\((\d+),(\d+)\): error (TS\d+): (.+)$/);
339
- if (!match) continue;
340
-
341
- const [, file, line, , , message] = match;
342
- const filePath = path.join(process.cwd(), file);
343
-
344
- if (!await fs.pathExists(filePath)) continue;
345
-
346
- const content = await fs.readFile(filePath, 'utf-8');
347
-
348
- const prompt = `Fix this TypeScript error:
349
-
350
- File: ${file}
351
- Line: ${line}
352
- Error: ${message}
353
-
354
- Current file content:
355
- \`\`\`typescript
356
- ${content}
357
- \`\`\`
358
-
359
- Output ONLY the corrected file content, no explanations.`;
360
-
361
- const response = await anthropic.messages.create({
362
- model: 'claude-sonnet-4-5-20250929',
363
- max_tokens: 8192,
364
- messages: [{ role: 'user', content: prompt }],
365
- });
366
-
367
- let fixed = response.content[0].type === 'text' ? response.content[0].text : '';
368
-
369
- const codeMatch = fixed.match(/```(?:typescript|tsx?)?\n([\s\S]+?)\n```/);
370
- if (codeMatch) {
371
- fixed = codeMatch[1];
372
- }
373
-
374
- await fs.writeFile(filePath, fixed);
375
- }
376
-
377
- return true;
378
- } catch {
379
- return false;
380
- }
381
- }
382
-
383
- async function fixBuildErrors(config: Config, errorOutput: string): Promise<boolean> {
384
- const anthropicCreds = config.getCredentials('anthropic');
385
- if (!anthropicCreds?.apiKey) {
386
- return false;
387
- }
388
-
389
- const anthropic = new Anthropic({
390
- apiKey: anthropicCreds.apiKey,
391
- });
392
-
393
- // Parse error to find file
394
- const fileMatch = errorOutput.match(/(?:Error|error).*?(?:in|at)\s+(.+?\.tsx?)(?::|$)/);
395
- if (!fileMatch) return false;
396
-
397
- const file = fileMatch[1];
398
- const filePath = path.join(process.cwd(), file);
399
-
400
- if (!await fs.pathExists(filePath)) return false;
401
-
402
- const content = await fs.readFile(filePath, 'utf-8');
403
-
404
- const prompt = `Fix this build error:
405
-
406
- Error output:
407
- ${errorOutput}
408
-
409
- File: ${file}
410
-
411
- Current file content:
412
- \`\`\`typescript
413
- ${content}
414
- \`\`\`
415
-
416
- Output ONLY the corrected file content, no explanations.`;
417
-
418
- try {
419
- const response = await anthropic.messages.create({
420
- model: 'claude-sonnet-4-5-20250929',
421
- max_tokens: 8192,
422
- messages: [{ role: 'user', content: prompt }],
423
- });
424
-
425
- let fixed = response.content[0].type === 'text' ? response.content[0].text : '';
426
-
427
- const codeMatch = fixed.match(/```(?:typescript|tsx?)?\n([\s\S]+?)\n```/);
428
- if (codeMatch) {
429
- fixed = codeMatch[1];
430
- }
431
-
432
- await fs.writeFile(filePath, fixed);
433
- return true;
434
- } catch {
435
- return false;
436
- }
437
- }
438
-
439
- function boxedOutput(content: string): string {
440
- const lines = content.split('\n');
441
- const maxLength = Math.max(...lines.map(l => l.replace(/\x1b\[[0-9;]*m/g, '').length));
442
- const border = '─'.repeat(maxLength + 2);
443
-
444
- return `
445
- ╭${border}╮
446
- ${lines.map(l => `│ ${l.padEnd(maxLength)} │`).join('\n')}
447
- ╰${border}╯`;
448
- }