/** * @file Detect which AI agent CLIs are installed on PATH. Strategy: * which()-based lookup with a two-tier cache: * * 1. In-process Map — survives until the Node process exits. * 2. On-disk JSON at `/.cache/repo/agent-discovery.json`, TTL 1h — * survives across subprocess invocations like per-file ai-lint-fix batches * without re-running which(). Cache invalidation: stale on-disk cache is * detected by mtime comparison; missing or expired → fresh which() pass + * rewrite. Why two tiers: hooks and skills spawn dozens of short-lived * Node processes per session. In-process alone misses the cross-process * speedup; on-disk alone hits the filesystem on every call. The * combination keeps repeated lookups under a millisecond after the * cold-start cost. */ import type { DiscoveredAgents } from './types.js'; export interface OnDiskCache { readonly agents: DiscoveredAgents; readonly writtenAt: number; } export declare function cachePathFor(repoRoot: string): string; /** * Discover which AI agent CLIs are installed. * * @param options.repoRoot - Where to read/write the on-disk cache. Defaults to * process.cwd(). Skill runners typically pass the target repo's root. * @param options.refresh - When true, bypass both caches and re-run which(). * Useful after `npm i -g ` mid-session. * * Returns a map of agent → absolute binary path. Agents that aren't installed * are absent from the map rather than present-with-undefined, so callers can * use `'claude' in agents` for the existence check. */ export declare function discoverAiAgents(options?: { readonly refresh?: boolean | undefined; readonly repoRoot?: string | undefined; }): Promise; export declare function discoverFresh(): DiscoveredAgents; /** * Synchronous in-process lookup. Skips disk cache + which(). Returns undefined * if discoverAiAgents() hasn't been called yet in this process, OR returns the * most recent discovery result. * * Useful in fast paths where the caller has already populated the cache and * just wants to read it back. * * @unused No internal or Socket consumers; exercised only by its unit tests. */ export declare function getDiscoveredAiAgents(): DiscoveredAgents | undefined; export declare function readDiskCache(cachePath: string): DiscoveredAgents | undefined; /** * Reset the in-process cache. Tests use this; production callers shouldn't need * it (use `refresh: true` on discoverAiAgents()). * * @unused No internal or Socket consumers; exercised only by its unit tests. */ export declare function resetAiAgentDiscoveryCache(): void; export declare function writeDiskCache(cachePath: string, agents: DiscoveredAgents): Promise;