@actiondock/core 2.0.0 → 2.0.1

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
@@ -10,7 +10,7 @@ The core engine and domain kernel of ActionDock 2.0.
10
10
 
11
11
  > **Role & Usage Context**:
12
12
  > - **Authoring Actions**: Use [`@actiondock/sdk`](../sdk) for defining actions, testing with in-memory harness, and zero-dependency action packages.
13
- > - **CLI Toolchain**: Use [`@actiondock/cli`](../cli) (`ac`) for command-line workflows.
13
+ > - **CLI Toolchain**: Use [`@actiondock/cli`](../cli) (`ad`) for command-line workflows.
14
14
  > - **Engine & Embedding**: Use `@actiondock/core` when you need programmatic access to the ActionRunner engine, project loader, or custom server integrations.
15
15
  >
16
16
  > **Runtime requirement**: [Bun](https://bun.sh/) >= 1.2.0 is required (`@actiondock/core` leverages native `bun:sqlite` and Bun runtime APIs).
@@ -38,13 +38,13 @@ bun add @actiondock/core
38
38
 
39
39
  ## 📖 Documentation
40
40
 
41
- - [Runtime Architecture](https://github.com/team4u/actiondock/blob/main/docs/architecture/runtime.md)
42
- - [Storage & Persistence Guide](https://github.com/team4u/actiondock/blob/main/docs/guides/storage.md)
43
- - [Standalone Binary Build](https://github.com/team4u/actiondock/blob/main/docs/guides/standalone-build.md)
44
- - [HTTP Server & Remote Dispatch](https://github.com/team4u/actiondock/blob/main/docs/guides/http-server.md)
41
+ - [Runtime Architecture](../../docs/architecture/runtime.md)
42
+ - [Storage & Persistence Guide](../../docs/developer/storage.md)
43
+ - [Standalone Binary Build](../../docs/developer/build-and-export.md)
44
+ - [HTTP Server & Remote Dispatch](../../docs/consumer/http-service.md)
45
45
 
46
46
  ---
47
47
 
48
48
  ## License
49
49
 
50
- [Apache-2.0](LICENSE) © team4u
50
+ [Apache-2.0](../../LICENSE) © team4u
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actiondock/core",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "ActionDock Core Engine - Project loader, runtime execution, SQLite storage, standalone builder, and skill exporter",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -18,7 +18,7 @@ export interface BuildOptions {
18
18
  outfile?: string;
19
19
  /** 是否开启代码压缩混淆(默认 true) */
20
20
  minify?: boolean;
21
- /** 是否编译为 V8/JavaScriptCore 字节码(默认 false) */
21
+ /** 是否编译为 V8/JavaScriptCore 字节码(默认 true) */
22
22
  bytecode?: boolean;
23
23
  /** 显式挑选打包的 Action ID 清单(用于按需子集打包) */
24
24
  actions?: string[];
@@ -55,25 +55,25 @@ export async function runDoctorChecks(options?: {
55
55
  name: "Bun Runtime",
56
56
  status: "error",
57
57
  message: "Bun runtime not detected",
58
- fix: "Install Bun via 'npm install bun -g'",
58
+ fix: "Install Bun via 'npm install -g bun'",
59
59
  });
60
60
  }
61
61
 
62
62
  // 2. Check CLI in PATH
63
- let acPath: string | null = null;
63
+ let adPath: string | null = null;
64
64
  try {
65
- acPath = typeof Bun !== "undefined" && Bun.which ? Bun.which("ac") : null;
65
+ adPath = typeof Bun !== "undefined" && Bun.which ? Bun.which("ad") : null;
66
66
  } catch {
67
67
  // ignore
68
68
  }
69
69
 
70
- if (acPath) {
70
+ if (adPath) {
71
71
  checks.push({
72
72
  id: "runtime.cli",
73
73
  category: "runtime",
74
74
  name: "CLI Executable",
75
75
  status: "ok",
76
- message: `Found 'ac' in PATH at ${acPath}`,
76
+ message: `Found 'ad' in PATH at ${adPath}`,
77
77
  });
78
78
  } else {
79
79
  checks.push({
@@ -81,8 +81,8 @@ export async function runDoctorChecks(options?: {
81
81
  category: "runtime",
82
82
  name: "CLI Executable",
83
83
  status: "warn",
84
- message: "'ac' command not found in PATH",
85
- fix: "Run 'bun add -g @actiondock/cli' or in SDK workspace run 'cd packages/cli && bun link'",
84
+ message: "'ad' command not found in PATH",
85
+ fix: "Run 'npm install -g @actiondock/cli' or in SDK workspace run 'cd packages/cli && bun link'",
86
86
  });
87
87
  }
88
88
 
@@ -99,7 +99,7 @@ export async function runDoctorChecks(options?: {
99
99
  category: "storage",
100
100
  name: "Global Storage",
101
101
  status: "ok",
102
- message: `Database writable at ${join(globalHome, ".actiondock", "global.db")}`,
102
+ message: `Global SQLite database verified at ${globalHome}`,
103
103
  });
104
104
  } catch (err: any) {
105
105
  checks.push({
@@ -107,8 +107,8 @@ export async function runDoctorChecks(options?: {
107
107
  category: "storage",
108
108
  name: "Global Storage",
109
109
  status: "error",
110
- message: `Failed to write global database: ${err.message}`,
111
- fix: `Check write permissions for directory '${join(globalHome, ".actiondock")}'`,
110
+ message: `Failed to access global storage: ${err.message}`,
111
+ fix: `Ensure directory '${globalHome}' is writable`,
112
112
  });
113
113
  }
114
114
 
@@ -122,7 +122,7 @@ export async function runDoctorChecks(options?: {
122
122
  name: "Global Registry",
123
123
  status: "warn",
124
124
  message: `${regStatus.totalPackagesCount} package(s), ${regStatus.workspaces.length} workspace(s), but ${regStatus.staleCount} stale path(s) detected`,
125
- fix: "Run 'ac unlink --prune' to clean up stale entries from registry",
125
+ fix: "Run 'ad unlink --prune' to clean up stale entries from registry",
126
126
  });
127
127
  } else {
128
128
  checks.push({
@@ -226,7 +226,7 @@ export async function runDoctorChecks(options?: {
226
226
  name: "Actions",
227
227
  status: "warn",
228
228
  message: `No actions found in '${config.actionsDir || "actions"}'`,
229
- fix: "Run 'ac action create <id>' to create your first action",
229
+ fix: "Run 'ad action create <id>' to create your first action",
230
230
  });
231
231
  } else {
232
232
  checks.push({
@@ -289,7 +289,7 @@ export async function runDoctorChecks(options?: {
289
289
  name: "Config Readiness",
290
290
  status: "warn",
291
291
  message: `Required config item(s) missing: ${missingKeys.join(", ")}`,
292
- fix: `Run 'ac config set <KEY> <VALUE>' to configure missing keys`,
292
+ fix: `Run 'ad config set <KEY> <VALUE>' to configure missing keys`,
293
293
  });
294
294
  } else {
295
295
  checks.push({
@@ -30,7 +30,7 @@ function renderActionListMarkdown(
30
30
  const idLabel = options.packageId
31
31
  ? `\`${options.packageId}/${a.id}\` (或 \`${a.id}\`)`
32
32
  : `\`${a.id}\``;
33
- return `* ${idLabel}${aDesc}${params}`;
33
+ return `- ${idLabel}${aDesc}${params}`;
34
34
  })
35
35
  .join("\n");
36
36
  }
@@ -40,7 +40,7 @@ function renderPlaybookSectionMarkdown(playbooks: PlaybookDefinition[]): string
40
40
  const list = playbooks
41
41
  .map((p) => {
42
42
  const rel = `./playbooks/${basename(p.filePath)}`;
43
- return `* **${p.id}** (\`${rel}\`): ${p.description || "任务指南"}`;
43
+ return `- **${p.id}** (\`${rel}\`): ${p.description || "任务指南"}`;
44
44
  })
45
45
  .join("\n");
46
46
  return `
@@ -73,34 +73,34 @@ description: ${desc}
73
73
 
74
74
  ${desc}
75
75
 
76
- ## ActionDock 运行时 (ActionDock Runtime)
76
+ ## ActionDock 运行时
77
77
 
78
- 本技能为 **ActionDock 源码型 Package (Source Skill)**。AI Agent 可直接通过已安装的 ActionDock 命令行工具 (\`ac\`) 执行其中的 Action。
78
+ 本技能为 **ActionDock 源码型技能包**。AI Agent 可直接通过已安装的 ActionDock 命令行工具 (\`ad\`) 执行其中的 Action。
79
79
 
80
- ### 注册与链接 (Idempotent Setup)
80
+ ### 注册与链接
81
81
 
82
82
  在初次调用或初始化时,将包含本 \`SKILL.md\` 的目录解析为 \`<skill_root>\` 并完成注册:
83
83
 
84
84
  \`\`\`bash
85
- ac link "<skill_root>"
85
+ ad link "<skill_root>"
86
86
  \`\`\`
87
87
 
88
- > \`ac link\` 天然具备幂等性,同一 Package 多次执行会直接更新路径,可安全重复调用。
88
+ > \`ad link\` 天然具备幂等性,同一 Package 多次执行会直接更新路径,可安全重复调用。
89
89
 
90
- ### 执行 Action (统一推荐 Package-Qualified ID)
90
+ ### 执行 Action
91
91
 
92
92
  为避免多技能之间的 Action ID 命名冲突,建议统一使用带有 Package 前缀的完全限定 ID:
93
93
 
94
94
  \`\`\`bash
95
- # 格式:ac run <package-id>/<action-id> --input '<json>'
96
- ac run ${pkgId}/${firstAction} --input '{"param": "value"}'
95
+ # 格式:ad run <package-id>/<action-id> --input '<json>'
96
+ ad run ${pkgId}/${firstAction} --input '{"param": "value"}'
97
97
  \`\`\`
98
98
 
99
- > **免注册本地执行 (Direct Execution Alternative)**:
99
+ > **免注册本地执行**:
100
100
  > 若 Agent 工作目录已位于本 Skill 根目录,亦可直接免 link 执行:
101
101
  > \`\`\`bash
102
102
  > cd <skill_root>
103
- > ac run <action-id> --input '<json>'
103
+ > ad run <action-id> --input '<json>'
104
104
  > \`\`\`
105
105
 
106
106
  所有 Action 执行结果均在 \`stdout\` 输出标准格式的 JSON Envelope:
@@ -127,13 +127,56 @@ ${playbookSection}
127
127
 
128
128
  \`\`\`bash
129
129
  # 查看与设置配置项
130
- ac config list --package ${pkgId}
131
- ac config set KEY VALUE --package ${pkgId}
130
+ ad config list --package ${pkgId}
131
+ ad config set KEY VALUE --package ${pkgId}
132
132
 
133
133
  # 查看与检索状态数据
134
- ac state list --package ${pkgId}
135
- ac state get KEY --package ${pkgId}
134
+ ad state list --package ${pkgId}
135
+ ad state get KEY --package ${pkgId}
136
136
  \`\`\`
137
+
138
+ ---
139
+
140
+ ## 故障排查与环境安装指引(按需查阅)
141
+
142
+ > [!NOTE]
143
+ > **按需排查原则**:默认宿主环境中已预置 \`ad\` 命令行工具。正常执行流程直接调用上述 Action 即可,**严禁在任务启动前盲目进行前置环境检查或体检**;仅在终端明确报错提示命令不存在(如 \`ad: command not found\`)时,方可按本节指引安装初始化。
144
+
145
+ ### 命令行工具未找到时的安装指引
146
+
147
+ 若宿主环境未安装 \`ad\` 命令行工具,请依次按如下步骤完成安装:
148
+
149
+ - **安装 Bun 运行时**(若系统未安装):
150
+ \`\`\`bash
151
+ npm install -g bun
152
+ \`\`\`
153
+
154
+ - **全局安装 ActionDock 命令行工具**:
155
+ \`\`\`bash
156
+ npm install -g @actiondock/cli
157
+ \`\`\`
158
+
159
+ - **验证工具就绪**:
160
+ \`\`\`bash
161
+ ad --version
162
+ \`\`\`
163
+
164
+ - **源码本地开发模式**(若在本地源码仓库中贡献或开发):
165
+ \`\`\`bash
166
+ cd packages/cli && bun link
167
+ cd ../sdk && bun link
168
+ \`\`\`
169
+
170
+ - **环境诊断与体检**:
171
+ 安装完成后若仍遇到异常,执行体检命令排查:
172
+ \`\`\`bash
173
+ ad doctor
174
+ \`\`\`
175
+
176
+ - **完成安装后重新链接本技能**:
177
+ \`\`\`bash
178
+ ad link "<skill_root>"
179
+ \`\`\`
137
180
  `;
138
181
  }
139
182
 
@@ -144,7 +144,7 @@ export function useProfile(name: string, customHome?: string): void {
144
144
 
145
145
  if (trimmedName !== "local" && !profilesConfig.profiles[trimmedName]) {
146
146
  throw new Error(
147
- `Profile '${trimmedName}' not found. Use 'ac profile list' to see available profiles or 'ac profile add' to register one.`
147
+ `Profile '${trimmedName}' not found. Use 'ad profile list' to see available profiles or 'ad profile add' to register one.`
148
148
  );
149
149
  }
150
150
 
@@ -274,7 +274,7 @@ export function resolveTarget(
274
274
  const found = profilesConfig.profiles[pName];
275
275
  if (!found) {
276
276
  throw new Error(
277
- `Profile '${pName}' not found. Configure it with 'ac profile add ${pName} --server <url>'`
277
+ `Profile '${pName}' not found. Configure it with 'ad profile add ${pName} --server <url>'`
278
278
  );
279
279
  }
280
280
  const resolvedToken = resolveProfileToken(pName, found, options.token);
@@ -307,7 +307,7 @@ export function resolveTarget(
307
307
  const found = profilesConfig.profiles[pName];
308
308
  if (!found) {
309
309
  throw new Error(
310
- `Profile '${pName}' (from ACTIONDOCK_PROFILE) not found. Configure it with 'ac profile add ${pName} --server <url>'`
310
+ `Profile '${pName}' (from ACTIONDOCK_PROFILE) not found. Configure it with 'ad profile add ${pName} --server <url>'`
311
311
  );
312
312
  }
313
313
  const resolvedToken = resolveProfileToken(pName, found, options?.token);
@@ -161,8 +161,8 @@ actions:
161
161
 
162
162
  # Greeting SOP
163
163
 
164
- 1. Call \`sample.greet\` with the user's name.
165
- 2. Confirm the returned greeting message.
164
+ - Call \`sample.greet\` with the user's name.
165
+ - Confirm the returned greeting message.
166
166
  `;
167
167
  writeFileSync(join(playbooksDir, "greet-user.md"), samplePlaybook);
168
168
 
@@ -376,7 +376,7 @@ export async function resolveActionProject(
376
376
 
377
377
  if (!pkg || !existsSync(pkg.path)) {
378
378
  throw new Error(
379
- `Linked package '${targetPackage}' not found or path no longer exists (${pkg?.path || "unregistered"}). Run 'ac link' in the package directory.`
379
+ `Linked package '${targetPackage}' not found or path no longer exists (${pkg?.path || "unregistered"}). Run 'ad link' in the package directory.`
380
380
  );
381
381
  }
382
382
 
@@ -428,7 +428,7 @@ export async function resolveActionProject(
428
428
  throw new Error(`Action '${actionIdentifier}' not found in current project or any linked packages`);
429
429
  } else {
430
430
  throw new Error(
431
- `Action '${actionIdentifier}' not found. You are not in an ActionDock project, and no linked package provides '${actionIdentifier}'. Use 'ac link' to register your package.`
431
+ `Action '${actionIdentifier}' not found. You are not in an ActionDock project, and no linked package provides '${actionIdentifier}'. Use 'ad link' to register your package.`
432
432
  );
433
433
  }
434
434
  }
@@ -505,7 +505,7 @@ export function resolvePlaybookProject(
505
505
 
506
506
  if (!pkg || !existsSync(pkg.path)) {
507
507
  throw new Error(
508
- `Linked package '${targetPackage}' not found or path no longer exists (${pkg?.path || "unregistered"}). Run 'ac link' in the package directory.`
508
+ `Linked package '${targetPackage}' not found or path no longer exists (${pkg?.path || "unregistered"}). Run 'ad link' in the package directory.`
509
509
  );
510
510
  }
511
511
 
@@ -564,7 +564,7 @@ export function resolvePlaybookProject(
564
564
  throw new Error(`Playbook '${playbookIdentifier}' not found in current project or any linked packages`);
565
565
  } else {
566
566
  throw new Error(
567
- `Playbook '${playbookIdentifier}' not found. You are not in an ActionDock project, and no linked package provides '${playbookIdentifier}'. Use 'ac link' to register your package.`
567
+ `Playbook '${playbookIdentifier}' not found. You are not in an ActionDock project, and no linked package provides '${playbookIdentifier}'. Use 'ad link' to register your package.`
568
568
  );
569
569
  }
570
570
  }
@@ -26,8 +26,8 @@ export interface StandaloneRuntimeOptions {
26
26
  * 独立二进制可执行文件运行时(Standalone Runtime)。
27
27
  *
28
28
  * 职责:
29
- * 1. 作为由 `ac build` 编译生成的单文件独立可执行文件(Standalone Binary)的运行时入口。
30
- * 2. 保证与开发态(`ac run` / `ac action`)在输出信封、配置优先级、状态存储等方面的 100% 行为一致性。
29
+ * 1. 作为由 `ad build` 编译生成的单文件独立可执行文件(Standalone Binary)的运行时入口。
30
+ * 2. 保证与开发态(`ad run` / `ad action`)在输出信封、配置优先级、状态存储等方面的 100% 行为一致性。
31
31
  * 3. 自带轻量 CLI 分发器,支持 `list`, `describe`, `run`, `config`, `state`, `version`, `help` 子命令。
32
32
  */
33
33
  export class StandaloneRuntime {
@@ -6,7 +6,7 @@ import type { RuntimeStorage } from "../storage/types";
6
6
  * 服务端运行时注册表(ServerRuntimeRegistry)。
7
7
  *
8
8
  * 职责:
9
- * 1. 在长期运行的 HTTP 服务端(`ac serve` / `ac mcp serve`)中,跨请求缓存并池化管理 SQLite 数据库存储连接。
9
+ * 1. 在长期运行的 HTTP 服务端(`ad serve` / `ad mcp serve`)中,跨请求缓存并池化管理 SQLite 数据库存储连接。
10
10
  * 2. 集中维护活跃的在途任务执行句柄(ExecutionManager)。
11
11
  * 3. 服务端停止或优雅关机(Graceful Shutdown)时,统一中断在途任务并安全关闭所有数据库连接。
12
12
  */