@actiondock/cli 2.7.0 → 2.8.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 (65) hide show
  1. package/README.md +4 -6
  2. package/dist/commands/action/create.js +4 -5
  3. package/dist/commands/add.js +9 -17
  4. package/dist/commands/build.js +3 -18
  5. package/dist/commands/config/delete.js +8 -7
  6. package/dist/commands/config/env.js +7 -11
  7. package/dist/commands/config/get.js +8 -5
  8. package/dist/commands/config/list.js +16 -22
  9. package/dist/commands/config/schema.d.ts +7 -1
  10. package/dist/commands/config/schema.js +44 -67
  11. package/dist/commands/config/set.js +9 -7
  12. package/dist/commands/describe.js +10 -9
  13. package/dist/commands/doctor.js +4 -3
  14. package/dist/commands/export.js +5 -13
  15. package/dist/commands/generate.js +4 -3
  16. package/dist/commands/info.js +3 -1
  17. package/dist/commands/init.js +3 -3
  18. package/dist/commands/link.js +4 -4
  19. package/dist/commands/list.js +19 -10
  20. package/dist/commands/mcp.js +27 -66
  21. package/dist/commands/pack.js +3 -12
  22. package/dist/commands/playbook.js +30 -10
  23. package/dist/commands/profile.js +10 -19
  24. package/dist/commands/remove.js +5 -14
  25. package/dist/commands/run.d.ts +5 -2
  26. package/dist/commands/run.js +19 -20
  27. package/dist/commands/runs.js +26 -35
  28. package/dist/commands/serve.js +66 -44
  29. package/dist/commands/state-list.d.ts +2 -2
  30. package/dist/commands/state-list.js +10 -8
  31. package/dist/commands/state.d.ts +2 -2
  32. package/dist/commands/state.js +110 -103
  33. package/dist/commands/test.js +1 -1
  34. package/dist/commands/validate.js +4 -17
  35. package/dist/errors.d.ts +14 -0
  36. package/dist/errors.js +46 -2
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.js +3 -3
  39. package/dist/renderer.d.ts +1 -1
  40. package/dist/renderer.js +1 -1
  41. package/dist/services/config-merge.d.ts +6 -5
  42. package/dist/services/config-merge.js +10 -8
  43. package/dist/services/inspect.js +3 -1
  44. package/dist/standalone/index.d.ts +4 -14
  45. package/dist/standalone/index.js +5 -44
  46. package/dist/types.d.ts +2 -1
  47. package/dist/types.js +1 -1
  48. package/dist/utils/cert.js +1 -1
  49. package/dist/utils/duration.d.ts +1 -1
  50. package/dist/utils/duration.js +1 -1
  51. package/dist/utils/index.d.ts +1 -2
  52. package/dist/utils/index.js +1 -2
  53. package/dist/utils/input.d.ts +9 -1
  54. package/dist/utils/input.js +12 -1
  55. package/dist/utils/server-launch.d.ts +61 -0
  56. package/dist/utils/server-launch.js +114 -0
  57. package/dist/utils/target.d.ts +14 -13
  58. package/dist/utils/target.js +20 -39
  59. package/dist/utils/utils.d.ts +101 -1
  60. package/dist/utils/utils.js +97 -7
  61. package/package.json +5 -6
  62. package/dist/utils/bytes.d.ts +0 -1
  63. package/dist/utils/bytes.js +0 -1
  64. package/dist/utils/filter.d.ts +0 -1
  65. package/dist/utils/filter.js +0 -1
@@ -1,5 +1,36 @@
1
- import { resolvePackageRoot, findProjectRoot } from "@actiondock/core";
2
- import { ArgumentError, notInProjectError, packageNotFoundError } from "../errors.js";
1
+ import { resolvePackageRoot, } from "@actiondock/core/registry";
2
+ import { findProjectRoot, loadProjectConfig, } from "@actiondock/core";
3
+ import { loadManifest, } from "@actiondock/core/project";
4
+ import { resolve } from "node:path";
5
+ import { ArgumentError, ExecutionError, notInProjectError, packageNotFoundError, wrapAsExecutionError } from "../errors.js";
6
+ /**
7
+ * 「未显式指定包且当前目录无工程」的统一补救提示(单一事实源)。
8
+ */
9
+ export const PACKAGE_HINT_MESSAGE = "Please specify -P, --package <id> or cd into a project directory.";
10
+ /**
11
+ * 拼接远端目标标题后缀(单一事实源)。
12
+ *
13
+ * 形如 `on remote server <url> (Profile: <name>)`,供列表类命令的
14
+ * 标题拼接复用(如 `Actions ${remoteTargetSuffix(target)}`),
15
+ * 消除五处同构模板漂移。
16
+ *
17
+ * @param resolved 目标拓扑解析结果(远端分支)
18
+ */
19
+ export function remoteTargetSuffix(resolved) {
20
+ const profile = resolved.profileName ? ` (Profile: ${resolved.profileName})` : "";
21
+ return `on remote server ${resolved.serverUrl}${profile}`;
22
+ }
23
+ /**
24
+ * 拼接远端目标标题标签(单一事实源)。
25
+ *
26
+ * 形如 `Remote Server <url> (Profile: <name>)`,与 remoteTargetSuffix 共享
27
+ * 同一拼接实现,供 state、config 等直接以远端目标为标题主体的命令复用。
28
+ *
29
+ * @param resolved 目标拓扑解析结果(远端分支)
30
+ */
31
+ export function remoteTargetLabel(resolved) {
32
+ return `Remote Server ${resolved.serverUrl}${resolved.profileName ? ` (Profile: ${resolved.profileName})` : ""}`;
33
+ }
3
34
  /**
4
35
  * 解析意图字符串(从显式 --intent 或位置模式参数聚合)。
5
36
  * 多个关键字使用 '|'(正则逻辑或)连接。
@@ -81,11 +112,64 @@ export function getTargetRoot(packageOption, keyHint) {
81
112
  throw packageNotFoundError(targetPackage);
82
113
  }
83
114
  else {
84
- throw notInProjectError("Please specify -P, --package <id> or cd into a project directory.");
115
+ throw notInProjectError(PACKAGE_HINT_MESSAGE);
85
116
  }
86
117
  }
87
118
  return { root, key: effectiveKey };
88
119
  }
120
+ export function requirePackageRoot(packageOption, options) {
121
+ const root = packageOption ? resolvePackageRoot(packageOption) : findProjectRoot();
122
+ if (!root) {
123
+ if (packageOption) {
124
+ throw packageNotFoundError(packageOption);
125
+ }
126
+ throw notInProjectError(options?.hint ?? PACKAGE_HINT_MESSAGE);
127
+ }
128
+ return options?.loadConfig
129
+ ? { root, projConfig: loadProjectConfig(root) }
130
+ : { root };
131
+ }
132
+ /**
133
+ * 依赖类命令(ad add / ad remove)的工程根目录与清单解析脚手架(单一事实源)。
134
+ *
135
+ * 与 requirePackageRoot 的差异:-P 语义为工程目录路径而非包标识,
136
+ * 显式路径不做注册表寻址(不抛 packageNotFoundError,缺失清单由后续存在性检查报错)。
137
+ *
138
+ * @param packageOption 显式指定的工程目录路径(对应 -P, --package <path>)
139
+ * @returns 工程根目录与已验存的 actiondock.json 清单
140
+ */
141
+ export function requireProjectManifestRoot(packageOption) {
142
+ const root = packageOption ? resolve(packageOption) : findProjectRoot();
143
+ if (!root) {
144
+ throw notInProjectError("Please specify -P, --package <path> or cd into a project directory.");
145
+ }
146
+ const manifest = loadManifest(root);
147
+ if (!manifest) {
148
+ throw new ArgumentError(`actiondock.json not found in ${root}`);
149
+ }
150
+ return { root, manifest };
151
+ }
152
+ /**
153
+ * 依赖事务失败回滚辅助(ad add / ad remove 共享):回滚事务后按统一规则透传异常。
154
+ *
155
+ * 回滚与包裹规则:
156
+ * - 先执行事务回滚快照,保留原始磁盘状态;
157
+ * - ActionDockError 与 CliError 原样透传(保留 code 与 details);
158
+ * - 其余包裹为 ExecutionError 并保留原始 code,缺省时回退 fallbackCode。
159
+ *
160
+ * @param tx 已开启的工程事务快照
161
+ * @param err 业务回调抛出的原始异常
162
+ * @param fallbackCode 包裹分支缺省错误码(命令专属,如 ADD_DEPENDENCY_FAILED)
163
+ */
164
+ export async function rollbackAndRethrow(tx, err, fallbackCode) {
165
+ await tx.rollback({ frozenInstall: false });
166
+ const passthrough = wrapAsExecutionError(err);
167
+ if (passthrough !== err) {
168
+ const original = err;
169
+ throw new ExecutionError(original.message, err, original.code || fallbackCode);
170
+ }
171
+ throw passthrough;
172
+ }
89
173
  /**
90
174
  * 聚合命令自身选项与根程序全局选项(如 --json、--data-dir 等)。
91
175
  */
@@ -97,15 +181,21 @@ export function getEffectiveOptions(rawOptions, cmd) {
97
181
  }
98
182
  /**
99
183
  * 解析意图过滤回退策略。
100
- * 机器输出模式(--json)仅在显式传 --fallback 时回退,
184
+ *
185
+ * 统一事实源:机器输出模式(--json)仅在显式传 --fallback 时回退,
101
186
  * 人类交互模式默认回退(可被 --no-fallback 关闭)。
187
+ *
188
+ * 回退标志的显式性判定完全依据 Commander 解析结果(由调用方传入):
189
+ * 同时注册 --fallback 与 --no-fallback 的命令,未指定时 fallback 为
190
+ * undefined、显式 --fallback 为 true、--no-fallback 为 false,
191
+ * 不再直读 process.argv,消除隐藏的全局依赖。
192
+ *
193
+ * @param options 命令选项视图(含 fallback 与 json 字段)
102
194
  */
103
195
  export function resolveFallbackStrategy(options) {
104
196
  const isMachine = Boolean(options.json);
105
- const fallbackExplicit = options.fallback === true ||
106
- (Array.isArray(process.argv) && process.argv.includes("--fallback"));
107
197
  return {
108
198
  isMachine,
109
- shouldFallback: isMachine ? fallbackExplicit : options.fallback !== false,
199
+ shouldFallback: isMachine ? options.fallback === true : options.fallback !== false,
110
200
  };
111
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actiondock/cli",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "ActionDock CLI facade for developing, testing, building, and exporting standalone Agent Actions and Skills",
5
5
  "type": "module",
6
6
  "bin": {
@@ -34,11 +34,10 @@
34
34
  "test": "node ../../scripts/run-tests.ts"
35
35
  },
36
36
  "dependencies": {
37
- "@actiondock/builder": "^2.7.0",
38
- "@actiondock/core": "^2.7.0",
39
- "@actiondock/mcp": "^2.7.0",
40
- "@actiondock/runtime-node": "^2.7.0",
41
- "@actiondock/sdk": "^2.7.0",
37
+ "@actiondock/builder": "^2.8.0",
38
+ "@actiondock/core": "^2.8.0",
39
+ "@actiondock/mcp": "^2.8.0",
40
+ "@actiondock/sdk": "^2.8.0",
42
41
  "commander": "^13.1.0",
43
42
  "selfsigned": "^5.5.0"
44
43
  },
@@ -1 +0,0 @@
1
- export { parseByteSize } from "./utils.js";
@@ -1 +0,0 @@
1
- export { parseByteSize } from "./utils.js";
@@ -1 +0,0 @@
1
- export { resolveIntent } from "./utils.js";
@@ -1 +0,0 @@
1
- export { resolveIntent } from "./utils.js";