/** * Grammar Manager * * Manages tree-sitter grammar installation and loading. * Uses Bun for dynamic package installation on first use. * * This is an infrastructure component that handles: * - Grammar package installation via Bun * - Grammar caching in memory * - Thread-safe concurrent installation handling */ import type { IGrammarManager, GrammarStatus, ParserLanguage } from "../../domain/ports/parser"; import type { Logger } from "../../domain/ports/logger"; /** * Singleton Grammar Manager for tree-sitter grammars. * * Handles: * - Checking if grammars are installed * - Installing grammars via Bun on demand * - Caching loaded grammars * - Thread-safe concurrent installation */ export declare class GrammarManager implements IGrammarManager { private static instance; /** Cache of loaded grammars */ private grammarCache; /** Track installation status */ private installationStatus; /** Track pending installations to prevent duplicate installs */ private pendingInstalls; /** Optional logger for progress reporting */ private logger?; private constructor(); /** * Get the singleton instance. */ static getInstance(): GrammarManager; /** * Set a logger for progress reporting. */ setLogger(logger: Logger): void; /** * Check if a grammar package is installed. */ isInstalled(language: ParserLanguage): Promise; /** * Install a grammar for a language using Bun. * * Thread-safe: concurrent calls for the same language will wait * for the first installation to complete. */ install(language: ParserLanguage): Promise; /** * Perform the actual installation using Bun. */ private doInstall; /** * Get the status of all supported grammars. */ getStatus(): Promise; /** * Pre-install grammars for a batch of languages. * Shows overall progress and handles failures gracefully. */ preInstallBatch(languages: ParserLanguage[]): Promise; /** * Load a grammar module. * Returns the grammar if installed, null otherwise. */ loadGrammar(language: ParserLanguage): Promise; /** * Get the package name for a language. */ getPackageName(language: ParserLanguage): string | undefined; /** * Clear cached grammars (mainly for testing). */ clearCache(): void; } /** * Get the singleton grammar manager instance. */ export declare function getGrammarManager(): GrammarManager;