export interface CodeFile { path: string; language: string; exports: string[]; apis: string[]; apiDetails: string[]; imports: string[]; lastModified: number; lines: number; endpoint: string; module: string; } export interface EndpointInfo { name: string; rootPath: string; techStack: string; entryFile: string; fileCount: number; frameworks: string[]; } export interface ModuleInfo { name: string; path: string; endpoint: string; fileCount: number; coreFiles: string[]; exports: string[]; dependencies: string[]; } export interface GitCorrelation { files: string[]; count: number; pattern: string; } export interface CodeIndex { updatedAt: string; files: CodeFile[]; endpoints: EndpointInfo[]; modules: ModuleInfo[]; correlations: GitCorrelation[]; gitStats: { totalCommits: number; analyzedCommits: number; }; } /** * 全量扫描构建代码索引 * scope: 扫描范围(逗号分隔目录) * preScannedFiles: v8.3.3xx+ 同源模式——复用 collectScanFiles 已收集的绝对路径文件列表, * 跳过目录扫描,供 code-index 与 code-graph 一次构建两份资产 */ export declare function buildCodeIndex(scope?: string, incremental?: boolean, preScannedFiles?: string[]): Promise; /** * v8.3.3xx+: 收集 scope 下的源码文件绝对路径(code-index 与 code-graph 同源复用) * 过滤规则与 scanDirectory 完全一致,保证两份资产基于同一文件集合。 */ export declare function collectScanFiles(scope?: string): Promise; /** * 根据需求内容查找匹配的源码文件(解耦设计:从完整索引中按 scope 筛选) * * v3 增强: * - 端配额:每个 endpoint 最多占 limit 的 40%,保证多端多样性 * - API 契约:加载 API_CONTRACT.yaml,命中契约路径的文件加分 * - 知识图谱:传入 iteration/taskId 时优先加载 KG 关联的代码文件 * - @spec 关联:扫描代码中的 @spec 注释,命中 taskId 的文件加分 * - Git 联动:命中了常一起变更的文件组,联动文件也加分 * - 语义扩展:关键词自动扩展同义词 */ export declare function findRelevantCode(requirements: string, limit?: number, scope?: string, // 查询时过滤:如 'src/commands,src/core' iteration?: string, // 迭代名(用于加载知识图谱) taskId?: string): Promise<{ file: string; exports: string[]; apis: string[]; score: number; }[]>; /** * 读取匹配到的源码文件内容(用于分析注入) * v8.3.122+: 移除 matches.slice(0, 5) 硬限制,改为按 maxBytes 动态控制, * 让 analyze 传入的 limit 和 maxBytes 真正生效。 */ export declare function readRelevantSource(matches: { file: string; score: number; }[], maxBytes?: number, // 最多读 50KB maxFiles?: number): Promise>; export interface SourceReadingMatch { file: string; exports: string[]; apis: string[]; score: number; } export declare function formatSourceReadingList(matches: SourceReadingMatch[], opts?: { maxEntries?: number; title?: string; withSymbolLines?: boolean; }): Promise; export declare function loadCodeIndex(): Promise; /** * 检查代码索引新鲜度 * 返回:{ fresh: boolean; indexAge: number; sourceAge: number; staleFiles: string[] } * - fresh: 索引是否新鲜(源码无更新,或更新在索引之后) * - indexAge: 索引更新时间戳 * - sourceAge: 源码最新修改时间戳 * - staleFiles: 索引后修改过的文件列表(最多10个) */ export declare function checkCodeIndexFreshness(scope?: string[]): Promise<{ fresh: boolean; indexAge: number; sourceAge: number; staleFiles: string[]; message: string; }>; export declare function expandKeywords(keywords: string[]): string[]; export declare function extractKeywords(text: string): string[]; /** * v8.3.3xx+: 消费前兜底——索引缺失/过期时自动重建,并输出无索引告警 * * 供 analyze/execute 的 findRelevantCode 消费链路在读取索引前调用: * - 索引不存在 → warn 告警 + 全量构建 * - 索引过期 → info 提示 + 增量重建 * - 索引新鲜 → 直接复用 * * @returns 本次是否执行了重建 */ export declare function ensureCodeIndexFresh(scope?: string): Promise; /** * 检查索引是否过期 * v8.3.125+: 基于实际文件 mtime 判断 + 24h 强制刷新(捕获新增文件) */ export declare function isIndexStale(scope?: string): Promise; /** * 加载完整索引(含端、模块、联动) */ export declare function loadFullIndex(): Promise; /** * v8.3.125+: 根据迭代名解析涉及的源码路径 scope * 读取 PLATFORMS.md / 020-specs/ 子目录推断端名,匹配 CONSTITUTION.md 中的源码路径 */ export declare function resolveIterationScope(iteration?: string): Promise; //# sourceMappingURL=code-scanner.d.ts.map