@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.
- package/README.md +10 -5
- package/bin/ad.js +225 -5
- package/dist/commands/action/create.d.ts +1 -1
- package/dist/commands/action/create.js +7 -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 +7 -2
- package/dist/commands/run.js +47 -59
- 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 +78 -0
- package/dist/renderers/action.js +187 -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
package/dist/renderer.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { formatActionDetail, } from "@actiondock/core/project";
|
|
2
1
|
import { formatError } from "./errors.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";
|
|
3
8
|
/**
|
|
4
9
|
* 构造标准成功结果信封。
|
|
5
10
|
*
|
|
@@ -110,440 +115,3 @@ export function renderError(err, options) {
|
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
|
-
/**
|
|
114
|
-
* 将工程详情信息转换为机器输出视图(结构化配置契约、规程与动作索引)。
|
|
115
|
-
*/
|
|
116
|
-
export function projectDetailToJson(info) {
|
|
117
|
-
const config = {};
|
|
118
|
-
if (info.configDeclared && info.configDeclared.length > 0) {
|
|
119
|
-
for (const key of info.configDeclared) {
|
|
120
|
-
const item = info.configDef?.[key];
|
|
121
|
-
config[key] = {
|
|
122
|
-
...(item?.description !== undefined ? { description: item.description } : {}),
|
|
123
|
-
...(item?.default !== undefined ? { default: item.default } : {}),
|
|
124
|
-
secret: Boolean(item?.secret),
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const playbooks = [];
|
|
129
|
-
if (info.playbooksMap && info.playbooksMap.size > 0) {
|
|
130
|
-
for (const [id, pb] of info.playbooksMap.entries()) {
|
|
131
|
-
playbooks.push({
|
|
132
|
-
id,
|
|
133
|
-
...(pb?.description ? { description: pb.description } : {}),
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else if (info.playbooks && info.playbooks.length > 0) {
|
|
138
|
-
for (const pbId of info.playbooks) {
|
|
139
|
-
playbooks.push({ id: pbId });
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const actions = [];
|
|
143
|
-
if (info.actionsMap && info.actionsMap.size > 0) {
|
|
144
|
-
for (const [id, act] of info.actionsMap.entries()) {
|
|
145
|
-
actions.push({
|
|
146
|
-
id,
|
|
147
|
-
...(act?.description ? { description: act.description } : {}),
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else if (info.actions && info.actions.length > 0) {
|
|
152
|
-
for (const actId of info.actions) {
|
|
153
|
-
actions.push({ id: actId });
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const hints = [
|
|
157
|
-
"Tip: Run 'ad playbook show <id>' to inspect procedure steps before execution.",
|
|
158
|
-
];
|
|
159
|
-
if (info.configDeclared && info.configDeclared.length > 0) {
|
|
160
|
-
hints.push("Tip: Run 'ad config set <KEY> <val>' to configure required settings.");
|
|
161
|
-
}
|
|
162
|
-
const result = {
|
|
163
|
-
id: info.id,
|
|
164
|
-
name: info.name || info.id,
|
|
165
|
-
version: info.version || "0.0.0",
|
|
166
|
-
root: info.projectRoot,
|
|
167
|
-
config,
|
|
168
|
-
playbooks,
|
|
169
|
-
actions,
|
|
170
|
-
hints,
|
|
171
|
-
};
|
|
172
|
-
if (info.description) {
|
|
173
|
-
result.description = info.description;
|
|
174
|
-
}
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* 格式化渲染单个项目的元数据与详情信息。
|
|
179
|
-
*/
|
|
180
|
-
export function renderProjectDetail(info) {
|
|
181
|
-
const lines = [];
|
|
182
|
-
lines.push(`ActionDock Project: ${info.name} (${info.id})`);
|
|
183
|
-
lines.push(`Version: ${info.version}`);
|
|
184
|
-
if (info.description) {
|
|
185
|
-
lines.push(`Description: ${info.description}`);
|
|
186
|
-
}
|
|
187
|
-
lines.push(`Root: ${info.projectRoot}`);
|
|
188
|
-
if (info.configDeclared.length > 0) {
|
|
189
|
-
lines.push(`\nDeclared Config Keys (${info.configDeclared.length}):`);
|
|
190
|
-
for (const k of info.configDeclared) {
|
|
191
|
-
const item = info.configDef?.[k];
|
|
192
|
-
const isSec = item?.secret ? " [secret]" : "";
|
|
193
|
-
const def = item?.default !== undefined ? ` (default: ${JSON.stringify(item.default)})` : "";
|
|
194
|
-
lines.push(` - ${k.padEnd(24)} ${item?.description || ""}${def}${isSec}`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
lines.push(`\nPlaybooks (${info.playbooksCount}):`);
|
|
198
|
-
if (info.playbooksMap && info.playbooksMap.size > 0) {
|
|
199
|
-
for (const [id, pb] of info.playbooksMap.entries()) {
|
|
200
|
-
lines.push(` - ${id.padEnd(28)} ${pb.description || ""}`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
else if (info.playbooks && info.playbooks.length > 0) {
|
|
204
|
-
for (const pbId of info.playbooks) {
|
|
205
|
-
lines.push(` - ${pbId}`);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
lines.push(" (no playbooks declared)");
|
|
210
|
-
}
|
|
211
|
-
lines.push(`\nActions (${info.actionsCount}):`);
|
|
212
|
-
const actionList = [];
|
|
213
|
-
if (info.actionsMap) {
|
|
214
|
-
for (const [id, act] of info.actionsMap.entries()) {
|
|
215
|
-
actionList.push({ id, description: act.description || "" });
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (info.actions) {
|
|
219
|
-
for (const actId of info.actions) {
|
|
220
|
-
actionList.push({ id: actId, description: "" });
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
if (actionList.length === 0) {
|
|
224
|
-
lines.push(" (no actions declared)");
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
for (const a of actionList) {
|
|
228
|
-
lines.push(` - ${a.id.padEnd(28)} ${a.description}`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
lines.push("\nTip: Run 'ad playbook show <id>' to inspect procedure steps before execution.");
|
|
232
|
-
if (info.configDeclared.length > 0) {
|
|
233
|
-
lines.push("Tip: Run 'ad config set <KEY> <val>' to configure required settings.");
|
|
234
|
-
}
|
|
235
|
-
return lines.join("\n");
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* 格式化渲染已链接的多个 Package 摘要信息。
|
|
239
|
-
*/
|
|
240
|
-
export function renderAggregatedPackages(packages, options) {
|
|
241
|
-
const lines = [];
|
|
242
|
-
if (options?.header) {
|
|
243
|
-
lines.push(options.header);
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
lines.push(`ActionDock Linked Packages (${packages.length}):\n`);
|
|
247
|
-
}
|
|
248
|
-
for (const p of packages) {
|
|
249
|
-
lines.push(`- ${p.name} (${p.id}) v${p.version}`);
|
|
250
|
-
lines.push(` Path: ${p.path}`);
|
|
251
|
-
if (p.description) {
|
|
252
|
-
lines.push(` Desc: ${p.description}`);
|
|
253
|
-
}
|
|
254
|
-
lines.push(` Actions (${p.actionsCount}): ${p.actions.join(", ") || "(none)"}`);
|
|
255
|
-
lines.push(` Playbooks (${p.playbooksCount}): ${p.playbooks.join(", ") || "(none)"}`);
|
|
256
|
-
lines.push("");
|
|
257
|
-
}
|
|
258
|
-
if (options?.showTip !== false) {
|
|
259
|
-
lines.push("Tip: Run 'ad info <package-id>' to view detailed package configuration and schema.");
|
|
260
|
-
}
|
|
261
|
-
return lines.join("\n");
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* 格式化渲染注册表层级树结构。
|
|
265
|
-
*/
|
|
266
|
-
export function renderRegistryTree(status) {
|
|
267
|
-
const lines = [];
|
|
268
|
-
const workspaces = status.workspaces || [];
|
|
269
|
-
const packages = status.packages || [];
|
|
270
|
-
const hasWorkspaces = workspaces.length > 0;
|
|
271
|
-
const hasPackages = packages.length > 0;
|
|
272
|
-
if (!hasWorkspaces && !hasPackages) {
|
|
273
|
-
lines.push("[INFO] No ActionDock packages or workspaces currently linked.");
|
|
274
|
-
lines.push(" Run 'ad link' inside an Action package or workspace to register it.");
|
|
275
|
-
return lines.join("\n");
|
|
276
|
-
}
|
|
277
|
-
lines.push("[ActionDock Workspace & Package Tree]\n");
|
|
278
|
-
if (hasWorkspaces) {
|
|
279
|
-
lines.push("Workspaces:");
|
|
280
|
-
for (const ws of workspaces) {
|
|
281
|
-
const tag = ws.status === "active" ? "[OK]" : "[STALE]";
|
|
282
|
-
lines.push(` ${tag} ${ws.path} (${ws.packagesCount} package${ws.packagesCount === 1 ? "" : "s"})`);
|
|
283
|
-
if (ws.children && ws.children.length > 0) {
|
|
284
|
-
const children = ws.children;
|
|
285
|
-
children.forEach((child, idx) => {
|
|
286
|
-
const isLast = idx === children.length - 1;
|
|
287
|
-
const prefix = isLast ? " +-- " : " |-- ";
|
|
288
|
-
lines.push(`${prefix}${child.id} (v${child.version}) -> ${child.path}`);
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
if (hasPackages) {
|
|
294
|
-
if (hasWorkspaces)
|
|
295
|
-
lines.push("");
|
|
296
|
-
lines.push("Standalone Packages:");
|
|
297
|
-
for (const pkg of packages) {
|
|
298
|
-
const tag = pkg.status === "active" ? "[OK]" : "[STALE]";
|
|
299
|
-
lines.push(` ${tag} ${pkg.id} (v${pkg.version || "unknown"}) -> ${pkg.path}`);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
const totalActive = status.totalPackagesCount ?? packages.length;
|
|
303
|
-
lines.push(`\n[Summary] Total: ${totalActive} active package(s), ${workspaces.length} workspace(s)`);
|
|
304
|
-
if (status.staleCount && status.staleCount > 0) {
|
|
305
|
-
lines.push(`[WARN] ${status.staleCount} stale entry/entries detected. Run 'ad unlink --prune' to clean up.`);
|
|
306
|
-
}
|
|
307
|
-
return lines.join("\n");
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* 格式化渲染 Action 列表。
|
|
311
|
-
*/
|
|
312
|
-
export function renderActionList(items, title = "Actions", isFallback = false, intent) {
|
|
313
|
-
const lines = [];
|
|
314
|
-
lines.push(`${title}:\n`);
|
|
315
|
-
if (isFallback && intent) {
|
|
316
|
-
lines.push(`(No actions matched intent '${intent}', showing all actions)\n`);
|
|
317
|
-
}
|
|
318
|
-
if (items.length === 0) {
|
|
319
|
-
lines.push(" (no actions found)");
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
for (const a of items) {
|
|
323
|
-
lines.push(` - ${a.id.padEnd(28)} ${a.description}`);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
lines.push("\nTip: For composite or multi-step tasks, check 'ad playbook list' for standard operating procedures.");
|
|
327
|
-
return lines.join("\n");
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* 格式化渲染 Action 详情(编码顾问 Encoding Advisor)。
|
|
331
|
-
* 统一复用 core 下沉的 formatActionDetail 实现,与独立分发器保持完全一致。
|
|
332
|
-
*/
|
|
333
|
-
export function renderActionDetail(action) {
|
|
334
|
-
return formatActionDetail(action);
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* 格式化渲染 Action 校验结果。
|
|
338
|
-
*/
|
|
339
|
-
export function renderActionValidation(results) {
|
|
340
|
-
const lines = [];
|
|
341
|
-
for (const r of results) {
|
|
342
|
-
if (r.valid) {
|
|
343
|
-
lines.push(`[OK] ${r.id}: Valid`);
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
lines.push(`[FAIL] ${r.id}: ${r.errors.join(", ")}`);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
return lines.join("\n");
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* 格式化渲染 Playbook 列表。
|
|
353
|
-
*/
|
|
354
|
-
export function renderPlaybookList(items, title = "Playbooks", isFallback = false, intent) {
|
|
355
|
-
const lines = [];
|
|
356
|
-
lines.push(`${title}:\n`);
|
|
357
|
-
if (isFallback && intent) {
|
|
358
|
-
lines.push(`(No playbooks matched intent '${intent}', showing all playbooks)\n`);
|
|
359
|
-
}
|
|
360
|
-
if (items.length === 0) {
|
|
361
|
-
lines.push(" (no playbooks found)");
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
for (const p of items) {
|
|
365
|
-
const pkgDesc = p.packageId ? ` (Package: ${p.packageId})` : "";
|
|
366
|
-
lines.push(` - ${p.id.padEnd(26)} ${p.description}${pkgDesc}`);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
lines.push("\nTip: Run 'ad playbook show <id>' to inspect procedure steps before execution.");
|
|
370
|
-
return lines.join("\n");
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* 格式化渲染 Playbook 详情。
|
|
374
|
-
*/
|
|
375
|
-
export function renderPlaybookDetail(pb) {
|
|
376
|
-
const lines = [];
|
|
377
|
-
const pkgDesc = pb.packageId ? ` (Package: ${pb.packageId})` : "";
|
|
378
|
-
lines.push(`Playbook: ${pb.id}${pkgDesc}`);
|
|
379
|
-
if (pb.description)
|
|
380
|
-
lines.push(`Description: ${pb.description}`);
|
|
381
|
-
if (pb.actions && pb.actions.length > 0) {
|
|
382
|
-
lines.push(`Actions: ${pb.actions.join(", ")}`);
|
|
383
|
-
}
|
|
384
|
-
if (pb.filePath)
|
|
385
|
-
lines.push(`File: ${pb.filePath}\n`);
|
|
386
|
-
if (pb.content) {
|
|
387
|
-
lines.push("--- Content ---");
|
|
388
|
-
lines.push(pb.content);
|
|
389
|
-
}
|
|
390
|
-
lines.push("\nTip: Follow steps sequentially. Invoke constituent actions using 'ad run <action> [options] -- <assignments...>'.");
|
|
391
|
-
return lines.join("\n");
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* 格式化渲染配置项列表。
|
|
395
|
-
* 掩码决策收敛在命令层(传入的 value 已完成是否打码处理),
|
|
396
|
-
* 此处仅负责值的字符串格式化:字符串原样输出,其余类型 JSON 序列化。
|
|
397
|
-
*/
|
|
398
|
-
export function renderConfigList(items, scopeLabel = "Global Scope", isFallback = false, intent) {
|
|
399
|
-
const lines = [];
|
|
400
|
-
lines.push(`Configurations [${scopeLabel}]:\n`);
|
|
401
|
-
if (isFallback && intent) {
|
|
402
|
-
lines.push(`(No config entries matched intent '${intent}', showing all entries)\n`);
|
|
403
|
-
}
|
|
404
|
-
if (items.length === 0) {
|
|
405
|
-
lines.push(" (No configuration entries found)");
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
for (const item of items) {
|
|
409
|
-
const valStr = formatConfigValue(item.value);
|
|
410
|
-
const secretBadge = item.secret ? ", secret" : "";
|
|
411
|
-
lines.push(` - ${item.key.padEnd(24)} = ${valStr} (${item.source}${secretBadge})`);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return lines.join("\n");
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* 格式化配置值:字符串原样输出,其余类型 JSON 序列化。
|
|
418
|
-
*/
|
|
419
|
-
function formatConfigValue(value) {
|
|
420
|
-
return typeof value === "string" ? value : JSON.stringify(value);
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* 格式化渲染配置依赖规范检查。
|
|
424
|
-
*/
|
|
425
|
-
export function renderConfigSchema(items, packageId, root) {
|
|
426
|
-
const lines = [];
|
|
427
|
-
lines.push(`Configuration Requirements for ${packageId} (${root}):\n`);
|
|
428
|
-
if (items.length === 0) {
|
|
429
|
-
lines.push(" (No configuration dependencies declared for this package)");
|
|
430
|
-
return lines.join("\n");
|
|
431
|
-
}
|
|
432
|
-
lines.push(` ${"KEY".padEnd(24)} ${"STATUS".padEnd(12)} ${"SOURCE".padEnd(10)} ${"SECRET".padEnd(8)} DESCRIPTION`);
|
|
433
|
-
lines.push(" " + "-".repeat(85));
|
|
434
|
-
const missing = [];
|
|
435
|
-
for (const item of items) {
|
|
436
|
-
const statusLabel = item.status === "SET" ? "[SET]" : item.status === "DEFAULT" ? "[DEFAULT]" : "[MISSING]";
|
|
437
|
-
const secretLabel = item.secret ? "yes" : "no";
|
|
438
|
-
lines.push(` ${item.key.padEnd(24)} ${statusLabel.padEnd(12)} ${item.source.padEnd(10)} ${secretLabel.padEnd(8)} ${item.description}`);
|
|
439
|
-
if (item.status === "MISSING") {
|
|
440
|
-
missing.push(item.key);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
if (missing.length > 0) {
|
|
444
|
-
lines.push(`\n[WARNING] ${missing.length} required config(s) not set:`);
|
|
445
|
-
for (const m of missing) {
|
|
446
|
-
lines.push(` - ${m}: Run 'ad config set ${m} <value>' to configure.`);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
else {
|
|
450
|
-
lines.push("\n[OK] All configuration dependencies are satisfied.");
|
|
451
|
-
}
|
|
452
|
-
return lines.join("\n");
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* 格式化渲染环境变量满足率诊断。
|
|
456
|
-
*/
|
|
457
|
-
export function renderConfigEnv(checks, packageId) {
|
|
458
|
-
const lines = [];
|
|
459
|
-
const targetDesc = packageId ? `for Package '${packageId}'` : "Global";
|
|
460
|
-
lines.push(`Environment Variable Satisfaction Diagnostics ${targetDesc}:\n`);
|
|
461
|
-
if (checks.length === 0) {
|
|
462
|
-
lines.push(" (No configuration dependencies declared)");
|
|
463
|
-
return lines.join("\n");
|
|
464
|
-
}
|
|
465
|
-
lines.push(` ${"KEY".padEnd(24)} ${"SATISFIED".padEnd(12)} ${"REQUIRED".padEnd(10)} ${"MATCHED ENV".padEnd(28)} SECRET`);
|
|
466
|
-
lines.push(" " + "-".repeat(85));
|
|
467
|
-
for (const c of checks) {
|
|
468
|
-
const satLabel = c.satisfied ? "[OK]" : "[MISSING]";
|
|
469
|
-
const reqLabel = c.required ? "yes" : "no";
|
|
470
|
-
const matched = c.matchedEnv || (c.hasDefault ? "(using default)" : "-");
|
|
471
|
-
const secLabel = c.secret ? "yes" : "no";
|
|
472
|
-
lines.push(` ${c.key.padEnd(24)} ${satLabel.padEnd(12)} ${reqLabel.padEnd(10)} ${matched.padEnd(28)} ${secLabel}`);
|
|
473
|
-
}
|
|
474
|
-
const missingRequired = checks.filter((c) => c.required && !c.satisfied);
|
|
475
|
-
if (missingRequired.length > 0) {
|
|
476
|
-
lines.push(`\n[WARNING] ${missingRequired.length} required environment variable(s) not satisfied:`);
|
|
477
|
-
for (const m of missingRequired) {
|
|
478
|
-
lines.push(` - ${m.key}: Please export ${m.key}=... in your environment.`);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
lines.push("\n[OK] All declared configuration dependencies are satisfied by environment or defaults.");
|
|
483
|
-
}
|
|
484
|
-
return lines.join("\n");
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* 格式化渲染状态键列表。
|
|
488
|
-
*/
|
|
489
|
-
export function renderStateList(keys, scopeLabel = "Current State", isFallback = false, intent) {
|
|
490
|
-
const lines = [];
|
|
491
|
-
lines.push(`State keys for ${scopeLabel} (${keys.length}):\n`);
|
|
492
|
-
if (isFallback && intent) {
|
|
493
|
-
lines.push(`(No state keys matched intent '${intent}', showing all keys)\n`);
|
|
494
|
-
}
|
|
495
|
-
if (keys.length === 0) {
|
|
496
|
-
lines.push(" (no state keys found)");
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
for (const k of keys) {
|
|
500
|
-
lines.push(` - ${k}`);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
return lines.join("\n");
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* 格式化渲染执行记录列表。
|
|
507
|
-
*/
|
|
508
|
-
export function renderRunsList(items, scopeLabel = "Execution Runs", isFallback = false, intent) {
|
|
509
|
-
const lines = [];
|
|
510
|
-
lines.push(`${scopeLabel} (${items.length}):\n`);
|
|
511
|
-
if (isFallback && intent) {
|
|
512
|
-
lines.push(`(No runs matched intent '${intent}', showing all runs)\n`);
|
|
513
|
-
}
|
|
514
|
-
lines.push(` ${"RUN ID".padEnd(38)} ${"PACKAGE".padEnd(18)} ${"ACTION".padEnd(22)} ${"STATUS".padEnd(10)} STARTED`);
|
|
515
|
-
lines.push(" " + "-".repeat(105));
|
|
516
|
-
for (const r of items) {
|
|
517
|
-
const time = (r.startedAt || "").replace("T", " ").slice(0, 19);
|
|
518
|
-
const pkg = (r.packageId || "").padEnd(18);
|
|
519
|
-
lines.push(` ${r.id.padEnd(38)} ${pkg} ${r.actionId.padEnd(22)} ${r.status.padEnd(10)} ${time}`);
|
|
520
|
-
}
|
|
521
|
-
return lines.join("\n");
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* 格式化渲染单次执行记录详情。
|
|
525
|
-
*/
|
|
526
|
-
export function renderRunDetail(run) {
|
|
527
|
-
const lines = [];
|
|
528
|
-
lines.push(`Run: ${run.id}`);
|
|
529
|
-
lines.push(`Action: ${run.actionId}`);
|
|
530
|
-
if (run.packageId)
|
|
531
|
-
lines.push(`Package: ${run.packageId}`);
|
|
532
|
-
lines.push(`Status: ${run.status}`);
|
|
533
|
-
if (run.parentRunId)
|
|
534
|
-
lines.push(`Parent Run: ${run.parentRunId}`);
|
|
535
|
-
lines.push(`Started: ${run.startedAt}`);
|
|
536
|
-
if (run.finishedAt)
|
|
537
|
-
lines.push(`Finished: ${run.finishedAt}`);
|
|
538
|
-
lines.push("\nInput:");
|
|
539
|
-
lines.push(JSON.stringify(run.input, null, 2));
|
|
540
|
-
if (run.output !== undefined) {
|
|
541
|
-
lines.push("\nOutput:");
|
|
542
|
-
lines.push(JSON.stringify(run.output, null, 2));
|
|
543
|
-
}
|
|
544
|
-
if (run.error) {
|
|
545
|
-
lines.push("\nError:");
|
|
546
|
-
lines.push(JSON.stringify(run.error, null, 2));
|
|
547
|
-
}
|
|
548
|
-
return lines.join("\n");
|
|
549
|
-
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ActionSpec } from "@actiondock/core";
|
|
2
|
+
import { buildActionDescribePayload } from "@actiondock/core/project";
|
|
3
|
+
/**
|
|
4
|
+
* 解析 Action 注解中的默认正文输出字段声明。
|
|
5
|
+
*
|
|
6
|
+
* 契约规范:
|
|
7
|
+
* - 注解键名固定为 actiondock.cli,值必须为非空非数组对象。
|
|
8
|
+
* - 正文字段键名为 textField,值必须为非空字符串。
|
|
9
|
+
* - 无相关注解或未声明 textField 时返回 undefined。
|
|
10
|
+
* - 注解存在但类型非法时抛出 ExecutionError。
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveActionDefaultTextField(annotations?: Record<string, unknown>): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* 结构化正文与元数据抽取结果。
|
|
15
|
+
*/
|
|
16
|
+
export interface TextFieldExtractionResult {
|
|
17
|
+
text: string;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 从 Action 执行数据中抽取指定自有顶层正文字段及剩余元数据。
|
|
22
|
+
*
|
|
23
|
+
* 契约规范:
|
|
24
|
+
* - 仅支持结果数据的顶层自有字符串字段,拒绝通过原型链提取。
|
|
25
|
+
* - 结果数据本身必须为对象且不能为数组。
|
|
26
|
+
* - 目标字段必须存在且值为字符串(空字符串为合法有效正文)。
|
|
27
|
+
* - 剩余元数据安全构造,杜绝原型污染;元数据为空时返回 undefined。
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractTextFieldPayload(data: unknown, textField: string): TextFieldExtractionResult;
|
|
30
|
+
/**
|
|
31
|
+
* 格式化渲染 Action 列表。
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderActionList(items: Array<{
|
|
34
|
+
id: string;
|
|
35
|
+
description: string;
|
|
36
|
+
packageId?: string;
|
|
37
|
+
}>, title?: string, isFallback?: boolean, intent?: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* 格式化渲染 Action 详情人类可读文本。
|
|
40
|
+
*
|
|
41
|
+
* @param input Action 描述载荷或 Action 规范
|
|
42
|
+
* @returns 格式化后的说明文本
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatActionDetail(input: ReturnType<typeof buildActionDescribePayload> | (Partial<ActionSpec> & {
|
|
45
|
+
id: string;
|
|
46
|
+
}) | {
|
|
47
|
+
id: string;
|
|
48
|
+
packageId?: string;
|
|
49
|
+
projectRoot?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
inputSchema?: unknown;
|
|
52
|
+
outputSchema?: unknown;
|
|
53
|
+
tags?: string[];
|
|
54
|
+
annotations?: Record<string, unknown>;
|
|
55
|
+
uses?: string[];
|
|
56
|
+
entry?: string;
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}): string;
|
|
59
|
+
/**
|
|
60
|
+
* 格式化渲染 Action 详情(编码顾问 Encoding Advisor)。
|
|
61
|
+
* 统一复用 formatActionDetail 实现。
|
|
62
|
+
*/
|
|
63
|
+
export declare function renderActionDetail(action: {
|
|
64
|
+
id: string;
|
|
65
|
+
packageId?: string;
|
|
66
|
+
projectRoot?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
inputSchema?: unknown;
|
|
69
|
+
outputSchema?: unknown;
|
|
70
|
+
}): string;
|
|
71
|
+
/**
|
|
72
|
+
* 格式化渲染 Action 校验结果。
|
|
73
|
+
*/
|
|
74
|
+
export declare function renderActionValidation(results: Array<{
|
|
75
|
+
id: string;
|
|
76
|
+
valid: boolean;
|
|
77
|
+
errors: string[];
|
|
78
|
+
}>): string;
|