/** * Git Hooks Installer for User Projects * * Installs pre-commit hooks to enforce SpecWeave best practices: * - Root folder pollution check (CRITICAL) * - Increment folder cleanliness * - Duplicate increment detection * - YAML frontmatter validation * - Mass deletion protection */ /** * Version of the hook body this build ships. Bump whenever the template * changes behaviour so already-installed hooks in user repos get refreshed * instead of being left on a stale (1.x) body forever. */ export declare const PRE_COMMIT_HOOK_VERSION = "2.0.0"; /** * Render the pre-commit template: substitutes the increment-root allow-list so * the shipped hook can never drift from INCREMENT_ROOT_FILES. */ export declare function renderPreCommitHook(template: string): string; /** Version stamped into an installed SpecWeave hook, or null if absent/foreign. */ export declare function readInstalledHookVersion(content: string): string | null; /** * True when an installed SpecWeave hook is older than the one we ship and must * be rewritten. Foreign (non-SpecWeave) hooks are never touched. */ export declare function needsHookRefresh(existingContent: string): boolean; /** Outcome of {@link refreshManagedGitHook}. */ export type HookRefreshOutcome = /** No `.git/hooks/pre-commit` at all — nothing to refresh. */ 'absent' /** Not a git repository (or no `.git` directory). */ | 'not-a-repo' /** A hand-written / third-party hook. Never touched. */ | 'foreign' /** A SpecWeave hook already at the shipped version. */ | 'current' /** A stale SpecWeave hook that was rewritten to the shipped template. */ | 'refreshed' /** A stale SpecWeave hook that WOULD be rewritten (`--check` / dry run). */ | 'would-refresh' /** The refresh was attempted and failed (permissions, missing template). */ | 'failed'; export interface HookRefreshResult { outcome: HookRefreshOutcome; /** Version stamped in the hook found on disk (null when foreign/absent). */ installedVersion: string | null; /** Version this build ships. */ shippedVersion: string; /** Human-readable one-liner for CLI output. */ message: string; } /** * Refresh an ALREADY-INSTALLED SpecWeave pre-commit hook to the shipped * template. Used by `specweave update` so an upgraded 1.x project does not keep * a hook body that rejects `ledger.jsonl` at the increment root and reports a * false duplicate id for every increment that has a `reports/` folder. * * Deliberately conservative: * - a hook the USER wrote (no `SpecWeave Pre-Commit Hook` marker) is left * alone and reported, never rewritten; * - a project with no hook at all is left alone (installing one is `init`'s * job, not an upgrade side effect). */ export declare function refreshManagedGitHook(projectPath: string, templatesDir: string, options?: { dryRun?: boolean; }): HookRefreshResult; /** * Install git pre-commit hook in user project * * @param projectPath - Project directory path * @param templatesDir - Templates directory path * @returns Success boolean */ export declare function installGitHooks(projectPath: string, templatesDir: string): boolean; /** * Uninstall SpecWeave git hooks * * @param projectPath - Project directory path * @returns Success boolean */ export declare function uninstallGitHooks(projectPath: string): boolean; /** * Check if SpecWeave git hooks are installed * * @param projectPath - Project directory path * @returns True if installed */ export declare function areGitHooksInstalled(projectPath: string): boolean; //# sourceMappingURL=git-hooks-installer.d.ts.map