vipcare 0.3.22 → 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.
Files changed (2) hide show
  1. package/lib/synthesizer.js +38 -8
  2. package/package.json +1 -1
@@ -1,4 +1,7 @@
1
- import { execFileSync } from 'child_process';
1
+ import { execFileSync, spawnSync } from 'child_process';
2
+ import fs from 'fs';
3
+ import os from 'os';
4
+ import path from 'path';
2
5
  import { checkTool, loadConfig } from './config.js';
3
6
  import { PROFILE_SYSTEM_PROMPT, CHANGE_DETECTION_PROMPT } from './templates.js';
4
7
 
@@ -31,13 +34,40 @@ function copilotAvailable() {
31
34
  }
32
35
 
33
36
  function callClaudeCli(prompt, timeout = 120000) {
34
- const result = execFileSync('claude', ['--print', '-p', prompt], {
35
- encoding: 'utf-8',
36
- timeout,
37
- stdio: ['pipe', 'pipe', 'pipe'],
38
- maxBuffer: 1024 * 1024 * 10,
39
- });
40
- return result.trim();
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 {}
70
+ }
41
71
  }
42
72
 
43
73
  async function callAnthropicApi(prompt) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vipcare",
3
- "version": "0.3.22",
3
+ "version": "0.3.24",
4
4
  "description": "Auto-build VIP person profiles from Twitter/LinkedIn public data",
5
5
  "type": "module",
6
6
  "bin": {