@@ -137,8 +137,8 @@ export function buildClassificationPrompt({ prompt, candidatePath, auditPath, ca
137137}
138138
139139export function buildCopilotArguments ( { prompt, candidatePath, auditPath, catalogPath, existingEntries } ) {
140+ buildClassificationPrompt ( { prompt, candidatePath, auditPath, catalogPath, existingEntries } ) ;
140141 return [
141- '-p' , buildClassificationPrompt ( { prompt, candidatePath, auditPath, catalogPath, existingEntries } ) ,
142142 '--agent=gallery-curator' ,
143143 '--silent' ,
144144 '--stream=off' ,
@@ -155,6 +155,7 @@ function invokeCopilot(options) {
155155 return spawnSync ( 'copilot' , buildCopilotArguments ( options ) , {
156156 encoding : 'utf8' ,
157157 env : process . env ,
158+ input : buildClassificationPrompt ( options ) ,
158159 maxBuffer : 2 * 1024 * 1024 ,
159160 windowsHide : true ,
160161 } ) ;
@@ -168,6 +169,8 @@ export function runCopilotClassification(options) {
168169 for ( let attempt = 1 ; attempt <= 2 ; attempt += 1 ) {
169170 try {
170171 const result = execute ( options ) ;
172+ if ( result . error ) throw result . error ;
173+ if ( result . signal ) throw new Error ( `Copilot terminated by signal ${ result . signal } ` ) ;
171174 if ( result . status !== 0 ) throw new Error ( `Copilot exited with status ${ result . status } : ${ ( result . stderr ?? '' ) . trim ( ) } ` ) ;
172175 const parsed = JSON . parse ( normalizeCopilotJson ( result . stdout ?? '' ) ) ;
173176 return { status : 'complete' , attempts : attempt , classification : validateClassification ( parsed , options . candidates , existingEntries ) } ;
0 commit comments