feat(chunker): structured JSON prompt for commit message generation#213
Merged
Conversation
…nk extractor Add AnnotatedEntry, CallGraphEntry, CFGEntry, CFGSummary domain types and DiffChunk.AnnotatedEntries/CallGraph fields (additive — AnnotatedDiff string kept for backward compat). Extract hunk-line helpers from diff_merger into the new hunk_extractor.go and add buildAnnotatedEntries, which converts labels + parsed diff hunks into per-symbol before/after hunk records. Add AnnotatedJSON/CallGraphJSON/CFGJSON to MessageParams with updated BuildMessageParams/BuildMessageParamsWithRetry signatures, and render the new JSON blocks in commit_message.md with a three-level fallback (AnnotatedJSON → AnnotatedDiff → Diff). Adapter callers pass empty JSON strings for now; full marshaling is wired in the integration phase. Includes table-driven buildAnnotatedEntries tests, approval tests proving the new path is hunk-equivalent to the legacy merge, and JSON-field prompt tests.
…hContent Refactor formatLabelsForChunk to return []AnnotatedEntry instead of an emoji-prefixed string, and populate chunk.AnnotatedEntries alongside the legacy AnnotatedDiff in both the UnifiedASTPass.Process chunk builder and Annotate. AnnotateWithContent now calls buildAnnotatedEntries with the parsed diff hunks and pre-computed labels to fill per-symbol before/after hunk lines on the structured entries, keeping ProcessWithContent at one call per file. Add formatEntriesAsLegacyString to render entries back to the emoji format for backward-compatible AnnotatedDiff consumers. Includes table-driven tests for the new return type, Annotate population, and AnnotateWithContent structured entry population.
…rompt GenerateChunkMessage and regenerateChunk now marshal chunk.AnnotatedEntries, CallGraph, and CFGBefore/CFGAfter into the AnnotatedJSON/CallGraphJSON/CFGJSON prompt params via the shared buildChunkAnnotationJSON helper. When AnnotatedEntries is non-empty the legacy emoji AnnotatedDiff and raw Diff are dropped so the prompt uses the structured JSON path exclusively; when empty the existing raw-diff fallback is preserved. CFGJSON is omitted when CFGBefore/CFGAfter are nil (cfg not computed). Includes tests covering annotated_diff/call_graph/cfg JSON rendering, the null-CFG omission, and the empty-entries raw-diff fallback for both generate and regenerate paths.
…ji merger combineChunks now merges AnnotatedEntries and CallGraph slices from sub-chunks into the combined chunk (append), alongside the existing CFG count summation. prepareStages stops clearing CFGBefore/CFGAfter after classification — CFG data is now needed downstream to build the CFGSummary for the LLM prompt. Remove the legacy emoji-era diff_merger.go functions (MergeDiffIntoAnnotations, parseLabelGroups, parseLabelLine, rebuildAnnotatedDiff) now that the structured buildAnnotatedEntries path is fully wired. Migrate the manual e2e test to use AnnotateWithContent (which populates AnnotatedEntries with hunk before/after) and drop the MergeDiffIntoAnnotations approval test, keeping the equivalence test that proves buildAnnotatedEntries matches the old merge's hunk extraction.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Closes #206
Summary
Changes
internal/core/domain/diff.gointernal/infra/chunkers/hunk_extractor.gointernal/infra/chunkers/diff_merger.gointernal/infra/chunkers/unified.gointernal/infra/chunkers/adapter.gointernal/shared/prompts/prompts.gointernal/shared/prompts/md/commit_message.mdinternal/adapters/llm/openai_standard/adapter_commit.gointernal/adapters/llm/openai_standard/adapter_release.gointernal/workflow/commit.goTest Plan
go test -short ./...— 42 packages, all passgo vet ./...— cleango vet -tags manual ./...— clean