import { type FffInstallOutcome } from "../utils/tools-manager.ts"; import { type AgentDirectoryLayoutReport } from "./agent-directory-layout.ts"; import { OllamaRuntime } from "./models/local-runtime.ts"; import { type PythonRuntimeOutcome } from "./python-runtime.ts"; /** * Environment doctor: verifies required tooling and installs what it safely * can, instead of leaving provisioning entirely to lazy first-use (the exact * gap behind "ran `pi-adaptative update` on another machine and fff-node * never got installed" -- see fff-lazy-install.test.ts/fff-search-tools.test.ts * for the underlying lazy-install fix; this module is the proactive half). * * Two tool kinds, two different postures: * - "managed": pi owns provisioning and attempts it when absent (fff-node, * pinned rg/jq/uv, and the Python interpreter resolved through uv). * - "system": pi does not own the install (Ollama). GUIDE MODE only -- exact * manual steps are reported, never executed. */ export type DoctorToolKind = "managed" | "system"; export interface DoctorCheck { /** Stable identifier, e.g. "fff-node", "ripgrep", "jq", "ollama", "python". */ id: string; /** Human-readable label for the report. */ label: string; kind: DoctorToolKind; present: boolean; /** Version/path/status summary, present or not. */ detail?: string; /** Only set for a "managed" tool: whether an install was just attempted. */ installAttempted?: boolean; /** Only set for a "system" tool that's missing: exact manual steps, never executed. */ guide?: string[]; } export interface DoctorReport { checks: DoctorCheck[]; notices?: DoctorNotice[]; } export interface DoctorNotice { id: string; label: string; detail: string; } /** Minimal slice of OllamaRuntime the doctor needs -- lets tests inject a fake without touching the real runtime. */ export type DoctorOllamaRuntime = Pick; export interface DoctorDeps { loadAvailableFffNodePackage: () => unknown | undefined; ensureFffNodePackage: (silent?: boolean) => Promise; getLastFffInstallOutcome: () => FffInstallOutcome | undefined; ensureTool: (tool: "jq" | "jscpd" | "rg", silent: boolean) => Promise; ensurePythonRuntime: (options: { silent: boolean; }) => Promise; /** Best-effort ` --version` probe; undefined if it can't be run. Used only to enrich a status line, never for presence detection. */ probeVersion: (command: string, versionArgs?: readonly string[]) => string | undefined; ollamaRuntime: DoctorOllamaRuntime; inspectAgentDirectoryLayout: () => AgentDirectoryLayoutReport; } export interface RunDoctorOptions { /** * Whether the fff-node managed install (if one is attempted) stays quiet. * Default true, matching runUpdatePreflight's existing background * behavior. The interactive `doctor` command passes `false` so a * multi-second install doesn't read as a silent hang. */ silent?: boolean; } export declare function runDoctor(deps?: DoctorDeps, options?: RunDoctorOptions): Promise; export declare function formatDoctorReport(report: DoctorReport): string; /** * Best-effort preflight meant to be called right after `pi-adaptative update` * succeeds. Must never fail the update itself: any error here is swallowed * and reported as a skipped check, not surfaced as an update failure. */ export declare function runUpdatePreflight(deps?: DoctorDeps): Promise; //# sourceMappingURL=doctor.d.ts.map