@codebakers/cli 1.1.5 → 1.1.6
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/doctor.d.ts +8 -0
- package/dist/commands/doctor.js +218 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +772 -0
- package/dist/commands/install-hook.d.ts +12 -0
- package/dist/commands/install-hook.js +193 -0
- package/dist/commands/install.d.ts +1 -0
- package/dist/commands/install.js +81 -0
- package/dist/commands/login.d.ts +1 -0
- package/dist/commands/login.js +54 -0
- package/dist/commands/mcp-config.d.ts +6 -0
- package/dist/commands/mcp-config.js +209 -0
- package/dist/commands/serve.d.ts +1 -0
- package/dist/commands/serve.js +26 -0
- package/dist/commands/setup.d.ts +1 -0
- package/dist/commands/setup.js +92 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +49 -0
- package/dist/commands/uninstall.d.ts +1 -0
- package/dist/commands/uninstall.js +50 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +33 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +71 -1075
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.js +544 -0
- package/package.json +16 -38
- package/src/commands/doctor.ts +231 -0
- package/src/commands/init.ts +827 -0
- package/src/commands/install-hook.ts +207 -0
- package/src/commands/install.ts +94 -0
- package/src/commands/login.ts +56 -0
- package/src/commands/mcp-config.ts +235 -0
- package/src/commands/serve.ts +23 -0
- package/src/commands/setup.ts +104 -0
- package/src/commands/status.ts +48 -0
- package/src/commands/uninstall.ts +49 -0
- package/src/config.ts +34 -0
- package/src/index.ts +87 -0
- package/src/mcp/server.ts +617 -0
- package/tsconfig.json +16 -0
- package/README.md +0 -89
- package/dist/chunk-7CKLRE2H.js +0 -36
- package/dist/config-R2H6JKGW.js +0 -16
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { createInterface } from 'readline';
|
|
4
|
+
import { setApiKey, getApiKey, getApiUrl } from '../config.js';
|
|
5
|
+
|
|
6
|
+
function prompt(question: string): Promise<string> {
|
|
7
|
+
const rl = createInterface({
|
|
8
|
+
input: process.stdin,
|
|
9
|
+
output: process.stdout,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
rl.question(question, (answer) => {
|
|
14
|
+
rl.close();
|
|
15
|
+
resolve(answer.trim());
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function setup(): Promise<void> {
|
|
21
|
+
console.log(chalk.blue('\n ╔══════════════════════════════════════╗'));
|
|
22
|
+
console.log(chalk.blue(' ║') + chalk.white(' CodeBakers One-Time Setup ') + chalk.blue('║'));
|
|
23
|
+
console.log(chalk.blue(' ╚══════════════════════════════════════╝\n'));
|
|
24
|
+
|
|
25
|
+
// Check if already set up
|
|
26
|
+
const existingKey = getApiKey();
|
|
27
|
+
if (existingKey) {
|
|
28
|
+
console.log(chalk.yellow(' You\'re already logged in!\n'));
|
|
29
|
+
const reconfigure = await prompt(chalk.gray(' Reconfigure? (y/N): '));
|
|
30
|
+
if (reconfigure.toLowerCase() !== 'y') {
|
|
31
|
+
showFinalInstructions();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
console.log('');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Step 1: Get API key
|
|
38
|
+
console.log(chalk.white(' Step 1: Enter your API key\n'));
|
|
39
|
+
console.log(chalk.gray(' Find it at: https://codebakers.ai/dashboard\n'));
|
|
40
|
+
|
|
41
|
+
const apiKey = await prompt(chalk.cyan(' API Key: '));
|
|
42
|
+
|
|
43
|
+
if (!apiKey) {
|
|
44
|
+
console.log(chalk.red('\n API key is required.\n'));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Validate API key
|
|
49
|
+
const spinner = ora('Validating API key...').start();
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const apiUrl = getApiUrl();
|
|
53
|
+
const response = await fetch(`${apiUrl}/api/patterns`, {
|
|
54
|
+
method: 'GET',
|
|
55
|
+
headers: {
|
|
56
|
+
Authorization: `Bearer ${apiKey}`,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
spinner.fail('Invalid API key');
|
|
62
|
+
const error = await response.json().catch(() => ({}));
|
|
63
|
+
console.log(chalk.red(`\n ${error.error || 'API key validation failed'}\n`));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
spinner.succeed('API key validated');
|
|
68
|
+
} catch {
|
|
69
|
+
spinner.fail('Could not connect to CodeBakers');
|
|
70
|
+
console.log(chalk.red('\n Check your internet connection and try again.\n'));
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Save API key
|
|
75
|
+
setApiKey(apiKey);
|
|
76
|
+
console.log(chalk.green(' ✓ API key saved\n'));
|
|
77
|
+
|
|
78
|
+
showFinalInstructions();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function showFinalInstructions(): void {
|
|
82
|
+
console.log(chalk.white(' Step 2: Enable in Claude Code\n'));
|
|
83
|
+
console.log(chalk.gray(' Copy this command and paste it into Claude Code:\n'));
|
|
84
|
+
|
|
85
|
+
// Box around the command for easy copying
|
|
86
|
+
const command = '/mcp add codebakers npx -y @codebakers/cli serve';
|
|
87
|
+
console.log(chalk.cyan(' ┌─────────────────────────────────────────────────────┐'));
|
|
88
|
+
console.log(chalk.cyan(' │ ') + chalk.white(command) + chalk.cyan(' │'));
|
|
89
|
+
console.log(chalk.cyan(' └─────────────────────────────────────────────────────┘\n'));
|
|
90
|
+
|
|
91
|
+
console.log(chalk.gray(' This only needs to be done once. No restart needed!\n'));
|
|
92
|
+
|
|
93
|
+
console.log(chalk.blue(' ══════════════════════════════════════\n'));
|
|
94
|
+
console.log(chalk.green(' Almost done! 🎉\n'));
|
|
95
|
+
console.log(chalk.white(' After running that command in Claude Code:\n'));
|
|
96
|
+
console.log(chalk.gray(' • Claude will have access to 34 production patterns'));
|
|
97
|
+
console.log(chalk.gray(' • Patterns are fetched on-demand (never stored locally)'));
|
|
98
|
+
console.log(chalk.gray(' • Works across all your projects\n'));
|
|
99
|
+
|
|
100
|
+
console.log(chalk.white(' Example prompt to try:\n'));
|
|
101
|
+
console.log(chalk.cyan(' "Build a login form with email validation"\n'));
|
|
102
|
+
|
|
103
|
+
console.log(chalk.gray(' Need help? https://codebakers.ai/docs\n'));
|
|
104
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { getApiKey } from '../config.js';
|
|
5
|
+
|
|
6
|
+
export async function status(): Promise<void> {
|
|
7
|
+
console.log(chalk.blue('\n CodeBakers Status\n'));
|
|
8
|
+
|
|
9
|
+
// Check login status
|
|
10
|
+
const apiKey = getApiKey();
|
|
11
|
+
if (apiKey) {
|
|
12
|
+
console.log(chalk.green(' ✓ Logged in'));
|
|
13
|
+
console.log(chalk.gray(` Key: ${apiKey.slice(0, 10)}...`));
|
|
14
|
+
} else {
|
|
15
|
+
console.log(chalk.red(' ✗ Not logged in'));
|
|
16
|
+
console.log(chalk.gray(' Run `codebakers login` to authenticate'));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
console.log('');
|
|
20
|
+
|
|
21
|
+
// Check installation status in current directory
|
|
22
|
+
const cwd = process.cwd();
|
|
23
|
+
const cursorrules = join(cwd, '.cursorrules');
|
|
24
|
+
const claudemd = join(cwd, 'CLAUDE.md');
|
|
25
|
+
const claudeDir = join(cwd, '.claude');
|
|
26
|
+
|
|
27
|
+
const hasCursorRules = existsSync(cursorrules);
|
|
28
|
+
const hasClaudeMd = existsSync(claudemd);
|
|
29
|
+
const hasClaudeDir = existsSync(claudeDir);
|
|
30
|
+
|
|
31
|
+
if (hasCursorRules || hasClaudeMd || hasClaudeDir) {
|
|
32
|
+
console.log(chalk.green(' ✓ Patterns installed in this directory'));
|
|
33
|
+
if (hasCursorRules) {
|
|
34
|
+
console.log(chalk.gray(' - .cursorrules (Cursor IDE)'));
|
|
35
|
+
}
|
|
36
|
+
if (hasClaudeMd) {
|
|
37
|
+
console.log(chalk.gray(' - CLAUDE.md (Claude Code)'));
|
|
38
|
+
}
|
|
39
|
+
if (hasClaudeDir) {
|
|
40
|
+
console.log(chalk.gray(' - .claude/ (Pattern modules)'));
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
console.log(chalk.yellow(' ○ Patterns not installed in this directory'));
|
|
44
|
+
console.log(chalk.gray(' Run `codebakers install` to install'));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log('');
|
|
48
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { existsSync, unlinkSync, rmSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
export async function uninstall(): Promise<void> {
|
|
7
|
+
console.log(chalk.blue('\n CodeBakers Uninstall\n'));
|
|
8
|
+
|
|
9
|
+
const spinner = ora('Removing patterns...').start();
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const cwd = process.cwd();
|
|
13
|
+
let removed = 0;
|
|
14
|
+
|
|
15
|
+
// Remove .cursorrules
|
|
16
|
+
const cursorrules = join(cwd, '.cursorrules');
|
|
17
|
+
if (existsSync(cursorrules)) {
|
|
18
|
+
unlinkSync(cursorrules);
|
|
19
|
+
removed++;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Remove CLAUDE.md
|
|
23
|
+
const claudemd = join(cwd, 'CLAUDE.md');
|
|
24
|
+
if (existsSync(claudemd)) {
|
|
25
|
+
unlinkSync(claudemd);
|
|
26
|
+
removed++;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Remove .claude directory
|
|
30
|
+
const claudeDir = join(cwd, '.claude');
|
|
31
|
+
if (existsSync(claudeDir)) {
|
|
32
|
+
rmSync(claudeDir, { recursive: true });
|
|
33
|
+
removed++;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (removed > 0) {
|
|
37
|
+
spinner.succeed('Patterns removed successfully!');
|
|
38
|
+
console.log(chalk.gray(`\n Removed ${removed} item(s)\n`));
|
|
39
|
+
} else {
|
|
40
|
+
spinner.info('No patterns found to remove');
|
|
41
|
+
console.log(chalk.gray('\n This directory has no CodeBakers patterns installed.\n'));
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
spinner.fail('Uninstall failed');
|
|
45
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
46
|
+
console.log(chalk.red(`\n Error: ${message}\n`));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
|
|
3
|
+
interface ConfigSchema {
|
|
4
|
+
apiKey: string | null;
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const config = new Conf<ConfigSchema>({
|
|
9
|
+
projectName: 'codebakers',
|
|
10
|
+
defaults: {
|
|
11
|
+
apiKey: null,
|
|
12
|
+
apiUrl: 'https://codebakers.ai',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export function getApiKey(): string | null {
|
|
17
|
+
return config.get('apiKey');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function setApiKey(key: string): void {
|
|
21
|
+
config.set('apiKey', key);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function clearApiKey(): void {
|
|
25
|
+
config.delete('apiKey');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getApiUrl(): string {
|
|
29
|
+
return config.get('apiUrl');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function setApiUrl(url: string): void {
|
|
33
|
+
config.set('apiUrl', url);
|
|
34
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { login } from './commands/login.js';
|
|
5
|
+
import { install } from './commands/install.js';
|
|
6
|
+
import { status } from './commands/status.js';
|
|
7
|
+
import { uninstall } from './commands/uninstall.js';
|
|
8
|
+
import { installHook, uninstallHook } from './commands/install-hook.js';
|
|
9
|
+
import { doctor } from './commands/doctor.js';
|
|
10
|
+
import { init } from './commands/init.js';
|
|
11
|
+
import { serve } from './commands/serve.js';
|
|
12
|
+
import { mcpConfig, mcpUninstall } from './commands/mcp-config.js';
|
|
13
|
+
import { setup } from './commands/setup.js';
|
|
14
|
+
|
|
15
|
+
const program = new Command();
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.name('codebakers')
|
|
19
|
+
.description('CodeBakers CLI - Production patterns for AI-assisted development')
|
|
20
|
+
.version('1.0.0');
|
|
21
|
+
|
|
22
|
+
// Primary command - one-time setup
|
|
23
|
+
program
|
|
24
|
+
.command('setup')
|
|
25
|
+
.description('One-time setup: login + configure Claude Code (recommended)')
|
|
26
|
+
.action(setup);
|
|
27
|
+
|
|
28
|
+
program
|
|
29
|
+
.command('init')
|
|
30
|
+
.description('Interactive project setup wizard')
|
|
31
|
+
.action(init);
|
|
32
|
+
|
|
33
|
+
program
|
|
34
|
+
.command('login')
|
|
35
|
+
.description('Login with your API key')
|
|
36
|
+
.action(login);
|
|
37
|
+
|
|
38
|
+
program
|
|
39
|
+
.command('install')
|
|
40
|
+
.description('Install patterns in the current project')
|
|
41
|
+
.action(install);
|
|
42
|
+
|
|
43
|
+
program
|
|
44
|
+
.command('status')
|
|
45
|
+
.description('Check installation status')
|
|
46
|
+
.action(status);
|
|
47
|
+
|
|
48
|
+
program
|
|
49
|
+
.command('uninstall')
|
|
50
|
+
.description('Remove patterns from the current project')
|
|
51
|
+
.action(uninstall);
|
|
52
|
+
|
|
53
|
+
program
|
|
54
|
+
.command('install-hook')
|
|
55
|
+
.description('Install the CodeBakers hook into Claude Code')
|
|
56
|
+
.action(installHook);
|
|
57
|
+
|
|
58
|
+
program
|
|
59
|
+
.command('uninstall-hook')
|
|
60
|
+
.description('Remove the CodeBakers hook from Claude Code')
|
|
61
|
+
.action(uninstallHook);
|
|
62
|
+
|
|
63
|
+
program
|
|
64
|
+
.command('doctor')
|
|
65
|
+
.description('Check if CodeBakers is set up correctly')
|
|
66
|
+
.action(doctor);
|
|
67
|
+
|
|
68
|
+
// MCP Server commands
|
|
69
|
+
program
|
|
70
|
+
.command('serve')
|
|
71
|
+
.description('Start the MCP server for Claude Code integration')
|
|
72
|
+
.action(serve);
|
|
73
|
+
|
|
74
|
+
program
|
|
75
|
+
.command('mcp-config')
|
|
76
|
+
.description('Show or install MCP configuration for Claude Code')
|
|
77
|
+
.option('--install', 'Install to global Claude Code config')
|
|
78
|
+
.option('--project', 'Create .mcp.json in current directory (for boilerplates)')
|
|
79
|
+
.option('--show', 'Show configuration without installing')
|
|
80
|
+
.action(mcpConfig);
|
|
81
|
+
|
|
82
|
+
program
|
|
83
|
+
.command('mcp-uninstall')
|
|
84
|
+
.description('Remove MCP configuration from Claude Code')
|
|
85
|
+
.action(mcpUninstall);
|
|
86
|
+
|
|
87
|
+
program.parse();
|