/** * 模板哈希增量更新 * * P1-10: 跟踪模板文件哈希,实现增量更新 * * 核心逻辑: * 1. 计算新模板哈希 * 2. 对比存储哈希(.specpow/.template-hashes.json) * 3. 未修改 → 跳过(节省 I/O) * 4. 用户修改过 → 创建 .new 文件(不覆盖用户修改) * 5. 框架更新 → 覆盖 */ export interface TemplateHashEntry { /** SHA-256 哈希值 */ hash: string; /** 原始模板哈希(框架提供的版本) */ originalHash: string; /** 最后更新时间戳 */ updatedAt: string; } export interface TemplateHashStore { /** 版本号 */ __version: number; /** 文件哈希映射(相对于项目根目录的路径 → 哈希条目) */ hashes: Record; } export interface HashUpdateResult { /** 跳过的文件(未变化) */ skipped: string[]; /** 更新的文件(框架更新) */ updated: string[]; /** 用户修改过的文件(创建 .new 文件) */ userModified: string[]; /** 新增的文件 */ added: string[]; } /** * 计算文件内容的 SHA-256 哈希 */ export declare function computeHash(content: string): string; /** * 加载哈希存储文件 */ export declare function loadHashStore(projectRoot: string): TemplateHashStore; /** * 保存哈希存储文件 */ export declare function saveHashStore(projectRoot: string, store: TemplateHashStore): void; /** * 模板哈希管理器 * * 用于在 specpow init / specpow update 时跟踪模板文件变化, * 实现增量更新而非全量覆盖。 */ export declare class TemplateHashManager { private projectRoot; private store; constructor(projectRoot: string); /** * 处理单个文件的写入 * * @param relativePath 相对于项目根目录的路径 * @param newContent 新文件内容 * @returns 操作类型:'skipped' | 'updated' | 'user-modified' | 'added' */ processFile(relativePath: string, newContent: string): 'skipped' | 'updated' | 'user-modified' | 'added'; /** * 批量处理文件写入 */ processFiles(files: Array<{ path: string; content: string; }>): HashUpdateResult; /** * 获取当前哈希存储的统计信息 */ getStats(): { total: number; lastUpdated: string | null; }; /** * 重置哈希存储(用于 --force 重新初始化) */ reset(): void; } //# sourceMappingURL=template-hash.d.ts.map