@zhongqian97-code/ecode 0.5.61 → 0.5.63
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.
|
@@ -126,6 +126,23 @@ async function loadSkillsFromDir(dir) {
|
|
|
126
126
|
return skills.sort((a, b) => a.name.localeCompare(b.name));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
// src/llm.ts
|
|
130
|
+
function buildAssistantMessage(assistantText, toolCalls, assistantReasoning) {
|
|
131
|
+
const msg = {
|
|
132
|
+
role: "assistant",
|
|
133
|
+
content: assistantText || (toolCalls.length > 0 ? null : ""),
|
|
134
|
+
reasoning_content: assistantReasoning ?? ""
|
|
135
|
+
};
|
|
136
|
+
if (toolCalls.length > 0) {
|
|
137
|
+
msg.tool_calls = toolCalls.map((tc) => ({
|
|
138
|
+
id: tc.id,
|
|
139
|
+
type: "function",
|
|
140
|
+
function: { name: tc.name, arguments: tc.arguments }
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
return msg;
|
|
144
|
+
}
|
|
145
|
+
|
|
129
146
|
// src/tools/read.ts
|
|
130
147
|
import * as fs from "fs/promises";
|
|
131
148
|
var READ_TOOL = {
|
|
@@ -1708,6 +1725,7 @@ ${prompt}` : prompt;
|
|
|
1708
1725
|
export {
|
|
1709
1726
|
isTrustedSkillPath,
|
|
1710
1727
|
loadSkillsFromDir,
|
|
1728
|
+
buildAssistantMessage,
|
|
1711
1729
|
READ_TOOL,
|
|
1712
1730
|
readFile3 as readFile,
|
|
1713
1731
|
GLOB_TOOL,
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
WEB_FETCH_TOOL,
|
|
21
21
|
WRITE_TOOL,
|
|
22
22
|
applyPatch,
|
|
23
|
+
buildAssistantMessage,
|
|
23
24
|
classifyCommand,
|
|
24
25
|
createLogger,
|
|
25
26
|
createLoggerAtPath,
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
todo,
|
|
34
35
|
webFetch,
|
|
35
36
|
writeFile
|
|
36
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-ZLF4HLQ7.js";
|
|
37
38
|
import {
|
|
38
39
|
createProvider,
|
|
39
40
|
createSessionMetadata,
|
|
@@ -185,14 +186,7 @@ async function runPipe(prompt, llm, out = process.stdout, systemPrompt) {
|
|
|
185
186
|
}
|
|
186
187
|
if (toolCalls.length > 0) {
|
|
187
188
|
messages.push({
|
|
188
|
-
|
|
189
|
-
content: assistantText || null,
|
|
190
|
-
tool_calls: toolCalls.map((tc) => ({
|
|
191
|
-
id: tc.id,
|
|
192
|
-
type: "function",
|
|
193
|
-
function: { name: tc.name, arguments: tc.arguments }
|
|
194
|
-
})),
|
|
195
|
-
...lastReasoning ? { reasoning_content: lastReasoning } : {},
|
|
189
|
+
...buildAssistantMessage(assistantText, toolCalls, lastReasoning),
|
|
196
190
|
...lastReasoningDetails ? { reasoning_details: lastReasoningDetails } : {}
|
|
197
191
|
});
|
|
198
192
|
for (const tc of toolCalls) {
|
|
@@ -456,14 +450,7 @@ var SessionRuntime = class {
|
|
|
456
450
|
if (toolCalls.length > 0) {
|
|
457
451
|
this._status = "tool_calling";
|
|
458
452
|
this.messages.push({
|
|
459
|
-
|
|
460
|
-
content: assistantText || null,
|
|
461
|
-
tool_calls: toolCalls.map((tc) => ({
|
|
462
|
-
id: tc.id,
|
|
463
|
-
type: "function",
|
|
464
|
-
function: { name: tc.name, arguments: tc.arguments }
|
|
465
|
-
})),
|
|
466
|
-
...assistantReasoning ? { reasoning_content: assistantReasoning } : {},
|
|
453
|
+
...buildAssistantMessage(assistantText, toolCalls, assistantReasoning),
|
|
467
454
|
...lastReasoningDetails ? { reasoning_details: lastReasoningDetails } : {}
|
|
468
455
|
});
|
|
469
456
|
(_a = this.logger) == null ? void 0 : _a.append({
|
|
@@ -486,11 +473,7 @@ var SessionRuntime = class {
|
|
|
486
473
|
}
|
|
487
474
|
} else {
|
|
488
475
|
if (assistantText) {
|
|
489
|
-
this.messages.push(
|
|
490
|
-
role: "assistant",
|
|
491
|
-
content: assistantText,
|
|
492
|
-
...assistantReasoning ? { reasoning_content: assistantReasoning } : {}
|
|
493
|
-
});
|
|
476
|
+
this.messages.push(buildAssistantMessage(assistantText, [], assistantReasoning));
|
|
494
477
|
(_c = this.logger) == null ? void 0 : _c.append({ ts: (/* @__PURE__ */ new Date()).toISOString(), role: "assistant", content: assistantText || null });
|
|
495
478
|
}
|
|
496
479
|
break;
|
|
@@ -819,7 +802,7 @@ if (rawArgs[0] === "web") {
|
|
|
819
802
|
webAutoApprove = true;
|
|
820
803
|
}
|
|
821
804
|
}
|
|
822
|
-
const { buildServer, generateAccessToken } = await import("./web-
|
|
805
|
+
const { buildServer, generateAccessToken } = await import("./web-JSKN3U25.js");
|
|
823
806
|
const token = finalConfig.webToken ?? generateAccessToken();
|
|
824
807
|
const manager = new SessionManager(finalConfig);
|
|
825
808
|
const __webDirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -916,7 +899,7 @@ Node.js 16/18 \u8BF7\u4F7F\u7528 --web \u6216 --pipe \u6A21\u5F0F\u3002
|
|
|
916
899
|
);
|
|
917
900
|
process.exit(1);
|
|
918
901
|
}
|
|
919
|
-
const { App, React, render, createStdinFilter } = await import("./ui-
|
|
902
|
+
const { App, React, render, createStdinFilter } = await import("./ui-445CQEQR.js");
|
|
920
903
|
const stdinFilter = process.stdin.isTTY ? createStdinFilter(process.stdin) : process.stdin;
|
|
921
904
|
render(
|
|
922
905
|
React.createElement(App, { config: finalConfig, version: VERSION, autoMode, registry, trustedSkillDirs, initialMessages, stdinFilter }),
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
WEB_FETCH_TOOL,
|
|
13
13
|
WRITE_TOOL,
|
|
14
14
|
applyPatch,
|
|
15
|
+
buildAssistantMessage,
|
|
15
16
|
createLogger,
|
|
16
17
|
editFile,
|
|
17
18
|
executeBash,
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
todo,
|
|
25
26
|
webFetch,
|
|
26
27
|
writeFile
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-ZLF4HLQ7.js";
|
|
28
29
|
import {
|
|
29
30
|
handleSkillInput,
|
|
30
31
|
loadJobs,
|
|
@@ -2969,18 +2970,11 @@ function App({ config, version, autoMode = false, registry, trustedSkillDirs = [
|
|
|
2969
2970
|
throw err;
|
|
2970
2971
|
}
|
|
2971
2972
|
if (toolCalls.length > 0) {
|
|
2972
|
-
const assistantMsg =
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
id: tc.id,
|
|
2978
|
-
type: "function",
|
|
2979
|
-
function: { name: tc.name, arguments: tc.arguments }
|
|
2980
|
-
})),
|
|
2981
|
-
// 仅在存在思考内容时扩展 reasoning_content 字段
|
|
2982
|
-
...assistantReasoning ? { reasoning_content: assistantReasoning } : {}
|
|
2983
|
-
};
|
|
2973
|
+
const assistantMsg = buildAssistantMessage(
|
|
2974
|
+
assistantText,
|
|
2975
|
+
toolCalls,
|
|
2976
|
+
assistantReasoning
|
|
2977
|
+
);
|
|
2984
2978
|
setMessages((prev) => {
|
|
2985
2979
|
const last = prev[prev.length - 1];
|
|
2986
2980
|
const withoutStreaming = (last == null ? void 0 : last.role) === "assistant" && !last.tool_calls ? prev.slice(0, -1) : prev;
|
|
@@ -3056,11 +3050,7 @@ function App({ config, version, autoMode = false, registry, trustedSkillDirs = [
|
|
|
3056
3050
|
setMessages((prev) => {
|
|
3057
3051
|
const last = prev[prev.length - 1];
|
|
3058
3052
|
if ((last == null ? void 0 : last.role) === "assistant" && !last.tool_calls) {
|
|
3059
|
-
const updated =
|
|
3060
|
-
role: "assistant",
|
|
3061
|
-
content: assistantText,
|
|
3062
|
-
...assistantReasoning ? { reasoning_content: assistantReasoning } : {}
|
|
3063
|
-
};
|
|
3053
|
+
const updated = buildAssistantMessage(assistantText, [], assistantReasoning);
|
|
3064
3054
|
return [...prev.slice(0, -1), updated];
|
|
3065
3055
|
}
|
|
3066
3056
|
return prev;
|
|
@@ -3068,11 +3058,7 @@ function App({ config, version, autoMode = false, registry, trustedSkillDirs = [
|
|
|
3068
3058
|
if (assistantText) {
|
|
3069
3059
|
currentMessages = [
|
|
3070
3060
|
...currentMessages,
|
|
3071
|
-
|
|
3072
|
-
role: "assistant",
|
|
3073
|
-
content: assistantText,
|
|
3074
|
-
...assistantReasoning ? { reasoning_content: assistantReasoning } : {}
|
|
3075
|
-
}
|
|
3061
|
+
buildAssistantMessage(assistantText, [], assistantReasoning)
|
|
3076
3062
|
];
|
|
3077
3063
|
}
|
|
3078
3064
|
}
|
|
@@ -670,20 +670,45 @@ function generateAdminHtml(version) {
|
|
|
670
670
|
|
|
671
671
|
// Basic markdown \u2192 HTML (no libs)
|
|
672
672
|
function renderMarkdown(text) {
|
|
673
|
-
//
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
.replace(
|
|
677
|
-
.
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
673
|
+
// Protect fenced/inline code BEFORE escaping (highlightCode/escHtml escape internally)
|
|
674
|
+
const codeBlocks = [];
|
|
675
|
+
let s = String(text).replace(/\`\`\`([\\s\\S]*?)\`\`\`/g, (_, code) => {
|
|
676
|
+
codeBlocks.push('<pre><code>' + highlightCode(code.replace(/^\\n+/, '').replace(/\\n+$/, '')) + '</code></pre>');
|
|
677
|
+
return '\\u0001CB' + (codeBlocks.length - 1) + '\\u0001';
|
|
678
|
+
});
|
|
679
|
+
const inlineCode = [];
|
|
680
|
+
s = s.replace(/\`([^\`]+)\`/g, (_, code) => {
|
|
681
|
+
inlineCode.push('<code>' + escHtml(code) + '</code>');
|
|
682
|
+
return '\\u0001IC' + (inlineCode.length - 1) + '\\u0001';
|
|
683
|
+
});
|
|
684
|
+
// Escape remaining text
|
|
685
|
+
s = escHtml(s);
|
|
686
|
+
// Inline: links, bold, italic, strikethrough
|
|
687
|
+
s = s.replace(/\\[([^\\]]+)\\]\\(([^)\\s]+)\\)/g, '<a href="$2" target="_blank" rel="noopener">$1</a>');
|
|
684
688
|
s = s.replace(/\\*\\*([^*]+)\\*\\*/g, '<strong>$1</strong>');
|
|
689
|
+
s = s.replace(/(^|[^*])\\*([^*\\n]+)\\*/g, '$1<em>$2</em>');
|
|
690
|
+
s = s.replace(/~~([^~]+)~~/g, '<del>$1</del>');
|
|
691
|
+
// Block: headers + lists, line by line
|
|
692
|
+
const lines = s.split('\\n');
|
|
693
|
+
const out = [];
|
|
694
|
+
let listType = null;
|
|
695
|
+
const closeList = () => { if (listType) { out.push('</' + listType + '>'); listType = null; } };
|
|
696
|
+
for (const line of lines) {
|
|
697
|
+
const h = line.match(/^(#+)\\s+(.*)$/);
|
|
698
|
+
const ul = line.match(/^\\s*[-*]\\s+(.*)$/);
|
|
699
|
+
const ol = line.match(/^\\s*\\d+\\.\\s+(.*)$/);
|
|
700
|
+
if (h) { closeList(); const lvl = Math.min(h[1].length, 6); out.push('<h' + lvl + '>' + h[2] + '</h' + lvl + '>'); }
|
|
701
|
+
else if (ul) { if (listType !== 'ul') { closeList(); out.push('<ul>'); listType = 'ul'; } out.push('<li>' + ul[1] + '</li>'); }
|
|
702
|
+
else if (ol) { if (listType !== 'ol') { closeList(); out.push('<ol>'); listType = 'ol'; } out.push('<li>' + ol[1] + '</li>'); }
|
|
703
|
+
else { closeList(); out.push(line); }
|
|
704
|
+
}
|
|
705
|
+
closeList();
|
|
706
|
+
s = out.join('\\n');
|
|
685
707
|
// Paragraph breaks
|
|
686
708
|
s = s.replace(/\\n\\n+/g, '</p><p>');
|
|
709
|
+
// Restore code placeholders
|
|
710
|
+
s = s.replace(/\\u0001CB(\\d+)\\u0001/g, (_, i) => codeBlocks[+i]);
|
|
711
|
+
s = s.replace(/\\u0001IC(\\d+)\\u0001/g, (_, i) => inlineCode[+i]);
|
|
687
712
|
return '<p>' + s + '</p>';
|
|
688
713
|
}
|
|
689
714
|
|
|
@@ -834,7 +859,10 @@ function generateAdminHtml(version) {
|
|
|
834
859
|
function finalizeStreamingMsg() {
|
|
835
860
|
if (state.streamingMsgEl) {
|
|
836
861
|
const body = state.streamingMsgEl.querySelector('.msg-body');
|
|
837
|
-
if (body)
|
|
862
|
+
if (body) {
|
|
863
|
+
body.classList.remove('cursor-blink');
|
|
864
|
+
body.innerHTML = renderMarkdown(body.textContent);
|
|
865
|
+
}
|
|
838
866
|
state.streamingMsgEl = null;
|
|
839
867
|
}
|
|
840
868
|
state.streamingThinkEl = null;
|