UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

73 lines • 4.24 kB
export interface PathInputOptions { /** Trim leading/trailing whitespace before normalization. */ trim?: boolean; /** Expand leading `~` to a home directory. Defaults to true. */ expandTilde?: boolean; /** Home directory used for `~` expansion. Defaults to `os.homedir()`. */ homeDir?: string; /** Strip a leading `@`, used for CLI @file paths. */ stripAtPrefix?: boolean; /** Normalize unicode space variants to regular spaces. */ normalizeUnicodeSpaces?: boolean; } /** * Resolve a path to its canonical (real) form, following symlinks. * Falls back to the raw path if resolution fails (e.g. the target does * not exist yet), so that callers never crash on missing filesystem * entries. */ export declare function canonicalizePath(path: string): string; /** * {@link canonicalizePath} that refuses to guess. * * The convenience form hands back its input when resolution fails, which is what most callers * want: they compare two canonical spellings and an unresolvable path simply compares unequal. * A security decision cannot use that, because the raw input is indistinguishable from a * canonical answer - so a path that could not be resolved would be keyed, compared, or trusted * under a spelling the filesystem never confirmed. This form throws instead, leaving the caller * to decide what an unresolvable path means. */ export declare function canonicalizePathStrict(path: string): string; /** * Resolve symlinks without ever open(2)-ing a component, tolerating every error. * * Bun's `fs.realpath*` opens every directory it resolves, so an autofs trigger such as macOS * `/home` blocks the calling thread (on the host main thread that freezes the TUI) and an * execute-only directory fails with EACCES; lstat needs only search permission and never mounts * anything. Components from the first unresolvable one onward are kept verbatim, so a file that * does not exist yet still lands where its symlinked parent points. * * Never throws, so the resolved path may be incomplete. Use it where an approximate answer is * better than a blocked thread — the external-path classifier and the monitor parent identity — * and use {@link realpathWithoutOpenStrict} where an incomplete answer must not be trusted. */ export declare function realpathWithoutOpen(inputPath: string): string; /** * {@link realpathWithoutOpen} that refuses to answer with a guess: a missing component is still * tolerated (its name is appended verbatim, which is what a not-yet-created target needs), but * EACCES, EIO, ELOOP and hop exhaustion throw instead of returning an unresolved path. Callers * that feed a canonical path into a containment or identity decision need this contract, because * an unresolved path can name a different file than the one the I/O will reach. */ export declare function realpathWithoutOpenStrict(inputPath: string): string; export declare function getFileRevision(path: string): string | undefined; /** * Returns a revision derived from file contents rather than filesystem timestamps. * Use this when a same-tick rewrite must invalidate an in-memory snapshot. */ export declare function getFileContentRevision(path: string): string | undefined; /** * Returns true if the value is NOT a package source (npm:, git:, etc.), * a built-in extension (builtin:), or a remote URL protocol. Bare names, * relative paths, and file: URLs are considered local. */ export declare function isLocalPath(value: string): boolean; /** Convert Git Bash, MSYS, Cygwin, and WSL drive paths to a form native Windows APIs accept. */ export declare function normalizeWindowsShellPath(filePath: string): string; export declare function normalizePath(input: string, options?: PathInputOptions): string; export declare function resolvePath(input: string, baseDir?: string, options?: PathInputOptions): string; export declare function getCwdRelativePath(filePath: string, cwd: string): string | undefined; export declare function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string): string; export declare function shortenPath(path: string): string; export declare function markPathIgnoredByCloudSync(path: string): void; //# sourceMappingURL=paths.d.ts.map