Repository navigation
feat(tree): compact tree with line counts, hub addresses and symbols - #296
Merged
Merged
Conversation
The tree starred the five largest source files with no legend, so a reader could not tell what the star meant, and on this repo it landed on main_more_test.go. File size says nothing about blast radius. The star now marks hubs from the file graph, with the importer count inline: `types.ts ←41` for a file, `scanner/ ←73` on the directory of a multi-file Go package (Go imports name packages, so the count belongs to the package, per #292). N is the importer count used by get_hubs and the session-start hub list; a hub needs 3+ non-test importers, so test files are never starred. One legend line under the tree says what the marker and N mean, and carries the graph note: partial coverage, or why stars are missing (no graph, or the repo is above the 5000-file graph limit). Hubs come from the daemon's validated graph when it was built with the same filters, else a fresh BuildFileGraph scan (docling, no daemon: 0.41s -> 1.8s per `codemap .`; codemap with a warm daemon: no measurable change). The session-start hook drops its own hub block when the tree carries the legend, so hubs are stated once and the werkzeug tree still fits the 10,000 char cap at full depth. --json, --deps, --skyline and --diff output are unchanged. MCP get_structure renders without hub data, so its tree loses the old size stars and gains no legend; its HUB FILES section is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWQw8DzwM4bQnL7mvk6Fsq
Builds on the hub stars and legend from #295. All changes apply to the plain `codemap .` tree; --json, --deps, --skyline and --diff are unchanged. - Fold same-directory tests into their source: `filegraph.go (+3 tests)` (Go x_test/x_*_test, JS/TS .test/.spec, Python test_x/x_test). - Count unmatched tests as `+N other tests`, except in a tests tree (test/, tests/, __tests__/, spec/ or no folded test), which lists its files. - Collapse 4+ siblings that differ only in digit-bearing tokens: `page-*.yml ×9`. - Collapse a wholly untracked directory (git ls-files --others --directory) to one line with its file count and size. - Print a single-file directory as `dir/FILE`, at any depth, so .claude/skills/ and plugins/codemap/skills/ render alike. - Give an overlong name its own row in sorted position instead of forcing a whole directory into one column. - Show physical line counts at 100+ lines (`hooks.go 2535L`; text files up to 2MB, binaries and assets skipped). - Read files for line counts and symbol lines only when Lstat says regular (symlinks, FIFOs and devices skipped), through a reader capped at 2MB+1. - Trailer: `Hubs (top 10 of N)` with full paths, importer counts and line counts, wrapped under 400 chars; `path:line Name` for up to 3 exported top-level functions of the top 5 file hubs, kept only when the reported source line names the symbol; `Next:` commands. - ast-grep function and type matches now record their line (FileAnalysis.SymbolLines, not serialized). - Session-start hook: hubs stated once (its own hub block is dropped when the tree prints the legend), and the tree sheds extras before depth via CODEMAP_TREE_LEAN (1: no symbols, top 3 hubs; 2: also no line counts) before fitSessionStart cuts depth. Renders are cached by depth and level. Measured (`codemap .`, warm, vs origin/main): - codemap (daemon cache warm): 0.04s -> 0.13s; docling (no daemon): 0.40s -> 1.97s, of which the hub graph scan is ~1.4s, line counts and symbols ~0.2s. - Output: codemap 307 -> 163 lines, 16.1KB -> 10.3KB; docling 492 -> 456 lines; CodeMachine-CLI 313 -> 324 lines. - Hook: werkzeug full depth at 8,040 chars (#295: 8,028, full depth); codemap full depth at 8,528 chars (#295: depth 1, 3,369). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWQw8DzwM4bQnL7mvk6Fsq
First-three-exported-in-file-order symbols were arbitrary and Go package hubs got none, so the symbol rows and the ast-grep line recording behind them are gone. The hub list prints one hub per line, right-aligned count first, so names align and no 400-char wrapping is needed; hook lean level 1 now cuts it to three rows. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWQw8DzwM4bQnL7mvk6Fsq
…e-compact-addresses
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.
Follows #295 (hub stars and legend), now merged.
What
Everything here applies to the plain
codemap .tree. The goal is a tree an agent can act on directly: less repeated structure, and addresses it can hand straight torgor a file read.Less noise
filegraph.go (+3 tests). Unmatched tests show as+N other tests, except inside a tests tree, which still lists its files.page-*.yml ×9.dir/FILE.Addresses
hooks.go 2535L.Hubs (top 10 of N, by importers), one hub per line with its importer count, full repo-relative path and line count.path:line Name) were built and then removed: the first exported functions in file order are arbitrary, and Go package hubs got none.Next:line with the follow-up commands.Hook
Evidence
Cost
codemap .About 1.4s of the docling increase is the hub graph scan that #295 already adds. The timings were measured before the symbol lines were removed, so they are an upper bound.
Output size: codemap 307 to 163 lines (16.1KB to 10.3KB), docling 492 to 456 lines, CodeMachine-CLI 313 to 324 lines (22.4KB, up from 20.0KB).
Safety
Line counts read file contents. Reads go through one function that skips anything
Lstatdoes not report as a regular file (symlinks, FIFOs, devices) and reads through a 2MB+1 limit. Known remaining gap: a path swapped for a FIFO between theLstatand the open could block; closing it needs a non-blocking open.Unchanged
--json,--deps,--skylineare byte-identical to origin/main on codemap and docling.get_structuregets the folding and layout changes but no stars, line counts, legend or trailer, since MCP passes no hub or line data. Its HUB FILES block is unchanged.Test
gofmt -l .clean,go vet ./...,go test ./...pass locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01FWQw8DzwM4bQnL7mvk6Fsq