kernelbot 1.0.17 → 1.0.18
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/package.json +1 -1
- package/src/coder.js +7 -2
- package/src/tools/coding.js +25 -2
package/package.json
CHANGED
package/src/coder.js
CHANGED
|
@@ -222,8 +222,13 @@ export class ClaudeCodeSpawner {
|
|
|
222
222
|
processEvent(buffer.trim(), onOutput, logger);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
logger.info(`Claude Code exited with code ${code} | stdout: ${fullOutput.length} chars | stderr: ${stderr.length} chars`);
|
|
226
|
+
|
|
227
|
+
if (code !== 0) {
|
|
228
|
+
const errMsg = stderr.trim() || fullOutput.trim() || `exited with code ${code}`;
|
|
229
|
+
logger.error(`Claude Code failed: ${errMsg.slice(0, 500)}`);
|
|
230
|
+
if (onOutput) onOutput(`❌ Claude Code failed (exit ${code}):\n\`\`\`\n${errMsg.slice(0, 400)}\n\`\`\``).catch(() => {});
|
|
231
|
+
reject(new Error(`Claude Code exited with code ${code}: ${errMsg.slice(0, 500)}`));
|
|
227
232
|
} else {
|
|
228
233
|
resolve({
|
|
229
234
|
output: resultText || fullOutput.trim(),
|
package/src/tools/coding.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { resolve } from 'path';
|
|
1
3
|
import { ClaudeCodeSpawner } from '../coder.js';
|
|
4
|
+
import { getLogger } from '../utils/logger.js';
|
|
2
5
|
|
|
3
6
|
let spawner = null;
|
|
4
7
|
|
|
@@ -35,16 +38,36 @@ export const definitions = [
|
|
|
35
38
|
|
|
36
39
|
export const handlers = {
|
|
37
40
|
spawn_claude_code: async (params, context) => {
|
|
41
|
+
const logger = getLogger();
|
|
42
|
+
const onUpdate = context.onUpdate || null;
|
|
43
|
+
const dir = resolve(params.working_directory);
|
|
44
|
+
|
|
45
|
+
// Validate directory exists
|
|
46
|
+
if (!existsSync(dir)) {
|
|
47
|
+
const msg = `Directory not found: ${dir}`;
|
|
48
|
+
logger.error(`spawn_claude_code: ${msg}`);
|
|
49
|
+
if (onUpdate) onUpdate(`❌ ${msg}`).catch(() => {});
|
|
50
|
+
return { error: msg };
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
try {
|
|
39
54
|
const coder = getSpawner(context.config);
|
|
40
55
|
const result = await coder.run({
|
|
41
|
-
workingDirectory:
|
|
56
|
+
workingDirectory: dir,
|
|
42
57
|
prompt: params.prompt,
|
|
43
58
|
maxTurns: params.max_turns,
|
|
44
|
-
onOutput:
|
|
59
|
+
onOutput: onUpdate,
|
|
45
60
|
});
|
|
61
|
+
|
|
62
|
+
// Show stderr if any
|
|
63
|
+
if (result.stderr && onUpdate) {
|
|
64
|
+
onUpdate(`⚠️ Claude Code stderr:\n\`\`\`\n${result.stderr.slice(0, 500)}\n\`\`\``).catch(() => {});
|
|
65
|
+
}
|
|
66
|
+
|
|
46
67
|
return { success: true, output: result.output };
|
|
47
68
|
} catch (err) {
|
|
69
|
+
logger.error(`spawn_claude_code failed: ${err.message}`);
|
|
70
|
+
if (onUpdate) onUpdate(`❌ Claude Code error: ${err.message}`).catch(() => {});
|
|
48
71
|
return { error: err.message };
|
|
49
72
|
}
|
|
50
73
|
},
|