@actiondock/cli 2.10.0 → 2.12.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 (64) hide show
  1. package/README.md +10 -5
  2. package/bin/ad.js +225 -5
  3. package/dist/commands/action/create.d.ts +1 -1
  4. package/dist/commands/action/create.js +7 -14
  5. package/dist/commands/add.js +1 -1
  6. package/dist/commands/config/delete.js +3 -1
  7. package/dist/commands/config/env.js +2 -1
  8. package/dist/commands/config/get.js +3 -1
  9. package/dist/commands/config/list.js +6 -5
  10. package/dist/commands/config/set.js +3 -1
  11. package/dist/commands/describe.js +2 -3
  12. package/dist/commands/export.js +34 -16
  13. package/dist/commands/index.d.ts +37 -24
  14. package/dist/commands/index.js +326 -48
  15. package/dist/commands/mcp.js +0 -1
  16. package/dist/commands/playbook.js +15 -35
  17. package/dist/commands/profile.js +2 -1
  18. package/dist/commands/remove.js +1 -1
  19. package/dist/commands/run.d.ts +7 -2
  20. package/dist/commands/run.js +47 -59
  21. package/dist/commands/runs.d.ts +6 -1
  22. package/dist/commands/runs.js +274 -11
  23. package/dist/commands/serve.js +5 -2
  24. package/dist/commands/state.js +84 -15
  25. package/dist/index.d.ts +10 -2
  26. package/dist/index.js +15 -12
  27. package/dist/prompt.d.ts +3 -0
  28. package/dist/prompt.js +6 -14
  29. package/dist/renderer.d.ts +7 -137
  30. package/dist/renderer.js +6 -438
  31. package/dist/renderers/action.d.ts +78 -0
  32. package/dist/renderers/action.js +187 -0
  33. package/dist/renderers/config.d.ts +31 -0
  34. package/dist/renderers/config.js +93 -0
  35. package/dist/renderers/playbook.d.ts +19 -0
  36. package/dist/renderers/playbook.js +42 -0
  37. package/dist/renderers/project.d.ts +45 -0
  38. package/dist/renderers/project.js +196 -0
  39. package/dist/renderers/runs.d.ts +15 -0
  40. package/dist/renderers/runs.js +47 -0
  41. package/dist/renderers/state.d.ts +4 -0
  42. package/dist/renderers/state.js +19 -0
  43. package/dist/services/config-merge.js +1 -2
  44. package/dist/services/index.d.ts +1 -0
  45. package/dist/services/index.js +1 -0
  46. package/dist/services/run-watch.d.ts +156 -0
  47. package/dist/services/run-watch.js +395 -0
  48. package/dist/utils/cert.js +1 -1
  49. package/dist/utils/index.d.ts +1 -1
  50. package/dist/utils/index.js +1 -1
  51. package/dist/utils/input.d.ts +2 -1
  52. package/dist/utils/input.js +2 -1
  53. package/dist/utils/target.d.ts +6 -2
  54. package/dist/utils/target.js +4 -4
  55. package/dist/utils/utils.js +3 -11
  56. package/dist/utils/warning.d.ts +4 -0
  57. package/dist/utils/warning.js +4 -0
  58. package/package.json +5 -5
  59. package/dist/commands/state-list.d.ts +0 -24
  60. package/dist/commands/state-list.js +0 -81
  61. package/dist/standalone/index.d.ts +0 -12
  62. package/dist/standalone/index.js +0 -13
  63. package/dist/utils/duration.d.ts +0 -1
  64. package/dist/utils/duration.js +0 -1
package/dist/index.d.ts CHANGED
@@ -1,12 +1,20 @@
1
- import { type InvocationControl, type CliContext } from "./types.js";
1
+ import { type InvocationControl, type CliContext, type StandaloneOptions } from "./types.js";
2
2
  export * from "./types.js";
3
3
  export * from "./errors.js";
4
4
  export * from "./renderer.js";
5
5
  export * from "./prompt.js";
6
- export * from "./standalone/index.js";
7
6
  export * from "./utils/index.js";
8
7
  export * from "./services/index.js";
9
8
  export * from "./commands/index.js";
9
+ /**
10
+ * 运行独立二进制参数解析分发器并返回退出状态码(委托 Core 统一实现)。
11
+ */
12
+ export declare function runStandaloneCli(argv: string[] | undefined, options: StandaloneOptions, control?: InvocationControl): Promise<number>;
13
+ /**
14
+ * 独立二进制进程入口适配器(事实源位于 core 包,此处 re-export 维持既有导入路径兼容)。
15
+ * 仅在命令行可执行入口调用,负责全局 SIGINT 监听与退出状态码写入。
16
+ */
17
+ export { runStandaloneProcess } from "@actiondock/core/server";
10
18
  /**
11
19
  * ActionDock CLI 主执行入口函数。
12
20
  *
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { CommanderError } from "commander";
2
- import { createCliProgram } from "./commands/index.js";
2
+ import { StandaloneDispatcher } from "@actiondock/core/server";
3
+ import { createCliProgram, isNodeArgv } from "./commands/index.js";
3
4
  import { formatError, SigintError } from "./errors.js";
4
5
  import { renderError } from "./renderer.js";
5
6
  import { ExitCode } from "./types.js";
@@ -7,10 +8,21 @@ export * from "./types.js";
7
8
  export * from "./errors.js";
8
9
  export * from "./renderer.js";
9
10
  export * from "./prompt.js";
10
- export * from "./standalone/index.js";
11
11
  export * from "./utils/index.js";
12
12
  export * from "./services/index.js";
13
13
  export * from "./commands/index.js";
14
+ /**
15
+ * 运行独立二进制参数解析分发器并返回退出状态码(委托 Core 统一实现)。
16
+ */
17
+ export async function runStandaloneCli(argv = process.argv.slice(2), options, control) {
18
+ const dispatcher = new StandaloneDispatcher(options);
19
+ return dispatcher.dispatch(argv, control);
20
+ }
21
+ /**
22
+ * 独立二进制进程入口适配器(事实源位于 core 包,此处 re-export 维持既有导入路径兼容)。
23
+ * 仅在命令行可执行入口调用,负责全局 SIGINT 监听与退出状态码写入。
24
+ */
25
+ export { runStandaloneProcess } from "@actiondock/core/server";
14
26
  /**
15
27
  * ActionDock CLI 主执行入口函数。
16
28
  *
@@ -22,16 +34,7 @@ export async function main(argv = process.argv, control, contextOptions) {
22
34
  const context = { control, exitCode: 0, ...contextOptions };
23
35
  const program = createCliProgram(context);
24
36
  const isMachine = argv.includes("--json");
25
- const normalizedArgv = argv.length >= 2 &&
26
- (argv[0].endsWith("node") ||
27
- argv[0].endsWith("bun") ||
28
- argv[0].endsWith("tsx") ||
29
- argv[1].includes("/") ||
30
- argv[1].includes("\\") ||
31
- argv[1].endsWith(".js") ||
32
- argv[1].endsWith(".ts"))
33
- ? argv
34
- : ["node", "ad", ...argv];
37
+ const normalizedArgv = isNodeArgv(argv) ? argv : ["node", "ad", ...argv];
35
38
  try {
36
39
  await program.parseAsync(normalizedArgv);
37
40
  if (control?.cancellationSource === "sigint" && control?.signal?.aborted) {
package/dist/prompt.d.ts CHANGED
@@ -34,6 +34,9 @@ export declare function promptText(promptText: string, options?: {
34
34
  export declare function readStreamLine(stream: NodeJS.ReadableStream): Promise<string>;
35
35
  /**
36
36
  * 从流中完整读取所有数据,并移除末尾的换行符。
37
+ *
38
+ * 委托 readStdinBounded 统一收集:保留宽松 UTF-8 解码与 BOM,
39
+ * 补齐默认 10MB 上限保护,流错误通过 INPUT_FILE_READ_FAILED 透传。
37
40
  */
38
41
  export declare function readEntireStdin(stream?: NodeJS.ReadableStream): Promise<string>;
39
42
  /**
package/dist/prompt.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createInterface } from "node:readline";
2
+ import { readStdinBounded } from "@actiondock/core/project";
2
3
  import { ArgumentError, SigintError } from "./errors.js";
3
4
  /**
4
5
  * 在终端中安全交互式读取用户输入的密码或敏感信息。
@@ -126,22 +127,13 @@ export async function readStreamLine(stream) {
126
127
  }
127
128
  /**
128
129
  * 从流中完整读取所有数据,并移除末尾的换行符。
130
+ *
131
+ * 委托 readStdinBounded 统一收集:保留宽松 UTF-8 解码与 BOM,
132
+ * 补齐默认 10MB 上限保护,流错误通过 INPUT_FILE_READ_FAILED 透传。
129
133
  */
130
134
  export async function readEntireStdin(stream = process.stdin) {
131
- return new Promise((resolve, reject) => {
132
- const chunks = [];
133
- stream.on("data", (chunk) => {
134
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
135
- });
136
- stream.once("end", () => {
137
- const content = Buffer.concat(chunks).toString("utf-8");
138
- resolve(content.replace(/[\r\n]+$/, ""));
139
- });
140
- stream.once("error", reject);
141
- if ("resume" in stream && typeof stream.resume === "function") {
142
- stream.resume();
143
- }
144
- });
135
+ const content = await readStdinBounded(stream, { strictUtf8: false });
136
+ return content.replace(/[\r\n]+$/, "");
145
137
  }
146
138
  /**
147
139
  * 解析并获取配置项的具体输入值。
@@ -1,6 +1,10 @@
1
- import type { RunRecord } from "@actiondock/sdk";
2
- import { type RegistryStatusReport } from "@actiondock/core/registry";
3
- import type { Envelope, ProjectDetailInfo, ProjectDetailJson, AggregatedPackage, EnvCheckItem, CliContext } from "./types.js";
1
+ import type { Envelope, CliContext } from "./types.js";
2
+ export * from "./renderers/project.js";
3
+ export * from "./renderers/action.js";
4
+ export * from "./renderers/playbook.js";
5
+ export * from "./renderers/config.js";
6
+ export * from "./renderers/state.js";
7
+ export * from "./renderers/runs.js";
4
8
  /**
5
9
  * 构造标准成功结果信封。
6
10
  *
@@ -47,137 +51,3 @@ export declare function renderError(err: unknown, options: {
47
51
  json?: boolean;
48
52
  context?: CliContext;
49
53
  }): void;
50
- /**
51
- * 将工程详情信息转换为机器输出视图(结构化配置契约、规程与动作索引)。
52
- */
53
- export declare function projectDetailToJson(info: ProjectDetailInfo): ProjectDetailJson;
54
- /**
55
- * 格式化渲染单个项目的元数据与详情信息。
56
- */
57
- export declare function renderProjectDetail(info: ProjectDetailInfo): string;
58
- /**
59
- * 格式化渲染已链接的多个 Package 摘要信息。
60
- */
61
- export declare function renderAggregatedPackages(packages: AggregatedPackage[], options?: {
62
- header?: string;
63
- showTip?: boolean;
64
- }): string;
65
- /**
66
- * 远端 info 接口返回的注册表树视图(与 RegistryStatusReport 字段兼容的宽松结构)。
67
- */
68
- export type RegistryTreeView = RegistryStatusReport | (Record<string, unknown> & {
69
- workspaces?: Array<{
70
- id?: string;
71
- path: string;
72
- status: string;
73
- packagesCount?: number;
74
- children?: Array<{
75
- id: string;
76
- version?: string;
77
- path: string;
78
- }>;
79
- }>;
80
- packages?: Array<{
81
- id: string;
82
- version?: string;
83
- path: string;
84
- status: string;
85
- }>;
86
- totalPackagesCount?: number;
87
- staleCount?: number;
88
- });
89
- /**
90
- * 格式化渲染注册表层级树结构。
91
- */
92
- export declare function renderRegistryTree(status: RegistryTreeView): string;
93
- /**
94
- * 格式化渲染 Action 列表。
95
- */
96
- export declare function renderActionList(items: Array<{
97
- id: string;
98
- description: string;
99
- packageId?: string;
100
- }>, title?: string, isFallback?: boolean, intent?: string): string;
101
- /**
102
- * 格式化渲染 Action 详情(编码顾问 Encoding Advisor)。
103
- * 统一复用 core 下沉的 formatActionDetail 实现,与独立分发器保持完全一致。
104
- */
105
- export declare function renderActionDetail(action: {
106
- id: string;
107
- packageId?: string;
108
- projectRoot?: string;
109
- description?: string;
110
- inputSchema?: unknown;
111
- outputSchema?: unknown;
112
- }): string;
113
- /**
114
- * 格式化渲染 Action 校验结果。
115
- */
116
- export declare function renderActionValidation(results: Array<{
117
- id: string;
118
- valid: boolean;
119
- errors: string[];
120
- }>): string;
121
- /**
122
- * 格式化渲染 Playbook 列表。
123
- */
124
- export declare function renderPlaybookList(items: Array<{
125
- id: string;
126
- description?: string;
127
- packageId?: string;
128
- }>, title?: string, isFallback?: boolean, intent?: string): string;
129
- /**
130
- * 格式化渲染 Playbook 详情。
131
- */
132
- export declare function renderPlaybookDetail(pb: {
133
- id: string;
134
- packageId?: string;
135
- description?: string;
136
- actions?: string[];
137
- filePath?: string;
138
- content?: string;
139
- }): string;
140
- /**
141
- * 格式化渲染配置项列表。
142
- * 掩码决策收敛在命令层(传入的 value 已完成是否打码处理),
143
- * 此处仅负责值的字符串格式化:字符串原样输出,其余类型 JSON 序列化。
144
- */
145
- export declare function renderConfigList(items: Array<{
146
- key: string;
147
- value: unknown;
148
- source: string;
149
- secret: boolean;
150
- description?: string;
151
- }>, scopeLabel?: string, isFallback?: boolean, intent?: string): string;
152
- /**
153
- * 格式化渲染配置依赖规范检查。
154
- */
155
- export declare function renderConfigSchema(items: Array<{
156
- key: string;
157
- status: string;
158
- source: string;
159
- secret: boolean;
160
- description: string;
161
- }>, packageId: string, root: string): string;
162
- /**
163
- * 格式化渲染环境变量满足率诊断。
164
- */
165
- export declare function renderConfigEnv(checks: EnvCheckItem[], packageId?: string): string;
166
- /**
167
- * 格式化渲染状态键列表。
168
- */
169
- export declare function renderStateList(keys: string[], scopeLabel?: string, isFallback?: boolean, intent?: string): string;
170
- /**
171
- * 格式化渲染执行记录列表。
172
- */
173
- export declare function renderRunsList(items: Array<{
174
- id: string;
175
- actionId: string;
176
- packageId?: string;
177
- status: string;
178
- startedAt: string;
179
- }>, scopeLabel?: string, isFallback?: boolean, intent?: string): string;
180
- /**
181
- * 格式化渲染单次执行记录详情。
182
- */
183
- export declare function renderRunDetail(run: RunRecord): string;