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

Function runDoctor

packages/cli/src/commands/doctor-pi.ts:977–1040  ·  view source on GitHub ↗
(options: RunDoctorOptions = {})

Source from the content-addressed store, hash-verified

975}
976
977export async function runDoctor(options: RunDoctorOptions = {}): Promise<number> {
978 const deps = depsFrom(options);
979 const prompts = options.prompts ?? deps.prompts;
980 const cwd = options.cwd ?? process.cwd();
981
982 if (options.help) {
983 printDoctorHelp();
984 return 0;
985 }
986
987 const configMigrationWarnings = migrateConfigLocationsForCli(cwd, prompts.log);
988
989 if (options.issue) {
990 return runIssueFlow({ cwd, prompts, deps });
991 }
992
993 const v22Result = await runV22BackfillCommands(
994 {
995 name: "Pi",
996 openDatabase: deps.openDatabase,
997 closeDatabase: deps.closeDatabase,
998 log: prompts.log,
999 },
1000 options,
1001 );
1002 if (v22Result.handled) {
1003 return v22Result.exitCode;
1004 }
1005
1006 prompts.intro("Magic Context for Pi Doctor");
1007 const first = await runHealthChecks({
1008 cwd,
1009 prompts,
1010 deps,
1011 configMigrationWarnings,
1012 });
1013 console.log("");
1014 prompts.log.message(`Summary: PASS ${first.pass} / WARN ${first.warn} / FAIL ${first.fail}`);
1015
1016 if (options.force) {
1017 const fixed = repair(first.repairPlan, prompts);
1018 console.log("");
1019 prompts.log.message(
1020 `Repair attempted; ${fixed} item(s) changed. Re-running health checks.`,
1021 );
1022 const second = await runHealthChecks({
1023 cwd,
1024 prompts,
1025 deps,
1026 configMigrationWarnings,
1027 });
1028 console.log("");
1029 prompts.log.message(
1030 `Summary: PASS ${second.pass} / WARN ${second.warn} / FAIL ${second.fail}`,
1031 );
1032 prompts.outro(
1033 second.fail > 0 ? "Doctor found failures after repair" : "Doctor repair complete",
1034 );

Callers 2

doctor-pi.test.tsFile · 0.90
doctorFunction · 0.70

Calls 10

runV22BackfillCommandsFunction · 0.90
depsFromFunction · 0.85
printDoctorHelpFunction · 0.85
runHealthChecksFunction · 0.85
repairFunction · 0.85
runIssueFlowFunction · 0.70
introMethod · 0.65
messageMethod · 0.65
outroMethod · 0.65

Tested by

no test coverage detected