/** * Git hook installer (T1588). * * Copies CLEO's project-agnostic git hooks from the * `@cleocode/core/templates/git-hooks/` directory (T9858 relocated from * `packages/cleo/templates/hooks/`) into the target project's * `.git/hooks/` (or `core.hooksPath` if set). * * Project-agnostic: the templates are POSIX `/bin/sh` and have no * node/pnpm dependencies, so they install cleanly into Rust, Python, * bare-repo, or any other environment cleo init runs against. * * Content-based ownership: only exact shipped templates or hash-verified installation receipts authorize * refresh. Foreign and customized files are always preserved. */ import { type GitHookInstallOptions, type GitHookInstallReceipt } from '@cleocode/contracts/git-hooks.js'; /** * Diagnostic marker embedded in shipped hooks. A marker alone never grants * refresh authority; installation validates content hashes. */ export declare const CLEO_HOOK_SENTINEL = "# CLEO_MANAGED_HOOK v1"; /** * The set of hooks CLEO ships and manages. Order matches the order * we iterate them; all names match the on-disk filenames in * `packages/core/templates/git-hooks/` (T9858 relocated cleo→core). */ export declare const CLEO_HOOK_NAMES: readonly ["commit-msg", "pre-commit", "pre-push", "post-merge"]; /** Name of a shipped Git hook. */ export type CleoHookName = (typeof CLEO_HOOK_NAMES)[number]; /** Options for {@link installCleoHooks}. */ export type InstallCleoHooksOptions = GitHookInstallOptions; /** Result of {@link installCleoHooks}. */ export interface InstallCleoHooksResult { /** Absolute path to the hooks dir we wrote into. */ hooksDir: string; /** Recovery receipt for this installation; absent on previews. */ receipt?: GitHookInstallReceipt; /** Names of hooks that were installed (newly written or overwritten). */ installed: CleoHookName[]; /** Names of hooks skipped because a non-CLEO file already exists. */ skipped: CleoHookName[]; /** Reason for each skip, keyed by hook name. */ skipReasons: Partial>; } /** * Install CLEO's git hooks into a project. * * Resolves `core.hooksPath` first (so Husky / lefthook / nested * worktree configs are respected). Git resolves the common directory for linked worktrees. * * For each managed hook: * - If the destination file is missing → write it (mode 0o755). * - If its hash matches a shipped template or receipt → refresh. * - Otherwise preserve it, including files with customized CLEO markers. * * @param projectRoot Absolute path to the git project root. * @param opts See {@link InstallCleoHooksOptions}. * @returns Summary of installed/skipped hooks. * @throws If `projectRoot` is not a git repository. */ export declare function installCleoHooks(projectRoot: string, opts?: InstallCleoHooksOptions): Promise; /** * Detect the CLEO marker for diagnostics, without establishing ownership. * Returns false on read error; installers must validate the content hash. */ export declare function isCleoManagedHook(filePath: string): boolean; /** * Resolve the `.git` directory for a project. Returns `null` when the * path is not inside a git repository. * * Handles both `.git/` (regular repo) and `.git` as a file (worktree * pointing at `gitdir: ...`). */ export declare function resolveGitDir(projectRoot: string): string | null; /** * Resolve the hooks directory the project actually uses. * * If `core.hooksPath` is set (Husky / lefthook / custom), respect it. * Git resolves its common directory for linked worktrees. */ export declare function resolveHooksDir(projectRoot: string, gitDir: string): string; /** * Default templates dir resolution. * * Tries (in order): * 1. Sibling to compiled JS: `/../../templates/git-hooks` * (works once @cleocode/core is installed and shipped with templates). * 2. Monorepo source layout: `/packages/core/templates/git-hooks` * (used during local dev / tests against repo source). * * T9858 relocated the hook templates packages/cleo → packages/core, so the * canonical layout is now `packages/core/templates/git-hooks/`. We retain * fallback probes for the legacy `packages/cleo/templates/hooks/` path so * old global installs continue to function during the v2026.5.x upgrade * window. * * Tests should pass `templatesDir` explicitly to bypass resolution. */ export declare function defaultTemplatesDir(): string; //# sourceMappingURL=hooks-install.d.ts.map