feat: add --dry-run flag to estimate output size (#23)#53
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
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.pywithEstimateResult,estimate(), andformat_estimate(). - Adds
--dry-runClick option tofileandprojectcommands 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.
- 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>
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.
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
Why
Token budget management. An agent needs to decide between \project\ and \ile\ mode, and between flag combinations, without trial and error.
Closes #23