/** * Skill Registry — in-memory store and search for skills * * Mirrors ToolRegistry but for skills. Provides discovery, search, and filtering. * Supports both substring matching (default) and semantic search via pluggable embeddings. */ import { SkillDefinition, SkillSummary, SearchSkillsOptions, EmbeddingProvider, SkillContentOptions } from './types.js'; /** * Semantic search result with relevance score. */ export interface SemanticSearchResult { skill: SkillSummary; /** Cosine similarity score (0–1, higher = more relevant) */ score: number; } export declare class SkillRegistry { private logger; private skills; /** Pluggable embedding provider for semantic search */ private embeddingProvider; /** Cached embeddings: skill name → vector */ private embeddings; /** Whether embeddings need rebuilding */ private embeddingsDirty; /** Cached parsed content for selective loading */ private parsedContent; /** * Set a custom embedding provider (OpenAI, Cohere, etc.). * If not set, a built-in TF-IDF provider is used as fallback. */ setEmbeddingProvider(provider: EmbeddingProvider): void; /** * Register a single skill */ register(skill: SkillDefinition): void; /** * Register multiple skills */ registerAll(skills: SkillDefinition[]): void; /** * Get a single skill by name */ get(name: string): SkillDefinition | undefined; /** * Get a single skill by name (throws if not found) */ getRequired(name: string): SkillDefinition; /** * Get selective skill content — only the sections an agent needs. * This prevents dumping entire SKILL.md files into the LLM context. * * @example * // Get only the error handling section, max 500 tokens * registry.getSkillContent('postgres-query-operations', { * sections: ['Error Handling'], * maxTokens: 500, * }) */ getSkillContent(name: string, options?: SkillContentOptions): string | null; /** * List all sections of a skill with their token costs. * Agents use this to decide which sections to load. */ getSkillSections(name: string): Array<{ path: string; level: number; tokenEstimate: number; }> | null; /** * List all skills (Level 1 discovery — minimal context) */ list(): SkillSummary[]; /** * Search skills by keyword, category, difficulty, etc. * * When `options.semantic` is true, uses embedding-based similarity ranking * instead of substring matching. Falls back to built-in TF-IDF if no * external embedding provider is configured. */ search(options?: SearchSkillsOptions): SkillSummary[]; /** * Semantic search with relevance scores. * Returns ranked results with cosine similarity scores. * * @example * const results = await registry.semanticSearch('How do I handle Postgres connection pooling?'); * // → [{ skill: { name: 'postgres-query-operations', ... }, score: 0.82 }] */ semanticSearch(query: string, options?: { limit?: number; minScore?: number; }): Promise; /** * Get all skills (full definitions) */ getAll(): SkillDefinition[]; /** * Check if a skill exists */ has(name: string): boolean; /** * Get the count of registered skills */ count(): number; /** * Clear all skills */ clear(): void; /** * Remove a skill */ remove(name: string): boolean; /** * Ensure embeddings are computed and up-to-date. */ private ensureEmbeddings; /** * Synchronous ranking using TF-IDF (for the non-async search() method). */ private rankBySimilarity; /** * Get or create the default TF-IDF provider. */ private defaultProvider; private getDefaultProvider; /** * Convert a skill into a searchable text string for embedding. */ private skillToText; } //# sourceMappingURL=skill-registry.d.ts.map