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