/** 只读文件上限,对齐 files-api TEXT_MAX(512KB)。 */ export declare const KB_TEXT_MAX: number; /** 断流判定阈值(天):git 最近 commit 晚于最近日志超过该天数 = 疑似断流。 */ export declare const STALL_THRESHOLD_DAYS = 3; /** 「项目在开发」观察窗(天,审查 N-6):无日志分支的 stall 需 commit 距今在该窗内—— * 死项目(commit 半年前、知识库从未建)不算断流,只有近期还在提交却从未记录才标 🔴。 */ export declare const RECENT_COMMIT_WINDOW_DAYS = 90; export type KbErrorCode = 'bad_request' | 'not_found' | 'forbidden' | 'too_large' | 'not_configured'; export declare class KbError extends Error { readonly code: KbErrorCode; constructor(code: KbErrorCode, message: string); } export interface KbProjectCard { /** vault 内项目目录名。 */ name: string; /** 活跃看板文件名;null = 无活跃看板(两者均归档/缺席)。 */ boardFile: string | null; boardStatus: string; done: number | null; total: number | null; /** 最近开发日志日期(YYYY-MM-DD,来自文件名);null = 无日志。 */ lastLogDate: string | null; lastLogTitle: string; /** CLAUDE.md 映射到的本地仓库绝对路径;null = 映射表无此项目。 */ repoPath: string | null; /** git 最近 commit ISO 日期;null = 无仓库/查询失败。 */ lastCommitDate: string | null; /** commit 晚于最近日志的天数;null = 不可算。 */ stallDays: number | null; /** 疑似断流:代码在动而知识库停滞(超 STALL_THRESHOLD_DAYS 天,或有 commit 而从未有日志)。 */ stall: boolean; } export interface KbOverview { configured: boolean; /** vault 根存在性(configured 但目录缺失时前端给修复引导)。 */ vaultExists: boolean; /** vault 目录名(obsidian:// URI 的 vault 参数)。 */ vaultName: string; projects: KbProjectCard[]; } export interface KbLogEntry { /** 相对「开发日志/」的文件名。 */ file: string; date: string; title: string; /** frontmatter status 原值;'' = 未写。 */ status: string; } export interface KbBoardSection { text: string; } export interface KbProjectDetail { name: string; board: { file: string; done: number | null; total: number | null; sections: KbBoardSection[]; } | null; logs: KbLogEntry[]; } export interface KbFileContent { content: string; size: number; } /** git 最近 commit 查询注入面(测试隔离);返回 %cI ISO 串,null = 无仓库/失败。 */ export type GitLogFn = (repoPath: string) => Promise; /** 简单并发限制 map(信号量模式;git 查询用)。导出供并发上限直接单测(审查 N-5)。 */ export declare function mapLimit(items: readonly T[], limit: number, fn: (t: T) => Promise): Promise; /** 轻量 frontmatter 解析:--- 块内 `key: value` 行;重复键取首个(堆叠 last-updated 容错); * 列表/多行值不解析(本层只需要标量)。 */ export declare function parseFrontmatterHead(head: string): Record; /** 解析 CLAUDE.md/AGENTS.md「项目目录映射」表:| `repoPath` | `kbDir` | 行 → kbDir(去尾斜杠) → repoPath。 * 表头/分隔行无反引号自然跳过;格式异常行静默跳过(用户手写文件,容错优先)。 * 取"第一对反引号 = repoPath、最后一对 = kbDir"(真机验证 2026-10-08:GodotMCP 行 * 附注含旧仓库路径的反引号段,居中取第 2 对会误把旧路径当 kbDir → 映射丢失;两侧 * 各取与全部现存行形态一致)。 */ export declare function parseRepoMapLine(line: string): { repoPath: string; kbDir: string; } | null; export interface KbApiOpts { /** vault 根注入(测试隔离);缺省现读 env GODOT_MCP_VAULT_PATH。 */ vaultDir?: string; /** git log 注入(测试隔离);缺省 spawn git。 */ gitLog?: GitLogFn; } export declare class KbApi { private readonly gitLog; private readonly gitCache; /** 测试注入的固定 vault 根(优先于 env)。 */ private readonly fixedVault; constructor(opts?: KbApiOpts); /** 生效 vault 根(注入优先,env 兜底);'' = 未配置。 */ private vaultRoot; /** 带缓存的 git 查询(TTL 内复用;并发安全——重复请求只是多算一次覆盖同值)。 */ private gitLastCommit; overview(): Promise; projectDetail(name: string): Promise; /** 开发日志正文(只读;rel 限制在 //开发日志/ 内,防穿越链复用 resolveWithinRoot)。 */ readFile(name: string, rel: string): Promise; private requireVault; }