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

Function runHealthChecks

packages/cli/src/commands/doctor-pi.ts:399–808  ·  view source on GitHub ↗
(options: {
    cwd: string;
    prompts: PromptIO;
    deps: DoctorDeps;
    quiet?: boolean;
    configMigrationWarnings?: readonly string[];
})

Source from the content-addressed store, hash-verified

397}
398
399async function runHealthChecks(options: {
400 cwd: string;
401 prompts: PromptIO;
402 deps: DoctorDeps;
403 quiet?: boolean;
404 configMigrationWarnings?: readonly string[];
405}): Promise<HealthReport> {
406 const results: CheckResult[] = [];
407 const userConfigMigrationRefused = hasUserConfigLocationMigrationRefusal(
408 options.configMigrationWarnings ?? [],
409 );
410 const repairPlan: RepairPlan = {
411 addPackageEntry: false,
412 writeUserConfig: false,
413 clearCachePaths: [],
414 };
415 const self = selfVersion();
416
417 const pi = options.deps.detectPiBinary();
418 if (!pi) {
419 add(results, "fail", "Pi binary not found on PATH or at ~/.pi/bin/pi");
420 } else {
421 const version = options.deps.getPiVersion(pi.path);
422 add(
423 results,
424 "pass",
425 version ? `Pi ${version} detected at ${pi.path}` : `Pi detected at ${pi.path}`,
426 );
427 const compare = compareSemver(version, MIN_PI_VERSION);
428 if (compare !== null && compare < 0) {
429 add(
430 results,
431 "fail",
432 `Pi ${version} is older than required ${MIN_PI_VERSION}. Subagents (historian/dreamer/sidekick) use the long-form \`--extension\` flag introduced in Pi 0.71.0; older versions hard-fail with "Unknown option". Run \`pi update\` (or \`npm install -g @earendil-works/pi-coding-agent@latest\`).`,
433 );
434 } else if (version) {
435 add(results, "pass", `Pi version meets minimum ${MIN_PI_VERSION} requirement`);
436 }
437 }
438
439 const latest = options.deps.getLatestNpmVersion();
440 if (latest && compareSemver(self, latest) === -1) {
441 add(
442 results,
443 "warn",
444 `Magic Context for Pi CLI v${self} is older than npm latest v${latest}`,
445 );
446 } else if (latest) {
447 add(
448 results,
449 "pass",
450 `Magic Context for Pi CLI v${self} is current (npm latest v${latest})`,
451 );
452 } else {
453 add(results, "info", `Magic Context for Pi CLI v${self}; npm latest check unavailable`);
454 }
455
456 const settingsPath = getPiUserExtensionsPath();

Callers 1

runDoctorFunction · 0.85

Tested by

no test coverage detected