@@ -1973,6 +1973,7 @@ async function foldAtomicCutFile(
19731973 file : AtomicCutFileRequest ,
19741974 absPath : string ,
19751975 before : string ,
1976+ writer : "recast" | "acorn" ,
19761977) : Promise < FoldedAtomicCutFile | Response > {
19771978 let after = before ;
19781979 let splitCount = 0 ;
@@ -2032,6 +2033,7 @@ async function foldAtomicCutFile(
20322033 } ,
20332034 block ,
20342035 respond ,
2036+ writer ,
20352037 ) ;
20362038 if ( result instanceof Response ) return result ;
20372039 let script = typeof result === "string" ? result : result . script ;
@@ -2423,6 +2425,12 @@ export function registerFileRoutes(api: Hono, adapter: StudioApiAdapter): void {
24232425 const files = body . files as AtomicCutFileRequest [ ] ;
24242426 const project = await adapter . resolveProject ( c . req . param ( "id" ) ) ;
24252427 if ( ! project ) return c . json ( { error : "not found" } , 404 ) ;
2428+ let writer : "recast" | "acorn" ;
2429+ try {
2430+ writer = resolveGsapWriter ( process . env ) ;
2431+ } catch ( error ) {
2432+ return c . json ( { error : error instanceof Error ? error . message : String ( error ) } , 400 ) ;
2433+ }
24262434
24272435 return serializeAtomicCut ( async ( ) => {
24282436 const seen = new Set < string > ( ) ;
@@ -2453,7 +2461,7 @@ export function registerFileRoutes(api: Hono, adapter: StudioApiAdapter): void {
24532461 }
24542462 let folded : FoldedAtomicCutFile | Response ;
24552463 try {
2456- folded = await foldAtomicCutFile ( c , file , absPath , before ) ;
2464+ folded = await foldAtomicCutFile ( c , file , absPath , before , writer ) ;
24572465 } catch ( error ) {
24582466 const message = error instanceof Error ? error . message : "Cut transform failed" ;
24592467 return c . json ( { error : message } , 400 ) ;
0 commit comments