export interface CodeFile { path: string; language: string; exports: string[]; apis: 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: 扫描范围 ("src/:backend/**" 表示只扫 backend 下的 src) */ /** * 全量扫描构建代码索引 */ export declare function buildCodeIndex(scope?: string, incremental?: boolean): 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; }[]>; /** * 读取匹配到的源码文件内容(用于分析注入) */ export declare function readRelevantSource(matches: { file: string; score: number; }[], maxBytes?: number): 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; }>; /** * 检查索引是否过期 (超过 1 小时) */ export declare function isIndexStale(): Promise; /** * 加载完整索引(含端、模块、联动) */ export declare function loadFullIndex(): Promise; //# sourceMappingURL=code-scanner.d.ts.map