codebakers 2.0.0 → 2.0.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/index.js +386 -125
- package/package.json +1 -1
- package/src/commands/design.ts +298 -0
- package/src/index.ts +10 -0
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
5
|
+
import * as p13 from "@clack/prompts";
|
|
6
|
+
import chalk14 from "chalk";
|
|
7
7
|
import boxen from "boxen";
|
|
8
8
|
import gradient from "gradient-string";
|
|
9
9
|
|
|
@@ -371,7 +371,7 @@ ${chalk2.dim("and are never sent to our servers.")}`,
|
|
|
371
371
|
p.outro(chalk2.green("\u2713 Setup complete! Run `codebakers init` to create your first project."));
|
|
372
372
|
}
|
|
373
373
|
async function connectService(config, serviceKey, serviceName, required) {
|
|
374
|
-
const
|
|
374
|
+
const spinner11 = p.spinner();
|
|
375
375
|
switch (serviceKey) {
|
|
376
376
|
case "github": {
|
|
377
377
|
p.log.info(`${chalk2.bold("GitHub")} - Opens browser for OAuth authorization`);
|
|
@@ -845,10 +845,10 @@ var SupabaseService = class {
|
|
|
845
845
|
throw new Error("Failed to list projects");
|
|
846
846
|
}
|
|
847
847
|
const projects = await response.json();
|
|
848
|
-
return projects.map((
|
|
849
|
-
id:
|
|
850
|
-
name:
|
|
851
|
-
region:
|
|
848
|
+
return projects.map((p14) => ({
|
|
849
|
+
id: p14.id,
|
|
850
|
+
name: p14.name,
|
|
851
|
+
region: p14.region
|
|
852
852
|
}));
|
|
853
853
|
}
|
|
854
854
|
};
|
|
@@ -1268,20 +1268,20 @@ Domain: ${domain || "Vercel default"}`,
|
|
|
1268
1268
|
p2.cancel("Project creation cancelled.");
|
|
1269
1269
|
return;
|
|
1270
1270
|
}
|
|
1271
|
-
const
|
|
1271
|
+
const spinner11 = p2.spinner();
|
|
1272
1272
|
const projectPath = path2.join(process.cwd(), projectName);
|
|
1273
1273
|
try {
|
|
1274
|
-
|
|
1274
|
+
spinner11.start("Creating local project...");
|
|
1275
1275
|
await createLocalProject(projectPath, projectConfig);
|
|
1276
|
-
|
|
1277
|
-
|
|
1276
|
+
spinner11.stop("Local project created");
|
|
1277
|
+
spinner11.start("Installing dependencies...");
|
|
1278
1278
|
await execa2("pnpm", ["install"], { cwd: projectPath });
|
|
1279
|
-
|
|
1279
|
+
spinner11.stop("Dependencies installed");
|
|
1280
1280
|
if (services.includes("github")) {
|
|
1281
|
-
|
|
1281
|
+
spinner11.start("Creating GitHub repository...");
|
|
1282
1282
|
const github = new GitHubService(config);
|
|
1283
1283
|
const repo = await github.createRepo(projectName, { private: true });
|
|
1284
|
-
|
|
1284
|
+
spinner11.stop(`GitHub repo created: ${repo.html_url}`);
|
|
1285
1285
|
await execa2("git", ["init"], { cwd: projectPath });
|
|
1286
1286
|
await execa2("git", ["add", "."], { cwd: projectPath });
|
|
1287
1287
|
await execa2("git", ["commit", "-m", "Initial commit by CodeBakers"], { cwd: projectPath });
|
|
@@ -1289,10 +1289,10 @@ Domain: ${domain || "Vercel default"}`,
|
|
|
1289
1289
|
await execa2("git", ["push", "-u", "origin", "main"], { cwd: projectPath });
|
|
1290
1290
|
}
|
|
1291
1291
|
if (services.includes("supabase")) {
|
|
1292
|
-
|
|
1292
|
+
spinner11.start("Creating Supabase project...");
|
|
1293
1293
|
const supabase = new SupabaseService(config);
|
|
1294
1294
|
const project = await supabase.createProject(projectName);
|
|
1295
|
-
|
|
1295
|
+
spinner11.stop(`Supabase project created: ${project.name}`);
|
|
1296
1296
|
await fs2.writeJson(
|
|
1297
1297
|
path2.join(projectPath, ".codebakers", "supabase.json"),
|
|
1298
1298
|
{ projectId: project.id, projectUrl: project.api_url },
|
|
@@ -1300,26 +1300,26 @@ Domain: ${domain || "Vercel default"}`,
|
|
|
1300
1300
|
);
|
|
1301
1301
|
}
|
|
1302
1302
|
if (services.includes("vercel")) {
|
|
1303
|
-
|
|
1303
|
+
spinner11.start("Creating Vercel project...");
|
|
1304
1304
|
const vercel = new VercelService(config);
|
|
1305
1305
|
const project = await vercel.createProject(projectName);
|
|
1306
|
-
|
|
1306
|
+
spinner11.stop(`Vercel project created`);
|
|
1307
1307
|
if (domain) {
|
|
1308
|
-
|
|
1308
|
+
spinner11.start(`Configuring domain: ${domain}...`);
|
|
1309
1309
|
await vercel.addDomain(projectName, domain);
|
|
1310
|
-
|
|
1310
|
+
spinner11.stop("Domain configured");
|
|
1311
1311
|
}
|
|
1312
|
-
|
|
1312
|
+
spinner11.start("Deploying to Vercel...");
|
|
1313
1313
|
const deployment = await vercel.deploy(projectPath);
|
|
1314
|
-
|
|
1314
|
+
spinner11.stop(`Deployed: ${deployment.url}`);
|
|
1315
1315
|
}
|
|
1316
|
-
|
|
1316
|
+
spinner11.start("Generating CLAUDE.md...");
|
|
1317
1317
|
const claudeMd = generateClaudeMd(projectConfig);
|
|
1318
1318
|
await fs2.writeFile(path2.join(projectPath, "CLAUDE.md"), claudeMd);
|
|
1319
|
-
|
|
1320
|
-
|
|
1319
|
+
spinner11.stop("CLAUDE.md generated");
|
|
1320
|
+
spinner11.start("Setting up CodeBakers enforcement...");
|
|
1321
1321
|
await setupGitHooks(projectPath);
|
|
1322
|
-
|
|
1322
|
+
spinner11.stop("CodeBakers enforcement configured");
|
|
1323
1323
|
config.addProject({
|
|
1324
1324
|
name: projectName,
|
|
1325
1325
|
path: projectPath,
|
|
@@ -1339,7 +1339,7 @@ ${chalk3.dim("Shortcuts:")}
|
|
|
1339
1339
|
${chalk3.cyan("codebakers deploy")} \u2014 Deploy to production
|
|
1340
1340
|
`));
|
|
1341
1341
|
} catch (error) {
|
|
1342
|
-
|
|
1342
|
+
spinner11.stop("Error occurred");
|
|
1343
1343
|
p2.log.error(`Failed to create project: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1344
1344
|
const cleanup = await p2.confirm({
|
|
1345
1345
|
message: "Clean up partially created project?"
|
|
@@ -2065,17 +2065,17 @@ async function checkCommand(options = {}) {
|
|
|
2065
2065
|
return;
|
|
2066
2066
|
}
|
|
2067
2067
|
p3.intro(chalk4.bgCyan.black(" CodeBakers Pattern Check "));
|
|
2068
|
-
const
|
|
2069
|
-
|
|
2068
|
+
const spinner11 = p3.spinner();
|
|
2069
|
+
spinner11.start("Analyzing code...");
|
|
2070
2070
|
const result = await runPatternCheck(options.fix || false);
|
|
2071
|
-
|
|
2071
|
+
spinner11.stop("Analysis complete");
|
|
2072
2072
|
displayResults(result);
|
|
2073
2073
|
if (result.violations.length > 0 && options.fix) {
|
|
2074
2074
|
const fixable = result.violations.filter((v) => v.autoFixable);
|
|
2075
2075
|
if (fixable.length > 0) {
|
|
2076
|
-
|
|
2076
|
+
spinner11.start(`Auto-fixing ${fixable.length} violations...`);
|
|
2077
2077
|
await autoFix(fixable);
|
|
2078
|
-
|
|
2078
|
+
spinner11.stop("Auto-fix complete");
|
|
2079
2079
|
}
|
|
2080
2080
|
}
|
|
2081
2081
|
const errors = result.violations.filter((v) => v.severity === "error");
|
|
@@ -2267,14 +2267,14 @@ async function codeCommand(prompt, options = {}) {
|
|
|
2267
2267
|
}
|
|
2268
2268
|
}
|
|
2269
2269
|
async function processUserInput(userInput, messages, anthropic, systemPrompt, projectContext, config) {
|
|
2270
|
-
const
|
|
2270
|
+
const spinner11 = p4.spinner();
|
|
2271
2271
|
messages.push({ role: "user", content: userInput });
|
|
2272
2272
|
const wizardResult = await checkForWizard(userInput);
|
|
2273
2273
|
if (wizardResult) {
|
|
2274
2274
|
messages[messages.length - 1].content = wizardResult;
|
|
2275
2275
|
}
|
|
2276
2276
|
try {
|
|
2277
|
-
|
|
2277
|
+
spinner11.start("Thinking...");
|
|
2278
2278
|
const response = await anthropic.messages.create({
|
|
2279
2279
|
model: "claude-sonnet-4-20250514",
|
|
2280
2280
|
max_tokens: 8192,
|
|
@@ -2284,7 +2284,7 @@ async function processUserInput(userInput, messages, anthropic, systemPrompt, pr
|
|
|
2284
2284
|
content: m.content
|
|
2285
2285
|
}))
|
|
2286
2286
|
});
|
|
2287
|
-
|
|
2287
|
+
spinner11.stop("");
|
|
2288
2288
|
const assistantMessage = response.content[0].type === "text" ? response.content[0].text : "";
|
|
2289
2289
|
messages.push({ role: "assistant", content: assistantMessage });
|
|
2290
2290
|
const actions = parseActions(assistantMessage);
|
|
@@ -2299,11 +2299,11 @@ async function processUserInput(userInput, messages, anthropic, systemPrompt, pr
|
|
|
2299
2299
|
initialValue: true
|
|
2300
2300
|
});
|
|
2301
2301
|
if (proceed && !p4.isCancel(proceed)) {
|
|
2302
|
-
|
|
2302
|
+
spinner11.start("Building...");
|
|
2303
2303
|
for (const action of actions) {
|
|
2304
|
-
await executeAction(action,
|
|
2304
|
+
await executeAction(action, spinner11);
|
|
2305
2305
|
}
|
|
2306
|
-
|
|
2306
|
+
spinner11.stop("Build complete");
|
|
2307
2307
|
console.log(chalk5.dim("\n\u{1F50D} Running CodeBakers check..."));
|
|
2308
2308
|
const checkResult = await runPatternCheck(false);
|
|
2309
2309
|
if (checkResult.violations.length > 0) {
|
|
@@ -2314,9 +2314,9 @@ async function processUserInput(userInput, messages, anthropic, systemPrompt, pr
|
|
|
2314
2314
|
initialValue: true
|
|
2315
2315
|
});
|
|
2316
2316
|
if (autoFix2 && !p4.isCancel(autoFix2)) {
|
|
2317
|
-
|
|
2317
|
+
spinner11.start("Auto-fixing...");
|
|
2318
2318
|
await autoFixViolations(checkResult.violations, anthropic, systemPrompt);
|
|
2319
|
-
|
|
2319
|
+
spinner11.stop("Violations fixed");
|
|
2320
2320
|
}
|
|
2321
2321
|
} else {
|
|
2322
2322
|
console.log(chalk5.green("\u2713 All patterns satisfied"));
|
|
@@ -2327,7 +2327,7 @@ async function processUserInput(userInput, messages, anthropic, systemPrompt, pr
|
|
|
2327
2327
|
console.log("\n" + assistantMessage + "\n");
|
|
2328
2328
|
}
|
|
2329
2329
|
} catch (error) {
|
|
2330
|
-
|
|
2330
|
+
spinner11.stop("Error");
|
|
2331
2331
|
console.log(chalk5.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
2332
2332
|
}
|
|
2333
2333
|
}
|
|
@@ -2439,14 +2439,14 @@ function parseActions(response) {
|
|
|
2439
2439
|
}
|
|
2440
2440
|
return actions;
|
|
2441
2441
|
}
|
|
2442
|
-
async function executeAction(action,
|
|
2442
|
+
async function executeAction(action, spinner11) {
|
|
2443
2443
|
const cwd = process.cwd();
|
|
2444
2444
|
switch (action.type) {
|
|
2445
2445
|
case "CREATE_FILE": {
|
|
2446
2446
|
const filePath = path5.join(cwd, action.path);
|
|
2447
2447
|
await fs5.ensureDir(path5.dirname(filePath));
|
|
2448
2448
|
await fs5.writeFile(filePath, action.content);
|
|
2449
|
-
|
|
2449
|
+
spinner11.message(`Created ${action.path}`);
|
|
2450
2450
|
break;
|
|
2451
2451
|
}
|
|
2452
2452
|
case "EDIT_FILE": {
|
|
@@ -2456,13 +2456,13 @@ async function executeAction(action, spinner10) {
|
|
|
2456
2456
|
if (action.find && content.includes(action.find)) {
|
|
2457
2457
|
content = content.replace(action.find, action.replace || "");
|
|
2458
2458
|
await fs5.writeFile(filePath, content);
|
|
2459
|
-
|
|
2459
|
+
spinner11.message(`Edited ${action.path}`);
|
|
2460
2460
|
}
|
|
2461
2461
|
}
|
|
2462
2462
|
break;
|
|
2463
2463
|
}
|
|
2464
2464
|
case "RUN_COMMAND": {
|
|
2465
|
-
|
|
2465
|
+
spinner11.message(`Running: ${action.command}`);
|
|
2466
2466
|
const [cmd, ...args2] = action.command.split(" ");
|
|
2467
2467
|
await execa3(cmd, args2, { cwd, stdio: "pipe" });
|
|
2468
2468
|
break;
|
|
@@ -2471,7 +2471,7 @@ async function executeAction(action, spinner10) {
|
|
|
2471
2471
|
const filePath = path5.join(cwd, action.path);
|
|
2472
2472
|
if (await fs5.pathExists(filePath)) {
|
|
2473
2473
|
await fs5.remove(filePath);
|
|
2474
|
-
|
|
2474
|
+
spinner11.message(`Deleted ${action.path}`);
|
|
2475
2475
|
}
|
|
2476
2476
|
break;
|
|
2477
2477
|
}
|
|
@@ -2719,12 +2719,12 @@ async function deployCommand(options = {}) {
|
|
|
2719
2719
|
return;
|
|
2720
2720
|
}
|
|
2721
2721
|
p5.intro(chalk6.bgCyan.black(" Deploy to Production "));
|
|
2722
|
-
const
|
|
2722
|
+
const spinner11 = p5.spinner();
|
|
2723
2723
|
if (options.check !== false) {
|
|
2724
|
-
|
|
2724
|
+
spinner11.start("Running CodeBakers check...");
|
|
2725
2725
|
const checkResult = await runPatternCheck(false);
|
|
2726
2726
|
if (!checkResult.passed) {
|
|
2727
|
-
|
|
2727
|
+
spinner11.stop("");
|
|
2728
2728
|
const errors = checkResult.violations.filter((v) => v.severity === "error");
|
|
2729
2729
|
if (errors.length > 0) {
|
|
2730
2730
|
p5.log.error(`${errors.length} pattern violations found. Fix before deploying.`);
|
|
@@ -2745,9 +2745,9 @@ async function deployCommand(options = {}) {
|
|
|
2745
2745
|
p5.outro(chalk6.red("Deploy cancelled."));
|
|
2746
2746
|
return;
|
|
2747
2747
|
}
|
|
2748
|
-
|
|
2748
|
+
spinner11.start("Auto-fixing with AI...");
|
|
2749
2749
|
await autoFixWithAI(config, errors);
|
|
2750
|
-
|
|
2750
|
+
spinner11.stop("Auto-fix complete");
|
|
2751
2751
|
const recheck = await runPatternCheck(false);
|
|
2752
2752
|
if (!recheck.passed) {
|
|
2753
2753
|
p5.log.error("Some violations remain. Manual fix required.");
|
|
@@ -2756,23 +2756,23 @@ async function deployCommand(options = {}) {
|
|
|
2756
2756
|
}
|
|
2757
2757
|
}
|
|
2758
2758
|
}
|
|
2759
|
-
|
|
2759
|
+
spinner11.stop("Pattern check passed");
|
|
2760
2760
|
}
|
|
2761
|
-
|
|
2761
|
+
spinner11.start("Running TypeScript check...");
|
|
2762
2762
|
try {
|
|
2763
2763
|
await execa4("npx", ["tsc", "--noEmit"], { cwd: process.cwd() });
|
|
2764
|
-
|
|
2764
|
+
spinner11.stop("TypeScript check passed");
|
|
2765
2765
|
} catch (error) {
|
|
2766
|
-
|
|
2766
|
+
spinner11.stop("");
|
|
2767
2767
|
p5.log.error("TypeScript errors found.");
|
|
2768
2768
|
const fix = await p5.confirm({
|
|
2769
2769
|
message: "Attempt to fix TypeScript errors?",
|
|
2770
2770
|
initialValue: true
|
|
2771
2771
|
});
|
|
2772
2772
|
if (fix && !p5.isCancel(fix)) {
|
|
2773
|
-
|
|
2773
|
+
spinner11.start("Fixing TypeScript errors...");
|
|
2774
2774
|
const fixed = await fixTypeScriptErrors(config);
|
|
2775
|
-
|
|
2775
|
+
spinner11.stop(fixed ? "TypeScript errors fixed" : "Could not auto-fix all errors");
|
|
2776
2776
|
if (!fixed) {
|
|
2777
2777
|
p5.outro(chalk6.red("Deploy cancelled."));
|
|
2778
2778
|
return;
|
|
@@ -2782,12 +2782,12 @@ async function deployCommand(options = {}) {
|
|
|
2782
2782
|
return;
|
|
2783
2783
|
}
|
|
2784
2784
|
}
|
|
2785
|
-
|
|
2785
|
+
spinner11.start("Building project...");
|
|
2786
2786
|
try {
|
|
2787
2787
|
await execa4("pnpm", ["build"], { cwd: process.cwd() });
|
|
2788
|
-
|
|
2788
|
+
spinner11.stop("Build successful");
|
|
2789
2789
|
} catch (error) {
|
|
2790
|
-
|
|
2790
|
+
spinner11.stop("");
|
|
2791
2791
|
p5.log.error("Build failed.");
|
|
2792
2792
|
const errorOutput = error instanceof Error ? error.message : "Unknown error";
|
|
2793
2793
|
console.log(chalk6.dim(errorOutput));
|
|
@@ -2796,16 +2796,16 @@ async function deployCommand(options = {}) {
|
|
|
2796
2796
|
initialValue: true
|
|
2797
2797
|
});
|
|
2798
2798
|
if (fix && !p5.isCancel(fix)) {
|
|
2799
|
-
|
|
2799
|
+
spinner11.start("Fixing build errors...");
|
|
2800
2800
|
const fixed = await fixBuildErrors(config, errorOutput);
|
|
2801
|
-
|
|
2801
|
+
spinner11.stop(fixed ? "Build errors fixed" : "Could not auto-fix");
|
|
2802
2802
|
if (fixed) {
|
|
2803
|
-
|
|
2803
|
+
spinner11.start("Retrying build...");
|
|
2804
2804
|
try {
|
|
2805
2805
|
await execa4("pnpm", ["build"], { cwd: process.cwd() });
|
|
2806
|
-
|
|
2806
|
+
spinner11.stop("Build successful");
|
|
2807
2807
|
} catch {
|
|
2808
|
-
|
|
2808
|
+
spinner11.stop("Build still failing");
|
|
2809
2809
|
p5.outro(chalk6.red("Deploy cancelled."));
|
|
2810
2810
|
return;
|
|
2811
2811
|
}
|
|
@@ -2818,10 +2818,10 @@ async function deployCommand(options = {}) {
|
|
|
2818
2818
|
return;
|
|
2819
2819
|
}
|
|
2820
2820
|
}
|
|
2821
|
-
|
|
2821
|
+
spinner11.start("Checking for uncommitted changes...");
|
|
2822
2822
|
const { stdout: gitStatus } = await execa4("git", ["status", "--porcelain"], { cwd: process.cwd() });
|
|
2823
2823
|
if (gitStatus.trim()) {
|
|
2824
|
-
|
|
2824
|
+
spinner11.stop("");
|
|
2825
2825
|
const commit = await p5.confirm({
|
|
2826
2826
|
message: "You have uncommitted changes. Commit before deploying?",
|
|
2827
2827
|
initialValue: true
|
|
@@ -2835,20 +2835,20 @@ async function deployCommand(options = {}) {
|
|
|
2835
2835
|
if (!p5.isCancel(message)) {
|
|
2836
2836
|
await execa4("git", ["add", "."], { cwd: process.cwd() });
|
|
2837
2837
|
await execa4("git", ["commit", "-m", message], { cwd: process.cwd() });
|
|
2838
|
-
|
|
2838
|
+
spinner11.start("Pushing to GitHub...");
|
|
2839
2839
|
await execa4("git", ["push"], { cwd: process.cwd() });
|
|
2840
|
-
|
|
2840
|
+
spinner11.stop("Pushed to GitHub");
|
|
2841
2841
|
}
|
|
2842
2842
|
}
|
|
2843
2843
|
} else {
|
|
2844
|
-
|
|
2844
|
+
spinner11.stop("No uncommitted changes");
|
|
2845
2845
|
}
|
|
2846
2846
|
const deployType = options.preview ? "preview" : "production";
|
|
2847
|
-
|
|
2847
|
+
spinner11.start(`Deploying to ${deployType}...`);
|
|
2848
2848
|
try {
|
|
2849
2849
|
const vercel = new VercelService(config);
|
|
2850
2850
|
const deployment = await vercel.deploy(process.cwd(), !options.preview);
|
|
2851
|
-
|
|
2851
|
+
spinner11.stop("Deployment complete!");
|
|
2852
2852
|
console.log(boxedOutput(`
|
|
2853
2853
|
${chalk6.green("\u2713")} Deployed successfully!
|
|
2854
2854
|
|
|
@@ -2860,7 +2860,7 @@ ${chalk6.dim("View in Vercel Dashboard:")}
|
|
|
2860
2860
|
${chalk6.dim(deployment.dashboardUrl || "https://vercel.com/dashboard")}
|
|
2861
2861
|
`));
|
|
2862
2862
|
} catch (error) {
|
|
2863
|
-
|
|
2863
|
+
spinner11.stop("");
|
|
2864
2864
|
const errorMsg = error instanceof Error ? error.message : "Unknown error";
|
|
2865
2865
|
p5.log.error(`Deployment failed: ${errorMsg}`);
|
|
2866
2866
|
if (errorMsg.includes("Build failed")) {
|
|
@@ -2869,8 +2869,8 @@ ${chalk6.dim(deployment.dashboardUrl || "https://vercel.com/dashboard")}
|
|
|
2869
2869
|
initialValue: true
|
|
2870
2870
|
});
|
|
2871
2871
|
if (retry && !p5.isCancel(retry)) {
|
|
2872
|
-
|
|
2873
|
-
|
|
2872
|
+
spinner11.start("Analyzing Vercel build error...");
|
|
2873
|
+
spinner11.stop("Fix attempted");
|
|
2874
2874
|
}
|
|
2875
2875
|
}
|
|
2876
2876
|
p5.outro(chalk6.red("Deploy failed."));
|
|
@@ -3236,10 +3236,10 @@ you'll need a Meta Business account.
|
|
|
3236
3236
|
initialValue: true
|
|
3237
3237
|
});
|
|
3238
3238
|
if (!proceed || p7.isCancel(proceed)) return;
|
|
3239
|
-
const
|
|
3240
|
-
|
|
3239
|
+
const spinner11 = p7.spinner();
|
|
3240
|
+
spinner11.start("Generating QR code...");
|
|
3241
3241
|
try {
|
|
3242
|
-
|
|
3242
|
+
spinner11.stop("");
|
|
3243
3243
|
console.log(chalk8.cyan(`
|
|
3244
3244
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
3245
3245
|
\u2551 \u2551
|
|
@@ -3271,7 +3271,7 @@ Scan this QR code with WhatsApp:
|
|
|
3271
3271
|
p7.log.success("WhatsApp connected!");
|
|
3272
3272
|
}
|
|
3273
3273
|
} catch (error) {
|
|
3274
|
-
|
|
3274
|
+
spinner11.stop("Error connecting WhatsApp");
|
|
3275
3275
|
p7.log.error(error instanceof Error ? error.message : "Unknown error");
|
|
3276
3276
|
}
|
|
3277
3277
|
}
|
|
@@ -3302,15 +3302,15 @@ To create a Telegram bot:
|
|
|
3302
3302
|
}
|
|
3303
3303
|
});
|
|
3304
3304
|
if (p7.isCancel(token)) return;
|
|
3305
|
-
const
|
|
3306
|
-
|
|
3305
|
+
const spinner11 = p7.spinner();
|
|
3306
|
+
spinner11.start("Verifying bot token...");
|
|
3307
3307
|
try {
|
|
3308
3308
|
const response = await fetch(`https://api.telegram.org/bot${token}/getMe`);
|
|
3309
3309
|
const data = await response.json();
|
|
3310
3310
|
if (!data.ok) {
|
|
3311
3311
|
throw new Error(data.description || "Invalid token");
|
|
3312
3312
|
}
|
|
3313
|
-
|
|
3313
|
+
spinner11.stop("Bot verified!");
|
|
3314
3314
|
config.setChannelConfig("telegram", {
|
|
3315
3315
|
enabled: true,
|
|
3316
3316
|
botToken: token,
|
|
@@ -3318,7 +3318,7 @@ To create a Telegram bot:
|
|
|
3318
3318
|
});
|
|
3319
3319
|
p7.log.success(`Connected to @${data.result.username}`);
|
|
3320
3320
|
} catch (error) {
|
|
3321
|
-
|
|
3321
|
+
spinner11.stop("Verification failed");
|
|
3322
3322
|
p7.log.error(error instanceof Error ? error.message : "Invalid token");
|
|
3323
3323
|
}
|
|
3324
3324
|
}
|
|
@@ -3456,10 +3456,10 @@ This requires:
|
|
|
3456
3456
|
p7.log.info("iMessage support coming soon.");
|
|
3457
3457
|
}
|
|
3458
3458
|
async function startAllChannels(config) {
|
|
3459
|
-
const
|
|
3460
|
-
|
|
3459
|
+
const spinner11 = p7.spinner();
|
|
3460
|
+
spinner11.start("Starting channel gateway...");
|
|
3461
3461
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
3462
|
-
|
|
3462
|
+
spinner11.stop("Gateway started");
|
|
3463
3463
|
console.log(chalk8.green(`
|
|
3464
3464
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
3465
3465
|
\u2551 Gateway is running! \u2551
|
|
@@ -3473,10 +3473,10 @@ async function startAllChannels(config) {
|
|
|
3473
3473
|
`));
|
|
3474
3474
|
}
|
|
3475
3475
|
async function stopAllChannels(config) {
|
|
3476
|
-
const
|
|
3477
|
-
|
|
3476
|
+
const spinner11 = p7.spinner();
|
|
3477
|
+
spinner11.start("Stopping gateway...");
|
|
3478
3478
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
3479
|
-
|
|
3479
|
+
spinner11.stop("Gateway stopped");
|
|
3480
3480
|
}
|
|
3481
3481
|
async function deployGatewayWizard(config) {
|
|
3482
3482
|
p7.log.info(chalk8.bold("Deploy Gateway to Cloud"));
|
|
@@ -3591,10 +3591,10 @@ import glob2 from "fast-glob";
|
|
|
3591
3591
|
import * as path8 from "path";
|
|
3592
3592
|
async function securityCommand() {
|
|
3593
3593
|
p9.intro(chalk10.bgCyan.black(" Security Audit "));
|
|
3594
|
-
const
|
|
3595
|
-
|
|
3594
|
+
const spinner11 = p9.spinner();
|
|
3595
|
+
spinner11.start("Scanning for security issues...");
|
|
3596
3596
|
const issues = await runSecurityScan();
|
|
3597
|
-
|
|
3597
|
+
spinner11.stop("Scan complete");
|
|
3598
3598
|
if (issues.length === 0) {
|
|
3599
3599
|
console.log(chalk10.green("\n\u2713 No security issues found!\n"));
|
|
3600
3600
|
displaySecurityScore(100);
|
|
@@ -3688,10 +3688,10 @@ async function generateCommand(type) {
|
|
|
3688
3688
|
validate: (v) => !v ? "Name is required" : void 0
|
|
3689
3689
|
});
|
|
3690
3690
|
if (p10.isCancel(name)) return;
|
|
3691
|
-
const
|
|
3692
|
-
|
|
3691
|
+
const spinner11 = p10.spinner();
|
|
3692
|
+
spinner11.start("Generating...");
|
|
3693
3693
|
await generateFile(generateType, name);
|
|
3694
|
-
|
|
3694
|
+
spinner11.stop(`Generated ${name}`);
|
|
3695
3695
|
p10.outro("");
|
|
3696
3696
|
}
|
|
3697
3697
|
async function generateFile(type, name) {
|
|
@@ -3836,17 +3836,273 @@ import * as p11 from "@clack/prompts";
|
|
|
3836
3836
|
import chalk12 from "chalk";
|
|
3837
3837
|
async function fixCommand() {
|
|
3838
3838
|
p11.intro(chalk12.bgCyan.black(" Auto-Fix "));
|
|
3839
|
-
const
|
|
3840
|
-
|
|
3839
|
+
const spinner11 = p11.spinner();
|
|
3840
|
+
spinner11.start("Analyzing code...");
|
|
3841
3841
|
const result = await runPatternCheck(true);
|
|
3842
3842
|
if (result.passed) {
|
|
3843
|
-
|
|
3843
|
+
spinner11.stop("No issues found!");
|
|
3844
3844
|
} else {
|
|
3845
|
-
|
|
3845
|
+
spinner11.stop(`Fixed ${result.violations.length} issues`);
|
|
3846
3846
|
}
|
|
3847
3847
|
p11.outro(chalk12.green("Done!"));
|
|
3848
3848
|
}
|
|
3849
3849
|
|
|
3850
|
+
// src/commands/design.ts
|
|
3851
|
+
import * as p12 from "@clack/prompts";
|
|
3852
|
+
import chalk13 from "chalk";
|
|
3853
|
+
import * as fs10 from "fs-extra";
|
|
3854
|
+
import * as path10 from "path";
|
|
3855
|
+
var DESIGN_PROFILES = {
|
|
3856
|
+
minimal: {
|
|
3857
|
+
name: "Minimal",
|
|
3858
|
+
inspiration: "Linear, Notion, Vercel",
|
|
3859
|
+
fonts: { heading: "Inter", body: "Inter" },
|
|
3860
|
+
corners: "rounded-md",
|
|
3861
|
+
shadows: "none",
|
|
3862
|
+
spacing: "generous"
|
|
3863
|
+
},
|
|
3864
|
+
bold: {
|
|
3865
|
+
name: "Bold",
|
|
3866
|
+
inspiration: "Stripe, Ramp, Mercury",
|
|
3867
|
+
fonts: { heading: "Plus Jakarta Sans", body: "Inter" },
|
|
3868
|
+
corners: "rounded-2xl",
|
|
3869
|
+
shadows: "elevated",
|
|
3870
|
+
spacing: "generous"
|
|
3871
|
+
},
|
|
3872
|
+
editorial: {
|
|
3873
|
+
name: "Editorial",
|
|
3874
|
+
inspiration: "Medium, Substack, NY Times",
|
|
3875
|
+
fonts: { heading: "Playfair Display", body: "Source Serif Pro" },
|
|
3876
|
+
corners: "rounded-none",
|
|
3877
|
+
shadows: "none",
|
|
3878
|
+
spacing: "reading"
|
|
3879
|
+
},
|
|
3880
|
+
playful: {
|
|
3881
|
+
name: "Playful",
|
|
3882
|
+
inspiration: "Figma, Slack, Notion",
|
|
3883
|
+
fonts: { heading: "Nunito", body: "Nunito" },
|
|
3884
|
+
corners: "rounded-full",
|
|
3885
|
+
shadows: "soft",
|
|
3886
|
+
spacing: "comfortable"
|
|
3887
|
+
},
|
|
3888
|
+
premium: {
|
|
3889
|
+
name: "Premium",
|
|
3890
|
+
inspiration: "Apple, Porsche, Amex",
|
|
3891
|
+
fonts: { heading: "Cormorant Garamond", body: "Lato" },
|
|
3892
|
+
corners: "rounded-lg",
|
|
3893
|
+
shadows: "subtle",
|
|
3894
|
+
spacing: "luxurious"
|
|
3895
|
+
},
|
|
3896
|
+
dashboard: {
|
|
3897
|
+
name: "Dashboard",
|
|
3898
|
+
inspiration: "Datadog, Grafana, Linear",
|
|
3899
|
+
fonts: { heading: "Inter", body: "Inter" },
|
|
3900
|
+
corners: "rounded-md",
|
|
3901
|
+
shadows: "card",
|
|
3902
|
+
spacing: "compact"
|
|
3903
|
+
}
|
|
3904
|
+
};
|
|
3905
|
+
async function designCommand(subcommand) {
|
|
3906
|
+
const config = new Config();
|
|
3907
|
+
if (!config.isInProject()) {
|
|
3908
|
+
p12.log.error("Not in a CodeBakers project. Run `codebakers init` first.");
|
|
3909
|
+
return;
|
|
3910
|
+
}
|
|
3911
|
+
p12.intro(chalk13.bgCyan.black(" Design System "));
|
|
3912
|
+
const action = subcommand || await p12.select({
|
|
3913
|
+
message: "What do you want to do?",
|
|
3914
|
+
options: [
|
|
3915
|
+
{ value: "profile", label: "\u{1F3A8} Set design profile" },
|
|
3916
|
+
{ value: "palette", label: "\u{1F308} Generate color palette" },
|
|
3917
|
+
{ value: "check", label: "\u2705 Check design quality" },
|
|
3918
|
+
{ value: "view", label: "\u{1F440} View current settings" }
|
|
3919
|
+
]
|
|
3920
|
+
});
|
|
3921
|
+
if (p12.isCancel(action)) return;
|
|
3922
|
+
switch (action) {
|
|
3923
|
+
case "profile":
|
|
3924
|
+
await setProfile();
|
|
3925
|
+
break;
|
|
3926
|
+
case "palette":
|
|
3927
|
+
await generatePalette();
|
|
3928
|
+
break;
|
|
3929
|
+
case "check":
|
|
3930
|
+
await checkDesign();
|
|
3931
|
+
break;
|
|
3932
|
+
case "view":
|
|
3933
|
+
await viewSettings();
|
|
3934
|
+
break;
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
async function setProfile() {
|
|
3938
|
+
const profile = await p12.select({
|
|
3939
|
+
message: "Choose your design profile:",
|
|
3940
|
+
options: Object.entries(DESIGN_PROFILES).map(([key, value]) => ({
|
|
3941
|
+
value: key,
|
|
3942
|
+
label: `${value.name}`,
|
|
3943
|
+
hint: value.inspiration
|
|
3944
|
+
}))
|
|
3945
|
+
});
|
|
3946
|
+
if (p12.isCancel(profile)) return;
|
|
3947
|
+
const selected = DESIGN_PROFILES[profile];
|
|
3948
|
+
const configPath = path10.join(process.cwd(), ".codebakers", "design.json");
|
|
3949
|
+
await fs10.ensureDir(path10.dirname(configPath));
|
|
3950
|
+
await fs10.writeJson(configPath, {
|
|
3951
|
+
profile,
|
|
3952
|
+
...selected,
|
|
3953
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3954
|
+
}, { spaces: 2 });
|
|
3955
|
+
p12.log.success(`Design profile set to ${selected.name}`);
|
|
3956
|
+
console.log(chalk13.dim(`
|
|
3957
|
+
Fonts: ${selected.fonts.heading} / ${selected.fonts.body}
|
|
3958
|
+
Corners: ${selected.corners}
|
|
3959
|
+
Shadows: ${selected.shadows}
|
|
3960
|
+
Spacing: ${selected.spacing}
|
|
3961
|
+
`));
|
|
3962
|
+
}
|
|
3963
|
+
async function generatePalette() {
|
|
3964
|
+
const brandColor = await p12.text({
|
|
3965
|
+
message: "Enter your brand color (hex):",
|
|
3966
|
+
placeholder: "#6366F1",
|
|
3967
|
+
validate: (v) => {
|
|
3968
|
+
if (!v.match(/^#[0-9A-Fa-f]{6}$/)) return "Enter a valid hex color (#RRGGBB)";
|
|
3969
|
+
return void 0;
|
|
3970
|
+
}
|
|
3971
|
+
});
|
|
3972
|
+
if (p12.isCancel(brandColor)) return;
|
|
3973
|
+
const palette = generateColorPalette(brandColor);
|
|
3974
|
+
const configPath = path10.join(process.cwd(), ".codebakers", "design.json");
|
|
3975
|
+
let config = {};
|
|
3976
|
+
if (await fs10.pathExists(configPath)) {
|
|
3977
|
+
config = await fs10.readJson(configPath);
|
|
3978
|
+
}
|
|
3979
|
+
await fs10.writeJson(configPath, {
|
|
3980
|
+
...config,
|
|
3981
|
+
colors: palette,
|
|
3982
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3983
|
+
}, { spaces: 2 });
|
|
3984
|
+
p12.log.success("Color palette generated!");
|
|
3985
|
+
console.log(`
|
|
3986
|
+
${chalk13.bgHex(palette.brand[500]).black(" Brand ")} ${palette.brand[500]}
|
|
3987
|
+
${chalk13.bgHex(palette.brand[100]).black(" Light ")} ${palette.brand[100]}
|
|
3988
|
+
${chalk13.bgHex(palette.brand[900]).white(" Dark ")} ${palette.brand[900]}
|
|
3989
|
+
${chalk13.bgHex(palette.accent).black(" Accent ")} ${palette.accent}
|
|
3990
|
+
`);
|
|
3991
|
+
}
|
|
3992
|
+
function generateColorPalette(hex) {
|
|
3993
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
3994
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
3995
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
3996
|
+
const max = Math.max(r, g, b);
|
|
3997
|
+
const min = Math.min(r, g, b);
|
|
3998
|
+
let h = 0, s = 0, l = (max + min) / 2;
|
|
3999
|
+
if (max !== min) {
|
|
4000
|
+
const d = max - min;
|
|
4001
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
4002
|
+
switch (max) {
|
|
4003
|
+
case r:
|
|
4004
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
4005
|
+
break;
|
|
4006
|
+
case g:
|
|
4007
|
+
h = ((b - r) / d + 2) / 6;
|
|
4008
|
+
break;
|
|
4009
|
+
case b:
|
|
4010
|
+
h = ((r - g) / d + 4) / 6;
|
|
4011
|
+
break;
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
h = Math.round(h * 360);
|
|
4015
|
+
s = Math.round(s * 100);
|
|
4016
|
+
l = Math.round(l * 100);
|
|
4017
|
+
const hslToHex = (h2, s2, l2) => {
|
|
4018
|
+
l2 /= 100;
|
|
4019
|
+
const a = s2 * Math.min(l2, 1 - l2) / 100;
|
|
4020
|
+
const f = (n) => {
|
|
4021
|
+
const k = (n + h2 / 30) % 12;
|
|
4022
|
+
const color = l2 - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
4023
|
+
return Math.round(255 * color).toString(16).padStart(2, "0");
|
|
4024
|
+
};
|
|
4025
|
+
return `#${f(0)}${f(8)}${f(4)}`;
|
|
4026
|
+
};
|
|
4027
|
+
return {
|
|
4028
|
+
brand: {
|
|
4029
|
+
50: hslToHex(h, s * 0.3, 97),
|
|
4030
|
+
100: hslToHex(h, s * 0.4, 94),
|
|
4031
|
+
200: hslToHex(h, s * 0.5, 86),
|
|
4032
|
+
300: hslToHex(h, s * 0.6, 74),
|
|
4033
|
+
400: hslToHex(h, s * 0.8, 62),
|
|
4034
|
+
500: hex,
|
|
4035
|
+
// Original
|
|
4036
|
+
600: hslToHex(h, s, l * 0.85),
|
|
4037
|
+
700: hslToHex(h, s, l * 0.7),
|
|
4038
|
+
800: hslToHex(h, s, l * 0.55),
|
|
4039
|
+
900: hslToHex(h, s, l * 0.4)
|
|
4040
|
+
},
|
|
4041
|
+
accent: hslToHex((h + 180) % 360, s, l)
|
|
4042
|
+
// Complementary
|
|
4043
|
+
};
|
|
4044
|
+
}
|
|
4045
|
+
async function checkDesign() {
|
|
4046
|
+
const spinner11 = p12.spinner();
|
|
4047
|
+
spinner11.start("Checking design quality...");
|
|
4048
|
+
const cwd = process.cwd();
|
|
4049
|
+
const issues = [];
|
|
4050
|
+
const glob3 = (await import("fast-glob")).default;
|
|
4051
|
+
const files = await glob3(["src/**/*.{tsx,jsx}"], { cwd });
|
|
4052
|
+
for (const file of files) {
|
|
4053
|
+
const content = await fs10.readFile(path10.join(cwd, file), "utf-8");
|
|
4054
|
+
if (content.includes("bg-gradient-to-r from-blue-500") || content.includes("bg-gradient-to-r from-purple-500")) {
|
|
4055
|
+
issues.push(`${file}: Generic gradient hero detected`);
|
|
4056
|
+
}
|
|
4057
|
+
const iconMatches = content.match(/<(Rocket|Shield|Zap|Star|Check|Lightning)/g);
|
|
4058
|
+
if (iconMatches && iconMatches.length > 3) {
|
|
4059
|
+
issues.push(`${file}: Too many generic icons (${iconMatches.length})`);
|
|
4060
|
+
}
|
|
4061
|
+
if (content.includes(">Get Started<") || content.includes(">Learn More<")) {
|
|
4062
|
+
issues.push(`${file}: Generic CTA text - be more specific`);
|
|
4063
|
+
}
|
|
4064
|
+
if (content.includes("No data") || content.includes("Nothing here")) {
|
|
4065
|
+
issues.push(`${file}: Lazy empty state - add helpful message`);
|
|
4066
|
+
}
|
|
4067
|
+
if (content.includes("py-4") || content.includes("py-6") || content.includes("py-8")) {
|
|
4068
|
+
if (content.includes("<section")) {
|
|
4069
|
+
issues.push(`${file}: Section padding too small - use py-16 or larger`);
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
spinner11.stop("Check complete");
|
|
4074
|
+
if (issues.length === 0) {
|
|
4075
|
+
console.log(chalk13.green("\n\u2713 No design issues found!\n"));
|
|
4076
|
+
} else {
|
|
4077
|
+
console.log(chalk13.yellow(`
|
|
4078
|
+
\u26A0\uFE0F ${issues.length} design issues found:
|
|
4079
|
+
`));
|
|
4080
|
+
for (const issue of issues) {
|
|
4081
|
+
console.log(chalk13.dim(` \u2022 ${issue}`));
|
|
4082
|
+
}
|
|
4083
|
+
console.log("");
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4086
|
+
async function viewSettings() {
|
|
4087
|
+
const configPath = path10.join(process.cwd(), ".codebakers", "design.json");
|
|
4088
|
+
if (!await fs10.pathExists(configPath)) {
|
|
4089
|
+
p12.log.info("No design settings configured. Run `codebakers design profile` to set up.");
|
|
4090
|
+
return;
|
|
4091
|
+
}
|
|
4092
|
+
const config = await fs10.readJson(configPath);
|
|
4093
|
+
console.log(chalk13.bold("\nCurrent Design Settings:\n"));
|
|
4094
|
+
console.log(` Profile: ${config.name || config.profile}`);
|
|
4095
|
+
console.log(` Fonts: ${config.fonts?.heading} / ${config.fonts?.body}`);
|
|
4096
|
+
console.log(` Corners: ${config.corners}`);
|
|
4097
|
+
console.log(` Shadows: ${config.shadows}`);
|
|
4098
|
+
console.log(` Spacing: ${config.spacing}`);
|
|
4099
|
+
if (config.colors) {
|
|
4100
|
+
console.log(` Brand: ${config.colors.brand?.[500]}`);
|
|
4101
|
+
console.log(` Accent: ${config.colors.accent}`);
|
|
4102
|
+
}
|
|
4103
|
+
console.log("");
|
|
4104
|
+
}
|
|
4105
|
+
|
|
3850
4106
|
// src/index.ts
|
|
3851
4107
|
var VERSION2 = "1.0.0";
|
|
3852
4108
|
var logo = `
|
|
@@ -3861,18 +4117,18 @@ async function showMainMenu() {
|
|
|
3861
4117
|
const config = new Config();
|
|
3862
4118
|
const isSetup = config.isConfigured();
|
|
3863
4119
|
console.log(gradient.pastel.multiline(logo));
|
|
3864
|
-
console.log(
|
|
4120
|
+
console.log(chalk14.dim(` v${VERSION2} \u2014 AI dev team that follows the rules
|
|
3865
4121
|
`));
|
|
3866
4122
|
if (!isSetup) {
|
|
3867
4123
|
console.log(boxen(
|
|
3868
|
-
|
|
4124
|
+
chalk14.yellow("Welcome to CodeBakers! Let's get you set up."),
|
|
3869
4125
|
{ padding: 1, borderColor: "yellow", borderStyle: "round" }
|
|
3870
4126
|
));
|
|
3871
4127
|
await setupCommand();
|
|
3872
4128
|
return;
|
|
3873
4129
|
}
|
|
3874
4130
|
const inProject = config.isInProject();
|
|
3875
|
-
const action = await
|
|
4131
|
+
const action = await p13.select({
|
|
3876
4132
|
message: "What do you want to do?",
|
|
3877
4133
|
options: inProject ? [
|
|
3878
4134
|
{ value: "code", label: "\u{1F4AC} Code with AI", hint: "build features, fix bugs" },
|
|
@@ -3886,6 +4142,7 @@ async function showMainMenu() {
|
|
|
3886
4142
|
{ value: "gateway", label: "\u{1F4F1} Channel gateway", hint: "WhatsApp, Telegram, etc." },
|
|
3887
4143
|
{ value: "learn", label: "\u{1F9E0} Learning settings", hint: "view what I've learned" },
|
|
3888
4144
|
{ value: "security", label: "\u{1F512} Security audit", hint: "check for vulnerabilities" },
|
|
4145
|
+
{ value: "design", label: "\u{1F3A8} Design system", hint: "set profile, colors" },
|
|
3889
4146
|
{ value: "separator2", label: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" },
|
|
3890
4147
|
{ value: "new", label: "\u{1F195} Create new project" },
|
|
3891
4148
|
{ value: "settings", label: "\u2699\uFE0F Settings" },
|
|
@@ -3902,8 +4159,8 @@ async function showMainMenu() {
|
|
|
3902
4159
|
{ value: "help", label: "\u2753 Help" }
|
|
3903
4160
|
]
|
|
3904
4161
|
});
|
|
3905
|
-
if (
|
|
3906
|
-
|
|
4162
|
+
if (p13.isCancel(action)) {
|
|
4163
|
+
p13.cancel("Goodbye!");
|
|
3907
4164
|
process.exit(0);
|
|
3908
4165
|
}
|
|
3909
4166
|
switch (action) {
|
|
@@ -3937,6 +4194,9 @@ async function showMainMenu() {
|
|
|
3937
4194
|
case "security":
|
|
3938
4195
|
await securityCommand();
|
|
3939
4196
|
break;
|
|
4197
|
+
case "design":
|
|
4198
|
+
await designCommand();
|
|
4199
|
+
break;
|
|
3940
4200
|
case "new":
|
|
3941
4201
|
await initCommand();
|
|
3942
4202
|
break;
|
|
@@ -3952,27 +4212,27 @@ async function showMainMenu() {
|
|
|
3952
4212
|
}
|
|
3953
4213
|
function showHelp2() {
|
|
3954
4214
|
console.log(boxen(`
|
|
3955
|
-
${
|
|
3956
|
-
|
|
3957
|
-
${
|
|
3958
|
-
${
|
|
3959
|
-
${
|
|
3960
|
-
${
|
|
3961
|
-
${
|
|
3962
|
-
${
|
|
3963
|
-
${
|
|
3964
|
-
${
|
|
3965
|
-
${
|
|
3966
|
-
${
|
|
3967
|
-
${
|
|
3968
|
-
${
|
|
3969
|
-
${
|
|
3970
|
-
|
|
3971
|
-
${
|
|
3972
|
-
Press ${
|
|
3973
|
-
|
|
3974
|
-
${
|
|
3975
|
-
${
|
|
4215
|
+
${chalk14.bold("CodeBakers CLI")} \u2014 AI dev team that follows the rules
|
|
4216
|
+
|
|
4217
|
+
${chalk14.bold("Commands:")}
|
|
4218
|
+
${chalk14.cyan("codebakers")} Interactive menu (or just run with no args)
|
|
4219
|
+
${chalk14.cyan("codebakers init")} Create a new project
|
|
4220
|
+
${chalk14.cyan("codebakers code")} Start AI coding session
|
|
4221
|
+
${chalk14.cyan("codebakers check")} Run pattern enforcement
|
|
4222
|
+
${chalk14.cyan("codebakers deploy")} Deploy to production
|
|
4223
|
+
${chalk14.cyan("codebakers fix")} Auto-fix errors
|
|
4224
|
+
${chalk14.cyan("codebakers generate")} Generate components/pages
|
|
4225
|
+
${chalk14.cyan("codebakers connect")} Connect external services
|
|
4226
|
+
${chalk14.cyan("codebakers gateway")} Manage messaging channels
|
|
4227
|
+
${chalk14.cyan("codebakers status")} View project status
|
|
4228
|
+
${chalk14.cyan("codebakers security")} Run security audit
|
|
4229
|
+
${chalk14.cyan("codebakers learn")} View/manage learning
|
|
4230
|
+
|
|
4231
|
+
${chalk14.bold("Help at any time:")}
|
|
4232
|
+
Press ${chalk14.yellow("?")} during any command to get contextual help
|
|
4233
|
+
|
|
4234
|
+
${chalk14.bold("Documentation:")}
|
|
4235
|
+
${chalk14.dim("https://codebakers.dev/docs")}
|
|
3976
4236
|
`, { padding: 1, borderColor: "cyan", borderStyle: "round" }));
|
|
3977
4237
|
}
|
|
3978
4238
|
var program = new Command();
|
|
@@ -3989,6 +4249,7 @@ program.command("gateway").description("Manage messaging channel gateway").optio
|
|
|
3989
4249
|
program.command("status").description("View project status and health").option("-a, --all", "Show all projects").action(statusCommand);
|
|
3990
4250
|
program.command("security").description("Run security audit").option("--fix", "Auto-fix security issues").action(securityCommand);
|
|
3991
4251
|
program.command("learn").description("View and manage learning settings").option("--forget <item>", "Forget a learned preference").option("--reset", "Reset all learning").option("--export", "Export learned patterns").action(learnCommand);
|
|
4252
|
+
program.command("design [action]").description("Manage design system (profile, palette, check)").action(designCommand);
|
|
3992
4253
|
var args = process.argv.slice(2);
|
|
3993
4254
|
if (args.length === 0) {
|
|
3994
4255
|
checkForUpdates().catch(() => {
|
package/package.json
CHANGED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import * as fs from 'fs-extra';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { Config } from '../utils/config.js';
|
|
6
|
+
|
|
7
|
+
const DESIGN_PROFILES = {
|
|
8
|
+
minimal: {
|
|
9
|
+
name: 'Minimal',
|
|
10
|
+
inspiration: 'Linear, Notion, Vercel',
|
|
11
|
+
fonts: { heading: 'Inter', body: 'Inter' },
|
|
12
|
+
corners: 'rounded-md',
|
|
13
|
+
shadows: 'none',
|
|
14
|
+
spacing: 'generous',
|
|
15
|
+
},
|
|
16
|
+
bold: {
|
|
17
|
+
name: 'Bold',
|
|
18
|
+
inspiration: 'Stripe, Ramp, Mercury',
|
|
19
|
+
fonts: { heading: 'Plus Jakarta Sans', body: 'Inter' },
|
|
20
|
+
corners: 'rounded-2xl',
|
|
21
|
+
shadows: 'elevated',
|
|
22
|
+
spacing: 'generous',
|
|
23
|
+
},
|
|
24
|
+
editorial: {
|
|
25
|
+
name: 'Editorial',
|
|
26
|
+
inspiration: 'Medium, Substack, NY Times',
|
|
27
|
+
fonts: { heading: 'Playfair Display', body: 'Source Serif Pro' },
|
|
28
|
+
corners: 'rounded-none',
|
|
29
|
+
shadows: 'none',
|
|
30
|
+
spacing: 'reading',
|
|
31
|
+
},
|
|
32
|
+
playful: {
|
|
33
|
+
name: 'Playful',
|
|
34
|
+
inspiration: 'Figma, Slack, Notion',
|
|
35
|
+
fonts: { heading: 'Nunito', body: 'Nunito' },
|
|
36
|
+
corners: 'rounded-full',
|
|
37
|
+
shadows: 'soft',
|
|
38
|
+
spacing: 'comfortable',
|
|
39
|
+
},
|
|
40
|
+
premium: {
|
|
41
|
+
name: 'Premium',
|
|
42
|
+
inspiration: 'Apple, Porsche, Amex',
|
|
43
|
+
fonts: { heading: 'Cormorant Garamond', body: 'Lato' },
|
|
44
|
+
corners: 'rounded-lg',
|
|
45
|
+
shadows: 'subtle',
|
|
46
|
+
spacing: 'luxurious',
|
|
47
|
+
},
|
|
48
|
+
dashboard: {
|
|
49
|
+
name: 'Dashboard',
|
|
50
|
+
inspiration: 'Datadog, Grafana, Linear',
|
|
51
|
+
fonts: { heading: 'Inter', body: 'Inter' },
|
|
52
|
+
corners: 'rounded-md',
|
|
53
|
+
shadows: 'card',
|
|
54
|
+
spacing: 'compact',
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export async function designCommand(subcommand?: string): Promise<void> {
|
|
59
|
+
const config = new Config();
|
|
60
|
+
|
|
61
|
+
if (!config.isInProject()) {
|
|
62
|
+
p.log.error('Not in a CodeBakers project. Run `codebakers init` first.');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
p.intro(chalk.bgCyan.black(' Design System '));
|
|
67
|
+
|
|
68
|
+
const action = subcommand || await p.select({
|
|
69
|
+
message: 'What do you want to do?',
|
|
70
|
+
options: [
|
|
71
|
+
{ value: 'profile', label: '🎨 Set design profile' },
|
|
72
|
+
{ value: 'palette', label: '🌈 Generate color palette' },
|
|
73
|
+
{ value: 'check', label: '✅ Check design quality' },
|
|
74
|
+
{ value: 'view', label: '👀 View current settings' },
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (p.isCancel(action)) return;
|
|
79
|
+
|
|
80
|
+
switch (action) {
|
|
81
|
+
case 'profile':
|
|
82
|
+
await setProfile();
|
|
83
|
+
break;
|
|
84
|
+
case 'palette':
|
|
85
|
+
await generatePalette();
|
|
86
|
+
break;
|
|
87
|
+
case 'check':
|
|
88
|
+
await checkDesign();
|
|
89
|
+
break;
|
|
90
|
+
case 'view':
|
|
91
|
+
await viewSettings();
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function setProfile(): Promise<void> {
|
|
97
|
+
const profile = await p.select({
|
|
98
|
+
message: 'Choose your design profile:',
|
|
99
|
+
options: Object.entries(DESIGN_PROFILES).map(([key, value]) => ({
|
|
100
|
+
value: key,
|
|
101
|
+
label: `${value.name}`,
|
|
102
|
+
hint: value.inspiration,
|
|
103
|
+
})),
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (p.isCancel(profile)) return;
|
|
107
|
+
|
|
108
|
+
const selected = DESIGN_PROFILES[profile as keyof typeof DESIGN_PROFILES];
|
|
109
|
+
|
|
110
|
+
// Save to project config
|
|
111
|
+
const configPath = path.join(process.cwd(), '.codebakers', 'design.json');
|
|
112
|
+
await fs.ensureDir(path.dirname(configPath));
|
|
113
|
+
await fs.writeJson(configPath, {
|
|
114
|
+
profile,
|
|
115
|
+
...selected,
|
|
116
|
+
updatedAt: new Date().toISOString(),
|
|
117
|
+
}, { spaces: 2 });
|
|
118
|
+
|
|
119
|
+
p.log.success(`Design profile set to ${selected.name}`);
|
|
120
|
+
|
|
121
|
+
console.log(chalk.dim(`
|
|
122
|
+
Fonts: ${selected.fonts.heading} / ${selected.fonts.body}
|
|
123
|
+
Corners: ${selected.corners}
|
|
124
|
+
Shadows: ${selected.shadows}
|
|
125
|
+
Spacing: ${selected.spacing}
|
|
126
|
+
`));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function generatePalette(): Promise<void> {
|
|
130
|
+
const brandColor = await p.text({
|
|
131
|
+
message: 'Enter your brand color (hex):',
|
|
132
|
+
placeholder: '#6366F1',
|
|
133
|
+
validate: (v) => {
|
|
134
|
+
if (!v.match(/^#[0-9A-Fa-f]{6}$/)) return 'Enter a valid hex color (#RRGGBB)';
|
|
135
|
+
return undefined;
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (p.isCancel(brandColor)) return;
|
|
140
|
+
|
|
141
|
+
const palette = generateColorPalette(brandColor as string);
|
|
142
|
+
|
|
143
|
+
// Save to project
|
|
144
|
+
const configPath = path.join(process.cwd(), '.codebakers', 'design.json');
|
|
145
|
+
let config = {};
|
|
146
|
+
if (await fs.pathExists(configPath)) {
|
|
147
|
+
config = await fs.readJson(configPath);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
await fs.writeJson(configPath, {
|
|
151
|
+
...config,
|
|
152
|
+
colors: palette,
|
|
153
|
+
updatedAt: new Date().toISOString(),
|
|
154
|
+
}, { spaces: 2 });
|
|
155
|
+
|
|
156
|
+
p.log.success('Color palette generated!');
|
|
157
|
+
|
|
158
|
+
console.log(`
|
|
159
|
+
${chalk.bgHex(palette.brand[500]).black(' Brand ')} ${palette.brand[500]}
|
|
160
|
+
${chalk.bgHex(palette.brand[100]).black(' Light ')} ${palette.brand[100]}
|
|
161
|
+
${chalk.bgHex(palette.brand[900]).white(' Dark ')} ${palette.brand[900]}
|
|
162
|
+
${chalk.bgHex(palette.accent).black(' Accent ')} ${palette.accent}
|
|
163
|
+
`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function generateColorPalette(hex: string): Record<string, any> {
|
|
167
|
+
// Convert hex to HSL
|
|
168
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
169
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
170
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
171
|
+
|
|
172
|
+
const max = Math.max(r, g, b);
|
|
173
|
+
const min = Math.min(r, g, b);
|
|
174
|
+
let h = 0, s = 0, l = (max + min) / 2;
|
|
175
|
+
|
|
176
|
+
if (max !== min) {
|
|
177
|
+
const d = max - min;
|
|
178
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
179
|
+
switch (max) {
|
|
180
|
+
case r: h = ((g - b) / d + (g < b ? 6 : 0)) / 6; break;
|
|
181
|
+
case g: h = ((b - r) / d + 2) / 6; break;
|
|
182
|
+
case b: h = ((r - g) / d + 4) / 6; break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
h = Math.round(h * 360);
|
|
187
|
+
s = Math.round(s * 100);
|
|
188
|
+
l = Math.round(l * 100);
|
|
189
|
+
|
|
190
|
+
// Generate scale
|
|
191
|
+
const hslToHex = (h: number, s: number, l: number): string => {
|
|
192
|
+
l /= 100;
|
|
193
|
+
const a = s * Math.min(l, 1 - l) / 100;
|
|
194
|
+
const f = (n: number) => {
|
|
195
|
+
const k = (n + h / 30) % 12;
|
|
196
|
+
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
197
|
+
return Math.round(255 * color).toString(16).padStart(2, '0');
|
|
198
|
+
};
|
|
199
|
+
return `#${f(0)}${f(8)}${f(4)}`;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
brand: {
|
|
204
|
+
50: hslToHex(h, s * 0.3, 97),
|
|
205
|
+
100: hslToHex(h, s * 0.4, 94),
|
|
206
|
+
200: hslToHex(h, s * 0.5, 86),
|
|
207
|
+
300: hslToHex(h, s * 0.6, 74),
|
|
208
|
+
400: hslToHex(h, s * 0.8, 62),
|
|
209
|
+
500: hex, // Original
|
|
210
|
+
600: hslToHex(h, s, l * 0.85),
|
|
211
|
+
700: hslToHex(h, s, l * 0.7),
|
|
212
|
+
800: hslToHex(h, s, l * 0.55),
|
|
213
|
+
900: hslToHex(h, s, l * 0.4),
|
|
214
|
+
},
|
|
215
|
+
accent: hslToHex((h + 180) % 360, s, l), // Complementary
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function checkDesign(): Promise<void> {
|
|
220
|
+
const spinner = p.spinner();
|
|
221
|
+
spinner.start('Checking design quality...');
|
|
222
|
+
|
|
223
|
+
const cwd = process.cwd();
|
|
224
|
+
const issues: string[] = [];
|
|
225
|
+
|
|
226
|
+
// Check for anti-patterns in code
|
|
227
|
+
const glob = (await import('fast-glob')).default;
|
|
228
|
+
const files = await glob(['src/**/*.{tsx,jsx}'], { cwd });
|
|
229
|
+
|
|
230
|
+
for (const file of files) {
|
|
231
|
+
const content = await fs.readFile(path.join(cwd, file), 'utf-8');
|
|
232
|
+
|
|
233
|
+
// Check for generic gradient hero
|
|
234
|
+
if (content.includes('bg-gradient-to-r from-blue-500') ||
|
|
235
|
+
content.includes('bg-gradient-to-r from-purple-500')) {
|
|
236
|
+
issues.push(`${file}: Generic gradient hero detected`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Check for icon spam
|
|
240
|
+
const iconMatches = content.match(/<(Rocket|Shield|Zap|Star|Check|Lightning)/g);
|
|
241
|
+
if (iconMatches && iconMatches.length > 3) {
|
|
242
|
+
issues.push(`${file}: Too many generic icons (${iconMatches.length})`);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Check for generic CTAs
|
|
246
|
+
if (content.includes('>Get Started<') || content.includes('>Learn More<')) {
|
|
247
|
+
issues.push(`${file}: Generic CTA text - be more specific`);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Check for lazy empty states
|
|
251
|
+
if (content.includes('No data') || content.includes('Nothing here')) {
|
|
252
|
+
issues.push(`${file}: Lazy empty state - add helpful message`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Check for small section padding
|
|
256
|
+
if (content.includes('py-4') || content.includes('py-6') || content.includes('py-8')) {
|
|
257
|
+
if (content.includes('<section')) {
|
|
258
|
+
issues.push(`${file}: Section padding too small - use py-16 or larger`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
spinner.stop('Check complete');
|
|
264
|
+
|
|
265
|
+
if (issues.length === 0) {
|
|
266
|
+
console.log(chalk.green('\n✓ No design issues found!\n'));
|
|
267
|
+
} else {
|
|
268
|
+
console.log(chalk.yellow(`\n⚠️ ${issues.length} design issues found:\n`));
|
|
269
|
+
for (const issue of issues) {
|
|
270
|
+
console.log(chalk.dim(` • ${issue}`));
|
|
271
|
+
}
|
|
272
|
+
console.log('');
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
async function viewSettings(): Promise<void> {
|
|
277
|
+
const configPath = path.join(process.cwd(), '.codebakers', 'design.json');
|
|
278
|
+
|
|
279
|
+
if (!await fs.pathExists(configPath)) {
|
|
280
|
+
p.log.info('No design settings configured. Run `codebakers design profile` to set up.');
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const config = await fs.readJson(configPath);
|
|
285
|
+
|
|
286
|
+
console.log(chalk.bold('\nCurrent Design Settings:\n'));
|
|
287
|
+
console.log(` Profile: ${config.name || config.profile}`);
|
|
288
|
+
console.log(` Fonts: ${config.fonts?.heading} / ${config.fonts?.body}`);
|
|
289
|
+
console.log(` Corners: ${config.corners}`);
|
|
290
|
+
console.log(` Shadows: ${config.shadows}`);
|
|
291
|
+
console.log(` Spacing: ${config.spacing}`);
|
|
292
|
+
|
|
293
|
+
if (config.colors) {
|
|
294
|
+
console.log(` Brand: ${config.colors.brand?.[500]}`);
|
|
295
|
+
console.log(` Accent: ${config.colors.accent}`);
|
|
296
|
+
}
|
|
297
|
+
console.log('');
|
|
298
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { learnCommand } from './commands/learn.js';
|
|
|
19
19
|
import { securityCommand } from './commands/security.js';
|
|
20
20
|
import { generateCommand } from './commands/generate.js';
|
|
21
21
|
import { fixCommand } from './commands/fix.js';
|
|
22
|
+
import { designCommand } from './commands/design.js';
|
|
22
23
|
|
|
23
24
|
const VERSION = '1.0.0';
|
|
24
25
|
|
|
@@ -69,6 +70,7 @@ async function showMainMenu(): Promise<void> {
|
|
|
69
70
|
{ value: 'gateway', label: '📱 Channel gateway', hint: 'WhatsApp, Telegram, etc.' },
|
|
70
71
|
{ value: 'learn', label: '🧠 Learning settings', hint: 'view what I\'ve learned' },
|
|
71
72
|
{ value: 'security', label: '🔒 Security audit', hint: 'check for vulnerabilities' },
|
|
73
|
+
{ value: 'design', label: '🎨 Design system', hint: 'set profile, colors' },
|
|
72
74
|
{ value: 'separator2', label: '─────────────────────────' },
|
|
73
75
|
{ value: 'new', label: '🆕 Create new project' },
|
|
74
76
|
{ value: 'settings', label: '⚙️ Settings' },
|
|
@@ -123,6 +125,9 @@ async function showMainMenu(): Promise<void> {
|
|
|
123
125
|
case 'security':
|
|
124
126
|
await securityCommand();
|
|
125
127
|
break;
|
|
128
|
+
case 'design':
|
|
129
|
+
await designCommand();
|
|
130
|
+
break;
|
|
126
131
|
case 'new':
|
|
127
132
|
await initCommand();
|
|
128
133
|
break;
|
|
@@ -254,6 +259,11 @@ program
|
|
|
254
259
|
.option('--export', 'Export learned patterns')
|
|
255
260
|
.action(learnCommand);
|
|
256
261
|
|
|
262
|
+
program
|
|
263
|
+
.command('design [action]')
|
|
264
|
+
.description('Manage design system (profile, palette, check)')
|
|
265
|
+
.action(designCommand);
|
|
266
|
+
|
|
257
267
|
// Parse args or show menu
|
|
258
268
|
const args = process.argv.slice(2);
|
|
259
269
|
|