@ai-setting/roy-agent-cli 1.5.114 → 1.5.116
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 +1011 -758
- package/dist/index.js +1011 -758
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +1 -1
package/dist/bin/roy-agent.js
CHANGED
|
@@ -7427,7 +7427,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7427
7427
|
var require_package = __commonJS((exports, module) => {
|
|
7428
7428
|
module.exports = {
|
|
7429
7429
|
name: "@ai-setting/roy-agent-cli",
|
|
7430
|
-
version: "1.5.
|
|
7430
|
+
version: "1.5.116",
|
|
7431
7431
|
type: "module",
|
|
7432
7432
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7433
7433
|
main: "./dist/index.js",
|
|
@@ -10851,8 +10851,56 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10851
10851
|
}
|
|
10852
10852
|
var InteractiveCommand = createInteractiveCommand();
|
|
10853
10853
|
|
|
10854
|
-
// src/commands/
|
|
10854
|
+
// src/commands/shared/list-output.ts
|
|
10855
10855
|
import chalk6 from "chalk";
|
|
10856
|
+
var PAGINATION_OPTIONS = {
|
|
10857
|
+
limit: {
|
|
10858
|
+
alias: "n",
|
|
10859
|
+
type: "number",
|
|
10860
|
+
default: 20,
|
|
10861
|
+
description: "每页数量(-n alias)"
|
|
10862
|
+
},
|
|
10863
|
+
offset: {
|
|
10864
|
+
alias: "o",
|
|
10865
|
+
type: "number",
|
|
10866
|
+
default: 0,
|
|
10867
|
+
description: "分页偏移(-o alias)"
|
|
10868
|
+
}
|
|
10869
|
+
};
|
|
10870
|
+
function applyPagination(items, args) {
|
|
10871
|
+
const offset = Math.max(0, args.offset);
|
|
10872
|
+
const limit = Math.max(1, args.limit);
|
|
10873
|
+
return items.slice(offset, offset + limit);
|
|
10874
|
+
}
|
|
10875
|
+
function renderPaginationFooter(opts) {
|
|
10876
|
+
const { total, count, offset, limit, itemName, extras = [] } = opts;
|
|
10877
|
+
const start = total === 0 ? 0 : offset + 1;
|
|
10878
|
+
const end = offset + count;
|
|
10879
|
+
const items = `${itemName}${count === 1 ? "" : "s"}`;
|
|
10880
|
+
const base = `Showing ${start}-${end} of ${total} ${items}`;
|
|
10881
|
+
const suffix = extras.length > 0 ? ` (${extras.join(", ")})` : "";
|
|
10882
|
+
const truncatedHint = total > count && offset + count < total ? chalk6.cyan(` — use -o ${offset + limit} for next page`) : "";
|
|
10883
|
+
return chalk6.gray(base + suffix + truncatedHint);
|
|
10884
|
+
}
|
|
10885
|
+
function renderQuietHeader(total, itemName) {
|
|
10886
|
+
const items = `${itemName}${total === 1 ? "" : "s"}`;
|
|
10887
|
+
return `# Total: ${total} ${items}`;
|
|
10888
|
+
}
|
|
10889
|
+
function renderQuietLine(id, name) {
|
|
10890
|
+
return `${id} ${name}`;
|
|
10891
|
+
}
|
|
10892
|
+
function renderQuietPaginationHint(opts) {
|
|
10893
|
+
const { count, total, offset, limit } = opts;
|
|
10894
|
+
if (total <= count) {
|
|
10895
|
+
return "";
|
|
10896
|
+
}
|
|
10897
|
+
const start = offset + 1;
|
|
10898
|
+
const end = offset + count;
|
|
10899
|
+
return `# (showing ${start}-${end} of ${total}, use -o ${offset + limit} for next page)`;
|
|
10900
|
+
}
|
|
10901
|
+
|
|
10902
|
+
// src/commands/sessions/list.ts
|
|
10903
|
+
import chalk7 from "chalk";
|
|
10856
10904
|
|
|
10857
10905
|
// src/commands/sessions/session-graph.ts
|
|
10858
10906
|
function buildSessionTree(sessions) {
|
|
@@ -11015,14 +11063,9 @@ var ListCommand = {
|
|
|
11015
11063
|
command: "list [options]",
|
|
11016
11064
|
aliases: ["ls"],
|
|
11017
11065
|
describe: "列出所有会话",
|
|
11018
|
-
builder: (yargs) => yargs.option("limit", { alias: "n", type: "number", default: 20 }).option("offset", { type: "number", default: 0 }).option("sort", { type: "string", default: "updatedAt" }).option("order", { type: "string", default: "desc" }).option("json", { alias: "j", type: "boolean", default: false }).option("quiet", { alias: "q", type: "boolean", hidden: true }).option("id", { alias: "i", type: "boolean", default: false, description: "显示 Session ID" }).option("type", { alias: "t", type: "string", description: "按 session 类型过滤 (如 workflow)" }).option("status", { alias: "s", type: "string", description: "按状态过滤 (如 running, paused)" }).option("graph", { alias: "g", type: "boolean", default: false, description: "以层次化树形结构展示 session 父子关系" }).option("short-id", { type: "boolean", default: false, description: "[graph] 用 8 字符截断 id 显示(默认显示完整 sessionId)" }),
|
|
11066
|
+
builder: (yargs) => yargs.option("limit", { alias: "n", type: "number", default: 20 }).option("offset", { alias: "o", type: "number", default: 0, description: "分页偏移(-o alias)" }).option("sort", { type: "string", default: "updatedAt" }).option("order", { type: "string", default: "desc" }).option("json", { alias: "j", type: "boolean", default: false }).option("quiet", { alias: "q", type: "boolean", hidden: true }).option("id", { alias: "i", type: "boolean", default: false, description: "显示 Session ID" }).option("type", { alias: "t", type: "string", description: "按 session 类型过滤 (如 workflow)" }).option("status", { alias: "s", type: "string", description: "按状态过滤 (如 running, paused)" }).option("graph", { alias: "g", type: "boolean", default: false, description: "以层次化树形结构展示 session 父子关系" }).option("short-id", { type: "boolean", default: false, description: "[graph] 用 8 字符截断 id 显示(默认显示完整 sessionId)" }),
|
|
11019
11067
|
async handler(args) {
|
|
11020
|
-
const isQuiet = args.quiet === true;
|
|
11021
|
-
if (isQuiet) {
|
|
11022
|
-
CliQuietModeService.getInstance().setQuiet(true);
|
|
11023
|
-
}
|
|
11024
11068
|
const output = new OutputService2;
|
|
11025
|
-
output.configure({ quiet: isQuiet });
|
|
11026
11069
|
const envService = new EnvironmentService(output);
|
|
11027
11070
|
try {
|
|
11028
11071
|
await envService.create({ configPath: args.config });
|
|
@@ -11063,8 +11106,11 @@ var ListCommand = {
|
|
|
11063
11106
|
}
|
|
11064
11107
|
if (args.json) {
|
|
11065
11108
|
output.json({
|
|
11066
|
-
total:
|
|
11067
|
-
|
|
11109
|
+
total: totalCount,
|
|
11110
|
+
count: sessions.length,
|
|
11111
|
+
truncated: totalCount > sessions.length,
|
|
11112
|
+
limit: args.limit,
|
|
11113
|
+
offset: args.offset,
|
|
11068
11114
|
sessions: sessions.map((s) => {
|
|
11069
11115
|
const workflowMeta = s.metadata?.type === "workflow" ? s.metadata : null;
|
|
11070
11116
|
return {
|
|
@@ -11085,48 +11131,58 @@ var ListCommand = {
|
|
|
11085
11131
|
};
|
|
11086
11132
|
})
|
|
11087
11133
|
});
|
|
11088
|
-
} else if (args.
|
|
11134
|
+
} else if (args.id) {
|
|
11089
11135
|
sessions.forEach((s) => output.log(s.id));
|
|
11136
|
+
} else if (args.quiet) {
|
|
11137
|
+
output.log(renderQuietHeader(totalCount, "session"));
|
|
11138
|
+
sessions.forEach((s) => output.log(renderQuietLine(s.id, s.title)));
|
|
11139
|
+
const hint = renderQuietPaginationHint({
|
|
11140
|
+
count: sessions.length,
|
|
11141
|
+
total: totalCount,
|
|
11142
|
+
offset: args.offset ?? 0,
|
|
11143
|
+
limit: args.limit ?? 20
|
|
11144
|
+
});
|
|
11145
|
+
if (hint)
|
|
11146
|
+
output.log(hint);
|
|
11090
11147
|
} else {
|
|
11091
11148
|
const hasTypeFilter = !!args.type;
|
|
11092
11149
|
const hasStatusFilter = !!args.status;
|
|
11093
11150
|
const header = [
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
hasTypeFilter || hasStatusFilter ?
|
|
11099
|
-
|
|
11100
|
-
|
|
11151
|
+
chalk7.bold("#"),
|
|
11152
|
+
chalk7.bold("Title"),
|
|
11153
|
+
chalk7.bold("ID"),
|
|
11154
|
+
chalk7.bold("Parent"),
|
|
11155
|
+
hasTypeFilter || hasStatusFilter ? chalk7.bold("Status") : null,
|
|
11156
|
+
chalk7.bold("Msgs"),
|
|
11157
|
+
chalk7.bold("CP")
|
|
11101
11158
|
].filter(Boolean).join(" │ ");
|
|
11102
11159
|
const rows = sessions.map((s, i) => {
|
|
11103
|
-
const marker = s.id === activeSessionId ?
|
|
11160
|
+
const marker = s.id === activeSessionId ? chalk7.green("▶") : " ";
|
|
11104
11161
|
const hasCp = (s.metadata?.checkpoints?.checkpoints?.length ?? 0) > 0;
|
|
11105
11162
|
const title = s.title.length > 20 ? s.title.slice(0, 17) + "..." : s.title;
|
|
11106
11163
|
const idStr = s.id;
|
|
11107
11164
|
const useShortId = args.shortId === true;
|
|
11108
|
-
const parentStr = s.parentSessionId ?
|
|
11165
|
+
const parentStr = s.parentSessionId ? chalk7.gray(useShortId ? shortSessionId(s.parentSessionId) : s.parentSessionId) : chalk7.gray("-");
|
|
11109
11166
|
const workflowMeta = s.metadata?.type === "workflow" ? s.metadata : null;
|
|
11110
11167
|
const statusStr = workflowMeta?.status || "";
|
|
11111
11168
|
let statusDisplay = "";
|
|
11112
11169
|
if (hasTypeFilter || hasStatusFilter) {
|
|
11113
11170
|
if (workflowMeta) {
|
|
11114
|
-
statusDisplay = workflowMeta.status === "running" ?
|
|
11171
|
+
statusDisplay = workflowMeta.status === "running" ? chalk7.green("running") : workflowMeta.status === "paused" ? chalk7.yellow("paused") : workflowMeta.status === "completed" ? chalk7.gray("completed") : workflowMeta.status === "failed" ? chalk7.red("failed") : statusStr;
|
|
11115
11172
|
}
|
|
11116
11173
|
}
|
|
11117
11174
|
const cells = [
|
|
11118
11175
|
marker + " " + (args.offset + i + 1),
|
|
11119
11176
|
title,
|
|
11120
|
-
|
|
11177
|
+
chalk7.gray(idStr),
|
|
11121
11178
|
parentStr
|
|
11122
11179
|
];
|
|
11123
11180
|
if (hasTypeFilter || hasStatusFilter) {
|
|
11124
|
-
cells.push(statusDisplay ||
|
|
11181
|
+
cells.push(statusDisplay || chalk7.gray("-"));
|
|
11125
11182
|
}
|
|
11126
|
-
cells.push(s.messageCount.toString(), hasCp ?
|
|
11183
|
+
cells.push(s.messageCount.toString(), hasCp ? chalk7.green("✓") : chalk7.gray("-"));
|
|
11127
11184
|
return cells.join(" │ ");
|
|
11128
11185
|
});
|
|
11129
|
-
const showingInfo = totalCount > sessions.length ? `Showing ${sessions.length} of ${totalCount} sessions` : `${totalCount} sessions`;
|
|
11130
11186
|
output.log([
|
|
11131
11187
|
`┌─ Sessions ${"─".repeat(50)}┐`,
|
|
11132
11188
|
`│${header}│`,
|
|
@@ -11134,7 +11190,17 @@ var ListCommand = {
|
|
|
11134
11190
|
...rows.map((r) => `│${r}│`),
|
|
11135
11191
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
11136
11192
|
"",
|
|
11137
|
-
|
|
11193
|
+
renderPaginationFooter({
|
|
11194
|
+
total: totalCount,
|
|
11195
|
+
count: sessions.length,
|
|
11196
|
+
offset: args.offset ?? 0,
|
|
11197
|
+
limit: args.limit ?? 20,
|
|
11198
|
+
itemName: "session",
|
|
11199
|
+
extras: [
|
|
11200
|
+
...args.type ? [`type=${args.type}`] : [],
|
|
11201
|
+
...args.status ? [`status=${args.status}`] : []
|
|
11202
|
+
]
|
|
11203
|
+
})
|
|
11138
11204
|
].join(`
|
|
11139
11205
|
`));
|
|
11140
11206
|
}
|
|
@@ -11148,7 +11214,7 @@ var ListCommand = {
|
|
|
11148
11214
|
};
|
|
11149
11215
|
|
|
11150
11216
|
// src/commands/sessions/get.ts
|
|
11151
|
-
import
|
|
11217
|
+
import chalk8 from "chalk";
|
|
11152
11218
|
var GetCommand = {
|
|
11153
11219
|
command: "get <session-id>",
|
|
11154
11220
|
aliases: ["show"],
|
|
@@ -11204,29 +11270,29 @@ var GetCommand = {
|
|
|
11204
11270
|
});
|
|
11205
11271
|
} else {
|
|
11206
11272
|
const lines = [
|
|
11207
|
-
|
|
11273
|
+
chalk8.bold("┌─ Session Details ─────────────────────────────────┐"),
|
|
11208
11274
|
`│ ID: ${session.id}`,
|
|
11209
11275
|
`│ Title: ${session.title}`,
|
|
11210
11276
|
`│ Directory: ${session.directory}`,
|
|
11211
11277
|
`│ Messages: ${session.messageCount}`,
|
|
11212
|
-
`│ Active: ${session.id === activeSessionId ?
|
|
11278
|
+
`│ Active: ${session.id === activeSessionId ? chalk8.green("✓") : chalk8.gray("-")}`,
|
|
11213
11279
|
`│ Created: ${new Date(session.createdAt).toLocaleString("zh-CN")}`,
|
|
11214
11280
|
`│ Updated: ${new Date(session.updatedAt).toLocaleString("zh-CN")}`
|
|
11215
11281
|
];
|
|
11216
11282
|
const workflowMeta = session.metadata?.type === "workflow" ? session.metadata : null;
|
|
11217
11283
|
if (workflowMeta) {
|
|
11218
11284
|
lines.push("├─ Workflow Info ─────────────────────────────────────┤");
|
|
11219
|
-
lines.push(`│ Type: ${
|
|
11285
|
+
lines.push(`│ Type: ${chalk8.cyan("workflow")}`);
|
|
11220
11286
|
lines.push(`│ Workflow: ${workflowMeta.workflowName}`);
|
|
11221
11287
|
if (workflowMeta.workflowId) {
|
|
11222
11288
|
lines.push(`│ Workflow ID: ${workflowMeta.workflowId}`);
|
|
11223
11289
|
}
|
|
11224
|
-
const statusColor = workflowMeta.status === "running" ?
|
|
11290
|
+
const statusColor = workflowMeta.status === "running" ? chalk8.green : workflowMeta.status === "paused" ? chalk8.yellow : workflowMeta.status === "completed" ? chalk8.gray : chalk8.red;
|
|
11225
11291
|
lines.push(`│ Status: ${statusColor(workflowMeta.status)}`);
|
|
11226
11292
|
if (workflowMeta.agentSessions && workflowMeta.agentSessions.length > 0) {
|
|
11227
11293
|
lines.push("├─ Agent Sub-sessions ─────────────────────────────────┤");
|
|
11228
11294
|
workflowMeta.agentSessions.forEach((agent) => {
|
|
11229
|
-
const agentStatusColor = agent.status === "active" ?
|
|
11295
|
+
const agentStatusColor = agent.status === "active" ? chalk8.green : agent.status === "paused" ? chalk8.yellow : chalk8.gray;
|
|
11230
11296
|
lines.push(`│ ${agent.nodeId}: ${agent.sessionId} (${agentStatusColor(agent.status)})`);
|
|
11231
11297
|
});
|
|
11232
11298
|
}
|
|
@@ -11253,7 +11319,7 @@ var GetCommand = {
|
|
|
11253
11319
|
};
|
|
11254
11320
|
|
|
11255
11321
|
// src/commands/sessions/new.ts
|
|
11256
|
-
import
|
|
11322
|
+
import chalk9 from "chalk";
|
|
11257
11323
|
var NewCommand = {
|
|
11258
11324
|
command: "new [options]",
|
|
11259
11325
|
aliases: ["create"],
|
|
@@ -11292,7 +11358,7 @@ var NewCommand = {
|
|
|
11292
11358
|
}
|
|
11293
11359
|
});
|
|
11294
11360
|
} else {
|
|
11295
|
-
output.success(
|
|
11361
|
+
output.success(chalk9.green("✓") + " Session created: " + session.id);
|
|
11296
11362
|
output.info("Title: " + session.title);
|
|
11297
11363
|
output.info("Directory: " + session.directory);
|
|
11298
11364
|
}
|
|
@@ -11306,7 +11372,7 @@ var NewCommand = {
|
|
|
11306
11372
|
};
|
|
11307
11373
|
|
|
11308
11374
|
// src/commands/sessions/rename.ts
|
|
11309
|
-
import
|
|
11375
|
+
import chalk10 from "chalk";
|
|
11310
11376
|
var RenameCommand = {
|
|
11311
11377
|
command: "rename <session-id> <title>",
|
|
11312
11378
|
aliases: ["mv"],
|
|
@@ -11361,7 +11427,7 @@ var RenameCommand = {
|
|
|
11361
11427
|
}
|
|
11362
11428
|
});
|
|
11363
11429
|
} else {
|
|
11364
|
-
output.success(`Session renamed: ${
|
|
11430
|
+
output.success(`Session renamed: ${chalk10.green(a.title)}`);
|
|
11365
11431
|
output.info(`ID: ${a.sessionId}`);
|
|
11366
11432
|
}
|
|
11367
11433
|
} catch (error) {
|
|
@@ -11374,7 +11440,7 @@ var RenameCommand = {
|
|
|
11374
11440
|
};
|
|
11375
11441
|
|
|
11376
11442
|
// src/commands/sessions/delete.ts
|
|
11377
|
-
import
|
|
11443
|
+
import chalk11 from "chalk";
|
|
11378
11444
|
var DeleteCommand = {
|
|
11379
11445
|
command: "delete [session-ids...]",
|
|
11380
11446
|
aliases: ["rm"],
|
|
@@ -11453,7 +11519,7 @@ var DeleteCommand = {
|
|
|
11453
11519
|
return true;
|
|
11454
11520
|
});
|
|
11455
11521
|
if (a.keepActive && sessionsToDelete.length > 0) {
|
|
11456
|
-
output.log(
|
|
11522
|
+
output.log(chalk11.yellow(`Keeping active session: ${activeSessionId}`));
|
|
11457
11523
|
}
|
|
11458
11524
|
} else if (a.olderThan !== undefined) {
|
|
11459
11525
|
const cutoffDate = new Date;
|
|
@@ -11470,7 +11536,7 @@ var DeleteCommand = {
|
|
|
11470
11536
|
}
|
|
11471
11537
|
return false;
|
|
11472
11538
|
});
|
|
11473
|
-
output.log(
|
|
11539
|
+
output.log(chalk11.gray(`Deleting sessions not updated since ${cutoffDate.toISOString().split("T")[0]} (${a.olderThan} days ago)`));
|
|
11474
11540
|
} else {
|
|
11475
11541
|
output.log("No sessions to delete");
|
|
11476
11542
|
return;
|
|
@@ -11480,10 +11546,10 @@ var DeleteCommand = {
|
|
|
11480
11546
|
return;
|
|
11481
11547
|
}
|
|
11482
11548
|
if (a.dryRun) {
|
|
11483
|
-
output.log(
|
|
11549
|
+
output.log(chalk11.yellow(`[DRY RUN] Would delete ${sessionsToDelete.length} session(s):
|
|
11484
11550
|
`));
|
|
11485
11551
|
sessionsToDelete.forEach((s, i) => {
|
|
11486
|
-
const marker = s.id === activeSessionId ?
|
|
11552
|
+
const marker = s.id === activeSessionId ? chalk11.green("▶") : " ";
|
|
11487
11553
|
output.log(` ${marker} ${s.id}`);
|
|
11488
11554
|
output.log(` Title: ${s.title}`);
|
|
11489
11555
|
output.log(` Updated: ${new Date(s.updatedAt).toLocaleString()}`);
|
|
@@ -11493,11 +11559,11 @@ var DeleteCommand = {
|
|
|
11493
11559
|
return;
|
|
11494
11560
|
}
|
|
11495
11561
|
if (!a.force) {
|
|
11496
|
-
output.log(
|
|
11562
|
+
output.log(chalk11.red(`
|
|
11497
11563
|
⚠️ About to delete ${sessionsToDelete.length} session(s):
|
|
11498
11564
|
`));
|
|
11499
11565
|
sessionsToDelete.forEach((s, i) => {
|
|
11500
|
-
const marker = s.id === activeSessionId ?
|
|
11566
|
+
const marker = s.id === activeSessionId ? chalk11.green("▶") : " ";
|
|
11501
11567
|
output.log(` ${marker} ${s.id} - ${s.title}`);
|
|
11502
11568
|
});
|
|
11503
11569
|
output.log("");
|
|
@@ -11507,7 +11573,7 @@ var DeleteCommand = {
|
|
|
11507
11573
|
input: process.stdin,
|
|
11508
11574
|
output: process.stdout
|
|
11509
11575
|
});
|
|
11510
|
-
rl.question(
|
|
11576
|
+
rl.question(chalk11.red("Type 'yes' to confirm deletion: "), (res) => {
|
|
11511
11577
|
rl.close();
|
|
11512
11578
|
resolve(res);
|
|
11513
11579
|
});
|
|
@@ -11535,7 +11601,7 @@ var DeleteCommand = {
|
|
|
11535
11601
|
}
|
|
11536
11602
|
}
|
|
11537
11603
|
if (successCount > 0) {
|
|
11538
|
-
output.success(
|
|
11604
|
+
output.success(chalk11.green(`✓`) + ` Deleted ${successCount} session(s)`);
|
|
11539
11605
|
}
|
|
11540
11606
|
if (failCount > 0) {
|
|
11541
11607
|
output.error(`✗ Failed to delete ${failCount} session(s)`);
|
|
@@ -11554,7 +11620,7 @@ var DeleteCommand = {
|
|
|
11554
11620
|
};
|
|
11555
11621
|
|
|
11556
11622
|
// src/commands/sessions/messages.ts
|
|
11557
|
-
import
|
|
11623
|
+
import chalk12 from "chalk";
|
|
11558
11624
|
|
|
11559
11625
|
// src/commands/sessions/format-message-content.ts
|
|
11560
11626
|
var TEXT_MAX_CHARS = 300;
|
|
@@ -11766,20 +11832,20 @@ var MessagesCommand = {
|
|
|
11766
11832
|
} else {
|
|
11767
11833
|
const detail = a.detail === true;
|
|
11768
11834
|
const roleColors = {
|
|
11769
|
-
user:
|
|
11770
|
-
assistant:
|
|
11771
|
-
system:
|
|
11772
|
-
tool:
|
|
11835
|
+
user: chalk12.blue,
|
|
11836
|
+
assistant: chalk12.green,
|
|
11837
|
+
system: chalk12.gray,
|
|
11838
|
+
tool: chalk12.yellow
|
|
11773
11839
|
};
|
|
11774
|
-
output.log(
|
|
11840
|
+
output.log(chalk12.bold(`┌─ Messages (${a.sessionId}) ────────────────────────┐`));
|
|
11775
11841
|
messages.forEach((m, i) => {
|
|
11776
|
-
const roleColor = roleColors[m.role] ||
|
|
11842
|
+
const roleColor = roleColors[m.role] || chalk12.white;
|
|
11777
11843
|
const time = new Date(m.timestamp).toLocaleTimeString("zh-CN", {
|
|
11778
11844
|
hour: "2-digit",
|
|
11779
11845
|
minute: "2-digit"
|
|
11780
11846
|
});
|
|
11781
11847
|
if (m.metadata?.isCheckpoint) {
|
|
11782
|
-
output.log(
|
|
11848
|
+
output.log(chalk12.cyan("├─ #" + (a.offset + i + 1) + " checkpoint") + " " + chalk12.gray(time));
|
|
11783
11849
|
output.log("│");
|
|
11784
11850
|
const checkpointContent = formatCheckpointContent(m.content, { detail });
|
|
11785
11851
|
output.log("│ " + checkpointContent.split(`
|
|
@@ -11787,7 +11853,7 @@ var MessagesCommand = {
|
|
|
11787
11853
|
│ `));
|
|
11788
11854
|
output.log("│");
|
|
11789
11855
|
} else {
|
|
11790
|
-
output.log(
|
|
11856
|
+
output.log(chalk12.cyan("├─ #" + (a.offset + i + 1) + " ") + roleColor(m.role.padEnd(10)) + " " + chalk12.gray(time));
|
|
11791
11857
|
const rawLines = formatMessageContent(m, { detail });
|
|
11792
11858
|
const contentLines = colorizeContentLines(rawLines, m);
|
|
11793
11859
|
const finalLines = detail ? contentLines : contentLines.slice(0, MAX_CONTENT_LINES);
|
|
@@ -11795,7 +11861,7 @@ var MessagesCommand = {
|
|
|
11795
11861
|
output.log("│ " + line);
|
|
11796
11862
|
}
|
|
11797
11863
|
if (!detail && contentLines.length > MAX_CONTENT_LINES) {
|
|
11798
|
-
output.log("│ " +
|
|
11864
|
+
output.log("│ " + chalk12.gray(`... (truncated, total ${contentLines.length} lines)`));
|
|
11799
11865
|
}
|
|
11800
11866
|
output.log("│");
|
|
11801
11867
|
}
|
|
@@ -11803,7 +11869,7 @@ var MessagesCommand = {
|
|
|
11803
11869
|
output.log("└" + "─".repeat(51) + "┘");
|
|
11804
11870
|
const hasMore = a.offset + a.limit < totalMessages;
|
|
11805
11871
|
const showingEnd = Math.min(a.offset + a.limit, totalMessages);
|
|
11806
|
-
output.log(
|
|
11872
|
+
output.log(chalk12.gray(`Showing ${a.offset + 1}-${showingEnd} of ${totalMessages} messages` + (hasMore ? " (more available)" : "")));
|
|
11807
11873
|
}
|
|
11808
11874
|
} catch (error) {
|
|
11809
11875
|
output.error(`Failed to get messages: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -11816,43 +11882,43 @@ var MessagesCommand = {
|
|
|
11816
11882
|
function colorizeContentLines(lines, _m) {
|
|
11817
11883
|
return lines.map((line) => {
|
|
11818
11884
|
if (line.startsWith("[Tool Call]"))
|
|
11819
|
-
return
|
|
11885
|
+
return chalk12.cyan(line);
|
|
11820
11886
|
if (line.startsWith("[Tool Result]"))
|
|
11821
|
-
return
|
|
11887
|
+
return chalk12.yellow(line);
|
|
11822
11888
|
if (line === "[Reasoning]")
|
|
11823
|
-
return
|
|
11889
|
+
return chalk12.magenta(line);
|
|
11824
11890
|
if (line === "[Checkpoint]")
|
|
11825
|
-
return
|
|
11891
|
+
return chalk12.cyan(line);
|
|
11826
11892
|
if (line.startsWith("[Node Call]"))
|
|
11827
|
-
return
|
|
11893
|
+
return chalk12.blue(line);
|
|
11828
11894
|
if (line.startsWith("[Node Interrupt]"))
|
|
11829
|
-
return
|
|
11895
|
+
return chalk12.yellow(line);
|
|
11830
11896
|
if (line.startsWith("[Node Resume]"))
|
|
11831
|
-
return
|
|
11897
|
+
return chalk12.green(line);
|
|
11832
11898
|
if (line.startsWith("[Node Start]"))
|
|
11833
|
-
return
|
|
11899
|
+
return chalk12.blue(line);
|
|
11834
11900
|
if (line.startsWith("✅") || line.startsWith("❌")) {
|
|
11835
11901
|
if (line.includes("[Node Result]"))
|
|
11836
|
-
return
|
|
11902
|
+
return chalk12.green(line);
|
|
11837
11903
|
if (line.includes("[Node End]"))
|
|
11838
|
-
return
|
|
11904
|
+
return chalk12.green(line);
|
|
11839
11905
|
return line;
|
|
11840
11906
|
}
|
|
11841
11907
|
if (line.startsWith(" ")) {
|
|
11842
11908
|
if (line.startsWith(" Error:"))
|
|
11843
|
-
return
|
|
11909
|
+
return chalk12.red(line);
|
|
11844
11910
|
if (line.startsWith(" Query:"))
|
|
11845
|
-
return
|
|
11911
|
+
return chalk12.bold(line);
|
|
11846
11912
|
if (line.startsWith(" Options:") || line.startsWith(" agentSessionId:") || line.startsWith(" Duration:"))
|
|
11847
|
-
return
|
|
11848
|
-
return
|
|
11913
|
+
return chalk12.gray(line);
|
|
11914
|
+
return chalk12.gray(line);
|
|
11849
11915
|
}
|
|
11850
11916
|
return line;
|
|
11851
11917
|
});
|
|
11852
11918
|
}
|
|
11853
11919
|
|
|
11854
11920
|
// src/commands/sessions/compact.ts
|
|
11855
|
-
import
|
|
11921
|
+
import chalk13 from "chalk";
|
|
11856
11922
|
var CompactCommand = {
|
|
11857
11923
|
command: "compact <session-id>",
|
|
11858
11924
|
aliases: ["compress", "checkpoint"],
|
|
@@ -11906,13 +11972,13 @@ var CompactCommand = {
|
|
|
11906
11972
|
dryRun: true
|
|
11907
11973
|
});
|
|
11908
11974
|
} else {
|
|
11909
|
-
output.log(
|
|
11975
|
+
output.log(chalk13.bold("┌─ Compact Preview ─────────────────────────────────┐"));
|
|
11910
11976
|
output.log(`│ Session: ${session.title}`);
|
|
11911
|
-
output.log(`│ Messages to compact: ${
|
|
11977
|
+
output.log(`│ Messages to compact: ${chalk13.yellow(preview.messageCountToCompact)}`);
|
|
11912
11978
|
output.log(`│ Estimated checkpoint tokens: ${preview.estimatedCheckpointTokens}`);
|
|
11913
|
-
output.log(`│ Would trigger: ${preview.wouldTrigger ?
|
|
11979
|
+
output.log(`│ Would trigger: ${preview.wouldTrigger ? chalk13.green("Yes") : chalk13.gray("No")}`);
|
|
11914
11980
|
output.log("│");
|
|
11915
|
-
output.log("│ " +
|
|
11981
|
+
output.log("│ " + chalk13.gray("(Dry run - no changes made)"));
|
|
11916
11982
|
output.log("└" + "─".repeat(51) + "┘");
|
|
11917
11983
|
}
|
|
11918
11984
|
return;
|
|
@@ -11927,10 +11993,10 @@ var CompactCommand = {
|
|
|
11927
11993
|
try {
|
|
11928
11994
|
scenarioHint = await sessionComponent.generateCompactHint(a.sessionId);
|
|
11929
11995
|
if (!a.json) {
|
|
11930
|
-
output.log(
|
|
11931
|
-
output.log("│ " +
|
|
11996
|
+
output.log(chalk13.bold("├─ Auto-generated Scenario Hint ──────────────────────────┤"));
|
|
11997
|
+
output.log("│ " + chalk13.cyan(scenarioHint.substring(0, 70)));
|
|
11932
11998
|
if (scenarioHint.length > 70) {
|
|
11933
|
-
output.log(
|
|
11999
|
+
output.log(chalk13.gray("│ ") + scenarioHint.substring(70, 140));
|
|
11934
12000
|
}
|
|
11935
12001
|
}
|
|
11936
12002
|
} catch (hintError) {
|
|
@@ -11977,29 +12043,29 @@ var CompactCommand = {
|
|
|
11977
12043
|
}
|
|
11978
12044
|
});
|
|
11979
12045
|
} else {
|
|
11980
|
-
output.log(
|
|
12046
|
+
output.log(chalk13.bold.green("┌─ Checkpoint Created ────────────────────────────────┐"));
|
|
11981
12047
|
output.log(`│ ID: ${result.checkpoint.id}`);
|
|
11982
12048
|
output.log(`│ Title: ${result.checkpoint.title}`);
|
|
11983
12049
|
output.log(`│ Type: compact`);
|
|
11984
12050
|
output.log(`│ Created: ${new Date(result.checkpoint.createdAt).toLocaleString("zh-CN")}`);
|
|
11985
|
-
output.log(
|
|
12051
|
+
output.log(chalk13.bold("├─ Scenario Hint ────────────────────────────────────┤"));
|
|
11986
12052
|
if (scenarioHint) {
|
|
11987
12053
|
const hintLines = scenarioHint.split(`
|
|
11988
12054
|
`);
|
|
11989
12055
|
hintLines.forEach((line, i) => {
|
|
11990
12056
|
if (i === 0) {
|
|
11991
|
-
output.log(
|
|
12057
|
+
output.log(chalk13.cyan("│ " + line.substring(0, 48)));
|
|
11992
12058
|
if (line.length > 48) {
|
|
11993
12059
|
for (let j = 48;j < line.length; j += 48) {
|
|
11994
|
-
output.log(
|
|
12060
|
+
output.log(chalk13.gray("│ ") + line.substring(j, j + 48));
|
|
11995
12061
|
}
|
|
11996
12062
|
}
|
|
11997
12063
|
} else {
|
|
11998
|
-
output.log(
|
|
12064
|
+
output.log(chalk13.gray("│ ") + line);
|
|
11999
12065
|
}
|
|
12000
12066
|
});
|
|
12001
12067
|
} else {
|
|
12002
|
-
output.log(
|
|
12068
|
+
output.log(chalk13.gray("│ (no hint)"));
|
|
12003
12069
|
}
|
|
12004
12070
|
output.log("├─ Process Key Points ─────────────────────────────────┤");
|
|
12005
12071
|
result.checkpoint.processKeyPoints.forEach((p, i) => {
|
|
@@ -12024,11 +12090,11 @@ var CompactCommand = {
|
|
|
12024
12090
|
result.checkpoint.recentMessages.forEach((msg) => {
|
|
12025
12091
|
const prefix = msg.role === "user" ? "\uD83D\uDC64" : "\uD83E\uDD16";
|
|
12026
12092
|
const content = msg.content.length > 60 ? msg.content.substring(0, 60) + "..." : msg.content;
|
|
12027
|
-
output.log(
|
|
12093
|
+
output.log(chalk13.gray(`│ ${prefix} [${msg.role}] ${content}`));
|
|
12028
12094
|
});
|
|
12029
12095
|
}
|
|
12030
12096
|
output.log("├─ Stats ─────────────────────────────────────────────┤");
|
|
12031
|
-
output.log(`│ Messages compacted: ${
|
|
12097
|
+
output.log(`│ Messages compacted: ${chalk13.yellow(result.deletedMessageCount)}`);
|
|
12032
12098
|
output.log(`│ Remaining messages: ${result.remainingMessageCount}`);
|
|
12033
12099
|
output.log(`│ Total checkpoints: ${result.checkpointCount}`);
|
|
12034
12100
|
output.log("└" + "─".repeat(51) + "┘");
|
|
@@ -12046,7 +12112,7 @@ var CompactCommand = {
|
|
|
12046
12112
|
};
|
|
12047
12113
|
|
|
12048
12114
|
// src/commands/sessions/checkpoints.ts
|
|
12049
|
-
import
|
|
12115
|
+
import chalk14 from "chalk";
|
|
12050
12116
|
var CheckpointsCommand = {
|
|
12051
12117
|
command: "checkpoints <session-id>",
|
|
12052
12118
|
aliases: ["cps"],
|
|
@@ -12079,7 +12145,7 @@ var CheckpointsCommand = {
|
|
|
12079
12145
|
}
|
|
12080
12146
|
const checkpoints = await sessionComponent.getCheckpoints(a.sessionId);
|
|
12081
12147
|
if (checkpoints.length === 0) {
|
|
12082
|
-
output.log(
|
|
12148
|
+
output.log(chalk14.gray("No checkpoints for this session"));
|
|
12083
12149
|
return;
|
|
12084
12150
|
}
|
|
12085
12151
|
if (a.json) {
|
|
@@ -12104,7 +12170,7 @@ var CheckpointsCommand = {
|
|
|
12104
12170
|
if (a.detail) {
|
|
12105
12171
|
checkpoints.reverse().forEach((cp, i) => {
|
|
12106
12172
|
const isLatest = i === 0;
|
|
12107
|
-
output.log(
|
|
12173
|
+
output.log(chalk14.bold(`┌─ Checkpoint: ${cp.title} ${isLatest ? chalk14.green("✓") : ""} ──────` + "─".repeat(Math.max(0, 30 - cp.title.length)) + "┐"));
|
|
12108
12174
|
output.log(`│ ID: ${cp.id}`);
|
|
12109
12175
|
output.log(`│ Type: ${cp.type}`);
|
|
12110
12176
|
output.log(`│ Message Index: ${cp.messageIndex} (${cp.messageCountBefore} messages)`);
|
|
@@ -12132,18 +12198,18 @@ var CheckpointsCommand = {
|
|
|
12132
12198
|
});
|
|
12133
12199
|
} else {
|
|
12134
12200
|
const header = [
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12201
|
+
chalk14.bold("#"),
|
|
12202
|
+
chalk14.bold("Title"),
|
|
12203
|
+
chalk14.bold("Type"),
|
|
12204
|
+
chalk14.bold("Messages"),
|
|
12205
|
+
chalk14.bold("Created")
|
|
12140
12206
|
].join(" │ ");
|
|
12141
12207
|
output.log(`┌─ Checkpoints (${checkpoints.length}) ${"─".repeat(40)}┐`);
|
|
12142
12208
|
output.log(`│${header}│`);
|
|
12143
12209
|
output.log("├" + "─".repeat(header.length + 2) + "┤");
|
|
12144
12210
|
checkpoints.reverse().forEach((cp, i) => {
|
|
12145
12211
|
const isLatest = i === 0;
|
|
12146
|
-
const marker = isLatest ?
|
|
12212
|
+
const marker = isLatest ? chalk14.green("✓ ") : " ";
|
|
12147
12213
|
const title = cp.title.length > 25 ? cp.title.slice(0, 22) + "..." : cp.title;
|
|
12148
12214
|
const created = new Date(cp.createdAt).toLocaleString("zh-CN", {
|
|
12149
12215
|
month: "2-digit",
|
|
@@ -12151,7 +12217,7 @@ var CheckpointsCommand = {
|
|
|
12151
12217
|
hour: "2-digit",
|
|
12152
12218
|
minute: "2-digit"
|
|
12153
12219
|
});
|
|
12154
|
-
output.log(`│${marker}${i + 1} ${title.padEnd(25)} │ ${cp.type.padEnd(5)} │ ${cp.messageCountBefore.toString().padStart(8)} │ ${
|
|
12220
|
+
output.log(`│${marker}${i + 1} ${title.padEnd(25)} │ ${cp.type.padEnd(5)} │ ${cp.messageCountBefore.toString().padStart(8)} │ ${chalk14.gray(created)}│`);
|
|
12155
12221
|
});
|
|
12156
12222
|
output.log("└" + "─".repeat(header.length + 2) + "┘");
|
|
12157
12223
|
}
|
|
@@ -12165,7 +12231,7 @@ var CheckpointsCommand = {
|
|
|
12165
12231
|
};
|
|
12166
12232
|
|
|
12167
12233
|
// src/commands/sessions/active.ts
|
|
12168
|
-
import
|
|
12234
|
+
import chalk15 from "chalk";
|
|
12169
12235
|
var ActiveCommand = {
|
|
12170
12236
|
command: "active",
|
|
12171
12237
|
aliases: ["current"],
|
|
@@ -12192,7 +12258,7 @@ var ActiveCommand = {
|
|
|
12192
12258
|
return;
|
|
12193
12259
|
}
|
|
12194
12260
|
if (!activeId) {
|
|
12195
|
-
output.log(
|
|
12261
|
+
output.log(chalk15.gray("No active session set"));
|
|
12196
12262
|
return;
|
|
12197
12263
|
}
|
|
12198
12264
|
const session = await sessionComponent.get(activeId);
|
|
@@ -12210,10 +12276,10 @@ var ActiveCommand = {
|
|
|
12210
12276
|
});
|
|
12211
12277
|
} else {
|
|
12212
12278
|
if (!session) {
|
|
12213
|
-
output.log(
|
|
12279
|
+
output.log(chalk15.gray("Active session not found: " + activeId));
|
|
12214
12280
|
return;
|
|
12215
12281
|
}
|
|
12216
|
-
output.log(
|
|
12282
|
+
output.log(chalk15.bold.green("┌─ Active Session ─────────────────────────────────┐"));
|
|
12217
12283
|
output.log(`│ ID: ${session.id}`);
|
|
12218
12284
|
output.log(`│ Title: ${session.title}`);
|
|
12219
12285
|
output.log(`│ Directory: ${session.directory}`);
|
|
@@ -12295,7 +12361,7 @@ var AddMessageCommand = {
|
|
|
12295
12361
|
};
|
|
12296
12362
|
|
|
12297
12363
|
// src/commands/sessions/mock.ts
|
|
12298
|
-
import
|
|
12364
|
+
import chalk16 from "chalk";
|
|
12299
12365
|
var MOCK_SEQUENCES = [
|
|
12300
12366
|
{
|
|
12301
12367
|
name: "文件操作流程",
|
|
@@ -12428,7 +12494,7 @@ var MockCommand = {
|
|
|
12428
12494
|
for (let seqIdx = 0;seqIdx < count; seqIdx++) {
|
|
12429
12495
|
const sequence = MOCK_SEQUENCES[seqIdx];
|
|
12430
12496
|
if (!a.json) {
|
|
12431
|
-
output.log(
|
|
12497
|
+
output.log(chalk16.bold(`
|
|
12432
12498
|
\uD83D\uDCDD Sequence ${seqIdx + 1}: ${sequence.name}`));
|
|
12433
12499
|
}
|
|
12434
12500
|
for (const msg of sequence.messages) {
|
|
@@ -12446,7 +12512,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12446
12512
|
if (assistantMsgId)
|
|
12447
12513
|
addedMessages.push(assistantMsgId);
|
|
12448
12514
|
if (!a.json) {
|
|
12449
|
-
output.log(
|
|
12515
|
+
output.log(chalk16.cyan(` [${addedMessages.length}] assistant: \uD83D\uDD27 Tool call`));
|
|
12450
12516
|
}
|
|
12451
12517
|
const toolMsgId = await sessionComponent.addMessage(a.sessionId, {
|
|
12452
12518
|
role: "tool",
|
|
@@ -12455,7 +12521,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12455
12521
|
if (toolMsgId)
|
|
12456
12522
|
addedMessages.push(toolMsgId);
|
|
12457
12523
|
if (!a.json) {
|
|
12458
|
-
output.log(
|
|
12524
|
+
output.log(chalk16.yellow(` [${addedMessages.length}] tool: ${msg.content.substring(0, 50)}...`));
|
|
12459
12525
|
}
|
|
12460
12526
|
} else {
|
|
12461
12527
|
const msgId = await sessionComponent.addMessage(a.sessionId, {
|
|
@@ -12465,7 +12531,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12465
12531
|
if (msgId)
|
|
12466
12532
|
addedMessages.push(msgId);
|
|
12467
12533
|
if (!a.json) {
|
|
12468
|
-
const roleColor = msg.role === "user" ?
|
|
12534
|
+
const roleColor = msg.role === "user" ? chalk16.green : msg.role === "assistant" ? chalk16.cyan : chalk16.gray;
|
|
12469
12535
|
output.log(roleColor(` [${addedMessages.length}] ${msg.role}: ${msg.content.substring(0, 50)}...`));
|
|
12470
12536
|
}
|
|
12471
12537
|
}
|
|
@@ -12481,14 +12547,14 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12481
12547
|
});
|
|
12482
12548
|
} else {
|
|
12483
12549
|
output.log(`
|
|
12484
|
-
` +
|
|
12550
|
+
` + chalk16.bold.green("✅ Mock data inserted successfully!"));
|
|
12485
12551
|
output.log(` Session: ${a.sessionId}`);
|
|
12486
12552
|
output.log(` Sequences: ${count}`);
|
|
12487
12553
|
output.log(` Messages: ${addedMessages.length}`);
|
|
12488
12554
|
output.log("");
|
|
12489
|
-
output.log(
|
|
12490
|
-
output.log(
|
|
12491
|
-
output.log(
|
|
12555
|
+
output.log(chalk16.gray(" Now run: "));
|
|
12556
|
+
output.log(chalk16.gray(` roy-agent sessions compact ${a.sessionId}`));
|
|
12557
|
+
output.log(chalk16.gray(" to trigger checkpoint generation"));
|
|
12492
12558
|
}
|
|
12493
12559
|
} finally {
|
|
12494
12560
|
await envService.dispose();
|
|
@@ -12497,7 +12563,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12497
12563
|
};
|
|
12498
12564
|
|
|
12499
12565
|
// src/commands/sessions/grep.ts
|
|
12500
|
-
import
|
|
12566
|
+
import chalk17 from "chalk";
|
|
12501
12567
|
var GrepCommand = {
|
|
12502
12568
|
command: "grep <query...>",
|
|
12503
12569
|
aliases: ["search"],
|
|
@@ -12577,7 +12643,7 @@ var GrepCommand = {
|
|
|
12577
12643
|
const results = await sessionComponent.searchMessages(searchOptions);
|
|
12578
12644
|
if (results.length === 0) {
|
|
12579
12645
|
if (!a.quiet) {
|
|
12580
|
-
output.log(
|
|
12646
|
+
output.log(chalk17.yellow(`No results found for: ${query}`));
|
|
12581
12647
|
}
|
|
12582
12648
|
return;
|
|
12583
12649
|
}
|
|
@@ -12604,7 +12670,7 @@ var GrepCommand = {
|
|
|
12604
12670
|
for (const result of results) {
|
|
12605
12671
|
for (const match of result.matches) {
|
|
12606
12672
|
const time = new Date(match.timestamp).toLocaleString("zh-CN");
|
|
12607
|
-
output.log(`${
|
|
12673
|
+
output.log(`${chalk17.gray(result.sessionId)} ${chalk17.blue(result.sessionTitle)} ${chalk17.gray(time)}`);
|
|
12608
12674
|
output.log(` ${match.content}`);
|
|
12609
12675
|
output.log("");
|
|
12610
12676
|
}
|
|
@@ -12616,40 +12682,40 @@ var GrepCommand = {
|
|
|
12616
12682
|
totalMatches += result.matches.length;
|
|
12617
12683
|
const time = new Date(result.updatedAt).toLocaleString("zh-CN");
|
|
12618
12684
|
const titleStr = `─ ${result.sessionTitle} (${result.sessionId})`;
|
|
12619
|
-
output.log(
|
|
12685
|
+
output.log(chalk17.bold(`
|
|
12620
12686
|
┌${titleStr}${"─".repeat(Math.max(0, 50 - titleStr.length))}┐`));
|
|
12621
|
-
output.log(`│ ${
|
|
12687
|
+
output.log(`│ ${chalk17.gray(`Updated: ${time} | ${result.messageCount} messages | ${result.matches.length} matches`)}${" ".repeat(Math.max(0, 50 - 60))}│`);
|
|
12622
12688
|
for (let i = 0;i < result.matches.length; i++) {
|
|
12623
12689
|
const match = result.matches[i];
|
|
12624
|
-
const roleColor = match.role === "user" ?
|
|
12690
|
+
const roleColor = match.role === "user" ? chalk17.blue : match.role === "assistant" ? chalk17.green : chalk17.gray;
|
|
12625
12691
|
const msgTime = new Date(match.timestamp).toLocaleTimeString("zh-CN", {
|
|
12626
12692
|
hour: "2-digit",
|
|
12627
12693
|
minute: "2-digit"
|
|
12628
12694
|
});
|
|
12629
|
-
output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${
|
|
12695
|
+
output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${chalk17.gray(msgTime)}`);
|
|
12630
12696
|
output.log("│");
|
|
12631
12697
|
const lines = match.content.split(`
|
|
12632
12698
|
`).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
12633
12699
|
const maxLines = 5;
|
|
12634
12700
|
const displayLines = lines.slice(0, maxLines);
|
|
12635
12701
|
if (displayLines.length === 0) {
|
|
12636
|
-
output.log("│ " +
|
|
12702
|
+
output.log("│ " + chalk17.gray("(empty content)"));
|
|
12637
12703
|
} else {
|
|
12638
12704
|
for (const line of displayLines) {
|
|
12639
12705
|
const truncated = line.length > 76 ? line.slice(0, 73) + "..." : line;
|
|
12640
|
-
output.log(`│ ${
|
|
12706
|
+
output.log(`│ ${chalk17.gray(truncated)}`);
|
|
12641
12707
|
}
|
|
12642
12708
|
}
|
|
12643
12709
|
if (lines.length > maxLines) {
|
|
12644
|
-
output.log("│ " +
|
|
12710
|
+
output.log("│ " + chalk17.gray(`... (${lines.length - maxLines} more lines)`));
|
|
12645
12711
|
}
|
|
12646
12712
|
output.log("│");
|
|
12647
12713
|
}
|
|
12648
12714
|
output.log(`└${"─".repeat(52)}┘`);
|
|
12649
12715
|
}
|
|
12650
12716
|
output.log(`
|
|
12651
|
-
${
|
|
12652
|
-
output.log(
|
|
12717
|
+
${chalk17.green("✓")} Found ${chalk17.bold(totalMatches.toString())} matches in ${chalk17.bold(results.length.toString())} sessions`);
|
|
12718
|
+
output.log(chalk17.gray(`Query: "${query}"`));
|
|
12653
12719
|
}
|
|
12654
12720
|
} catch (error) {
|
|
12655
12721
|
output.error(`Search failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -12688,7 +12754,7 @@ var SessionsCommand = {
|
|
|
12688
12754
|
};
|
|
12689
12755
|
|
|
12690
12756
|
// src/commands/tasks/list.ts
|
|
12691
|
-
import
|
|
12757
|
+
import chalk18 from "chalk";
|
|
12692
12758
|
|
|
12693
12759
|
// src/commands/tasks/_build-list-json.ts
|
|
12694
12760
|
function buildListTasksJson(tasks, total, args, extras) {
|
|
@@ -12736,7 +12802,7 @@ var ListCommand2 = {
|
|
|
12736
12802
|
type: "string",
|
|
12737
12803
|
choices: ["normal", "cycle", "longterm"],
|
|
12738
12804
|
description: "按任务类型筛选"
|
|
12739
|
-
}).option("limit", { alias: "n", type: "number", default: 20, description: "返回数量" }).option("offset", { type: "number", default: 0, description: "
|
|
12805
|
+
}).option("limit", { alias: "n", type: "number", default: 20, description: "返回数量" }).option("offset", { alias: "o", type: "number", default: 0, description: "分页偏移(-o alias)" }).option("depth", {
|
|
12740
12806
|
type: "number",
|
|
12741
12807
|
description: "检索层级深度:0=只根任务(无父任务),1=根+一层子任务,2=根+二层子任务,-1 或忽略=全部"
|
|
12742
12808
|
}).option("include-archived", {
|
|
@@ -12774,20 +12840,29 @@ var ListCommand2 = {
|
|
|
12774
12840
|
if (args.json) {
|
|
12775
12841
|
output.json(buildListTasksJson(tasks, total, args));
|
|
12776
12842
|
} else if (args.quiet) {
|
|
12777
|
-
|
|
12843
|
+
output.log(renderQuietHeader(total, "task"));
|
|
12844
|
+
tasks.forEach((t) => output.log(renderQuietLine(t.id, t.title)));
|
|
12845
|
+
const hint = renderQuietPaginationHint({
|
|
12846
|
+
count: tasks.length,
|
|
12847
|
+
total,
|
|
12848
|
+
offset: args.offset ?? 0,
|
|
12849
|
+
limit: args.limit ?? 20
|
|
12850
|
+
});
|
|
12851
|
+
if (hint)
|
|
12852
|
+
output.log(hint);
|
|
12778
12853
|
} else {
|
|
12779
12854
|
const header = [
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12855
|
+
chalk18.bold("#"),
|
|
12856
|
+
chalk18.bold("Title"),
|
|
12857
|
+
chalk18.bold("Status"),
|
|
12858
|
+
chalk18.bold("Priority"),
|
|
12859
|
+
chalk18.bold("Type"),
|
|
12860
|
+
chalk18.bold("Progress"),
|
|
12861
|
+
chalk18.bold("Parent")
|
|
12787
12862
|
].join(" │ ");
|
|
12788
12863
|
const rows = tasks.map((t, i) => {
|
|
12789
|
-
const statusColor = t.status === "completed" ?
|
|
12790
|
-
const priorityColor = t.priority === "high" ?
|
|
12864
|
+
const statusColor = t.status === "completed" ? chalk18.green : t.status === "active" ? chalk18.blue : t.status === "paused" ? chalk18.yellow : t.status === "cancelled" ? chalk18.strikethrough : chalk18.gray;
|
|
12865
|
+
const priorityColor = t.priority === "high" ? chalk18.red : t.priority === "medium" ? chalk18.yellow : chalk18.gray;
|
|
12791
12866
|
return [
|
|
12792
12867
|
(args.offset + i + 1).toString(),
|
|
12793
12868
|
t.title.length > 30 ? t.title.slice(0, 27) + "..." : t.title,
|
|
@@ -12795,11 +12870,11 @@ var ListCommand2 = {
|
|
|
12795
12870
|
priorityColor(t.priority),
|
|
12796
12871
|
t.type || "normal",
|
|
12797
12872
|
`${t.progress}%`,
|
|
12798
|
-
t.parent_task_id ? `#${t.parent_task_id}` :
|
|
12873
|
+
t.parent_task_id ? `#${t.parent_task_id}` : chalk18.gray("root")
|
|
12799
12874
|
].join(" │ ");
|
|
12800
12875
|
});
|
|
12801
|
-
const depthNote = args.depth !== undefined ?
|
|
12802
|
-
const archivedNote = args.includeArchived ?
|
|
12876
|
+
const depthNote = args.depth !== undefined ? chalk18.gray(` depth=${args.depth}`) : "";
|
|
12877
|
+
const archivedNote = args.includeArchived ? chalk18.gray(" include-archived") : "";
|
|
12803
12878
|
output.log([
|
|
12804
12879
|
`┌─ Tasks ${"─".repeat(55)}┐`,
|
|
12805
12880
|
`│${header}│`,
|
|
@@ -12807,7 +12882,7 @@ var ListCommand2 = {
|
|
|
12807
12882
|
...rows.map((r) => `│${r}│`),
|
|
12808
12883
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
12809
12884
|
"",
|
|
12810
|
-
|
|
12885
|
+
chalk18.gray(`Showing ${tasks.length} of ${total} tasks (offset=${args.offset}, limit=${args.limit})${depthNote}${archivedNote}`)
|
|
12811
12886
|
].join(`
|
|
12812
12887
|
`));
|
|
12813
12888
|
}
|
|
@@ -12821,7 +12896,7 @@ var ListCommand2 = {
|
|
|
12821
12896
|
};
|
|
12822
12897
|
|
|
12823
12898
|
// src/commands/tasks/get.ts
|
|
12824
|
-
import
|
|
12899
|
+
import chalk19 from "chalk";
|
|
12825
12900
|
var GetCommand2 = {
|
|
12826
12901
|
command: "get <id>",
|
|
12827
12902
|
aliases: ["show"],
|
|
@@ -12860,10 +12935,10 @@ var GetCommand2 = {
|
|
|
12860
12935
|
if (args.json) {
|
|
12861
12936
|
output.json(result);
|
|
12862
12937
|
} else {
|
|
12863
|
-
output.log(
|
|
12938
|
+
output.log(chalk19.bold(`
|
|
12864
12939
|
Task #${result.task.id}: ${result.task.title}
|
|
12865
12940
|
`));
|
|
12866
|
-
output.log(`Status: ${
|
|
12941
|
+
output.log(`Status: ${chalk19.blue(result.task.status)} | Priority: ${result.task.priority} | Type: ${result.task.type} | Progress: ${result.task.progress}%`);
|
|
12867
12942
|
output.log(`Created: ${result.task.createdAt} | Updated: ${result.task.updatedAt}`);
|
|
12868
12943
|
output.log(`Project Path: ${result.task.project_path}`);
|
|
12869
12944
|
output.log(`Context: ${result.task.context}`);
|
|
@@ -12871,7 +12946,7 @@ Task #${result.task.id}: ${result.task.title}
|
|
|
12871
12946
|
output.log(`
|
|
12872
12947
|
Current Status: ${result.task.current_status}`);
|
|
12873
12948
|
}
|
|
12874
|
-
output.log(
|
|
12949
|
+
output.log(chalk19.bold(`
|
|
12875
12950
|
Operations (${result.operations.length}):
|
|
12876
12951
|
`));
|
|
12877
12952
|
result.operations.forEach((op, i) => {
|
|
@@ -12891,10 +12966,10 @@ Operations (${result.operations.length}):
|
|
|
12891
12966
|
if (args.json) {
|
|
12892
12967
|
output.json(task);
|
|
12893
12968
|
} else {
|
|
12894
|
-
output.log(
|
|
12969
|
+
output.log(chalk19.bold(`
|
|
12895
12970
|
Task #${task.id}: ${task.title}
|
|
12896
12971
|
`));
|
|
12897
|
-
output.log(`Status: ${
|
|
12972
|
+
output.log(`Status: ${chalk19.blue(task.status)} | Priority: ${task.priority} | Type: ${task.type} | Progress: ${task.progress}%`);
|
|
12898
12973
|
output.log(`Created: ${task.createdAt} | Updated: ${task.updatedAt}`);
|
|
12899
12974
|
output.log(`Project Path: ${task.project_path}`);
|
|
12900
12975
|
output.log(`Context: ${task.context}`);
|
|
@@ -12918,7 +12993,7 @@ Description: ${task.description}`);
|
|
|
12918
12993
|
};
|
|
12919
12994
|
|
|
12920
12995
|
// src/commands/tasks/create.ts
|
|
12921
|
-
import
|
|
12996
|
+
import chalk20 from "chalk";
|
|
12922
12997
|
var CreateCommand = {
|
|
12923
12998
|
command: "create <title>",
|
|
12924
12999
|
aliases: ["add", "new"],
|
|
@@ -12996,7 +13071,7 @@ var CreateCommand = {
|
|
|
12996
13071
|
if (args.json) {
|
|
12997
13072
|
output.json(task);
|
|
12998
13073
|
} else {
|
|
12999
|
-
output.log(
|
|
13074
|
+
output.log(chalk20.green(`
|
|
13000
13075
|
✓ Task created: #${task.id}`));
|
|
13001
13076
|
output.log(` Title: ${task.title}`);
|
|
13002
13077
|
output.log(` Status: ${task.status}`);
|
|
@@ -13014,7 +13089,7 @@ var CreateCommand = {
|
|
|
13014
13089
|
};
|
|
13015
13090
|
|
|
13016
13091
|
// src/commands/tasks/update.ts
|
|
13017
|
-
import
|
|
13092
|
+
import chalk21 from "chalk";
|
|
13018
13093
|
var UpdateCommand = {
|
|
13019
13094
|
command: "update <id>",
|
|
13020
13095
|
aliases: ["set"],
|
|
@@ -13072,7 +13147,7 @@ var UpdateCommand = {
|
|
|
13072
13147
|
if (args.json) {
|
|
13073
13148
|
output.json(task);
|
|
13074
13149
|
} else {
|
|
13075
|
-
output.log(
|
|
13150
|
+
output.log(chalk21.green(`
|
|
13076
13151
|
✓ Task updated: #${task.id}`));
|
|
13077
13152
|
output.log(` Title: ${task.title}`);
|
|
13078
13153
|
output.log(` Status: ${task.status}`);
|
|
@@ -13095,7 +13170,7 @@ var UpdateCommand = {
|
|
|
13095
13170
|
};
|
|
13096
13171
|
|
|
13097
13172
|
// src/commands/tasks/delete.ts
|
|
13098
|
-
import
|
|
13173
|
+
import chalk22 from "chalk";
|
|
13099
13174
|
var DeleteCommand2 = {
|
|
13100
13175
|
command: "delete <id>",
|
|
13101
13176
|
aliases: ["remove", "rm", "del"],
|
|
@@ -13131,16 +13206,16 @@ var DeleteCommand2 = {
|
|
|
13131
13206
|
process.exit(1);
|
|
13132
13207
|
}
|
|
13133
13208
|
if (!args.force) {
|
|
13134
|
-
output.log(
|
|
13135
|
-
output.log(
|
|
13136
|
-
output.log(
|
|
13137
|
-
output.log(
|
|
13209
|
+
output.log(chalk22.yellow(`Are you sure you want to delete task #${args.id}?`));
|
|
13210
|
+
output.log(chalk22.yellow(` Title: ${task.title}`));
|
|
13211
|
+
output.log(chalk22.yellow(` Status: ${task.status}`));
|
|
13212
|
+
output.log(chalk22.yellow(`
|
|
13138
13213
|
Use --force to skip this confirmation`));
|
|
13139
13214
|
process.exit(1);
|
|
13140
13215
|
}
|
|
13141
13216
|
const deleted = await taskComponent.deleteTask(args.id);
|
|
13142
13217
|
if (deleted) {
|
|
13143
|
-
output.log(
|
|
13218
|
+
output.log(chalk22.green(`
|
|
13144
13219
|
✓ Task deleted: #${args.id}`));
|
|
13145
13220
|
} else {
|
|
13146
13221
|
output.error(`Failed to delete task: ${args.id}`);
|
|
@@ -13156,7 +13231,7 @@ Use --force to skip this confirmation`));
|
|
|
13156
13231
|
};
|
|
13157
13232
|
|
|
13158
13233
|
// src/commands/tasks/complete.ts
|
|
13159
|
-
import
|
|
13234
|
+
import chalk23 from "chalk";
|
|
13160
13235
|
var CompleteCommand = {
|
|
13161
13236
|
command: "complete <id>",
|
|
13162
13237
|
aliases: ["done", "finish"],
|
|
@@ -13213,7 +13288,7 @@ var CompleteCommand = {
|
|
|
13213
13288
|
if (args.json) {
|
|
13214
13289
|
output.json(task);
|
|
13215
13290
|
} else {
|
|
13216
|
-
output.log(
|
|
13291
|
+
output.log(chalk23.green(`
|
|
13217
13292
|
✓ Task completed: #${task.id}`));
|
|
13218
13293
|
output.log(` Title: ${task.title}`);
|
|
13219
13294
|
output.log(` Progress: ${task.progress}%`);
|
|
@@ -13229,7 +13304,7 @@ var CompleteCommand = {
|
|
|
13229
13304
|
};
|
|
13230
13305
|
|
|
13231
13306
|
// src/commands/tasks/operations.ts
|
|
13232
|
-
import
|
|
13307
|
+
import chalk24 from "chalk";
|
|
13233
13308
|
var OperationsCommand = {
|
|
13234
13309
|
command: "operations <task-id>",
|
|
13235
13310
|
aliases: ["ops", "log"],
|
|
@@ -13279,23 +13354,23 @@ var OperationsCommand = {
|
|
|
13279
13354
|
operations
|
|
13280
13355
|
});
|
|
13281
13356
|
} else {
|
|
13282
|
-
output.log(
|
|
13357
|
+
output.log(chalk24.bold(`
|
|
13283
13358
|
Operations for Task #${task.id}: ${task.title}
|
|
13284
13359
|
`));
|
|
13285
13360
|
if (operations.length === 0) {
|
|
13286
|
-
output.log(
|
|
13361
|
+
output.log(chalk24.gray("No operations found."));
|
|
13287
13362
|
} else {
|
|
13288
13363
|
operations.forEach((op, i) => {
|
|
13289
|
-
const actionColor = op.actionType === "completed" ?
|
|
13290
|
-
output.log(`${
|
|
13291
|
-
output.log(` Session: ${
|
|
13364
|
+
const actionColor = op.actionType === "completed" ? chalk24.green : op.actionType === "milestone" ? chalk24.blue : op.actionType === "problem" ? chalk24.red : chalk24.gray;
|
|
13365
|
+
output.log(`${chalk24.bold(a.offset + i + 1)}. ` + actionColor(`[${op.actionType}]`) + ` ${op.actionTitle}`);
|
|
13366
|
+
output.log(` Session: ${chalk24.cyan(op.sessionId)} | Time: ${op.timestamp}`);
|
|
13292
13367
|
if (op.actionDescription) {
|
|
13293
13368
|
output.log(` ${op.actionDescription}`);
|
|
13294
13369
|
}
|
|
13295
13370
|
output.log("");
|
|
13296
13371
|
});
|
|
13297
13372
|
}
|
|
13298
|
-
output.log(
|
|
13373
|
+
output.log(chalk24.gray(`Total: ${operations.length} operations`));
|
|
13299
13374
|
}
|
|
13300
13375
|
} catch (error) {
|
|
13301
13376
|
output.error(`Failed to list operations: ${error}`);
|
|
@@ -13307,7 +13382,7 @@ Operations for Task #${task.id}: ${task.title}
|
|
|
13307
13382
|
};
|
|
13308
13383
|
|
|
13309
13384
|
// src/commands/tasks/tree.ts
|
|
13310
|
-
import
|
|
13385
|
+
import chalk25 from "chalk";
|
|
13311
13386
|
function buildTree(tasks) {
|
|
13312
13387
|
const byParent = new Map;
|
|
13313
13388
|
const nodeById = new Map;
|
|
@@ -13342,7 +13417,7 @@ function printTree(nodes, prefix, isRoot, output, currentDepth, maxDepth) {
|
|
|
13342
13417
|
const statusColor = colorByStatus(node.task.status);
|
|
13343
13418
|
const typeLabel = node.task.type ? ` [${node.task.type}]` : "";
|
|
13344
13419
|
const progressLabel = node.task.progress > 0 ? ` (${node.task.progress}%)` : "";
|
|
13345
|
-
const header = `#${node.task.id}${typeLabel} ${node.task.title} ${
|
|
13420
|
+
const header = `#${node.task.id}${typeLabel} ${node.task.title} ${chalk25.gray("[" + node.task.status + "]")}${progressLabel}`;
|
|
13346
13421
|
output.log(prefix + connector + statusColor(header));
|
|
13347
13422
|
if (node.children.length > 0) {
|
|
13348
13423
|
const childPrefix = isRoot ? prefix : prefix + (isLast ? " " : "│ ");
|
|
@@ -13353,15 +13428,15 @@ function printTree(nodes, prefix, isRoot, output, currentDepth, maxDepth) {
|
|
|
13353
13428
|
function colorByStatus(status) {
|
|
13354
13429
|
switch (status) {
|
|
13355
13430
|
case "completed":
|
|
13356
|
-
return
|
|
13431
|
+
return chalk25.green;
|
|
13357
13432
|
case "active":
|
|
13358
|
-
return
|
|
13433
|
+
return chalk25.blue;
|
|
13359
13434
|
case "paused":
|
|
13360
|
-
return
|
|
13435
|
+
return chalk25.yellow;
|
|
13361
13436
|
case "cancelled":
|
|
13362
|
-
return
|
|
13437
|
+
return chalk25.strikethrough;
|
|
13363
13438
|
default:
|
|
13364
|
-
return
|
|
13439
|
+
return chalk25.gray;
|
|
13365
13440
|
}
|
|
13366
13441
|
}
|
|
13367
13442
|
var TreeCommand = {
|
|
@@ -13448,10 +13523,10 @@ var TreeCommand = {
|
|
|
13448
13523
|
}
|
|
13449
13524
|
const tree = buildTree(tasks);
|
|
13450
13525
|
if (tree.length === 0) {
|
|
13451
|
-
output.log(
|
|
13526
|
+
output.log(chalk25.gray("No tasks to display."));
|
|
13452
13527
|
return;
|
|
13453
13528
|
}
|
|
13454
|
-
output.log(
|
|
13529
|
+
output.log(chalk25.bold(`Task Tree (${tasks.length} tasks, ${tree.length} roots)`) + (args.rootId !== undefined ? chalk25.gray(` — subtree of #${args.rootId}`) : ""));
|
|
13455
13530
|
output.log("");
|
|
13456
13531
|
printTree(tree, "", true, output, 0, args.maxDepth);
|
|
13457
13532
|
} catch (error) {
|
|
@@ -13464,7 +13539,7 @@ var TreeCommand = {
|
|
|
13464
13539
|
};
|
|
13465
13540
|
|
|
13466
13541
|
// src/commands/tasks/search.ts
|
|
13467
|
-
import
|
|
13542
|
+
import chalk26 from "chalk";
|
|
13468
13543
|
var SearchCommand = {
|
|
13469
13544
|
command: "search <keywords..>",
|
|
13470
13545
|
aliases: ["find", "grep"],
|
|
@@ -13474,7 +13549,7 @@ var SearchCommand = {
|
|
|
13474
13549
|
array: true,
|
|
13475
13550
|
describe: "搜索关键词(多个关键词 AND 逻辑)",
|
|
13476
13551
|
demandOption: true
|
|
13477
|
-
}).option("limit", { alias: "n", type: "number", default: 20, description: "返回数量" }).option("offset", { type: "number", default: 0, description: "
|
|
13552
|
+
}).option("limit", { alias: "n", type: "number", default: 20, description: "返回数量" }).option("offset", { alias: "o", type: "number", default: 0, description: "分页偏移(-o alias)" }).option("status", {
|
|
13478
13553
|
alias: "s",
|
|
13479
13554
|
type: "string",
|
|
13480
13555
|
choices: ["todo", "active", "completed", "paused", "cancelled", "archived"],
|
|
@@ -13525,29 +13600,38 @@ var SearchCommand = {
|
|
|
13525
13600
|
if (args.json) {
|
|
13526
13601
|
output.json(buildListTasksJson(tasks, total, { limit: args.limit, offset: args.offset }, { keywords: args.keywords }));
|
|
13527
13602
|
} else if (args.quiet) {
|
|
13528
|
-
|
|
13603
|
+
output.log(renderQuietHeader(total, "task"));
|
|
13604
|
+
tasks.forEach((t) => output.log(renderQuietLine(t.id, t.title)));
|
|
13605
|
+
const hint = renderQuietPaginationHint({
|
|
13606
|
+
count: tasks.length,
|
|
13607
|
+
total,
|
|
13608
|
+
offset: args.offset ?? 0,
|
|
13609
|
+
limit: args.limit ?? 20
|
|
13610
|
+
});
|
|
13611
|
+
if (hint)
|
|
13612
|
+
output.log(hint);
|
|
13529
13613
|
} else {
|
|
13530
13614
|
const keywordStr = args.keywords.join(" ");
|
|
13531
|
-
output.log(
|
|
13615
|
+
output.log(chalk26.bold(`
|
|
13532
13616
|
\uD83D\uDD0D Search: "${keywordStr}" — ${total} results
|
|
13533
13617
|
`));
|
|
13534
13618
|
if (tasks.length === 0) {
|
|
13535
|
-
output.log(
|
|
13619
|
+
output.log(chalk26.gray(" No matching tasks found."));
|
|
13536
13620
|
return;
|
|
13537
13621
|
}
|
|
13538
13622
|
for (const t of tasks) {
|
|
13539
|
-
const statusColor = t.status === "completed" ?
|
|
13540
|
-
const pid = t.parent_task_id ?
|
|
13623
|
+
const statusColor = t.status === "completed" ? chalk26.green : t.status === "active" ? chalk26.blue : t.status === "paused" ? chalk26.yellow : t.status === "cancelled" ? chalk26.strikethrough : t.status === "archived" ? chalk26.gray : chalk26.gray;
|
|
13624
|
+
const pid = t.parent_task_id ? chalk26.gray(` (#${t.parent_task_id})`) : "";
|
|
13541
13625
|
output.log(` #${t.id} ${statusColor("[" + t.status + "]")} ${t.title}${pid}`);
|
|
13542
13626
|
if (t.current_status) {
|
|
13543
|
-
output.log(` ${
|
|
13627
|
+
output.log(` ${chalk26.gray(t.current_status.slice(0, 80))}`);
|
|
13544
13628
|
}
|
|
13545
13629
|
}
|
|
13546
13630
|
if (total > tasks.length) {
|
|
13547
|
-
output.log(
|
|
13631
|
+
output.log(chalk26.gray(`
|
|
13548
13632
|
... and ${total - tasks.length} more. Use --offset and --limit to paginate.`));
|
|
13549
13633
|
}
|
|
13550
|
-
output.log(
|
|
13634
|
+
output.log(chalk26.gray(` Page: ${Math.floor((args.offset || 0) / (args.limit || 20)) + 1}/${Math.ceil(total / (args.limit || 20))}`));
|
|
13551
13635
|
}
|
|
13552
13636
|
} catch (error) {
|
|
13553
13637
|
output.error(`Failed to search tasks: ${error}`);
|
|
@@ -13807,7 +13891,7 @@ var TasksCommand = {
|
|
|
13807
13891
|
};
|
|
13808
13892
|
|
|
13809
13893
|
// src/commands/skills/list.ts
|
|
13810
|
-
import
|
|
13894
|
+
import chalk27 from "chalk";
|
|
13811
13895
|
var ListCommand3 = {
|
|
13812
13896
|
command: "list",
|
|
13813
13897
|
aliases: ["ls"],
|
|
@@ -13823,12 +13907,7 @@ var ListCommand3 = {
|
|
|
13823
13907
|
type: "boolean",
|
|
13824
13908
|
default: false,
|
|
13825
13909
|
description: "JSON 输出"
|
|
13826
|
-
}).option("quiet", {
|
|
13827
|
-
alias: "q",
|
|
13828
|
-
type: "boolean",
|
|
13829
|
-
default: false,
|
|
13830
|
-
description: "简洁输出"
|
|
13831
|
-
}),
|
|
13910
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
13832
13911
|
async handler(args) {
|
|
13833
13912
|
const a = args;
|
|
13834
13913
|
const output = new OutputService2;
|
|
@@ -13845,41 +13924,61 @@ var ListCommand3 = {
|
|
|
13845
13924
|
output.error("SkillComponent not available");
|
|
13846
13925
|
process.exit(1);
|
|
13847
13926
|
}
|
|
13848
|
-
const
|
|
13849
|
-
const filtered = a.source && a.source !== "all" ?
|
|
13927
|
+
const allSkills = skillComponent.getSkillList();
|
|
13928
|
+
const filtered = a.source && a.source !== "all" ? allSkills.filter((s) => s.source === a.source) : allSkills;
|
|
13929
|
+
const total = filtered.length;
|
|
13930
|
+
const page = {
|
|
13931
|
+
limit: a.limit ?? 20,
|
|
13932
|
+
offset: a.offset ?? 0
|
|
13933
|
+
};
|
|
13934
|
+
const skills = applyPagination(filtered, page);
|
|
13850
13935
|
if (a.json) {
|
|
13851
13936
|
output.json({
|
|
13852
|
-
|
|
13853
|
-
|
|
13937
|
+
total,
|
|
13938
|
+
count: skills.length,
|
|
13939
|
+
truncated: total > skills.length,
|
|
13940
|
+
limit: page.limit,
|
|
13941
|
+
offset: page.offset,
|
|
13942
|
+
source: a.source ?? "all",
|
|
13943
|
+
skills: skills.map((s) => ({
|
|
13854
13944
|
name: s.name,
|
|
13855
13945
|
description: s.description,
|
|
13856
13946
|
source: s.source
|
|
13857
13947
|
}))
|
|
13858
13948
|
});
|
|
13859
13949
|
} else if (a.quiet) {
|
|
13860
|
-
|
|
13950
|
+
output.log(renderQuietHeader(total, "skill"));
|
|
13951
|
+
skills.forEach((s) => output.log(renderQuietLine(s.name, s.name)));
|
|
13952
|
+
const hint = renderQuietPaginationHint({
|
|
13953
|
+
count: skills.length,
|
|
13954
|
+
total,
|
|
13955
|
+
offset: page.offset,
|
|
13956
|
+
limit: page.limit
|
|
13957
|
+
});
|
|
13958
|
+
if (hint)
|
|
13959
|
+
output.log(hint);
|
|
13861
13960
|
} else {
|
|
13862
13961
|
const header = [
|
|
13863
|
-
|
|
13864
|
-
|
|
13865
|
-
|
|
13962
|
+
chalk27.bold("Name"),
|
|
13963
|
+
chalk27.bold("Description"),
|
|
13964
|
+
chalk27.bold("Source")
|
|
13866
13965
|
].join(" | ");
|
|
13867
13966
|
const sourceColor = (source) => {
|
|
13868
13967
|
switch (source) {
|
|
13869
13968
|
case "project":
|
|
13870
|
-
return
|
|
13969
|
+
return chalk27.green;
|
|
13871
13970
|
case "user":
|
|
13872
|
-
return
|
|
13971
|
+
return chalk27.blue;
|
|
13873
13972
|
case "built-in":
|
|
13874
|
-
return
|
|
13973
|
+
return chalk27.gray;
|
|
13875
13974
|
default:
|
|
13876
|
-
return
|
|
13975
|
+
return chalk27.white;
|
|
13877
13976
|
}
|
|
13878
13977
|
};
|
|
13879
|
-
const rows =
|
|
13978
|
+
const rows = skills.map((s) => {
|
|
13880
13979
|
const desc2 = s.description.length > 50 ? s.description.slice(0, 47) + "..." : s.description;
|
|
13881
13980
|
return [
|
|
13882
|
-
|
|
13981
|
+
chalk27.cyan(s.name),
|
|
13883
13982
|
desc2,
|
|
13884
13983
|
sourceColor(s.source)(`[${s.source}]`)
|
|
13885
13984
|
].join(" | ");
|
|
@@ -13891,7 +13990,14 @@ var ListCommand3 = {
|
|
|
13891
13990
|
...rows.map((r) => `│${r}│`),
|
|
13892
13991
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
13893
13992
|
"",
|
|
13894
|
-
|
|
13993
|
+
renderPaginationFooter({
|
|
13994
|
+
total,
|
|
13995
|
+
count: skills.length,
|
|
13996
|
+
offset: page.offset,
|
|
13997
|
+
limit: page.limit,
|
|
13998
|
+
itemName: "skill",
|
|
13999
|
+
extras: a.source && a.source !== "all" ? [`source=${a.source}`] : []
|
|
14000
|
+
})
|
|
13895
14001
|
].join(`
|
|
13896
14002
|
`));
|
|
13897
14003
|
}
|
|
@@ -13905,7 +14011,7 @@ var ListCommand3 = {
|
|
|
13905
14011
|
};
|
|
13906
14012
|
|
|
13907
14013
|
// src/commands/skills/get.ts
|
|
13908
|
-
import
|
|
14014
|
+
import chalk28 from "chalk";
|
|
13909
14015
|
var GetCommand3 = {
|
|
13910
14016
|
command: "get <name>",
|
|
13911
14017
|
describe: "获取指定技能内容",
|
|
@@ -13949,13 +14055,13 @@ var GetCommand3 = {
|
|
|
13949
14055
|
content: skill.content
|
|
13950
14056
|
});
|
|
13951
14057
|
} else {
|
|
13952
|
-
output.log(
|
|
14058
|
+
output.log(chalk28.bold.cyan(`# ${skill.name}`));
|
|
13953
14059
|
output.log("");
|
|
13954
|
-
output.log(`${
|
|
13955
|
-
output.log(`${
|
|
13956
|
-
output.log(`${
|
|
14060
|
+
output.log(`${chalk28.gray("Description:")} ${skill.description}`);
|
|
14061
|
+
output.log(`${chalk28.gray("Source:")} ${skill.source}`);
|
|
14062
|
+
output.log(`${chalk28.gray("File:")} ${skill.filePath}`);
|
|
13957
14063
|
output.log("");
|
|
13958
|
-
output.log(
|
|
14064
|
+
output.log(chalk28.bold("--- Content ---"));
|
|
13959
14065
|
output.log("");
|
|
13960
14066
|
output.log(skill.content);
|
|
13961
14067
|
}
|
|
@@ -13969,7 +14075,7 @@ var GetCommand3 = {
|
|
|
13969
14075
|
};
|
|
13970
14076
|
|
|
13971
14077
|
// src/commands/skills/search.ts
|
|
13972
|
-
import
|
|
14078
|
+
import chalk29 from "chalk";
|
|
13973
14079
|
var SearchCommand2 = {
|
|
13974
14080
|
command: "search <term>",
|
|
13975
14081
|
aliases: ["find"],
|
|
@@ -14008,7 +14114,7 @@ var SearchCommand2 = {
|
|
|
14008
14114
|
const term = args.term.toLowerCase();
|
|
14009
14115
|
const results = allSkills.filter((s) => s.name.toLowerCase().includes(term) || s.description.toLowerCase().includes(term));
|
|
14010
14116
|
if (results.length === 0) {
|
|
14011
|
-
output.log(
|
|
14117
|
+
output.log(chalk29.yellow(`No skills found matching: ${args.term}`));
|
|
14012
14118
|
return;
|
|
14013
14119
|
}
|
|
14014
14120
|
if (args.json) {
|
|
@@ -14025,19 +14131,19 @@ var SearchCommand2 = {
|
|
|
14025
14131
|
} else if (args.quiet) {
|
|
14026
14132
|
results.forEach((s) => output.log(s.name));
|
|
14027
14133
|
} else {
|
|
14028
|
-
output.log(
|
|
14134
|
+
output.log(chalk29.bold(`Search results for "${args.term}":`));
|
|
14029
14135
|
output.log("");
|
|
14030
14136
|
const header = [
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
|
|
14137
|
+
chalk29.bold("Name"),
|
|
14138
|
+
chalk29.bold("Description"),
|
|
14139
|
+
chalk29.bold("Match")
|
|
14034
14140
|
].join(" | ");
|
|
14035
14141
|
const rows = results.map((s) => {
|
|
14036
14142
|
const matchedIn = s.name.toLowerCase().includes(term) ? "name" : "description";
|
|
14037
|
-
const matchColor = matchedIn === "name" ?
|
|
14143
|
+
const matchColor = matchedIn === "name" ? chalk29.green : chalk29.blue;
|
|
14038
14144
|
const desc2 = s.description.length > 40 ? s.description.slice(0, 37) + "..." : s.description;
|
|
14039
14145
|
return [
|
|
14040
|
-
|
|
14146
|
+
chalk29.cyan(s.name),
|
|
14041
14147
|
desc2,
|
|
14042
14148
|
matchColor(`[${matchedIn}]`)
|
|
14043
14149
|
].join(" | ");
|
|
@@ -14049,7 +14155,7 @@ var SearchCommand2 = {
|
|
|
14049
14155
|
...rows.map((r) => `│${r}│`),
|
|
14050
14156
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
14051
14157
|
"",
|
|
14052
|
-
|
|
14158
|
+
chalk29.gray(`${results.length} matching skill(s) found.`)
|
|
14053
14159
|
].join(`
|
|
14054
14160
|
`));
|
|
14055
14161
|
}
|
|
@@ -14063,7 +14169,7 @@ var SearchCommand2 = {
|
|
|
14063
14169
|
};
|
|
14064
14170
|
|
|
14065
14171
|
// src/commands/skills/reload.ts
|
|
14066
|
-
import
|
|
14172
|
+
import chalk30 from "chalk";
|
|
14067
14173
|
var ReloadCommand = {
|
|
14068
14174
|
command: "reload",
|
|
14069
14175
|
describe: "重新扫描并更新 SkillTool",
|
|
@@ -14086,10 +14192,10 @@ var ReloadCommand = {
|
|
|
14086
14192
|
output.error("SkillComponent not available");
|
|
14087
14193
|
process.exit(1);
|
|
14088
14194
|
}
|
|
14089
|
-
output.log(
|
|
14195
|
+
output.log(chalk30.blue("Reloading skills..."));
|
|
14090
14196
|
await skillComponent.reload();
|
|
14091
14197
|
const skills = skillComponent.getSkillList();
|
|
14092
|
-
output.log(
|
|
14198
|
+
output.log(chalk30.green(`Successfully reloaded ${skills.length} skills`));
|
|
14093
14199
|
} catch (error) {
|
|
14094
14200
|
output.error(`Failed to reload skills: ${error}`);
|
|
14095
14201
|
process.exit(1);
|
|
@@ -14100,7 +14206,7 @@ var ReloadCommand = {
|
|
|
14100
14206
|
};
|
|
14101
14207
|
|
|
14102
14208
|
// src/commands/skills/show-config.ts
|
|
14103
|
-
import
|
|
14209
|
+
import chalk31 from "chalk";
|
|
14104
14210
|
var ShowConfigCommand = {
|
|
14105
14211
|
command: "show-config",
|
|
14106
14212
|
aliases: ["config"],
|
|
@@ -14125,38 +14231,38 @@ var ShowConfigCommand = {
|
|
|
14125
14231
|
process.exit(1);
|
|
14126
14232
|
}
|
|
14127
14233
|
const defaultConfig = skillComponent.getConfig?.();
|
|
14128
|
-
output.log(
|
|
14234
|
+
output.log(chalk31.bold.cyan(`# Skills Configuration
|
|
14129
14235
|
`));
|
|
14130
|
-
output.log(
|
|
14236
|
+
output.log(chalk31.bold(`## Scan Paths
|
|
14131
14237
|
`));
|
|
14132
14238
|
const paths = [
|
|
14133
14239
|
{ type: "user", desc: "用户路径", path: "~/.config/roy-agent/skills/" },
|
|
14134
14240
|
{ type: "project", desc: "项目路径", path: ".roy/skills/" }
|
|
14135
14241
|
];
|
|
14136
14242
|
for (const p of paths) {
|
|
14137
|
-
const typeColor = p.type === "project" ?
|
|
14138
|
-
output.log(` ${typeColor("[ " + p.type + " ]")} ${
|
|
14139
|
-
output.log(` ${
|
|
14243
|
+
const typeColor = p.type === "project" ? chalk31.green : chalk31.blue;
|
|
14244
|
+
output.log(` ${typeColor("[ " + p.type + " ]")} ${chalk31.gray(p.desc)}`);
|
|
14245
|
+
output.log(` ${chalk31.cyan(p.path)}
|
|
14140
14246
|
`);
|
|
14141
14247
|
}
|
|
14142
|
-
output.log(
|
|
14248
|
+
output.log(chalk31.bold(`## Scan Rules
|
|
14143
14249
|
`));
|
|
14144
|
-
output.log(` ${
|
|
14145
|
-
output.log(` ${
|
|
14146
|
-
output.log(` ${
|
|
14250
|
+
output.log(` ${chalk31.gray("Pattern:")} ${chalk31.cyan("**/SKILL.md")}`);
|
|
14251
|
+
output.log(` ${chalk31.gray("Recursive:")} ${chalk31.green("true")}`);
|
|
14252
|
+
output.log(` ${chalk31.gray("Ignore:")} ${chalk31.cyan("**/node_modules/**")}
|
|
14147
14253
|
`);
|
|
14148
|
-
output.log(
|
|
14254
|
+
output.log(chalk31.bold(`## Priority (High to Low)
|
|
14149
14255
|
`));
|
|
14150
|
-
output.log(` ${
|
|
14151
|
-
output.log(` ${
|
|
14152
|
-
output.log(` ${
|
|
14256
|
+
output.log(` ${chalk31.green("1. project")} - 项目路径(最高优先级)`);
|
|
14257
|
+
output.log(` ${chalk31.blue("2. user")} - 用户路径`);
|
|
14258
|
+
output.log(` ${chalk31.gray("3. built-in")} - 内置路径(预留)
|
|
14153
14259
|
`);
|
|
14154
|
-
output.log(
|
|
14260
|
+
output.log(chalk31.bold(`## Usage
|
|
14155
14261
|
`));
|
|
14156
|
-
output.log(` ${
|
|
14157
|
-
output.log(` ${
|
|
14158
|
-
output.log(` ${
|
|
14159
|
-
output.log(` ${
|
|
14262
|
+
output.log(` ${chalk31.cyan("roy-agent skills list")} ${chalk31.gray("- 列出所有技能")}`);
|
|
14263
|
+
output.log(` ${chalk31.cyan("roy-agent skills get <name>")} ${chalk31.gray("- 获取技能内容")}`);
|
|
14264
|
+
output.log(` ${chalk31.cyan("roy-agent skills search <term>")} ${chalk31.gray("- 搜索技能")}`);
|
|
14265
|
+
output.log(` ${chalk31.cyan("roy-agent skills reload")} ${chalk31.gray("- 重新扫描技能")}`);
|
|
14160
14266
|
} catch (error) {
|
|
14161
14267
|
output.error(`Failed to show config: ${error}`);
|
|
14162
14268
|
process.exit(1);
|
|
@@ -14177,7 +14283,7 @@ var SkillsCommand = {
|
|
|
14177
14283
|
};
|
|
14178
14284
|
|
|
14179
14285
|
// src/commands/agents/list.ts
|
|
14180
|
-
import
|
|
14286
|
+
import chalk32 from "chalk";
|
|
14181
14287
|
var ListCommand4 = {
|
|
14182
14288
|
command: "list",
|
|
14183
14289
|
aliases: ["ls"],
|
|
@@ -14193,12 +14299,7 @@ var ListCommand4 = {
|
|
|
14193
14299
|
type: "boolean",
|
|
14194
14300
|
default: false,
|
|
14195
14301
|
description: "JSON 输出"
|
|
14196
|
-
}).option("quiet", {
|
|
14197
|
-
alias: "q",
|
|
14198
|
-
type: "boolean",
|
|
14199
|
-
default: false,
|
|
14200
|
-
description: "简洁输出"
|
|
14201
|
-
}),
|
|
14302
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
14202
14303
|
async handler(args) {
|
|
14203
14304
|
const output = new OutputService2;
|
|
14204
14305
|
const envService = new EnvironmentService(output);
|
|
@@ -14230,10 +14331,21 @@ var ListCommand4 = {
|
|
|
14230
14331
|
} else {
|
|
14231
14332
|
agents = registry.list();
|
|
14232
14333
|
}
|
|
14334
|
+
const total = agents.length;
|
|
14335
|
+
const page = {
|
|
14336
|
+
limit: args.limit ?? 20,
|
|
14337
|
+
offset: args.offset ?? 0
|
|
14338
|
+
};
|
|
14339
|
+
const pagedAgents = applyPagination(agents, page);
|
|
14233
14340
|
if (args.json) {
|
|
14234
14341
|
output.json({
|
|
14235
|
-
|
|
14236
|
-
|
|
14342
|
+
total,
|
|
14343
|
+
count: pagedAgents.length,
|
|
14344
|
+
truncated: total > pagedAgents.length,
|
|
14345
|
+
limit: page.limit,
|
|
14346
|
+
offset: page.offset,
|
|
14347
|
+
type: args.type ?? "all",
|
|
14348
|
+
agents: pagedAgents.map((a) => ({
|
|
14237
14349
|
name: a.name,
|
|
14238
14350
|
type: a.type,
|
|
14239
14351
|
source: builtInSubAgentNames.has(a.name) ? "built-in" : "user",
|
|
@@ -14245,30 +14357,39 @@ var ListCommand4 = {
|
|
|
14245
14357
|
}))
|
|
14246
14358
|
});
|
|
14247
14359
|
} else if (args.quiet) {
|
|
14248
|
-
|
|
14360
|
+
output.log(renderQuietHeader(total, "agent"));
|
|
14361
|
+
pagedAgents.forEach((a) => output.log(renderQuietLine(a.name, a.name)));
|
|
14362
|
+
const hint = renderQuietPaginationHint({
|
|
14363
|
+
count: pagedAgents.length,
|
|
14364
|
+
total,
|
|
14365
|
+
offset: page.offset,
|
|
14366
|
+
limit: page.limit
|
|
14367
|
+
});
|
|
14368
|
+
if (hint)
|
|
14369
|
+
output.log(hint);
|
|
14249
14370
|
} else {
|
|
14250
14371
|
const header = [
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14372
|
+
chalk32.bold("Name"),
|
|
14373
|
+
chalk32.bold("Type"),
|
|
14374
|
+
chalk32.bold("Source"),
|
|
14375
|
+
chalk32.bold("Model"),
|
|
14376
|
+
chalk32.bold("Workflow"),
|
|
14377
|
+
chalk32.bold("Description")
|
|
14257
14378
|
].join(" | ");
|
|
14258
14379
|
const typeColor = (type) => {
|
|
14259
14380
|
if (type === "primary")
|
|
14260
|
-
return
|
|
14381
|
+
return chalk32.yellow;
|
|
14261
14382
|
if (type === "workflow")
|
|
14262
|
-
return
|
|
14263
|
-
return
|
|
14383
|
+
return chalk32.magenta;
|
|
14384
|
+
return chalk32.blue;
|
|
14264
14385
|
};
|
|
14265
|
-
const rows =
|
|
14386
|
+
const rows = pagedAgents.map((a) => {
|
|
14266
14387
|
const desc2 = (a.description || "").length > 40 ? (a.description || "").slice(0, 37) + "..." : a.description || "-";
|
|
14267
|
-
const workflowDisplay = a.type === "workflow" && a.workflow ?
|
|
14268
|
-
const modelDisplay = a.model ?
|
|
14269
|
-
const sourceDisplay = builtInSubAgentNames.has(a.name) ?
|
|
14388
|
+
const workflowDisplay = a.type === "workflow" && a.workflow ? chalk32.cyan(a.workflow.length > 30 ? a.workflow.slice(0, 27) + "..." : a.workflow) : chalk32.gray("-");
|
|
14389
|
+
const modelDisplay = a.model ? chalk32.yellow(a.model.length > 20 ? a.model.slice(0, 17) + "..." : a.model) : chalk32.gray("-");
|
|
14390
|
+
const sourceDisplay = builtInSubAgentNames.has(a.name) ? chalk32.green("built-in") : chalk32.gray("user");
|
|
14270
14391
|
return [
|
|
14271
|
-
|
|
14392
|
+
chalk32.cyan(a.name),
|
|
14272
14393
|
typeColor(a.type)(a.type),
|
|
14273
14394
|
sourceDisplay,
|
|
14274
14395
|
modelDisplay,
|
|
@@ -14277,9 +14398,9 @@ var ListCommand4 = {
|
|
|
14277
14398
|
].join(" | ");
|
|
14278
14399
|
});
|
|
14279
14400
|
if (rows.length === 0) {
|
|
14280
|
-
output.log(
|
|
14401
|
+
output.log(chalk32.yellow("No agents found."));
|
|
14281
14402
|
output.log("");
|
|
14282
|
-
output.log(
|
|
14403
|
+
output.log(chalk32.gray("Tip: Create agent configs in ~/.local/share/roy-agent/agents/"));
|
|
14283
14404
|
} else {
|
|
14284
14405
|
output.log([
|
|
14285
14406
|
`┌─ Agents ${"─".repeat(50)}┐`,
|
|
@@ -14288,7 +14409,14 @@ var ListCommand4 = {
|
|
|
14288
14409
|
...rows.map((r) => `│${r}│`),
|
|
14289
14410
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
14290
14411
|
"",
|
|
14291
|
-
|
|
14412
|
+
renderPaginationFooter({
|
|
14413
|
+
total,
|
|
14414
|
+
count: pagedAgents.length,
|
|
14415
|
+
offset: page.offset,
|
|
14416
|
+
limit: page.limit,
|
|
14417
|
+
itemName: "agent",
|
|
14418
|
+
extras: args.type && args.type !== "all" ? [`type=${args.type}`] : []
|
|
14419
|
+
})
|
|
14292
14420
|
].join(`
|
|
14293
14421
|
`));
|
|
14294
14422
|
}
|
|
@@ -14303,7 +14431,7 @@ var ListCommand4 = {
|
|
|
14303
14431
|
};
|
|
14304
14432
|
|
|
14305
14433
|
// src/commands/agents/get.ts
|
|
14306
|
-
import
|
|
14434
|
+
import chalk33 from "chalk";
|
|
14307
14435
|
var GetCommand4 = {
|
|
14308
14436
|
command: "get <name>",
|
|
14309
14437
|
describe: "获取指定 agent 的详细信息",
|
|
@@ -14362,69 +14490,69 @@ var GetCommand4 = {
|
|
|
14362
14490
|
filterHistory: agent.filterHistory
|
|
14363
14491
|
});
|
|
14364
14492
|
} else {
|
|
14365
|
-
output.log(
|
|
14493
|
+
output.log(chalk33.bold.cyan(`# Agent: ${agent.name}`));
|
|
14366
14494
|
output.log("");
|
|
14367
|
-
output.log(
|
|
14368
|
-
output.log(` ${
|
|
14369
|
-
output.log(` ${
|
|
14495
|
+
output.log(chalk33.bold("Basic Info:"));
|
|
14496
|
+
output.log(` ${chalk33.cyan("name:")} ${agent.name}`);
|
|
14497
|
+
output.log(` ${chalk33.cyan("type:")} ${agent.type}`);
|
|
14370
14498
|
if (agent.description) {
|
|
14371
|
-
output.log(` ${
|
|
14499
|
+
output.log(` ${chalk33.cyan("description:")} ${agent.description}`);
|
|
14372
14500
|
}
|
|
14373
14501
|
output.log("");
|
|
14374
14502
|
if (agent.type === "workflow") {
|
|
14375
|
-
output.log(
|
|
14503
|
+
output.log(chalk33.bold("Workflow:"));
|
|
14376
14504
|
if (agent.workflow) {
|
|
14377
|
-
output.log(` ${
|
|
14378
|
-
output.log(` ${
|
|
14505
|
+
output.log(` ${chalk33.cyan("workflow:")} ${agent.workflow}`);
|
|
14506
|
+
output.log(` ${chalk33.gray("→")} ${chalk33.gray(`roy-agent workflow run ${agent.workflow} --input '{"query":"..."}'`)}`);
|
|
14379
14507
|
} else {
|
|
14380
|
-
output.log(` ${
|
|
14508
|
+
output.log(` ${chalk33.gray("(no workflow configured)")}`);
|
|
14381
14509
|
}
|
|
14382
14510
|
output.log("");
|
|
14383
14511
|
}
|
|
14384
|
-
output.log(
|
|
14512
|
+
output.log(chalk33.bold("System Prompt:"));
|
|
14385
14513
|
if (agent.systemPromptRef) {
|
|
14386
|
-
output.log(` ${
|
|
14514
|
+
output.log(` ${chalk33.green("[ref]")} ${chalk33.cyan("systemPromptRef:")} ${agent.systemPromptRef}`);
|
|
14387
14515
|
}
|
|
14388
14516
|
if (agent.systemPrompt && !agent.systemPromptRef) {
|
|
14389
14517
|
const promptPreview = agent.systemPrompt.length > 100 ? agent.systemPrompt.slice(0, 97) + "..." : agent.systemPrompt;
|
|
14390
|
-
output.log(` ${
|
|
14391
|
-
output.log(` ${
|
|
14518
|
+
output.log(` ${chalk33.gray("[inline]")}`);
|
|
14519
|
+
output.log(` ${chalk33.gray(promptPreview.split(`
|
|
14392
14520
|
`).join(`
|
|
14393
14521
|
`))}`);
|
|
14394
14522
|
}
|
|
14395
14523
|
if (resolvedSystemPrompt) {
|
|
14396
14524
|
const resolvedPreview = resolvedSystemPrompt.length > 200 ? resolvedSystemPrompt.slice(0, 197) + "..." : resolvedSystemPrompt;
|
|
14397
|
-
output.log(` ${
|
|
14398
|
-
output.log(` ${
|
|
14525
|
+
output.log(` ${chalk33.green("[resolved]")}`);
|
|
14526
|
+
output.log(` ${chalk33.gray(resolvedPreview.split(`
|
|
14399
14527
|
`).join(`
|
|
14400
14528
|
`))}`);
|
|
14401
14529
|
}
|
|
14402
14530
|
if (!agent.systemPromptRef && !agent.systemPrompt && !resolvedSystemPrompt) {
|
|
14403
|
-
output.log(` ${
|
|
14531
|
+
output.log(` ${chalk33.gray("(none)")}`);
|
|
14404
14532
|
}
|
|
14405
14533
|
output.log("");
|
|
14406
14534
|
const hasOptions = agent.model || agent.maxIterations || agent.toolTimeout;
|
|
14407
14535
|
if (hasOptions) {
|
|
14408
|
-
output.log(
|
|
14536
|
+
output.log(chalk33.bold("Options:"));
|
|
14409
14537
|
if (agent.model) {
|
|
14410
|
-
output.log(` ${
|
|
14538
|
+
output.log(` ${chalk33.cyan("model:")} ${agent.model}`);
|
|
14411
14539
|
}
|
|
14412
14540
|
if (agent.maxIterations) {
|
|
14413
|
-
output.log(` ${
|
|
14541
|
+
output.log(` ${chalk33.cyan("maxIterations:")} ${agent.maxIterations}`);
|
|
14414
14542
|
}
|
|
14415
14543
|
if (agent.toolTimeout) {
|
|
14416
|
-
output.log(` ${
|
|
14544
|
+
output.log(` ${chalk33.cyan("toolTimeout:")} ${agent.toolTimeout}ms`);
|
|
14417
14545
|
}
|
|
14418
14546
|
output.log("");
|
|
14419
14547
|
}
|
|
14420
14548
|
const hasTools = agent.allowedTools?.length || agent.deniedTools?.length;
|
|
14421
14549
|
if (hasTools) {
|
|
14422
|
-
output.log(
|
|
14550
|
+
output.log(chalk33.bold("Tool Permissions:"));
|
|
14423
14551
|
if (agent.allowedTools?.length) {
|
|
14424
|
-
output.log(` ${
|
|
14552
|
+
output.log(` ${chalk33.green("allowed:")} ${agent.allowedTools.join(", ")}`);
|
|
14425
14553
|
}
|
|
14426
14554
|
if (agent.deniedTools?.length) {
|
|
14427
|
-
output.log(` ${
|
|
14555
|
+
output.log(` ${chalk33.red("denied:")} ${agent.deniedTools.join(", ")}`);
|
|
14428
14556
|
}
|
|
14429
14557
|
output.log("");
|
|
14430
14558
|
}
|
|
@@ -14439,7 +14567,7 @@ var GetCommand4 = {
|
|
|
14439
14567
|
};
|
|
14440
14568
|
|
|
14441
14569
|
// src/commands/agents/add.ts
|
|
14442
|
-
import
|
|
14570
|
+
import chalk34 from "chalk";
|
|
14443
14571
|
function parseToolList(value) {
|
|
14444
14572
|
if (!value?.trim()) {
|
|
14445
14573
|
return;
|
|
@@ -14531,8 +14659,8 @@ var AddCommand = {
|
|
|
14531
14659
|
if (args.json) {
|
|
14532
14660
|
output.json({ agent, filePath });
|
|
14533
14661
|
} else {
|
|
14534
|
-
output.log(
|
|
14535
|
-
output.log(
|
|
14662
|
+
output.log(chalk34.green(`✓ Agent '${args.name}' created`));
|
|
14663
|
+
output.log(chalk34.gray(` ${filePath}`));
|
|
14536
14664
|
}
|
|
14537
14665
|
} catch (error) {
|
|
14538
14666
|
output.error(`Failed to add agent: ${error}`);
|
|
@@ -14544,7 +14672,7 @@ var AddCommand = {
|
|
|
14544
14672
|
};
|
|
14545
14673
|
|
|
14546
14674
|
// src/commands/agents/delete.ts
|
|
14547
|
-
import
|
|
14675
|
+
import chalk35 from "chalk";
|
|
14548
14676
|
var DeleteCommand3 = {
|
|
14549
14677
|
command: "delete <name>",
|
|
14550
14678
|
describe: "删除 agent 配置文件",
|
|
@@ -14586,7 +14714,7 @@ var DeleteCommand3 = {
|
|
|
14586
14714
|
}
|
|
14587
14715
|
const filePath = registry.getAgentFilePath(args.name);
|
|
14588
14716
|
if (!args.yes) {
|
|
14589
|
-
output.log(
|
|
14717
|
+
output.log(chalk35.yellow(`Delete agent '${args.name}'? This removes ${filePath} (use --yes to skip confirmation)`));
|
|
14590
14718
|
process.exit(1);
|
|
14591
14719
|
}
|
|
14592
14720
|
const deleted = await registry.deleteAgent(args.name);
|
|
@@ -14597,7 +14725,7 @@ var DeleteCommand3 = {
|
|
|
14597
14725
|
if (args.json) {
|
|
14598
14726
|
output.json({ deleted: true, name: args.name, filePath });
|
|
14599
14727
|
} else {
|
|
14600
|
-
output.log(
|
|
14728
|
+
output.log(chalk35.green(`✓ Agent '${args.name}' deleted`));
|
|
14601
14729
|
}
|
|
14602
14730
|
} catch (error) {
|
|
14603
14731
|
output.error(`Failed to delete agent: ${error}`);
|
|
@@ -14609,7 +14737,7 @@ var DeleteCommand3 = {
|
|
|
14609
14737
|
};
|
|
14610
14738
|
|
|
14611
14739
|
// src/commands/agents/config-dir.ts
|
|
14612
|
-
import
|
|
14740
|
+
import chalk36 from "chalk";
|
|
14613
14741
|
var ConfigDirCommand = {
|
|
14614
14742
|
command: "config-dir",
|
|
14615
14743
|
describe: "显示 agent 配置目录路径",
|
|
@@ -14640,8 +14768,8 @@ var ConfigDirCommand = {
|
|
|
14640
14768
|
if (args.json) {
|
|
14641
14769
|
output.json({ configDir, exists });
|
|
14642
14770
|
} else {
|
|
14643
|
-
output.log(`${
|
|
14644
|
-
output.log(`${
|
|
14771
|
+
output.log(`${chalk36.cyan("Agent Config Directory:")} ${configDir}`);
|
|
14772
|
+
output.log(`${chalk36.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
14645
14773
|
}
|
|
14646
14774
|
} catch (error) {
|
|
14647
14775
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -14664,7 +14792,7 @@ var AgentsCommand = {
|
|
|
14664
14792
|
};
|
|
14665
14793
|
|
|
14666
14794
|
// src/commands/prompt/list.ts
|
|
14667
|
-
import
|
|
14795
|
+
import chalk37 from "chalk";
|
|
14668
14796
|
var ListCommand5 = {
|
|
14669
14797
|
command: "list",
|
|
14670
14798
|
aliases: ["ls"],
|
|
@@ -14680,12 +14808,7 @@ var ListCommand5 = {
|
|
|
14680
14808
|
type: "boolean",
|
|
14681
14809
|
default: false,
|
|
14682
14810
|
description: "JSON 输出"
|
|
14683
|
-
}).option("quiet", {
|
|
14684
|
-
alias: "q",
|
|
14685
|
-
type: "boolean",
|
|
14686
|
-
default: false,
|
|
14687
|
-
description: "简洁输出"
|
|
14688
|
-
}),
|
|
14811
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
14689
14812
|
async handler(args) {
|
|
14690
14813
|
const output = new OutputService2;
|
|
14691
14814
|
const envService = new EnvironmentService(output);
|
|
@@ -14701,36 +14824,54 @@ var ListCommand5 = {
|
|
|
14701
14824
|
output.error("PromptComponent not available");
|
|
14702
14825
|
process.exit(1);
|
|
14703
14826
|
}
|
|
14704
|
-
|
|
14827
|
+
const allPrompts = promptComponent.listEntries().map((entry) => ({
|
|
14705
14828
|
name: entry.name,
|
|
14706
14829
|
source: entry.source
|
|
14707
14830
|
}));
|
|
14708
|
-
|
|
14709
|
-
|
|
14710
|
-
|
|
14831
|
+
const filtered = args.source && args.source !== "all" ? allPrompts.filter((p) => p.source === args.source) : allPrompts;
|
|
14832
|
+
const total = filtered.length;
|
|
14833
|
+
const page = {
|
|
14834
|
+
limit: args.limit ?? 20,
|
|
14835
|
+
offset: args.offset ?? 0
|
|
14836
|
+
};
|
|
14837
|
+
const prompts = applyPagination(filtered, page);
|
|
14711
14838
|
if (args.json) {
|
|
14712
14839
|
output.json({
|
|
14840
|
+
total,
|
|
14841
|
+
count: prompts.length,
|
|
14842
|
+
truncated: total > prompts.length,
|
|
14843
|
+
limit: page.limit,
|
|
14844
|
+
offset: page.offset,
|
|
14845
|
+
source: args.source ?? "all",
|
|
14713
14846
|
prompts: prompts.map((p) => ({
|
|
14714
14847
|
name: p.name,
|
|
14715
14848
|
source: p.source
|
|
14716
|
-
}))
|
|
14717
|
-
count: prompts.length
|
|
14849
|
+
}))
|
|
14718
14850
|
});
|
|
14719
14851
|
} else if (args.quiet) {
|
|
14720
|
-
|
|
14852
|
+
output.log(renderQuietHeader(total, "prompt"));
|
|
14853
|
+
prompts.forEach((p) => output.log(renderQuietLine(p.name, p.name)));
|
|
14854
|
+
const hint = renderQuietPaginationHint({
|
|
14855
|
+
count: prompts.length,
|
|
14856
|
+
total,
|
|
14857
|
+
offset: page.offset,
|
|
14858
|
+
limit: page.limit
|
|
14859
|
+
});
|
|
14860
|
+
if (hint)
|
|
14861
|
+
output.log(hint);
|
|
14721
14862
|
} else {
|
|
14722
14863
|
const header = [
|
|
14723
|
-
|
|
14724
|
-
|
|
14864
|
+
chalk37.bold("Name"),
|
|
14865
|
+
chalk37.bold("Source")
|
|
14725
14866
|
].join(" | ");
|
|
14726
14867
|
const rows = prompts.map((p) => {
|
|
14727
14868
|
return [
|
|
14728
|
-
|
|
14729
|
-
|
|
14869
|
+
chalk37.cyan(p.name),
|
|
14870
|
+
chalk37.gray(`[${p.source}]`)
|
|
14730
14871
|
].join(" | ");
|
|
14731
14872
|
});
|
|
14732
14873
|
if (rows.length === 0) {
|
|
14733
|
-
output.log(
|
|
14874
|
+
output.log(chalk37.yellow("No prompts found."));
|
|
14734
14875
|
} else {
|
|
14735
14876
|
output.log([
|
|
14736
14877
|
`┌─ Prompts ${"─".repeat(50)}┐`,
|
|
@@ -14739,7 +14880,14 @@ var ListCommand5 = {
|
|
|
14739
14880
|
...rows.map((r) => `│${r}│`),
|
|
14740
14881
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
14741
14882
|
"",
|
|
14742
|
-
|
|
14883
|
+
renderPaginationFooter({
|
|
14884
|
+
total,
|
|
14885
|
+
count: prompts.length,
|
|
14886
|
+
offset: page.offset,
|
|
14887
|
+
limit: page.limit,
|
|
14888
|
+
itemName: "prompt",
|
|
14889
|
+
extras: args.source && args.source !== "all" ? [`source=${args.source}`] : []
|
|
14890
|
+
})
|
|
14743
14891
|
].join(`
|
|
14744
14892
|
`));
|
|
14745
14893
|
}
|
|
@@ -14754,7 +14902,7 @@ var ListCommand5 = {
|
|
|
14754
14902
|
};
|
|
14755
14903
|
|
|
14756
14904
|
// src/commands/prompt/get.ts
|
|
14757
|
-
import
|
|
14905
|
+
import chalk38 from "chalk";
|
|
14758
14906
|
var GetCommand5 = {
|
|
14759
14907
|
command: "get <name>",
|
|
14760
14908
|
describe: "获取指定 prompt 的内容",
|
|
@@ -14801,16 +14949,16 @@ var GetCommand5 = {
|
|
|
14801
14949
|
variables: vars
|
|
14802
14950
|
});
|
|
14803
14951
|
} else {
|
|
14804
|
-
output.log(
|
|
14952
|
+
output.log(chalk38.bold.cyan(`# Prompt: ${args.name}`));
|
|
14805
14953
|
output.log("");
|
|
14806
14954
|
if (Object.keys(vars).length > 0) {
|
|
14807
|
-
output.log(
|
|
14955
|
+
output.log(chalk38.gray("Variables:"));
|
|
14808
14956
|
for (const [key, value] of Object.entries(vars)) {
|
|
14809
|
-
output.log(` ${
|
|
14957
|
+
output.log(` ${chalk38.cyan(key + ":")} ${value}`);
|
|
14810
14958
|
}
|
|
14811
14959
|
output.log("");
|
|
14812
14960
|
}
|
|
14813
|
-
output.log(
|
|
14961
|
+
output.log(chalk38.bold("Content:"));
|
|
14814
14962
|
output.log("─".repeat(60));
|
|
14815
14963
|
output.log(prompt);
|
|
14816
14964
|
output.log("─".repeat(60));
|
|
@@ -14840,7 +14988,7 @@ function parseVars(vars) {
|
|
|
14840
14988
|
|
|
14841
14989
|
// src/commands/prompt/add.ts
|
|
14842
14990
|
import { readFile as readFile2 } from "fs/promises";
|
|
14843
|
-
import
|
|
14991
|
+
import chalk39 from "chalk";
|
|
14844
14992
|
var AddCommand2 = {
|
|
14845
14993
|
command: "add <name>",
|
|
14846
14994
|
describe: "添加 prompt 并持久化到 ~/.local/share/roy-agent/prompts/",
|
|
@@ -14891,8 +15039,8 @@ var AddCommand2 = {
|
|
|
14891
15039
|
length: content.trim().length
|
|
14892
15040
|
});
|
|
14893
15041
|
} else {
|
|
14894
|
-
output.log(
|
|
14895
|
-
output.log(
|
|
15042
|
+
output.log(chalk39.green(`✓ Prompt '${args.name}' saved`));
|
|
15043
|
+
output.log(chalk39.gray(` ${filePath}`));
|
|
14896
15044
|
}
|
|
14897
15045
|
} catch (error) {
|
|
14898
15046
|
output.error(`Failed to add prompt: ${error}`);
|
|
@@ -14904,7 +15052,7 @@ var AddCommand2 = {
|
|
|
14904
15052
|
};
|
|
14905
15053
|
|
|
14906
15054
|
// src/commands/prompt/config-dir.ts
|
|
14907
|
-
import
|
|
15055
|
+
import chalk40 from "chalk";
|
|
14908
15056
|
var ConfigDirCommand2 = {
|
|
14909
15057
|
command: "config-dir",
|
|
14910
15058
|
describe: "显示 prompt 持久化目录路径",
|
|
@@ -14934,8 +15082,8 @@ var ConfigDirCommand2 = {
|
|
|
14934
15082
|
if (args.json) {
|
|
14935
15083
|
output.json({ configDir, exists });
|
|
14936
15084
|
} else {
|
|
14937
|
-
output.log(`${
|
|
14938
|
-
output.log(`${
|
|
15085
|
+
output.log(`${chalk40.cyan("Prompt Config Directory:")} ${configDir}`);
|
|
15086
|
+
output.log(`${chalk40.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
14939
15087
|
}
|
|
14940
15088
|
} catch (error) {
|
|
14941
15089
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -14957,7 +15105,7 @@ var PromptCommand = {
|
|
|
14957
15105
|
};
|
|
14958
15106
|
|
|
14959
15107
|
// src/commands/commands-list.ts
|
|
14960
|
-
import
|
|
15108
|
+
import chalk41 from "chalk";
|
|
14961
15109
|
function truncateVisual(str, maxWidth) {
|
|
14962
15110
|
let result = "";
|
|
14963
15111
|
let width = 0;
|
|
@@ -14972,16 +15120,16 @@ function truncateVisual(str, maxWidth) {
|
|
|
14972
15120
|
}
|
|
14973
15121
|
function formatCommandsTable(commands) {
|
|
14974
15122
|
if (commands.length === 0) {
|
|
14975
|
-
return
|
|
15123
|
+
return chalk41.yellow("命令目录为空,使用 'roy-agent commands add' 添加命令");
|
|
14976
15124
|
}
|
|
14977
15125
|
const NAME_WIDTH = 20;
|
|
14978
15126
|
const SOURCE_WIDTH = 10;
|
|
14979
15127
|
const DESC_WIDTH = 50;
|
|
14980
15128
|
const GAP = " ";
|
|
14981
15129
|
const headerLine = [
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
15130
|
+
chalk41.bold("NAME".padEnd(NAME_WIDTH)),
|
|
15131
|
+
chalk41.bold("SOURCE".padEnd(SOURCE_WIDTH)),
|
|
15132
|
+
chalk41.bold("DESCRIPTION")
|
|
14985
15133
|
].join(GAP);
|
|
14986
15134
|
const sepLine = "─".repeat(NAME_WIDTH + SOURCE_WIDTH + DESC_WIDTH + GAP.length * 2);
|
|
14987
15135
|
const formatRow = (cmd) => {
|
|
@@ -15005,7 +15153,7 @@ var CommandsListCommand = {
|
|
|
15005
15153
|
describe: "JSON 格式输出",
|
|
15006
15154
|
type: "boolean",
|
|
15007
15155
|
default: false
|
|
15008
|
-
}).option("config", {
|
|
15156
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }).option("config", {
|
|
15009
15157
|
describe: "配置文件路径",
|
|
15010
15158
|
type: "string"
|
|
15011
15159
|
}),
|
|
@@ -15025,18 +15173,41 @@ var CommandsListCommand = {
|
|
|
15025
15173
|
process.exit(1);
|
|
15026
15174
|
}
|
|
15027
15175
|
const result = await commandsComponent.discover({ pattern: args.pattern });
|
|
15176
|
+
const total = result.commands.length;
|
|
15177
|
+
const page = {
|
|
15178
|
+
limit: args.limit ?? 20,
|
|
15179
|
+
offset: args.offset ?? 0
|
|
15180
|
+
};
|
|
15181
|
+
const commands = applyPagination(result.commands, page);
|
|
15028
15182
|
if (args.json) {
|
|
15029
15183
|
output.json({
|
|
15030
|
-
|
|
15184
|
+
total,
|
|
15185
|
+
count: commands.length,
|
|
15186
|
+
truncated: total > commands.length,
|
|
15187
|
+
limit: page.limit,
|
|
15188
|
+
offset: page.offset,
|
|
15189
|
+
pattern: args.pattern ?? null,
|
|
15190
|
+
stats: result.stats,
|
|
15191
|
+
commands: commands.map((cmd) => ({
|
|
15031
15192
|
name: cmd.name,
|
|
15032
15193
|
path: cmd.path,
|
|
15033
15194
|
source: cmd.source,
|
|
15034
15195
|
description: cmd.shortDescription
|
|
15035
|
-
}))
|
|
15036
|
-
|
|
15196
|
+
}))
|
|
15197
|
+
});
|
|
15198
|
+
} else if (args.quiet) {
|
|
15199
|
+
output.log(renderQuietHeader(total, "command"));
|
|
15200
|
+
commands.forEach((cmd) => output.log(renderQuietLine(cmd.name, cmd.name)));
|
|
15201
|
+
const hint = renderQuietPaginationHint({
|
|
15202
|
+
count: commands.length,
|
|
15203
|
+
total,
|
|
15204
|
+
offset: page.offset,
|
|
15205
|
+
limit: page.limit
|
|
15037
15206
|
});
|
|
15207
|
+
if (hint)
|
|
15208
|
+
output.log(hint);
|
|
15038
15209
|
} else {
|
|
15039
|
-
const rows =
|
|
15210
|
+
const rows = commands.map((cmd) => ({
|
|
15040
15211
|
name: cmd.name,
|
|
15041
15212
|
path: cmd.path,
|
|
15042
15213
|
source: cmd.source === "user" ? "USER" : "PROJECT",
|
|
@@ -15044,7 +15215,17 @@ var CommandsListCommand = {
|
|
|
15044
15215
|
}));
|
|
15045
15216
|
output.log(formatCommandsTable(rows));
|
|
15046
15217
|
output.info("");
|
|
15047
|
-
output.log(
|
|
15218
|
+
output.log(renderPaginationFooter({
|
|
15219
|
+
total,
|
|
15220
|
+
count: commands.length,
|
|
15221
|
+
offset: page.offset,
|
|
15222
|
+
limit: page.limit,
|
|
15223
|
+
itemName: "command",
|
|
15224
|
+
extras: [
|
|
15225
|
+
`user:${result.stats.userCount}`,
|
|
15226
|
+
`project:${result.stats.projectCount}`
|
|
15227
|
+
]
|
|
15228
|
+
}));
|
|
15048
15229
|
}
|
|
15049
15230
|
} catch (error) {
|
|
15050
15231
|
output.error(`Failed to list commands: ${error}`);
|
|
@@ -15056,7 +15237,7 @@ var CommandsListCommand = {
|
|
|
15056
15237
|
};
|
|
15057
15238
|
|
|
15058
15239
|
// src/commands/commands-add.ts
|
|
15059
|
-
import
|
|
15240
|
+
import chalk42 from "chalk";
|
|
15060
15241
|
var CommandsAddCommand = {
|
|
15061
15242
|
command: "add <name> <target>",
|
|
15062
15243
|
describe: "添加收藏命令(自动创建 symlink)",
|
|
@@ -15117,10 +15298,10 @@ var CommandsAddCommand = {
|
|
|
15117
15298
|
});
|
|
15118
15299
|
const dirs = await commandsComponent.getCommandDirs();
|
|
15119
15300
|
const targetDir = source === "user" ? dirs.user : dirs.project;
|
|
15120
|
-
output.log(
|
|
15121
|
-
output.log(
|
|
15122
|
-
output.log(
|
|
15123
|
-
output.log(
|
|
15301
|
+
output.log(chalk42.green(`✅ 已添加命令 '${args.name}'`));
|
|
15302
|
+
output.log(chalk42.gray(` 目标: ${args.target}`));
|
|
15303
|
+
output.log(chalk42.gray(` 位置: ${targetDir}/${args.name}`));
|
|
15304
|
+
output.log(chalk42.gray(` 级别: ${source === "user" ? "USER" : "PROJECT"}`));
|
|
15124
15305
|
} catch (error) {
|
|
15125
15306
|
output.error(`添加失败: ${error.message}`);
|
|
15126
15307
|
process.exit(1);
|
|
@@ -15131,7 +15312,7 @@ var CommandsAddCommand = {
|
|
|
15131
15312
|
};
|
|
15132
15313
|
|
|
15133
15314
|
// src/commands/commands-remove.ts
|
|
15134
|
-
import
|
|
15315
|
+
import chalk43 from "chalk";
|
|
15135
15316
|
var CommandsRemoveCommand = {
|
|
15136
15317
|
command: "remove <name>",
|
|
15137
15318
|
aliases: ["rm"],
|
|
@@ -15175,7 +15356,7 @@ var CommandsRemoveCommand = {
|
|
|
15175
15356
|
name: args.name,
|
|
15176
15357
|
source: "user"
|
|
15177
15358
|
});
|
|
15178
|
-
output.log(
|
|
15359
|
+
output.log(chalk43.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
15179
15360
|
} catch (error) {
|
|
15180
15361
|
if (!error.message?.includes("不存在")) {
|
|
15181
15362
|
throw error;
|
|
@@ -15188,7 +15369,7 @@ var CommandsRemoveCommand = {
|
|
|
15188
15369
|
name: args.name,
|
|
15189
15370
|
source: "project"
|
|
15190
15371
|
});
|
|
15191
|
-
output.log(
|
|
15372
|
+
output.log(chalk43.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
15192
15373
|
} catch (error) {
|
|
15193
15374
|
if (!error.message?.includes("不存在")) {
|
|
15194
15375
|
throw error;
|
|
@@ -15202,7 +15383,7 @@ var CommandsRemoveCommand = {
|
|
|
15202
15383
|
name: args.name,
|
|
15203
15384
|
source: "user"
|
|
15204
15385
|
});
|
|
15205
|
-
output.log(
|
|
15386
|
+
output.log(chalk43.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
15206
15387
|
removed = true;
|
|
15207
15388
|
} catch (error) {
|
|
15208
15389
|
if (!error.message?.includes("不存在")) {
|
|
@@ -15214,7 +15395,7 @@ var CommandsRemoveCommand = {
|
|
|
15214
15395
|
name: args.name,
|
|
15215
15396
|
source: "project"
|
|
15216
15397
|
});
|
|
15217
|
-
output.log(
|
|
15398
|
+
output.log(chalk43.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
15218
15399
|
removed = true;
|
|
15219
15400
|
} catch (error) {
|
|
15220
15401
|
if (!error.message?.includes("不存在")) {
|
|
@@ -15236,7 +15417,7 @@ var CommandsRemoveCommand = {
|
|
|
15236
15417
|
};
|
|
15237
15418
|
|
|
15238
15419
|
// src/commands/commands-info.ts
|
|
15239
|
-
import
|
|
15420
|
+
import chalk44 from "chalk";
|
|
15240
15421
|
import { exec as exec2 } from "child_process";
|
|
15241
15422
|
import { promisify } from "util";
|
|
15242
15423
|
var execAsync2 = promisify(exec2);
|
|
@@ -15271,12 +15452,12 @@ var CommandsInfoCommand = {
|
|
|
15271
15452
|
output.error(`命令 '${args.name}' 不存在`);
|
|
15272
15453
|
process.exit(1);
|
|
15273
15454
|
}
|
|
15274
|
-
output.log(
|
|
15275
|
-
output.log(
|
|
15276
|
-
output.log(
|
|
15277
|
-
output.log(
|
|
15455
|
+
output.log(chalk44.bold("Name:") + ` ${info.name}`);
|
|
15456
|
+
output.log(chalk44.bold("Path:") + ` ${info.path}`);
|
|
15457
|
+
output.log(chalk44.bold("Source:") + ` ${info.source.toUpperCase()}`);
|
|
15458
|
+
output.log(chalk44.bold("Description:") + ` ${info.shortDescription || "-"}`);
|
|
15278
15459
|
output.log();
|
|
15279
|
-
output.log(
|
|
15460
|
+
output.log(chalk44.gray("─".repeat(50)));
|
|
15280
15461
|
output.log();
|
|
15281
15462
|
try {
|
|
15282
15463
|
const { stdout } = await execAsync2(`${info.path} --help`, { timeout: 5000 });
|
|
@@ -15286,7 +15467,7 @@ var CommandsInfoCommand = {
|
|
|
15286
15467
|
const { stdout } = await execAsync2(`${info.path} -h`, { timeout: 5000 });
|
|
15287
15468
|
output.log(stdout);
|
|
15288
15469
|
} catch {
|
|
15289
|
-
output.log(
|
|
15470
|
+
output.log(chalk44.gray("(无法获取帮助信息)"));
|
|
15290
15471
|
}
|
|
15291
15472
|
}
|
|
15292
15473
|
} catch (error) {
|
|
@@ -15299,7 +15480,7 @@ var CommandsInfoCommand = {
|
|
|
15299
15480
|
};
|
|
15300
15481
|
|
|
15301
15482
|
// src/commands/commands-dirs.ts
|
|
15302
|
-
import
|
|
15483
|
+
import chalk45 from "chalk";
|
|
15303
15484
|
var CommandsDirsCommand = {
|
|
15304
15485
|
command: "dirs",
|
|
15305
15486
|
describe: "显示命令目录",
|
|
@@ -15331,10 +15512,10 @@ var CommandsDirsCommand = {
|
|
|
15331
15512
|
if (args.json) {
|
|
15332
15513
|
output.json(dirs);
|
|
15333
15514
|
} else {
|
|
15334
|
-
output.log(
|
|
15515
|
+
output.log(chalk45.bold("命令目录:"));
|
|
15335
15516
|
output.log();
|
|
15336
|
-
output.log(
|
|
15337
|
-
output.log(
|
|
15517
|
+
output.log(chalk45.cyan("USER:") + ` ${dirs.user}`);
|
|
15518
|
+
output.log(chalk45.cyan("PROJECT:") + ` ${dirs.project}`);
|
|
15338
15519
|
}
|
|
15339
15520
|
} catch (error) {
|
|
15340
15521
|
output.error(`错误: ${error.message}`);
|
|
@@ -15354,7 +15535,7 @@ var CommandsCommand = {
|
|
|
15354
15535
|
};
|
|
15355
15536
|
|
|
15356
15537
|
// src/commands/config/list.ts
|
|
15357
|
-
import
|
|
15538
|
+
import chalk46 from "chalk";
|
|
15358
15539
|
|
|
15359
15540
|
// src/commands/config/config-service.ts
|
|
15360
15541
|
import * as fsSync from "fs";
|
|
@@ -15658,7 +15839,7 @@ var ConfigListCommand = {
|
|
|
15658
15839
|
output.log("");
|
|
15659
15840
|
output.log("Supported components:");
|
|
15660
15841
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
15661
|
-
output.log(` ${
|
|
15842
|
+
output.log(` ${chalk46.cyan(comp.padEnd(15))} ${COMPONENT_DESCRIPTIONS[comp] || ""}`);
|
|
15662
15843
|
}
|
|
15663
15844
|
process.exit(1);
|
|
15664
15845
|
}
|
|
@@ -15676,27 +15857,27 @@ var ConfigListCommand = {
|
|
|
15676
15857
|
}
|
|
15677
15858
|
};
|
|
15678
15859
|
function showHelp(output) {
|
|
15679
|
-
output.log(
|
|
15860
|
+
output.log(chalk46.bold.cyan("# roy-agent config list"));
|
|
15680
15861
|
output.log("");
|
|
15681
15862
|
output.log("查看 roy-agent 组件配置信息");
|
|
15682
15863
|
output.log("");
|
|
15683
|
-
output.log(
|
|
15684
|
-
output.log(` ${
|
|
15864
|
+
output.log(chalk46.bold("Usage:"));
|
|
15865
|
+
output.log(` ${chalk46.cyan("roy-agent config list [component] [options]")}`);
|
|
15685
15866
|
output.log("");
|
|
15686
|
-
output.log(
|
|
15867
|
+
output.log(chalk46.bold("Components:"));
|
|
15687
15868
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
15688
|
-
output.log(` ${
|
|
15869
|
+
output.log(` ${chalk46.cyan(comp.padEnd(15))} ${chalk46.gray(COMPONENT_DESCRIPTIONS[comp] || "")}`);
|
|
15689
15870
|
}
|
|
15690
|
-
output.log(` ${
|
|
15871
|
+
output.log(` ${chalk46.cyan("all".padEnd(15))} 显示所有 components 概览`);
|
|
15691
15872
|
output.log("");
|
|
15692
|
-
output.log(
|
|
15693
|
-
output.log(` ${
|
|
15694
|
-
output.log(` ${
|
|
15695
|
-
output.log(` ${
|
|
15873
|
+
output.log(chalk46.bold("Options:"));
|
|
15874
|
+
output.log(` ${chalk46.cyan("-j, --json")} JSON 格式输出`);
|
|
15875
|
+
output.log(` ${chalk46.cyan("-k, --keys")} 只显示配置键`);
|
|
15876
|
+
output.log(` ${chalk46.cyan("-s, --sources")} 只显示配置源`);
|
|
15696
15877
|
output.log("");
|
|
15697
|
-
output.log(
|
|
15878
|
+
output.log(chalk46.bold("Examples:"));
|
|
15698
15879
|
for (const { command: command2, description } of USAGE_COMMANDS) {
|
|
15699
|
-
output.log(` ${
|
|
15880
|
+
output.log(` ${chalk46.cyan(command2.padEnd(40))} ${chalk46.gray(description)}`);
|
|
15700
15881
|
}
|
|
15701
15882
|
}
|
|
15702
15883
|
async function showAllComponents(output, configService) {
|
|
@@ -15705,13 +15886,13 @@ async function showAllComponents(output, configService) {
|
|
|
15705
15886
|
const config = configService.getComponentConfig(compName);
|
|
15706
15887
|
components.push({ name: compName, config });
|
|
15707
15888
|
}
|
|
15708
|
-
output.log(
|
|
15889
|
+
output.log(chalk46.bold.cyan("# All Components Overview"));
|
|
15709
15890
|
output.log("");
|
|
15710
|
-
output.log(` ${
|
|
15711
|
-
output.log(` ${
|
|
15891
|
+
output.log(` ${chalk46.cyan("Component".padEnd(15))} ${chalk46.cyan("Keys".padEnd(10))} ${chalk46.gray("Description")}`);
|
|
15892
|
+
output.log(` ${chalk46.gray("─".repeat(60))}`);
|
|
15712
15893
|
for (const comp of components) {
|
|
15713
15894
|
const keyCount = Object.keys(comp.config).length;
|
|
15714
|
-
output.log(` ${
|
|
15895
|
+
output.log(` ${chalk46.cyan(comp.name.padEnd(15))} ${keyCount.toString().padEnd(10)} ${chalk46.gray(COMPONENT_DESCRIPTIONS[comp.name] || "")}`);
|
|
15715
15896
|
}
|
|
15716
15897
|
}
|
|
15717
15898
|
async function showComponentConfig(componentName, output, configService, options) {
|
|
@@ -15733,22 +15914,22 @@ async function showComponentConfig(componentName, output, configService, options
|
|
|
15733
15914
|
});
|
|
15734
15915
|
return;
|
|
15735
15916
|
}
|
|
15736
|
-
output.log(
|
|
15917
|
+
output.log(chalk46.bold.cyan(`# ${componentName} Component Configuration`));
|
|
15737
15918
|
output.log("");
|
|
15738
15919
|
if (filePath) {
|
|
15739
|
-
output.log(
|
|
15740
|
-
output.log(` ${
|
|
15920
|
+
output.log(chalk46.bold("File:"));
|
|
15921
|
+
output.log(` ${chalk46.cyan(filePath)}`);
|
|
15741
15922
|
output.log("");
|
|
15742
15923
|
}
|
|
15743
15924
|
if (!options.sources) {
|
|
15744
|
-
output.log(
|
|
15925
|
+
output.log(chalk46.bold("Configuration:"));
|
|
15745
15926
|
if (Object.keys(config).length === 0) {
|
|
15746
|
-
output.log(` ${
|
|
15927
|
+
output.log(` ${chalk46.gray("(无配置)")}`);
|
|
15747
15928
|
} else {
|
|
15748
15929
|
const flatConfig = flattenConfig(config);
|
|
15749
15930
|
for (const [key, value] of flatConfig) {
|
|
15750
15931
|
const displayValue = formatValue(value);
|
|
15751
|
-
output.log(` ${
|
|
15932
|
+
output.log(` ${chalk46.cyan(key + ":")} ${displayValue}`);
|
|
15752
15933
|
}
|
|
15753
15934
|
}
|
|
15754
15935
|
output.log("");
|
|
@@ -15763,17 +15944,17 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
15763
15944
|
});
|
|
15764
15945
|
return;
|
|
15765
15946
|
}
|
|
15766
|
-
output.log(
|
|
15947
|
+
output.log(chalk46.bold.cyan("# Agent Component Configuration"));
|
|
15767
15948
|
output.log("");
|
|
15768
15949
|
if (!options.sources) {
|
|
15769
|
-
output.log(
|
|
15950
|
+
output.log(chalk46.bold("Configuration:"));
|
|
15770
15951
|
if (Object.keys(config).length === 0) {
|
|
15771
|
-
output.log(` ${
|
|
15952
|
+
output.log(` ${chalk46.gray("(无配置,使用默认值)")}`);
|
|
15772
15953
|
} else {
|
|
15773
15954
|
const flatConfig = flattenConfig(config);
|
|
15774
15955
|
for (const [key, value] of flatConfig) {
|
|
15775
15956
|
const displayValue = formatValue(value);
|
|
15776
|
-
output.log(` ${
|
|
15957
|
+
output.log(` ${chalk46.cyan(key + ":")} ${displayValue}`);
|
|
15777
15958
|
}
|
|
15778
15959
|
}
|
|
15779
15960
|
output.log("");
|
|
@@ -15787,10 +15968,10 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
15787
15968
|
const configDir = registry.getConfigDir();
|
|
15788
15969
|
const exists = registry.configDirExists();
|
|
15789
15970
|
const agentCount = registry.list().length;
|
|
15790
|
-
output.log(
|
|
15791
|
-
output.log(` ${
|
|
15792
|
-
output.log(` ${
|
|
15793
|
-
output.log(` ${
|
|
15971
|
+
output.log(chalk46.bold("Agent Config Directory:"));
|
|
15972
|
+
output.log(` ${chalk46.cyan("path:")} ${configDir}`);
|
|
15973
|
+
output.log(` ${chalk46.cyan("exists:")} ${exists ? chalk46.green("yes") : chalk46.red("no")}`);
|
|
15974
|
+
output.log(` ${chalk46.cyan("agents:")} ${agentCount} loaded`);
|
|
15794
15975
|
output.log("");
|
|
15795
15976
|
}
|
|
15796
15977
|
}
|
|
@@ -15806,41 +15987,41 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
15806
15987
|
});
|
|
15807
15988
|
return;
|
|
15808
15989
|
}
|
|
15809
|
-
output.log(
|
|
15990
|
+
output.log(chalk46.bold.cyan("# Prompt Component Configuration"));
|
|
15810
15991
|
output.log("");
|
|
15811
15992
|
if (filePath) {
|
|
15812
|
-
output.log(
|
|
15813
|
-
output.log(` ${
|
|
15993
|
+
output.log(chalk46.bold("File:"));
|
|
15994
|
+
output.log(` ${chalk46.cyan(filePath)}`);
|
|
15814
15995
|
output.log("");
|
|
15815
15996
|
}
|
|
15816
15997
|
if (!options.sources) {
|
|
15817
|
-
output.log(
|
|
15998
|
+
output.log(chalk46.bold("Configuration:"));
|
|
15818
15999
|
if (Object.keys(config).length === 0) {
|
|
15819
|
-
output.log(` ${
|
|
16000
|
+
output.log(` ${chalk46.gray("(无配置,使用默认值)")}`);
|
|
15820
16001
|
} else {
|
|
15821
16002
|
const flatConfig = flattenConfig(config);
|
|
15822
16003
|
for (const [key, value] of flatConfig) {
|
|
15823
16004
|
const displayValue = formatValue(value);
|
|
15824
|
-
output.log(` ${
|
|
16005
|
+
output.log(` ${chalk46.cyan(key + ":")} ${displayValue}`);
|
|
15825
16006
|
}
|
|
15826
16007
|
}
|
|
15827
16008
|
output.log("");
|
|
15828
16009
|
}
|
|
15829
|
-
output.log(
|
|
15830
|
-
output.log(` ${
|
|
16010
|
+
output.log(chalk46.bold("Prompts:"));
|
|
16011
|
+
output.log(` ${chalk46.gray("- 内置: 5 个(default, coding, review, project-memory, global-memory)")}`);
|
|
15831
16012
|
const promptPaths = config?.promptPaths;
|
|
15832
16013
|
if (promptPaths && Array.isArray(promptPaths) && promptPaths.length > 0) {
|
|
15833
|
-
output.log(` ${
|
|
16014
|
+
output.log(` ${chalk46.gray("- 外部: " + promptPaths.length + " 个路径")}`);
|
|
15834
16015
|
for (const p of promptPaths) {
|
|
15835
|
-
output.log(` ${
|
|
16016
|
+
output.log(` ${chalk46.cyan(p.path)} ${chalk46.gray("(type: " + p.type + ")")}`);
|
|
15836
16017
|
}
|
|
15837
16018
|
} else {
|
|
15838
|
-
output.log(` ${
|
|
16019
|
+
output.log(` ${chalk46.gray("- 外部: 0 个(未配置 promptPaths)")}`);
|
|
15839
16020
|
}
|
|
15840
16021
|
output.log("");
|
|
15841
16022
|
const defaultName = config?.defaultName || "default";
|
|
15842
|
-
output.log(
|
|
15843
|
-
output.log(` ${
|
|
16023
|
+
output.log(chalk46.bold("Default Prompt:"));
|
|
16024
|
+
output.log(` ${chalk46.cyan("defaultName:")} ${defaultName}`);
|
|
15844
16025
|
output.log("");
|
|
15845
16026
|
const env = envService?.getEnvironment?.();
|
|
15846
16027
|
if (env) {
|
|
@@ -15855,10 +16036,10 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
15855
16036
|
const stored = await store?.loadAll?.();
|
|
15856
16037
|
promptCount = Array.isArray(stored) ? stored.length : 0;
|
|
15857
16038
|
} catch {}
|
|
15858
|
-
output.log(
|
|
15859
|
-
output.log(` ${
|
|
15860
|
-
output.log(` ${
|
|
15861
|
-
output.log(` ${
|
|
16039
|
+
output.log(chalk46.bold("Prompt Storage Directory:"));
|
|
16040
|
+
output.log(` ${chalk46.cyan("path:")} ${configDir}`);
|
|
16041
|
+
output.log(` ${chalk46.cyan("exists:")} ${exists ? chalk46.green("yes") : chalk46.red("no")}`);
|
|
16042
|
+
output.log(` ${chalk46.cyan("prompts:")} ${promptCount} loaded`);
|
|
15862
16043
|
output.log("");
|
|
15863
16044
|
}
|
|
15864
16045
|
}
|
|
@@ -15884,19 +16065,19 @@ function flattenConfig(obj, prefix = "") {
|
|
|
15884
16065
|
}
|
|
15885
16066
|
function formatValue(value) {
|
|
15886
16067
|
if (value === undefined) {
|
|
15887
|
-
return
|
|
16068
|
+
return chalk46.gray("undefined");
|
|
15888
16069
|
}
|
|
15889
16070
|
if (value === null) {
|
|
15890
|
-
return
|
|
16071
|
+
return chalk46.gray("null");
|
|
15891
16072
|
}
|
|
15892
16073
|
if (typeof value === "object") {
|
|
15893
|
-
return
|
|
16074
|
+
return chalk46.gray(JSON.stringify(value));
|
|
15894
16075
|
}
|
|
15895
16076
|
return String(value);
|
|
15896
16077
|
}
|
|
15897
16078
|
|
|
15898
16079
|
// src/commands/config/export.ts
|
|
15899
|
-
import
|
|
16080
|
+
import chalk47 from "chalk";
|
|
15900
16081
|
var ConfigExportCommand = {
|
|
15901
16082
|
command: "export <component>",
|
|
15902
16083
|
describe: "导出组件配置到文件",
|
|
@@ -15941,7 +16122,7 @@ var ConfigExportCommand = {
|
|
|
15941
16122
|
output.log("");
|
|
15942
16123
|
output.log("Supported components:");
|
|
15943
16124
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
15944
|
-
output.log(` ${
|
|
16125
|
+
output.log(` ${chalk47.cyan(comp)}`);
|
|
15945
16126
|
}
|
|
15946
16127
|
process.exit(1);
|
|
15947
16128
|
}
|
|
@@ -15959,7 +16140,7 @@ var ConfigExportCommand = {
|
|
|
15959
16140
|
};
|
|
15960
16141
|
|
|
15961
16142
|
// src/commands/config/import.ts
|
|
15962
|
-
import
|
|
16143
|
+
import chalk48 from "chalk";
|
|
15963
16144
|
var ConfigImportCommand = {
|
|
15964
16145
|
command: "import <component>",
|
|
15965
16146
|
describe: "从文件导入配置到组件的 file source",
|
|
@@ -16009,7 +16190,7 @@ var ConfigImportCommand = {
|
|
|
16009
16190
|
output.log("");
|
|
16010
16191
|
output.log("Supported components:");
|
|
16011
16192
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
16012
|
-
output.log(` ${
|
|
16193
|
+
output.log(` ${chalk48.cyan(comp)}`);
|
|
16013
16194
|
}
|
|
16014
16195
|
process.exit(1);
|
|
16015
16196
|
}
|
|
@@ -16024,7 +16205,7 @@ var ConfigImportCommand = {
|
|
|
16024
16205
|
}
|
|
16025
16206
|
if (result.merged && result.changes.length > 0 && args.verbose) {
|
|
16026
16207
|
output.log("");
|
|
16027
|
-
output.log(
|
|
16208
|
+
output.log(chalk48.bold("变更详情:"));
|
|
16028
16209
|
for (const change of result.changes) {
|
|
16029
16210
|
output.log(` ${change.key}: ${JSON.stringify(change.oldValue)} → ${JSON.stringify(change.newValue)}`);
|
|
16030
16211
|
}
|
|
@@ -16048,7 +16229,7 @@ var ConfigCommand = {
|
|
|
16048
16229
|
};
|
|
16049
16230
|
|
|
16050
16231
|
// src/commands/mcp/list.ts
|
|
16051
|
-
import
|
|
16232
|
+
import chalk49 from "chalk";
|
|
16052
16233
|
var ListCommand6 = {
|
|
16053
16234
|
command: "list",
|
|
16054
16235
|
aliases: ["ls"],
|
|
@@ -16058,12 +16239,7 @@ var ListCommand6 = {
|
|
|
16058
16239
|
type: "boolean",
|
|
16059
16240
|
default: false,
|
|
16060
16241
|
description: "JSON 输出"
|
|
16061
|
-
}).option("quiet", {
|
|
16062
|
-
alias: "q",
|
|
16063
|
-
type: "boolean",
|
|
16064
|
-
default: false,
|
|
16065
|
-
description: "简洁输出"
|
|
16066
|
-
}),
|
|
16242
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
16067
16243
|
async handler(args) {
|
|
16068
16244
|
const output = new OutputService2;
|
|
16069
16245
|
const envService = new EnvironmentService(output);
|
|
@@ -16079,45 +16255,64 @@ var ListCommand6 = {
|
|
|
16079
16255
|
output.error("McpComponent not available");
|
|
16080
16256
|
process.exit(1);
|
|
16081
16257
|
}
|
|
16082
|
-
const
|
|
16258
|
+
const allServers = mcpComponent.listServers();
|
|
16259
|
+
const total = allServers.length;
|
|
16260
|
+
const page = {
|
|
16261
|
+
limit: args.limit ?? 20,
|
|
16262
|
+
offset: args.offset ?? 0
|
|
16263
|
+
};
|
|
16264
|
+
const servers = applyPagination(allServers, page);
|
|
16083
16265
|
if (args.json) {
|
|
16084
16266
|
output.json({
|
|
16267
|
+
total,
|
|
16268
|
+
count: servers.length,
|
|
16269
|
+
truncated: total > servers.length,
|
|
16270
|
+
limit: page.limit,
|
|
16271
|
+
offset: page.offset,
|
|
16085
16272
|
servers: servers.map((s) => ({
|
|
16086
16273
|
name: s.name,
|
|
16087
16274
|
status: s.status,
|
|
16088
16275
|
error: s.error,
|
|
16089
16276
|
toolsCount: s.toolsCount
|
|
16090
|
-
}))
|
|
16091
|
-
count: servers.length
|
|
16277
|
+
}))
|
|
16092
16278
|
});
|
|
16093
16279
|
} else if (args.quiet) {
|
|
16094
|
-
|
|
16280
|
+
output.log(renderQuietHeader(total, "mcp server"));
|
|
16281
|
+
servers.forEach((s) => output.log(renderQuietLine(s.name, s.name)));
|
|
16282
|
+
const hint = renderQuietPaginationHint({
|
|
16283
|
+
count: servers.length,
|
|
16284
|
+
total,
|
|
16285
|
+
offset: page.offset,
|
|
16286
|
+
limit: page.limit
|
|
16287
|
+
});
|
|
16288
|
+
if (hint)
|
|
16289
|
+
output.log(hint);
|
|
16095
16290
|
} else {
|
|
16096
16291
|
if (servers.length === 0) {
|
|
16097
|
-
output.log(
|
|
16292
|
+
output.log(chalk49.yellow("No MCP servers configured"));
|
|
16098
16293
|
return;
|
|
16099
16294
|
}
|
|
16100
16295
|
const statusColor = (status) => {
|
|
16101
16296
|
switch (status) {
|
|
16102
16297
|
case "connected":
|
|
16103
|
-
return
|
|
16298
|
+
return chalk49.green;
|
|
16104
16299
|
case "connecting":
|
|
16105
|
-
return
|
|
16300
|
+
return chalk49.yellow;
|
|
16106
16301
|
case "error":
|
|
16107
|
-
return
|
|
16302
|
+
return chalk49.red;
|
|
16108
16303
|
case "disconnected":
|
|
16109
|
-
return
|
|
16304
|
+
return chalk49.gray;
|
|
16110
16305
|
default:
|
|
16111
|
-
return
|
|
16306
|
+
return chalk49.white;
|
|
16112
16307
|
}
|
|
16113
16308
|
};
|
|
16114
16309
|
const header = [
|
|
16115
|
-
|
|
16116
|
-
|
|
16117
|
-
|
|
16310
|
+
chalk49.bold("Name"),
|
|
16311
|
+
chalk49.bold("Status"),
|
|
16312
|
+
chalk49.bold("Tools")
|
|
16118
16313
|
].join(" | ");
|
|
16119
16314
|
const rows = servers.map((s) => [
|
|
16120
|
-
|
|
16315
|
+
chalk49.cyan(s.name),
|
|
16121
16316
|
statusColor(s.status)(`[${s.status}]`),
|
|
16122
16317
|
s.toolsCount !== undefined ? String(s.toolsCount) : "-"
|
|
16123
16318
|
].join(" | "));
|
|
@@ -16128,7 +16323,13 @@ var ListCommand6 = {
|
|
|
16128
16323
|
...rows.map((r) => `│${r}│`),
|
|
16129
16324
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
16130
16325
|
"",
|
|
16131
|
-
|
|
16326
|
+
renderPaginationFooter({
|
|
16327
|
+
total,
|
|
16328
|
+
count: servers.length,
|
|
16329
|
+
offset: page.offset,
|
|
16330
|
+
limit: page.limit,
|
|
16331
|
+
itemName: "mcp server"
|
|
16332
|
+
})
|
|
16132
16333
|
].join(`
|
|
16133
16334
|
`));
|
|
16134
16335
|
}
|
|
@@ -16142,7 +16343,7 @@ var ListCommand6 = {
|
|
|
16142
16343
|
};
|
|
16143
16344
|
|
|
16144
16345
|
// src/commands/mcp/tools.ts
|
|
16145
|
-
import
|
|
16346
|
+
import chalk50 from "chalk";
|
|
16146
16347
|
var ToolsCommand = {
|
|
16147
16348
|
command: "tools",
|
|
16148
16349
|
aliases: ["t"],
|
|
@@ -16195,7 +16396,7 @@ var ToolsCommand = {
|
|
|
16195
16396
|
tools.forEach((t) => output.log(t.name));
|
|
16196
16397
|
} else {
|
|
16197
16398
|
if (tools.length === 0) {
|
|
16198
|
-
output.log(
|
|
16399
|
+
output.log(chalk50.yellow("No MCP tools available"));
|
|
16199
16400
|
return;
|
|
16200
16401
|
}
|
|
16201
16402
|
const byServer = new Map;
|
|
@@ -16207,15 +16408,15 @@ var ToolsCommand = {
|
|
|
16207
16408
|
byServer.get(serverName).push(tool);
|
|
16208
16409
|
}
|
|
16209
16410
|
for (const [serverName, serverTools] of byServer) {
|
|
16210
|
-
output.log(
|
|
16411
|
+
output.log(chalk50.bold.cyan(`
|
|
16211
16412
|
[${serverName}] ${serverTools.length} tools`));
|
|
16212
16413
|
for (const tool of serverTools) {
|
|
16213
16414
|
const desc2 = tool.description.length > 80 ? tool.description.slice(0, 77) + "..." : tool.description;
|
|
16214
|
-
output.log(` ${
|
|
16215
|
-
output.log(` ${
|
|
16415
|
+
output.log(` ${chalk50.green("+")} ${chalk50.white(tool.name)}`);
|
|
16416
|
+
output.log(` ${chalk50.gray(desc2)}`);
|
|
16216
16417
|
}
|
|
16217
16418
|
}
|
|
16218
|
-
output.log(
|
|
16419
|
+
output.log(chalk50.gray(`
|
|
16219
16420
|
Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
16220
16421
|
}
|
|
16221
16422
|
} catch (error) {
|
|
@@ -16228,7 +16429,7 @@ Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
|
16228
16429
|
};
|
|
16229
16430
|
|
|
16230
16431
|
// src/commands/mcp/reload.ts
|
|
16231
|
-
import
|
|
16432
|
+
import chalk51 from "chalk";
|
|
16232
16433
|
var ReloadCommand2 = {
|
|
16233
16434
|
command: "reload",
|
|
16234
16435
|
aliases: ["r"],
|
|
@@ -16249,19 +16450,19 @@ var ReloadCommand2 = {
|
|
|
16249
16450
|
output.error("McpComponent not available");
|
|
16250
16451
|
process.exit(1);
|
|
16251
16452
|
}
|
|
16252
|
-
output.log(
|
|
16453
|
+
output.log(chalk51.cyan("Reloading MCP servers..."));
|
|
16253
16454
|
await mcpComponent.reload();
|
|
16254
16455
|
const servers = mcpComponent.listServers();
|
|
16255
16456
|
const connected = servers.filter((s) => s.status === "connected").length;
|
|
16256
16457
|
const errors = servers.filter((s) => s.status === "error").length;
|
|
16257
|
-
output.log(
|
|
16458
|
+
output.log(chalk51.green(`✓ Reloaded ${servers.length} servers`));
|
|
16258
16459
|
if (connected > 0) {
|
|
16259
|
-
output.log(
|
|
16460
|
+
output.log(chalk51.green(` • ${connected} connected`));
|
|
16260
16461
|
}
|
|
16261
16462
|
if (errors > 0) {
|
|
16262
16463
|
output.warn(` • ${errors} failed`);
|
|
16263
16464
|
for (const server of servers.filter((s) => s.status === "error")) {
|
|
16264
|
-
output.log(
|
|
16465
|
+
output.log(chalk51.gray(` - ${server.name}: ${server.error}`));
|
|
16265
16466
|
}
|
|
16266
16467
|
}
|
|
16267
16468
|
} catch (error) {
|
|
@@ -16282,7 +16483,7 @@ var McpCommand = {
|
|
|
16282
16483
|
};
|
|
16283
16484
|
|
|
16284
16485
|
// src/commands/tools/list.ts
|
|
16285
|
-
import
|
|
16486
|
+
import chalk52 from "chalk";
|
|
16286
16487
|
var ListCommand7 = {
|
|
16287
16488
|
command: "list",
|
|
16288
16489
|
aliases: ["ls"],
|
|
@@ -16292,12 +16493,7 @@ var ListCommand7 = {
|
|
|
16292
16493
|
type: "boolean",
|
|
16293
16494
|
default: false,
|
|
16294
16495
|
description: "JSON 输出"
|
|
16295
|
-
}).option("quiet", {
|
|
16296
|
-
alias: "q",
|
|
16297
|
-
type: "boolean",
|
|
16298
|
-
default: false,
|
|
16299
|
-
description: "简洁输出(仅名称)"
|
|
16300
|
-
}),
|
|
16496
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
16301
16497
|
async handler(args) {
|
|
16302
16498
|
const output = new OutputService2;
|
|
16303
16499
|
const envService = new EnvironmentService(output);
|
|
@@ -16313,10 +16509,20 @@ var ListCommand7 = {
|
|
|
16313
16509
|
output.error("ToolComponent not available");
|
|
16314
16510
|
process.exit(1);
|
|
16315
16511
|
}
|
|
16316
|
-
const
|
|
16512
|
+
const allTools = toolComponent.listTools();
|
|
16513
|
+
const total = allTools.length;
|
|
16514
|
+
const page = {
|
|
16515
|
+
limit: args.limit ?? 20,
|
|
16516
|
+
offset: args.offset ?? 0
|
|
16517
|
+
};
|
|
16518
|
+
const tools = applyPagination(allTools, page);
|
|
16317
16519
|
if (args.json) {
|
|
16318
16520
|
output.json({
|
|
16521
|
+
total,
|
|
16319
16522
|
count: tools.length,
|
|
16523
|
+
truncated: total > tools.length,
|
|
16524
|
+
limit: page.limit,
|
|
16525
|
+
offset: page.offset,
|
|
16320
16526
|
tools: tools.map((t) => ({
|
|
16321
16527
|
name: t.name,
|
|
16322
16528
|
description: t.description,
|
|
@@ -16324,19 +16530,28 @@ var ListCommand7 = {
|
|
|
16324
16530
|
}))
|
|
16325
16531
|
});
|
|
16326
16532
|
} else if (args.quiet) {
|
|
16327
|
-
|
|
16533
|
+
output.log(renderQuietHeader(total, "tool"));
|
|
16534
|
+
tools.forEach((t) => output.log(renderQuietLine(t.name, t.name)));
|
|
16535
|
+
const hint = renderQuietPaginationHint({
|
|
16536
|
+
count: tools.length,
|
|
16537
|
+
total,
|
|
16538
|
+
offset: page.offset,
|
|
16539
|
+
limit: page.limit
|
|
16540
|
+
});
|
|
16541
|
+
if (hint)
|
|
16542
|
+
output.log(hint);
|
|
16328
16543
|
} else {
|
|
16329
16544
|
const header = [
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16545
|
+
chalk52.bold("Name"),
|
|
16546
|
+
chalk52.bold("Description"),
|
|
16547
|
+
chalk52.bold("Category")
|
|
16333
16548
|
].join(" | ");
|
|
16334
16549
|
const rows = tools.map((t) => {
|
|
16335
16550
|
const desc2 = t.description.length > 40 ? t.description.slice(0, 37) + "..." : t.description;
|
|
16336
16551
|
return [
|
|
16337
|
-
|
|
16552
|
+
chalk52.cyan(t.name),
|
|
16338
16553
|
desc2,
|
|
16339
|
-
t.metadata?.category ?
|
|
16554
|
+
t.metadata?.category ? chalk52.gray(`[${t.metadata.category}]`) : "-"
|
|
16340
16555
|
].join(" | ");
|
|
16341
16556
|
});
|
|
16342
16557
|
output.log([
|
|
@@ -16346,7 +16561,13 @@ var ListCommand7 = {
|
|
|
16346
16561
|
...rows.map((r) => `│${r}│`),
|
|
16347
16562
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
16348
16563
|
"",
|
|
16349
|
-
|
|
16564
|
+
renderPaginationFooter({
|
|
16565
|
+
total,
|
|
16566
|
+
count: tools.length,
|
|
16567
|
+
offset: page.offset,
|
|
16568
|
+
limit: page.limit,
|
|
16569
|
+
itemName: "tool"
|
|
16570
|
+
})
|
|
16350
16571
|
].join(`
|
|
16351
16572
|
`));
|
|
16352
16573
|
}
|
|
@@ -16360,7 +16581,7 @@ var ListCommand7 = {
|
|
|
16360
16581
|
};
|
|
16361
16582
|
|
|
16362
16583
|
// src/commands/tools/get.ts
|
|
16363
|
-
import
|
|
16584
|
+
import chalk53 from "chalk";
|
|
16364
16585
|
|
|
16365
16586
|
// src/commands/tools/shared/schema-helper.ts
|
|
16366
16587
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -16435,8 +16656,8 @@ var GetCommand6 = {
|
|
|
16435
16656
|
}))
|
|
16436
16657
|
});
|
|
16437
16658
|
} else {
|
|
16438
|
-
output.log(
|
|
16439
|
-
output.log(
|
|
16659
|
+
output.log(chalk53.bold.cyan(`Tool: ${tool.name}`));
|
|
16660
|
+
output.log(chalk53.gray("─".repeat(60)));
|
|
16440
16661
|
output.log(`Description: ${tool.description}`);
|
|
16441
16662
|
if (tool.metadata?.category) {
|
|
16442
16663
|
output.log(`Category: ${tool.metadata.category}`);
|
|
@@ -16445,9 +16666,9 @@ var GetCommand6 = {
|
|
|
16445
16666
|
output.log(`Tags: ${tool.metadata.tags.join(", ")}`);
|
|
16446
16667
|
}
|
|
16447
16668
|
output.log("");
|
|
16448
|
-
output.log(
|
|
16669
|
+
output.log(chalk53.bold("Parameters:"));
|
|
16449
16670
|
for (const param of params) {
|
|
16450
|
-
const required = param.required ?
|
|
16671
|
+
const required = param.required ? chalk53.red("(required)") : chalk53.gray("(optional)");
|
|
16451
16672
|
const defaultVal = param.default !== undefined ? ` [default: ${JSON.stringify(param.default)}]` : "";
|
|
16452
16673
|
output.log(` --${param.name} <${param.type}> ${required}`);
|
|
16453
16674
|
output.log(` ${param.description}${defaultVal}`);
|
|
@@ -16556,14 +16777,14 @@ var ToolsCommand2 = {
|
|
|
16556
16777
|
};
|
|
16557
16778
|
|
|
16558
16779
|
// src/commands/memory/record.ts
|
|
16559
|
-
import
|
|
16780
|
+
import chalk54 from "chalk";
|
|
16560
16781
|
import { createMemoryAgentTools, getBuiltInPrompt } from "@ai-setting/roy-agent-core";
|
|
16561
16782
|
import { bashTool, globTool, readFileTool } from "@ai-setting/roy-agent-core";
|
|
16562
16783
|
async function runExtractMode(output, memoryComponent, agentComponent, sessionComponent, env, options) {
|
|
16563
16784
|
const { scope, sessionId, require: userRequirement } = options;
|
|
16564
|
-
output.log(
|
|
16785
|
+
output.log(chalk54.blue(`
|
|
16565
16786
|
\uD83D\uDD0D Memory Extract Mode (${scope})`));
|
|
16566
|
-
output.log(
|
|
16787
|
+
output.log(chalk54.gray(`正在分析会话历史,生成记忆...
|
|
16567
16788
|
`));
|
|
16568
16789
|
try {
|
|
16569
16790
|
const currentMemory = await memoryComponent.recallMemory(scope) || "(无现有记忆)";
|
|
@@ -16609,13 +16830,13 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
16609
16830
|
for (const tool of agentTools) {
|
|
16610
16831
|
try {
|
|
16611
16832
|
toolComponent.register(tool);
|
|
16612
|
-
output.log(
|
|
16833
|
+
output.log(chalk54.gray(`Tool registered: ${tool.name}`));
|
|
16613
16834
|
} catch (err) {
|
|
16614
|
-
output.log(
|
|
16835
|
+
output.log(chalk54.gray(`Tool already registered: ${tool.name}`));
|
|
16615
16836
|
}
|
|
16616
16837
|
}
|
|
16617
16838
|
}
|
|
16618
|
-
output.log(
|
|
16839
|
+
output.log(chalk54.gray(`Agent "${agentName}" registered with ${agentTools.length} tools`));
|
|
16619
16840
|
const query = `请分析会话历史,提炼${scope === "project" ? "项目" : "全局"}记忆并写入记忆文件。`;
|
|
16620
16841
|
let result;
|
|
16621
16842
|
try {
|
|
@@ -16629,12 +16850,12 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
16629
16850
|
if (result && result.startsWith("执行失败")) {
|
|
16630
16851
|
output.error(`提取失败: ${result}`);
|
|
16631
16852
|
} else if (result) {
|
|
16632
|
-
output.log(
|
|
16853
|
+
output.log(chalk54.green(`
|
|
16633
16854
|
✅ 记忆提取完成`));
|
|
16634
|
-
output.log(
|
|
16855
|
+
output.log(chalk54.gray(`记忆已保存到 memory 文件。
|
|
16635
16856
|
`));
|
|
16636
16857
|
if (result.length > 0 && result !== "✅ 记忆提取完成") {
|
|
16637
|
-
output.log(
|
|
16858
|
+
output.log(chalk54.gray(`执行摘要: ${result.substring(0, 200)}${result.length > 200 ? "..." : ""}`));
|
|
16638
16859
|
}
|
|
16639
16860
|
}
|
|
16640
16861
|
agentComponent.unregisterAgent(agentName);
|
|
@@ -16752,11 +16973,11 @@ var RecordCommand = {
|
|
|
16752
16973
|
prepend: "已插入内容到记忆文件开头",
|
|
16753
16974
|
delete: "已删除记忆文件"
|
|
16754
16975
|
};
|
|
16755
|
-
output.log(
|
|
16756
|
-
output.log(
|
|
16976
|
+
output.log(chalk54.green(`✓ ${actionMessages[result.action]}`));
|
|
16977
|
+
output.log(chalk54.gray(`路径: ${result.path}`));
|
|
16757
16978
|
if (result.action !== "delete" && a.content) {
|
|
16758
16979
|
const preview = a.content.substring(0, 100);
|
|
16759
|
-
output.log(
|
|
16980
|
+
output.log(chalk54.gray(`内容预览: ${preview}${a.content.length > 100 ? "..." : ""}`));
|
|
16760
16981
|
}
|
|
16761
16982
|
} catch (error) {
|
|
16762
16983
|
output.error(`Failed to record memory: ${error}`);
|
|
@@ -16768,7 +16989,7 @@ var RecordCommand = {
|
|
|
16768
16989
|
};
|
|
16769
16990
|
|
|
16770
16991
|
// src/commands/memory/recall.ts
|
|
16771
|
-
import
|
|
16992
|
+
import chalk55 from "chalk";
|
|
16772
16993
|
var RecallCommand = {
|
|
16773
16994
|
command: "recall",
|
|
16774
16995
|
aliases: ["load"],
|
|
@@ -16804,7 +17025,7 @@ var RecallCommand = {
|
|
|
16804
17025
|
}
|
|
16805
17026
|
const content = await memoryComponent.recallMemory(a.scope);
|
|
16806
17027
|
if (!content) {
|
|
16807
|
-
output.log(
|
|
17028
|
+
output.log(chalk55.gray("(No memory files found)"));
|
|
16808
17029
|
return;
|
|
16809
17030
|
}
|
|
16810
17031
|
if (a.json) {
|
|
@@ -16830,7 +17051,7 @@ var MemoryCommand = {
|
|
|
16830
17051
|
handler: () => {}
|
|
16831
17052
|
};
|
|
16832
17053
|
// src/commands/eventsource/list.ts
|
|
16833
|
-
import
|
|
17054
|
+
import chalk56 from "chalk";
|
|
16834
17055
|
function truncateVisual2(str, maxWidth) {
|
|
16835
17056
|
let result = "";
|
|
16836
17057
|
let width = 0;
|
|
@@ -16845,7 +17066,7 @@ function truncateVisual2(str, maxWidth) {
|
|
|
16845
17066
|
}
|
|
16846
17067
|
function formatSourcesTable(sources) {
|
|
16847
17068
|
if (sources.length === 0) {
|
|
16848
|
-
return
|
|
17069
|
+
return chalk56.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加");
|
|
16849
17070
|
}
|
|
16850
17071
|
const ID_WIDTH = 10;
|
|
16851
17072
|
const NAME_WIDTH = 20;
|
|
@@ -16854,11 +17075,11 @@ function formatSourcesTable(sources) {
|
|
|
16854
17075
|
const ENABLED_WIDTH = 8;
|
|
16855
17076
|
const GAP = " ";
|
|
16856
17077
|
const headerLine = [
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
17078
|
+
chalk56.bold("ID".padEnd(ID_WIDTH)),
|
|
17079
|
+
chalk56.bold("NAME".padEnd(NAME_WIDTH)),
|
|
17080
|
+
chalk56.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
17081
|
+
chalk56.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
17082
|
+
chalk56.bold("ENABLED".padEnd(ENABLED_WIDTH))
|
|
16862
17083
|
].join(GAP);
|
|
16863
17084
|
const sepLine = "─".repeat(ID_WIDTH + NAME_WIDTH + TYPE_WIDTH + STATUS_WIDTH + ENABLED_WIDTH + GAP.length * 4);
|
|
16864
17085
|
const formatRow = (src) => {
|
|
@@ -16882,15 +17103,9 @@ var EventSourceListCommand = {
|
|
|
16882
17103
|
describe: "JSON 格式输出",
|
|
16883
17104
|
type: "boolean",
|
|
16884
17105
|
default: false
|
|
16885
|
-
}).option("quiet", {
|
|
16886
|
-
alias: "q",
|
|
16887
|
-
describe: "静默模式",
|
|
16888
|
-
type: "boolean",
|
|
16889
|
-
default: false
|
|
16890
|
-
}),
|
|
17106
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
16891
17107
|
async handler(args) {
|
|
16892
17108
|
const output = new OutputService2;
|
|
16893
|
-
output.configure({ quiet: args.quiet });
|
|
16894
17109
|
const envService = new EnvironmentService(output);
|
|
16895
17110
|
try {
|
|
16896
17111
|
await envService.create({ configPath: args.config });
|
|
@@ -16899,53 +17114,90 @@ var EventSourceListCommand = {
|
|
|
16899
17114
|
output.error("Failed to create environment");
|
|
16900
17115
|
process.exit(1);
|
|
16901
17116
|
}
|
|
16902
|
-
const components = env.listComponents().map((c) => c.name);
|
|
16903
|
-
output.log("Available components: " + components.join(", "));
|
|
16904
17117
|
const esComponent = env.getComponent("event-source");
|
|
16905
17118
|
if (!esComponent) {
|
|
16906
17119
|
output.error("EventSourceComponent not available");
|
|
16907
17120
|
process.exit(1);
|
|
16908
17121
|
}
|
|
16909
|
-
const
|
|
16910
|
-
|
|
17122
|
+
const allSources = esComponent.list() ?? [];
|
|
17123
|
+
const total = allSources.length;
|
|
17124
|
+
const page = {
|
|
17125
|
+
limit: args.limit ?? 20,
|
|
17126
|
+
offset: args.offset ?? 0
|
|
17127
|
+
};
|
|
17128
|
+
const sources = applyPagination(allSources, page);
|
|
17129
|
+
if (total === 0) {
|
|
16911
17130
|
if (args.json) {
|
|
16912
|
-
output.json({
|
|
17131
|
+
output.json({
|
|
17132
|
+
total: 0,
|
|
17133
|
+
count: 0,
|
|
17134
|
+
truncated: false,
|
|
17135
|
+
limit: page.limit,
|
|
17136
|
+
offset: page.offset,
|
|
17137
|
+
sources: []
|
|
17138
|
+
});
|
|
16913
17139
|
} else {
|
|
16914
|
-
output.log(
|
|
17140
|
+
output.log(chalk56.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加"));
|
|
16915
17141
|
}
|
|
16916
17142
|
return;
|
|
16917
17143
|
}
|
|
17144
|
+
const sourcesWithStatus = sources.map((s) => ({
|
|
17145
|
+
...s,
|
|
17146
|
+
status: esComponent.getStatus(s.id) || "unknown"
|
|
17147
|
+
}));
|
|
16918
17148
|
if (args.json) {
|
|
16919
|
-
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
17149
|
+
output.json({
|
|
17150
|
+
total,
|
|
17151
|
+
count: sourcesWithStatus.length,
|
|
17152
|
+
truncated: total > sourcesWithStatus.length,
|
|
17153
|
+
limit: page.limit,
|
|
17154
|
+
offset: page.offset,
|
|
17155
|
+
sources: sourcesWithStatus
|
|
17156
|
+
});
|
|
17157
|
+
return;
|
|
17158
|
+
}
|
|
17159
|
+
if (args.quiet) {
|
|
17160
|
+
output.log(renderQuietHeader(total, "event source"));
|
|
17161
|
+
sources.forEach((s) => output.log(renderQuietLine(s.id, s.name)));
|
|
17162
|
+
const hint = renderQuietPaginationHint({
|
|
17163
|
+
count: sources.length,
|
|
17164
|
+
total,
|
|
17165
|
+
offset: page.offset,
|
|
17166
|
+
limit: page.limit
|
|
17167
|
+
});
|
|
17168
|
+
if (hint)
|
|
17169
|
+
output.log(hint);
|
|
16924
17170
|
return;
|
|
16925
17171
|
}
|
|
16926
17172
|
const rows = sources.map((s) => {
|
|
16927
17173
|
const status = esComponent.getStatus(s.id) || "unknown";
|
|
16928
17174
|
const statusColorMap = {
|
|
16929
|
-
running:
|
|
16930
|
-
stopped:
|
|
16931
|
-
error:
|
|
16932
|
-
starting:
|
|
16933
|
-
created:
|
|
16934
|
-
stopping:
|
|
16935
|
-
unknown:
|
|
17175
|
+
running: chalk56.green,
|
|
17176
|
+
stopped: chalk56.gray,
|
|
17177
|
+
error: chalk56.red,
|
|
17178
|
+
starting: chalk56.yellow,
|
|
17179
|
+
created: chalk56.gray,
|
|
17180
|
+
stopping: chalk56.yellow,
|
|
17181
|
+
unknown: chalk56.gray
|
|
16936
17182
|
};
|
|
16937
|
-
const statusColor = statusColorMap[status] ||
|
|
17183
|
+
const statusColor = statusColorMap[status] || chalk56.gray;
|
|
16938
17184
|
return {
|
|
16939
17185
|
id: s.id.substring(0, 8),
|
|
16940
17186
|
name: s.name,
|
|
16941
17187
|
type: s.type,
|
|
16942
17188
|
status: statusColor(status),
|
|
16943
|
-
enabled: s.enabled ?
|
|
17189
|
+
enabled: s.enabled ? chalk56.green("✓") : chalk56.gray("✗")
|
|
16944
17190
|
};
|
|
16945
17191
|
});
|
|
16946
17192
|
output.log(formatSourcesTable(rows));
|
|
16947
|
-
output.
|
|
16948
|
-
output.log(
|
|
17193
|
+
output.log("");
|
|
17194
|
+
output.log(renderPaginationFooter({
|
|
17195
|
+
total,
|
|
17196
|
+
count: sources.length,
|
|
17197
|
+
offset: page.offset,
|
|
17198
|
+
limit: page.limit,
|
|
17199
|
+
itemName: "event source"
|
|
17200
|
+
}));
|
|
16949
17201
|
} catch (error) {
|
|
16950
17202
|
output.error(`Failed to list event sources: ${error}`);
|
|
16951
17203
|
process.exit(1);
|
|
@@ -16956,11 +17208,11 @@ var EventSourceListCommand = {
|
|
|
16956
17208
|
};
|
|
16957
17209
|
|
|
16958
17210
|
// src/commands/eventsource/add.ts
|
|
16959
|
-
import
|
|
17211
|
+
import chalk58 from "chalk";
|
|
16960
17212
|
import { generateId } from "@ai-setting/roy-agent-core";
|
|
16961
17213
|
|
|
16962
17214
|
// src/commands/eventsource/server-url-option.ts
|
|
16963
|
-
import
|
|
17215
|
+
import chalk57 from "chalk";
|
|
16964
17216
|
function addServerUrlOption(yargs) {
|
|
16965
17217
|
return yargs.option("server-url", {
|
|
16966
17218
|
alias: "s",
|
|
@@ -16976,7 +17228,7 @@ function resolveServerUrl(serverUrl, fallback) {
|
|
|
16976
17228
|
return fallback;
|
|
16977
17229
|
const trimmed = serverUrl.replace(/\/+$/, "");
|
|
16978
17230
|
if (!/^(https?|wss?):\/\//.test(trimmed)) {
|
|
16979
|
-
console.error(
|
|
17231
|
+
console.error(chalk57.red(`
|
|
16980
17232
|
✗ Invalid --server-url: "${serverUrl}". Must start with http://, https://, ws://, or wss://
|
|
16981
17233
|
`));
|
|
16982
17234
|
process.exit(1);
|
|
@@ -17069,39 +17321,39 @@ var EventSourceAddCommand = {
|
|
|
17069
17321
|
options: a.prompt ? { prompt: a.prompt } : undefined
|
|
17070
17322
|
};
|
|
17071
17323
|
esComponent.register(config);
|
|
17072
|
-
output.success(
|
|
17324
|
+
output.success(chalk58.green(`事件源 '${a.name}' 添加成功!`));
|
|
17073
17325
|
output.log("");
|
|
17074
|
-
output.log(` ID: ${
|
|
17075
|
-
output.log(` Type: ${
|
|
17326
|
+
output.log(` ID: ${chalk58.gray(config.id)}`);
|
|
17327
|
+
output.log(` Type: ${chalk58.cyan(a.type)}`);
|
|
17076
17328
|
if (eventTypes?.length) {
|
|
17077
|
-
output.log(` Event Types: ${
|
|
17329
|
+
output.log(` Event Types: ${chalk58.gray(eventTypes.join(", "))}`);
|
|
17078
17330
|
}
|
|
17079
17331
|
if (a.command) {
|
|
17080
|
-
output.log(` Command: ${
|
|
17332
|
+
output.log(` Command: ${chalk58.gray(a.command)}`);
|
|
17081
17333
|
}
|
|
17082
17334
|
if (a.interval) {
|
|
17083
|
-
output.log(` Interval: ${
|
|
17335
|
+
output.log(` Interval: ${chalk58.gray(`${a.interval}ms`)}`);
|
|
17084
17336
|
}
|
|
17085
17337
|
if (a.profile) {
|
|
17086
|
-
output.log(` Profile: ${
|
|
17338
|
+
output.log(` Profile: ${chalk58.gray(a.profile)}`);
|
|
17087
17339
|
}
|
|
17088
17340
|
if (a.address) {
|
|
17089
|
-
output.log(` Address: ${
|
|
17341
|
+
output.log(` Address: ${chalk58.gray(a.address)}`);
|
|
17090
17342
|
}
|
|
17091
17343
|
if (a.imServerUrl) {
|
|
17092
|
-
output.log(` IM Server URL: ${
|
|
17344
|
+
output.log(` IM Server URL: ${chalk58.gray(a.imServerUrl)}`);
|
|
17093
17345
|
}
|
|
17094
17346
|
if (resolvedServerUrl) {
|
|
17095
|
-
output.log(` Server URL: ${
|
|
17347
|
+
output.log(` Server URL: ${chalk58.gray(resolvedServerUrl)}`);
|
|
17096
17348
|
}
|
|
17097
17349
|
if (a.tlsSkipVerify) {
|
|
17098
|
-
output.log(` TLS Skip Verify: ${
|
|
17350
|
+
output.log(` TLS Skip Verify: ${chalk58.yellow("⚠ true (自签名场景)")}`);
|
|
17099
17351
|
}
|
|
17100
17352
|
if (a.prompt) {
|
|
17101
|
-
output.log(` Prompt: ${
|
|
17353
|
+
output.log(` Prompt: ${chalk58.gray(a.prompt.length > 60 ? a.prompt.slice(0, 60) + "..." : a.prompt)}`);
|
|
17102
17354
|
}
|
|
17103
17355
|
output.log("");
|
|
17104
|
-
output.log(
|
|
17356
|
+
output.log(chalk58.gray(`使用 'roy-agent eventsource start ${config.id.substring(0, 8)}' 启动它。`));
|
|
17105
17357
|
} finally {
|
|
17106
17358
|
await envService.dispose();
|
|
17107
17359
|
}
|
|
@@ -17109,7 +17361,7 @@ var EventSourceAddCommand = {
|
|
|
17109
17361
|
};
|
|
17110
17362
|
|
|
17111
17363
|
// src/commands/eventsource/update.ts
|
|
17112
|
-
import
|
|
17364
|
+
import chalk59 from "chalk";
|
|
17113
17365
|
function findSource(esComponent, id) {
|
|
17114
17366
|
const sources = esComponent.list();
|
|
17115
17367
|
const matched = sources.find((s) => s.id === id || s.id.startsWith(id));
|
|
@@ -17181,7 +17433,7 @@ var EventSourceUpdateCommand = {
|
|
|
17181
17433
|
const all = esComponent.list();
|
|
17182
17434
|
if (all.length > 0) {
|
|
17183
17435
|
output.info("");
|
|
17184
|
-
output.info(
|
|
17436
|
+
output.info(chalk59.gray("可用的事件源:"));
|
|
17185
17437
|
for (const s of all) {
|
|
17186
17438
|
output.info(` - ${s.id.substring(0, 8)}: ${s.name} (${s.type})`);
|
|
17187
17439
|
}
|
|
@@ -17223,19 +17475,19 @@ var EventSourceUpdateCommand = {
|
|
|
17223
17475
|
}
|
|
17224
17476
|
try {
|
|
17225
17477
|
const result = await esComponent.update(match.fullId, partial);
|
|
17226
|
-
output.success(
|
|
17478
|
+
output.success(chalk59.green(`✅ 事件源已更新: ${match.source.name}`));
|
|
17227
17479
|
output.log("");
|
|
17228
|
-
output.log(
|
|
17480
|
+
output.log(chalk59.bold("修改字段:"));
|
|
17229
17481
|
const before = match.source;
|
|
17230
17482
|
const after = result.updated;
|
|
17231
17483
|
for (const field of result.fields) {
|
|
17232
17484
|
const beforeVal = JSON.stringify(before[field] ?? before.options?.[field]);
|
|
17233
17485
|
const afterVal = JSON.stringify(after[field] ?? after.options?.[field]);
|
|
17234
|
-
output.log(` ${
|
|
17486
|
+
output.log(` ${chalk59.cyan(field)}: ${chalk59.gray(beforeVal)} ${chalk59.gray("→")} ${chalk59.green(afterVal)}`);
|
|
17235
17487
|
}
|
|
17236
17488
|
output.log("");
|
|
17237
17489
|
if (result.wasRunning) {
|
|
17238
|
-
output.info(
|
|
17490
|
+
output.info(chalk59.yellow(`⚠️ 事件源在更新前正在运行,已自动停止。请使用 'roy-agent eventsource start ${match.fullId.substring(0, 8)}' 手动启动以应用新配置。`));
|
|
17239
17491
|
}
|
|
17240
17492
|
} catch (error) {
|
|
17241
17493
|
output.error(`❌ 更新失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -17248,7 +17500,7 @@ var EventSourceUpdateCommand = {
|
|
|
17248
17500
|
};
|
|
17249
17501
|
|
|
17250
17502
|
// src/commands/eventsource/remove.ts
|
|
17251
|
-
import
|
|
17503
|
+
import chalk60 from "chalk";
|
|
17252
17504
|
var EventSourceRemoveCommand = {
|
|
17253
17505
|
command: "remove <id>",
|
|
17254
17506
|
aliases: ["rm"],
|
|
@@ -17287,7 +17539,7 @@ var EventSourceRemoveCommand = {
|
|
|
17287
17539
|
const status = esComponent.getStatus(matchedSource.id);
|
|
17288
17540
|
if (status === "running" && !args.force) {
|
|
17289
17541
|
output.error(`事件源正在运行中,请先停止: ${matchedSource.name} (${status})`);
|
|
17290
|
-
output.log(
|
|
17542
|
+
output.log(chalk60.gray(`使用 --force 强制移除或 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' 先停止`));
|
|
17291
17543
|
process.exit(1);
|
|
17292
17544
|
}
|
|
17293
17545
|
if (status === "running") {
|
|
@@ -17296,7 +17548,7 @@ var EventSourceRemoveCommand = {
|
|
|
17296
17548
|
}
|
|
17297
17549
|
const result = esComponent.unregister(matchedSource.id);
|
|
17298
17550
|
if (result) {
|
|
17299
|
-
output.success(
|
|
17551
|
+
output.success(chalk60.green(`事件源已移除: ${matchedSource.name}`));
|
|
17300
17552
|
} else {
|
|
17301
17553
|
output.error("移除失败");
|
|
17302
17554
|
process.exit(1);
|
|
@@ -17308,7 +17560,7 @@ var EventSourceRemoveCommand = {
|
|
|
17308
17560
|
};
|
|
17309
17561
|
|
|
17310
17562
|
// src/commands/eventsource/start.ts
|
|
17311
|
-
import
|
|
17563
|
+
import chalk61 from "chalk";
|
|
17312
17564
|
var EventSourceStartCommand = {
|
|
17313
17565
|
command: "start <id>",
|
|
17314
17566
|
describe: "启动指定的事件源",
|
|
@@ -17345,15 +17597,15 @@ var EventSourceStartCommand = {
|
|
|
17345
17597
|
}
|
|
17346
17598
|
const status = esComponent.getStatus(matchedSource.id);
|
|
17347
17599
|
if (status === "running") {
|
|
17348
|
-
output.log(
|
|
17600
|
+
output.log(chalk61.yellow(`事件源已在运行: ${matchedSource.name}`));
|
|
17349
17601
|
return;
|
|
17350
17602
|
}
|
|
17351
17603
|
output.info(`正在启动事件源 '${matchedSource.name}'...`);
|
|
17352
17604
|
try {
|
|
17353
17605
|
await esComponent.startSource(matchedSource.id);
|
|
17354
|
-
output.success(
|
|
17606
|
+
output.success(chalk61.green(`事件源已启动: ${matchedSource.name}`));
|
|
17355
17607
|
if (!args.background) {
|
|
17356
|
-
output.log(
|
|
17608
|
+
output.log(chalk61.gray("按 Ctrl+C 停止..."));
|
|
17357
17609
|
await new Promise((resolve) => {
|
|
17358
17610
|
const cleanup = () => {
|
|
17359
17611
|
process.removeListener("SIGINT", cleanup);
|
|
@@ -17375,7 +17627,7 @@ var EventSourceStartCommand = {
|
|
|
17375
17627
|
};
|
|
17376
17628
|
|
|
17377
17629
|
// src/commands/eventsource/stop.ts
|
|
17378
|
-
import
|
|
17630
|
+
import chalk62 from "chalk";
|
|
17379
17631
|
var EventSourceStopCommand = {
|
|
17380
17632
|
command: "stop <id>",
|
|
17381
17633
|
aliases: ["kill"],
|
|
@@ -17413,13 +17665,13 @@ var EventSourceStopCommand = {
|
|
|
17413
17665
|
}
|
|
17414
17666
|
const status = esComponent.getStatus(matchedSource.id);
|
|
17415
17667
|
if (status !== "running") {
|
|
17416
|
-
output.log(
|
|
17668
|
+
output.log(chalk62.yellow(`事件源未运行: ${matchedSource.name} (${status || "unknown"})`));
|
|
17417
17669
|
return;
|
|
17418
17670
|
}
|
|
17419
17671
|
output.info(`正在停止事件源 '${matchedSource.name}'...`);
|
|
17420
17672
|
try {
|
|
17421
17673
|
await esComponent.stopSource(matchedSource.id);
|
|
17422
|
-
output.success(
|
|
17674
|
+
output.success(chalk62.green(`事件源已停止: ${matchedSource.name}`));
|
|
17423
17675
|
} catch (error) {
|
|
17424
17676
|
output.error(`停止失败: ${error}`);
|
|
17425
17677
|
process.exit(1);
|
|
@@ -17431,14 +17683,14 @@ var EventSourceStopCommand = {
|
|
|
17431
17683
|
};
|
|
17432
17684
|
|
|
17433
17685
|
// src/commands/eventsource/status.ts
|
|
17434
|
-
import
|
|
17686
|
+
import chalk63 from "chalk";
|
|
17435
17687
|
var STATUS_COLORS = {
|
|
17436
|
-
created:
|
|
17437
|
-
starting:
|
|
17438
|
-
running:
|
|
17439
|
-
stopping:
|
|
17440
|
-
stopped:
|
|
17441
|
-
error:
|
|
17688
|
+
created: chalk63.gray,
|
|
17689
|
+
starting: chalk63.yellow,
|
|
17690
|
+
running: chalk63.green,
|
|
17691
|
+
stopping: chalk63.yellow,
|
|
17692
|
+
stopped: chalk63.gray,
|
|
17693
|
+
error: chalk63.red
|
|
17442
17694
|
};
|
|
17443
17695
|
var STATUS_ICONS = {
|
|
17444
17696
|
created: "○",
|
|
@@ -17492,7 +17744,7 @@ var EventSourceStatusCommand = {
|
|
|
17492
17744
|
process.exit(1);
|
|
17493
17745
|
}
|
|
17494
17746
|
const status = esComponent.getStatus(matchedSource.id) || "unknown";
|
|
17495
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
17747
|
+
const statusColor = STATUS_COLORS[status] || chalk63.gray;
|
|
17496
17748
|
if (args.json) {
|
|
17497
17749
|
output.json({
|
|
17498
17750
|
id: matchedSource.id,
|
|
@@ -17509,31 +17761,31 @@ var EventSourceStatusCommand = {
|
|
|
17509
17761
|
});
|
|
17510
17762
|
return;
|
|
17511
17763
|
}
|
|
17512
|
-
output.log(
|
|
17764
|
+
output.log(chalk63.bold("事件源详情"));
|
|
17513
17765
|
output.log("─".repeat(50));
|
|
17514
|
-
output.log(` ID: ${
|
|
17515
|
-
output.log(` Name: ${
|
|
17516
|
-
output.log(` Type: ${
|
|
17766
|
+
output.log(` ID: ${chalk63.gray(matchedSource.id)}`);
|
|
17767
|
+
output.log(` Name: ${chalk63.cyan(matchedSource.name)}`);
|
|
17768
|
+
output.log(` Type: ${chalk63.cyan(matchedSource.type)}`);
|
|
17517
17769
|
output.log(` Status: ${statusColor(`${STATUS_ICONS[status]} ${STATUS_LABELS[status]}`)}`);
|
|
17518
|
-
output.log(` Enabled: ${matchedSource.enabled ?
|
|
17770
|
+
output.log(` Enabled: ${matchedSource.enabled ? chalk63.green("是") : chalk63.gray("否")}`);
|
|
17519
17771
|
if (matchedSource.eventTypes?.length) {
|
|
17520
|
-
output.log(` Events: ${
|
|
17772
|
+
output.log(` Events: ${chalk63.gray(matchedSource.eventTypes.join(", "))}`);
|
|
17521
17773
|
}
|
|
17522
17774
|
if (matchedSource.command) {
|
|
17523
|
-
output.log(` Command: ${
|
|
17775
|
+
output.log(` Command: ${chalk63.gray(matchedSource.command)}`);
|
|
17524
17776
|
}
|
|
17525
17777
|
if (matchedSource.interval) {
|
|
17526
|
-
output.log(` Interval: ${
|
|
17778
|
+
output.log(` Interval: ${chalk63.gray(`${matchedSource.interval}ms`)}`);
|
|
17527
17779
|
}
|
|
17528
17780
|
if (matchedSource.url) {
|
|
17529
|
-
output.log(` URL: ${
|
|
17781
|
+
output.log(` URL: ${chalk63.gray(matchedSource.url)}`);
|
|
17530
17782
|
}
|
|
17531
17783
|
output.log("");
|
|
17532
17784
|
return;
|
|
17533
17785
|
}
|
|
17534
17786
|
const sources = esComponent.list();
|
|
17535
17787
|
if (sources.length === 0) {
|
|
17536
|
-
output.log(
|
|
17788
|
+
output.log(chalk63.yellow("没有配置的事件源"));
|
|
17537
17789
|
return;
|
|
17538
17790
|
}
|
|
17539
17791
|
if (args.json) {
|
|
@@ -17547,21 +17799,21 @@ var EventSourceStatusCommand = {
|
|
|
17547
17799
|
output.json({ sources: sourcesWithStatus, count: sources.length });
|
|
17548
17800
|
return;
|
|
17549
17801
|
}
|
|
17550
|
-
output.log(
|
|
17802
|
+
output.log(chalk63.bold("事件源状态概览"));
|
|
17551
17803
|
output.log("─".repeat(60));
|
|
17552
17804
|
for (const source of sources) {
|
|
17553
17805
|
const status = esComponent.getStatus(source.id) || "unknown";
|
|
17554
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
17806
|
+
const statusColor = STATUS_COLORS[status] || chalk63.gray;
|
|
17555
17807
|
const icon = STATUS_ICONS[status] || "?";
|
|
17556
17808
|
const label = STATUS_LABELS[status] || status;
|
|
17557
17809
|
output.log("");
|
|
17558
|
-
output.log(` ${
|
|
17810
|
+
output.log(` ${chalk63.cyan(source.name)} ${chalk63.gray(`(${source.type})`)}`);
|
|
17559
17811
|
output.log(` └─ Status: ${statusColor(`${icon} ${label}`)}`);
|
|
17560
|
-
output.log(` ID: ${
|
|
17812
|
+
output.log(` ID: ${chalk63.gray(source.id.substring(0, 8))}...`);
|
|
17561
17813
|
}
|
|
17562
17814
|
output.log("");
|
|
17563
17815
|
const runningCount = sources.filter((s) => esComponent.getStatus(s.id) === "running").length;
|
|
17564
|
-
output.log(
|
|
17816
|
+
output.log(chalk63.green(`✅ ${runningCount}/${sources.length} 运行中`));
|
|
17565
17817
|
} finally {
|
|
17566
17818
|
await envService.dispose();
|
|
17567
17819
|
}
|
|
@@ -17874,7 +18126,7 @@ var DebugCommand = {
|
|
|
17874
18126
|
};
|
|
17875
18127
|
|
|
17876
18128
|
// src/commands/workflow/renderers.ts
|
|
17877
|
-
import
|
|
18129
|
+
import chalk64 from "chalk";
|
|
17878
18130
|
function truncateVisual3(str, maxWidth) {
|
|
17879
18131
|
if (!str)
|
|
17880
18132
|
return "-";
|
|
@@ -17909,18 +18161,18 @@ function formatDuration(ms) {
|
|
|
17909
18161
|
function statusColor(status) {
|
|
17910
18162
|
switch (status) {
|
|
17911
18163
|
case "completed":
|
|
17912
|
-
return
|
|
18164
|
+
return chalk64.green;
|
|
17913
18165
|
case "running":
|
|
17914
18166
|
case "idle":
|
|
17915
|
-
return
|
|
18167
|
+
return chalk64.blue;
|
|
17916
18168
|
case "paused":
|
|
17917
|
-
return
|
|
18169
|
+
return chalk64.yellow;
|
|
17918
18170
|
case "failed":
|
|
17919
|
-
return
|
|
18171
|
+
return chalk64.red;
|
|
17920
18172
|
case "stopped":
|
|
17921
|
-
return
|
|
18173
|
+
return chalk64.gray;
|
|
17922
18174
|
default:
|
|
17923
|
-
return
|
|
18175
|
+
return chalk64.white;
|
|
17924
18176
|
}
|
|
17925
18177
|
}
|
|
17926
18178
|
function renderWorkflowList(workflows, options) {
|
|
@@ -17939,7 +18191,7 @@ function renderWorkflowList(workflows, options) {
|
|
|
17939
18191
|
}, null, 2);
|
|
17940
18192
|
}
|
|
17941
18193
|
if (workflows.length === 0) {
|
|
17942
|
-
return
|
|
18194
|
+
return chalk64.yellow("No workflows found");
|
|
17943
18195
|
}
|
|
17944
18196
|
const NAME_WIDTH = 30;
|
|
17945
18197
|
const VERSION_WIDTH = 10;
|
|
@@ -17947,10 +18199,10 @@ function renderWorkflowList(workflows, options) {
|
|
|
17947
18199
|
const UPDATED_WIDTH = 20;
|
|
17948
18200
|
const GAP = " ";
|
|
17949
18201
|
const headerLine = [
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
18202
|
+
chalk64.bold("NAME".padEnd(NAME_WIDTH)),
|
|
18203
|
+
chalk64.bold("VER".padEnd(VERSION_WIDTH)),
|
|
18204
|
+
chalk64.bold("TAGS".padEnd(TAGS_WIDTH)),
|
|
18205
|
+
chalk64.bold("UPDATED")
|
|
17954
18206
|
].join(GAP);
|
|
17955
18207
|
const sepLine = "─".repeat(NAME_WIDTH + VERSION_WIDTH + TAGS_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
17956
18208
|
const rows = workflows.map((w) => {
|
|
@@ -17965,18 +18217,18 @@ function renderWorkflowList(workflows, options) {
|
|
|
17965
18217
|
}
|
|
17966
18218
|
function renderWorkflowDetail(workflow, options) {
|
|
17967
18219
|
const lines = [];
|
|
17968
|
-
lines.push(
|
|
18220
|
+
lines.push(chalk64.bold(`
|
|
17969
18221
|
\uD83D\uDCCB Workflow Details
|
|
17970
18222
|
`));
|
|
17971
|
-
lines.push(` ${
|
|
17972
|
-
lines.push(` ${
|
|
17973
|
-
lines.push(` ${
|
|
17974
|
-
lines.push(` ${
|
|
17975
|
-
lines.push(` ${
|
|
17976
|
-
lines.push(` ${
|
|
17977
|
-
lines.push(` ${
|
|
18223
|
+
lines.push(` ${chalk64.cyan("ID:")} ${workflow.id}`);
|
|
18224
|
+
lines.push(` ${chalk64.cyan("Name:")} ${workflow.name}`);
|
|
18225
|
+
lines.push(` ${chalk64.cyan("Version:")} ${workflow.version}`);
|
|
18226
|
+
lines.push(` ${chalk64.cyan("Description:")} ${workflow.description || "-"}`);
|
|
18227
|
+
lines.push(` ${chalk64.cyan("Tags:")} ${workflow.tags.join(", ") || "-"}`);
|
|
18228
|
+
lines.push(` ${chalk64.cyan("Created:")} ${formatDate(workflow.createdAt)}`);
|
|
18229
|
+
lines.push(` ${chalk64.cyan("Updated:")} ${formatDate(workflow.updatedAt)}`);
|
|
17978
18230
|
const nodeCount = workflow.definition.nodes.length;
|
|
17979
|
-
lines.push(
|
|
18231
|
+
lines.push(chalk64.bold(`
|
|
17980
18232
|
\uD83D\uDCCA Nodes Summary
|
|
17981
18233
|
`));
|
|
17982
18234
|
lines.push(` Total: ${nodeCount} nodes`);
|
|
@@ -17988,7 +18240,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
17988
18240
|
lines.push(` - ${type}: ${count}`);
|
|
17989
18241
|
}
|
|
17990
18242
|
if (workflow.definition.config) {
|
|
17991
|
-
lines.push(
|
|
18243
|
+
lines.push(chalk64.bold(`
|
|
17992
18244
|
⚙️ Configuration
|
|
17993
18245
|
`));
|
|
17994
18246
|
if (workflow.definition.config.parallel_limit !== undefined) {
|
|
@@ -18002,7 +18254,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
18002
18254
|
}
|
|
18003
18255
|
}
|
|
18004
18256
|
if (options?.includeRuns && options.includeRuns.length > 0) {
|
|
18005
|
-
lines.push(
|
|
18257
|
+
lines.push(chalk64.bold(`
|
|
18006
18258
|
\uD83D\uDCDC Recent Runs
|
|
18007
18259
|
`));
|
|
18008
18260
|
lines.push(renderRunsList(options.includeRuns.slice(0, 5)));
|
|
@@ -18026,7 +18278,7 @@ function renderRunsList(runs, options) {
|
|
|
18026
18278
|
}, null, 2);
|
|
18027
18279
|
}
|
|
18028
18280
|
if (runs.length === 0) {
|
|
18029
|
-
return
|
|
18281
|
+
return chalk64.yellow("No runs found");
|
|
18030
18282
|
}
|
|
18031
18283
|
const ID_WIDTH = 20;
|
|
18032
18284
|
const STATUS_WIDTH = 12;
|
|
@@ -18034,10 +18286,10 @@ function renderRunsList(runs, options) {
|
|
|
18034
18286
|
const UPDATED_WIDTH = 20;
|
|
18035
18287
|
const GAP = " ";
|
|
18036
18288
|
const headerLine = [
|
|
18037
|
-
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
|
|
18289
|
+
chalk64.bold("RUN ID".padEnd(ID_WIDTH)),
|
|
18290
|
+
chalk64.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
18291
|
+
chalk64.bold("DURATION".padEnd(DURATION_WIDTH)),
|
|
18292
|
+
chalk64.bold("STARTED")
|
|
18041
18293
|
].join(GAP);
|
|
18042
18294
|
const sepLine = "─".repeat(ID_WIDTH + STATUS_WIDTH + DURATION_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
18043
18295
|
const rows = runs.map((r) => {
|
|
@@ -18052,34 +18304,34 @@ function renderRunsList(runs, options) {
|
|
|
18052
18304
|
}
|
|
18053
18305
|
function renderRunDetail(run) {
|
|
18054
18306
|
const lines = [];
|
|
18055
|
-
lines.push(
|
|
18307
|
+
lines.push(chalk64.bold(`
|
|
18056
18308
|
\uD83C\uDFC3 Run Details
|
|
18057
18309
|
`));
|
|
18058
|
-
lines.push(` ${
|
|
18059
|
-
lines.push(` ${
|
|
18060
|
-
lines.push(` ${
|
|
18061
|
-
lines.push(` ${
|
|
18310
|
+
lines.push(` ${chalk64.cyan("Run ID:")} ${run.id}`);
|
|
18311
|
+
lines.push(` ${chalk64.cyan("Workflow:")} ${run.workflowId}`);
|
|
18312
|
+
lines.push(` ${chalk64.cyan("Status:")} ${statusColor(run.status)(run.status)}`);
|
|
18313
|
+
lines.push(` ${chalk64.cyan("Started:")} ${formatDate(run.startedAt)}`);
|
|
18062
18314
|
if (run.pausedAt) {
|
|
18063
|
-
lines.push(` ${
|
|
18315
|
+
lines.push(` ${chalk64.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
|
|
18064
18316
|
}
|
|
18065
18317
|
if (run.resumedAt) {
|
|
18066
|
-
lines.push(` ${
|
|
18318
|
+
lines.push(` ${chalk64.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
|
|
18067
18319
|
}
|
|
18068
18320
|
if (run.stoppedAt) {
|
|
18069
|
-
lines.push(` ${
|
|
18321
|
+
lines.push(` ${chalk64.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
|
|
18070
18322
|
}
|
|
18071
18323
|
if (run.completedAt) {
|
|
18072
|
-
lines.push(` ${
|
|
18324
|
+
lines.push(` ${chalk64.cyan("Completed:")} ${formatDate(run.completedAt)}`);
|
|
18073
18325
|
}
|
|
18074
|
-
lines.push(` ${
|
|
18326
|
+
lines.push(` ${chalk64.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
|
|
18075
18327
|
if (run.error) {
|
|
18076
|
-
lines.push(
|
|
18328
|
+
lines.push(chalk64.bold(`
|
|
18077
18329
|
❌ Error
|
|
18078
18330
|
`));
|
|
18079
|
-
lines.push(` ${
|
|
18331
|
+
lines.push(` ${chalk64.red(run.error)}`);
|
|
18080
18332
|
}
|
|
18081
18333
|
if (run.output) {
|
|
18082
|
-
lines.push(
|
|
18334
|
+
lines.push(chalk64.bold(`
|
|
18083
18335
|
\uD83D\uDCE4 Output
|
|
18084
18336
|
`));
|
|
18085
18337
|
lines.push(" " + JSON.stringify(run.output, null, 2).split(`
|
|
@@ -18090,36 +18342,36 @@ function renderRunDetail(run) {
|
|
|
18090
18342
|
`);
|
|
18091
18343
|
}
|
|
18092
18344
|
function renderWorkflowAdded(workflow) {
|
|
18093
|
-
return
|
|
18345
|
+
return chalk64.green(`
|
|
18094
18346
|
✅ Workflow '${workflow.name}' added successfully
|
|
18095
18347
|
`) + ` ID: ${workflow.id}
|
|
18096
18348
|
` + ` Version: ${workflow.version}
|
|
18097
18349
|
`;
|
|
18098
18350
|
}
|
|
18099
18351
|
function renderWorkflowUpdated(workflow) {
|
|
18100
|
-
return
|
|
18352
|
+
return chalk64.green(`
|
|
18101
18353
|
✅ Workflow '${workflow.name}' updated successfully
|
|
18102
18354
|
`) + ` ID: ${workflow.id}
|
|
18103
18355
|
`;
|
|
18104
18356
|
}
|
|
18105
18357
|
function renderWorkflowDeleted(name) {
|
|
18106
|
-
return
|
|
18358
|
+
return chalk64.green(`
|
|
18107
18359
|
✅ Workflow '${name}' deleted successfully
|
|
18108
18360
|
`);
|
|
18109
18361
|
}
|
|
18110
18362
|
function renderRunResult(result) {
|
|
18111
18363
|
const lines = [];
|
|
18112
18364
|
if (result.status === "completed") {
|
|
18113
|
-
lines.push(
|
|
18365
|
+
lines.push(chalk64.green(`
|
|
18114
18366
|
✅ Workflow completed successfully`));
|
|
18115
18367
|
} else if (result.status === "failed") {
|
|
18116
|
-
lines.push(
|
|
18368
|
+
lines.push(chalk64.red(`
|
|
18117
18369
|
❌ Workflow failed`));
|
|
18118
18370
|
} else if (result.status === "stopped") {
|
|
18119
|
-
lines.push(
|
|
18371
|
+
lines.push(chalk64.yellow(`
|
|
18120
18372
|
⚠️ Workflow stopped`));
|
|
18121
18373
|
} else {
|
|
18122
|
-
lines.push(
|
|
18374
|
+
lines.push(chalk64.blue(`
|
|
18123
18375
|
\uD83D\uDD04 Workflow ${result.status}`));
|
|
18124
18376
|
}
|
|
18125
18377
|
lines.push(` Run ID: ${result.runId}`);
|
|
@@ -18127,11 +18379,11 @@ function renderRunResult(result) {
|
|
|
18127
18379
|
lines.push(` Duration: ${formatDuration(result.durationMs)}`);
|
|
18128
18380
|
}
|
|
18129
18381
|
if (result.error) {
|
|
18130
|
-
lines.push(
|
|
18382
|
+
lines.push(chalk64.red(`
|
|
18131
18383
|
Error: ${result.error}`));
|
|
18132
18384
|
}
|
|
18133
18385
|
if (result.output) {
|
|
18134
|
-
lines.push(
|
|
18386
|
+
lines.push(chalk64.bold(`
|
|
18135
18387
|
\uD83D\uDCE4 Output:`));
|
|
18136
18388
|
lines.push(JSON.stringify(result.output, null, 2));
|
|
18137
18389
|
}
|
|
@@ -18145,10 +18397,10 @@ function renderNodesList(nodes) {
|
|
|
18145
18397
|
const DEPS_WIDTH = 20;
|
|
18146
18398
|
const GAP = " ";
|
|
18147
18399
|
const headerLine = [
|
|
18148
|
-
|
|
18149
|
-
|
|
18150
|
-
|
|
18151
|
-
|
|
18400
|
+
chalk64.bold("NODE ID".padEnd(ID_WIDTH)),
|
|
18401
|
+
chalk64.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
18402
|
+
chalk64.bold("NAME".padEnd(NAME_WIDTH)),
|
|
18403
|
+
chalk64.bold("DEPENDS ON")
|
|
18152
18404
|
].join(GAP);
|
|
18153
18405
|
const sepLine = "─".repeat(ID_WIDTH + TYPE_WIDTH + NAME_WIDTH + DEPS_WIDTH + GAP.length * 3);
|
|
18154
18406
|
const rows = nodes.map((n) => {
|
|
@@ -18163,7 +18415,7 @@ function renderNodesList(nodes) {
|
|
|
18163
18415
|
}
|
|
18164
18416
|
|
|
18165
18417
|
// src/commands/workflow/commands/list.ts
|
|
18166
|
-
import
|
|
18418
|
+
import chalk65 from "chalk";
|
|
18167
18419
|
import { createWorkflowListTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18168
18420
|
function buildListWorkflowsJson(workflows, total, args, availableTags) {
|
|
18169
18421
|
const output = {
|
|
@@ -18194,10 +18446,10 @@ var WorkflowListCommand = {
|
|
|
18194
18446
|
describe: "搜索 description 和 tags(支持 AND/OR/NOT 语法)",
|
|
18195
18447
|
type: "string"
|
|
18196
18448
|
}).option("limit", {
|
|
18197
|
-
alias: "l",
|
|
18198
|
-
describe: "
|
|
18449
|
+
alias: ["l", "n"],
|
|
18450
|
+
describe: "返回数量限制(-l 旧 alias, -n 新统一 alias)",
|
|
18199
18451
|
type: "number",
|
|
18200
|
-
default:
|
|
18452
|
+
default: 20
|
|
18201
18453
|
}).option("offset", {
|
|
18202
18454
|
alias: "o",
|
|
18203
18455
|
describe: "分页偏移",
|
|
@@ -18295,6 +18547,18 @@ var WorkflowListCommand = {
|
|
|
18295
18547
|
offset: finalOffset,
|
|
18296
18548
|
page: page > 1 ? page : Math.floor(finalOffset / pageSize) + 1
|
|
18297
18549
|
}, availableTags));
|
|
18550
|
+
} else if (args.quiet) {
|
|
18551
|
+
output.log(renderQuietHeader(total, "workflow"));
|
|
18552
|
+
workflows.forEach((w) => output.log(renderQuietLine(w.name, w.name)));
|
|
18553
|
+
const hint = renderQuietPaginationHint({
|
|
18554
|
+
count: workflows.length,
|
|
18555
|
+
total,
|
|
18556
|
+
offset: finalOffset,
|
|
18557
|
+
limit: pageSize
|
|
18558
|
+
});
|
|
18559
|
+
if (hint)
|
|
18560
|
+
output.log(hint);
|
|
18561
|
+
return;
|
|
18298
18562
|
} else {
|
|
18299
18563
|
const renderWorkflows = workflows.map((w) => ({
|
|
18300
18564
|
id: w.name,
|
|
@@ -18311,20 +18575,20 @@ var WorkflowListCommand = {
|
|
|
18311
18575
|
if (total > workflows.length) {
|
|
18312
18576
|
const start = finalOffset + 1;
|
|
18313
18577
|
const end = finalOffset + workflows.length;
|
|
18314
|
-
output.log(
|
|
18578
|
+
output.log(chalk65.green(`
|
|
18315
18579
|
✅ 显示 ${start}-${end} / 共 ${total} 个 Workflow`));
|
|
18316
18580
|
const totalPages = Math.ceil(total / pageSize);
|
|
18317
18581
|
const currentPage = Math.floor(finalOffset / pageSize) + 1;
|
|
18318
18582
|
if (totalPages > 1) {
|
|
18319
|
-
output.log(
|
|
18583
|
+
output.log(chalk65.cyan(`\uD83D\uDCC4 第 ${currentPage} / ${totalPages} 页`));
|
|
18320
18584
|
}
|
|
18321
18585
|
} else {
|
|
18322
|
-
output.log(
|
|
18586
|
+
output.log(chalk65.green(`
|
|
18323
18587
|
✅ 共 ${total} 个 Workflow`));
|
|
18324
18588
|
}
|
|
18325
18589
|
if (availableTags.length > 0) {
|
|
18326
18590
|
const tagsLine = availableTags.map((t) => `${t.name}(${t.count})`).join(", ");
|
|
18327
|
-
output.log(
|
|
18591
|
+
output.log(chalk65.cyan(`
|
|
18328
18592
|
\uD83C\uDFF7️ Available tags: ${tagsLine}`));
|
|
18329
18593
|
}
|
|
18330
18594
|
}
|
|
@@ -18928,7 +19192,7 @@ class WorkflowValidator {
|
|
|
18928
19192
|
|
|
18929
19193
|
// src/commands/workflow/commands/add.ts
|
|
18930
19194
|
import { validateWorkflowDefinition } from "@ai-setting/roy-agent-core/env/workflow/utils";
|
|
18931
|
-
import
|
|
19195
|
+
import chalk66 from "chalk";
|
|
18932
19196
|
import fs3 from "fs";
|
|
18933
19197
|
import path6 from "path";
|
|
18934
19198
|
async function parseWorkflowContent(content, filename) {
|
|
@@ -19070,7 +19334,7 @@ var WorkflowAddCommand = {
|
|
|
19070
19334
|
definition = await parseWorkflowContent(content, filePath);
|
|
19071
19335
|
workflowName = a.name || definition.name || path6.basename(filePath);
|
|
19072
19336
|
if (a.validate) {
|
|
19073
|
-
output.log(
|
|
19337
|
+
output.log(chalk66.blue("\uD83D\uDD0D Validating workflow..."));
|
|
19074
19338
|
const dagResult = validateWorkflowDefinition(definition);
|
|
19075
19339
|
if (!dagResult.valid) {
|
|
19076
19340
|
output.error(`
|
|
@@ -19094,11 +19358,11 @@ var WorkflowAddCommand = {
|
|
|
19094
19358
|
});
|
|
19095
19359
|
process.exit(1);
|
|
19096
19360
|
}
|
|
19097
|
-
output.log(
|
|
19361
|
+
output.log(chalk66.green(`✅ Workflow validation passed
|
|
19098
19362
|
`));
|
|
19099
19363
|
}
|
|
19100
19364
|
} else if (a.desc) {
|
|
19101
|
-
output.log(
|
|
19365
|
+
output.log(chalk66.blue(`\uD83E\uDD16 Generating workflow from description...
|
|
19102
19366
|
`));
|
|
19103
19367
|
const agentComponent = env.getComponent("agent");
|
|
19104
19368
|
if (!agentComponent) {
|
|
@@ -19120,20 +19384,20 @@ ${a.desc}
|
|
|
19120
19384
|
1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
|
|
19121
19385
|
2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
|
|
19122
19386
|
3. 验证通过后才输出最终 YAML`;
|
|
19123
|
-
output.log(
|
|
19387
|
+
output.log(chalk66.gray("Running workflow-extract agent..."));
|
|
19124
19388
|
const result = await agentComponent.run("workflow-extract", prompt);
|
|
19125
19389
|
const agentOutput = result.finalText || "";
|
|
19126
19390
|
definition = parseYamlFromAgentOutput(agentOutput);
|
|
19127
19391
|
if (definition === null) {
|
|
19128
19392
|
output.error("Failed to parse workflow from agent output");
|
|
19129
|
-
output.log(
|
|
19393
|
+
output.log(chalk66.gray(`
|
|
19130
19394
|
Agent output:
|
|
19131
19395
|
` + agentOutput.slice(0, 500)));
|
|
19132
19396
|
process.exit(1);
|
|
19133
19397
|
}
|
|
19134
19398
|
workflowName = a.name || definition.name;
|
|
19135
19399
|
if (a.validate) {
|
|
19136
|
-
output.log(
|
|
19400
|
+
output.log(chalk66.blue(`
|
|
19137
19401
|
\uD83D\uDD0D Validating generated workflow...`));
|
|
19138
19402
|
const dagResult = validateWorkflowDefinition(definition);
|
|
19139
19403
|
if (!dagResult.valid) {
|
|
@@ -19142,7 +19406,7 @@ Agent output:
|
|
|
19142
19406
|
dagResult.errors.forEach((msg, i) => {
|
|
19143
19407
|
output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
|
|
19144
19408
|
});
|
|
19145
|
-
output.log(
|
|
19409
|
+
output.log(chalk66.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
19146
19410
|
process.exit(1);
|
|
19147
19411
|
}
|
|
19148
19412
|
const validator = new WorkflowValidator;
|
|
@@ -19157,16 +19421,16 @@ Agent output:
|
|
|
19157
19421
|
output.error(` Fix: ${error.fix}
|
|
19158
19422
|
`);
|
|
19159
19423
|
});
|
|
19160
|
-
output.log(
|
|
19424
|
+
output.log(chalk66.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
19161
19425
|
process.exit(1);
|
|
19162
19426
|
}
|
|
19163
|
-
output.log(
|
|
19427
|
+
output.log(chalk66.green(`✅ Generated workflow validation passed
|
|
19164
19428
|
`));
|
|
19165
19429
|
}
|
|
19166
19430
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
19167
|
-
output.log(
|
|
19431
|
+
output.log(chalk66.gray("--- Generated YAML ---"));
|
|
19168
19432
|
output.log(yaml.stringify(definition));
|
|
19169
|
-
output.log(
|
|
19433
|
+
output.log(chalk66.gray(`------------------------
|
|
19170
19434
|
`));
|
|
19171
19435
|
} else {
|
|
19172
19436
|
output.error("Please provide --file or --desc option");
|
|
@@ -19192,10 +19456,10 @@ Agent output:
|
|
|
19192
19456
|
force: a.force
|
|
19193
19457
|
});
|
|
19194
19458
|
output.log(renderWorkflowAdded(workflow));
|
|
19195
|
-
output.log(
|
|
19459
|
+
output.log(chalk66.bold(`
|
|
19196
19460
|
\uD83D\uDCCA Nodes Summary:`));
|
|
19197
19461
|
output.log(renderNodesList(definition.nodes));
|
|
19198
|
-
output.log(
|
|
19462
|
+
output.log(chalk66.green(`
|
|
19199
19463
|
✅ Workflow '${workflowName}' added successfully`));
|
|
19200
19464
|
} catch (error) {
|
|
19201
19465
|
if (error.message?.includes("already exists") && !a.force) {
|
|
@@ -19212,7 +19476,7 @@ Agent output:
|
|
|
19212
19476
|
};
|
|
19213
19477
|
|
|
19214
19478
|
// src/commands/workflow/commands/get.ts
|
|
19215
|
-
import
|
|
19479
|
+
import chalk67 from "chalk";
|
|
19216
19480
|
import { createWorkflowGetTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
19217
19481
|
var WorkflowGetCommand = {
|
|
19218
19482
|
command: "get <identifier>",
|
|
@@ -19350,15 +19614,15 @@ var WorkflowGetCommand = {
|
|
|
19350
19614
|
} else {
|
|
19351
19615
|
output.log(renderWorkflowDetail(workflow, { includeRuns: runs }));
|
|
19352
19616
|
if (args.includeNodes) {
|
|
19353
|
-
output.log(
|
|
19617
|
+
output.log(chalk67.bold(`
|
|
19354
19618
|
\uD83D\uDCCB All Nodes:`));
|
|
19355
19619
|
output.log(renderNodesList(data.nodes || []));
|
|
19356
19620
|
}
|
|
19357
19621
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
19358
19622
|
const defYaml = yaml.stringify(data.definition || {}, { indent: 2 });
|
|
19359
|
-
output.log(
|
|
19623
|
+
output.log(chalk67.bold(`
|
|
19360
19624
|
\uD83D\uDCC4 Definition (YAML):`));
|
|
19361
|
-
output.log(
|
|
19625
|
+
output.log(chalk67.gray(defYaml));
|
|
19362
19626
|
}
|
|
19363
19627
|
}
|
|
19364
19628
|
} catch (error) {
|
|
@@ -19371,7 +19635,7 @@ var WorkflowGetCommand = {
|
|
|
19371
19635
|
};
|
|
19372
19636
|
|
|
19373
19637
|
// src/commands/workflow/commands/update.ts
|
|
19374
|
-
import
|
|
19638
|
+
import chalk68 from "chalk";
|
|
19375
19639
|
import fs4 from "fs";
|
|
19376
19640
|
import path7 from "path";
|
|
19377
19641
|
import { parseWorkflowFile } from "@ai-setting/roy-agent-core/env/workflow/types";
|
|
@@ -19444,7 +19708,7 @@ var WorkflowUpdateCommand = {
|
|
|
19444
19708
|
const tags = a.tags ? a.tags.split(",").map((t) => t.trim()) : undefined;
|
|
19445
19709
|
const workflow = await service.updateWorkflow(a.name, updates, { tags });
|
|
19446
19710
|
output.log(renderWorkflowUpdated(workflow));
|
|
19447
|
-
output.log(
|
|
19711
|
+
output.log(chalk68.green(`
|
|
19448
19712
|
✅ Workflow '${a.name}' updated successfully`));
|
|
19449
19713
|
} catch (error) {
|
|
19450
19714
|
output.error(`Failed to update workflow: ${error}`);
|
|
@@ -19456,7 +19720,7 @@ var WorkflowUpdateCommand = {
|
|
|
19456
19720
|
};
|
|
19457
19721
|
|
|
19458
19722
|
// src/commands/workflow/commands/remove.ts
|
|
19459
|
-
import
|
|
19723
|
+
import chalk69 from "chalk";
|
|
19460
19724
|
var WorkflowRemoveCommand = {
|
|
19461
19725
|
command: "remove <name>",
|
|
19462
19726
|
describe: "删除 Workflow",
|
|
@@ -19495,8 +19759,8 @@ var WorkflowRemoveCommand = {
|
|
|
19495
19759
|
process.exit(1);
|
|
19496
19760
|
}
|
|
19497
19761
|
if (!args.force) {
|
|
19498
|
-
output.log(
|
|
19499
|
-
output.log(
|
|
19762
|
+
output.log(chalk69.yellow(`Are you sure you want to delete workflow '${args.name}'?`));
|
|
19763
|
+
output.log(chalk69.gray("Use --force to skip confirmation"));
|
|
19500
19764
|
process.exit(1);
|
|
19501
19765
|
}
|
|
19502
19766
|
const deleted = await service.deleteWorkflow(args.name);
|
|
@@ -19516,7 +19780,7 @@ var WorkflowRemoveCommand = {
|
|
|
19516
19780
|
|
|
19517
19781
|
// src/commands/workflow/commands/run.ts
|
|
19518
19782
|
var import_yaml = __toESM(require_dist(), 1);
|
|
19519
|
-
import
|
|
19783
|
+
import chalk70 from "chalk";
|
|
19520
19784
|
import fs5 from "fs";
|
|
19521
19785
|
import path8 from "path";
|
|
19522
19786
|
import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
@@ -19603,43 +19867,24 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19603
19867
|
}
|
|
19604
19868
|
if (args.session) {
|
|
19605
19869
|
const sessionId = args.session;
|
|
19606
|
-
output.log(
|
|
19607
|
-
|
|
19608
|
-
|
|
19609
|
-
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19613
|
-
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
|
|
19617
|
-
|
|
19618
|
-
|
|
19619
|
-
|
|
19620
|
-
|
|
19621
|
-
|
|
19622
|
-
|
|
19623
|
-
if (!workflowName) {
|
|
19624
|
-
output.error("Workflow name not found in session metadata");
|
|
19625
|
-
process.exit(1);
|
|
19626
|
-
}
|
|
19627
|
-
const workflow = service.getWorkflowByName(workflowName);
|
|
19628
|
-
if (!workflow) {
|
|
19629
|
-
output.error(`Workflow not found: ${workflowName}`);
|
|
19630
|
-
process.exit(1);
|
|
19870
|
+
output.log(chalk70.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
19871
|
+
try {
|
|
19872
|
+
const resumeInput = typeof input === "string" ? { userQuery: input } : input;
|
|
19873
|
+
const result = await service.resumeSession(sessionId, {
|
|
19874
|
+
...runOptions,
|
|
19875
|
+
...resumeInput !== undefined ? { input: resumeInput } : {}
|
|
19876
|
+
});
|
|
19877
|
+
output.log(renderRunResult({
|
|
19878
|
+
runId: sessionId,
|
|
19879
|
+
status: result.status,
|
|
19880
|
+
output: result.output,
|
|
19881
|
+
error: result.error,
|
|
19882
|
+
durationMs: result.durationMs
|
|
19883
|
+
}));
|
|
19884
|
+
} catch (err) {
|
|
19885
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
19886
|
+
output.error(`Failed to resume session ${sessionId}: ${msg}`);
|
|
19631
19887
|
}
|
|
19632
|
-
const engine = service.engineFactory(workflow);
|
|
19633
|
-
const result = await engine.run(sessionId, {
|
|
19634
|
-
input: input || undefined
|
|
19635
|
-
});
|
|
19636
|
-
output.log(renderRunResult({
|
|
19637
|
-
runId: sessionId,
|
|
19638
|
-
status: result.status,
|
|
19639
|
-
output: result.output,
|
|
19640
|
-
error: result.error,
|
|
19641
|
-
durationMs: result.durationMs
|
|
19642
|
-
}));
|
|
19643
19888
|
if (workflowSpan) {
|
|
19644
19889
|
workflowSpan.end();
|
|
19645
19890
|
}
|
|
@@ -19665,17 +19910,17 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19665
19910
|
definition = { ...definition, name: args.name };
|
|
19666
19911
|
}
|
|
19667
19912
|
const workflow = await service.createWorkflow(definition, { force: true });
|
|
19668
|
-
output.log(
|
|
19669
|
-
output.log(
|
|
19913
|
+
output.log(chalk70.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
|
|
19914
|
+
output.log(chalk70.green(`✅ Workflow registered: ${workflow.name} (${workflow.id})`));
|
|
19670
19915
|
if (args.registerOnly) {
|
|
19671
|
-
output.log(
|
|
19916
|
+
output.log(chalk70.gray("ℹ️ Use --register-only, skipping execution"));
|
|
19672
19917
|
if (workflowSpan) {
|
|
19673
19918
|
workflowSpan.end();
|
|
19674
19919
|
}
|
|
19675
19920
|
await envService.dispose();
|
|
19676
19921
|
process.exit(0);
|
|
19677
19922
|
}
|
|
19678
|
-
output.log(
|
|
19923
|
+
output.log(chalk70.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
|
|
19679
19924
|
const result = await service.runWorkflow(definition, input, runOptions);
|
|
19680
19925
|
output.log(renderRunResult({
|
|
19681
19926
|
runId: result.runId,
|
|
@@ -19685,7 +19930,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19685
19930
|
durationMs: result.durationMs
|
|
19686
19931
|
}));
|
|
19687
19932
|
if (result.status === "paused") {
|
|
19688
|
-
output.log(
|
|
19933
|
+
output.log(chalk70.gray(`
|
|
19689
19934
|
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session ${result.runId} --input '<response>'" to resume`));
|
|
19690
19935
|
}
|
|
19691
19936
|
} else {
|
|
@@ -19708,7 +19953,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19708
19953
|
durationMs: runData.duration_ms
|
|
19709
19954
|
}));
|
|
19710
19955
|
if (runData.status === "paused") {
|
|
19711
|
-
output.log(
|
|
19956
|
+
output.log(chalk70.gray(`
|
|
19712
19957
|
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session ${runData.run_id} --input '<response>'" to resume`));
|
|
19713
19958
|
}
|
|
19714
19959
|
}
|
|
@@ -19780,7 +20025,7 @@ var WorkflowRunCommand = {
|
|
|
19780
20025
|
};
|
|
19781
20026
|
|
|
19782
20027
|
// src/commands/workflow/commands/stop.ts
|
|
19783
|
-
import
|
|
20028
|
+
import chalk71 from "chalk";
|
|
19784
20029
|
import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
19785
20030
|
import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
|
|
19786
20031
|
var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
@@ -19805,7 +20050,7 @@ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
|
19805
20050
|
output.error(result.error || `Failed to stop workflow: ${args.runId}`);
|
|
19806
20051
|
process.exit(1);
|
|
19807
20052
|
}
|
|
19808
|
-
output.log(
|
|
20053
|
+
output.log(chalk71.red(`
|
|
19809
20054
|
⏹️ Workflow stopped: ${args.runId}`));
|
|
19810
20055
|
} catch (error) {
|
|
19811
20056
|
output.error(`Failed to stop workflow: ${error}`);
|
|
@@ -19829,7 +20074,7 @@ var WorkflowStopCommand = {
|
|
|
19829
20074
|
};
|
|
19830
20075
|
|
|
19831
20076
|
// src/commands/workflow/commands/status.ts
|
|
19832
|
-
import
|
|
20077
|
+
import chalk72 from "chalk";
|
|
19833
20078
|
import { createWorkflowRunStatusTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
19834
20079
|
var WorkflowStatusCommand = {
|
|
19835
20080
|
command: "status <runId>",
|
|
@@ -19922,7 +20167,7 @@ var WorkflowStatusCommand = {
|
|
|
19922
20167
|
stopped: "⏹️"
|
|
19923
20168
|
};
|
|
19924
20169
|
const emoji = statusEmoji[status] || "❓";
|
|
19925
|
-
output.log(
|
|
20170
|
+
output.log(chalk72.bold(`
|
|
19926
20171
|
${emoji} Status: ${status.toUpperCase()}`));
|
|
19927
20172
|
}
|
|
19928
20173
|
} catch (error) {
|
|
@@ -19935,7 +20180,7 @@ ${emoji} Status: ${status.toUpperCase()}`));
|
|
|
19935
20180
|
};
|
|
19936
20181
|
|
|
19937
20182
|
// src/commands/workflow/commands/nodes.ts
|
|
19938
|
-
import
|
|
20183
|
+
import chalk73 from "chalk";
|
|
19939
20184
|
var BUILT_IN_NODES = [
|
|
19940
20185
|
{
|
|
19941
20186
|
name: "ToolNode",
|
|
@@ -20272,7 +20517,7 @@ nodes:
|
|
|
20272
20517
|
];
|
|
20273
20518
|
function renderNodeTypesTable(nodes) {
|
|
20274
20519
|
const lines = [];
|
|
20275
|
-
lines.push(
|
|
20520
|
+
lines.push(chalk73.bold(`
|
|
20276
20521
|
\uD83D\uDCE6 Built-in Node Types
|
|
20277
20522
|
`));
|
|
20278
20523
|
lines.push("┌────────────┬────────────────────┬─────────────────────────────────────────────────────────────┐");
|
|
@@ -20290,29 +20535,29 @@ function renderNodeTypesTable(nodes) {
|
|
|
20290
20535
|
}
|
|
20291
20536
|
function renderNodeDetail(node) {
|
|
20292
20537
|
const lines = [];
|
|
20293
|
-
lines.push(
|
|
20538
|
+
lines.push(chalk73.bold(`
|
|
20294
20539
|
[${node.type}] ${node.name}`));
|
|
20295
|
-
lines.push(
|
|
20540
|
+
lines.push(chalk73.dim("─".repeat(60)) + `
|
|
20296
20541
|
`);
|
|
20297
|
-
lines.push(
|
|
20542
|
+
lines.push(chalk73.bold("Description:"));
|
|
20298
20543
|
lines.push(` ${node.description}
|
|
20299
20544
|
`);
|
|
20300
|
-
lines.push(
|
|
20545
|
+
lines.push(chalk73.bold("Configuration:"));
|
|
20301
20546
|
lines.push(' type: "' + node.type + '"');
|
|
20302
20547
|
lines.push(" config:");
|
|
20303
20548
|
for (const input of node.inputs) {
|
|
20304
|
-
const required = input.required ?
|
|
20549
|
+
const required = input.required ? chalk73.red("*") : " ";
|
|
20305
20550
|
lines.push(` ${input.name} (${input.type})${required}`);
|
|
20306
20551
|
lines.push(` ${input.description}`);
|
|
20307
20552
|
}
|
|
20308
20553
|
lines.push(`
|
|
20309
|
-
${
|
|
20554
|
+
${chalk73.bold("Output:")} ${node.output}`);
|
|
20310
20555
|
if (node.example) {
|
|
20311
|
-
lines.push(
|
|
20556
|
+
lines.push(chalk73.bold(`
|
|
20312
20557
|
Example:`));
|
|
20313
|
-
lines.push(
|
|
20558
|
+
lines.push(chalk73.gray("```yaml"));
|
|
20314
20559
|
lines.push(node.example);
|
|
20315
|
-
lines.push(
|
|
20560
|
+
lines.push(chalk73.gray("```"));
|
|
20316
20561
|
}
|
|
20317
20562
|
return lines.join(`
|
|
20318
20563
|
`);
|
|
@@ -20328,16 +20573,16 @@ var WorkflowNodesCommand = {
|
|
|
20328
20573
|
const nodeType = args.type?.toLowerCase();
|
|
20329
20574
|
if (!nodeType) {
|
|
20330
20575
|
console.log(renderNodeTypesTable(BUILT_IN_NODES));
|
|
20331
|
-
console.log(
|
|
20332
|
-
Use `) +
|
|
20333
|
-
console.log(
|
|
20576
|
+
console.log(chalk73.gray(`
|
|
20577
|
+
Use `) + chalk73.cyan("roy-agent workflow nodes <type>") + chalk73.gray(" for detailed information"));
|
|
20578
|
+
console.log(chalk73.gray("Available types: ") + chalk73.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
20334
20579
|
return;
|
|
20335
20580
|
}
|
|
20336
20581
|
const node = BUILT_IN_NODES.find((n) => n.type === nodeType);
|
|
20337
20582
|
if (!node) {
|
|
20338
|
-
console.log(
|
|
20583
|
+
console.log(chalk73.red(`
|
|
20339
20584
|
❌ Unknown node type: ${nodeType}`));
|
|
20340
|
-
console.log(
|
|
20585
|
+
console.log(chalk73.gray("Available types: ") + chalk73.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
20341
20586
|
process.exit(1);
|
|
20342
20587
|
}
|
|
20343
20588
|
console.log(renderNodeDetail(node));
|
|
@@ -20345,7 +20590,7 @@ Use `) + chalk72.cyan("roy-agent workflow nodes <type>") + chalk72.gray(" for de
|
|
|
20345
20590
|
};
|
|
20346
20591
|
|
|
20347
20592
|
// src/commands/workflow/commands/validate.ts
|
|
20348
|
-
import
|
|
20593
|
+
import chalk74 from "chalk";
|
|
20349
20594
|
import { readFileSync } from "fs";
|
|
20350
20595
|
async function parseWorkflowInput(input, yamlStr) {
|
|
20351
20596
|
const parseYaml = async (content) => {
|
|
@@ -20378,25 +20623,25 @@ function renderResult(result, options) {
|
|
|
20378
20623
|
return;
|
|
20379
20624
|
}
|
|
20380
20625
|
if (result.valid) {
|
|
20381
|
-
console.log(
|
|
20626
|
+
console.log(chalk74.green(`
|
|
20382
20627
|
✅ Workflow validation PASSED
|
|
20383
20628
|
`));
|
|
20384
|
-
console.log(
|
|
20629
|
+
console.log(chalk74.bold(`Workflow: ${result.workflowName}`));
|
|
20385
20630
|
console.log(`Nodes: ${result.nodeCount}`);
|
|
20386
20631
|
console.log(`
|
|
20387
20632
|
Valid nodes:`);
|
|
20388
|
-
console.log(
|
|
20633
|
+
console.log(chalk74.green(" ✓ All nodes passed validation"));
|
|
20389
20634
|
} else {
|
|
20390
|
-
console.log(
|
|
20635
|
+
console.log(chalk74.red(`
|
|
20391
20636
|
❌ Workflow validation FAILED (${result.errors.length} errors found)
|
|
20392
20637
|
`));
|
|
20393
20638
|
result.errors.forEach((error, index) => {
|
|
20394
|
-
console.log(
|
|
20395
|
-
console.log(` ${
|
|
20396
|
-
console.log(` ${
|
|
20397
|
-
console.log(` ${
|
|
20398
|
-
console.log(` ${
|
|
20399
|
-
console.log(` ${
|
|
20639
|
+
console.log(chalk74.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
|
|
20640
|
+
console.log(` ${chalk74.bold("Type:")} ${error.type}`);
|
|
20641
|
+
console.log(` ${chalk74.bold("Description:")} ${error.description}`);
|
|
20642
|
+
console.log(` ${chalk74.bold("Expected:")} ${error.expected}`);
|
|
20643
|
+
console.log(` ${chalk74.bold("Actual:")} ${error.actual}`);
|
|
20644
|
+
console.log(` ${chalk74.green("Fix:")} ${error.fix}`);
|
|
20400
20645
|
console.log();
|
|
20401
20646
|
});
|
|
20402
20647
|
}
|
|
@@ -20421,7 +20666,7 @@ var WorkflowValidateCommand = {
|
|
|
20421
20666
|
try {
|
|
20422
20667
|
const workflow = await parseWorkflowInput(options.input, options.yaml);
|
|
20423
20668
|
if (!workflow) {
|
|
20424
|
-
console.error(
|
|
20669
|
+
console.error(chalk74.red("Failed to parse workflow input"));
|
|
20425
20670
|
process.exit(1);
|
|
20426
20671
|
}
|
|
20427
20672
|
const validator = new WorkflowValidator;
|
|
@@ -20429,7 +20674,7 @@ var WorkflowValidateCommand = {
|
|
|
20429
20674
|
renderResult(result, options);
|
|
20430
20675
|
process.exit(result.valid ? 0 : 1);
|
|
20431
20676
|
} catch (error) {
|
|
20432
|
-
console.error(
|
|
20677
|
+
console.error(chalk74.red(`
|
|
20433
20678
|
Error: ${error.message}`));
|
|
20434
20679
|
process.exit(1);
|
|
20435
20680
|
}
|
|
@@ -20437,7 +20682,7 @@ Error: ${error.message}`));
|
|
|
20437
20682
|
};
|
|
20438
20683
|
|
|
20439
20684
|
// src/commands/workflow/commands/search.ts
|
|
20440
|
-
import
|
|
20685
|
+
import chalk75 from "chalk";
|
|
20441
20686
|
import { wrapFunction as wrapFunction3 } from "@ai-setting/roy-agent-core";
|
|
20442
20687
|
var WorkflowSearchCommand = {
|
|
20443
20688
|
command: "search",
|
|
@@ -20594,22 +20839,22 @@ var _runWorkflowSearchImpl = async function(opts) {
|
|
|
20594
20839
|
metadata: {}
|
|
20595
20840
|
}));
|
|
20596
20841
|
if (renderWorkflows.length === 0) {
|
|
20597
|
-
output.log(
|
|
20598
|
-
output.log(
|
|
20599
|
-
output.log(
|
|
20842
|
+
output.log(chalk75.yellow("\uD83D\uDD0D No workflows matched the search criteria."));
|
|
20843
|
+
output.log(chalk75.gray(` keyword: ${keyword || "(none)"}`));
|
|
20844
|
+
output.log(chalk75.gray(` tags: ${tags && tags.length > 0 ? tags.join(", ") : "(none)"}`));
|
|
20600
20845
|
} else {
|
|
20601
|
-
output.log(
|
|
20846
|
+
output.log(chalk75.bold(`\uD83D\uDD0D Search results (${renderWorkflows.length}):`));
|
|
20602
20847
|
output.log(renderWorkflowList(renderWorkflows));
|
|
20603
|
-
output.log(
|
|
20848
|
+
output.log(chalk75.green(`
|
|
20604
20849
|
✅ Found ${renderWorkflows.length} workflow(s)`));
|
|
20605
20850
|
}
|
|
20606
20851
|
if (availableTags.length > 0) {
|
|
20607
20852
|
output.log("");
|
|
20608
|
-
output.log(
|
|
20853
|
+
output.log(chalk75.bold("\uD83D\uDCDA Available tags (sorted by usage_count):"));
|
|
20609
20854
|
for (const t of availableTags) {
|
|
20610
20855
|
const name = t.name ?? t.tag;
|
|
20611
20856
|
const count = t.count ?? t.usage_count;
|
|
20612
|
-
output.log(
|
|
20857
|
+
output.log(chalk75.gray(` - ${name} (${count})`));
|
|
20613
20858
|
}
|
|
20614
20859
|
}
|
|
20615
20860
|
};
|
|
@@ -20621,7 +20866,7 @@ var runWorkflowSearch = wrapFunction3(_runWorkflowSearchImpl, "workflow.cli.sear
|
|
|
20621
20866
|
|
|
20622
20867
|
// src/commands/workflow/commands/tag.ts
|
|
20623
20868
|
import { wrapFunction as wrapFunction4 } from "@ai-setting/roy-agent-core";
|
|
20624
|
-
import
|
|
20869
|
+
import chalk76 from "chalk";
|
|
20625
20870
|
var WorkflowTagListCommand = {
|
|
20626
20871
|
command: "list",
|
|
20627
20872
|
describe: "List all workflow tags from the workflow_tags table (sorted by usage_count DESC by default). Use this BEFORE `workflow add` to discover existing tags and reuse them for semantic consistency.",
|
|
@@ -20742,17 +20987,17 @@ var _runWorkflowTagListImpl = async function(opts) {
|
|
|
20742
20987
|
return;
|
|
20743
20988
|
}
|
|
20744
20989
|
if (result.tags.length === 0) {
|
|
20745
|
-
output.log(
|
|
20746
|
-
output.log(
|
|
20990
|
+
output.log(chalk76.yellow("\uD83C\uDFF7️ No tags in the workflow_tags table yet."));
|
|
20991
|
+
output.log(chalk76.gray(" Tags are created automatically when you run `workflow add --tags <name>`."));
|
|
20747
20992
|
return;
|
|
20748
20993
|
}
|
|
20749
|
-
output.log(
|
|
20750
|
-
output.log(
|
|
20994
|
+
output.log(chalk76.bold(`\uD83C\uDFF7️ Workflow tags (${result.total}):`));
|
|
20995
|
+
output.log(chalk76.gray(` ${padRight("NAME", 24)}${padRight("USAGE", 8)}${padRight("CREATED", 22)}`));
|
|
20751
20996
|
for (const t of result.tags) {
|
|
20752
20997
|
const line = ` ${padRight(t.name, 24)}${padRight(String(t.usage_count), 8)}${padRight(formatDate2(t.created_at), 22)}`;
|
|
20753
20998
|
output.log(line);
|
|
20754
20999
|
}
|
|
20755
|
-
output.log(
|
|
21000
|
+
output.log(chalk76.gray(`
|
|
20756
21001
|
\uD83D\uDCA1 Tip: when adding a new workflow, prefer tags from this list to ensure semantic consistency.`));
|
|
20757
21002
|
};
|
|
20758
21003
|
var _runWorkflowTagGetImpl = async function(opts) {
|
|
@@ -20779,7 +21024,7 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
20779
21024
|
output.json({ error: "Tag not found", name: opts.name });
|
|
20780
21025
|
} else {
|
|
20781
21026
|
output.error(`Tag "${opts.name}" not found in the workflow_tags table.`);
|
|
20782
|
-
output.log(
|
|
21027
|
+
output.log(chalk76.gray(`Tip: run \`roy-agent workflow tag list\` to see available tags.`));
|
|
20783
21028
|
}
|
|
20784
21029
|
process.exitCode = 1;
|
|
20785
21030
|
return;
|
|
@@ -20788,10 +21033,10 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
20788
21033
|
output.json(tag);
|
|
20789
21034
|
return;
|
|
20790
21035
|
}
|
|
20791
|
-
output.log(
|
|
20792
|
-
output.log(
|
|
20793
|
-
output.log(
|
|
20794
|
-
output.log(
|
|
21036
|
+
output.log(chalk76.bold(`\uD83C\uDFF7️ Tag: ${tag.name}`));
|
|
21037
|
+
output.log(chalk76.gray(` usage_count: ${tag.usage_count}`));
|
|
21038
|
+
output.log(chalk76.gray(` created_at: ${tag.created_at}`));
|
|
21039
|
+
output.log(chalk76.gray(` updated_at: ${tag.updated_at}`));
|
|
20795
21040
|
};
|
|
20796
21041
|
async function callListTags(service, options) {
|
|
20797
21042
|
if (typeof service.listTags !== "function") {
|
|
@@ -21445,6 +21690,10 @@ var InstallCommand = {
|
|
|
21445
21690
|
|
|
21446
21691
|
// src/cli.ts
|
|
21447
21692
|
function quietModeMiddleware(argv) {
|
|
21693
|
+
if (argv.noquiet === true) {
|
|
21694
|
+
argv.quiet = false;
|
|
21695
|
+
delete argv.noquiet;
|
|
21696
|
+
}
|
|
21448
21697
|
const quietService = CliQuietModeService.getInstance();
|
|
21449
21698
|
if (argv.quiet === true) {
|
|
21450
21699
|
quietService.setQuiet(true);
|
|
@@ -21486,6 +21735,10 @@ async function runCli() {
|
|
|
21486
21735
|
type: "boolean",
|
|
21487
21736
|
default: true,
|
|
21488
21737
|
global: true
|
|
21738
|
+
}).option("noquiet", {
|
|
21739
|
+
type: "boolean",
|
|
21740
|
+
description: "Alias for --no-quiet (no hyphen form). Disables quiet mode.",
|
|
21741
|
+
global: true
|
|
21489
21742
|
}).option("plugin", {
|
|
21490
21743
|
alias: "p",
|
|
21491
21744
|
type: "string",
|