@zhongqian97-code/ecode 0.5.1 → 0.5.3
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/dist/index.js +51 -5
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -3524,18 +3524,64 @@ var SkillRegistry = class {
|
|
|
3524
3524
|
};
|
|
3525
3525
|
|
|
3526
3526
|
// src/pipe.ts
|
|
3527
|
+
var PIPE_TOOLS = [READ_TOOL, GLOB_TOOL, GREP_TOOL];
|
|
3527
3528
|
function emit(out, event) {
|
|
3528
3529
|
out.write(JSON.stringify(event) + "\n");
|
|
3529
3530
|
}
|
|
3531
|
+
async function executeToolCall(name, args) {
|
|
3532
|
+
if (name === "read") {
|
|
3533
|
+
const parsed = JSON.parse(args);
|
|
3534
|
+
return readFile2(parsed);
|
|
3535
|
+
}
|
|
3536
|
+
if (name === "glob") {
|
|
3537
|
+
const parsed = JSON.parse(args);
|
|
3538
|
+
return globFiles(parsed);
|
|
3539
|
+
}
|
|
3540
|
+
if (name === "grep") {
|
|
3541
|
+
const parsed = JSON.parse(args);
|
|
3542
|
+
return grepFiles(parsed);
|
|
3543
|
+
}
|
|
3544
|
+
return `Unknown tool: ${name}`;
|
|
3545
|
+
}
|
|
3530
3546
|
async function runPipe(prompt, llm, out = process.stdout) {
|
|
3531
3547
|
const messages = [{ role: "user", content: prompt }];
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3548
|
+
while (true) {
|
|
3549
|
+
let assistantText = "";
|
|
3550
|
+
let lastUsage;
|
|
3551
|
+
const toolCalls = [];
|
|
3552
|
+
for await (const chunk of llm.stream(messages, PIPE_TOOLS)) {
|
|
3553
|
+
if (chunk.text) {
|
|
3554
|
+
emit(out, { type: "chunk", text: chunk.text });
|
|
3555
|
+
assistantText += chunk.text;
|
|
3556
|
+
}
|
|
3557
|
+
if (chunk.reasoning) {
|
|
3558
|
+
emit(out, { type: "reasoning", text: chunk.reasoning });
|
|
3559
|
+
}
|
|
3560
|
+
if (chunk.done) {
|
|
3561
|
+
if (chunk.toolCalls) toolCalls.push(...chunk.toolCalls);
|
|
3562
|
+
if (chunk.usage) lastUsage = chunk.usage;
|
|
3563
|
+
}
|
|
3535
3564
|
}
|
|
3536
|
-
if (
|
|
3537
|
-
|
|
3565
|
+
if (toolCalls.length > 0) {
|
|
3566
|
+
messages.push({
|
|
3567
|
+
role: "assistant",
|
|
3568
|
+
content: assistantText || null,
|
|
3569
|
+
tool_calls: toolCalls.map((tc) => ({
|
|
3570
|
+
id: tc.id,
|
|
3571
|
+
type: "function",
|
|
3572
|
+
function: { name: tc.name, arguments: tc.arguments }
|
|
3573
|
+
}))
|
|
3574
|
+
});
|
|
3575
|
+
for (const tc of toolCalls) {
|
|
3576
|
+
emit(out, { type: "tool_call", id: tc.id, name: tc.name, arguments: tc.arguments });
|
|
3577
|
+
const content = await executeToolCall(tc.name, tc.arguments);
|
|
3578
|
+
emit(out, { type: "tool_result", toolCallId: tc.id, name: tc.name, content });
|
|
3579
|
+
messages.push({ role: "tool", tool_call_id: tc.id, content });
|
|
3580
|
+
}
|
|
3581
|
+
} else {
|
|
3582
|
+
const doneEvent = lastUsage ? { type: "done", usage: lastUsage } : { type: "done" };
|
|
3538
3583
|
emit(out, doneEvent);
|
|
3584
|
+
break;
|
|
3539
3585
|
}
|
|
3540
3586
|
}
|
|
3541
3587
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhongqian97-code/ecode",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "A minimal Claude Code clone with REPL interface and bash tool calling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "zhongqian97-code",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"build": "tsup",
|
|
38
38
|
"dev": "tsx src/index.ts",
|
|
39
39
|
"test": "vitest run",
|
|
40
|
+
"pretest:integration": "npm run build",
|
|
40
41
|
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
41
42
|
"test:watch": "vitest"
|
|
42
43
|
},
|