@echo-agent/coding 0.3.0 → 0.5.0
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 +4 -4
- package/src/agent.ts +1 -0
- package/src/tools/bash.ts +9 -4
- package/src/tools/fs.ts +18 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@echo-agent/coding",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Echo's coding agent: file, search, shell and web tools, its own identity and conduct. Installs the `echo-coding` command. Requires Bun.",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"echo-coding": "./bin/echo-coding.ts"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@echo-agent/base": "0.
|
|
12
|
-
"@echo-agent/core": "0.
|
|
13
|
-
"@echo-agent/tui": "0.
|
|
11
|
+
"@echo-agent/base": "0.5.0",
|
|
12
|
+
"@echo-agent/core": "0.5.0",
|
|
13
|
+
"@echo-agent/tui": "0.5.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/bun": "latest",
|
package/src/agent.ts
CHANGED
|
@@ -103,6 +103,7 @@ const AGENT_BUILTIN_TOOLS = [
|
|
|
103
103
|
"skill_activate",
|
|
104
104
|
"skill_create",
|
|
105
105
|
"tool_search", // 2026-09-02 渐进式披露的入口,core 恒装(在不在菜单上另算,这里是池)
|
|
106
|
+
"tool_output_read", // 2026-11-02 大工具结果外存之后的读回,core 恒装、常驻菜单
|
|
106
107
|
"transcript_read",
|
|
107
108
|
// **会话面(`session_*`)不在这里**:挂不挂它是**容器**的决定(`CreateEchoOptions.sessions`),
|
|
108
109
|
// 不是产品身份。cli 开着它,所以真跑起来的 echo-coding 会多三件;而这份 digest 描述的是
|
package/src/tools/bash.ts
CHANGED
|
@@ -12,7 +12,12 @@ import { spawn, type ChildProcess } from "node:child_process";
|
|
|
12
12
|
import { existsSync } from "node:fs";
|
|
13
13
|
import { toolError, toolOk, type AgentBackground, type AgentToolResult, type ModelTool } from "@echo-agent/core";
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* 前台命令最多收这么多字符(2026-11-02):不再在这里截到 30,000 丢掉后半——报错多在末尾。
|
|
17
|
+
* 收全了交给 core:超过内联上限时全文外存、对话里只留头尾预览(`@echo-agent/core` 的工具结果外存)。
|
|
18
|
+
* 这个上限只防内存失控。
|
|
19
|
+
*/
|
|
20
|
+
const CAPTURE_CAP = 8 * 1024 * 1024;
|
|
16
21
|
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
17
22
|
/** job_output 缺省回读的字符数:够看清最近的日志,又不至于一次把缓冲全倒进上下文。 */
|
|
18
23
|
const JOB_TAIL_DEFAULT = 4_000;
|
|
@@ -217,7 +222,7 @@ function runForeground(
|
|
|
217
222
|
let tail = ""; // 末尾几百字节单独留着:cwd 标记在这里找,输出被截断也丢不了
|
|
218
223
|
const append = (chunk: string): void => {
|
|
219
224
|
tail = (tail + chunk).slice(-CWD_TAIL_KEEP);
|
|
220
|
-
if (out.length >=
|
|
225
|
+
if (out.length >= CAPTURE_CAP) {
|
|
221
226
|
truncated = true;
|
|
222
227
|
return;
|
|
223
228
|
}
|
|
@@ -248,8 +253,8 @@ function runForeground(
|
|
|
248
253
|
const marked = CWD_MARK_RE.exec(tail);
|
|
249
254
|
const newCwd = marked?.[1];
|
|
250
255
|
const body = marked === null ? out : out.replace(CWD_MARK_RE, "").replace(/\n$/, "");
|
|
251
|
-
let text = body.slice(0,
|
|
252
|
-
if (truncated || body.length >
|
|
256
|
+
let text = body.slice(0, CAPTURE_CAP);
|
|
257
|
+
if (truncated || body.length > CAPTURE_CAP) text += `\n…[output truncated: over ${CAPTURE_CAP} characters]`;
|
|
253
258
|
const withCwd = (r: AgentToolResult): AgentToolResult & { cwd?: string } => (newCwd === undefined ? r : { ...r, cwd: newCwd });
|
|
254
259
|
if (spawnError !== undefined) {
|
|
255
260
|
resolvePromise(toolError(`The command could not start: ${spawnError}`));
|
package/src/tools/fs.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { mkdir, readFile, realpath, stat, writeFile } from "node:fs/promises";
|
|
14
14
|
import { dirname, isAbsolute, resolve, sep } from "node:path";
|
|
15
15
|
import { toolError, toolOk, type ModelTool, type ToolExecutionContext } from "@echo-agent/core";
|
|
16
|
+
import { isImagePath, loadImageFile } from "@echo-agent/base";
|
|
16
17
|
|
|
17
18
|
/** 读回显的上限:超过就截断并标注——一个 50MB 的日志不该挤爆上下文。 */
|
|
18
19
|
const READ_CAP = 50_000;
|
|
@@ -98,8 +99,11 @@ function readFileTool(seen: SeenFiles): ModelTool<{ path: string; offset?: numbe
|
|
|
98
99
|
label: "读文件",
|
|
99
100
|
// 只读:模型一口气读五个文件时同批同跑。`seen` 只按路径记一条 mtime,同批互不覆盖。
|
|
100
101
|
concurrent: true,
|
|
102
|
+
// 自己会分页(行数 + `READ_CAP` 截断并教 offset/limit),不走 core 的外存——外存再读一遍是绕路(2026-11-02,同 Claude Code 的 Read)
|
|
103
|
+
maxInlineTokens: Infinity,
|
|
101
104
|
description:
|
|
102
|
-
"Read a file with line numbers. Use offset/limit to read a large file in parts. Read a file before editing it."
|
|
105
|
+
"Read a file with line numbers. Use offset/limit to read a large file in parts. Read a file before editing it. " +
|
|
106
|
+
"PNG, JPEG, GIF and WebP files are returned as images you can see; large ones are scaled down first.",
|
|
103
107
|
parameters: {
|
|
104
108
|
type: "object",
|
|
105
109
|
properties: {
|
|
@@ -112,6 +116,19 @@ function readFileTool(seen: SeenFiles): ModelTool<{ path: string; offset?: numbe
|
|
|
112
116
|
async execute({ path, offset, limit }, ctx) {
|
|
113
117
|
const abs = await resolveSafe(ctx, path);
|
|
114
118
|
if (abs === null) return toolError(`Path outside the workspace: '${path}'`);
|
|
119
|
+
// 图片按图片返回(2026-11-02,照 Claude Code 的 Read):大了先缩放。文件不存在、或扩展名是图片但内容不是,
|
|
120
|
+
// 落到下面照文本读(不存在就报 File not found)
|
|
121
|
+
if (isImagePath(abs)) {
|
|
122
|
+
const loaded = await loadImageFile(abs);
|
|
123
|
+
if (loaded.ok) {
|
|
124
|
+
const { width, height } = loaded.info;
|
|
125
|
+
const scaled = loaded.original === undefined ? "" : `, scaled down from ${loaded.original.width}×${loaded.original.height}`;
|
|
126
|
+
return toolOk(`Image file ${path} (${width}×${height}${scaled})`, { path, width, height }, [loaded.image]);
|
|
127
|
+
}
|
|
128
|
+
if (loaded.reason === "too_large") {
|
|
129
|
+
return toolError(`Cannot read ${path} as an image: ${loaded.message}. Make a smaller copy (for example with ImageMagick via bash) and read that.`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
115
132
|
let raw: string;
|
|
116
133
|
try {
|
|
117
134
|
raw = await readFile(abs, "utf8");
|