Skip to content

feat: add --dry-run flag to estimate output size (#23)#53

Merged
b-j-karl merged 2 commits into
developfrom
feat/dry-run
Apr 11, 2026
Merged

feat: add --dry-run flag to estimate output size (#23)#53
b-j-karl merged 2 commits into
developfrom
feat/dry-run

Conversation

@b-j-karl

Copy link
Copy Markdown
Owner

Summary

Adds a --dry-run\ flag to both \ ile\ and \project\ CLI commands. When set, modules are extracted and rendered in memory to compute exact byte counts, then a concise summary is printed instead of the full output:

\
Scanned 42 files: 15 classes, 80 functions, 20 constants, 5 type aliases
Estimated output: ~12.0 KB (current flags), ~4.2 KB (minimal)
\\

Minimal = --no-docstrings --no-private --no-constants\ all applied.

What changed

  • New module \src/api_squash/estimator.py\ — \EstimateResult\ dataclass, \�stimate(), and \ ormat_estimate()\
  • CLI — --dry-run\ Click option on both \ ile\ and \project\ commands
  • Tests — 14 estimator unit tests + 6 CLI integration tests (TDD)

Why

Token budget management. An agent needs to decide between \project\ and \ ile\ mode, and between flag combinations, without trial and error.

Closes #23

Add --dry-run to both file and project commands. When set, extracts
modules as normal but prints a concise summary instead of the full
rendered output:

  Scanned N files: X classes, Y functions, Z constants, W type aliases
  Estimated output: ~X.X KB (current flags), ~Y.Y KB (minimal)

'Minimal' means --no-docstrings --no-private --no-constants all applied.
Sizes are computed by rendering in memory, giving exact byte counts.

- New estimator module with EstimateResult dataclass, estimate(), and
  format_estimate()
- 14 unit tests for estimator, 6 CLI integration tests
- TDD: all tests written before implementation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a --dry-run mode to the file and project CLI commands so users can compute entity counts and estimated output sizes (current flags vs “minimal”) without printing the rendered API output.

Changes:

  • Introduces src/api_squash/estimator.py with EstimateResult, estimate(), and format_estimate().
  • Adds --dry-run Click option to file and project commands and prints the estimate summary instead of full rendered output.
  • Adds unit tests for the estimator and CLI integration tests covering --dry-run.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/api_squash/estimator.py New estimation API that renders in-memory to compute byte sizes and formats a concise summary.
src/api_squash/cli.py Wires --dry-run into both CLI commands to print estimate summaries.
tests/test_estimator.py Adds estimator unit tests for counts, sizing, and formatting.
tests/test_cli.py Adds CLI integration tests ensuring --dry-run prints only the summary and handles errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/api_squash/estimator.py Outdated
Comment thread src/api_squash/estimator.py Outdated
Comment thread src/api_squash/estimator.py Outdated
- Compute sizes incrementally per module instead of building full
  concatenated strings, avoiding memory spikes for large projects
- Change 'Scanned' to 'Extracted' in format_estimate() since the count
  reflects successfully parsed modules, not discovered files
- Remove '~' prefix from KB values since byte counts are exact

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@b-j-karl
b-j-karl merged commit 2c82058 into develop Apr 11, 2026
14 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.

Add --dry-run to estimate output size before running

3 participants