Handle buffer overflows gracefully and truncate diffs fairly (#5083)

- Gracefully fall back to file-name summaries when staged diffs exceed
  node/ssh execution maxBuffer limits, preventing generation failures.
- Split oversized diffs by file and allocate budget via water-filling,
  ensuring single huge files do not starve smaller human changes.
- Clip truncated diff sections on line boundaries to avoid half-lines.
This commit is contained in:
Jinjing
2026-06-09 23:56:36 -07:00
committed by GitHub
parent c12164c8cc
commit 256e0ef81a
9 changed files with 265 additions and 24 deletions
@@ -33,6 +33,20 @@ describe('buildCommitMessagePrompt', () => {
expect(prompt).toContain('Branch: (detached)')
expect(prompt).toContain('Additional user prompt:\nUse Conventional Commits.')
})
it('notes when the diff was omitted so the agent relies on the file list', () => {
const prompt = buildCommitMessagePrompt(
{
branch: 'feature/big-diff',
stagedSummary: 'A\thuge.jsonl',
stagedPatch: ''
},
''
)
expect(prompt).toContain('Staged files:\nA\thuge.jsonl')
expect(prompt).toContain('diff omitted — too large to read')
})
})
describe('splitGeneratedCommitMessage', () => {