Fix OpenCode backend invocation and diagnostics
This commit is contained in:
@@ -37,6 +37,9 @@ function inferArgs(name: ExternalBackendName, prompt: string): string[] {
|
||||
if (name === 'claude_code') {
|
||||
return ['--print', prompt];
|
||||
}
|
||||
if (name === 'opencode') {
|
||||
return ['run', '--format', 'default', prompt];
|
||||
}
|
||||
return ['-p', prompt];
|
||||
}
|
||||
|
||||
@@ -99,7 +102,11 @@ function execFileAsync(command: string, args: string[], timeoutMs: number): Prom
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(command, args, { timeout: timeoutMs, maxBuffer: 1024 * 1024 }, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(new Error(`${error.message}${stderr ? `\n${stderr}` : ''}`));
|
||||
const details = [stderr, stdout]
|
||||
.map((entry) => entry.trim())
|
||||
.filter((entry) => entry.length > 0)
|
||||
.join('\n');
|
||||
reject(new Error(details ? `${error.message}\n${details}` : error.message));
|
||||
return;
|
||||
}
|
||||
resolve(stdout || '');
|
||||
|
||||
Reference in New Issue
Block a user