Skip to content

refactor(init): make list_dir bounded and metadata-only - #1446

Merged
betegon merged 3 commits into
mainfrom
feat/init-tools-size
Aug 20, 2026
Merged

refactor(init): make list_dir bounded and metadata-only#1446
betegon merged 3 commits into
mainfrom
feat/init-tools-size

Conversation

@betegon

@betegon betegon commented Aug 20, 2026

Copy link
Copy Markdown
Member

CLI side of the simplified repository-tool contract. Pairs with getsentry/cli-init-api#243.

What changed

list_dir now behaves like bounded metadata discovery:

  • regular files include byte size;
  • it never opens or reads file contents just to build a listing;
  • the advisory isBinary sniff is removed;
  • it returns truncated: true when maxDepth/maxEntries stop traversal or a directory cannot be read.

This gives the agent enough information to avoid obviously huge files without paying an extra open/read for every file. When traversal is incomplete, the agent can list a narrower path instead of assuming the result is exhaustive.

Compatibility

File size remains optional and truncated is additive. Older server versions ignore the extra result field; newer servers preserve it through the agent transcript. The existing read-files V2 contract is unchanged.

Validation

  • Init test suite: 34 files, 517 tests
  • Focused filesystem tools: 21 tests
  • TypeScript typecheck
  • Full Biome lint (987 files)
  • git diff --check

The full local CLI suite also ran 9,203 tests successfully; its two existing Bash-completion shell simulations fail on this local macOS shell environment and are unrelated to this diff.

Pairs with the server bash-like file-tool redesign (cli-init-api#243). list_dir
now attaches size (statSync) and an advisory isBinary (NUL sniff of the first
bytes) to each file entry, so the agent can skip huge/binary files without
reading them — the ls -l data it was missing. Additive + backward-safe: DirEntry
gains two optional fields the server's dirEntrySchema already accepts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli Ready Ready Preview Aug 20, 2026 7:52pm

Request Review

@betegon
betegon marked this pull request as ready for review August 20, 2026 19:17
@github-actions github-actions Bot added the risk: low PR risk score: low label Aug 20, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 16ea0c8. Configure here.

Comment thread packages/cli/src/lib/init/tools/list-dir.ts
Addresses Cursor Bugbot on #1446: looksBinary opened every non-directory entry
with a blocking openSync and no regular-file check, so a FIFO in the tree could
hang list_dir (and sentry init); it also attached size/isBinary:false to
symlinks and other special files. Now only entry.isFile() regular files get
hints, and the read opens with O_RDONLY|O_NONBLOCK + re-checks fstat().isFile()
before reading — the same guard read-files uses. Verified: a named pipe no
longer blocks the walk and carries no hints; regular files still get size.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: low PR risk score: low labels Aug 20, 2026
@betegon betegon changed the title feat(init): list_dir returns file size and a binary hint refactor(init): make list_dir bounded and metadata-only Aug 20, 2026
@betegon
betegon merged commit 34c9e72 into main Aug 20, 2026
32 checks passed
@betegon
betegon deleted the feat/init-tools-size branch August 20, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant