/** * Guards for files Codeep writes inside a project. * * A project's `.codeep/` directory usually arrives with a cloned repo, so the * repo decides what its entries are. writeFileSync and mkdirSync follow * symlinks: a committed `.codeep/progress.md -> ~/.zshrc`, or a symlinked * `.codeep/` itself, would have Codeep overwrite, append to or delete files the * user never pointed it at. */ export declare class UnsafeProjectPathError extends Error { readonly path: string; constructor(path: string); } /** * True when `dirPath` is a real directory tree under `projectRoot`: it lies * inside the root by name, and every part of it that exists — itself * included — is a directory, not a symlink to one. Missing parts are fine: * mkdirSync creates real directories. * * The root itself may be a symlink; the user chose to open it. */ export declare function isSafeProjectDir(projectRoot: string, dirPath: string): boolean; /** * True when writing `filePath` lands exactly where the path says: the file * lies inside `projectRoot`, no existing directory between the root and the * file is a symlink, and the file itself — if it exists — is a regular file, * not a symlink. */ export declare function isSafeProjectWriteTarget(projectRoot: string, filePath: string): boolean; /** Create `dirPath` under `projectRoot`, refusing a path through a symlink. */ export declare function ensureProjectDir(projectRoot: string, dirPath: string): void; /** Write a file under `projectRoot`, creating its directory, never through a symlink. */ export declare function writeProjectFile(projectRoot: string, filePath: string, data: string): void; /** Append to a file under `projectRoot`, creating its directory, never through a symlink. */ export declare function appendProjectFile(projectRoot: string, filePath: string, data: string): void; /** * writeFileSync that refuses a symlink as the file itself. For files whose * directory was already checked (or is the user's own), where only the last * component can still be a link. */ export declare function writeFileNoFollow(filePath: string, data: string): void; /** * A notice for a project whose `.codeep/` (or its sessions directory) is a * symlink, or null. Codeep does not write through it, so without this the * user would find their sessions, notes and logs silently not saved there. */ export declare function symlinkedCodeepNotice(projectRoot: string): string | null; /** * True when `filePath` exists and, with symlinks resolved, lies outside the * (resolved) project root — a committed `CODEEP.md -> ~/.aws/credentials`. * A path that does not resolve is not judged here; reading it fails on its own. */ export declare function leadsOutsideProject(filePath: string, projectRoot: string): boolean;