/** * @fileoverview SkillVersionRepository — persistent content-hash version tracking * @module @skillsmith/core/repositories/SkillVersionRepository * @see SMI-skill-version-tracking Wave 1 * * Records a content hash after every successful skill upsert so that the * skill_updates MCP tool (Individual tier) can detect registry changes by * comparing the locally-stored hash against the current registry hash. * * Design notes: * - No FK on skill_id — soft reference, version history survives skill removal * - recordVersion is idempotent via INSERT OR IGNORE on the unique index * - pruneVersions keeps the 50 most-recent rows per skill (configurable) */ import type { Database as DatabaseType } from '../db/database-interface.js'; /** * Raw database row for skill_versions */ export interface SkillVersionRow { id: number; skill_id: string; content_hash: string; recorded_at: number; semver: string | null; metadata: string | null; } /** * Repository for reading and writing skill version records */ export declare class SkillVersionRepository { private db; constructor(db: DatabaseType); /** * Record a version hash for a skill. * * Idempotent: if (skill_id, content_hash) already exists the INSERT is * silently ignored (INSERT OR IGNORE on the unique index). * * After inserting, prunes rows beyond keepCount to bound table growth. * * @param skillId Registry skill identifier * @param contentHash SHA-256 hex digest * @param semver Optional semver string * @param metadata Optional JSON string for future extension * @param keepCount Maximum rows to keep per skill (default 50) */ recordVersion(skillId: string, contentHash: string, semver?: string, metadata?: string, keepCount?: number): Promise; /** * Get the most recently recorded version for a skill. * * @param skillId Registry skill identifier * @returns Most recent SkillVersionRow or null if none recorded */ getLatestVersion(skillId: string): Promise; /** * Get the full version history for a skill, newest first. * * @param skillId Registry skill identifier * @param limit Maximum rows to return (default 20) * @returns Array of SkillVersionRow ordered by recorded_at DESC */ getVersionHistory(skillId: string, limit?: number): Promise; /** * Look up a specific version by its content hash. * * @param skillId Registry skill identifier * @param contentHash SHA-256 hex digest to look up * @returns Matching SkillVersionRow or null */ getVersionByHash(skillId: string, contentHash: string): Promise; /** * Prune version history to at most keepCount rows per skill. * * Uses the subquery pattern (DELETE WHERE id NOT IN SELECT … LIMIT) * which is compatible with SQLite's restricted DELETE syntax. * * @param skillId Registry skill identifier * @param keepCount Number of most-recent rows to retain (default 50) */ pruneVersions(skillId: string, keepCount?: number): Promise; } //# sourceMappingURL=SkillVersionRepository.d.ts.map