Skip to content

Add repo structure tree to CLI and HTML report#4

Merged
lex0c merged 5 commits intomainfrom
feat/repo-structure-tree
Apr 19, 2026
Merged

Add repo structure tree to CLI and HTML report#4
lex0c merged 5 commits intomainfrom
feat/repo-structure-tree

Conversation

@lex0c
Copy link
Copy Markdown
Owner

@lex0c lex0c commented Apr 19, 2026

Architecture-view section built from stats.FileHotspots, shared between the CLI (gitcortex stats --stat structure [--tree-depth N]) and the HTML report (collapsed accordion below the glossary, capped at 3 levels). Directories aggregate Churn + Files but leave Commits at zero to avoid the double-counting trap DirStat hit before the FileTouches rename; same-name file/dir collisions across history get separate sibling nodes instead of corrupting each other.

Architecture-view section built from stats.FileHotspots, shared between
the CLI (gitcortex stats --stat structure [--tree-depth N]) and the HTML
report (collapsed accordion below the glossary, capped at 3 levels).
Directories aggregate Churn + Files but leave Commits at zero to avoid
the double-counting trap DirStat hit before the FileTouches rename;
same-name file/dir collisions across history get separate sibling nodes
instead of corrupting each other.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lex0c
Copy link
Copy Markdown
Owner Author

lex0c commented Apr 19, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09f25dca86

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/gitcortex/main.go
Comment thread internal/report/tree.go Outdated
lex0c and others added 2 commits April 19, 2026 20:08
The structure branch previously always wrote the Unicode tree to stdout,
breaking the "single clean table per --stat" CSV contract that
downstream parsers rely on. Add RenderTreeCSV (one row per node in DFS
preorder with path/type/depth/commits/churn/files/truncated columns) and
route --format csv through it. Dir rows still carry commits=0 so the CSV
matches the struct semantics documented on TreeNode.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The subtree-hidden message pointed users at --depth, but the flag is
actually named --tree-depth; copy-pasting from the hint produced an
unknown-flag error.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lex0c
Copy link
Copy Markdown
Owner Author

lex0c commented Apr 19, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

lex0c and others added 2 commits April 19, 2026 20:19
- Honest comment on the leaf Commits += accumulator (defense-in-depth,
  not a real case — FileHotspots is map-keyed, no dupes reach here).
- Rename the glossary CSS class to .accordion so the Repo Structure
  <details> no longer reads as misusing a glossary-specific class.
- Banner prints "depth unlimited" when --tree-depth 0 is passed, rather
  than showing a misleading "depth 0".
- Replace O(N) findChild linear scan with per-node map index so wide
  flat directories no longer degrade the build to quadratic.
- Prune depth during descent instead of a post-pass, so nodes past the
  cap are never allocated.
- CapChildrenPerDir caps the HTML surface to 50 children per dir,
  pushing long tails into a "… N more hidden" counter so wide repos
  don't balloon the report. CLI intentionally left uncapped.
- RenderTreeForFormat centralizes the text/CSV dispatch so a future
  format addition can't repeat the "csv silently wrote Unicode" bug.
- New tests: format dispatch table, truncation markers in text + CSV
  renderers, HTML per-dir cap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mention --stat structure in the README stat table and RUNBOOK command
list, and add a Repo Structure section in METRICS.md explaining the
history-lens aggregation semantics (dir Commits=0, child count cap,
tree-depth default).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lex0c lex0c merged commit 3c9ea3e into main Apr 19, 2026
1 check passed
@lex0c lex0c deleted the feat/repo-structure-tree branch April 19, 2026 23:32
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