@vibe-validate/git
Version:
Git utilities for vibe-validate - tree hash calculation, branch sync, and post-merge cleanup
44 lines • 1.6 kB
TypeScript
/**
* Cache key encoding for run command results
*
* Generates deterministic cache keys for storing command execution results in git notes.
*/
/**
* Encode a run command cache key
*
* Cache keys uniquely identify command+workdir combinations for caching purposes.
*
* Normalization rules:
* - Always trim leading/trailing whitespace from command and workdir
* - For simple commands (no quotes/escapes/shell metacharacters): collapse multiple spaces
* - For complex commands (has quotes, escapes, etc.): preserve internal spacing
*
* Format:
* - SHA256 hash of `command__workdir` (first 16 chars for brevity)
* - Examples: `85ac6127576393ac` (for command+workdir combination)
*
* @param command - The command to run (e.g., "npm test")
* @param workdir - Working directory relative to git root ("" for root, "packages/cli" for subdirectory)
* @returns SHA256 hash (first 16 chars) suitable for use in git ref paths
*
* @example
* ```ts
* // Simple command at root
* encodeRunCacheKey('npm test', '')
* // → SHA256('npm test__')[:16]
*
* // Command with workdir
* encodeRunCacheKey('npm test', 'packages/cli')
* // → SHA256('npm test__packages/cli')[:16]
*
* // Whitespace normalization (simple commands)
* encodeRunCacheKey(' npm test ', '')
* // → SHA256('npm test__')[:16]
*
* // Complex command (preserve internal spacing)
* encodeRunCacheKey('echo "hello world"', '')
* // → SHA256('echo "hello world"__')[:16]
* ```
*/
export declare function encodeRunCacheKey(command: string, workdir: string): string;
//# sourceMappingURL=cache-key.d.ts.map