/** * System health checks core module. * @task T4783 * @task T4795 */ import type { DependencyReport } from '@cleocode/contracts'; import { type SystemInfo } from '../platform.js'; export interface HealthCheck { name: string; status: 'pass' | 'warn' | 'fail'; message?: string; /** Machine-readable detail for checks that carry more than a message (T12886). */ details?: Record; } export interface HealthResult { overall: 'healthy' | 'warning' | 'error'; checks: HealthCheck[]; version: string; installation: 'ok' | 'degraded'; } export interface DiagnosticsCheck { name: string; status: 'pass' | 'warn' | 'fail'; details?: string; fix?: string; } export interface DiagnosticsResult { timestamp: string; checks: DiagnosticsCheck[]; summary: { total: number; passed: number; warned: number; failed: number; }; } /** Run system health checks (SQLite-first per ADR-006). */ export declare function getSystemHealth(projectRoot: string, opts?: { detailed?: boolean; }): Promise; /** Run extended diagnostics with fix suggestions. */ export declare function getSystemDiagnostics(projectRoot: string, opts?: { checks?: string[]; }): Promise; export interface DoctorCheck { check: string; status: 'ok' | 'error' | 'warning'; message: string; details?: Record; fix?: string; } export interface DoctorReport { healthy: boolean; errors: number; warnings: number; checks: DoctorCheck[]; /** Dependency registry report — populated by `checkAllDependencies()`. */ dependencies?: DependencyReport; } /** * One doctor check per provider in use: is CLEO's heavy-command hook (T12983) * installed, outdated, missing or blocked in this project, with the exact * remedy (T13124). Where a hook is in place, one more check says whether the * `cleo` on PATH can answer it (an older CLEO governs nothing). Providers not * in use add nothing; when none is in use, one `ok` check says so. A delivery * module that cannot load is a warning, never a crash of the report. * * @param projectRoot - Absolute path to the project root * @returns The `heavy_command_hook*` checks * @task T13124 */ export declare function checkHeavyCommandHooks(projectRoot: string): Promise; /** * The CLEO Goal runtime check (`@cleocode/goal`, bin `cleo-goal` or `ocg`): * installed or missing, its version, and whether its `status --json` speaks a * schema this CLEO understands. Local only: npm is asked for the latest * version only with `checkUpdates` (`cleo doctor goal-runtime * --check-updates`), never by a bare `cleo doctor`. CLEO works without the * runtime, so a missing bin is informational (`ok`) unless an opted-in npm * lookup found the package. * * @param projectRoot - absolute project root (cwd of `cleo-goal status --json`) * @param options - `checkUpdates` asks npm for the latest version (network) * @returns the `goal_runtime` check * @task T13819 */ export declare function checkGoalRuntime(projectRoot: string, options?: { readonly checkUpdates?: boolean; }): Promise; /** * Run comprehensive doctor diagnostics combining dependency checks, * directory checks, data file checks, gitignore checks, and environment info. * @task T4795 */ export declare function coreDoctorReport(projectRoot: string): Promise; export interface FixResult { check: string; action: 'fixed' | 'skipped' | 'failed'; message: string; } export declare function runDoctorFixes(projectRoot: string): Promise; /** * Outcome of a startup health check. Tells the caller exactly what state * the system is in so it can route to init, upgrade, or proceed normally. */ export type StartupState = 'healthy' | 'needs_init' | 'needs_upgrade'; export interface StartupHealthCheck { check: string; status: 'pass' | 'warn' | 'fail'; message: string; repaired?: boolean; } export interface StartupHealthResult { /** Overall system state after health check + auto-repair. */ state: StartupState; /** True if the global ~/.cleo scaffold is healthy (after auto-repair). */ globalHealthy: boolean; /** True if the project .cleo/ scaffold is present and healthy. */ projectHealthy: boolean; /** Individual check results for logging/diagnostics. */ checks: StartupHealthCheck[]; /** Checks that failed and could not be auto-repaired. */ failures: StartupHealthCheck[]; /** Host system snapshot for diagnostics, error reports, and logging. */ system: SystemInfo; } /** * Unified startup health check for CLI entry points. * * This is the single entry point for startup diagnostics. It follows a * three-phase approach: * * Phase 1: Global scaffold (~/.cleo/) — always auto-repaired. * The global home is CLEO infrastructure, not project data. It is safe * to create/repair unconditionally on every startup. * * Phase 2: Project detection — determines if this is an initialized project. * Uses isProjectInitialized() from paths.ts as the SSoT for detection. * * Phase 3: Project health — lightweight checks on the project scaffold. * If the project is initialized, runs check* functions to detect drift. * Auto-repairs safe items (missing subdirs via ensureCleoStructure). * Flags items requiring full upgrade (missing DB, config issues). * * Design principles: * - SSoT: All checks delegate to scaffold.ts check* functions * - DRY: No duplicated health-check logic * - SRP: This function only diagnoses and does safe auto-repair * - Graceful: Never throws. All errors are captured as check results. * - Logged: Returns structured results for the caller to log via pino * * @param projectRoot - Absolute path to the project root (defaults to cwd) */ export declare function startupHealthCheck(projectRoot?: string): Promise; //# sourceMappingURL=health.d.ts.map