/** * Worktree path primitives — project hashing + canonical worktree root. * * Canonical layout per D029: * `/worktrees///` * * `cleoHome` is resolved via {@link getCleoHome} (env-paths + `CLEO_HOME` override). * * Council verdict D009 (T9802 / SG-WORKTREE-CANON) added the hybrid sentinel * index concept: a per-project JSON file at `/.cleo/worktrees.json` * that acts as the canonical registry of active worktrees for that project. * Use {@link resolveWorktreeIndexPath} to get this path. * * @task T1883 * @task T9802 */ /** * Compute a stable 16-character project hash from an absolute project root path. * * Uses SHA-256 truncated to 16 hex chars. The truncation is consistent with * the historical implementation in `branch-lock.ts#resolveAgentWorktreeRoot` * (the root cause of the duplicated logic this package consolidates). * * **Cross-mount normalization (T11023 AC3):** The input path is resolved * through `realpathSync` before hashing so that different mount points * (/mnt/projects/X vs /workspace/X) produce the same hash. * * @param projectRoot - Absolute path to the project root. * @returns 16-character lowercase hex string. * * @public */ export declare function computeProjectHash(projectRoot: string): string; /** * Resolve the worktrees root directory for a given project hash. * * Result: `/worktrees//` * * Priority: * 1. Explicit `worktreeRoot` arg (used by tests / config overrides) * 2. `CLEO_HOME` env var via {@link getCleoHome} * 3. env-paths XDG data dir via {@link getCleoHome} * * @param projectHash - 16-char project hash from {@link computeProjectHash}. * @param worktreeRoot - Optional explicit override for the full root path. * @returns Absolute path to the project-scoped worktree root directory. * * @public */ export declare function resolveWorktreeRootForHash(projectHash: string, worktreeRoot?: string): string; /** * Resolve the worktree directory for a specific task. * * Result: `/worktrees///` * * @param projectHash - 16-char project hash from {@link computeProjectHash}. * @param taskId - The task ID. * @param worktreeRoot - Optional override for the worktree root. * @returns Absolute path to the task-specific worktree directory. * * @public */ export declare function resolveTaskWorktreePath(projectHash: string, taskId: string, worktreeRoot?: string): string; /** * Resolve the canonical worktrees-by-project root for the current process — * `/worktrees/`. Project-agnostic; useful when listing or scanning * across all projects. * * @returns Absolute path to `/worktrees/`. * * @public */ export declare function getCleoWorktreesRoot(): string; /** * Resolve the canonical SENTINEL INDEX path for active worktrees associated * with a project — `/.cleo/worktrees.json`. * * Council verdict D009 (T9802 / SG-WORKTREE-CANON) introduced the hybrid * worktree-location model: worktree directories themselves live under the XDG * data directory (see {@link resolveWorktreeRootForHash}), while a lightweight * JSON index file lives **inside the project** at * `/.cleo/worktrees.json`. This sentinel acts as the canonical * registry of active worktrees for that project and is: * * - **Tracked alongside project state** — lives in `.cleo/` (git-ignored), * survives across `CLEO_HOME` changes and machine migrations. * - **Machine-local** — absolute XDG paths inside the JSON are valid only on * the machine that created them; consumers must handle stale entries. * - **FILE not DIRECTORY** — the path ends in `.json`, never a directory. * Create with `JSON.stringify` + `fs.writeFileSync`; read with * `JSON.parse(fs.readFileSync(...))`. * * Invariant: the returned path is always * `/.cleo/worktrees.json` regardless of `CLEO_HOME`, XDG * environment variables, or platform. It is the T9805 lifecycle hook's * canonical write target. * * @param projectRoot - Absolute path to the project root (the directory that * contains the `.cleo/` subdirectory for this project). * @returns Absolute path to `/.cleo/worktrees.json`. * * @example * ```typescript * import { resolveWorktreeIndexPath } from '@cleocode/paths'; * * const indexPath = resolveWorktreeIndexPath('/mnt/projects/cleocode'); * // "/mnt/projects/cleocode/.cleo/worktrees.json" * ``` * * @public */ export declare function resolveWorktreeIndexPath(projectRoot: string): string; //# sourceMappingURL=worktree-paths.d.ts.map