| 166 | } |
| 167 | |
| 168 | func PrintDiffFile(out io.Writer, manifest FileDiffManifest) { |
| 169 | fmt.Fprintf(out, "run=%s file=%s base_snapshot=%s\n", manifest.RunID, manifest.File, manifest.BaseSnapshotID) |
| 170 | fmt.Fprintf(out, "base_sha256=%s base_path=%s\n", manifest.BaseSHA256, manifest.BasePath) |
| 171 | fmt.Fprintln(out, "diffs:") |
| 172 | for _, attempt := range manifest.Attempts { |
| 173 | fmt.Fprintf(out, " attempt=%s rollout=%s tool_call=%s winner=%t status=%s strategy=%s changed=%t base_sha256=%s attempt_sha256=%s workspace=%s\n", |
| 174 | attempt.AttemptID, attempt.RolloutID, attempt.ToolCallID, attempt.IsWinner, attempt.Status, attempt.Strategy, attempt.Changed, manifest.BaseSHA256, attempt.FileSHA256, attempt.WorkspacePath) |
| 175 | if !attempt.Changed { |
| 176 | continue |
| 177 | } |
| 178 | fmt.Fprintf(out, " --- base/%s\n", manifest.File) |
| 179 | fmt.Fprintf(out, " +++ attempt/%s/%s\n", attempt.AttemptID, manifest.File) |
| 180 | for _, line := range attempt.UnifiedDiff { |
| 181 | fmt.Fprintf(out, " %s\n", line) |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | func BlameFileJSON(db *sql.DB, runID, filePath string, out io.Writer) error { |
| 187 | manifest, err := BuildBlameFile(db, runID, filePath) |