Smart Token Budgeting & Large Diff Truncation for Large Commits
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
Research direction
Start by reading the staged-diff handling in internal/git and the configuration surfaces config.env and .git-commit-summary.yaml. Use mock large diff inputs to understand the required internal/git tests. Done means oversized diffs stay within configured limits, lockfiles and generated files are collapsed, and the related configuration or CLI option is covered by tests.
Written by the indexing model from the issue text.
Description
Problem Statement
When working on large commits (such as updating dependency lockfiles (go.sum, package-lock.json), large code refactors, or bulk file additions), the raw git diff can easily exceed LLM context windows or unnecessarily consume a large number of input tokens. Currently, git-commit-summary sends the entire raw diff to the LLM provider.
Proposed Feature: Smart Token Budgeting & Large Diff Truncation
Implement a preprocessing step for staged diffs that ensures large changes fit comfortably within LLM token limits while retaining the essential semantic summary of the changes.
Detailed Outline Plan
-
Diff Statistics & Token Estimation:
- Parse the git diff output into file-level chunks (
internal/git). - Implement a lightweight token estimator (e.g., character-to-token heuristic or using a tokenizer helper) to gauge the size of each file diff.
- Parse the git diff output into file-level chunks (
-
Diff Prioritization & Truncation Strategy:
- Lockfiles & Generated Files: Automatically collapse or omit full diffs for well-known generated files / lockfiles (
go.sum,package-lock.json,pnpm-lock.yaml, minified assets), replacing them with a summary line (e.g.,... (lockfile updated: X dependencies added, Y removed)). - Code Files: If total diff exceeds a configured threshold (e.g., max token limit or max line count):
- Prioritize core logic files over documentation or tests, or truncate individual file diffs after a maximum number of hunks/lines, appending a truncation notice (e.g.,
... [diff truncated for length]).
- Prioritize core logic files over documentation or tests, or truncate individual file diffs after a maximum number of hunks/lines, appending a truncation notice (e.g.,
- Lockfiles & Generated Files: Automatically collapse or omit full diffs for well-known generated files / lockfiles (
-
Configuration & Flags:
- Add configuration options (in
config.env/.git-commit-summary.yaml) for max diff tokens / size thresholds. - Add CLI flag support if needed (e.g.,
--max-diff-tokens).
- Add configuration options (in
-
Testing & Validation:
- Add unit tests in
internal/gitfor diff truncation and lockfile collapsing logic. - Verify behavior against mock large diff inputs.
- Add unit tests in
- Dominant language
- Go
- Stars
- 0
- Forks
- 0
- Avg merge
- 18h 49m
- Merged PRs (30d)
- 13
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rm-hull/git-commit-summary
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
rm-hull/git-commit-summary#190 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
rm-hull/git-commit-summary#189 ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
rm-hull/git-commit-summary#185 ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
rm-hull/git-commit-summary#184 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
rm-hull/git-commit-summary#106 ·
All issues in rm-hull/git-commit-summary
Similar issues
-
area/dev-productivity area/disaster-recovery area/ipcei kind/enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
kind/bug status/0-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
🤔 refinement needed
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
equinor/radix-operator#1979 ·