feat(pierre): add diff chunking and configurable review settings #2
Reference in New Issue
Block a user
Delete Branch "feat/context-improvements"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@@ -40,0 +103,4 @@for j, h := range hunks {hseg := hif j != 0 {hseg = "@@ " + hThe
splitDiffIntoChunksimplementation drops the newline that separates two files when it splits on"\ndiff --git ". After the split the code re‑adds the prefix with"diff --git " + part, which loses the leading line‑break. When the chunks are concatenated the original diff is no longer identical, causing theTestSplitDiffIntoChunks_LargeSingleFiletest to fail. Fix by adding the missing newline, e.g.seg = "\n" + "diff --git " + part(or keep the delimiter when splitting withstrings.SplitAfter). (Generated by: OpenAI (openai/gpt-oss-120b))@@ -0,0 +30,4 @@if !strings.HasPrefix(chunks[0], "diff --git a/file1.txt") {t.Fatalf("first chunk does not contain file1 header: %s", chunks[0])}if !strings.HasPrefix(chunks[1], "diff --git a/file2.txt") {The test
TestSplitDiffIntoChunks_LargeSingleFilerelies on an exact string equality after re‑joining the chunks. Because of the newline‑loss bug described above the test will currently fail. Once the split function preserves delimiters, the test will pass; otherwise consider comparing the recombined diff with the original usingcmp.Diffonly (as you already do) rather than a strict equality check. (Generated by: OpenAI (openai/gpt-oss-120b))@@ -7,7 +7,9 @@ require (github.com/alecthomas/kong v1.14.0github.com/alecthomas/kong-yaml v0.2.0github.com/google/generative-ai-go v0.20.1You added
github.com/google/go-cmp v0.7.0as a direct dependency – good for the new tests. Remember to rungo mod tidyso that thego.sumis updated accordingly. (Generated by: OpenAI (openai/gpt-oss-120b))The error message now correctly uses
response.StatusCode. No further changes needed. (Generated by: OpenAI (openai/gpt-oss-120b))@@ -13,0 +11,4 @@maxChunkSize intguidelines []stringgit GitAdapterchat ChatAdapterNewnow takes the extra parametersmaxChunkSizeandguidelines. Ensure all call‑sites (currently onlycmd/pierre/main.go) are updated accordingly. Consider adding a comment that documents the meaning ofmaxChunkSize(bytes) and that a non‑positive value triggers the built‑in default. (Generated by: OpenAI (openai/gpt-oss-120b))@@ -40,0 +80,4 @@// It tries to split on file boundaries ("diff --git") first, then on hunk boundaries (@@),// and finally on a hard byte limit.func splitDiffIntoChunks(diff []byte, maxSize int) []string {if len(diff) <= maxSize {The comment that builds
baseSystemconcatenates the dynamically createdguidelinesTextdirectly inside a raw string literal. This makes the final prompt contain a leading tab on every line, which the LLM will treat as part of the instruction. Consider using a plain string without the leading indentation or runstrings.TrimSpaceon the final prompt. (Generated by: OpenAI (openai/gpt-oss-120b))@@ -40,0 +121,4 @@}} else {current.WriteString(seg)}splitDiffIntoChunksmay split a diff in the middle of a line (e.g. when a single line exceedsmaxSize). Breaking a diff line arbitrarily can corrupt the unified‑diff syntax and confuse the model. Prefer to split only on line boundaries – e.g. split the input withstrings.SplitAfter(diff, "\n")and then build chunks while staying under the size limit. (Generated by: OpenAI (openai/gpt-oss-120b))cfg.Review.MaxChunkCharsis anintthat may be zero if the user omits the flag. The service correctly falls back to the default (60000) insidejudgePR, but you could also enforce the default earlier (e.g. in the config struct default tag or after flag parsing) to avoid passing a zero value downstream. (Generated by: OpenAI (openai/gpt-oss-120b))985fac347cto61d538d4a561d538d4a5toac5ff7aeebac5ff7aeebtocc321be6582bde5dff47tob5912d0725b5912d0725to3b709bc48e@@ -23,0 +26,4 @@headSHA, err := s.git.GetPRHeadSHA(ctx, organisation, repo, prID)if err != nil {log.Printf("warning: could not fetch PR head SHA (%v); skipping sanity check", err)} else {The condition for posting comments is inverted; it adds comments when
disableCommentsis true. Changeif s.disableComments {toif !s.disableComments {. (Reason: The code adds VCS comments only whens.disableCommentsis true, which contradicts the flag's purpose; flipping the condition fixes the logic.) (Generated by: OpenAI (openai/gpt-oss-120b))@@ -23,0 +30,4 @@filtered := []Comment{}for _, c := range comments {// Retrieve full file content at the PR headfileContent, fErr := s.git.GetFileContent(ctx, organisation, repo, c.File, headSHA)Update the comment above the block to reflect that comments are posted only when not in dry‑run mode. (Reason: The comment correctly identifies that the existing comment is misleading—the code posts comments only when
disableComments(dry‑run) is true, so the comment should be updated to reflect posting occurs when not in dry‑run mode.) (Generated by: OpenAI (openai/gpt-oss-120b))3b709bc48eto1ba0e879f91ba0e879f9to2e12c397869f6c6830a6toef55295c4def55295c4dto75ef8da1a4View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.