@actiondock/cli 2.0.11 → 2.2.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.
Files changed (123) hide show
  1. package/README.md +41 -21
  2. package/bin/ad.js +29 -31
  3. package/dist/commands/action/create.d.ts +10 -0
  4. package/dist/commands/action/create.js +120 -0
  5. package/dist/commands/add.d.ts +7 -0
  6. package/dist/commands/add.js +144 -0
  7. package/dist/commands/build.d.ts +3 -0
  8. package/dist/commands/build.js +83 -0
  9. package/dist/commands/config/delete.d.ts +9 -0
  10. package/dist/commands/config/delete.js +52 -0
  11. package/dist/commands/config/env.d.ts +9 -0
  12. package/dist/commands/config/env.js +85 -0
  13. package/dist/commands/config/get.d.ts +9 -0
  14. package/dist/commands/config/get.js +120 -0
  15. package/dist/commands/config/index.d.ts +9 -0
  16. package/dist/commands/config/index.js +23 -0
  17. package/dist/commands/config/list.d.ts +9 -0
  18. package/dist/commands/config/list.js +137 -0
  19. package/dist/commands/config/schema.d.ts +9 -0
  20. package/dist/commands/config/schema.js +121 -0
  21. package/dist/commands/config/set.d.ts +9 -0
  22. package/dist/commands/config/set.js +85 -0
  23. package/dist/commands/describe.d.ts +9 -0
  24. package/dist/commands/describe.js +68 -0
  25. package/dist/commands/doctor.d.ts +3 -0
  26. package/dist/commands/doctor.js +82 -0
  27. package/dist/commands/export.d.ts +3 -0
  28. package/dist/commands/export.js +212 -0
  29. package/dist/commands/generate.d.ts +9 -0
  30. package/dist/commands/generate.js +44 -0
  31. package/dist/commands/index.d.ts +32 -0
  32. package/dist/commands/index.js +111 -0
  33. package/dist/commands/info.d.ts +9 -0
  34. package/dist/commands/info.js +210 -0
  35. package/dist/commands/init.d.ts +2 -0
  36. package/dist/commands/init.js +24 -0
  37. package/dist/commands/link.d.ts +2 -0
  38. package/dist/commands/link.js +71 -0
  39. package/dist/commands/list.d.ts +9 -0
  40. package/dist/commands/list.js +77 -0
  41. package/dist/commands/mcp.d.ts +9 -0
  42. package/dist/commands/mcp.js +172 -0
  43. package/dist/commands/new.d.ts +9 -0
  44. package/dist/commands/new.js +33 -0
  45. package/dist/commands/pack.d.ts +3 -0
  46. package/dist/commands/pack.js +63 -0
  47. package/dist/commands/playbook.d.ts +10 -0
  48. package/dist/commands/playbook.js +433 -0
  49. package/dist/commands/profile.d.ts +2 -0
  50. package/dist/commands/profile.js +253 -0
  51. package/dist/commands/remove.d.ts +7 -0
  52. package/dist/commands/remove.js +118 -0
  53. package/dist/commands/run.d.ts +13 -0
  54. package/dist/commands/run.js +146 -0
  55. package/dist/commands/runs.d.ts +9 -0
  56. package/dist/commands/runs.js +245 -0
  57. package/dist/commands/serve.d.ts +9 -0
  58. package/dist/commands/serve.js +129 -0
  59. package/dist/commands/state-list.d.ts +24 -0
  60. package/dist/commands/state-list.js +82 -0
  61. package/dist/commands/state.d.ts +9 -0
  62. package/dist/commands/state.js +310 -0
  63. package/dist/commands/test.d.ts +2 -0
  64. package/dist/commands/test.js +44 -0
  65. package/dist/commands/validate.d.ts +9 -0
  66. package/dist/commands/validate.js +106 -0
  67. package/dist/errors.d.ts +43 -0
  68. package/dist/errors.js +103 -0
  69. package/dist/index.d.ts +15 -0
  70. package/dist/index.js +47 -65969
  71. package/dist/prompt.d.ts +53 -0
  72. package/dist/prompt.js +192 -0
  73. package/dist/renderer.d.ts +197 -0
  74. package/dist/renderer.js +502 -0
  75. package/dist/services/index.d.ts +1 -0
  76. package/dist/services/index.js +1 -0
  77. package/dist/services/inspect.d.ts +23 -0
  78. package/dist/services/inspect.js +96 -0
  79. package/dist/standalone/index.d.ts +16 -0
  80. package/dist/standalone/index.js +22 -0
  81. package/dist/types.d.ts +132 -0
  82. package/dist/types.js +9 -0
  83. package/dist/utils/bytes.d.ts +1 -0
  84. package/dist/utils/bytes.js +1 -0
  85. package/dist/utils/duration.js +1 -0
  86. package/dist/utils/filter.d.ts +1 -0
  87. package/dist/utils/filter.js +1 -0
  88. package/dist/utils/index.d.ts +6 -0
  89. package/dist/utils/index.js +6 -0
  90. package/dist/utils/spawn.d.ts +27 -0
  91. package/dist/utils/spawn.js +35 -0
  92. package/dist/utils/target.d.ts +45 -0
  93. package/dist/utils/target.js +78 -0
  94. package/dist/utils/utils.d.ts +38 -0
  95. package/dist/utils/utils.js +111 -0
  96. package/package.json +20 -17
  97. package/src/commands/action/create.ts +0 -129
  98. package/src/commands/action/index.ts +0 -27
  99. package/src/commands/action/list.ts +0 -247
  100. package/src/commands/action/run.ts +0 -197
  101. package/src/commands/action/show.ts +0 -128
  102. package/src/commands/action/sync.ts +0 -76
  103. package/src/commands/action/validate.ts +0 -102
  104. package/src/commands/action.ts +0 -1
  105. package/src/commands/build.ts +0 -56
  106. package/src/commands/config.ts +0 -583
  107. package/src/commands/doctor.ts +0 -84
  108. package/src/commands/export.ts +0 -196
  109. package/src/commands/index.ts +0 -75
  110. package/src/commands/info.ts +0 -537
  111. package/src/commands/init.ts +0 -24
  112. package/src/commands/link.ts +0 -73
  113. package/src/commands/mcp.ts +0 -195
  114. package/src/commands/playbook.ts +0 -566
  115. package/src/commands/profile.ts +0 -296
  116. package/src/commands/runs.ts +0 -452
  117. package/src/commands/serve.ts +0 -132
  118. package/src/commands/state.ts +0 -590
  119. package/src/commands/test.ts +0 -48
  120. package/src/index.ts +0 -58
  121. package/src/utils/bytes.ts +0 -2
  122. package/src/utils/filter.ts +0 -2
  123. /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", "-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
- }