@actiondock/cli 2.0.11-beta.0 → 2.0.12

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.
Files changed (54) hide show
  1. package/README.md +15 -2
  2. package/bin/ad.js +13 -2
  3. package/dist/commands/action/create.d.ts +2 -0
  4. package/dist/commands/action/index.d.ts +16 -0
  5. package/dist/commands/action/list.d.ts +5 -0
  6. package/dist/commands/action/run.d.ts +4 -0
  7. package/dist/commands/action/show.d.ts +5 -0
  8. package/dist/commands/action/sync.d.ts +2 -0
  9. package/dist/commands/action/validate.d.ts +5 -0
  10. package/dist/commands/build.d.ts +2 -0
  11. package/dist/commands/config.d.ts +2 -0
  12. package/dist/commands/doctor.d.ts +2 -0
  13. package/dist/commands/export.d.ts +2 -0
  14. package/dist/commands/index.d.ts +2 -0
  15. package/dist/commands/info.d.ts +2 -0
  16. package/dist/commands/init.d.ts +2 -0
  17. package/dist/commands/link.d.ts +2 -0
  18. package/dist/commands/mcp.d.ts +2 -0
  19. package/dist/commands/playbook.d.ts +6 -0
  20. package/dist/commands/profile.d.ts +2 -0
  21. package/dist/commands/runs.d.ts +2 -0
  22. package/dist/commands/serve.d.ts +2 -0
  23. package/dist/commands/state.d.ts +2 -0
  24. package/dist/commands/test.d.ts +2 -0
  25. package/dist/index.d.ts +8 -0
  26. package/dist/index.js +745 -65708
  27. package/{src/utils/bytes.ts → dist/utils/bytes.d.ts} +0 -1
  28. package/{src/utils/filter.ts → dist/utils/filter.d.ts} +0 -1
  29. package/package.json +20 -15
  30. package/src/commands/action/create.ts +0 -129
  31. package/src/commands/action/index.ts +0 -27
  32. package/src/commands/action/list.ts +0 -247
  33. package/src/commands/action/run.ts +0 -197
  34. package/src/commands/action/show.ts +0 -128
  35. package/src/commands/action/sync.ts +0 -76
  36. package/src/commands/action/validate.ts +0 -102
  37. package/src/commands/build.ts +0 -56
  38. package/src/commands/config.ts +0 -583
  39. package/src/commands/doctor.ts +0 -84
  40. package/src/commands/export.ts +0 -196
  41. package/src/commands/index.ts +0 -75
  42. package/src/commands/info.ts +0 -537
  43. package/src/commands/init.ts +0 -24
  44. package/src/commands/link.ts +0 -73
  45. package/src/commands/mcp.ts +0 -195
  46. package/src/commands/playbook.ts +0 -566
  47. package/src/commands/profile.ts +0 -296
  48. package/src/commands/runs.ts +0 -452
  49. package/src/commands/serve.ts +0 -132
  50. package/src/commands/state.ts +0 -590
  51. package/src/commands/test.ts +0 -48
  52. package/src/index.ts +0 -58
  53. /package/{src/commands/action.ts → dist/commands/action.d.ts} +0 -0
  54. /package/{src/utils/duration.ts → dist/utils/duration.d.ts} +0 -0
@@ -1,196 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { basename } from "node:path";
3
- import { exportCompositeSkill, exportSkill, exportSkillBatch } from "@actiondock/builder";
4
- import { discoverProjects, findProjectRoot, listLinkedPackages, resolvePackageRoot } from "@actiondock/core";
5
- import { ExecutionError } from "@actiondock/runtime-cli";
6
- import { Command } from "commander";
7
-
8
- function parseListOption(val: string, prev: string[] = []): string[] {
9
- const parts = val.split(",").map((s) => s.trim()).filter(Boolean);
10
- return [...prev, ...parts];
11
- }
12
-
13
- export function registerExportCommand(program: Command): void {
14
- const exportCmd = program
15
- .command("export")
16
- .description("Export project artifacts");
17
-
18
- exportCmd
19
- .command("skill")
20
- .description("Export Skill directory for AI Agents (default: source skill; use -s/--standalone for pre-built standalone binary)")
21
- .option(
22
- "-P, --package <id...>",
23
- "Target package ID(s) or path(s) (can be specified multiple times or comma-separated)",
24
- parseListOption,
25
- []
26
- )
27
- .option("--workspace", "Export all packages discovered in current workspace")
28
- .option("--all", "Export all linked packages from global registry")
29
- .option(
30
- "--bundle [name]",
31
- "Export multiple packages as a unified composite Skill bundle (defaults to workspace directory name if omitted)"
32
- )
33
- .option("-s, --standalone", "Export pre-compiled standalone binary skill (for environments without ActionDock runtime)")
34
- .option("-t, --target <target>", "Target compilation platform for standalone mode (e.g. host, linux-x64, darwin-arm64, windows-x64)")
35
- .option("-o, --out <path>", "Output skill directory")
36
- .option("-p, --playbook <playbooks...>", "Only export specific playbook(s) and their dependent actions (Playbook-driven minimal export)")
37
- .option("-a, --actions <actions...>", "Only export specific action(s)")
38
- .option("-m, --minify", "Minify bundled JavaScript in standalone mode (default: true)", true)
39
- .option("--no-minify", "Disable JavaScript minification in standalone mode")
40
- .option("--bytecode", "Compile JavaScript to bytecode in standalone mode (default: true)", true)
41
- .option("--no-bytecode", "Disable bytecode compilation in standalone mode")
42
- .option("-z, --archive", "Create a .zip archive of the exported skill")
43
- .option("--skill-md <path>", "Use specified existing SKILL.md file instead of auto-generating")
44
- .action(async (options) => {
45
- const isStandalone = Boolean(options.standalone);
46
-
47
- if (options.bundle && isStandalone) {
48
- throw new ExecutionError(
49
- "Composite Skill export (--bundle) currently only supports source mode. Please remove --standalone to export as a composite workspace Skill."
50
- );
51
- }
52
-
53
- const sourceCount =
54
- (options.all ? 1 : 0) +
55
- (options.workspace ? 1 : 0) +
56
- (options.package && options.package.length > 0 ? 1 : 0);
57
- if (sourceCount > 1) {
58
- throw new ExecutionError(
59
- "Options -P/--package, --workspace, and --all are mutually exclusive. Please specify only one package selection mode."
60
- );
61
- }
62
-
63
- let roots: string[] = [];
64
-
65
- if (options.all) {
66
- const linked = listLinkedPackages();
67
- roots = linked.map((p) => p.path).filter((p) => existsSync(p));
68
- if (roots.length === 0) {
69
- throw new ExecutionError("No linked packages found in global registry.");
70
- }
71
- } else if (options.workspace) {
72
- const cwd = process.cwd();
73
- const discovered = discoverProjects(cwd);
74
- roots = discovered.length > 0 ? discovered : (findProjectRoot(cwd) ? [findProjectRoot(cwd)!] : []);
75
- if (roots.length === 0) {
76
- throw new ExecutionError(
77
- `No ActionDock packages found in workspace '${cwd}'.\nMake sure child directories contain actiondock.json.`
78
- );
79
- }
80
- } else if (options.package && options.package.length > 0) {
81
- for (const pkgIdOrPath of options.package) {
82
- const root = resolvePackageRoot(pkgIdOrPath);
83
- if (!root) {
84
- throw new ExecutionError(`Package '${pkgIdOrPath}' not found in linked packages or path`);
85
- }
86
- if (!roots.includes(root)) {
87
- roots.push(root);
88
- }
89
- }
90
- } else {
91
- const root = findProjectRoot();
92
- if (root) {
93
- roots.push(root);
94
- } else {
95
- throw new ExecutionError(
96
- "Not in an ActionDock project (actiondock.json not found).\nPlease specify -P, --package <id>, --workspace, --all, or cd into a project directory."
97
- );
98
- }
99
- }
100
-
101
- if (roots.length > 1 && (options.actions || options.playbook)) {
102
- throw new ExecutionError(
103
- "Filtering options (--actions, --playbook) can only be used when exporting a single package."
104
- );
105
- }
106
-
107
- try {
108
- if (options.bundle !== undefined) {
109
- const bundleName =
110
- typeof options.bundle === "string" && options.bundle.trim()
111
- ? options.bundle.trim()
112
- : basename(process.cwd());
113
- console.log(`Exporting composite Skill bundle '${bundleName}' (${roots.length} package${roots.length > 1 ? "s" : ""})...`);
114
- const result = await exportCompositeSkill({
115
- bundleName,
116
- projectRoots: roots,
117
- outDir: options.out,
118
- archive: options.archive,
119
- workspaceRoot: options.workspace ? process.cwd() : undefined,
120
- skillMdPath: options.skillMd,
121
- });
122
-
123
- console.log(`[OK] Successfully exported Composite Skill: ${result.bundleName}`);
124
- console.log(` Packages: ${result.packagesCount}`);
125
- console.log(` Actions: ${result.actionsCount}`);
126
- console.log(` Playbooks: ${result.playbooksCount}`);
127
- console.log(` Skill Dir: ${result.skillDir}`);
128
- if (result.usedExistingSkillMd) {
129
- console.log(` SKILL.md: Reused existing file from ${result.usedExistingSkillMd}`);
130
- }
131
- if (result.archivePath) {
132
- console.log(` Archive: ${result.archivePath}`);
133
- }
134
- return;
135
- }
136
-
137
- if (roots.length > 1) {
138
- console.log(`Batch exporting ${roots.length} Skill packages...`);
139
- const batchRes = await exportSkillBatch({
140
- projectRoots: roots,
141
- mode: isStandalone ? "standalone" : "source",
142
- standalone: isStandalone,
143
- target: options.target,
144
- outDir: options.out,
145
- archive: options.archive,
146
- playbooks: options.playbook,
147
- actions: options.actions,
148
- minify: options.minify,
149
- bytecode: options.bytecode,
150
- skillMdPath: options.skillMd,
151
- });
152
-
153
- console.log(`[OK] Successfully batch exported ${batchRes.results.length} Skill packages to: ${batchRes.outDir}`);
154
- for (const res of batchRes.results) {
155
- console.log(` - ${res.packageId} (v${res.version}): ${res.actionsCount} actions, ${res.playbooksCount} playbooks -> ${res.skillDir}`);
156
- }
157
- console.log(` Total Actions: ${batchRes.totalActions}`);
158
- console.log(` Total Playbooks: ${batchRes.totalPlaybooks}`);
159
- return;
160
- }
161
-
162
- const root = roots[0];
163
- console.log(`Exporting ${isStandalone ? "standalone binary" : "source"} Skill artifact...`);
164
- const result = await exportSkill({
165
- projectRoot: root,
166
- mode: isStandalone ? "standalone" : "source",
167
- standalone: isStandalone,
168
- target: options.target,
169
- outDir: options.out,
170
- archive: options.archive,
171
- playbooks: options.playbook,
172
- actions: options.actions,
173
- minify: options.minify,
174
- bytecode: options.bytecode,
175
- skillMdPath: options.skillMd,
176
- });
177
-
178
- console.log(`[OK] Successfully exported ${result.mode === "standalone" ? "Standalone" : "Source"} Skill: ${result.packageId} (v${result.version})`);
179
- console.log(` Mode: ${result.mode}${result.mode === "standalone" ? ` (target: ${result.target})` : ""}`);
180
- console.log(` Actions: ${result.actionsCount}`);
181
- console.log(` Playbooks: ${result.playbooksCount}`);
182
- console.log(` Skill Dir: ${result.skillDir}`);
183
- if (result.usedExistingSkillMd) {
184
- console.log(` SKILL.md: Reused existing file from ${result.usedExistingSkillMd}`);
185
- }
186
- if (result.archivePath) {
187
- console.log(` Archive: ${result.archivePath}`);
188
- }
189
- } catch (err: any) {
190
- throw new ExecutionError(`Export failed: ${err.message}`);
191
- }
192
- });
193
- }
194
-
195
-
196
-
@@ -1,75 +0,0 @@
1
- import { Command } from "commander";
2
- import { registerActionCommands } from "./action";
3
- import { registerBuildCommand } from "./build";
4
- import { registerConfigCommands } from "./config";
5
- import { registerDoctorCommand } from "./doctor";
6
- import { registerExportCommand } from "./export";
7
- import { registerInfoCommand } from "./info";
8
- import { registerInitCommand } from "./init";
9
- import { registerLinkCommands } from "./link";
10
- import { registerMcpCommands } from "./mcp";
11
- import { registerPlaybookCommands } from "./playbook";
12
- import { registerProfileCommands } from "./profile";
13
- import { registerRunsCommands } from "./runs";
14
- import { registerServeCommand } from "./serve";
15
- import { registerStateCommands } from "./state";
16
- import { registerTestCommand } from "./test";
17
-
18
- function applyCommonOptions(cmd: Command): void {
19
- const hasOpt = (flagName: string) =>
20
- cmd.options.some((o) => o.name() === flagName || o.long === `--${flagName}`);
21
-
22
- if (!hasOpt("json")) {
23
- cmd.option("--json", "Output as JSON");
24
- }
25
- if (!hasOpt("envelope")) {
26
- cmd.option("--envelope", "Wrap JSON output in standard envelope");
27
- }
28
- if (!hasOpt("dataDir") && !hasOpt("data-dir")) {
29
- cmd.option("--data-dir <path>", "Custom database storage directory");
30
- }
31
-
32
- for (const sub of cmd.commands) {
33
- applyCommonOptions(sub);
34
- }
35
- }
36
-
37
- export function createCliProgram(): Command {
38
- const program = new Command();
39
-
40
- program
41
- .name("ad")
42
- .description("ActionDock (ad) 2.0 - Toolchain for building and shipping standalone AI Agent Actions & Skills")
43
- .version("2.0.11-beta.0", "-v, --version");
44
-
45
- program.option("-V", "output the version number");
46
- program.on("option:V", () => {
47
- (program as any)._outputConfiguration.writeOut(`${program.version()}\n`);
48
- (program as any)._exit(0, "commander.version", program.version()!);
49
- });
50
-
51
- // 禁用 Commander 内部直接 process.exit,统一由顶层调度器管控退出码
52
- program.exitOverride((err) => {
53
- throw err;
54
- });
55
-
56
- registerInitCommand(program);
57
- registerInfoCommand(program);
58
- registerDoctorCommand(program);
59
- registerActionCommands(program);
60
- registerPlaybookCommands(program);
61
- registerConfigCommands(program);
62
- registerStateCommands(program);
63
- registerRunsCommands(program);
64
- registerTestCommand(program);
65
- registerBuildCommand(program);
66
- registerExportCommand(program);
67
- registerLinkCommands(program);
68
- registerProfileCommands(program);
69
- registerServeCommand(program);
70
- registerMcpCommands(program);
71
-
72
- applyCommonOptions(program);
73
-
74
- return program;
75
- }