import { type SkillPresence } from '../skills/skill-presence-service.js'; export type DoctorCheck = { id: string; ok: boolean; message: string; }; export type DoctorReport = { checks: DoctorCheck[]; summary: { ok: boolean; passed: number; failed: number; }; }; export type CodegraphCapabilityProbe = { packagePath: string; version: string; binaryPath: string; binaryExists: boolean; }; export type DistVersionComparison = { dist: string | null; source: string; match: boolean; distReadable: boolean; }; export type DistVersionProbe = () => DistVersionComparison; export type WorkspaceLayoutInspection = { topLevelSessionDirs: string[]; legacyDotfiles: string[]; /** * Slice 007 — per-change-id top-level dirs (e.g. `.peaks/001-2026-06-06-.../`). * The pre-F3 canonical layout put reviewable artifacts under a * per-change-id top-level dir; the post-F3 canonical layout * consolidates them under `.peaks/_runtime///`. Any * leftover per-change-id top-level dir is a regression to flag. * Slice 008's migration will consolidate these; until then, the * check reports them as `ok: false`. * * Optional in the type for back-compat with test probes that * pre-date the slice 007 broadening; the check itself falls back * to an empty array when the field is missing. */ perChangeIdDirs?: string[]; }; export type WorkspaceLayoutProbe = () => WorkspaceLayoutInspection; /** * 2026-06-10 — `gateguard-fact-force` (a third-party PreToolUse hook, * NOT peaks-cli) fires on Edit / Write and demands a 4-fact questionnaire * before allowing the edit. When the LLM is in a peaks-qa flow and tries * to update `.peaks/_runtime//qa/requests/*.md` via the Edit/Write * tool, the hook demands facts that are inapplicable to QA envelope * templates (no importers, no public API, no data files, user * instruction already in the conversation context). The check detects * this hook in the user's global and project `.claude/settings.json` and * warns when no `.peaks/**` skip is configured. The probe is injected so * tests do not depend on the real `~/.claude/settings.json` state. */ export type GateguardHookLocation = { /** Source file the hook was discovered in (`global` or `project .claude/settings.json`). */ source: 'global' | 'project'; /** Resolved absolute path to the source file (for the message). */ sourcePath: string; /** The PreToolUse entry that contains a gateguard hook command. */ entry: { matcher?: string; hooks: ReadonlyArray<{ type?: string; command?: string; }>; }; }; export type GateguardProbeResult = { /** Absolute path to `~/.claude/settings.json` (or null when the probe could not resolve it). */ globalSettingsPath: string | null; /** Parsed global settings payload (or null when missing / unreadable / malformed). */ globalSettings: unknown; /** Absolute path to the project `.claude/settings.json` (or null when the project root is not in a peaks project). */ projectSettingsPath: string | null; /** Parsed project settings payload (or null when missing / unreadable / malformed). */ projectSettings: unknown; }; export type GateguardProbe = () => GateguardProbeResult; export type DoctorOptions = { schemasBaseDir?: string; skillsBaseDir?: string; codegraphProbe?: () => CodegraphCapabilityProbe; skillPresenceProbe?: () => SkillPresence | null; skillPresenceFreshnessThresholdMs?: number; statusLineInstalledProbe?: () => boolean; /** Returns true when a Peaks workspace session (.peaks/.session.json) exists. */ workspaceInitializedProbe?: () => boolean; /** Platform string (defaults to process.platform); injectable for tests. */ platform?: NodeJS.Platform; /** Injected for the build:dist-version-matches-source check (defaults to compareDistVersion on disk). */ distVersionProbe?: DistVersionProbe; /** Injected for the build:workspace-layout-canonical check (defaults to inspectWorkspaceLayout on disk). */ workspaceLayoutProbe?: WorkspaceLayoutProbe; /** Injected for the integration:gateguard-peaks-conflict check (defaults to defaultGateguardProbe on disk). */ gateguardProbe?: GateguardProbe; /** * Slice 2026-06-13-repair-pre-existing-test-failures: injected * root for the L3:l3-memory-health check (defaults to * `findProjectRoot(process.cwd())`). Tests use this to point the * check at a temp dir without monkey-patching `findProjectRoot`. */ l3ProjectRoot?: string; }; /** * Pure helper extracted from `defaultWorkspaceInitializedProbe` so tests can * drive the filesystem check without monkey-patching `process.cwd()` or * `findProjectRoot`. Returns `true` when EITHER the canonical * `.peaks/_runtime/session.json` OR the legacy `.peaks/.session.json` exists. */ export declare function isWorkspaceInitializedAt(projectRoot: string): boolean; /** * Pure helper that compares the published dist `CLI_VERSION` against the * source-of-truth `package.json#version`. Default readers fail-soft to `null` * on missing/unreadable/malformed input. Exported so tests can drive the * filesystem reads without monkey-patching `process.cwd()`. */ export declare function compareDistVersion(opts: { projectRoot: string; distVersionReader?: (root: string) => string | null; sourceVersionReader?: (root: string) => string | null; }): DistVersionComparison; /** * Pure helper that inspects the on-disk workspace layout for * post-F3-canonical violations. The post-F3 canonical layout puts * session dirs under `.peaks/_runtime//` and the runtime * binding at `.peaks/_runtime/session.json`; the legacy paths * (top-level `>/` dirs and the legacy * top-level `.peaks/.session.json` / `.peaks/.active-skill.json` * dotfiles) must be absent. This helper is exported so tests can * drive the filesystem walk without monkey-patching `process.cwd()` * or `findProjectRoot`. * * Both scanners fail-soft (return `[]` on read errors) so a flaky * filesystem read on a non-fatal probe path never escalates into a * doctor failure. */ export declare function inspectWorkspaceLayout(opts: { projectRoot: string; topLevelScanner?: (root: string) => string[]; dotfileScanner?: (root: string) => string[]; perChangeIdScanner?: (root: string) => string[]; }): WorkspaceLayoutInspection; export declare function collectGateguardEntries(probe: GateguardProbeResult): GateguardHookLocation[]; export declare function runDoctor(options?: DoctorOptions): Promise;