/** * Shared Analysis Orchestrator * * Extracts the core analysis pipeline from the CLI analyze command into a * reusable function that can be called from both the CLI and a server-side * worker process. * * IMPORTANT: This module must NEVER call process.exit(). The caller (CLI * wrapper or server worker) is responsible for process lifecycle. */ import { type RepoMeta } from '../storage/repo-manager.js'; import type { ContentEncoding } from '@codragraph/graphstore'; import { type AnalyzeProfileOption, type CompressionOption, type EmbeddingMode } from './adaptive-profile.js'; export interface AnalyzeCallbacks { onProgress: (phase: string, percent: number, message: string) => void; onLog?: (message: string) => void; } export interface AnalyzeOptions { /** * Force a full re-index of the pipeline. Callers may OR this with * other flags that imply re-analysis (e.g. `--skills`), so the value * here is the PIPELINE-force signal, NOT the registry-collision * bypass. See `allowDuplicateName` below. */ force?: boolean; embeddings?: boolean; profile?: AnalyzeProfileOption; embeddingMode?: EmbeddingMode; skipGit?: boolean; /** Skip AGENTS.md and CLAUDE.md codragraph block updates. */ skipAgentsMd?: boolean; /** Omit volatile symbol/relationship counts from AGENTS.md and CLAUDE.md. */ noStats?: boolean; /** * User-provided alias for the registry `name` (#829). When set, * forwarded to `registerRepo` so the indexed repo is stored under * this alias instead of the path-derived basename. */ registryName?: string; /** * Bypass the `RegistryNameCollisionError` guard and allow two paths * to register under the same `name` (#829). Controlled by the * dedicated `--allow-duplicate-name` CLI flag, intentionally * independent from `--force` — users who hit the collision guard * should be able to accept the duplicate without paying the cost * of a pipeline re-index. */ allowDuplicateName?: boolean; /** * RFC 0001 Phase 2 — opt into per-row content compression. `'none'` * (or undefined) writes plain text and the schema-default tag, exactly * as pre-Phase-2 indexes do. `'brotli'` and `'zstd'` route every * content field through `encodeContent` before it hits the CSV; the * read path decodes via the per-row `contentEncoding` tag. * * Choosing `'zstd'` requires Node ≥ 22.15 on the indexer (the runtime * that wrote the rows). Readers on older Node will get a clear * forward-compat error rather than silently bad content. */ compress?: CompressionOption; } export interface AnalyzeResult { repoName: string; repoPath: string; stats: { files?: number; nodes?: number; edges?: number; communities?: number; featureClusters?: number; processes?: number; embeddings?: number; }; alreadyUpToDate?: boolean; /** User-facing explanation for a reused index fast path. */ reuseReason?: string; /** True when the git commit advanced but indexed inputs did not. */ reusedExistingIndex?: boolean; /** The raw pipeline result — only populated when needed by callers (e.g. skill generation). */ pipelineResult?: any; } export interface AnalyzeChangedPath { /** Git name-status token, e.g. M, A, D, R100. */ status: string; /** Current path for additions/modifications, or deleted path for deletions. */ path: string; /** Previous path for renames/copies. */ previousPath?: string; } export declare const PHASE_LABELS: Record; export declare const parseGitNameStatus: (raw: string) => AnalyzeChangedPath[]; export declare const listChangedPathsBetweenCommits: (repoPath: string, fromRef: string, toRef: string) => AnalyzeChangedPath[] | null; export declare const isGeneratedAgentContextPath: (filePath: string) => boolean; export declare const isGraphContentPath: (filePath: string) => boolean; export declare const changedPathAffectsGraph: (change: AnalyzeChangedPath) => boolean; export declare const getGraphRelevantChangedPaths: (changes: readonly AnalyzeChangedPath[]) => AnalyzeChangedPath[]; export interface IncrementalFilePatchPlan { eligible: boolean; reason: string; replacePaths: string[]; currentPaths: string[]; fileCountDelta: number; /** * True when a change can affect resolver/global structure broadly * (config/ignore/package). The incremental path still avoids deleting the * whole DB, but it replaces every file-scoped node from a fresh full scan. */ replaceAllFileScoped: boolean; /** Old path -> new path aliases used to reconnect external edges across renames. */ pathAliases: Record; } export declare const isPatchableIncrementalPath: (filePath: string) => boolean; export declare const buildIncrementalFilePatchPlan: (changes: readonly AnalyzeChangedPath[], _options?: { limit?: number; }) => IncrementalFilePatchPlan; export declare const getAnalyzeConfigRebuildReason: (existingMeta: Pick, options: { compress?: ContentEncoding; embeddings?: boolean; }) => string | null; /** * Run the full CodraGraph analysis pipeline. * * This is the shared core extracted from the CLI `analyze` command. It * handles: pipeline execution, LadybugDB loading, FTS indexing, embedding * generation, metadata persistence, and AI context file generation. * * The function communicates progress and log messages exclusively through * the {@link AnalyzeCallbacks} interface — it never writes to stdout/stderr * directly and never calls `process.exit()`. */ export declare function runFullAnalysis(repoPath: string, options: AnalyzeOptions, callbacks: AnalyzeCallbacks): Promise;