(cwd, baseRef, options = {})
| 259 | } |
| 260 | |
| 261 | function collectBranchContext(cwd, baseRef, options = {}) { |
| 262 | const includeDiff = options.includeDiff !== false; |
| 263 | const comparison = options.comparison ?? buildBranchComparison(cwd, baseRef); |
| 264 | const currentBranch = getCurrentBranch(cwd); |
| 265 | const changedFiles = gitChecked(cwd, ["diff", "--name-only", comparison.commitRange]).stdout.trim().split("\n").filter(Boolean); |
| 266 | const logOutput = gitChecked(cwd, ["log", "--oneline", "--decorate", comparison.commitRange]).stdout.trim(); |
| 267 | const diffStat = gitChecked(cwd, ["diff", "--stat", comparison.commitRange]).stdout.trim(); |
| 268 | |
| 269 | return { |
| 270 | mode: "branch", |
| 271 | summary: `Reviewing branch ${currentBranch} against ${baseRef} from merge-base ${comparison.mergeBase}.`, |
| 272 | content: includeDiff |
| 273 | ? [ |
| 274 | formatSection("Commit Log", logOutput), |
| 275 | formatSection("Diff Stat", diffStat), |
| 276 | formatSection( |
| 277 | "Branch Diff", |
| 278 | gitChecked(cwd, ["diff", "--binary", "--no-ext-diff", "--submodule=diff", comparison.commitRange]).stdout |
| 279 | ) |
| 280 | ].join("\n") |
| 281 | : [ |
| 282 | formatSection("Commit Log", logOutput), |
| 283 | formatSection("Diff Stat", diffStat), |
| 284 | formatSection("Changed Files", changedFiles.join("\n")) |
| 285 | ].join("\n"), |
| 286 | changedFiles, |
| 287 | comparison |
| 288 | }; |
| 289 | } |
| 290 | |
| 291 | function buildAdversarialCollectionGuidance(options = {}) { |
| 292 | if (options.includeDiff !== false) { |
no test coverage detected