Skip to content

feat(codedb): grok-build list_dir inside codedb - #579

Merged
justrach merged 5 commits into
release/v0.0.268from
cursor/codedb-list-dir-554f
Aug 20, 2026
Merged

feat(codedb): grok-build list_dir inside codedb#579
justrach merged 5 commits into
release/v0.0.268from
cursor/codedb-list-dir-554f

Conversation

@justrach

@justrach justrach commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Why

Grok-build's list_dir (BFS, .gitignore, any folder, 10k-char cap) is the listing we were reaching for with bash ls. Graff already owns that slot with codedb — a new always-on catalog tool would tax every turn (that is how the first #574 A/B lost).

What

codedb list_dir <path> is implemented in-process (no codedb binary, no index):

  • BFS: depth-1 seed first so a fat sibling cannot hide later top-level dirs
  • .gitignore + .git/info/exclude when the walk is inside a git repo; without a git root, only the walk dir's ignore file (no climb into /tmp/.gitignore)
  • .git omitted; other dotfiles stay visible (.github is load-bearing)
  • 10k-character budget; leftover dirs collapse to [N files in subtree: K *.ext]
  • Same PathConfine jail as read_file, including --add-dir extra roots

codedb ls / tree stay index queries. ADR 0013 records the "subcommand, not catalog tool" decision.

The root prompt now says to use this instead of bash ls.

Sibling: codedb repo

Same algorithm in a checkout at /workspace/codedb (gitignored here, like surfer/):

Graff stays in-process so --add-dir and a missing binary still work.

Showcase (offline)

python3 scripts/list-dir-showcase.py
python3 scripts/list-dir-showcase.py --self-test

Measured on a 400-file fat-sibling fixture (gitignore + .git + .github):

walk chars time
find -print 30,341
ls -la 580
codedb list_dir 153 6 ms
codedb ls (index) 103 (one level, no collapse) 39 ms

list_dir is 198× smaller than find, hides skip.log / build/, keeps .github, collapses aaa/ to [400 files in subtree: 400 *.zig], and still lists zzz/tail.md. Catalog stays one codedb tool.

Tests

  • gitignore: star / dir-only / negation / rooted / nested / ** / no-git-root climb
  • list_dir: hides ignored + .git, keeps .github, fat-sibling collapse, extra-root listing, confinement, empty dir
  • Prompt golden updated
  • Showcase --self-test green
  • Tier 1: fmt, lines, spec, reach (1461 declared at first cut; +1 after climb fix), build, sdk sync. zig build test for the new cases is green.

Base: release/v0.0.268.

Open in Web Open in Cursor 

Port grok-build's directory listing into the existing codedb tool instead
of adding a catalog entry. codedb list_dir walks any PathConfine folder
(including --add-dir), honors .gitignore, seeds depth-1 so a fat sibling
cannot hide the rest, and collapses leftover dirs under a 10k-char budget.
A listing of an unindexed extra root must not inherit /tmp/.gitignore
(or /). Nested files under the walk dir still apply.
Keep a local codedb/ checkout (gitignored, like surfer/) so the harness
and github.com/justrach/codedb#696 can evolve the same BFS listing.
Graff still runs list_dir in-process for PathConfine.
The sibling checkout is /workspace/codedb (gitignored). CLI list_dir
landed there as #696 / #697; graff stays in-process for PathConfine.
Prints the current graff surface (one codedb tool, prompt-cache max)
and a fixture bake-off: find/ls vs codedb list_dir vs codedb ls.
No provider. --self-test checks gitignore, 10k cap, and catalog tax.
@justrach
justrach marked this pull request as ready for review August 20, 2026 07:44
@justrach
justrach merged commit 332c001 into release/v0.0.268 Aug 20, 2026
6 checks passed
@justrach
justrach deleted the cursor/codedb-list-dir-554f branch August 20, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants