vipcare 0.3.23 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/synthesizer.js +33 -14
- package/package.json +1 -1
package/lib/synthesizer.js
CHANGED
|
@@ -34,21 +34,40 @@ function copilotAvailable() {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function callClaudeCli(prompt, timeout = 120000) {
|
|
37
|
-
//
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
// Write prompt to temp file, pass via -p flag reading from file
|
|
38
|
+
const tmpFile = path.join(os.tmpdir(), `vip-prompt-${Date.now()}.txt`);
|
|
39
|
+
try {
|
|
40
|
+
fs.writeFileSync(tmpFile, prompt);
|
|
41
|
+
// Try stdin pipe first
|
|
42
|
+
const result = spawnSync('claude', ['--print'], {
|
|
43
|
+
input: prompt,
|
|
44
|
+
encoding: 'utf-8',
|
|
45
|
+
timeout,
|
|
46
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
47
|
+
maxBuffer: 1024 * 1024 * 10,
|
|
48
|
+
});
|
|
49
|
+
if (result.error) {
|
|
50
|
+
throw new Error(`Claude CLI error: ${result.error.message}`);
|
|
51
|
+
}
|
|
52
|
+
if (result.status !== 0) {
|
|
53
|
+
const stderr = result.stderr?.trim() || '';
|
|
54
|
+
const stdout = result.stdout?.trim() || '';
|
|
55
|
+
// If stdin pipe failed, try with temp file
|
|
56
|
+
const result2 = spawnSync('sh', ['-c', `cat "${tmpFile}" | claude --print`], {
|
|
57
|
+
encoding: 'utf-8',
|
|
58
|
+
timeout,
|
|
59
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
60
|
+
maxBuffer: 1024 * 1024 * 10,
|
|
61
|
+
});
|
|
62
|
+
if (result2.status === 0 && result2.stdout?.trim()) {
|
|
63
|
+
return result2.stdout.trim();
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Claude CLI failed (exit ${result.status}): ${stderr || stdout || 'no output'}`);
|
|
66
|
+
}
|
|
67
|
+
return result.stdout.trim();
|
|
68
|
+
} finally {
|
|
69
|
+
try { fs.unlinkSync(tmpFile); } catch {}
|
|
50
70
|
}
|
|
51
|
-
return result.stdout.trim();
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
async function callAnthropicApi(prompt) {
|