@ai-zen/cli 0.8.1 → 0.9.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/CHANGELOG.md +39 -0
- package/README.md +5 -4
- package/README.zh.md +5 -4
- package/dist/agent-creator.d.ts +5 -5
- package/dist/agent-creator.d.ts.map +1 -1
- package/dist/agent-creator.js +17 -15
- package/dist/agent-creator.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.0] - 2026-09-30
|
|
4
|
+
|
|
5
|
+
### 💥 破坏性变更
|
|
6
|
+
|
|
7
|
+
- **升级 `@ai-zen/agents-sdk` 到 `1.0.0-alpha.0`(Provider → Scope 架构重构)** — SDK 1.0.0-alpha.0 将全局入口对象 `Provider` 改名为 `Scope`,把四类能力来源疏散为 5 个可组合的 `ScopePlugin`,并移除 `Provider.create()`(改为显式装配)。CLI 侧同步适配 `src/agent-creator.ts`:
|
|
8
|
+
- 导入 `Scope` / `allInOne` 取代 `Provider`
|
|
9
|
+
- `Provider.create({ config, agentsDir, subAgentsPaths, skillsPaths, toolsPaths, mcpPaths })` → `new Scope({ config, agentsDir }).use(...allInOne({ subAgentsPaths, skillsPaths, toolsPaths, mcpPaths }))` + `await scope.init()`
|
|
10
|
+
- 单例/工厂改名:`getProvider` → `getScope`、`resetProvider` → `resetScope`;`createAgent` 内部改调 `sdkCreateAgent(scope, agentId)`
|
|
11
|
+
- 依赖声明由 `^0.12.0` 改为精确 `1.0.0-alpha.0`(alpha 阶段锁定)
|
|
12
|
+
|
|
13
|
+
### 📝 文档
|
|
14
|
+
|
|
15
|
+
- 中英 README 与 `docs/zh|en/{tools,mcp,skills}.md`:`Provider` / `getProvider()` 同步为 `Scope` / `getScope()`
|
|
16
|
+
- `docs/zh|en/getting-started.md`:运行时依赖版本同步为 `@ai-zen/agents-sdk` `1.0.0-alpha.0`
|
|
17
|
+
- `docs/manifest.json`:版本号同步为 `0.9.0`
|
|
18
|
+
|
|
19
|
+
### ✅ 测试
|
|
20
|
+
|
|
21
|
+
- `tsc --noEmit`(`tsconfig.test.json`)与 `npm run build` 零错误
|
|
22
|
+
- 全量单测 9 文件 / 74 用例通过
|
|
23
|
+
- e2e 6 用例通过(含真实 DeepSeek API 对话,验证 CLI → SDK `1.0.0-alpha.0` → API 全链路)
|
|
24
|
+
|
|
25
|
+
## [0.8.2] - 2026-09-29
|
|
26
|
+
|
|
27
|
+
### ⚠️ 依赖升级
|
|
28
|
+
|
|
29
|
+
- **`@ai-zen/agents-sdk` 升至 `^0.12.0`** — SDK 0.12.0 新增内置工具 `inspectFile`(内置工具类 19 → 20)、`readFile` 的 `range` 分批读取参数,新增配置项 `maxToolOutput`(缺省 32768 字符)与工具输出保护行为,并精简了 `batchEdit` 的输出。该版本**无破坏性变更**,CLI 源码无需适配:类型与默认配置全量委托 SDK,`src/version.ts` 由实际安装版本读取,工具清单由 SDK 静态注册表自动发现,故版本横幅随之显示 sdk `0.12.0`
|
|
30
|
+
|
|
31
|
+
### 📝 文档
|
|
32
|
+
|
|
33
|
+
- 同步内置工具计数 19 → 20:中英 README、`docs/zh|en/tools.md`、`docs/zh|en/index.md` 与 `docs/manifest.json`
|
|
34
|
+
- 工具表补充 `inspectFile`(勘察文件结构概况),并为 `readFile` 补注 `range` 参数
|
|
35
|
+
- `docs/zh|en/tools.md` 新增「输出保护」说明:超限时 `exec` / `findText` / `glob` / `ls` 落盘并返回警告,`readFile` / `inspectFile` 仅警告不落盘
|
|
36
|
+
- `docs/zh|en/getting-started.md` 的运行时依赖版本同步为 `@ai-zen/agents-sdk` `^0.12.0`
|
|
37
|
+
|
|
38
|
+
### ✅ 测试
|
|
39
|
+
|
|
40
|
+
- 沿用既有 9 文件 / 74 用例,全部通过;`tsc --noEmit` 与 `npm run build`(`0.8.2`)均通过
|
|
41
|
+
|
|
3
42
|
## [0.8.1] - 2026-09-28
|
|
4
43
|
|
|
5
44
|
### 🚀 新功能
|
package/README.md
CHANGED
|
@@ -204,12 +204,13 @@ Same-named servers in higher priority override lower ones.
|
|
|
204
204
|
|
|
205
205
|
## Built-in Tools
|
|
206
206
|
|
|
207
|
-
The CLI provides
|
|
207
|
+
The CLI provides 20 built-in tools, implemented by `@ai-zen/agents-sdk`. Tool availability is self-declared by each tool via `isAvailable(config, definition)` at build time (when the model is already known):
|
|
208
208
|
|
|
209
209
|
| Tool | Description |
|
|
210
210
|
|------|-------------|
|
|
211
211
|
| `cwd` | Get current working directory |
|
|
212
|
-
| `readFile` | Read file contents |
|
|
212
|
+
| `readFile` | Read file contents (supports `range` for partial reads) |
|
|
213
|
+
| `inspectFile` | Inspect file structure (lines, chars, column widths, line-ending style) without reading content |
|
|
213
214
|
| `writeFile` | Write content to file |
|
|
214
215
|
| `edit` | Replace text in files (single replacement) |
|
|
215
216
|
| `batchEdit` | Batch replace text in files |
|
|
@@ -242,9 +243,9 @@ In addition to built-in tools, the SDK provides 5 dynamic loading tools that are
|
|
|
242
243
|
|
|
243
244
|
## Tool Assembly Pipeline
|
|
244
245
|
|
|
245
|
-
Tools are assembled in three phases by the SDK's `
|
|
246
|
+
Tools are assembled in three phases by the SDK's `Scope` capability pipeline:
|
|
246
247
|
|
|
247
|
-
1. **Discovery** — Scan filesystem for built-in tools, user tools, SubAgents, Skills, and MCP servers. All
|
|
248
|
+
1. **Discovery** — Scan filesystem for built-in tools, user tools, SubAgents, Skills, and MCP servers. All 20 built-in tools are discovered unconditionally (no filtering at this stage)
|
|
248
249
|
2. **Filtering** — Apply permissions (`allow`/`deny`), security exclusions (recursion protection), and each tool's self-declared `isAvailable(config, definition)` (availability is decided at build time when the model is known; e.g. `viewImage` only for vision models, `generateImage` requires `defaultImageModel`)
|
|
249
250
|
3. **Instantiation** — Map filtered names to `Tool` instances and register dynamic loaders
|
|
250
251
|
|
package/README.zh.md
CHANGED
|
@@ -204,12 +204,13 @@ MCP 服务器配置从多个来源合并(优先级从高到低):
|
|
|
204
204
|
|
|
205
205
|
## 内置工具
|
|
206
206
|
|
|
207
|
-
CLI 提供
|
|
207
|
+
CLI 提供 20 个内置工具,由 `@ai-zen/agents-sdk` 实现。工具可用性由各工具在构建阶段(模型已知时)通过 `isAvailable(config, definition)` 自声明:
|
|
208
208
|
|
|
209
209
|
| 工具 | 说明 |
|
|
210
210
|
|------|------|
|
|
211
211
|
| `cwd` | 获取当前工作目录 |
|
|
212
|
-
| `readFile` |
|
|
212
|
+
| `readFile` | 读取文件内容(支持 `range` 分批读取) |
|
|
213
|
+
| `inspectFile` | 勘察文件结构概况(行数、字符数、列宽分布、行尾风格),不读取内容 |
|
|
213
214
|
| `writeFile` | 写入文件 |
|
|
214
215
|
| `edit` | 替换文件中的文本(单次替换) |
|
|
215
216
|
| `batchEdit` | 批量编辑文本 |
|
|
@@ -242,9 +243,9 @@ CLI 提供 19 个内置工具,由 `@ai-zen/agents-sdk` 实现。工具可用
|
|
|
242
243
|
|
|
243
244
|
## 工具装配流程
|
|
244
245
|
|
|
245
|
-
工具装配由 SDK 的 `
|
|
246
|
+
工具装配由 SDK 的 `Scope` 能力管线管理,分为三个阶段:
|
|
246
247
|
|
|
247
|
-
1. **发现** — 扫描文件系统获取内置工具、用户工具、SubAgent、Skill 和 MCP 服务器。
|
|
248
|
+
1. **发现** — 扫描文件系统获取内置工具、用户工具、SubAgent、Skill 和 MCP 服务器。20 个内置工具全部无条件发现(此阶段不做过滤)
|
|
248
249
|
2. **过滤** — 应用权限(`allow`/`deny`)、安全排除(递归保护),以及各工具自声明的 `isAvailable(config, definition)`(在模型已知的构建阶段判断可用性;如 `viewImage` 仅视觉模型、`generateImage` 需配置 `defaultImageModel`)
|
|
249
250
|
3. **实例化** — 将过滤后的名称映射为 `Tool` 实例,注册动态加载器
|
|
250
251
|
|
package/dist/agent-creator.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent 创建 — CLI 层
|
|
3
3
|
*
|
|
4
|
-
* 委托给 @ai-zen/agents-sdk 的
|
|
5
|
-
* CLI 层负责:组装路径、构建
|
|
4
|
+
* 委托给 @ai-zen/agents-sdk 的 Scope。
|
|
5
|
+
* CLI 层负责:组装路径、构建 Scope 单例、装配能力插件。
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { Scope, SdkAgent } from "@ai-zen/agents-sdk";
|
|
8
8
|
import type { AgentNS } from "@ai-zen/agents-core";
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
9
|
+
export declare function getScope(): Promise<Scope>;
|
|
10
|
+
export declare function resetScope(): void;
|
|
11
11
|
export interface CreateAgentOptions {
|
|
12
12
|
messages?: AgentNS.Message[];
|
|
13
13
|
agentId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-creator.d.ts","sourceRoot":"","sources":["../src/agent-creator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"agent-creator.d.ts","sourceRoot":"","sources":["../src/agent-creator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,KAAK,EAGL,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAiBnD,wBAAsB,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,CA8C/C;AAED,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAchF"}
|
package/dist/agent-creator.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent 创建 — CLI 层
|
|
3
3
|
*
|
|
4
|
-
* 委托给 @ai-zen/agents-sdk 的
|
|
5
|
-
* CLI 层负责:组装路径、构建
|
|
4
|
+
* 委托给 @ai-zen/agents-sdk 的 Scope。
|
|
5
|
+
* CLI 层负责:组装路径、构建 Scope 单例、装配能力插件。
|
|
6
6
|
*/
|
|
7
7
|
import { existsSync } from "fs";
|
|
8
8
|
import { join } from "path";
|
|
9
|
-
import {
|
|
9
|
+
import { Scope, allInOne, createAgent as sdkCreateAgent, } from "@ai-zen/agents-sdk";
|
|
10
10
|
import { AGENTS_DIR, SUB_AGENTS_DIR, SKILLS_DIR, TOOLS_DIR, AI_ZEN_DIR, PROJECT_SUB_AGENTS_DIR, PROJECT_SKILLS_DIR, PROJECT_TOOLS_DIR, USER_AGENTS_SKILLS_DIR, USER_AGENTS_MCP_CONFIG_FILE, PROJECT_AGENTS_SKILLS_DIR, PROJECT_AGENTS_MCP_CONFIG_FILE, } from "./config.js";
|
|
11
11
|
import { readConfig } from "./config.js";
|
|
12
|
-
// ====================
|
|
13
|
-
let
|
|
12
|
+
// ==================== Scope 创建(单例)====================
|
|
13
|
+
let _scope = null;
|
|
14
14
|
/** existsSync 的别名,用于数组 .filter() 场景 */
|
|
15
15
|
const exists = existsSync;
|
|
16
|
-
export async function
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
16
|
+
export async function getScope() {
|
|
17
|
+
if (_scope)
|
|
18
|
+
return _scope;
|
|
19
19
|
const config = await readConfig();
|
|
20
20
|
// MCP 配置合并优先级(从高到低):
|
|
21
21
|
// 1. 项目/.mcp.json
|
|
@@ -41,24 +41,26 @@ export async function getProvider() {
|
|
|
41
41
|
SKILLS_DIR,
|
|
42
42
|
USER_AGENTS_SKILLS_DIR,
|
|
43
43
|
].filter(exists);
|
|
44
|
-
|
|
44
|
+
_scope = new Scope({
|
|
45
45
|
config,
|
|
46
46
|
agentsDir: AGENTS_DIR,
|
|
47
|
+
}).use(...allInOne({
|
|
47
48
|
subAgentsPaths: [PROJECT_SUB_AGENTS_DIR, SUB_AGENTS_DIR].filter(exists),
|
|
48
49
|
skillsPaths,
|
|
49
50
|
toolsPaths: [PROJECT_TOOLS_DIR, TOOLS_DIR].filter(exists),
|
|
50
51
|
mcpPaths,
|
|
51
|
-
});
|
|
52
|
-
|
|
52
|
+
}));
|
|
53
|
+
await _scope.init();
|
|
54
|
+
return _scope;
|
|
53
55
|
}
|
|
54
|
-
export function
|
|
55
|
-
|
|
56
|
+
export function resetScope() {
|
|
57
|
+
_scope = null;
|
|
56
58
|
}
|
|
57
59
|
export async function createAgent(options) {
|
|
58
60
|
const { messages, agentId } = options;
|
|
59
|
-
const
|
|
61
|
+
const scope = await getScope();
|
|
60
62
|
// 始终从磁盘读取 Agent 定义(含 permissions、工具配置等)
|
|
61
|
-
const agent = await sdkCreateAgent(
|
|
63
|
+
const agent = await sdkCreateAgent(scope, agentId || "default");
|
|
62
64
|
// 有历史消息时替换(恢复草稿/已保存对话)。
|
|
63
65
|
// 拷贝而非直接引用:恢复的数组来自草稿/对话存档,直接引用会让后续 append 改写传入数组。
|
|
64
66
|
if (messages && messages.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-creator.js","sourceRoot":"","sources":["../src/agent-creator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,QAAQ,EACR,WAAW,IAAI,cAAc,GAE9B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EACjD,UAAU,EACV,sBAAsB,EAAE,kBAAkB,EAAE,iBAAiB,EAC7D,sBAAsB,EAAE,2BAA2B,EACnD,yBAAyB,EAAE,8BAA8B,GAC1D,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,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,MAAM,WAAW,GAAG;QAClB,kBAAkB;QAClB,yBAAyB;QACzB,UAAU;QACV,sBAAsB;KACvB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjB,MAAM,GAAG,IAAI,KAAK,CAAC;QACjB,MAAM;QACN,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC,GAAG,CACJ,GAAG,QAAQ,CAAC;QACV,cAAc,EAAE,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;QACvE,WAAW;QACX,UAAU,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;QACzD,QAAQ;KACT,CAAC,CACH,CAAC;IAEF,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAEpB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC;AASD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B;IAC3D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,KAAK,GAAG,MAAM,QAAQ,EAAE,CAAC;IAE/B,wCAAwC;IACxC,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,OAAO,IAAI,SAAS,CAAC,CAAC;IAEhE,wBAAwB;IACxB,kDAAkD;IAClD,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-zen/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "AI-ZEN CLI - interactive conversation terminal with file tools and draft recovery",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@ai-zen/agents-core": "^4.3.0",
|
|
24
|
-
"@ai-zen/agents-sdk": "
|
|
24
|
+
"@ai-zen/agents-sdk": "1.0.0-alpha.0",
|
|
25
25
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
26
26
|
"chalk": "^5.3.0",
|
|
27
27
|
"dayjs": "^1.11.21",
|