feat(tools): bound list_directory output; root call is a folders-only overview - #513
Merged
Merged
Conversation
… overview `list_directory` was the one read tool with no output cap: it walked every vault file, defaulted to depth 3 with files included, and returned a JSON tree carrying name, extension and size per file. In a vault with thousands of notes a single orientation call could cost tens of thousands of tokens — and the explore-vault skill told the model to make that call first. Now: - Root call (no path) is an overview: folders with recursive file counts, 2 levels deep, no file names. It stays a few hundred tokens in any vault. Inside a folder, files are listed (1 level deep by default). `includeFiles` / `maxDepth` override either. - Output is bounded by a context-derived budget (5% of the window, capped at 40k chars) and shrinks structurally, never mid-JSON: tighter per-folder caps first, then one level shallower. `moreFiles` / `moreFolders` say what was left out, `note` says how to get it. - Compact shape: files are bare names, sizes dropped, every folder carries `fileCount`. - `recursive` / `includeFolders` parameters removed (`maxDepth` alone expresses the former). - Tool description always uses the shipped default rather than a persisted copy, matching read_content / search_notes — descriptions aren't user-editable. - explore-vault 1.1 → 1.2: tags and properties first; list the root only when layout matters; never walk the tree to find a note. 1.1 body retained in history per the shipped-skill protocol. - Chat tool card renders the new shape (counts, "+N more" rows, no size column). Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
…pse in overviews Review follow-ups on #513: - The collapse ladder could fall through with an over-budget listing when even twenty top-level folder names were too long for the floor budget. Two last-resort rungs, tried only at depth 1, now end at "counts only" — a few hundred characters for any vault. - A folders-only overview that had to drop folders produced `moreFolders` without a `note`, because collapse detection was gated on `includeFiles`. Omitted folders now always count as a collapse; omitted files count only when file names were requested. Co-Authored-By: Claude <noreply@anthropic.com>
…when it is available The explore-vault procedure sent every "which notes…" question through tags, properties, a broad search and several reads. Where the Dataview integration is enabled, that is one DQL query returning a compact table — far cheaper in context and more accurate for counts. - dataview 1.1 → 1.2: the description (what the model sees in the always-visible skills block) now names the trigger questions — a category of notes, a filter by tag/property/date, counts and groupings — and says to prefer it over search for structural questions. A new "When to reach for it" section draws the line: structure yes, prose no; verify names first; combine with read_content for the few notes that matter. 1.1 body retained in history. - explore-vault (still 1.2, unreleased): step 1 loads the dataview skill first when it is listed; step 6 prefers a GROUP BY / sum query over gather-then-execute_javascript. Both mentions are conditional on the skill being listed, so a vault without Dataview reads one inert line. Co-Authored-By: Claude <noreply@anthropic.com>
…fault A GROUP BY, count or sum is only correct over the whole result set; the display limit applies to LIST / TABLE output shown to the user. Review follow-up on #513. Co-Authored-By: Claude <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
list_directoryhad no output cap: it walked every vault file at depth 3 with files included and returned a JSON tree with name, extension and size per entry, so one orientation call in a large vault could fill tens of thousands of tokens of context — and the explore-vault skill told the model to make that call first.includeFiles/maxDepthoverride both defaults.moreFiles/moreFoldersmark what was omitted,notetells the model how to see it (subfolder path, orsearch_notes/grep_notes).fileCount.recursiveandincludeFoldersparams removed (maxDepthalone expresses the former).read_content/search_notesalready do) so existing agents aren't stuck describing the old shape.src/skills/history/per the shipped-skill protocol.read_content). explore-vault step 1 loads it first when listed, step 6 prefers aGROUP BYquery over gather-then-execute_javascript. Both mentions are conditional, so a vault without Dataview reads one inert line. 1.1 body retained in history.How I tested it
bun run check,format,lint,test(1863 passing, incl. new budget-collapse tests and the shipped-skill history guard); madge reports no cycles. Built once in slot wt3; not yet exercised in a live vault — that is Leo's call.AI assistance: Claude Code implemented it from Leo's brief ("the agent lists the vault so often that large vaults fill the context — how to avoid it"); Leo reviewed the approach and will live-test in his vault.
Checklist
bun run check,bun run format,bun run lint, andbun run testpass locallymanifest.json: I noted that the docs site needs updating (see "Documentation" in CONTRIBUTING.md)