import { type RepositorySource } from "../sources/repository-source.js"; import { type CacheReuse } from "../sources/cache.js"; import type { TrustPolicy } from "../trust/policy.js"; /** Structural shape of the wildcard-subset of a skill dependency, used by the lib resolver. */ export interface WildcardDependencyInput { source: string; ref?: string; path?: string; exclude?: readonly string[]; } export declare class ResolveError extends Error { constructor(message: string); } /** * Thrown when `parseSource` is asked to parse a malformed shorthand specifier * that previously produced a silent partial parse. * * - `empty-sha`: input ends with `@` and nothing after (`owner/repo@`). * - `multi-segment-shorthand`: shorthand has more than two slash-separated * segments (`owner/repo/nested`). GitLab nested groups are unaffected * because they go through `applyDefaultRepositorySource` first. */ export type ParseSourceErrorKind = "empty-sha" | "multi-segment-shorthand"; export declare class ParseSourceError extends Error { readonly kind: ParseSourceErrorKind; constructor(message: string, kind: ParseSourceErrorKind); } export interface ResolvedGitSkill { type: "git"; /** Original source string */ source: string; /** Resolved git clone URL */ resolvedUrl: string; /** Path within the repo to the skill directory */ resolvedPath: string; /** Ref that was resolved */ resolvedRef?: string; /** Full 40-char commit SHA */ commit: string; /** Absolute path to the cached skill directory */ skillDir: string; } export interface ResolvedLocalSkill { type: "local"; source: string; /** Path within the local source root, when discovered from a wildcard. */ resolvedPath?: string; /** Absolute path to the skill directory */ skillDir: string; } export interface ResolvedWellKnownSkill { type: "well-known"; /** Original source string */ source: string; /** Resolved HTTP URL */ resolvedUrl: string; /** Absolute path to the cached skill directory */ skillDir: string; } export type ResolvedSkill = ResolvedGitSkill | ResolvedLocalSkill | ResolvedWellKnownSkill; export declare function isExplicitSourceSpecifier(specifier: string): boolean; /** Strip a leading `@` from npm-style scoped specifiers (e.g. `@owner/repo` → `owner/repo`). */ export declare function stripLeadingAt(specifier: string): string; export declare function parseOwnerRepoShorthand(specifier: string): { owner: string; repo: string; ref?: string; } | undefined; /** * Expand owner/repo shorthand according to defaultRepositorySource. * Returns input unchanged for explicit sources or non-shorthand values. * * When defaultRepositorySource is "gitlab", also handles multi-slash paths * (e.g., `group/subgroup/repo`) since GitLab supports nested groups. */ export declare function applyDefaultRepositorySource(specifier: string, defaultRepositorySource?: RepositorySource): string; /** * Parse a source string into its components. */ export declare function parseSource(source: string): { type: "github" | "git" | "local" | "well-known"; url?: string; /** Original URL to use for cloning (preserves SSH/HTTPS protocol). Undefined for owner/repo shorthand. */ cloneUrl?: string; owner?: string; repo?: string; ref?: string; path?: string; }; /** * Normalize hosted sources to canonical owner/repo form for comparison/dedup. * * Best-effort: malformed inputs that `parseSource` rejects are returned as-is * so dedup and comparison paths don't crash on stale or hand-edited config. * Real install/add paths still call `parseSource` directly and surface the * error to the user. */ export declare function normalizeSource(source: string): string; /** Compare two source strings for equivalence (normalizes hosted URLs to owner/repo). */ export declare function sourcesMatch(a: string, b: string): boolean; /** * Resolve a skill dependency to a concrete directory on disk. */ export interface ResolveOpts { /** Cache root directory. Required — host owns this. */ stateDir: string; projectRoot?: string; defaultRepositorySource?: RepositorySource; /** Extra recursive directories to scan when looking for SKILL.md inside a source. */ scanDirs?: readonly string[]; /** Override cache TTL for well-known sources (pass 0 to force refresh). */ ttlMs?: number; /** When set, resolve to the newest commit at least this many minutes old. */ minimumReleaseAge?: number; /** Sources excluded from the age gate (org or org/repo patterns). */ minimumReleaseAgeExclude?: string[]; /** When provided, validate the source against the policy BEFORE any network access. */ trust?: TrustPolicy; /** Exact git checkout acquired earlier in the current operation. */ reuse?: CacheReuse; } export declare function resolveSkill(skillName: string, dep: { source: string; ref?: string; path?: string; }, opts: ResolveOpts): Promise; export interface NamedResolvedSkill { name: string; resolved: ResolvedSkill; } /** Skill names must be safe for use in file paths. */ export declare const VALID_SKILL_NAME: RegExp; /** * Resolve a wildcard dependency, optionally restricting recursive discovery to * a contained source subdirectory. Excludes are filtered out and skill names * are validated before they are used as install paths. */ export declare function resolveWildcardSkills(dep: WildcardDependencyInput, opts: ResolveOpts): Promise; /** * Check if a source string matches any pattern in the exclude list. * Patterns: "org" matches "org/anything", "org/repo" is exact match, * "org/*" matches "org/anything" (explicit wildcard). */ export declare function isSourceExcluded(source: string, exclude?: string[]): boolean; //# sourceMappingURL=resolver.d.ts.map