/** * SkillRegistry: manages all known skills for the Cortex agent. * * Config-driven: the consumer provides paths to SKILL.md files from any * source (plugins, user directories, built-ins). The registry does not * scan directories. * * Skills are parsed at registration time (frontmatter extracted, body * deferred to load time). The registry produces a compact summary for * the load_skill tool description. * * References: * - docs/cortex/skill-system.md * - docs/cortex/plans/phase-4-sub-agents-and-skills.md */ import type { SkillConfig, SkillEntry } from './types.js'; /** * Parse YAML frontmatter from a SKILL.md file. * Expects --- delimited frontmatter at the start of the file. * * This is a lightweight parser that handles the common SKILL.md patterns * without requiring a full YAML library. It handles: * - Simple key: value pairs * - Multi-line strings (using > or |) * - Nested metadata maps * - Space-delimited lists (for allowed-tools) */ declare function parseFrontmatter(content: string): { frontmatter: Record; body: string; }; export declare class SkillRegistry { private readonly entries; /** Consumer-provided variables for ${VAR} substitution. */ private preprocessorVariables; /** Consumer-provided context for !{script:} executions. */ private scriptContext; /** * Callback fired when skills are added or removed. * CortexAgent sets this to rebuild the load_skill tool description. */ onChange: (() => void) | null; constructor(configs?: SkillConfig[]); /** * Add a skill from a SKILL.md file path. * Reads and parses the frontmatter synchronously at registration time. * * If a skill with the same name already exists, the new one replaces it * (last-registered wins). */ addSkill(config: SkillConfig): void; /** * Remove a skill by name. */ removeSkill(name: string): void; /** * Get a skill entry by name. */ getEntry(name: string): SkillEntry | null; /** * Get all registered skill entries. */ getAll(): SkillEntry[]; /** * Get the number of registered skills. */ get size(): number; /** * Generate the available skills summary for the load_skill tool description. * * Skills with disable-model-invocation: true (modelInvocable: false) are * excluded from the summary. The agent cannot see or auto-load them. * * Format: XML listing with name, source, and description per skill. * Each skill consumes approximately 100 tokens. */ getAvailableSkillsSummary(maxTokens?: number): string; /** * Read and preprocess a skill's full body content. * Runs variable substitution, shell commands, and scripts. * * @param name - The skill name * @param callArgs - Arguments from the load_skill tool call * @returns The preprocessed skill body * @throws Error if the skill is not found */ getSkillBody(name: string, callArgs: { args: string[]; rawArgs: string; }): Promise; /** * Set consumer-provided variables for ${VAR} substitution. * Called each tick during GATHER to update runtime values. */ setPreprocessorVariables(variables: Record): void; /** * Set consumer-provided context for !{script:} executions. * Called each tick during GATHER to update runtime values. */ setScriptContext(context: Record): void; /** * Clear all entries. Called during destroy. */ clear(): void; } export { parseFrontmatter }; //# sourceMappingURL=skill-registry.d.ts.map