/** * Cognitive Anchor — 模块模块。 * * 职责边界: * - 负责:CognitiveMapAnchor 等 模块职责 * - 不负责:不属于本模块的职责由对应模块承担 * * 被谁调用:上层模块按需调用 * 调用谁:node:fs、node:path、logger、helpers * * 数据流:输入 → CognitiveMapAnchor 处理 → 输出 * 持久化:读写本地文件(详见代码内路径) */ /** 认知地图锚点 */ export interface CognitiveMapAnchor { /** 锚点 ID */ anchor_id: string; /** 所属模块 */ module: string; /** 核心契约列表 */ core_contracts: string[]; /** 已知副作用 */ side_effects: string[]; /** 不变量 */ invariants: string[]; /** 决策原因 */ decision_reasons: string[]; /** 风险标注 */ risk_notes: string[]; /** 证据引用: 文件/commit/task/diff/命令输出 */ source_refs: Array<{ type: "file" | "commit" | "task" | "diff" | "command_output" | "audit"; ref: string; }>; /** 置信度 */ confidence: "high" | "medium" | "low"; /** 上次验证时间 */ last_verified_at: string; /** 是否过时 */ stale_anchor?: boolean; } /** .map.json 文件结构 */ export interface MapJsonFile { version: 1; anchors: CognitiveMapAnchor[]; generated_at: string; } /** * 写入 .map.json 文件。 * @param filePath - 目标文件路径 * @param anchors - 要写入的锚点列表 */ export declare function writeMapJson(filePath: string, anchors: CognitiveMapAnchor[]): void; /** * 读取 .map.json 文件。文件不存在时返回空锚点列表。 * @param filePath - 目标文件路径 * @returns 解析后的地图文件,文件不存在或解析失败时返回 null */ export declare function readMapJson(filePath: string): MapJsonFile | null; /** * 检查锚点是否过时 — 与当前文件列表比对 source_refs。 * 文件不存在的 source_ref 标记 stale_anchor。 * @param anchors - 要检查的锚点列表 * @param existingFiles - 当前存在的文件路径集合 * @returns 更新了 stale_anchor 标记的锚点列表 */ export declare function checkAnchorStaleness(anchors: CognitiveMapAnchor[], existingFiles: Set): CognitiveMapAnchor[]; /** * 按相关性筛选锚点 — 根据模块名或文件路径前缀匹配。 * 不全量加载,避免污染上下文。 * @param anchors - 锚点列表 * @param query - 查询条件 * @param query.module - 按模块名精确匹配 * @param query.file_path - 按文件路径前缀匹配 * @returns 匹配的锚点列表 */ export declare function filterRelevantAnchors(anchors: CognitiveMapAnchor[], query: { module?: string; file_path?: string; }): CognitiveMapAnchor[];