/** * Post-session audit: analyze what an agent changed vs. what specs expected. * * Compares the git diff (files changed since a base ref) against the spec * surface area (keyFiles, commands, tracked inputs). Reports: * - Files modified that aren't in any spec's keyFiles * - Specs whose inputs changed (may need recompile) * * Read-only analysis. No commands executed, no files modified. */ import type { SidecarManifest } from "./sidecar.js"; /** * Get files changed since a base ref (commit, branch, or HEAD~N). * Returns paths relative to the repo root. * * Uses execFileSync with an argv array — `baseRef` is passed as a separate * argument so shell metacharacters can't escape into command execution. * `--no-renames` keeps both source and destination paths visible (without it, * `git mv old.ts new.ts` would only report `new.ts`). * * Throws on git failure (e.g., invalid baseRef) so a typo doesn't silently * masquerade as "no changes" and suppress real findings downstream. */ export declare function gitChangedFiles(basePath: string, baseRef: string): string[]; /** * Get the most recent commit hash. Returns null if not a git repo. */ export declare function gitHead(basePath: string): string | null; /** * Find a reasonable base ref for session analysis. * * Strategy: * 1. If `--base` is provided, use it directly. * 2. If sidecar manifests exist, use the most recent compiledAt commit. * 3. Fall back to HEAD (shows only uncommitted changes). */ export declare function resolveBaseRef(explicitBase?: string): string; /** Aggregated surface area from all specs via sidecar manifests. */ export interface SpecSurface { /** All files declared in any spec's keyFiles. */ keyFiles: Set; /** All files tracked as inputs to any spec. */ trackedInputs: Set; /** All spec source files. */ specFiles: Set; /** All compiled targets. */ targets: Set; /** Map: file → which spec targets track it. */ fileToSpecs: Map; /** Loaded manifests. */ manifests: SidecarManifest[]; } /** * Load all sidecar manifests and build the aggregate spec surface area. */ export declare function loadSpecSurface(basePath: string): SpecSurface; /** * Load keyFiles from compiled markdown files. Reads each target's * "## Key Files" section and extracts the file paths. * * @deprecated Goes away together with the deprecated `keyFiles` spec field (see * the `deprecated-key-files` rule), in the major after the one that deprecates * it. It reads the field back out of COMPILED markdown with a regex rather than * from the spec, and it is deliberately not ported in the release that * deprecates the field: with the field gone, the session audit's "files the * specs know about" is `surface.trackedInputs` (the sidecar manifests) alone. */ export declare function loadKeyFilesFromSpecs(basePath: string): Set; /** A finding about a file not tracked by any spec. */ interface UntrackedFinding { type: "untracked-file"; file: string; message: string; } /** A finding about a file tracked by one or more specs. */ interface TrackedFinding { type: "stale-spec" | "spec-modified" | "target-modified"; file: string; message: string; specs: string[]; } /** A single finding from session analysis. */ export type SessionFinding = UntrackedFinding | TrackedFinding; /** Full session analysis result. */ export interface SessionReport { /** Git base ref used for comparison. */ baseRef: string; /** All files changed since baseRef. */ changedFiles: string[]; /** Files changed that are tracked by at least one spec. */ trackedChanges: string[]; /** Files changed that are NOT tracked by any spec. */ untrackedChanges: string[]; /** Individual findings. */ findings: SessionFinding[]; } /** * Analyze a session: compare changed files against spec surface area. */ export declare function analyzeSession(basePath: string, baseRef: string): SessionReport; /** Format a session report as human-readable text. */ export declare function formatSessionReport(report: SessionReport): string; export {}; //# sourceMappingURL=session.d.ts.map