aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
76 lines • 2.69 kB
TypeScript
/**
* Checksum Manifest — Fast Change Detection
*
* Stores `{ path, checksum, mtime, size }` per indexed file to enable
* two-phase change detection:
* Phase 1: stat() comparison (no file read) — filter out unchanged files
* Phase 2: content read + checksum — only for candidates where stat differs
*
* This avoids reading every file on `aiwg index build` when most haven't
* changed, reducing rebuild time from O(N reads) to O(N stats + M reads)
* where M << N on typical projects.
*
* @implements #794
* @source @src/artifacts/index-builder.ts
*/
import fs from 'fs';
/**
* Per-file entry in the checksum manifest
*/
export interface ManifestEntry {
/** Truncated SHA-256 checksum (matches MetadataEntry.checksum) */
checksum: string;
/** File modification time (ISO string for stable serialization) */
mtime: string;
/** File size in bytes */
size: number;
}
/**
* On-disk manifest format
*/
export interface ChecksumManifest {
version: 1;
generated: string;
entries: Record<string, ManifestEntry>;
}
/**
* Build a manifest entry from a file's current stat + checksum
*/
export declare function makeEntry(checksum: string, stat: fs.Stats): ManifestEntry;
/**
* Load the checksum manifest from an index directory.
* Returns an empty manifest if the file is missing or malformed.
*/
export declare function loadManifest(indexDir: string): ChecksumManifest;
/**
* Write the checksum manifest atomically (write to temp, rename).
*/
export declare function writeManifest(indexDir: string, manifest: ChecksumManifest): void;
/**
* Phase 1 check: can we skip this file based on stat alone?
*
* Returns true if the file's current mtime and size match the manifest entry —
* in which case we presume the content is unchanged and skip the read.
*/
export declare function statMatches(stat: fs.Stats, entry: ManifestEntry | undefined): boolean;
/**
* Remove stale entries (files that no longer exist on disk) from the manifest.
* Returns the count removed.
*/
export declare function pruneManifest(manifest: ChecksumManifest, cwd: string): number;
/**
* Stats collected during a build using the manifest for change detection
*/
export interface ManifestStats {
/** Files checked (matches total file count) */
checked: number;
/** Files skipped entirely (stat matched manifest) */
statSkipped: number;
/** Files read and checksum verified as unchanged */
checksumSkipped: number;
/** Files that actually changed and were re-indexed */
reindexed: number;
/** Files removed from manifest (deleted from disk) */
pruned: number;
}
//# sourceMappingURL=checksum-manifest.d.ts.map