@morebeans/cli 2.1.2 → 2.2.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/index.ts +85 -14
- 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.
|
|
18
|
+
const VERSION = "2.2.0";
|
|
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
|
-
|
|
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
|
|
296
|
-
|
|
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
|
-
|
|
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,52 @@ async function cmdDoctor() {
|
|
|
309
336
|
if (existsSync(join(cwd, dir))) {
|
|
310
337
|
success(dir);
|
|
311
338
|
} else {
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
350
|
+
|
|
351
|
+
// Check beads database (now in .beans, created by bd init)
|
|
352
|
+
const beansDir = join(cwd, ".beans");
|
|
353
|
+
const hasBeadsDb = existsSync(join(beansDir, "beads.db")) || existsSync(join(beansDir, "issues.jsonl"));
|
|
354
|
+
|
|
355
|
+
if (hasBeadsDb) {
|
|
356
|
+
success(".beans/beads.db (issue tracker)");
|
|
357
|
+
|
|
358
|
+
// Run bd doctor if --fix
|
|
359
|
+
if (fix) {
|
|
360
|
+
log(`\n${c.bold}Running bd doctor --fix...${c.reset}`);
|
|
361
|
+
try {
|
|
362
|
+
const result = await $`bd doctor --fix`.nothrow();
|
|
363
|
+
if (result.exitCode !== 0) {
|
|
364
|
+
warn("bd doctor reported issues (see output above)");
|
|
365
|
+
} else {
|
|
366
|
+
fixed++;
|
|
367
|
+
}
|
|
368
|
+
} catch {
|
|
369
|
+
warn("bd doctor failed");
|
|
370
|
+
}
|
|
371
|
+
}
|
|
319
372
|
} else {
|
|
320
|
-
|
|
373
|
+
if (fix) {
|
|
374
|
+
info("Initializing beads (bd init)...");
|
|
375
|
+
try {
|
|
376
|
+
await $`bd init`.nothrow();
|
|
377
|
+
success("beads initialized in .beans/");
|
|
378
|
+
fixed++;
|
|
379
|
+
} catch {
|
|
380
|
+
warn("bd init failed - run manually");
|
|
381
|
+
}
|
|
382
|
+
} else {
|
|
383
|
+
warn("beads not initialized (run 'beans doctor --fix' or 'bd init')");
|
|
384
|
+
}
|
|
321
385
|
}
|
|
322
386
|
|
|
323
387
|
// Check config
|
|
@@ -365,10 +429,16 @@ async function cmdDoctor() {
|
|
|
365
429
|
}
|
|
366
430
|
|
|
367
431
|
log("");
|
|
432
|
+
if (fix && fixed > 0) {
|
|
433
|
+
log(`${c.green}${c.bold}🔧 Fixed ${fixed} issue(s)${c.reset}`);
|
|
434
|
+
}
|
|
368
435
|
if (issues === 0) {
|
|
369
436
|
log(`${c.green}${c.bold}✅ BEANS is healthy!${c.reset}`);
|
|
370
437
|
} else {
|
|
371
|
-
log(`${c.yellow}⚠ ${issues} issue(s) found
|
|
438
|
+
log(`${c.yellow}⚠ ${issues} issue(s) found.${c.reset}`);
|
|
439
|
+
if (!fix) {
|
|
440
|
+
log(`${c.dim}Run 'beans doctor --fix' to auto-fix.${c.reset}`);
|
|
441
|
+
}
|
|
372
442
|
}
|
|
373
443
|
log("");
|
|
374
444
|
}
|
|
@@ -387,6 +457,7 @@ ${c.bold}Commands:${c.reset}
|
|
|
387
457
|
${c.cyan}config --github${c.reset} Set GitHub token
|
|
388
458
|
${c.cyan}config --show${c.reset} Show current configuration
|
|
389
459
|
${c.cyan}doctor${c.reset} Check installation status
|
|
460
|
+
${c.cyan}doctor --fix${c.reset} Auto-fix issues (install tools, run bd doctor)
|
|
390
461
|
${c.cyan}help${c.reset} Show this help message
|
|
391
462
|
|
|
392
463
|
${c.bold}In Claude Code:${c.reset}
|
|
@@ -418,7 +489,7 @@ switch (command) {
|
|
|
418
489
|
await cmdConfig(args);
|
|
419
490
|
break;
|
|
420
491
|
case "doctor":
|
|
421
|
-
await cmdDoctor();
|
|
492
|
+
await cmdDoctor(args);
|
|
422
493
|
break;
|
|
423
494
|
case "help":
|
|
424
495
|
case "--help":
|