Skip to content

Add --recursive discovery to summarize_git.py - #9

Merged
DNSGeek merged 1 commit into
masterfrom
claude/agitated-elgamal-9f16bd
Oct 18, 2026
Merged

DNSGeek merged 1 commit into
masterfrom
claude/agitated-elgamal-9f16bd

Conversation

@DNSGeek

@DNSGeek DNSGeek commented Oct 18, 2026

Copy link
Copy Markdown
Owner

What changed

summarize_git.py gains an opt-in recursive mode; the flat scan of immediate subdirectories stays the default and behaves exactly as before (its dry-run output, entries and cache keys are unchanged, and a test pins the flat cache digest).

  • -r/--recursive walks the scanned directory with os.walk and collects units: git repos (.git dir), submodules and worktrees (.git file; a worktree when its gitdir contains /worktrees/), bare repos (HEAD, config, objects/, refs/; never descended into) and directories with a README. Hidden directories and SKIP_DIRS are pruned. Units are keyed by their path relative to the scanned directory.
  • --build-dirs also accepts README-less directories holding a build file (Makefile, package.json, pyproject.toml, go.mod, Cargo.toml, CMakeLists.txt, Chart.yaml, Dockerfile, ...), summarized from their build and CI files.
  • --exclude NAME / --include NAME (repeatable) adjust SKIP_DIRS. All four options live in DEFAULTS and are stored by --save; --no-recursive overrides a saved config.
  • Parent and depth: each unit's parent is its nearest enclosing unit. The prompt gets a short structure note (the unit's role inside its parent, and its direct children with the first paragraph of each child's README). Child units' READMEs are no longer fed into the parent's context. Entries store kind, depth, parent and children.
  • Viewer (summaries.py): entries in tree order with an indented menu, Kind: / Parent: / Contains: lines under the header, nested units resolvable by their last path component. --list, --json and --text keep working.
  • Dry run in recursive mode lists every unit with its kind and indentation, including skipped README-less ones.

Why

The work version of this tool treats nested repos, submodules, worktrees and sub-components as units with parent/child links; the repo version was deliberately flat. This ports that mode without changing the default.

Reviewer notes

  • USER_PROMPT is now USER_PROMPT_HEAD + USER_PROMPT_TAIL (same string). The structure note and STRUCTURE_PROMPT enter the cache key only when the note is non-empty, which is what keeps flat-mode keys stable.
  • Bare repos are discovered for the tree and the dry run but always skipped, since nothing on disk can be summarized; reading their README from HEAD would be a possible follow-up.
  • Verified with ruff, black, isort, ssort and mypy, 23 tests (11 new, run with uv run --python 3.13 --with pytest --with requests -- pytest -q test_summarize_git.py), and a live run against LM Studio on a nested fixture whose viewer shows the parent/child links and is fully cached on a rerun.
  • The README table row was re-padded by hand to prettier's widths; CI's formatter may still touch it.

🤖 Generated with Claude Code

- Walk the scanned directory with os.walk and treat git repos, submodules
  and worktrees (.git file; a worktree when its gitdir is under
  /worktrees/), bare repos (never descended into) and directories with a
  README as units, keyed by their path relative to the scanned directory.
  Flat mode stays the default and its keys and cache digests are unchanged
- Add --build-dirs for README-less directories holding a build file, and
  repeatable --exclude/--include to adjust SKIP_DIRS; --save stores them
- Give each unit its nearest enclosing unit as parent plus a depth; tell
  the model about the parent and the direct children (with the first
  paragraph of each child's README), keep child units' READMEs out of the
  parent's context, and store kind, depth, parent and children per entry
- Viewer: list in tree order with indentation, print Kind, Parent and
  Contains lines, and resolve nested units by their last path component
- Dry run lists every unit with its kind and indentation
- Tests for discovery, parent assignment, --build-dirs, --exclude and
  --include, context isolation, README excerpts, the structure prompt,
  unchanged flat cache keys, the dry run and a mocked end-to-end run that
  checks the generated viewer

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@DNSGeek
DNSGeek merged commit 62beb3a into master Oct 18, 2026
3 of 4 checks passed
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