/** * Multi-level path tree shared by grouped file listings (find / grep / ast tools) * and compaction file-operation lists. * * Flat path lists used to group by the *immediate* parent directory and print the * full directory path in every header. For results spread across a deep tree — or * rooted outside cwd, where paths stay absolute — that repeated the shared prefix * on every line. The tree below folds single-child directory chains (so the common * prefix collapses into one header) and nests the rest, charging the model one * token per path segment instead of one per file. */ /** True for `scheme://…` entries that have no meaningful directory structure. */ export declare function isUrlLikePath(filePath: string): boolean; export interface PathTreeNode { /** Direct file leaves, in first-seen order. */ files: Array<{ name: string; key: string; }>; /** Dedup set for `files` (a glob can surface the same path twice on retry). */ fileNames: Set; /** Child directories, in first-seen order. */ subdirs: Array<{ name: string; node: PathTreeNode; }>; /** Dedup index for `subdirs`. */ dirIndex: Map; } export interface PathTreeInput { /** Path string; absolute, cwd-relative, or url-like. Backslashes are normalized. */ path: string; /** Whether the leaf itself is a directory (trailing-slash match from find). */ isDir: boolean; /** Opaque key carried onto file events for section lookup. Defaults to `path`. */ key?: string; } /** One node emitted while walking the tree: a folded directory or a file leaf. */ export interface GroupedTreeEvent { kind: "dir" | "file"; /** 0-based nesting depth (root children are depth 0). */ depth: number; /** Folded chain for dirs (e.g. `a/b/c`, no trailing slash); basename for files. */ name: string; /** File key for `kind === "file"`; empty string for directories. */ key: string; } /** * Build a directory tree from a flat list of paths. URL-like entries are kept * whole as root-level file leaves (they have no meaningful directory structure). * Absolute paths carry a leading empty segment so they share a common `/` root * and fold like any other prefix. */ export declare function buildPathTree(entries: Iterable): PathTreeNode; /** * Depth-first walk yielding directory and file events. Directories collapse their * single-child chains (`a` → `a/b` → `a/b/c`) so a shared prefix becomes one * header. Each node's direct files are emitted before its subdirectories, keeping * a file unambiguously attached to the header above it. */ export declare function walkPathTree(node: PathTreeNode, depth?: number): Generator; /** * Render a flat path list as a grouped, prefix-folded directory tree without * per-file bodies (find-tool output shape, also used by compaction `` * lists). Single-child directory chains fold into one header (`# a/b/c/`), * each level adds one `#`, and files are listed bare under the deepest * directory header that owns them. Trailing-slash entries are directory * leaves and keep their slash in the header. * * `annotate` receives each file's full original path and its return value is * appended verbatim to the file line (e.g. ` (RW)`). * * Order follows the input: a directory appears when its first member is * emitted, and a node's own files precede its subdirectories. */ export declare function formatGroupedPaths(paths: readonly string[], annotate?: (path: string) => string): string;