@sudocode-ai/cli
Version:
Git-native spec and issue management CLI for AI-assisted software development
58 lines • 1.9 kB
TypeScript
/**
* ID generation utilities
*
* Supports two ID formats:
* 1. Legacy: SPEC-001, ISSUE-001 (sequential numbers)
* 2. Hash-based: s-x7k9, i-a3f2 (UUID-derived base36 hashes)
*
* New entities use hash-based IDs for better distributed workflow support.
* Legacy IDs remain supported indefinitely.
*/
import type Database from "better-sqlite3";
/**
* Calculate adaptive hash length based on entity count
* Uses birthday paradox probability to determine safe length
*
* Target: Keep collision probability under 25%
* Base36 namespace sizes:
* - 4 chars: ~1.7M namespace → ~980 items at 25% collision prob
* - 5 chars: ~60M namespace → ~5.9K items at 25% collision prob
* - 6 chars: ~2.2B namespace → ~35K items at 25% collision prob
* - 7 chars: ~78B namespace → ~212K items at 25% collision prob
* - 8 chars: ~2.8T namespace → ~1M+ items at 25% collision prob
*/
export declare function getAdaptiveHashLength(count: number): number;
/**
* Convert UUID to base36 hash
* Takes first N hex digits of SHA256(UUID) and converts to base36
*/
export declare function hashUUIDToBase36(uuid: string, length: number): string;
/**
* Check if ID is legacy format (SPEC-001, ISSUE-001)
*/
export declare function isLegacyID(id: string): boolean;
/**
* Check if ID is hash format (i-x7k9, s-a3f2)
*/
export declare function isHashID(id: string): boolean;
/**
* Generate spec ID and UUID
* Returns hash-based ID derived from UUID
*/
export declare function generateSpecId(db: Database.Database, outputDir: string): {
id: string;
uuid: string;
};
/**
* Generate issue ID and UUID
* Returns hash-based ID derived from UUID
*/
export declare function generateIssueId(db: Database.Database, outputDir: string): {
id: string;
uuid: string;
};
/**
* Generate a UUID v4
*/
export declare function generateUUID(): string;
//# sourceMappingURL=id-generator.d.ts.map