/** * Artifact discovery — shared scanner used by artifact_list and * artifact_read. The point of this module is to make artifacts into a * working surface instead of one-shot files on disk: * * - Canonical identity is (pack, slug). Paths are secondary. * - Listing is metadata-only. Full payloads live in read. * - Slug collisions within a pack fail loud rather than guess. * - extra_artifact_dirs are read-only SEARCH surfaces; they don't * change the identity rules. * - {json_path} reads are path-safety-guarded — must normalize * absolute, must end in .json, must live under a recognized dir. */ import type { IncidentPackArtifact } from "../packs/incidentPack.js"; import type { RepoPackArtifact } from "../packs/repoPack.js"; import type { ChangePackArtifact } from "../packs/changePack.js"; export type PackName = "incident_pack" | "repo_pack" | "change_pack"; export declare const KNOWN_PACKS: readonly PackName[]; export type PackArtifact = IncidentPackArtifact | RepoPackArtifact | ChangePackArtifact; /** Compact metadata — what artifact_list returns per artifact. */ export interface ArtifactMetadata { pack: PackName; slug: string; title: string; created_at: string; weak: boolean; corpus_used: { name: string; chunks_used: number; } | null; evidence_count: number; /** Pack-specific section item counts. Keys depend on pack; never flattened. */ section_counts: Record; md_path: string; json_path: string; } export interface ScanOptions { /** Extra directories to search in addition to the canonical set. Read-only — identity stays (pack, slug). */ extra_artifact_dirs?: string[]; } /** Base artifact dir: INTERN_ARTIFACT_DIR if set, else ~/.ollama-intern/artifacts/. */ export declare function artifactRoot(): string; /** Per-pack subdirs under the canonical root. */ export declare function canonicalPackDirs(): Record; /** * Assert that an absolute path lives under one of the allowed artifact * dirs. Used by artifact_read for the secondary {json_path} entry point * to keep the tool from drifting into a generic file reader. */ export declare function assertPathUnderAllowedDir(absPath: string, extraDirs?: string[]): void; /** * Extract metadata from a parsed artifact JSON. Returns null when the * shape doesn't match a known pack artifact — the scanner skips such * files silently rather than crashing on an unrelated .json file that * happens to sit in an artifact dir. */ export declare function metadataFromArtifact(obj: unknown, jsonPath: string): ArtifactMetadata | null; export interface ScanResult { /** Every artifact metadata discovered (including collision duplicates — callers decide how to handle). */ all: ArtifactMetadata[]; /** (pack, slug) pairs that appear in more than one location. */ duplicates: Array<{ pack: PackName; slug: string; paths: string[]; }>; } /** * Walk the canonical pack dirs + any extras, extract metadata from * every .json file that matches the known-pack shape, and flag slug * collisions. Files that don't match a known pack shape are skipped * silently — artifact dirs may legitimately contain unrelated JSON. */ export declare function scanAllArtifacts(opts?: ScanOptions): Promise; /** * Look up a single artifact by (pack, slug). Fails loud on collision * so callers never unknowingly pick one of several candidates. */ export declare function resolveArtifactByIdentity(pack: PackName, slug: string, opts?: ScanOptions): Promise; /** * Read the full artifact JSON at a validated path. * Path must be absolute, must end in .json, and must live under a * recognized artifact dir (canonical roots + extras). */ export declare function readArtifactAtPath(absPath: string, opts?: ScanOptions): Promise; //# sourceMappingURL=scan.d.ts.map