/** * Source bundle location and integrity checking (spec 03, REQ-OPS-06, D7). * * Resolves the read-only adapter bundle for an agent from one of three locations (explicit * `--source`, the packaged copy, or the in-repo `../adapters/`), runs the minimal integrity * check, and fingerprints it (sourceHash + skills + files). Fallible operations return * `Result` and never throw for expected errors. Zero runtime dependencies. */ import { type AgentId, type Result } from "./types.js"; /** Options for bundle resolution. */ export interface LocateBundleOpts { /** * Hidden test hook (`--source `, D7). When set, the bundle is resolved as * `/` and the packaged / in-repo locations are NOT consulted. */ source?: string; } /** * Aggregate of a located, integrity-checked, fingerprinted bundle (spec 03 §3.7). */ export interface LocatedSource { /** Absolute path to the agent bundle root (e.g. `.../adapters/claude`). */ readonly root: string; /** sha256 over the bundle's sorted-path file set — the drift anchor (`manifest.sourceHash`). */ readonly sourceHash: string; /** Installed skill ids (the bundle's `skills/*` dir names) for `manifest.skills`. */ readonly skills: readonly string[]; /** Per-file inventory (`{ relpath, sha256 }`, sorted by POSIX relpath) — the planner's input. */ readonly files: ReadonlyArray<{ readonly relpath: string; readonly sha256: string; }>; } /** * Locate the read-only adapter bundle directory for `agent` (D7, REQ-OPS-06). * * Resolution order (first existing directory wins): `opts.source/`, then * `/adapters/`, then `/adapters/` (both derived from * `import.meta.url`, cwd-independent). * * @returns ok(absolutePath) when a candidate dir exists; err(SOURCE_MISSING) naming the expected * path + remedy otherwise. */ export declare function locateBundle(agent: AgentId, opts?: LocateBundleOpts): Result; /** * Minimal integrity check for a located bundle (REQ-OPS-06). Valid iff the `BUNDLE_REQUIRED_PATHS` * are present: `skills/` is a non-empty dir, the neutral `.feature-forge-bundle.json` sentinel and * every bundled runtime helper (`forge-root.sh`, `forge-init.sh`, `epic-manifest.py`, * `validate-traceability.py`, `forge-bootstrap.py`) exist, and (gemini) `gemini-extension.json` * exists. Keys on the neutral sentinel, NOT the Claude-only `.claude-plugin/plugin.json`. * * @returns ok(undefined) when every required path is present; err(SOURCE_INVALID) naming the * first missing/invalid required path otherwise. */ export declare function checkIntegrity(bundlePath: string, agent: AgentId): Result; /** * List the skill ids a bundle contains: the directory names directly under * `/skills/` (REQ-SCALE-02). Enumerates DIRECTORY NAMES ONLY and never opens a skill * file. Returned sorted (byte-wise). */ export declare function listBundleSkills(bundlePath: string): string[]; /** * Locate, integrity-check, and fingerprint one agent's bundle in a single call (spec 03 §3.7). * * @returns ok(LocatedSource) when the bundle exists and passes the integrity check; otherwise the * exact err(SOURCE_MISSING) / err(SOURCE_INVALID) from locateBundle/checkIntegrity. */ export declare function locateSource(agent: AgentId, opts?: { source?: string; }): Result;