@actiondock/cli 2.0.2 → 2.0.4
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 +67 -41
- package/bin/ad.js +27 -2
- package/package.json +5 -2
- package/src/commands/action.ts +32 -1
- package/src/commands/index.ts +1 -1
- package/src/commands/playbook.ts +21 -3
- package/src/commands/profile.ts +1 -1
- package/src/commands/test.ts +29 -7
- package/src/index.ts +5 -3
package/README.md
CHANGED
|
@@ -1,84 +1,110 @@
|
|
|
1
1
|
# @actiondock/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ActionDock 2.0 官方命令行门面工具链。
|
|
4
4
|
|
|
5
|
-
[](https://nodejs.org/)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
7
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`@actiondock/cli` 提供 `ad` 命令行接口,用于开发、测试、构建、分发和运行 AI 智能体工具与技能。
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 运行环境
|
|
14
|
+
|
|
15
|
+
- 原生基于 Node.js 22.12.0 或更高版本运行。
|
|
16
|
+
- 支持 npm、pnpm 与 yarn 进行全局安装或项目级管理。
|
|
17
|
+
- 日常开发、调试、测试、MCP 服务启动与 HTTP 部署完全基于 Node.js,无需安装 Bun。
|
|
18
|
+
- 仅在使用 `ad build` 编译单文件独立二进制产物时,需要系统安装外部 Bun 编译器。
|
|
12
19
|
|
|
13
20
|
---
|
|
14
21
|
|
|
15
|
-
##
|
|
22
|
+
## 安装方式
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
# 1. Install Bun runtime (if not already installed)
|
|
19
|
-
npm install -g bun
|
|
24
|
+
使用标准包管理器全局安装:
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
```bash
|
|
22
27
|
npm install -g @actiondock/cli
|
|
23
28
|
```
|
|
24
29
|
|
|
30
|
+
也可以在项目中通过 npx 临时调用:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx ad --help
|
|
34
|
+
```
|
|
35
|
+
|
|
25
36
|
---
|
|
26
37
|
|
|
27
|
-
##
|
|
38
|
+
## 快速上手流程
|
|
28
39
|
|
|
40
|
+
- 初始化项目脚手架:
|
|
29
41
|
```bash
|
|
30
|
-
# 1. Initialize a new Action package scaffold
|
|
31
42
|
ad init my-tools
|
|
32
43
|
cd my-tools
|
|
44
|
+
npm install
|
|
45
|
+
```
|
|
33
46
|
|
|
34
|
-
|
|
47
|
+
- 本地执行 Action:
|
|
48
|
+
```bash
|
|
35
49
|
ad run sample.greet --input '{"name": "Alice"}'
|
|
50
|
+
```
|
|
36
51
|
|
|
37
|
-
|
|
52
|
+
- 运行单元测试:
|
|
53
|
+
```bash
|
|
38
54
|
ad test
|
|
55
|
+
```
|
|
39
56
|
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
- 启动为 MCP 协议服务:
|
|
58
|
+
```bash
|
|
59
|
+
ad mcp
|
|
60
|
+
```
|
|
42
61
|
|
|
43
|
-
|
|
62
|
+
- 导出为便携式 Agent Skill 技能包:
|
|
63
|
+
```bash
|
|
44
64
|
ad export skill
|
|
45
65
|
```
|
|
46
66
|
|
|
67
|
+
- 编译为零依赖单文件独立二进制产物(需外部安装 Bun):
|
|
68
|
+
```bash
|
|
69
|
+
ad build
|
|
70
|
+
```
|
|
71
|
+
|
|
47
72
|
---
|
|
48
73
|
|
|
49
|
-
##
|
|
74
|
+
## 常用命令速查
|
|
50
75
|
|
|
51
|
-
|
|
|
76
|
+
| 命令 | 说明 |
|
|
52
77
|
|---|---|
|
|
53
|
-
| `ad init [dir]` |
|
|
54
|
-
| `ad info [patterns...]` |
|
|
55
|
-
| `ad doctor` |
|
|
56
|
-
| `ad
|
|
57
|
-
| `ad
|
|
58
|
-
| `ad
|
|
59
|
-
| `ad
|
|
60
|
-
| `ad
|
|
61
|
-
| `ad
|
|
62
|
-
| `ad
|
|
63
|
-
| `ad
|
|
64
|
-
| `ad
|
|
65
|
-
| `ad
|
|
66
|
-
| `ad
|
|
78
|
+
| `ad init [dir]` | 初始化 Action Package 项目脚手架 |
|
|
79
|
+
| `ad info [patterns...]` | 检索包元数据与能力清单,支持模式匹配与树形展示 |
|
|
80
|
+
| `ad doctor` | 执行运行环境与项目结构健康诊断 |
|
|
81
|
+
| `ad run <id>` | 本地执行指定 Action 并输出标准信封结果 |
|
|
82
|
+
| `ad action list` | 列出包内所有已注册的 Action |
|
|
83
|
+
| `ad playbook list` / `show` | 查看智能体操作规程 Playbook |
|
|
84
|
+
| `ad config list` / `get` / `set` | 管理包运行时配置与环境变量绑定 |
|
|
85
|
+
| `ad state list` / `get` / `set` / `delete` / `clear` | 查看与维护 SQLite 持久化状态 |
|
|
86
|
+
| `ad runs list` / `show` | 查询任务执行历史与追踪记录 |
|
|
87
|
+
| `ad test` | 执行快速单元测试 |
|
|
88
|
+
| `ad build` | 调度外部 Bun 编译器打包单文件独立二进制产物 |
|
|
89
|
+
| `ad export skill` | 导出包含操作规程的 Agent Skill 技能包 |
|
|
90
|
+
| `ad link` / `unlink` | 注册或注销工作区全局路由与符号链接 |
|
|
91
|
+
| `ad profile` | 管理远程执行节点凭证与环境配置 |
|
|
92
|
+
| `ad serve` | 启动远程 HTTP 执行调度微服务 |
|
|
93
|
+
| `ad mcp` | 以 STDIO 或 HTTP 协议启动 MCP 服务 |
|
|
67
94
|
|
|
68
95
|
---
|
|
69
96
|
|
|
70
|
-
##
|
|
97
|
+
## 架构集成
|
|
71
98
|
|
|
72
|
-
|
|
99
|
+
作为顶层门面,`@actiondock/cli` 串联以下子包:
|
|
73
100
|
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
- [Agent Skill Usage Guide](../../docs/consumer/use-as-skill.md)
|
|
101
|
+
- 运行时适配:依赖 `@actiondock/runtime-node`,在启动时自动注入基于 Node.js 原生能力的驱动实现。
|
|
102
|
+
- 共享命令集:复用 `@actiondock/runtime-cli` 的命令处理器与标准信封输出渲染器。
|
|
103
|
+
- 构建与打包:调用 `@actiondock/builder` 完成依赖闭包分析与产物装配。
|
|
104
|
+
- 协议服务:通过 `@actiondock/mcp` 与 `@actiondock/core` 启动协议监听。
|
|
79
105
|
|
|
80
106
|
---
|
|
81
107
|
|
|
82
|
-
##
|
|
108
|
+
## 开源协议
|
|
83
109
|
|
|
84
|
-
|
|
110
|
+
本项目采用 Apache-2.0 开源协议。
|
package/bin/ad.js
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
import {
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
|
|
5
|
+
const isBun = typeof process.versions.bun !== "undefined";
|
|
6
|
+
|
|
7
|
+
if (!isBun && !process.env.ACTIONDOCK_TSX_BOOTSTRAPPED) {
|
|
8
|
+
const hasTsx =
|
|
9
|
+
process.execArgv.some((arg, i) => arg === "--import" && process.execArgv[i + 1] === "tsx") ||
|
|
10
|
+
process.execArgv.some((arg) => arg.includes("tsx"));
|
|
11
|
+
if (!hasTsx) {
|
|
12
|
+
const res = spawnSync(
|
|
13
|
+
process.execPath,
|
|
14
|
+
["--import", "tsx", fileURLToPath(import.meta.url), ...process.argv.slice(2)],
|
|
15
|
+
{
|
|
16
|
+
stdio: "inherit",
|
|
17
|
+
env: {
|
|
18
|
+
...process.env,
|
|
19
|
+
ACTIONDOCK_TSX_BOOTSTRAPPED: "1",
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
process.exit(res.status ?? (res.signal ? 1 : 0));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { main } = await import("../src/index.ts");
|
|
4
28
|
await main(process.argv);
|
|
29
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actiondock/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "ActionDock CLI facade for developing, testing, building, and exporting standalone Agent Actions and Skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
19
|
"engines": {
|
|
20
|
-
"
|
|
20
|
+
"node": ">=22.12.0"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public",
|
|
@@ -28,8 +28,11 @@
|
|
|
28
28
|
"build": "bun build ./src/index.ts --outdir ./dist --target bun"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@actiondock/builder": "^2.0.0",
|
|
31
32
|
"@actiondock/core": "^2.0.0",
|
|
32
33
|
"@actiondock/mcp": "^2.0.0",
|
|
34
|
+
"@actiondock/runtime-cli": "^2.0.0",
|
|
35
|
+
"@actiondock/runtime-node": "^2.0.0",
|
|
33
36
|
"@actiondock/sdk": "^2.0.0",
|
|
34
37
|
"commander": "^13.1.0"
|
|
35
38
|
},
|
package/src/commands/action.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
3
|
import {
|
|
4
4
|
ActionRunner,
|
|
5
5
|
createStorage,
|
|
@@ -11,9 +11,11 @@ import {
|
|
|
11
11
|
getPackageSlug,
|
|
12
12
|
listLinkedPackages,
|
|
13
13
|
loadActions,
|
|
14
|
+
loadManifest,
|
|
14
15
|
loadProjectConfig,
|
|
15
16
|
resolveActionProject,
|
|
16
17
|
resolveTarget,
|
|
18
|
+
saveManifest,
|
|
17
19
|
validateSchema,
|
|
18
20
|
} from "@actiondock/core";
|
|
19
21
|
import { Command } from "commander";
|
|
@@ -281,6 +283,35 @@ export default defineAction<Input, Output>({
|
|
|
281
283
|
`;
|
|
282
284
|
|
|
283
285
|
writeFileSync(targetFullFile, template, "utf-8");
|
|
286
|
+
|
|
287
|
+
const manifest = loadManifest(root) || { schemaVersion: 1, actions: {}, assets: [] };
|
|
288
|
+
manifest.actions = manifest.actions || {};
|
|
289
|
+
manifest.actions[id] = {
|
|
290
|
+
entry: join(config.actionsDir || "actions", targetRelFile),
|
|
291
|
+
description: desc,
|
|
292
|
+
inputSchema: {
|
|
293
|
+
type: "object",
|
|
294
|
+
properties: {
|
|
295
|
+
exampleParam: {
|
|
296
|
+
type: "string",
|
|
297
|
+
description: "Example parameter description",
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
required: [],
|
|
301
|
+
},
|
|
302
|
+
outputSchema: {
|
|
303
|
+
type: "object",
|
|
304
|
+
properties: {
|
|
305
|
+
success: { type: "boolean" },
|
|
306
|
+
result: {},
|
|
307
|
+
},
|
|
308
|
+
required: ["success"],
|
|
309
|
+
},
|
|
310
|
+
uses: [],
|
|
311
|
+
tags: [],
|
|
312
|
+
};
|
|
313
|
+
saveManifest(root, manifest);
|
|
314
|
+
|
|
284
315
|
console.log(`[OK] Created Action '${id}' at ${targetFullFile}`);
|
|
285
316
|
console.log(`\nTo run this action:`);
|
|
286
317
|
console.log(` ad action run ${id} --input '{"exampleParam": "hello"}'`);
|
package/src/commands/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ export function createCliProgram(): Command {
|
|
|
21
21
|
program
|
|
22
22
|
.name("ad")
|
|
23
23
|
.description("ActionDock (ad) 2.0 - Toolchain for building and shipping standalone AI Agent Actions & Skills")
|
|
24
|
-
.version("2.0.
|
|
24
|
+
.version("2.0.4");
|
|
25
25
|
|
|
26
26
|
registerInitCommand(program);
|
|
27
27
|
registerInfoCommand(program);
|
package/src/commands/playbook.ts
CHANGED
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
findProjectRoot,
|
|
8
8
|
listLinkedPackages,
|
|
9
9
|
loadActions,
|
|
10
|
+
loadManifest,
|
|
10
11
|
loadPlaybooks,
|
|
11
12
|
loadProjectConfig,
|
|
13
|
+
resolveActionProject,
|
|
12
14
|
resolvePlaybookProject,
|
|
13
15
|
resolveTarget,
|
|
14
16
|
} from "@actiondock/core";
|
|
@@ -368,7 +370,18 @@ This playbook provides task execution guidance for AI Agents.
|
|
|
368
370
|
|
|
369
371
|
for (const target of targets) {
|
|
370
372
|
const config = loadProjectConfig(target.root);
|
|
371
|
-
|
|
373
|
+
let actionIds = new Set<string>();
|
|
374
|
+
const manifest = loadManifest(target.root);
|
|
375
|
+
if (manifest?.actions) {
|
|
376
|
+
actionIds = new Set(Object.keys(manifest.actions));
|
|
377
|
+
} else {
|
|
378
|
+
try {
|
|
379
|
+
const actions = await loadActions(target.root, config.actionsDir, { autoInstall: false });
|
|
380
|
+
actionIds = new Set(actions.keys());
|
|
381
|
+
} catch {
|
|
382
|
+
// Ignore action loading failure during validation
|
|
383
|
+
}
|
|
384
|
+
}
|
|
372
385
|
|
|
373
386
|
for (const pb of target.playbooks) {
|
|
374
387
|
if (!pb) continue;
|
|
@@ -380,8 +393,13 @@ This playbook provides task execution guidance for AI Agents.
|
|
|
380
393
|
|
|
381
394
|
if (pb.actions) {
|
|
382
395
|
for (const actId of pb.actions) {
|
|
383
|
-
if (
|
|
384
|
-
|
|
396
|
+
if (actionIds.has(actId)) {
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
try {
|
|
400
|
+
await resolveActionProject(actId, target.root);
|
|
401
|
+
} catch (err: any) {
|
|
402
|
+
warnings.push(err.message);
|
|
385
403
|
}
|
|
386
404
|
}
|
|
387
405
|
}
|
package/src/commands/profile.ts
CHANGED
|
@@ -235,7 +235,7 @@ export function registerProfileCommands(program: Command): void {
|
|
|
235
235
|
if (options.json) {
|
|
236
236
|
console.log(JSON.stringify({ ok: true, type: "local", message: "Local execution" }, null, 2));
|
|
237
237
|
} else {
|
|
238
|
-
console.log(`Target profile '${target.profileName || "local"}' is local (runs in local
|
|
238
|
+
console.log(`Target profile '${target.profileName || "local"}' is local (runs in local runtime).`);
|
|
239
239
|
}
|
|
240
240
|
return;
|
|
241
241
|
}
|
package/src/commands/test.ts
CHANGED
|
@@ -1,26 +1,48 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
1
4
|
import { findProjectRoot } from "@actiondock/core";
|
|
2
5
|
import { Command } from "commander";
|
|
3
6
|
|
|
4
7
|
export function registerTestCommand(program: Command): void {
|
|
5
8
|
program
|
|
6
9
|
.command("test [pattern]")
|
|
7
|
-
.description("Run project tests using
|
|
10
|
+
.description("Run project tests using configured test runner (node:test or bun test)")
|
|
8
11
|
.action((pattern) => {
|
|
9
12
|
const root = findProjectRoot();
|
|
10
13
|
const cwd = root || process.cwd();
|
|
11
14
|
|
|
12
|
-
const
|
|
15
|
+
const pkgJsonPath = join(cwd, "package.json");
|
|
16
|
+
let testCmd = "npm";
|
|
17
|
+
let testArgs = ["test"];
|
|
18
|
+
|
|
19
|
+
if (existsSync(pkgJsonPath)) {
|
|
20
|
+
try {
|
|
21
|
+
const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
22
|
+
if (pkg.scripts?.test?.includes("bun test") && typeof (globalThis as any).Bun !== "undefined") {
|
|
23
|
+
testCmd = "bun";
|
|
24
|
+
testArgs = ["test"];
|
|
25
|
+
}
|
|
26
|
+
} catch {
|
|
27
|
+
// ignore
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
if (pattern) {
|
|
14
|
-
|
|
32
|
+
if (testCmd === "npm") {
|
|
33
|
+
testArgs.push("--", pattern);
|
|
34
|
+
} else {
|
|
35
|
+
testArgs.push(pattern);
|
|
36
|
+
}
|
|
15
37
|
}
|
|
16
38
|
|
|
17
|
-
const proc =
|
|
39
|
+
const proc = spawnSync(testCmd, testArgs, {
|
|
18
40
|
cwd,
|
|
19
|
-
stdio:
|
|
41
|
+
stdio: "inherit",
|
|
20
42
|
});
|
|
21
43
|
|
|
22
|
-
if (proc.
|
|
23
|
-
process.exit(proc.
|
|
44
|
+
if (proc.status !== 0) {
|
|
45
|
+
process.exit(proc.status ?? 1);
|
|
24
46
|
}
|
|
25
47
|
});
|
|
26
48
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { setupNodeRuntime } from "@actiondock/runtime-node";
|
|
3
2
|
import { createCliProgram } from "./commands";
|
|
4
3
|
|
|
4
|
+
export * from "./commands";
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* ActionDock CLI 主执行入口函数。
|
|
7
8
|
*
|
|
8
9
|
* @param argv 命令行参数数组(默认使用 process.argv)
|
|
9
10
|
*/
|
|
10
11
|
export async function main(argv: string[] = process.argv): Promise<void> {
|
|
12
|
+
setupNodeRuntime();
|
|
11
13
|
const program = createCliProgram();
|
|
12
14
|
await program.parseAsync(argv);
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
if (import.meta.main) {
|
|
17
|
+
if ((import.meta as any).main) {
|
|
16
18
|
main().catch((err) => {
|
|
17
19
|
console.error("Fatal error:", err);
|
|
18
20
|
process.exit(1);
|