export declare class CacheError extends Error { constructor(message: string); } /** * Derive a safe relative cache-key from a clone URL. * * Strips schemes, leading slashes (so `file:///abs/path` and `/abs/path` * both land under `/abs/path/`), and `.git` suffixes. Drops `.` * and `..` segments to keep the result inside the cache root. * * Callers that build a cacheKey from a hosted owner/repo (e.g. GitHub) can * skip this and use the parsed values directly. */ export declare function sanitizeCacheKey(url: string): string; /** * Reject `cacheKey` values that would let `path.join(stateDir, cacheKey)` * resolve outside `stateDir`. * * The cacheKey is derived from URL paths or owner/repo strings, which can * contain `..` if a caller pipes through a malicious source spec. Without * this guard, a cacheKey like `evil.com/../../etc` would let `git clone` * write into arbitrary filesystem locations. */ export declare function validateCacheKey(cacheKey: string): void; export interface CacheResult { /** Path to the cached repo checkout */ repoDir: string; /** Resolved commit SHA */ commit: string; } /** Exact checkout state acquired earlier in the current operation. */ export interface CacheReuse { repoDir: string; ref?: string; commit: string; } /** * Get or populate the global cache for a git source. * * Always fetches the latest from the remote when a cached clone exists. * A shallow `git fetch --depth=1` is essentially free when already at * the latest commit, so there is no TTL — callers always get fresh state. * * The caller MUST supply the cache root directory (`stateDir`); the lib * does not impose a default. Hosts typically resolve this from their own * convention (e.g. `~/.local//`) plus an optional env var override. * * Cache layout: `//` -- shallow clone */ export declare function ensureCached(opts: { /** Cache root directory. Required — host owns this. */ stateDir: string; url: string; /** Cache key, e.g. "anthropics/skills" or "git.corp.example.com/team/skills" */ cacheKey: string; ref?: string; /** When set, resolve to the newest commit at least this many minutes old. */ minimumReleaseAge?: number; /** Restore an exact checkout acquired earlier instead of fetching it again. */ reuse?: CacheReuse; }): Promise; //# sourceMappingURL=cache.d.ts.map