@codebakers/cli 3.4.1 → 3.5.1
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 +1 -1
- package/dist/commands/doctor.js +40 -82
- package/dist/commands/go.js +147 -107
- package/dist/commands/init.js +56 -41
- package/dist/commands/install-hook.js +8 -8
- package/dist/commands/install.js +54 -55
- package/dist/commands/scaffold.js +39 -22
- package/dist/commands/status.js +41 -13
- package/dist/mcp/server.js +165 -146
- package/package.json +1 -1
- package/src/commands/doctor.ts +39 -81
- package/src/commands/go.ts +152 -132
- package/src/commands/init.ts +55 -43
- package/src/commands/install-hook.ts +8 -8
- package/src/commands/install.ts +59 -68
- package/src/commands/scaffold.ts +39 -22
- package/src/commands/status.ts +45 -15
- package/src/mcp/server.ts +167 -160
package/dist/commands/doctor.js
CHANGED
|
@@ -12,12 +12,11 @@ const os_1 = require("os");
|
|
|
12
12
|
const install_hook_js_1 = require("./install-hook.js");
|
|
13
13
|
const config_js_1 = require("../config.js");
|
|
14
14
|
const api_js_1 = require("../lib/api.js");
|
|
15
|
-
const stats_js_1 = require("../lib/stats.js");
|
|
16
15
|
/**
|
|
17
16
|
* Run all health checks for CodeBakers setup
|
|
18
17
|
*/
|
|
19
18
|
async function doctor() {
|
|
20
|
-
console.log(chalk_1.default.blue('\n CodeBakers Doctor\n'));
|
|
19
|
+
console.log(chalk_1.default.blue('\n CodeBakers Doctor (v6.0)\n'));
|
|
21
20
|
// Show version
|
|
22
21
|
const version = (0, api_js_1.getCliVersion)();
|
|
23
22
|
console.log(chalk_1.default.gray(` CLI Version: ${version}\n`));
|
|
@@ -64,7 +63,7 @@ async function doctor() {
|
|
|
64
63
|
console.log(chalk_1.default.white(' Suggested fixes:'));
|
|
65
64
|
const claudeMdCheck = projectChecks.find(c => c.message.includes('CLAUDE.md'));
|
|
66
65
|
if (claudeMdCheck && !claudeMdCheck.ok) {
|
|
67
|
-
console.log(chalk_1.default.gray(' • Run: codebakers
|
|
66
|
+
console.log(chalk_1.default.gray(' • Run: codebakers go'));
|
|
68
67
|
}
|
|
69
68
|
const hookCheck = systemChecks.find(c => c.message.includes('Hook'));
|
|
70
69
|
if (hookCheck && !hookCheck.ok) {
|
|
@@ -84,23 +83,30 @@ async function doctor() {
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
87
|
-
* Check project-level setup
|
|
86
|
+
* Check project-level setup (v6.0 bootstrap files)
|
|
88
87
|
*/
|
|
89
88
|
function checkProject() {
|
|
90
89
|
const results = [];
|
|
91
90
|
const cwd = process.cwd();
|
|
92
|
-
// Check CLAUDE.md
|
|
91
|
+
// Check CLAUDE.md with v6 content
|
|
93
92
|
const claudeMdPath = (0, path_1.join)(cwd, 'CLAUDE.md');
|
|
94
93
|
if ((0, fs_1.existsSync)(claudeMdPath)) {
|
|
95
94
|
const content = (0, fs_1.readFileSync)(claudeMdPath, 'utf-8');
|
|
96
|
-
if (content.includes('
|
|
97
|
-
results.push({ ok: true, message: 'CLAUDE.md exists (
|
|
95
|
+
if (content.includes('discover_patterns') || content.includes('v6.0')) {
|
|
96
|
+
results.push({ ok: true, message: 'CLAUDE.md exists (v6.0 gateway)' });
|
|
97
|
+
}
|
|
98
|
+
else if (content.includes('CodeBakers') || content.includes('.claude')) {
|
|
99
|
+
results.push({
|
|
100
|
+
ok: false,
|
|
101
|
+
message: 'CLAUDE.md exists but is v5 format',
|
|
102
|
+
details: 'Run: codebakers go --upgrade'
|
|
103
|
+
});
|
|
98
104
|
}
|
|
99
105
|
else {
|
|
100
106
|
results.push({
|
|
101
107
|
ok: false,
|
|
102
|
-
message: 'CLAUDE.md exists but
|
|
103
|
-
details: 'Run: codebakers
|
|
108
|
+
message: 'CLAUDE.md exists but not CodeBakers',
|
|
109
|
+
details: 'Run: codebakers go'
|
|
104
110
|
});
|
|
105
111
|
}
|
|
106
112
|
}
|
|
@@ -108,92 +114,43 @@ function checkProject() {
|
|
|
108
114
|
results.push({
|
|
109
115
|
ok: false,
|
|
110
116
|
message: 'CLAUDE.md not found',
|
|
111
|
-
details: 'Run: codebakers
|
|
117
|
+
details: 'Run: codebakers go'
|
|
112
118
|
});
|
|
113
119
|
}
|
|
114
|
-
// Check .
|
|
115
|
-
const
|
|
116
|
-
if ((0, fs_1.existsSync)(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const files = (0, fs_1.readdirSync)(claudeDir).filter(f => f.endsWith('.md'));
|
|
121
|
-
const moduleCount = files.length;
|
|
122
|
-
if (moduleCount >= 50) {
|
|
123
|
-
results.push({ ok: true, message: `${moduleCount} modules present (full set)` });
|
|
124
|
-
}
|
|
125
|
-
else if (moduleCount >= 10) {
|
|
126
|
-
results.push({
|
|
127
|
-
ok: true,
|
|
128
|
-
message: `${moduleCount} modules present (partial set)`,
|
|
129
|
-
details: `Run: codebakers upgrade to get all ${stats_js_1.CODEBAKERS_STATS.moduleCount} modules`
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
else if (moduleCount > 0) {
|
|
133
|
-
results.push({
|
|
134
|
-
ok: false,
|
|
135
|
-
message: `Only ${moduleCount} modules found (expected ${stats_js_1.CODEBAKERS_STATS.moduleCount})`,
|
|
136
|
-
details: 'Run: codebakers upgrade to get all modules'
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
results.push({
|
|
141
|
-
ok: false,
|
|
142
|
-
message: 'No modules found in .claude/',
|
|
143
|
-
details: 'Run: codebakers install'
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
// Check for 00-core.md
|
|
147
|
-
const corePath = (0, path_1.join)(claudeDir, '00-core.md');
|
|
148
|
-
if ((0, fs_1.existsSync)(corePath)) {
|
|
149
|
-
results.push({ ok: true, message: '00-core.md exists (base patterns)' });
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
results.push({
|
|
153
|
-
ok: false,
|
|
154
|
-
message: '00-core.md not found',
|
|
155
|
-
details: 'This module is loaded on every task'
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
// Check for 00-system.md
|
|
159
|
-
const systemPath = (0, path_1.join)(claudeDir, '00-system.md');
|
|
160
|
-
if ((0, fs_1.existsSync)(systemPath)) {
|
|
161
|
-
results.push({ ok: true, message: '00-system.md exists (workflow module)' });
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
results.push({
|
|
165
|
-
ok: true, // Not required, just recommended
|
|
166
|
-
message: '00-system.md not found (optional workflow module)',
|
|
167
|
-
details: 'Contains 9-step execution flow'
|
|
168
|
-
});
|
|
169
|
-
}
|
|
120
|
+
// Check .cursorrules with v6 content
|
|
121
|
+
const cursorRulesPath = (0, path_1.join)(cwd, '.cursorrules');
|
|
122
|
+
if ((0, fs_1.existsSync)(cursorRulesPath)) {
|
|
123
|
+
const content = (0, fs_1.readFileSync)(cursorRulesPath, 'utf-8');
|
|
124
|
+
if (content.includes('discover_patterns') || content.includes('v6.0')) {
|
|
125
|
+
results.push({ ok: true, message: '.cursorrules exists (v6.0 gateway)' });
|
|
170
126
|
}
|
|
171
|
-
|
|
127
|
+
else {
|
|
172
128
|
results.push({
|
|
173
129
|
ok: false,
|
|
174
|
-
message: '
|
|
175
|
-
details: '
|
|
130
|
+
message: '.cursorrules exists but is old format',
|
|
131
|
+
details: 'Run: codebakers go --upgrade'
|
|
176
132
|
});
|
|
177
133
|
}
|
|
178
134
|
}
|
|
179
135
|
else {
|
|
180
136
|
results.push({
|
|
181
137
|
ok: false,
|
|
182
|
-
message: '.
|
|
183
|
-
details: 'Run: codebakers
|
|
138
|
+
message: '.cursorrules not found',
|
|
139
|
+
details: 'Run: codebakers go'
|
|
184
140
|
});
|
|
185
141
|
}
|
|
186
|
-
// Check
|
|
187
|
-
const
|
|
188
|
-
if ((0, fs_1.existsSync)(
|
|
189
|
-
results.push({ ok: true, message: 'PROJECT-STATE.md exists' });
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
142
|
+
// Check for legacy .claude folder (should be removed in v6)
|
|
143
|
+
const claudeDir = (0, path_1.join)(cwd, '.claude');
|
|
144
|
+
if ((0, fs_1.existsSync)(claudeDir)) {
|
|
192
145
|
results.push({
|
|
193
|
-
ok:
|
|
194
|
-
message: '
|
|
146
|
+
ok: false,
|
|
147
|
+
message: 'Legacy .claude/ folder found',
|
|
148
|
+
details: 'v6.0 uses server-side patterns. Run: codebakers go --upgrade'
|
|
195
149
|
});
|
|
196
150
|
}
|
|
151
|
+
else {
|
|
152
|
+
results.push({ ok: true, message: 'No legacy .claude/ folder (v6.0 clean)' });
|
|
153
|
+
}
|
|
197
154
|
return results;
|
|
198
155
|
}
|
|
199
156
|
/**
|
|
@@ -269,13 +226,14 @@ async function checkAuth() {
|
|
|
269
226
|
return results;
|
|
270
227
|
}
|
|
271
228
|
/**
|
|
272
|
-
* Quick check - returns true if
|
|
229
|
+
* Quick check - returns true if v6 setup is complete
|
|
273
230
|
*/
|
|
274
231
|
function isSetupComplete() {
|
|
275
232
|
const cwd = process.cwd();
|
|
276
233
|
const hasClaudeMd = (0, fs_1.existsSync)((0, path_1.join)(cwd, 'CLAUDE.md'));
|
|
277
|
-
const
|
|
234
|
+
const hasCursorRules = (0, fs_1.existsSync)((0, path_1.join)(cwd, '.cursorrules'));
|
|
278
235
|
const hasHook = (0, install_hook_js_1.isHookInstalled)();
|
|
279
236
|
const hasApiKey = !!(0, config_js_1.getApiKey)();
|
|
280
|
-
|
|
237
|
+
// v6: No .claude folder required
|
|
238
|
+
return hasClaudeMd && hasCursorRules && hasHook && hasApiKey;
|
|
281
239
|
}
|
package/dist/commands/go.js
CHANGED
|
@@ -194,7 +194,7 @@ async function go(options = {}) {
|
|
|
194
194
|
(0, config_js_1.setTrialState)(trialState);
|
|
195
195
|
spinner.succeed(`Trial started (${data.daysRemaining} days free)`);
|
|
196
196
|
console.log('');
|
|
197
|
-
// Install
|
|
197
|
+
// Install v6.0 bootstrap files (CLAUDE.md and .cursorrules only)
|
|
198
198
|
await installPatterns(data.trialId, options);
|
|
199
199
|
// Configure MCP
|
|
200
200
|
await configureMCP(options);
|
|
@@ -319,126 +319,166 @@ async function showSuccessAndRestart() {
|
|
|
319
319
|
console.log(chalk_1.default.yellow(' Could not auto-restart. Please restart Claude Code manually.\n'));
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
+
// v6.0 Bootstrap content - minimal files that point to MCP tools
|
|
323
|
+
const V6_CLAUDE_MD = `# CodeBakers v6.0 - Server-Enforced Patterns
|
|
324
|
+
|
|
325
|
+
**All patterns are server-side. No local pattern files needed.**
|
|
326
|
+
|
|
327
|
+
## Required MCP Tools
|
|
328
|
+
|
|
329
|
+
Before writing ANY code, you MUST use these CodeBakers MCP tools:
|
|
330
|
+
|
|
331
|
+
### 1. discover_patterns (MANDATORY - START GATE)
|
|
332
|
+
Call this BEFORE writing any code:
|
|
333
|
+
\`\`\`
|
|
334
|
+
Tool: discover_patterns
|
|
335
|
+
Args: { task: "what you're about to do", files: ["files to modify"], keywords: ["relevant terms"] }
|
|
336
|
+
\`\`\`
|
|
337
|
+
This returns:
|
|
338
|
+
- Relevant patterns from the server
|
|
339
|
+
- A session token (required for validation)
|
|
340
|
+
- Code examples to follow
|
|
341
|
+
|
|
342
|
+
### 2. validate_complete (MANDATORY - END GATE)
|
|
343
|
+
Call this BEFORE saying "done" or "complete":
|
|
344
|
+
\`\`\`
|
|
345
|
+
Tool: validate_complete
|
|
346
|
+
Args: { feature: "what you built", files: ["files modified"] }
|
|
347
|
+
\`\`\`
|
|
348
|
+
This checks:
|
|
349
|
+
- You called discover_patterns first (server verifies)
|
|
350
|
+
- Tests exist and pass
|
|
351
|
+
- TypeScript compiles
|
|
352
|
+
- Returns pass/fail from server
|
|
353
|
+
|
|
354
|
+
## Rules
|
|
355
|
+
|
|
356
|
+
1. **You CANNOT skip discover_patterns** - Server tracks compliance
|
|
357
|
+
2. **You CANNOT say "done" without validate_complete** - Server must approve
|
|
358
|
+
3. **Follow patterns returned by server** - They are mandatory
|
|
359
|
+
4. **Write tests** - Validation will fail without them
|
|
360
|
+
5. **Fix TypeScript errors** - Validation will fail with errors
|
|
361
|
+
|
|
362
|
+
## If Server is Unreachable
|
|
363
|
+
|
|
364
|
+
The tools will show "OFFLINE MODE" if the server can't be reached. In this case:
|
|
365
|
+
- Enforcement is limited to local checks only
|
|
366
|
+
- You should still follow best practices
|
|
367
|
+
- Try again when connection is restored
|
|
368
|
+
|
|
369
|
+
## Getting Help
|
|
370
|
+
|
|
371
|
+
- Run \`codebakers doctor\` to diagnose issues
|
|
372
|
+
- Run \`codebakers upgrade\` to update patterns
|
|
373
|
+
- Visit https://codebakers.ai/support for help
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
*CodeBakers v6.0 - Server-Enforced Patterns*
|
|
377
|
+
`;
|
|
378
|
+
const V6_CURSORRULES = `# CodeBakers v6.0 - Server-Enforced Patterns
|
|
379
|
+
|
|
380
|
+
All patterns are server-side. No local pattern files needed.
|
|
381
|
+
|
|
382
|
+
## Required MCP Tools
|
|
383
|
+
|
|
384
|
+
Before writing ANY code, you MUST use these CodeBakers MCP tools:
|
|
385
|
+
|
|
386
|
+
### 1. discover_patterns (MANDATORY - START GATE)
|
|
387
|
+
Call this BEFORE writing any code:
|
|
388
|
+
- Tool: discover_patterns
|
|
389
|
+
- Args: { task: "what you're about to do", files: ["files to modify"], keywords: ["relevant terms"] }
|
|
390
|
+
|
|
391
|
+
Returns:
|
|
392
|
+
- Relevant patterns from the server
|
|
393
|
+
- A session token (required for validation)
|
|
394
|
+
- Code examples to follow
|
|
395
|
+
|
|
396
|
+
### 2. validate_complete (MANDATORY - END GATE)
|
|
397
|
+
Call this BEFORE saying "done" or "complete":
|
|
398
|
+
- Tool: validate_complete
|
|
399
|
+
- Args: { feature: "what you built", files: ["files modified"] }
|
|
400
|
+
|
|
401
|
+
Checks:
|
|
402
|
+
- You called discover_patterns first (server verifies)
|
|
403
|
+
- Tests exist and pass
|
|
404
|
+
- TypeScript compiles
|
|
405
|
+
- Returns pass/fail from server
|
|
406
|
+
|
|
407
|
+
## Rules
|
|
408
|
+
|
|
409
|
+
1. You CANNOT skip discover_patterns - Server tracks compliance
|
|
410
|
+
2. You CANNOT say "done" without validate_complete - Server must approve
|
|
411
|
+
3. Follow patterns returned by server - They are mandatory
|
|
412
|
+
4. Write tests - Validation will fail without them
|
|
413
|
+
5. Fix TypeScript errors - Validation will fail with errors
|
|
414
|
+
|
|
415
|
+
## If Server is Unreachable
|
|
416
|
+
|
|
417
|
+
The tools will show "OFFLINE MODE" if the server can't be reached. In this case:
|
|
418
|
+
- Enforcement is limited to local checks only
|
|
419
|
+
- You should still follow best practices
|
|
420
|
+
- Try again when connection is restored
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
CodeBakers v6.0 - Server-Enforced Patterns
|
|
424
|
+
`;
|
|
322
425
|
/**
|
|
323
|
-
* Install
|
|
426
|
+
* Install v6.0 bootstrap files for API key users (paid users)
|
|
427
|
+
* Only installs minimal CLAUDE.md and .cursorrules - no .claude/ folder
|
|
324
428
|
*/
|
|
325
429
|
async function installPatternsWithApiKey(apiKey, options = {}) {
|
|
326
|
-
log('Installing
|
|
327
|
-
|
|
328
|
-
const cwd = process.cwd();
|
|
329
|
-
const apiUrl = (0, config_js_1.getApiUrl)();
|
|
330
|
-
log(`Fetching from: ${apiUrl}/api/content`, options);
|
|
331
|
-
try {
|
|
332
|
-
const response = await fetch(`${apiUrl}/api/content`, {
|
|
333
|
-
method: 'GET',
|
|
334
|
-
headers: {
|
|
335
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
336
|
-
},
|
|
337
|
-
});
|
|
338
|
-
if (!response.ok) {
|
|
339
|
-
log(`Response not OK: ${response.status} ${response.statusText}`, options);
|
|
340
|
-
spinner.warn('Could not download patterns');
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
log('Response OK, parsing JSON...', options);
|
|
344
|
-
const content = await response.json();
|
|
345
|
-
log(`Received version: ${content.version}, modules: ${Object.keys(content.modules || {}).length}`, options);
|
|
346
|
-
await writePatternFiles(cwd, content, spinner, options, { apiKey });
|
|
347
|
-
}
|
|
348
|
-
catch (error) {
|
|
349
|
-
log(`Error: ${error instanceof Error ? error.message : String(error)}`, options);
|
|
350
|
-
spinner.warn('Could not install patterns');
|
|
351
|
-
console.log(chalk_1.default.gray(' Check your internet connection.\n'));
|
|
352
|
-
}
|
|
430
|
+
log('Installing v6.0 bootstrap files (API key user)...', options);
|
|
431
|
+
await installBootstrapFiles(options, { apiKey });
|
|
353
432
|
}
|
|
354
433
|
/**
|
|
355
|
-
* Install
|
|
434
|
+
* Install v6.0 bootstrap files for trial users
|
|
435
|
+
* Only installs minimal CLAUDE.md and .cursorrules - no .claude/ folder
|
|
356
436
|
*/
|
|
357
437
|
async function installPatterns(trialId, options = {}) {
|
|
358
|
-
log(`Installing
|
|
359
|
-
|
|
438
|
+
log(`Installing v6.0 bootstrap files (trial: ${trialId.substring(0, 8)}...)`, options);
|
|
439
|
+
await installBootstrapFiles(options, { trialId });
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Install v6.0 minimal bootstrap files
|
|
443
|
+
* - CLAUDE.md: Instructions for Claude Code
|
|
444
|
+
* - .cursorrules: Instructions for Cursor
|
|
445
|
+
* - NO .claude/ folder - all patterns are server-side
|
|
446
|
+
*/
|
|
447
|
+
async function installBootstrapFiles(options = {}, auth) {
|
|
448
|
+
const spinner = (0, ora_1.default)('Installing CodeBakers v6.0...').start();
|
|
360
449
|
const cwd = process.cwd();
|
|
361
|
-
const apiUrl = (0, config_js_1.getApiUrl)();
|
|
362
450
|
try {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
});
|
|
371
|
-
if (!response.ok) {
|
|
372
|
-
log(`Primary endpoint failed: ${response.status}, trying trial endpoint...`, options);
|
|
373
|
-
// Try without auth - some patterns may be available for trial
|
|
374
|
-
const publicResponse = await fetch(`${apiUrl}/api/content/trial`, {
|
|
375
|
-
method: 'GET',
|
|
376
|
-
headers: {
|
|
377
|
-
'X-Trial-ID': trialId,
|
|
378
|
-
},
|
|
379
|
-
});
|
|
380
|
-
if (!publicResponse.ok) {
|
|
381
|
-
log(`Trial endpoint also failed: ${publicResponse.status}`, options);
|
|
382
|
-
spinner.warn('Could not download patterns (will use MCP tools)');
|
|
451
|
+
const claudeMdPath = (0, path_1.join)(cwd, 'CLAUDE.md');
|
|
452
|
+
const cursorRulesPath = (0, path_1.join)(cwd, '.cursorrules');
|
|
453
|
+
// Check if already installed with v6
|
|
454
|
+
if ((0, fs_1.existsSync)(claudeMdPath)) {
|
|
455
|
+
const content = (0, fs_1.readFileSync)(claudeMdPath, 'utf-8');
|
|
456
|
+
if (content.includes('v6.0') && content.includes('discover_patterns')) {
|
|
457
|
+
spinner.succeed('CodeBakers v6.0 already installed');
|
|
383
458
|
return;
|
|
384
459
|
}
|
|
385
|
-
|
|
386
|
-
log(
|
|
387
|
-
|
|
388
|
-
|
|
460
|
+
// Upgrade from v5
|
|
461
|
+
log('Upgrading from v5 to v6...', options);
|
|
462
|
+
}
|
|
463
|
+
// Write v6.0 bootstrap files
|
|
464
|
+
(0, fs_1.writeFileSync)(claudeMdPath, V6_CLAUDE_MD);
|
|
465
|
+
(0, fs_1.writeFileSync)(cursorRulesPath, V6_CURSORRULES);
|
|
466
|
+
spinner.succeed('CodeBakers v6.0 installed');
|
|
467
|
+
console.log(chalk_1.default.gray(' Patterns are server-enforced via MCP tools\n'));
|
|
468
|
+
// Confirm install to server (non-blocking)
|
|
469
|
+
if (auth) {
|
|
470
|
+
const apiUrl = (0, config_js_1.getApiUrl)();
|
|
471
|
+
confirmDownload(apiUrl, auth, {
|
|
472
|
+
version: '6.0',
|
|
473
|
+
moduleCount: 0, // No local modules in v6
|
|
474
|
+
cliVersion: getCliVersion(),
|
|
475
|
+
command: 'go',
|
|
476
|
+
}).catch(() => { }); // Silently ignore
|
|
389
477
|
}
|
|
390
|
-
const content = await response.json();
|
|
391
|
-
log(`Received version: ${content.version}, modules: ${Object.keys(content.modules || {}).length}`, options);
|
|
392
|
-
await writePatternFiles(cwd, content, spinner, options, { trialId });
|
|
393
478
|
}
|
|
394
479
|
catch (error) {
|
|
395
480
|
log(`Error: ${error instanceof Error ? error.message : String(error)}`, options);
|
|
396
|
-
spinner.warn('Could not install
|
|
397
|
-
console.log(chalk_1.default.gray('
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
async function writePatternFiles(cwd, content, spinner, options = {}, auth) {
|
|
401
|
-
log(`Writing pattern files to ${cwd}...`, options);
|
|
402
|
-
// Check if patterns already exist
|
|
403
|
-
const claudeMdPath = (0, path_1.join)(cwd, 'CLAUDE.md');
|
|
404
|
-
if ((0, fs_1.existsSync)(claudeMdPath)) {
|
|
405
|
-
spinner.succeed('CodeBakers patterns already installed');
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
// Write CLAUDE.md (router file)
|
|
409
|
-
if (content.router) {
|
|
410
|
-
(0, fs_1.writeFileSync)(claudeMdPath, content.router);
|
|
411
|
-
}
|
|
412
|
-
// Write pattern modules to .claude/
|
|
413
|
-
const moduleCount = Object.keys(content.modules || {}).length;
|
|
414
|
-
if (content.modules && moduleCount > 0) {
|
|
415
|
-
const modulesDir = (0, path_1.join)(cwd, '.claude');
|
|
416
|
-
if (!(0, fs_1.existsSync)(modulesDir)) {
|
|
417
|
-
(0, fs_1.mkdirSync)(modulesDir, { recursive: true });
|
|
418
|
-
}
|
|
419
|
-
for (const [name, data] of Object.entries(content.modules)) {
|
|
420
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(modulesDir, name), data);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
// Update .gitignore to exclude encoded patterns
|
|
424
|
-
const gitignorePath = (0, path_1.join)(cwd, '.gitignore');
|
|
425
|
-
if ((0, fs_1.existsSync)(gitignorePath)) {
|
|
426
|
-
const { readFileSync } = await import('fs');
|
|
427
|
-
const gitignore = readFileSync(gitignorePath, 'utf-8');
|
|
428
|
-
if (!gitignore.includes('.claude/')) {
|
|
429
|
-
(0, fs_1.writeFileSync)(gitignorePath, gitignore + '\n# CodeBakers patterns\n.claude/\n');
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
spinner.succeed(`CodeBakers patterns installed (v${content.version})`);
|
|
433
|
-
console.log(chalk_1.default.gray(` ${moduleCount} pattern modules ready\n`));
|
|
434
|
-
// Confirm download to server (non-blocking)
|
|
435
|
-
if (auth) {
|
|
436
|
-
const apiUrl = (0, config_js_1.getApiUrl)();
|
|
437
|
-
confirmDownload(apiUrl, auth, {
|
|
438
|
-
version: content.version,
|
|
439
|
-
moduleCount,
|
|
440
|
-
cliVersion: getCliVersion(),
|
|
441
|
-
command: 'go',
|
|
442
|
-
}).catch(() => { }); // Silently ignore
|
|
481
|
+
spinner.warn('Could not install bootstrap files');
|
|
482
|
+
console.log(chalk_1.default.gray(' MCP tools will still work without local files.\n'));
|
|
443
483
|
}
|
|
444
484
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -38,9 +38,9 @@ If PROJECT-CONTEXT.md is empty or stale (>7 days), SCAN THE PROJECT FIRST:
|
|
|
38
38
|
- Update PROJECT-CONTEXT.md
|
|
39
39
|
|
|
40
40
|
### PHASE 3: EXECUTE
|
|
41
|
-
- State: \`📋 CodeBakers | [Type] |
|
|
42
|
-
-
|
|
43
|
-
- Follow patterns EXACTLY
|
|
41
|
+
- State: \`📋 CodeBakers | [Type] | v6.0 Server-Enforced\`
|
|
42
|
+
- Call discover_patterns MCP tool first
|
|
43
|
+
- Follow patterns from server EXACTLY
|
|
44
44
|
|
|
45
45
|
### PHASE 4: SELF-REVIEW (before saying "done")
|
|
46
46
|
- [ ] TypeScript compiles? (npx tsc --noEmit)
|
|
@@ -386,9 +386,9 @@ When you make a decision that affects architecture, add an entry:
|
|
|
386
386
|
---
|
|
387
387
|
|
|
388
388
|
## ${date}: Project Initialized
|
|
389
|
-
**Decision:** Using CodeBakers pattern system
|
|
389
|
+
**Decision:** Using CodeBakers v6.0 pattern system
|
|
390
390
|
**Reason:** Ensure consistent, production-quality code
|
|
391
|
-
**Pattern:**
|
|
391
|
+
**Pattern:** Server-enforced via discover_patterns MCP tool
|
|
392
392
|
|
|
393
393
|
---
|
|
394
394
|
|
|
@@ -573,43 +573,59 @@ async function init() {
|
|
|
573
573
|
process.exit(1);
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
// Step 4: Install
|
|
577
|
-
console.log(chalk_1.default.white('\n Step 2: Installing
|
|
578
|
-
const spinner = (0, ora_1.default)('
|
|
576
|
+
// Step 4: Install v6.0 bootstrap files
|
|
577
|
+
console.log(chalk_1.default.white('\n Step 2: Installing CodeBakers v6.0\n'));
|
|
578
|
+
const spinner = (0, ora_1.default)(' Installing v6.0 bootstrap...').start();
|
|
579
|
+
// v6.0 bootstrap content - minimal files, patterns from server
|
|
580
|
+
const V6_CLAUDE_MD = `# CodeBakers v6.0
|
|
581
|
+
|
|
582
|
+
**MANDATORY: Before writing ANY code, call the \`discover_patterns\` MCP tool.**
|
|
583
|
+
|
|
584
|
+
\`\`\`
|
|
585
|
+
Tool: discover_patterns
|
|
586
|
+
Args: { task: "description of what you're building" }
|
|
587
|
+
\`\`\`
|
|
588
|
+
|
|
589
|
+
The server will return:
|
|
590
|
+
- All coding patterns and rules you must follow
|
|
591
|
+
- Test requirements
|
|
592
|
+
- Validation instructions
|
|
593
|
+
|
|
594
|
+
**You cannot write code without calling this tool first. The server tracks compliance.**
|
|
595
|
+
|
|
596
|
+
---
|
|
597
|
+
*CodeBakers v6.0 - Server-Enforced*
|
|
598
|
+
`;
|
|
599
|
+
const V6_CURSORRULES = `# CodeBakers v6.0
|
|
600
|
+
|
|
601
|
+
MANDATORY: Before writing ANY code, call the discover_patterns MCP tool.
|
|
602
|
+
|
|
603
|
+
Tool: discover_patterns
|
|
604
|
+
Args: { task: "description of what you're building" }
|
|
605
|
+
|
|
606
|
+
The server returns all patterns, rules, and test requirements.
|
|
607
|
+
You cannot write code without calling this tool first.
|
|
608
|
+
`;
|
|
579
609
|
try {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
throw new Error(error.error || 'Failed to fetch content');
|
|
590
|
-
}
|
|
591
|
-
const content = await response.json();
|
|
592
|
-
spinner.text = ' Installing patterns...';
|
|
593
|
-
// Write router file (CLAUDE.md)
|
|
594
|
-
if (content.router) {
|
|
595
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'CLAUDE.md'), content.router);
|
|
596
|
-
}
|
|
597
|
-
// Write modules to .claude/
|
|
598
|
-
if (content.modules && Object.keys(content.modules).length > 0) {
|
|
599
|
-
const modulesDir = (0, path_1.join)(cwd, '.claude');
|
|
600
|
-
if (!(0, fs_1.existsSync)(modulesDir)) {
|
|
601
|
-
(0, fs_1.mkdirSync)(modulesDir, { recursive: true });
|
|
610
|
+
// Write v6.0 bootstrap files
|
|
611
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'CLAUDE.md'), V6_CLAUDE_MD);
|
|
612
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.cursorrules'), V6_CURSORRULES);
|
|
613
|
+
// Remove old .claude folder if it exists (v5 → v6 migration)
|
|
614
|
+
const claudeDir = (0, path_1.join)(cwd, '.claude');
|
|
615
|
+
if ((0, fs_1.existsSync)(claudeDir)) {
|
|
616
|
+
const { rmSync } = await import('fs');
|
|
617
|
+
try {
|
|
618
|
+
rmSync(claudeDir, { recursive: true, force: true });
|
|
602
619
|
}
|
|
603
|
-
|
|
604
|
-
|
|
620
|
+
catch {
|
|
621
|
+
// Ignore errors
|
|
605
622
|
}
|
|
606
623
|
}
|
|
607
|
-
spinner.succeed('
|
|
608
|
-
console.log(chalk_1.default.gray(
|
|
609
|
-
console.log(chalk_1.default.gray(` Modules: ${Object.keys(content.modules || {}).length} pattern files`));
|
|
624
|
+
spinner.succeed('CodeBakers v6.0 installed!');
|
|
625
|
+
console.log(chalk_1.default.gray('\n Patterns are server-enforced via MCP tools'));
|
|
610
626
|
}
|
|
611
627
|
catch (error) {
|
|
612
|
-
spinner.fail('
|
|
628
|
+
spinner.fail('Installation failed');
|
|
613
629
|
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
614
630
|
console.log(chalk_1.default.red(`\n Error: ${message}\n`));
|
|
615
631
|
process.exit(1);
|
|
@@ -711,7 +727,7 @@ async function init() {
|
|
|
711
727
|
if ((0, fs_1.existsSync)(gitignorePath)) {
|
|
712
728
|
const gitignore = (0, fs_1.readFileSync)(gitignorePath, 'utf-8');
|
|
713
729
|
if (!gitignore.includes('.cursorrules')) {
|
|
714
|
-
const additions = '\n# CodeBakers
|
|
730
|
+
const additions = '\n# CodeBakers\n.cursorrules\n';
|
|
715
731
|
(0, fs_1.writeFileSync)(gitignorePath, gitignore + additions);
|
|
716
732
|
}
|
|
717
733
|
}
|
|
@@ -785,16 +801,15 @@ async function init() {
|
|
|
785
801
|
╚═══════════════════════════════════════════════════════════╝
|
|
786
802
|
`));
|
|
787
803
|
console.log(chalk_1.default.white(' Files created:\n'));
|
|
788
|
-
console.log(chalk_1.default.cyan(' CLAUDE.md ') + chalk_1.default.gray('→
|
|
804
|
+
console.log(chalk_1.default.cyan(' CLAUDE.md ') + chalk_1.default.gray('→ v6.0 bootstrap (patterns via MCP)'));
|
|
805
|
+
console.log(chalk_1.default.cyan(' .cursorrules ') + chalk_1.default.gray('→ v6.0 bootstrap (patterns via MCP)'));
|
|
789
806
|
if (prdCreated) {
|
|
790
807
|
console.log(chalk_1.default.cyan(' PRD.md ') + chalk_1.default.gray('→ Product requirements (AI reads this!)'));
|
|
791
808
|
}
|
|
792
809
|
console.log(chalk_1.default.cyan(' PROJECT-CONTEXT.md ') + chalk_1.default.gray('→ Codebase knowledge (auto-updated)'));
|
|
793
810
|
console.log(chalk_1.default.cyan(' PROJECT-STATE.md ') + chalk_1.default.gray('→ Task tracking (auto-updated)'));
|
|
794
811
|
console.log(chalk_1.default.cyan(' DECISIONS.md ') + chalk_1.default.gray('→ Architecture log (auto-updated)'));
|
|
795
|
-
console.log(chalk_1.default.cyan(' .
|
|
796
|
-
console.log(chalk_1.default.cyan(' .cursorignore ') + chalk_1.default.gray('→ Context optimization'));
|
|
797
|
-
console.log(chalk_1.default.cyan(' .claude/ ') + chalk_1.default.gray('→ Pattern modules\n'));
|
|
812
|
+
console.log(chalk_1.default.cyan(' .cursorignore ') + chalk_1.default.gray('→ Context optimization\n'));
|
|
798
813
|
console.log(chalk_1.default.white(' What happens automatically:\n'));
|
|
799
814
|
console.log(chalk_1.default.gray(' ✓ AI loads context before every response'));
|
|
800
815
|
console.log(chalk_1.default.gray(' ✓ AI checks for existing patterns to copy'));
|
|
@@ -29,16 +29,16 @@ const HOOK_TEMPLATE = {
|
|
|
29
29
|
]
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
// Instructions that get injected into the system prompt
|
|
32
|
+
// Instructions that get injected into the system prompt (v6.0)
|
|
33
33
|
const CODEBAKERS_INSTRUCTIONS = `
|
|
34
34
|
<user-prompt-submit-hook>
|
|
35
|
-
[CodeBakers] Active - Follow these steps for EVERY request:
|
|
35
|
+
[CodeBakers v6.0] Active - Follow these steps for EVERY request:
|
|
36
36
|
|
|
37
|
-
1. CONTEXT: Read CLAUDE.md
|
|
38
|
-
2.
|
|
39
|
-
3. EXECUTE:
|
|
37
|
+
1. CONTEXT: Read CLAUDE.md
|
|
38
|
+
2. DISCOVER: Call discover_patterns MCP tool before writing any code
|
|
39
|
+
3. EXECUTE: Follow the patterns returned by the server
|
|
40
40
|
4. SELF-REVIEW: Verify TypeScript compiles, imports resolve, error handling exists
|
|
41
|
-
5.
|
|
41
|
+
5. VALIDATE: Call validate_complete MCP tool when done
|
|
42
42
|
|
|
43
43
|
Output format: "[CodeBakers] Building [feature] using [patterns]"
|
|
44
44
|
</user-prompt-submit-hook>
|
|
@@ -97,9 +97,9 @@ async function installHook() {
|
|
|
97
97
|
console.log(chalk_1.default.cyan(' [CodeBakers] Code written - remember to self-review\n'));
|
|
98
98
|
console.log(chalk_1.default.white(' What happens automatically:\n'));
|
|
99
99
|
console.log(chalk_1.default.gray(' ✓ Loads project context before every response'));
|
|
100
|
-
console.log(chalk_1.default.gray(' ✓
|
|
100
|
+
console.log(chalk_1.default.gray(' ✓ Calls discover_patterns MCP tool before coding'));
|
|
101
101
|
console.log(chalk_1.default.gray(' ✓ Self-review reminders after code changes'));
|
|
102
|
-
console.log(chalk_1.default.gray(' ✓
|
|
102
|
+
console.log(chalk_1.default.gray(' ✓ Server-side patterns (always up-to-date)\n'));
|
|
103
103
|
console.log(chalk_1.default.yellow.bold(' ⚠️ RESTART REQUIRED:\n'));
|
|
104
104
|
console.log(chalk_1.default.gray(' 1. Type ') + chalk_1.default.cyan('exit') + chalk_1.default.gray(' to close this terminal'));
|
|
105
105
|
console.log(chalk_1.default.gray(' 2. Open a NEW terminal window'));
|