/** * Cache command — local cache inspection and clearing * (Cache Module Unification Ticket 03). * * The command is presentation-only: it receives already-resolved stats * or clear results through injected dependencies and wraps them with a * TTY presentation override. Directory resolution, env-var policy, and * on-disk I/O live in `src/lib/cache.ts` (Ticket 01). The dispatcher * (`src/index.ts`) wires production to the real `cacheStats()` and * `clearAllCaches()` and threads them through these dependencies; tests * inject doubles. * * Output format (core-flows artifact): * * ```text * Cache directory: ~/.scoutline/ * Status: enabled (TTL 24h, cap 100MB) * * Response cache: * Entries: 47 * Size: 12.3 MB * * Tool cache: * Entries: 1 * Size: 8.2 KB * ``` * * L1 fix: Doctor's one-line cache summary is computed from the same * `cacheStats()` shape but formatted by the dispatcher, not by this * module. See `formatDoctorCacheSummary`. */ import type { CommandResult } from "../command-invocation.js"; export interface CacheStatsReport { readonly dir: string; readonly enabled: boolean; readonly ttlMs: number; readonly sizeCapBytes: number; readonly responseCache: { readonly entries: number; readonly totalBytes: number; }; readonly toolCache: { readonly entries: number; readonly totalBytes: number; }; } export interface CacheClearReport { readonly responsesCleared: number; readonly toolsCleared: number; readonly bytesFreed: number; } /** * Mirror of {@link PruneCachesResult} in `src/lib/cache.ts`. Counts * reflect actual deletions performed during the prune run. */ export interface CachePruneReport { readonly prunedResponses: number; readonly prunedTools: number; readonly bytesFreed: number; } /** * Selectors narrowing a prune run. All optional and AND together; * mirrors {@link PruneSelectors} from `src/lib/cache.ts` (DESIGN D2/D3). * The dispatcher parses `--older-than`/`--provider`/`--capability` into * this shape and passes it to the production `pruneCaches`. */ export interface CachePruneSelectors { readonly olderThanMs?: number; readonly provider?: string; readonly capability?: string; } /** * Format a byte count as e.g. `"12.3 MB"`, `"8.2 KB"`, `"510 B"`. Used * by `cache stats` presentation and by Doctor's one-line summary. Pure: * no I/O, no env reads. */ export declare function formatBytes(bytes: number): string; /** * Format a TTL in ms as `"24h"`, `"30m"`, or `"60s"`. Chooses the * largest whole-unit that divides the input evenly so the default * 24h renders as `24h` rather than `86400000ms`. */ export declare function formatTtl(ms: number): string; /** * Format the inventory of both caches as a multi-line TTY block per * the core-flows artifact. Used as the TTY/compact/markdown/refs * presentation for `cache stats`. Pure. */ export declare function formatCacheStats(stats: CacheStatsReport): string; /** * Format a clear result as a one-line TTY notice. */ export declare function formatCacheClear(result: CacheClearReport): string; /** * Format a prune result as a one-line TTY notice. Same voice as * {@link formatCacheClear} (cleared vs pruned is the only swap). */ export declare function formatCachePrune(result: CachePruneReport): string; /** * Format the one-line Doctor cache summary from a `cacheStats()` value. * The dispatcher calls this before invoking `buildDiagnosticsReport`; * the report builder embeds the result verbatim. Examples: * * ```text * Cache: enabled, 47 response entries (12.3 MB), 1 tool entry (8.2 KB), ~/.scoutline/ * Cache: disabled * ``` * * Pure: never reads env or touches the filesystem. */ export declare function formatDoctorCacheSummary(stats: CacheStatsReport): string; export interface CacheStatsDependencies { readonly getStats: () => Promise; } export interface CacheClearDependencies { readonly clear: () => Promise; } export interface CachePruneDependencies { readonly prune: (selectors: CachePruneSelectors) => Promise; } /** * Run the `cache stats` subcommand. Returns the inventory as base data * with a TTY presentation override. Exit code is always 0 on success; * I/O failures propagate as ordinary errors through the dispatcher. */ export declare function cacheStatsCommand(deps: CacheStatsDependencies): Promise>; /** * Run the `cache clear` subcommand. Returns the count of cleared * entries and bytes freed as base data with a TTY presentation * override. */ export declare function cacheClearCommand(deps: CacheClearDependencies): Promise>; /** * Run the `cache prune` subcommand. Returns the count of pruned * entries and bytes freed as base data with a TTY presentation * override. Selectors are passed through to `deps.prune` verbatim * (the dispatcher parses `--older-than`/`--provider`/`--capability` * into this shape). Lock-timeout errors propagate so the * dispatcher's error boundary emits the sanitized stderr envelope * (DESIGN D5). */ export declare function cachePruneCommand(deps: CachePruneDependencies, selectors: CachePruneSelectors): Promise>; export declare const CACHE_HELP: string; //# sourceMappingURL=cache.d.ts.map