@@ -8,6 +8,7 @@ import type {
88 export interface StructuredOutputWriter {
99 stdout: (text: string) => void;
1010 stderr: (text: string) => void;
11+ supportsColor?: boolean;
1112 }
1213
1314 type FileEditCliSuccess = { ok: true } & ApplyExactTextEditResult;
@@ -51,9 +52,10 @@ export function renderUnifiedDiff(
5152 filePath: string,
5253 before: string,
5354 after: string,
55+ colorize = true,
5456 ): string {
5557 if (before === after) {
56- return c.dim("(no changes)");
58+ return colorize ? c.dim("(no changes)") : "(no changes)";
5759 }
5860
5961 const patchText = createTwoFilesPatch(
@@ -71,6 +73,7 @@ export function renderUnifiedDiff(
7173
7274 return lines
7375 .map((line) => {
76+ if (!colorize) return line;
7477 if (line.startsWith("+++ ") || line.startsWith("+")) {
7578 return c.green(line);
7679 }
@@ -110,7 +113,12 @@ export function writeFileEditResult(
110113 ): void {
111114 if (result.ok) {
112115 const sections = [
113- renderUnifiedDiff(result.path, result.before, result.after),
116+ renderUnifiedDiff(
117+ result.path,
118+ result.before,
119+ result.after,
120+ io.supportsColor ?? process.stdout.isTTY === true,
121+ ),
114122 renderMetadataBlock(result),
115123 ];
116124 io.stdout(`${sections.join("\n\n")}\n`);