@@ -2,7 +2,7 @@ import dedent from 'dedent';
2
2
import { findVisualFile } from './find-visual-file' ;
3
3
import { getCompletion } from './openai' ;
4
4
import { RunOptions } from './run' ;
5
- import { readFile , writeFile } from 'fs/promises' ;
5
+ import { readFile , writeFile , mkdir , stat } from 'fs/promises' ;
6
6
import { success , fail , formatMessage } from './test' ;
7
7
import { getScreenshot } from './get-screenshot' ;
8
8
import { KnownError } from './error' ;
@@ -96,10 +96,24 @@ export async function visualGenerate(options: RunOptions) {
96
96
` ;
97
97
98
98
const designUrl = await imageFilePathToBase64Url ( filename ) ;
99
- await writeFile ( 'design-image-url.txt' , designUrl , 'utf-8' ) ;
99
+ const debugImageOutputFolder = 'debug/images' ;
100
+ try {
101
+ await stat ( debugImageOutputFolder ) ;
102
+ } catch ( error ) {
103
+ await mkdir ( debugImageOutputFolder , { recursive : true } ) ;
104
+ }
105
+ await writeFile (
106
+ `${ debugImageOutputFolder } /design-image-url.txt` ,
107
+ designUrl ,
108
+ 'utf-8'
109
+ ) ;
100
110
101
111
const screenshotUrl = bufferToBase64Url ( await getScreenshot ( options ) ) ;
102
- await writeFile ( 'screenshot-image-url.txt' , screenshotUrl , 'utf-8' ) ;
112
+ await writeFile (
113
+ `${ debugImageOutputFolder } /screenshot-image-url.txt` ,
114
+ screenshotUrl ,
115
+ 'utf-8'
116
+ ) ;
103
117
104
118
let output : string ;
105
119
if ( USE_ANTHROPIC ) {
0 commit comments