/** * @author jasonHzq * @description Completion manifest for persistent caching * * 为 shell completion 提供持久化缓存,缓存 API 完整信息以提升性能。 * * 架构设计: * - 使用 manifest 文件缓存所有 API 元数据(name, title, description, params) * - 基于 mtime 做增量更新,避免不必要的重新扫描 * - 分离 local 和 external specs 的缓存和指纹 * - 支持并行读取多个 spec 文件 */ /** * 参数信息(补全需要的完整信息) */ export interface ParamEntry { /** 参数名 */ name: string; /** 参数类型 */ type: string; /** 是否必填 */ required: boolean; /** 参数描述 */ description?: string; /** 枚举值(用于值补全) */ enum?: string[]; /** 参数位置(path/query/body/formData 等) */ in?: string; } /** * API 信息(补全需要的完整信息) */ export interface ApiEntry { /** API 名称,如 "pet/uploadFile" */ name: string; /** API 标题(summary) */ title: string; /** API 描述 */ description?: string; /** 参数列表 */ params: ParamEntry[]; } /** * Tag 信息 */ export interface TagEntry { /** tag 名称 */ name: string; /** tag 描述 */ description?: string; } /** * Spec 信息 */ export interface SpecEntry { /** spec 名称 */ name: string; /** api-lock.json 绝对路径 */ path: string; /** 文件 mtime (ms) */ mtime: number; /** spec 描述(来自 info.title 或 info.description) */ description?: string; /** 缓存的 tags 列表 */ tags?: TagEntry[]; /** 缓存的 API 列表 */ apis: ApiEntry[]; } /** * Completion manifest 结构 */ export interface CompletionManifest { /** manifest 版本 */ version: number; /** Local specs 缓存(来自 pontx.config.ts 扫描) */ local: { /** pontx.config.ts 的 mtime (ms) */ configMtime: number; /** 缓存的 outDir(来自 config) */ outDir?: string; /** spec 路径列表 */ specs: SpecEntry[]; }; /** External specs 缓存(来自 package.json) */ external: { /** package.json 的 mtime (ms) */ packageJsonMtime: number; /** spec 路径列表 */ specs: SpecEntry[]; }; } /** * Manifest 加载结果 */ export interface ManifestResult { /** 所有 spec 列表 */ specs: SpecEntry[]; /** 是否从缓存加载 */ fromCache: boolean; } /** * 加载或重建 manifest * * 流程: * 1. 读取 manifest 文件 * 2. 检查 local specs(configMtime 变化?) * 3. 检查 external specs(packageJsonMtime 变化?) * 4. 增量更新变化的部分 * 5. 持久化更新后的 manifest */ export declare function loadManifest(cwd: string): Promise; /** * 清理 manifest 缓存 */ export declare function cleanManifest(cwd: string): boolean;