Fix OpenCode backend invocation and diagnostics

This commit is contained in:
William Valentin
2026-02-22 17:51:56 -08:00
parent 9a9375ef5d
commit 7d0d8abec6
4 changed files with 178 additions and 2 deletions
+8 -1
View File
@@ -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 || '');