Skip to content

fix(tree): star marks import hubs, not the largest files; add legend - #295

Merged
JordanCoin merged 1 commit into
mainfrom
fix/tree-star-hubs
Nov 11, 2026
Merged

JordanCoin merged 1 commit into
mainfrom
fix/tree-star-hubs

Conversation

@JordanCoin

Copy link
Copy Markdown
Owner

What

In codemap ., the star used to mark the five largest source files, with no legend. On this repo that put a star on main_more_test.go. File size says nothing about what breaks when you edit a file.

The star now marks import hubs, with the importer count inline, and one legend line under the tree says what it means:

├──   ⭐️ render/ ←3 (15 files, 107.6KB, all .go)
├──   ⭐️ scanner/ ←73 (95 files, 789.7KB, all .go)
│   └── ⭐️ config.go ←41 config_test.go
...
⭐️ ←N = imported by N files, 3+ of them non-test (Go: package count, on its dir)
  • A hub is the same thing get_hubs and the session-start hub list report: 3+ non-test importers. Test files are never starred.
  • Multi-file Go packages are starred on their directory (per fix(go): report package-level importers as packages, not per-file hubs #292); everything else on the file.
  • The legend carries the graph note when coverage is partial, and says why there are no stars when the graph is unavailable or the repo is above the 5000-file graph limit.
  • The session-start hook drops its own hub block when the tree carries the legend, so hubs are stated once. werkzeug session-start: 8,281 chars before, 8,028 after, still full depth.

Cost

Hubs come from the daemon's validated graph when one exists, otherwise a fresh BuildFileGraph scan. With no daemon, codemap . on docling goes from 0.41s to about 1.8s. With a warm daemon on this repo there is no measurable change.

Unchanged

  • --json, --deps, --skyline output is byte-identical on codemap and docling; --diff shows no stars or legend.
  • 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. (Checked by reading the code, not by running the MCP server.)

Known loose wording

  • "imported by" means edges as each language's resolver sees them (#include for C, type references for Swift).
  • The "Go: package count" clause prints on non-Go repos too.

Test

gofmt -l . clean, go vet ./..., go test ./... pass locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FWQw8DzwM4bQnL7mvk6Fsq

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
@JordanCoin
JordanCoin merged commit a03ff74 into main Nov 11, 2026
13 checks passed
JordanCoin added a commit that referenced this pull request Nov 11, 2026
JordanCoin added a commit that referenced this pull request Nov 11, 2026
…296)

* fix(tree): star marks import hubs, not the largest files; add legend

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

* feat(tree): compact tree with line counts, hub addresses and symbols

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

* fix(tree): hub list one per line, drop symbol lines

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

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
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.

1 participant