/** * Analysis Artifact Generator * * Takes all analysis results and generates structured output files * that will be consumed by the LLM generation phase and optionally by humans. */ import type { RepositoryMap } from './repository-mapper.js'; import type { DependencyGraphResult } from './dependency-graph.js'; import type { UIComponent } from './ui-component-extractor.js'; import type { SchemaTable } from './schema-extractor.js'; import type { RouteInventory } from './http-route-parser.js'; import type { MiddlewareEntry } from './middleware-extractor.js'; import type { EnvVar } from './env-extractor.js'; export { isTestFile } from './test-file.js'; /** * Architecture layer information */ export interface ArchitectureLayer { name: string; purpose: string; files: string[]; representativeFile: string | null; } /** * Detected domain (maps to OpenSpec spec) */ export interface DetectedDomain { name: string; suggestedSpecPath: string; files: string[]; entities: string[]; keyFile: string | null; } /** * Entry point information */ export interface EntryPointInfo { file: string; type: 'application-entry' | 'api-entry' | 'test-entry' | 'build-entry'; initializes: string[]; } /** * Data flow information */ export interface DataFlowInfo { sources: string[]; sinks: string[]; transformers: string[]; } /** * Key files by category */ export interface KeyFiles { schemas: string[]; config: string[]; auth: string[]; database: string[]; routes: string[]; services: string[]; } /** * Repository structure (JSON artifact) */ export interface RepoStructure { projectName: string; projectType: string; frameworks: string[]; architecture: { pattern: 'layered' | 'modular' | 'microservices' | 'monolith' | 'unknown'; layers: ArchitectureLayer[]; }; domains: DetectedDomain[]; entryPoints: EntryPointInfo[]; dataFlow: DataFlowInfo; keyFiles: KeyFiles; /** Detected UI components (React, Vue, Svelte, Angular) */ uiComponents: UIComponent[]; /** Detected database schema tables */ schemas: SchemaTable[]; /** Aggregated HTTP route inventory */ routeInventory: RouteInventory; /** Detected middleware entries */ middleware: MiddlewareEntry[]; /** Detected environment variables */ envVars: EnvVar[]; statistics: { totalFiles: number; analyzedFiles: number; skippedFiles: number; avgFileScore: number; nodeCount: number; edgeCount: number; cycleCount: number; clusterCount: number; }; } /** * LLM context phase */ export interface LLMContextPhase { purpose: string; files: Array<{ path: string; content?: string; tokens: number; }>; totalTokens?: number; estimatedTokens?: number; } /** * LLM context preparation */ export interface LLMContext { phase1_survey: LLMContextPhase; phase2_deep: LLMContextPhase; phase3_validation: LLMContextPhase; /** Compact signatures for ALL analyzed files — used by Stage 1 instead of bare file paths */ signatures?: import('./signature-extractor.js').FileSignatureMap[]; /** Static call graph: function→function relationships across all TS/Python files */ callGraph?: import('./call-graph.js').SerializedCallGraph; /** * Per-function CFG + reaching-definitions overlay (spec: * add-intraprocedural-cfg-dataflow-overlay). Transient: written to the SQLite * store but STRIPPED before llm-context.json is persisted, so it never enters * the always-resident graph or the hot cache. */ cfgs?: Array<{ functionId: string; filePath: string; cfg: import('./cfg.js').FunctionCfg; }>; } /** * All generated artifacts */ export interface AnalysisArtifacts { repoStructure: RepoStructure; summaryMarkdown: string; dependencyDiagram: string; llmContext: LLMContext; } /** * Optional enrichment data produced by new extractors, passed into generate(). */ export interface EnrichmentData { uiComponents?: UIComponent[]; schemas?: SchemaTable[]; routeInventory?: RouteInventory; middleware?: MiddlewareEntry[]; envVars?: EnvVar[]; } /** * Options for artifact generation */ export interface ArtifactGeneratorOptions { /** Root directory of the project */ rootDir: string; /** Output directory for artifacts */ outputDir: string; /** Maximum files to include in LLM deep analysis */ maxDeepAnalysisFiles?: number; /** Maximum files for validation phase */ maxValidationFiles?: number; /** Approximate tokens per character for estimation */ tokensPerChar?: number; } /** * Convert a serialised RepoStructure (from repo-structure.json on disk) back * to a minimal RepositoryMap-compatible object. Only the fields that * consumers of the cached-analysis path actually use are populated; the * file-level arrays (`allFiles`, `highValueFiles`, etc.) are left empty * because the original per-file data is not persisted to disk. */ export declare function repoStructureToRepoMap(rs: RepoStructure): RepositoryMap; /** * Generates analysis artifacts from repository map and dependency graph */ export declare class AnalysisArtifactGenerator { private options; constructor(options: ArtifactGeneratorOptions); /** * Generate all artifacts */ generate(repoMap: RepositoryMap, depGraph: DependencyGraphResult, enrichment?: EnrichmentData): Promise; /** * Generate and save all artifacts to disk */ generateAndSave(repoMap: RepositoryMap, depGraph: DependencyGraphResult, enrichment?: EnrichmentData): Promise; /** * Generate repo-structure.json */ private generateRepoStructure; /** * Format project type for display */ private formatProjectType; /** * Detect architecture pattern from code structure */ private detectArchitecturePattern; /** * Generate architecture layers */ private generateArchitectureLayers; /** * Generate domains from clusters */ private generateDomains; /** * Normalize domain name for OpenSpec path */ private normalizeDomainName; /** * Extract potential entity names from files */ private extractEntities; /** * Generate entry points information */ private generateEntryPoints; /** * Generate data flow information */ private generateDataFlow; /** * Generate key files by category */ private generateKeyFiles; /** * Generate SUMMARY.md */ private generateSummaryMarkdown; /** * Format project type for human reading */ private formatProjectTypeReadable; /** * Generate dependency diagram in Mermaid format */ private generateDependencyDiagram; /** * Generate LLM context preparation */ private generateLLMContext; } /** * Writes the full call graph (nodes, edges, classes, inheritance) to SQLite. * Full rebuild on every analyze — incremental updates handled by the watcher. * Additive alongside llm-context.json; backward compat preserved. */ export declare function writeEdgesToSQLite(callGraph: import('./call-graph.js').SerializedCallGraph, dbPath: string, rootPath?: string, cfgs?: Array<{ functionId: string; filePath: string; cfg: import('./cfg.js').FunctionCfg; }>): Promise; /** * Generate all artifacts */ export declare function generateArtifacts(repoMap: RepositoryMap, depGraph: DependencyGraphResult, options: ArtifactGeneratorOptions): Promise; /** * Generate and save all artifacts */ export declare function generateAndSaveArtifacts(repoMap: RepositoryMap, depGraph: DependencyGraphResult, options: ArtifactGeneratorOptions): Promise; //# sourceMappingURL=artifact-generator.d.ts.map