@ai-setting/roy-agent-cli 1.5.113 → 1.5.115
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 +1029 -725
- package/dist/index.js +1029 -725
- 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.115",
|
|
7431
7431
|
type: "module",
|
|
7432
7432
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7433
7433
|
main: "./dist/index.js",
|
|
@@ -9495,7 +9495,6 @@ class EventHandler {
|
|
|
9495
9495
|
console.error(`[EventHandler] 处理事件失败:`, error);
|
|
9496
9496
|
}
|
|
9497
9497
|
}
|
|
9498
|
-
this.clearActiveSession();
|
|
9499
9498
|
this.isProcessing = false;
|
|
9500
9499
|
}
|
|
9501
9500
|
async ensureActiveSession() {
|
|
@@ -9512,13 +9511,29 @@ class EventHandler {
|
|
|
9512
9511
|
return null;
|
|
9513
9512
|
}
|
|
9514
9513
|
this.activeEventSessionId = existing.id;
|
|
9514
|
+
await this.sessionComponent.setActiveSession(existing.id);
|
|
9515
9515
|
return existing.id;
|
|
9516
9516
|
}
|
|
9517
|
-
console.warn(`[EventHandler] Parent session ${triggerSessionId} not found,
|
|
9517
|
+
console.warn(`[EventHandler] Parent session ${triggerSessionId} not found, trying global active session`);
|
|
9518
9518
|
} catch (error) {
|
|
9519
9519
|
console.error(`[EventHandler] Failed to lookup parent session ${triggerSessionId}:`, error);
|
|
9520
9520
|
}
|
|
9521
9521
|
}
|
|
9522
|
+
try {
|
|
9523
|
+
const activeId = this.sessionComponent.getActiveSessionId();
|
|
9524
|
+
if (activeId) {
|
|
9525
|
+
const existing = await this.sessionComponent.get(activeId);
|
|
9526
|
+
if (existing) {
|
|
9527
|
+
if (this.isStopped) {
|
|
9528
|
+
return null;
|
|
9529
|
+
}
|
|
9530
|
+
this.activeEventSessionId = existing.id;
|
|
9531
|
+
return existing.id;
|
|
9532
|
+
}
|
|
9533
|
+
}
|
|
9534
|
+
} catch (error) {
|
|
9535
|
+
console.error(`[EventHandler] Failed to lookup global active session:`, error);
|
|
9536
|
+
}
|
|
9522
9537
|
return this.createNewEventSession();
|
|
9523
9538
|
}
|
|
9524
9539
|
async createNewEventSession() {
|
|
@@ -9531,6 +9546,7 @@ class EventHandler {
|
|
|
9531
9546
|
return null;
|
|
9532
9547
|
}
|
|
9533
9548
|
this.activeEventSessionId = session.id;
|
|
9549
|
+
await this.sessionComponent.setActiveSession(session.id);
|
|
9534
9550
|
return session.id;
|
|
9535
9551
|
} catch (error) {
|
|
9536
9552
|
console.error(`[EventHandler] 创建事件 session 失败:`, error);
|
|
@@ -9953,6 +9969,7 @@ class REPL {
|
|
|
9953
9969
|
inputHandler;
|
|
9954
9970
|
keypressHandler;
|
|
9955
9971
|
sessionManager = null;
|
|
9972
|
+
sessionComponent = null;
|
|
9956
9973
|
lastAttachPath = undefined;
|
|
9957
9974
|
lastUsage = null;
|
|
9958
9975
|
setLastUsage(usage) {
|
|
@@ -10191,9 +10208,22 @@ ${COLORS.system("⏳ 上一次请求尚未完成,请稍候...")}
|
|
|
10191
10208
|
`);
|
|
10192
10209
|
return;
|
|
10193
10210
|
}
|
|
10211
|
+
await this.ensureActiveSession();
|
|
10194
10212
|
const payload = this.sessionManager ? await this.sessionManager.getQueryPayload(message) : message;
|
|
10195
10213
|
await this.executeInternal(payload, { showPrompt: false });
|
|
10196
10214
|
}
|
|
10215
|
+
async ensureActiveSession() {
|
|
10216
|
+
if (!this.sessionComponent)
|
|
10217
|
+
return;
|
|
10218
|
+
try {
|
|
10219
|
+
const activeId = this.sessionComponent.getActiveSessionId();
|
|
10220
|
+
if (!activeId && this.sessionManager) {
|
|
10221
|
+
await this.sessionManager.init(undefined, false);
|
|
10222
|
+
}
|
|
10223
|
+
} catch (error) {
|
|
10224
|
+
console.error(`[REPL] Failed to ensure active session:`, error);
|
|
10225
|
+
}
|
|
10226
|
+
}
|
|
10197
10227
|
async handleEventMessage(message) {
|
|
10198
10228
|
console.log(`
|
|
10199
10229
|
${COLORS.system("[通知] ❯ " + message.replace(/\n/g, `
|
|
@@ -10207,6 +10237,7 @@ ${COLORS.system("[通知] ❯ " + message.replace(/\n/g, `
|
|
|
10207
10237
|
${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
10208
10238
|
` + COLORS.system("[通知2] ❯ ")))}
|
|
10209
10239
|
`);
|
|
10240
|
+
await this.ensureActiveSession();
|
|
10210
10241
|
const sourceId = envEvent.metadata?.sourceId;
|
|
10211
10242
|
let pluginEnabled = envEvent.metadata?.pluginEnabled;
|
|
10212
10243
|
let plugins = envEvent.metadata?.plugins;
|
|
@@ -10775,6 +10806,7 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10775
10806
|
};
|
|
10776
10807
|
process.on("SIGINT", sigintHandler);
|
|
10777
10808
|
repl.sessionManager = sessionManager;
|
|
10809
|
+
repl.sessionComponent = sessionComponent;
|
|
10778
10810
|
await repl.start();
|
|
10779
10811
|
process.removeListener("SIGINT", sigintHandler);
|
|
10780
10812
|
console.log("正在清理资源...");
|
|
@@ -10819,8 +10851,56 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10819
10851
|
}
|
|
10820
10852
|
var InteractiveCommand = createInteractiveCommand();
|
|
10821
10853
|
|
|
10822
|
-
// src/commands/
|
|
10854
|
+
// src/commands/shared/list-output.ts
|
|
10823
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";
|
|
10824
10904
|
|
|
10825
10905
|
// src/commands/sessions/session-graph.ts
|
|
10826
10906
|
function buildSessionTree(sessions) {
|
|
@@ -10983,14 +11063,9 @@ var ListCommand = {
|
|
|
10983
11063
|
command: "list [options]",
|
|
10984
11064
|
aliases: ["ls"],
|
|
10985
11065
|
describe: "列出所有会话",
|
|
10986
|
-
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)" }),
|
|
10987
11067
|
async handler(args) {
|
|
10988
|
-
const isQuiet = args.quiet === true;
|
|
10989
|
-
if (isQuiet) {
|
|
10990
|
-
CliQuietModeService.getInstance().setQuiet(true);
|
|
10991
|
-
}
|
|
10992
11068
|
const output = new OutputService2;
|
|
10993
|
-
output.configure({ quiet: isQuiet });
|
|
10994
11069
|
const envService = new EnvironmentService(output);
|
|
10995
11070
|
try {
|
|
10996
11071
|
await envService.create({ configPath: args.config });
|
|
@@ -11031,8 +11106,11 @@ var ListCommand = {
|
|
|
11031
11106
|
}
|
|
11032
11107
|
if (args.json) {
|
|
11033
11108
|
output.json({
|
|
11034
|
-
total:
|
|
11035
|
-
|
|
11109
|
+
total: totalCount,
|
|
11110
|
+
count: sessions.length,
|
|
11111
|
+
truncated: totalCount > sessions.length,
|
|
11112
|
+
limit: args.limit,
|
|
11113
|
+
offset: args.offset,
|
|
11036
11114
|
sessions: sessions.map((s) => {
|
|
11037
11115
|
const workflowMeta = s.metadata?.type === "workflow" ? s.metadata : null;
|
|
11038
11116
|
return {
|
|
@@ -11053,48 +11131,58 @@ var ListCommand = {
|
|
|
11053
11131
|
};
|
|
11054
11132
|
})
|
|
11055
11133
|
});
|
|
11056
|
-
} else if (args.
|
|
11134
|
+
} else if (args.id) {
|
|
11057
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);
|
|
11058
11147
|
} else {
|
|
11059
11148
|
const hasTypeFilter = !!args.type;
|
|
11060
11149
|
const hasStatusFilter = !!args.status;
|
|
11061
11150
|
const header = [
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
hasTypeFilter || hasStatusFilter ?
|
|
11067
|
-
|
|
11068
|
-
|
|
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")
|
|
11069
11158
|
].filter(Boolean).join(" │ ");
|
|
11070
11159
|
const rows = sessions.map((s, i) => {
|
|
11071
|
-
const marker = s.id === activeSessionId ?
|
|
11160
|
+
const marker = s.id === activeSessionId ? chalk7.green("▶") : " ";
|
|
11072
11161
|
const hasCp = (s.metadata?.checkpoints?.checkpoints?.length ?? 0) > 0;
|
|
11073
11162
|
const title = s.title.length > 20 ? s.title.slice(0, 17) + "..." : s.title;
|
|
11074
11163
|
const idStr = s.id;
|
|
11075
11164
|
const useShortId = args.shortId === true;
|
|
11076
|
-
const parentStr = s.parentSessionId ?
|
|
11165
|
+
const parentStr = s.parentSessionId ? chalk7.gray(useShortId ? shortSessionId(s.parentSessionId) : s.parentSessionId) : chalk7.gray("-");
|
|
11077
11166
|
const workflowMeta = s.metadata?.type === "workflow" ? s.metadata : null;
|
|
11078
11167
|
const statusStr = workflowMeta?.status || "";
|
|
11079
11168
|
let statusDisplay = "";
|
|
11080
11169
|
if (hasTypeFilter || hasStatusFilter) {
|
|
11081
11170
|
if (workflowMeta) {
|
|
11082
|
-
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;
|
|
11083
11172
|
}
|
|
11084
11173
|
}
|
|
11085
11174
|
const cells = [
|
|
11086
11175
|
marker + " " + (args.offset + i + 1),
|
|
11087
11176
|
title,
|
|
11088
|
-
|
|
11177
|
+
chalk7.gray(idStr),
|
|
11089
11178
|
parentStr
|
|
11090
11179
|
];
|
|
11091
11180
|
if (hasTypeFilter || hasStatusFilter) {
|
|
11092
|
-
cells.push(statusDisplay ||
|
|
11181
|
+
cells.push(statusDisplay || chalk7.gray("-"));
|
|
11093
11182
|
}
|
|
11094
|
-
cells.push(s.messageCount.toString(), hasCp ?
|
|
11183
|
+
cells.push(s.messageCount.toString(), hasCp ? chalk7.green("✓") : chalk7.gray("-"));
|
|
11095
11184
|
return cells.join(" │ ");
|
|
11096
11185
|
});
|
|
11097
|
-
const showingInfo = totalCount > sessions.length ? `Showing ${sessions.length} of ${totalCount} sessions` : `${totalCount} sessions`;
|
|
11098
11186
|
output.log([
|
|
11099
11187
|
`┌─ Sessions ${"─".repeat(50)}┐`,
|
|
11100
11188
|
`│${header}│`,
|
|
@@ -11102,7 +11190,17 @@ var ListCommand = {
|
|
|
11102
11190
|
...rows.map((r) => `│${r}│`),
|
|
11103
11191
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
11104
11192
|
"",
|
|
11105
|
-
|
|
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
|
+
})
|
|
11106
11204
|
].join(`
|
|
11107
11205
|
`));
|
|
11108
11206
|
}
|
|
@@ -11116,7 +11214,7 @@ var ListCommand = {
|
|
|
11116
11214
|
};
|
|
11117
11215
|
|
|
11118
11216
|
// src/commands/sessions/get.ts
|
|
11119
|
-
import
|
|
11217
|
+
import chalk8 from "chalk";
|
|
11120
11218
|
var GetCommand = {
|
|
11121
11219
|
command: "get <session-id>",
|
|
11122
11220
|
aliases: ["show"],
|
|
@@ -11172,29 +11270,29 @@ var GetCommand = {
|
|
|
11172
11270
|
});
|
|
11173
11271
|
} else {
|
|
11174
11272
|
const lines = [
|
|
11175
|
-
|
|
11273
|
+
chalk8.bold("┌─ Session Details ─────────────────────────────────┐"),
|
|
11176
11274
|
`│ ID: ${session.id}`,
|
|
11177
11275
|
`│ Title: ${session.title}`,
|
|
11178
11276
|
`│ Directory: ${session.directory}`,
|
|
11179
11277
|
`│ Messages: ${session.messageCount}`,
|
|
11180
|
-
`│ Active: ${session.id === activeSessionId ?
|
|
11278
|
+
`│ Active: ${session.id === activeSessionId ? chalk8.green("✓") : chalk8.gray("-")}`,
|
|
11181
11279
|
`│ Created: ${new Date(session.createdAt).toLocaleString("zh-CN")}`,
|
|
11182
11280
|
`│ Updated: ${new Date(session.updatedAt).toLocaleString("zh-CN")}`
|
|
11183
11281
|
];
|
|
11184
11282
|
const workflowMeta = session.metadata?.type === "workflow" ? session.metadata : null;
|
|
11185
11283
|
if (workflowMeta) {
|
|
11186
11284
|
lines.push("├─ Workflow Info ─────────────────────────────────────┤");
|
|
11187
|
-
lines.push(`│ Type: ${
|
|
11285
|
+
lines.push(`│ Type: ${chalk8.cyan("workflow")}`);
|
|
11188
11286
|
lines.push(`│ Workflow: ${workflowMeta.workflowName}`);
|
|
11189
11287
|
if (workflowMeta.workflowId) {
|
|
11190
11288
|
lines.push(`│ Workflow ID: ${workflowMeta.workflowId}`);
|
|
11191
11289
|
}
|
|
11192
|
-
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;
|
|
11193
11291
|
lines.push(`│ Status: ${statusColor(workflowMeta.status)}`);
|
|
11194
11292
|
if (workflowMeta.agentSessions && workflowMeta.agentSessions.length > 0) {
|
|
11195
11293
|
lines.push("├─ Agent Sub-sessions ─────────────────────────────────┤");
|
|
11196
11294
|
workflowMeta.agentSessions.forEach((agent) => {
|
|
11197
|
-
const agentStatusColor = agent.status === "active" ?
|
|
11295
|
+
const agentStatusColor = agent.status === "active" ? chalk8.green : agent.status === "paused" ? chalk8.yellow : chalk8.gray;
|
|
11198
11296
|
lines.push(`│ ${agent.nodeId}: ${agent.sessionId} (${agentStatusColor(agent.status)})`);
|
|
11199
11297
|
});
|
|
11200
11298
|
}
|
|
@@ -11221,7 +11319,7 @@ var GetCommand = {
|
|
|
11221
11319
|
};
|
|
11222
11320
|
|
|
11223
11321
|
// src/commands/sessions/new.ts
|
|
11224
|
-
import
|
|
11322
|
+
import chalk9 from "chalk";
|
|
11225
11323
|
var NewCommand = {
|
|
11226
11324
|
command: "new [options]",
|
|
11227
11325
|
aliases: ["create"],
|
|
@@ -11260,7 +11358,7 @@ var NewCommand = {
|
|
|
11260
11358
|
}
|
|
11261
11359
|
});
|
|
11262
11360
|
} else {
|
|
11263
|
-
output.success(
|
|
11361
|
+
output.success(chalk9.green("✓") + " Session created: " + session.id);
|
|
11264
11362
|
output.info("Title: " + session.title);
|
|
11265
11363
|
output.info("Directory: " + session.directory);
|
|
11266
11364
|
}
|
|
@@ -11274,7 +11372,7 @@ var NewCommand = {
|
|
|
11274
11372
|
};
|
|
11275
11373
|
|
|
11276
11374
|
// src/commands/sessions/rename.ts
|
|
11277
|
-
import
|
|
11375
|
+
import chalk10 from "chalk";
|
|
11278
11376
|
var RenameCommand = {
|
|
11279
11377
|
command: "rename <session-id> <title>",
|
|
11280
11378
|
aliases: ["mv"],
|
|
@@ -11329,7 +11427,7 @@ var RenameCommand = {
|
|
|
11329
11427
|
}
|
|
11330
11428
|
});
|
|
11331
11429
|
} else {
|
|
11332
|
-
output.success(`Session renamed: ${
|
|
11430
|
+
output.success(`Session renamed: ${chalk10.green(a.title)}`);
|
|
11333
11431
|
output.info(`ID: ${a.sessionId}`);
|
|
11334
11432
|
}
|
|
11335
11433
|
} catch (error) {
|
|
@@ -11342,7 +11440,7 @@ var RenameCommand = {
|
|
|
11342
11440
|
};
|
|
11343
11441
|
|
|
11344
11442
|
// src/commands/sessions/delete.ts
|
|
11345
|
-
import
|
|
11443
|
+
import chalk11 from "chalk";
|
|
11346
11444
|
var DeleteCommand = {
|
|
11347
11445
|
command: "delete [session-ids...]",
|
|
11348
11446
|
aliases: ["rm"],
|
|
@@ -11421,7 +11519,7 @@ var DeleteCommand = {
|
|
|
11421
11519
|
return true;
|
|
11422
11520
|
});
|
|
11423
11521
|
if (a.keepActive && sessionsToDelete.length > 0) {
|
|
11424
|
-
output.log(
|
|
11522
|
+
output.log(chalk11.yellow(`Keeping active session: ${activeSessionId}`));
|
|
11425
11523
|
}
|
|
11426
11524
|
} else if (a.olderThan !== undefined) {
|
|
11427
11525
|
const cutoffDate = new Date;
|
|
@@ -11438,7 +11536,7 @@ var DeleteCommand = {
|
|
|
11438
11536
|
}
|
|
11439
11537
|
return false;
|
|
11440
11538
|
});
|
|
11441
|
-
output.log(
|
|
11539
|
+
output.log(chalk11.gray(`Deleting sessions not updated since ${cutoffDate.toISOString().split("T")[0]} (${a.olderThan} days ago)`));
|
|
11442
11540
|
} else {
|
|
11443
11541
|
output.log("No sessions to delete");
|
|
11444
11542
|
return;
|
|
@@ -11448,10 +11546,10 @@ var DeleteCommand = {
|
|
|
11448
11546
|
return;
|
|
11449
11547
|
}
|
|
11450
11548
|
if (a.dryRun) {
|
|
11451
|
-
output.log(
|
|
11549
|
+
output.log(chalk11.yellow(`[DRY RUN] Would delete ${sessionsToDelete.length} session(s):
|
|
11452
11550
|
`));
|
|
11453
11551
|
sessionsToDelete.forEach((s, i) => {
|
|
11454
|
-
const marker = s.id === activeSessionId ?
|
|
11552
|
+
const marker = s.id === activeSessionId ? chalk11.green("▶") : " ";
|
|
11455
11553
|
output.log(` ${marker} ${s.id}`);
|
|
11456
11554
|
output.log(` Title: ${s.title}`);
|
|
11457
11555
|
output.log(` Updated: ${new Date(s.updatedAt).toLocaleString()}`);
|
|
@@ -11461,11 +11559,11 @@ var DeleteCommand = {
|
|
|
11461
11559
|
return;
|
|
11462
11560
|
}
|
|
11463
11561
|
if (!a.force) {
|
|
11464
|
-
output.log(
|
|
11562
|
+
output.log(chalk11.red(`
|
|
11465
11563
|
⚠️ About to delete ${sessionsToDelete.length} session(s):
|
|
11466
11564
|
`));
|
|
11467
11565
|
sessionsToDelete.forEach((s, i) => {
|
|
11468
|
-
const marker = s.id === activeSessionId ?
|
|
11566
|
+
const marker = s.id === activeSessionId ? chalk11.green("▶") : " ";
|
|
11469
11567
|
output.log(` ${marker} ${s.id} - ${s.title}`);
|
|
11470
11568
|
});
|
|
11471
11569
|
output.log("");
|
|
@@ -11475,7 +11573,7 @@ var DeleteCommand = {
|
|
|
11475
11573
|
input: process.stdin,
|
|
11476
11574
|
output: process.stdout
|
|
11477
11575
|
});
|
|
11478
|
-
rl.question(
|
|
11576
|
+
rl.question(chalk11.red("Type 'yes' to confirm deletion: "), (res) => {
|
|
11479
11577
|
rl.close();
|
|
11480
11578
|
resolve(res);
|
|
11481
11579
|
});
|
|
@@ -11503,7 +11601,7 @@ var DeleteCommand = {
|
|
|
11503
11601
|
}
|
|
11504
11602
|
}
|
|
11505
11603
|
if (successCount > 0) {
|
|
11506
|
-
output.success(
|
|
11604
|
+
output.success(chalk11.green(`✓`) + ` Deleted ${successCount} session(s)`);
|
|
11507
11605
|
}
|
|
11508
11606
|
if (failCount > 0) {
|
|
11509
11607
|
output.error(`✗ Failed to delete ${failCount} session(s)`);
|
|
@@ -11522,7 +11620,7 @@ var DeleteCommand = {
|
|
|
11522
11620
|
};
|
|
11523
11621
|
|
|
11524
11622
|
// src/commands/sessions/messages.ts
|
|
11525
|
-
import
|
|
11623
|
+
import chalk12 from "chalk";
|
|
11526
11624
|
|
|
11527
11625
|
// src/commands/sessions/format-message-content.ts
|
|
11528
11626
|
var TEXT_MAX_CHARS = 300;
|
|
@@ -11734,20 +11832,20 @@ var MessagesCommand = {
|
|
|
11734
11832
|
} else {
|
|
11735
11833
|
const detail = a.detail === true;
|
|
11736
11834
|
const roleColors = {
|
|
11737
|
-
user:
|
|
11738
|
-
assistant:
|
|
11739
|
-
system:
|
|
11740
|
-
tool:
|
|
11835
|
+
user: chalk12.blue,
|
|
11836
|
+
assistant: chalk12.green,
|
|
11837
|
+
system: chalk12.gray,
|
|
11838
|
+
tool: chalk12.yellow
|
|
11741
11839
|
};
|
|
11742
|
-
output.log(
|
|
11840
|
+
output.log(chalk12.bold(`┌─ Messages (${a.sessionId}) ────────────────────────┐`));
|
|
11743
11841
|
messages.forEach((m, i) => {
|
|
11744
|
-
const roleColor = roleColors[m.role] ||
|
|
11842
|
+
const roleColor = roleColors[m.role] || chalk12.white;
|
|
11745
11843
|
const time = new Date(m.timestamp).toLocaleTimeString("zh-CN", {
|
|
11746
11844
|
hour: "2-digit",
|
|
11747
11845
|
minute: "2-digit"
|
|
11748
11846
|
});
|
|
11749
11847
|
if (m.metadata?.isCheckpoint) {
|
|
11750
|
-
output.log(
|
|
11848
|
+
output.log(chalk12.cyan("├─ #" + (a.offset + i + 1) + " checkpoint") + " " + chalk12.gray(time));
|
|
11751
11849
|
output.log("│");
|
|
11752
11850
|
const checkpointContent = formatCheckpointContent(m.content, { detail });
|
|
11753
11851
|
output.log("│ " + checkpointContent.split(`
|
|
@@ -11755,7 +11853,7 @@ var MessagesCommand = {
|
|
|
11755
11853
|
│ `));
|
|
11756
11854
|
output.log("│");
|
|
11757
11855
|
} else {
|
|
11758
|
-
output.log(
|
|
11856
|
+
output.log(chalk12.cyan("├─ #" + (a.offset + i + 1) + " ") + roleColor(m.role.padEnd(10)) + " " + chalk12.gray(time));
|
|
11759
11857
|
const rawLines = formatMessageContent(m, { detail });
|
|
11760
11858
|
const contentLines = colorizeContentLines(rawLines, m);
|
|
11761
11859
|
const finalLines = detail ? contentLines : contentLines.slice(0, MAX_CONTENT_LINES);
|
|
@@ -11763,7 +11861,7 @@ var MessagesCommand = {
|
|
|
11763
11861
|
output.log("│ " + line);
|
|
11764
11862
|
}
|
|
11765
11863
|
if (!detail && contentLines.length > MAX_CONTENT_LINES) {
|
|
11766
|
-
output.log("│ " +
|
|
11864
|
+
output.log("│ " + chalk12.gray(`... (truncated, total ${contentLines.length} lines)`));
|
|
11767
11865
|
}
|
|
11768
11866
|
output.log("│");
|
|
11769
11867
|
}
|
|
@@ -11771,7 +11869,7 @@ var MessagesCommand = {
|
|
|
11771
11869
|
output.log("└" + "─".repeat(51) + "┘");
|
|
11772
11870
|
const hasMore = a.offset + a.limit < totalMessages;
|
|
11773
11871
|
const showingEnd = Math.min(a.offset + a.limit, totalMessages);
|
|
11774
|
-
output.log(
|
|
11872
|
+
output.log(chalk12.gray(`Showing ${a.offset + 1}-${showingEnd} of ${totalMessages} messages` + (hasMore ? " (more available)" : "")));
|
|
11775
11873
|
}
|
|
11776
11874
|
} catch (error) {
|
|
11777
11875
|
output.error(`Failed to get messages: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -11784,43 +11882,43 @@ var MessagesCommand = {
|
|
|
11784
11882
|
function colorizeContentLines(lines, _m) {
|
|
11785
11883
|
return lines.map((line) => {
|
|
11786
11884
|
if (line.startsWith("[Tool Call]"))
|
|
11787
|
-
return
|
|
11885
|
+
return chalk12.cyan(line);
|
|
11788
11886
|
if (line.startsWith("[Tool Result]"))
|
|
11789
|
-
return
|
|
11887
|
+
return chalk12.yellow(line);
|
|
11790
11888
|
if (line === "[Reasoning]")
|
|
11791
|
-
return
|
|
11889
|
+
return chalk12.magenta(line);
|
|
11792
11890
|
if (line === "[Checkpoint]")
|
|
11793
|
-
return
|
|
11891
|
+
return chalk12.cyan(line);
|
|
11794
11892
|
if (line.startsWith("[Node Call]"))
|
|
11795
|
-
return
|
|
11893
|
+
return chalk12.blue(line);
|
|
11796
11894
|
if (line.startsWith("[Node Interrupt]"))
|
|
11797
|
-
return
|
|
11895
|
+
return chalk12.yellow(line);
|
|
11798
11896
|
if (line.startsWith("[Node Resume]"))
|
|
11799
|
-
return
|
|
11897
|
+
return chalk12.green(line);
|
|
11800
11898
|
if (line.startsWith("[Node Start]"))
|
|
11801
|
-
return
|
|
11899
|
+
return chalk12.blue(line);
|
|
11802
11900
|
if (line.startsWith("✅") || line.startsWith("❌")) {
|
|
11803
11901
|
if (line.includes("[Node Result]"))
|
|
11804
|
-
return
|
|
11902
|
+
return chalk12.green(line);
|
|
11805
11903
|
if (line.includes("[Node End]"))
|
|
11806
|
-
return
|
|
11904
|
+
return chalk12.green(line);
|
|
11807
11905
|
return line;
|
|
11808
11906
|
}
|
|
11809
11907
|
if (line.startsWith(" ")) {
|
|
11810
11908
|
if (line.startsWith(" Error:"))
|
|
11811
|
-
return
|
|
11909
|
+
return chalk12.red(line);
|
|
11812
11910
|
if (line.startsWith(" Query:"))
|
|
11813
|
-
return
|
|
11911
|
+
return chalk12.bold(line);
|
|
11814
11912
|
if (line.startsWith(" Options:") || line.startsWith(" agentSessionId:") || line.startsWith(" Duration:"))
|
|
11815
|
-
return
|
|
11816
|
-
return
|
|
11913
|
+
return chalk12.gray(line);
|
|
11914
|
+
return chalk12.gray(line);
|
|
11817
11915
|
}
|
|
11818
11916
|
return line;
|
|
11819
11917
|
});
|
|
11820
11918
|
}
|
|
11821
11919
|
|
|
11822
11920
|
// src/commands/sessions/compact.ts
|
|
11823
|
-
import
|
|
11921
|
+
import chalk13 from "chalk";
|
|
11824
11922
|
var CompactCommand = {
|
|
11825
11923
|
command: "compact <session-id>",
|
|
11826
11924
|
aliases: ["compress", "checkpoint"],
|
|
@@ -11874,13 +11972,13 @@ var CompactCommand = {
|
|
|
11874
11972
|
dryRun: true
|
|
11875
11973
|
});
|
|
11876
11974
|
} else {
|
|
11877
|
-
output.log(
|
|
11975
|
+
output.log(chalk13.bold("┌─ Compact Preview ─────────────────────────────────┐"));
|
|
11878
11976
|
output.log(`│ Session: ${session.title}`);
|
|
11879
|
-
output.log(`│ Messages to compact: ${
|
|
11977
|
+
output.log(`│ Messages to compact: ${chalk13.yellow(preview.messageCountToCompact)}`);
|
|
11880
11978
|
output.log(`│ Estimated checkpoint tokens: ${preview.estimatedCheckpointTokens}`);
|
|
11881
|
-
output.log(`│ Would trigger: ${preview.wouldTrigger ?
|
|
11979
|
+
output.log(`│ Would trigger: ${preview.wouldTrigger ? chalk13.green("Yes") : chalk13.gray("No")}`);
|
|
11882
11980
|
output.log("│");
|
|
11883
|
-
output.log("│ " +
|
|
11981
|
+
output.log("│ " + chalk13.gray("(Dry run - no changes made)"));
|
|
11884
11982
|
output.log("└" + "─".repeat(51) + "┘");
|
|
11885
11983
|
}
|
|
11886
11984
|
return;
|
|
@@ -11895,10 +11993,10 @@ var CompactCommand = {
|
|
|
11895
11993
|
try {
|
|
11896
11994
|
scenarioHint = await sessionComponent.generateCompactHint(a.sessionId);
|
|
11897
11995
|
if (!a.json) {
|
|
11898
|
-
output.log(
|
|
11899
|
-
output.log("│ " +
|
|
11996
|
+
output.log(chalk13.bold("├─ Auto-generated Scenario Hint ──────────────────────────┤"));
|
|
11997
|
+
output.log("│ " + chalk13.cyan(scenarioHint.substring(0, 70)));
|
|
11900
11998
|
if (scenarioHint.length > 70) {
|
|
11901
|
-
output.log(
|
|
11999
|
+
output.log(chalk13.gray("│ ") + scenarioHint.substring(70, 140));
|
|
11902
12000
|
}
|
|
11903
12001
|
}
|
|
11904
12002
|
} catch (hintError) {
|
|
@@ -11945,29 +12043,29 @@ var CompactCommand = {
|
|
|
11945
12043
|
}
|
|
11946
12044
|
});
|
|
11947
12045
|
} else {
|
|
11948
|
-
output.log(
|
|
12046
|
+
output.log(chalk13.bold.green("┌─ Checkpoint Created ────────────────────────────────┐"));
|
|
11949
12047
|
output.log(`│ ID: ${result.checkpoint.id}`);
|
|
11950
12048
|
output.log(`│ Title: ${result.checkpoint.title}`);
|
|
11951
12049
|
output.log(`│ Type: compact`);
|
|
11952
12050
|
output.log(`│ Created: ${new Date(result.checkpoint.createdAt).toLocaleString("zh-CN")}`);
|
|
11953
|
-
output.log(
|
|
12051
|
+
output.log(chalk13.bold("├─ Scenario Hint ────────────────────────────────────┤"));
|
|
11954
12052
|
if (scenarioHint) {
|
|
11955
12053
|
const hintLines = scenarioHint.split(`
|
|
11956
12054
|
`);
|
|
11957
12055
|
hintLines.forEach((line, i) => {
|
|
11958
12056
|
if (i === 0) {
|
|
11959
|
-
output.log(
|
|
12057
|
+
output.log(chalk13.cyan("│ " + line.substring(0, 48)));
|
|
11960
12058
|
if (line.length > 48) {
|
|
11961
12059
|
for (let j = 48;j < line.length; j += 48) {
|
|
11962
|
-
output.log(
|
|
12060
|
+
output.log(chalk13.gray("│ ") + line.substring(j, j + 48));
|
|
11963
12061
|
}
|
|
11964
12062
|
}
|
|
11965
12063
|
} else {
|
|
11966
|
-
output.log(
|
|
12064
|
+
output.log(chalk13.gray("│ ") + line);
|
|
11967
12065
|
}
|
|
11968
12066
|
});
|
|
11969
12067
|
} else {
|
|
11970
|
-
output.log(
|
|
12068
|
+
output.log(chalk13.gray("│ (no hint)"));
|
|
11971
12069
|
}
|
|
11972
12070
|
output.log("├─ Process Key Points ─────────────────────────────────┤");
|
|
11973
12071
|
result.checkpoint.processKeyPoints.forEach((p, i) => {
|
|
@@ -11992,11 +12090,11 @@ var CompactCommand = {
|
|
|
11992
12090
|
result.checkpoint.recentMessages.forEach((msg) => {
|
|
11993
12091
|
const prefix = msg.role === "user" ? "\uD83D\uDC64" : "\uD83E\uDD16";
|
|
11994
12092
|
const content = msg.content.length > 60 ? msg.content.substring(0, 60) + "..." : msg.content;
|
|
11995
|
-
output.log(
|
|
12093
|
+
output.log(chalk13.gray(`│ ${prefix} [${msg.role}] ${content}`));
|
|
11996
12094
|
});
|
|
11997
12095
|
}
|
|
11998
12096
|
output.log("├─ Stats ─────────────────────────────────────────────┤");
|
|
11999
|
-
output.log(`│ Messages compacted: ${
|
|
12097
|
+
output.log(`│ Messages compacted: ${chalk13.yellow(result.deletedMessageCount)}`);
|
|
12000
12098
|
output.log(`│ Remaining messages: ${result.remainingMessageCount}`);
|
|
12001
12099
|
output.log(`│ Total checkpoints: ${result.checkpointCount}`);
|
|
12002
12100
|
output.log("└" + "─".repeat(51) + "┘");
|
|
@@ -12014,7 +12112,7 @@ var CompactCommand = {
|
|
|
12014
12112
|
};
|
|
12015
12113
|
|
|
12016
12114
|
// src/commands/sessions/checkpoints.ts
|
|
12017
|
-
import
|
|
12115
|
+
import chalk14 from "chalk";
|
|
12018
12116
|
var CheckpointsCommand = {
|
|
12019
12117
|
command: "checkpoints <session-id>",
|
|
12020
12118
|
aliases: ["cps"],
|
|
@@ -12047,7 +12145,7 @@ var CheckpointsCommand = {
|
|
|
12047
12145
|
}
|
|
12048
12146
|
const checkpoints = await sessionComponent.getCheckpoints(a.sessionId);
|
|
12049
12147
|
if (checkpoints.length === 0) {
|
|
12050
|
-
output.log(
|
|
12148
|
+
output.log(chalk14.gray("No checkpoints for this session"));
|
|
12051
12149
|
return;
|
|
12052
12150
|
}
|
|
12053
12151
|
if (a.json) {
|
|
@@ -12072,7 +12170,7 @@ var CheckpointsCommand = {
|
|
|
12072
12170
|
if (a.detail) {
|
|
12073
12171
|
checkpoints.reverse().forEach((cp, i) => {
|
|
12074
12172
|
const isLatest = i === 0;
|
|
12075
|
-
output.log(
|
|
12173
|
+
output.log(chalk14.bold(`┌─ Checkpoint: ${cp.title} ${isLatest ? chalk14.green("✓") : ""} ──────` + "─".repeat(Math.max(0, 30 - cp.title.length)) + "┐"));
|
|
12076
12174
|
output.log(`│ ID: ${cp.id}`);
|
|
12077
12175
|
output.log(`│ Type: ${cp.type}`);
|
|
12078
12176
|
output.log(`│ Message Index: ${cp.messageIndex} (${cp.messageCountBefore} messages)`);
|
|
@@ -12100,18 +12198,18 @@ var CheckpointsCommand = {
|
|
|
12100
12198
|
});
|
|
12101
12199
|
} else {
|
|
12102
12200
|
const header = [
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12201
|
+
chalk14.bold("#"),
|
|
12202
|
+
chalk14.bold("Title"),
|
|
12203
|
+
chalk14.bold("Type"),
|
|
12204
|
+
chalk14.bold("Messages"),
|
|
12205
|
+
chalk14.bold("Created")
|
|
12108
12206
|
].join(" │ ");
|
|
12109
12207
|
output.log(`┌─ Checkpoints (${checkpoints.length}) ${"─".repeat(40)}┐`);
|
|
12110
12208
|
output.log(`│${header}│`);
|
|
12111
12209
|
output.log("├" + "─".repeat(header.length + 2) + "┤");
|
|
12112
12210
|
checkpoints.reverse().forEach((cp, i) => {
|
|
12113
12211
|
const isLatest = i === 0;
|
|
12114
|
-
const marker = isLatest ?
|
|
12212
|
+
const marker = isLatest ? chalk14.green("✓ ") : " ";
|
|
12115
12213
|
const title = cp.title.length > 25 ? cp.title.slice(0, 22) + "..." : cp.title;
|
|
12116
12214
|
const created = new Date(cp.createdAt).toLocaleString("zh-CN", {
|
|
12117
12215
|
month: "2-digit",
|
|
@@ -12119,7 +12217,7 @@ var CheckpointsCommand = {
|
|
|
12119
12217
|
hour: "2-digit",
|
|
12120
12218
|
minute: "2-digit"
|
|
12121
12219
|
});
|
|
12122
|
-
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)}│`);
|
|
12123
12221
|
});
|
|
12124
12222
|
output.log("└" + "─".repeat(header.length + 2) + "┘");
|
|
12125
12223
|
}
|
|
@@ -12133,7 +12231,7 @@ var CheckpointsCommand = {
|
|
|
12133
12231
|
};
|
|
12134
12232
|
|
|
12135
12233
|
// src/commands/sessions/active.ts
|
|
12136
|
-
import
|
|
12234
|
+
import chalk15 from "chalk";
|
|
12137
12235
|
var ActiveCommand = {
|
|
12138
12236
|
command: "active",
|
|
12139
12237
|
aliases: ["current"],
|
|
@@ -12160,7 +12258,7 @@ var ActiveCommand = {
|
|
|
12160
12258
|
return;
|
|
12161
12259
|
}
|
|
12162
12260
|
if (!activeId) {
|
|
12163
|
-
output.log(
|
|
12261
|
+
output.log(chalk15.gray("No active session set"));
|
|
12164
12262
|
return;
|
|
12165
12263
|
}
|
|
12166
12264
|
const session = await sessionComponent.get(activeId);
|
|
@@ -12178,10 +12276,10 @@ var ActiveCommand = {
|
|
|
12178
12276
|
});
|
|
12179
12277
|
} else {
|
|
12180
12278
|
if (!session) {
|
|
12181
|
-
output.log(
|
|
12279
|
+
output.log(chalk15.gray("Active session not found: " + activeId));
|
|
12182
12280
|
return;
|
|
12183
12281
|
}
|
|
12184
|
-
output.log(
|
|
12282
|
+
output.log(chalk15.bold.green("┌─ Active Session ─────────────────────────────────┐"));
|
|
12185
12283
|
output.log(`│ ID: ${session.id}`);
|
|
12186
12284
|
output.log(`│ Title: ${session.title}`);
|
|
12187
12285
|
output.log(`│ Directory: ${session.directory}`);
|
|
@@ -12263,7 +12361,7 @@ var AddMessageCommand = {
|
|
|
12263
12361
|
};
|
|
12264
12362
|
|
|
12265
12363
|
// src/commands/sessions/mock.ts
|
|
12266
|
-
import
|
|
12364
|
+
import chalk16 from "chalk";
|
|
12267
12365
|
var MOCK_SEQUENCES = [
|
|
12268
12366
|
{
|
|
12269
12367
|
name: "文件操作流程",
|
|
@@ -12396,7 +12494,7 @@ var MockCommand = {
|
|
|
12396
12494
|
for (let seqIdx = 0;seqIdx < count; seqIdx++) {
|
|
12397
12495
|
const sequence = MOCK_SEQUENCES[seqIdx];
|
|
12398
12496
|
if (!a.json) {
|
|
12399
|
-
output.log(
|
|
12497
|
+
output.log(chalk16.bold(`
|
|
12400
12498
|
\uD83D\uDCDD Sequence ${seqIdx + 1}: ${sequence.name}`));
|
|
12401
12499
|
}
|
|
12402
12500
|
for (const msg of sequence.messages) {
|
|
@@ -12414,7 +12512,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12414
12512
|
if (assistantMsgId)
|
|
12415
12513
|
addedMessages.push(assistantMsgId);
|
|
12416
12514
|
if (!a.json) {
|
|
12417
|
-
output.log(
|
|
12515
|
+
output.log(chalk16.cyan(` [${addedMessages.length}] assistant: \uD83D\uDD27 Tool call`));
|
|
12418
12516
|
}
|
|
12419
12517
|
const toolMsgId = await sessionComponent.addMessage(a.sessionId, {
|
|
12420
12518
|
role: "tool",
|
|
@@ -12423,7 +12521,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12423
12521
|
if (toolMsgId)
|
|
12424
12522
|
addedMessages.push(toolMsgId);
|
|
12425
12523
|
if (!a.json) {
|
|
12426
|
-
output.log(
|
|
12524
|
+
output.log(chalk16.yellow(` [${addedMessages.length}] tool: ${msg.content.substring(0, 50)}...`));
|
|
12427
12525
|
}
|
|
12428
12526
|
} else {
|
|
12429
12527
|
const msgId = await sessionComponent.addMessage(a.sessionId, {
|
|
@@ -12433,7 +12531,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12433
12531
|
if (msgId)
|
|
12434
12532
|
addedMessages.push(msgId);
|
|
12435
12533
|
if (!a.json) {
|
|
12436
|
-
const roleColor = msg.role === "user" ?
|
|
12534
|
+
const roleColor = msg.role === "user" ? chalk16.green : msg.role === "assistant" ? chalk16.cyan : chalk16.gray;
|
|
12437
12535
|
output.log(roleColor(` [${addedMessages.length}] ${msg.role}: ${msg.content.substring(0, 50)}...`));
|
|
12438
12536
|
}
|
|
12439
12537
|
}
|
|
@@ -12449,14 +12547,14 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12449
12547
|
});
|
|
12450
12548
|
} else {
|
|
12451
12549
|
output.log(`
|
|
12452
|
-
` +
|
|
12550
|
+
` + chalk16.bold.green("✅ Mock data inserted successfully!"));
|
|
12453
12551
|
output.log(` Session: ${a.sessionId}`);
|
|
12454
12552
|
output.log(` Sequences: ${count}`);
|
|
12455
12553
|
output.log(` Messages: ${addedMessages.length}`);
|
|
12456
12554
|
output.log("");
|
|
12457
|
-
output.log(
|
|
12458
|
-
output.log(
|
|
12459
|
-
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"));
|
|
12460
12558
|
}
|
|
12461
12559
|
} finally {
|
|
12462
12560
|
await envService.dispose();
|
|
@@ -12465,7 +12563,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
12465
12563
|
};
|
|
12466
12564
|
|
|
12467
12565
|
// src/commands/sessions/grep.ts
|
|
12468
|
-
import
|
|
12566
|
+
import chalk17 from "chalk";
|
|
12469
12567
|
var GrepCommand = {
|
|
12470
12568
|
command: "grep <query...>",
|
|
12471
12569
|
aliases: ["search"],
|
|
@@ -12545,7 +12643,7 @@ var GrepCommand = {
|
|
|
12545
12643
|
const results = await sessionComponent.searchMessages(searchOptions);
|
|
12546
12644
|
if (results.length === 0) {
|
|
12547
12645
|
if (!a.quiet) {
|
|
12548
|
-
output.log(
|
|
12646
|
+
output.log(chalk17.yellow(`No results found for: ${query}`));
|
|
12549
12647
|
}
|
|
12550
12648
|
return;
|
|
12551
12649
|
}
|
|
@@ -12572,7 +12670,7 @@ var GrepCommand = {
|
|
|
12572
12670
|
for (const result of results) {
|
|
12573
12671
|
for (const match of result.matches) {
|
|
12574
12672
|
const time = new Date(match.timestamp).toLocaleString("zh-CN");
|
|
12575
|
-
output.log(`${
|
|
12673
|
+
output.log(`${chalk17.gray(result.sessionId)} ${chalk17.blue(result.sessionTitle)} ${chalk17.gray(time)}`);
|
|
12576
12674
|
output.log(` ${match.content}`);
|
|
12577
12675
|
output.log("");
|
|
12578
12676
|
}
|
|
@@ -12584,40 +12682,40 @@ var GrepCommand = {
|
|
|
12584
12682
|
totalMatches += result.matches.length;
|
|
12585
12683
|
const time = new Date(result.updatedAt).toLocaleString("zh-CN");
|
|
12586
12684
|
const titleStr = `─ ${result.sessionTitle} (${result.sessionId})`;
|
|
12587
|
-
output.log(
|
|
12685
|
+
output.log(chalk17.bold(`
|
|
12588
12686
|
┌${titleStr}${"─".repeat(Math.max(0, 50 - titleStr.length))}┐`));
|
|
12589
|
-
output.log(`│ ${
|
|
12687
|
+
output.log(`│ ${chalk17.gray(`Updated: ${time} | ${result.messageCount} messages | ${result.matches.length} matches`)}${" ".repeat(Math.max(0, 50 - 60))}│`);
|
|
12590
12688
|
for (let i = 0;i < result.matches.length; i++) {
|
|
12591
12689
|
const match = result.matches[i];
|
|
12592
|
-
const roleColor = match.role === "user" ?
|
|
12690
|
+
const roleColor = match.role === "user" ? chalk17.blue : match.role === "assistant" ? chalk17.green : chalk17.gray;
|
|
12593
12691
|
const msgTime = new Date(match.timestamp).toLocaleTimeString("zh-CN", {
|
|
12594
12692
|
hour: "2-digit",
|
|
12595
12693
|
minute: "2-digit"
|
|
12596
12694
|
});
|
|
12597
|
-
output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${
|
|
12695
|
+
output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${chalk17.gray(msgTime)}`);
|
|
12598
12696
|
output.log("│");
|
|
12599
12697
|
const lines = match.content.split(`
|
|
12600
12698
|
`).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
12601
12699
|
const maxLines = 5;
|
|
12602
12700
|
const displayLines = lines.slice(0, maxLines);
|
|
12603
12701
|
if (displayLines.length === 0) {
|
|
12604
|
-
output.log("│ " +
|
|
12702
|
+
output.log("│ " + chalk17.gray("(empty content)"));
|
|
12605
12703
|
} else {
|
|
12606
12704
|
for (const line of displayLines) {
|
|
12607
12705
|
const truncated = line.length > 76 ? line.slice(0, 73) + "..." : line;
|
|
12608
|
-
output.log(`│ ${
|
|
12706
|
+
output.log(`│ ${chalk17.gray(truncated)}`);
|
|
12609
12707
|
}
|
|
12610
12708
|
}
|
|
12611
12709
|
if (lines.length > maxLines) {
|
|
12612
|
-
output.log("│ " +
|
|
12710
|
+
output.log("│ " + chalk17.gray(`... (${lines.length - maxLines} more lines)`));
|
|
12613
12711
|
}
|
|
12614
12712
|
output.log("│");
|
|
12615
12713
|
}
|
|
12616
12714
|
output.log(`└${"─".repeat(52)}┘`);
|
|
12617
12715
|
}
|
|
12618
12716
|
output.log(`
|
|
12619
|
-
${
|
|
12620
|
-
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}"`));
|
|
12621
12719
|
}
|
|
12622
12720
|
} catch (error) {
|
|
12623
12721
|
output.error(`Search failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -12656,7 +12754,7 @@ var SessionsCommand = {
|
|
|
12656
12754
|
};
|
|
12657
12755
|
|
|
12658
12756
|
// src/commands/tasks/list.ts
|
|
12659
|
-
import
|
|
12757
|
+
import chalk18 from "chalk";
|
|
12660
12758
|
|
|
12661
12759
|
// src/commands/tasks/_build-list-json.ts
|
|
12662
12760
|
function buildListTasksJson(tasks, total, args, extras) {
|
|
@@ -12704,7 +12802,7 @@ var ListCommand2 = {
|
|
|
12704
12802
|
type: "string",
|
|
12705
12803
|
choices: ["normal", "cycle", "longterm"],
|
|
12706
12804
|
description: "按任务类型筛选"
|
|
12707
|
-
}).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", {
|
|
12708
12806
|
type: "number",
|
|
12709
12807
|
description: "检索层级深度:0=只根任务(无父任务),1=根+一层子任务,2=根+二层子任务,-1 或忽略=全部"
|
|
12710
12808
|
}).option("include-archived", {
|
|
@@ -12742,20 +12840,29 @@ var ListCommand2 = {
|
|
|
12742
12840
|
if (args.json) {
|
|
12743
12841
|
output.json(buildListTasksJson(tasks, total, args));
|
|
12744
12842
|
} else if (args.quiet) {
|
|
12745
|
-
|
|
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);
|
|
12746
12853
|
} else {
|
|
12747
12854
|
const header = [
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
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")
|
|
12755
12862
|
].join(" │ ");
|
|
12756
12863
|
const rows = tasks.map((t, i) => {
|
|
12757
|
-
const statusColor = t.status === "completed" ?
|
|
12758
|
-
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;
|
|
12759
12866
|
return [
|
|
12760
12867
|
(args.offset + i + 1).toString(),
|
|
12761
12868
|
t.title.length > 30 ? t.title.slice(0, 27) + "..." : t.title,
|
|
@@ -12763,11 +12870,11 @@ var ListCommand2 = {
|
|
|
12763
12870
|
priorityColor(t.priority),
|
|
12764
12871
|
t.type || "normal",
|
|
12765
12872
|
`${t.progress}%`,
|
|
12766
|
-
t.parent_task_id ? `#${t.parent_task_id}` :
|
|
12873
|
+
t.parent_task_id ? `#${t.parent_task_id}` : chalk18.gray("root")
|
|
12767
12874
|
].join(" │ ");
|
|
12768
12875
|
});
|
|
12769
|
-
const depthNote = args.depth !== undefined ?
|
|
12770
|
-
const archivedNote = args.includeArchived ?
|
|
12876
|
+
const depthNote = args.depth !== undefined ? chalk18.gray(` depth=${args.depth}`) : "";
|
|
12877
|
+
const archivedNote = args.includeArchived ? chalk18.gray(" include-archived") : "";
|
|
12771
12878
|
output.log([
|
|
12772
12879
|
`┌─ Tasks ${"─".repeat(55)}┐`,
|
|
12773
12880
|
`│${header}│`,
|
|
@@ -12775,7 +12882,7 @@ var ListCommand2 = {
|
|
|
12775
12882
|
...rows.map((r) => `│${r}│`),
|
|
12776
12883
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
12777
12884
|
"",
|
|
12778
|
-
|
|
12885
|
+
chalk18.gray(`Showing ${tasks.length} of ${total} tasks (offset=${args.offset}, limit=${args.limit})${depthNote}${archivedNote}`)
|
|
12779
12886
|
].join(`
|
|
12780
12887
|
`));
|
|
12781
12888
|
}
|
|
@@ -12789,7 +12896,7 @@ var ListCommand2 = {
|
|
|
12789
12896
|
};
|
|
12790
12897
|
|
|
12791
12898
|
// src/commands/tasks/get.ts
|
|
12792
|
-
import
|
|
12899
|
+
import chalk19 from "chalk";
|
|
12793
12900
|
var GetCommand2 = {
|
|
12794
12901
|
command: "get <id>",
|
|
12795
12902
|
aliases: ["show"],
|
|
@@ -12828,10 +12935,10 @@ var GetCommand2 = {
|
|
|
12828
12935
|
if (args.json) {
|
|
12829
12936
|
output.json(result);
|
|
12830
12937
|
} else {
|
|
12831
|
-
output.log(
|
|
12938
|
+
output.log(chalk19.bold(`
|
|
12832
12939
|
Task #${result.task.id}: ${result.task.title}
|
|
12833
12940
|
`));
|
|
12834
|
-
output.log(`Status: ${
|
|
12941
|
+
output.log(`Status: ${chalk19.blue(result.task.status)} | Priority: ${result.task.priority} | Type: ${result.task.type} | Progress: ${result.task.progress}%`);
|
|
12835
12942
|
output.log(`Created: ${result.task.createdAt} | Updated: ${result.task.updatedAt}`);
|
|
12836
12943
|
output.log(`Project Path: ${result.task.project_path}`);
|
|
12837
12944
|
output.log(`Context: ${result.task.context}`);
|
|
@@ -12839,7 +12946,7 @@ Task #${result.task.id}: ${result.task.title}
|
|
|
12839
12946
|
output.log(`
|
|
12840
12947
|
Current Status: ${result.task.current_status}`);
|
|
12841
12948
|
}
|
|
12842
|
-
output.log(
|
|
12949
|
+
output.log(chalk19.bold(`
|
|
12843
12950
|
Operations (${result.operations.length}):
|
|
12844
12951
|
`));
|
|
12845
12952
|
result.operations.forEach((op, i) => {
|
|
@@ -12859,10 +12966,10 @@ Operations (${result.operations.length}):
|
|
|
12859
12966
|
if (args.json) {
|
|
12860
12967
|
output.json(task);
|
|
12861
12968
|
} else {
|
|
12862
|
-
output.log(
|
|
12969
|
+
output.log(chalk19.bold(`
|
|
12863
12970
|
Task #${task.id}: ${task.title}
|
|
12864
12971
|
`));
|
|
12865
|
-
output.log(`Status: ${
|
|
12972
|
+
output.log(`Status: ${chalk19.blue(task.status)} | Priority: ${task.priority} | Type: ${task.type} | Progress: ${task.progress}%`);
|
|
12866
12973
|
output.log(`Created: ${task.createdAt} | Updated: ${task.updatedAt}`);
|
|
12867
12974
|
output.log(`Project Path: ${task.project_path}`);
|
|
12868
12975
|
output.log(`Context: ${task.context}`);
|
|
@@ -12886,7 +12993,7 @@ Description: ${task.description}`);
|
|
|
12886
12993
|
};
|
|
12887
12994
|
|
|
12888
12995
|
// src/commands/tasks/create.ts
|
|
12889
|
-
import
|
|
12996
|
+
import chalk20 from "chalk";
|
|
12890
12997
|
var CreateCommand = {
|
|
12891
12998
|
command: "create <title>",
|
|
12892
12999
|
aliases: ["add", "new"],
|
|
@@ -12964,7 +13071,7 @@ var CreateCommand = {
|
|
|
12964
13071
|
if (args.json) {
|
|
12965
13072
|
output.json(task);
|
|
12966
13073
|
} else {
|
|
12967
|
-
output.log(
|
|
13074
|
+
output.log(chalk20.green(`
|
|
12968
13075
|
✓ Task created: #${task.id}`));
|
|
12969
13076
|
output.log(` Title: ${task.title}`);
|
|
12970
13077
|
output.log(` Status: ${task.status}`);
|
|
@@ -12982,7 +13089,7 @@ var CreateCommand = {
|
|
|
12982
13089
|
};
|
|
12983
13090
|
|
|
12984
13091
|
// src/commands/tasks/update.ts
|
|
12985
|
-
import
|
|
13092
|
+
import chalk21 from "chalk";
|
|
12986
13093
|
var UpdateCommand = {
|
|
12987
13094
|
command: "update <id>",
|
|
12988
13095
|
aliases: ["set"],
|
|
@@ -13040,7 +13147,7 @@ var UpdateCommand = {
|
|
|
13040
13147
|
if (args.json) {
|
|
13041
13148
|
output.json(task);
|
|
13042
13149
|
} else {
|
|
13043
|
-
output.log(
|
|
13150
|
+
output.log(chalk21.green(`
|
|
13044
13151
|
✓ Task updated: #${task.id}`));
|
|
13045
13152
|
output.log(` Title: ${task.title}`);
|
|
13046
13153
|
output.log(` Status: ${task.status}`);
|
|
@@ -13063,7 +13170,7 @@ var UpdateCommand = {
|
|
|
13063
13170
|
};
|
|
13064
13171
|
|
|
13065
13172
|
// src/commands/tasks/delete.ts
|
|
13066
|
-
import
|
|
13173
|
+
import chalk22 from "chalk";
|
|
13067
13174
|
var DeleteCommand2 = {
|
|
13068
13175
|
command: "delete <id>",
|
|
13069
13176
|
aliases: ["remove", "rm", "del"],
|
|
@@ -13099,16 +13206,16 @@ var DeleteCommand2 = {
|
|
|
13099
13206
|
process.exit(1);
|
|
13100
13207
|
}
|
|
13101
13208
|
if (!args.force) {
|
|
13102
|
-
output.log(
|
|
13103
|
-
output.log(
|
|
13104
|
-
output.log(
|
|
13105
|
-
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(`
|
|
13106
13213
|
Use --force to skip this confirmation`));
|
|
13107
13214
|
process.exit(1);
|
|
13108
13215
|
}
|
|
13109
13216
|
const deleted = await taskComponent.deleteTask(args.id);
|
|
13110
13217
|
if (deleted) {
|
|
13111
|
-
output.log(
|
|
13218
|
+
output.log(chalk22.green(`
|
|
13112
13219
|
✓ Task deleted: #${args.id}`));
|
|
13113
13220
|
} else {
|
|
13114
13221
|
output.error(`Failed to delete task: ${args.id}`);
|
|
@@ -13124,7 +13231,7 @@ Use --force to skip this confirmation`));
|
|
|
13124
13231
|
};
|
|
13125
13232
|
|
|
13126
13233
|
// src/commands/tasks/complete.ts
|
|
13127
|
-
import
|
|
13234
|
+
import chalk23 from "chalk";
|
|
13128
13235
|
var CompleteCommand = {
|
|
13129
13236
|
command: "complete <id>",
|
|
13130
13237
|
aliases: ["done", "finish"],
|
|
@@ -13181,7 +13288,7 @@ var CompleteCommand = {
|
|
|
13181
13288
|
if (args.json) {
|
|
13182
13289
|
output.json(task);
|
|
13183
13290
|
} else {
|
|
13184
|
-
output.log(
|
|
13291
|
+
output.log(chalk23.green(`
|
|
13185
13292
|
✓ Task completed: #${task.id}`));
|
|
13186
13293
|
output.log(` Title: ${task.title}`);
|
|
13187
13294
|
output.log(` Progress: ${task.progress}%`);
|
|
@@ -13197,7 +13304,7 @@ var CompleteCommand = {
|
|
|
13197
13304
|
};
|
|
13198
13305
|
|
|
13199
13306
|
// src/commands/tasks/operations.ts
|
|
13200
|
-
import
|
|
13307
|
+
import chalk24 from "chalk";
|
|
13201
13308
|
var OperationsCommand = {
|
|
13202
13309
|
command: "operations <task-id>",
|
|
13203
13310
|
aliases: ["ops", "log"],
|
|
@@ -13247,23 +13354,23 @@ var OperationsCommand = {
|
|
|
13247
13354
|
operations
|
|
13248
13355
|
});
|
|
13249
13356
|
} else {
|
|
13250
|
-
output.log(
|
|
13357
|
+
output.log(chalk24.bold(`
|
|
13251
13358
|
Operations for Task #${task.id}: ${task.title}
|
|
13252
13359
|
`));
|
|
13253
13360
|
if (operations.length === 0) {
|
|
13254
|
-
output.log(
|
|
13361
|
+
output.log(chalk24.gray("No operations found."));
|
|
13255
13362
|
} else {
|
|
13256
13363
|
operations.forEach((op, i) => {
|
|
13257
|
-
const actionColor = op.actionType === "completed" ?
|
|
13258
|
-
output.log(`${
|
|
13259
|
-
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}`);
|
|
13260
13367
|
if (op.actionDescription) {
|
|
13261
13368
|
output.log(` ${op.actionDescription}`);
|
|
13262
13369
|
}
|
|
13263
13370
|
output.log("");
|
|
13264
13371
|
});
|
|
13265
13372
|
}
|
|
13266
|
-
output.log(
|
|
13373
|
+
output.log(chalk24.gray(`Total: ${operations.length} operations`));
|
|
13267
13374
|
}
|
|
13268
13375
|
} catch (error) {
|
|
13269
13376
|
output.error(`Failed to list operations: ${error}`);
|
|
@@ -13275,7 +13382,7 @@ Operations for Task #${task.id}: ${task.title}
|
|
|
13275
13382
|
};
|
|
13276
13383
|
|
|
13277
13384
|
// src/commands/tasks/tree.ts
|
|
13278
|
-
import
|
|
13385
|
+
import chalk25 from "chalk";
|
|
13279
13386
|
function buildTree(tasks) {
|
|
13280
13387
|
const byParent = new Map;
|
|
13281
13388
|
const nodeById = new Map;
|
|
@@ -13310,7 +13417,7 @@ function printTree(nodes, prefix, isRoot, output, currentDepth, maxDepth) {
|
|
|
13310
13417
|
const statusColor = colorByStatus(node.task.status);
|
|
13311
13418
|
const typeLabel = node.task.type ? ` [${node.task.type}]` : "";
|
|
13312
13419
|
const progressLabel = node.task.progress > 0 ? ` (${node.task.progress}%)` : "";
|
|
13313
|
-
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}`;
|
|
13314
13421
|
output.log(prefix + connector + statusColor(header));
|
|
13315
13422
|
if (node.children.length > 0) {
|
|
13316
13423
|
const childPrefix = isRoot ? prefix : prefix + (isLast ? " " : "│ ");
|
|
@@ -13321,15 +13428,15 @@ function printTree(nodes, prefix, isRoot, output, currentDepth, maxDepth) {
|
|
|
13321
13428
|
function colorByStatus(status) {
|
|
13322
13429
|
switch (status) {
|
|
13323
13430
|
case "completed":
|
|
13324
|
-
return
|
|
13431
|
+
return chalk25.green;
|
|
13325
13432
|
case "active":
|
|
13326
|
-
return
|
|
13433
|
+
return chalk25.blue;
|
|
13327
13434
|
case "paused":
|
|
13328
|
-
return
|
|
13435
|
+
return chalk25.yellow;
|
|
13329
13436
|
case "cancelled":
|
|
13330
|
-
return
|
|
13437
|
+
return chalk25.strikethrough;
|
|
13331
13438
|
default:
|
|
13332
|
-
return
|
|
13439
|
+
return chalk25.gray;
|
|
13333
13440
|
}
|
|
13334
13441
|
}
|
|
13335
13442
|
var TreeCommand = {
|
|
@@ -13416,10 +13523,10 @@ var TreeCommand = {
|
|
|
13416
13523
|
}
|
|
13417
13524
|
const tree = buildTree(tasks);
|
|
13418
13525
|
if (tree.length === 0) {
|
|
13419
|
-
output.log(
|
|
13526
|
+
output.log(chalk25.gray("No tasks to display."));
|
|
13420
13527
|
return;
|
|
13421
13528
|
}
|
|
13422
|
-
output.log(
|
|
13529
|
+
output.log(chalk25.bold(`Task Tree (${tasks.length} tasks, ${tree.length} roots)`) + (args.rootId !== undefined ? chalk25.gray(` — subtree of #${args.rootId}`) : ""));
|
|
13423
13530
|
output.log("");
|
|
13424
13531
|
printTree(tree, "", true, output, 0, args.maxDepth);
|
|
13425
13532
|
} catch (error) {
|
|
@@ -13432,7 +13539,7 @@ var TreeCommand = {
|
|
|
13432
13539
|
};
|
|
13433
13540
|
|
|
13434
13541
|
// src/commands/tasks/search.ts
|
|
13435
|
-
import
|
|
13542
|
+
import chalk26 from "chalk";
|
|
13436
13543
|
var SearchCommand = {
|
|
13437
13544
|
command: "search <keywords..>",
|
|
13438
13545
|
aliases: ["find", "grep"],
|
|
@@ -13442,7 +13549,7 @@ var SearchCommand = {
|
|
|
13442
13549
|
array: true,
|
|
13443
13550
|
describe: "搜索关键词(多个关键词 AND 逻辑)",
|
|
13444
13551
|
demandOption: true
|
|
13445
|
-
}).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", {
|
|
13446
13553
|
alias: "s",
|
|
13447
13554
|
type: "string",
|
|
13448
13555
|
choices: ["todo", "active", "completed", "paused", "cancelled", "archived"],
|
|
@@ -13493,29 +13600,38 @@ var SearchCommand = {
|
|
|
13493
13600
|
if (args.json) {
|
|
13494
13601
|
output.json(buildListTasksJson(tasks, total, { limit: args.limit, offset: args.offset }, { keywords: args.keywords }));
|
|
13495
13602
|
} else if (args.quiet) {
|
|
13496
|
-
|
|
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);
|
|
13497
13613
|
} else {
|
|
13498
13614
|
const keywordStr = args.keywords.join(" ");
|
|
13499
|
-
output.log(
|
|
13615
|
+
output.log(chalk26.bold(`
|
|
13500
13616
|
\uD83D\uDD0D Search: "${keywordStr}" — ${total} results
|
|
13501
13617
|
`));
|
|
13502
13618
|
if (tasks.length === 0) {
|
|
13503
|
-
output.log(
|
|
13619
|
+
output.log(chalk26.gray(" No matching tasks found."));
|
|
13504
13620
|
return;
|
|
13505
13621
|
}
|
|
13506
13622
|
for (const t of tasks) {
|
|
13507
|
-
const statusColor = t.status === "completed" ?
|
|
13508
|
-
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})`) : "";
|
|
13509
13625
|
output.log(` #${t.id} ${statusColor("[" + t.status + "]")} ${t.title}${pid}`);
|
|
13510
13626
|
if (t.current_status) {
|
|
13511
|
-
output.log(` ${
|
|
13627
|
+
output.log(` ${chalk26.gray(t.current_status.slice(0, 80))}`);
|
|
13512
13628
|
}
|
|
13513
13629
|
}
|
|
13514
13630
|
if (total > tasks.length) {
|
|
13515
|
-
output.log(
|
|
13631
|
+
output.log(chalk26.gray(`
|
|
13516
13632
|
... and ${total - tasks.length} more. Use --offset and --limit to paginate.`));
|
|
13517
13633
|
}
|
|
13518
|
-
output.log(
|
|
13634
|
+
output.log(chalk26.gray(` Page: ${Math.floor((args.offset || 0) / (args.limit || 20)) + 1}/${Math.ceil(total / (args.limit || 20))}`));
|
|
13519
13635
|
}
|
|
13520
13636
|
} catch (error) {
|
|
13521
13637
|
output.error(`Failed to search tasks: ${error}`);
|
|
@@ -13775,7 +13891,7 @@ var TasksCommand = {
|
|
|
13775
13891
|
};
|
|
13776
13892
|
|
|
13777
13893
|
// src/commands/skills/list.ts
|
|
13778
|
-
import
|
|
13894
|
+
import chalk27 from "chalk";
|
|
13779
13895
|
var ListCommand3 = {
|
|
13780
13896
|
command: "list",
|
|
13781
13897
|
aliases: ["ls"],
|
|
@@ -13791,12 +13907,7 @@ var ListCommand3 = {
|
|
|
13791
13907
|
type: "boolean",
|
|
13792
13908
|
default: false,
|
|
13793
13909
|
description: "JSON 输出"
|
|
13794
|
-
}).option("quiet", {
|
|
13795
|
-
alias: "q",
|
|
13796
|
-
type: "boolean",
|
|
13797
|
-
default: false,
|
|
13798
|
-
description: "简洁输出"
|
|
13799
|
-
}),
|
|
13910
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
13800
13911
|
async handler(args) {
|
|
13801
13912
|
const a = args;
|
|
13802
13913
|
const output = new OutputService2;
|
|
@@ -13813,41 +13924,61 @@ var ListCommand3 = {
|
|
|
13813
13924
|
output.error("SkillComponent not available");
|
|
13814
13925
|
process.exit(1);
|
|
13815
13926
|
}
|
|
13816
|
-
const
|
|
13817
|
-
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);
|
|
13818
13935
|
if (a.json) {
|
|
13819
13936
|
output.json({
|
|
13820
|
-
|
|
13821
|
-
|
|
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) => ({
|
|
13822
13944
|
name: s.name,
|
|
13823
13945
|
description: s.description,
|
|
13824
13946
|
source: s.source
|
|
13825
13947
|
}))
|
|
13826
13948
|
});
|
|
13827
13949
|
} else if (a.quiet) {
|
|
13828
|
-
|
|
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);
|
|
13829
13960
|
} else {
|
|
13830
13961
|
const header = [
|
|
13831
|
-
|
|
13832
|
-
|
|
13833
|
-
|
|
13962
|
+
chalk27.bold("Name"),
|
|
13963
|
+
chalk27.bold("Description"),
|
|
13964
|
+
chalk27.bold("Source")
|
|
13834
13965
|
].join(" | ");
|
|
13835
13966
|
const sourceColor = (source) => {
|
|
13836
13967
|
switch (source) {
|
|
13837
13968
|
case "project":
|
|
13838
|
-
return
|
|
13969
|
+
return chalk27.green;
|
|
13839
13970
|
case "user":
|
|
13840
|
-
return
|
|
13971
|
+
return chalk27.blue;
|
|
13841
13972
|
case "built-in":
|
|
13842
|
-
return
|
|
13973
|
+
return chalk27.gray;
|
|
13843
13974
|
default:
|
|
13844
|
-
return
|
|
13975
|
+
return chalk27.white;
|
|
13845
13976
|
}
|
|
13846
13977
|
};
|
|
13847
|
-
const rows =
|
|
13978
|
+
const rows = skills.map((s) => {
|
|
13848
13979
|
const desc2 = s.description.length > 50 ? s.description.slice(0, 47) + "..." : s.description;
|
|
13849
13980
|
return [
|
|
13850
|
-
|
|
13981
|
+
chalk27.cyan(s.name),
|
|
13851
13982
|
desc2,
|
|
13852
13983
|
sourceColor(s.source)(`[${s.source}]`)
|
|
13853
13984
|
].join(" | ");
|
|
@@ -13859,7 +13990,14 @@ var ListCommand3 = {
|
|
|
13859
13990
|
...rows.map((r) => `│${r}│`),
|
|
13860
13991
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
13861
13992
|
"",
|
|
13862
|
-
|
|
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
|
+
})
|
|
13863
14001
|
].join(`
|
|
13864
14002
|
`));
|
|
13865
14003
|
}
|
|
@@ -13873,7 +14011,7 @@ var ListCommand3 = {
|
|
|
13873
14011
|
};
|
|
13874
14012
|
|
|
13875
14013
|
// src/commands/skills/get.ts
|
|
13876
|
-
import
|
|
14014
|
+
import chalk28 from "chalk";
|
|
13877
14015
|
var GetCommand3 = {
|
|
13878
14016
|
command: "get <name>",
|
|
13879
14017
|
describe: "获取指定技能内容",
|
|
@@ -13917,13 +14055,13 @@ var GetCommand3 = {
|
|
|
13917
14055
|
content: skill.content
|
|
13918
14056
|
});
|
|
13919
14057
|
} else {
|
|
13920
|
-
output.log(
|
|
14058
|
+
output.log(chalk28.bold.cyan(`# ${skill.name}`));
|
|
13921
14059
|
output.log("");
|
|
13922
|
-
output.log(`${
|
|
13923
|
-
output.log(`${
|
|
13924
|
-
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}`);
|
|
13925
14063
|
output.log("");
|
|
13926
|
-
output.log(
|
|
14064
|
+
output.log(chalk28.bold("--- Content ---"));
|
|
13927
14065
|
output.log("");
|
|
13928
14066
|
output.log(skill.content);
|
|
13929
14067
|
}
|
|
@@ -13937,7 +14075,7 @@ var GetCommand3 = {
|
|
|
13937
14075
|
};
|
|
13938
14076
|
|
|
13939
14077
|
// src/commands/skills/search.ts
|
|
13940
|
-
import
|
|
14078
|
+
import chalk29 from "chalk";
|
|
13941
14079
|
var SearchCommand2 = {
|
|
13942
14080
|
command: "search <term>",
|
|
13943
14081
|
aliases: ["find"],
|
|
@@ -13976,7 +14114,7 @@ var SearchCommand2 = {
|
|
|
13976
14114
|
const term = args.term.toLowerCase();
|
|
13977
14115
|
const results = allSkills.filter((s) => s.name.toLowerCase().includes(term) || s.description.toLowerCase().includes(term));
|
|
13978
14116
|
if (results.length === 0) {
|
|
13979
|
-
output.log(
|
|
14117
|
+
output.log(chalk29.yellow(`No skills found matching: ${args.term}`));
|
|
13980
14118
|
return;
|
|
13981
14119
|
}
|
|
13982
14120
|
if (args.json) {
|
|
@@ -13993,19 +14131,19 @@ var SearchCommand2 = {
|
|
|
13993
14131
|
} else if (args.quiet) {
|
|
13994
14132
|
results.forEach((s) => output.log(s.name));
|
|
13995
14133
|
} else {
|
|
13996
|
-
output.log(
|
|
14134
|
+
output.log(chalk29.bold(`Search results for "${args.term}":`));
|
|
13997
14135
|
output.log("");
|
|
13998
14136
|
const header = [
|
|
13999
|
-
|
|
14000
|
-
|
|
14001
|
-
|
|
14137
|
+
chalk29.bold("Name"),
|
|
14138
|
+
chalk29.bold("Description"),
|
|
14139
|
+
chalk29.bold("Match")
|
|
14002
14140
|
].join(" | ");
|
|
14003
14141
|
const rows = results.map((s) => {
|
|
14004
14142
|
const matchedIn = s.name.toLowerCase().includes(term) ? "name" : "description";
|
|
14005
|
-
const matchColor = matchedIn === "name" ?
|
|
14143
|
+
const matchColor = matchedIn === "name" ? chalk29.green : chalk29.blue;
|
|
14006
14144
|
const desc2 = s.description.length > 40 ? s.description.slice(0, 37) + "..." : s.description;
|
|
14007
14145
|
return [
|
|
14008
|
-
|
|
14146
|
+
chalk29.cyan(s.name),
|
|
14009
14147
|
desc2,
|
|
14010
14148
|
matchColor(`[${matchedIn}]`)
|
|
14011
14149
|
].join(" | ");
|
|
@@ -14017,7 +14155,7 @@ var SearchCommand2 = {
|
|
|
14017
14155
|
...rows.map((r) => `│${r}│`),
|
|
14018
14156
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
14019
14157
|
"",
|
|
14020
|
-
|
|
14158
|
+
chalk29.gray(`${results.length} matching skill(s) found.`)
|
|
14021
14159
|
].join(`
|
|
14022
14160
|
`));
|
|
14023
14161
|
}
|
|
@@ -14031,7 +14169,7 @@ var SearchCommand2 = {
|
|
|
14031
14169
|
};
|
|
14032
14170
|
|
|
14033
14171
|
// src/commands/skills/reload.ts
|
|
14034
|
-
import
|
|
14172
|
+
import chalk30 from "chalk";
|
|
14035
14173
|
var ReloadCommand = {
|
|
14036
14174
|
command: "reload",
|
|
14037
14175
|
describe: "重新扫描并更新 SkillTool",
|
|
@@ -14054,10 +14192,10 @@ var ReloadCommand = {
|
|
|
14054
14192
|
output.error("SkillComponent not available");
|
|
14055
14193
|
process.exit(1);
|
|
14056
14194
|
}
|
|
14057
|
-
output.log(
|
|
14195
|
+
output.log(chalk30.blue("Reloading skills..."));
|
|
14058
14196
|
await skillComponent.reload();
|
|
14059
14197
|
const skills = skillComponent.getSkillList();
|
|
14060
|
-
output.log(
|
|
14198
|
+
output.log(chalk30.green(`Successfully reloaded ${skills.length} skills`));
|
|
14061
14199
|
} catch (error) {
|
|
14062
14200
|
output.error(`Failed to reload skills: ${error}`);
|
|
14063
14201
|
process.exit(1);
|
|
@@ -14068,7 +14206,7 @@ var ReloadCommand = {
|
|
|
14068
14206
|
};
|
|
14069
14207
|
|
|
14070
14208
|
// src/commands/skills/show-config.ts
|
|
14071
|
-
import
|
|
14209
|
+
import chalk31 from "chalk";
|
|
14072
14210
|
var ShowConfigCommand = {
|
|
14073
14211
|
command: "show-config",
|
|
14074
14212
|
aliases: ["config"],
|
|
@@ -14093,38 +14231,38 @@ var ShowConfigCommand = {
|
|
|
14093
14231
|
process.exit(1);
|
|
14094
14232
|
}
|
|
14095
14233
|
const defaultConfig = skillComponent.getConfig?.();
|
|
14096
|
-
output.log(
|
|
14234
|
+
output.log(chalk31.bold.cyan(`# Skills Configuration
|
|
14097
14235
|
`));
|
|
14098
|
-
output.log(
|
|
14236
|
+
output.log(chalk31.bold(`## Scan Paths
|
|
14099
14237
|
`));
|
|
14100
14238
|
const paths = [
|
|
14101
14239
|
{ type: "user", desc: "用户路径", path: "~/.config/roy-agent/skills/" },
|
|
14102
14240
|
{ type: "project", desc: "项目路径", path: ".roy/skills/" }
|
|
14103
14241
|
];
|
|
14104
14242
|
for (const p of paths) {
|
|
14105
|
-
const typeColor = p.type === "project" ?
|
|
14106
|
-
output.log(` ${typeColor("[ " + p.type + " ]")} ${
|
|
14107
|
-
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)}
|
|
14108
14246
|
`);
|
|
14109
14247
|
}
|
|
14110
|
-
output.log(
|
|
14248
|
+
output.log(chalk31.bold(`## Scan Rules
|
|
14111
14249
|
`));
|
|
14112
|
-
output.log(` ${
|
|
14113
|
-
output.log(` ${
|
|
14114
|
-
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/**")}
|
|
14115
14253
|
`);
|
|
14116
|
-
output.log(
|
|
14254
|
+
output.log(chalk31.bold(`## Priority (High to Low)
|
|
14117
14255
|
`));
|
|
14118
|
-
output.log(` ${
|
|
14119
|
-
output.log(` ${
|
|
14120
|
-
output.log(` ${
|
|
14256
|
+
output.log(` ${chalk31.green("1. project")} - 项目路径(最高优先级)`);
|
|
14257
|
+
output.log(` ${chalk31.blue("2. user")} - 用户路径`);
|
|
14258
|
+
output.log(` ${chalk31.gray("3. built-in")} - 内置路径(预留)
|
|
14121
14259
|
`);
|
|
14122
|
-
output.log(
|
|
14260
|
+
output.log(chalk31.bold(`## Usage
|
|
14123
14261
|
`));
|
|
14124
|
-
output.log(` ${
|
|
14125
|
-
output.log(` ${
|
|
14126
|
-
output.log(` ${
|
|
14127
|
-
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("- 重新扫描技能")}`);
|
|
14128
14266
|
} catch (error) {
|
|
14129
14267
|
output.error(`Failed to show config: ${error}`);
|
|
14130
14268
|
process.exit(1);
|
|
@@ -14145,7 +14283,7 @@ var SkillsCommand = {
|
|
|
14145
14283
|
};
|
|
14146
14284
|
|
|
14147
14285
|
// src/commands/agents/list.ts
|
|
14148
|
-
import
|
|
14286
|
+
import chalk32 from "chalk";
|
|
14149
14287
|
var ListCommand4 = {
|
|
14150
14288
|
command: "list",
|
|
14151
14289
|
aliases: ["ls"],
|
|
@@ -14161,12 +14299,7 @@ var ListCommand4 = {
|
|
|
14161
14299
|
type: "boolean",
|
|
14162
14300
|
default: false,
|
|
14163
14301
|
description: "JSON 输出"
|
|
14164
|
-
}).option("quiet", {
|
|
14165
|
-
alias: "q",
|
|
14166
|
-
type: "boolean",
|
|
14167
|
-
default: false,
|
|
14168
|
-
description: "简洁输出"
|
|
14169
|
-
}),
|
|
14302
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
14170
14303
|
async handler(args) {
|
|
14171
14304
|
const output = new OutputService2;
|
|
14172
14305
|
const envService = new EnvironmentService(output);
|
|
@@ -14198,10 +14331,21 @@ var ListCommand4 = {
|
|
|
14198
14331
|
} else {
|
|
14199
14332
|
agents = registry.list();
|
|
14200
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);
|
|
14201
14340
|
if (args.json) {
|
|
14202
14341
|
output.json({
|
|
14203
|
-
|
|
14204
|
-
|
|
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) => ({
|
|
14205
14349
|
name: a.name,
|
|
14206
14350
|
type: a.type,
|
|
14207
14351
|
source: builtInSubAgentNames.has(a.name) ? "built-in" : "user",
|
|
@@ -14213,30 +14357,39 @@ var ListCommand4 = {
|
|
|
14213
14357
|
}))
|
|
14214
14358
|
});
|
|
14215
14359
|
} else if (args.quiet) {
|
|
14216
|
-
|
|
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);
|
|
14217
14370
|
} else {
|
|
14218
14371
|
const header = [
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14372
|
+
chalk32.bold("Name"),
|
|
14373
|
+
chalk32.bold("Type"),
|
|
14374
|
+
chalk32.bold("Source"),
|
|
14375
|
+
chalk32.bold("Model"),
|
|
14376
|
+
chalk32.bold("Workflow"),
|
|
14377
|
+
chalk32.bold("Description")
|
|
14225
14378
|
].join(" | ");
|
|
14226
14379
|
const typeColor = (type) => {
|
|
14227
14380
|
if (type === "primary")
|
|
14228
|
-
return
|
|
14381
|
+
return chalk32.yellow;
|
|
14229
14382
|
if (type === "workflow")
|
|
14230
|
-
return
|
|
14231
|
-
return
|
|
14383
|
+
return chalk32.magenta;
|
|
14384
|
+
return chalk32.blue;
|
|
14232
14385
|
};
|
|
14233
|
-
const rows =
|
|
14386
|
+
const rows = pagedAgents.map((a) => {
|
|
14234
14387
|
const desc2 = (a.description || "").length > 40 ? (a.description || "").slice(0, 37) + "..." : a.description || "-";
|
|
14235
|
-
const workflowDisplay = a.type === "workflow" && a.workflow ?
|
|
14236
|
-
const modelDisplay = a.model ?
|
|
14237
|
-
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");
|
|
14238
14391
|
return [
|
|
14239
|
-
|
|
14392
|
+
chalk32.cyan(a.name),
|
|
14240
14393
|
typeColor(a.type)(a.type),
|
|
14241
14394
|
sourceDisplay,
|
|
14242
14395
|
modelDisplay,
|
|
@@ -14245,9 +14398,9 @@ var ListCommand4 = {
|
|
|
14245
14398
|
].join(" | ");
|
|
14246
14399
|
});
|
|
14247
14400
|
if (rows.length === 0) {
|
|
14248
|
-
output.log(
|
|
14401
|
+
output.log(chalk32.yellow("No agents found."));
|
|
14249
14402
|
output.log("");
|
|
14250
|
-
output.log(
|
|
14403
|
+
output.log(chalk32.gray("Tip: Create agent configs in ~/.local/share/roy-agent/agents/"));
|
|
14251
14404
|
} else {
|
|
14252
14405
|
output.log([
|
|
14253
14406
|
`┌─ Agents ${"─".repeat(50)}┐`,
|
|
@@ -14256,7 +14409,14 @@ var ListCommand4 = {
|
|
|
14256
14409
|
...rows.map((r) => `│${r}│`),
|
|
14257
14410
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
14258
14411
|
"",
|
|
14259
|
-
|
|
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
|
+
})
|
|
14260
14420
|
].join(`
|
|
14261
14421
|
`));
|
|
14262
14422
|
}
|
|
@@ -14271,7 +14431,7 @@ var ListCommand4 = {
|
|
|
14271
14431
|
};
|
|
14272
14432
|
|
|
14273
14433
|
// src/commands/agents/get.ts
|
|
14274
|
-
import
|
|
14434
|
+
import chalk33 from "chalk";
|
|
14275
14435
|
var GetCommand4 = {
|
|
14276
14436
|
command: "get <name>",
|
|
14277
14437
|
describe: "获取指定 agent 的详细信息",
|
|
@@ -14330,69 +14490,69 @@ var GetCommand4 = {
|
|
|
14330
14490
|
filterHistory: agent.filterHistory
|
|
14331
14491
|
});
|
|
14332
14492
|
} else {
|
|
14333
|
-
output.log(
|
|
14493
|
+
output.log(chalk33.bold.cyan(`# Agent: ${agent.name}`));
|
|
14334
14494
|
output.log("");
|
|
14335
|
-
output.log(
|
|
14336
|
-
output.log(` ${
|
|
14337
|
-
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}`);
|
|
14338
14498
|
if (agent.description) {
|
|
14339
|
-
output.log(` ${
|
|
14499
|
+
output.log(` ${chalk33.cyan("description:")} ${agent.description}`);
|
|
14340
14500
|
}
|
|
14341
14501
|
output.log("");
|
|
14342
14502
|
if (agent.type === "workflow") {
|
|
14343
|
-
output.log(
|
|
14503
|
+
output.log(chalk33.bold("Workflow:"));
|
|
14344
14504
|
if (agent.workflow) {
|
|
14345
|
-
output.log(` ${
|
|
14346
|
-
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":"..."}'`)}`);
|
|
14347
14507
|
} else {
|
|
14348
|
-
output.log(` ${
|
|
14508
|
+
output.log(` ${chalk33.gray("(no workflow configured)")}`);
|
|
14349
14509
|
}
|
|
14350
14510
|
output.log("");
|
|
14351
14511
|
}
|
|
14352
|
-
output.log(
|
|
14512
|
+
output.log(chalk33.bold("System Prompt:"));
|
|
14353
14513
|
if (agent.systemPromptRef) {
|
|
14354
|
-
output.log(` ${
|
|
14514
|
+
output.log(` ${chalk33.green("[ref]")} ${chalk33.cyan("systemPromptRef:")} ${agent.systemPromptRef}`);
|
|
14355
14515
|
}
|
|
14356
14516
|
if (agent.systemPrompt && !agent.systemPromptRef) {
|
|
14357
14517
|
const promptPreview = agent.systemPrompt.length > 100 ? agent.systemPrompt.slice(0, 97) + "..." : agent.systemPrompt;
|
|
14358
|
-
output.log(` ${
|
|
14359
|
-
output.log(` ${
|
|
14518
|
+
output.log(` ${chalk33.gray("[inline]")}`);
|
|
14519
|
+
output.log(` ${chalk33.gray(promptPreview.split(`
|
|
14360
14520
|
`).join(`
|
|
14361
14521
|
`))}`);
|
|
14362
14522
|
}
|
|
14363
14523
|
if (resolvedSystemPrompt) {
|
|
14364
14524
|
const resolvedPreview = resolvedSystemPrompt.length > 200 ? resolvedSystemPrompt.slice(0, 197) + "..." : resolvedSystemPrompt;
|
|
14365
|
-
output.log(` ${
|
|
14366
|
-
output.log(` ${
|
|
14525
|
+
output.log(` ${chalk33.green("[resolved]")}`);
|
|
14526
|
+
output.log(` ${chalk33.gray(resolvedPreview.split(`
|
|
14367
14527
|
`).join(`
|
|
14368
14528
|
`))}`);
|
|
14369
14529
|
}
|
|
14370
14530
|
if (!agent.systemPromptRef && !agent.systemPrompt && !resolvedSystemPrompt) {
|
|
14371
|
-
output.log(` ${
|
|
14531
|
+
output.log(` ${chalk33.gray("(none)")}`);
|
|
14372
14532
|
}
|
|
14373
14533
|
output.log("");
|
|
14374
14534
|
const hasOptions = agent.model || agent.maxIterations || agent.toolTimeout;
|
|
14375
14535
|
if (hasOptions) {
|
|
14376
|
-
output.log(
|
|
14536
|
+
output.log(chalk33.bold("Options:"));
|
|
14377
14537
|
if (agent.model) {
|
|
14378
|
-
output.log(` ${
|
|
14538
|
+
output.log(` ${chalk33.cyan("model:")} ${agent.model}`);
|
|
14379
14539
|
}
|
|
14380
14540
|
if (agent.maxIterations) {
|
|
14381
|
-
output.log(` ${
|
|
14541
|
+
output.log(` ${chalk33.cyan("maxIterations:")} ${agent.maxIterations}`);
|
|
14382
14542
|
}
|
|
14383
14543
|
if (agent.toolTimeout) {
|
|
14384
|
-
output.log(` ${
|
|
14544
|
+
output.log(` ${chalk33.cyan("toolTimeout:")} ${agent.toolTimeout}ms`);
|
|
14385
14545
|
}
|
|
14386
14546
|
output.log("");
|
|
14387
14547
|
}
|
|
14388
14548
|
const hasTools = agent.allowedTools?.length || agent.deniedTools?.length;
|
|
14389
14549
|
if (hasTools) {
|
|
14390
|
-
output.log(
|
|
14550
|
+
output.log(chalk33.bold("Tool Permissions:"));
|
|
14391
14551
|
if (agent.allowedTools?.length) {
|
|
14392
|
-
output.log(` ${
|
|
14552
|
+
output.log(` ${chalk33.green("allowed:")} ${agent.allowedTools.join(", ")}`);
|
|
14393
14553
|
}
|
|
14394
14554
|
if (agent.deniedTools?.length) {
|
|
14395
|
-
output.log(` ${
|
|
14555
|
+
output.log(` ${chalk33.red("denied:")} ${agent.deniedTools.join(", ")}`);
|
|
14396
14556
|
}
|
|
14397
14557
|
output.log("");
|
|
14398
14558
|
}
|
|
@@ -14407,7 +14567,7 @@ var GetCommand4 = {
|
|
|
14407
14567
|
};
|
|
14408
14568
|
|
|
14409
14569
|
// src/commands/agents/add.ts
|
|
14410
|
-
import
|
|
14570
|
+
import chalk34 from "chalk";
|
|
14411
14571
|
function parseToolList(value) {
|
|
14412
14572
|
if (!value?.trim()) {
|
|
14413
14573
|
return;
|
|
@@ -14499,8 +14659,8 @@ var AddCommand = {
|
|
|
14499
14659
|
if (args.json) {
|
|
14500
14660
|
output.json({ agent, filePath });
|
|
14501
14661
|
} else {
|
|
14502
|
-
output.log(
|
|
14503
|
-
output.log(
|
|
14662
|
+
output.log(chalk34.green(`✓ Agent '${args.name}' created`));
|
|
14663
|
+
output.log(chalk34.gray(` ${filePath}`));
|
|
14504
14664
|
}
|
|
14505
14665
|
} catch (error) {
|
|
14506
14666
|
output.error(`Failed to add agent: ${error}`);
|
|
@@ -14512,7 +14672,7 @@ var AddCommand = {
|
|
|
14512
14672
|
};
|
|
14513
14673
|
|
|
14514
14674
|
// src/commands/agents/delete.ts
|
|
14515
|
-
import
|
|
14675
|
+
import chalk35 from "chalk";
|
|
14516
14676
|
var DeleteCommand3 = {
|
|
14517
14677
|
command: "delete <name>",
|
|
14518
14678
|
describe: "删除 agent 配置文件",
|
|
@@ -14554,7 +14714,7 @@ var DeleteCommand3 = {
|
|
|
14554
14714
|
}
|
|
14555
14715
|
const filePath = registry.getAgentFilePath(args.name);
|
|
14556
14716
|
if (!args.yes) {
|
|
14557
|
-
output.log(
|
|
14717
|
+
output.log(chalk35.yellow(`Delete agent '${args.name}'? This removes ${filePath} (use --yes to skip confirmation)`));
|
|
14558
14718
|
process.exit(1);
|
|
14559
14719
|
}
|
|
14560
14720
|
const deleted = await registry.deleteAgent(args.name);
|
|
@@ -14565,7 +14725,7 @@ var DeleteCommand3 = {
|
|
|
14565
14725
|
if (args.json) {
|
|
14566
14726
|
output.json({ deleted: true, name: args.name, filePath });
|
|
14567
14727
|
} else {
|
|
14568
|
-
output.log(
|
|
14728
|
+
output.log(chalk35.green(`✓ Agent '${args.name}' deleted`));
|
|
14569
14729
|
}
|
|
14570
14730
|
} catch (error) {
|
|
14571
14731
|
output.error(`Failed to delete agent: ${error}`);
|
|
@@ -14577,7 +14737,7 @@ var DeleteCommand3 = {
|
|
|
14577
14737
|
};
|
|
14578
14738
|
|
|
14579
14739
|
// src/commands/agents/config-dir.ts
|
|
14580
|
-
import
|
|
14740
|
+
import chalk36 from "chalk";
|
|
14581
14741
|
var ConfigDirCommand = {
|
|
14582
14742
|
command: "config-dir",
|
|
14583
14743
|
describe: "显示 agent 配置目录路径",
|
|
@@ -14608,8 +14768,8 @@ var ConfigDirCommand = {
|
|
|
14608
14768
|
if (args.json) {
|
|
14609
14769
|
output.json({ configDir, exists });
|
|
14610
14770
|
} else {
|
|
14611
|
-
output.log(`${
|
|
14612
|
-
output.log(`${
|
|
14771
|
+
output.log(`${chalk36.cyan("Agent Config Directory:")} ${configDir}`);
|
|
14772
|
+
output.log(`${chalk36.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
14613
14773
|
}
|
|
14614
14774
|
} catch (error) {
|
|
14615
14775
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -14632,7 +14792,7 @@ var AgentsCommand = {
|
|
|
14632
14792
|
};
|
|
14633
14793
|
|
|
14634
14794
|
// src/commands/prompt/list.ts
|
|
14635
|
-
import
|
|
14795
|
+
import chalk37 from "chalk";
|
|
14636
14796
|
var ListCommand5 = {
|
|
14637
14797
|
command: "list",
|
|
14638
14798
|
aliases: ["ls"],
|
|
@@ -14648,12 +14808,7 @@ var ListCommand5 = {
|
|
|
14648
14808
|
type: "boolean",
|
|
14649
14809
|
default: false,
|
|
14650
14810
|
description: "JSON 输出"
|
|
14651
|
-
}).option("quiet", {
|
|
14652
|
-
alias: "q",
|
|
14653
|
-
type: "boolean",
|
|
14654
|
-
default: false,
|
|
14655
|
-
description: "简洁输出"
|
|
14656
|
-
}),
|
|
14811
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
14657
14812
|
async handler(args) {
|
|
14658
14813
|
const output = new OutputService2;
|
|
14659
14814
|
const envService = new EnvironmentService(output);
|
|
@@ -14669,36 +14824,54 @@ var ListCommand5 = {
|
|
|
14669
14824
|
output.error("PromptComponent not available");
|
|
14670
14825
|
process.exit(1);
|
|
14671
14826
|
}
|
|
14672
|
-
|
|
14827
|
+
const allPrompts = promptComponent.listEntries().map((entry) => ({
|
|
14673
14828
|
name: entry.name,
|
|
14674
14829
|
source: entry.source
|
|
14675
14830
|
}));
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
-
|
|
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);
|
|
14679
14838
|
if (args.json) {
|
|
14680
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",
|
|
14681
14846
|
prompts: prompts.map((p) => ({
|
|
14682
14847
|
name: p.name,
|
|
14683
14848
|
source: p.source
|
|
14684
|
-
}))
|
|
14685
|
-
count: prompts.length
|
|
14849
|
+
}))
|
|
14686
14850
|
});
|
|
14687
14851
|
} else if (args.quiet) {
|
|
14688
|
-
|
|
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);
|
|
14689
14862
|
} else {
|
|
14690
14863
|
const header = [
|
|
14691
|
-
|
|
14692
|
-
|
|
14864
|
+
chalk37.bold("Name"),
|
|
14865
|
+
chalk37.bold("Source")
|
|
14693
14866
|
].join(" | ");
|
|
14694
14867
|
const rows = prompts.map((p) => {
|
|
14695
14868
|
return [
|
|
14696
|
-
|
|
14697
|
-
|
|
14869
|
+
chalk37.cyan(p.name),
|
|
14870
|
+
chalk37.gray(`[${p.source}]`)
|
|
14698
14871
|
].join(" | ");
|
|
14699
14872
|
});
|
|
14700
14873
|
if (rows.length === 0) {
|
|
14701
|
-
output.log(
|
|
14874
|
+
output.log(chalk37.yellow("No prompts found."));
|
|
14702
14875
|
} else {
|
|
14703
14876
|
output.log([
|
|
14704
14877
|
`┌─ Prompts ${"─".repeat(50)}┐`,
|
|
@@ -14707,7 +14880,14 @@ var ListCommand5 = {
|
|
|
14707
14880
|
...rows.map((r) => `│${r}│`),
|
|
14708
14881
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
14709
14882
|
"",
|
|
14710
|
-
|
|
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
|
+
})
|
|
14711
14891
|
].join(`
|
|
14712
14892
|
`));
|
|
14713
14893
|
}
|
|
@@ -14722,7 +14902,7 @@ var ListCommand5 = {
|
|
|
14722
14902
|
};
|
|
14723
14903
|
|
|
14724
14904
|
// src/commands/prompt/get.ts
|
|
14725
|
-
import
|
|
14905
|
+
import chalk38 from "chalk";
|
|
14726
14906
|
var GetCommand5 = {
|
|
14727
14907
|
command: "get <name>",
|
|
14728
14908
|
describe: "获取指定 prompt 的内容",
|
|
@@ -14769,16 +14949,16 @@ var GetCommand5 = {
|
|
|
14769
14949
|
variables: vars
|
|
14770
14950
|
});
|
|
14771
14951
|
} else {
|
|
14772
|
-
output.log(
|
|
14952
|
+
output.log(chalk38.bold.cyan(`# Prompt: ${args.name}`));
|
|
14773
14953
|
output.log("");
|
|
14774
14954
|
if (Object.keys(vars).length > 0) {
|
|
14775
|
-
output.log(
|
|
14955
|
+
output.log(chalk38.gray("Variables:"));
|
|
14776
14956
|
for (const [key, value] of Object.entries(vars)) {
|
|
14777
|
-
output.log(` ${
|
|
14957
|
+
output.log(` ${chalk38.cyan(key + ":")} ${value}`);
|
|
14778
14958
|
}
|
|
14779
14959
|
output.log("");
|
|
14780
14960
|
}
|
|
14781
|
-
output.log(
|
|
14961
|
+
output.log(chalk38.bold("Content:"));
|
|
14782
14962
|
output.log("─".repeat(60));
|
|
14783
14963
|
output.log(prompt);
|
|
14784
14964
|
output.log("─".repeat(60));
|
|
@@ -14808,7 +14988,7 @@ function parseVars(vars) {
|
|
|
14808
14988
|
|
|
14809
14989
|
// src/commands/prompt/add.ts
|
|
14810
14990
|
import { readFile as readFile2 } from "fs/promises";
|
|
14811
|
-
import
|
|
14991
|
+
import chalk39 from "chalk";
|
|
14812
14992
|
var AddCommand2 = {
|
|
14813
14993
|
command: "add <name>",
|
|
14814
14994
|
describe: "添加 prompt 并持久化到 ~/.local/share/roy-agent/prompts/",
|
|
@@ -14859,8 +15039,8 @@ var AddCommand2 = {
|
|
|
14859
15039
|
length: content.trim().length
|
|
14860
15040
|
});
|
|
14861
15041
|
} else {
|
|
14862
|
-
output.log(
|
|
14863
|
-
output.log(
|
|
15042
|
+
output.log(chalk39.green(`✓ Prompt '${args.name}' saved`));
|
|
15043
|
+
output.log(chalk39.gray(` ${filePath}`));
|
|
14864
15044
|
}
|
|
14865
15045
|
} catch (error) {
|
|
14866
15046
|
output.error(`Failed to add prompt: ${error}`);
|
|
@@ -14872,7 +15052,7 @@ var AddCommand2 = {
|
|
|
14872
15052
|
};
|
|
14873
15053
|
|
|
14874
15054
|
// src/commands/prompt/config-dir.ts
|
|
14875
|
-
import
|
|
15055
|
+
import chalk40 from "chalk";
|
|
14876
15056
|
var ConfigDirCommand2 = {
|
|
14877
15057
|
command: "config-dir",
|
|
14878
15058
|
describe: "显示 prompt 持久化目录路径",
|
|
@@ -14902,8 +15082,8 @@ var ConfigDirCommand2 = {
|
|
|
14902
15082
|
if (args.json) {
|
|
14903
15083
|
output.json({ configDir, exists });
|
|
14904
15084
|
} else {
|
|
14905
|
-
output.log(`${
|
|
14906
|
-
output.log(`${
|
|
15085
|
+
output.log(`${chalk40.cyan("Prompt Config Directory:")} ${configDir}`);
|
|
15086
|
+
output.log(`${chalk40.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
14907
15087
|
}
|
|
14908
15088
|
} catch (error) {
|
|
14909
15089
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -14925,7 +15105,7 @@ var PromptCommand = {
|
|
|
14925
15105
|
};
|
|
14926
15106
|
|
|
14927
15107
|
// src/commands/commands-list.ts
|
|
14928
|
-
import
|
|
15108
|
+
import chalk41 from "chalk";
|
|
14929
15109
|
function truncateVisual(str, maxWidth) {
|
|
14930
15110
|
let result = "";
|
|
14931
15111
|
let width = 0;
|
|
@@ -14940,16 +15120,16 @@ function truncateVisual(str, maxWidth) {
|
|
|
14940
15120
|
}
|
|
14941
15121
|
function formatCommandsTable(commands) {
|
|
14942
15122
|
if (commands.length === 0) {
|
|
14943
|
-
return
|
|
15123
|
+
return chalk41.yellow("命令目录为空,使用 'roy-agent commands add' 添加命令");
|
|
14944
15124
|
}
|
|
14945
15125
|
const NAME_WIDTH = 20;
|
|
14946
15126
|
const SOURCE_WIDTH = 10;
|
|
14947
15127
|
const DESC_WIDTH = 50;
|
|
14948
15128
|
const GAP = " ";
|
|
14949
15129
|
const headerLine = [
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
15130
|
+
chalk41.bold("NAME".padEnd(NAME_WIDTH)),
|
|
15131
|
+
chalk41.bold("SOURCE".padEnd(SOURCE_WIDTH)),
|
|
15132
|
+
chalk41.bold("DESCRIPTION")
|
|
14953
15133
|
].join(GAP);
|
|
14954
15134
|
const sepLine = "─".repeat(NAME_WIDTH + SOURCE_WIDTH + DESC_WIDTH + GAP.length * 2);
|
|
14955
15135
|
const formatRow = (cmd) => {
|
|
@@ -14973,7 +15153,7 @@ var CommandsListCommand = {
|
|
|
14973
15153
|
describe: "JSON 格式输出",
|
|
14974
15154
|
type: "boolean",
|
|
14975
15155
|
default: false
|
|
14976
|
-
}).option("config", {
|
|
15156
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }).option("config", {
|
|
14977
15157
|
describe: "配置文件路径",
|
|
14978
15158
|
type: "string"
|
|
14979
15159
|
}),
|
|
@@ -14993,18 +15173,41 @@ var CommandsListCommand = {
|
|
|
14993
15173
|
process.exit(1);
|
|
14994
15174
|
}
|
|
14995
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);
|
|
14996
15182
|
if (args.json) {
|
|
14997
15183
|
output.json({
|
|
14998
|
-
|
|
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) => ({
|
|
14999
15192
|
name: cmd.name,
|
|
15000
15193
|
path: cmd.path,
|
|
15001
15194
|
source: cmd.source,
|
|
15002
15195
|
description: cmd.shortDescription
|
|
15003
|
-
}))
|
|
15004
|
-
|
|
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
|
|
15005
15206
|
});
|
|
15207
|
+
if (hint)
|
|
15208
|
+
output.log(hint);
|
|
15006
15209
|
} else {
|
|
15007
|
-
const rows =
|
|
15210
|
+
const rows = commands.map((cmd) => ({
|
|
15008
15211
|
name: cmd.name,
|
|
15009
15212
|
path: cmd.path,
|
|
15010
15213
|
source: cmd.source === "user" ? "USER" : "PROJECT",
|
|
@@ -15012,7 +15215,17 @@ var CommandsListCommand = {
|
|
|
15012
15215
|
}));
|
|
15013
15216
|
output.log(formatCommandsTable(rows));
|
|
15014
15217
|
output.info("");
|
|
15015
|
-
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
|
+
}));
|
|
15016
15229
|
}
|
|
15017
15230
|
} catch (error) {
|
|
15018
15231
|
output.error(`Failed to list commands: ${error}`);
|
|
@@ -15024,7 +15237,7 @@ var CommandsListCommand = {
|
|
|
15024
15237
|
};
|
|
15025
15238
|
|
|
15026
15239
|
// src/commands/commands-add.ts
|
|
15027
|
-
import
|
|
15240
|
+
import chalk42 from "chalk";
|
|
15028
15241
|
var CommandsAddCommand = {
|
|
15029
15242
|
command: "add <name> <target>",
|
|
15030
15243
|
describe: "添加收藏命令(自动创建 symlink)",
|
|
@@ -15085,10 +15298,10 @@ var CommandsAddCommand = {
|
|
|
15085
15298
|
});
|
|
15086
15299
|
const dirs = await commandsComponent.getCommandDirs();
|
|
15087
15300
|
const targetDir = source === "user" ? dirs.user : dirs.project;
|
|
15088
|
-
output.log(
|
|
15089
|
-
output.log(
|
|
15090
|
-
output.log(
|
|
15091
|
-
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"}`));
|
|
15092
15305
|
} catch (error) {
|
|
15093
15306
|
output.error(`添加失败: ${error.message}`);
|
|
15094
15307
|
process.exit(1);
|
|
@@ -15099,7 +15312,7 @@ var CommandsAddCommand = {
|
|
|
15099
15312
|
};
|
|
15100
15313
|
|
|
15101
15314
|
// src/commands/commands-remove.ts
|
|
15102
|
-
import
|
|
15315
|
+
import chalk43 from "chalk";
|
|
15103
15316
|
var CommandsRemoveCommand = {
|
|
15104
15317
|
command: "remove <name>",
|
|
15105
15318
|
aliases: ["rm"],
|
|
@@ -15143,7 +15356,7 @@ var CommandsRemoveCommand = {
|
|
|
15143
15356
|
name: args.name,
|
|
15144
15357
|
source: "user"
|
|
15145
15358
|
});
|
|
15146
|
-
output.log(
|
|
15359
|
+
output.log(chalk43.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
15147
15360
|
} catch (error) {
|
|
15148
15361
|
if (!error.message?.includes("不存在")) {
|
|
15149
15362
|
throw error;
|
|
@@ -15156,7 +15369,7 @@ var CommandsRemoveCommand = {
|
|
|
15156
15369
|
name: args.name,
|
|
15157
15370
|
source: "project"
|
|
15158
15371
|
});
|
|
15159
|
-
output.log(
|
|
15372
|
+
output.log(chalk43.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
15160
15373
|
} catch (error) {
|
|
15161
15374
|
if (!error.message?.includes("不存在")) {
|
|
15162
15375
|
throw error;
|
|
@@ -15170,7 +15383,7 @@ var CommandsRemoveCommand = {
|
|
|
15170
15383
|
name: args.name,
|
|
15171
15384
|
source: "user"
|
|
15172
15385
|
});
|
|
15173
|
-
output.log(
|
|
15386
|
+
output.log(chalk43.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
15174
15387
|
removed = true;
|
|
15175
15388
|
} catch (error) {
|
|
15176
15389
|
if (!error.message?.includes("不存在")) {
|
|
@@ -15182,7 +15395,7 @@ var CommandsRemoveCommand = {
|
|
|
15182
15395
|
name: args.name,
|
|
15183
15396
|
source: "project"
|
|
15184
15397
|
});
|
|
15185
|
-
output.log(
|
|
15398
|
+
output.log(chalk43.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
15186
15399
|
removed = true;
|
|
15187
15400
|
} catch (error) {
|
|
15188
15401
|
if (!error.message?.includes("不存在")) {
|
|
@@ -15204,7 +15417,7 @@ var CommandsRemoveCommand = {
|
|
|
15204
15417
|
};
|
|
15205
15418
|
|
|
15206
15419
|
// src/commands/commands-info.ts
|
|
15207
|
-
import
|
|
15420
|
+
import chalk44 from "chalk";
|
|
15208
15421
|
import { exec as exec2 } from "child_process";
|
|
15209
15422
|
import { promisify } from "util";
|
|
15210
15423
|
var execAsync2 = promisify(exec2);
|
|
@@ -15239,12 +15452,12 @@ var CommandsInfoCommand = {
|
|
|
15239
15452
|
output.error(`命令 '${args.name}' 不存在`);
|
|
15240
15453
|
process.exit(1);
|
|
15241
15454
|
}
|
|
15242
|
-
output.log(
|
|
15243
|
-
output.log(
|
|
15244
|
-
output.log(
|
|
15245
|
-
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 || "-"}`);
|
|
15246
15459
|
output.log();
|
|
15247
|
-
output.log(
|
|
15460
|
+
output.log(chalk44.gray("─".repeat(50)));
|
|
15248
15461
|
output.log();
|
|
15249
15462
|
try {
|
|
15250
15463
|
const { stdout } = await execAsync2(`${info.path} --help`, { timeout: 5000 });
|
|
@@ -15254,7 +15467,7 @@ var CommandsInfoCommand = {
|
|
|
15254
15467
|
const { stdout } = await execAsync2(`${info.path} -h`, { timeout: 5000 });
|
|
15255
15468
|
output.log(stdout);
|
|
15256
15469
|
} catch {
|
|
15257
|
-
output.log(
|
|
15470
|
+
output.log(chalk44.gray("(无法获取帮助信息)"));
|
|
15258
15471
|
}
|
|
15259
15472
|
}
|
|
15260
15473
|
} catch (error) {
|
|
@@ -15267,7 +15480,7 @@ var CommandsInfoCommand = {
|
|
|
15267
15480
|
};
|
|
15268
15481
|
|
|
15269
15482
|
// src/commands/commands-dirs.ts
|
|
15270
|
-
import
|
|
15483
|
+
import chalk45 from "chalk";
|
|
15271
15484
|
var CommandsDirsCommand = {
|
|
15272
15485
|
command: "dirs",
|
|
15273
15486
|
describe: "显示命令目录",
|
|
@@ -15299,10 +15512,10 @@ var CommandsDirsCommand = {
|
|
|
15299
15512
|
if (args.json) {
|
|
15300
15513
|
output.json(dirs);
|
|
15301
15514
|
} else {
|
|
15302
|
-
output.log(
|
|
15515
|
+
output.log(chalk45.bold("命令目录:"));
|
|
15303
15516
|
output.log();
|
|
15304
|
-
output.log(
|
|
15305
|
-
output.log(
|
|
15517
|
+
output.log(chalk45.cyan("USER:") + ` ${dirs.user}`);
|
|
15518
|
+
output.log(chalk45.cyan("PROJECT:") + ` ${dirs.project}`);
|
|
15306
15519
|
}
|
|
15307
15520
|
} catch (error) {
|
|
15308
15521
|
output.error(`错误: ${error.message}`);
|
|
@@ -15322,7 +15535,7 @@ var CommandsCommand = {
|
|
|
15322
15535
|
};
|
|
15323
15536
|
|
|
15324
15537
|
// src/commands/config/list.ts
|
|
15325
|
-
import
|
|
15538
|
+
import chalk46 from "chalk";
|
|
15326
15539
|
|
|
15327
15540
|
// src/commands/config/config-service.ts
|
|
15328
15541
|
import * as fsSync from "fs";
|
|
@@ -15626,7 +15839,7 @@ var ConfigListCommand = {
|
|
|
15626
15839
|
output.log("");
|
|
15627
15840
|
output.log("Supported components:");
|
|
15628
15841
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
15629
|
-
output.log(` ${
|
|
15842
|
+
output.log(` ${chalk46.cyan(comp.padEnd(15))} ${COMPONENT_DESCRIPTIONS[comp] || ""}`);
|
|
15630
15843
|
}
|
|
15631
15844
|
process.exit(1);
|
|
15632
15845
|
}
|
|
@@ -15644,27 +15857,27 @@ var ConfigListCommand = {
|
|
|
15644
15857
|
}
|
|
15645
15858
|
};
|
|
15646
15859
|
function showHelp(output) {
|
|
15647
|
-
output.log(
|
|
15860
|
+
output.log(chalk46.bold.cyan("# roy-agent config list"));
|
|
15648
15861
|
output.log("");
|
|
15649
15862
|
output.log("查看 roy-agent 组件配置信息");
|
|
15650
15863
|
output.log("");
|
|
15651
|
-
output.log(
|
|
15652
|
-
output.log(` ${
|
|
15864
|
+
output.log(chalk46.bold("Usage:"));
|
|
15865
|
+
output.log(` ${chalk46.cyan("roy-agent config list [component] [options]")}`);
|
|
15653
15866
|
output.log("");
|
|
15654
|
-
output.log(
|
|
15867
|
+
output.log(chalk46.bold("Components:"));
|
|
15655
15868
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
15656
|
-
output.log(` ${
|
|
15869
|
+
output.log(` ${chalk46.cyan(comp.padEnd(15))} ${chalk46.gray(COMPONENT_DESCRIPTIONS[comp] || "")}`);
|
|
15657
15870
|
}
|
|
15658
|
-
output.log(` ${
|
|
15871
|
+
output.log(` ${chalk46.cyan("all".padEnd(15))} 显示所有 components 概览`);
|
|
15659
15872
|
output.log("");
|
|
15660
|
-
output.log(
|
|
15661
|
-
output.log(` ${
|
|
15662
|
-
output.log(` ${
|
|
15663
|
-
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")} 只显示配置源`);
|
|
15664
15877
|
output.log("");
|
|
15665
|
-
output.log(
|
|
15878
|
+
output.log(chalk46.bold("Examples:"));
|
|
15666
15879
|
for (const { command: command2, description } of USAGE_COMMANDS) {
|
|
15667
|
-
output.log(` ${
|
|
15880
|
+
output.log(` ${chalk46.cyan(command2.padEnd(40))} ${chalk46.gray(description)}`);
|
|
15668
15881
|
}
|
|
15669
15882
|
}
|
|
15670
15883
|
async function showAllComponents(output, configService) {
|
|
@@ -15673,13 +15886,13 @@ async function showAllComponents(output, configService) {
|
|
|
15673
15886
|
const config = configService.getComponentConfig(compName);
|
|
15674
15887
|
components.push({ name: compName, config });
|
|
15675
15888
|
}
|
|
15676
|
-
output.log(
|
|
15889
|
+
output.log(chalk46.bold.cyan("# All Components Overview"));
|
|
15677
15890
|
output.log("");
|
|
15678
|
-
output.log(` ${
|
|
15679
|
-
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))}`);
|
|
15680
15893
|
for (const comp of components) {
|
|
15681
15894
|
const keyCount = Object.keys(comp.config).length;
|
|
15682
|
-
output.log(` ${
|
|
15895
|
+
output.log(` ${chalk46.cyan(comp.name.padEnd(15))} ${keyCount.toString().padEnd(10)} ${chalk46.gray(COMPONENT_DESCRIPTIONS[comp.name] || "")}`);
|
|
15683
15896
|
}
|
|
15684
15897
|
}
|
|
15685
15898
|
async function showComponentConfig(componentName, output, configService, options) {
|
|
@@ -15701,22 +15914,22 @@ async function showComponentConfig(componentName, output, configService, options
|
|
|
15701
15914
|
});
|
|
15702
15915
|
return;
|
|
15703
15916
|
}
|
|
15704
|
-
output.log(
|
|
15917
|
+
output.log(chalk46.bold.cyan(`# ${componentName} Component Configuration`));
|
|
15705
15918
|
output.log("");
|
|
15706
15919
|
if (filePath) {
|
|
15707
|
-
output.log(
|
|
15708
|
-
output.log(` ${
|
|
15920
|
+
output.log(chalk46.bold("File:"));
|
|
15921
|
+
output.log(` ${chalk46.cyan(filePath)}`);
|
|
15709
15922
|
output.log("");
|
|
15710
15923
|
}
|
|
15711
15924
|
if (!options.sources) {
|
|
15712
|
-
output.log(
|
|
15925
|
+
output.log(chalk46.bold("Configuration:"));
|
|
15713
15926
|
if (Object.keys(config).length === 0) {
|
|
15714
|
-
output.log(` ${
|
|
15927
|
+
output.log(` ${chalk46.gray("(无配置)")}`);
|
|
15715
15928
|
} else {
|
|
15716
15929
|
const flatConfig = flattenConfig(config);
|
|
15717
15930
|
for (const [key, value] of flatConfig) {
|
|
15718
15931
|
const displayValue = formatValue(value);
|
|
15719
|
-
output.log(` ${
|
|
15932
|
+
output.log(` ${chalk46.cyan(key + ":")} ${displayValue}`);
|
|
15720
15933
|
}
|
|
15721
15934
|
}
|
|
15722
15935
|
output.log("");
|
|
@@ -15731,17 +15944,17 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
15731
15944
|
});
|
|
15732
15945
|
return;
|
|
15733
15946
|
}
|
|
15734
|
-
output.log(
|
|
15947
|
+
output.log(chalk46.bold.cyan("# Agent Component Configuration"));
|
|
15735
15948
|
output.log("");
|
|
15736
15949
|
if (!options.sources) {
|
|
15737
|
-
output.log(
|
|
15950
|
+
output.log(chalk46.bold("Configuration:"));
|
|
15738
15951
|
if (Object.keys(config).length === 0) {
|
|
15739
|
-
output.log(` ${
|
|
15952
|
+
output.log(` ${chalk46.gray("(无配置,使用默认值)")}`);
|
|
15740
15953
|
} else {
|
|
15741
15954
|
const flatConfig = flattenConfig(config);
|
|
15742
15955
|
for (const [key, value] of flatConfig) {
|
|
15743
15956
|
const displayValue = formatValue(value);
|
|
15744
|
-
output.log(` ${
|
|
15957
|
+
output.log(` ${chalk46.cyan(key + ":")} ${displayValue}`);
|
|
15745
15958
|
}
|
|
15746
15959
|
}
|
|
15747
15960
|
output.log("");
|
|
@@ -15755,10 +15968,10 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
15755
15968
|
const configDir = registry.getConfigDir();
|
|
15756
15969
|
const exists = registry.configDirExists();
|
|
15757
15970
|
const agentCount = registry.list().length;
|
|
15758
|
-
output.log(
|
|
15759
|
-
output.log(` ${
|
|
15760
|
-
output.log(` ${
|
|
15761
|
-
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`);
|
|
15762
15975
|
output.log("");
|
|
15763
15976
|
}
|
|
15764
15977
|
}
|
|
@@ -15774,41 +15987,41 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
15774
15987
|
});
|
|
15775
15988
|
return;
|
|
15776
15989
|
}
|
|
15777
|
-
output.log(
|
|
15990
|
+
output.log(chalk46.bold.cyan("# Prompt Component Configuration"));
|
|
15778
15991
|
output.log("");
|
|
15779
15992
|
if (filePath) {
|
|
15780
|
-
output.log(
|
|
15781
|
-
output.log(` ${
|
|
15993
|
+
output.log(chalk46.bold("File:"));
|
|
15994
|
+
output.log(` ${chalk46.cyan(filePath)}`);
|
|
15782
15995
|
output.log("");
|
|
15783
15996
|
}
|
|
15784
15997
|
if (!options.sources) {
|
|
15785
|
-
output.log(
|
|
15998
|
+
output.log(chalk46.bold("Configuration:"));
|
|
15786
15999
|
if (Object.keys(config).length === 0) {
|
|
15787
|
-
output.log(` ${
|
|
16000
|
+
output.log(` ${chalk46.gray("(无配置,使用默认值)")}`);
|
|
15788
16001
|
} else {
|
|
15789
16002
|
const flatConfig = flattenConfig(config);
|
|
15790
16003
|
for (const [key, value] of flatConfig) {
|
|
15791
16004
|
const displayValue = formatValue(value);
|
|
15792
|
-
output.log(` ${
|
|
16005
|
+
output.log(` ${chalk46.cyan(key + ":")} ${displayValue}`);
|
|
15793
16006
|
}
|
|
15794
16007
|
}
|
|
15795
16008
|
output.log("");
|
|
15796
16009
|
}
|
|
15797
|
-
output.log(
|
|
15798
|
-
output.log(` ${
|
|
16010
|
+
output.log(chalk46.bold("Prompts:"));
|
|
16011
|
+
output.log(` ${chalk46.gray("- 内置: 5 个(default, coding, review, project-memory, global-memory)")}`);
|
|
15799
16012
|
const promptPaths = config?.promptPaths;
|
|
15800
16013
|
if (promptPaths && Array.isArray(promptPaths) && promptPaths.length > 0) {
|
|
15801
|
-
output.log(` ${
|
|
16014
|
+
output.log(` ${chalk46.gray("- 外部: " + promptPaths.length + " 个路径")}`);
|
|
15802
16015
|
for (const p of promptPaths) {
|
|
15803
|
-
output.log(` ${
|
|
16016
|
+
output.log(` ${chalk46.cyan(p.path)} ${chalk46.gray("(type: " + p.type + ")")}`);
|
|
15804
16017
|
}
|
|
15805
16018
|
} else {
|
|
15806
|
-
output.log(` ${
|
|
16019
|
+
output.log(` ${chalk46.gray("- 外部: 0 个(未配置 promptPaths)")}`);
|
|
15807
16020
|
}
|
|
15808
16021
|
output.log("");
|
|
15809
16022
|
const defaultName = config?.defaultName || "default";
|
|
15810
|
-
output.log(
|
|
15811
|
-
output.log(` ${
|
|
16023
|
+
output.log(chalk46.bold("Default Prompt:"));
|
|
16024
|
+
output.log(` ${chalk46.cyan("defaultName:")} ${defaultName}`);
|
|
15812
16025
|
output.log("");
|
|
15813
16026
|
const env = envService?.getEnvironment?.();
|
|
15814
16027
|
if (env) {
|
|
@@ -15823,10 +16036,10 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
15823
16036
|
const stored = await store?.loadAll?.();
|
|
15824
16037
|
promptCount = Array.isArray(stored) ? stored.length : 0;
|
|
15825
16038
|
} catch {}
|
|
15826
|
-
output.log(
|
|
15827
|
-
output.log(` ${
|
|
15828
|
-
output.log(` ${
|
|
15829
|
-
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`);
|
|
15830
16043
|
output.log("");
|
|
15831
16044
|
}
|
|
15832
16045
|
}
|
|
@@ -15852,19 +16065,19 @@ function flattenConfig(obj, prefix = "") {
|
|
|
15852
16065
|
}
|
|
15853
16066
|
function formatValue(value) {
|
|
15854
16067
|
if (value === undefined) {
|
|
15855
|
-
return
|
|
16068
|
+
return chalk46.gray("undefined");
|
|
15856
16069
|
}
|
|
15857
16070
|
if (value === null) {
|
|
15858
|
-
return
|
|
16071
|
+
return chalk46.gray("null");
|
|
15859
16072
|
}
|
|
15860
16073
|
if (typeof value === "object") {
|
|
15861
|
-
return
|
|
16074
|
+
return chalk46.gray(JSON.stringify(value));
|
|
15862
16075
|
}
|
|
15863
16076
|
return String(value);
|
|
15864
16077
|
}
|
|
15865
16078
|
|
|
15866
16079
|
// src/commands/config/export.ts
|
|
15867
|
-
import
|
|
16080
|
+
import chalk47 from "chalk";
|
|
15868
16081
|
var ConfigExportCommand = {
|
|
15869
16082
|
command: "export <component>",
|
|
15870
16083
|
describe: "导出组件配置到文件",
|
|
@@ -15909,7 +16122,7 @@ var ConfigExportCommand = {
|
|
|
15909
16122
|
output.log("");
|
|
15910
16123
|
output.log("Supported components:");
|
|
15911
16124
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
15912
|
-
output.log(` ${
|
|
16125
|
+
output.log(` ${chalk47.cyan(comp)}`);
|
|
15913
16126
|
}
|
|
15914
16127
|
process.exit(1);
|
|
15915
16128
|
}
|
|
@@ -15927,7 +16140,7 @@ var ConfigExportCommand = {
|
|
|
15927
16140
|
};
|
|
15928
16141
|
|
|
15929
16142
|
// src/commands/config/import.ts
|
|
15930
|
-
import
|
|
16143
|
+
import chalk48 from "chalk";
|
|
15931
16144
|
var ConfigImportCommand = {
|
|
15932
16145
|
command: "import <component>",
|
|
15933
16146
|
describe: "从文件导入配置到组件的 file source",
|
|
@@ -15977,7 +16190,7 @@ var ConfigImportCommand = {
|
|
|
15977
16190
|
output.log("");
|
|
15978
16191
|
output.log("Supported components:");
|
|
15979
16192
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
15980
|
-
output.log(` ${
|
|
16193
|
+
output.log(` ${chalk48.cyan(comp)}`);
|
|
15981
16194
|
}
|
|
15982
16195
|
process.exit(1);
|
|
15983
16196
|
}
|
|
@@ -15992,7 +16205,7 @@ var ConfigImportCommand = {
|
|
|
15992
16205
|
}
|
|
15993
16206
|
if (result.merged && result.changes.length > 0 && args.verbose) {
|
|
15994
16207
|
output.log("");
|
|
15995
|
-
output.log(
|
|
16208
|
+
output.log(chalk48.bold("变更详情:"));
|
|
15996
16209
|
for (const change of result.changes) {
|
|
15997
16210
|
output.log(` ${change.key}: ${JSON.stringify(change.oldValue)} → ${JSON.stringify(change.newValue)}`);
|
|
15998
16211
|
}
|
|
@@ -16016,7 +16229,7 @@ var ConfigCommand = {
|
|
|
16016
16229
|
};
|
|
16017
16230
|
|
|
16018
16231
|
// src/commands/mcp/list.ts
|
|
16019
|
-
import
|
|
16232
|
+
import chalk49 from "chalk";
|
|
16020
16233
|
var ListCommand6 = {
|
|
16021
16234
|
command: "list",
|
|
16022
16235
|
aliases: ["ls"],
|
|
@@ -16026,12 +16239,7 @@ var ListCommand6 = {
|
|
|
16026
16239
|
type: "boolean",
|
|
16027
16240
|
default: false,
|
|
16028
16241
|
description: "JSON 输出"
|
|
16029
|
-
}).option("quiet", {
|
|
16030
|
-
alias: "q",
|
|
16031
|
-
type: "boolean",
|
|
16032
|
-
default: false,
|
|
16033
|
-
description: "简洁输出"
|
|
16034
|
-
}),
|
|
16242
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
16035
16243
|
async handler(args) {
|
|
16036
16244
|
const output = new OutputService2;
|
|
16037
16245
|
const envService = new EnvironmentService(output);
|
|
@@ -16047,45 +16255,64 @@ var ListCommand6 = {
|
|
|
16047
16255
|
output.error("McpComponent not available");
|
|
16048
16256
|
process.exit(1);
|
|
16049
16257
|
}
|
|
16050
|
-
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);
|
|
16051
16265
|
if (args.json) {
|
|
16052
16266
|
output.json({
|
|
16267
|
+
total,
|
|
16268
|
+
count: servers.length,
|
|
16269
|
+
truncated: total > servers.length,
|
|
16270
|
+
limit: page.limit,
|
|
16271
|
+
offset: page.offset,
|
|
16053
16272
|
servers: servers.map((s) => ({
|
|
16054
16273
|
name: s.name,
|
|
16055
16274
|
status: s.status,
|
|
16056
16275
|
error: s.error,
|
|
16057
16276
|
toolsCount: s.toolsCount
|
|
16058
|
-
}))
|
|
16059
|
-
count: servers.length
|
|
16277
|
+
}))
|
|
16060
16278
|
});
|
|
16061
16279
|
} else if (args.quiet) {
|
|
16062
|
-
|
|
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);
|
|
16063
16290
|
} else {
|
|
16064
16291
|
if (servers.length === 0) {
|
|
16065
|
-
output.log(
|
|
16292
|
+
output.log(chalk49.yellow("No MCP servers configured"));
|
|
16066
16293
|
return;
|
|
16067
16294
|
}
|
|
16068
16295
|
const statusColor = (status) => {
|
|
16069
16296
|
switch (status) {
|
|
16070
16297
|
case "connected":
|
|
16071
|
-
return
|
|
16298
|
+
return chalk49.green;
|
|
16072
16299
|
case "connecting":
|
|
16073
|
-
return
|
|
16300
|
+
return chalk49.yellow;
|
|
16074
16301
|
case "error":
|
|
16075
|
-
return
|
|
16302
|
+
return chalk49.red;
|
|
16076
16303
|
case "disconnected":
|
|
16077
|
-
return
|
|
16304
|
+
return chalk49.gray;
|
|
16078
16305
|
default:
|
|
16079
|
-
return
|
|
16306
|
+
return chalk49.white;
|
|
16080
16307
|
}
|
|
16081
16308
|
};
|
|
16082
16309
|
const header = [
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16310
|
+
chalk49.bold("Name"),
|
|
16311
|
+
chalk49.bold("Status"),
|
|
16312
|
+
chalk49.bold("Tools")
|
|
16086
16313
|
].join(" | ");
|
|
16087
16314
|
const rows = servers.map((s) => [
|
|
16088
|
-
|
|
16315
|
+
chalk49.cyan(s.name),
|
|
16089
16316
|
statusColor(s.status)(`[${s.status}]`),
|
|
16090
16317
|
s.toolsCount !== undefined ? String(s.toolsCount) : "-"
|
|
16091
16318
|
].join(" | "));
|
|
@@ -16096,7 +16323,13 @@ var ListCommand6 = {
|
|
|
16096
16323
|
...rows.map((r) => `│${r}│`),
|
|
16097
16324
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
16098
16325
|
"",
|
|
16099
|
-
|
|
16326
|
+
renderPaginationFooter({
|
|
16327
|
+
total,
|
|
16328
|
+
count: servers.length,
|
|
16329
|
+
offset: page.offset,
|
|
16330
|
+
limit: page.limit,
|
|
16331
|
+
itemName: "mcp server"
|
|
16332
|
+
})
|
|
16100
16333
|
].join(`
|
|
16101
16334
|
`));
|
|
16102
16335
|
}
|
|
@@ -16110,7 +16343,7 @@ var ListCommand6 = {
|
|
|
16110
16343
|
};
|
|
16111
16344
|
|
|
16112
16345
|
// src/commands/mcp/tools.ts
|
|
16113
|
-
import
|
|
16346
|
+
import chalk50 from "chalk";
|
|
16114
16347
|
var ToolsCommand = {
|
|
16115
16348
|
command: "tools",
|
|
16116
16349
|
aliases: ["t"],
|
|
@@ -16163,7 +16396,7 @@ var ToolsCommand = {
|
|
|
16163
16396
|
tools.forEach((t) => output.log(t.name));
|
|
16164
16397
|
} else {
|
|
16165
16398
|
if (tools.length === 0) {
|
|
16166
|
-
output.log(
|
|
16399
|
+
output.log(chalk50.yellow("No MCP tools available"));
|
|
16167
16400
|
return;
|
|
16168
16401
|
}
|
|
16169
16402
|
const byServer = new Map;
|
|
@@ -16175,15 +16408,15 @@ var ToolsCommand = {
|
|
|
16175
16408
|
byServer.get(serverName).push(tool);
|
|
16176
16409
|
}
|
|
16177
16410
|
for (const [serverName, serverTools] of byServer) {
|
|
16178
|
-
output.log(
|
|
16411
|
+
output.log(chalk50.bold.cyan(`
|
|
16179
16412
|
[${serverName}] ${serverTools.length} tools`));
|
|
16180
16413
|
for (const tool of serverTools) {
|
|
16181
16414
|
const desc2 = tool.description.length > 80 ? tool.description.slice(0, 77) + "..." : tool.description;
|
|
16182
|
-
output.log(` ${
|
|
16183
|
-
output.log(` ${
|
|
16415
|
+
output.log(` ${chalk50.green("+")} ${chalk50.white(tool.name)}`);
|
|
16416
|
+
output.log(` ${chalk50.gray(desc2)}`);
|
|
16184
16417
|
}
|
|
16185
16418
|
}
|
|
16186
|
-
output.log(
|
|
16419
|
+
output.log(chalk50.gray(`
|
|
16187
16420
|
Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
16188
16421
|
}
|
|
16189
16422
|
} catch (error) {
|
|
@@ -16196,7 +16429,7 @@ Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
|
16196
16429
|
};
|
|
16197
16430
|
|
|
16198
16431
|
// src/commands/mcp/reload.ts
|
|
16199
|
-
import
|
|
16432
|
+
import chalk51 from "chalk";
|
|
16200
16433
|
var ReloadCommand2 = {
|
|
16201
16434
|
command: "reload",
|
|
16202
16435
|
aliases: ["r"],
|
|
@@ -16217,19 +16450,19 @@ var ReloadCommand2 = {
|
|
|
16217
16450
|
output.error("McpComponent not available");
|
|
16218
16451
|
process.exit(1);
|
|
16219
16452
|
}
|
|
16220
|
-
output.log(
|
|
16453
|
+
output.log(chalk51.cyan("Reloading MCP servers..."));
|
|
16221
16454
|
await mcpComponent.reload();
|
|
16222
16455
|
const servers = mcpComponent.listServers();
|
|
16223
16456
|
const connected = servers.filter((s) => s.status === "connected").length;
|
|
16224
16457
|
const errors = servers.filter((s) => s.status === "error").length;
|
|
16225
|
-
output.log(
|
|
16458
|
+
output.log(chalk51.green(`✓ Reloaded ${servers.length} servers`));
|
|
16226
16459
|
if (connected > 0) {
|
|
16227
|
-
output.log(
|
|
16460
|
+
output.log(chalk51.green(` • ${connected} connected`));
|
|
16228
16461
|
}
|
|
16229
16462
|
if (errors > 0) {
|
|
16230
16463
|
output.warn(` • ${errors} failed`);
|
|
16231
16464
|
for (const server of servers.filter((s) => s.status === "error")) {
|
|
16232
|
-
output.log(
|
|
16465
|
+
output.log(chalk51.gray(` - ${server.name}: ${server.error}`));
|
|
16233
16466
|
}
|
|
16234
16467
|
}
|
|
16235
16468
|
} catch (error) {
|
|
@@ -16250,7 +16483,7 @@ var McpCommand = {
|
|
|
16250
16483
|
};
|
|
16251
16484
|
|
|
16252
16485
|
// src/commands/tools/list.ts
|
|
16253
|
-
import
|
|
16486
|
+
import chalk52 from "chalk";
|
|
16254
16487
|
var ListCommand7 = {
|
|
16255
16488
|
command: "list",
|
|
16256
16489
|
aliases: ["ls"],
|
|
@@ -16260,12 +16493,7 @@ var ListCommand7 = {
|
|
|
16260
16493
|
type: "boolean",
|
|
16261
16494
|
default: false,
|
|
16262
16495
|
description: "JSON 输出"
|
|
16263
|
-
}).option("quiet", {
|
|
16264
|
-
alias: "q",
|
|
16265
|
-
type: "boolean",
|
|
16266
|
-
default: false,
|
|
16267
|
-
description: "简洁输出(仅名称)"
|
|
16268
|
-
}),
|
|
16496
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
16269
16497
|
async handler(args) {
|
|
16270
16498
|
const output = new OutputService2;
|
|
16271
16499
|
const envService = new EnvironmentService(output);
|
|
@@ -16281,10 +16509,20 @@ var ListCommand7 = {
|
|
|
16281
16509
|
output.error("ToolComponent not available");
|
|
16282
16510
|
process.exit(1);
|
|
16283
16511
|
}
|
|
16284
|
-
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);
|
|
16285
16519
|
if (args.json) {
|
|
16286
16520
|
output.json({
|
|
16521
|
+
total,
|
|
16287
16522
|
count: tools.length,
|
|
16523
|
+
truncated: total > tools.length,
|
|
16524
|
+
limit: page.limit,
|
|
16525
|
+
offset: page.offset,
|
|
16288
16526
|
tools: tools.map((t) => ({
|
|
16289
16527
|
name: t.name,
|
|
16290
16528
|
description: t.description,
|
|
@@ -16292,19 +16530,28 @@ var ListCommand7 = {
|
|
|
16292
16530
|
}))
|
|
16293
16531
|
});
|
|
16294
16532
|
} else if (args.quiet) {
|
|
16295
|
-
|
|
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);
|
|
16296
16543
|
} else {
|
|
16297
16544
|
const header = [
|
|
16298
|
-
|
|
16299
|
-
|
|
16300
|
-
|
|
16545
|
+
chalk52.bold("Name"),
|
|
16546
|
+
chalk52.bold("Description"),
|
|
16547
|
+
chalk52.bold("Category")
|
|
16301
16548
|
].join(" | ");
|
|
16302
16549
|
const rows = tools.map((t) => {
|
|
16303
16550
|
const desc2 = t.description.length > 40 ? t.description.slice(0, 37) + "..." : t.description;
|
|
16304
16551
|
return [
|
|
16305
|
-
|
|
16552
|
+
chalk52.cyan(t.name),
|
|
16306
16553
|
desc2,
|
|
16307
|
-
t.metadata?.category ?
|
|
16554
|
+
t.metadata?.category ? chalk52.gray(`[${t.metadata.category}]`) : "-"
|
|
16308
16555
|
].join(" | ");
|
|
16309
16556
|
});
|
|
16310
16557
|
output.log([
|
|
@@ -16314,7 +16561,13 @@ var ListCommand7 = {
|
|
|
16314
16561
|
...rows.map((r) => `│${r}│`),
|
|
16315
16562
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
16316
16563
|
"",
|
|
16317
|
-
|
|
16564
|
+
renderPaginationFooter({
|
|
16565
|
+
total,
|
|
16566
|
+
count: tools.length,
|
|
16567
|
+
offset: page.offset,
|
|
16568
|
+
limit: page.limit,
|
|
16569
|
+
itemName: "tool"
|
|
16570
|
+
})
|
|
16318
16571
|
].join(`
|
|
16319
16572
|
`));
|
|
16320
16573
|
}
|
|
@@ -16328,7 +16581,7 @@ var ListCommand7 = {
|
|
|
16328
16581
|
};
|
|
16329
16582
|
|
|
16330
16583
|
// src/commands/tools/get.ts
|
|
16331
|
-
import
|
|
16584
|
+
import chalk53 from "chalk";
|
|
16332
16585
|
|
|
16333
16586
|
// src/commands/tools/shared/schema-helper.ts
|
|
16334
16587
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -16403,8 +16656,8 @@ var GetCommand6 = {
|
|
|
16403
16656
|
}))
|
|
16404
16657
|
});
|
|
16405
16658
|
} else {
|
|
16406
|
-
output.log(
|
|
16407
|
-
output.log(
|
|
16659
|
+
output.log(chalk53.bold.cyan(`Tool: ${tool.name}`));
|
|
16660
|
+
output.log(chalk53.gray("─".repeat(60)));
|
|
16408
16661
|
output.log(`Description: ${tool.description}`);
|
|
16409
16662
|
if (tool.metadata?.category) {
|
|
16410
16663
|
output.log(`Category: ${tool.metadata.category}`);
|
|
@@ -16413,9 +16666,9 @@ var GetCommand6 = {
|
|
|
16413
16666
|
output.log(`Tags: ${tool.metadata.tags.join(", ")}`);
|
|
16414
16667
|
}
|
|
16415
16668
|
output.log("");
|
|
16416
|
-
output.log(
|
|
16669
|
+
output.log(chalk53.bold("Parameters:"));
|
|
16417
16670
|
for (const param of params) {
|
|
16418
|
-
const required = param.required ?
|
|
16671
|
+
const required = param.required ? chalk53.red("(required)") : chalk53.gray("(optional)");
|
|
16419
16672
|
const defaultVal = param.default !== undefined ? ` [default: ${JSON.stringify(param.default)}]` : "";
|
|
16420
16673
|
output.log(` --${param.name} <${param.type}> ${required}`);
|
|
16421
16674
|
output.log(` ${param.description}${defaultVal}`);
|
|
@@ -16524,14 +16777,14 @@ var ToolsCommand2 = {
|
|
|
16524
16777
|
};
|
|
16525
16778
|
|
|
16526
16779
|
// src/commands/memory/record.ts
|
|
16527
|
-
import
|
|
16780
|
+
import chalk54 from "chalk";
|
|
16528
16781
|
import { createMemoryAgentTools, getBuiltInPrompt } from "@ai-setting/roy-agent-core";
|
|
16529
16782
|
import { bashTool, globTool, readFileTool } from "@ai-setting/roy-agent-core";
|
|
16530
16783
|
async function runExtractMode(output, memoryComponent, agentComponent, sessionComponent, env, options) {
|
|
16531
16784
|
const { scope, sessionId, require: userRequirement } = options;
|
|
16532
|
-
output.log(
|
|
16785
|
+
output.log(chalk54.blue(`
|
|
16533
16786
|
\uD83D\uDD0D Memory Extract Mode (${scope})`));
|
|
16534
|
-
output.log(
|
|
16787
|
+
output.log(chalk54.gray(`正在分析会话历史,生成记忆...
|
|
16535
16788
|
`));
|
|
16536
16789
|
try {
|
|
16537
16790
|
const currentMemory = await memoryComponent.recallMemory(scope) || "(无现有记忆)";
|
|
@@ -16577,13 +16830,13 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
16577
16830
|
for (const tool of agentTools) {
|
|
16578
16831
|
try {
|
|
16579
16832
|
toolComponent.register(tool);
|
|
16580
|
-
output.log(
|
|
16833
|
+
output.log(chalk54.gray(`Tool registered: ${tool.name}`));
|
|
16581
16834
|
} catch (err) {
|
|
16582
|
-
output.log(
|
|
16835
|
+
output.log(chalk54.gray(`Tool already registered: ${tool.name}`));
|
|
16583
16836
|
}
|
|
16584
16837
|
}
|
|
16585
16838
|
}
|
|
16586
|
-
output.log(
|
|
16839
|
+
output.log(chalk54.gray(`Agent "${agentName}" registered with ${agentTools.length} tools`));
|
|
16587
16840
|
const query = `请分析会话历史,提炼${scope === "project" ? "项目" : "全局"}记忆并写入记忆文件。`;
|
|
16588
16841
|
let result;
|
|
16589
16842
|
try {
|
|
@@ -16597,12 +16850,12 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
16597
16850
|
if (result && result.startsWith("执行失败")) {
|
|
16598
16851
|
output.error(`提取失败: ${result}`);
|
|
16599
16852
|
} else if (result) {
|
|
16600
|
-
output.log(
|
|
16853
|
+
output.log(chalk54.green(`
|
|
16601
16854
|
✅ 记忆提取完成`));
|
|
16602
|
-
output.log(
|
|
16855
|
+
output.log(chalk54.gray(`记忆已保存到 memory 文件。
|
|
16603
16856
|
`));
|
|
16604
16857
|
if (result.length > 0 && result !== "✅ 记忆提取完成") {
|
|
16605
|
-
output.log(
|
|
16858
|
+
output.log(chalk54.gray(`执行摘要: ${result.substring(0, 200)}${result.length > 200 ? "..." : ""}`));
|
|
16606
16859
|
}
|
|
16607
16860
|
}
|
|
16608
16861
|
agentComponent.unregisterAgent(agentName);
|
|
@@ -16720,11 +16973,11 @@ var RecordCommand = {
|
|
|
16720
16973
|
prepend: "已插入内容到记忆文件开头",
|
|
16721
16974
|
delete: "已删除记忆文件"
|
|
16722
16975
|
};
|
|
16723
|
-
output.log(
|
|
16724
|
-
output.log(
|
|
16976
|
+
output.log(chalk54.green(`✓ ${actionMessages[result.action]}`));
|
|
16977
|
+
output.log(chalk54.gray(`路径: ${result.path}`));
|
|
16725
16978
|
if (result.action !== "delete" && a.content) {
|
|
16726
16979
|
const preview = a.content.substring(0, 100);
|
|
16727
|
-
output.log(
|
|
16980
|
+
output.log(chalk54.gray(`内容预览: ${preview}${a.content.length > 100 ? "..." : ""}`));
|
|
16728
16981
|
}
|
|
16729
16982
|
} catch (error) {
|
|
16730
16983
|
output.error(`Failed to record memory: ${error}`);
|
|
@@ -16736,7 +16989,7 @@ var RecordCommand = {
|
|
|
16736
16989
|
};
|
|
16737
16990
|
|
|
16738
16991
|
// src/commands/memory/recall.ts
|
|
16739
|
-
import
|
|
16992
|
+
import chalk55 from "chalk";
|
|
16740
16993
|
var RecallCommand = {
|
|
16741
16994
|
command: "recall",
|
|
16742
16995
|
aliases: ["load"],
|
|
@@ -16772,7 +17025,7 @@ var RecallCommand = {
|
|
|
16772
17025
|
}
|
|
16773
17026
|
const content = await memoryComponent.recallMemory(a.scope);
|
|
16774
17027
|
if (!content) {
|
|
16775
|
-
output.log(
|
|
17028
|
+
output.log(chalk55.gray("(No memory files found)"));
|
|
16776
17029
|
return;
|
|
16777
17030
|
}
|
|
16778
17031
|
if (a.json) {
|
|
@@ -16798,7 +17051,7 @@ var MemoryCommand = {
|
|
|
16798
17051
|
handler: () => {}
|
|
16799
17052
|
};
|
|
16800
17053
|
// src/commands/eventsource/list.ts
|
|
16801
|
-
import
|
|
17054
|
+
import chalk56 from "chalk";
|
|
16802
17055
|
function truncateVisual2(str, maxWidth) {
|
|
16803
17056
|
let result = "";
|
|
16804
17057
|
let width = 0;
|
|
@@ -16813,7 +17066,7 @@ function truncateVisual2(str, maxWidth) {
|
|
|
16813
17066
|
}
|
|
16814
17067
|
function formatSourcesTable(sources) {
|
|
16815
17068
|
if (sources.length === 0) {
|
|
16816
|
-
return
|
|
17069
|
+
return chalk56.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加");
|
|
16817
17070
|
}
|
|
16818
17071
|
const ID_WIDTH = 10;
|
|
16819
17072
|
const NAME_WIDTH = 20;
|
|
@@ -16822,11 +17075,11 @@ function formatSourcesTable(sources) {
|
|
|
16822
17075
|
const ENABLED_WIDTH = 8;
|
|
16823
17076
|
const GAP = " ";
|
|
16824
17077
|
const headerLine = [
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
|
|
16829
|
-
|
|
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))
|
|
16830
17083
|
].join(GAP);
|
|
16831
17084
|
const sepLine = "─".repeat(ID_WIDTH + NAME_WIDTH + TYPE_WIDTH + STATUS_WIDTH + ENABLED_WIDTH + GAP.length * 4);
|
|
16832
17085
|
const formatRow = (src) => {
|
|
@@ -16850,15 +17103,9 @@ var EventSourceListCommand = {
|
|
|
16850
17103
|
describe: "JSON 格式输出",
|
|
16851
17104
|
type: "boolean",
|
|
16852
17105
|
default: false
|
|
16853
|
-
}).option("quiet", {
|
|
16854
|
-
alias: "q",
|
|
16855
|
-
describe: "静默模式",
|
|
16856
|
-
type: "boolean",
|
|
16857
|
-
default: false
|
|
16858
|
-
}),
|
|
17106
|
+
}).option("limit", PAGINATION_OPTIONS.limit).option("offset", PAGINATION_OPTIONS.offset).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
16859
17107
|
async handler(args) {
|
|
16860
17108
|
const output = new OutputService2;
|
|
16861
|
-
output.configure({ quiet: args.quiet });
|
|
16862
17109
|
const envService = new EnvironmentService(output);
|
|
16863
17110
|
try {
|
|
16864
17111
|
await envService.create({ configPath: args.config });
|
|
@@ -16867,53 +17114,90 @@ var EventSourceListCommand = {
|
|
|
16867
17114
|
output.error("Failed to create environment");
|
|
16868
17115
|
process.exit(1);
|
|
16869
17116
|
}
|
|
16870
|
-
const components = env.listComponents().map((c) => c.name);
|
|
16871
|
-
output.log("Available components: " + components.join(", "));
|
|
16872
17117
|
const esComponent = env.getComponent("event-source");
|
|
16873
17118
|
if (!esComponent) {
|
|
16874
17119
|
output.error("EventSourceComponent not available");
|
|
16875
17120
|
process.exit(1);
|
|
16876
17121
|
}
|
|
16877
|
-
const
|
|
16878
|
-
|
|
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) {
|
|
16879
17130
|
if (args.json) {
|
|
16880
|
-
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
|
+
});
|
|
16881
17139
|
} else {
|
|
16882
|
-
output.log(
|
|
17140
|
+
output.log(chalk56.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加"));
|
|
16883
17141
|
}
|
|
16884
17142
|
return;
|
|
16885
17143
|
}
|
|
17144
|
+
const sourcesWithStatus = sources.map((s) => ({
|
|
17145
|
+
...s,
|
|
17146
|
+
status: esComponent.getStatus(s.id) || "unknown"
|
|
17147
|
+
}));
|
|
16886
17148
|
if (args.json) {
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16890
|
-
|
|
16891
|
-
|
|
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);
|
|
16892
17170
|
return;
|
|
16893
17171
|
}
|
|
16894
17172
|
const rows = sources.map((s) => {
|
|
16895
17173
|
const status = esComponent.getStatus(s.id) || "unknown";
|
|
16896
17174
|
const statusColorMap = {
|
|
16897
|
-
running:
|
|
16898
|
-
stopped:
|
|
16899
|
-
error:
|
|
16900
|
-
starting:
|
|
16901
|
-
created:
|
|
16902
|
-
stopping:
|
|
16903
|
-
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
|
|
16904
17182
|
};
|
|
16905
|
-
const statusColor = statusColorMap[status] ||
|
|
17183
|
+
const statusColor = statusColorMap[status] || chalk56.gray;
|
|
16906
17184
|
return {
|
|
16907
17185
|
id: s.id.substring(0, 8),
|
|
16908
17186
|
name: s.name,
|
|
16909
17187
|
type: s.type,
|
|
16910
17188
|
status: statusColor(status),
|
|
16911
|
-
enabled: s.enabled ?
|
|
17189
|
+
enabled: s.enabled ? chalk56.green("✓") : chalk56.gray("✗")
|
|
16912
17190
|
};
|
|
16913
17191
|
});
|
|
16914
17192
|
output.log(formatSourcesTable(rows));
|
|
16915
|
-
output.
|
|
16916
|
-
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
|
+
}));
|
|
16917
17201
|
} catch (error) {
|
|
16918
17202
|
output.error(`Failed to list event sources: ${error}`);
|
|
16919
17203
|
process.exit(1);
|
|
@@ -16924,11 +17208,11 @@ var EventSourceListCommand = {
|
|
|
16924
17208
|
};
|
|
16925
17209
|
|
|
16926
17210
|
// src/commands/eventsource/add.ts
|
|
16927
|
-
import
|
|
17211
|
+
import chalk58 from "chalk";
|
|
16928
17212
|
import { generateId } from "@ai-setting/roy-agent-core";
|
|
16929
17213
|
|
|
16930
17214
|
// src/commands/eventsource/server-url-option.ts
|
|
16931
|
-
import
|
|
17215
|
+
import chalk57 from "chalk";
|
|
16932
17216
|
function addServerUrlOption(yargs) {
|
|
16933
17217
|
return yargs.option("server-url", {
|
|
16934
17218
|
alias: "s",
|
|
@@ -16944,7 +17228,7 @@ function resolveServerUrl(serverUrl, fallback) {
|
|
|
16944
17228
|
return fallback;
|
|
16945
17229
|
const trimmed = serverUrl.replace(/\/+$/, "");
|
|
16946
17230
|
if (!/^(https?|wss?):\/\//.test(trimmed)) {
|
|
16947
|
-
console.error(
|
|
17231
|
+
console.error(chalk57.red(`
|
|
16948
17232
|
✗ Invalid --server-url: "${serverUrl}". Must start with http://, https://, ws://, or wss://
|
|
16949
17233
|
`));
|
|
16950
17234
|
process.exit(1);
|
|
@@ -17037,39 +17321,39 @@ var EventSourceAddCommand = {
|
|
|
17037
17321
|
options: a.prompt ? { prompt: a.prompt } : undefined
|
|
17038
17322
|
};
|
|
17039
17323
|
esComponent.register(config);
|
|
17040
|
-
output.success(
|
|
17324
|
+
output.success(chalk58.green(`事件源 '${a.name}' 添加成功!`));
|
|
17041
17325
|
output.log("");
|
|
17042
|
-
output.log(` ID: ${
|
|
17043
|
-
output.log(` Type: ${
|
|
17326
|
+
output.log(` ID: ${chalk58.gray(config.id)}`);
|
|
17327
|
+
output.log(` Type: ${chalk58.cyan(a.type)}`);
|
|
17044
17328
|
if (eventTypes?.length) {
|
|
17045
|
-
output.log(` Event Types: ${
|
|
17329
|
+
output.log(` Event Types: ${chalk58.gray(eventTypes.join(", "))}`);
|
|
17046
17330
|
}
|
|
17047
17331
|
if (a.command) {
|
|
17048
|
-
output.log(` Command: ${
|
|
17332
|
+
output.log(` Command: ${chalk58.gray(a.command)}`);
|
|
17049
17333
|
}
|
|
17050
17334
|
if (a.interval) {
|
|
17051
|
-
output.log(` Interval: ${
|
|
17335
|
+
output.log(` Interval: ${chalk58.gray(`${a.interval}ms`)}`);
|
|
17052
17336
|
}
|
|
17053
17337
|
if (a.profile) {
|
|
17054
|
-
output.log(` Profile: ${
|
|
17338
|
+
output.log(` Profile: ${chalk58.gray(a.profile)}`);
|
|
17055
17339
|
}
|
|
17056
17340
|
if (a.address) {
|
|
17057
|
-
output.log(` Address: ${
|
|
17341
|
+
output.log(` Address: ${chalk58.gray(a.address)}`);
|
|
17058
17342
|
}
|
|
17059
17343
|
if (a.imServerUrl) {
|
|
17060
|
-
output.log(` IM Server URL: ${
|
|
17344
|
+
output.log(` IM Server URL: ${chalk58.gray(a.imServerUrl)}`);
|
|
17061
17345
|
}
|
|
17062
17346
|
if (resolvedServerUrl) {
|
|
17063
|
-
output.log(` Server URL: ${
|
|
17347
|
+
output.log(` Server URL: ${chalk58.gray(resolvedServerUrl)}`);
|
|
17064
17348
|
}
|
|
17065
17349
|
if (a.tlsSkipVerify) {
|
|
17066
|
-
output.log(` TLS Skip Verify: ${
|
|
17350
|
+
output.log(` TLS Skip Verify: ${chalk58.yellow("⚠ true (自签名场景)")}`);
|
|
17067
17351
|
}
|
|
17068
17352
|
if (a.prompt) {
|
|
17069
|
-
output.log(` Prompt: ${
|
|
17353
|
+
output.log(` Prompt: ${chalk58.gray(a.prompt.length > 60 ? a.prompt.slice(0, 60) + "..." : a.prompt)}`);
|
|
17070
17354
|
}
|
|
17071
17355
|
output.log("");
|
|
17072
|
-
output.log(
|
|
17356
|
+
output.log(chalk58.gray(`使用 'roy-agent eventsource start ${config.id.substring(0, 8)}' 启动它。`));
|
|
17073
17357
|
} finally {
|
|
17074
17358
|
await envService.dispose();
|
|
17075
17359
|
}
|
|
@@ -17077,7 +17361,7 @@ var EventSourceAddCommand = {
|
|
|
17077
17361
|
};
|
|
17078
17362
|
|
|
17079
17363
|
// src/commands/eventsource/update.ts
|
|
17080
|
-
import
|
|
17364
|
+
import chalk59 from "chalk";
|
|
17081
17365
|
function findSource(esComponent, id) {
|
|
17082
17366
|
const sources = esComponent.list();
|
|
17083
17367
|
const matched = sources.find((s) => s.id === id || s.id.startsWith(id));
|
|
@@ -17149,7 +17433,7 @@ var EventSourceUpdateCommand = {
|
|
|
17149
17433
|
const all = esComponent.list();
|
|
17150
17434
|
if (all.length > 0) {
|
|
17151
17435
|
output.info("");
|
|
17152
|
-
output.info(
|
|
17436
|
+
output.info(chalk59.gray("可用的事件源:"));
|
|
17153
17437
|
for (const s of all) {
|
|
17154
17438
|
output.info(` - ${s.id.substring(0, 8)}: ${s.name} (${s.type})`);
|
|
17155
17439
|
}
|
|
@@ -17191,19 +17475,19 @@ var EventSourceUpdateCommand = {
|
|
|
17191
17475
|
}
|
|
17192
17476
|
try {
|
|
17193
17477
|
const result = await esComponent.update(match.fullId, partial);
|
|
17194
|
-
output.success(
|
|
17478
|
+
output.success(chalk59.green(`✅ 事件源已更新: ${match.source.name}`));
|
|
17195
17479
|
output.log("");
|
|
17196
|
-
output.log(
|
|
17480
|
+
output.log(chalk59.bold("修改字段:"));
|
|
17197
17481
|
const before = match.source;
|
|
17198
17482
|
const after = result.updated;
|
|
17199
17483
|
for (const field of result.fields) {
|
|
17200
17484
|
const beforeVal = JSON.stringify(before[field] ?? before.options?.[field]);
|
|
17201
17485
|
const afterVal = JSON.stringify(after[field] ?? after.options?.[field]);
|
|
17202
|
-
output.log(` ${
|
|
17486
|
+
output.log(` ${chalk59.cyan(field)}: ${chalk59.gray(beforeVal)} ${chalk59.gray("→")} ${chalk59.green(afterVal)}`);
|
|
17203
17487
|
}
|
|
17204
17488
|
output.log("");
|
|
17205
17489
|
if (result.wasRunning) {
|
|
17206
|
-
output.info(
|
|
17490
|
+
output.info(chalk59.yellow(`⚠️ 事件源在更新前正在运行,已自动停止。请使用 'roy-agent eventsource start ${match.fullId.substring(0, 8)}' 手动启动以应用新配置。`));
|
|
17207
17491
|
}
|
|
17208
17492
|
} catch (error) {
|
|
17209
17493
|
output.error(`❌ 更新失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -17216,7 +17500,7 @@ var EventSourceUpdateCommand = {
|
|
|
17216
17500
|
};
|
|
17217
17501
|
|
|
17218
17502
|
// src/commands/eventsource/remove.ts
|
|
17219
|
-
import
|
|
17503
|
+
import chalk60 from "chalk";
|
|
17220
17504
|
var EventSourceRemoveCommand = {
|
|
17221
17505
|
command: "remove <id>",
|
|
17222
17506
|
aliases: ["rm"],
|
|
@@ -17255,7 +17539,7 @@ var EventSourceRemoveCommand = {
|
|
|
17255
17539
|
const status = esComponent.getStatus(matchedSource.id);
|
|
17256
17540
|
if (status === "running" && !args.force) {
|
|
17257
17541
|
output.error(`事件源正在运行中,请先停止: ${matchedSource.name} (${status})`);
|
|
17258
|
-
output.log(
|
|
17542
|
+
output.log(chalk60.gray(`使用 --force 强制移除或 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' 先停止`));
|
|
17259
17543
|
process.exit(1);
|
|
17260
17544
|
}
|
|
17261
17545
|
if (status === "running") {
|
|
@@ -17264,7 +17548,7 @@ var EventSourceRemoveCommand = {
|
|
|
17264
17548
|
}
|
|
17265
17549
|
const result = esComponent.unregister(matchedSource.id);
|
|
17266
17550
|
if (result) {
|
|
17267
|
-
output.success(
|
|
17551
|
+
output.success(chalk60.green(`事件源已移除: ${matchedSource.name}`));
|
|
17268
17552
|
} else {
|
|
17269
17553
|
output.error("移除失败");
|
|
17270
17554
|
process.exit(1);
|
|
@@ -17276,7 +17560,7 @@ var EventSourceRemoveCommand = {
|
|
|
17276
17560
|
};
|
|
17277
17561
|
|
|
17278
17562
|
// src/commands/eventsource/start.ts
|
|
17279
|
-
import
|
|
17563
|
+
import chalk61 from "chalk";
|
|
17280
17564
|
var EventSourceStartCommand = {
|
|
17281
17565
|
command: "start <id>",
|
|
17282
17566
|
describe: "启动指定的事件源",
|
|
@@ -17313,15 +17597,15 @@ var EventSourceStartCommand = {
|
|
|
17313
17597
|
}
|
|
17314
17598
|
const status = esComponent.getStatus(matchedSource.id);
|
|
17315
17599
|
if (status === "running") {
|
|
17316
|
-
output.log(
|
|
17600
|
+
output.log(chalk61.yellow(`事件源已在运行: ${matchedSource.name}`));
|
|
17317
17601
|
return;
|
|
17318
17602
|
}
|
|
17319
17603
|
output.info(`正在启动事件源 '${matchedSource.name}'...`);
|
|
17320
17604
|
try {
|
|
17321
17605
|
await esComponent.startSource(matchedSource.id);
|
|
17322
|
-
output.success(
|
|
17606
|
+
output.success(chalk61.green(`事件源已启动: ${matchedSource.name}`));
|
|
17323
17607
|
if (!args.background) {
|
|
17324
|
-
output.log(
|
|
17608
|
+
output.log(chalk61.gray("按 Ctrl+C 停止..."));
|
|
17325
17609
|
await new Promise((resolve) => {
|
|
17326
17610
|
const cleanup = () => {
|
|
17327
17611
|
process.removeListener("SIGINT", cleanup);
|
|
@@ -17343,7 +17627,7 @@ var EventSourceStartCommand = {
|
|
|
17343
17627
|
};
|
|
17344
17628
|
|
|
17345
17629
|
// src/commands/eventsource/stop.ts
|
|
17346
|
-
import
|
|
17630
|
+
import chalk62 from "chalk";
|
|
17347
17631
|
var EventSourceStopCommand = {
|
|
17348
17632
|
command: "stop <id>",
|
|
17349
17633
|
aliases: ["kill"],
|
|
@@ -17381,13 +17665,13 @@ var EventSourceStopCommand = {
|
|
|
17381
17665
|
}
|
|
17382
17666
|
const status = esComponent.getStatus(matchedSource.id);
|
|
17383
17667
|
if (status !== "running") {
|
|
17384
|
-
output.log(
|
|
17668
|
+
output.log(chalk62.yellow(`事件源未运行: ${matchedSource.name} (${status || "unknown"})`));
|
|
17385
17669
|
return;
|
|
17386
17670
|
}
|
|
17387
17671
|
output.info(`正在停止事件源 '${matchedSource.name}'...`);
|
|
17388
17672
|
try {
|
|
17389
17673
|
await esComponent.stopSource(matchedSource.id);
|
|
17390
|
-
output.success(
|
|
17674
|
+
output.success(chalk62.green(`事件源已停止: ${matchedSource.name}`));
|
|
17391
17675
|
} catch (error) {
|
|
17392
17676
|
output.error(`停止失败: ${error}`);
|
|
17393
17677
|
process.exit(1);
|
|
@@ -17399,14 +17683,14 @@ var EventSourceStopCommand = {
|
|
|
17399
17683
|
};
|
|
17400
17684
|
|
|
17401
17685
|
// src/commands/eventsource/status.ts
|
|
17402
|
-
import
|
|
17686
|
+
import chalk63 from "chalk";
|
|
17403
17687
|
var STATUS_COLORS = {
|
|
17404
|
-
created:
|
|
17405
|
-
starting:
|
|
17406
|
-
running:
|
|
17407
|
-
stopping:
|
|
17408
|
-
stopped:
|
|
17409
|
-
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
|
|
17410
17694
|
};
|
|
17411
17695
|
var STATUS_ICONS = {
|
|
17412
17696
|
created: "○",
|
|
@@ -17460,7 +17744,7 @@ var EventSourceStatusCommand = {
|
|
|
17460
17744
|
process.exit(1);
|
|
17461
17745
|
}
|
|
17462
17746
|
const status = esComponent.getStatus(matchedSource.id) || "unknown";
|
|
17463
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
17747
|
+
const statusColor = STATUS_COLORS[status] || chalk63.gray;
|
|
17464
17748
|
if (args.json) {
|
|
17465
17749
|
output.json({
|
|
17466
17750
|
id: matchedSource.id,
|
|
@@ -17477,31 +17761,31 @@ var EventSourceStatusCommand = {
|
|
|
17477
17761
|
});
|
|
17478
17762
|
return;
|
|
17479
17763
|
}
|
|
17480
|
-
output.log(
|
|
17764
|
+
output.log(chalk63.bold("事件源详情"));
|
|
17481
17765
|
output.log("─".repeat(50));
|
|
17482
|
-
output.log(` ID: ${
|
|
17483
|
-
output.log(` Name: ${
|
|
17484
|
-
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)}`);
|
|
17485
17769
|
output.log(` Status: ${statusColor(`${STATUS_ICONS[status]} ${STATUS_LABELS[status]}`)}`);
|
|
17486
|
-
output.log(` Enabled: ${matchedSource.enabled ?
|
|
17770
|
+
output.log(` Enabled: ${matchedSource.enabled ? chalk63.green("是") : chalk63.gray("否")}`);
|
|
17487
17771
|
if (matchedSource.eventTypes?.length) {
|
|
17488
|
-
output.log(` Events: ${
|
|
17772
|
+
output.log(` Events: ${chalk63.gray(matchedSource.eventTypes.join(", "))}`);
|
|
17489
17773
|
}
|
|
17490
17774
|
if (matchedSource.command) {
|
|
17491
|
-
output.log(` Command: ${
|
|
17775
|
+
output.log(` Command: ${chalk63.gray(matchedSource.command)}`);
|
|
17492
17776
|
}
|
|
17493
17777
|
if (matchedSource.interval) {
|
|
17494
|
-
output.log(` Interval: ${
|
|
17778
|
+
output.log(` Interval: ${chalk63.gray(`${matchedSource.interval}ms`)}`);
|
|
17495
17779
|
}
|
|
17496
17780
|
if (matchedSource.url) {
|
|
17497
|
-
output.log(` URL: ${
|
|
17781
|
+
output.log(` URL: ${chalk63.gray(matchedSource.url)}`);
|
|
17498
17782
|
}
|
|
17499
17783
|
output.log("");
|
|
17500
17784
|
return;
|
|
17501
17785
|
}
|
|
17502
17786
|
const sources = esComponent.list();
|
|
17503
17787
|
if (sources.length === 0) {
|
|
17504
|
-
output.log(
|
|
17788
|
+
output.log(chalk63.yellow("没有配置的事件源"));
|
|
17505
17789
|
return;
|
|
17506
17790
|
}
|
|
17507
17791
|
if (args.json) {
|
|
@@ -17515,21 +17799,21 @@ var EventSourceStatusCommand = {
|
|
|
17515
17799
|
output.json({ sources: sourcesWithStatus, count: sources.length });
|
|
17516
17800
|
return;
|
|
17517
17801
|
}
|
|
17518
|
-
output.log(
|
|
17802
|
+
output.log(chalk63.bold("事件源状态概览"));
|
|
17519
17803
|
output.log("─".repeat(60));
|
|
17520
17804
|
for (const source of sources) {
|
|
17521
17805
|
const status = esComponent.getStatus(source.id) || "unknown";
|
|
17522
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
17806
|
+
const statusColor = STATUS_COLORS[status] || chalk63.gray;
|
|
17523
17807
|
const icon = STATUS_ICONS[status] || "?";
|
|
17524
17808
|
const label = STATUS_LABELS[status] || status;
|
|
17525
17809
|
output.log("");
|
|
17526
|
-
output.log(` ${
|
|
17810
|
+
output.log(` ${chalk63.cyan(source.name)} ${chalk63.gray(`(${source.type})`)}`);
|
|
17527
17811
|
output.log(` └─ Status: ${statusColor(`${icon} ${label}`)}`);
|
|
17528
|
-
output.log(` ID: ${
|
|
17812
|
+
output.log(` ID: ${chalk63.gray(source.id.substring(0, 8))}...`);
|
|
17529
17813
|
}
|
|
17530
17814
|
output.log("");
|
|
17531
17815
|
const runningCount = sources.filter((s) => esComponent.getStatus(s.id) === "running").length;
|
|
17532
|
-
output.log(
|
|
17816
|
+
output.log(chalk63.green(`✅ ${runningCount}/${sources.length} 运行中`));
|
|
17533
17817
|
} finally {
|
|
17534
17818
|
await envService.dispose();
|
|
17535
17819
|
}
|
|
@@ -17842,7 +18126,7 @@ var DebugCommand = {
|
|
|
17842
18126
|
};
|
|
17843
18127
|
|
|
17844
18128
|
// src/commands/workflow/renderers.ts
|
|
17845
|
-
import
|
|
18129
|
+
import chalk64 from "chalk";
|
|
17846
18130
|
function truncateVisual3(str, maxWidth) {
|
|
17847
18131
|
if (!str)
|
|
17848
18132
|
return "-";
|
|
@@ -17877,18 +18161,18 @@ function formatDuration(ms) {
|
|
|
17877
18161
|
function statusColor(status) {
|
|
17878
18162
|
switch (status) {
|
|
17879
18163
|
case "completed":
|
|
17880
|
-
return
|
|
18164
|
+
return chalk64.green;
|
|
17881
18165
|
case "running":
|
|
17882
18166
|
case "idle":
|
|
17883
|
-
return
|
|
18167
|
+
return chalk64.blue;
|
|
17884
18168
|
case "paused":
|
|
17885
|
-
return
|
|
18169
|
+
return chalk64.yellow;
|
|
17886
18170
|
case "failed":
|
|
17887
|
-
return
|
|
18171
|
+
return chalk64.red;
|
|
17888
18172
|
case "stopped":
|
|
17889
|
-
return
|
|
18173
|
+
return chalk64.gray;
|
|
17890
18174
|
default:
|
|
17891
|
-
return
|
|
18175
|
+
return chalk64.white;
|
|
17892
18176
|
}
|
|
17893
18177
|
}
|
|
17894
18178
|
function renderWorkflowList(workflows, options) {
|
|
@@ -17907,7 +18191,7 @@ function renderWorkflowList(workflows, options) {
|
|
|
17907
18191
|
}, null, 2);
|
|
17908
18192
|
}
|
|
17909
18193
|
if (workflows.length === 0) {
|
|
17910
|
-
return
|
|
18194
|
+
return chalk64.yellow("No workflows found");
|
|
17911
18195
|
}
|
|
17912
18196
|
const NAME_WIDTH = 30;
|
|
17913
18197
|
const VERSION_WIDTH = 10;
|
|
@@ -17915,10 +18199,10 @@ function renderWorkflowList(workflows, options) {
|
|
|
17915
18199
|
const UPDATED_WIDTH = 20;
|
|
17916
18200
|
const GAP = " ";
|
|
17917
18201
|
const headerLine = [
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
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")
|
|
17922
18206
|
].join(GAP);
|
|
17923
18207
|
const sepLine = "─".repeat(NAME_WIDTH + VERSION_WIDTH + TAGS_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
17924
18208
|
const rows = workflows.map((w) => {
|
|
@@ -17933,18 +18217,18 @@ function renderWorkflowList(workflows, options) {
|
|
|
17933
18217
|
}
|
|
17934
18218
|
function renderWorkflowDetail(workflow, options) {
|
|
17935
18219
|
const lines = [];
|
|
17936
|
-
lines.push(
|
|
18220
|
+
lines.push(chalk64.bold(`
|
|
17937
18221
|
\uD83D\uDCCB Workflow Details
|
|
17938
18222
|
`));
|
|
17939
|
-
lines.push(` ${
|
|
17940
|
-
lines.push(` ${
|
|
17941
|
-
lines.push(` ${
|
|
17942
|
-
lines.push(` ${
|
|
17943
|
-
lines.push(` ${
|
|
17944
|
-
lines.push(` ${
|
|
17945
|
-
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)}`);
|
|
17946
18230
|
const nodeCount = workflow.definition.nodes.length;
|
|
17947
|
-
lines.push(
|
|
18231
|
+
lines.push(chalk64.bold(`
|
|
17948
18232
|
\uD83D\uDCCA Nodes Summary
|
|
17949
18233
|
`));
|
|
17950
18234
|
lines.push(` Total: ${nodeCount} nodes`);
|
|
@@ -17956,7 +18240,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
17956
18240
|
lines.push(` - ${type}: ${count}`);
|
|
17957
18241
|
}
|
|
17958
18242
|
if (workflow.definition.config) {
|
|
17959
|
-
lines.push(
|
|
18243
|
+
lines.push(chalk64.bold(`
|
|
17960
18244
|
⚙️ Configuration
|
|
17961
18245
|
`));
|
|
17962
18246
|
if (workflow.definition.config.parallel_limit !== undefined) {
|
|
@@ -17970,7 +18254,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
17970
18254
|
}
|
|
17971
18255
|
}
|
|
17972
18256
|
if (options?.includeRuns && options.includeRuns.length > 0) {
|
|
17973
|
-
lines.push(
|
|
18257
|
+
lines.push(chalk64.bold(`
|
|
17974
18258
|
\uD83D\uDCDC Recent Runs
|
|
17975
18259
|
`));
|
|
17976
18260
|
lines.push(renderRunsList(options.includeRuns.slice(0, 5)));
|
|
@@ -17994,7 +18278,7 @@ function renderRunsList(runs, options) {
|
|
|
17994
18278
|
}, null, 2);
|
|
17995
18279
|
}
|
|
17996
18280
|
if (runs.length === 0) {
|
|
17997
|
-
return
|
|
18281
|
+
return chalk64.yellow("No runs found");
|
|
17998
18282
|
}
|
|
17999
18283
|
const ID_WIDTH = 20;
|
|
18000
18284
|
const STATUS_WIDTH = 12;
|
|
@@ -18002,10 +18286,10 @@ function renderRunsList(runs, options) {
|
|
|
18002
18286
|
const UPDATED_WIDTH = 20;
|
|
18003
18287
|
const GAP = " ";
|
|
18004
18288
|
const headerLine = [
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
|
|
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")
|
|
18009
18293
|
].join(GAP);
|
|
18010
18294
|
const sepLine = "─".repeat(ID_WIDTH + STATUS_WIDTH + DURATION_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
18011
18295
|
const rows = runs.map((r) => {
|
|
@@ -18020,34 +18304,34 @@ function renderRunsList(runs, options) {
|
|
|
18020
18304
|
}
|
|
18021
18305
|
function renderRunDetail(run) {
|
|
18022
18306
|
const lines = [];
|
|
18023
|
-
lines.push(
|
|
18307
|
+
lines.push(chalk64.bold(`
|
|
18024
18308
|
\uD83C\uDFC3 Run Details
|
|
18025
18309
|
`));
|
|
18026
|
-
lines.push(` ${
|
|
18027
|
-
lines.push(` ${
|
|
18028
|
-
lines.push(` ${
|
|
18029
|
-
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)}`);
|
|
18030
18314
|
if (run.pausedAt) {
|
|
18031
|
-
lines.push(` ${
|
|
18315
|
+
lines.push(` ${chalk64.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
|
|
18032
18316
|
}
|
|
18033
18317
|
if (run.resumedAt) {
|
|
18034
|
-
lines.push(` ${
|
|
18318
|
+
lines.push(` ${chalk64.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
|
|
18035
18319
|
}
|
|
18036
18320
|
if (run.stoppedAt) {
|
|
18037
|
-
lines.push(` ${
|
|
18321
|
+
lines.push(` ${chalk64.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
|
|
18038
18322
|
}
|
|
18039
18323
|
if (run.completedAt) {
|
|
18040
|
-
lines.push(` ${
|
|
18324
|
+
lines.push(` ${chalk64.cyan("Completed:")} ${formatDate(run.completedAt)}`);
|
|
18041
18325
|
}
|
|
18042
|
-
lines.push(` ${
|
|
18326
|
+
lines.push(` ${chalk64.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
|
|
18043
18327
|
if (run.error) {
|
|
18044
|
-
lines.push(
|
|
18328
|
+
lines.push(chalk64.bold(`
|
|
18045
18329
|
❌ Error
|
|
18046
18330
|
`));
|
|
18047
|
-
lines.push(` ${
|
|
18331
|
+
lines.push(` ${chalk64.red(run.error)}`);
|
|
18048
18332
|
}
|
|
18049
18333
|
if (run.output) {
|
|
18050
|
-
lines.push(
|
|
18334
|
+
lines.push(chalk64.bold(`
|
|
18051
18335
|
\uD83D\uDCE4 Output
|
|
18052
18336
|
`));
|
|
18053
18337
|
lines.push(" " + JSON.stringify(run.output, null, 2).split(`
|
|
@@ -18058,36 +18342,36 @@ function renderRunDetail(run) {
|
|
|
18058
18342
|
`);
|
|
18059
18343
|
}
|
|
18060
18344
|
function renderWorkflowAdded(workflow) {
|
|
18061
|
-
return
|
|
18345
|
+
return chalk64.green(`
|
|
18062
18346
|
✅ Workflow '${workflow.name}' added successfully
|
|
18063
18347
|
`) + ` ID: ${workflow.id}
|
|
18064
18348
|
` + ` Version: ${workflow.version}
|
|
18065
18349
|
`;
|
|
18066
18350
|
}
|
|
18067
18351
|
function renderWorkflowUpdated(workflow) {
|
|
18068
|
-
return
|
|
18352
|
+
return chalk64.green(`
|
|
18069
18353
|
✅ Workflow '${workflow.name}' updated successfully
|
|
18070
18354
|
`) + ` ID: ${workflow.id}
|
|
18071
18355
|
`;
|
|
18072
18356
|
}
|
|
18073
18357
|
function renderWorkflowDeleted(name) {
|
|
18074
|
-
return
|
|
18358
|
+
return chalk64.green(`
|
|
18075
18359
|
✅ Workflow '${name}' deleted successfully
|
|
18076
18360
|
`);
|
|
18077
18361
|
}
|
|
18078
18362
|
function renderRunResult(result) {
|
|
18079
18363
|
const lines = [];
|
|
18080
18364
|
if (result.status === "completed") {
|
|
18081
|
-
lines.push(
|
|
18365
|
+
lines.push(chalk64.green(`
|
|
18082
18366
|
✅ Workflow completed successfully`));
|
|
18083
18367
|
} else if (result.status === "failed") {
|
|
18084
|
-
lines.push(
|
|
18368
|
+
lines.push(chalk64.red(`
|
|
18085
18369
|
❌ Workflow failed`));
|
|
18086
18370
|
} else if (result.status === "stopped") {
|
|
18087
|
-
lines.push(
|
|
18371
|
+
lines.push(chalk64.yellow(`
|
|
18088
18372
|
⚠️ Workflow stopped`));
|
|
18089
18373
|
} else {
|
|
18090
|
-
lines.push(
|
|
18374
|
+
lines.push(chalk64.blue(`
|
|
18091
18375
|
\uD83D\uDD04 Workflow ${result.status}`));
|
|
18092
18376
|
}
|
|
18093
18377
|
lines.push(` Run ID: ${result.runId}`);
|
|
@@ -18095,11 +18379,11 @@ function renderRunResult(result) {
|
|
|
18095
18379
|
lines.push(` Duration: ${formatDuration(result.durationMs)}`);
|
|
18096
18380
|
}
|
|
18097
18381
|
if (result.error) {
|
|
18098
|
-
lines.push(
|
|
18382
|
+
lines.push(chalk64.red(`
|
|
18099
18383
|
Error: ${result.error}`));
|
|
18100
18384
|
}
|
|
18101
18385
|
if (result.output) {
|
|
18102
|
-
lines.push(
|
|
18386
|
+
lines.push(chalk64.bold(`
|
|
18103
18387
|
\uD83D\uDCE4 Output:`));
|
|
18104
18388
|
lines.push(JSON.stringify(result.output, null, 2));
|
|
18105
18389
|
}
|
|
@@ -18113,10 +18397,10 @@ function renderNodesList(nodes) {
|
|
|
18113
18397
|
const DEPS_WIDTH = 20;
|
|
18114
18398
|
const GAP = " ";
|
|
18115
18399
|
const headerLine = [
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
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")
|
|
18120
18404
|
].join(GAP);
|
|
18121
18405
|
const sepLine = "─".repeat(ID_WIDTH + TYPE_WIDTH + NAME_WIDTH + DEPS_WIDTH + GAP.length * 3);
|
|
18122
18406
|
const rows = nodes.map((n) => {
|
|
@@ -18131,7 +18415,7 @@ function renderNodesList(nodes) {
|
|
|
18131
18415
|
}
|
|
18132
18416
|
|
|
18133
18417
|
// src/commands/workflow/commands/list.ts
|
|
18134
|
-
import
|
|
18418
|
+
import chalk65 from "chalk";
|
|
18135
18419
|
import { createWorkflowListTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18136
18420
|
function buildListWorkflowsJson(workflows, total, args, availableTags) {
|
|
18137
18421
|
const output = {
|
|
@@ -18162,10 +18446,10 @@ var WorkflowListCommand = {
|
|
|
18162
18446
|
describe: "搜索 description 和 tags(支持 AND/OR/NOT 语法)",
|
|
18163
18447
|
type: "string"
|
|
18164
18448
|
}).option("limit", {
|
|
18165
|
-
alias: "l",
|
|
18166
|
-
describe: "
|
|
18449
|
+
alias: ["l", "n"],
|
|
18450
|
+
describe: "返回数量限制(-l 旧 alias, -n 新统一 alias)",
|
|
18167
18451
|
type: "number",
|
|
18168
|
-
default:
|
|
18452
|
+
default: 20
|
|
18169
18453
|
}).option("offset", {
|
|
18170
18454
|
alias: "o",
|
|
18171
18455
|
describe: "分页偏移",
|
|
@@ -18263,6 +18547,18 @@ var WorkflowListCommand = {
|
|
|
18263
18547
|
offset: finalOffset,
|
|
18264
18548
|
page: page > 1 ? page : Math.floor(finalOffset / pageSize) + 1
|
|
18265
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;
|
|
18266
18562
|
} else {
|
|
18267
18563
|
const renderWorkflows = workflows.map((w) => ({
|
|
18268
18564
|
id: w.name,
|
|
@@ -18279,20 +18575,20 @@ var WorkflowListCommand = {
|
|
|
18279
18575
|
if (total > workflows.length) {
|
|
18280
18576
|
const start = finalOffset + 1;
|
|
18281
18577
|
const end = finalOffset + workflows.length;
|
|
18282
|
-
output.log(
|
|
18578
|
+
output.log(chalk65.green(`
|
|
18283
18579
|
✅ 显示 ${start}-${end} / 共 ${total} 个 Workflow`));
|
|
18284
18580
|
const totalPages = Math.ceil(total / pageSize);
|
|
18285
18581
|
const currentPage = Math.floor(finalOffset / pageSize) + 1;
|
|
18286
18582
|
if (totalPages > 1) {
|
|
18287
|
-
output.log(
|
|
18583
|
+
output.log(chalk65.cyan(`\uD83D\uDCC4 第 ${currentPage} / ${totalPages} 页`));
|
|
18288
18584
|
}
|
|
18289
18585
|
} else {
|
|
18290
|
-
output.log(
|
|
18586
|
+
output.log(chalk65.green(`
|
|
18291
18587
|
✅ 共 ${total} 个 Workflow`));
|
|
18292
18588
|
}
|
|
18293
18589
|
if (availableTags.length > 0) {
|
|
18294
18590
|
const tagsLine = availableTags.map((t) => `${t.name}(${t.count})`).join(", ");
|
|
18295
|
-
output.log(
|
|
18591
|
+
output.log(chalk65.cyan(`
|
|
18296
18592
|
\uD83C\uDFF7️ Available tags: ${tagsLine}`));
|
|
18297
18593
|
}
|
|
18298
18594
|
}
|
|
@@ -18896,7 +19192,7 @@ class WorkflowValidator {
|
|
|
18896
19192
|
|
|
18897
19193
|
// src/commands/workflow/commands/add.ts
|
|
18898
19194
|
import { validateWorkflowDefinition } from "@ai-setting/roy-agent-core/env/workflow/utils";
|
|
18899
|
-
import
|
|
19195
|
+
import chalk66 from "chalk";
|
|
18900
19196
|
import fs3 from "fs";
|
|
18901
19197
|
import path6 from "path";
|
|
18902
19198
|
async function parseWorkflowContent(content, filename) {
|
|
@@ -19038,7 +19334,7 @@ var WorkflowAddCommand = {
|
|
|
19038
19334
|
definition = await parseWorkflowContent(content, filePath);
|
|
19039
19335
|
workflowName = a.name || definition.name || path6.basename(filePath);
|
|
19040
19336
|
if (a.validate) {
|
|
19041
|
-
output.log(
|
|
19337
|
+
output.log(chalk66.blue("\uD83D\uDD0D Validating workflow..."));
|
|
19042
19338
|
const dagResult = validateWorkflowDefinition(definition);
|
|
19043
19339
|
if (!dagResult.valid) {
|
|
19044
19340
|
output.error(`
|
|
@@ -19062,11 +19358,11 @@ var WorkflowAddCommand = {
|
|
|
19062
19358
|
});
|
|
19063
19359
|
process.exit(1);
|
|
19064
19360
|
}
|
|
19065
|
-
output.log(
|
|
19361
|
+
output.log(chalk66.green(`✅ Workflow validation passed
|
|
19066
19362
|
`));
|
|
19067
19363
|
}
|
|
19068
19364
|
} else if (a.desc) {
|
|
19069
|
-
output.log(
|
|
19365
|
+
output.log(chalk66.blue(`\uD83E\uDD16 Generating workflow from description...
|
|
19070
19366
|
`));
|
|
19071
19367
|
const agentComponent = env.getComponent("agent");
|
|
19072
19368
|
if (!agentComponent) {
|
|
@@ -19088,20 +19384,20 @@ ${a.desc}
|
|
|
19088
19384
|
1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
|
|
19089
19385
|
2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
|
|
19090
19386
|
3. 验证通过后才输出最终 YAML`;
|
|
19091
|
-
output.log(
|
|
19387
|
+
output.log(chalk66.gray("Running workflow-extract agent..."));
|
|
19092
19388
|
const result = await agentComponent.run("workflow-extract", prompt);
|
|
19093
19389
|
const agentOutput = result.finalText || "";
|
|
19094
19390
|
definition = parseYamlFromAgentOutput(agentOutput);
|
|
19095
19391
|
if (definition === null) {
|
|
19096
19392
|
output.error("Failed to parse workflow from agent output");
|
|
19097
|
-
output.log(
|
|
19393
|
+
output.log(chalk66.gray(`
|
|
19098
19394
|
Agent output:
|
|
19099
19395
|
` + agentOutput.slice(0, 500)));
|
|
19100
19396
|
process.exit(1);
|
|
19101
19397
|
}
|
|
19102
19398
|
workflowName = a.name || definition.name;
|
|
19103
19399
|
if (a.validate) {
|
|
19104
|
-
output.log(
|
|
19400
|
+
output.log(chalk66.blue(`
|
|
19105
19401
|
\uD83D\uDD0D Validating generated workflow...`));
|
|
19106
19402
|
const dagResult = validateWorkflowDefinition(definition);
|
|
19107
19403
|
if (!dagResult.valid) {
|
|
@@ -19110,7 +19406,7 @@ Agent output:
|
|
|
19110
19406
|
dagResult.errors.forEach((msg, i) => {
|
|
19111
19407
|
output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
|
|
19112
19408
|
});
|
|
19113
|
-
output.log(
|
|
19409
|
+
output.log(chalk66.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
19114
19410
|
process.exit(1);
|
|
19115
19411
|
}
|
|
19116
19412
|
const validator = new WorkflowValidator;
|
|
@@ -19125,16 +19421,16 @@ Agent output:
|
|
|
19125
19421
|
output.error(` Fix: ${error.fix}
|
|
19126
19422
|
`);
|
|
19127
19423
|
});
|
|
19128
|
-
output.log(
|
|
19424
|
+
output.log(chalk66.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
19129
19425
|
process.exit(1);
|
|
19130
19426
|
}
|
|
19131
|
-
output.log(
|
|
19427
|
+
output.log(chalk66.green(`✅ Generated workflow validation passed
|
|
19132
19428
|
`));
|
|
19133
19429
|
}
|
|
19134
19430
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
19135
|
-
output.log(
|
|
19431
|
+
output.log(chalk66.gray("--- Generated YAML ---"));
|
|
19136
19432
|
output.log(yaml.stringify(definition));
|
|
19137
|
-
output.log(
|
|
19433
|
+
output.log(chalk66.gray(`------------------------
|
|
19138
19434
|
`));
|
|
19139
19435
|
} else {
|
|
19140
19436
|
output.error("Please provide --file or --desc option");
|
|
@@ -19160,10 +19456,10 @@ Agent output:
|
|
|
19160
19456
|
force: a.force
|
|
19161
19457
|
});
|
|
19162
19458
|
output.log(renderWorkflowAdded(workflow));
|
|
19163
|
-
output.log(
|
|
19459
|
+
output.log(chalk66.bold(`
|
|
19164
19460
|
\uD83D\uDCCA Nodes Summary:`));
|
|
19165
19461
|
output.log(renderNodesList(definition.nodes));
|
|
19166
|
-
output.log(
|
|
19462
|
+
output.log(chalk66.green(`
|
|
19167
19463
|
✅ Workflow '${workflowName}' added successfully`));
|
|
19168
19464
|
} catch (error) {
|
|
19169
19465
|
if (error.message?.includes("already exists") && !a.force) {
|
|
@@ -19180,7 +19476,7 @@ Agent output:
|
|
|
19180
19476
|
};
|
|
19181
19477
|
|
|
19182
19478
|
// src/commands/workflow/commands/get.ts
|
|
19183
|
-
import
|
|
19479
|
+
import chalk67 from "chalk";
|
|
19184
19480
|
import { createWorkflowGetTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
19185
19481
|
var WorkflowGetCommand = {
|
|
19186
19482
|
command: "get <identifier>",
|
|
@@ -19318,15 +19614,15 @@ var WorkflowGetCommand = {
|
|
|
19318
19614
|
} else {
|
|
19319
19615
|
output.log(renderWorkflowDetail(workflow, { includeRuns: runs }));
|
|
19320
19616
|
if (args.includeNodes) {
|
|
19321
|
-
output.log(
|
|
19617
|
+
output.log(chalk67.bold(`
|
|
19322
19618
|
\uD83D\uDCCB All Nodes:`));
|
|
19323
19619
|
output.log(renderNodesList(data.nodes || []));
|
|
19324
19620
|
}
|
|
19325
19621
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
19326
19622
|
const defYaml = yaml.stringify(data.definition || {}, { indent: 2 });
|
|
19327
|
-
output.log(
|
|
19623
|
+
output.log(chalk67.bold(`
|
|
19328
19624
|
\uD83D\uDCC4 Definition (YAML):`));
|
|
19329
|
-
output.log(
|
|
19625
|
+
output.log(chalk67.gray(defYaml));
|
|
19330
19626
|
}
|
|
19331
19627
|
}
|
|
19332
19628
|
} catch (error) {
|
|
@@ -19339,7 +19635,7 @@ var WorkflowGetCommand = {
|
|
|
19339
19635
|
};
|
|
19340
19636
|
|
|
19341
19637
|
// src/commands/workflow/commands/update.ts
|
|
19342
|
-
import
|
|
19638
|
+
import chalk68 from "chalk";
|
|
19343
19639
|
import fs4 from "fs";
|
|
19344
19640
|
import path7 from "path";
|
|
19345
19641
|
import { parseWorkflowFile } from "@ai-setting/roy-agent-core/env/workflow/types";
|
|
@@ -19412,7 +19708,7 @@ var WorkflowUpdateCommand = {
|
|
|
19412
19708
|
const tags = a.tags ? a.tags.split(",").map((t) => t.trim()) : undefined;
|
|
19413
19709
|
const workflow = await service.updateWorkflow(a.name, updates, { tags });
|
|
19414
19710
|
output.log(renderWorkflowUpdated(workflow));
|
|
19415
|
-
output.log(
|
|
19711
|
+
output.log(chalk68.green(`
|
|
19416
19712
|
✅ Workflow '${a.name}' updated successfully`));
|
|
19417
19713
|
} catch (error) {
|
|
19418
19714
|
output.error(`Failed to update workflow: ${error}`);
|
|
@@ -19424,7 +19720,7 @@ var WorkflowUpdateCommand = {
|
|
|
19424
19720
|
};
|
|
19425
19721
|
|
|
19426
19722
|
// src/commands/workflow/commands/remove.ts
|
|
19427
|
-
import
|
|
19723
|
+
import chalk69 from "chalk";
|
|
19428
19724
|
var WorkflowRemoveCommand = {
|
|
19429
19725
|
command: "remove <name>",
|
|
19430
19726
|
describe: "删除 Workflow",
|
|
@@ -19463,8 +19759,8 @@ var WorkflowRemoveCommand = {
|
|
|
19463
19759
|
process.exit(1);
|
|
19464
19760
|
}
|
|
19465
19761
|
if (!args.force) {
|
|
19466
|
-
output.log(
|
|
19467
|
-
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"));
|
|
19468
19764
|
process.exit(1);
|
|
19469
19765
|
}
|
|
19470
19766
|
const deleted = await service.deleteWorkflow(args.name);
|
|
@@ -19484,7 +19780,7 @@ var WorkflowRemoveCommand = {
|
|
|
19484
19780
|
|
|
19485
19781
|
// src/commands/workflow/commands/run.ts
|
|
19486
19782
|
var import_yaml = __toESM(require_dist(), 1);
|
|
19487
|
-
import
|
|
19783
|
+
import chalk70 from "chalk";
|
|
19488
19784
|
import fs5 from "fs";
|
|
19489
19785
|
import path8 from "path";
|
|
19490
19786
|
import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
@@ -19571,7 +19867,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19571
19867
|
}
|
|
19572
19868
|
if (args.session) {
|
|
19573
19869
|
const sessionId = args.session;
|
|
19574
|
-
output.log(
|
|
19870
|
+
output.log(chalk70.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
19575
19871
|
const sessionComponent = workflowComponent.sessionComponent;
|
|
19576
19872
|
if (!sessionComponent) {
|
|
19577
19873
|
output.error("SessionComponent not available");
|
|
@@ -19633,17 +19929,17 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19633
19929
|
definition = { ...definition, name: args.name };
|
|
19634
19930
|
}
|
|
19635
19931
|
const workflow = await service.createWorkflow(definition, { force: true });
|
|
19636
|
-
output.log(
|
|
19637
|
-
output.log(
|
|
19932
|
+
output.log(chalk70.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
|
|
19933
|
+
output.log(chalk70.green(`✅ Workflow registered: ${workflow.name} (${workflow.id})`));
|
|
19638
19934
|
if (args.registerOnly) {
|
|
19639
|
-
output.log(
|
|
19935
|
+
output.log(chalk70.gray("ℹ️ Use --register-only, skipping execution"));
|
|
19640
19936
|
if (workflowSpan) {
|
|
19641
19937
|
workflowSpan.end();
|
|
19642
19938
|
}
|
|
19643
19939
|
await envService.dispose();
|
|
19644
19940
|
process.exit(0);
|
|
19645
19941
|
}
|
|
19646
|
-
output.log(
|
|
19942
|
+
output.log(chalk70.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
|
|
19647
19943
|
const result = await service.runWorkflow(definition, input, runOptions);
|
|
19648
19944
|
output.log(renderRunResult({
|
|
19649
19945
|
runId: result.runId,
|
|
@@ -19653,7 +19949,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19653
19949
|
durationMs: result.durationMs
|
|
19654
19950
|
}));
|
|
19655
19951
|
if (result.status === "paused") {
|
|
19656
|
-
output.log(
|
|
19952
|
+
output.log(chalk70.gray(`
|
|
19657
19953
|
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session ${result.runId} --input '<response>'" to resume`));
|
|
19658
19954
|
}
|
|
19659
19955
|
} else {
|
|
@@ -19676,7 +19972,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19676
19972
|
durationMs: runData.duration_ms
|
|
19677
19973
|
}));
|
|
19678
19974
|
if (runData.status === "paused") {
|
|
19679
|
-
output.log(
|
|
19975
|
+
output.log(chalk70.gray(`
|
|
19680
19976
|
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session ${runData.run_id} --input '<response>'" to resume`));
|
|
19681
19977
|
}
|
|
19682
19978
|
}
|
|
@@ -19748,7 +20044,7 @@ var WorkflowRunCommand = {
|
|
|
19748
20044
|
};
|
|
19749
20045
|
|
|
19750
20046
|
// src/commands/workflow/commands/stop.ts
|
|
19751
|
-
import
|
|
20047
|
+
import chalk71 from "chalk";
|
|
19752
20048
|
import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
19753
20049
|
import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
|
|
19754
20050
|
var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
@@ -19773,7 +20069,7 @@ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
|
19773
20069
|
output.error(result.error || `Failed to stop workflow: ${args.runId}`);
|
|
19774
20070
|
process.exit(1);
|
|
19775
20071
|
}
|
|
19776
|
-
output.log(
|
|
20072
|
+
output.log(chalk71.red(`
|
|
19777
20073
|
⏹️ Workflow stopped: ${args.runId}`));
|
|
19778
20074
|
} catch (error) {
|
|
19779
20075
|
output.error(`Failed to stop workflow: ${error}`);
|
|
@@ -19797,7 +20093,7 @@ var WorkflowStopCommand = {
|
|
|
19797
20093
|
};
|
|
19798
20094
|
|
|
19799
20095
|
// src/commands/workflow/commands/status.ts
|
|
19800
|
-
import
|
|
20096
|
+
import chalk72 from "chalk";
|
|
19801
20097
|
import { createWorkflowRunStatusTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
19802
20098
|
var WorkflowStatusCommand = {
|
|
19803
20099
|
command: "status <runId>",
|
|
@@ -19890,7 +20186,7 @@ var WorkflowStatusCommand = {
|
|
|
19890
20186
|
stopped: "⏹️"
|
|
19891
20187
|
};
|
|
19892
20188
|
const emoji = statusEmoji[status] || "❓";
|
|
19893
|
-
output.log(
|
|
20189
|
+
output.log(chalk72.bold(`
|
|
19894
20190
|
${emoji} Status: ${status.toUpperCase()}`));
|
|
19895
20191
|
}
|
|
19896
20192
|
} catch (error) {
|
|
@@ -19903,7 +20199,7 @@ ${emoji} Status: ${status.toUpperCase()}`));
|
|
|
19903
20199
|
};
|
|
19904
20200
|
|
|
19905
20201
|
// src/commands/workflow/commands/nodes.ts
|
|
19906
|
-
import
|
|
20202
|
+
import chalk73 from "chalk";
|
|
19907
20203
|
var BUILT_IN_NODES = [
|
|
19908
20204
|
{
|
|
19909
20205
|
name: "ToolNode",
|
|
@@ -20240,7 +20536,7 @@ nodes:
|
|
|
20240
20536
|
];
|
|
20241
20537
|
function renderNodeTypesTable(nodes) {
|
|
20242
20538
|
const lines = [];
|
|
20243
|
-
lines.push(
|
|
20539
|
+
lines.push(chalk73.bold(`
|
|
20244
20540
|
\uD83D\uDCE6 Built-in Node Types
|
|
20245
20541
|
`));
|
|
20246
20542
|
lines.push("┌────────────┬────────────────────┬─────────────────────────────────────────────────────────────┐");
|
|
@@ -20258,29 +20554,29 @@ function renderNodeTypesTable(nodes) {
|
|
|
20258
20554
|
}
|
|
20259
20555
|
function renderNodeDetail(node) {
|
|
20260
20556
|
const lines = [];
|
|
20261
|
-
lines.push(
|
|
20557
|
+
lines.push(chalk73.bold(`
|
|
20262
20558
|
[${node.type}] ${node.name}`));
|
|
20263
|
-
lines.push(
|
|
20559
|
+
lines.push(chalk73.dim("─".repeat(60)) + `
|
|
20264
20560
|
`);
|
|
20265
|
-
lines.push(
|
|
20561
|
+
lines.push(chalk73.bold("Description:"));
|
|
20266
20562
|
lines.push(` ${node.description}
|
|
20267
20563
|
`);
|
|
20268
|
-
lines.push(
|
|
20564
|
+
lines.push(chalk73.bold("Configuration:"));
|
|
20269
20565
|
lines.push(' type: "' + node.type + '"');
|
|
20270
20566
|
lines.push(" config:");
|
|
20271
20567
|
for (const input of node.inputs) {
|
|
20272
|
-
const required = input.required ?
|
|
20568
|
+
const required = input.required ? chalk73.red("*") : " ";
|
|
20273
20569
|
lines.push(` ${input.name} (${input.type})${required}`);
|
|
20274
20570
|
lines.push(` ${input.description}`);
|
|
20275
20571
|
}
|
|
20276
20572
|
lines.push(`
|
|
20277
|
-
${
|
|
20573
|
+
${chalk73.bold("Output:")} ${node.output}`);
|
|
20278
20574
|
if (node.example) {
|
|
20279
|
-
lines.push(
|
|
20575
|
+
lines.push(chalk73.bold(`
|
|
20280
20576
|
Example:`));
|
|
20281
|
-
lines.push(
|
|
20577
|
+
lines.push(chalk73.gray("```yaml"));
|
|
20282
20578
|
lines.push(node.example);
|
|
20283
|
-
lines.push(
|
|
20579
|
+
lines.push(chalk73.gray("```"));
|
|
20284
20580
|
}
|
|
20285
20581
|
return lines.join(`
|
|
20286
20582
|
`);
|
|
@@ -20296,16 +20592,16 @@ var WorkflowNodesCommand = {
|
|
|
20296
20592
|
const nodeType = args.type?.toLowerCase();
|
|
20297
20593
|
if (!nodeType) {
|
|
20298
20594
|
console.log(renderNodeTypesTable(BUILT_IN_NODES));
|
|
20299
|
-
console.log(
|
|
20300
|
-
Use `) +
|
|
20301
|
-
console.log(
|
|
20595
|
+
console.log(chalk73.gray(`
|
|
20596
|
+
Use `) + chalk73.cyan("roy-agent workflow nodes <type>") + chalk73.gray(" for detailed information"));
|
|
20597
|
+
console.log(chalk73.gray("Available types: ") + chalk73.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
20302
20598
|
return;
|
|
20303
20599
|
}
|
|
20304
20600
|
const node = BUILT_IN_NODES.find((n) => n.type === nodeType);
|
|
20305
20601
|
if (!node) {
|
|
20306
|
-
console.log(
|
|
20602
|
+
console.log(chalk73.red(`
|
|
20307
20603
|
❌ Unknown node type: ${nodeType}`));
|
|
20308
|
-
console.log(
|
|
20604
|
+
console.log(chalk73.gray("Available types: ") + chalk73.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
20309
20605
|
process.exit(1);
|
|
20310
20606
|
}
|
|
20311
20607
|
console.log(renderNodeDetail(node));
|
|
@@ -20313,7 +20609,7 @@ Use `) + chalk72.cyan("roy-agent workflow nodes <type>") + chalk72.gray(" for de
|
|
|
20313
20609
|
};
|
|
20314
20610
|
|
|
20315
20611
|
// src/commands/workflow/commands/validate.ts
|
|
20316
|
-
import
|
|
20612
|
+
import chalk74 from "chalk";
|
|
20317
20613
|
import { readFileSync } from "fs";
|
|
20318
20614
|
async function parseWorkflowInput(input, yamlStr) {
|
|
20319
20615
|
const parseYaml = async (content) => {
|
|
@@ -20346,25 +20642,25 @@ function renderResult(result, options) {
|
|
|
20346
20642
|
return;
|
|
20347
20643
|
}
|
|
20348
20644
|
if (result.valid) {
|
|
20349
|
-
console.log(
|
|
20645
|
+
console.log(chalk74.green(`
|
|
20350
20646
|
✅ Workflow validation PASSED
|
|
20351
20647
|
`));
|
|
20352
|
-
console.log(
|
|
20648
|
+
console.log(chalk74.bold(`Workflow: ${result.workflowName}`));
|
|
20353
20649
|
console.log(`Nodes: ${result.nodeCount}`);
|
|
20354
20650
|
console.log(`
|
|
20355
20651
|
Valid nodes:`);
|
|
20356
|
-
console.log(
|
|
20652
|
+
console.log(chalk74.green(" ✓ All nodes passed validation"));
|
|
20357
20653
|
} else {
|
|
20358
|
-
console.log(
|
|
20654
|
+
console.log(chalk74.red(`
|
|
20359
20655
|
❌ Workflow validation FAILED (${result.errors.length} errors found)
|
|
20360
20656
|
`));
|
|
20361
20657
|
result.errors.forEach((error, index) => {
|
|
20362
|
-
console.log(
|
|
20363
|
-
console.log(` ${
|
|
20364
|
-
console.log(` ${
|
|
20365
|
-
console.log(` ${
|
|
20366
|
-
console.log(` ${
|
|
20367
|
-
console.log(` ${
|
|
20658
|
+
console.log(chalk74.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
|
|
20659
|
+
console.log(` ${chalk74.bold("Type:")} ${error.type}`);
|
|
20660
|
+
console.log(` ${chalk74.bold("Description:")} ${error.description}`);
|
|
20661
|
+
console.log(` ${chalk74.bold("Expected:")} ${error.expected}`);
|
|
20662
|
+
console.log(` ${chalk74.bold("Actual:")} ${error.actual}`);
|
|
20663
|
+
console.log(` ${chalk74.green("Fix:")} ${error.fix}`);
|
|
20368
20664
|
console.log();
|
|
20369
20665
|
});
|
|
20370
20666
|
}
|
|
@@ -20389,7 +20685,7 @@ var WorkflowValidateCommand = {
|
|
|
20389
20685
|
try {
|
|
20390
20686
|
const workflow = await parseWorkflowInput(options.input, options.yaml);
|
|
20391
20687
|
if (!workflow) {
|
|
20392
|
-
console.error(
|
|
20688
|
+
console.error(chalk74.red("Failed to parse workflow input"));
|
|
20393
20689
|
process.exit(1);
|
|
20394
20690
|
}
|
|
20395
20691
|
const validator = new WorkflowValidator;
|
|
@@ -20397,7 +20693,7 @@ var WorkflowValidateCommand = {
|
|
|
20397
20693
|
renderResult(result, options);
|
|
20398
20694
|
process.exit(result.valid ? 0 : 1);
|
|
20399
20695
|
} catch (error) {
|
|
20400
|
-
console.error(
|
|
20696
|
+
console.error(chalk74.red(`
|
|
20401
20697
|
Error: ${error.message}`));
|
|
20402
20698
|
process.exit(1);
|
|
20403
20699
|
}
|
|
@@ -20405,7 +20701,7 @@ Error: ${error.message}`));
|
|
|
20405
20701
|
};
|
|
20406
20702
|
|
|
20407
20703
|
// src/commands/workflow/commands/search.ts
|
|
20408
|
-
import
|
|
20704
|
+
import chalk75 from "chalk";
|
|
20409
20705
|
import { wrapFunction as wrapFunction3 } from "@ai-setting/roy-agent-core";
|
|
20410
20706
|
var WorkflowSearchCommand = {
|
|
20411
20707
|
command: "search",
|
|
@@ -20562,22 +20858,22 @@ var _runWorkflowSearchImpl = async function(opts) {
|
|
|
20562
20858
|
metadata: {}
|
|
20563
20859
|
}));
|
|
20564
20860
|
if (renderWorkflows.length === 0) {
|
|
20565
|
-
output.log(
|
|
20566
|
-
output.log(
|
|
20567
|
-
output.log(
|
|
20861
|
+
output.log(chalk75.yellow("\uD83D\uDD0D No workflows matched the search criteria."));
|
|
20862
|
+
output.log(chalk75.gray(` keyword: ${keyword || "(none)"}`));
|
|
20863
|
+
output.log(chalk75.gray(` tags: ${tags && tags.length > 0 ? tags.join(", ") : "(none)"}`));
|
|
20568
20864
|
} else {
|
|
20569
|
-
output.log(
|
|
20865
|
+
output.log(chalk75.bold(`\uD83D\uDD0D Search results (${renderWorkflows.length}):`));
|
|
20570
20866
|
output.log(renderWorkflowList(renderWorkflows));
|
|
20571
|
-
output.log(
|
|
20867
|
+
output.log(chalk75.green(`
|
|
20572
20868
|
✅ Found ${renderWorkflows.length} workflow(s)`));
|
|
20573
20869
|
}
|
|
20574
20870
|
if (availableTags.length > 0) {
|
|
20575
20871
|
output.log("");
|
|
20576
|
-
output.log(
|
|
20872
|
+
output.log(chalk75.bold("\uD83D\uDCDA Available tags (sorted by usage_count):"));
|
|
20577
20873
|
for (const t of availableTags) {
|
|
20578
20874
|
const name = t.name ?? t.tag;
|
|
20579
20875
|
const count = t.count ?? t.usage_count;
|
|
20580
|
-
output.log(
|
|
20876
|
+
output.log(chalk75.gray(` - ${name} (${count})`));
|
|
20581
20877
|
}
|
|
20582
20878
|
}
|
|
20583
20879
|
};
|
|
@@ -20589,7 +20885,7 @@ var runWorkflowSearch = wrapFunction3(_runWorkflowSearchImpl, "workflow.cli.sear
|
|
|
20589
20885
|
|
|
20590
20886
|
// src/commands/workflow/commands/tag.ts
|
|
20591
20887
|
import { wrapFunction as wrapFunction4 } from "@ai-setting/roy-agent-core";
|
|
20592
|
-
import
|
|
20888
|
+
import chalk76 from "chalk";
|
|
20593
20889
|
var WorkflowTagListCommand = {
|
|
20594
20890
|
command: "list",
|
|
20595
20891
|
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.",
|
|
@@ -20710,17 +21006,17 @@ var _runWorkflowTagListImpl = async function(opts) {
|
|
|
20710
21006
|
return;
|
|
20711
21007
|
}
|
|
20712
21008
|
if (result.tags.length === 0) {
|
|
20713
|
-
output.log(
|
|
20714
|
-
output.log(
|
|
21009
|
+
output.log(chalk76.yellow("\uD83C\uDFF7️ No tags in the workflow_tags table yet."));
|
|
21010
|
+
output.log(chalk76.gray(" Tags are created automatically when you run `workflow add --tags <name>`."));
|
|
20715
21011
|
return;
|
|
20716
21012
|
}
|
|
20717
|
-
output.log(
|
|
20718
|
-
output.log(
|
|
21013
|
+
output.log(chalk76.bold(`\uD83C\uDFF7️ Workflow tags (${result.total}):`));
|
|
21014
|
+
output.log(chalk76.gray(` ${padRight("NAME", 24)}${padRight("USAGE", 8)}${padRight("CREATED", 22)}`));
|
|
20719
21015
|
for (const t of result.tags) {
|
|
20720
21016
|
const line = ` ${padRight(t.name, 24)}${padRight(String(t.usage_count), 8)}${padRight(formatDate2(t.created_at), 22)}`;
|
|
20721
21017
|
output.log(line);
|
|
20722
21018
|
}
|
|
20723
|
-
output.log(
|
|
21019
|
+
output.log(chalk76.gray(`
|
|
20724
21020
|
\uD83D\uDCA1 Tip: when adding a new workflow, prefer tags from this list to ensure semantic consistency.`));
|
|
20725
21021
|
};
|
|
20726
21022
|
var _runWorkflowTagGetImpl = async function(opts) {
|
|
@@ -20747,7 +21043,7 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
20747
21043
|
output.json({ error: "Tag not found", name: opts.name });
|
|
20748
21044
|
} else {
|
|
20749
21045
|
output.error(`Tag "${opts.name}" not found in the workflow_tags table.`);
|
|
20750
|
-
output.log(
|
|
21046
|
+
output.log(chalk76.gray(`Tip: run \`roy-agent workflow tag list\` to see available tags.`));
|
|
20751
21047
|
}
|
|
20752
21048
|
process.exitCode = 1;
|
|
20753
21049
|
return;
|
|
@@ -20756,10 +21052,10 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
20756
21052
|
output.json(tag);
|
|
20757
21053
|
return;
|
|
20758
21054
|
}
|
|
20759
|
-
output.log(
|
|
20760
|
-
output.log(
|
|
20761
|
-
output.log(
|
|
20762
|
-
output.log(
|
|
21055
|
+
output.log(chalk76.bold(`\uD83C\uDFF7️ Tag: ${tag.name}`));
|
|
21056
|
+
output.log(chalk76.gray(` usage_count: ${tag.usage_count}`));
|
|
21057
|
+
output.log(chalk76.gray(` created_at: ${tag.created_at}`));
|
|
21058
|
+
output.log(chalk76.gray(` updated_at: ${tag.updated_at}`));
|
|
20763
21059
|
};
|
|
20764
21060
|
async function callListTags(service, options) {
|
|
20765
21061
|
if (typeof service.listTags !== "function") {
|
|
@@ -21413,6 +21709,10 @@ var InstallCommand = {
|
|
|
21413
21709
|
|
|
21414
21710
|
// src/cli.ts
|
|
21415
21711
|
function quietModeMiddleware(argv) {
|
|
21712
|
+
if (argv.noquiet === true) {
|
|
21713
|
+
argv.quiet = false;
|
|
21714
|
+
delete argv.noquiet;
|
|
21715
|
+
}
|
|
21416
21716
|
const quietService = CliQuietModeService.getInstance();
|
|
21417
21717
|
if (argv.quiet === true) {
|
|
21418
21718
|
quietService.setQuiet(true);
|
|
@@ -21454,6 +21754,10 @@ async function runCli() {
|
|
|
21454
21754
|
type: "boolean",
|
|
21455
21755
|
default: true,
|
|
21456
21756
|
global: true
|
|
21757
|
+
}).option("noquiet", {
|
|
21758
|
+
type: "boolean",
|
|
21759
|
+
description: "Alias for --no-quiet (no hyphen form). Disables quiet mode.",
|
|
21760
|
+
global: true
|
|
21457
21761
|
}).option("plugin", {
|
|
21458
21762
|
alias: "p",
|
|
21459
21763
|
type: "string",
|