/** * knowledge-graph — 知识图谱构建引擎 * * 从文件系统扫描需求/规格/任务/子任务,提取实体和关联关系 * 输出 knowledge-graph.json(机器读)+ CONTEXT.md(AI 读) */ export interface KnowledgeGraph { version: string; generated: string; iteration: string; entities: Record; relations: GraphRelation[]; stats: GraphStats; } export interface GraphEntity { id: string; type: 'requirement' | 'spec' | 'task' | 'subtask' | 'user-file' | 'source-file' | 'global-doc' | 'task-spec' | 'business_module'; title: string; file: string; hash: string; mtime: string; status?: string; platform?: string; parentTaskId?: string; tags?: string[]; endpoint?: string; module?: string; language?: string; exports?: string[]; imports?: string[]; apis?: string[]; codeEntities?: string[]; businessModule?: string; semanticTags?: string[]; description?: string; businessRole?: string; } export interface GraphRelation { from: string; to: string; type: 'implements' | 'specifies' | 'subtask_of' | 'depends_on' | 'references' | 'imports' | 'module_depends' | 'co_changes' | 'governs' | 'elaborates' | 'maps_to' | 'uses_table' | 'calls_api' | 'affects' | string; metadata?: Record; } export interface GraphStats { requirements: number; specs: number; tasks: number; subtasks: number; userFiles: number; sourceFiles: number; globalDocs: number; taskSpecs: number; businessModules: number; relations: number; } export declare function buildKnowledgeGraph(cwd: string, iteration?: string): Promise; /** 保存知识图谱到 cache 目录 */ export declare function saveKnowledgeGraph(cwd: string, graph: KnowledgeGraph): Promise; /** 加载已存在的知识图谱 */ /** * 加载知识图谱(带进程缓存) * 文件 mtime 未变时直接返回缓存,避免重复 JSON 解析 */ export declare function loadKnowledgeGraph(cwd: string): Promise; /** 获取指定任务的关联链(上游需求 + 关联子任务) */ export declare function getTaskContext(graph: KnowledgeGraph, taskId: string): { requirement: GraphEntity | null; siblingSubtasks: GraphEntity[]; parentTask: GraphEntity | null; relatedSpecs: GraphEntity[]; dependsOn: GraphEntity[]; }; /** 检查知识图谱是否已过期(带 500ms 超时保护) */ export declare function isGraphStale(cwd: string, iteration?: string): Promise; /** 刷新知识图谱(重建 + 保存)—— 供命令完成后调用 */ export declare function refreshKnowledgeGraph(cwd: string, iteration?: string): Promise; export interface DependencyChain { taskId: string; taskName: string; depth: number; path: string[]; relations: GraphRelation[]; entities: GraphEntity[]; } /** * 追踪任务的完整依赖链路(向上追溯) * 递归追踪 implements → references → depends_on 关系 */ export declare function traceDependencyChain(graph: KnowledgeGraph, taskId: string, maxDepth?: number, visited?: Set): DependencyChain[]; /** * 获取任务的完整上下文(扩展版,包含依赖链路) * 在 getTaskContext 基础上增加 dependencyChain 字段 */ export declare function getFullTaskContext(graph: KnowledgeGraph, taskId: string): { requirement: GraphEntity | null; siblingSubtasks: GraphEntity[]; parentTask: GraphEntity | null; relatedSpecs: GraphEntity[]; dependsOn: GraphEntity[]; dependencyChain: DependencyChain[]; downstreamTasks: GraphEntity[]; }; //# sourceMappingURL=knowledge-graph.d.ts.map