@actiondock/cli 2.10.0 → 2.11.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/README.md +2 -2
- package/bin/ad.js +225 -5
- package/dist/commands/action/create.d.ts +1 -1
- package/dist/commands/action/create.js +6 -14
- package/dist/commands/add.js +1 -1
- package/dist/commands/config/delete.js +3 -1
- package/dist/commands/config/env.js +2 -1
- package/dist/commands/config/get.js +3 -1
- package/dist/commands/config/list.js +6 -5
- package/dist/commands/config/set.js +3 -1
- package/dist/commands/describe.js +2 -3
- package/dist/commands/export.js +34 -16
- package/dist/commands/index.d.ts +37 -24
- package/dist/commands/index.js +326 -48
- package/dist/commands/mcp.js +0 -1
- package/dist/commands/playbook.js +15 -35
- package/dist/commands/profile.js +2 -1
- package/dist/commands/remove.js +1 -1
- package/dist/commands/run.d.ts +2 -1
- package/dist/commands/run.js +4 -56
- package/dist/commands/runs.d.ts +6 -1
- package/dist/commands/runs.js +274 -11
- package/dist/commands/serve.js +5 -2
- package/dist/commands/state.js +84 -15
- package/dist/index.d.ts +10 -2
- package/dist/index.js +15 -12
- package/dist/prompt.d.ts +3 -0
- package/dist/prompt.js +6 -14
- package/dist/renderer.d.ts +7 -137
- package/dist/renderer.js +6 -438
- package/dist/renderers/action.d.ts +51 -0
- package/dist/renderers/action.js +112 -0
- package/dist/renderers/config.d.ts +31 -0
- package/dist/renderers/config.js +93 -0
- package/dist/renderers/playbook.d.ts +19 -0
- package/dist/renderers/playbook.js +42 -0
- package/dist/renderers/project.d.ts +45 -0
- package/dist/renderers/project.js +196 -0
- package/dist/renderers/runs.d.ts +15 -0
- package/dist/renderers/runs.js +47 -0
- package/dist/renderers/state.d.ts +4 -0
- package/dist/renderers/state.js +19 -0
- package/dist/services/config-merge.js +1 -2
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/run-watch.d.ts +156 -0
- package/dist/services/run-watch.js +395 -0
- package/dist/utils/cert.js +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/input.d.ts +2 -1
- package/dist/utils/input.js +2 -1
- package/dist/utils/target.d.ts +6 -2
- package/dist/utils/target.js +4 -4
- package/dist/utils/utils.js +3 -11
- package/dist/utils/warning.d.ts +4 -0
- package/dist/utils/warning.js +4 -0
- package/package.json +5 -5
- package/dist/commands/state-list.d.ts +0 -24
- package/dist/commands/state-list.js +0 -81
- package/dist/standalone/index.d.ts +0 -12
- package/dist/standalone/index.js +0 -13
- package/dist/utils/duration.d.ts +0 -1
- package/dist/utils/duration.js +0 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { buildActionDescribePayload, ACTION_DESCRIBE_SYNTAX_REFERENCE, } from "@actiondock/core/project";
|
|
2
|
+
/**
|
|
3
|
+
* 格式化渲染 Action 列表。
|
|
4
|
+
*/
|
|
5
|
+
export function renderActionList(items, title = "Actions", isFallback = false, intent) {
|
|
6
|
+
const lines = [];
|
|
7
|
+
lines.push(`${title}:\n`);
|
|
8
|
+
if (isFallback && intent) {
|
|
9
|
+
lines.push(`(No actions matched intent '${intent}', showing all actions)\n`);
|
|
10
|
+
}
|
|
11
|
+
if (items.length === 0) {
|
|
12
|
+
lines.push(" (no actions found)");
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
for (const a of items) {
|
|
16
|
+
lines.push(` - ${a.id.padEnd(28)} ${a.description}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
lines.push("\nTip: For composite or multi-step tasks, check 'ad playbook list' for standard operating procedures.");
|
|
20
|
+
return lines.join("\n");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 格式化渲染 Action 详情人类可读文本。
|
|
24
|
+
*
|
|
25
|
+
* @param input Action 描述载荷或 Action 规范
|
|
26
|
+
* @returns 格式化后的说明文本
|
|
27
|
+
*/
|
|
28
|
+
export function formatActionDetail(input) {
|
|
29
|
+
const payload = "inputAdvice" in input && input.inputAdvice
|
|
30
|
+
? input
|
|
31
|
+
: buildActionDescribePayload(input);
|
|
32
|
+
const lines = [];
|
|
33
|
+
lines.push(`Action: ${payload.id}`);
|
|
34
|
+
if (payload.packageId) {
|
|
35
|
+
lines.push(`Package: ${payload.packageId}`);
|
|
36
|
+
}
|
|
37
|
+
if (payload.description) {
|
|
38
|
+
lines.push(`Description: ${payload.description}`);
|
|
39
|
+
}
|
|
40
|
+
if (payload.tags && payload.tags.length > 0) {
|
|
41
|
+
lines.push(`Tags: ${payload.tags.join(", ")}`);
|
|
42
|
+
}
|
|
43
|
+
if (payload.uses && payload.uses.length > 0) {
|
|
44
|
+
lines.push(`Uses: ${payload.uses.join(", ")}`);
|
|
45
|
+
}
|
|
46
|
+
if (payload.entry) {
|
|
47
|
+
lines.push(`Entry: ${payload.entry}`);
|
|
48
|
+
}
|
|
49
|
+
if (payload.inputSchema !== undefined) {
|
|
50
|
+
lines.push("");
|
|
51
|
+
lines.push("Input Schema:");
|
|
52
|
+
lines.push(typeof payload.inputSchema === "string"
|
|
53
|
+
? payload.inputSchema
|
|
54
|
+
: JSON.stringify(payload.inputSchema, null, 2));
|
|
55
|
+
}
|
|
56
|
+
if (payload.outputSchema !== undefined) {
|
|
57
|
+
lines.push("");
|
|
58
|
+
lines.push("Output Schema:");
|
|
59
|
+
lines.push(typeof payload.outputSchema === "string"
|
|
60
|
+
? payload.outputSchema
|
|
61
|
+
: JSON.stringify(payload.outputSchema, null, 2));
|
|
62
|
+
}
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push(`Recommended Input: ${payload.inputAdvice.recommendedMode}`);
|
|
65
|
+
if (payload.inputAdvice.reason) {
|
|
66
|
+
lines.push(`Reason: ${payload.inputAdvice.reason}`);
|
|
67
|
+
}
|
|
68
|
+
const hasAssignments = Boolean(payload.inputAdvice.assignments &&
|
|
69
|
+
Object.keys(payload.inputAdvice.assignments).length > 0);
|
|
70
|
+
if (hasAssignments) {
|
|
71
|
+
lines.push("");
|
|
72
|
+
lines.push("Assignments:");
|
|
73
|
+
for (const [key, op] of Object.entries(payload.inputAdvice.assignments)) {
|
|
74
|
+
lines.push(` ${key}${op}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (payload.inputAdvice.recommendedMode === "flat" || hasAssignments) {
|
|
78
|
+
lines.push("");
|
|
79
|
+
lines.push("Syntax Reference:");
|
|
80
|
+
lines.push(...(payload.syntaxReference || ACTION_DESCRIBE_SYNTAX_REFERENCE));
|
|
81
|
+
}
|
|
82
|
+
if (payload.inputAdvice.issues && payload.inputAdvice.issues.length > 0) {
|
|
83
|
+
lines.push("");
|
|
84
|
+
lines.push("Issues:");
|
|
85
|
+
for (const issue of payload.inputAdvice.issues) {
|
|
86
|
+
lines.push(` - ${issue.path}: ${issue.code}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return lines.join("\n");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 格式化渲染 Action 详情(编码顾问 Encoding Advisor)。
|
|
93
|
+
* 统一复用 formatActionDetail 实现。
|
|
94
|
+
*/
|
|
95
|
+
export function renderActionDetail(action) {
|
|
96
|
+
return formatActionDetail(action);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 格式化渲染 Action 校验结果。
|
|
100
|
+
*/
|
|
101
|
+
export function renderActionValidation(results) {
|
|
102
|
+
const lines = [];
|
|
103
|
+
for (const r of results) {
|
|
104
|
+
if (r.valid) {
|
|
105
|
+
lines.push(`[OK] ${r.id}: Valid`);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
lines.push(`[FAIL] ${r.id}: ${r.errors.join(", ")}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return lines.join("\n");
|
|
112
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EnvCheckItem } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* 格式化渲染配置项列表。
|
|
4
|
+
* 掩码决策收敛在命令层(传入的 value 已完成是否打码处理),
|
|
5
|
+
* 此处仅负责值的字符串格式化:字符串原样输出,其余类型 JSON 序列化。
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderConfigList(items: Array<{
|
|
8
|
+
key: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
source: string;
|
|
11
|
+
secret: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
}>, scopeLabel?: string, isFallback?: boolean, intent?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* 格式化配置值:字符串原样输出,其余类型 JSON 序列化。
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatConfigValue(value: unknown): string;
|
|
18
|
+
/**
|
|
19
|
+
* 格式化渲染配置依赖规范检查。
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderConfigSchema(items: Array<{
|
|
22
|
+
key: string;
|
|
23
|
+
status: string;
|
|
24
|
+
source: string;
|
|
25
|
+
secret: boolean;
|
|
26
|
+
description: string;
|
|
27
|
+
}>, packageId: string, root: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* 格式化渲染环境变量满足率诊断。
|
|
30
|
+
*/
|
|
31
|
+
export declare function renderConfigEnv(checks: EnvCheckItem[], packageId?: string): string;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化渲染配置项列表。
|
|
3
|
+
* 掩码决策收敛在命令层(传入的 value 已完成是否打码处理),
|
|
4
|
+
* 此处仅负责值的字符串格式化:字符串原样输出,其余类型 JSON 序列化。
|
|
5
|
+
*/
|
|
6
|
+
export function renderConfigList(items, scopeLabel = "Global Scope", isFallback = false, intent) {
|
|
7
|
+
const lines = [];
|
|
8
|
+
lines.push(`Configurations [${scopeLabel}]:\n`);
|
|
9
|
+
if (isFallback && intent) {
|
|
10
|
+
lines.push(`(No config entries matched intent '${intent}', showing all entries)\n`);
|
|
11
|
+
}
|
|
12
|
+
if (items.length === 0) {
|
|
13
|
+
lines.push(" (No configuration entries found)");
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
for (const item of items) {
|
|
17
|
+
const valStr = formatConfigValue(item.value);
|
|
18
|
+
const secretBadge = item.secret ? ", secret" : "";
|
|
19
|
+
lines.push(` - ${item.key.padEnd(24)} = ${valStr} (${item.source}${secretBadge})`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return lines.join("\n");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 格式化配置值:字符串原样输出,其余类型 JSON 序列化。
|
|
26
|
+
*/
|
|
27
|
+
export function formatConfigValue(value) {
|
|
28
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 格式化渲染配置依赖规范检查。
|
|
32
|
+
*/
|
|
33
|
+
export function renderConfigSchema(items, packageId, root) {
|
|
34
|
+
const lines = [];
|
|
35
|
+
lines.push(`Configuration Requirements for ${packageId} (${root}):\n`);
|
|
36
|
+
if (items.length === 0) {
|
|
37
|
+
lines.push(" (No configuration dependencies declared for this package)");
|
|
38
|
+
return lines.join("\n");
|
|
39
|
+
}
|
|
40
|
+
lines.push(` ${"KEY".padEnd(24)} ${"STATUS".padEnd(12)} ${"SOURCE".padEnd(10)} ${"SECRET".padEnd(8)} DESCRIPTION`);
|
|
41
|
+
lines.push(" " + "-".repeat(85));
|
|
42
|
+
const missing = [];
|
|
43
|
+
for (const item of items) {
|
|
44
|
+
const statusLabel = item.status === "SET" ? "[SET]" : item.status === "DEFAULT" ? "[DEFAULT]" : "[MISSING]";
|
|
45
|
+
const secretLabel = item.secret ? "yes" : "no";
|
|
46
|
+
lines.push(` ${item.key.padEnd(24)} ${statusLabel.padEnd(12)} ${item.source.padEnd(10)} ${secretLabel.padEnd(8)} ${item.description}`);
|
|
47
|
+
if (item.status === "MISSING") {
|
|
48
|
+
missing.push(item.key);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (missing.length > 0) {
|
|
52
|
+
lines.push(`\n[WARNING] ${missing.length} required config(s) not set:`);
|
|
53
|
+
for (const m of missing) {
|
|
54
|
+
lines.push(` - ${m}: Run 'ad config set ${m} <value>' to configure.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
lines.push("\n[OK] All configuration dependencies are satisfied.");
|
|
59
|
+
}
|
|
60
|
+
return lines.join("\n");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 格式化渲染环境变量满足率诊断。
|
|
64
|
+
*/
|
|
65
|
+
export function renderConfigEnv(checks, packageId) {
|
|
66
|
+
const lines = [];
|
|
67
|
+
const targetDesc = packageId ? `for Package '${packageId}'` : "Global";
|
|
68
|
+
lines.push(`Environment Variable Satisfaction Diagnostics ${targetDesc}:\n`);
|
|
69
|
+
if (checks.length === 0) {
|
|
70
|
+
lines.push(" (No configuration dependencies declared)");
|
|
71
|
+
return lines.join("\n");
|
|
72
|
+
}
|
|
73
|
+
lines.push(` ${"KEY".padEnd(24)} ${"SATISFIED".padEnd(12)} ${"REQUIRED".padEnd(10)} ${"MATCHED ENV".padEnd(28)} SECRET`);
|
|
74
|
+
lines.push(" " + "-".repeat(85));
|
|
75
|
+
for (const c of checks) {
|
|
76
|
+
const satLabel = c.satisfied ? "[OK]" : "[MISSING]";
|
|
77
|
+
const reqLabel = c.required ? "yes" : "no";
|
|
78
|
+
const matched = c.matchedEnv || (c.hasDefault ? "(using default)" : "-");
|
|
79
|
+
const secLabel = c.secret ? "yes" : "no";
|
|
80
|
+
lines.push(` ${c.key.padEnd(24)} ${satLabel.padEnd(12)} ${reqLabel.padEnd(10)} ${matched.padEnd(28)} ${secLabel}`);
|
|
81
|
+
}
|
|
82
|
+
const missingRequired = checks.filter((c) => c.required && !c.satisfied);
|
|
83
|
+
if (missingRequired.length > 0) {
|
|
84
|
+
lines.push(`\n[WARNING] ${missingRequired.length} required environment variable(s) not satisfied:`);
|
|
85
|
+
for (const m of missingRequired) {
|
|
86
|
+
lines.push(` - ${m.key}: Please export ${m.key}=... in your environment.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
lines.push("\n[OK] All declared configuration dependencies are satisfied by environment or defaults.");
|
|
91
|
+
}
|
|
92
|
+
return lines.join("\n");
|
|
93
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化渲染 Playbook 列表。
|
|
3
|
+
*/
|
|
4
|
+
export declare function renderPlaybookList(items: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
packageId?: string;
|
|
8
|
+
}>, title?: string, isFallback?: boolean, intent?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* 格式化渲染 Playbook 详情。
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderPlaybookDetail(pb: {
|
|
13
|
+
id: string;
|
|
14
|
+
packageId?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
actions?: string[];
|
|
17
|
+
filePath?: string;
|
|
18
|
+
content?: string;
|
|
19
|
+
}): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化渲染 Playbook 列表。
|
|
3
|
+
*/
|
|
4
|
+
export function renderPlaybookList(items, title = "Playbooks", isFallback = false, intent) {
|
|
5
|
+
const lines = [];
|
|
6
|
+
lines.push(`${title}:\n`);
|
|
7
|
+
if (isFallback && intent) {
|
|
8
|
+
lines.push(`(No playbooks matched intent '${intent}', showing all playbooks)\n`);
|
|
9
|
+
}
|
|
10
|
+
if (items.length === 0) {
|
|
11
|
+
lines.push(" (no playbooks found)");
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
for (const p of items) {
|
|
15
|
+
const pkgDesc = p.packageId ? ` (Package: ${p.packageId})` : "";
|
|
16
|
+
lines.push(` - ${p.id.padEnd(26)} ${p.description}${pkgDesc}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
lines.push("\nTip: Run 'ad playbook show <id>' to inspect procedure steps before execution.");
|
|
20
|
+
return lines.join("\n");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 格式化渲染 Playbook 详情。
|
|
24
|
+
*/
|
|
25
|
+
export function renderPlaybookDetail(pb) {
|
|
26
|
+
const lines = [];
|
|
27
|
+
const pkgDesc = pb.packageId ? ` (Package: ${pb.packageId})` : "";
|
|
28
|
+
lines.push(`Playbook: ${pb.id}${pkgDesc}`);
|
|
29
|
+
if (pb.description)
|
|
30
|
+
lines.push(`Description: ${pb.description}`);
|
|
31
|
+
if (pb.actions && pb.actions.length > 0) {
|
|
32
|
+
lines.push(`Actions: ${pb.actions.join(", ")}`);
|
|
33
|
+
}
|
|
34
|
+
if (pb.filePath)
|
|
35
|
+
lines.push(`File: ${pb.filePath}\n`);
|
|
36
|
+
if (pb.content) {
|
|
37
|
+
lines.push("--- Content ---");
|
|
38
|
+
lines.push(pb.content);
|
|
39
|
+
}
|
|
40
|
+
lines.push("\nTip: Follow steps sequentially. Invoke constituent actions using 'ad run <action> [options] -- <assignments...>'.");
|
|
41
|
+
return lines.join("\n");
|
|
42
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ProjectDetailInfo, ProjectDetailJson, AggregatedPackage } from "../types.js";
|
|
2
|
+
import type { RegistryStatusReport } from "@actiondock/core/registry";
|
|
3
|
+
/**
|
|
4
|
+
* 将工程详情信息转换为机器输出视图(结构化配置契约、规程与动作索引)。
|
|
5
|
+
*/
|
|
6
|
+
export declare function projectDetailToJson(info: ProjectDetailInfo): ProjectDetailJson;
|
|
7
|
+
/**
|
|
8
|
+
* 格式化渲染单个项目的元数据与详情信息。
|
|
9
|
+
*/
|
|
10
|
+
export declare function renderProjectDetail(info: ProjectDetailInfo): string;
|
|
11
|
+
/**
|
|
12
|
+
* 格式化渲染已链接的多个 Package 摘要信息。
|
|
13
|
+
*/
|
|
14
|
+
export declare function renderAggregatedPackages(packages: AggregatedPackage[], options?: {
|
|
15
|
+
header?: string;
|
|
16
|
+
showTip?: boolean;
|
|
17
|
+
}): string;
|
|
18
|
+
/**
|
|
19
|
+
* 远端 info 接口返回的注册表树视图(与 RegistryStatusReport 字段兼容的宽松结构)。
|
|
20
|
+
*/
|
|
21
|
+
export type RegistryTreeView = RegistryStatusReport | (Record<string, unknown> & {
|
|
22
|
+
workspaces?: Array<{
|
|
23
|
+
id?: string;
|
|
24
|
+
path: string;
|
|
25
|
+
status: string;
|
|
26
|
+
packagesCount?: number;
|
|
27
|
+
children?: Array<{
|
|
28
|
+
id: string;
|
|
29
|
+
version?: string;
|
|
30
|
+
path: string;
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
packages?: Array<{
|
|
34
|
+
id: string;
|
|
35
|
+
version?: string;
|
|
36
|
+
path: string;
|
|
37
|
+
status: string;
|
|
38
|
+
}>;
|
|
39
|
+
totalPackagesCount?: number;
|
|
40
|
+
staleCount?: number;
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* 格式化渲染注册表层级树结构。
|
|
44
|
+
*/
|
|
45
|
+
export declare function renderRegistryTree(status: RegistryTreeView): string;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将工程详情信息转换为机器输出视图(结构化配置契约、规程与动作索引)。
|
|
3
|
+
*/
|
|
4
|
+
export function projectDetailToJson(info) {
|
|
5
|
+
const config = {};
|
|
6
|
+
if (info.configDeclared && info.configDeclared.length > 0) {
|
|
7
|
+
for (const key of info.configDeclared) {
|
|
8
|
+
const item = info.configDef?.[key];
|
|
9
|
+
config[key] = {
|
|
10
|
+
...(item?.description !== undefined ? { description: item.description } : {}),
|
|
11
|
+
...(item?.default !== undefined ? { default: item.default } : {}),
|
|
12
|
+
secret: Boolean(item?.secret),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const playbooks = [];
|
|
17
|
+
if (info.playbooksMap && info.playbooksMap.size > 0) {
|
|
18
|
+
for (const [id, pb] of info.playbooksMap.entries()) {
|
|
19
|
+
playbooks.push({
|
|
20
|
+
id,
|
|
21
|
+
...(pb?.description ? { description: pb.description } : {}),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (info.playbooks && info.playbooks.length > 0) {
|
|
26
|
+
for (const pbId of info.playbooks) {
|
|
27
|
+
playbooks.push({ id: pbId });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const actions = [];
|
|
31
|
+
if (info.actionsMap && info.actionsMap.size > 0) {
|
|
32
|
+
for (const [id, act] of info.actionsMap.entries()) {
|
|
33
|
+
actions.push({
|
|
34
|
+
id,
|
|
35
|
+
...(act?.description ? { description: act.description } : {}),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (info.actions && info.actions.length > 0) {
|
|
40
|
+
for (const actId of info.actions) {
|
|
41
|
+
actions.push({ id: actId });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const hints = [
|
|
45
|
+
"Tip: Run 'ad playbook show <id>' to inspect procedure steps before execution.",
|
|
46
|
+
];
|
|
47
|
+
if (info.configDeclared && info.configDeclared.length > 0) {
|
|
48
|
+
hints.push("Tip: Run 'ad config set <KEY> <val>' to configure required settings.");
|
|
49
|
+
}
|
|
50
|
+
const result = {
|
|
51
|
+
id: info.id,
|
|
52
|
+
name: info.name || info.id,
|
|
53
|
+
version: info.version || "0.0.0",
|
|
54
|
+
root: info.projectRoot,
|
|
55
|
+
config,
|
|
56
|
+
playbooks,
|
|
57
|
+
actions,
|
|
58
|
+
hints,
|
|
59
|
+
};
|
|
60
|
+
if (info.description) {
|
|
61
|
+
result.description = info.description;
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 格式化渲染单个项目的元数据与详情信息。
|
|
67
|
+
*/
|
|
68
|
+
export function renderProjectDetail(info) {
|
|
69
|
+
const lines = [];
|
|
70
|
+
lines.push(`ActionDock Project: ${info.name} (${info.id})`);
|
|
71
|
+
lines.push(`Version: ${info.version}`);
|
|
72
|
+
if (info.description) {
|
|
73
|
+
lines.push(`Description: ${info.description}`);
|
|
74
|
+
}
|
|
75
|
+
lines.push(`Root: ${info.projectRoot}`);
|
|
76
|
+
if (info.configDeclared.length > 0) {
|
|
77
|
+
lines.push(`\nDeclared Config Keys (${info.configDeclared.length}):`);
|
|
78
|
+
for (const k of info.configDeclared) {
|
|
79
|
+
const item = info.configDef?.[k];
|
|
80
|
+
const isSec = item?.secret ? " [secret]" : "";
|
|
81
|
+
const def = item?.default !== undefined ? ` (default: ${JSON.stringify(item.default)})` : "";
|
|
82
|
+
lines.push(` - ${k.padEnd(24)} ${item?.description || ""}${def}${isSec}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
lines.push(`\nPlaybooks (${info.playbooksCount}):`);
|
|
86
|
+
if (info.playbooksMap && info.playbooksMap.size > 0) {
|
|
87
|
+
for (const [id, pb] of info.playbooksMap.entries()) {
|
|
88
|
+
lines.push(` - ${id.padEnd(28)} ${pb.description || ""}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (info.playbooks && info.playbooks.length > 0) {
|
|
92
|
+
for (const pbId of info.playbooks) {
|
|
93
|
+
lines.push(` - ${pbId}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
lines.push(" (no playbooks declared)");
|
|
98
|
+
}
|
|
99
|
+
lines.push(`\nActions (${info.actionsCount}):`);
|
|
100
|
+
const actionList = [];
|
|
101
|
+
if (info.actionsMap) {
|
|
102
|
+
for (const [id, act] of info.actionsMap.entries()) {
|
|
103
|
+
actionList.push({ id, description: act.description || "" });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (info.actions) {
|
|
107
|
+
for (const actId of info.actions) {
|
|
108
|
+
actionList.push({ id: actId, description: "" });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (actionList.length === 0) {
|
|
112
|
+
lines.push(" (no actions declared)");
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
for (const a of actionList) {
|
|
116
|
+
lines.push(` - ${a.id.padEnd(28)} ${a.description}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
lines.push("\nTip: Run 'ad playbook show <id>' to inspect procedure steps before execution.");
|
|
120
|
+
if (info.configDeclared.length > 0) {
|
|
121
|
+
lines.push("Tip: Run 'ad config set <KEY> <val>' to configure required settings.");
|
|
122
|
+
}
|
|
123
|
+
return lines.join("\n");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 格式化渲染已链接的多个 Package 摘要信息。
|
|
127
|
+
*/
|
|
128
|
+
export function renderAggregatedPackages(packages, options) {
|
|
129
|
+
const lines = [];
|
|
130
|
+
if (options?.header) {
|
|
131
|
+
lines.push(options.header);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
lines.push(`ActionDock Linked Packages (${packages.length}):\n`);
|
|
135
|
+
}
|
|
136
|
+
for (const p of packages) {
|
|
137
|
+
lines.push(`- ${p.name} (${p.id}) v${p.version}`);
|
|
138
|
+
lines.push(` Path: ${p.path}`);
|
|
139
|
+
if (p.description) {
|
|
140
|
+
lines.push(` Desc: ${p.description}`);
|
|
141
|
+
}
|
|
142
|
+
lines.push(` Actions (${p.actionsCount}): ${p.actions.join(", ") || "(none)"}`);
|
|
143
|
+
lines.push(` Playbooks (${p.playbooksCount}): ${p.playbooks.join(", ") || "(none)"}`);
|
|
144
|
+
lines.push("");
|
|
145
|
+
}
|
|
146
|
+
if (options?.showTip !== false) {
|
|
147
|
+
lines.push("Tip: Run 'ad info <package-id>' to view detailed package configuration and schema.");
|
|
148
|
+
}
|
|
149
|
+
return lines.join("\n");
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 格式化渲染注册表层级树结构。
|
|
153
|
+
*/
|
|
154
|
+
export function renderRegistryTree(status) {
|
|
155
|
+
const lines = [];
|
|
156
|
+
const workspaces = status.workspaces || [];
|
|
157
|
+
const packages = status.packages || [];
|
|
158
|
+
const hasWorkspaces = workspaces.length > 0;
|
|
159
|
+
const hasPackages = packages.length > 0;
|
|
160
|
+
if (!hasWorkspaces && !hasPackages) {
|
|
161
|
+
lines.push("[INFO] No ActionDock packages or workspaces currently linked.");
|
|
162
|
+
lines.push(" Run 'ad link' inside an Action package or workspace to register it.");
|
|
163
|
+
return lines.join("\n");
|
|
164
|
+
}
|
|
165
|
+
lines.push("[ActionDock Workspace & Package Tree]\n");
|
|
166
|
+
if (hasWorkspaces) {
|
|
167
|
+
lines.push("Workspaces:");
|
|
168
|
+
for (const ws of workspaces) {
|
|
169
|
+
const tag = ws.status === "active" ? "[OK]" : "[STALE]";
|
|
170
|
+
lines.push(` ${tag} ${ws.path} (${ws.packagesCount} package${ws.packagesCount === 1 ? "" : "s"})`);
|
|
171
|
+
if (ws.children && ws.children.length > 0) {
|
|
172
|
+
const children = ws.children;
|
|
173
|
+
children.forEach((child, idx) => {
|
|
174
|
+
const isLast = idx === children.length - 1;
|
|
175
|
+
const prefix = isLast ? " +-- " : " |-- ";
|
|
176
|
+
lines.push(`${prefix}${child.id} (v${child.version}) -> ${child.path}`);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (hasPackages) {
|
|
182
|
+
if (hasWorkspaces)
|
|
183
|
+
lines.push("");
|
|
184
|
+
lines.push("Standalone Packages:");
|
|
185
|
+
for (const pkg of packages) {
|
|
186
|
+
const tag = pkg.status === "active" ? "[OK]" : "[STALE]";
|
|
187
|
+
lines.push(` ${tag} ${pkg.id} (v${pkg.version || "unknown"}) -> ${pkg.path}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const totalActive = status.totalPackagesCount ?? packages.length;
|
|
191
|
+
lines.push(`\n[Summary] Total: ${totalActive} active package(s), ${workspaces.length} workspace(s)`);
|
|
192
|
+
if (status.staleCount && status.staleCount > 0) {
|
|
193
|
+
lines.push(`[WARN] ${status.staleCount} stale entry/entries detected. Run 'ad unlink --prune' to clean up.`);
|
|
194
|
+
}
|
|
195
|
+
return lines.join("\n");
|
|
196
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { RunRecord } from "@actiondock/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* 格式化渲染执行记录列表。
|
|
4
|
+
*/
|
|
5
|
+
export declare function renderRunsList(items: Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
actionId: string;
|
|
8
|
+
packageId?: string;
|
|
9
|
+
status: string;
|
|
10
|
+
startedAt: string;
|
|
11
|
+
}>, scopeLabel?: string, isFallback?: boolean, intent?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* 格式化渲染单次执行记录详情。
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderRunDetail(run: RunRecord): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化渲染执行记录列表。
|
|
3
|
+
*/
|
|
4
|
+
export function renderRunsList(items, scopeLabel = "Execution Runs", isFallback = false, intent) {
|
|
5
|
+
const lines = [];
|
|
6
|
+
lines.push(`${scopeLabel} (${items.length}):\n`);
|
|
7
|
+
if (isFallback && intent) {
|
|
8
|
+
lines.push(`(No runs matched intent '${intent}', showing all runs)\n`);
|
|
9
|
+
}
|
|
10
|
+
lines.push(` ${"RUN ID".padEnd(38)} ${"PACKAGE".padEnd(18)} ${"ACTION".padEnd(22)} ${"STATUS".padEnd(10)} STARTED`);
|
|
11
|
+
lines.push(" " + "-".repeat(105));
|
|
12
|
+
for (const r of items) {
|
|
13
|
+
const time = (r.startedAt || "").replace("T", " ").slice(0, 19);
|
|
14
|
+
const pkg = (r.packageId || "").padEnd(18);
|
|
15
|
+
lines.push(` ${r.id.padEnd(38)} ${pkg} ${r.actionId.padEnd(22)} ${r.status.padEnd(10)} ${time}`);
|
|
16
|
+
}
|
|
17
|
+
return lines.join("\n");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 格式化渲染单次执行记录详情。
|
|
21
|
+
*/
|
|
22
|
+
export function renderRunDetail(run) {
|
|
23
|
+
const lines = [];
|
|
24
|
+
lines.push(`Run: ${run.id}`);
|
|
25
|
+
lines.push(`Action: ${run.actionId}`);
|
|
26
|
+
if (run.packageId)
|
|
27
|
+
lines.push(`Package: ${run.packageId}`);
|
|
28
|
+
if (run.requestId)
|
|
29
|
+
lines.push(`Request ID: ${run.requestId}`);
|
|
30
|
+
lines.push(`Status: ${run.status}`);
|
|
31
|
+
if (run.parentRunId)
|
|
32
|
+
lines.push(`Parent Run: ${run.parentRunId}`);
|
|
33
|
+
lines.push(`Started: ${run.startedAt}`);
|
|
34
|
+
if (run.finishedAt)
|
|
35
|
+
lines.push(`Finished: ${run.finishedAt}`);
|
|
36
|
+
lines.push("\nInput:");
|
|
37
|
+
lines.push(JSON.stringify(run.input, null, 2));
|
|
38
|
+
if (run.output !== undefined) {
|
|
39
|
+
lines.push("\nOutput:");
|
|
40
|
+
lines.push(JSON.stringify(run.output, null, 2));
|
|
41
|
+
}
|
|
42
|
+
if (run.error) {
|
|
43
|
+
lines.push("\nError:");
|
|
44
|
+
lines.push(JSON.stringify(run.error, null, 2));
|
|
45
|
+
}
|
|
46
|
+
return lines.join("\n");
|
|
47
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化渲染状态键列表。
|
|
3
|
+
*/
|
|
4
|
+
export function renderStateList(keys, scopeLabel = "Current State", isFallback = false, intent) {
|
|
5
|
+
const lines = [];
|
|
6
|
+
lines.push(`State keys for ${scopeLabel} (${keys.length}):\n`);
|
|
7
|
+
if (isFallback && intent) {
|
|
8
|
+
lines.push(`(No state keys matched intent '${intent}', showing all keys)\n`);
|
|
9
|
+
}
|
|
10
|
+
if (keys.length === 0) {
|
|
11
|
+
lines.push(" (no state keys found)");
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
for (const k of keys) {
|
|
15
|
+
lines.push(` - ${k}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return lines.join("\n");
|
|
19
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isSecretConfigKey, maskSecretValue, } from "@actiondock/core/project";
|
|
2
|
-
import { loadProjectConfig, } from "@actiondock/core";
|
|
3
|
-
import { resolveEnvValue, } from "@actiondock/core/profile";
|
|
2
|
+
import { loadProjectConfig, resolveEnvValue, } from "@actiondock/core";
|
|
4
3
|
/**
|
|
5
4
|
* 解析单个配置键的合并视图(项目包级 > 全局持久化 > 环境变量 > 声明默认值)。
|
|
6
5
|
*
|
package/dist/services/index.d.ts
CHANGED
package/dist/services/index.js
CHANGED