@ai-setting/roy-agent-cli 1.5.60 → 1.5.61
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/dist/bin/roy-agent.js +748 -441
- package/dist/index.js +748 -441
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +2 -2
package/dist/bin/roy-agent.js
CHANGED
|
@@ -7320,7 +7320,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7320
7320
|
var require_package = __commonJS((exports, module) => {
|
|
7321
7321
|
module.exports = {
|
|
7322
7322
|
name: "@ai-setting/roy-agent-cli",
|
|
7323
|
-
version: "1.5.
|
|
7323
|
+
version: "1.5.61",
|
|
7324
7324
|
type: "module",
|
|
7325
7325
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7326
7326
|
main: "./dist/index.js",
|
|
@@ -7347,7 +7347,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7347
7347
|
},
|
|
7348
7348
|
dependencies: {
|
|
7349
7349
|
"@ai-setting/roy-agent-coder-harness": "^1.5.48",
|
|
7350
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7350
|
+
"@ai-setting/roy-agent-core": "^1.5.60",
|
|
7351
7351
|
"@ai-setting/roy-agent-ontology-harness": "^1.5.47",
|
|
7352
7352
|
chalk: "^5.6.2",
|
|
7353
7353
|
commander: "^14.0.3",
|
|
@@ -11680,7 +11680,14 @@ var ListCommand2 = {
|
|
|
11680
11680
|
type: "string",
|
|
11681
11681
|
choices: ["normal", "cycle", "longterm"],
|
|
11682
11682
|
description: "按任务类型筛选"
|
|
11683
|
-
}).option("limit", { alias: "n", type: "number", default: 20, description: "返回数量" }).option("offset", { type: "number", default: 0, description: "偏移量" }).option("
|
|
11683
|
+
}).option("limit", { alias: "n", type: "number", default: 20, description: "返回数量" }).option("offset", { type: "number", default: 0, description: "偏移量" }).option("depth", {
|
|
11684
|
+
type: "number",
|
|
11685
|
+
description: "检索层级深度:0=只根任务(无父任务),1=根+一层子任务,2=根+二层子任务,-1 或忽略=全部"
|
|
11686
|
+
}).option("include-archived", {
|
|
11687
|
+
type: "boolean",
|
|
11688
|
+
default: false,
|
|
11689
|
+
description: "是否包含已归档任务(status=archived 的任务默认被排除)"
|
|
11690
|
+
}).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
11684
11691
|
async handler(args) {
|
|
11685
11692
|
const output = new OutputService;
|
|
11686
11693
|
const envService = new EnvironmentService(output);
|
|
@@ -11701,9 +11708,13 @@ var ListCommand2 = {
|
|
|
11701
11708
|
priority: args.priority,
|
|
11702
11709
|
type: args.type,
|
|
11703
11710
|
limit: args.limit,
|
|
11704
|
-
offset: args.offset
|
|
11711
|
+
offset: args.offset,
|
|
11712
|
+
depth: args.depth,
|
|
11713
|
+
include_archived: args.includeArchived
|
|
11705
11714
|
};
|
|
11706
|
-
const
|
|
11715
|
+
const listResult = await taskComponent.listTasks(listOptions);
|
|
11716
|
+
const tasks = listResult.tasks;
|
|
11717
|
+
const total = listResult.total;
|
|
11707
11718
|
if (args.json) {
|
|
11708
11719
|
output.json({
|
|
11709
11720
|
tasks: tasks.map((t) => ({
|
|
@@ -11719,7 +11730,10 @@ var ListCommand2 = {
|
|
|
11719
11730
|
createdAt: t.createdAt,
|
|
11720
11731
|
updatedAt: t.updatedAt
|
|
11721
11732
|
})),
|
|
11722
|
-
|
|
11733
|
+
total,
|
|
11734
|
+
count: tasks.length,
|
|
11735
|
+
limit: args.limit,
|
|
11736
|
+
offset: args.offset
|
|
11723
11737
|
});
|
|
11724
11738
|
} else if (args.quiet) {
|
|
11725
11739
|
tasks.forEach((t) => output.log(t.id.toString()));
|
|
@@ -11730,7 +11744,8 @@ var ListCommand2 = {
|
|
|
11730
11744
|
chalk16.bold("Status"),
|
|
11731
11745
|
chalk16.bold("Priority"),
|
|
11732
11746
|
chalk16.bold("Type"),
|
|
11733
|
-
chalk16.bold("Progress")
|
|
11747
|
+
chalk16.bold("Progress"),
|
|
11748
|
+
chalk16.bold("Parent")
|
|
11734
11749
|
].join(" │ ");
|
|
11735
11750
|
const rows = tasks.map((t, i) => {
|
|
11736
11751
|
const statusColor = t.status === "completed" ? chalk16.green : t.status === "active" ? chalk16.blue : t.status === "paused" ? chalk16.yellow : t.status === "cancelled" ? chalk16.strikethrough : chalk16.gray;
|
|
@@ -11741,9 +11756,12 @@ var ListCommand2 = {
|
|
|
11741
11756
|
statusColor(t.status),
|
|
11742
11757
|
priorityColor(t.priority),
|
|
11743
11758
|
t.type || "normal",
|
|
11744
|
-
`${t.progress}
|
|
11759
|
+
`${t.progress}%`,
|
|
11760
|
+
t.parent_task_id ? `#${t.parent_task_id}` : chalk16.gray("root")
|
|
11745
11761
|
].join(" │ ");
|
|
11746
11762
|
});
|
|
11763
|
+
const depthNote = args.depth !== undefined ? chalk16.gray(` depth=${args.depth}`) : "";
|
|
11764
|
+
const archivedNote = args.includeArchived ? chalk16.gray(" include-archived") : "";
|
|
11747
11765
|
output.log([
|
|
11748
11766
|
`┌─ Tasks ${"─".repeat(55)}┐`,
|
|
11749
11767
|
`│${header}│`,
|
|
@@ -11751,7 +11769,7 @@ var ListCommand2 = {
|
|
|
11751
11769
|
...rows.map((r) => `│${r}│`),
|
|
11752
11770
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
11753
11771
|
"",
|
|
11754
|
-
chalk16.gray(`
|
|
11772
|
+
chalk16.gray(`Showing ${tasks.length} of ${total} tasks (offset=${args.offset}, limit=${args.limit})${depthNote}${archivedNote}`)
|
|
11755
11773
|
].join(`
|
|
11756
11774
|
`));
|
|
11757
11775
|
}
|
|
@@ -11899,6 +11917,9 @@ var CreateCommand = {
|
|
|
11899
11917
|
}).option("project-path", {
|
|
11900
11918
|
type: "string",
|
|
11901
11919
|
description: "项目路径"
|
|
11920
|
+
}).option("parent-id", {
|
|
11921
|
+
type: "number",
|
|
11922
|
+
description: "父任务 ID(可选)"
|
|
11902
11923
|
}).option("context", {
|
|
11903
11924
|
type: "string",
|
|
11904
11925
|
description: "任务上下文 (JSON 字符串)"
|
|
@@ -11921,6 +11942,7 @@ var CreateCommand = {
|
|
|
11921
11942
|
}
|
|
11922
11943
|
const currentSessionId = sessionComponent?.getActiveSessionId() || "cli";
|
|
11923
11944
|
const createOptions = {
|
|
11945
|
+
parent_task_id: args["parent-id"],
|
|
11924
11946
|
title: args.title,
|
|
11925
11947
|
description: args.description,
|
|
11926
11948
|
priority: args.priority,
|
|
@@ -12105,7 +12127,7 @@ var CompleteCommand = {
|
|
|
12105
12127
|
type: "number",
|
|
12106
12128
|
describe: "任务 ID",
|
|
12107
12129
|
demandOption: true
|
|
12108
|
-
}).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }).option("plugin", {
|
|
12130
|
+
}).option("archive", { alias: "a", type: "boolean", default: false, description: "归档任务(设为 archived 状态而非完成)" }).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }).option("plugin", {
|
|
12109
12131
|
alias: "p",
|
|
12110
12132
|
type: "string",
|
|
12111
12133
|
array: true,
|
|
@@ -12131,7 +12153,21 @@ var CompleteCommand = {
|
|
|
12131
12153
|
process.exit(1);
|
|
12132
12154
|
}
|
|
12133
12155
|
const currentSessionId = sessionComponent?.getActiveSessionId() || "cli";
|
|
12134
|
-
|
|
12156
|
+
let task;
|
|
12157
|
+
if (args.archive) {
|
|
12158
|
+
task = await taskComponent.updateTask(args.id, { status: "archived" });
|
|
12159
|
+
if (task) {
|
|
12160
|
+
await taskComponent.createOperation({
|
|
12161
|
+
taskId: args.id,
|
|
12162
|
+
sessionId: currentSessionId,
|
|
12163
|
+
actionType: "completed",
|
|
12164
|
+
actionTitle: "Task archived",
|
|
12165
|
+
actionDescription: "归档任务"
|
|
12166
|
+
});
|
|
12167
|
+
}
|
|
12168
|
+
} else {
|
|
12169
|
+
task = await taskComponent.completeTask(args.id, currentSessionId);
|
|
12170
|
+
}
|
|
12135
12171
|
if (!task) {
|
|
12136
12172
|
output.error(`Task not found: ${args.id}`);
|
|
12137
12173
|
process.exit(1);
|
|
@@ -12232,6 +12268,276 @@ Operations for Task #${task.id}: ${task.title}
|
|
|
12232
12268
|
}
|
|
12233
12269
|
};
|
|
12234
12270
|
|
|
12271
|
+
// src/commands/tasks/tree.ts
|
|
12272
|
+
import chalk23 from "chalk";
|
|
12273
|
+
function buildTree(tasks) {
|
|
12274
|
+
const byParent = new Map;
|
|
12275
|
+
const nodeById = new Map;
|
|
12276
|
+
const roots = [];
|
|
12277
|
+
for (const t of tasks) {
|
|
12278
|
+
nodeById.set(t.id, { task: t, children: [] });
|
|
12279
|
+
}
|
|
12280
|
+
for (const t of tasks) {
|
|
12281
|
+
if (t.parent_task_id !== undefined && t.parent_task_id !== null && nodeById.has(t.parent_task_id)) {
|
|
12282
|
+
const list = byParent.get(t.parent_task_id) || [];
|
|
12283
|
+
list.push(t);
|
|
12284
|
+
byParent.set(t.parent_task_id, list);
|
|
12285
|
+
} else {
|
|
12286
|
+
roots.push(t);
|
|
12287
|
+
}
|
|
12288
|
+
}
|
|
12289
|
+
for (const [parentId, children] of byParent.entries()) {
|
|
12290
|
+
const parentNode = nodeById.get(parentId);
|
|
12291
|
+
children.sort((a, b) => a.updatedAt < b.updatedAt ? 1 : -1);
|
|
12292
|
+
parentNode.children = children.map((c) => nodeById.get(c.id));
|
|
12293
|
+
}
|
|
12294
|
+
roots.sort((a, b) => a.updatedAt < b.updatedAt ? 1 : -1);
|
|
12295
|
+
return roots.map((r) => nodeById.get(r.id));
|
|
12296
|
+
}
|
|
12297
|
+
function printTree(nodes, prefix, isRoot, output, currentDepth, maxDepth) {
|
|
12298
|
+
if (maxDepth !== undefined && currentDepth > maxDepth)
|
|
12299
|
+
return;
|
|
12300
|
+
for (let i = 0;i < nodes.length; i++) {
|
|
12301
|
+
const node = nodes[i];
|
|
12302
|
+
const isLast = i === nodes.length - 1;
|
|
12303
|
+
const connector = isRoot ? "" : isLast ? "└─ " : "├─ ";
|
|
12304
|
+
const statusColor = colorByStatus(node.task.status);
|
|
12305
|
+
const typeLabel = node.task.type ? ` [${node.task.type}]` : "";
|
|
12306
|
+
const progressLabel = node.task.progress > 0 ? ` (${node.task.progress}%)` : "";
|
|
12307
|
+
const header = `#${node.task.id}${typeLabel} ${node.task.title} ${chalk23.gray("[" + node.task.status + "]")}${progressLabel}`;
|
|
12308
|
+
output.log(prefix + connector + statusColor(header));
|
|
12309
|
+
if (node.children.length > 0) {
|
|
12310
|
+
const childPrefix = isRoot ? prefix : prefix + (isLast ? " " : "│ ");
|
|
12311
|
+
printTree(node.children, childPrefix, false, output, currentDepth + 1, maxDepth);
|
|
12312
|
+
}
|
|
12313
|
+
}
|
|
12314
|
+
}
|
|
12315
|
+
function colorByStatus(status) {
|
|
12316
|
+
switch (status) {
|
|
12317
|
+
case "completed":
|
|
12318
|
+
return chalk23.green;
|
|
12319
|
+
case "active":
|
|
12320
|
+
return chalk23.blue;
|
|
12321
|
+
case "paused":
|
|
12322
|
+
return chalk23.yellow;
|
|
12323
|
+
case "cancelled":
|
|
12324
|
+
return chalk23.strikethrough;
|
|
12325
|
+
default:
|
|
12326
|
+
return chalk23.gray;
|
|
12327
|
+
}
|
|
12328
|
+
}
|
|
12329
|
+
var TreeCommand = {
|
|
12330
|
+
command: "tree",
|
|
12331
|
+
describe: "以树形结构展示所有任务(基于 parent_task_id)",
|
|
12332
|
+
builder: (yargs) => yargs.option("status", {
|
|
12333
|
+
alias: "s",
|
|
12334
|
+
type: "string",
|
|
12335
|
+
choices: ["todo", "active", "completed", "paused", "cancelled"],
|
|
12336
|
+
description: "按状态筛选"
|
|
12337
|
+
}).option("priority", {
|
|
12338
|
+
alias: "p",
|
|
12339
|
+
type: "string",
|
|
12340
|
+
choices: ["low", "medium", "high"],
|
|
12341
|
+
description: "按优先级筛选"
|
|
12342
|
+
}).option("type", {
|
|
12343
|
+
type: "string",
|
|
12344
|
+
choices: ["normal", "cycle", "longterm"],
|
|
12345
|
+
description: "按任务类型筛选"
|
|
12346
|
+
}).option("root-id", {
|
|
12347
|
+
type: "number",
|
|
12348
|
+
description: "以指定任务 ID 作为根开始构建子树(仅展示该任务及其后代)"
|
|
12349
|
+
}).option("max-depth", {
|
|
12350
|
+
type: "number",
|
|
12351
|
+
description: "最大展示深度(不限层级请忽略)"
|
|
12352
|
+
}).option("json", {
|
|
12353
|
+
alias: "j",
|
|
12354
|
+
type: "boolean",
|
|
12355
|
+
default: false,
|
|
12356
|
+
description: "以 JSON 格式输出树形结构"
|
|
12357
|
+
}),
|
|
12358
|
+
async handler(args) {
|
|
12359
|
+
const output = new OutputService;
|
|
12360
|
+
const envService = new EnvironmentService(output);
|
|
12361
|
+
try {
|
|
12362
|
+
await envService.create({ configPath: args.config });
|
|
12363
|
+
const env = envService.getEnvironment();
|
|
12364
|
+
if (!env) {
|
|
12365
|
+
output.error("Failed to create environment");
|
|
12366
|
+
process.exit(1);
|
|
12367
|
+
}
|
|
12368
|
+
const taskComponent = env.getComponent("task");
|
|
12369
|
+
if (!taskComponent) {
|
|
12370
|
+
output.error("TaskComponent not available");
|
|
12371
|
+
process.exit(1);
|
|
12372
|
+
}
|
|
12373
|
+
const listOptions = {
|
|
12374
|
+
status: args.status,
|
|
12375
|
+
priority: args.priority,
|
|
12376
|
+
type: args.type,
|
|
12377
|
+
limit: 9999
|
|
12378
|
+
};
|
|
12379
|
+
const listResult = await taskComponent.listTasks(listOptions);
|
|
12380
|
+
let tasks = listResult.tasks;
|
|
12381
|
+
if (args.rootId !== undefined) {
|
|
12382
|
+
const rootId = args.rootId;
|
|
12383
|
+
const root = tasks.find((t) => t.id === rootId);
|
|
12384
|
+
if (!root) {
|
|
12385
|
+
output.error(`Task #${rootId} not found`);
|
|
12386
|
+
process.exit(1);
|
|
12387
|
+
}
|
|
12388
|
+
const allowed = new Set([rootId]);
|
|
12389
|
+
let frontier = [rootId];
|
|
12390
|
+
while (frontier.length > 0) {
|
|
12391
|
+
const next = [];
|
|
12392
|
+
for (const t of tasks) {
|
|
12393
|
+
if (t.parent_task_id !== undefined && frontier.includes(t.parent_task_id) && !allowed.has(t.id)) {
|
|
12394
|
+
allowed.add(t.id);
|
|
12395
|
+
next.push(t.id);
|
|
12396
|
+
}
|
|
12397
|
+
}
|
|
12398
|
+
frontier = next;
|
|
12399
|
+
}
|
|
12400
|
+
tasks = tasks.filter((t) => allowed.has(t.id));
|
|
12401
|
+
}
|
|
12402
|
+
if (args.json) {
|
|
12403
|
+
const tree2 = buildTree(tasks);
|
|
12404
|
+
output.json({
|
|
12405
|
+
total: tasks.length,
|
|
12406
|
+
rootCount: tree2.length,
|
|
12407
|
+
tree: tree2
|
|
12408
|
+
});
|
|
12409
|
+
return;
|
|
12410
|
+
}
|
|
12411
|
+
const tree = buildTree(tasks);
|
|
12412
|
+
if (tree.length === 0) {
|
|
12413
|
+
output.log(chalk23.gray("No tasks to display."));
|
|
12414
|
+
return;
|
|
12415
|
+
}
|
|
12416
|
+
output.log(chalk23.bold(`Task Tree (${tasks.length} tasks, ${tree.length} roots)`) + (args.rootId !== undefined ? chalk23.gray(` — subtree of #${args.rootId}`) : ""));
|
|
12417
|
+
output.log("");
|
|
12418
|
+
printTree(tree, "", true, output, 0, args.maxDepth);
|
|
12419
|
+
} catch (error) {
|
|
12420
|
+
output.error(`Failed to build task tree: ${error}`);
|
|
12421
|
+
process.exit(1);
|
|
12422
|
+
} finally {
|
|
12423
|
+
await envService.dispose();
|
|
12424
|
+
}
|
|
12425
|
+
}
|
|
12426
|
+
};
|
|
12427
|
+
|
|
12428
|
+
// src/commands/tasks/search.ts
|
|
12429
|
+
import chalk24 from "chalk";
|
|
12430
|
+
var SearchCommand = {
|
|
12431
|
+
command: "search <keywords..>",
|
|
12432
|
+
aliases: ["find", "grep"],
|
|
12433
|
+
describe: "关键词搜索任务(匹配 title/description/goals/tags/operations)",
|
|
12434
|
+
builder: (yargs) => yargs.positional("keywords", {
|
|
12435
|
+
type: "string",
|
|
12436
|
+
array: true,
|
|
12437
|
+
describe: "搜索关键词(多个关键词 AND 逻辑)",
|
|
12438
|
+
demandOption: true
|
|
12439
|
+
}).option("limit", { alias: "n", type: "number", default: 20, description: "返回数量" }).option("offset", { type: "number", default: 0, description: "偏移量" }).option("status", {
|
|
12440
|
+
alias: "s",
|
|
12441
|
+
type: "string",
|
|
12442
|
+
choices: ["todo", "active", "completed", "paused", "cancelled", "archived"],
|
|
12443
|
+
description: "按状态筛选"
|
|
12444
|
+
}).option("priority", {
|
|
12445
|
+
alias: "p",
|
|
12446
|
+
type: "string",
|
|
12447
|
+
choices: ["low", "medium", "high"],
|
|
12448
|
+
description: "按优先级筛选"
|
|
12449
|
+
}).option("type", {
|
|
12450
|
+
type: "string",
|
|
12451
|
+
choices: ["normal", "cycle", "longterm"],
|
|
12452
|
+
description: "按任务类型筛选"
|
|
12453
|
+
}).option("depth", {
|
|
12454
|
+
type: "number",
|
|
12455
|
+
description: "检索层级深度:0=只根任务,1=根+一层子任务,2=根+二层子任务"
|
|
12456
|
+
}).option("include-archived", {
|
|
12457
|
+
type: "boolean",
|
|
12458
|
+
default: false,
|
|
12459
|
+
description: "是否包含已归档任务"
|
|
12460
|
+
}).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
12461
|
+
async handler(args) {
|
|
12462
|
+
const output = new OutputService;
|
|
12463
|
+
const envService = new EnvironmentService(output);
|
|
12464
|
+
try {
|
|
12465
|
+
await envService.create({ configPath: args.config });
|
|
12466
|
+
const env = envService.getEnvironment();
|
|
12467
|
+
if (!env) {
|
|
12468
|
+
output.error("Failed to create environment");
|
|
12469
|
+
process.exit(1);
|
|
12470
|
+
}
|
|
12471
|
+
const taskComponent = env.getComponent("task");
|
|
12472
|
+
if (!taskComponent) {
|
|
12473
|
+
output.error("TaskComponent not available");
|
|
12474
|
+
process.exit(1);
|
|
12475
|
+
}
|
|
12476
|
+
const result = await taskComponent.searchTasksByKeywords(args.keywords, {
|
|
12477
|
+
limit: args.limit,
|
|
12478
|
+
offset: args.offset,
|
|
12479
|
+
status: args.status,
|
|
12480
|
+
priority: args.priority,
|
|
12481
|
+
type: args.type,
|
|
12482
|
+
depth: args.depth,
|
|
12483
|
+
include_archived: args.includeArchived
|
|
12484
|
+
});
|
|
12485
|
+
const tasks = result.tasks;
|
|
12486
|
+
const total = result.total;
|
|
12487
|
+
if (args.json) {
|
|
12488
|
+
output.json({
|
|
12489
|
+
keywords: args.keywords,
|
|
12490
|
+
tasks: tasks.map((t) => ({
|
|
12491
|
+
id: t.id,
|
|
12492
|
+
title: t.title,
|
|
12493
|
+
status: t.status,
|
|
12494
|
+
priority: t.priority,
|
|
12495
|
+
type: t.type,
|
|
12496
|
+
progress: t.progress,
|
|
12497
|
+
parent_task_id: t.parent_task_id,
|
|
12498
|
+
project_path: t.project_path,
|
|
12499
|
+
createdAt: t.createdAt,
|
|
12500
|
+
updatedAt: t.updatedAt
|
|
12501
|
+
})),
|
|
12502
|
+
total,
|
|
12503
|
+
count: tasks.length,
|
|
12504
|
+
limit: args.limit,
|
|
12505
|
+
offset: args.offset
|
|
12506
|
+
});
|
|
12507
|
+
} else if (args.quiet) {
|
|
12508
|
+
tasks.forEach((t) => output.log(t.id.toString()));
|
|
12509
|
+
} else {
|
|
12510
|
+
const keywordStr = args.keywords.join(" ");
|
|
12511
|
+
output.log(chalk24.bold(`
|
|
12512
|
+
\uD83D\uDD0D Search: "${keywordStr}" — ${total} results
|
|
12513
|
+
`));
|
|
12514
|
+
if (tasks.length === 0) {
|
|
12515
|
+
output.log(chalk24.gray(" No matching tasks found."));
|
|
12516
|
+
return;
|
|
12517
|
+
}
|
|
12518
|
+
for (const t of tasks) {
|
|
12519
|
+
const statusColor = t.status === "completed" ? chalk24.green : t.status === "active" ? chalk24.blue : t.status === "paused" ? chalk24.yellow : t.status === "cancelled" ? chalk24.strikethrough : t.status === "archived" ? chalk24.gray : chalk24.gray;
|
|
12520
|
+
const pid = t.parent_task_id ? chalk24.gray(` (#${t.parent_task_id})`) : "";
|
|
12521
|
+
output.log(` #${t.id} ${statusColor("[" + t.status + "]")} ${t.title}${pid}`);
|
|
12522
|
+
if (t.current_status) {
|
|
12523
|
+
output.log(` ${chalk24.gray(t.current_status.slice(0, 80))}`);
|
|
12524
|
+
}
|
|
12525
|
+
}
|
|
12526
|
+
if (total > tasks.length) {
|
|
12527
|
+
output.log(chalk24.gray(`
|
|
12528
|
+
... and ${total - tasks.length} more. Use --offset and --limit to paginate.`));
|
|
12529
|
+
}
|
|
12530
|
+
output.log(chalk24.gray(` Page: ${Math.floor((args.offset || 0) / (args.limit || 20)) + 1}/${Math.ceil(total / (args.limit || 20))}`));
|
|
12531
|
+
}
|
|
12532
|
+
} catch (error) {
|
|
12533
|
+
output.error(`Failed to search tasks: ${error}`);
|
|
12534
|
+
process.exit(1);
|
|
12535
|
+
} finally {
|
|
12536
|
+
await envService.dispose();
|
|
12537
|
+
}
|
|
12538
|
+
}
|
|
12539
|
+
};
|
|
12540
|
+
|
|
12235
12541
|
// src/commands/tasks/organize.ts
|
|
12236
12542
|
var command = "organize";
|
|
12237
12543
|
var desc = "整理系统中的任务(清理测试任务、聚合相似任务、构建任务树)";
|
|
@@ -12420,9 +12726,10 @@ var handler = async (args) => {
|
|
|
12420
12726
|
const { getDefaultTaskDbPath, SQLiteTaskStore } = await import("@ai-setting/roy-agent-core");
|
|
12421
12727
|
const store = new SQLiteTaskStore(getDefaultTaskDbPath());
|
|
12422
12728
|
await store.initialize?.();
|
|
12423
|
-
const
|
|
12729
|
+
const listResult = await store.listTasks({ limit: 9999 });
|
|
12730
|
+
const allTasks = listResult.tasks;
|
|
12424
12731
|
console.log(`
|
|
12425
|
-
\uD83D\uDCCA 系统中共有 ` + allTasks.length +
|
|
12732
|
+
\uD83D\uDCCA 系统中共有 ` + allTasks.length + " 个任务 (total=" + listResult.total + `)
|
|
12426
12733
|
`);
|
|
12427
12734
|
const report = [];
|
|
12428
12735
|
if (args.deleteTest || args.auto) {
|
|
@@ -12473,14 +12780,14 @@ var TasksCommand = {
|
|
|
12473
12780
|
array: true,
|
|
12474
12781
|
description: "Enable plugin (e.g., --plugin task-tag)",
|
|
12475
12782
|
global: false
|
|
12476
|
-
}).command(ListCommand2).command(GetCommand2).command(CreateCommand).command(UpdateCommand).command(DeleteCommand2).command(CompleteCommand).command(OperationsCommand).command(OrganizeCommand).demandCommand().help(),
|
|
12783
|
+
}).command(ListCommand2).command(SearchCommand).command(TreeCommand).command(GetCommand2).command(CreateCommand).command(UpdateCommand).command(DeleteCommand2).command(CompleteCommand).command(OperationsCommand).command(OrganizeCommand).demandCommand().help(),
|
|
12477
12784
|
handler: () => {
|
|
12478
12785
|
console.log("Use 'roy-agent tasks --help' for usage information");
|
|
12479
12786
|
}
|
|
12480
12787
|
};
|
|
12481
12788
|
|
|
12482
12789
|
// src/commands/skills/list.ts
|
|
12483
|
-
import
|
|
12790
|
+
import chalk25 from "chalk";
|
|
12484
12791
|
var ListCommand3 = {
|
|
12485
12792
|
command: "list",
|
|
12486
12793
|
aliases: ["ls"],
|
|
@@ -12533,26 +12840,26 @@ var ListCommand3 = {
|
|
|
12533
12840
|
filtered.forEach((s) => output.log(s.name));
|
|
12534
12841
|
} else {
|
|
12535
12842
|
const header = [
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12843
|
+
chalk25.bold("Name"),
|
|
12844
|
+
chalk25.bold("Description"),
|
|
12845
|
+
chalk25.bold("Source")
|
|
12539
12846
|
].join(" | ");
|
|
12540
12847
|
const sourceColor = (source) => {
|
|
12541
12848
|
switch (source) {
|
|
12542
12849
|
case "project":
|
|
12543
|
-
return
|
|
12850
|
+
return chalk25.green;
|
|
12544
12851
|
case "user":
|
|
12545
|
-
return
|
|
12852
|
+
return chalk25.blue;
|
|
12546
12853
|
case "built-in":
|
|
12547
|
-
return
|
|
12854
|
+
return chalk25.gray;
|
|
12548
12855
|
default:
|
|
12549
|
-
return
|
|
12856
|
+
return chalk25.white;
|
|
12550
12857
|
}
|
|
12551
12858
|
};
|
|
12552
12859
|
const rows = filtered.map((s) => {
|
|
12553
12860
|
const desc2 = s.description.length > 50 ? s.description.slice(0, 47) + "..." : s.description;
|
|
12554
12861
|
return [
|
|
12555
|
-
|
|
12862
|
+
chalk25.cyan(s.name),
|
|
12556
12863
|
desc2,
|
|
12557
12864
|
sourceColor(s.source)(`[${s.source}]`)
|
|
12558
12865
|
].join(" | ");
|
|
@@ -12564,7 +12871,7 @@ var ListCommand3 = {
|
|
|
12564
12871
|
...rows.map((r) => `│${r}│`),
|
|
12565
12872
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
12566
12873
|
"",
|
|
12567
|
-
|
|
12874
|
+
chalk25.gray(`Total: ${filtered.length} skills`)
|
|
12568
12875
|
].join(`
|
|
12569
12876
|
`));
|
|
12570
12877
|
}
|
|
@@ -12578,7 +12885,7 @@ var ListCommand3 = {
|
|
|
12578
12885
|
};
|
|
12579
12886
|
|
|
12580
12887
|
// src/commands/skills/get.ts
|
|
12581
|
-
import
|
|
12888
|
+
import chalk26 from "chalk";
|
|
12582
12889
|
var GetCommand3 = {
|
|
12583
12890
|
command: "get <name>",
|
|
12584
12891
|
describe: "获取指定技能内容",
|
|
@@ -12622,13 +12929,13 @@ var GetCommand3 = {
|
|
|
12622
12929
|
content: skill.content
|
|
12623
12930
|
});
|
|
12624
12931
|
} else {
|
|
12625
|
-
output.log(
|
|
12932
|
+
output.log(chalk26.bold.cyan(`# ${skill.name}`));
|
|
12626
12933
|
output.log("");
|
|
12627
|
-
output.log(`${
|
|
12628
|
-
output.log(`${
|
|
12629
|
-
output.log(`${
|
|
12934
|
+
output.log(`${chalk26.gray("Description:")} ${skill.description}`);
|
|
12935
|
+
output.log(`${chalk26.gray("Source:")} ${skill.source}`);
|
|
12936
|
+
output.log(`${chalk26.gray("File:")} ${skill.filePath}`);
|
|
12630
12937
|
output.log("");
|
|
12631
|
-
output.log(
|
|
12938
|
+
output.log(chalk26.bold("--- Content ---"));
|
|
12632
12939
|
output.log("");
|
|
12633
12940
|
output.log(skill.content);
|
|
12634
12941
|
}
|
|
@@ -12642,8 +12949,8 @@ var GetCommand3 = {
|
|
|
12642
12949
|
};
|
|
12643
12950
|
|
|
12644
12951
|
// src/commands/skills/search.ts
|
|
12645
|
-
import
|
|
12646
|
-
var
|
|
12952
|
+
import chalk27 from "chalk";
|
|
12953
|
+
var SearchCommand2 = {
|
|
12647
12954
|
command: "search <term>",
|
|
12648
12955
|
aliases: ["find"],
|
|
12649
12956
|
describe: "搜索技能(按名称或描述)",
|
|
@@ -12681,7 +12988,7 @@ var SearchCommand = {
|
|
|
12681
12988
|
const term = args.term.toLowerCase();
|
|
12682
12989
|
const results = allSkills.filter((s) => s.name.toLowerCase().includes(term) || s.description.toLowerCase().includes(term));
|
|
12683
12990
|
if (results.length === 0) {
|
|
12684
|
-
output.log(
|
|
12991
|
+
output.log(chalk27.yellow(`No skills found matching: ${args.term}`));
|
|
12685
12992
|
return;
|
|
12686
12993
|
}
|
|
12687
12994
|
if (args.json) {
|
|
@@ -12698,19 +13005,19 @@ var SearchCommand = {
|
|
|
12698
13005
|
} else if (args.quiet) {
|
|
12699
13006
|
results.forEach((s) => output.log(s.name));
|
|
12700
13007
|
} else {
|
|
12701
|
-
output.log(
|
|
13008
|
+
output.log(chalk27.bold(`Search results for "${args.term}":`));
|
|
12702
13009
|
output.log("");
|
|
12703
13010
|
const header = [
|
|
12704
|
-
|
|
12705
|
-
|
|
12706
|
-
|
|
13011
|
+
chalk27.bold("Name"),
|
|
13012
|
+
chalk27.bold("Description"),
|
|
13013
|
+
chalk27.bold("Match")
|
|
12707
13014
|
].join(" | ");
|
|
12708
13015
|
const rows = results.map((s) => {
|
|
12709
13016
|
const matchedIn = s.name.toLowerCase().includes(term) ? "name" : "description";
|
|
12710
|
-
const matchColor = matchedIn === "name" ?
|
|
13017
|
+
const matchColor = matchedIn === "name" ? chalk27.green : chalk27.blue;
|
|
12711
13018
|
const desc2 = s.description.length > 40 ? s.description.slice(0, 37) + "..." : s.description;
|
|
12712
13019
|
return [
|
|
12713
|
-
|
|
13020
|
+
chalk27.cyan(s.name),
|
|
12714
13021
|
desc2,
|
|
12715
13022
|
matchColor(`[${matchedIn}]`)
|
|
12716
13023
|
].join(" | ");
|
|
@@ -12722,7 +13029,7 @@ var SearchCommand = {
|
|
|
12722
13029
|
...rows.map((r) => `│${r}│`),
|
|
12723
13030
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
12724
13031
|
"",
|
|
12725
|
-
|
|
13032
|
+
chalk27.gray(`${results.length} matching skill(s) found.`)
|
|
12726
13033
|
].join(`
|
|
12727
13034
|
`));
|
|
12728
13035
|
}
|
|
@@ -12736,7 +13043,7 @@ var SearchCommand = {
|
|
|
12736
13043
|
};
|
|
12737
13044
|
|
|
12738
13045
|
// src/commands/skills/reload.ts
|
|
12739
|
-
import
|
|
13046
|
+
import chalk28 from "chalk";
|
|
12740
13047
|
var ReloadCommand = {
|
|
12741
13048
|
command: "reload",
|
|
12742
13049
|
describe: "重新扫描并更新 SkillTool",
|
|
@@ -12759,10 +13066,10 @@ var ReloadCommand = {
|
|
|
12759
13066
|
output.error("SkillComponent not available");
|
|
12760
13067
|
process.exit(1);
|
|
12761
13068
|
}
|
|
12762
|
-
output.log(
|
|
13069
|
+
output.log(chalk28.blue("Reloading skills..."));
|
|
12763
13070
|
await skillComponent.reload();
|
|
12764
13071
|
const skills = skillComponent.getSkillList();
|
|
12765
|
-
output.log(
|
|
13072
|
+
output.log(chalk28.green(`Successfully reloaded ${skills.length} skills`));
|
|
12766
13073
|
} catch (error) {
|
|
12767
13074
|
output.error(`Failed to reload skills: ${error}`);
|
|
12768
13075
|
process.exit(1);
|
|
@@ -12773,7 +13080,7 @@ var ReloadCommand = {
|
|
|
12773
13080
|
};
|
|
12774
13081
|
|
|
12775
13082
|
// src/commands/skills/show-config.ts
|
|
12776
|
-
import
|
|
13083
|
+
import chalk29 from "chalk";
|
|
12777
13084
|
var ShowConfigCommand = {
|
|
12778
13085
|
command: "show-config",
|
|
12779
13086
|
aliases: ["config"],
|
|
@@ -12798,38 +13105,38 @@ var ShowConfigCommand = {
|
|
|
12798
13105
|
process.exit(1);
|
|
12799
13106
|
}
|
|
12800
13107
|
const defaultConfig = skillComponent.getConfig?.();
|
|
12801
|
-
output.log(
|
|
13108
|
+
output.log(chalk29.bold.cyan(`# Skills Configuration
|
|
12802
13109
|
`));
|
|
12803
|
-
output.log(
|
|
13110
|
+
output.log(chalk29.bold(`## Scan Paths
|
|
12804
13111
|
`));
|
|
12805
13112
|
const paths = [
|
|
12806
13113
|
{ type: "user", desc: "用户路径", path: "~/.config/roy-agent/skills/" },
|
|
12807
13114
|
{ type: "project", desc: "项目路径", path: ".roy/skills/" }
|
|
12808
13115
|
];
|
|
12809
13116
|
for (const p of paths) {
|
|
12810
|
-
const typeColor = p.type === "project" ?
|
|
12811
|
-
output.log(` ${typeColor("[ " + p.type + " ]")} ${
|
|
12812
|
-
output.log(` ${
|
|
13117
|
+
const typeColor = p.type === "project" ? chalk29.green : chalk29.blue;
|
|
13118
|
+
output.log(` ${typeColor("[ " + p.type + " ]")} ${chalk29.gray(p.desc)}`);
|
|
13119
|
+
output.log(` ${chalk29.cyan(p.path)}
|
|
12813
13120
|
`);
|
|
12814
13121
|
}
|
|
12815
|
-
output.log(
|
|
13122
|
+
output.log(chalk29.bold(`## Scan Rules
|
|
12816
13123
|
`));
|
|
12817
|
-
output.log(` ${
|
|
12818
|
-
output.log(` ${
|
|
12819
|
-
output.log(` ${
|
|
13124
|
+
output.log(` ${chalk29.gray("Pattern:")} ${chalk29.cyan("**/SKILL.md")}`);
|
|
13125
|
+
output.log(` ${chalk29.gray("Recursive:")} ${chalk29.green("true")}`);
|
|
13126
|
+
output.log(` ${chalk29.gray("Ignore:")} ${chalk29.cyan("**/node_modules/**")}
|
|
12820
13127
|
`);
|
|
12821
|
-
output.log(
|
|
13128
|
+
output.log(chalk29.bold(`## Priority (High to Low)
|
|
12822
13129
|
`));
|
|
12823
|
-
output.log(` ${
|
|
12824
|
-
output.log(` ${
|
|
12825
|
-
output.log(` ${
|
|
13130
|
+
output.log(` ${chalk29.green("1. project")} - 项目路径(最高优先级)`);
|
|
13131
|
+
output.log(` ${chalk29.blue("2. user")} - 用户路径`);
|
|
13132
|
+
output.log(` ${chalk29.gray("3. built-in")} - 内置路径(预留)
|
|
12826
13133
|
`);
|
|
12827
|
-
output.log(
|
|
13134
|
+
output.log(chalk29.bold(`## Usage
|
|
12828
13135
|
`));
|
|
12829
|
-
output.log(` ${
|
|
12830
|
-
output.log(` ${
|
|
12831
|
-
output.log(` ${
|
|
12832
|
-
output.log(` ${
|
|
13136
|
+
output.log(` ${chalk29.cyan("roy-agent skills list")} ${chalk29.gray("- 列出所有技能")}`);
|
|
13137
|
+
output.log(` ${chalk29.cyan("roy-agent skills get <name>")} ${chalk29.gray("- 获取技能内容")}`);
|
|
13138
|
+
output.log(` ${chalk29.cyan("roy-agent skills search <term>")} ${chalk29.gray("- 搜索技能")}`);
|
|
13139
|
+
output.log(` ${chalk29.cyan("roy-agent skills reload")} ${chalk29.gray("- 重新扫描技能")}`);
|
|
12833
13140
|
} catch (error) {
|
|
12834
13141
|
output.error(`Failed to show config: ${error}`);
|
|
12835
13142
|
process.exit(1);
|
|
@@ -12843,14 +13150,14 @@ var ShowConfigCommand = {
|
|
|
12843
13150
|
var SkillsCommand = {
|
|
12844
13151
|
command: "skills",
|
|
12845
13152
|
describe: "技能管理 - 列出、获取、搜索、重新加载技能",
|
|
12846
|
-
builder: (yargs) => yargs.command(ListCommand3).command(GetCommand3).command(
|
|
13153
|
+
builder: (yargs) => yargs.command(ListCommand3).command(GetCommand3).command(SearchCommand2).command(ReloadCommand).command(ShowConfigCommand).demandCommand().help(),
|
|
12847
13154
|
handler: () => {
|
|
12848
13155
|
console.log("Use 'roy-agent skills --help' for usage information");
|
|
12849
13156
|
}
|
|
12850
13157
|
};
|
|
12851
13158
|
|
|
12852
13159
|
// src/commands/agents/list.ts
|
|
12853
|
-
import
|
|
13160
|
+
import chalk30 from "chalk";
|
|
12854
13161
|
var ListCommand4 = {
|
|
12855
13162
|
command: "list",
|
|
12856
13163
|
aliases: ["ls"],
|
|
@@ -12915,25 +13222,25 @@ var ListCommand4 = {
|
|
|
12915
13222
|
agents.forEach((a) => output.log(a.name));
|
|
12916
13223
|
} else {
|
|
12917
13224
|
const header = [
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
13225
|
+
chalk30.bold("Name"),
|
|
13226
|
+
chalk30.bold("Type"),
|
|
13227
|
+
chalk30.bold("Model"),
|
|
13228
|
+
chalk30.bold("Workflow"),
|
|
13229
|
+
chalk30.bold("Description")
|
|
12923
13230
|
].join(" | ");
|
|
12924
13231
|
const typeColor = (type) => {
|
|
12925
13232
|
if (type === "primary")
|
|
12926
|
-
return
|
|
13233
|
+
return chalk30.yellow;
|
|
12927
13234
|
if (type === "workflow")
|
|
12928
|
-
return
|
|
12929
|
-
return
|
|
13235
|
+
return chalk30.magenta;
|
|
13236
|
+
return chalk30.blue;
|
|
12930
13237
|
};
|
|
12931
13238
|
const rows = agents.map((a) => {
|
|
12932
13239
|
const desc2 = (a.description || "").length > 40 ? (a.description || "").slice(0, 37) + "..." : a.description || "-";
|
|
12933
|
-
const workflowDisplay = a.type === "workflow" && a.workflow ?
|
|
12934
|
-
const modelDisplay = a.model ?
|
|
13240
|
+
const workflowDisplay = a.type === "workflow" && a.workflow ? chalk30.cyan(a.workflow.length > 30 ? a.workflow.slice(0, 27) + "..." : a.workflow) : chalk30.gray("-");
|
|
13241
|
+
const modelDisplay = a.model ? chalk30.yellow(a.model.length > 20 ? a.model.slice(0, 17) + "..." : a.model) : chalk30.gray("-");
|
|
12935
13242
|
return [
|
|
12936
|
-
|
|
13243
|
+
chalk30.cyan(a.name),
|
|
12937
13244
|
typeColor(a.type)(a.type),
|
|
12938
13245
|
modelDisplay,
|
|
12939
13246
|
workflowDisplay,
|
|
@@ -12941,9 +13248,9 @@ var ListCommand4 = {
|
|
|
12941
13248
|
].join(" | ");
|
|
12942
13249
|
});
|
|
12943
13250
|
if (rows.length === 0) {
|
|
12944
|
-
output.log(
|
|
13251
|
+
output.log(chalk30.yellow("No agents found."));
|
|
12945
13252
|
output.log("");
|
|
12946
|
-
output.log(
|
|
13253
|
+
output.log(chalk30.gray("Tip: Create agent configs in ~/.local/share/roy-agent/agents/"));
|
|
12947
13254
|
} else {
|
|
12948
13255
|
output.log([
|
|
12949
13256
|
`┌─ Agents ${"─".repeat(50)}┐`,
|
|
@@ -12952,7 +13259,7 @@ var ListCommand4 = {
|
|
|
12952
13259
|
...rows.map((r) => `│${r}│`),
|
|
12953
13260
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
12954
13261
|
"",
|
|
12955
|
-
|
|
13262
|
+
chalk30.gray(`Total: ${agents.length} agents`)
|
|
12956
13263
|
].join(`
|
|
12957
13264
|
`));
|
|
12958
13265
|
}
|
|
@@ -12967,7 +13274,7 @@ var ListCommand4 = {
|
|
|
12967
13274
|
};
|
|
12968
13275
|
|
|
12969
13276
|
// src/commands/agents/get.ts
|
|
12970
|
-
import
|
|
13277
|
+
import chalk31 from "chalk";
|
|
12971
13278
|
var GetCommand4 = {
|
|
12972
13279
|
command: "get <name>",
|
|
12973
13280
|
describe: "获取指定 agent 的详细信息",
|
|
@@ -13026,69 +13333,69 @@ var GetCommand4 = {
|
|
|
13026
13333
|
filterHistory: agent.filterHistory
|
|
13027
13334
|
});
|
|
13028
13335
|
} else {
|
|
13029
|
-
output.log(
|
|
13336
|
+
output.log(chalk31.bold.cyan(`# Agent: ${agent.name}`));
|
|
13030
13337
|
output.log("");
|
|
13031
|
-
output.log(
|
|
13032
|
-
output.log(` ${
|
|
13033
|
-
output.log(` ${
|
|
13338
|
+
output.log(chalk31.bold("Basic Info:"));
|
|
13339
|
+
output.log(` ${chalk31.cyan("name:")} ${agent.name}`);
|
|
13340
|
+
output.log(` ${chalk31.cyan("type:")} ${agent.type}`);
|
|
13034
13341
|
if (agent.description) {
|
|
13035
|
-
output.log(` ${
|
|
13342
|
+
output.log(` ${chalk31.cyan("description:")} ${agent.description}`);
|
|
13036
13343
|
}
|
|
13037
13344
|
output.log("");
|
|
13038
13345
|
if (agent.type === "workflow") {
|
|
13039
|
-
output.log(
|
|
13346
|
+
output.log(chalk31.bold("Workflow:"));
|
|
13040
13347
|
if (agent.workflow) {
|
|
13041
|
-
output.log(` ${
|
|
13042
|
-
output.log(` ${
|
|
13348
|
+
output.log(` ${chalk31.cyan("workflow:")} ${agent.workflow}`);
|
|
13349
|
+
output.log(` ${chalk31.gray("→")} ${chalk31.gray(`roy-agent workflow run ${agent.workflow} --input '{"query":"..."}'`)}`);
|
|
13043
13350
|
} else {
|
|
13044
|
-
output.log(` ${
|
|
13351
|
+
output.log(` ${chalk31.gray("(no workflow configured)")}`);
|
|
13045
13352
|
}
|
|
13046
13353
|
output.log("");
|
|
13047
13354
|
}
|
|
13048
|
-
output.log(
|
|
13355
|
+
output.log(chalk31.bold("System Prompt:"));
|
|
13049
13356
|
if (agent.systemPromptRef) {
|
|
13050
|
-
output.log(` ${
|
|
13357
|
+
output.log(` ${chalk31.green("[ref]")} ${chalk31.cyan("systemPromptRef:")} ${agent.systemPromptRef}`);
|
|
13051
13358
|
}
|
|
13052
13359
|
if (agent.systemPrompt && !agent.systemPromptRef) {
|
|
13053
13360
|
const promptPreview = agent.systemPrompt.length > 100 ? agent.systemPrompt.slice(0, 97) + "..." : agent.systemPrompt;
|
|
13054
|
-
output.log(` ${
|
|
13055
|
-
output.log(` ${
|
|
13361
|
+
output.log(` ${chalk31.gray("[inline]")}`);
|
|
13362
|
+
output.log(` ${chalk31.gray(promptPreview.split(`
|
|
13056
13363
|
`).join(`
|
|
13057
13364
|
`))}`);
|
|
13058
13365
|
}
|
|
13059
13366
|
if (resolvedSystemPrompt) {
|
|
13060
13367
|
const resolvedPreview = resolvedSystemPrompt.length > 200 ? resolvedSystemPrompt.slice(0, 197) + "..." : resolvedSystemPrompt;
|
|
13061
|
-
output.log(` ${
|
|
13062
|
-
output.log(` ${
|
|
13368
|
+
output.log(` ${chalk31.green("[resolved]")}`);
|
|
13369
|
+
output.log(` ${chalk31.gray(resolvedPreview.split(`
|
|
13063
13370
|
`).join(`
|
|
13064
13371
|
`))}`);
|
|
13065
13372
|
}
|
|
13066
13373
|
if (!agent.systemPromptRef && !agent.systemPrompt && !resolvedSystemPrompt) {
|
|
13067
|
-
output.log(` ${
|
|
13374
|
+
output.log(` ${chalk31.gray("(none)")}`);
|
|
13068
13375
|
}
|
|
13069
13376
|
output.log("");
|
|
13070
13377
|
const hasOptions = agent.model || agent.maxIterations || agent.toolTimeout;
|
|
13071
13378
|
if (hasOptions) {
|
|
13072
|
-
output.log(
|
|
13379
|
+
output.log(chalk31.bold("Options:"));
|
|
13073
13380
|
if (agent.model) {
|
|
13074
|
-
output.log(` ${
|
|
13381
|
+
output.log(` ${chalk31.cyan("model:")} ${agent.model}`);
|
|
13075
13382
|
}
|
|
13076
13383
|
if (agent.maxIterations) {
|
|
13077
|
-
output.log(` ${
|
|
13384
|
+
output.log(` ${chalk31.cyan("maxIterations:")} ${agent.maxIterations}`);
|
|
13078
13385
|
}
|
|
13079
13386
|
if (agent.toolTimeout) {
|
|
13080
|
-
output.log(` ${
|
|
13387
|
+
output.log(` ${chalk31.cyan("toolTimeout:")} ${agent.toolTimeout}ms`);
|
|
13081
13388
|
}
|
|
13082
13389
|
output.log("");
|
|
13083
13390
|
}
|
|
13084
13391
|
const hasTools = agent.allowedTools?.length || agent.deniedTools?.length;
|
|
13085
13392
|
if (hasTools) {
|
|
13086
|
-
output.log(
|
|
13393
|
+
output.log(chalk31.bold("Tool Permissions:"));
|
|
13087
13394
|
if (agent.allowedTools?.length) {
|
|
13088
|
-
output.log(` ${
|
|
13395
|
+
output.log(` ${chalk31.green("allowed:")} ${agent.allowedTools.join(", ")}`);
|
|
13089
13396
|
}
|
|
13090
13397
|
if (agent.deniedTools?.length) {
|
|
13091
|
-
output.log(` ${
|
|
13398
|
+
output.log(` ${chalk31.red("denied:")} ${agent.deniedTools.join(", ")}`);
|
|
13092
13399
|
}
|
|
13093
13400
|
output.log("");
|
|
13094
13401
|
}
|
|
@@ -13103,7 +13410,7 @@ var GetCommand4 = {
|
|
|
13103
13410
|
};
|
|
13104
13411
|
|
|
13105
13412
|
// src/commands/agents/add.ts
|
|
13106
|
-
import
|
|
13413
|
+
import chalk32 from "chalk";
|
|
13107
13414
|
function parseToolList(value) {
|
|
13108
13415
|
if (!value?.trim()) {
|
|
13109
13416
|
return;
|
|
@@ -13195,8 +13502,8 @@ var AddCommand = {
|
|
|
13195
13502
|
if (args.json) {
|
|
13196
13503
|
output.json({ agent, filePath });
|
|
13197
13504
|
} else {
|
|
13198
|
-
output.log(
|
|
13199
|
-
output.log(
|
|
13505
|
+
output.log(chalk32.green(`✓ Agent '${args.name}' created`));
|
|
13506
|
+
output.log(chalk32.gray(` ${filePath}`));
|
|
13200
13507
|
}
|
|
13201
13508
|
} catch (error) {
|
|
13202
13509
|
output.error(`Failed to add agent: ${error}`);
|
|
@@ -13208,7 +13515,7 @@ var AddCommand = {
|
|
|
13208
13515
|
};
|
|
13209
13516
|
|
|
13210
13517
|
// src/commands/agents/delete.ts
|
|
13211
|
-
import
|
|
13518
|
+
import chalk33 from "chalk";
|
|
13212
13519
|
var DeleteCommand3 = {
|
|
13213
13520
|
command: "delete <name>",
|
|
13214
13521
|
describe: "删除 agent 配置文件",
|
|
@@ -13250,7 +13557,7 @@ var DeleteCommand3 = {
|
|
|
13250
13557
|
}
|
|
13251
13558
|
const filePath = registry.getAgentFilePath(args.name);
|
|
13252
13559
|
if (!args.yes) {
|
|
13253
|
-
output.log(
|
|
13560
|
+
output.log(chalk33.yellow(`Delete agent '${args.name}'? This removes ${filePath} (use --yes to skip confirmation)`));
|
|
13254
13561
|
process.exit(1);
|
|
13255
13562
|
}
|
|
13256
13563
|
const deleted = await registry.deleteAgent(args.name);
|
|
@@ -13261,7 +13568,7 @@ var DeleteCommand3 = {
|
|
|
13261
13568
|
if (args.json) {
|
|
13262
13569
|
output.json({ deleted: true, name: args.name, filePath });
|
|
13263
13570
|
} else {
|
|
13264
|
-
output.log(
|
|
13571
|
+
output.log(chalk33.green(`✓ Agent '${args.name}' deleted`));
|
|
13265
13572
|
}
|
|
13266
13573
|
} catch (error) {
|
|
13267
13574
|
output.error(`Failed to delete agent: ${error}`);
|
|
@@ -13273,7 +13580,7 @@ var DeleteCommand3 = {
|
|
|
13273
13580
|
};
|
|
13274
13581
|
|
|
13275
13582
|
// src/commands/agents/config-dir.ts
|
|
13276
|
-
import
|
|
13583
|
+
import chalk34 from "chalk";
|
|
13277
13584
|
var ConfigDirCommand = {
|
|
13278
13585
|
command: "config-dir",
|
|
13279
13586
|
describe: "显示 agent 配置目录路径",
|
|
@@ -13304,8 +13611,8 @@ var ConfigDirCommand = {
|
|
|
13304
13611
|
if (args.json) {
|
|
13305
13612
|
output.json({ configDir, exists });
|
|
13306
13613
|
} else {
|
|
13307
|
-
output.log(`${
|
|
13308
|
-
output.log(`${
|
|
13614
|
+
output.log(`${chalk34.cyan("Agent Config Directory:")} ${configDir}`);
|
|
13615
|
+
output.log(`${chalk34.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
13309
13616
|
}
|
|
13310
13617
|
} catch (error) {
|
|
13311
13618
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -13328,7 +13635,7 @@ var AgentsCommand = {
|
|
|
13328
13635
|
};
|
|
13329
13636
|
|
|
13330
13637
|
// src/commands/prompt/list.ts
|
|
13331
|
-
import
|
|
13638
|
+
import chalk35 from "chalk";
|
|
13332
13639
|
var ListCommand5 = {
|
|
13333
13640
|
command: "list",
|
|
13334
13641
|
aliases: ["ls"],
|
|
@@ -13384,17 +13691,17 @@ var ListCommand5 = {
|
|
|
13384
13691
|
prompts.forEach((p) => output.log(p.name));
|
|
13385
13692
|
} else {
|
|
13386
13693
|
const header = [
|
|
13387
|
-
|
|
13388
|
-
|
|
13694
|
+
chalk35.bold("Name"),
|
|
13695
|
+
chalk35.bold("Source")
|
|
13389
13696
|
].join(" | ");
|
|
13390
13697
|
const rows = prompts.map((p) => {
|
|
13391
13698
|
return [
|
|
13392
|
-
|
|
13393
|
-
|
|
13699
|
+
chalk35.cyan(p.name),
|
|
13700
|
+
chalk35.gray(`[${p.source}]`)
|
|
13394
13701
|
].join(" | ");
|
|
13395
13702
|
});
|
|
13396
13703
|
if (rows.length === 0) {
|
|
13397
|
-
output.log(
|
|
13704
|
+
output.log(chalk35.yellow("No prompts found."));
|
|
13398
13705
|
} else {
|
|
13399
13706
|
output.log([
|
|
13400
13707
|
`┌─ Prompts ${"─".repeat(50)}┐`,
|
|
@@ -13403,7 +13710,7 @@ var ListCommand5 = {
|
|
|
13403
13710
|
...rows.map((r) => `│${r}│`),
|
|
13404
13711
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
13405
13712
|
"",
|
|
13406
|
-
|
|
13713
|
+
chalk35.gray(`Total: ${prompts.length} prompts`)
|
|
13407
13714
|
].join(`
|
|
13408
13715
|
`));
|
|
13409
13716
|
}
|
|
@@ -13418,7 +13725,7 @@ var ListCommand5 = {
|
|
|
13418
13725
|
};
|
|
13419
13726
|
|
|
13420
13727
|
// src/commands/prompt/get.ts
|
|
13421
|
-
import
|
|
13728
|
+
import chalk36 from "chalk";
|
|
13422
13729
|
var GetCommand5 = {
|
|
13423
13730
|
command: "get <name>",
|
|
13424
13731
|
describe: "获取指定 prompt 的内容",
|
|
@@ -13465,16 +13772,16 @@ var GetCommand5 = {
|
|
|
13465
13772
|
variables: vars
|
|
13466
13773
|
});
|
|
13467
13774
|
} else {
|
|
13468
|
-
output.log(
|
|
13775
|
+
output.log(chalk36.bold.cyan(`# Prompt: ${args.name}`));
|
|
13469
13776
|
output.log("");
|
|
13470
13777
|
if (Object.keys(vars).length > 0) {
|
|
13471
|
-
output.log(
|
|
13778
|
+
output.log(chalk36.gray("Variables:"));
|
|
13472
13779
|
for (const [key, value] of Object.entries(vars)) {
|
|
13473
|
-
output.log(` ${
|
|
13780
|
+
output.log(` ${chalk36.cyan(key + ":")} ${value}`);
|
|
13474
13781
|
}
|
|
13475
13782
|
output.log("");
|
|
13476
13783
|
}
|
|
13477
|
-
output.log(
|
|
13784
|
+
output.log(chalk36.bold("Content:"));
|
|
13478
13785
|
output.log("─".repeat(60));
|
|
13479
13786
|
output.log(prompt);
|
|
13480
13787
|
output.log("─".repeat(60));
|
|
@@ -13504,7 +13811,7 @@ function parseVars(vars) {
|
|
|
13504
13811
|
|
|
13505
13812
|
// src/commands/prompt/add.ts
|
|
13506
13813
|
import { readFile } from "fs/promises";
|
|
13507
|
-
import
|
|
13814
|
+
import chalk37 from "chalk";
|
|
13508
13815
|
var AddCommand2 = {
|
|
13509
13816
|
command: "add <name>",
|
|
13510
13817
|
describe: "添加 prompt 并持久化到 ~/.local/share/roy-agent/prompts/",
|
|
@@ -13555,8 +13862,8 @@ var AddCommand2 = {
|
|
|
13555
13862
|
length: content.trim().length
|
|
13556
13863
|
});
|
|
13557
13864
|
} else {
|
|
13558
|
-
output.log(
|
|
13559
|
-
output.log(
|
|
13865
|
+
output.log(chalk37.green(`✓ Prompt '${args.name}' saved`));
|
|
13866
|
+
output.log(chalk37.gray(` ${filePath}`));
|
|
13560
13867
|
}
|
|
13561
13868
|
} catch (error) {
|
|
13562
13869
|
output.error(`Failed to add prompt: ${error}`);
|
|
@@ -13568,7 +13875,7 @@ var AddCommand2 = {
|
|
|
13568
13875
|
};
|
|
13569
13876
|
|
|
13570
13877
|
// src/commands/prompt/config-dir.ts
|
|
13571
|
-
import
|
|
13878
|
+
import chalk38 from "chalk";
|
|
13572
13879
|
var ConfigDirCommand2 = {
|
|
13573
13880
|
command: "config-dir",
|
|
13574
13881
|
describe: "显示 prompt 持久化目录路径",
|
|
@@ -13598,8 +13905,8 @@ var ConfigDirCommand2 = {
|
|
|
13598
13905
|
if (args.json) {
|
|
13599
13906
|
output.json({ configDir, exists });
|
|
13600
13907
|
} else {
|
|
13601
|
-
output.log(`${
|
|
13602
|
-
output.log(`${
|
|
13908
|
+
output.log(`${chalk38.cyan("Prompt Config Directory:")} ${configDir}`);
|
|
13909
|
+
output.log(`${chalk38.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
13603
13910
|
}
|
|
13604
13911
|
} catch (error) {
|
|
13605
13912
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -13621,7 +13928,7 @@ var PromptCommand = {
|
|
|
13621
13928
|
};
|
|
13622
13929
|
|
|
13623
13930
|
// src/commands/commands-list.ts
|
|
13624
|
-
import
|
|
13931
|
+
import chalk39 from "chalk";
|
|
13625
13932
|
function truncateVisual(str, maxWidth) {
|
|
13626
13933
|
let result = "";
|
|
13627
13934
|
let width = 0;
|
|
@@ -13636,16 +13943,16 @@ function truncateVisual(str, maxWidth) {
|
|
|
13636
13943
|
}
|
|
13637
13944
|
function formatCommandsTable(commands) {
|
|
13638
13945
|
if (commands.length === 0) {
|
|
13639
|
-
return
|
|
13946
|
+
return chalk39.yellow("命令目录为空,使用 'roy-agent commands add' 添加命令");
|
|
13640
13947
|
}
|
|
13641
13948
|
const NAME_WIDTH = 20;
|
|
13642
13949
|
const SOURCE_WIDTH = 10;
|
|
13643
13950
|
const DESC_WIDTH = 50;
|
|
13644
13951
|
const GAP = " ";
|
|
13645
13952
|
const headerLine = [
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13953
|
+
chalk39.bold("NAME".padEnd(NAME_WIDTH)),
|
|
13954
|
+
chalk39.bold("SOURCE".padEnd(SOURCE_WIDTH)),
|
|
13955
|
+
chalk39.bold("DESCRIPTION")
|
|
13649
13956
|
].join(GAP);
|
|
13650
13957
|
const sepLine = "─".repeat(NAME_WIDTH + SOURCE_WIDTH + DESC_WIDTH + GAP.length * 2);
|
|
13651
13958
|
const formatRow = (cmd) => {
|
|
@@ -13708,7 +14015,7 @@ var CommandsListCommand = {
|
|
|
13708
14015
|
}));
|
|
13709
14016
|
output.log(formatCommandsTable(rows));
|
|
13710
14017
|
output.info("");
|
|
13711
|
-
output.log(
|
|
14018
|
+
output.log(chalk39.green(`✅ 共 ${result.commands.length} 个命令`) + chalk39.gray(` (user: ${result.stats.userCount}, project: ${result.stats.projectCount})`));
|
|
13712
14019
|
}
|
|
13713
14020
|
} catch (error) {
|
|
13714
14021
|
output.error(`Failed to list commands: ${error}`);
|
|
@@ -13720,7 +14027,7 @@ var CommandsListCommand = {
|
|
|
13720
14027
|
};
|
|
13721
14028
|
|
|
13722
14029
|
// src/commands/commands-add.ts
|
|
13723
|
-
import
|
|
14030
|
+
import chalk40 from "chalk";
|
|
13724
14031
|
var CommandsAddCommand = {
|
|
13725
14032
|
command: "add <name> <target>",
|
|
13726
14033
|
describe: "添加收藏命令(自动创建 symlink)",
|
|
@@ -13781,10 +14088,10 @@ var CommandsAddCommand = {
|
|
|
13781
14088
|
});
|
|
13782
14089
|
const dirs = await commandsComponent.getCommandDirs();
|
|
13783
14090
|
const targetDir = source === "user" ? dirs.user : dirs.project;
|
|
13784
|
-
output.log(
|
|
13785
|
-
output.log(
|
|
13786
|
-
output.log(
|
|
13787
|
-
output.log(
|
|
14091
|
+
output.log(chalk40.green(`✅ 已添加命令 '${args.name}'`));
|
|
14092
|
+
output.log(chalk40.gray(` 目标: ${args.target}`));
|
|
14093
|
+
output.log(chalk40.gray(` 位置: ${targetDir}/${args.name}`));
|
|
14094
|
+
output.log(chalk40.gray(` 级别: ${source === "user" ? "USER" : "PROJECT"}`));
|
|
13788
14095
|
} catch (error) {
|
|
13789
14096
|
output.error(`添加失败: ${error.message}`);
|
|
13790
14097
|
process.exit(1);
|
|
@@ -13795,7 +14102,7 @@ var CommandsAddCommand = {
|
|
|
13795
14102
|
};
|
|
13796
14103
|
|
|
13797
14104
|
// src/commands/commands-remove.ts
|
|
13798
|
-
import
|
|
14105
|
+
import chalk41 from "chalk";
|
|
13799
14106
|
var CommandsRemoveCommand = {
|
|
13800
14107
|
command: "remove <name>",
|
|
13801
14108
|
aliases: ["rm"],
|
|
@@ -13839,7 +14146,7 @@ var CommandsRemoveCommand = {
|
|
|
13839
14146
|
name: args.name,
|
|
13840
14147
|
source: "user"
|
|
13841
14148
|
});
|
|
13842
|
-
output.log(
|
|
14149
|
+
output.log(chalk41.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
13843
14150
|
} catch (error) {
|
|
13844
14151
|
if (!error.message?.includes("不存在")) {
|
|
13845
14152
|
throw error;
|
|
@@ -13852,7 +14159,7 @@ var CommandsRemoveCommand = {
|
|
|
13852
14159
|
name: args.name,
|
|
13853
14160
|
source: "project"
|
|
13854
14161
|
});
|
|
13855
|
-
output.log(
|
|
14162
|
+
output.log(chalk41.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
13856
14163
|
} catch (error) {
|
|
13857
14164
|
if (!error.message?.includes("不存在")) {
|
|
13858
14165
|
throw error;
|
|
@@ -13866,7 +14173,7 @@ var CommandsRemoveCommand = {
|
|
|
13866
14173
|
name: args.name,
|
|
13867
14174
|
source: "user"
|
|
13868
14175
|
});
|
|
13869
|
-
output.log(
|
|
14176
|
+
output.log(chalk41.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
13870
14177
|
removed = true;
|
|
13871
14178
|
} catch (error) {
|
|
13872
14179
|
if (!error.message?.includes("不存在")) {
|
|
@@ -13878,7 +14185,7 @@ var CommandsRemoveCommand = {
|
|
|
13878
14185
|
name: args.name,
|
|
13879
14186
|
source: "project"
|
|
13880
14187
|
});
|
|
13881
|
-
output.log(
|
|
14188
|
+
output.log(chalk41.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
13882
14189
|
removed = true;
|
|
13883
14190
|
} catch (error) {
|
|
13884
14191
|
if (!error.message?.includes("不存在")) {
|
|
@@ -13900,7 +14207,7 @@ var CommandsRemoveCommand = {
|
|
|
13900
14207
|
};
|
|
13901
14208
|
|
|
13902
14209
|
// src/commands/commands-info.ts
|
|
13903
|
-
import
|
|
14210
|
+
import chalk42 from "chalk";
|
|
13904
14211
|
import { exec } from "child_process";
|
|
13905
14212
|
import { promisify } from "util";
|
|
13906
14213
|
var execAsync = promisify(exec);
|
|
@@ -13935,12 +14242,12 @@ var CommandsInfoCommand = {
|
|
|
13935
14242
|
output.error(`命令 '${args.name}' 不存在`);
|
|
13936
14243
|
process.exit(1);
|
|
13937
14244
|
}
|
|
13938
|
-
output.log(
|
|
13939
|
-
output.log(
|
|
13940
|
-
output.log(
|
|
13941
|
-
output.log(
|
|
14245
|
+
output.log(chalk42.bold("Name:") + ` ${info.name}`);
|
|
14246
|
+
output.log(chalk42.bold("Path:") + ` ${info.path}`);
|
|
14247
|
+
output.log(chalk42.bold("Source:") + ` ${info.source.toUpperCase()}`);
|
|
14248
|
+
output.log(chalk42.bold("Description:") + ` ${info.shortDescription || "-"}`);
|
|
13942
14249
|
output.log();
|
|
13943
|
-
output.log(
|
|
14250
|
+
output.log(chalk42.gray("─".repeat(50)));
|
|
13944
14251
|
output.log();
|
|
13945
14252
|
try {
|
|
13946
14253
|
const { stdout } = await execAsync(`${info.path} --help`, { timeout: 5000 });
|
|
@@ -13950,7 +14257,7 @@ var CommandsInfoCommand = {
|
|
|
13950
14257
|
const { stdout } = await execAsync(`${info.path} -h`, { timeout: 5000 });
|
|
13951
14258
|
output.log(stdout);
|
|
13952
14259
|
} catch {
|
|
13953
|
-
output.log(
|
|
14260
|
+
output.log(chalk42.gray("(无法获取帮助信息)"));
|
|
13954
14261
|
}
|
|
13955
14262
|
}
|
|
13956
14263
|
} catch (error) {
|
|
@@ -13963,7 +14270,7 @@ var CommandsInfoCommand = {
|
|
|
13963
14270
|
};
|
|
13964
14271
|
|
|
13965
14272
|
// src/commands/commands-dirs.ts
|
|
13966
|
-
import
|
|
14273
|
+
import chalk43 from "chalk";
|
|
13967
14274
|
var CommandsDirsCommand = {
|
|
13968
14275
|
command: "dirs",
|
|
13969
14276
|
describe: "显示命令目录",
|
|
@@ -13995,10 +14302,10 @@ var CommandsDirsCommand = {
|
|
|
13995
14302
|
if (args.json) {
|
|
13996
14303
|
output.json(dirs);
|
|
13997
14304
|
} else {
|
|
13998
|
-
output.log(
|
|
14305
|
+
output.log(chalk43.bold("命令目录:"));
|
|
13999
14306
|
output.log();
|
|
14000
|
-
output.log(
|
|
14001
|
-
output.log(
|
|
14307
|
+
output.log(chalk43.cyan("USER:") + ` ${dirs.user}`);
|
|
14308
|
+
output.log(chalk43.cyan("PROJECT:") + ` ${dirs.project}`);
|
|
14002
14309
|
}
|
|
14003
14310
|
} catch (error) {
|
|
14004
14311
|
output.error(`错误: ${error.message}`);
|
|
@@ -14018,7 +14325,7 @@ var CommandsCommand = {
|
|
|
14018
14325
|
};
|
|
14019
14326
|
|
|
14020
14327
|
// src/commands/config/list.ts
|
|
14021
|
-
import
|
|
14328
|
+
import chalk44 from "chalk";
|
|
14022
14329
|
|
|
14023
14330
|
// src/commands/config/config-service.ts
|
|
14024
14331
|
import * as fsSync from "fs";
|
|
@@ -14322,7 +14629,7 @@ var ConfigListCommand = {
|
|
|
14322
14629
|
output.log("");
|
|
14323
14630
|
output.log("Supported components:");
|
|
14324
14631
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
14325
|
-
output.log(` ${
|
|
14632
|
+
output.log(` ${chalk44.cyan(comp.padEnd(15))} ${COMPONENT_DESCRIPTIONS[comp] || ""}`);
|
|
14326
14633
|
}
|
|
14327
14634
|
process.exit(1);
|
|
14328
14635
|
}
|
|
@@ -14340,27 +14647,27 @@ var ConfigListCommand = {
|
|
|
14340
14647
|
}
|
|
14341
14648
|
};
|
|
14342
14649
|
function showHelp(output) {
|
|
14343
|
-
output.log(
|
|
14650
|
+
output.log(chalk44.bold.cyan("# roy-agent config list"));
|
|
14344
14651
|
output.log("");
|
|
14345
14652
|
output.log("查看 roy-agent 组件配置信息");
|
|
14346
14653
|
output.log("");
|
|
14347
|
-
output.log(
|
|
14348
|
-
output.log(` ${
|
|
14654
|
+
output.log(chalk44.bold("Usage:"));
|
|
14655
|
+
output.log(` ${chalk44.cyan("roy-agent config list [component] [options]")}`);
|
|
14349
14656
|
output.log("");
|
|
14350
|
-
output.log(
|
|
14657
|
+
output.log(chalk44.bold("Components:"));
|
|
14351
14658
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
14352
|
-
output.log(` ${
|
|
14659
|
+
output.log(` ${chalk44.cyan(comp.padEnd(15))} ${chalk44.gray(COMPONENT_DESCRIPTIONS[comp] || "")}`);
|
|
14353
14660
|
}
|
|
14354
|
-
output.log(` ${
|
|
14661
|
+
output.log(` ${chalk44.cyan("all".padEnd(15))} 显示所有 components 概览`);
|
|
14355
14662
|
output.log("");
|
|
14356
|
-
output.log(
|
|
14357
|
-
output.log(` ${
|
|
14358
|
-
output.log(` ${
|
|
14359
|
-
output.log(` ${
|
|
14663
|
+
output.log(chalk44.bold("Options:"));
|
|
14664
|
+
output.log(` ${chalk44.cyan("-j, --json")} JSON 格式输出`);
|
|
14665
|
+
output.log(` ${chalk44.cyan("-k, --keys")} 只显示配置键`);
|
|
14666
|
+
output.log(` ${chalk44.cyan("-s, --sources")} 只显示配置源`);
|
|
14360
14667
|
output.log("");
|
|
14361
|
-
output.log(
|
|
14668
|
+
output.log(chalk44.bold("Examples:"));
|
|
14362
14669
|
for (const { command: command2, description } of USAGE_COMMANDS) {
|
|
14363
|
-
output.log(` ${
|
|
14670
|
+
output.log(` ${chalk44.cyan(command2.padEnd(40))} ${chalk44.gray(description)}`);
|
|
14364
14671
|
}
|
|
14365
14672
|
}
|
|
14366
14673
|
async function showAllComponents(output, configService) {
|
|
@@ -14369,13 +14676,13 @@ async function showAllComponents(output, configService) {
|
|
|
14369
14676
|
const config = configService.getComponentConfig(compName);
|
|
14370
14677
|
components.push({ name: compName, config });
|
|
14371
14678
|
}
|
|
14372
|
-
output.log(
|
|
14679
|
+
output.log(chalk44.bold.cyan("# All Components Overview"));
|
|
14373
14680
|
output.log("");
|
|
14374
|
-
output.log(` ${
|
|
14375
|
-
output.log(` ${
|
|
14681
|
+
output.log(` ${chalk44.cyan("Component".padEnd(15))} ${chalk44.cyan("Keys".padEnd(10))} ${chalk44.gray("Description")}`);
|
|
14682
|
+
output.log(` ${chalk44.gray("─".repeat(60))}`);
|
|
14376
14683
|
for (const comp of components) {
|
|
14377
14684
|
const keyCount = Object.keys(comp.config).length;
|
|
14378
|
-
output.log(` ${
|
|
14685
|
+
output.log(` ${chalk44.cyan(comp.name.padEnd(15))} ${keyCount.toString().padEnd(10)} ${chalk44.gray(COMPONENT_DESCRIPTIONS[comp.name] || "")}`);
|
|
14379
14686
|
}
|
|
14380
14687
|
}
|
|
14381
14688
|
async function showComponentConfig(componentName, output, configService, options) {
|
|
@@ -14397,22 +14704,22 @@ async function showComponentConfig(componentName, output, configService, options
|
|
|
14397
14704
|
});
|
|
14398
14705
|
return;
|
|
14399
14706
|
}
|
|
14400
|
-
output.log(
|
|
14707
|
+
output.log(chalk44.bold.cyan(`# ${componentName} Component Configuration`));
|
|
14401
14708
|
output.log("");
|
|
14402
14709
|
if (filePath) {
|
|
14403
|
-
output.log(
|
|
14404
|
-
output.log(` ${
|
|
14710
|
+
output.log(chalk44.bold("File:"));
|
|
14711
|
+
output.log(` ${chalk44.cyan(filePath)}`);
|
|
14405
14712
|
output.log("");
|
|
14406
14713
|
}
|
|
14407
14714
|
if (!options.sources) {
|
|
14408
|
-
output.log(
|
|
14715
|
+
output.log(chalk44.bold("Configuration:"));
|
|
14409
14716
|
if (Object.keys(config).length === 0) {
|
|
14410
|
-
output.log(` ${
|
|
14717
|
+
output.log(` ${chalk44.gray("(无配置)")}`);
|
|
14411
14718
|
} else {
|
|
14412
14719
|
const flatConfig = flattenConfig(config);
|
|
14413
14720
|
for (const [key, value] of flatConfig) {
|
|
14414
14721
|
const displayValue = formatValue(value);
|
|
14415
|
-
output.log(` ${
|
|
14722
|
+
output.log(` ${chalk44.cyan(key + ":")} ${displayValue}`);
|
|
14416
14723
|
}
|
|
14417
14724
|
}
|
|
14418
14725
|
output.log("");
|
|
@@ -14427,17 +14734,17 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
14427
14734
|
});
|
|
14428
14735
|
return;
|
|
14429
14736
|
}
|
|
14430
|
-
output.log(
|
|
14737
|
+
output.log(chalk44.bold.cyan("# Agent Component Configuration"));
|
|
14431
14738
|
output.log("");
|
|
14432
14739
|
if (!options.sources) {
|
|
14433
|
-
output.log(
|
|
14740
|
+
output.log(chalk44.bold("Configuration:"));
|
|
14434
14741
|
if (Object.keys(config).length === 0) {
|
|
14435
|
-
output.log(` ${
|
|
14742
|
+
output.log(` ${chalk44.gray("(无配置,使用默认值)")}`);
|
|
14436
14743
|
} else {
|
|
14437
14744
|
const flatConfig = flattenConfig(config);
|
|
14438
14745
|
for (const [key, value] of flatConfig) {
|
|
14439
14746
|
const displayValue = formatValue(value);
|
|
14440
|
-
output.log(` ${
|
|
14747
|
+
output.log(` ${chalk44.cyan(key + ":")} ${displayValue}`);
|
|
14441
14748
|
}
|
|
14442
14749
|
}
|
|
14443
14750
|
output.log("");
|
|
@@ -14451,10 +14758,10 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
14451
14758
|
const configDir = registry.getConfigDir();
|
|
14452
14759
|
const exists = registry.configDirExists();
|
|
14453
14760
|
const agentCount = registry.list().length;
|
|
14454
|
-
output.log(
|
|
14455
|
-
output.log(` ${
|
|
14456
|
-
output.log(` ${
|
|
14457
|
-
output.log(` ${
|
|
14761
|
+
output.log(chalk44.bold("Agent Config Directory:"));
|
|
14762
|
+
output.log(` ${chalk44.cyan("path:")} ${configDir}`);
|
|
14763
|
+
output.log(` ${chalk44.cyan("exists:")} ${exists ? chalk44.green("yes") : chalk44.red("no")}`);
|
|
14764
|
+
output.log(` ${chalk44.cyan("agents:")} ${agentCount} loaded`);
|
|
14458
14765
|
output.log("");
|
|
14459
14766
|
}
|
|
14460
14767
|
}
|
|
@@ -14470,41 +14777,41 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
14470
14777
|
});
|
|
14471
14778
|
return;
|
|
14472
14779
|
}
|
|
14473
|
-
output.log(
|
|
14780
|
+
output.log(chalk44.bold.cyan("# Prompt Component Configuration"));
|
|
14474
14781
|
output.log("");
|
|
14475
14782
|
if (filePath) {
|
|
14476
|
-
output.log(
|
|
14477
|
-
output.log(` ${
|
|
14783
|
+
output.log(chalk44.bold("File:"));
|
|
14784
|
+
output.log(` ${chalk44.cyan(filePath)}`);
|
|
14478
14785
|
output.log("");
|
|
14479
14786
|
}
|
|
14480
14787
|
if (!options.sources) {
|
|
14481
|
-
output.log(
|
|
14788
|
+
output.log(chalk44.bold("Configuration:"));
|
|
14482
14789
|
if (Object.keys(config).length === 0) {
|
|
14483
|
-
output.log(` ${
|
|
14790
|
+
output.log(` ${chalk44.gray("(无配置,使用默认值)")}`);
|
|
14484
14791
|
} else {
|
|
14485
14792
|
const flatConfig = flattenConfig(config);
|
|
14486
14793
|
for (const [key, value] of flatConfig) {
|
|
14487
14794
|
const displayValue = formatValue(value);
|
|
14488
|
-
output.log(` ${
|
|
14795
|
+
output.log(` ${chalk44.cyan(key + ":")} ${displayValue}`);
|
|
14489
14796
|
}
|
|
14490
14797
|
}
|
|
14491
14798
|
output.log("");
|
|
14492
14799
|
}
|
|
14493
|
-
output.log(
|
|
14494
|
-
output.log(` ${
|
|
14800
|
+
output.log(chalk44.bold("Prompts:"));
|
|
14801
|
+
output.log(` ${chalk44.gray("- 内置: 5 个(default, coding, review, project-memory, global-memory)")}`);
|
|
14495
14802
|
const promptPaths = config?.promptPaths;
|
|
14496
14803
|
if (promptPaths && Array.isArray(promptPaths) && promptPaths.length > 0) {
|
|
14497
|
-
output.log(` ${
|
|
14804
|
+
output.log(` ${chalk44.gray("- 外部: " + promptPaths.length + " 个路径")}`);
|
|
14498
14805
|
for (const p of promptPaths) {
|
|
14499
|
-
output.log(` ${
|
|
14806
|
+
output.log(` ${chalk44.cyan(p.path)} ${chalk44.gray("(type: " + p.type + ")")}`);
|
|
14500
14807
|
}
|
|
14501
14808
|
} else {
|
|
14502
|
-
output.log(` ${
|
|
14809
|
+
output.log(` ${chalk44.gray("- 外部: 0 个(未配置 promptPaths)")}`);
|
|
14503
14810
|
}
|
|
14504
14811
|
output.log("");
|
|
14505
14812
|
const defaultName = config?.defaultName || "default";
|
|
14506
|
-
output.log(
|
|
14507
|
-
output.log(` ${
|
|
14813
|
+
output.log(chalk44.bold("Default Prompt:"));
|
|
14814
|
+
output.log(` ${chalk44.cyan("defaultName:")} ${defaultName}`);
|
|
14508
14815
|
output.log("");
|
|
14509
14816
|
const env = envService?.getEnvironment?.();
|
|
14510
14817
|
if (env) {
|
|
@@ -14519,10 +14826,10 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
14519
14826
|
const stored = await store?.loadAll?.();
|
|
14520
14827
|
promptCount = Array.isArray(stored) ? stored.length : 0;
|
|
14521
14828
|
} catch {}
|
|
14522
|
-
output.log(
|
|
14523
|
-
output.log(` ${
|
|
14524
|
-
output.log(` ${
|
|
14525
|
-
output.log(` ${
|
|
14829
|
+
output.log(chalk44.bold("Prompt Storage Directory:"));
|
|
14830
|
+
output.log(` ${chalk44.cyan("path:")} ${configDir}`);
|
|
14831
|
+
output.log(` ${chalk44.cyan("exists:")} ${exists ? chalk44.green("yes") : chalk44.red("no")}`);
|
|
14832
|
+
output.log(` ${chalk44.cyan("prompts:")} ${promptCount} loaded`);
|
|
14526
14833
|
output.log("");
|
|
14527
14834
|
}
|
|
14528
14835
|
}
|
|
@@ -14548,19 +14855,19 @@ function flattenConfig(obj, prefix = "") {
|
|
|
14548
14855
|
}
|
|
14549
14856
|
function formatValue(value) {
|
|
14550
14857
|
if (value === undefined) {
|
|
14551
|
-
return
|
|
14858
|
+
return chalk44.gray("undefined");
|
|
14552
14859
|
}
|
|
14553
14860
|
if (value === null) {
|
|
14554
|
-
return
|
|
14861
|
+
return chalk44.gray("null");
|
|
14555
14862
|
}
|
|
14556
14863
|
if (typeof value === "object") {
|
|
14557
|
-
return
|
|
14864
|
+
return chalk44.gray(JSON.stringify(value));
|
|
14558
14865
|
}
|
|
14559
14866
|
return String(value);
|
|
14560
14867
|
}
|
|
14561
14868
|
|
|
14562
14869
|
// src/commands/config/export.ts
|
|
14563
|
-
import
|
|
14870
|
+
import chalk45 from "chalk";
|
|
14564
14871
|
var ConfigExportCommand = {
|
|
14565
14872
|
command: "export <component>",
|
|
14566
14873
|
describe: "导出组件配置到文件",
|
|
@@ -14605,7 +14912,7 @@ var ConfigExportCommand = {
|
|
|
14605
14912
|
output.log("");
|
|
14606
14913
|
output.log("Supported components:");
|
|
14607
14914
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
14608
|
-
output.log(` ${
|
|
14915
|
+
output.log(` ${chalk45.cyan(comp)}`);
|
|
14609
14916
|
}
|
|
14610
14917
|
process.exit(1);
|
|
14611
14918
|
}
|
|
@@ -14623,7 +14930,7 @@ var ConfigExportCommand = {
|
|
|
14623
14930
|
};
|
|
14624
14931
|
|
|
14625
14932
|
// src/commands/config/import.ts
|
|
14626
|
-
import
|
|
14933
|
+
import chalk46 from "chalk";
|
|
14627
14934
|
var ConfigImportCommand = {
|
|
14628
14935
|
command: "import <component>",
|
|
14629
14936
|
describe: "从文件导入配置到组件的 file source",
|
|
@@ -14673,7 +14980,7 @@ var ConfigImportCommand = {
|
|
|
14673
14980
|
output.log("");
|
|
14674
14981
|
output.log("Supported components:");
|
|
14675
14982
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
14676
|
-
output.log(` ${
|
|
14983
|
+
output.log(` ${chalk46.cyan(comp)}`);
|
|
14677
14984
|
}
|
|
14678
14985
|
process.exit(1);
|
|
14679
14986
|
}
|
|
@@ -14688,7 +14995,7 @@ var ConfigImportCommand = {
|
|
|
14688
14995
|
}
|
|
14689
14996
|
if (result.merged && result.changes.length > 0 && args.verbose) {
|
|
14690
14997
|
output.log("");
|
|
14691
|
-
output.log(
|
|
14998
|
+
output.log(chalk46.bold("变更详情:"));
|
|
14692
14999
|
for (const change of result.changes) {
|
|
14693
15000
|
output.log(` ${change.key}: ${JSON.stringify(change.oldValue)} → ${JSON.stringify(change.newValue)}`);
|
|
14694
15001
|
}
|
|
@@ -14712,7 +15019,7 @@ var ConfigCommand = {
|
|
|
14712
15019
|
};
|
|
14713
15020
|
|
|
14714
15021
|
// src/commands/mcp/list.ts
|
|
14715
|
-
import
|
|
15022
|
+
import chalk47 from "chalk";
|
|
14716
15023
|
var ListCommand6 = {
|
|
14717
15024
|
command: "list",
|
|
14718
15025
|
aliases: ["ls"],
|
|
@@ -14758,30 +15065,30 @@ var ListCommand6 = {
|
|
|
14758
15065
|
servers.forEach((s) => output.log(s.name));
|
|
14759
15066
|
} else {
|
|
14760
15067
|
if (servers.length === 0) {
|
|
14761
|
-
output.log(
|
|
15068
|
+
output.log(chalk47.yellow("No MCP servers configured"));
|
|
14762
15069
|
return;
|
|
14763
15070
|
}
|
|
14764
15071
|
const statusColor = (status) => {
|
|
14765
15072
|
switch (status) {
|
|
14766
15073
|
case "connected":
|
|
14767
|
-
return
|
|
15074
|
+
return chalk47.green;
|
|
14768
15075
|
case "connecting":
|
|
14769
|
-
return
|
|
15076
|
+
return chalk47.yellow;
|
|
14770
15077
|
case "error":
|
|
14771
|
-
return
|
|
15078
|
+
return chalk47.red;
|
|
14772
15079
|
case "disconnected":
|
|
14773
|
-
return
|
|
15080
|
+
return chalk47.gray;
|
|
14774
15081
|
default:
|
|
14775
|
-
return
|
|
15082
|
+
return chalk47.white;
|
|
14776
15083
|
}
|
|
14777
15084
|
};
|
|
14778
15085
|
const header = [
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
|
|
15086
|
+
chalk47.bold("Name"),
|
|
15087
|
+
chalk47.bold("Status"),
|
|
15088
|
+
chalk47.bold("Tools")
|
|
14782
15089
|
].join(" | ");
|
|
14783
15090
|
const rows = servers.map((s) => [
|
|
14784
|
-
|
|
15091
|
+
chalk47.cyan(s.name),
|
|
14785
15092
|
statusColor(s.status)(`[${s.status}]`),
|
|
14786
15093
|
s.toolsCount !== undefined ? String(s.toolsCount) : "-"
|
|
14787
15094
|
].join(" | "));
|
|
@@ -14792,7 +15099,7 @@ var ListCommand6 = {
|
|
|
14792
15099
|
...rows.map((r) => `│${r}│`),
|
|
14793
15100
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
14794
15101
|
"",
|
|
14795
|
-
|
|
15102
|
+
chalk47.gray(`Total: ${servers.length} servers`)
|
|
14796
15103
|
].join(`
|
|
14797
15104
|
`));
|
|
14798
15105
|
}
|
|
@@ -14806,7 +15113,7 @@ var ListCommand6 = {
|
|
|
14806
15113
|
};
|
|
14807
15114
|
|
|
14808
15115
|
// src/commands/mcp/tools.ts
|
|
14809
|
-
import
|
|
15116
|
+
import chalk48 from "chalk";
|
|
14810
15117
|
var ToolsCommand = {
|
|
14811
15118
|
command: "tools",
|
|
14812
15119
|
aliases: ["t"],
|
|
@@ -14859,7 +15166,7 @@ var ToolsCommand = {
|
|
|
14859
15166
|
tools.forEach((t) => output.log(t.name));
|
|
14860
15167
|
} else {
|
|
14861
15168
|
if (tools.length === 0) {
|
|
14862
|
-
output.log(
|
|
15169
|
+
output.log(chalk48.yellow("No MCP tools available"));
|
|
14863
15170
|
return;
|
|
14864
15171
|
}
|
|
14865
15172
|
const byServer = new Map;
|
|
@@ -14871,15 +15178,15 @@ var ToolsCommand = {
|
|
|
14871
15178
|
byServer.get(serverName).push(tool);
|
|
14872
15179
|
}
|
|
14873
15180
|
for (const [serverName, serverTools] of byServer) {
|
|
14874
|
-
output.log(
|
|
15181
|
+
output.log(chalk48.bold.cyan(`
|
|
14875
15182
|
[${serverName}] ${serverTools.length} tools`));
|
|
14876
15183
|
for (const tool of serverTools) {
|
|
14877
15184
|
const desc2 = tool.description.length > 80 ? tool.description.slice(0, 77) + "..." : tool.description;
|
|
14878
|
-
output.log(` ${
|
|
14879
|
-
output.log(` ${
|
|
15185
|
+
output.log(` ${chalk48.green("+")} ${chalk48.white(tool.name)}`);
|
|
15186
|
+
output.log(` ${chalk48.gray(desc2)}`);
|
|
14880
15187
|
}
|
|
14881
15188
|
}
|
|
14882
|
-
output.log(
|
|
15189
|
+
output.log(chalk48.gray(`
|
|
14883
15190
|
Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
14884
15191
|
}
|
|
14885
15192
|
} catch (error) {
|
|
@@ -14892,7 +15199,7 @@ Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
|
14892
15199
|
};
|
|
14893
15200
|
|
|
14894
15201
|
// src/commands/mcp/reload.ts
|
|
14895
|
-
import
|
|
15202
|
+
import chalk49 from "chalk";
|
|
14896
15203
|
var ReloadCommand2 = {
|
|
14897
15204
|
command: "reload",
|
|
14898
15205
|
aliases: ["r"],
|
|
@@ -14913,19 +15220,19 @@ var ReloadCommand2 = {
|
|
|
14913
15220
|
output.error("McpComponent not available");
|
|
14914
15221
|
process.exit(1);
|
|
14915
15222
|
}
|
|
14916
|
-
output.log(
|
|
15223
|
+
output.log(chalk49.cyan("Reloading MCP servers..."));
|
|
14917
15224
|
await mcpComponent.reload();
|
|
14918
15225
|
const servers = mcpComponent.listServers();
|
|
14919
15226
|
const connected = servers.filter((s) => s.status === "connected").length;
|
|
14920
15227
|
const errors = servers.filter((s) => s.status === "error").length;
|
|
14921
|
-
output.log(
|
|
15228
|
+
output.log(chalk49.green(`✓ Reloaded ${servers.length} servers`));
|
|
14922
15229
|
if (connected > 0) {
|
|
14923
|
-
output.log(
|
|
15230
|
+
output.log(chalk49.green(` • ${connected} connected`));
|
|
14924
15231
|
}
|
|
14925
15232
|
if (errors > 0) {
|
|
14926
15233
|
output.warn(` • ${errors} failed`);
|
|
14927
15234
|
for (const server of servers.filter((s) => s.status === "error")) {
|
|
14928
|
-
output.log(
|
|
15235
|
+
output.log(chalk49.gray(` - ${server.name}: ${server.error}`));
|
|
14929
15236
|
}
|
|
14930
15237
|
}
|
|
14931
15238
|
} catch (error) {
|
|
@@ -14946,7 +15253,7 @@ var McpCommand = {
|
|
|
14946
15253
|
};
|
|
14947
15254
|
|
|
14948
15255
|
// src/commands/tools/list.ts
|
|
14949
|
-
import
|
|
15256
|
+
import chalk50 from "chalk";
|
|
14950
15257
|
var ListCommand7 = {
|
|
14951
15258
|
command: "list",
|
|
14952
15259
|
aliases: ["ls"],
|
|
@@ -14991,16 +15298,16 @@ var ListCommand7 = {
|
|
|
14991
15298
|
tools.forEach((t) => output.log(t.name));
|
|
14992
15299
|
} else {
|
|
14993
15300
|
const header = [
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
15301
|
+
chalk50.bold("Name"),
|
|
15302
|
+
chalk50.bold("Description"),
|
|
15303
|
+
chalk50.bold("Category")
|
|
14997
15304
|
].join(" | ");
|
|
14998
15305
|
const rows = tools.map((t) => {
|
|
14999
15306
|
const desc2 = t.description.length > 40 ? t.description.slice(0, 37) + "..." : t.description;
|
|
15000
15307
|
return [
|
|
15001
|
-
|
|
15308
|
+
chalk50.cyan(t.name),
|
|
15002
15309
|
desc2,
|
|
15003
|
-
t.metadata?.category ?
|
|
15310
|
+
t.metadata?.category ? chalk50.gray(`[${t.metadata.category}]`) : "-"
|
|
15004
15311
|
].join(" | ");
|
|
15005
15312
|
});
|
|
15006
15313
|
output.log([
|
|
@@ -15010,7 +15317,7 @@ var ListCommand7 = {
|
|
|
15010
15317
|
...rows.map((r) => `│${r}│`),
|
|
15011
15318
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
15012
15319
|
"",
|
|
15013
|
-
|
|
15320
|
+
chalk50.gray(`Total: ${tools.length} tools`)
|
|
15014
15321
|
].join(`
|
|
15015
15322
|
`));
|
|
15016
15323
|
}
|
|
@@ -15024,7 +15331,7 @@ var ListCommand7 = {
|
|
|
15024
15331
|
};
|
|
15025
15332
|
|
|
15026
15333
|
// src/commands/tools/get.ts
|
|
15027
|
-
import
|
|
15334
|
+
import chalk51 from "chalk";
|
|
15028
15335
|
|
|
15029
15336
|
// src/commands/tools/shared/schema-helper.ts
|
|
15030
15337
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -15099,8 +15406,8 @@ var GetCommand6 = {
|
|
|
15099
15406
|
}))
|
|
15100
15407
|
});
|
|
15101
15408
|
} else {
|
|
15102
|
-
output.log(
|
|
15103
|
-
output.log(
|
|
15409
|
+
output.log(chalk51.bold.cyan(`Tool: ${tool.name}`));
|
|
15410
|
+
output.log(chalk51.gray("─".repeat(60)));
|
|
15104
15411
|
output.log(`Description: ${tool.description}`);
|
|
15105
15412
|
if (tool.metadata?.category) {
|
|
15106
15413
|
output.log(`Category: ${tool.metadata.category}`);
|
|
@@ -15109,9 +15416,9 @@ var GetCommand6 = {
|
|
|
15109
15416
|
output.log(`Tags: ${tool.metadata.tags.join(", ")}`);
|
|
15110
15417
|
}
|
|
15111
15418
|
output.log("");
|
|
15112
|
-
output.log(
|
|
15419
|
+
output.log(chalk51.bold("Parameters:"));
|
|
15113
15420
|
for (const param of params) {
|
|
15114
|
-
const required = param.required ?
|
|
15421
|
+
const required = param.required ? chalk51.red("(required)") : chalk51.gray("(optional)");
|
|
15115
15422
|
const defaultVal = param.default !== undefined ? ` [default: ${JSON.stringify(param.default)}]` : "";
|
|
15116
15423
|
output.log(` --${param.name} <${param.type}> ${required}`);
|
|
15117
15424
|
output.log(` ${param.description}${defaultVal}`);
|
|
@@ -15220,14 +15527,14 @@ var ToolsCommand2 = {
|
|
|
15220
15527
|
};
|
|
15221
15528
|
|
|
15222
15529
|
// src/commands/memory/record.ts
|
|
15223
|
-
import
|
|
15530
|
+
import chalk52 from "chalk";
|
|
15224
15531
|
import { createMemoryAgentTools, getBuiltInPrompt } from "@ai-setting/roy-agent-core";
|
|
15225
15532
|
import { bashTool, globTool, readFileTool } from "@ai-setting/roy-agent-core";
|
|
15226
15533
|
async function runExtractMode(output, memoryComponent, agentComponent, sessionComponent, env, options) {
|
|
15227
15534
|
const { scope, sessionId, require: userRequirement } = options;
|
|
15228
|
-
output.log(
|
|
15535
|
+
output.log(chalk52.blue(`
|
|
15229
15536
|
\uD83D\uDD0D Memory Extract Mode (${scope})`));
|
|
15230
|
-
output.log(
|
|
15537
|
+
output.log(chalk52.gray(`正在分析会话历史,生成记忆...
|
|
15231
15538
|
`));
|
|
15232
15539
|
try {
|
|
15233
15540
|
const currentMemory = await memoryComponent.recallMemory(scope) || "(无现有记忆)";
|
|
@@ -15273,13 +15580,13 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
15273
15580
|
for (const tool of agentTools) {
|
|
15274
15581
|
try {
|
|
15275
15582
|
toolComponent.register(tool);
|
|
15276
|
-
output.log(
|
|
15583
|
+
output.log(chalk52.gray(`Tool registered: ${tool.name}`));
|
|
15277
15584
|
} catch (err) {
|
|
15278
|
-
output.log(
|
|
15585
|
+
output.log(chalk52.gray(`Tool already registered: ${tool.name}`));
|
|
15279
15586
|
}
|
|
15280
15587
|
}
|
|
15281
15588
|
}
|
|
15282
|
-
output.log(
|
|
15589
|
+
output.log(chalk52.gray(`Agent "${agentName}" registered with ${agentTools.length} tools`));
|
|
15283
15590
|
const query = `请分析会话历史,提炼${scope === "project" ? "项目" : "全局"}记忆并写入记忆文件。`;
|
|
15284
15591
|
let result;
|
|
15285
15592
|
try {
|
|
@@ -15293,12 +15600,12 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
15293
15600
|
if (result && result.startsWith("执行失败")) {
|
|
15294
15601
|
output.error(`提取失败: ${result}`);
|
|
15295
15602
|
} else if (result) {
|
|
15296
|
-
output.log(
|
|
15603
|
+
output.log(chalk52.green(`
|
|
15297
15604
|
✅ 记忆提取完成`));
|
|
15298
|
-
output.log(
|
|
15605
|
+
output.log(chalk52.gray(`记忆已保存到 memory 文件。
|
|
15299
15606
|
`));
|
|
15300
15607
|
if (result.length > 0 && result !== "✅ 记忆提取完成") {
|
|
15301
|
-
output.log(
|
|
15608
|
+
output.log(chalk52.gray(`执行摘要: ${result.substring(0, 200)}${result.length > 200 ? "..." : ""}`));
|
|
15302
15609
|
}
|
|
15303
15610
|
}
|
|
15304
15611
|
agentComponent.unregisterAgent(agentName);
|
|
@@ -15416,11 +15723,11 @@ var RecordCommand = {
|
|
|
15416
15723
|
prepend: "已插入内容到记忆文件开头",
|
|
15417
15724
|
delete: "已删除记忆文件"
|
|
15418
15725
|
};
|
|
15419
|
-
output.log(
|
|
15420
|
-
output.log(
|
|
15726
|
+
output.log(chalk52.green(`✓ ${actionMessages[result.action]}`));
|
|
15727
|
+
output.log(chalk52.gray(`路径: ${result.path}`));
|
|
15421
15728
|
if (result.action !== "delete" && a.content) {
|
|
15422
15729
|
const preview = a.content.substring(0, 100);
|
|
15423
|
-
output.log(
|
|
15730
|
+
output.log(chalk52.gray(`内容预览: ${preview}${a.content.length > 100 ? "..." : ""}`));
|
|
15424
15731
|
}
|
|
15425
15732
|
} catch (error) {
|
|
15426
15733
|
output.error(`Failed to record memory: ${error}`);
|
|
@@ -15432,7 +15739,7 @@ var RecordCommand = {
|
|
|
15432
15739
|
};
|
|
15433
15740
|
|
|
15434
15741
|
// src/commands/memory/recall.ts
|
|
15435
|
-
import
|
|
15742
|
+
import chalk53 from "chalk";
|
|
15436
15743
|
var RecallCommand = {
|
|
15437
15744
|
command: "recall",
|
|
15438
15745
|
aliases: ["load"],
|
|
@@ -15468,7 +15775,7 @@ var RecallCommand = {
|
|
|
15468
15775
|
}
|
|
15469
15776
|
const content = await memoryComponent.recallMemory(a.scope);
|
|
15470
15777
|
if (!content) {
|
|
15471
|
-
output.log(
|
|
15778
|
+
output.log(chalk53.gray("(No memory files found)"));
|
|
15472
15779
|
return;
|
|
15473
15780
|
}
|
|
15474
15781
|
if (a.json) {
|
|
@@ -15494,7 +15801,7 @@ var MemoryCommand = {
|
|
|
15494
15801
|
handler: () => {}
|
|
15495
15802
|
};
|
|
15496
15803
|
// src/commands/eventsource/list.ts
|
|
15497
|
-
import
|
|
15804
|
+
import chalk54 from "chalk";
|
|
15498
15805
|
function truncateVisual2(str, maxWidth) {
|
|
15499
15806
|
let result = "";
|
|
15500
15807
|
let width = 0;
|
|
@@ -15509,7 +15816,7 @@ function truncateVisual2(str, maxWidth) {
|
|
|
15509
15816
|
}
|
|
15510
15817
|
function formatSourcesTable(sources) {
|
|
15511
15818
|
if (sources.length === 0) {
|
|
15512
|
-
return
|
|
15819
|
+
return chalk54.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加");
|
|
15513
15820
|
}
|
|
15514
15821
|
const ID_WIDTH = 10;
|
|
15515
15822
|
const NAME_WIDTH = 20;
|
|
@@ -15518,11 +15825,11 @@ function formatSourcesTable(sources) {
|
|
|
15518
15825
|
const ENABLED_WIDTH = 8;
|
|
15519
15826
|
const GAP = " ";
|
|
15520
15827
|
const headerLine = [
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15828
|
+
chalk54.bold("ID".padEnd(ID_WIDTH)),
|
|
15829
|
+
chalk54.bold("NAME".padEnd(NAME_WIDTH)),
|
|
15830
|
+
chalk54.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
15831
|
+
chalk54.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
15832
|
+
chalk54.bold("ENABLED".padEnd(ENABLED_WIDTH))
|
|
15526
15833
|
].join(GAP);
|
|
15527
15834
|
const sepLine = "─".repeat(ID_WIDTH + NAME_WIDTH + TYPE_WIDTH + STATUS_WIDTH + ENABLED_WIDTH + GAP.length * 4);
|
|
15528
15835
|
const formatRow = (src) => {
|
|
@@ -15575,7 +15882,7 @@ var EventSourceListCommand = {
|
|
|
15575
15882
|
if (args.json) {
|
|
15576
15883
|
output.json({ sources: [], count: 0 });
|
|
15577
15884
|
} else {
|
|
15578
|
-
output.log(
|
|
15885
|
+
output.log(chalk54.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加"));
|
|
15579
15886
|
}
|
|
15580
15887
|
return;
|
|
15581
15888
|
}
|
|
@@ -15590,26 +15897,26 @@ var EventSourceListCommand = {
|
|
|
15590
15897
|
const rows = sources.map((s) => {
|
|
15591
15898
|
const status = esComponent.getStatus(s.id) || "unknown";
|
|
15592
15899
|
const statusColorMap = {
|
|
15593
|
-
running:
|
|
15594
|
-
stopped:
|
|
15595
|
-
error:
|
|
15596
|
-
starting:
|
|
15597
|
-
created:
|
|
15598
|
-
stopping:
|
|
15599
|
-
unknown:
|
|
15900
|
+
running: chalk54.green,
|
|
15901
|
+
stopped: chalk54.gray,
|
|
15902
|
+
error: chalk54.red,
|
|
15903
|
+
starting: chalk54.yellow,
|
|
15904
|
+
created: chalk54.gray,
|
|
15905
|
+
stopping: chalk54.yellow,
|
|
15906
|
+
unknown: chalk54.gray
|
|
15600
15907
|
};
|
|
15601
|
-
const statusColor = statusColorMap[status] ||
|
|
15908
|
+
const statusColor = statusColorMap[status] || chalk54.gray;
|
|
15602
15909
|
return {
|
|
15603
15910
|
id: s.id.substring(0, 8),
|
|
15604
15911
|
name: s.name,
|
|
15605
15912
|
type: s.type,
|
|
15606
15913
|
status: statusColor(status),
|
|
15607
|
-
enabled: s.enabled ?
|
|
15914
|
+
enabled: s.enabled ? chalk54.green("✓") : chalk54.gray("✗")
|
|
15608
15915
|
};
|
|
15609
15916
|
});
|
|
15610
15917
|
output.log(formatSourcesTable(rows));
|
|
15611
15918
|
output.info("");
|
|
15612
|
-
output.log(
|
|
15919
|
+
output.log(chalk54.green(`✅ 共 ${sources.length} 个事件源`));
|
|
15613
15920
|
} catch (error) {
|
|
15614
15921
|
output.error(`Failed to list event sources: ${error}`);
|
|
15615
15922
|
process.exit(1);
|
|
@@ -15620,7 +15927,7 @@ var EventSourceListCommand = {
|
|
|
15620
15927
|
};
|
|
15621
15928
|
|
|
15622
15929
|
// src/commands/eventsource/add.ts
|
|
15623
|
-
import
|
|
15930
|
+
import chalk55 from "chalk";
|
|
15624
15931
|
import { generateId } from "@ai-setting/roy-agent-core";
|
|
15625
15932
|
function uuid() {
|
|
15626
15933
|
return generateId();
|
|
@@ -15685,21 +15992,21 @@ var EventSourceAddCommand = {
|
|
|
15685
15992
|
cron: a.cron
|
|
15686
15993
|
};
|
|
15687
15994
|
esComponent.register(config);
|
|
15688
|
-
output.success(
|
|
15995
|
+
output.success(chalk55.green(`事件源 '${a.name}' 添加成功!`));
|
|
15689
15996
|
output.log("");
|
|
15690
|
-
output.log(` ID: ${
|
|
15691
|
-
output.log(` Type: ${
|
|
15997
|
+
output.log(` ID: ${chalk55.gray(config.id)}`);
|
|
15998
|
+
output.log(` Type: ${chalk55.cyan(a.type)}`);
|
|
15692
15999
|
if (eventTypes?.length) {
|
|
15693
|
-
output.log(` Event Types: ${
|
|
16000
|
+
output.log(` Event Types: ${chalk55.gray(eventTypes.join(", "))}`);
|
|
15694
16001
|
}
|
|
15695
16002
|
if (a.command) {
|
|
15696
|
-
output.log(` Command: ${
|
|
16003
|
+
output.log(` Command: ${chalk55.gray(a.command)}`);
|
|
15697
16004
|
}
|
|
15698
16005
|
if (a.interval) {
|
|
15699
|
-
output.log(` Interval: ${
|
|
16006
|
+
output.log(` Interval: ${chalk55.gray(`${a.interval}ms`)}`);
|
|
15700
16007
|
}
|
|
15701
16008
|
output.log("");
|
|
15702
|
-
output.log(
|
|
16009
|
+
output.log(chalk55.gray(`使用 'roy-agent eventsource start ${config.id.substring(0, 8)}' 启动它。`));
|
|
15703
16010
|
} finally {
|
|
15704
16011
|
await envService.dispose();
|
|
15705
16012
|
}
|
|
@@ -15707,7 +16014,7 @@ var EventSourceAddCommand = {
|
|
|
15707
16014
|
};
|
|
15708
16015
|
|
|
15709
16016
|
// src/commands/eventsource/remove.ts
|
|
15710
|
-
import
|
|
16017
|
+
import chalk56 from "chalk";
|
|
15711
16018
|
var EventSourceRemoveCommand = {
|
|
15712
16019
|
command: "remove <id>",
|
|
15713
16020
|
aliases: ["rm"],
|
|
@@ -15746,7 +16053,7 @@ var EventSourceRemoveCommand = {
|
|
|
15746
16053
|
const status = esComponent.getStatus(matchedSource.id);
|
|
15747
16054
|
if (status === "running" && !args.force) {
|
|
15748
16055
|
output.error(`事件源正在运行中,请先停止: ${matchedSource.name} (${status})`);
|
|
15749
|
-
output.log(
|
|
16056
|
+
output.log(chalk56.gray(`使用 --force 强制移除或 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' 先停止`));
|
|
15750
16057
|
process.exit(1);
|
|
15751
16058
|
}
|
|
15752
16059
|
if (status === "running") {
|
|
@@ -15755,7 +16062,7 @@ var EventSourceRemoveCommand = {
|
|
|
15755
16062
|
}
|
|
15756
16063
|
const result = esComponent.unregister(matchedSource.id);
|
|
15757
16064
|
if (result) {
|
|
15758
|
-
output.success(
|
|
16065
|
+
output.success(chalk56.green(`事件源已移除: ${matchedSource.name}`));
|
|
15759
16066
|
} else {
|
|
15760
16067
|
output.error("移除失败");
|
|
15761
16068
|
process.exit(1);
|
|
@@ -15767,7 +16074,7 @@ var EventSourceRemoveCommand = {
|
|
|
15767
16074
|
};
|
|
15768
16075
|
|
|
15769
16076
|
// src/commands/eventsource/start.ts
|
|
15770
|
-
import
|
|
16077
|
+
import chalk57 from "chalk";
|
|
15771
16078
|
var EventSourceStartCommand = {
|
|
15772
16079
|
command: "start <id>",
|
|
15773
16080
|
describe: "启动指定的事件源",
|
|
@@ -15804,15 +16111,15 @@ var EventSourceStartCommand = {
|
|
|
15804
16111
|
}
|
|
15805
16112
|
const status = esComponent.getStatus(matchedSource.id);
|
|
15806
16113
|
if (status === "running") {
|
|
15807
|
-
output.log(
|
|
16114
|
+
output.log(chalk57.yellow(`事件源已在运行: ${matchedSource.name}`));
|
|
15808
16115
|
return;
|
|
15809
16116
|
}
|
|
15810
16117
|
output.info(`正在启动事件源 '${matchedSource.name}'...`);
|
|
15811
16118
|
try {
|
|
15812
16119
|
await esComponent.startSource(matchedSource.id);
|
|
15813
|
-
output.success(
|
|
16120
|
+
output.success(chalk57.green(`事件源已启动: ${matchedSource.name}`));
|
|
15814
16121
|
if (!args.background) {
|
|
15815
|
-
output.log(
|
|
16122
|
+
output.log(chalk57.gray("按 Ctrl+C 停止..."));
|
|
15816
16123
|
await new Promise((resolve) => {
|
|
15817
16124
|
const cleanup = () => {
|
|
15818
16125
|
process.removeListener("SIGINT", cleanup);
|
|
@@ -15834,7 +16141,7 @@ var EventSourceStartCommand = {
|
|
|
15834
16141
|
};
|
|
15835
16142
|
|
|
15836
16143
|
// src/commands/eventsource/stop.ts
|
|
15837
|
-
import
|
|
16144
|
+
import chalk58 from "chalk";
|
|
15838
16145
|
var EventSourceStopCommand = {
|
|
15839
16146
|
command: "stop <id>",
|
|
15840
16147
|
aliases: ["kill"],
|
|
@@ -15872,13 +16179,13 @@ var EventSourceStopCommand = {
|
|
|
15872
16179
|
}
|
|
15873
16180
|
const status = esComponent.getStatus(matchedSource.id);
|
|
15874
16181
|
if (status !== "running") {
|
|
15875
|
-
output.log(
|
|
16182
|
+
output.log(chalk58.yellow(`事件源未运行: ${matchedSource.name} (${status || "unknown"})`));
|
|
15876
16183
|
return;
|
|
15877
16184
|
}
|
|
15878
16185
|
output.info(`正在停止事件源 '${matchedSource.name}'...`);
|
|
15879
16186
|
try {
|
|
15880
16187
|
await esComponent.stopSource(matchedSource.id);
|
|
15881
|
-
output.success(
|
|
16188
|
+
output.success(chalk58.green(`事件源已停止: ${matchedSource.name}`));
|
|
15882
16189
|
} catch (error) {
|
|
15883
16190
|
output.error(`停止失败: ${error}`);
|
|
15884
16191
|
process.exit(1);
|
|
@@ -15890,14 +16197,14 @@ var EventSourceStopCommand = {
|
|
|
15890
16197
|
};
|
|
15891
16198
|
|
|
15892
16199
|
// src/commands/eventsource/status.ts
|
|
15893
|
-
import
|
|
16200
|
+
import chalk59 from "chalk";
|
|
15894
16201
|
var STATUS_COLORS = {
|
|
15895
|
-
created:
|
|
15896
|
-
starting:
|
|
15897
|
-
running:
|
|
15898
|
-
stopping:
|
|
15899
|
-
stopped:
|
|
15900
|
-
error:
|
|
16202
|
+
created: chalk59.gray,
|
|
16203
|
+
starting: chalk59.yellow,
|
|
16204
|
+
running: chalk59.green,
|
|
16205
|
+
stopping: chalk59.yellow,
|
|
16206
|
+
stopped: chalk59.gray,
|
|
16207
|
+
error: chalk59.red
|
|
15901
16208
|
};
|
|
15902
16209
|
var STATUS_ICONS = {
|
|
15903
16210
|
created: "○",
|
|
@@ -15951,7 +16258,7 @@ var EventSourceStatusCommand = {
|
|
|
15951
16258
|
process.exit(1);
|
|
15952
16259
|
}
|
|
15953
16260
|
const status = esComponent.getStatus(matchedSource.id) || "unknown";
|
|
15954
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
16261
|
+
const statusColor = STATUS_COLORS[status] || chalk59.gray;
|
|
15955
16262
|
if (args.json) {
|
|
15956
16263
|
output.json({
|
|
15957
16264
|
id: matchedSource.id,
|
|
@@ -15968,31 +16275,31 @@ var EventSourceStatusCommand = {
|
|
|
15968
16275
|
});
|
|
15969
16276
|
return;
|
|
15970
16277
|
}
|
|
15971
|
-
output.log(
|
|
16278
|
+
output.log(chalk59.bold("事件源详情"));
|
|
15972
16279
|
output.log("─".repeat(50));
|
|
15973
|
-
output.log(` ID: ${
|
|
15974
|
-
output.log(` Name: ${
|
|
15975
|
-
output.log(` Type: ${
|
|
16280
|
+
output.log(` ID: ${chalk59.gray(matchedSource.id)}`);
|
|
16281
|
+
output.log(` Name: ${chalk59.cyan(matchedSource.name)}`);
|
|
16282
|
+
output.log(` Type: ${chalk59.cyan(matchedSource.type)}`);
|
|
15976
16283
|
output.log(` Status: ${statusColor(`${STATUS_ICONS[status]} ${STATUS_LABELS[status]}`)}`);
|
|
15977
|
-
output.log(` Enabled: ${matchedSource.enabled ?
|
|
16284
|
+
output.log(` Enabled: ${matchedSource.enabled ? chalk59.green("是") : chalk59.gray("否")}`);
|
|
15978
16285
|
if (matchedSource.eventTypes?.length) {
|
|
15979
|
-
output.log(` Events: ${
|
|
16286
|
+
output.log(` Events: ${chalk59.gray(matchedSource.eventTypes.join(", "))}`);
|
|
15980
16287
|
}
|
|
15981
16288
|
if (matchedSource.command) {
|
|
15982
|
-
output.log(` Command: ${
|
|
16289
|
+
output.log(` Command: ${chalk59.gray(matchedSource.command)}`);
|
|
15983
16290
|
}
|
|
15984
16291
|
if (matchedSource.interval) {
|
|
15985
|
-
output.log(` Interval: ${
|
|
16292
|
+
output.log(` Interval: ${chalk59.gray(`${matchedSource.interval}ms`)}`);
|
|
15986
16293
|
}
|
|
15987
16294
|
if (matchedSource.url) {
|
|
15988
|
-
output.log(` URL: ${
|
|
16295
|
+
output.log(` URL: ${chalk59.gray(matchedSource.url)}`);
|
|
15989
16296
|
}
|
|
15990
16297
|
output.log("");
|
|
15991
16298
|
return;
|
|
15992
16299
|
}
|
|
15993
16300
|
const sources = esComponent.list();
|
|
15994
16301
|
if (sources.length === 0) {
|
|
15995
|
-
output.log(
|
|
16302
|
+
output.log(chalk59.yellow("没有配置的事件源"));
|
|
15996
16303
|
return;
|
|
15997
16304
|
}
|
|
15998
16305
|
if (args.json) {
|
|
@@ -16006,21 +16313,21 @@ var EventSourceStatusCommand = {
|
|
|
16006
16313
|
output.json({ sources: sourcesWithStatus, count: sources.length });
|
|
16007
16314
|
return;
|
|
16008
16315
|
}
|
|
16009
|
-
output.log(
|
|
16316
|
+
output.log(chalk59.bold("事件源状态概览"));
|
|
16010
16317
|
output.log("─".repeat(60));
|
|
16011
16318
|
for (const source of sources) {
|
|
16012
16319
|
const status = esComponent.getStatus(source.id) || "unknown";
|
|
16013
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
16320
|
+
const statusColor = STATUS_COLORS[status] || chalk59.gray;
|
|
16014
16321
|
const icon = STATUS_ICONS[status] || "?";
|
|
16015
16322
|
const label = STATUS_LABELS[status] || status;
|
|
16016
16323
|
output.log("");
|
|
16017
|
-
output.log(` ${
|
|
16324
|
+
output.log(` ${chalk59.cyan(source.name)} ${chalk59.gray(`(${source.type})`)}`);
|
|
16018
16325
|
output.log(` └─ Status: ${statusColor(`${icon} ${label}`)}`);
|
|
16019
|
-
output.log(` ID: ${
|
|
16326
|
+
output.log(` ID: ${chalk59.gray(source.id.substring(0, 8))}...`);
|
|
16020
16327
|
}
|
|
16021
16328
|
output.log("");
|
|
16022
16329
|
const runningCount = sources.filter((s) => esComponent.getStatus(s.id) === "running").length;
|
|
16023
|
-
output.log(
|
|
16330
|
+
output.log(chalk59.green(`✅ ${runningCount}/${sources.length} 运行中`));
|
|
16024
16331
|
} finally {
|
|
16025
16332
|
await envService.dispose();
|
|
16026
16333
|
}
|
|
@@ -16333,7 +16640,7 @@ var DebugCommand = {
|
|
|
16333
16640
|
};
|
|
16334
16641
|
|
|
16335
16642
|
// src/commands/workflow/renderers.ts
|
|
16336
|
-
import
|
|
16643
|
+
import chalk60 from "chalk";
|
|
16337
16644
|
function truncateVisual3(str, maxWidth) {
|
|
16338
16645
|
if (!str)
|
|
16339
16646
|
return "-";
|
|
@@ -16368,18 +16675,18 @@ function formatDuration(ms) {
|
|
|
16368
16675
|
function statusColor(status) {
|
|
16369
16676
|
switch (status) {
|
|
16370
16677
|
case "completed":
|
|
16371
|
-
return
|
|
16678
|
+
return chalk60.green;
|
|
16372
16679
|
case "running":
|
|
16373
16680
|
case "idle":
|
|
16374
|
-
return
|
|
16681
|
+
return chalk60.blue;
|
|
16375
16682
|
case "paused":
|
|
16376
|
-
return
|
|
16683
|
+
return chalk60.yellow;
|
|
16377
16684
|
case "failed":
|
|
16378
|
-
return
|
|
16685
|
+
return chalk60.red;
|
|
16379
16686
|
case "stopped":
|
|
16380
|
-
return
|
|
16687
|
+
return chalk60.gray;
|
|
16381
16688
|
default:
|
|
16382
|
-
return
|
|
16689
|
+
return chalk60.white;
|
|
16383
16690
|
}
|
|
16384
16691
|
}
|
|
16385
16692
|
function renderWorkflowList(workflows, options) {
|
|
@@ -16398,7 +16705,7 @@ function renderWorkflowList(workflows, options) {
|
|
|
16398
16705
|
}, null, 2);
|
|
16399
16706
|
}
|
|
16400
16707
|
if (workflows.length === 0) {
|
|
16401
|
-
return
|
|
16708
|
+
return chalk60.yellow("No workflows found");
|
|
16402
16709
|
}
|
|
16403
16710
|
const NAME_WIDTH = 30;
|
|
16404
16711
|
const VERSION_WIDTH = 10;
|
|
@@ -16406,10 +16713,10 @@ function renderWorkflowList(workflows, options) {
|
|
|
16406
16713
|
const UPDATED_WIDTH = 20;
|
|
16407
16714
|
const GAP = " ";
|
|
16408
16715
|
const headerLine = [
|
|
16409
|
-
|
|
16410
|
-
|
|
16411
|
-
|
|
16412
|
-
|
|
16716
|
+
chalk60.bold("NAME".padEnd(NAME_WIDTH)),
|
|
16717
|
+
chalk60.bold("VER".padEnd(VERSION_WIDTH)),
|
|
16718
|
+
chalk60.bold("TAGS".padEnd(TAGS_WIDTH)),
|
|
16719
|
+
chalk60.bold("UPDATED")
|
|
16413
16720
|
].join(GAP);
|
|
16414
16721
|
const sepLine = "─".repeat(NAME_WIDTH + VERSION_WIDTH + TAGS_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
16415
16722
|
const rows = workflows.map((w) => {
|
|
@@ -16424,18 +16731,18 @@ function renderWorkflowList(workflows, options) {
|
|
|
16424
16731
|
}
|
|
16425
16732
|
function renderWorkflowDetail(workflow, options) {
|
|
16426
16733
|
const lines = [];
|
|
16427
|
-
lines.push(
|
|
16734
|
+
lines.push(chalk60.bold(`
|
|
16428
16735
|
\uD83D\uDCCB Workflow Details
|
|
16429
16736
|
`));
|
|
16430
|
-
lines.push(` ${
|
|
16431
|
-
lines.push(` ${
|
|
16432
|
-
lines.push(` ${
|
|
16433
|
-
lines.push(` ${
|
|
16434
|
-
lines.push(` ${
|
|
16435
|
-
lines.push(` ${
|
|
16436
|
-
lines.push(` ${
|
|
16737
|
+
lines.push(` ${chalk60.cyan("ID:")} ${workflow.id}`);
|
|
16738
|
+
lines.push(` ${chalk60.cyan("Name:")} ${workflow.name}`);
|
|
16739
|
+
lines.push(` ${chalk60.cyan("Version:")} ${workflow.version}`);
|
|
16740
|
+
lines.push(` ${chalk60.cyan("Description:")} ${workflow.description || "-"}`);
|
|
16741
|
+
lines.push(` ${chalk60.cyan("Tags:")} ${workflow.tags.join(", ") || "-"}`);
|
|
16742
|
+
lines.push(` ${chalk60.cyan("Created:")} ${formatDate(workflow.createdAt)}`);
|
|
16743
|
+
lines.push(` ${chalk60.cyan("Updated:")} ${formatDate(workflow.updatedAt)}`);
|
|
16437
16744
|
const nodeCount = workflow.definition.nodes.length;
|
|
16438
|
-
lines.push(
|
|
16745
|
+
lines.push(chalk60.bold(`
|
|
16439
16746
|
\uD83D\uDCCA Nodes Summary
|
|
16440
16747
|
`));
|
|
16441
16748
|
lines.push(` Total: ${nodeCount} nodes`);
|
|
@@ -16447,7 +16754,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
16447
16754
|
lines.push(` - ${type}: ${count}`);
|
|
16448
16755
|
}
|
|
16449
16756
|
if (workflow.definition.config) {
|
|
16450
|
-
lines.push(
|
|
16757
|
+
lines.push(chalk60.bold(`
|
|
16451
16758
|
⚙️ Configuration
|
|
16452
16759
|
`));
|
|
16453
16760
|
if (workflow.definition.config.parallel_limit !== undefined) {
|
|
@@ -16461,7 +16768,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
16461
16768
|
}
|
|
16462
16769
|
}
|
|
16463
16770
|
if (options?.includeRuns && options.includeRuns.length > 0) {
|
|
16464
|
-
lines.push(
|
|
16771
|
+
lines.push(chalk60.bold(`
|
|
16465
16772
|
\uD83D\uDCDC Recent Runs
|
|
16466
16773
|
`));
|
|
16467
16774
|
lines.push(renderRunsList(options.includeRuns.slice(0, 5)));
|
|
@@ -16485,7 +16792,7 @@ function renderRunsList(runs, options) {
|
|
|
16485
16792
|
}, null, 2);
|
|
16486
16793
|
}
|
|
16487
16794
|
if (runs.length === 0) {
|
|
16488
|
-
return
|
|
16795
|
+
return chalk60.yellow("No runs found");
|
|
16489
16796
|
}
|
|
16490
16797
|
const ID_WIDTH = 20;
|
|
16491
16798
|
const STATUS_WIDTH = 12;
|
|
@@ -16493,10 +16800,10 @@ function renderRunsList(runs, options) {
|
|
|
16493
16800
|
const UPDATED_WIDTH = 20;
|
|
16494
16801
|
const GAP = " ";
|
|
16495
16802
|
const headerLine = [
|
|
16496
|
-
|
|
16497
|
-
|
|
16498
|
-
|
|
16499
|
-
|
|
16803
|
+
chalk60.bold("RUN ID".padEnd(ID_WIDTH)),
|
|
16804
|
+
chalk60.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
16805
|
+
chalk60.bold("DURATION".padEnd(DURATION_WIDTH)),
|
|
16806
|
+
chalk60.bold("STARTED")
|
|
16500
16807
|
].join(GAP);
|
|
16501
16808
|
const sepLine = "─".repeat(ID_WIDTH + STATUS_WIDTH + DURATION_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
16502
16809
|
const rows = runs.map((r) => {
|
|
@@ -16511,34 +16818,34 @@ function renderRunsList(runs, options) {
|
|
|
16511
16818
|
}
|
|
16512
16819
|
function renderRunDetail(run) {
|
|
16513
16820
|
const lines = [];
|
|
16514
|
-
lines.push(
|
|
16821
|
+
lines.push(chalk60.bold(`
|
|
16515
16822
|
\uD83C\uDFC3 Run Details
|
|
16516
16823
|
`));
|
|
16517
|
-
lines.push(` ${
|
|
16518
|
-
lines.push(` ${
|
|
16519
|
-
lines.push(` ${
|
|
16520
|
-
lines.push(` ${
|
|
16824
|
+
lines.push(` ${chalk60.cyan("Run ID:")} ${run.id}`);
|
|
16825
|
+
lines.push(` ${chalk60.cyan("Workflow:")} ${run.workflowId}`);
|
|
16826
|
+
lines.push(` ${chalk60.cyan("Status:")} ${statusColor(run.status)(run.status)}`);
|
|
16827
|
+
lines.push(` ${chalk60.cyan("Started:")} ${formatDate(run.startedAt)}`);
|
|
16521
16828
|
if (run.pausedAt) {
|
|
16522
|
-
lines.push(` ${
|
|
16829
|
+
lines.push(` ${chalk60.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
|
|
16523
16830
|
}
|
|
16524
16831
|
if (run.resumedAt) {
|
|
16525
|
-
lines.push(` ${
|
|
16832
|
+
lines.push(` ${chalk60.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
|
|
16526
16833
|
}
|
|
16527
16834
|
if (run.stoppedAt) {
|
|
16528
|
-
lines.push(` ${
|
|
16835
|
+
lines.push(` ${chalk60.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
|
|
16529
16836
|
}
|
|
16530
16837
|
if (run.completedAt) {
|
|
16531
|
-
lines.push(` ${
|
|
16838
|
+
lines.push(` ${chalk60.cyan("Completed:")} ${formatDate(run.completedAt)}`);
|
|
16532
16839
|
}
|
|
16533
|
-
lines.push(` ${
|
|
16840
|
+
lines.push(` ${chalk60.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
|
|
16534
16841
|
if (run.error) {
|
|
16535
|
-
lines.push(
|
|
16842
|
+
lines.push(chalk60.bold(`
|
|
16536
16843
|
❌ Error
|
|
16537
16844
|
`));
|
|
16538
|
-
lines.push(` ${
|
|
16845
|
+
lines.push(` ${chalk60.red(run.error)}`);
|
|
16539
16846
|
}
|
|
16540
16847
|
if (run.output) {
|
|
16541
|
-
lines.push(
|
|
16848
|
+
lines.push(chalk60.bold(`
|
|
16542
16849
|
\uD83D\uDCE4 Output
|
|
16543
16850
|
`));
|
|
16544
16851
|
lines.push(" " + JSON.stringify(run.output, null, 2).split(`
|
|
@@ -16549,36 +16856,36 @@ function renderRunDetail(run) {
|
|
|
16549
16856
|
`);
|
|
16550
16857
|
}
|
|
16551
16858
|
function renderWorkflowAdded(workflow) {
|
|
16552
|
-
return
|
|
16859
|
+
return chalk60.green(`
|
|
16553
16860
|
✅ Workflow '${workflow.name}' added successfully
|
|
16554
16861
|
`) + ` ID: ${workflow.id}
|
|
16555
16862
|
` + ` Version: ${workflow.version}
|
|
16556
16863
|
`;
|
|
16557
16864
|
}
|
|
16558
16865
|
function renderWorkflowUpdated(workflow) {
|
|
16559
|
-
return
|
|
16866
|
+
return chalk60.green(`
|
|
16560
16867
|
✅ Workflow '${workflow.name}' updated successfully
|
|
16561
16868
|
`) + ` ID: ${workflow.id}
|
|
16562
16869
|
`;
|
|
16563
16870
|
}
|
|
16564
16871
|
function renderWorkflowDeleted(name) {
|
|
16565
|
-
return
|
|
16872
|
+
return chalk60.green(`
|
|
16566
16873
|
✅ Workflow '${name}' deleted successfully
|
|
16567
16874
|
`);
|
|
16568
16875
|
}
|
|
16569
16876
|
function renderRunResult(result) {
|
|
16570
16877
|
const lines = [];
|
|
16571
16878
|
if (result.status === "completed") {
|
|
16572
|
-
lines.push(
|
|
16879
|
+
lines.push(chalk60.green(`
|
|
16573
16880
|
✅ Workflow completed successfully`));
|
|
16574
16881
|
} else if (result.status === "failed") {
|
|
16575
|
-
lines.push(
|
|
16882
|
+
lines.push(chalk60.red(`
|
|
16576
16883
|
❌ Workflow failed`));
|
|
16577
16884
|
} else if (result.status === "stopped") {
|
|
16578
|
-
lines.push(
|
|
16885
|
+
lines.push(chalk60.yellow(`
|
|
16579
16886
|
⚠️ Workflow stopped`));
|
|
16580
16887
|
} else {
|
|
16581
|
-
lines.push(
|
|
16888
|
+
lines.push(chalk60.blue(`
|
|
16582
16889
|
\uD83D\uDD04 Workflow ${result.status}`));
|
|
16583
16890
|
}
|
|
16584
16891
|
lines.push(` Run ID: ${result.runId}`);
|
|
@@ -16586,11 +16893,11 @@ function renderRunResult(result) {
|
|
|
16586
16893
|
lines.push(` Duration: ${formatDuration(result.durationMs)}`);
|
|
16587
16894
|
}
|
|
16588
16895
|
if (result.error) {
|
|
16589
|
-
lines.push(
|
|
16896
|
+
lines.push(chalk60.red(`
|
|
16590
16897
|
Error: ${result.error}`));
|
|
16591
16898
|
}
|
|
16592
16899
|
if (result.output) {
|
|
16593
|
-
lines.push(
|
|
16900
|
+
lines.push(chalk60.bold(`
|
|
16594
16901
|
\uD83D\uDCE4 Output:`));
|
|
16595
16902
|
lines.push(JSON.stringify(result.output, null, 2));
|
|
16596
16903
|
}
|
|
@@ -16604,10 +16911,10 @@ function renderNodesList(nodes) {
|
|
|
16604
16911
|
const DEPS_WIDTH = 20;
|
|
16605
16912
|
const GAP = " ";
|
|
16606
16913
|
const headerLine = [
|
|
16607
|
-
|
|
16608
|
-
|
|
16609
|
-
|
|
16610
|
-
|
|
16914
|
+
chalk60.bold("NODE ID".padEnd(ID_WIDTH)),
|
|
16915
|
+
chalk60.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
16916
|
+
chalk60.bold("NAME".padEnd(NAME_WIDTH)),
|
|
16917
|
+
chalk60.bold("DEPENDS ON")
|
|
16611
16918
|
].join(GAP);
|
|
16612
16919
|
const sepLine = "─".repeat(ID_WIDTH + TYPE_WIDTH + NAME_WIDTH + DEPS_WIDTH + GAP.length * 3);
|
|
16613
16920
|
const rows = nodes.map((n) => {
|
|
@@ -16622,7 +16929,7 @@ function renderNodesList(nodes) {
|
|
|
16622
16929
|
}
|
|
16623
16930
|
|
|
16624
16931
|
// src/commands/workflow/commands/list.ts
|
|
16625
|
-
import
|
|
16932
|
+
import chalk61 from "chalk";
|
|
16626
16933
|
var WorkflowListCommand = {
|
|
16627
16934
|
command: "list",
|
|
16628
16935
|
describe: "列出所有已注册的 Workflow",
|
|
@@ -16705,7 +17012,7 @@ var WorkflowListCommand = {
|
|
|
16705
17012
|
});
|
|
16706
17013
|
} else {
|
|
16707
17014
|
output.log(renderWorkflowList(workflows));
|
|
16708
|
-
output.log(
|
|
17015
|
+
output.log(chalk61.green(`
|
|
16709
17016
|
✅ 共 ${workflows.length} 个 Workflow`));
|
|
16710
17017
|
}
|
|
16711
17018
|
} catch (error) {
|
|
@@ -17307,7 +17614,7 @@ class WorkflowValidator {
|
|
|
17307
17614
|
}
|
|
17308
17615
|
|
|
17309
17616
|
// src/commands/workflow/commands/add.ts
|
|
17310
|
-
import
|
|
17617
|
+
import chalk62 from "chalk";
|
|
17311
17618
|
import fs3 from "fs";
|
|
17312
17619
|
import path6 from "path";
|
|
17313
17620
|
import { createWorkflowExtractorAgent } from "@ai-setting/roy-agent-core/env/task/plugins";
|
|
@@ -17421,7 +17728,7 @@ var WorkflowAddCommand = {
|
|
|
17421
17728
|
definition = await parseWorkflowContent(content, filePath);
|
|
17422
17729
|
workflowName = a.name || definition.name || path6.basename(filePath);
|
|
17423
17730
|
if (a.validate) {
|
|
17424
|
-
output.log(
|
|
17731
|
+
output.log(chalk62.blue("\uD83D\uDD0D Validating workflow..."));
|
|
17425
17732
|
const validator = new WorkflowValidator;
|
|
17426
17733
|
const result = validator.validate(definition);
|
|
17427
17734
|
if (!result.valid) {
|
|
@@ -17436,11 +17743,11 @@ var WorkflowAddCommand = {
|
|
|
17436
17743
|
});
|
|
17437
17744
|
process.exit(1);
|
|
17438
17745
|
}
|
|
17439
|
-
output.log(
|
|
17746
|
+
output.log(chalk62.green(`✅ Workflow validation passed
|
|
17440
17747
|
`));
|
|
17441
17748
|
}
|
|
17442
17749
|
} else if (a.desc) {
|
|
17443
|
-
output.log(
|
|
17750
|
+
output.log(chalk62.blue(`\uD83E\uDD16 Generating workflow from description...
|
|
17444
17751
|
`));
|
|
17445
17752
|
const agentComponent = env.getComponent("agent");
|
|
17446
17753
|
if (!agentComponent) {
|
|
@@ -17448,10 +17755,10 @@ var WorkflowAddCommand = {
|
|
|
17448
17755
|
process.exit(1);
|
|
17449
17756
|
}
|
|
17450
17757
|
if (!agentComponent.getAgent("workflow-extractor")) {
|
|
17451
|
-
output.log(
|
|
17758
|
+
output.log(chalk62.gray("Auto-registering workflow-extractor agent..."));
|
|
17452
17759
|
const extractorConfig = createWorkflowExtractorAgent();
|
|
17453
17760
|
agentComponent.registerAgent(extractorConfig.name, extractorConfig);
|
|
17454
|
-
output.log(
|
|
17761
|
+
output.log(chalk62.green(`✅ workflow-extractor agent registered
|
|
17455
17762
|
`));
|
|
17456
17763
|
}
|
|
17457
17764
|
const prompt = `## 任务
|
|
@@ -17465,20 +17772,20 @@ ${a.desc}
|
|
|
17465
17772
|
1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
|
|
17466
17773
|
2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
|
|
17467
17774
|
3. 验证通过后才输出最终 YAML`;
|
|
17468
|
-
output.log(
|
|
17775
|
+
output.log(chalk62.gray("Running workflow-extractor agent..."));
|
|
17469
17776
|
const result = await agentComponent.run("workflow-extractor", prompt);
|
|
17470
17777
|
const agentOutput = result.finalText || "";
|
|
17471
17778
|
definition = parseYamlFromAgentOutput(agentOutput);
|
|
17472
17779
|
if (definition === null) {
|
|
17473
17780
|
output.error("Failed to parse workflow from agent output");
|
|
17474
|
-
output.log(
|
|
17781
|
+
output.log(chalk62.gray(`
|
|
17475
17782
|
Agent output:
|
|
17476
17783
|
` + agentOutput.slice(0, 500)));
|
|
17477
17784
|
process.exit(1);
|
|
17478
17785
|
}
|
|
17479
17786
|
workflowName = a.name || definition.name;
|
|
17480
17787
|
if (a.validate) {
|
|
17481
|
-
output.log(
|
|
17788
|
+
output.log(chalk62.blue(`
|
|
17482
17789
|
\uD83D\uDD0D Validating generated workflow...`));
|
|
17483
17790
|
const validator = new WorkflowValidator;
|
|
17484
17791
|
const result2 = validator.validate(definition);
|
|
@@ -17492,16 +17799,16 @@ Agent output:
|
|
|
17492
17799
|
output.error(` Fix: ${error.fix}
|
|
17493
17800
|
`);
|
|
17494
17801
|
});
|
|
17495
|
-
output.log(
|
|
17802
|
+
output.log(chalk62.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
17496
17803
|
process.exit(1);
|
|
17497
17804
|
}
|
|
17498
|
-
output.log(
|
|
17805
|
+
output.log(chalk62.green(`✅ Generated workflow validation passed
|
|
17499
17806
|
`));
|
|
17500
17807
|
}
|
|
17501
17808
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
17502
|
-
output.log(
|
|
17809
|
+
output.log(chalk62.gray("--- Generated YAML ---"));
|
|
17503
17810
|
output.log(yaml.stringify(definition));
|
|
17504
|
-
output.log(
|
|
17811
|
+
output.log(chalk62.gray(`------------------------
|
|
17505
17812
|
`));
|
|
17506
17813
|
} else {
|
|
17507
17814
|
output.error("Please provide --file or --desc option");
|
|
@@ -17515,10 +17822,10 @@ Agent output:
|
|
|
17515
17822
|
force: a.force
|
|
17516
17823
|
});
|
|
17517
17824
|
output.log(renderWorkflowAdded(workflow));
|
|
17518
|
-
output.log(
|
|
17825
|
+
output.log(chalk62.bold(`
|
|
17519
17826
|
\uD83D\uDCCA Nodes Summary:`));
|
|
17520
17827
|
output.log(renderNodesList(definition.nodes));
|
|
17521
|
-
output.log(
|
|
17828
|
+
output.log(chalk62.green(`
|
|
17522
17829
|
✅ Workflow '${workflowName}' added successfully`));
|
|
17523
17830
|
} catch (error) {
|
|
17524
17831
|
if (error.message?.includes("already exists") && !a.force) {
|
|
@@ -17535,7 +17842,7 @@ Agent output:
|
|
|
17535
17842
|
};
|
|
17536
17843
|
|
|
17537
17844
|
// src/commands/workflow/commands/get.ts
|
|
17538
|
-
import
|
|
17845
|
+
import chalk63 from "chalk";
|
|
17539
17846
|
var WorkflowGetCommand = {
|
|
17540
17847
|
command: "get <identifier>",
|
|
17541
17848
|
describe: "获取 Workflow 或 Run 详情",
|
|
@@ -17659,7 +17966,7 @@ var WorkflowGetCommand = {
|
|
|
17659
17966
|
} else {
|
|
17660
17967
|
output.log(renderWorkflowDetail(workflow, { includeRuns: runs }));
|
|
17661
17968
|
if (args.includeNodes) {
|
|
17662
|
-
output.log(
|
|
17969
|
+
output.log(chalk63.bold(`
|
|
17663
17970
|
\uD83D\uDCCB All Nodes:`));
|
|
17664
17971
|
output.log(renderNodesList(workflow.definition.nodes));
|
|
17665
17972
|
}
|
|
@@ -17675,7 +17982,7 @@ var WorkflowGetCommand = {
|
|
|
17675
17982
|
};
|
|
17676
17983
|
|
|
17677
17984
|
// src/commands/workflow/commands/update.ts
|
|
17678
|
-
import
|
|
17985
|
+
import chalk64 from "chalk";
|
|
17679
17986
|
import fs4 from "fs";
|
|
17680
17987
|
import path7 from "path";
|
|
17681
17988
|
import { parseWorkflowFile } from "@ai-setting/roy-agent-core/env/workflow/types";
|
|
@@ -17748,7 +18055,7 @@ var WorkflowUpdateCommand = {
|
|
|
17748
18055
|
const tags = a.tags ? a.tags.split(",").map((t) => t.trim()) : undefined;
|
|
17749
18056
|
const workflow = await service.updateWorkflow(a.name, updates, { tags });
|
|
17750
18057
|
output.log(renderWorkflowUpdated(workflow));
|
|
17751
|
-
output.log(
|
|
18058
|
+
output.log(chalk64.green(`
|
|
17752
18059
|
✅ Workflow '${a.name}' updated successfully`));
|
|
17753
18060
|
} catch (error) {
|
|
17754
18061
|
output.error(`Failed to update workflow: ${error}`);
|
|
@@ -17760,7 +18067,7 @@ var WorkflowUpdateCommand = {
|
|
|
17760
18067
|
};
|
|
17761
18068
|
|
|
17762
18069
|
// src/commands/workflow/commands/remove.ts
|
|
17763
|
-
import
|
|
18070
|
+
import chalk65 from "chalk";
|
|
17764
18071
|
var WorkflowRemoveCommand = {
|
|
17765
18072
|
command: "remove <name>",
|
|
17766
18073
|
describe: "删除 Workflow",
|
|
@@ -17799,8 +18106,8 @@ var WorkflowRemoveCommand = {
|
|
|
17799
18106
|
process.exit(1);
|
|
17800
18107
|
}
|
|
17801
18108
|
if (!args.force) {
|
|
17802
|
-
output.log(
|
|
17803
|
-
output.log(
|
|
18109
|
+
output.log(chalk65.yellow(`Are you sure you want to delete workflow '${args.name}'?`));
|
|
18110
|
+
output.log(chalk65.gray("Use --force to skip confirmation"));
|
|
17804
18111
|
process.exit(1);
|
|
17805
18112
|
}
|
|
17806
18113
|
const deleted = await service.deleteWorkflow(args.name);
|
|
@@ -17820,7 +18127,7 @@ var WorkflowRemoveCommand = {
|
|
|
17820
18127
|
|
|
17821
18128
|
// src/commands/workflow/commands/run.ts
|
|
17822
18129
|
var import_yaml = __toESM(require_dist(), 1);
|
|
17823
|
-
import
|
|
18130
|
+
import chalk66 from "chalk";
|
|
17824
18131
|
import fs5 from "fs";
|
|
17825
18132
|
import path8 from "path";
|
|
17826
18133
|
import { getTracerProvider as getTracerProvider4, propagation, wrapFunction } from "@ai-setting/roy-agent-core";
|
|
@@ -17893,7 +18200,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
17893
18200
|
};
|
|
17894
18201
|
if (args.sessionId) {
|
|
17895
18202
|
const sessionId = args.sessionId.startsWith("workflow_") ? args.sessionId : `workflow_${args.sessionId}`;
|
|
17896
|
-
output.log(
|
|
18203
|
+
output.log(chalk66.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
17897
18204
|
const sessionComponent = workflowComponent.sessionComponent;
|
|
17898
18205
|
if (!sessionComponent) {
|
|
17899
18206
|
output.error("SessionComponent not available");
|
|
@@ -17955,17 +18262,17 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
17955
18262
|
definition = { ...definition, name: args.name };
|
|
17956
18263
|
}
|
|
17957
18264
|
const workflow = await service.createWorkflow(definition, { force: true });
|
|
17958
|
-
output.log(
|
|
17959
|
-
output.log(
|
|
18265
|
+
output.log(chalk66.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
|
|
18266
|
+
output.log(chalk66.green(`✅ Workflow registered: ${workflow.name} (${workflow.id})`));
|
|
17960
18267
|
if (args.registerOnly) {
|
|
17961
|
-
output.log(
|
|
18268
|
+
output.log(chalk66.gray("ℹ️ Use --register-only, skipping execution"));
|
|
17962
18269
|
if (workflowSpan) {
|
|
17963
18270
|
workflowSpan.end();
|
|
17964
18271
|
}
|
|
17965
18272
|
await envService.dispose();
|
|
17966
18273
|
process.exit(0);
|
|
17967
18274
|
}
|
|
17968
|
-
output.log(
|
|
18275
|
+
output.log(chalk66.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
|
|
17969
18276
|
const result = await service.runWorkflow(definition, input, runOptions);
|
|
17970
18277
|
output.log(renderRunResult({
|
|
17971
18278
|
runId: result.runId,
|
|
@@ -17975,11 +18282,11 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
17975
18282
|
durationMs: result.durationMs
|
|
17976
18283
|
}));
|
|
17977
18284
|
if (result.status === "paused") {
|
|
17978
|
-
output.log(
|
|
18285
|
+
output.log(chalk66.gray(`
|
|
17979
18286
|
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session-id ${result.runId} --input '<response>'" to resume`));
|
|
17980
18287
|
}
|
|
17981
18288
|
} else {
|
|
17982
|
-
output.log(
|
|
18289
|
+
output.log(chalk66.blue(`\uD83D\uDE80 Running workflow: ${args.identifier}`));
|
|
17983
18290
|
const result = await service.runWorkflow(args.identifier, input, runOptions);
|
|
17984
18291
|
output.log(renderRunResult({
|
|
17985
18292
|
runId: result.runId,
|
|
@@ -17989,7 +18296,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
17989
18296
|
durationMs: result.durationMs
|
|
17990
18297
|
}));
|
|
17991
18298
|
if (result.status === "paused") {
|
|
17992
|
-
output.log(
|
|
18299
|
+
output.log(chalk66.gray(`
|
|
17993
18300
|
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session-id ${result.runId} --input '<response>'" to resume`));
|
|
17994
18301
|
}
|
|
17995
18302
|
}
|
|
@@ -18061,7 +18368,7 @@ var WorkflowRunCommand = {
|
|
|
18061
18368
|
};
|
|
18062
18369
|
|
|
18063
18370
|
// src/commands/workflow/commands/stop.ts
|
|
18064
|
-
import
|
|
18371
|
+
import chalk67 from "chalk";
|
|
18065
18372
|
import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
|
|
18066
18373
|
var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
18067
18374
|
const output = new OutputService;
|
|
@@ -18090,7 +18397,7 @@ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
|
18090
18397
|
process.exit(1);
|
|
18091
18398
|
}
|
|
18092
18399
|
await service.stopRun(args.runId);
|
|
18093
|
-
output.log(
|
|
18400
|
+
output.log(chalk67.red(`
|
|
18094
18401
|
⏹️ Workflow stopped: ${args.runId}`));
|
|
18095
18402
|
} catch (error) {
|
|
18096
18403
|
output.error(`Failed to stop workflow: ${error}`);
|
|
@@ -18114,7 +18421,7 @@ var WorkflowStopCommand = {
|
|
|
18114
18421
|
};
|
|
18115
18422
|
|
|
18116
18423
|
// src/commands/workflow/commands/status.ts
|
|
18117
|
-
import
|
|
18424
|
+
import chalk68 from "chalk";
|
|
18118
18425
|
var WorkflowStatusCommand = {
|
|
18119
18426
|
command: "status <runId>",
|
|
18120
18427
|
describe: "查看 Workflow 运行状态",
|
|
@@ -18205,7 +18512,7 @@ var WorkflowStatusCommand = {
|
|
|
18205
18512
|
stopped: "⏹️"
|
|
18206
18513
|
};
|
|
18207
18514
|
const emoji = statusEmoji[status] || "❓";
|
|
18208
|
-
output.log(
|
|
18515
|
+
output.log(chalk68.bold(`
|
|
18209
18516
|
${emoji} Status: ${status.toUpperCase()}`));
|
|
18210
18517
|
}
|
|
18211
18518
|
} catch (error) {
|
|
@@ -18218,7 +18525,7 @@ ${emoji} Status: ${status.toUpperCase()}`));
|
|
|
18218
18525
|
};
|
|
18219
18526
|
|
|
18220
18527
|
// src/commands/workflow/commands/nodes.ts
|
|
18221
|
-
import
|
|
18528
|
+
import chalk69 from "chalk";
|
|
18222
18529
|
var BUILT_IN_NODES = [
|
|
18223
18530
|
{
|
|
18224
18531
|
name: "ToolNode",
|
|
@@ -18555,7 +18862,7 @@ nodes:
|
|
|
18555
18862
|
];
|
|
18556
18863
|
function renderNodeTypesTable(nodes) {
|
|
18557
18864
|
const lines = [];
|
|
18558
|
-
lines.push(
|
|
18865
|
+
lines.push(chalk69.bold(`
|
|
18559
18866
|
\uD83D\uDCE6 Built-in Node Types
|
|
18560
18867
|
`));
|
|
18561
18868
|
lines.push("┌────────────┬────────────────────┬─────────────────────────────────────────────────────────────┐");
|
|
@@ -18573,29 +18880,29 @@ function renderNodeTypesTable(nodes) {
|
|
|
18573
18880
|
}
|
|
18574
18881
|
function renderNodeDetail(node) {
|
|
18575
18882
|
const lines = [];
|
|
18576
|
-
lines.push(
|
|
18883
|
+
lines.push(chalk69.bold(`
|
|
18577
18884
|
[${node.type}] ${node.name}`));
|
|
18578
|
-
lines.push(
|
|
18885
|
+
lines.push(chalk69.dim("─".repeat(60)) + `
|
|
18579
18886
|
`);
|
|
18580
|
-
lines.push(
|
|
18887
|
+
lines.push(chalk69.bold("Description:"));
|
|
18581
18888
|
lines.push(` ${node.description}
|
|
18582
18889
|
`);
|
|
18583
|
-
lines.push(
|
|
18890
|
+
lines.push(chalk69.bold("Configuration:"));
|
|
18584
18891
|
lines.push(' type: "' + node.type + '"');
|
|
18585
18892
|
lines.push(" config:");
|
|
18586
18893
|
for (const input of node.inputs) {
|
|
18587
|
-
const required = input.required ?
|
|
18894
|
+
const required = input.required ? chalk69.red("*") : " ";
|
|
18588
18895
|
lines.push(` ${input.name} (${input.type})${required}`);
|
|
18589
18896
|
lines.push(` ${input.description}`);
|
|
18590
18897
|
}
|
|
18591
18898
|
lines.push(`
|
|
18592
|
-
${
|
|
18899
|
+
${chalk69.bold("Output:")} ${node.output}`);
|
|
18593
18900
|
if (node.example) {
|
|
18594
|
-
lines.push(
|
|
18901
|
+
lines.push(chalk69.bold(`
|
|
18595
18902
|
Example:`));
|
|
18596
|
-
lines.push(
|
|
18903
|
+
lines.push(chalk69.gray("```yaml"));
|
|
18597
18904
|
lines.push(node.example);
|
|
18598
|
-
lines.push(
|
|
18905
|
+
lines.push(chalk69.gray("```"));
|
|
18599
18906
|
}
|
|
18600
18907
|
return lines.join(`
|
|
18601
18908
|
`);
|
|
@@ -18611,16 +18918,16 @@ var WorkflowNodesCommand = {
|
|
|
18611
18918
|
const nodeType = args.type?.toLowerCase();
|
|
18612
18919
|
if (!nodeType) {
|
|
18613
18920
|
console.log(renderNodeTypesTable(BUILT_IN_NODES));
|
|
18614
|
-
console.log(
|
|
18615
|
-
Use `) +
|
|
18616
|
-
console.log(
|
|
18921
|
+
console.log(chalk69.gray(`
|
|
18922
|
+
Use `) + chalk69.cyan("roy-agent workflow nodes <type>") + chalk69.gray(" for detailed information"));
|
|
18923
|
+
console.log(chalk69.gray("Available types: ") + chalk69.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
18617
18924
|
return;
|
|
18618
18925
|
}
|
|
18619
18926
|
const node = BUILT_IN_NODES.find((n) => n.type === nodeType);
|
|
18620
18927
|
if (!node) {
|
|
18621
|
-
console.log(
|
|
18928
|
+
console.log(chalk69.red(`
|
|
18622
18929
|
❌ Unknown node type: ${nodeType}`));
|
|
18623
|
-
console.log(
|
|
18930
|
+
console.log(chalk69.gray("Available types: ") + chalk69.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
18624
18931
|
process.exit(1);
|
|
18625
18932
|
}
|
|
18626
18933
|
console.log(renderNodeDetail(node));
|
|
@@ -18628,7 +18935,7 @@ Use `) + chalk67.cyan("roy-agent workflow nodes <type>") + chalk67.gray(" for de
|
|
|
18628
18935
|
};
|
|
18629
18936
|
|
|
18630
18937
|
// src/commands/workflow/commands/validate.ts
|
|
18631
|
-
import
|
|
18938
|
+
import chalk70 from "chalk";
|
|
18632
18939
|
import { readFileSync } from "fs";
|
|
18633
18940
|
async function parseWorkflowInput(input, yamlStr) {
|
|
18634
18941
|
const parseYaml = async (content) => {
|
|
@@ -18661,25 +18968,25 @@ function renderResult(result, options) {
|
|
|
18661
18968
|
return;
|
|
18662
18969
|
}
|
|
18663
18970
|
if (result.valid) {
|
|
18664
|
-
console.log(
|
|
18971
|
+
console.log(chalk70.green(`
|
|
18665
18972
|
✅ Workflow validation PASSED
|
|
18666
18973
|
`));
|
|
18667
|
-
console.log(
|
|
18974
|
+
console.log(chalk70.bold(`Workflow: ${result.workflowName}`));
|
|
18668
18975
|
console.log(`Nodes: ${result.nodeCount}`);
|
|
18669
18976
|
console.log(`
|
|
18670
18977
|
Valid nodes:`);
|
|
18671
|
-
console.log(
|
|
18978
|
+
console.log(chalk70.green(" ✓ All nodes passed validation"));
|
|
18672
18979
|
} else {
|
|
18673
|
-
console.log(
|
|
18980
|
+
console.log(chalk70.red(`
|
|
18674
18981
|
❌ Workflow validation FAILED (${result.errors.length} errors found)
|
|
18675
18982
|
`));
|
|
18676
18983
|
result.errors.forEach((error, index) => {
|
|
18677
|
-
console.log(
|
|
18678
|
-
console.log(` ${
|
|
18679
|
-
console.log(` ${
|
|
18680
|
-
console.log(` ${
|
|
18681
|
-
console.log(` ${
|
|
18682
|
-
console.log(` ${
|
|
18984
|
+
console.log(chalk70.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
|
|
18985
|
+
console.log(` ${chalk70.bold("Type:")} ${error.type}`);
|
|
18986
|
+
console.log(` ${chalk70.bold("Description:")} ${error.description}`);
|
|
18987
|
+
console.log(` ${chalk70.bold("Expected:")} ${error.expected}`);
|
|
18988
|
+
console.log(` ${chalk70.bold("Actual:")} ${error.actual}`);
|
|
18989
|
+
console.log(` ${chalk70.green("Fix:")} ${error.fix}`);
|
|
18683
18990
|
console.log();
|
|
18684
18991
|
});
|
|
18685
18992
|
}
|
|
@@ -18704,7 +19011,7 @@ var WorkflowValidateCommand = {
|
|
|
18704
19011
|
try {
|
|
18705
19012
|
const workflow = await parseWorkflowInput(options.input, options.yaml);
|
|
18706
19013
|
if (!workflow) {
|
|
18707
|
-
console.error(
|
|
19014
|
+
console.error(chalk70.red("Failed to parse workflow input"));
|
|
18708
19015
|
process.exit(1);
|
|
18709
19016
|
}
|
|
18710
19017
|
const validator = new WorkflowValidator;
|
|
@@ -18712,7 +19019,7 @@ var WorkflowValidateCommand = {
|
|
|
18712
19019
|
renderResult(result, options);
|
|
18713
19020
|
process.exit(result.valid ? 0 : 1);
|
|
18714
19021
|
} catch (error) {
|
|
18715
|
-
console.error(
|
|
19022
|
+
console.error(chalk70.red(`
|
|
18716
19023
|
Error: ${error.message}`));
|
|
18717
19024
|
process.exit(1);
|
|
18718
19025
|
}
|