Repository navigation
scan: add a local JSON Lines mode to the headless helper - #119
Open
snowsword20 wants to merge 1 commit into
Open
snowsword20 wants to merge 1 commit into
snowsword20 wants to merge 1 commit into
Conversation
disktree-scan scan PATH [--apparent-size] [--no-hidden] [--min-size N] writes the finished tree as JSON Lines, one directory per line, parent before children, children largest first. Same read-only promise as the SSH helper: no stdin, no deletion. Scripts and coding agents cannot open a window, and du is an order of magnitude slower than the scanner on the same tree. The mode reuses disktree_core::scan unchanged; directories below --min-size are left out of the output while the totals on surviving lines stay complete.
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.
Closes the proposal in issue #118 (headless
scanmode for scripts and coding agents).What
A
scansubcommand ondisktree-scan, the GPUI-free helper:It runs the same read-only scan the treemap draws and writes JSON Lines to stdout — one directory per line, parent before children, children largest first:
--min-size Nprunes printed directories while totals on surviving lines stay complete. Same promises as--stdio-v1: no stdin, no deletion surface, no GPUI dependency.Why
Scripts and coding agents cannot open a window, and
duis an order of magnitude slower than the scanner on the same tree (measured: >20 min vs 30 s cold / 2.6 s warm on a 364k-file HDD tree). The app already exportsagent_promptfor the cleanup half; this gives agents the scan half, so the whole loop can run headless.How
disktree_core::scan::scanis reused unchanged; the mode parses its own flags, calls it, and walks the returned tree writing one JSON object per line. ~180 lines in the helper, one new dependency (serde_json), no app or protocol changes.Tests
Four new tests in the helper: root summary first,
--min-sizepruning (pruned subtree still counted on the parent), apparent vs allocated bytes, and flag validation (missing/repeated path, unknown option).Related prior art (and why this still exists)
Three open proposals overlap with this one, all worth reading before judging it:
disktree-cli— the ambitious shape: scan, findings, git state, and removal through disktree's own guards. It is the fuller product; it also carries a destructive surface and a new distribution artifact, which may be part of why it is still open.dupersonality on disktree-core, meeting agents where they already are (du -sh *).disktree --cli: print the tree to stdout, for agents and headless sessions #74 — a human- and agent-readable text tree from the main binary, keeping the JSON surface JSON.This PR deliberately takes the smallest slice: JSON Lines out of the existing read-only helper. No new binary, no destructive surface, no opinion about what a fuller CLI should eventually be. If the direction lands on #32 or a
--cliflag instead, this is ~180 lines to rebase or close — and the tests travel.