@actiondock/cli 2.13.0 → 2.14.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.
- package/bin/ad.js +0 -16
- package/dist/commands/config/delete.js +8 -19
- package/dist/commands/config/env.js +3 -2
- package/dist/commands/config/get.js +10 -17
- package/dist/commands/config/list.js +10 -16
- package/dist/commands/config/schema.js +7 -6
- package/dist/commands/config/set.js +12 -34
- package/dist/commands/describe.js +6 -9
- package/dist/commands/list.js +16 -16
- package/dist/commands/run.js +7 -20
- package/dist/commands/state.js +19 -2
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/target.d.ts +57 -3
- package/dist/utils/target.js +202 -18
- package/package.json +5 -5
- package/dist/utils/warning.d.ts +0 -4
- package/dist/utils/warning.js +0 -4
package/bin/ad.js
CHANGED
|
@@ -3,19 +3,6 @@ import { enableCompileCache } from "node:module";
|
|
|
3
3
|
try {
|
|
4
4
|
enableCompileCache?.();
|
|
5
5
|
} catch {}
|
|
6
|
-
try {
|
|
7
|
-
await import("@actiondock/core/warning");
|
|
8
|
-
} catch {
|
|
9
|
-
try {
|
|
10
|
-
const { resolve } = await import("node:path");
|
|
11
|
-
const { existsSync } = await import("node:fs");
|
|
12
|
-
const { pathToFileURL } = await import("node:url");
|
|
13
|
-
const coreWarningSrc = resolve(import.meta.dirname, "../../core/src/utils/warning.ts");
|
|
14
|
-
if (existsSync(coreWarningSrc)) {
|
|
15
|
-
await import(pathToFileURL(coreWarningSrc).href);
|
|
16
|
-
}
|
|
17
|
-
} catch {}
|
|
18
|
-
}
|
|
19
6
|
|
|
20
7
|
import { spawn } from "node:child_process";
|
|
21
8
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -238,9 +225,6 @@ if (needsTsx) {
|
|
|
238
225
|
|
|
239
226
|
if (tsxSpecifier) {
|
|
240
227
|
const extraFlags = [];
|
|
241
|
-
if (process.env.ACTIONDOCK_SILENCE_WARNINGS !== "0") {
|
|
242
|
-
extraFlags.push("--no-warnings=ExperimentalWarning");
|
|
243
|
-
}
|
|
244
228
|
if (nodeMajor >= 24) {
|
|
245
229
|
extraFlags.push("--no-strip-types");
|
|
246
230
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolvePackageRoot, } from "@actiondock/core/registry";
|
|
3
|
-
import { ArgumentError, packageNotFoundError } from "../../errors.js";
|
|
1
|
+
import { ArgumentError } from "../../errors.js";
|
|
4
2
|
import { writeStdout } from "../../renderer.js";
|
|
5
|
-
import { applyTargetOptions, getEffectiveOptions, withService } from "../../utils/index.js";
|
|
3
|
+
import { applyTargetOptions, getEffectiveOptions, resolveTargetPackageScope, withService, } from "../../utils/index.js";
|
|
6
4
|
/**
|
|
7
5
|
* 注册 config delete 子命令:删除配置项。
|
|
8
6
|
*
|
|
@@ -22,31 +20,22 @@ export function registerConfigDeleteCommand(configCmd, context) {
|
|
|
22
20
|
if (!key) {
|
|
23
21
|
throw new ArgumentError("Configuration key is required");
|
|
24
22
|
}
|
|
25
|
-
const
|
|
23
|
+
const scope = resolveTargetPackageScope(options, context);
|
|
26
24
|
await withService(options, context, async (service, resolved) => {
|
|
27
25
|
if (resolved.type === "remote") {
|
|
28
|
-
await service.management?.config.delete(
|
|
26
|
+
await service.management?.config.delete(scope.packageId, key);
|
|
29
27
|
writeStdout(`[OK] Configuration '${key}' deleted from remote server`, context);
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
32
|
-
if (options.global) {
|
|
30
|
+
if (options.global || (!scope.root && !options.package)) {
|
|
33
31
|
await service.management?.config.delete("global", key);
|
|
34
32
|
writeStdout(`[OK] Global configuration '${key}' deleted`, context);
|
|
35
33
|
return;
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
throw packageNotFoundError(options.package);
|
|
40
|
-
}
|
|
41
|
-
await service.management?.config.delete("global", key);
|
|
42
|
-
writeStdout(`[OK] Global configuration '${key}' deleted`, context);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const projConfig = loadProjectConfig(root);
|
|
46
|
-
await service.management?.config.delete(projConfig.id, key);
|
|
47
|
-
writeStdout(`[OK] Configuration '${key}' deleted for package '${projConfig.id}'`, context);
|
|
35
|
+
await service.management?.config.delete(scope.packageId, key);
|
|
36
|
+
writeStdout(`[OK] Configuration '${key}' deleted for package '${scope.packageId}'`, context);
|
|
48
37
|
},
|
|
49
38
|
// 按实际查询范围打开存储:显式包寻址结果作为本地根目录传递
|
|
50
|
-
{ localRoot: root
|
|
39
|
+
{ localRoot: scope.root });
|
|
51
40
|
});
|
|
52
41
|
}
|
|
@@ -2,7 +2,7 @@ import { resolveEnvValue } from "@actiondock/core";
|
|
|
2
2
|
import { fetchRemoteConfigEnv } from "@actiondock/core/profile";
|
|
3
3
|
import { isSecretConfigKey, } from "@actiondock/core/project";
|
|
4
4
|
import { renderConfigEnv, renderResult } from "../../renderer.js";
|
|
5
|
-
import { applyTargetOptions, getEffectiveOptions, requirePackageRoot, resolveTargetFromOptions } from "../../utils/index.js";
|
|
5
|
+
import { applyTargetOptions, assertNotCompositeSkill, getEffectiveOptions, requirePackageRoot, resolveTargetFromOptions, } from "../../utils/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* 注册 config env 子命令:诊断环境变量对声明配置的满足率。
|
|
8
8
|
*
|
|
@@ -18,7 +18,7 @@ export function registerConfigEnvCommand(configCmd, context) {
|
|
|
18
18
|
.action(async (identifier, rawOptions, cmd) => {
|
|
19
19
|
const options = getEffectiveOptions(rawOptions, cmd);
|
|
20
20
|
const targetPkg = identifier || options.package;
|
|
21
|
-
//
|
|
21
|
+
// 1. 目标拓扑解析(远端服务分支完全隔离本地文件系统)
|
|
22
22
|
const target = resolveTargetFromOptions(options, context);
|
|
23
23
|
if (target.type === "remote") {
|
|
24
24
|
const res = await fetchRemoteConfigEnv(target.serverUrl, target.token, targetPkg, {
|
|
@@ -37,6 +37,7 @@ export function registerConfigEnvCommand(configCmd, context) {
|
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
// 本地项目分支
|
|
40
|
+
assertNotCompositeSkill(targetPkg);
|
|
40
41
|
const { root, projConfig } = requirePackageRoot(targetPkg, {
|
|
41
42
|
loadConfig: true,
|
|
42
43
|
hint: "Usage: ad config env [package-id] or cd into a project directory.",
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { fetchRemoteConfig, } from "@actiondock/core/profile";
|
|
2
2
|
import { isSecretConfigKey, maskSecretValue, } from "@actiondock/core/project";
|
|
3
3
|
import { loadProjectConfig, } from "@actiondock/core";
|
|
4
|
-
import {
|
|
5
|
-
import { ArgumentError, packageNotFoundError } from "../../errors.js";
|
|
4
|
+
import { ArgumentError } from "../../errors.js";
|
|
6
5
|
import { renderResult } from "../../renderer.js";
|
|
7
6
|
import { resolveMergedConfigEntry } from "../../services/config-merge.js";
|
|
8
|
-
import { applyTargetOptions, getEffectiveOptions,
|
|
7
|
+
import { applyTargetOptions, getEffectiveOptions, resolveTargetPackageScope, withService, } from "../../utils/index.js";
|
|
9
8
|
/**
|
|
10
9
|
* 注册 config get 子命令:查询指定配置键的生效值。
|
|
11
10
|
*
|
|
@@ -27,12 +26,11 @@ export function registerConfigGetCommand(configCmd, context) {
|
|
|
27
26
|
throw new ArgumentError("Configuration key is required");
|
|
28
27
|
}
|
|
29
28
|
const reveal = Boolean(options.reveal || options.showSecrets);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const res = await fetchRemoteConfig(target.serverUrl, target.token, options.package, {
|
|
29
|
+
const scope = resolveTargetPackageScope(options, context);
|
|
30
|
+
if (scope.isRemote) {
|
|
31
|
+
const res = await fetchRemoteConfig(scope.resolved.serverUrl, scope.resolved.token, scope.packageId, {
|
|
34
32
|
allowInsecureHttp: Boolean(options.allowInsecureHttp),
|
|
35
|
-
insecure:
|
|
33
|
+
insecure: scope.resolved.insecure,
|
|
36
34
|
});
|
|
37
35
|
const val = res.values?.[key];
|
|
38
36
|
const isSecret = isSecretConfigKey(key, res.declared?.[key]);
|
|
@@ -50,13 +48,8 @@ export function registerConfigGetCommand(configCmd, context) {
|
|
|
50
48
|
});
|
|
51
49
|
return;
|
|
52
50
|
}
|
|
53
|
-
// 本地分支
|
|
54
|
-
const root = resolvePackageRoot(options.package);
|
|
55
51
|
await withService(options, context, async (service) => {
|
|
56
|
-
if (options.global || !root) {
|
|
57
|
-
if (!options.global && options.package && !root) {
|
|
58
|
-
throw packageNotFoundError(options.package);
|
|
59
|
-
}
|
|
52
|
+
if (options.global || !scope.root) {
|
|
60
53
|
const confView = await service.management?.config.get("global", key);
|
|
61
54
|
const val = confView?.value;
|
|
62
55
|
const isSecret = confView?.secret ?? isSecretConfigKey(key);
|
|
@@ -74,10 +67,10 @@ export function registerConfigGetCommand(configCmd, context) {
|
|
|
74
67
|
});
|
|
75
68
|
return;
|
|
76
69
|
}
|
|
77
|
-
const projConfig = loadProjectConfig(root);
|
|
70
|
+
const projConfig = scope.projConfig || loadProjectConfig(scope.root);
|
|
78
71
|
const declaredItem = projConfig.config?.[key];
|
|
79
72
|
// 合并优先级链单一事实源:项目包级 > 全局持久化 > 环境变量 > 声明默认值
|
|
80
|
-
const { value: displayValue, source, secret: isSecret } = await resolveMergedConfigEntry(key,
|
|
73
|
+
const { value: displayValue, source, secret: isSecret } = await resolveMergedConfigEntry(key, scope.packageId, declaredItem, service, reveal);
|
|
81
74
|
const payload = {
|
|
82
75
|
key,
|
|
83
76
|
value: displayValue,
|
|
@@ -91,6 +84,6 @@ export function registerConfigGetCommand(configCmd, context) {
|
|
|
91
84
|
});
|
|
92
85
|
},
|
|
93
86
|
// 按实际查询范围打开存储:显式包寻址结果作为本地根目录传递
|
|
94
|
-
{ localRoot: root
|
|
87
|
+
{ localRoot: scope.root });
|
|
95
88
|
});
|
|
96
89
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { fetchRemoteConfig, } from "@actiondock/core/profile";
|
|
2
2
|
import { loadProjectConfig, } from "@actiondock/core";
|
|
3
3
|
import { filterWithFallbackInfo, isSecretConfigKey, maskSecretValue, } from "@actiondock/core/project";
|
|
4
|
-
import { packageNotFoundError } from "../../errors.js";
|
|
5
4
|
import { renderConfigList, renderResult } from "../../renderer.js";
|
|
6
5
|
import { buildMergedConfigEntries } from "../../services/config-merge.js";
|
|
7
|
-
import { applyTargetOptions, getEffectiveOptions, remoteTargetLabel, resolveFallbackStrategy, resolveIntent,
|
|
6
|
+
import { applyTargetOptions, getEffectiveOptions, remoteTargetLabel, resolveFallbackStrategy, resolveIntent, resolveTargetPackageScope, withService, } from "../../utils/index.js";
|
|
8
7
|
/**
|
|
9
8
|
* 构造单条配置项的展示视图(含掩码决策,reveal 为假且为敏感键时打码)。
|
|
10
9
|
* 掩码决策收敛于命令层,renderer 仅负责值的字符串格式化。
|
|
@@ -42,29 +41,24 @@ export function registerConfigListCommand(configCmd, context) {
|
|
|
42
41
|
const effectiveIntent = resolveIntent(options.intent, patterns);
|
|
43
42
|
const { shouldFallback } = resolveFallbackStrategy(options);
|
|
44
43
|
const reveal = Boolean(options.reveal || options.showSecrets);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const res = await fetchRemoteConfig(remoteTargetInfo.serverUrl, remoteTargetInfo.token, options.package, {
|
|
44
|
+
const scope = resolveTargetPackageScope(options, context);
|
|
45
|
+
if (scope.isRemote) {
|
|
46
|
+
const res = await fetchRemoteConfig(scope.resolved.serverUrl, scope.resolved.token, scope.packageId, {
|
|
49
47
|
allowInsecureHttp: Boolean(options.allowInsecureHttp),
|
|
50
|
-
insecure:
|
|
48
|
+
insecure: scope.resolved.insecure,
|
|
51
49
|
});
|
|
52
50
|
const entries = Object.entries(res.values || {}).map(([k, v]) => toDisplayEntry(k, v, "remote", isSecretConfigKey(k, res.declared?.[k]), reveal, res.declared?.[k]?.description || ""));
|
|
53
51
|
renderResult(entries, {
|
|
54
52
|
json: options.json,
|
|
55
|
-
humanFormatter: () => renderConfigList(entries, remoteTargetLabel(
|
|
53
|
+
humanFormatter: () => renderConfigList(entries, remoteTargetLabel(scope.resolved), false, effectiveIntent),
|
|
56
54
|
context,
|
|
57
55
|
});
|
|
58
56
|
return;
|
|
59
57
|
}
|
|
60
58
|
// 本地分支(通过 Service 门面统一访问):显式包寻址结果作为本地根目录传递(仅 local 分支求值)
|
|
61
59
|
await withService(options, context, async (service) => {
|
|
62
|
-
const root = resolveLocalPackageRoot(options.package) || undefined;
|
|
63
60
|
// 全局作用域分支:显式 --global 或无工程回退时仅列举全局配置
|
|
64
|
-
if (options.global || !root) {
|
|
65
|
-
if (!options.global && options.package) {
|
|
66
|
-
throw packageNotFoundError(options.package);
|
|
67
|
-
}
|
|
61
|
+
if (options.global || !scope.root) {
|
|
68
62
|
const all = (await service.management?.config.list("global")) ?? [];
|
|
69
63
|
const entries = all.map((item) => toDisplayEntry(item.key, item.value, "global", item.secret || isSecretConfigKey(item.key), reveal));
|
|
70
64
|
const filterRes = filterWithFallbackInfo(entries, effectiveIntent, [(c) => c.key, (c) => c.value], shouldFallback);
|
|
@@ -75,9 +69,9 @@ export function registerConfigListCommand(configCmd, context) {
|
|
|
75
69
|
});
|
|
76
70
|
return;
|
|
77
71
|
}
|
|
78
|
-
const projConfig = loadProjectConfig(root);
|
|
72
|
+
const projConfig = scope.projConfig || loadProjectConfig(scope.root);
|
|
79
73
|
// 跨作用域合并视图单一事实源:项目包级 > 全局持久化 > 环境变量 > 声明默认值
|
|
80
|
-
const merged = await buildMergedConfigEntries(root, service, reveal);
|
|
74
|
+
const merged = await buildMergedConfigEntries(scope.root, service, reveal);
|
|
81
75
|
const filterRes = filterWithFallbackInfo(merged, effectiveIntent, [(c) => c.key, (c) => c.value, (c) => c.description, (c) => c.source], shouldFallback);
|
|
82
76
|
renderResult(filterRes.items, {
|
|
83
77
|
json: options.json,
|
|
@@ -85,7 +79,7 @@ export function registerConfigListCommand(configCmd, context) {
|
|
|
85
79
|
context,
|
|
86
80
|
});
|
|
87
81
|
}, {
|
|
88
|
-
localRoot:
|
|
82
|
+
localRoot: scope.root,
|
|
89
83
|
});
|
|
90
84
|
});
|
|
91
85
|
}
|
|
@@ -2,7 +2,7 @@ import { isSecretConfigKey, } from "@actiondock/core/project";
|
|
|
2
2
|
import { notInProjectError } from "../../errors.js";
|
|
3
3
|
import { renderConfigSchema, renderResult } from "../../renderer.js";
|
|
4
4
|
import { buildMergedConfigEntries } from "../../services/config-merge.js";
|
|
5
|
-
import { applyTargetOptions, getEffectiveOptions, requirePackageRoot, withService } from "../../utils/index.js";
|
|
5
|
+
import { applyTargetOptions, assertNotCompositeSkill, getEffectiveOptions, requirePackageRoot, withService, } from "../../utils/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* 注册 config schema 子命令:检查声明配置的解析状态。
|
|
8
8
|
*
|
|
@@ -25,17 +25,18 @@ export function registerConfigSchemaCommand(configCmd, context) {
|
|
|
25
25
|
.option("--json", "Output as JSON")
|
|
26
26
|
.action(async (identifier, rawOptions, cmd) => {
|
|
27
27
|
const options = getEffectiveOptions(rawOptions, cmd);
|
|
28
|
+
// 远端目标显式拒绝:schema 状态推导依赖本地工程声明与环境变量解析,
|
|
29
|
+
// 远端作用域无法获得等价视图,静默落到本地会误导调用方
|
|
30
|
+
if (options.profile || options.server) {
|
|
31
|
+
throw notInProjectError("'ad config schema' only supports local projects. Remote targets are not supported for schema inspection.");
|
|
32
|
+
}
|
|
28
33
|
const targetPkg = identifier || options.package;
|
|
34
|
+
assertNotCompositeSkill(targetPkg);
|
|
29
35
|
const { root, projConfig } = requirePackageRoot(targetPkg, {
|
|
30
36
|
loadConfig: true,
|
|
31
37
|
hint: "Usage: ad config schema [package-id] or cd into a project directory.",
|
|
32
38
|
});
|
|
33
39
|
const declared = projConfig.config || {};
|
|
34
|
-
// 远端目标显式拒绝:schema 状态推导依赖本地工程声明与环境变量解析,
|
|
35
|
-
// 远端作用域无法获得等价视图,静默落到本地会误导调用方
|
|
36
|
-
if (options.profile || options.server) {
|
|
37
|
-
throw notInProjectError("'ad config schema' only supports local projects. Remote targets are not supported for schema inspection.");
|
|
38
|
-
}
|
|
39
40
|
// 跨作用域合并视图单一事实源:与 config list 共享同一条优先级链
|
|
40
41
|
await withService(options, context, async (service) => {
|
|
41
42
|
const merged = await buildMergedConfigEntries(root, service, true);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { isSecretConfigKey, } from "@actiondock/core/project";
|
|
2
|
-
import {
|
|
3
|
-
import { resolvePackageRoot, } from "@actiondock/core/registry";
|
|
4
|
-
import { ArgumentError, packageNotFoundError } from "../../errors.js";
|
|
2
|
+
import { ArgumentError } from "../../errors.js";
|
|
5
3
|
import { writeStdout } from "../../renderer.js";
|
|
6
|
-
import { applyTargetOptions, getEffectiveOptions, withService } from "../../utils/index.js";
|
|
4
|
+
import { applyTargetOptions, getEffectiveOptions, resolveTargetPackageScope, withService, } from "../../utils/index.js";
|
|
7
5
|
import { resolveConfigValueInput } from "../../prompt.js";
|
|
8
6
|
/**
|
|
9
7
|
* 注册 config set 子命令:写入配置值(支持标准输入与安全提示)。
|
|
@@ -24,22 +22,8 @@ export function registerConfigSetCommand(configCmd, context) {
|
|
|
24
22
|
if (!key) {
|
|
25
23
|
throw new ArgumentError("Configuration key is required");
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let declaredDef;
|
|
30
|
-
if (!options.global && !options.profile && !options.server) {
|
|
31
|
-
root = resolvePackageRoot(options.package);
|
|
32
|
-
if (root) {
|
|
33
|
-
try {
|
|
34
|
-
projConfig = loadProjectConfig(root);
|
|
35
|
-
declaredDef = projConfig.config?.[key];
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
// 清单损坏时必须让错误可见:静默忽略会导致写入错误的作用域
|
|
39
|
-
throw err;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
25
|
+
const scope = resolveTargetPackageScope(options, context);
|
|
26
|
+
const declaredDef = scope.projConfig?.config?.[key];
|
|
43
27
|
const isSecret = isSecretConfigKey(key, declaredDef);
|
|
44
28
|
let effectiveValueStr = rawVal;
|
|
45
29
|
if (effectiveValueStr === undefined || options.stdin) {
|
|
@@ -60,27 +44,21 @@ export function registerConfigSetCommand(configCmd, context) {
|
|
|
60
44
|
// 目标解析与写入(远端分支直接写远端作用域,本地分支按全局/项目作用域写入)
|
|
61
45
|
await withService(options, context, async (service, resolved) => {
|
|
62
46
|
if (resolved.type === "remote") {
|
|
63
|
-
await service.management?.config.set(
|
|
47
|
+
await service.management?.config.set(scope.packageId, key, parsedVal);
|
|
64
48
|
writeStdout(`[OK] Configuration '${key}' updated on remote server`, context);
|
|
65
49
|
return;
|
|
66
50
|
}
|
|
67
|
-
if (options.global) {
|
|
68
|
-
await service.management?.config.set("global", key, parsedVal);
|
|
69
|
-
writeStdout(`[OK] Global configuration '${key}' updated`, context);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!root) {
|
|
73
|
-
if (options.package) {
|
|
74
|
-
throw packageNotFoundError(options.package);
|
|
75
|
-
}
|
|
51
|
+
if (options.global || (!scope.root && !options.package)) {
|
|
76
52
|
await service.management?.config.set("global", key, parsedVal);
|
|
77
|
-
writeStdout(
|
|
53
|
+
writeStdout(!scope.root && !options.package
|
|
54
|
+
? `[OK] Global configuration '${key}' updated (no project in current directory)`
|
|
55
|
+
: `[OK] Global configuration '${key}' updated`, context);
|
|
78
56
|
return;
|
|
79
57
|
}
|
|
80
|
-
await service.management?.config.set(
|
|
81
|
-
writeStdout(`[OK] Configuration '${key}' updated for package '${
|
|
58
|
+
await service.management?.config.set(scope.packageId, key, parsedVal);
|
|
59
|
+
writeStdout(`[OK] Configuration '${key}' updated for package '${scope.packageId}'`, context);
|
|
82
60
|
},
|
|
83
61
|
// 按实际查询范围打开存储:显式包寻址结果作为本地根目录传递
|
|
84
|
-
{ localRoot: root
|
|
62
|
+
{ localRoot: scope.root });
|
|
85
63
|
});
|
|
86
64
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ACTION_NOT_FOUND, PACKAGE_NOT_FOUND, NOT_FOUND, } from "@actiondock/core";
|
|
2
2
|
import { buildActionDescribePayload, } from "@actiondock/core/project";
|
|
3
|
-
import { ArgumentError, ExecutionError
|
|
3
|
+
import { ArgumentError, ExecutionError } from "../errors.js";
|
|
4
4
|
import { formatActionDetail, renderResult } from "../renderer.js";
|
|
5
|
-
import { applyTargetOptions, getEffectiveOptions,
|
|
5
|
+
import { applyTargetOptions, getEffectiveOptions, resolveCommandTarget, withService, } from "../utils/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* 挂载 describe 子命令至指定 Commander 节点。
|
|
8
8
|
*
|
|
@@ -22,12 +22,9 @@ export function attachDescribeCommand(parent, context) {
|
|
|
22
22
|
if (!id) {
|
|
23
23
|
throw new ArgumentError("Action ID is required for describe");
|
|
24
24
|
}
|
|
25
|
-
//
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
throw packageNotFoundError(options.package);
|
|
29
|
-
}
|
|
30
|
-
const targetRef = id;
|
|
25
|
+
// 目标拓扑与动作引用解析(远端目标完全隔离本地文件系统)
|
|
26
|
+
const target = resolveCommandTarget(options, context);
|
|
27
|
+
const targetRef = target.resolveActionRef(id);
|
|
31
28
|
// 通过 Service 门面统一查询 Action 规范
|
|
32
29
|
await withService(options, context, async (service) => {
|
|
33
30
|
let spec;
|
|
@@ -50,7 +47,7 @@ export function attachDescribeCommand(parent, context) {
|
|
|
50
47
|
humanFormatter: () => formatActionDetail(payload),
|
|
51
48
|
context,
|
|
52
49
|
});
|
|
53
|
-
}, { localRoot: targetPackageRoot
|
|
50
|
+
}, { localRoot: target.targetPackageRoot, scanLinkedPackages: !target.localSkill });
|
|
54
51
|
});
|
|
55
52
|
}
|
|
56
53
|
/**
|
package/dist/commands/list.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { filterWithFallbackInfo, } from "@actiondock/core/project";
|
|
2
|
-
import { packageNotFoundError } from "../errors.js";
|
|
3
2
|
import { renderActionList, renderResult } from "../renderer.js";
|
|
4
|
-
import { applyTargetOptions, getEffectiveOptions, remoteTargetSuffix, resolveFallbackStrategy, resolveIntent,
|
|
3
|
+
import { applyTargetOptions, getEffectiveOptions, remoteTargetSuffix, resolveCommandTarget, resolveFallbackStrategy, resolveIntent, withService, } from "../utils/index.js";
|
|
5
4
|
/**
|
|
6
5
|
* 挂载 list 子命令至指定 Commander 节点。
|
|
7
6
|
*
|
|
@@ -23,22 +22,20 @@ export function attachListCommand(parent, context) {
|
|
|
23
22
|
const options = getEffectiveOptions(rawOptions, cmd);
|
|
24
23
|
const effectiveIntent = resolveIntent(options.intent, patterns);
|
|
25
24
|
const { isMachine, shouldFallback } = resolveFallbackStrategy(options);
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
if (options.package && !targetPackageRoot) {
|
|
29
|
-
throw packageNotFoundError(options.package);
|
|
30
|
-
}
|
|
25
|
+
// 目标拓扑与动作引用解析(远端目标完全隔离本地文件系统)
|
|
26
|
+
const target = resolveCommandTarget(options, context);
|
|
31
27
|
// 通过 Service 门面统一获取 Action 列表
|
|
32
28
|
await withService(options, context, async (service, resolved) => {
|
|
33
29
|
let rawSummaries = await service.discovery.listActions();
|
|
34
|
-
//
|
|
30
|
+
// 若指定了包 ID(非本地技能目录),则按包归属精确过滤(本地与远端统一生效):
|
|
35
31
|
// 仅保留全限定名命中目标包前缀、或 packageId 归属目标包的条目;
|
|
36
32
|
// 无法归属到目标包的无前缀短 id 条目不放行,避免他包短 id 混入
|
|
37
|
-
if (options.package && !
|
|
33
|
+
if (options.package && !target.localSkill) {
|
|
38
34
|
const targetPkg = options.package;
|
|
39
35
|
rawSummaries = rawSummaries.filter((s) => {
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const pkgId = s.packageId;
|
|
37
|
+
if (pkgId) {
|
|
38
|
+
return (pkgId === targetPkg ||
|
|
42
39
|
s.id === targetPkg ||
|
|
43
40
|
s.id.startsWith(`${targetPkg}/`));
|
|
44
41
|
}
|
|
@@ -46,14 +43,17 @@ export function attachListCommand(parent, context) {
|
|
|
46
43
|
return s.id === targetPkg || s.id.startsWith(`${targetPkg}/`);
|
|
47
44
|
});
|
|
48
45
|
}
|
|
46
|
+
const isCompositeSkill = target.localSkill?.type === "composite";
|
|
49
47
|
const rawList = rawSummaries.map((s) => {
|
|
50
48
|
let id = s.id;
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
// 复合技能保持完全限定 ID,不剥离包名前缀
|
|
50
|
+
if (!isCompositeSkill && (target.targetPackageRoot || options.package)) {
|
|
51
|
+
const targetPkg = target.localSkill ? target.localSkill.packages[0].packageId : options.package;
|
|
52
|
+
const pkgId = targetPkg || s.packageId;
|
|
53
53
|
if (pkgId && id.startsWith(`${pkgId}/`)) {
|
|
54
54
|
id = id.slice(pkgId.length + 1);
|
|
55
55
|
}
|
|
56
|
-
else if (targetPackageRoot && id.includes("/")) {
|
|
56
|
+
else if (target.targetPackageRoot && id.includes("/")) {
|
|
57
57
|
id = id.slice(id.indexOf("/") + 1);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ export function attachListCommand(parent, context) {
|
|
|
80
80
|
}
|
|
81
81
|
const title = resolved.type === "remote"
|
|
82
82
|
? `Actions ${remoteTargetSuffix(resolved)}`
|
|
83
|
-
: targetPackageRoot
|
|
83
|
+
: target.targetPackageRoot
|
|
84
84
|
? `Actions in ${options.package || "current project"}`
|
|
85
85
|
: "Available Actions";
|
|
86
86
|
renderResult(filterRes.items, {
|
|
@@ -88,7 +88,7 @@ export function attachListCommand(parent, context) {
|
|
|
88
88
|
humanFormatter: () => renderActionList(filterRes.items, title, filterRes.isFallback, effectiveIntent),
|
|
89
89
|
context,
|
|
90
90
|
});
|
|
91
|
-
}, { localRoot: targetPackageRoot
|
|
91
|
+
}, { localRoot: target.targetPackageRoot, scanLinkedPackages: !target.localSkill });
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
/**
|
package/dist/commands/run.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { validateActionInputValue, mapInputValidationFailure, } from "@actiondock/core/project";
|
|
2
|
-
import { resolveTarget, } from "@actiondock/core/profile";
|
|
3
2
|
import { ACTION_NOT_FOUND, NOT_FOUND, resolveExecutionHint, } from "@actiondock/core";
|
|
4
|
-
import { ArgumentError, ExecutionError, SigintError
|
|
3
|
+
import { ArgumentError, ExecutionError, SigintError } from "../errors.js";
|
|
5
4
|
import { extractTextFieldPayload, resolveActionDefaultTextField, writeStderr, writeStdout, } from "../renderer.js";
|
|
6
|
-
import { applyTargetOptions, getEffectiveOptions, resolveActionInput,
|
|
5
|
+
import { applyTargetOptions, getEffectiveOptions, resolveActionInput, resolveCommandTarget, resolveTimeoutMs, withService, } from "../utils/index.js";
|
|
7
6
|
/**
|
|
8
7
|
* 以原始纯文本形式渲染 Action 执行终态结果(默认纯文本模式)。
|
|
9
8
|
*
|
|
@@ -111,25 +110,13 @@ export async function executeAction(id, options, context, flatArgs, control) {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
try {
|
|
113
|
+
// 目标拓扑与动作引用解析(远端目标完全隔离本地文件系统)
|
|
114
|
+
const target = resolveCommandTarget(options, context);
|
|
114
115
|
// 异步执行仅支持远端目标,本地模式直接拒绝
|
|
115
|
-
|
|
116
|
-
profile: options.profile,
|
|
117
|
-
server: options.server,
|
|
118
|
-
token: options.token,
|
|
119
|
-
insecure: options.insecure,
|
|
120
|
-
}, context?.customHome);
|
|
121
|
-
if (resolvedTopology.type === "local" && options.async) {
|
|
116
|
+
if (!target.isRemote && options.async) {
|
|
122
117
|
throw new ExecutionError("Async execution requires a long-running ActionDock server.\nUse --profile, --server, or start 'ad serve'.");
|
|
123
118
|
}
|
|
124
|
-
|
|
125
|
-
const targetPackageRoot = resolveLocalPackageRoot(options.package);
|
|
126
|
-
if (options.package && !targetPackageRoot) {
|
|
127
|
-
throw packageNotFoundError(options.package);
|
|
128
|
-
}
|
|
129
|
-
let targetRef = id;
|
|
130
|
-
if (options.package && !id.includes("/")) {
|
|
131
|
-
targetRef = `${options.package}/${id}`;
|
|
132
|
-
}
|
|
119
|
+
const targetRef = target.resolveActionRef(id);
|
|
133
120
|
// 通过 Service 统一执行
|
|
134
121
|
await withService(options, context, async (service) => {
|
|
135
122
|
const isMachine = Boolean(options.json);
|
|
@@ -205,7 +192,7 @@ export async function executeAction(id, options, context, flatArgs, control) {
|
|
|
205
192
|
return;
|
|
206
193
|
}
|
|
207
194
|
}
|
|
208
|
-
}, { localRoot: targetPackageRoot || undefined, scanLinkedPackages:
|
|
195
|
+
}, { localRoot: target.targetPackageRoot || undefined, scanLinkedPackages: !target.localSkill, ownDataDir: true });
|
|
209
196
|
}
|
|
210
197
|
catch (err) {
|
|
211
198
|
// sigint 取消源、中断链路特征错误码或 SigintError 本身,均统一归并为 SigintError
|
package/dist/commands/state.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { decodeStateKey, } from "@actiondock/sdk";
|
|
2
|
-
import { loadProjectConfig, } from "@actiondock/core";
|
|
2
|
+
import { loadProjectConfig, inspectLocalPackageDirectory, } from "@actiondock/core";
|
|
3
3
|
import { filterWithFallbackInfo, } from "@actiondock/core/project";
|
|
4
4
|
import { listLinkedPackages, } from "@actiondock/core/registry";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { ArgumentError, ExecutionError, NO_PROJECT_NO_LINKED_MESSAGE } from "../errors.js";
|
|
7
7
|
import { renderResult, renderStateList, writeStderr, writeStdout } from "../renderer.js";
|
|
8
|
-
import { applyTargetOptions, getEffectiveOptions, getTargetRoot, remoteTargetLabel, requirePackageRoot, resolveFallbackStrategy, resolveIntent, resolveLocalPackageRoot, resolveTargetFromOptions, withService, } from "../utils/index.js";
|
|
8
|
+
import { applyTargetOptions, assertNotCompositeSkill, getEffectiveOptions, getTargetRoot, remoteTargetLabel, requirePackageRoot, resolveFallbackStrategy, resolveIntent, resolveLocalPackageRoot, resolveTargetFromOptions, withService, } from "../utils/index.js";
|
|
9
9
|
/**
|
|
10
10
|
* 统一预解码状态键寻址(get、set、delete 共享的单一事实源)。
|
|
11
11
|
*
|
|
@@ -57,6 +57,22 @@ function resolveStateScope(resolved, options, rawKey) {
|
|
|
57
57
|
localRoot: undefined,
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
+
assertNotCompositeSkill(options.package);
|
|
61
|
+
// 本地单包技能目录优先处理
|
|
62
|
+
if (options.package) {
|
|
63
|
+
const localSkill = inspectLocalPackageDirectory(options.package);
|
|
64
|
+
if (localSkill?.type === "single") {
|
|
65
|
+
const pkg = localSkill.packages[0];
|
|
66
|
+
return {
|
|
67
|
+
packageId: pkg.packageId,
|
|
68
|
+
scopeSuffix: `in package '${pkg.packageId}'`,
|
|
69
|
+
deleteSuffix: `from package '${pkg.packageId}'`,
|
|
70
|
+
effectiveKey: rawKey || "",
|
|
71
|
+
projConfig: pkg.projectConfig,
|
|
72
|
+
localRoot: pkg.packageRoot,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
60
76
|
// 本地项目模式:getTargetRoot 会从键中剥离 pkg/ 前缀,寻址基于解耦后的裸键
|
|
61
77
|
const { root, key: effectiveKey } = getTargetRoot(options.package, rawKey);
|
|
62
78
|
const projConfig = loadProjectConfig(root);
|
|
@@ -175,6 +191,7 @@ export function registerStateCommands(program, context) {
|
|
|
175
191
|
return;
|
|
176
192
|
}
|
|
177
193
|
// 本地工程与链接包模式:按目标根目录决策输出范围
|
|
194
|
+
assertNotCompositeSkill(options.package);
|
|
178
195
|
const targetRoot = options.package
|
|
179
196
|
? requirePackageRoot(options.package).root
|
|
180
197
|
: resolveLocalPackageRoot();
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/dist/utils/target.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionDockService } from "@actiondock/core";
|
|
1
|
+
import { loadProjectConfig, type ActionDockService, type LocalSkillDirectory } from "@actiondock/core";
|
|
2
2
|
import { type ResolvedTarget } from "@actiondock/core/profile";
|
|
3
3
|
import type { Command } from "commander";
|
|
4
4
|
import type { CliContext } from "../types.js";
|
|
@@ -33,14 +33,68 @@ export interface TargetResolutionOptions {
|
|
|
33
33
|
/**
|
|
34
34
|
* 目标拓扑解析单一入口:从命令选项视图解析远端/本地目标拓扑信息。
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* 显式路径与包标识符分类规则:
|
|
37
|
+
* - 显式路径形态(以 .、/、~ 开头或包含非 scoped 分隔符):
|
|
38
|
+
* 严格作为本地技能或包目录解析;禁止与显式远端选项(--server 或非 local 的 --profile)组合,违规抛出 ArgumentError;
|
|
39
|
+
* 不受隐式 Profile 或 ACTIONDOCK_SERVER_URL 环境变量改变目标,本地执行优先;
|
|
40
|
+
* 若本地目录不存在或不合法,抛出 packageNotFoundError;
|
|
41
|
+
* - 纯词法包标识符(如 pkg.a、@scope/pkg):
|
|
42
|
+
* 若存在远端目标(显式 --server、非 local profile 或默认远端环境),严格作为远端包标识解析,绝不因本地 cwd 存在同名目录而劫持为本地执行;
|
|
43
|
+
* 若无远端目标,正常按本地目标解析。
|
|
38
44
|
*
|
|
39
45
|
* @param options 命令选项视图(支持直接传入 Commander 解析后的 options 对象)
|
|
40
46
|
* @param context CLI 上下文
|
|
41
47
|
* @returns 解析后的目标拓扑信息(仅信息解析,不创建 Service 实例)
|
|
42
48
|
*/
|
|
43
49
|
export declare function resolveTargetFromOptions(options: TargetResolutionOptions, context?: CliContext): ResolvedTarget;
|
|
50
|
+
/**
|
|
51
|
+
* 命令目标与动作引用解析结果。
|
|
52
|
+
*/
|
|
53
|
+
export interface CommandTargetResolution {
|
|
54
|
+
/** 目标拓扑信息 */
|
|
55
|
+
resolved: ResolvedTarget;
|
|
56
|
+
/** 是否为远端目标 */
|
|
57
|
+
isRemote: boolean;
|
|
58
|
+
/** 本地封闭技能目录视图(非本地技能目录时为 null) */
|
|
59
|
+
localSkill: LocalSkillDirectory | null;
|
|
60
|
+
/** 本地包根目录路径(远端分支为 undefined,未找到为 undefined) */
|
|
61
|
+
targetPackageRoot?: string;
|
|
62
|
+
/** 统一计算目标 Action 引用的辅助函数 */
|
|
63
|
+
resolveActionRef: (actionId: string) => string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 统一解析 CLI 命令的目标拓扑与包作用域(run, describe, list 等命令的单一事实源)。
|
|
67
|
+
*
|
|
68
|
+
* 保证:
|
|
69
|
+
* - 优先判定目标拓扑;
|
|
70
|
+
* - 远端目标(remote)完全隔离:不执行任何本地目录探测、清单加载或包根寻址;
|
|
71
|
+
* - 远端目标动作引用保持原始词法包 ID 拼接(${options.package}/${actionId}),绝不被本地同名目录或清单 ID 篡改;
|
|
72
|
+
* - 本地目标按本地封闭技能目录或工程包严格解析,不存在时透明抛出 packageNotFoundError。
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveCommandTarget(options: TargetResolutionOptions, context?: CliContext): CommandTargetResolution;
|
|
75
|
+
/**
|
|
76
|
+
* 配置与状态管理目标作用域。
|
|
77
|
+
*/
|
|
78
|
+
export interface TargetPackageScope {
|
|
79
|
+
/** 解析后的目标拓扑 */
|
|
80
|
+
resolved: ResolvedTarget;
|
|
81
|
+
/** 是否为远端目标 */
|
|
82
|
+
isRemote: boolean;
|
|
83
|
+
/** 目标包标识(远端为 options.package 原值,本地为工程配置 id 或 "global") */
|
|
84
|
+
packageId: string;
|
|
85
|
+
/** 本地工程根目录(远端分支为 undefined) */
|
|
86
|
+
root?: string;
|
|
87
|
+
/** 本地工程配置(远端分支为 undefined) */
|
|
88
|
+
projConfig?: ReturnType<typeof loadProjectConfig>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 校验并拒绝复合技能目录用于配置或状态管理命令(单一事实源)。
|
|
92
|
+
*/
|
|
93
|
+
export declare function assertNotCompositeSkill(packageOption?: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* 统一解析配置与状态命令的目标作用域(支持单包技能目录、本地工程、远端服务与 --profile local)。
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveTargetPackageScope(options: TargetResolutionOptions, context?: CliContext): TargetPackageScope;
|
|
44
98
|
/**
|
|
45
99
|
* 高阶服务执行辅助:统一封装「目标解析 → Service 创建 → 业务回调 → try/finally close」样板。
|
|
46
100
|
*
|
package/dist/utils/target.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { connectActionDock, createActionDock, createNodePlatform, findProjectRoot, } from "@actiondock/core";
|
|
1
|
+
import { connectActionDock, createActionDock, createNodePlatform, findProjectRoot, inspectLocalPackageDirectory, isExplicitPath, loadProjectConfig, } from "@actiondock/core";
|
|
2
2
|
import { resolvePackageRoot, } from "@actiondock/core/registry";
|
|
3
3
|
import { resolveTarget, } from "@actiondock/core/profile";
|
|
4
|
-
import { ArgumentError } from "../errors.js";
|
|
4
|
+
import { ArgumentError, packageNotFoundError } from "../errors.js";
|
|
5
5
|
/**
|
|
6
6
|
* 统一为 Commander 命令节点挂载目标环境解析相关选项(单一事实源)。
|
|
7
7
|
* 包括:-p/--profile, -s/--server, -t/--token, -k/--insecure, --allow-insecure-http。
|
|
@@ -20,14 +20,36 @@ export function applyTargetOptions(command) {
|
|
|
20
20
|
/**
|
|
21
21
|
* 目标拓扑解析单一入口:从命令选项视图解析远端/本地目标拓扑信息。
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* 显式路径与包标识符分类规则:
|
|
24
|
+
* - 显式路径形态(以 .、/、~ 开头或包含非 scoped 分隔符):
|
|
25
|
+
* 严格作为本地技能或包目录解析;禁止与显式远端选项(--server 或非 local 的 --profile)组合,违规抛出 ArgumentError;
|
|
26
|
+
* 不受隐式 Profile 或 ACTIONDOCK_SERVER_URL 环境变量改变目标,本地执行优先;
|
|
27
|
+
* 若本地目录不存在或不合法,抛出 packageNotFoundError;
|
|
28
|
+
* - 纯词法包标识符(如 pkg.a、@scope/pkg):
|
|
29
|
+
* 若存在远端目标(显式 --server、非 local profile 或默认远端环境),严格作为远端包标识解析,绝不因本地 cwd 存在同名目录而劫持为本地执行;
|
|
30
|
+
* 若无远端目标,正常按本地目标解析。
|
|
25
31
|
*
|
|
26
32
|
* @param options 命令选项视图(支持直接传入 Commander 解析后的 options 对象)
|
|
27
33
|
* @param context CLI 上下文
|
|
28
34
|
* @returns 解析后的目标拓扑信息(仅信息解析,不创建 Service 实例)
|
|
29
35
|
*/
|
|
30
36
|
export function resolveTargetFromOptions(options, context) {
|
|
37
|
+
const isExplicit = options.package ? isExplicitPath(options.package) : false;
|
|
38
|
+
if (isExplicit) {
|
|
39
|
+
const hasExplicitServer = Boolean(options.server && options.server.trim());
|
|
40
|
+
const hasExplicitProfile = Boolean(options.profile && options.profile.trim() && options.profile.trim() !== "local");
|
|
41
|
+
if (hasExplicitServer || hasExplicitProfile) {
|
|
42
|
+
throw new ArgumentError("Cannot combine local package/skill directory with remote target options (--server or --profile). Specify a package ID for remote targets, or remove remote target options for local directory execution.");
|
|
43
|
+
}
|
|
44
|
+
const localSkill = inspectLocalPackageDirectory(options.package);
|
|
45
|
+
if (!localSkill) {
|
|
46
|
+
throw packageNotFoundError(options.package);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
type: "local",
|
|
50
|
+
profileName: "local",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
31
53
|
return resolveTarget({
|
|
32
54
|
profile: options.profile,
|
|
33
55
|
server: options.server,
|
|
@@ -36,6 +58,143 @@ export function resolveTargetFromOptions(options, context) {
|
|
|
36
58
|
allowInsecureHttp: options.allowInsecureHttp,
|
|
37
59
|
}, context?.customHome);
|
|
38
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* 统一解析 CLI 命令的目标拓扑与包作用域(run, describe, list 等命令的单一事实源)。
|
|
63
|
+
*
|
|
64
|
+
* 保证:
|
|
65
|
+
* - 优先判定目标拓扑;
|
|
66
|
+
* - 远端目标(remote)完全隔离:不执行任何本地目录探测、清单加载或包根寻址;
|
|
67
|
+
* - 远端目标动作引用保持原始词法包 ID 拼接(${options.package}/${actionId}),绝不被本地同名目录或清单 ID 篡改;
|
|
68
|
+
* - 本地目标按本地封闭技能目录或工程包严格解析,不存在时透明抛出 packageNotFoundError。
|
|
69
|
+
*/
|
|
70
|
+
export function resolveCommandTarget(options, context) {
|
|
71
|
+
const resolved = resolveTargetFromOptions(options, context);
|
|
72
|
+
if (resolved.type === "remote") {
|
|
73
|
+
return {
|
|
74
|
+
resolved,
|
|
75
|
+
isRemote: true,
|
|
76
|
+
localSkill: null,
|
|
77
|
+
targetPackageRoot: undefined,
|
|
78
|
+
resolveActionRef: (actionId) => {
|
|
79
|
+
if (options.package && !actionId.includes("/")) {
|
|
80
|
+
return `${options.package}/${actionId}`;
|
|
81
|
+
}
|
|
82
|
+
return actionId;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// 本地分支
|
|
87
|
+
const localSkill = options.package ? inspectLocalPackageDirectory(options.package) : null;
|
|
88
|
+
const targetPackageRoot = localSkill
|
|
89
|
+
? localSkill.root
|
|
90
|
+
: options.package
|
|
91
|
+
? resolveLocalPackageRoot(options.package)
|
|
92
|
+
: findProjectRoot();
|
|
93
|
+
if (options.package && !targetPackageRoot) {
|
|
94
|
+
throw packageNotFoundError(options.package);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
resolved,
|
|
98
|
+
isRemote: false,
|
|
99
|
+
localSkill,
|
|
100
|
+
targetPackageRoot: targetPackageRoot || undefined,
|
|
101
|
+
resolveActionRef: (actionId) => {
|
|
102
|
+
if (!options.package)
|
|
103
|
+
return actionId;
|
|
104
|
+
if (localSkill) {
|
|
105
|
+
if (localSkill.type === "single" && !actionId.includes("/")) {
|
|
106
|
+
return `${localSkill.packages[0].packageId}/${actionId}`;
|
|
107
|
+
}
|
|
108
|
+
// 复合技能短名不拼目录名,保持 actionId 供 Host resolveAction 裁决唯一匹配或多包歧义
|
|
109
|
+
return actionId;
|
|
110
|
+
}
|
|
111
|
+
if (!actionId.includes("/")) {
|
|
112
|
+
return `${options.package}/${actionId}`;
|
|
113
|
+
}
|
|
114
|
+
return actionId;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 校验并拒绝复合技能目录用于配置或状态管理命令(单一事实源)。
|
|
120
|
+
*/
|
|
121
|
+
export function assertNotCompositeSkill(packageOption) {
|
|
122
|
+
if (!packageOption)
|
|
123
|
+
return;
|
|
124
|
+
const localSkill = inspectLocalPackageDirectory(packageOption);
|
|
125
|
+
if (localSkill?.type === "composite") {
|
|
126
|
+
throw new ArgumentError("Multi-package entries do not support config/state management; configure actions using --config and --data-dir.");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 统一解析配置与状态命令的目标作用域(支持单包技能目录、本地工程、远端服务与 --profile local)。
|
|
131
|
+
*/
|
|
132
|
+
export function resolveTargetPackageScope(options, context) {
|
|
133
|
+
// 1. 目标拓扑解析
|
|
134
|
+
const resolved = resolveTargetFromOptions(options, context);
|
|
135
|
+
// 2. 远端分支:直接消费 options.package,不触碰本地文件系统
|
|
136
|
+
if (resolved.type === "remote") {
|
|
137
|
+
return {
|
|
138
|
+
resolved,
|
|
139
|
+
isRemote: true,
|
|
140
|
+
packageId: options.package || "",
|
|
141
|
+
root: undefined,
|
|
142
|
+
projConfig: undefined,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
// 3. 复合技能目录守卫(单一事实源)仅在本地分支生效
|
|
146
|
+
assertNotCompositeSkill(options.package);
|
|
147
|
+
// 4. 本地分支:统一解析单包目录、工程包或全局作用域
|
|
148
|
+
if (options.package) {
|
|
149
|
+
const localSkill = inspectLocalPackageDirectory(options.package);
|
|
150
|
+
if (localSkill?.type === "single") {
|
|
151
|
+
const pkg = localSkill.packages[0];
|
|
152
|
+
return {
|
|
153
|
+
resolved,
|
|
154
|
+
isRemote: false,
|
|
155
|
+
packageId: pkg.packageId,
|
|
156
|
+
root: pkg.packageRoot,
|
|
157
|
+
projConfig: pkg.projectConfig,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const root = resolveLocalPackageRoot(options.package);
|
|
161
|
+
if (!root) {
|
|
162
|
+
throw packageNotFoundError(options.package);
|
|
163
|
+
}
|
|
164
|
+
const projConfig = loadProjectConfig(root);
|
|
165
|
+
return {
|
|
166
|
+
resolved,
|
|
167
|
+
isRemote: false,
|
|
168
|
+
packageId: projConfig.id,
|
|
169
|
+
root,
|
|
170
|
+
projConfig,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// 未指定 -P:当前目录工程探测
|
|
174
|
+
const root = findProjectRoot();
|
|
175
|
+
if (root) {
|
|
176
|
+
try {
|
|
177
|
+
const projConfig = loadProjectConfig(root);
|
|
178
|
+
return {
|
|
179
|
+
resolved,
|
|
180
|
+
isRemote: false,
|
|
181
|
+
packageId: projConfig.id,
|
|
182
|
+
root,
|
|
183
|
+
projConfig,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
// 当前目录配置损坏时仍允许全局操作
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
resolved,
|
|
192
|
+
isRemote: false,
|
|
193
|
+
packageId: "global",
|
|
194
|
+
root: undefined,
|
|
195
|
+
projConfig: undefined,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
39
198
|
/**
|
|
40
199
|
* 高阶服务执行辅助:统一封装「目标解析 → Service 创建 → 业务回调 → try/finally close」样板。
|
|
41
200
|
*
|
|
@@ -56,10 +215,13 @@ export async function withService(options, context, fn, localOptions) {
|
|
|
56
215
|
if (localOptions?.requireRemote && resolved.type === "local") {
|
|
57
216
|
throw new ArgumentError("'ad runs cancel' is only supported for remote execution targets. Use --profile <name> or --server <url>.");
|
|
58
217
|
}
|
|
218
|
+
const localSkill = resolved.type === "local" && options.package
|
|
219
|
+
? inspectLocalPackageDirectory(options.package)
|
|
220
|
+
: null;
|
|
59
221
|
// localRoot 仅在 local 分支求值,避免远端模式下触发包寻址副作用
|
|
60
|
-
const localRoot = resolved.type === "local"
|
|
222
|
+
const localRoot = resolved.type === "local" && !localSkill
|
|
61
223
|
? (typeof localOptions?.localRoot === "function" ? localOptions.localRoot() : localOptions?.localRoot) ??
|
|
62
|
-
findProjectRoot() ??
|
|
224
|
+
(options.package ? resolveLocalPackageRoot(options.package) : findProjectRoot()) ??
|
|
63
225
|
undefined
|
|
64
226
|
: undefined;
|
|
65
227
|
const recoverOrphans = localOptions?.recoverOrphans ?? (localOptions?.ownDataDir === true);
|
|
@@ -70,20 +232,38 @@ export async function withService(options, context, fn, localOptions) {
|
|
|
70
232
|
insecure: resolved.insecure,
|
|
71
233
|
allowInsecureHttp: resolved.allowInsecureHttp ?? options.allowInsecureHttp,
|
|
72
234
|
})
|
|
73
|
-
:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
235
|
+
: localSkill
|
|
236
|
+
? await createActionDock({
|
|
237
|
+
type: "local",
|
|
238
|
+
packages: localSkill.packages.map((pkg) => ({
|
|
239
|
+
packageRoot: pkg.packageRoot,
|
|
240
|
+
projectConfig: pkg.projectConfig,
|
|
241
|
+
dataDir: options.dataDir || context?.dataDir,
|
|
242
|
+
})),
|
|
243
|
+
customHome: context?.customHome,
|
|
244
|
+
dataDir: options.dataDir || context?.dataDir,
|
|
245
|
+
platform: createNodePlatform({
|
|
246
|
+
customHome: context?.customHome,
|
|
247
|
+
dataDir: options.dataDir || context?.dataDir,
|
|
248
|
+
}),
|
|
249
|
+
autoLoadCurrentProject: false,
|
|
250
|
+
scanLinkedPackages: false,
|
|
251
|
+
recoverOrphans,
|
|
252
|
+
})
|
|
253
|
+
: await createActionDock({
|
|
254
|
+
type: "local",
|
|
255
|
+
projectRoot: localRoot,
|
|
79
256
|
customHome: context?.customHome,
|
|
80
257
|
dataDir: options.dataDir || context?.dataDir,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
258
|
+
platform: createNodePlatform({
|
|
259
|
+
customHome: context?.customHome,
|
|
260
|
+
dataDir: options.dataDir || context?.dataDir,
|
|
261
|
+
}),
|
|
262
|
+
...(localOptions?.scanLinkedPackages !== undefined
|
|
263
|
+
? { scanLinkedPackages: localOptions.scanLinkedPackages }
|
|
264
|
+
: undefined),
|
|
265
|
+
recoverOrphans,
|
|
266
|
+
});
|
|
87
267
|
try {
|
|
88
268
|
await fn(service, resolved);
|
|
89
269
|
}
|
|
@@ -97,6 +277,10 @@ export async function withService(options, context, fn, localOptions) {
|
|
|
97
277
|
*/
|
|
98
278
|
export function resolveLocalPackageRoot(pkgId) {
|
|
99
279
|
if (pkgId) {
|
|
280
|
+
const localSkill = inspectLocalPackageDirectory(pkgId);
|
|
281
|
+
if (localSkill) {
|
|
282
|
+
return localSkill.root;
|
|
283
|
+
}
|
|
100
284
|
return resolvePackageRoot(pkgId);
|
|
101
285
|
}
|
|
102
286
|
return findProjectRoot();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actiondock/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.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,10 +34,10 @@
|
|
|
34
34
|
"test": "node ../../scripts/run-tests.ts"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@actiondock/builder": "^2.
|
|
38
|
-
"@actiondock/core": "^2.
|
|
39
|
-
"@actiondock/mcp": "^2.
|
|
40
|
-
"@actiondock/sdk": "^2.
|
|
37
|
+
"@actiondock/builder": "^2.14.0",
|
|
38
|
+
"@actiondock/core": "^2.14.0",
|
|
39
|
+
"@actiondock/mcp": "^2.14.0",
|
|
40
|
+
"@actiondock/sdk": "^2.14.0",
|
|
41
41
|
"commander": "^13.1.0",
|
|
42
42
|
"selfsigned": "^5.5.0"
|
|
43
43
|
},
|
package/dist/utils/warning.d.ts
DELETED
package/dist/utils/warning.js
DELETED