knoxis-helper 1.4.6 → 1.4.8
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.
|
@@ -177,8 +177,10 @@ function callGroq(systemPrompt, userMessage) {
|
|
|
177
177
|
// === RUN CLAUDE TURN ===
|
|
178
178
|
function runClaudeTurn(message, isResume) {
|
|
179
179
|
return new Promise((resolve) => {
|
|
180
|
-
// Check claude is available
|
|
181
|
-
const
|
|
180
|
+
// Check claude is available (Windows uses `where`, Unix uses `which`)
|
|
181
|
+
const isWindows = process.platform === 'win32';
|
|
182
|
+
const detector = isWindows ? 'where' : 'which';
|
|
183
|
+
const which = spawnSync(detector, ['claude'], { stdio: 'pipe' });
|
|
182
184
|
if (which.status !== 0) {
|
|
183
185
|
resolve({ stdout: '', stderr: 'claude CLI not found', code: 127 });
|
|
184
186
|
return;
|
|
@@ -191,11 +193,30 @@ function runClaudeTurn(message, isResume) {
|
|
|
191
193
|
args.push('--session-id', SESSION_ID);
|
|
192
194
|
}
|
|
193
195
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
// Windows: claude is usually claude.cmd (npm shim) or claude.exe.
|
|
197
|
+
// .cmd/.bat shims require going through cmd.exe (Node CVE-2024-27980).
|
|
198
|
+
// We can't just pass `shell: true` with an args array — that triggers
|
|
199
|
+
// DEP0190 in Node 22+ (args get concatenated into the shell command
|
|
200
|
+
// line without escaping). Instead, build the command line ourselves
|
|
201
|
+
// and pass it as a single string. Our args are static flags + a UUID
|
|
202
|
+
// (no whitespace, no quotes) so trivial space-quoting is sufficient.
|
|
203
|
+
let proc;
|
|
204
|
+
if (isWindows) {
|
|
205
|
+
const quote = a => /\s/.test(a) ? `"${a}"` : a;
|
|
206
|
+
const cmdLine = ['claude', ...args].map(quote).join(' ');
|
|
207
|
+
proc = spawn(cmdLine, [], {
|
|
208
|
+
cwd: process.cwd(),
|
|
209
|
+
env: process.env,
|
|
210
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
211
|
+
shell: true
|
|
212
|
+
});
|
|
213
|
+
} else {
|
|
214
|
+
proc = spawn('claude', args, {
|
|
215
|
+
cwd: process.cwd(),
|
|
216
|
+
env: process.env,
|
|
217
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
218
|
+
});
|
|
219
|
+
}
|
|
199
220
|
|
|
200
221
|
let stdout = '';
|
|
201
222
|
let stderr = '';
|
|
@@ -337,7 +358,10 @@ async function main() {
|
|
|
337
358
|
if (phase1.code !== 0 && !phase1.stdout) {
|
|
338
359
|
console.log('');
|
|
339
360
|
console.log(' Phase 1 failed (exit ' + phase1.code + '). Falling back to single-shot.');
|
|
340
|
-
|
|
361
|
+
if (phase1.stderr) {
|
|
362
|
+
console.log(' stderr: ' + phase1.stderr.split('\n').slice(0, 5).join('\n '));
|
|
363
|
+
}
|
|
364
|
+
appendLog('Phase 1 failed (exit ' + phase1.code + '). stderr: ' + (phase1.stderr || '(empty)') + '\n');
|
|
341
365
|
const code = await runSingleShot(task);
|
|
342
366
|
const logFile = saveSessionLog();
|
|
343
367
|
if (logFile) console.log(' Log: ' + logFile);
|