/** * Tree Formatter * * Formats directory structures as ASCII tree output. * Works with any WorkspaceFilesystem implementation. * * @example * ```typescript * import { formatAsTree } from './tree-formatter.js'; * * const result = await formatAsTree(filesystem, '/', { maxDepth: 3 }); * console.log(result.tree); * // . * // src * // index.ts * // utils * // helpers.ts * // package.json * console.log(result.summary); * // "2 directories, 3 files" * ``` */ import type { WorkspaceFilesystem } from '../filesystem/index.js'; import type { IgnoreFilter } from '../gitignore.js'; export interface TreeOptions { /** Maximum recursion depth (default: Infinity). Similar to tree's -L flag. */ maxDepth?: number; /** Show hidden files/directories starting with '.' (default: false). Similar to tree's -a flag. */ showHidden?: boolean; /** List directories only, no files (default: false). Similar to tree's -d flag. */ dirsOnly?: boolean; /** Pattern to exclude from listing (e.g., 'node_modules'). Similar to tree's -I flag. */ exclude?: string | string[]; /** Filter by file extension (e.g., '.ts'). Similar to tree's -P flag. */ extension?: string | string[]; /** Glob pattern(s) to filter files. Matches against paths relative to the listed directory. Directories always pass through so their contents can be checked. */ pattern?: string | string[]; /** Filter function that returns true if a relative path should be ignored (e.g., from .gitignore). */ ignoreFilter?: IgnoreFilter; /** Respect .gitignore entries in the listed directory (default: true). */ respectGitignore?: boolean; } export interface TreeResult { /** ASCII tree representation */ tree: string; /** Human-readable summary (e.g., "3 directories, 12 files") */ summary: string; /** Number of directories found */ dirCount: number; /** Number of files found */ fileCount: number; /** Whether output was truncated due to maxDepth */ truncated: boolean; /** Relative paths for compact output */ paths: string[]; } /** * Format a directory as an ASCII tree. * * @param fs - WorkspaceFilesystem implementation * @param path - Root path to format * @param options - Formatting options * @returns Tree result with formatted string and counts */ export declare function formatAsTree(fs: WorkspaceFilesystem, path: string, options?: TreeOptions): Promise; /** * Format entries directly (without filesystem access). * Useful when you already have the entries and want tree output. * * @param entries - Flat list of entries with path-like names (e.g., "dir/subdir/file.txt") * @returns Formatted tree string */ export declare function formatEntriesAsTree(entries: Array<{ name: string; type: 'file' | 'directory'; }>): string; //# sourceMappingURL=tree-formatter.d.ts.map