@actiondock/cli 2.15.0 → 2.16.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.
@@ -1,6 +1,8 @@
1
- import { ArgumentError } from "../../errors.js";
1
+ import { loadProjectConfig, } from "@actiondock/core";
2
+ import { resolvePackageRoot, } from "@actiondock/core/registry";
3
+ import { ArgumentError, packageNotFoundError } from "../../errors.js";
2
4
  import { writeStdout } from "../../renderer.js";
3
- import { applyTargetOptions, getEffectiveOptions, resolveTargetPackageScope, withService, } from "../../utils/index.js";
5
+ import { applyTargetOptions, getEffectiveOptions, withService } from "../../utils/index.js";
4
6
  /**
5
7
  * 注册 config delete 子命令:删除配置项。
6
8
  *
@@ -20,22 +22,31 @@ export function registerConfigDeleteCommand(configCmd, context) {
20
22
  if (!key) {
21
23
  throw new ArgumentError("Configuration key is required");
22
24
  }
23
- const scope = resolveTargetPackageScope(options, context);
25
+ const root = resolvePackageRoot(options.package);
24
26
  await withService(options, context, async (service, resolved) => {
25
27
  if (resolved.type === "remote") {
26
- await service.management?.config.delete(scope.packageId, key);
28
+ await service.management?.config.delete(options.package || "", key);
27
29
  writeStdout(`[OK] Configuration '${key}' deleted from remote server`, context);
28
30
  return;
29
31
  }
30
- if (options.global || (!scope.root && !options.package)) {
32
+ if (options.global) {
31
33
  await service.management?.config.delete("global", key);
32
34
  writeStdout(`[OK] Global configuration '${key}' deleted`, context);
33
35
  return;
34
36
  }
35
- await service.management?.config.delete(scope.packageId, key);
36
- writeStdout(`[OK] Configuration '${key}' deleted for package '${scope.packageId}'`, context);
37
+ if (!root) {
38
+ if (options.package) {
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);
37
48
  },
38
49
  // 按实际查询范围打开存储:显式包寻址结果作为本地根目录传递
39
- { localRoot: scope.root });
50
+ { localRoot: root || undefined });
40
51
  });
41
52
  }
@@ -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, assertNotCompositeSkill, getEffectiveOptions, requirePackageRoot, resolveTargetFromOptions, } from "../../utils/index.js";
5
+ import { applyTargetOptions, 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
- // 1. 目标拓扑解析(远端服务分支完全隔离本地文件系统)
21
+ // 远端服务分支直接查询远端配置环境诊断接口
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,7 +37,6 @@ export function registerConfigEnvCommand(configCmd, context) {
37
37
  return;
38
38
  }
39
39
  // 本地项目分支
40
- assertNotCompositeSkill(targetPkg);
41
40
  const { root, projConfig } = requirePackageRoot(targetPkg, {
42
41
  loadConfig: true,
43
42
  hint: "Usage: ad config env [package-id] or cd into a project directory.",
@@ -1,10 +1,11 @@
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 { ArgumentError } from "../../errors.js";
4
+ import { resolvePackageRoot, } from "@actiondock/core/registry";
5
+ import { ArgumentError, packageNotFoundError } from "../../errors.js";
5
6
  import { renderResult } from "../../renderer.js";
6
7
  import { resolveMergedConfigEntry } from "../../services/config-merge.js";
7
- import { applyTargetOptions, getEffectiveOptions, resolveTargetPackageScope, withService, } from "../../utils/index.js";
8
+ import { applyTargetOptions, getEffectiveOptions, resolveTargetFromOptions, withService, } from "../../utils/index.js";
8
9
  /**
9
10
  * 注册 config get 子命令:查询指定配置键的生效值。
10
11
  *
@@ -26,11 +27,12 @@ export function registerConfigGetCommand(configCmd, context) {
26
27
  throw new ArgumentError("Configuration key is required");
27
28
  }
28
29
  const reveal = Boolean(options.reveal || options.showSecrets);
29
- const scope = resolveTargetPackageScope(options, context);
30
- if (scope.isRemote) {
31
- const res = await fetchRemoteConfig(scope.resolved.serverUrl, scope.resolved.token, scope.packageId, {
30
+ // 远端服务分支不经过 Target 门面,直接查询远端配置接口
31
+ const target = resolveTargetFromOptions(options, context);
32
+ if (target.type === "remote") {
33
+ const res = await fetchRemoteConfig(target.serverUrl, target.token, options.package, {
32
34
  allowInsecureHttp: Boolean(options.allowInsecureHttp),
33
- insecure: scope.resolved.insecure,
35
+ insecure: target.insecure,
34
36
  });
35
37
  const val = res.values?.[key];
36
38
  const isSecret = isSecretConfigKey(key, res.declared?.[key]);
@@ -48,8 +50,13 @@ export function registerConfigGetCommand(configCmd, context) {
48
50
  });
49
51
  return;
50
52
  }
53
+ // 本地分支
54
+ const root = resolvePackageRoot(options.package);
51
55
  await withService(options, context, async (service) => {
52
- if (options.global || !scope.root) {
56
+ if (options.global || !root) {
57
+ if (!options.global && options.package && !root) {
58
+ throw packageNotFoundError(options.package);
59
+ }
53
60
  const confView = await service.management?.config.get("global", key);
54
61
  const val = confView?.value;
55
62
  const isSecret = confView?.secret ?? isSecretConfigKey(key);
@@ -67,10 +74,10 @@ export function registerConfigGetCommand(configCmd, context) {
67
74
  });
68
75
  return;
69
76
  }
70
- const projConfig = scope.projConfig || loadProjectConfig(scope.root);
77
+ const projConfig = loadProjectConfig(root);
71
78
  const declaredItem = projConfig.config?.[key];
72
79
  // 合并优先级链单一事实源:项目包级 > 全局持久化 > 环境变量 > 声明默认值
73
- const { value: displayValue, source, secret: isSecret } = await resolveMergedConfigEntry(key, scope.packageId, declaredItem, service, reveal);
80
+ const { value: displayValue, source, secret: isSecret } = await resolveMergedConfigEntry(key, projConfig.id, declaredItem, service, reveal);
74
81
  const payload = {
75
82
  key,
76
83
  value: displayValue,
@@ -84,6 +91,6 @@ export function registerConfigGetCommand(configCmd, context) {
84
91
  });
85
92
  },
86
93
  // 按实际查询范围打开存储:显式包寻址结果作为本地根目录传递
87
- { localRoot: scope.root });
94
+ { localRoot: root || undefined });
88
95
  });
89
96
  }
@@ -1,9 +1,10 @@
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";
4
5
  import { renderConfigList, renderResult } from "../../renderer.js";
5
6
  import { buildMergedConfigEntries } from "../../services/config-merge.js";
6
- import { applyTargetOptions, getEffectiveOptions, remoteTargetLabel, resolveFallbackStrategy, resolveIntent, resolveTargetPackageScope, withService, } from "../../utils/index.js";
7
+ import { applyTargetOptions, getEffectiveOptions, remoteTargetLabel, resolveFallbackStrategy, resolveIntent, resolveLocalPackageRoot, resolveTargetFromOptions, withService, } from "../../utils/index.js";
7
8
  /**
8
9
  * 构造单条配置项的展示视图(含掩码决策,reveal 为假且为敏感键时打码)。
9
10
  * 掩码决策收敛于命令层,renderer 仅负责值的字符串格式化。
@@ -41,24 +42,29 @@ export function registerConfigListCommand(configCmd, context) {
41
42
  const effectiveIntent = resolveIntent(options.intent, patterns);
42
43
  const { shouldFallback } = resolveFallbackStrategy(options);
43
44
  const reveal = Boolean(options.reveal || options.showSecrets);
44
- const scope = resolveTargetPackageScope(options, context);
45
- if (scope.isRemote) {
46
- const res = await fetchRemoteConfig(scope.resolved.serverUrl, scope.resolved.token, scope.packageId, {
45
+ // 远端服务分支不经过 Target 门面,直接查询远端配置接口
46
+ const remoteTargetInfo = resolveTargetFromOptions(options, context);
47
+ if (remoteTargetInfo.type === "remote") {
48
+ const res = await fetchRemoteConfig(remoteTargetInfo.serverUrl, remoteTargetInfo.token, options.package, {
47
49
  allowInsecureHttp: Boolean(options.allowInsecureHttp),
48
- insecure: scope.resolved.insecure,
50
+ insecure: remoteTargetInfo.insecure,
49
51
  });
50
52
  const entries = Object.entries(res.values || {}).map(([k, v]) => toDisplayEntry(k, v, "remote", isSecretConfigKey(k, res.declared?.[k]), reveal, res.declared?.[k]?.description || ""));
51
53
  renderResult(entries, {
52
54
  json: options.json,
53
- humanFormatter: () => renderConfigList(entries, remoteTargetLabel(scope.resolved), false, effectiveIntent),
55
+ humanFormatter: () => renderConfigList(entries, remoteTargetLabel(remoteTargetInfo), false, effectiveIntent),
54
56
  context,
55
57
  });
56
58
  return;
57
59
  }
58
60
  // 本地分支(通过 Service 门面统一访问):显式包寻址结果作为本地根目录传递(仅 local 分支求值)
59
61
  await withService(options, context, async (service) => {
62
+ const root = resolveLocalPackageRoot(options.package) || undefined;
60
63
  // 全局作用域分支:显式 --global 或无工程回退时仅列举全局配置
61
- if (options.global || !scope.root) {
64
+ if (options.global || !root) {
65
+ if (!options.global && options.package) {
66
+ throw packageNotFoundError(options.package);
67
+ }
62
68
  const all = (await service.management?.config.list("global")) ?? [];
63
69
  const entries = all.map((item) => toDisplayEntry(item.key, item.value, "global", item.secret || isSecretConfigKey(item.key), reveal));
64
70
  const filterRes = filterWithFallbackInfo(entries, effectiveIntent, [(c) => c.key, (c) => c.value], shouldFallback);
@@ -69,9 +75,9 @@ export function registerConfigListCommand(configCmd, context) {
69
75
  });
70
76
  return;
71
77
  }
72
- const projConfig = scope.projConfig || loadProjectConfig(scope.root);
78
+ const projConfig = loadProjectConfig(root);
73
79
  // 跨作用域合并视图单一事实源:项目包级 > 全局持久化 > 环境变量 > 声明默认值
74
- const merged = await buildMergedConfigEntries(scope.root, service, reveal);
80
+ const merged = await buildMergedConfigEntries(root, service, reveal);
75
81
  const filterRes = filterWithFallbackInfo(merged, effectiveIntent, [(c) => c.key, (c) => c.value, (c) => c.description, (c) => c.source], shouldFallback);
76
82
  renderResult(filterRes.items, {
77
83
  json: options.json,
@@ -79,7 +85,7 @@ export function registerConfigListCommand(configCmd, context) {
79
85
  context,
80
86
  });
81
87
  }, {
82
- localRoot: scope.root,
88
+ localRoot: () => resolveLocalPackageRoot(options.package) || undefined,
83
89
  });
84
90
  });
85
91
  }
@@ -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, assertNotCompositeSkill, getEffectiveOptions, requirePackageRoot, withService, } from "../../utils/index.js";
5
+ import { applyTargetOptions, getEffectiveOptions, requirePackageRoot, withService } from "../../utils/index.js";
6
6
  /**
7
7
  * 注册 config schema 子命令:检查声明配置的解析状态。
8
8
  *
@@ -25,18 +25,17 @@ 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
- }
33
28
  const targetPkg = identifier || options.package;
34
- assertNotCompositeSkill(targetPkg);
35
29
  const { root, projConfig } = requirePackageRoot(targetPkg, {
36
30
  loadConfig: true,
37
31
  hint: "Usage: ad config schema [package-id] or cd into a project directory.",
38
32
  });
39
33
  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
+ }
40
39
  // 跨作用域合并视图单一事实源:与 config list 共享同一条优先级链
41
40
  await withService(options, context, async (service) => {
42
41
  const merged = await buildMergedConfigEntries(root, service, true);
@@ -1,7 +1,9 @@
1
1
  import { isSecretConfigKey, } from "@actiondock/core/project";
2
- import { ArgumentError } from "../../errors.js";
2
+ import { loadProjectConfig, } from "@actiondock/core";
3
+ import { resolvePackageRoot, } from "@actiondock/core/registry";
4
+ import { ArgumentError, packageNotFoundError } from "../../errors.js";
3
5
  import { writeStdout } from "../../renderer.js";
4
- import { applyTargetOptions, getEffectiveOptions, resolveTargetPackageScope, withService, } from "../../utils/index.js";
6
+ import { applyTargetOptions, getEffectiveOptions, withService } from "../../utils/index.js";
5
7
  import { resolveConfigValueInput } from "../../prompt.js";
6
8
  /**
7
9
  * 注册 config set 子命令:写入配置值(支持标准输入与安全提示)。
@@ -22,8 +24,22 @@ export function registerConfigSetCommand(configCmd, context) {
22
24
  if (!key) {
23
25
  throw new ArgumentError("Configuration key is required");
24
26
  }
25
- const scope = resolveTargetPackageScope(options, context);
26
- const declaredDef = scope.projConfig?.config?.[key];
27
+ let root = null;
28
+ let projConfig = null;
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
+ }
27
43
  const isSecret = isSecretConfigKey(key, declaredDef);
28
44
  let effectiveValueStr = rawVal;
29
45
  if (effectiveValueStr === undefined || options.stdin) {
@@ -44,21 +60,27 @@ export function registerConfigSetCommand(configCmd, context) {
44
60
  // 目标解析与写入(远端分支直接写远端作用域,本地分支按全局/项目作用域写入)
45
61
  await withService(options, context, async (service, resolved) => {
46
62
  if (resolved.type === "remote") {
47
- await service.management?.config.set(scope.packageId, key, parsedVal);
63
+ await service.management?.config.set(options.package || "", key, parsedVal);
48
64
  writeStdout(`[OK] Configuration '${key}' updated on remote server`, context);
49
65
  return;
50
66
  }
51
- if (options.global || (!scope.root && !options.package)) {
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
+ }
52
76
  await service.management?.config.set("global", key, parsedVal);
53
- writeStdout(!scope.root && !options.package
54
- ? `[OK] Global configuration '${key}' updated (no project in current directory)`
55
- : `[OK] Global configuration '${key}' updated`, context);
77
+ writeStdout(`[OK] Global configuration '${key}' updated (no project in current directory)`, context);
56
78
  return;
57
79
  }
58
- await service.management?.config.set(scope.packageId, key, parsedVal);
59
- writeStdout(`[OK] Configuration '${key}' updated for package '${scope.packageId}'`, context);
80
+ await service.management?.config.set(projConfig.id, key, parsedVal);
81
+ writeStdout(`[OK] Configuration '${key}' updated for package '${projConfig.id}'`, context);
60
82
  },
61
83
  // 按实际查询范围打开存储:显式包寻址结果作为本地根目录传递
62
- { localRoot: scope.root });
84
+ { localRoot: root || undefined });
63
85
  });
64
86
  }
@@ -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 } from "../errors.js";
3
+ import { ArgumentError, ExecutionError, packageNotFoundError } from "../errors.js";
4
4
  import { formatActionDetail, renderResult } from "../renderer.js";
5
- import { applyTargetOptions, getEffectiveOptions, resolveCommandTarget, withService, } from "../utils/index.js";
5
+ import { applyTargetOptions, getEffectiveOptions, resolveLocalPackageRoot, withService, } from "../utils/index.js";
6
6
  /**
7
7
  * 挂载 describe 子命令至指定 Commander 节点。
8
8
  *
@@ -22,9 +22,12 @@ 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 target = resolveCommandTarget(options, context);
27
- const targetRef = target.resolveActionRef(id);
25
+ // 目标拓扑解析(仅 local 分支需要包寻址)
26
+ const targetPackageRoot = resolveLocalPackageRoot(options.package);
27
+ if (options.package && !targetPackageRoot) {
28
+ throw packageNotFoundError(options.package);
29
+ }
30
+ const targetRef = id;
28
31
  // 通过 Service 门面统一查询 Action 规范
29
32
  await withService(options, context, async (service) => {
30
33
  let spec;
@@ -47,7 +50,7 @@ export function attachDescribeCommand(parent, context) {
47
50
  humanFormatter: () => formatActionDetail(payload),
48
51
  context,
49
52
  });
50
- }, { localRoot: target.targetPackageRoot, scanLinkedPackages: !target.localSkill });
53
+ }, { localRoot: targetPackageRoot || undefined, scanLinkedPackages: true });
51
54
  });
52
55
  }
53
56
  /**
@@ -1,11 +1,10 @@
1
- import { isExplicitPath, } from "@actiondock/core";
2
- import { filterWithFallbackInfo, } from "@actiondock/core/project";
3
1
  import { fetchRemoteInfo, } from "@actiondock/core/profile";
2
+ import { filterWithFallbackInfo, } from "@actiondock/core/project";
4
3
  import { getRegistryStatus, resolvePackageRoot, } from "@actiondock/core/registry";
5
- import { ArgumentError, ExecutionError, NO_PROJECT_NO_LINKED_MESSAGE, packageNotFoundError } from "../errors.js";
6
- import { projectDetailToJson, renderAggregatedPackages, renderCompositeSkillDetail, renderProjectDetail, renderRegistryTree, renderResult, } from "../renderer.js";
7
- import { buildCompositeDetails, filterProjectDetails, getProjectDetailInfo, scanLocalAggregatedPackages, } from "../services/index.js";
8
- import { applyTargetOptions, getEffectiveOptions, resolveCommandTarget, resolveFallbackStrategy, resolveIntent, } from "../utils/index.js";
4
+ import { ExecutionError, NO_PROJECT_NO_LINKED_MESSAGE, packageNotFoundError } from "../errors.js";
5
+ import { projectDetailToJson, renderAggregatedPackages, renderProjectDetail, renderRegistryTree, renderResult, } from "../renderer.js";
6
+ import { getProjectDetailInfo, scanLocalAggregatedPackages } from "../services/index.js";
7
+ import { applyTargetOptions, getEffectiveOptions, resolveFallbackStrategy, resolveIntent, resolveTargetFromOptions, } from "../utils/index.js";
9
8
  /**
10
9
  * 将远端信息响应归一为本地工程详情视图。
11
10
  */
@@ -52,49 +51,9 @@ function remoteInfoToDetail(remoteInfo) {
52
51
  * 渲染工程详情输出(机器模式输出视图转换结果,人类模式渲染详情)。
53
52
  */
54
53
  function renderProjectDetailOutput(detail, options) {
55
- const { matchedCount, isFallback } = filterProjectDetails([detail], options.effectiveIntent, Boolean(options.shouldFallback));
56
- if (matchedCount === 0 && !isFallback) {
57
- if (options.isMachine) {
58
- renderResult({ root: detail.projectRoot, packages: [], matchedCount: 0, isFallback: false }, options);
59
- return;
60
- }
61
- throw new ExecutionError(`No packages matched intent '${options.effectiveIntent}'`);
62
- }
63
- renderResult({
64
- ...projectDetailToJson(detail),
65
- ...(options.effectiveIntent ? { matchedCount, isFallback } : {}),
66
- }, {
67
- json: options.json,
68
- humanFormatter: () => (isFallback ? `(No packages matched intent '${options.effectiveIntent}', showing selected package)\n\n` : "") +
69
- renderProjectDetail(detail),
70
- context: options.context,
71
- });
72
- }
73
- /**
74
- * 渲染复合技能整体输出(机器模式输出聚合结构,人类模式渲染各子包卡片)。
75
- */
76
- function renderCompositeSkillOutput(root, details, options) {
77
- const outOpts = { json: options.json, context: options.context };
78
- const { items: filteredDetails, isFallback, matchedCount } = filterProjectDetails(details, options.effectiveIntent, Boolean(options.shouldFallback));
79
- if (options.effectiveIntent && matchedCount === 0 && !isFallback) {
80
- if (options.isMachine) {
81
- renderResult({ root, packages: [], matchedCount: 0, isFallback: false }, outOpts);
82
- return;
83
- }
84
- throw new ExecutionError(`No packages matched intent '${options.effectiveIntent}' in skill directory`);
85
- }
86
- if (options.isMachine) {
87
- const machineResult = {
88
- root,
89
- packages: filteredDetails.map(projectDetailToJson),
90
- ...(options.effectiveIntent ? { matchedCount, isFallback } : {}),
91
- };
92
- renderResult(machineResult, outOpts);
93
- return;
94
- }
95
- renderResult(filteredDetails, {
54
+ renderResult(projectDetailToJson(detail), {
96
55
  json: options.json,
97
- humanFormatter: () => renderCompositeSkillDetail(root, filteredDetails, isFallback, options.effectiveIntent),
56
+ humanFormatter: () => renderProjectDetail(detail),
98
57
  context: options.context,
99
58
  });
100
59
  }
@@ -118,25 +77,18 @@ export function registerInfoCommand(program, context) {
118
77
  .option("--data-dir <path>", "Custom database storage directory")
119
78
  .action(async (patterns = [], rawOptions, cmd) => {
120
79
  const options = getEffectiveOptions(rawOptions, cmd);
121
- // 唯一显式路径位置参数属于寻址目标,必须先于远端与树状图分支裁决。
122
- if (!options.package && !options.intent && patterns.length === 1 && isExplicitPath(patterns[0])) {
123
- options.package = patterns[0];
124
- patterns = [];
125
- }
126
80
  const effectiveIntent = resolveIntent(options.intent, patterns);
127
81
  const { isMachine, shouldFallback } = resolveFallbackStrategy(options);
128
82
  const outOpts = { json: options.json, context };
129
- const detailOpts = { ...outOpts, effectiveIntent, shouldFallback, isMachine };
130
- // info 仅查询单包清单,复合目录仍保留封闭集合校验。
131
- const target = resolveCommandTarget(options, context, { metadataOnly: true });
132
83
  // 远端服务目标分支
133
- if (target.isRemote) {
134
- const remoteInfo = await fetchRemoteInfo(target.resolved.serverUrl, target.resolved.token, {
84
+ const target = resolveTargetFromOptions(options, context);
85
+ if (target.type === "remote") {
86
+ const remoteInfo = await fetchRemoteInfo(target.serverUrl, target.token, {
135
87
  intent: effectiveIntent,
136
88
  package: options.package,
137
89
  tree: Boolean(options.tree),
138
90
  allowInsecureHttp: Boolean(options.allowInsecureHttp),
139
- insecure: target.resolved.insecure,
91
+ insecure: target.insecure,
140
92
  });
141
93
  if (isMachine) {
142
94
  renderResult(remoteInfo, outOpts);
@@ -164,11 +116,8 @@ export function registerInfoCommand(program, context) {
164
116
  });
165
117
  return;
166
118
  }
167
- // 本地注册表树状图分支(若与显式技能或包组合,给出明确 ArgumentError)
119
+ // 本地注册表树状图分支
168
120
  if (options.tree) {
169
- if (options.package || target.localSkill) {
170
- throw new ArgumentError("Tree view (--tree) is not supported with explicit skill directories or packages; use 'ad info -P <path>' without --tree.");
171
- }
172
121
  const status = getRegistryStatus(context?.customHome);
173
122
  renderResult(status, {
174
123
  json: options.json,
@@ -177,30 +126,12 @@ export function registerInfoCommand(program, context) {
177
126
  });
178
127
  return;
179
128
  }
180
- // 显式复合技能分支
181
- if (target.localSkill?.type === "composite") {
182
- const details = await buildCompositeDetails(target.localSkill);
183
- renderCompositeSkillOutput(target.localSkill.root, details, {
184
- json: options.json,
185
- context,
186
- effectiveIntent,
187
- shouldFallback,
188
- isMachine,
189
- });
190
- return;
191
- }
192
- // 显式单包技能分支
193
- if (target.localSkill?.type === "single") {
194
- const pkg = target.localSkill.packages[0];
195
- const detail = await getProjectDetailInfo(pkg.packageRoot);
196
- renderProjectDetailOutput(detail, detailOpts);
197
- return;
198
- }
199
- // 显式指定 Package 参数分支(普通包 ID 或路径)
129
+ // 显式指定 Package 参数分支
200
130
  if (options.package) {
201
- if (target.targetPackageRoot) {
202
- const detail = await getProjectDetailInfo(target.targetPackageRoot);
203
- renderProjectDetailOutput(detail, detailOpts);
131
+ const directRoot = resolvePackageRoot(options.package);
132
+ if (directRoot) {
133
+ const detail = await getProjectDetailInfo(directRoot);
134
+ renderProjectDetailOutput(detail, outOpts);
204
135
  return;
205
136
  }
206
137
  throw packageNotFoundError(options.package);
@@ -232,18 +163,8 @@ export function registerInfoCommand(program, context) {
232
163
  }
233
164
  // 有关键字过滤场景:单一位置参数且非显式 --intent 时优先尝试包寻址
234
165
  if (patterns.length === 1 && !options.intent) {
235
- const directRoot = resolvePackageRoot(patterns[0], undefined, context?.customHome);
166
+ const directRoot = resolvePackageRoot(patterns[0]);
236
167
  if (directRoot) {
237
- const directTarget = resolveCommandTarget({ ...options, package: directRoot }, context, { metadataOnly: true });
238
- if (directTarget.localSkill?.type === "composite") {
239
- const details = await buildCompositeDetails(directTarget.localSkill);
240
- renderCompositeSkillOutput(directTarget.localSkill.root, details, {
241
- ...outOpts,
242
- shouldFallback,
243
- isMachine,
244
- });
245
- return;
246
- }
247
168
  const detail = await getProjectDetailInfo(directRoot);
248
169
  renderProjectDetailOutput(detail, outOpts);
249
170
  return;
@@ -1,6 +1,7 @@
1
1
  import { filterWithFallbackInfo, } from "@actiondock/core/project";
2
+ import { packageNotFoundError } from "../errors.js";
2
3
  import { renderActionList, renderResult } from "../renderer.js";
3
- import { applyTargetOptions, getEffectiveOptions, remoteTargetSuffix, resolveCommandTarget, resolveFallbackStrategy, resolveIntent, withService, } from "../utils/index.js";
4
+ import { applyTargetOptions, getEffectiveOptions, remoteTargetSuffix, resolveFallbackStrategy, resolveIntent, resolveLocalPackageRoot, withService, } from "../utils/index.js";
4
5
  /**
5
6
  * 挂载 list 子命令至指定 Commander 节点。
6
7
  *
@@ -22,20 +23,22 @@ export function attachListCommand(parent, context) {
22
23
  const options = getEffectiveOptions(rawOptions, cmd);
23
24
  const effectiveIntent = resolveIntent(options.intent, patterns);
24
25
  const { isMachine, shouldFallback } = resolveFallbackStrategy(options);
25
- // 目标拓扑与动作引用解析(远端目标完全隔离本地文件系统)
26
- const target = resolveCommandTarget(options, context);
26
+ // 目标拓扑解析(仅 local 分支需要包寻址)
27
+ const targetPackageRoot = resolveLocalPackageRoot(options.package);
28
+ if (options.package && !targetPackageRoot) {
29
+ throw packageNotFoundError(options.package);
30
+ }
27
31
  // 通过 Service 门面统一获取 Action 列表
28
32
  await withService(options, context, async (service, resolved) => {
29
33
  let rawSummaries = await service.discovery.listActions();
30
- // 若指定了包 ID(非本地技能目录),则按包归属精确过滤(本地与远端统一生效):
34
+ // 若指定了目标包但本地未过滤,则按包归属精确过滤:
31
35
  // 仅保留全限定名命中目标包前缀、或 packageId 归属目标包的条目;
32
36
  // 无法归属到目标包的无前缀短 id 条目不放行,避免他包短 id 混入
33
- if (options.package && !target.localSkill) {
37
+ if (options.package && !options.profile && !options.server) {
34
38
  const targetPkg = options.package;
35
39
  rawSummaries = rawSummaries.filter((s) => {
36
- const pkgId = s.packageId;
37
- if (pkgId) {
38
- return (pkgId === targetPkg ||
40
+ if (s.packageId) {
41
+ return (s.packageId === targetPkg ||
39
42
  s.id === targetPkg ||
40
43
  s.id.startsWith(`${targetPkg}/`));
41
44
  }
@@ -43,17 +46,14 @@ export function attachListCommand(parent, context) {
43
46
  return s.id === targetPkg || s.id.startsWith(`${targetPkg}/`);
44
47
  });
45
48
  }
46
- const isCompositeSkill = target.localSkill?.type === "composite";
47
49
  const rawList = rawSummaries.map((s) => {
48
50
  let id = s.id;
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;
51
+ if (targetPackageRoot || options.package) {
52
+ const pkgId = s.packageId || options.package;
53
53
  if (pkgId && id.startsWith(`${pkgId}/`)) {
54
54
  id = id.slice(pkgId.length + 1);
55
55
  }
56
- else if (target.targetPackageRoot && id.includes("/")) {
56
+ else if (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
- : target.targetPackageRoot
83
+ : 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: target.targetPackageRoot, scanLinkedPackages: !target.localSkill });
91
+ }, { localRoot: targetPackageRoot || undefined, scanLinkedPackages: true });
92
92
  });
93
93
  }
94
94
  /**