@codebakers/cli 2.7.0 → 2.9.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/dist/commands/push-patterns.d.ts +15 -0
- package/dist/commands/push-patterns.js +186 -0
- package/dist/commands/setup.js +13 -2
- package/dist/index.js +23 -1
- package/dist/lib/progress.d.ts +42 -0
- package/dist/lib/progress.js +160 -0
- package/dist/mcp/server.js +294 -10
- package/package.json +1 -1
- package/src/commands/push-patterns.ts +222 -0
- package/src/commands/setup.ts +11 -2
- package/src/index.ts +23 -1
- package/src/lib/progress.ts +192 -0
- package/src/mcp/server.ts +312 -12
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface PushOptions {
|
|
2
|
+
version: string;
|
|
3
|
+
changelog?: string;
|
|
4
|
+
autoPublish?: boolean;
|
|
5
|
+
sourcePath?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Push patterns to the server via admin API
|
|
9
|
+
*/
|
|
10
|
+
export declare function pushPatterns(options: PushOptions): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Interactive push command
|
|
13
|
+
*/
|
|
14
|
+
export declare function pushPatternsInteractive(): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.pushPatterns = pushPatterns;
|
|
7
|
+
exports.pushPatternsInteractive = pushPatternsInteractive;
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const ora_1 = __importDefault(require("ora"));
|
|
10
|
+
const readline_1 = require("readline");
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const config_js_1 = require("../config.js");
|
|
14
|
+
function prompt(question) {
|
|
15
|
+
const rl = (0, readline_1.createInterface)({
|
|
16
|
+
input: process.stdin,
|
|
17
|
+
output: process.stdout,
|
|
18
|
+
});
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
rl.question(question, (answer) => {
|
|
21
|
+
rl.close();
|
|
22
|
+
resolve(answer.trim());
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read all module files from a directory
|
|
28
|
+
*/
|
|
29
|
+
function readModulesFromDir(dirPath) {
|
|
30
|
+
const modules = {};
|
|
31
|
+
if (!(0, fs_1.existsSync)(dirPath)) {
|
|
32
|
+
return modules;
|
|
33
|
+
}
|
|
34
|
+
const files = (0, fs_1.readdirSync)(dirPath).filter(f => f.endsWith('.md'));
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
const filePath = (0, path_1.join)(dirPath, file);
|
|
37
|
+
const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
|
|
38
|
+
const moduleName = (0, path_1.basename)(file, '.md');
|
|
39
|
+
modules[moduleName] = content;
|
|
40
|
+
}
|
|
41
|
+
return modules;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Push patterns to the server via admin API
|
|
45
|
+
*/
|
|
46
|
+
async function pushPatterns(options) {
|
|
47
|
+
console.log(chalk_1.default.blue('\n CodeBakers Push Patterns\n'));
|
|
48
|
+
const sourcePath = options.sourcePath || process.cwd();
|
|
49
|
+
// Check for API key - first from config, then from environment
|
|
50
|
+
const apiKey = (0, config_js_1.getApiKey)() || process.env.CODEBAKERS_ADMIN_KEY;
|
|
51
|
+
if (!apiKey) {
|
|
52
|
+
console.log(chalk_1.default.red(' ✗ No API key found\n'));
|
|
53
|
+
console.log(chalk_1.default.gray(' Either:'));
|
|
54
|
+
console.log(chalk_1.default.cyan(' 1. Run `codebakers setup` to configure your API key'));
|
|
55
|
+
console.log(chalk_1.default.cyan(' 2. Set CODEBAKERS_ADMIN_KEY environment variable\n'));
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
// Read main files
|
|
59
|
+
const claudeMdPath = (0, path_1.join)(sourcePath, 'CLAUDE.md');
|
|
60
|
+
const cursorRulesPath = (0, path_1.join)(sourcePath, '.cursorrules');
|
|
61
|
+
let claudeMdContent = null;
|
|
62
|
+
let cursorRulesContent = null;
|
|
63
|
+
if ((0, fs_1.existsSync)(claudeMdPath)) {
|
|
64
|
+
claudeMdContent = (0, fs_1.readFileSync)(claudeMdPath, 'utf-8');
|
|
65
|
+
console.log(chalk_1.default.green(` ✓ Found CLAUDE.md (${(claudeMdContent.length / 1024).toFixed(1)} KB)`));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
console.log(chalk_1.default.yellow(` ⚠ CLAUDE.md not found at ${claudeMdPath}`));
|
|
69
|
+
}
|
|
70
|
+
if ((0, fs_1.existsSync)(cursorRulesPath)) {
|
|
71
|
+
cursorRulesContent = (0, fs_1.readFileSync)(cursorRulesPath, 'utf-8');
|
|
72
|
+
console.log(chalk_1.default.green(` ✓ Found .cursorrules (${(cursorRulesContent.length / 1024).toFixed(1)} KB)`));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
console.log(chalk_1.default.yellow(` ⚠ .cursorrules not found at ${cursorRulesPath}`));
|
|
76
|
+
}
|
|
77
|
+
if (!claudeMdContent && !cursorRulesContent) {
|
|
78
|
+
console.log(chalk_1.default.red('\n ✗ No pattern files found. Nothing to push.\n'));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
// Read module directories
|
|
82
|
+
const claudeModulesPath = (0, path_1.join)(sourcePath, '.claude');
|
|
83
|
+
const cursorModulesPath = (0, path_1.join)(sourcePath, '.cursorrules-modules');
|
|
84
|
+
const modulesContent = readModulesFromDir(claudeModulesPath);
|
|
85
|
+
const cursorModulesContent = readModulesFromDir(cursorModulesPath);
|
|
86
|
+
const claudeModuleCount = Object.keys(modulesContent).length;
|
|
87
|
+
const cursorModuleCount = Object.keys(cursorModulesContent).length;
|
|
88
|
+
if (claudeModuleCount > 0) {
|
|
89
|
+
console.log(chalk_1.default.green(` ✓ Found ${claudeModuleCount} Claude modules in .claude/`));
|
|
90
|
+
}
|
|
91
|
+
if (cursorModuleCount > 0) {
|
|
92
|
+
console.log(chalk_1.default.green(` ✓ Found ${cursorModuleCount} Cursor modules in .cursorrules-modules/`));
|
|
93
|
+
}
|
|
94
|
+
console.log('');
|
|
95
|
+
// Show summary
|
|
96
|
+
console.log(chalk_1.default.white(' Push Summary:\n'));
|
|
97
|
+
console.log(chalk_1.default.gray(` Version: ${chalk_1.default.cyan(options.version)}`));
|
|
98
|
+
console.log(chalk_1.default.gray(` Auto-publish: ${options.autoPublish ? chalk_1.default.green('Yes') : chalk_1.default.yellow('No')}`));
|
|
99
|
+
if (options.changelog) {
|
|
100
|
+
console.log(chalk_1.default.gray(` Changelog: ${chalk_1.default.dim(options.changelog.slice(0, 60))}...`));
|
|
101
|
+
}
|
|
102
|
+
console.log('');
|
|
103
|
+
// Files to upload
|
|
104
|
+
console.log(chalk_1.default.white(' Files to upload:\n'));
|
|
105
|
+
if (claudeMdContent)
|
|
106
|
+
console.log(chalk_1.default.cyan(' • CLAUDE.md'));
|
|
107
|
+
if (cursorRulesContent)
|
|
108
|
+
console.log(chalk_1.default.cyan(' • .cursorrules'));
|
|
109
|
+
for (const mod of Object.keys(modulesContent)) {
|
|
110
|
+
console.log(chalk_1.default.dim(` • .claude/${mod}.md`));
|
|
111
|
+
}
|
|
112
|
+
for (const mod of Object.keys(cursorModulesContent)) {
|
|
113
|
+
console.log(chalk_1.default.dim(` • .cursorrules-modules/${mod}.md`));
|
|
114
|
+
}
|
|
115
|
+
console.log('');
|
|
116
|
+
// Confirm
|
|
117
|
+
const confirm = await prompt(chalk_1.default.gray(' Push these patterns? (y/N): '));
|
|
118
|
+
if (confirm.toLowerCase() !== 'y') {
|
|
119
|
+
console.log(chalk_1.default.gray('\n Cancelled.\n'));
|
|
120
|
+
process.exit(0);
|
|
121
|
+
}
|
|
122
|
+
// Push to server
|
|
123
|
+
const spinner = (0, ora_1.default)('Pushing patterns to server...').start();
|
|
124
|
+
try {
|
|
125
|
+
const apiUrl = (0, config_js_1.getApiUrl)();
|
|
126
|
+
const response = await fetch(`${apiUrl}/api/admin/content/push`, {
|
|
127
|
+
method: 'POST',
|
|
128
|
+
headers: {
|
|
129
|
+
'Content-Type': 'application/json',
|
|
130
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
131
|
+
},
|
|
132
|
+
body: JSON.stringify({
|
|
133
|
+
version: options.version,
|
|
134
|
+
claudeMdContent,
|
|
135
|
+
cursorRulesContent,
|
|
136
|
+
modulesContent: claudeModuleCount > 0 ? modulesContent : undefined,
|
|
137
|
+
cursorModulesContent: cursorModuleCount > 0 ? cursorModulesContent : undefined,
|
|
138
|
+
changelog: options.changelog,
|
|
139
|
+
autoPublish: options.autoPublish,
|
|
140
|
+
}),
|
|
141
|
+
});
|
|
142
|
+
const data = await response.json();
|
|
143
|
+
if (!response.ok) {
|
|
144
|
+
spinner.fail(chalk_1.default.red(`Push failed: ${data.error || 'Unknown error'}`));
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
spinner.succeed(chalk_1.default.green('Patterns pushed successfully!'));
|
|
148
|
+
console.log(chalk_1.default.white('\n Result:\n'));
|
|
149
|
+
console.log(chalk_1.default.gray(` Version ID: ${chalk_1.default.cyan(data.version?.id || 'N/A')}`));
|
|
150
|
+
console.log(chalk_1.default.gray(` Version: ${chalk_1.default.cyan(data.version?.version || options.version)}`));
|
|
151
|
+
console.log(chalk_1.default.gray(` Published: ${data.published ? chalk_1.default.green('Yes') : chalk_1.default.yellow('No - run publish manually')}`));
|
|
152
|
+
console.log('');
|
|
153
|
+
console.log(chalk_1.default.green(` ${data.message}\n`));
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
spinner.fail(chalk_1.default.red('Failed to connect to server'));
|
|
157
|
+
console.log(chalk_1.default.gray(`\n Error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Interactive push command
|
|
163
|
+
*/
|
|
164
|
+
async function pushPatternsInteractive() {
|
|
165
|
+
console.log(chalk_1.default.blue('\n CodeBakers Push Patterns\n'));
|
|
166
|
+
// Get version
|
|
167
|
+
const version = await prompt(chalk_1.default.cyan(' Version (e.g., 4.5): '));
|
|
168
|
+
if (!version) {
|
|
169
|
+
console.log(chalk_1.default.red('\n Version is required.\n'));
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
// Get changelog
|
|
173
|
+
const changelog = await prompt(chalk_1.default.cyan(' Changelog (optional): '));
|
|
174
|
+
// Ask about auto-publish
|
|
175
|
+
const autoPublishAnswer = await prompt(chalk_1.default.cyan(' Auto-publish? (y/N): '));
|
|
176
|
+
const autoPublish = autoPublishAnswer.toLowerCase() === 'y';
|
|
177
|
+
// Get source path
|
|
178
|
+
const sourcePathAnswer = await prompt(chalk_1.default.cyan(' Source path (Enter for current directory): '));
|
|
179
|
+
const sourcePath = sourcePathAnswer || process.cwd();
|
|
180
|
+
await pushPatterns({
|
|
181
|
+
version,
|
|
182
|
+
changelog: changelog || undefined,
|
|
183
|
+
autoPublish,
|
|
184
|
+
sourcePath,
|
|
185
|
+
});
|
|
186
|
+
}
|
package/dist/commands/setup.js
CHANGED
|
@@ -10,6 +10,7 @@ const readline_1 = require("readline");
|
|
|
10
10
|
const child_process_1 = require("child_process");
|
|
11
11
|
const config_js_1 = require("../config.js");
|
|
12
12
|
const api_js_1 = require("../lib/api.js");
|
|
13
|
+
const progress_js_1 = require("../lib/progress.js");
|
|
13
14
|
function prompt(question) {
|
|
14
15
|
const rl = (0, readline_1.createInterface)({
|
|
15
16
|
input: process.stdin,
|
|
@@ -62,8 +63,18 @@ async function setup() {
|
|
|
62
63
|
}
|
|
63
64
|
catch (error) {
|
|
64
65
|
spinner.fail('Invalid API key');
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
// Use friendly error formatting
|
|
67
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
68
|
+
const code = error.code;
|
|
69
|
+
if (code === 'NETWORK_ERROR') {
|
|
70
|
+
console.log((0, progress_js_1.formatFriendlyError)((0, progress_js_1.getNetworkError)()));
|
|
71
|
+
}
|
|
72
|
+
else if (code === 'UNAUTHORIZED' || code === 'INVALID_FORMAT') {
|
|
73
|
+
console.log((0, progress_js_1.formatFriendlyError)((0, progress_js_1.getAuthError)()));
|
|
74
|
+
}
|
|
75
|
+
else if ('recoverySteps' in error) {
|
|
76
|
+
console.log(chalk_1.default.red(`\n ${(0, api_js_1.formatApiError)(error)}\n`));
|
|
77
|
+
}
|
|
67
78
|
}
|
|
68
79
|
else {
|
|
69
80
|
const message = error instanceof Error ? error.message : 'API key validation failed';
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ const upgrade_js_1 = require("./commands/upgrade.js");
|
|
|
22
22
|
const config_js_1 = require("./commands/config.js");
|
|
23
23
|
const audit_js_1 = require("./commands/audit.js");
|
|
24
24
|
const heal_js_1 = require("./commands/heal.js");
|
|
25
|
+
const push_patterns_js_1 = require("./commands/push-patterns.js");
|
|
25
26
|
// Show welcome message when no command is provided
|
|
26
27
|
function showWelcome() {
|
|
27
28
|
console.log(chalk_1.default.blue(`
|
|
@@ -63,7 +64,7 @@ const program = new commander_1.Command();
|
|
|
63
64
|
program
|
|
64
65
|
.name('codebakers')
|
|
65
66
|
.description('CodeBakers CLI - Production patterns for AI-assisted development')
|
|
66
|
-
.version('
|
|
67
|
+
.version('2.9.0');
|
|
67
68
|
// Primary command - one-time setup
|
|
68
69
|
program
|
|
69
70
|
.command('setup')
|
|
@@ -142,6 +143,27 @@ program
|
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
145
|
});
|
|
146
|
+
// Admin commands
|
|
147
|
+
program
|
|
148
|
+
.command('push-patterns')
|
|
149
|
+
.description('Push pattern files to the server (admin only)')
|
|
150
|
+
.option('-v, --version <version>', 'Version number (e.g., 4.5)')
|
|
151
|
+
.option('-c, --changelog <message>', 'Changelog message')
|
|
152
|
+
.option('-p, --publish', 'Auto-publish after push')
|
|
153
|
+
.option('-s, --source <path>', 'Source directory (default: current directory)')
|
|
154
|
+
.action(async (options) => {
|
|
155
|
+
if (options.version) {
|
|
156
|
+
await (0, push_patterns_js_1.pushPatterns)({
|
|
157
|
+
version: options.version,
|
|
158
|
+
changelog: options.changelog,
|
|
159
|
+
autoPublish: options.publish,
|
|
160
|
+
sourcePath: options.source,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
await (0, push_patterns_js_1.pushPatternsInteractive)();
|
|
165
|
+
}
|
|
166
|
+
});
|
|
145
167
|
// MCP Server commands
|
|
146
168
|
program
|
|
147
169
|
.command('serve')
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-step progress tracker for CLI operations
|
|
3
|
+
*/
|
|
4
|
+
export interface Step {
|
|
5
|
+
name: string;
|
|
6
|
+
action: () => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class ProgressTracker {
|
|
9
|
+
private currentStep;
|
|
10
|
+
private totalSteps;
|
|
11
|
+
private steps;
|
|
12
|
+
private spinner;
|
|
13
|
+
constructor(steps: Step[]);
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
private formatPrefix;
|
|
16
|
+
private formatStepText;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Show a success box after completing a command
|
|
20
|
+
*/
|
|
21
|
+
export declare function showSuccessBox(title: string, lines: string[]): void;
|
|
22
|
+
/**
|
|
23
|
+
* Display a quick start guide with examples
|
|
24
|
+
*/
|
|
25
|
+
export declare function showQuickStartGuide(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Format user-friendly error with context and recovery steps
|
|
28
|
+
*/
|
|
29
|
+
export interface FriendlyError {
|
|
30
|
+
title: string;
|
|
31
|
+
message: string;
|
|
32
|
+
cause?: string;
|
|
33
|
+
recovery: string[];
|
|
34
|
+
helpUrl?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function formatFriendlyError(error: FriendlyError): string;
|
|
37
|
+
/**
|
|
38
|
+
* Common error handlers with friendly messages
|
|
39
|
+
*/
|
|
40
|
+
export declare function getNetworkError(): FriendlyError;
|
|
41
|
+
export declare function getAuthError(): FriendlyError;
|
|
42
|
+
export declare function getSubscriptionError(): FriendlyError;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProgressTracker = void 0;
|
|
7
|
+
exports.showSuccessBox = showSuccessBox;
|
|
8
|
+
exports.showQuickStartGuide = showQuickStartGuide;
|
|
9
|
+
exports.formatFriendlyError = formatFriendlyError;
|
|
10
|
+
exports.getNetworkError = getNetworkError;
|
|
11
|
+
exports.getAuthError = getAuthError;
|
|
12
|
+
exports.getSubscriptionError = getSubscriptionError;
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const ora_1 = __importDefault(require("ora"));
|
|
15
|
+
class ProgressTracker {
|
|
16
|
+
currentStep = 0;
|
|
17
|
+
totalSteps;
|
|
18
|
+
steps;
|
|
19
|
+
spinner = null;
|
|
20
|
+
constructor(steps) {
|
|
21
|
+
this.steps = steps;
|
|
22
|
+
this.totalSteps = steps.length;
|
|
23
|
+
}
|
|
24
|
+
async run() {
|
|
25
|
+
for (let i = 0; i < this.steps.length; i++) {
|
|
26
|
+
this.currentStep = i + 1;
|
|
27
|
+
const step = this.steps[i];
|
|
28
|
+
this.spinner = (0, ora_1.default)({
|
|
29
|
+
text: this.formatStepText(step.name),
|
|
30
|
+
prefixText: this.formatPrefix(),
|
|
31
|
+
}).start();
|
|
32
|
+
try {
|
|
33
|
+
await step.action();
|
|
34
|
+
this.spinner.succeed(this.formatStepText(step.name));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
this.spinner.fail(this.formatStepText(step.name));
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
formatPrefix() {
|
|
43
|
+
return chalk_1.default.gray(` [${this.currentStep}/${this.totalSteps}]`);
|
|
44
|
+
}
|
|
45
|
+
formatStepText(text) {
|
|
46
|
+
return text;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ProgressTracker = ProgressTracker;
|
|
50
|
+
/**
|
|
51
|
+
* Show a success box after completing a command
|
|
52
|
+
*/
|
|
53
|
+
function showSuccessBox(title, lines) {
|
|
54
|
+
const maxLength = Math.max(title.length, ...lines.map(l => l.length)) + 4;
|
|
55
|
+
const border = '═'.repeat(maxLength);
|
|
56
|
+
console.log(chalk_1.default.green(`\n ╔${border}╗`));
|
|
57
|
+
console.log(chalk_1.default.green(` ║`) + chalk_1.default.bold.white(` ${title.padEnd(maxLength - 2)} `) + chalk_1.default.green(`║`));
|
|
58
|
+
console.log(chalk_1.default.green(` ╠${border}╣`));
|
|
59
|
+
for (const line of lines) {
|
|
60
|
+
console.log(chalk_1.default.green(` ║`) + chalk_1.default.white(` ${line.padEnd(maxLength - 2)} `) + chalk_1.default.green(`║`));
|
|
61
|
+
}
|
|
62
|
+
console.log(chalk_1.default.green(` ╚${border}╝\n`));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Display a quick start guide with examples
|
|
66
|
+
*/
|
|
67
|
+
function showQuickStartGuide() {
|
|
68
|
+
console.log(chalk_1.default.blue('\n ═══════════════════════════════════════════════════════════'));
|
|
69
|
+
console.log(chalk_1.default.bold.white('\n 📚 Quick Start Guide\n'));
|
|
70
|
+
console.log(chalk_1.default.blue(' ═══════════════════════════════════════════════════════════\n'));
|
|
71
|
+
console.log(chalk_1.default.white(' Just ask the AI in natural language:\n'));
|
|
72
|
+
const examples = [
|
|
73
|
+
{
|
|
74
|
+
prompt: '"Build me a user dashboard with stats cards"',
|
|
75
|
+
desc: 'AI will use CodeBakers patterns for layout, components, and data fetching',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
prompt: '"Add Stripe subscription to my app"',
|
|
79
|
+
desc: 'AI loads payment patterns: checkout, webhooks, customer portal',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
prompt: '"Create an API endpoint for user profiles"',
|
|
83
|
+
desc: 'AI generates: route handler, validation, error handling, types',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
prompt: '"Set up auth with Google and email login"',
|
|
87
|
+
desc: 'AI implements OAuth + email auth following security patterns',
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
for (const example of examples) {
|
|
91
|
+
console.log(chalk_1.default.cyan(` → ${example.prompt}`));
|
|
92
|
+
console.log(chalk_1.default.gray(` ${example.desc}\n`));
|
|
93
|
+
}
|
|
94
|
+
console.log(chalk_1.default.blue(' ───────────────────────────────────────────────────────────\n'));
|
|
95
|
+
console.log(chalk_1.default.white(' Pro Tips:\n'));
|
|
96
|
+
console.log(chalk_1.default.gray(' • Ask the AI ') + chalk_1.default.cyan('"What patterns do you have for payments?"'));
|
|
97
|
+
console.log(chalk_1.default.gray(' • Say ') + chalk_1.default.cyan('"/build a SaaS app"') + chalk_1.default.gray(' to start a full project'));
|
|
98
|
+
console.log(chalk_1.default.gray(' • Try ') + chalk_1.default.cyan('"/audit"') + chalk_1.default.gray(' to check code quality'));
|
|
99
|
+
console.log(chalk_1.default.gray(' • Use ') + chalk_1.default.cyan('"codebakers doctor"') + chalk_1.default.gray(' if something seems wrong\n'));
|
|
100
|
+
console.log(chalk_1.default.blue(' ═══════════════════════════════════════════════════════════\n'));
|
|
101
|
+
}
|
|
102
|
+
function formatFriendlyError(error) {
|
|
103
|
+
let output = '';
|
|
104
|
+
output += chalk_1.default.red(`\n ❌ ${error.title}\n`);
|
|
105
|
+
output += chalk_1.default.white(`\n ${error.message}\n`);
|
|
106
|
+
if (error.cause) {
|
|
107
|
+
output += chalk_1.default.gray(`\n Why: ${error.cause}\n`);
|
|
108
|
+
}
|
|
109
|
+
if (error.recovery.length > 0) {
|
|
110
|
+
output += chalk_1.default.yellow(`\n How to fix:\n`);
|
|
111
|
+
for (let i = 0; i < error.recovery.length; i++) {
|
|
112
|
+
output += chalk_1.default.white(` ${i + 1}. ${error.recovery[i]}\n`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (error.helpUrl) {
|
|
116
|
+
output += chalk_1.default.gray(`\n More help: ${error.helpUrl}\n`);
|
|
117
|
+
}
|
|
118
|
+
return output;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Common error handlers with friendly messages
|
|
122
|
+
*/
|
|
123
|
+
function getNetworkError() {
|
|
124
|
+
return {
|
|
125
|
+
title: 'Connection Failed',
|
|
126
|
+
message: 'Could not connect to CodeBakers servers.',
|
|
127
|
+
cause: 'This usually means a network issue or the server is temporarily unavailable.',
|
|
128
|
+
recovery: [
|
|
129
|
+
'Check your internet connection',
|
|
130
|
+
'Try again in a few seconds',
|
|
131
|
+
'If using a VPN, try disabling it temporarily',
|
|
132
|
+
'Check status.codebakers.ai for server status',
|
|
133
|
+
],
|
|
134
|
+
helpUrl: 'https://codebakers.ai/docs/troubleshooting',
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function getAuthError() {
|
|
138
|
+
return {
|
|
139
|
+
title: 'Authentication Failed',
|
|
140
|
+
message: 'Your API key is invalid or expired.',
|
|
141
|
+
recovery: [
|
|
142
|
+
'Go to codebakers.ai/dashboard',
|
|
143
|
+
'Copy your API key (starts with cb_)',
|
|
144
|
+
'Run: codebakers setup',
|
|
145
|
+
],
|
|
146
|
+
helpUrl: 'https://codebakers.ai/docs/getting-started',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function getSubscriptionError() {
|
|
150
|
+
return {
|
|
151
|
+
title: 'Subscription Required',
|
|
152
|
+
message: 'This feature requires an active subscription.',
|
|
153
|
+
recovery: [
|
|
154
|
+
'Visit codebakers.ai/pricing to see plans',
|
|
155
|
+
'Start a free trial with: codebakers setup',
|
|
156
|
+
'Contact support if you believe this is an error',
|
|
157
|
+
],
|
|
158
|
+
helpUrl: 'https://codebakers.ai/pricing',
|
|
159
|
+
};
|
|
160
|
+
}
|