Repository navigation
Conversation
AI agents and scripts can now ask disktree where the space went without opening a window: - `disktree scan PATH [--json]` prints a stable, documented report: the total, the largest directories and files, each with path, bytes, human size, type, modified time, depth, category and reclaim reason. Options for top-N, listing depth, apparent vs on-disk size, exclude patterns and staying on one filesystem; filters for minimum size, extension, older-than, name pattern, category and reclaim reason. - `disktree summary PATH [--json]`: the volume's capacity and free space, without scanning. - `disktree mcp`: a stdio MCP server with scan_path, largest_files, largest_dirs, list_files and disk_summary, returning the same JSON. Scans are cached for five minutes, report progress, and stop when cancelled. Everything lives in a new `disktree-agent` crate that reuses `disktree_core::scan` and never reaches `removal` or `export`; a test fails the build if its source ever names them or any file-writing call, and every tool is annotated read-only. The core gains `ScanOptions::exclude`, applied as entries are listed so excluded trees are never walked (the Windows MFT reader falls back to the walk when patterns are set). The window is unchanged: the subcommands are handed over in `main` before any settings or GPUI code runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
AI agents and scripts can ask disktree where the space went, without a window and without any way to change anything.
disktree scan PATH [--json]prints a stable, documented report: the total plus the largest directories and files, each withpath,bytes, humansize,type,modified,depth,categoryandreclaim. Options:--top,--depth(a listing depth over a full scan, so totals stay exact),--apparent-size,--exclude(repeatable),-x/-X,--only dirs|files. Filters:--min-size 1G,--ext iso,dmg,--older-than 6mo|2025-01-31,--name PATTERN,--category cache,--reclaim any|build-output|…(category and reclaim list only the outermost matching folder, so--category cachegives you~/.cache, not every folder inside it). Without--jsonit prints a short table.disktree summary PATH [--json]: capacity, used, free and available space for the volume. Nothing is scanned.disktree mcp: a stdio MCP server withscan_path,largest_files,largest_dirs,list_filesanddisk_summary. They return the same JSON as the CLI, asstructuredContentand as text.refresh: trueforces a new walk.notifications/cancelledstops the walk.isErrortool results.The JSON is documented field by field in
docs/agent-json.mdand versioned byschema_version. The README has a new "For scripts and AI agents" section with Claude Desktop, Cursor and Claude Code configs.Read-only, and how that is enforced
crates/disktree-agent, which depends ondisktree-corefor scanning only. It never namesremovalorexport.tests/read_only.rsreads the crate's own source and fails onremoval,export::,trash::,remove_file,remove_dir,rename(,fs::write,File::create,OpenOptions,Command::newand similar.readOnlyHint: true, destructiveHint: false, and a test checks that no tool name suggests otherwise.main, before Power Efficiency settings are loaded or saved, and before the cmux re-spawn, which would otherwise point stdout at/dev/null.Changes outside the new crate
disktree-core:ScanOptions::exclude, a compiled pattern set (exclude.rs). It is checked in the walk'sclassify, so excluded trees are never entered, and costs nothing when empty./match names; with/they match paths.*stays inside one path component,**crosses components, and?matches one character.follow_links.disktree-app/src/main.rs: the dispatch above, plus three usage lines. Nothing else in the window changed. A directory literally namedscanstill opens asdisktree ./scan.serde_json,dunceandchrono, all already in the lockfile. Nothing new is downloaded.Testing
cargo xtask lint(fmt check, then clippy with-D warnings) andcargo xtask testpass on macOS (Apple silicon). That includes 25 new agent tests, 5 new core tests and the existing 71 window-harness tests.cargo clippy -p disktree-core -p disktree-agent --all-targets -- -D warningsis clean forx86_64-pc-windows-msvcandx86_64-unknown-linux-gnu.disktree-appcan't be cross-checked for Windows from a Mac (GPUI's build script needs the Windows SDK), so CI is the first Windows build ofmain.rs.disktree scan ~ --jsonon a real home directory: 6.3M files and 718k directories (416 GiB) in 48 s, headless, exit 0.initialize,tools/listandscan_pathon a 3.8M-file tree, with progress notifications;list_filescall answered in 0.2 s;largest_dirswithcategory=cache;disk_summary.🤖 Generated with Claude Code