/** * Spec Generation Pipeline * * Orchestrates the multi-step LLM process to generate accurate specifications * in OpenSpec format from code analysis. */ import type { LLMService } from '../services/llm-service.js'; import type { RepoStructure, LLMContext } from '../analyzer/artifact-generator.js'; import type { DependencyGraphResult } from '../analyzer/dependency-graph.js'; import type { RefactorReport } from '../analyzer/refactor-analyzer.js'; import type { PipelineResult, StageResult, PipelineOptions, PipelineContext, ServiceSubSpec } from '../../types/pipeline.js'; export type { ProjectCategory, ArchitecturePattern, ProjectSurveyResult, EntityProperty, EntityRelationship, Scenario, ExtractedEntity, ServiceOperation, ServiceSubSpec, ExtractedService, ExtractedEndpoint, ArchitectureLayer, ArchitectureSynthesis, EnrichedADR, PipelineResult, StageResult, PipelineOptions, PipelineContext, } from '../../types/pipeline.js'; /** * Spec Generation Pipeline */ export declare class SpecGenerationPipeline implements PipelineContext { llm: LLMService; options: Required>; private progress?; private semanticSearch?; /** Set at the start of run() and used by stage methods for graph-based prompts */ private currentLLMContext?; /** Set at the start of run() and used by schemasFor() / routesFor() */ private currentRepoStructure?; constructor(llm: LLMService, options: PipelineOptions); /** * Run the complete pipeline */ run(repoStructure: RepoStructure, llmContext: LLMContext, depGraph?: DependencyGraphResult, refactorReport?: RefactorReport): Promise; /** * Check if a stage should run */ private shouldRunStage; /** * Split file content into chunks, breaking only on blank lines (function/class boundaries). * A chunk is emitted when its size exceeds maxChars and a blank line is encountered. * overlapLines trailing lines from the previous chunk are prepended to the next one, * preserving context (e.g. class declaration visible when processing its methods). */ chunkContent(content: string, maxChars: number, overlapLines?: number): string[]; /** * For a large file, try to build a graph-based prompt section. * Returns null when the file is small enough for raw chunking and has no graph data. * * Priority: * 1. Graph section (god functions) + optional skeleton supplement — richest representation * 2. Standalone skeleton for large files without god functions — avoids [PARTIAL SPEC] * 3. null → caller falls back to raw AST chunking * * The skeleton fallback fires when content would be split (> STAGE_CHUNK_MAX_CHARS) and * the skeleton achieves ≥ 20% size reduction AND fits within SKELETON_STANDALONE_MAX_CHARS. */ graphPromptFor(filePath: string, content?: string): string | null; signaturesFor(filePath: string): string | null; schemasFor(filePath: string): string | null; routesFor(filePath: string): string | null; /** * Generate sub-specifications for the direct callees of god functions in a file. * Makes a single batched LLM call covering all callees at once. * Returns [] when no graph data or no god functions are found. */ generateSubSpecs(filePath: string, parentName: string, parentPurpose: string): Promise; /** * Generation retrieval strategy: semantic-first → depth-N graph expansion. * * 1. Semantic search identifies seed files relevant to the query. * 2. BFS graph expansion up to `depth` hops adds callee files so indirect * implementations are not missed. Score decays by λ^hop (λ=0.6) — used * only for logging; all resolved files are passed to the LLM stage. */ private semanticFiles; /** Name-based heuristic fallback for schema/entity/type files. */ private heuristicSchemaFiles; /** Name-based heuristic fallback for service/business-logic files. */ private heuristicServiceFiles; /** Name-based heuristic fallback for API/route files. */ private heuristicApiFiles; /** * Get schema files — semantic-first, name-heuristic fallback. */ private getSchemaFiles; /** * Get service files — semantic-first, name-heuristic fallback. */ private getServiceFiles; /** * Get API files — semantic-first, name-heuristic fallback. */ private getApiFiles; /** * Resolve file paths identified by Stage 1 LLM to actual file content. * First looks in phase2_deep (already in memory); if not found and rootPath is set, * reads the file from disk so that files outside the top-20 scored set can still * be analyzed in later stages. * Falls back to the provided heuristic list if no paths resolve. */ private resolveFiles; /** * Get default survey when stage is skipped */ private getDefaultSurvey; /** * Get default architecture when stage is skipped */ private getDefaultArchitecture; /** * Save intermediate result */ saveResult(name: string, data: unknown): Promise; /** * Map short stage name to the filename used by saveResult. */ private stageFileName; /** * Load previous stage result (for resume) */ loadStageResult(stage: string): Promise | null>; } /** * Run the spec generation pipeline */ export declare function runSpecGenerationPipeline(llm: LLMService, repoStructure: RepoStructure, llmContext: LLMContext, options: PipelineOptions, depGraph?: DependencyGraphResult, refactorReport?: RefactorReport): Promise; //# sourceMappingURL=spec-pipeline.d.ts.map