@codebakers/cli 3.5.0 → 3.6.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/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +40 -82
- 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 +425 -147
- package/package.json +1 -1
- package/src/commands/doctor.ts +39 -81
- 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 +428 -161
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/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'));
|
package/dist/commands/install.js
CHANGED
|
@@ -10,77 +10,76 @@ const fs_1 = require("fs");
|
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const config_js_1 = require("../config.js");
|
|
12
12
|
const api_js_1 = require("../lib/api.js");
|
|
13
|
-
|
|
13
|
+
// v6.0 Bootstrap files - patterns come from server via MCP
|
|
14
|
+
const V6_CLAUDE_MD = `# CodeBakers v6.0
|
|
15
|
+
|
|
16
|
+
**MANDATORY: Before writing ANY code, call the \`discover_patterns\` MCP tool.**
|
|
17
|
+
|
|
18
|
+
Tool: discover_patterns
|
|
19
|
+
Args: { task: "description of what you're building" }
|
|
20
|
+
|
|
21
|
+
The server will return:
|
|
22
|
+
- All coding patterns and rules you must follow
|
|
23
|
+
- Test requirements
|
|
24
|
+
- Validation instructions
|
|
25
|
+
|
|
26
|
+
**You cannot write code without calling this tool first. The server tracks compliance.**
|
|
27
|
+
`;
|
|
28
|
+
const V6_CURSORRULES = `# CodeBakers v6.0
|
|
29
|
+
|
|
30
|
+
**MANDATORY: Before writing ANY code, call the \`discover_patterns\` MCP tool.**
|
|
31
|
+
|
|
32
|
+
Tool: discover_patterns
|
|
33
|
+
Args: { task: "description of what you're building" }
|
|
34
|
+
|
|
35
|
+
The server will return:
|
|
36
|
+
- All coding patterns and rules you must follow
|
|
37
|
+
- Test requirements
|
|
38
|
+
- Validation instructions
|
|
39
|
+
|
|
40
|
+
**You cannot write code without calling this tool first. The server tracks compliance.**
|
|
41
|
+
`;
|
|
14
42
|
async function install() {
|
|
15
|
-
console.log(chalk_1.default.blue('\n CodeBakers Install\n'));
|
|
43
|
+
console.log(chalk_1.default.blue('\n CodeBakers Install (v6.0)\n'));
|
|
16
44
|
const apiKey = (0, config_js_1.getApiKey)();
|
|
17
45
|
if (!apiKey) {
|
|
18
46
|
console.log(chalk_1.default.red(' Not logged in. Run `codebakers login` first.\n'));
|
|
19
47
|
process.exit(1);
|
|
20
48
|
}
|
|
21
|
-
const spinner = (0, ora_1.default)('
|
|
49
|
+
const spinner = (0, ora_1.default)('Installing CodeBakers v6.0...').start();
|
|
22
50
|
try {
|
|
23
|
-
const apiUrl = (0, config_js_1.getApiUrl)();
|
|
24
|
-
const response = await fetch(`${apiUrl}/api/content`, {
|
|
25
|
-
method: 'GET',
|
|
26
|
-
headers: {
|
|
27
|
-
Authorization: `Bearer ${apiKey}`,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
if (!response.ok) {
|
|
31
|
-
const error = await response.json().catch(() => ({}));
|
|
32
|
-
throw new Error(error.error || 'Failed to fetch content');
|
|
33
|
-
}
|
|
34
|
-
const content = await response.json();
|
|
35
|
-
spinner.text = 'Installing patterns...';
|
|
36
51
|
const cwd = process.cwd();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(0, fs_1.
|
|
44
|
-
}
|
|
45
|
-
// Write modules
|
|
46
|
-
const modulesDir = (0, path_1.join)(cwd, '.claude');
|
|
47
|
-
if (content.modules && Object.keys(content.modules).length > 0) {
|
|
48
|
-
if (!(0, fs_1.existsSync)(modulesDir)) {
|
|
49
|
-
(0, fs_1.mkdirSync)(modulesDir, { recursive: true });
|
|
50
|
-
}
|
|
51
|
-
for (const [name, data] of Object.entries(content.modules)) {
|
|
52
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(modulesDir, name), data);
|
|
53
|
-
}
|
|
54
|
-
// Write version file for tracking
|
|
55
|
-
const versionInfo = {
|
|
56
|
-
version: content.version,
|
|
57
|
-
moduleCount: Object.keys(content.modules).length,
|
|
58
|
-
installedAt: new Date().toISOString(),
|
|
59
|
-
cliVersion: (0, api_js_1.getCliVersion)(),
|
|
60
|
-
};
|
|
61
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(modulesDir, '.version.json'), JSON.stringify(versionInfo, null, 2));
|
|
52
|
+
const claudeMdPath = (0, path_1.join)(cwd, 'CLAUDE.md');
|
|
53
|
+
const cursorRulesPath = (0, path_1.join)(cwd, '.cursorrules');
|
|
54
|
+
const claudeDir = (0, path_1.join)(cwd, '.claude');
|
|
55
|
+
// Check for existing v5 installation and migrate
|
|
56
|
+
if ((0, fs_1.existsSync)(claudeDir)) {
|
|
57
|
+
spinner.text = 'Migrating from v5 to v6...';
|
|
58
|
+
(0, fs_1.rmSync)(claudeDir, { recursive: true, force: true });
|
|
62
59
|
}
|
|
63
|
-
//
|
|
60
|
+
// Write v6 bootstrap files
|
|
61
|
+
(0, fs_1.writeFileSync)(claudeMdPath, V6_CLAUDE_MD);
|
|
62
|
+
(0, fs_1.writeFileSync)(cursorRulesPath, V6_CURSORRULES);
|
|
63
|
+
// Add .cursorrules to .gitignore if not present
|
|
64
64
|
const gitignorePath = (0, path_1.join)(cwd, '.gitignore');
|
|
65
65
|
if ((0, fs_1.existsSync)(gitignorePath)) {
|
|
66
|
-
const
|
|
67
|
-
const gitignore = readFileSync(gitignorePath, 'utf-8');
|
|
66
|
+
const gitignore = (0, fs_1.readFileSync)(gitignorePath, 'utf-8');
|
|
68
67
|
if (!gitignore.includes('.cursorrules')) {
|
|
69
|
-
const additions = '\n# CodeBakers
|
|
68
|
+
const additions = '\n# CodeBakers\n.cursorrules\n';
|
|
70
69
|
(0, fs_1.writeFileSync)(gitignorePath, gitignore + additions);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
|
-
|
|
74
|
-
spinner.succeed('Patterns installed successfully!');
|
|
75
|
-
console.log(chalk_1.default.green(`\n Version: ${content.version}`));
|
|
76
|
-
console.log(chalk_1.default.green(` Modules: ${moduleCount}`));
|
|
72
|
+
spinner.succeed('CodeBakers v6.0 installed!');
|
|
77
73
|
console.log(chalk_1.default.gray('\n Files created:'));
|
|
78
|
-
console.log(chalk_1.default.gray(' - .
|
|
79
|
-
console.log(chalk_1.default.gray(' -
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.log(chalk_1.default.
|
|
74
|
+
console.log(chalk_1.default.gray(' - CLAUDE.md (Claude Code gateway)'));
|
|
75
|
+
console.log(chalk_1.default.gray(' - .cursorrules (Cursor IDE gateway)'));
|
|
76
|
+
console.log(chalk_1.default.cyan('\n What\'s new in v6.0:'));
|
|
77
|
+
console.log(chalk_1.default.gray(' - Patterns are now server-side'));
|
|
78
|
+
console.log(chalk_1.default.gray(' - AI calls discover_patterns before coding'));
|
|
79
|
+
console.log(chalk_1.default.gray(' - Real-time pattern updates'));
|
|
80
|
+
console.log(chalk_1.default.gray(' - Usage tracking & compliance'));
|
|
81
|
+
console.log(chalk_1.default.gray(`\n CLI version: ${(0, api_js_1.getCliVersion)()}`));
|
|
82
|
+
console.log(chalk_1.default.blue('\n Start building! AI will fetch patterns via MCP.\n'));
|
|
84
83
|
}
|
|
85
84
|
catch (error) {
|
|
86
85
|
spinner.fail('Installation failed');
|
|
@@ -94,7 +94,7 @@ Ask yourself silently:
|
|
|
94
94
|
|
|
95
95
|
### PHASE 3: EXECUTE
|
|
96
96
|
- State: \`📋 CodeBakers | [Type] | Modules: [list]\`
|
|
97
|
-
-
|
|
97
|
+
- Call discover_patterns MCP tool first
|
|
98
98
|
- Follow patterns EXACTLY
|
|
99
99
|
|
|
100
100
|
### PHASE 4: SELF-REVIEW (before saying "done")
|
|
@@ -521,28 +521,45 @@ async function scaffold() {
|
|
|
521
521
|
},
|
|
522
522
|
});
|
|
523
523
|
if (response.ok) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
524
|
+
// v6.0: Write minimal bootstrap files (patterns come from server)
|
|
525
|
+
const V6_CLAUDE_MD = `# CodeBakers v6.0
|
|
526
|
+
|
|
527
|
+
**MANDATORY: Before writing ANY code, call the \`discover_patterns\` MCP tool.**
|
|
528
|
+
|
|
529
|
+
\`\`\`
|
|
530
|
+
Tool: discover_patterns
|
|
531
|
+
Args: { task: "description of what you're building" }
|
|
532
|
+
\`\`\`
|
|
533
|
+
|
|
534
|
+
The server will return:
|
|
535
|
+
- All coding patterns and rules you must follow
|
|
536
|
+
- Test requirements
|
|
537
|
+
- Validation instructions
|
|
538
|
+
|
|
539
|
+
**You cannot write code without calling this tool first. The server tracks compliance.**
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
*CodeBakers v6.0 - Server-Enforced*
|
|
543
|
+
`;
|
|
544
|
+
const V6_CURSORRULES = `# CodeBakers v6.0
|
|
545
|
+
|
|
546
|
+
MANDATORY: Before writing ANY code, call the discover_patterns MCP tool.
|
|
547
|
+
|
|
548
|
+
Tool: discover_patterns
|
|
549
|
+
Args: { task: "description of what you're building" }
|
|
550
|
+
|
|
551
|
+
The server returns all patterns, rules, and test requirements.
|
|
552
|
+
You cannot write code without calling this tool first.
|
|
553
|
+
`;
|
|
554
|
+
// Write v6.0 bootstrap files
|
|
555
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'CLAUDE.md'), V6_CLAUDE_MD);
|
|
556
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.cursorrules'), V6_CURSORRULES);
|
|
539
557
|
// Write project management files
|
|
540
558
|
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'PRD.md'), createPrdTemplate(projectName));
|
|
541
559
|
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'PROJECT-STATE.md'), createProjectState(projectName));
|
|
542
560
|
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'PROJECT-CONTEXT.md'), createProjectContext(projectName));
|
|
543
561
|
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'DECISIONS.md'), createDecisionsLog(projectName));
|
|
544
562
|
// Write Cursor IDE files
|
|
545
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.cursorrules'), CURSORRULES_TEMPLATE);
|
|
546
563
|
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.cursorignore'), CURSORIGNORE_TEMPLATE);
|
|
547
564
|
// Create .vscode settings
|
|
548
565
|
const vscodeDir = (0, path_1.join)(cwd, '.vscode');
|
|
@@ -553,15 +570,15 @@ async function scaffold() {
|
|
|
553
570
|
"cursor.chat.defaultContext": ["CLAUDE.md", "PRD.md", "PROJECT-CONTEXT.md"],
|
|
554
571
|
"cursor.chat.alwaysIncludeRules": true
|
|
555
572
|
}, null, 2));
|
|
556
|
-
// Update .gitignore
|
|
573
|
+
// Update .gitignore (no .claude/ needed in v6)
|
|
557
574
|
const gitignorePath = (0, path_1.join)(cwd, '.gitignore');
|
|
558
575
|
if ((0, fs_1.existsSync)(gitignorePath)) {
|
|
559
576
|
const gitignore = (0, fs_1.readFileSync)(gitignorePath, 'utf-8');
|
|
560
577
|
if (!gitignore.includes('.cursorrules')) {
|
|
561
|
-
(0, fs_1.writeFileSync)(gitignorePath, gitignore + '\n# CodeBakers\n.cursorrules\n
|
|
578
|
+
(0, fs_1.writeFileSync)(gitignorePath, gitignore + '\n# CodeBakers\n.cursorrules\n');
|
|
562
579
|
}
|
|
563
580
|
}
|
|
564
|
-
patternSpinner.succeed(
|
|
581
|
+
patternSpinner.succeed('CodeBakers v6.0 installed!');
|
|
565
582
|
patternsInstalled = true;
|
|
566
583
|
}
|
|
567
584
|
else {
|
|
@@ -722,9 +739,9 @@ async function scaffold() {
|
|
|
722
739
|
}
|
|
723
740
|
if (patternsInstalled) {
|
|
724
741
|
console.log('');
|
|
725
|
-
console.log(chalk_1.default.gray(' CLAUDE.md ') + chalk_1.default.cyan('← AI
|
|
742
|
+
console.log(chalk_1.default.gray(' CLAUDE.md ') + chalk_1.default.cyan('← AI gateway (calls MCP for patterns)'));
|
|
743
|
+
console.log(chalk_1.default.gray(' .cursorrules ') + chalk_1.default.cyan('← Cursor IDE gateway'));
|
|
726
744
|
console.log(chalk_1.default.gray(' PRD.md ') + chalk_1.default.cyan('← Your product requirements'));
|
|
727
|
-
console.log(chalk_1.default.gray(' .claude/ ') + chalk_1.default.cyan('← 34 production patterns'));
|
|
728
745
|
}
|
|
729
746
|
console.log('');
|
|
730
747
|
console.log(chalk_1.default.white(' Next steps:\n'));
|