@morebeans/cli 2.1.2 → 2.1.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.
Files changed (2) hide show
  1. package/index.ts +80 -12
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -15,7 +15,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
15
15
  import { join, resolve } from "path";
16
16
  import { homedir } from "os";
17
17
 
18
- const VERSION = "2.1.2";
18
+ const VERSION = "2.1.3";
19
19
  const BEANS_HOME = join(homedir(), ".beans");
20
20
  const BEANS_CONFIG = join(BEANS_HOME, "config.json");
21
21
 
@@ -283,22 +283,49 @@ async function cmdConfig(args: string[]) {
283
283
  log(`\nConfig stored at: ${c.dim}${BEANS_CONFIG}${c.reset}`);
284
284
  }
285
285
 
286
- async function cmdDoctor() {
287
- log(`\n${c.bold}${c.blue}🩺 BEANS Doctor${c.reset}\n`);
286
+ async function cmdDoctor(args: string[]) {
287
+ const fix = args.includes("--fix") || args.includes("-f");
288
+
289
+ log(`\n${c.bold}${c.blue}🩺 BEANS Doctor${fix ? " (--fix)" : ""}${c.reset}\n`);
288
290
 
289
291
  const cwd = process.cwd();
290
292
  const config = loadConfig();
291
293
  let issues = 0;
294
+ let fixed = 0;
292
295
 
293
296
  // Check CLI tools
294
297
  log(`${c.bold}CLI Tools${c.reset}`);
295
- const tools = ["bd", "ast-grep", "repomix"];
296
- for (const tool of tools) {
298
+ const tools: Record<string, string> = {
299
+ "bd": "curl -fsSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash",
300
+ "ast-grep": "npm install -g @ast-grep/cli",
301
+ "repomix": "npm install -g repomix",
302
+ };
303
+
304
+ for (const [tool, installCmd] of Object.entries(tools)) {
297
305
  try {
298
306
  await $`which ${tool}`.quiet();
299
307
  success(tool);
300
308
  } catch {
301
- warn(`${tool} not found (optional)`);
309
+ if (fix && tool !== "bd") {
310
+ info(`Installing ${tool}...`);
311
+ try {
312
+ await $`${installCmd.split(" ")[0]} ${installCmd.split(" ").slice(1)}`.quiet();
313
+ success(`${tool} installed`);
314
+ fixed++;
315
+ } catch (e) {
316
+ error(`Failed to install ${tool}: ${e}`);
317
+ issues++;
318
+ }
319
+ } else if (tool === "bd") {
320
+ error(`${tool} not found (required)`);
321
+ info(` Install: ${installCmd}`);
322
+ issues++;
323
+ } else {
324
+ warn(`${tool} not found`);
325
+ if (fix) {
326
+ info(` Install: ${installCmd}`);
327
+ }
328
+ }
302
329
  }
303
330
  }
304
331
 
@@ -309,15 +336,49 @@ async function cmdDoctor() {
309
336
  if (existsSync(join(cwd, dir))) {
310
337
  success(dir);
311
338
  } else {
312
- error(dir);
313
- issues++;
339
+ if (fix) {
340
+ info(`Running beans init to fix missing directories...`);
341
+ await cmdInit();
342
+ fixed++;
343
+ break;
344
+ } else {
345
+ error(dir);
346
+ issues++;
347
+ }
314
348
  }
315
349
  }
316
- // Optional: .beads (created by bd init)
350
+
351
+ // Check .beads (created by bd init)
317
352
  if (existsSync(join(cwd, ".beads"))) {
318
353
  success(".beads (beads issue tracker)");
354
+
355
+ // Run bd doctor if --fix
356
+ if (fix) {
357
+ log(`\n${c.bold}Running bd doctor --fix...${c.reset}`);
358
+ try {
359
+ const result = await $`bd doctor --fix`.nothrow();
360
+ if (result.exitCode !== 0) {
361
+ warn("bd doctor reported issues (see output above)");
362
+ } else {
363
+ fixed++;
364
+ }
365
+ } catch {
366
+ warn("bd doctor failed");
367
+ }
368
+ }
319
369
  } else {
320
- warn(".beads not initialized (run 'bd init' to enable issue tracking)");
370
+ if (fix) {
371
+ info("Initializing beads...");
372
+ try {
373
+ await $`bd init`.nothrow();
374
+ success(".beads initialized");
375
+ fixed++;
376
+ } catch {
377
+ warn("bd init failed - run manually");
378
+ }
379
+ } else {
380
+ warn(".beads not initialized (run 'beans doctor --fix' or 'bd init')");
381
+ }
321
382
  }
322
383
 
323
384
  // Check config
@@ -365,10 +426,16 @@ async function cmdDoctor() {
365
426
  }
366
427
 
367
428
  log("");
429
+ if (fix && fixed > 0) {
430
+ log(`${c.green}${c.bold}🔧 Fixed ${fixed} issue(s)${c.reset}`);
431
+ }
368
432
  if (issues === 0) {
369
433
  log(`${c.green}${c.bold}✅ BEANS is healthy!${c.reset}`);
370
434
  } else {
371
- log(`${c.yellow}⚠ ${issues} issue(s) found. Run 'beans init' to fix.${c.reset}`);
435
+ log(`${c.yellow}⚠ ${issues} issue(s) found.${c.reset}`);
436
+ if (!fix) {
437
+ log(`${c.dim}Run 'beans doctor --fix' to auto-fix.${c.reset}`);
438
+ }
372
439
  }
373
440
  log("");
374
441
  }
@@ -387,6 +454,7 @@ ${c.bold}Commands:${c.reset}
387
454
  ${c.cyan}config --github${c.reset} Set GitHub token
388
455
  ${c.cyan}config --show${c.reset} Show current configuration
389
456
  ${c.cyan}doctor${c.reset} Check installation status
457
+ ${c.cyan}doctor --fix${c.reset} Auto-fix issues (install tools, run bd doctor)
390
458
  ${c.cyan}help${c.reset} Show this help message
391
459
 
392
460
  ${c.bold}In Claude Code:${c.reset}
@@ -418,7 +486,7 @@ switch (command) {
418
486
  await cmdConfig(args);
419
487
  break;
420
488
  case "doctor":
421
- await cmdDoctor();
489
+ await cmdDoctor(args);
422
490
  break;
423
491
  case "help":
424
492
  case "--help":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morebeans/cli",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "BEANS CLI - Setup and configure autonomous development for Claude Code",
5
5
  "type": "module",
6
6
  "main": "index.ts",