@echo-agent/coding 0.1.0 → 0.3.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/README.md +12 -12
- package/package.json +4 -4
- package/src/agent.ts +2 -1
- package/src/cli.ts +3 -1
- package/src/extensions.ts +15 -46
- package/src/permission.ts +2 -2
- package/src/tools/worktree.ts +3 -0
package/README.md
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
# @echo-agent/coding
|
|
2
2
|
|
|
3
|
-
Echo's coding agent: file, search, shell and web tools
|
|
4
|
-
|
|
3
|
+
Echo's coding agent: file, search, shell and web tools, as a product built from
|
|
4
|
+
`@echo-agent/base` and `@echo-agent/tui`. Installs the `echo-coding` command.
|
|
5
5
|
|
|
6
6
|
> **Requires [Bun](https://bun.sh/).** The executable is TypeScript with a `#!/usr/bin/env bun`
|
|
7
7
|
> shebang, and the package entry point is TypeScript source. Node is not supported for this
|
|
8
8
|
> package.
|
|
9
9
|
|
|
10
|
-
> **Status:
|
|
11
|
-
> before the first `0.x` release. Install from source for now.
|
|
10
|
+
> **Status: `0.x`.** Until `1.0`, a minor version may contain breaking changes.
|
|
12
11
|
|
|
13
12
|
## Run it
|
|
14
13
|
|
|
15
14
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
bun install
|
|
19
|
-
MOONSHOT_API_KEY=sk-... bun packages/coding/bin/echo-coding.ts
|
|
15
|
+
bun add -g @echo-agent/coding
|
|
16
|
+
MOONSHOT_API_KEY=sk-... echo-coding
|
|
20
17
|
```
|
|
21
18
|
|
|
19
|
+
Or run it once without installing: `bunx --package @echo-agent/coding echo-coding`.
|
|
20
|
+
|
|
22
21
|
The command name stays `echo-coding` even though the package is scoped — the unscoped name was
|
|
23
22
|
already taken on npm by an unrelated project.
|
|
24
23
|
|
|
@@ -31,10 +30,11 @@ conversation even in the same directory.
|
|
|
31
30
|
|
|
32
31
|
## What this package is
|
|
33
32
|
|
|
34
|
-
A **product**, not a framework layer. It owns its
|
|
35
|
-
`echo:workspace`, `echo:shell`, `echo:worktree` and `echo:web` extensions
|
|
36
|
-
|
|
37
|
-
path a third-party product
|
|
33
|
+
A **product**, not a framework layer. It owns its identity and conduct sections, its permission
|
|
34
|
+
policy and the `echo:workspace`, `echo:shell`, `echo:worktree` and `echo:web` extensions; the
|
|
35
|
+
launcher parts come from `@echo-agent/base` and the terminal shell from `@echo-agent/tui`. It does
|
|
36
|
+
not depend on `echo-agent` — the two are siblings, which is exactly the path a third-party product
|
|
37
|
+
would take on this runtime.
|
|
38
38
|
|
|
39
39
|
Full documentation is in the
|
|
40
40
|
[repository README](https://github.com/echo-yiyi/echo-agent#readme).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@echo-agent/coding",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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.3.0",
|
|
12
|
+
"@echo-agent/core": "0.3.0",
|
|
13
|
+
"@echo-agent/tui": "0.3.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/bun": "latest",
|
package/src/agent.ts
CHANGED
|
@@ -96,6 +96,7 @@ const AGENT_BUILTIN_TOOLS = [
|
|
|
96
96
|
"TaskList",
|
|
97
97
|
"TaskUpdate",
|
|
98
98
|
"subagent", // 2026-09-06 委派工具,core 恒装;子 agent 的样子由模型在调用时决定
|
|
99
|
+
"extension_reload", // 2026-09-14 模型自己触发热部署;`createEcho()` 有扩展目录可扫就装(低层没有)
|
|
99
100
|
"schedule_cancel",
|
|
100
101
|
"schedule_create",
|
|
101
102
|
"schedule_list",
|
|
@@ -179,5 +180,5 @@ export function codingPreset(opts: CodingPresetOptions = {}): CodingPreset {
|
|
|
179
180
|
};
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
/** `bash` 单独造一把(不经 Extension
|
|
183
|
+
/** `bash` 单独造一把(不经 Extension)。`makeShellTools()` 与测试都从这里造。 */
|
|
183
184
|
export { makeBashTool };
|
package/src/cli.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// 评测或别的宿主可以自己传——本产品不缺省开它。
|
|
15
15
|
|
|
16
16
|
import { readFileSync } from "node:fs";
|
|
17
|
-
import { conductEntry, mainFor, type Product } from "@echo-agent/base";
|
|
17
|
+
import { conductEntry, mainFor, retainRecentDays, type Product } from "@echo-agent/base";
|
|
18
18
|
import { terminalShell } from "@echo-agent/tui";
|
|
19
19
|
import { codingPreset } from "./agent.ts";
|
|
20
20
|
|
|
@@ -38,6 +38,8 @@ export const ECHO_CODING: Product = Object.freeze({
|
|
|
38
38
|
const preset = codingPreset({ permission: false, maxIterations: 200, credentials: host.credentials });
|
|
39
39
|
return { ...preset, extensions: [conductEntry(form), ...preset.extensions] };
|
|
40
40
|
},
|
|
41
|
+
// 观测留 30 天(2026-09-15 用户拍板,与 echo-agent 同一条规则;两个产品平级,各自声明各自的)。
|
|
42
|
+
observationExpiry: retainRecentDays(30),
|
|
41
43
|
});
|
|
42
44
|
|
|
43
45
|
/** 进程入口的实质:`echo-agent` 的 `main` 绑上本产品。签名与它完全相同,退出码语义也相同。 */
|
package/src/extensions.ts
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
// 并且规格明写 first-party Extension「是公开扩展面是否够用的第一个 conformance consumer」——
|
|
7
7
|
// 我们自己先用一遍,扩展作者才不会撞上只有他们能看见的坑。
|
|
8
8
|
//
|
|
9
|
-
// **`defineToolPack`
|
|
9
|
+
// **`defineToolPack` 与 `registerAll` 都来自 `@echo-agent/core/extension`,不在这里另抄一份**(review 二轮 P1;
|
|
10
|
+
// 2026-09-14 `registerAll` 导出后,下面两条扩展手抄的逆序撤销也换成了它):
|
|
10
11
|
// 上一版这里复制了 core 的实现,于是「注册中途撞名要整组回滚」那个修复得改两处——
|
|
11
12
|
// 复制一份实现就是复制一份将来会漏修的地方。
|
|
12
13
|
|
|
13
|
-
import { AgentBackgroundService, AgentPrompt, AgentRuntimeService, AgentTools, defineExtension, defineToolPack } from "@echo-agent/core/extension";
|
|
14
|
+
import { AgentBackgroundService, AgentPrompt, AgentRuntimeService, AgentTools, defineExtension, defineToolPack, registerAll } from "@echo-agent/core/extension";
|
|
14
15
|
import { makeShellTools } from "./tools/bash.ts";
|
|
15
16
|
import { makeWorktreeTools } from "./tools/worktree.ts";
|
|
16
17
|
import { shellToolsSection } from "./prompt.ts";
|
|
@@ -38,21 +39,8 @@ export const ECHO_WORKTREE = defineExtension({
|
|
|
38
39
|
const tools = makeWorktreeTools({ runtime: ctx.get(AgentRuntimeService) });
|
|
39
40
|
void ctx.effect({
|
|
40
41
|
boundary: "turn",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
for (const tool of tools) offs.push(registry.register(tool));
|
|
45
|
-
} catch (e) {
|
|
46
|
-
for (const off of offs.reverse()) void off();
|
|
47
|
-
throw e;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
value: tools.map((t) => t.name),
|
|
51
|
-
dispose: () => {
|
|
52
|
-
for (const off of offs.reverse()) void off();
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
},
|
|
42
|
+
// 中途撞名整组撤回、卸载逆序全撤:`registerAll`,与内建同一份
|
|
43
|
+
start: () => registerAll(tools.map((tool) => () => registry.register(tool))),
|
|
56
44
|
});
|
|
57
45
|
},
|
|
58
46
|
});
|
|
@@ -68,19 +56,15 @@ export const ECHO_WORKTREE = defineExtension({
|
|
|
68
56
|
* (`AgentBackgroundService`,见 `extension/registries.ts` 文件头)。于是本扩展变成
|
|
69
57
|
* 纯静态的一条 definition,装配层只管把它列进 `createEcho({ extensions })`。
|
|
70
58
|
*
|
|
71
|
-
* **`required: true
|
|
72
|
-
* `
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* 改 required 之后语义反而更准:`agent.background` 是 **Agent 恒有的能力**
|
|
78
|
-
* (构造函数无条件造),所以任何由 Agent 造出来的 registries 都提供得了它。
|
|
79
|
-
* 走 `createEcho()` 恒有;自己搭 Host 而不传 `background` 就装不上本扩展,
|
|
59
|
+
* **`required: true`,不是软依赖**(2026-08-31 review 三轮 P1 修正):上一版写的是 `required: false`,
|
|
60
|
+
* 理由是「没接后台队列照样能跑命令」——但 apply 里无条件 `ctx.get()`,缺 provider 一样抛,review 实测整代装不上
|
|
61
|
+
* (那时 ABI 也没有不抛的读法;2026-09-14 加了 `ctx.tryGet()`,软依赖从此有正式用法,但那是给真会缺席的
|
|
62
|
+
* Service 用的)。`agent.background` 是 **Agent 恒有的能力**(构造函数无条件造),任何由 Agent 造出来的 registries
|
|
63
|
+
* 都提供得了它,所以这里就该是硬依赖:走 `createEcho()` 恒有;自己搭 Host 而不传 `background` 就在 PREPARE 装不上,
|
|
80
64
|
* 报错明确指向缺的那条 Service——比装上一个「bash 在但后台不灵」的半残工具好。
|
|
81
65
|
*
|
|
82
|
-
* (`makeBashTool()` 的 `deps.background`
|
|
83
|
-
*
|
|
66
|
+
* (`makeBashTool()` 的 `deps.background` 仍是可选:单独造工具、不接后台队列时 `background: true` 不可用,
|
|
67
|
+
* 与本扩展的装配前提是两件事。)
|
|
84
68
|
*/
|
|
85
69
|
export const ECHO_SHELL = defineExtension({
|
|
86
70
|
name: "echo:shell",
|
|
@@ -98,24 +82,9 @@ export const ECHO_SHELL = defineExtension({
|
|
|
98
82
|
void ctx.effect({
|
|
99
83
|
// 与 `defineToolPack` 同一档:工具面每轮都可能变,声明得比实际需要强会挡住热重载
|
|
100
84
|
boundary: "turn",
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const offs: (() => unknown)[] = [];
|
|
105
|
-
try {
|
|
106
|
-
for (const tool of tools) offs.push(registry.register(tool));
|
|
107
|
-
offs.push(prompt.section(shellToolsSection()));
|
|
108
|
-
} catch (e) {
|
|
109
|
-
for (const off of offs.reverse()) void off();
|
|
110
|
-
throw e;
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
value: tools.map((t) => t.name),
|
|
114
|
-
dispose: () => {
|
|
115
|
-
for (const off of offs.reverse()) void off();
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
},
|
|
85
|
+
// 工具与它们的习惯段(`tool:shell`)同一个 effect:一起装、一起撤。
|
|
86
|
+
// 中途撞名要把已注册的撤回去——半组工具在、半组不在,比整组不在更难排查(`registerAll`,与内建同一份)
|
|
87
|
+
start: () => registerAll([...tools.map((tool) => () => registry.register(tool)), () => prompt.section(shellToolsSection())]),
|
|
119
88
|
});
|
|
120
89
|
},
|
|
121
90
|
});
|
package/src/permission.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 权限:产品策略翻译成 core 的 authorization stage,不再是一条 preToolUse hook。
|
|
2
2
|
//
|
|
3
3
|
// 三档规则不变:allow(放行)/ deny(拒)/ ask(问裁决人)。规则在构造期交给 Agent
|
|
4
|
-
// (`permissionPolicyFor()` → `
|
|
4
|
+
// (`permissionPolicyFor()` → `EchoAgentOptions.permission`),跑在固定 stage:
|
|
5
5
|
// transform hooks → 重新校验 → freeze → authorization → execute。裁决看到的是冻结后的最终参数,
|
|
6
6
|
// 人批准的和工具执行的是同一份;hook 在它之后改不了参数。
|
|
7
7
|
//
|
|
@@ -48,7 +48,7 @@ export const DEFAULT_PERMISSION: PermissionPolicy = {
|
|
|
48
48
|
fallback: "allow",
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
/** 把产品策略翻译成 core 的 stage
|
|
51
|
+
/** 把产品策略翻译成 core 的 stage 策略——构造期经 `createEcho({ agent: { permission } })` 交给 core。 */
|
|
52
52
|
export function permissionPolicyFor(policy: PermissionPolicy = DEFAULT_PERMISSION): CorePermissionPolicy {
|
|
53
53
|
return {
|
|
54
54
|
authorize: ({ toolName }) => {
|
package/src/tools/worktree.ts
CHANGED
|
@@ -70,6 +70,8 @@ function enterTool(deps: WorktreeDeps, state: WorktreeState): ModelTool<{ name?:
|
|
|
70
70
|
kind: "model",
|
|
71
71
|
name: "worktree_enter",
|
|
72
72
|
label: "进 worktree",
|
|
73
|
+
// 切的是父 agent 的 workspace:子 agent 调一下父就跟着换了目录(2026-09-14 拍板:不可委派)
|
|
74
|
+
delegable: false,
|
|
73
75
|
description:
|
|
74
76
|
"Create a git worktree for this repository at .echo/worktrees/<name> on a new branch <name> (from the current HEAD) " +
|
|
75
77
|
"and make it the workspace: from then on file tools, search and bash resolve paths there, while the original checkout " +
|
|
@@ -116,6 +118,7 @@ function exitTool(deps: WorktreeDeps, state: WorktreeState): ModelTool<{ remove?
|
|
|
116
118
|
name: "worktree_exit",
|
|
117
119
|
label: "出 worktree",
|
|
118
120
|
deferred: true,
|
|
121
|
+
delegable: false,
|
|
119
122
|
description:
|
|
120
123
|
"Leave the worktree entered with worktree_enter: the workspace goes back to the main checkout. " +
|
|
121
124
|
"With remove: true the worktree directory is deleted afterwards (git refuses while it has uncommitted changes); " +
|