/** * Skill Registry - Singleton registry and synchronization for agent skills. * * Purpose: * - Maintain one in-memory registry keyed by `skill_id` * - Sync registry entries from discovered SKILL.md files in user/project roots * * Key Features: * - Singleton module-level registry with exported helpers * - Recursive SKILL.md discovery with deterministic ordering * - Hash-based update checks using full SKILL.md content * - Automatic initial sync on module load so core starts with up-to-date skills * - Automatic pruning of entries whose files no longer exist * * Implementation Notes: * - `skill_id` is sourced from front-matter `name` * - `description` is sourced from front-matter `description` * - `hash` is computed from full SKILL.md content (front matter + body) * - Project roots are scanned after user roots, so later collisions always override earlier ones * * Recent Changes: * - 2026-02-28: Added symlink-aware skill discovery so SKILL.md files inside symlinked directories are indexed. * - 2026-02-27: Made collision precedence explicit in candidate resolution so project-scope definitions always win over global-scope definitions even if discovery order changes. * - 2026-02-16: Default project-skill roots now resolve from active workspace env (`AGENT_WORLD_PROJECT_PATH`/`AGENT_WORLD_WORKSPACE_PATH`) before falling back to process cwd. * - 2026-02-16: Added source-scope filtering helper so callers can include/exclude global or project skills when building system prompts. * - 2026-02-14: Added `getSkillSourcePath` API and source-path tracking map for on-demand `SKILL.md` loading. * - 2026-02-14: Added `~/.codex/skills` to default user skill roots for Codex-managed skills discovery. * - 2026-02-14: Removed timestamp-gated update blocking so project-scope collisions always override user-scope entries when hashes differ. * - 2026-02-14: Fixed skill collision precedence so project-root skills override user-root skills for the same `skill_id`. * - 2026-02-14: Added `waitForInitialSkillSync` and startup sync tracking promise for deterministic core-load sync completion. * - 2026-02-14: Added module-load auto-sync so each core load refreshes the skill registry. * - 2026-02-14: Switched skill hash generation to use full SKILL.md content instead of metadata-only fields. * - 2026-02-14: Switched registry metadata source to SKILL.md front matter (`name` + `description`). * - 2026-02-14: Use front-matter `name` as canonical `skill_id`. */ export interface SkillRegistryEntry { skill_id: string; description: string; hash: string; lastUpdated: string; } export type SkillSourceScope = 'global' | 'project'; export interface SyncSkillsOptions { userSkillRoots?: string[]; projectSkillRoots?: string[]; } export interface SyncSkillsResult { added: number; updated: number; removed: number; unchanged: number; total: number; } export interface SkillScopeFilterOptions { includeGlobal?: boolean; includeProject?: boolean; userSkillRoots?: string[]; projectSkillRoots?: string[]; } export declare const skillRegistry: { syncSkills: (options?: SyncSkillsOptions) => Promise; getSkills: () => SkillRegistryEntry[]; getSkill: (skillId: string) => SkillRegistryEntry | undefined; getSkillSourcePath: (skillId: string) => string | undefined; getSkillSourceScope: (skillId: string) => SkillSourceScope | undefined; getSkillsForSystemPrompt: (options?: SkillScopeFilterOptions) => SkillRegistryEntry[]; clearSkillsForTests: () => void; }; export declare const syncSkills: (options?: SyncSkillsOptions) => Promise; export declare const getSkills: () => SkillRegistryEntry[]; export declare const getSkill: (skillId: string) => SkillRegistryEntry | undefined; export declare const getSkillSourcePath: (skillId: string) => string | undefined; export declare const getSkillSourceScope: (skillId: string) => SkillSourceScope | undefined; export declare const getSkillsForSystemPrompt: (options?: SkillScopeFilterOptions) => SkillRegistryEntry[]; export declare const clearSkillsForTests: () => void; export declare function waitForInitialSkillSync(): Promise;