codebakers 2.0.2 → 2.0.3

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/index.js CHANGED
@@ -135,7 +135,75 @@ var Config = class {
135
135
  const cwd = process.cwd();
136
136
  const codebakersDir = path.join(cwd, ".codebakers");
137
137
  const claudeFile = path.join(cwd, "CLAUDE.md");
138
- return fs.existsSync(codebakersDir) || fs.existsSync(claudeFile);
138
+ if (fs.existsSync(codebakersDir) || fs.existsSync(claudeFile)) {
139
+ return true;
140
+ }
141
+ const projectIndicators = [
142
+ "package.json",
143
+ "next.config.js",
144
+ "next.config.mjs",
145
+ "next.config.ts",
146
+ "vite.config.ts",
147
+ "vite.config.js",
148
+ "remix.config.js",
149
+ "astro.config.mjs"
150
+ ];
151
+ const hasProjectFile = projectIndicators.some(
152
+ (file) => fs.existsSync(path.join(cwd, file))
153
+ );
154
+ if (hasProjectFile) {
155
+ this.autoInitExisting(cwd);
156
+ return true;
157
+ }
158
+ return false;
159
+ }
160
+ // Auto-initialize CodeBakers in an existing project
161
+ autoInitExisting(cwd) {
162
+ try {
163
+ let framework = "unknown";
164
+ let ui = "unknown";
165
+ if (fs.existsSync(path.join(cwd, "next.config.js")) || fs.existsSync(path.join(cwd, "next.config.mjs")) || fs.existsSync(path.join(cwd, "next.config.ts"))) {
166
+ framework = "nextjs";
167
+ } else if (fs.existsSync(path.join(cwd, "vite.config.ts")) || fs.existsSync(path.join(cwd, "vite.config.js"))) {
168
+ framework = "vite";
169
+ } else if (fs.existsSync(path.join(cwd, "remix.config.js"))) {
170
+ framework = "remix";
171
+ } else if (fs.existsSync(path.join(cwd, "astro.config.mjs"))) {
172
+ framework = "astro";
173
+ }
174
+ const pkgPath = path.join(cwd, "package.json");
175
+ if (fs.existsSync(pkgPath)) {
176
+ const pkg = fs.readJsonSync(pkgPath);
177
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
178
+ if (deps["@shadcn/ui"] || deps["class-variance-authority"]) {
179
+ ui = "shadcn";
180
+ } else if (deps["@chakra-ui/react"]) {
181
+ ui = "chakra";
182
+ } else if (deps["@mantine/core"]) {
183
+ ui = "mantine";
184
+ } else if (deps["@mui/material"]) {
185
+ ui = "mui";
186
+ }
187
+ }
188
+ const configDir = path.join(cwd, ".codebakers");
189
+ fs.ensureDirSync(configDir);
190
+ const config = {
191
+ name: path.basename(cwd),
192
+ framework,
193
+ ui,
194
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
195
+ autoDetected: true
196
+ };
197
+ fs.writeJsonSync(path.join(configDir, "config.json"), config, { spaces: 2 });
198
+ const gitignorePath = path.join(cwd, ".gitignore");
199
+ if (fs.existsSync(gitignorePath)) {
200
+ const gitignore = fs.readFileSync(gitignorePath, "utf-8");
201
+ if (!gitignore.includes(".codebakers")) {
202
+ fs.appendFileSync(gitignorePath, "\n# CodeBakers\n.codebakers/\n");
203
+ }
204
+ }
205
+ } catch {
206
+ }
139
207
  }
140
208
  // Get current project config
141
209
  getProjectConfig() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebakers",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "AI dev team that follows the rules. Build apps from anywhere with pattern enforcement.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -141,7 +141,99 @@ export class Config {
141
141
  const cwd = process.cwd();
142
142
  const codebakersDir = path.join(cwd, '.codebakers');
143
143
  const claudeFile = path.join(cwd, 'CLAUDE.md');
144
- return fs.existsSync(codebakersDir) || fs.existsSync(claudeFile);
144
+
145
+ // Already a CodeBakers project
146
+ if (fs.existsSync(codebakersDir) || fs.existsSync(claudeFile)) {
147
+ return true;
148
+ }
149
+
150
+ // Auto-detect existing projects by common files
151
+ const projectIndicators = [
152
+ 'package.json',
153
+ 'next.config.js',
154
+ 'next.config.mjs',
155
+ 'next.config.ts',
156
+ 'vite.config.ts',
157
+ 'vite.config.js',
158
+ 'remix.config.js',
159
+ 'astro.config.mjs',
160
+ ];
161
+
162
+ const hasProjectFile = projectIndicators.some(file =>
163
+ fs.existsSync(path.join(cwd, file))
164
+ );
165
+
166
+ // If it's a project but no .codebakers, auto-initialize
167
+ if (hasProjectFile) {
168
+ this.autoInitExisting(cwd);
169
+ return true;
170
+ }
171
+
172
+ return false;
173
+ }
174
+
175
+ // Auto-initialize CodeBakers in an existing project
176
+ private autoInitExisting(cwd: string): void {
177
+ try {
178
+ // Detect framework
179
+ let framework = 'unknown';
180
+ let ui = 'unknown';
181
+
182
+ if (fs.existsSync(path.join(cwd, 'next.config.js')) ||
183
+ fs.existsSync(path.join(cwd, 'next.config.mjs')) ||
184
+ fs.existsSync(path.join(cwd, 'next.config.ts'))) {
185
+ framework = 'nextjs';
186
+ } else if (fs.existsSync(path.join(cwd, 'vite.config.ts')) ||
187
+ fs.existsSync(path.join(cwd, 'vite.config.js'))) {
188
+ framework = 'vite';
189
+ } else if (fs.existsSync(path.join(cwd, 'remix.config.js'))) {
190
+ framework = 'remix';
191
+ } else if (fs.existsSync(path.join(cwd, 'astro.config.mjs'))) {
192
+ framework = 'astro';
193
+ }
194
+
195
+ // Check for UI libraries in package.json
196
+ const pkgPath = path.join(cwd, 'package.json');
197
+ if (fs.existsSync(pkgPath)) {
198
+ const pkg = fs.readJsonSync(pkgPath);
199
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
200
+
201
+ if (deps['@shadcn/ui'] || deps['class-variance-authority']) {
202
+ ui = 'shadcn';
203
+ } else if (deps['@chakra-ui/react']) {
204
+ ui = 'chakra';
205
+ } else if (deps['@mantine/core']) {
206
+ ui = 'mantine';
207
+ } else if (deps['@mui/material']) {
208
+ ui = 'mui';
209
+ }
210
+ }
211
+
212
+ // Create .codebakers config
213
+ const configDir = path.join(cwd, '.codebakers');
214
+ fs.ensureDirSync(configDir);
215
+
216
+ const config = {
217
+ name: path.basename(cwd),
218
+ framework,
219
+ ui,
220
+ createdAt: new Date().toISOString(),
221
+ autoDetected: true,
222
+ };
223
+
224
+ fs.writeJsonSync(path.join(configDir, 'config.json'), config, { spaces: 2 });
225
+
226
+ // Add to .gitignore if exists
227
+ const gitignorePath = path.join(cwd, '.gitignore');
228
+ if (fs.existsSync(gitignorePath)) {
229
+ const gitignore = fs.readFileSync(gitignorePath, 'utf-8');
230
+ if (!gitignore.includes('.codebakers')) {
231
+ fs.appendFileSync(gitignorePath, '\n# CodeBakers\n.codebakers/\n');
232
+ }
233
+ }
234
+ } catch {
235
+ // Silent fail - don't block if auto-init fails
236
+ }
145
237
  }
146
238
 
147
239
  // Get current project config