/** * Wiki Generator * * Orchestrates the full wiki generation pipeline: * Phase 0: Validate prerequisites + gather graph structure * Phase 1: Build module tree (one LLM call) * Phase 2: Generate module pages (one LLM call per module, bottom-up) * Phase 3: Generate overview page * * Supports incremental updates via git diff + module-file mapping. */ import { type LLMConfig } from './llm-client.js'; export interface WikiOptions { force?: boolean; model?: string; baseUrl?: string; apiKey?: string; maxTokensPerModule?: number; concurrency?: number; } export interface WikiMeta { fromCommit: string; generatedAt: string; model: string; moduleFiles: Record; moduleTree: ModuleTreeNode[]; } export interface ModuleTreeNode { name: string; slug: string; files: string[]; children?: ModuleTreeNode[]; } export type ProgressCallback = (phase: string, percent: number, detail?: string) => void; export declare class WikiGenerator { private repoPath; private storagePath; private wikiDir; private lbugPath; private llmConfig; private maxTokensPerModule; private concurrency; private options; private onProgress; private failedModules; constructor(repoPath: string, storagePath: string, lbugPath: string, llmConfig: LLMConfig, options?: WikiOptions, onProgress?: ProgressCallback); private lastPercent; /** * Create streaming options that report LLM progress to the progress bar. * Uses the last known percent so streaming doesn't reset the bar backwards. */ private streamOpts; /** * Main entry point. Runs the full pipeline or incremental update. */ run(): Promise<{ pagesGenerated: number; mode: 'full' | 'incremental' | 'up-to-date'; failedModules: string[]; }>; private ensureHTMLViewer; private fullGeneration; private buildModuleTree; /** * Parse LLM grouping response. Validates all files are assigned. */ private parseGroupingResponse; /** * Fallback grouping by top-level directory when LLM parsing fails. */ private fallbackGrouping; /** * Split a large module into sub-modules by subdirectory. */ private splitBySubdirectory; /** * Generate a leaf module page from source code + graph data. */ private generateLeafPage; /** * Generate a parent module page from children's documentation. */ private generateParentPage; private generateOverview; private incrementalUpdate; private getCurrentCommit; private getChangedFiles; private readSourceFiles; private truncateSource; private estimateModuleTokens; private readProjectInfo; private extractModuleFiles; private countModules; /** * Flatten the module tree into leaf nodes and parent nodes. * Leaves can be processed in parallel; parents must wait for children. */ private flattenModuleTree; /** * Run async tasks in parallel with a concurrency limit and adaptive rate limiting. * If a 429 rate limit is hit, concurrency is temporarily reduced. */ private runParallel; private findNodeBySlug; private slugify; private fileExists; private loadWikiMeta; private saveWikiMeta; private saveModuleTree; }