// engine/hooks/handlers/on-delete.ts — on-delete hook handler (SPEC-129)
// Flags broken annotations, warns about changed spec scope, removes hash snapshots.
import { removeStoredHash } from './on-save.js';
// ---------------------------------------------------------------------------
// Handler
// ---------------------------------------------------------------------------
/**
 * Handle on-delete event for a removed file.
 * - Flags broken @spec annotations in other files referencing this file
 * - Warns about affected spec scope
 * - Removes file from hash snapshots
 */
export function handleOnDelete(relPath, ctx) {
    const normalizedPath = relPath.replace(/\\/g, '/');
    const affectedSpecs = [];
    const brokenAnnotations = [];
    // Check which specs reference this file
    for (const entry of ctx.specAnnotations) {
        if (entry.annotatedFiles.includes(normalizedPath)) {
            affectedSpecs.push(entry.specId);
            brokenAnnotations.push(`${entry.specId}: ${normalizedPath}`);
        }
    }
    // Remove from hash snapshots
    removeStoredHash(normalizedPath);
    return {
        hook: 'on-delete',
        path: normalizedPath,
        affectedSpecs,
        brokenAnnotations,
    };
}
//# sourceMappingURL=on-delete.js.map