UNPKG

aiwg

Version:

Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo

106 lines 3.2 kB
/** * Extension Registry Loader * * Populates the ExtensionRegistry with command definitions and builds * capability indexes for fast lookup. * * @implements @.aiwg/requirements/use-cases/UC-004-extension-system.md * @architecture @.aiwg/architecture/unified-extension-schema.md * @tests @test/unit/extensions/loader.test.ts */ import { ExtensionRegistry } from './registry.js'; import { CapabilityIndex } from './capability-index.js'; import type { CommandHandler } from '../cli/handlers/types.js'; /** * Loader options */ export interface LoaderOptions { /** * Use existing registry or create new * * If not provided, a new registry instance is created. */ registry?: ExtensionRegistry; /** * Include capability indexing * * @default false */ indexCapabilities?: boolean; } /** * Loaded registry result */ export interface LoadedRegistry { /** Extension registry with all definitions */ registry: ExtensionRegistry; /** Capability index (if indexCapabilities = true) */ capabilityIndex?: CapabilityIndex; /** Handler map for O(1) handler lookup */ handlerMap: Map<string, CommandHandler>; } /** * Load and populate the registry * * Loads command definitions, registers them with the registry, builds alias * map, optionally builds capability index, and links handlers to definitions. * * @param options - Loader options * @returns Loaded registry with handler map * * @example * ```typescript * // Load with capability indexing * const result = await loadRegistry({ indexCapabilities: true }); * * // Resolve command alias * const id = result.registry.resolveCommand('--help'); // 'help' * * // Get extension definition * const ext = result.registry.get(id); * * // Get handler * const handler = result.handlerMap.get(id); * * // Query by capability * const cliCommands = result.capabilityIndex?.getByCapability('cli'); * ``` */ export declare function loadRegistry(options?: LoaderOptions): Promise<LoadedRegistry>; /** * Get the loaded global registry * * Convenience function for CLI - uses the global singleton registry. * This is useful when you want the same registry instance across calls. * * @returns Loaded registry with handler map * * @example * ```typescript * // Get global registry * const result = await getLoadedRegistry(); * * // Later, in another module * const sameResult = await getLoadedRegistry(); * // result.registry === sameResult.registry (same instance) * ``` */ export declare function getLoadedRegistry(): Promise<LoadedRegistry>; /** * Link handlers to command definitions * * Creates a map from handler ID to handler instance for O(1) lookup. * This allows routing from extension definition to handler implementation. * * @param handlers - Array of command handlers * @returns Map of handler ID -> handler * * @example * ```typescript * const handlerMap = linkHandlers(allHandlers); * const helpHandler = handlerMap.get('help'); * await helpHandler.execute(ctx); * ``` */ export declare function linkHandlers(handlers: readonly CommandHandler[]): Map<string, CommandHandler>; //# sourceMappingURL=loader.d.ts.map