// engine/skill-discovery/index.ts — SPEC-606: Universal skill discovery engine
// Barrel export + orchestrator for multi-source, ranked skill search.
export { createDefaultAdapters } from './source-adapter.js';
export { SkillsShAdapter, AnthropicAdapter, GithubAdapter, BuiltinAdapter, AgentSkillsShAdapter, } from './source-adapter.js';
export { rankResults, computeRankScore } from './ranker.js';
export { splitSkillContent } from './progressive-splitter.js';
export { writeSkillForAgents } from './multi-agent-writer.js';
import { createDefaultAdapters } from './source-adapter.js';
import { rankResults } from './ranker.js';
const DEFAULT_LIMIT = 10;
/**
 * Search skills across all (or selected) sources in parallel, then rank results.
 *
 * Steps:
 *  1. Resolve which adapters to use (all by default, or filtered by `sources`).
 *  2. Run all adapters concurrently with `Promise.allSettled` (failures silenced).
 *  3. Merge results, deduplicate by name, rank by composite score.
 *  4. Return top `limit` results.
 *
 * @param query   - Free-text search query.
 * @param options - Optional stack filter, result limit, and source selection.
 */
export async function searchSkillsUniversal(query, options) {
    const adapters = resolveAdapters(createDefaultAdapters(), options?.sources);
    const limit = options?.limit ?? DEFAULT_LIMIT;
    const settled = await Promise.allSettled(adapters.map((adapter) => adapter.search(query, { stack: options?.stack, limit })));
    const allResults = settled.flatMap((outcome) => outcome.status === 'fulfilled' ? outcome.value : []);
    const ranked = rankResults(allResults, options?.stack);
    return ranked.slice(0, limit);
}
/** Filter adapters to only those whose names match the requested sources. */
function resolveAdapters(all, sources) {
    if (!sources || sources.length === 0) {
        return all;
    }
    return all.filter((a) => sources.includes(a.name));
}
//# sourceMappingURL=index.js.map