MCPcopy Create free account
hub / github.com/cortexkit/magic-context / runDoctor

Function runDoctor

packages/cli/src/commands/doctor-opencode.ts:486–1230  ·  view source on GitHub ↗
(
    options: { force?: boolean; issue?: boolean } & V22BackfillCommandArgs = {},
)

Source from the content-addressed store, hash-verified

484// ── Main doctor entry ───────────────────────────────────────────────
485
486export async function runDoctor(
487 options: { force?: boolean; issue?: boolean } & V22BackfillCommandArgs = {},
488): Promise<number> {
489 migrateConfigLocationsForCli(process.cwd(), log);
490
491 if (options.issue) {
492 return runIssueFlow();
493 }
494
495 const v22Result = await runV22BackfillCommands(
496 {
497 name: "OpenCode",
498 openDatabase,
499 closeDatabase,
500 log,
501 },
502 options,
503 );
504 if (v22Result.handled) {
505 return v22Result.exitCode;
506 }
507
508 intro("Magic Context Doctor");
509
510 let issues = 0;
511 let fixed = 0;
512 // Aligned with Pi doctor: emit a PASS/WARN/FAIL summary at the end so
513 // results are scannable.
514 let passCount = 0;
515 let warnCount = 0;
516 let failCount = 0;
517 const pass = (msg: string) => {
518 log.success(msg);
519 passCount++;
520 };
521 const warn = (msg: string) => {
522 log.warn(msg);
523 warnCount++;
524 };
525 const fail = (msg: string) => {
526 log.error(msg);
527 failCount++;
528 issues++;
529 };
530
531 // 1. Check OpenCode is installed
532 const detection = detectOpenCode();
533 if (detection.kind === "none") {
534 fail("OpenCode is not installed or not in PATH");
535 // Help users whose binary IS on PATH but is shadowed by a wrapper
536 // script or lives in a directory not searched by our detection
537 // (e.g. tool-version shims that only inject PATH at shell time).
538 log.info("Doctor checked ~/.opencode/bin/opencode and each entry in $PATH.");
539 log.info(
540 "If `which opencode` succeeds outside doctor, your wrapper or shim may not be readable by Node — please share that wrapper in the issue.",
541 );
542 outro("Doctor failed — install OpenCode first");
543 return 1;

Callers

nothing calls this directly

Calls 15

runV22BackfillCommandsFunction · 0.90
introFunction · 0.90
detectOpenCodeFunction · 0.90
outroFunction · 0.90
detectConfigPathsFunction · 0.90
loadPluginConfigFunction · 0.90
writeFileAtomicFunction · 0.90
matchesPluginEntryFunction · 0.90

Tested by

no test coverage detected