@actiondock/cli 2.0.2 → 2.0.3

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 CHANGED
@@ -1,84 +1,110 @@
1
1
  # @actiondock/cli
2
2
 
3
- The official Command Line Interface (CLI) toolchain for ActionDock 2.0.
3
+ ActionDock 2.0 官方命令行门面工具链。
4
4
 
5
- [![Bun](https://img.shields.io/badge/Bun-%3E%3D1.2-black?logo=bun)](https://bun.sh/)
5
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22.12.0-green?logo=node.js)](https://nodejs.org/)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?logo=typescript)](https://www.typescriptlang.org/)
7
7
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8
8
 
9
- > **Runtime requirement**: [Bun](https://bun.sh/) >= 1.2.0.
9
+ `@actiondock/cli` 提供 `ad` 命令行接口,用于开发、测试、构建、分发和运行 AI 智能体工具与技能。
10
10
 
11
- `@actiondock/cli` provides the `ad` command to develop, test, build, deploy, and export AI Agent Actions and Skills across MCP, HTTP, CLI, and standalone executables.
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
- ## Installation
22
+ ## 安装方式
16
23
 
17
- ```bash
18
- # 1. Install Bun runtime (if not already installed)
19
- npm install -g bun
24
+ 使用标准包管理器全局安装:
20
25
 
21
- # 2. Install ActionDock CLI
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
- ## Quick Start in 5 Steps
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
- # 2. Run an Action locally (outputs standard JSON envelope)
47
+ - 本地执行 Action:
48
+ ```bash
35
49
  ad run sample.greet --input '{"name": "Alice"}'
50
+ ```
36
51
 
37
- # 3. Run in-memory unit tests
52
+ - 运行单元测试:
53
+ ```bash
38
54
  ad test
55
+ ```
39
56
 
40
- # 4. Compile into a single standalone binary
41
- ad build
57
+ - 启动为 MCP 协议服务:
58
+ ```bash
59
+ ad mcp
60
+ ```
42
61
 
43
- # 5. Export as a portable Agent Skill (with SOPs)
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
- ## Command Cheat Sheet
74
+ ## 常用命令速查
50
75
 
51
- | Command | Purpose |
76
+ | 命令 | 说明 |
52
77
  |---|---|
53
- | `ad init [dir]` | Initialize an Action package scaffold |
54
- | `ad info [patterns...]` | Explore capabilities and display metadata (supports fuzzy matching and `--tree`) |
55
- | `ad doctor` | Run environment, global registry health, and project diagnostics |
56
- | `ad action list` / `ad run <id>` | List and execute Actions |
57
- | `ad playbook list` / `show` | Inspect agent task SOP Playbooks |
58
- | `ad config list` / `get` / `set` | Manage runtime configurations |
59
- | `ad state list` / `get` / `set` / `delete` / `clear` | Inspect and manage persistent state (with namespaces, TTL, and clear) |
60
- | `ad runs list` / `show` | Inspect execution history and traces |
61
- | `ad test` | Run fast unit tests |
62
- | `ad build` | Compile into a zero-dependency standalone binary |
63
- | `ad export skill` | Export Skill bundle for AI Agent platforms |
64
- | `ad link` / `unlink` | Manage global router (with live subproject auto-discovery and prune) |
65
- | `ad profile` / `ad serve` | Manage remote node profiles and start HTTP Runner |
66
- | `ad mcp` | Start ActionDock as STDIO or HTTP MCP server |
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
- ## 📖 Complete Documentation
97
+ ## 架构集成
71
98
 
72
- For the full list of flags, options, remote profiles, and advanced usage, refer to the [ActionDock Documentation Center](../../docs/README.md):
99
+ 作为顶层门面,`@actiondock/cli` 串联以下子包:
73
100
 
74
- - [CLI Reference Manual](../../docs/reference/cli.md)
75
- - [Quick Start Guide](../../docs/developer/quick-start.md)
76
- - [MCP Integration Guide](../../docs/consumer/use-as-mcp.md)
77
- - [Standalone Binary Build Guide](../../docs/developer/build-and-export.md)
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
- ## License
108
+ ## 开源协议
83
109
 
84
- [Apache-2.0](../../LICENSE) © team4u
110
+ 本项目采用 Apache-2.0 开源协议。
package/bin/ad.js CHANGED
@@ -1,4 +1,29 @@
1
- #!/usr/bin/env bun
2
- import { main } from "../src/index.js";
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.2",
3
+ "version": "2.0.3",
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
- "bun": ">=1.2.0"
20
+ "node": ">=22.12.0"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public",
@@ -28,9 +28,12 @@
28
28
  "build": "bun build ./src/index.ts --outdir ./dist --target bun"
29
29
  },
30
30
  "dependencies": {
31
- "@actiondock/core": "^2.0.0",
32
- "@actiondock/mcp": "^2.0.0",
33
- "@actiondock/sdk": "^2.0.0",
31
+ "@actiondock/builder": "workspace:*",
32
+ "@actiondock/core": "workspace:*",
33
+ "@actiondock/mcp": "workspace:*",
34
+ "@actiondock/runtime-cli": "workspace:*",
35
+ "@actiondock/runtime-node": "workspace:*",
36
+ "@actiondock/sdk": "workspace:*",
34
37
  "commander": "^13.1.0"
35
38
  },
36
39
  "devDependencies": {
@@ -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"}'`);
@@ -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.2");
24
+ .version("2.0.3");
25
25
 
26
26
  registerInitCommand(program);
27
27
  registerInfoCommand(program);
@@ -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
- const actions = await loadActions(target.root, config.actionsDir);
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 (!actions.has(actId)) {
384
- warnings.push(`Referenced action '${actId}' not found in package '${target.packageId}'`);
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
  }
@@ -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 Bun runtime).`);
238
+ console.log(`Target profile '${target.profileName || "local"}' is local (runs in local runtime).`);
239
239
  }
240
240
  return;
241
241
  }
@@ -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 Bun test runner")
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 args = ["bun", "test"];
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
- args.push(pattern);
32
+ if (testCmd === "npm") {
33
+ testArgs.push("--", pattern);
34
+ } else {
35
+ testArgs.push(pattern);
36
+ }
15
37
  }
16
38
 
17
- const proc = Bun.spawnSync(args, {
39
+ const proc = spawnSync(testCmd, testArgs, {
18
40
  cwd,
19
- stdio: ["inherit", "inherit", "inherit"],
41
+ stdio: "inherit",
20
42
  });
21
43
 
22
- if (proc.exitCode !== 0) {
23
- process.exit(proc.exitCode ?? 1);
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
- export * from "./commands";
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);