/** * LLM-First Discovery — runs before flow detection. * * Uses claude-opus-4-6 to: * 1. Read all READMEs in the repo * 2. Walk the full directory tree and classify each directory * 3. Identify real business features (not Louvain code clusters) * 4. For multi-repo workspaces, detect system topology * (monolith / api+frontend / microservices / fullstack_monorepo) * * Output: * - SeedFlow[] fed into detectFlows() before Louvain runs * - DISCOVERY.md written to /ai-codeprism/DISCOVERY.md * - WorkspaceTopology (cross-repo only, written to workspace root) * * Requires ANTHROPIC_API_KEY for Opus. Falls back gracefully to empty seeds * if the key is missing or the LLM call fails. */ import type { ParsedFile } from "./types.js"; import type { LLMProvider } from "../llm/provider.js"; import type { SeedFlow } from "./route-extractor.js"; export interface DiscoveryResult { repoName: string; seedFlows: SeedFlow[]; mdContent: string; /** Compact summary used for workspace topology prompt */ dirSummary: string; framework: string; repoClass: string; } export interface WorkspaceTopology { topology: string; description: string; repos: Array<{ name: string; role: string; serves: string[]; dependsOn: string[]; }>; sharedConcepts: string[]; } interface RepoTypeHint { repoClass: string; likelyFramework: string; signals: string[]; } /** * Builds a full directory tree string showing every directory with its * direct file count. No depth cap — we want full visibility for the LLM. * Directories in SKIP_DIRS are collapsed to a single line with a note. */ export declare function buildDirectoryTree(repoPath: string): string; /** * Reads all READMEs found in the repo root and one level of subdirectories. * No content cap — the LLM should see everything. */ export declare function readAllReadmes(repoPath: string): string; export declare function detectRepoTypeHint(tree: string, readme: string, repoPath: string): RepoTypeHint; /** * Returns a compact block like: * app/controllers/api/v1/: accounts_controller, bookmarks_controller, ... * app/models/: account, bookmark, status, tag, ... * lib/kamal/commands/: app, builder, proxy, registry, ... * * Uses the LLM's own directory classification (from Call 1) to decide which * directories to surface — no hardcoded path patterns needed. Works for Rails, * Go, Ruby gems, CLI tools, Django, Laravel, etc. */ export declare function buildKeyFilesListing(parsedFiles: ParsedFile[], repoAbsPath: string, classifiedDirs: Array<{ path: string; role: string; layer: string; }>): string; /** * Runs the full LLM-first discovery for a single repo. * Returns SeedFlow[] (for flow-detector) and DISCOVERY.md content. */ export declare function discoverFeatures(repoAbsPath: string, repoName: string, parsedFiles: ParsedFile[], discoveryLlm: LLMProvider): Promise; /** * When 2+ repos are indexed together, detect how they relate to each other. * Returns WorkspaceTopology and updates each repo's DISCOVERY.md with topology section. */ export declare function discoverWorkspaceTopology(results: DiscoveryResult[], discoveryLlm: LLMProvider): Promise; /** * Merges LLM-discovered seed flows with route-extractor seeds. * LLM seeds take priority. Route seeds that don't overlap are appended. */ export declare function mergeSeedFlows(llmSeeds: SeedFlow[], routeSeeds: SeedFlow[]): SeedFlow[]; export {}; //# sourceMappingURL=llm-discovery.d.ts.map