@ai-setting/roy-agent-cli 1.6.18 → 1.6.20
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 +713 -705
- package/dist/index.js +713 -705
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +1 -1
package/dist/bin/roy-agent.js
CHANGED
|
@@ -705,8 +705,20 @@ ${COLORS.system("[已中断]")}
|
|
|
705
705
|
], StreamOutputService.prototype, "handleText", null);
|
|
706
706
|
});
|
|
707
707
|
|
|
708
|
-
// src/commands/ui/
|
|
708
|
+
// src/commands/ui/mascot/glasses-girl.ts
|
|
709
709
|
import chalk5 from "chalk";
|
|
710
|
+
var GLASSES_GIRL_RAW_LINES;
|
|
711
|
+
var init_glasses_girl = __esm(() => {
|
|
712
|
+
GLASSES_GIRL_RAW_LINES = [
|
|
713
|
+
" ▟♥▀▀♥▀▌ ",
|
|
714
|
+
" ◐◑ ◐◑ ",
|
|
715
|
+
" ▄ ▙▀▀▀▀▀▀▟ ▄ ",
|
|
716
|
+
" Roy mascot "
|
|
717
|
+
];
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
// src/commands/ui/welcome-card.ts
|
|
721
|
+
import chalk6 from "chalk";
|
|
710
722
|
function visibleLength(s) {
|
|
711
723
|
return s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
712
724
|
}
|
|
@@ -769,12 +781,8 @@ function printWelcomeCard(ctx) {
|
|
|
769
781
|
var PIXEL_LOGO_LINES, TIPS_LINES, WHATS_NEW_LINES;
|
|
770
782
|
var init_welcome_card = __esm(() => {
|
|
771
783
|
init_stream_output_service();
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
" ▝▜███▛▘ ",
|
|
775
|
-
" ▔▔▔ ",
|
|
776
|
-
" R.O.Y mascot "
|
|
777
|
-
];
|
|
784
|
+
init_glasses_girl();
|
|
785
|
+
PIXEL_LOGO_LINES = GLASSES_GIRL_RAW_LINES;
|
|
778
786
|
TIPS_LINES = [
|
|
779
787
|
"/help Show all commands",
|
|
780
788
|
"/init Create memory file",
|
|
@@ -904,7 +912,7 @@ var init_status_bar = __esm(() => {
|
|
|
904
912
|
var require_package = __commonJS((exports, module) => {
|
|
905
913
|
module.exports = {
|
|
906
914
|
name: "@ai-setting/roy-agent-cli",
|
|
907
|
-
version: "1.6.
|
|
915
|
+
version: "1.6.20",
|
|
908
916
|
type: "module",
|
|
909
917
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
910
918
|
main: "./dist/index.js",
|
|
@@ -1245,7 +1253,7 @@ var init_slash_command_popup = __esm(() => {
|
|
|
1245
1253
|
// src/commands/markdown-renderer.tsx
|
|
1246
1254
|
import * as React2 from "react";
|
|
1247
1255
|
import { Box as Box2, Text as Text2 } from "ink";
|
|
1248
|
-
import
|
|
1256
|
+
import chalk7 from "chalk";
|
|
1249
1257
|
import { wrapFunction } from "@ai-setting/roy-agent-core";
|
|
1250
1258
|
function parseInline(text, keyPrefix) {
|
|
1251
1259
|
const nodes = [];
|
|
@@ -1450,10 +1458,10 @@ function renderMarkdownLegacyImpl(content) {
|
|
|
1450
1458
|
const level = headingMatch[1].length;
|
|
1451
1459
|
const text = headingMatch[2];
|
|
1452
1460
|
if (level === 1) {
|
|
1453
|
-
const styled =
|
|
1461
|
+
const styled = chalk7.cyan.bold.underline(`▌ ${text}`);
|
|
1454
1462
|
blocks.push(React2.createElement(Box2, { key: `blk-h1-${blockKey++}`, marginY: 1 }, React2.createElement(Text2, {}, styled)));
|
|
1455
1463
|
} else if (level === 2) {
|
|
1456
|
-
const styled =
|
|
1464
|
+
const styled = chalk7.green.bold(`▶ ${text}`);
|
|
1457
1465
|
blocks.push(React2.createElement(Box2, { key: `blk-h2-${blockKey++}`, marginY: 1 }, React2.createElement(Text2, {}, styled)));
|
|
1458
1466
|
} else {
|
|
1459
1467
|
const colors = {
|
|
@@ -10702,7 +10710,7 @@ var ActCommand = createActCommand();
|
|
|
10702
10710
|
|
|
10703
10711
|
// src/commands/interactive.ts
|
|
10704
10712
|
import * as readline2 from "readline";
|
|
10705
|
-
import
|
|
10713
|
+
import chalk8 from "chalk";
|
|
10706
10714
|
|
|
10707
10715
|
// src/commands/shared/session-manager.ts
|
|
10708
10716
|
import { parseImageInput as parseImageInput2 } from "@ai-setting/roy-agent-core";
|
|
@@ -12548,7 +12556,7 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12548
12556
|
console.log(formatAskUserOutput({ ...errorInfo, query: question, options }));
|
|
12549
12557
|
const userResponse = await this.promptUser(question, options, errorInfo);
|
|
12550
12558
|
if (isAskUserTimeoutSentinel(userResponse)) {
|
|
12551
|
-
console.log(
|
|
12559
|
+
console.log(chalk8.dim(`
|
|
12552
12560
|
请直接输入新指令继续,或使用 /abort 中断当前工作流。`));
|
|
12553
12561
|
return;
|
|
12554
12562
|
}
|
|
@@ -12569,7 +12577,7 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12569
12577
|
const finishWithUserInput = (input) => {
|
|
12570
12578
|
const trimmedInput = input.trim();
|
|
12571
12579
|
if (!trimmedInput) {
|
|
12572
|
-
console.log(
|
|
12580
|
+
console.log(chalk8.yellow(`⚠️ 输入不能为空,请重新输入
|
|
12573
12581
|
`));
|
|
12574
12582
|
this.promptUser(question, options, errorInfo, opts).then(resolve);
|
|
12575
12583
|
return;
|
|
@@ -12577,11 +12585,11 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12577
12585
|
const parsed = parseUserInput(trimmedInput, options);
|
|
12578
12586
|
if (parsed.type === "option" && options) {
|
|
12579
12587
|
const selectedOption = options[parsed.value];
|
|
12580
|
-
console.log(
|
|
12588
|
+
console.log(chalk8.green(`✓ 您选择了: ${selectedOption}
|
|
12581
12589
|
`));
|
|
12582
12590
|
resolve(selectedOption);
|
|
12583
12591
|
} else {
|
|
12584
|
-
console.log(
|
|
12592
|
+
console.log(chalk8.green(`✓ 您的回答: ${parsed.value}
|
|
12585
12593
|
`));
|
|
12586
12594
|
resolve(parsed.value);
|
|
12587
12595
|
}
|
|
@@ -12594,7 +12602,7 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12594
12602
|
finishWithUserInput(input);
|
|
12595
12603
|
},
|
|
12596
12604
|
onTimeout: () => {
|
|
12597
|
-
console.log(
|
|
12605
|
+
console.log(chalk8.yellow(`
|
|
12598
12606
|
⏱ ask_user 超时:${timeoutMs}ms 内未收到回应,已自动解除等待。`));
|
|
12599
12607
|
resolve(createAskUserTimeoutSentinel(errorInfo, timeoutMs, {
|
|
12600
12608
|
source: "repl",
|
|
@@ -12718,61 +12726,61 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12718
12726
|
});
|
|
12719
12727
|
return;
|
|
12720
12728
|
}
|
|
12721
|
-
console.log(
|
|
12729
|
+
console.log(chalk8.bold(`
|
|
12722
12730
|
╔══════════════════════════════════════════════════╗`));
|
|
12723
|
-
console.log(
|
|
12724
|
-
console.log(
|
|
12731
|
+
console.log(chalk8.bold("║ ") + chalk8.green.bold("roy-agent") + chalk8.bold(" Interactive Mode") + chalk8.bold(" ║"));
|
|
12732
|
+
console.log(chalk8.bold(`╚══════════════════════════════════════════════════╝
|
|
12725
12733
|
`));
|
|
12726
|
-
console.log(`${
|
|
12727
|
-
console.log(`${
|
|
12734
|
+
console.log(`${chalk8.dim("会话:")} ${this.options.sessionTitle}`);
|
|
12735
|
+
console.log(`${chalk8.dim("输入 ")} ${COLORS.userInput("/help")} ${chalk8.dim("查看可用命令")}
|
|
12728
12736
|
`);
|
|
12729
12737
|
}
|
|
12730
12738
|
printHelp() {
|
|
12731
12739
|
console.log(`
|
|
12732
|
-
${
|
|
12733
|
-
${
|
|
12734
|
-
${
|
|
12735
|
-
${
|
|
12736
|
-
${
|
|
12737
|
-
${
|
|
12738
|
-
${
|
|
12739
|
-
${
|
|
12740
|
-
${
|
|
12741
|
-
${
|
|
12742
|
-
${
|
|
12743
|
-
${
|
|
12744
|
-
${
|
|
12745
|
-
${
|
|
12746
|
-
${
|
|
12747
|
-
${
|
|
12740
|
+
${chalk8.bold("╭")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╮")}
|
|
12741
|
+
${chalk8.bold("│")} ${chalk8.bold("快捷命令")} ${chalk8.bold("│")}
|
|
12742
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12743
|
+
${chalk8.bold("│")} ${COLORS.userInput("/help")}, ${COLORS.userInput("/h")} 显示帮助 ${chalk8.bold("│")}
|
|
12744
|
+
${chalk8.bold("│")} ${COLORS.userInput("/status")}, ${COLORS.userInput("/st")} 显示状态 ${chalk8.bold("│")}
|
|
12745
|
+
${chalk8.bold("│")} ${COLORS.userInput("/sessions")}, ${COLORS.userInput("/s")} 切换会话 ${chalk8.bold("│")}
|
|
12746
|
+
${chalk8.bold("│")} ${COLORS.userInput("/compact")}, ${COLORS.userInput("/c")} 压缩上下文 ${chalk8.bold("│")}
|
|
12747
|
+
${chalk8.bold("│")} ${COLORS.userInput("/abort")} 中断当前流式输出 ${chalk8.bold("│")}
|
|
12748
|
+
${chalk8.bold("│")} ${COLORS.userInput("/clear")}, ${COLORS.userInput("/cls")} 清屏 ${chalk8.bold("│")}
|
|
12749
|
+
${chalk8.bold("│")} ${COLORS.userInput("/exit")}, ${COLORS.userInput("/q")} 退出 ${chalk8.bold("│")}
|
|
12750
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12751
|
+
${chalk8.bold("│")} ${chalk8.bold("多行输入")} ${chalk8.bold("│")}
|
|
12752
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12753
|
+
${chalk8.bold("│")} 输入多行内容后,Alt+Enter 结束输入。 ${chalk8.bold("│")}
|
|
12754
|
+
${chalk8.bold("│")} Ctrl+C 可取消多行输入。 ${chalk8.bold("│")}
|
|
12755
|
+
${chalk8.bold("╰")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╯")}
|
|
12748
12756
|
`);
|
|
12749
12757
|
}
|
|
12750
12758
|
async printStatus() {
|
|
12751
12759
|
const status = await this.options.onStatus();
|
|
12752
12760
|
console.log(`
|
|
12753
|
-
${
|
|
12754
|
-
${
|
|
12755
|
-
${
|
|
12756
|
-
${
|
|
12757
|
-
${
|
|
12758
|
-
${
|
|
12759
|
-
${
|
|
12760
|
-
${
|
|
12761
|
+
${chalk8.bold("╭")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╮")}
|
|
12762
|
+
${chalk8.bold("│")} ${chalk8.bold("会话状态")} ${chalk8.bold("│")}
|
|
12763
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12764
|
+
${chalk8.bold("│")} ${chalk8.dim("会话:")} ${status.sessionTitle.padEnd(35)} ${chalk8.bold("│")}
|
|
12765
|
+
${chalk8.bold("│")} ${chalk8.dim("ID:")} ${status.sessionId.padEnd(37)} ${chalk8.bold("│")}
|
|
12766
|
+
${chalk8.bold("│")} ${chalk8.dim("消息:")} ${String(status.messageCount).padEnd(34)} ${chalk8.bold("│")}
|
|
12767
|
+
${chalk8.bold("│")} ${chalk8.dim("Token:")} ${String(status.tokenCount).padEnd(33)} ${chalk8.bold("│")}
|
|
12768
|
+
${chalk8.bold("╰")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╯")}
|
|
12761
12769
|
`);
|
|
12762
12770
|
}
|
|
12763
12771
|
printSessionsHelp() {
|
|
12764
12772
|
console.log(`
|
|
12765
|
-
${
|
|
12766
|
-
${
|
|
12767
|
-
${
|
|
12768
|
-
${
|
|
12769
|
-
${
|
|
12770
|
-
${
|
|
12771
|
-
${
|
|
12772
|
-
${
|
|
12773
|
-
${
|
|
12774
|
-
${
|
|
12775
|
-
${
|
|
12773
|
+
${chalk8.bold("╭")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╮")}
|
|
12774
|
+
${chalk8.bold("│")} ${chalk8.bold("切换会话")} ${chalk8.bold("│")}
|
|
12775
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12776
|
+
${chalk8.bold("│")} 退出当前交互模式后,使用以下命令切换会话: ${chalk8.bold("│")}
|
|
12777
|
+
${chalk8.bold("│")} ${chalk8.bold("│")}
|
|
12778
|
+
${chalk8.bold("│")} ${COLORS.userInput("roy-agent sessions list")} 列出所有会话 ${chalk8.bold("│")}
|
|
12779
|
+
${chalk8.bold("│")} ${COLORS.userInput("roy-agent sessions use <id>")} 切换到指定会话 ${chalk8.bold("│")}
|
|
12780
|
+
${chalk8.bold("│")} ${chalk8.bold("│")}
|
|
12781
|
+
${chalk8.bold("│")} 或直接指定会话启动: ${chalk8.bold("│")}
|
|
12782
|
+
${chalk8.bold("│")} ${COLORS.userInput("roy-agent interactive -s <session-id>")} ${chalk8.bold("│")}
|
|
12783
|
+
${chalk8.bold("╰")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╯")}
|
|
12776
12784
|
`);
|
|
12777
12785
|
}
|
|
12778
12786
|
}
|
|
@@ -13150,7 +13158,7 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
13150
13158
|
var InteractiveCommand = createInteractiveCommand();
|
|
13151
13159
|
|
|
13152
13160
|
// src/commands/shared/list-output.ts
|
|
13153
|
-
import
|
|
13161
|
+
import chalk9 from "chalk";
|
|
13154
13162
|
var PAGINATION_OPTIONS = {
|
|
13155
13163
|
limit: {
|
|
13156
13164
|
alias: "n",
|
|
@@ -13177,8 +13185,8 @@ function renderPaginationFooter(opts) {
|
|
|
13177
13185
|
const items = `${itemName}${count === 1 ? "" : "s"}`;
|
|
13178
13186
|
const base = `Showing ${start}-${end} of ${total} ${items}`;
|
|
13179
13187
|
const suffix = extras.length > 0 ? ` (${extras.join(", ")})` : "";
|
|
13180
|
-
const truncatedHint = total > count && offset + count < total ?
|
|
13181
|
-
return
|
|
13188
|
+
const truncatedHint = total > count && offset + count < total ? chalk9.cyan(` — use -o ${offset + limit} for next page`) : "";
|
|
13189
|
+
return chalk9.gray(base + suffix + truncatedHint);
|
|
13182
13190
|
}
|
|
13183
13191
|
function renderQuietHeader(total, itemName) {
|
|
13184
13192
|
const items = `${itemName}${total === 1 ? "" : "s"}`;
|
|
@@ -13198,7 +13206,7 @@ function renderQuietPaginationHint(opts) {
|
|
|
13198
13206
|
}
|
|
13199
13207
|
|
|
13200
13208
|
// src/commands/sessions/list.ts
|
|
13201
|
-
import
|
|
13209
|
+
import chalk10 from "chalk";
|
|
13202
13210
|
|
|
13203
13211
|
// src/commands/sessions/session-graph.ts
|
|
13204
13212
|
function buildSessionTree(sessions) {
|
|
@@ -13483,39 +13491,39 @@ var ListCommand = {
|
|
|
13483
13491
|
const hasTypeFilter = !!args.type;
|
|
13484
13492
|
const hasStatusFilter = !!args.status;
|
|
13485
13493
|
const header = [
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
hasTypeFilter || hasStatusFilter ?
|
|
13491
|
-
|
|
13492
|
-
|
|
13494
|
+
chalk10.bold("#"),
|
|
13495
|
+
chalk10.bold("Title"),
|
|
13496
|
+
chalk10.bold("ID"),
|
|
13497
|
+
chalk10.bold("Parent"),
|
|
13498
|
+
hasTypeFilter || hasStatusFilter ? chalk10.bold("Status") : null,
|
|
13499
|
+
chalk10.bold("Msgs"),
|
|
13500
|
+
chalk10.bold("CP")
|
|
13493
13501
|
].filter(Boolean).join(" │ ");
|
|
13494
13502
|
const rows = sessions.map((s, i) => {
|
|
13495
|
-
const marker = s.id === activeSessionId ?
|
|
13503
|
+
const marker = s.id === activeSessionId ? chalk10.green("▶") : " ";
|
|
13496
13504
|
const hasCp = (s.metadata?.checkpoints?.checkpoints?.length ?? 0) > 0;
|
|
13497
13505
|
const title = s.title.length > 20 ? s.title.slice(0, 17) + "..." : s.title;
|
|
13498
13506
|
const idStr = s.id;
|
|
13499
13507
|
const useShortId = args.shortId === true;
|
|
13500
|
-
const parentStr = s.parentSessionId ?
|
|
13508
|
+
const parentStr = s.parentSessionId ? chalk10.gray(useShortId ? shortSessionId(s.parentSessionId) : s.parentSessionId) : chalk10.gray("-");
|
|
13501
13509
|
const workflowMeta = s.metadata?.type === "workflow" ? s.metadata : null;
|
|
13502
13510
|
const statusStr = workflowMeta?.status || "";
|
|
13503
13511
|
let statusDisplay = "";
|
|
13504
13512
|
if (hasTypeFilter || hasStatusFilter) {
|
|
13505
13513
|
if (workflowMeta) {
|
|
13506
|
-
statusDisplay = workflowMeta.status === "running" ?
|
|
13514
|
+
statusDisplay = workflowMeta.status === "running" ? chalk10.green("running") : workflowMeta.status === "paused" ? chalk10.yellow("paused") : workflowMeta.status === "completed" ? chalk10.gray("completed") : workflowMeta.status === "failed" ? chalk10.red("failed") : statusStr;
|
|
13507
13515
|
}
|
|
13508
13516
|
}
|
|
13509
13517
|
const cells = [
|
|
13510
13518
|
marker + " " + (args.offset + i + 1),
|
|
13511
13519
|
title,
|
|
13512
|
-
|
|
13520
|
+
chalk10.gray(idStr),
|
|
13513
13521
|
parentStr
|
|
13514
13522
|
];
|
|
13515
13523
|
if (hasTypeFilter || hasStatusFilter) {
|
|
13516
|
-
cells.push(statusDisplay ||
|
|
13524
|
+
cells.push(statusDisplay || chalk10.gray("-"));
|
|
13517
13525
|
}
|
|
13518
|
-
cells.push(s.messageCount.toString(), hasCp ?
|
|
13526
|
+
cells.push(s.messageCount.toString(), hasCp ? chalk10.green("✓") : chalk10.gray("-"));
|
|
13519
13527
|
return cells.join(" │ ");
|
|
13520
13528
|
});
|
|
13521
13529
|
output.log([
|
|
@@ -13549,37 +13557,37 @@ var ListCommand = {
|
|
|
13549
13557
|
};
|
|
13550
13558
|
|
|
13551
13559
|
// src/commands/sessions/get.ts
|
|
13552
|
-
import
|
|
13560
|
+
import chalk11 from "chalk";
|
|
13553
13561
|
function colorWorkflowStatus(status) {
|
|
13554
13562
|
switch (status) {
|
|
13555
13563
|
case "running":
|
|
13556
|
-
return
|
|
13564
|
+
return chalk11.green;
|
|
13557
13565
|
case "paused":
|
|
13558
|
-
return
|
|
13566
|
+
return chalk11.yellow;
|
|
13559
13567
|
case "completed":
|
|
13560
|
-
return
|
|
13568
|
+
return chalk11.gray;
|
|
13561
13569
|
case "failed":
|
|
13562
|
-
return
|
|
13570
|
+
return chalk11.red;
|
|
13563
13571
|
case "stopped":
|
|
13564
|
-
return
|
|
13572
|
+
return chalk11.magenta;
|
|
13565
13573
|
default:
|
|
13566
|
-
return
|
|
13574
|
+
return chalk11.gray;
|
|
13567
13575
|
}
|
|
13568
13576
|
}
|
|
13569
13577
|
function colorAgentSessionStatus(status) {
|
|
13570
13578
|
switch (status) {
|
|
13571
13579
|
case "active":
|
|
13572
|
-
return
|
|
13580
|
+
return chalk11.green;
|
|
13573
13581
|
case "paused":
|
|
13574
|
-
return
|
|
13582
|
+
return chalk11.yellow;
|
|
13575
13583
|
case "completed":
|
|
13576
|
-
return
|
|
13584
|
+
return chalk11.gray;
|
|
13577
13585
|
case "failed":
|
|
13578
|
-
return
|
|
13586
|
+
return chalk11.red;
|
|
13579
13587
|
case "stopped":
|
|
13580
|
-
return
|
|
13588
|
+
return chalk11.magenta;
|
|
13581
13589
|
default:
|
|
13582
|
-
return
|
|
13590
|
+
return chalk11.gray;
|
|
13583
13591
|
}
|
|
13584
13592
|
}
|
|
13585
13593
|
var GetCommand = {
|
|
@@ -13637,19 +13645,19 @@ var GetCommand = {
|
|
|
13637
13645
|
});
|
|
13638
13646
|
} else {
|
|
13639
13647
|
const lines = [
|
|
13640
|
-
|
|
13648
|
+
chalk11.bold("┌─ Session Details ─────────────────────────────────┐"),
|
|
13641
13649
|
`│ ID: ${session.id}`,
|
|
13642
13650
|
`│ Title: ${session.title}`,
|
|
13643
13651
|
`│ Directory: ${session.directory}`,
|
|
13644
13652
|
`│ Messages: ${session.messageCount}`,
|
|
13645
|
-
`│ Active: ${session.id === activeSessionId ?
|
|
13653
|
+
`│ Active: ${session.id === activeSessionId ? chalk11.green("✓") : chalk11.gray("-")}`,
|
|
13646
13654
|
`│ Created: ${new Date(session.createdAt).toLocaleString("zh-CN")}`,
|
|
13647
13655
|
`│ Updated: ${new Date(session.updatedAt).toLocaleString("zh-CN")}`
|
|
13648
13656
|
];
|
|
13649
13657
|
const workflowMeta = session.metadata?.type === "workflow" ? session.metadata : null;
|
|
13650
13658
|
if (workflowMeta) {
|
|
13651
13659
|
lines.push("├─ Workflow Info ─────────────────────────────────────┤");
|
|
13652
|
-
lines.push(`│ Type: ${
|
|
13660
|
+
lines.push(`│ Type: ${chalk11.cyan("workflow")}`);
|
|
13653
13661
|
lines.push(`│ Workflow: ${workflowMeta.workflowName}`);
|
|
13654
13662
|
if (workflowMeta.workflowId) {
|
|
13655
13663
|
lines.push(`│ Workflow ID: ${workflowMeta.workflowId}`);
|
|
@@ -13686,7 +13694,7 @@ var GetCommand = {
|
|
|
13686
13694
|
};
|
|
13687
13695
|
|
|
13688
13696
|
// src/commands/sessions/new.ts
|
|
13689
|
-
import
|
|
13697
|
+
import chalk12 from "chalk";
|
|
13690
13698
|
var NewCommand = {
|
|
13691
13699
|
command: "new [options]",
|
|
13692
13700
|
aliases: ["create"],
|
|
@@ -13725,7 +13733,7 @@ var NewCommand = {
|
|
|
13725
13733
|
}
|
|
13726
13734
|
});
|
|
13727
13735
|
} else {
|
|
13728
|
-
output.success(
|
|
13736
|
+
output.success(chalk12.green("✓") + " Session created: " + session.id);
|
|
13729
13737
|
output.info("Title: " + session.title);
|
|
13730
13738
|
output.info("Directory: " + session.directory);
|
|
13731
13739
|
}
|
|
@@ -13739,7 +13747,7 @@ var NewCommand = {
|
|
|
13739
13747
|
};
|
|
13740
13748
|
|
|
13741
13749
|
// src/commands/sessions/rename.ts
|
|
13742
|
-
import
|
|
13750
|
+
import chalk13 from "chalk";
|
|
13743
13751
|
var RenameCommand = {
|
|
13744
13752
|
command: "rename <session-id> <title>",
|
|
13745
13753
|
aliases: ["mv"],
|
|
@@ -13794,7 +13802,7 @@ var RenameCommand = {
|
|
|
13794
13802
|
}
|
|
13795
13803
|
});
|
|
13796
13804
|
} else {
|
|
13797
|
-
output.success(`Session renamed: ${
|
|
13805
|
+
output.success(`Session renamed: ${chalk13.green(a.title)}`);
|
|
13798
13806
|
output.info(`ID: ${a.sessionId}`);
|
|
13799
13807
|
}
|
|
13800
13808
|
} catch (error) {
|
|
@@ -13807,7 +13815,7 @@ var RenameCommand = {
|
|
|
13807
13815
|
};
|
|
13808
13816
|
|
|
13809
13817
|
// src/commands/sessions/delete.ts
|
|
13810
|
-
import
|
|
13818
|
+
import chalk14 from "chalk";
|
|
13811
13819
|
var DeleteCommand = {
|
|
13812
13820
|
command: "delete [session-ids...]",
|
|
13813
13821
|
aliases: ["rm"],
|
|
@@ -13886,7 +13894,7 @@ var DeleteCommand = {
|
|
|
13886
13894
|
return true;
|
|
13887
13895
|
});
|
|
13888
13896
|
if (a.keepActive && sessionsToDelete.length > 0) {
|
|
13889
|
-
output.log(
|
|
13897
|
+
output.log(chalk14.yellow(`Keeping active session: ${activeSessionId}`));
|
|
13890
13898
|
}
|
|
13891
13899
|
} else if (a.olderThan !== undefined) {
|
|
13892
13900
|
const cutoffDate = new Date;
|
|
@@ -13903,7 +13911,7 @@ var DeleteCommand = {
|
|
|
13903
13911
|
}
|
|
13904
13912
|
return false;
|
|
13905
13913
|
});
|
|
13906
|
-
output.log(
|
|
13914
|
+
output.log(chalk14.gray(`Deleting sessions not updated since ${cutoffDate.toISOString().split("T")[0]} (${a.olderThan} days ago)`));
|
|
13907
13915
|
} else {
|
|
13908
13916
|
output.log("No sessions to delete");
|
|
13909
13917
|
return;
|
|
@@ -13913,10 +13921,10 @@ var DeleteCommand = {
|
|
|
13913
13921
|
return;
|
|
13914
13922
|
}
|
|
13915
13923
|
if (a.dryRun) {
|
|
13916
|
-
output.log(
|
|
13924
|
+
output.log(chalk14.yellow(`[DRY RUN] Would delete ${sessionsToDelete.length} session(s):
|
|
13917
13925
|
`));
|
|
13918
13926
|
sessionsToDelete.forEach((s, i) => {
|
|
13919
|
-
const marker = s.id === activeSessionId ?
|
|
13927
|
+
const marker = s.id === activeSessionId ? chalk14.green("▶") : " ";
|
|
13920
13928
|
output.log(` ${marker} ${s.id}`);
|
|
13921
13929
|
output.log(` Title: ${s.title}`);
|
|
13922
13930
|
output.log(` Updated: ${new Date(s.updatedAt).toLocaleString()}`);
|
|
@@ -13926,11 +13934,11 @@ var DeleteCommand = {
|
|
|
13926
13934
|
return;
|
|
13927
13935
|
}
|
|
13928
13936
|
if (!a.force) {
|
|
13929
|
-
output.log(
|
|
13937
|
+
output.log(chalk14.red(`
|
|
13930
13938
|
⚠️ About to delete ${sessionsToDelete.length} session(s):
|
|
13931
13939
|
`));
|
|
13932
13940
|
sessionsToDelete.forEach((s, i) => {
|
|
13933
|
-
const marker = s.id === activeSessionId ?
|
|
13941
|
+
const marker = s.id === activeSessionId ? chalk14.green("▶") : " ";
|
|
13934
13942
|
output.log(` ${marker} ${s.id} - ${s.title}`);
|
|
13935
13943
|
});
|
|
13936
13944
|
output.log("");
|
|
@@ -13940,7 +13948,7 @@ var DeleteCommand = {
|
|
|
13940
13948
|
input: process.stdin,
|
|
13941
13949
|
output: process.stdout
|
|
13942
13950
|
});
|
|
13943
|
-
rl.question(
|
|
13951
|
+
rl.question(chalk14.red("Type 'yes' to confirm deletion: "), (res) => {
|
|
13944
13952
|
rl.close();
|
|
13945
13953
|
resolve(res);
|
|
13946
13954
|
});
|
|
@@ -13968,7 +13976,7 @@ var DeleteCommand = {
|
|
|
13968
13976
|
}
|
|
13969
13977
|
}
|
|
13970
13978
|
if (successCount > 0) {
|
|
13971
|
-
output.success(
|
|
13979
|
+
output.success(chalk14.green(`✓`) + ` Deleted ${successCount} session(s)`);
|
|
13972
13980
|
}
|
|
13973
13981
|
if (failCount > 0) {
|
|
13974
13982
|
output.error(`✗ Failed to delete ${failCount} session(s)`);
|
|
@@ -13987,7 +13995,7 @@ var DeleteCommand = {
|
|
|
13987
13995
|
};
|
|
13988
13996
|
|
|
13989
13997
|
// src/commands/sessions/messages.ts
|
|
13990
|
-
import
|
|
13998
|
+
import chalk15 from "chalk";
|
|
13991
13999
|
|
|
13992
14000
|
// src/commands/sessions/format-message-content.ts
|
|
13993
14001
|
var TEXT_MAX_CHARS = 300;
|
|
@@ -14199,20 +14207,20 @@ var MessagesCommand = {
|
|
|
14199
14207
|
} else {
|
|
14200
14208
|
const detail = a.detail === true;
|
|
14201
14209
|
const roleColors = {
|
|
14202
|
-
user:
|
|
14203
|
-
assistant:
|
|
14204
|
-
system:
|
|
14205
|
-
tool:
|
|
14210
|
+
user: chalk15.blue,
|
|
14211
|
+
assistant: chalk15.green,
|
|
14212
|
+
system: chalk15.gray,
|
|
14213
|
+
tool: chalk15.yellow
|
|
14206
14214
|
};
|
|
14207
|
-
output.log(
|
|
14215
|
+
output.log(chalk15.bold(`┌─ Messages (${a.sessionId}) ────────────────────────┐`));
|
|
14208
14216
|
messages.forEach((m, i) => {
|
|
14209
|
-
const roleColor = roleColors[m.role] ||
|
|
14217
|
+
const roleColor = roleColors[m.role] || chalk15.white;
|
|
14210
14218
|
const time = new Date(m.timestamp).toLocaleTimeString("zh-CN", {
|
|
14211
14219
|
hour: "2-digit",
|
|
14212
14220
|
minute: "2-digit"
|
|
14213
14221
|
});
|
|
14214
14222
|
if (m.metadata?.isCheckpoint) {
|
|
14215
|
-
output.log(
|
|
14223
|
+
output.log(chalk15.cyan("├─ #" + (a.offset + i + 1) + " checkpoint") + " " + chalk15.gray(time));
|
|
14216
14224
|
output.log("│");
|
|
14217
14225
|
const checkpointContent = formatCheckpointContent(m.content, { detail });
|
|
14218
14226
|
output.log("│ " + checkpointContent.split(`
|
|
@@ -14220,7 +14228,7 @@ var MessagesCommand = {
|
|
|
14220
14228
|
│ `));
|
|
14221
14229
|
output.log("│");
|
|
14222
14230
|
} else {
|
|
14223
|
-
output.log(
|
|
14231
|
+
output.log(chalk15.cyan("├─ #" + (a.offset + i + 1) + " ") + roleColor(m.role.padEnd(10)) + " " + chalk15.gray(time));
|
|
14224
14232
|
const rawLines = formatMessageContent(m, { detail });
|
|
14225
14233
|
const contentLines = colorizeContentLines(rawLines, m);
|
|
14226
14234
|
const finalLines = detail ? contentLines : contentLines.slice(0, MAX_CONTENT_LINES);
|
|
@@ -14228,7 +14236,7 @@ var MessagesCommand = {
|
|
|
14228
14236
|
output.log("│ " + line);
|
|
14229
14237
|
}
|
|
14230
14238
|
if (!detail && contentLines.length > MAX_CONTENT_LINES) {
|
|
14231
|
-
output.log("│ " +
|
|
14239
|
+
output.log("│ " + chalk15.gray(`... (truncated, total ${contentLines.length} lines)`));
|
|
14232
14240
|
}
|
|
14233
14241
|
output.log("│");
|
|
14234
14242
|
}
|
|
@@ -14236,7 +14244,7 @@ var MessagesCommand = {
|
|
|
14236
14244
|
output.log("└" + "─".repeat(51) + "┘");
|
|
14237
14245
|
const hasMore = a.offset + a.limit < totalMessages;
|
|
14238
14246
|
const showingEnd = Math.min(a.offset + a.limit, totalMessages);
|
|
14239
|
-
output.log(
|
|
14247
|
+
output.log(chalk15.gray(`Showing ${a.offset + 1}-${showingEnd} of ${totalMessages} messages` + (hasMore ? " (more available)" : "")));
|
|
14240
14248
|
}
|
|
14241
14249
|
} catch (error) {
|
|
14242
14250
|
output.error(`Failed to get messages: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -14249,43 +14257,43 @@ var MessagesCommand = {
|
|
|
14249
14257
|
function colorizeContentLines(lines, _m) {
|
|
14250
14258
|
return lines.map((line) => {
|
|
14251
14259
|
if (line.startsWith("[Tool Call]"))
|
|
14252
|
-
return
|
|
14260
|
+
return chalk15.cyan(line);
|
|
14253
14261
|
if (line.startsWith("[Tool Result]"))
|
|
14254
|
-
return
|
|
14262
|
+
return chalk15.yellow(line);
|
|
14255
14263
|
if (line === "[Reasoning]")
|
|
14256
|
-
return
|
|
14264
|
+
return chalk15.magenta(line);
|
|
14257
14265
|
if (line === "[Checkpoint]")
|
|
14258
|
-
return
|
|
14266
|
+
return chalk15.cyan(line);
|
|
14259
14267
|
if (line.startsWith("[Node Call]"))
|
|
14260
|
-
return
|
|
14268
|
+
return chalk15.blue(line);
|
|
14261
14269
|
if (line.startsWith("[Node Interrupt]"))
|
|
14262
|
-
return
|
|
14270
|
+
return chalk15.yellow(line);
|
|
14263
14271
|
if (line.startsWith("[Node Resume]"))
|
|
14264
|
-
return
|
|
14272
|
+
return chalk15.green(line);
|
|
14265
14273
|
if (line.startsWith("[Node Start]"))
|
|
14266
|
-
return
|
|
14274
|
+
return chalk15.blue(line);
|
|
14267
14275
|
if (line.startsWith("✅") || line.startsWith("❌")) {
|
|
14268
14276
|
if (line.includes("[Node Result]"))
|
|
14269
|
-
return
|
|
14277
|
+
return chalk15.green(line);
|
|
14270
14278
|
if (line.includes("[Node End]"))
|
|
14271
|
-
return
|
|
14279
|
+
return chalk15.green(line);
|
|
14272
14280
|
return line;
|
|
14273
14281
|
}
|
|
14274
14282
|
if (line.startsWith(" ")) {
|
|
14275
14283
|
if (line.startsWith(" Error:"))
|
|
14276
|
-
return
|
|
14284
|
+
return chalk15.red(line);
|
|
14277
14285
|
if (line.startsWith(" Query:"))
|
|
14278
|
-
return
|
|
14286
|
+
return chalk15.bold(line);
|
|
14279
14287
|
if (line.startsWith(" Options:") || line.startsWith(" agentSessionId:") || line.startsWith(" Duration:"))
|
|
14280
|
-
return
|
|
14281
|
-
return
|
|
14288
|
+
return chalk15.gray(line);
|
|
14289
|
+
return chalk15.gray(line);
|
|
14282
14290
|
}
|
|
14283
14291
|
return line;
|
|
14284
14292
|
});
|
|
14285
14293
|
}
|
|
14286
14294
|
|
|
14287
14295
|
// src/commands/sessions/compact.ts
|
|
14288
|
-
import
|
|
14296
|
+
import chalk16 from "chalk";
|
|
14289
14297
|
var CompactCommand = {
|
|
14290
14298
|
command: "compact <session-id>",
|
|
14291
14299
|
aliases: ["compress", "checkpoint"],
|
|
@@ -14339,13 +14347,13 @@ var CompactCommand = {
|
|
|
14339
14347
|
dryRun: true
|
|
14340
14348
|
});
|
|
14341
14349
|
} else {
|
|
14342
|
-
output.log(
|
|
14350
|
+
output.log(chalk16.bold("┌─ Compact Preview ─────────────────────────────────┐"));
|
|
14343
14351
|
output.log(`│ Session: ${session.title}`);
|
|
14344
|
-
output.log(`│ Messages to compact: ${
|
|
14352
|
+
output.log(`│ Messages to compact: ${chalk16.yellow(preview.messageCountToCompact)}`);
|
|
14345
14353
|
output.log(`│ Estimated checkpoint tokens: ${preview.estimatedCheckpointTokens}`);
|
|
14346
|
-
output.log(`│ Would trigger: ${preview.wouldTrigger ?
|
|
14354
|
+
output.log(`│ Would trigger: ${preview.wouldTrigger ? chalk16.green("Yes") : chalk16.gray("No")}`);
|
|
14347
14355
|
output.log("│");
|
|
14348
|
-
output.log("│ " +
|
|
14356
|
+
output.log("│ " + chalk16.gray("(Dry run - no changes made)"));
|
|
14349
14357
|
output.log("└" + "─".repeat(51) + "┘");
|
|
14350
14358
|
}
|
|
14351
14359
|
return;
|
|
@@ -14360,10 +14368,10 @@ var CompactCommand = {
|
|
|
14360
14368
|
try {
|
|
14361
14369
|
scenarioHint = await sessionComponent.generateCompactHint(a.sessionId);
|
|
14362
14370
|
if (!a.json) {
|
|
14363
|
-
output.log(
|
|
14364
|
-
output.log("│ " +
|
|
14371
|
+
output.log(chalk16.bold("├─ Auto-generated Scenario Hint ──────────────────────────┤"));
|
|
14372
|
+
output.log("│ " + chalk16.cyan(scenarioHint.substring(0, 70)));
|
|
14365
14373
|
if (scenarioHint.length > 70) {
|
|
14366
|
-
output.log(
|
|
14374
|
+
output.log(chalk16.gray("│ ") + scenarioHint.substring(70, 140));
|
|
14367
14375
|
}
|
|
14368
14376
|
}
|
|
14369
14377
|
} catch (hintError) {
|
|
@@ -14410,29 +14418,29 @@ var CompactCommand = {
|
|
|
14410
14418
|
}
|
|
14411
14419
|
});
|
|
14412
14420
|
} else {
|
|
14413
|
-
output.log(
|
|
14421
|
+
output.log(chalk16.bold.green("┌─ Checkpoint Created ────────────────────────────────┐"));
|
|
14414
14422
|
output.log(`│ ID: ${result.checkpoint.id}`);
|
|
14415
14423
|
output.log(`│ Title: ${result.checkpoint.title}`);
|
|
14416
14424
|
output.log(`│ Type: compact`);
|
|
14417
14425
|
output.log(`│ Created: ${new Date(result.checkpoint.createdAt).toLocaleString("zh-CN")}`);
|
|
14418
|
-
output.log(
|
|
14426
|
+
output.log(chalk16.bold("├─ Scenario Hint ────────────────────────────────────┤"));
|
|
14419
14427
|
if (scenarioHint) {
|
|
14420
14428
|
const hintLines = scenarioHint.split(`
|
|
14421
14429
|
`);
|
|
14422
14430
|
hintLines.forEach((line, i) => {
|
|
14423
14431
|
if (i === 0) {
|
|
14424
|
-
output.log(
|
|
14432
|
+
output.log(chalk16.cyan("│ " + line.substring(0, 48)));
|
|
14425
14433
|
if (line.length > 48) {
|
|
14426
14434
|
for (let j = 48;j < line.length; j += 48) {
|
|
14427
|
-
output.log(
|
|
14435
|
+
output.log(chalk16.gray("│ ") + line.substring(j, j + 48));
|
|
14428
14436
|
}
|
|
14429
14437
|
}
|
|
14430
14438
|
} else {
|
|
14431
|
-
output.log(
|
|
14439
|
+
output.log(chalk16.gray("│ ") + line);
|
|
14432
14440
|
}
|
|
14433
14441
|
});
|
|
14434
14442
|
} else {
|
|
14435
|
-
output.log(
|
|
14443
|
+
output.log(chalk16.gray("│ (no hint)"));
|
|
14436
14444
|
}
|
|
14437
14445
|
output.log("├─ Process Key Points ─────────────────────────────────┤");
|
|
14438
14446
|
result.checkpoint.processKeyPoints.forEach((p, i) => {
|
|
@@ -14457,11 +14465,11 @@ var CompactCommand = {
|
|
|
14457
14465
|
result.checkpoint.recentMessages.forEach((msg) => {
|
|
14458
14466
|
const prefix = msg.role === "user" ? "\uD83D\uDC64" : "\uD83E\uDD16";
|
|
14459
14467
|
const content = msg.content.length > 60 ? msg.content.substring(0, 60) + "..." : msg.content;
|
|
14460
|
-
output.log(
|
|
14468
|
+
output.log(chalk16.gray(`│ ${prefix} [${msg.role}] ${content}`));
|
|
14461
14469
|
});
|
|
14462
14470
|
}
|
|
14463
14471
|
output.log("├─ Stats ─────────────────────────────────────────────┤");
|
|
14464
|
-
output.log(`│ Messages compacted: ${
|
|
14472
|
+
output.log(`│ Messages compacted: ${chalk16.yellow(result.deletedMessageCount)}`);
|
|
14465
14473
|
output.log(`│ Remaining messages: ${result.remainingMessageCount}`);
|
|
14466
14474
|
output.log(`│ Total checkpoints: ${result.checkpointCount}`);
|
|
14467
14475
|
output.log("└" + "─".repeat(51) + "┘");
|
|
@@ -14479,7 +14487,7 @@ var CompactCommand = {
|
|
|
14479
14487
|
};
|
|
14480
14488
|
|
|
14481
14489
|
// src/commands/sessions/checkpoints.ts
|
|
14482
|
-
import
|
|
14490
|
+
import chalk17 from "chalk";
|
|
14483
14491
|
var CheckpointsCommand = {
|
|
14484
14492
|
command: "checkpoints <session-id>",
|
|
14485
14493
|
aliases: ["cps"],
|
|
@@ -14512,7 +14520,7 @@ var CheckpointsCommand = {
|
|
|
14512
14520
|
}
|
|
14513
14521
|
const checkpoints = await sessionComponent.getCheckpoints(a.sessionId);
|
|
14514
14522
|
if (checkpoints.length === 0) {
|
|
14515
|
-
output.log(
|
|
14523
|
+
output.log(chalk17.gray("No checkpoints for this session"));
|
|
14516
14524
|
return;
|
|
14517
14525
|
}
|
|
14518
14526
|
if (a.json) {
|
|
@@ -14537,7 +14545,7 @@ var CheckpointsCommand = {
|
|
|
14537
14545
|
if (a.detail) {
|
|
14538
14546
|
checkpoints.reverse().forEach((cp, i) => {
|
|
14539
14547
|
const isLatest = i === 0;
|
|
14540
|
-
output.log(
|
|
14548
|
+
output.log(chalk17.bold(`┌─ Checkpoint: ${cp.title} ${isLatest ? chalk17.green("✓") : ""} ──────` + "─".repeat(Math.max(0, 30 - cp.title.length)) + "┐"));
|
|
14541
14549
|
output.log(`│ ID: ${cp.id}`);
|
|
14542
14550
|
output.log(`│ Type: ${cp.type}`);
|
|
14543
14551
|
output.log(`│ Message Index: ${cp.messageIndex} (${cp.messageCountBefore} messages)`);
|
|
@@ -14565,18 +14573,18 @@ var CheckpointsCommand = {
|
|
|
14565
14573
|
});
|
|
14566
14574
|
} else {
|
|
14567
14575
|
const header = [
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14576
|
+
chalk17.bold("#"),
|
|
14577
|
+
chalk17.bold("Title"),
|
|
14578
|
+
chalk17.bold("Type"),
|
|
14579
|
+
chalk17.bold("Messages"),
|
|
14580
|
+
chalk17.bold("Created")
|
|
14573
14581
|
].join(" │ ");
|
|
14574
14582
|
output.log(`┌─ Checkpoints (${checkpoints.length}) ${"─".repeat(40)}┐`);
|
|
14575
14583
|
output.log(`│${header}│`);
|
|
14576
14584
|
output.log("├" + "─".repeat(header.length + 2) + "┤");
|
|
14577
14585
|
checkpoints.reverse().forEach((cp, i) => {
|
|
14578
14586
|
const isLatest = i === 0;
|
|
14579
|
-
const marker = isLatest ?
|
|
14587
|
+
const marker = isLatest ? chalk17.green("✓ ") : " ";
|
|
14580
14588
|
const title = cp.title.length > 25 ? cp.title.slice(0, 22) + "..." : cp.title;
|
|
14581
14589
|
const created = new Date(cp.createdAt).toLocaleString("zh-CN", {
|
|
14582
14590
|
month: "2-digit",
|
|
@@ -14584,7 +14592,7 @@ var CheckpointsCommand = {
|
|
|
14584
14592
|
hour: "2-digit",
|
|
14585
14593
|
minute: "2-digit"
|
|
14586
14594
|
});
|
|
14587
|
-
output.log(`│${marker}${i + 1} ${title.padEnd(25)} │ ${cp.type.padEnd(5)} │ ${cp.messageCountBefore.toString().padStart(8)} │ ${
|
|
14595
|
+
output.log(`│${marker}${i + 1} ${title.padEnd(25)} │ ${cp.type.padEnd(5)} │ ${cp.messageCountBefore.toString().padStart(8)} │ ${chalk17.gray(created)}│`);
|
|
14588
14596
|
});
|
|
14589
14597
|
output.log("└" + "─".repeat(header.length + 2) + "┘");
|
|
14590
14598
|
}
|
|
@@ -14598,7 +14606,7 @@ var CheckpointsCommand = {
|
|
|
14598
14606
|
};
|
|
14599
14607
|
|
|
14600
14608
|
// src/commands/sessions/active.ts
|
|
14601
|
-
import
|
|
14609
|
+
import chalk18 from "chalk";
|
|
14602
14610
|
var ActiveCommand = {
|
|
14603
14611
|
command: "active",
|
|
14604
14612
|
aliases: ["current"],
|
|
@@ -14625,7 +14633,7 @@ var ActiveCommand = {
|
|
|
14625
14633
|
return;
|
|
14626
14634
|
}
|
|
14627
14635
|
if (!activeId) {
|
|
14628
|
-
output.log(
|
|
14636
|
+
output.log(chalk18.gray("No active session set"));
|
|
14629
14637
|
return;
|
|
14630
14638
|
}
|
|
14631
14639
|
const session = await sessionComponent.get(activeId);
|
|
@@ -14643,10 +14651,10 @@ var ActiveCommand = {
|
|
|
14643
14651
|
});
|
|
14644
14652
|
} else {
|
|
14645
14653
|
if (!session) {
|
|
14646
|
-
output.log(
|
|
14654
|
+
output.log(chalk18.gray("Active session not found: " + activeId));
|
|
14647
14655
|
return;
|
|
14648
14656
|
}
|
|
14649
|
-
output.log(
|
|
14657
|
+
output.log(chalk18.bold.green("┌─ Active Session ─────────────────────────────────┐"));
|
|
14650
14658
|
output.log(`│ ID: ${session.id}`);
|
|
14651
14659
|
output.log(`│ Title: ${session.title}`);
|
|
14652
14660
|
output.log(`│ Directory: ${session.directory}`);
|
|
@@ -14728,7 +14736,7 @@ var AddMessageCommand = {
|
|
|
14728
14736
|
};
|
|
14729
14737
|
|
|
14730
14738
|
// src/commands/sessions/mock.ts
|
|
14731
|
-
import
|
|
14739
|
+
import chalk19 from "chalk";
|
|
14732
14740
|
var MOCK_SEQUENCES = [
|
|
14733
14741
|
{
|
|
14734
14742
|
name: "文件操作流程",
|
|
@@ -14861,7 +14869,7 @@ var MockCommand = {
|
|
|
14861
14869
|
for (let seqIdx = 0;seqIdx < count; seqIdx++) {
|
|
14862
14870
|
const sequence = MOCK_SEQUENCES[seqIdx];
|
|
14863
14871
|
if (!a.json) {
|
|
14864
|
-
output.log(
|
|
14872
|
+
output.log(chalk19.bold(`
|
|
14865
14873
|
\uD83D\uDCDD Sequence ${seqIdx + 1}: ${sequence.name}`));
|
|
14866
14874
|
}
|
|
14867
14875
|
for (const msg of sequence.messages) {
|
|
@@ -14879,7 +14887,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14879
14887
|
if (assistantMsgId)
|
|
14880
14888
|
addedMessages.push(assistantMsgId);
|
|
14881
14889
|
if (!a.json) {
|
|
14882
|
-
output.log(
|
|
14890
|
+
output.log(chalk19.cyan(` [${addedMessages.length}] assistant: \uD83D\uDD27 Tool call`));
|
|
14883
14891
|
}
|
|
14884
14892
|
const toolMsgId = await sessionComponent.addMessage(a.sessionId, {
|
|
14885
14893
|
role: "tool",
|
|
@@ -14888,7 +14896,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14888
14896
|
if (toolMsgId)
|
|
14889
14897
|
addedMessages.push(toolMsgId);
|
|
14890
14898
|
if (!a.json) {
|
|
14891
|
-
output.log(
|
|
14899
|
+
output.log(chalk19.yellow(` [${addedMessages.length}] tool: ${msg.content.substring(0, 50)}...`));
|
|
14892
14900
|
}
|
|
14893
14901
|
} else {
|
|
14894
14902
|
const msgId = await sessionComponent.addMessage(a.sessionId, {
|
|
@@ -14898,7 +14906,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14898
14906
|
if (msgId)
|
|
14899
14907
|
addedMessages.push(msgId);
|
|
14900
14908
|
if (!a.json) {
|
|
14901
|
-
const roleColor = msg.role === "user" ?
|
|
14909
|
+
const roleColor = msg.role === "user" ? chalk19.green : msg.role === "assistant" ? chalk19.cyan : chalk19.gray;
|
|
14902
14910
|
output.log(roleColor(` [${addedMessages.length}] ${msg.role}: ${msg.content.substring(0, 50)}...`));
|
|
14903
14911
|
}
|
|
14904
14912
|
}
|
|
@@ -14914,14 +14922,14 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14914
14922
|
});
|
|
14915
14923
|
} else {
|
|
14916
14924
|
output.log(`
|
|
14917
|
-
` +
|
|
14925
|
+
` + chalk19.bold.green("✅ Mock data inserted successfully!"));
|
|
14918
14926
|
output.log(` Session: ${a.sessionId}`);
|
|
14919
14927
|
output.log(` Sequences: ${count}`);
|
|
14920
14928
|
output.log(` Messages: ${addedMessages.length}`);
|
|
14921
14929
|
output.log("");
|
|
14922
|
-
output.log(
|
|
14923
|
-
output.log(
|
|
14924
|
-
output.log(
|
|
14930
|
+
output.log(chalk19.gray(" Now run: "));
|
|
14931
|
+
output.log(chalk19.gray(` roy-agent sessions compact ${a.sessionId}`));
|
|
14932
|
+
output.log(chalk19.gray(" to trigger checkpoint generation"));
|
|
14925
14933
|
}
|
|
14926
14934
|
} finally {
|
|
14927
14935
|
await envService.dispose();
|
|
@@ -14930,7 +14938,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14930
14938
|
};
|
|
14931
14939
|
|
|
14932
14940
|
// src/commands/sessions/grep.ts
|
|
14933
|
-
import
|
|
14941
|
+
import chalk20 from "chalk";
|
|
14934
14942
|
var GrepCommand = {
|
|
14935
14943
|
command: "grep <query...>",
|
|
14936
14944
|
aliases: ["search"],
|
|
@@ -15010,7 +15018,7 @@ var GrepCommand = {
|
|
|
15010
15018
|
const results = await sessionComponent.searchMessages(searchOptions);
|
|
15011
15019
|
if (results.length === 0) {
|
|
15012
15020
|
if (!a.quiet) {
|
|
15013
|
-
output.log(
|
|
15021
|
+
output.log(chalk20.yellow(`No results found for: ${query}`));
|
|
15014
15022
|
}
|
|
15015
15023
|
return;
|
|
15016
15024
|
}
|
|
@@ -15037,7 +15045,7 @@ var GrepCommand = {
|
|
|
15037
15045
|
for (const result of results) {
|
|
15038
15046
|
for (const match of result.matches) {
|
|
15039
15047
|
const time = new Date(match.timestamp).toLocaleString("zh-CN");
|
|
15040
|
-
output.log(`${
|
|
15048
|
+
output.log(`${chalk20.gray(result.sessionId)} ${chalk20.blue(result.sessionTitle)} ${chalk20.gray(time)}`);
|
|
15041
15049
|
output.log(` ${match.content}`);
|
|
15042
15050
|
output.log("");
|
|
15043
15051
|
}
|
|
@@ -15049,40 +15057,40 @@ var GrepCommand = {
|
|
|
15049
15057
|
totalMatches += result.matches.length;
|
|
15050
15058
|
const time = new Date(result.updatedAt).toLocaleString("zh-CN");
|
|
15051
15059
|
const titleStr = `─ ${result.sessionTitle} (${result.sessionId})`;
|
|
15052
|
-
output.log(
|
|
15060
|
+
output.log(chalk20.bold(`
|
|
15053
15061
|
┌${titleStr}${"─".repeat(Math.max(0, 50 - titleStr.length))}┐`));
|
|
15054
|
-
output.log(`│ ${
|
|
15062
|
+
output.log(`│ ${chalk20.gray(`Updated: ${time} | ${result.messageCount} messages | ${result.matches.length} matches`)}${" ".repeat(Math.max(0, 50 - 60))}│`);
|
|
15055
15063
|
for (let i = 0;i < result.matches.length; i++) {
|
|
15056
15064
|
const match = result.matches[i];
|
|
15057
|
-
const roleColor = match.role === "user" ?
|
|
15065
|
+
const roleColor = match.role === "user" ? chalk20.blue : match.role === "assistant" ? chalk20.green : chalk20.gray;
|
|
15058
15066
|
const msgTime = new Date(match.timestamp).toLocaleTimeString("zh-CN", {
|
|
15059
15067
|
hour: "2-digit",
|
|
15060
15068
|
minute: "2-digit"
|
|
15061
15069
|
});
|
|
15062
|
-
output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${
|
|
15070
|
+
output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${chalk20.gray(msgTime)}`);
|
|
15063
15071
|
output.log("│");
|
|
15064
15072
|
const lines = match.content.split(`
|
|
15065
15073
|
`).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
15066
15074
|
const maxLines = 5;
|
|
15067
15075
|
const displayLines = lines.slice(0, maxLines);
|
|
15068
15076
|
if (displayLines.length === 0) {
|
|
15069
|
-
output.log("│ " +
|
|
15077
|
+
output.log("│ " + chalk20.gray("(empty content)"));
|
|
15070
15078
|
} else {
|
|
15071
15079
|
for (const line of displayLines) {
|
|
15072
15080
|
const truncated = line.length > 76 ? line.slice(0, 73) + "..." : line;
|
|
15073
|
-
output.log(`│ ${
|
|
15081
|
+
output.log(`│ ${chalk20.gray(truncated)}`);
|
|
15074
15082
|
}
|
|
15075
15083
|
}
|
|
15076
15084
|
if (lines.length > maxLines) {
|
|
15077
|
-
output.log("│ " +
|
|
15085
|
+
output.log("│ " + chalk20.gray(`... (${lines.length - maxLines} more lines)`));
|
|
15078
15086
|
}
|
|
15079
15087
|
output.log("│");
|
|
15080
15088
|
}
|
|
15081
15089
|
output.log(`└${"─".repeat(52)}┘`);
|
|
15082
15090
|
}
|
|
15083
15091
|
output.log(`
|
|
15084
|
-
${
|
|
15085
|
-
output.log(
|
|
15092
|
+
${chalk20.green("✓")} Found ${chalk20.bold(totalMatches.toString())} matches in ${chalk20.bold(results.length.toString())} sessions`);
|
|
15093
|
+
output.log(chalk20.gray(`Query: "${query}"`));
|
|
15086
15094
|
}
|
|
15087
15095
|
} catch (error) {
|
|
15088
15096
|
output.error(`Search failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -15121,7 +15129,7 @@ var SessionsCommand = {
|
|
|
15121
15129
|
};
|
|
15122
15130
|
|
|
15123
15131
|
// src/commands/tasks/list.ts
|
|
15124
|
-
import
|
|
15132
|
+
import chalk22 from "chalk";
|
|
15125
15133
|
|
|
15126
15134
|
// src/commands/tasks/_build-list-json.ts
|
|
15127
15135
|
function buildListTasksJson(tasks, total, args, extras) {
|
|
@@ -15151,7 +15159,7 @@ function buildListTasksJson(tasks, total, args, extras) {
|
|
|
15151
15159
|
}
|
|
15152
15160
|
|
|
15153
15161
|
// src/commands/tasks/task-graph.ts
|
|
15154
|
-
import
|
|
15162
|
+
import chalk21 from "chalk";
|
|
15155
15163
|
function buildTaskTree(tasks) {
|
|
15156
15164
|
const nodeById = new Map;
|
|
15157
15165
|
const byParent = new Map;
|
|
@@ -15234,9 +15242,9 @@ function renderTaskTree(roots, options = {}) {
|
|
|
15234
15242
|
}
|
|
15235
15243
|
const maxDepth = options.maxDepth !== undefined && options.maxDepth < 0 ? undefined : options.maxDepth;
|
|
15236
15244
|
const totalCount = countDeep(roots);
|
|
15237
|
-
const headerSuffix = options.rootId !== undefined ?
|
|
15245
|
+
const headerSuffix = options.rootId !== undefined ? chalk21.gray(` — subtree of #${options.rootId}`) : "";
|
|
15238
15246
|
const lines = [
|
|
15239
|
-
|
|
15247
|
+
chalk21.bold(`Task Tree (${totalCount} tasks, ${roots.length} roots)`) + headerSuffix,
|
|
15240
15248
|
""
|
|
15241
15249
|
];
|
|
15242
15250
|
for (let i = 0;i < roots.length; i++) {
|
|
@@ -15277,20 +15285,20 @@ function formatTaskLabel(task) {
|
|
|
15277
15285
|
const idStr = `#${task.id}`;
|
|
15278
15286
|
const typeLabel = task.type && task.type !== "normal" ? ` [${task.type}]` : "";
|
|
15279
15287
|
const progressLabel = task.progress > 0 ? ` (${task.progress}%)` : "";
|
|
15280
|
-
return `${idStr}${typeLabel} ${task.title} ${
|
|
15288
|
+
return `${idStr}${typeLabel} ${task.title} ${chalk21.gray("[" + task.status + "]")}${progressLabel}`;
|
|
15281
15289
|
}
|
|
15282
15290
|
function colorByStatus(status) {
|
|
15283
15291
|
switch (status) {
|
|
15284
15292
|
case "completed":
|
|
15285
|
-
return
|
|
15293
|
+
return chalk21.green;
|
|
15286
15294
|
case "active":
|
|
15287
|
-
return
|
|
15295
|
+
return chalk21.blue;
|
|
15288
15296
|
case "paused":
|
|
15289
|
-
return
|
|
15297
|
+
return chalk21.yellow;
|
|
15290
15298
|
case "cancelled":
|
|
15291
|
-
return
|
|
15299
|
+
return chalk21.strikethrough;
|
|
15292
15300
|
default:
|
|
15293
|
-
return
|
|
15301
|
+
return chalk21.gray;
|
|
15294
15302
|
}
|
|
15295
15303
|
}
|
|
15296
15304
|
|
|
@@ -15369,17 +15377,17 @@ var ListCommand2 = {
|
|
|
15369
15377
|
output.log(hint);
|
|
15370
15378
|
} else {
|
|
15371
15379
|
const header = [
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15380
|
+
chalk22.bold("#"),
|
|
15381
|
+
chalk22.bold("Title"),
|
|
15382
|
+
chalk22.bold("Status"),
|
|
15383
|
+
chalk22.bold("Priority"),
|
|
15384
|
+
chalk22.bold("Type"),
|
|
15385
|
+
chalk22.bold("Progress"),
|
|
15386
|
+
chalk22.bold("Parent")
|
|
15379
15387
|
].join(" │ ");
|
|
15380
15388
|
const rows = tasks.map((t, i) => {
|
|
15381
|
-
const statusColor = t.status === "completed" ?
|
|
15382
|
-
const priorityColor = t.priority === "high" ?
|
|
15389
|
+
const statusColor = t.status === "completed" ? chalk22.green : t.status === "active" ? chalk22.blue : t.status === "paused" ? chalk22.yellow : t.status === "cancelled" ? chalk22.strikethrough : chalk22.gray;
|
|
15390
|
+
const priorityColor = t.priority === "high" ? chalk22.red : t.priority === "medium" ? chalk22.yellow : chalk22.gray;
|
|
15383
15391
|
return [
|
|
15384
15392
|
(args.offset + i + 1).toString(),
|
|
15385
15393
|
t.title.length > 30 ? t.title.slice(0, 27) + "..." : t.title,
|
|
@@ -15387,11 +15395,11 @@ var ListCommand2 = {
|
|
|
15387
15395
|
priorityColor(t.priority),
|
|
15388
15396
|
t.type || "normal",
|
|
15389
15397
|
`${t.progress}%`,
|
|
15390
|
-
t.parent_task_id ? `#${t.parent_task_id}` :
|
|
15398
|
+
t.parent_task_id ? `#${t.parent_task_id}` : chalk22.gray("root")
|
|
15391
15399
|
].join(" │ ");
|
|
15392
15400
|
});
|
|
15393
|
-
const depthNote = args.depth !== undefined ?
|
|
15394
|
-
const archivedNote = args.includeArchived ?
|
|
15401
|
+
const depthNote = args.depth !== undefined ? chalk22.gray(` depth=${args.depth}`) : "";
|
|
15402
|
+
const archivedNote = args.includeArchived ? chalk22.gray(" include-archived") : "";
|
|
15395
15403
|
output.log([
|
|
15396
15404
|
`┌─ Tasks ${"─".repeat(55)}┐`,
|
|
15397
15405
|
`│${header}│`,
|
|
@@ -15399,7 +15407,7 @@ var ListCommand2 = {
|
|
|
15399
15407
|
...rows.map((r) => `│${r}│`),
|
|
15400
15408
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
15401
15409
|
"",
|
|
15402
|
-
|
|
15410
|
+
chalk22.gray(`Showing ${tasks.length} of ${total} tasks (offset=${args.offset}, limit=${args.limit})${depthNote}${archivedNote}`)
|
|
15403
15411
|
].join(`
|
|
15404
15412
|
`));
|
|
15405
15413
|
}
|
|
@@ -15413,7 +15421,7 @@ var ListCommand2 = {
|
|
|
15413
15421
|
};
|
|
15414
15422
|
|
|
15415
15423
|
// src/commands/tasks/get.ts
|
|
15416
|
-
import
|
|
15424
|
+
import chalk23 from "chalk";
|
|
15417
15425
|
var GetCommand2 = {
|
|
15418
15426
|
command: "get <id>",
|
|
15419
15427
|
aliases: ["show"],
|
|
@@ -15452,10 +15460,10 @@ var GetCommand2 = {
|
|
|
15452
15460
|
if (args.json) {
|
|
15453
15461
|
output.json(result);
|
|
15454
15462
|
} else {
|
|
15455
|
-
output.log(
|
|
15463
|
+
output.log(chalk23.bold(`
|
|
15456
15464
|
Task #${result.task.id}: ${result.task.title}
|
|
15457
15465
|
`));
|
|
15458
|
-
output.log(`Status: ${
|
|
15466
|
+
output.log(`Status: ${chalk23.blue(result.task.status)} | Priority: ${result.task.priority} | Type: ${result.task.type} | Progress: ${result.task.progress}%`);
|
|
15459
15467
|
output.log(`Created: ${result.task.createdAt} | Updated: ${result.task.updatedAt}`);
|
|
15460
15468
|
output.log(`Project Path: ${result.task.project_path}`);
|
|
15461
15469
|
output.log(`Context: ${result.task.context}`);
|
|
@@ -15463,18 +15471,18 @@ Task #${result.task.id}: ${result.task.title}
|
|
|
15463
15471
|
output.log(`
|
|
15464
15472
|
Current Status: ${result.task.current_status}`);
|
|
15465
15473
|
}
|
|
15466
|
-
output.log(
|
|
15474
|
+
output.log(chalk23.bold(`
|
|
15467
15475
|
Operations (${result.operations.length}):
|
|
15468
15476
|
`));
|
|
15469
15477
|
result.operations.forEach((op, i) => {
|
|
15470
|
-
const actionColor = op.milestoneType === "completed" ?
|
|
15478
|
+
const actionColor = op.milestoneType === "completed" ? chalk23.green : op.milestoneType === "milestone" ? chalk23.blue : op.milestoneType === "problem" ? chalk23.red : chalk23.gray;
|
|
15471
15479
|
output.log(` ${i + 1}. ` + actionColor(`[${op.milestoneType}]`) + ` ${op.milestoneTitle}`);
|
|
15472
15480
|
output.log(` Session: ${op.sessionId} | Time: ${op.timestamp}`);
|
|
15473
15481
|
if (op.milestoneDescription) {
|
|
15474
15482
|
output.log(` ${op.milestoneDescription}`);
|
|
15475
15483
|
}
|
|
15476
15484
|
if (op.processDescription) {
|
|
15477
|
-
output.log(
|
|
15485
|
+
output.log(chalk23.gray(` \uD83D\uDCCB 过程概要: ${op.processDescription}`));
|
|
15478
15486
|
}
|
|
15479
15487
|
});
|
|
15480
15488
|
}
|
|
@@ -15487,10 +15495,10 @@ Operations (${result.operations.length}):
|
|
|
15487
15495
|
if (args.json) {
|
|
15488
15496
|
output.json(task);
|
|
15489
15497
|
} else {
|
|
15490
|
-
output.log(
|
|
15498
|
+
output.log(chalk23.bold(`
|
|
15491
15499
|
Task #${task.id}: ${task.title}
|
|
15492
15500
|
`));
|
|
15493
|
-
output.log(`Status: ${
|
|
15501
|
+
output.log(`Status: ${chalk23.blue(task.status)} | Priority: ${task.priority} | Type: ${task.type} | Progress: ${task.progress}%`);
|
|
15494
15502
|
output.log(`Created: ${task.createdAt} | Updated: ${task.updatedAt}`);
|
|
15495
15503
|
output.log(`Project Path: ${task.project_path}`);
|
|
15496
15504
|
output.log(`Context: ${task.context}`);
|
|
@@ -15514,7 +15522,7 @@ Description: ${task.description}`);
|
|
|
15514
15522
|
};
|
|
15515
15523
|
|
|
15516
15524
|
// src/commands/tasks/create.ts
|
|
15517
|
-
import
|
|
15525
|
+
import chalk24 from "chalk";
|
|
15518
15526
|
var CreateCommand = {
|
|
15519
15527
|
command: "create <title>",
|
|
15520
15528
|
aliases: ["add", "new"],
|
|
@@ -15592,7 +15600,7 @@ var CreateCommand = {
|
|
|
15592
15600
|
if (args.json) {
|
|
15593
15601
|
output.json(task);
|
|
15594
15602
|
} else {
|
|
15595
|
-
output.log(
|
|
15603
|
+
output.log(chalk24.green(`
|
|
15596
15604
|
✓ Task created: #${task.id}`));
|
|
15597
15605
|
output.log(` Title: ${task.title}`);
|
|
15598
15606
|
output.log(` Status: ${task.status}`);
|
|
@@ -15610,7 +15618,7 @@ var CreateCommand = {
|
|
|
15610
15618
|
};
|
|
15611
15619
|
|
|
15612
15620
|
// src/commands/tasks/update.ts
|
|
15613
|
-
import
|
|
15621
|
+
import chalk25 from "chalk";
|
|
15614
15622
|
var UpdateCommand = {
|
|
15615
15623
|
command: "update <id>",
|
|
15616
15624
|
aliases: ["set"],
|
|
@@ -15670,7 +15678,7 @@ var UpdateCommand = {
|
|
|
15670
15678
|
if (args.json) {
|
|
15671
15679
|
output.json(task);
|
|
15672
15680
|
} else {
|
|
15673
|
-
output.log(
|
|
15681
|
+
output.log(chalk25.green(`
|
|
15674
15682
|
✓ Task updated: #${task.id}`));
|
|
15675
15683
|
output.log(` Title: ${task.title}`);
|
|
15676
15684
|
output.log(` Status: ${task.status}`);
|
|
@@ -15693,7 +15701,7 @@ var UpdateCommand = {
|
|
|
15693
15701
|
};
|
|
15694
15702
|
|
|
15695
15703
|
// src/commands/tasks/delete.ts
|
|
15696
|
-
import
|
|
15704
|
+
import chalk26 from "chalk";
|
|
15697
15705
|
var DeleteCommand2 = {
|
|
15698
15706
|
command: "delete <id>",
|
|
15699
15707
|
aliases: ["remove", "rm", "del"],
|
|
@@ -15729,16 +15737,16 @@ var DeleteCommand2 = {
|
|
|
15729
15737
|
process.exit(1);
|
|
15730
15738
|
}
|
|
15731
15739
|
if (!args.force) {
|
|
15732
|
-
output.log(
|
|
15733
|
-
output.log(
|
|
15734
|
-
output.log(
|
|
15735
|
-
output.log(
|
|
15740
|
+
output.log(chalk26.yellow(`Are you sure you want to delete task #${args.id}?`));
|
|
15741
|
+
output.log(chalk26.yellow(` Title: ${task.title}`));
|
|
15742
|
+
output.log(chalk26.yellow(` Status: ${task.status}`));
|
|
15743
|
+
output.log(chalk26.yellow(`
|
|
15736
15744
|
Use --force to skip this confirmation`));
|
|
15737
15745
|
process.exit(1);
|
|
15738
15746
|
}
|
|
15739
15747
|
const deleted = await taskComponent.deleteTask(args.id);
|
|
15740
15748
|
if (deleted) {
|
|
15741
|
-
output.log(
|
|
15749
|
+
output.log(chalk26.green(`
|
|
15742
15750
|
✓ Task deleted: #${args.id}`));
|
|
15743
15751
|
} else {
|
|
15744
15752
|
output.error(`Failed to delete task: ${args.id}`);
|
|
@@ -15754,7 +15762,7 @@ Use --force to skip this confirmation`));
|
|
|
15754
15762
|
};
|
|
15755
15763
|
|
|
15756
15764
|
// src/commands/tasks/complete.ts
|
|
15757
|
-
import
|
|
15765
|
+
import chalk27 from "chalk";
|
|
15758
15766
|
var CompleteCommand = {
|
|
15759
15767
|
command: "complete <id>",
|
|
15760
15768
|
aliases: ["done", "finish"],
|
|
@@ -15813,7 +15821,7 @@ var CompleteCommand = {
|
|
|
15813
15821
|
if (args.json) {
|
|
15814
15822
|
output.json(task);
|
|
15815
15823
|
} else {
|
|
15816
|
-
output.log(
|
|
15824
|
+
output.log(chalk27.green(`
|
|
15817
15825
|
✓ Task completed: #${task.id}`));
|
|
15818
15826
|
output.log(` Title: ${task.title}`);
|
|
15819
15827
|
output.log(` Progress: ${task.progress}%`);
|
|
@@ -15829,7 +15837,7 @@ var CompleteCommand = {
|
|
|
15829
15837
|
};
|
|
15830
15838
|
|
|
15831
15839
|
// src/commands/tasks/operations.ts
|
|
15832
|
-
import
|
|
15840
|
+
import chalk28 from "chalk";
|
|
15833
15841
|
var OperationsCommand = {
|
|
15834
15842
|
command: "operations <task-id>",
|
|
15835
15843
|
aliases: ["ops", "log"],
|
|
@@ -15879,26 +15887,26 @@ var OperationsCommand = {
|
|
|
15879
15887
|
operations
|
|
15880
15888
|
});
|
|
15881
15889
|
} else {
|
|
15882
|
-
output.log(
|
|
15890
|
+
output.log(chalk28.bold(`
|
|
15883
15891
|
Operations for Task #${task.id}: ${task.title}
|
|
15884
15892
|
`));
|
|
15885
15893
|
if (operations.length === 0) {
|
|
15886
|
-
output.log(
|
|
15894
|
+
output.log(chalk28.gray("No operations found."));
|
|
15887
15895
|
} else {
|
|
15888
15896
|
operations.forEach((op, i) => {
|
|
15889
|
-
const actionColor = op.milestoneType === "completed" ?
|
|
15890
|
-
output.log(`${
|
|
15891
|
-
output.log(` Session: ${
|
|
15897
|
+
const actionColor = op.milestoneType === "completed" ? chalk28.green : op.milestoneType === "milestone" ? chalk28.blue : op.milestoneType === "problem" ? chalk28.red : chalk28.gray;
|
|
15898
|
+
output.log(`${chalk28.bold(a.offset + i + 1)}. ` + actionColor(`[${op.milestoneType}]`) + ` ${op.milestoneTitle}`);
|
|
15899
|
+
output.log(` Session: ${chalk28.cyan(op.sessionId)} | Time: ${op.timestamp}`);
|
|
15892
15900
|
if (op.milestoneDescription) {
|
|
15893
15901
|
output.log(` ${op.milestoneDescription}`);
|
|
15894
15902
|
}
|
|
15895
15903
|
if (op.processDescription) {
|
|
15896
|
-
output.log(
|
|
15904
|
+
output.log(chalk28.gray(` \uD83D\uDCCB 过程概要: ${op.processDescription}`));
|
|
15897
15905
|
}
|
|
15898
15906
|
output.log("");
|
|
15899
15907
|
});
|
|
15900
15908
|
}
|
|
15901
|
-
output.log(
|
|
15909
|
+
output.log(chalk28.gray(`Total: ${operations.length} operations`));
|
|
15902
15910
|
}
|
|
15903
15911
|
} catch (error) {
|
|
15904
15912
|
output.error(`Failed to list operations: ${error}`);
|
|
@@ -15910,7 +15918,7 @@ Operations for Task #${task.id}: ${task.title}
|
|
|
15910
15918
|
};
|
|
15911
15919
|
|
|
15912
15920
|
// src/commands/tasks/tree.ts
|
|
15913
|
-
import
|
|
15921
|
+
import chalk29 from "chalk";
|
|
15914
15922
|
var TreeCommand = {
|
|
15915
15923
|
command: "tree",
|
|
15916
15924
|
describe: "以树形结构展示所有任务(基于 parent_task_id)",
|
|
@@ -16000,7 +16008,7 @@ var TreeCommand = {
|
|
|
16000
16008
|
return;
|
|
16001
16009
|
}
|
|
16002
16010
|
if (tree.length === 0) {
|
|
16003
|
-
output.log(
|
|
16011
|
+
output.log(chalk29.gray("No tasks to display."));
|
|
16004
16012
|
return;
|
|
16005
16013
|
}
|
|
16006
16014
|
output.log(renderTaskTree(tree, { maxDepth: args.depth, rootId: args.rootId }));
|
|
@@ -16014,7 +16022,7 @@ var TreeCommand = {
|
|
|
16014
16022
|
};
|
|
16015
16023
|
|
|
16016
16024
|
// src/commands/tasks/search.ts
|
|
16017
|
-
import
|
|
16025
|
+
import chalk30 from "chalk";
|
|
16018
16026
|
var SearchCommand = {
|
|
16019
16027
|
command: "search <keywords..>",
|
|
16020
16028
|
aliases: ["find", "grep"],
|
|
@@ -16087,26 +16095,26 @@ var SearchCommand = {
|
|
|
16087
16095
|
output.log(hint);
|
|
16088
16096
|
} else {
|
|
16089
16097
|
const keywordStr = args.keywords.join(" ");
|
|
16090
|
-
output.log(
|
|
16098
|
+
output.log(chalk30.bold(`
|
|
16091
16099
|
\uD83D\uDD0D Search: "${keywordStr}" — ${total} results
|
|
16092
16100
|
`));
|
|
16093
16101
|
if (tasks.length === 0) {
|
|
16094
|
-
output.log(
|
|
16102
|
+
output.log(chalk30.gray(" No matching tasks found."));
|
|
16095
16103
|
return;
|
|
16096
16104
|
}
|
|
16097
16105
|
for (const t of tasks) {
|
|
16098
|
-
const statusColor = t.status === "completed" ?
|
|
16099
|
-
const pid = t.parent_task_id ?
|
|
16106
|
+
const statusColor = t.status === "completed" ? chalk30.green : t.status === "active" ? chalk30.blue : t.status === "paused" ? chalk30.yellow : t.status === "cancelled" ? chalk30.strikethrough : t.status === "archived" ? chalk30.gray : chalk30.gray;
|
|
16107
|
+
const pid = t.parent_task_id ? chalk30.gray(` (#${t.parent_task_id})`) : "";
|
|
16100
16108
|
output.log(` #${t.id} ${statusColor("[" + t.status + "]")} ${t.title}${pid}`);
|
|
16101
16109
|
if (t.current_status) {
|
|
16102
|
-
output.log(` ${
|
|
16110
|
+
output.log(` ${chalk30.gray(t.current_status.slice(0, 80))}`);
|
|
16103
16111
|
}
|
|
16104
16112
|
}
|
|
16105
16113
|
if (total > tasks.length) {
|
|
16106
|
-
output.log(
|
|
16114
|
+
output.log(chalk30.gray(`
|
|
16107
16115
|
... and ${total - tasks.length} more. Use --offset and --limit to paginate.`));
|
|
16108
16116
|
}
|
|
16109
|
-
output.log(
|
|
16117
|
+
output.log(chalk30.gray(` Page: ${Math.floor((args.offset || 0) / (args.limit || 20)) + 1}/${Math.ceil(total / (args.limit || 20))}`));
|
|
16110
16118
|
}
|
|
16111
16119
|
} catch (error) {
|
|
16112
16120
|
output.error(`Failed to search tasks: ${error}`);
|
|
@@ -16366,7 +16374,7 @@ var TasksCommand = {
|
|
|
16366
16374
|
};
|
|
16367
16375
|
|
|
16368
16376
|
// src/commands/skills/list.ts
|
|
16369
|
-
import
|
|
16377
|
+
import chalk31 from "chalk";
|
|
16370
16378
|
var ListCommand3 = {
|
|
16371
16379
|
command: "list",
|
|
16372
16380
|
aliases: ["ls"],
|
|
@@ -16434,26 +16442,26 @@ var ListCommand3 = {
|
|
|
16434
16442
|
output.log(hint);
|
|
16435
16443
|
} else {
|
|
16436
16444
|
const header = [
|
|
16437
|
-
|
|
16438
|
-
|
|
16439
|
-
|
|
16445
|
+
chalk31.bold("Name"),
|
|
16446
|
+
chalk31.bold("Description"),
|
|
16447
|
+
chalk31.bold("Source")
|
|
16440
16448
|
].join(" | ");
|
|
16441
16449
|
const sourceColor = (source) => {
|
|
16442
16450
|
switch (source) {
|
|
16443
16451
|
case "project":
|
|
16444
|
-
return
|
|
16452
|
+
return chalk31.green;
|
|
16445
16453
|
case "user":
|
|
16446
|
-
return
|
|
16454
|
+
return chalk31.blue;
|
|
16447
16455
|
case "built-in":
|
|
16448
|
-
return
|
|
16456
|
+
return chalk31.gray;
|
|
16449
16457
|
default:
|
|
16450
|
-
return
|
|
16458
|
+
return chalk31.white;
|
|
16451
16459
|
}
|
|
16452
16460
|
};
|
|
16453
16461
|
const rows = skills.map((s) => {
|
|
16454
16462
|
const desc2 = s.description.length > 50 ? s.description.slice(0, 47) + "..." : s.description;
|
|
16455
16463
|
return [
|
|
16456
|
-
|
|
16464
|
+
chalk31.cyan(s.name),
|
|
16457
16465
|
desc2,
|
|
16458
16466
|
sourceColor(s.source)(`[${s.source}]`)
|
|
16459
16467
|
].join(" | ");
|
|
@@ -16486,7 +16494,7 @@ var ListCommand3 = {
|
|
|
16486
16494
|
};
|
|
16487
16495
|
|
|
16488
16496
|
// src/commands/skills/get.ts
|
|
16489
|
-
import
|
|
16497
|
+
import chalk32 from "chalk";
|
|
16490
16498
|
var GetCommand3 = {
|
|
16491
16499
|
command: "get <name>",
|
|
16492
16500
|
describe: "获取指定技能内容",
|
|
@@ -16530,13 +16538,13 @@ var GetCommand3 = {
|
|
|
16530
16538
|
content: skill.content
|
|
16531
16539
|
});
|
|
16532
16540
|
} else {
|
|
16533
|
-
output.log(
|
|
16541
|
+
output.log(chalk32.bold.cyan(`# ${skill.name}`));
|
|
16534
16542
|
output.log("");
|
|
16535
|
-
output.log(`${
|
|
16536
|
-
output.log(`${
|
|
16537
|
-
output.log(`${
|
|
16543
|
+
output.log(`${chalk32.gray("Description:")} ${skill.description}`);
|
|
16544
|
+
output.log(`${chalk32.gray("Source:")} ${skill.source}`);
|
|
16545
|
+
output.log(`${chalk32.gray("File:")} ${skill.filePath}`);
|
|
16538
16546
|
output.log("");
|
|
16539
|
-
output.log(
|
|
16547
|
+
output.log(chalk32.bold("--- Content ---"));
|
|
16540
16548
|
output.log("");
|
|
16541
16549
|
output.log(skill.content);
|
|
16542
16550
|
}
|
|
@@ -16550,7 +16558,7 @@ var GetCommand3 = {
|
|
|
16550
16558
|
};
|
|
16551
16559
|
|
|
16552
16560
|
// src/commands/skills/search.ts
|
|
16553
|
-
import
|
|
16561
|
+
import chalk33 from "chalk";
|
|
16554
16562
|
var SearchCommand2 = {
|
|
16555
16563
|
command: "search <term>",
|
|
16556
16564
|
aliases: ["find"],
|
|
@@ -16589,7 +16597,7 @@ var SearchCommand2 = {
|
|
|
16589
16597
|
const term = args.term.toLowerCase();
|
|
16590
16598
|
const results = allSkills.filter((s) => s.name.toLowerCase().includes(term) || s.description.toLowerCase().includes(term));
|
|
16591
16599
|
if (results.length === 0) {
|
|
16592
|
-
output.log(
|
|
16600
|
+
output.log(chalk33.yellow(`No skills found matching: ${args.term}`));
|
|
16593
16601
|
return;
|
|
16594
16602
|
}
|
|
16595
16603
|
if (args.json) {
|
|
@@ -16606,19 +16614,19 @@ var SearchCommand2 = {
|
|
|
16606
16614
|
} else if (args.quiet) {
|
|
16607
16615
|
results.forEach((s) => output.log(s.name));
|
|
16608
16616
|
} else {
|
|
16609
|
-
output.log(
|
|
16617
|
+
output.log(chalk33.bold(`Search results for "${args.term}":`));
|
|
16610
16618
|
output.log("");
|
|
16611
16619
|
const header = [
|
|
16612
|
-
|
|
16613
|
-
|
|
16614
|
-
|
|
16620
|
+
chalk33.bold("Name"),
|
|
16621
|
+
chalk33.bold("Description"),
|
|
16622
|
+
chalk33.bold("Match")
|
|
16615
16623
|
].join(" | ");
|
|
16616
16624
|
const rows = results.map((s) => {
|
|
16617
16625
|
const matchedIn = s.name.toLowerCase().includes(term) ? "name" : "description";
|
|
16618
|
-
const matchColor = matchedIn === "name" ?
|
|
16626
|
+
const matchColor = matchedIn === "name" ? chalk33.green : chalk33.blue;
|
|
16619
16627
|
const desc2 = s.description.length > 40 ? s.description.slice(0, 37) + "..." : s.description;
|
|
16620
16628
|
return [
|
|
16621
|
-
|
|
16629
|
+
chalk33.cyan(s.name),
|
|
16622
16630
|
desc2,
|
|
16623
16631
|
matchColor(`[${matchedIn}]`)
|
|
16624
16632
|
].join(" | ");
|
|
@@ -16630,7 +16638,7 @@ var SearchCommand2 = {
|
|
|
16630
16638
|
...rows.map((r) => `│${r}│`),
|
|
16631
16639
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
16632
16640
|
"",
|
|
16633
|
-
|
|
16641
|
+
chalk33.gray(`${results.length} matching skill(s) found.`)
|
|
16634
16642
|
].join(`
|
|
16635
16643
|
`));
|
|
16636
16644
|
}
|
|
@@ -16644,7 +16652,7 @@ var SearchCommand2 = {
|
|
|
16644
16652
|
};
|
|
16645
16653
|
|
|
16646
16654
|
// src/commands/skills/reload.ts
|
|
16647
|
-
import
|
|
16655
|
+
import chalk34 from "chalk";
|
|
16648
16656
|
var ReloadCommand = {
|
|
16649
16657
|
command: "reload",
|
|
16650
16658
|
describe: "重新扫描并更新 SkillTool",
|
|
@@ -16667,10 +16675,10 @@ var ReloadCommand = {
|
|
|
16667
16675
|
output.error("SkillComponent not available");
|
|
16668
16676
|
process.exit(1);
|
|
16669
16677
|
}
|
|
16670
|
-
output.log(
|
|
16678
|
+
output.log(chalk34.blue("Reloading skills..."));
|
|
16671
16679
|
await skillComponent.reload();
|
|
16672
16680
|
const skills = skillComponent.getSkillList();
|
|
16673
|
-
output.log(
|
|
16681
|
+
output.log(chalk34.green(`Successfully reloaded ${skills.length} skills`));
|
|
16674
16682
|
} catch (error) {
|
|
16675
16683
|
output.error(`Failed to reload skills: ${error}`);
|
|
16676
16684
|
process.exit(1);
|
|
@@ -16681,7 +16689,7 @@ var ReloadCommand = {
|
|
|
16681
16689
|
};
|
|
16682
16690
|
|
|
16683
16691
|
// src/commands/skills/show-config.ts
|
|
16684
|
-
import
|
|
16692
|
+
import chalk35 from "chalk";
|
|
16685
16693
|
var ShowConfigCommand = {
|
|
16686
16694
|
command: "show-config",
|
|
16687
16695
|
aliases: ["config"],
|
|
@@ -16706,38 +16714,38 @@ var ShowConfigCommand = {
|
|
|
16706
16714
|
process.exit(1);
|
|
16707
16715
|
}
|
|
16708
16716
|
const defaultConfig = skillComponent.getConfig?.();
|
|
16709
|
-
output.log(
|
|
16717
|
+
output.log(chalk35.bold.cyan(`# Skills Configuration
|
|
16710
16718
|
`));
|
|
16711
|
-
output.log(
|
|
16719
|
+
output.log(chalk35.bold(`## Scan Paths
|
|
16712
16720
|
`));
|
|
16713
16721
|
const paths = [
|
|
16714
16722
|
{ type: "user", desc: "用户路径", path: "~/.config/roy-agent/skills/" },
|
|
16715
16723
|
{ type: "project", desc: "项目路径", path: ".roy/skills/" }
|
|
16716
16724
|
];
|
|
16717
16725
|
for (const p of paths) {
|
|
16718
|
-
const typeColor = p.type === "project" ?
|
|
16719
|
-
output.log(` ${typeColor("[ " + p.type + " ]")} ${
|
|
16720
|
-
output.log(` ${
|
|
16726
|
+
const typeColor = p.type === "project" ? chalk35.green : chalk35.blue;
|
|
16727
|
+
output.log(` ${typeColor("[ " + p.type + " ]")} ${chalk35.gray(p.desc)}`);
|
|
16728
|
+
output.log(` ${chalk35.cyan(p.path)}
|
|
16721
16729
|
`);
|
|
16722
16730
|
}
|
|
16723
|
-
output.log(
|
|
16731
|
+
output.log(chalk35.bold(`## Scan Rules
|
|
16724
16732
|
`));
|
|
16725
|
-
output.log(` ${
|
|
16726
|
-
output.log(` ${
|
|
16727
|
-
output.log(` ${
|
|
16733
|
+
output.log(` ${chalk35.gray("Pattern:")} ${chalk35.cyan("**/SKILL.md")}`);
|
|
16734
|
+
output.log(` ${chalk35.gray("Recursive:")} ${chalk35.green("true")}`);
|
|
16735
|
+
output.log(` ${chalk35.gray("Ignore:")} ${chalk35.cyan("**/node_modules/**")}
|
|
16728
16736
|
`);
|
|
16729
|
-
output.log(
|
|
16737
|
+
output.log(chalk35.bold(`## Priority (High to Low)
|
|
16730
16738
|
`));
|
|
16731
|
-
output.log(` ${
|
|
16732
|
-
output.log(` ${
|
|
16733
|
-
output.log(` ${
|
|
16739
|
+
output.log(` ${chalk35.green("1. project")} - 项目路径(最高优先级)`);
|
|
16740
|
+
output.log(` ${chalk35.blue("2. user")} - 用户路径`);
|
|
16741
|
+
output.log(` ${chalk35.gray("3. built-in")} - 内置路径(预留)
|
|
16734
16742
|
`);
|
|
16735
|
-
output.log(
|
|
16743
|
+
output.log(chalk35.bold(`## Usage
|
|
16736
16744
|
`));
|
|
16737
|
-
output.log(` ${
|
|
16738
|
-
output.log(` ${
|
|
16739
|
-
output.log(` ${
|
|
16740
|
-
output.log(` ${
|
|
16745
|
+
output.log(` ${chalk35.cyan("roy-agent skills list")} ${chalk35.gray("- 列出所有技能")}`);
|
|
16746
|
+
output.log(` ${chalk35.cyan("roy-agent skills get <name>")} ${chalk35.gray("- 获取技能内容")}`);
|
|
16747
|
+
output.log(` ${chalk35.cyan("roy-agent skills search <term>")} ${chalk35.gray("- 搜索技能")}`);
|
|
16748
|
+
output.log(` ${chalk35.cyan("roy-agent skills reload")} ${chalk35.gray("- 重新扫描技能")}`);
|
|
16741
16749
|
} catch (error) {
|
|
16742
16750
|
output.error(`Failed to show config: ${error}`);
|
|
16743
16751
|
process.exit(1);
|
|
@@ -16758,7 +16766,7 @@ var SkillsCommand = {
|
|
|
16758
16766
|
};
|
|
16759
16767
|
|
|
16760
16768
|
// src/commands/agents/list.ts
|
|
16761
|
-
import
|
|
16769
|
+
import chalk36 from "chalk";
|
|
16762
16770
|
var ListCommand4 = {
|
|
16763
16771
|
command: "list",
|
|
16764
16772
|
aliases: ["ls"],
|
|
@@ -16845,27 +16853,27 @@ var ListCommand4 = {
|
|
|
16845
16853
|
output.log(hint);
|
|
16846
16854
|
} else {
|
|
16847
16855
|
const header = [
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
|
|
16853
|
-
|
|
16856
|
+
chalk36.bold("Name"),
|
|
16857
|
+
chalk36.bold("Type"),
|
|
16858
|
+
chalk36.bold("Source"),
|
|
16859
|
+
chalk36.bold("Model"),
|
|
16860
|
+
chalk36.bold("Workflow"),
|
|
16861
|
+
chalk36.bold("Description")
|
|
16854
16862
|
].join(" | ");
|
|
16855
16863
|
const typeColor = (type) => {
|
|
16856
16864
|
if (type === "primary")
|
|
16857
|
-
return
|
|
16865
|
+
return chalk36.yellow;
|
|
16858
16866
|
if (type === "workflow")
|
|
16859
|
-
return
|
|
16860
|
-
return
|
|
16867
|
+
return chalk36.magenta;
|
|
16868
|
+
return chalk36.blue;
|
|
16861
16869
|
};
|
|
16862
16870
|
const rows = pagedAgents.map((a) => {
|
|
16863
16871
|
const desc2 = (a.description || "").length > 40 ? (a.description || "").slice(0, 37) + "..." : a.description || "-";
|
|
16864
|
-
const workflowDisplay = a.type === "workflow" && a.workflow ?
|
|
16865
|
-
const modelDisplay = a.model ?
|
|
16866
|
-
const sourceDisplay = builtInSubAgentNames.has(a.name) ?
|
|
16872
|
+
const workflowDisplay = a.type === "workflow" && a.workflow ? chalk36.cyan(a.workflow.length > 30 ? a.workflow.slice(0, 27) + "..." : a.workflow) : chalk36.gray("-");
|
|
16873
|
+
const modelDisplay = a.model ? chalk36.yellow(a.model.length > 20 ? a.model.slice(0, 17) + "..." : a.model) : chalk36.gray("-");
|
|
16874
|
+
const sourceDisplay = builtInSubAgentNames.has(a.name) ? chalk36.green("built-in") : chalk36.gray("user");
|
|
16867
16875
|
return [
|
|
16868
|
-
|
|
16876
|
+
chalk36.cyan(a.name),
|
|
16869
16877
|
typeColor(a.type)(a.type),
|
|
16870
16878
|
sourceDisplay,
|
|
16871
16879
|
modelDisplay,
|
|
@@ -16874,9 +16882,9 @@ var ListCommand4 = {
|
|
|
16874
16882
|
].join(" | ");
|
|
16875
16883
|
});
|
|
16876
16884
|
if (rows.length === 0) {
|
|
16877
|
-
output.log(
|
|
16885
|
+
output.log(chalk36.yellow("No agents found."));
|
|
16878
16886
|
output.log("");
|
|
16879
|
-
output.log(
|
|
16887
|
+
output.log(chalk36.gray("Tip: Create agent configs in ~/.local/share/roy-agent/agents/"));
|
|
16880
16888
|
} else {
|
|
16881
16889
|
output.log([
|
|
16882
16890
|
`┌─ Agents ${"─".repeat(50)}┐`,
|
|
@@ -16907,7 +16915,7 @@ var ListCommand4 = {
|
|
|
16907
16915
|
};
|
|
16908
16916
|
|
|
16909
16917
|
// src/commands/agents/get.ts
|
|
16910
|
-
import
|
|
16918
|
+
import chalk37 from "chalk";
|
|
16911
16919
|
var GetCommand4 = {
|
|
16912
16920
|
command: "get <name>",
|
|
16913
16921
|
describe: "获取指定 agent 的详细信息",
|
|
@@ -16966,69 +16974,69 @@ var GetCommand4 = {
|
|
|
16966
16974
|
filterHistory: agent.filterHistory
|
|
16967
16975
|
});
|
|
16968
16976
|
} else {
|
|
16969
|
-
output.log(
|
|
16977
|
+
output.log(chalk37.bold.cyan(`# Agent: ${agent.name}`));
|
|
16970
16978
|
output.log("");
|
|
16971
|
-
output.log(
|
|
16972
|
-
output.log(` ${
|
|
16973
|
-
output.log(` ${
|
|
16979
|
+
output.log(chalk37.bold("Basic Info:"));
|
|
16980
|
+
output.log(` ${chalk37.cyan("name:")} ${agent.name}`);
|
|
16981
|
+
output.log(` ${chalk37.cyan("type:")} ${agent.type}`);
|
|
16974
16982
|
if (agent.description) {
|
|
16975
|
-
output.log(` ${
|
|
16983
|
+
output.log(` ${chalk37.cyan("description:")} ${agent.description}`);
|
|
16976
16984
|
}
|
|
16977
16985
|
output.log("");
|
|
16978
16986
|
if (agent.type === "workflow") {
|
|
16979
|
-
output.log(
|
|
16987
|
+
output.log(chalk37.bold("Workflow:"));
|
|
16980
16988
|
if (agent.workflow) {
|
|
16981
|
-
output.log(` ${
|
|
16982
|
-
output.log(` ${
|
|
16989
|
+
output.log(` ${chalk37.cyan("workflow:")} ${agent.workflow}`);
|
|
16990
|
+
output.log(` ${chalk37.gray("→")} ${chalk37.gray(`roy-agent workflow run ${agent.workflow} --input '{"query":"..."}'`)}`);
|
|
16983
16991
|
} else {
|
|
16984
|
-
output.log(` ${
|
|
16992
|
+
output.log(` ${chalk37.gray("(no workflow configured)")}`);
|
|
16985
16993
|
}
|
|
16986
16994
|
output.log("");
|
|
16987
16995
|
}
|
|
16988
|
-
output.log(
|
|
16996
|
+
output.log(chalk37.bold("System Prompt:"));
|
|
16989
16997
|
if (agent.systemPromptRef) {
|
|
16990
|
-
output.log(` ${
|
|
16998
|
+
output.log(` ${chalk37.green("[ref]")} ${chalk37.cyan("systemPromptRef:")} ${agent.systemPromptRef}`);
|
|
16991
16999
|
}
|
|
16992
17000
|
if (agent.systemPrompt && !agent.systemPromptRef) {
|
|
16993
17001
|
const promptPreview = agent.systemPrompt.length > 100 ? agent.systemPrompt.slice(0, 97) + "..." : agent.systemPrompt;
|
|
16994
|
-
output.log(` ${
|
|
16995
|
-
output.log(` ${
|
|
17002
|
+
output.log(` ${chalk37.gray("[inline]")}`);
|
|
17003
|
+
output.log(` ${chalk37.gray(promptPreview.split(`
|
|
16996
17004
|
`).join(`
|
|
16997
17005
|
`))}`);
|
|
16998
17006
|
}
|
|
16999
17007
|
if (resolvedSystemPrompt) {
|
|
17000
17008
|
const resolvedPreview = resolvedSystemPrompt.length > 200 ? resolvedSystemPrompt.slice(0, 197) + "..." : resolvedSystemPrompt;
|
|
17001
|
-
output.log(` ${
|
|
17002
|
-
output.log(` ${
|
|
17009
|
+
output.log(` ${chalk37.green("[resolved]")}`);
|
|
17010
|
+
output.log(` ${chalk37.gray(resolvedPreview.split(`
|
|
17003
17011
|
`).join(`
|
|
17004
17012
|
`))}`);
|
|
17005
17013
|
}
|
|
17006
17014
|
if (!agent.systemPromptRef && !agent.systemPrompt && !resolvedSystemPrompt) {
|
|
17007
|
-
output.log(` ${
|
|
17015
|
+
output.log(` ${chalk37.gray("(none)")}`);
|
|
17008
17016
|
}
|
|
17009
17017
|
output.log("");
|
|
17010
17018
|
const hasOptions = agent.model || agent.maxIterations || agent.toolTimeout;
|
|
17011
17019
|
if (hasOptions) {
|
|
17012
|
-
output.log(
|
|
17020
|
+
output.log(chalk37.bold("Options:"));
|
|
17013
17021
|
if (agent.model) {
|
|
17014
|
-
output.log(` ${
|
|
17022
|
+
output.log(` ${chalk37.cyan("model:")} ${agent.model}`);
|
|
17015
17023
|
}
|
|
17016
17024
|
if (agent.maxIterations) {
|
|
17017
|
-
output.log(` ${
|
|
17025
|
+
output.log(` ${chalk37.cyan("maxIterations:")} ${agent.maxIterations}`);
|
|
17018
17026
|
}
|
|
17019
17027
|
if (agent.toolTimeout) {
|
|
17020
|
-
output.log(` ${
|
|
17028
|
+
output.log(` ${chalk37.cyan("toolTimeout:")} ${agent.toolTimeout}ms`);
|
|
17021
17029
|
}
|
|
17022
17030
|
output.log("");
|
|
17023
17031
|
}
|
|
17024
17032
|
const hasTools = agent.allowedTools?.length || agent.deniedTools?.length;
|
|
17025
17033
|
if (hasTools) {
|
|
17026
|
-
output.log(
|
|
17034
|
+
output.log(chalk37.bold("Tool Permissions:"));
|
|
17027
17035
|
if (agent.allowedTools?.length) {
|
|
17028
|
-
output.log(` ${
|
|
17036
|
+
output.log(` ${chalk37.green("allowed:")} ${agent.allowedTools.join(", ")}`);
|
|
17029
17037
|
}
|
|
17030
17038
|
if (agent.deniedTools?.length) {
|
|
17031
|
-
output.log(` ${
|
|
17039
|
+
output.log(` ${chalk37.red("denied:")} ${agent.deniedTools.join(", ")}`);
|
|
17032
17040
|
}
|
|
17033
17041
|
output.log("");
|
|
17034
17042
|
}
|
|
@@ -17043,7 +17051,7 @@ var GetCommand4 = {
|
|
|
17043
17051
|
};
|
|
17044
17052
|
|
|
17045
17053
|
// src/commands/agents/add.ts
|
|
17046
|
-
import
|
|
17054
|
+
import chalk38 from "chalk";
|
|
17047
17055
|
function parseToolList(value) {
|
|
17048
17056
|
if (!value?.trim()) {
|
|
17049
17057
|
return;
|
|
@@ -17135,8 +17143,8 @@ var AddCommand = {
|
|
|
17135
17143
|
if (args.json) {
|
|
17136
17144
|
output.json({ agent, filePath });
|
|
17137
17145
|
} else {
|
|
17138
|
-
output.log(
|
|
17139
|
-
output.log(
|
|
17146
|
+
output.log(chalk38.green(`✓ Agent '${args.name}' created`));
|
|
17147
|
+
output.log(chalk38.gray(` ${filePath}`));
|
|
17140
17148
|
}
|
|
17141
17149
|
} catch (error) {
|
|
17142
17150
|
output.error(`Failed to add agent: ${error}`);
|
|
@@ -17148,7 +17156,7 @@ var AddCommand = {
|
|
|
17148
17156
|
};
|
|
17149
17157
|
|
|
17150
17158
|
// src/commands/agents/delete.ts
|
|
17151
|
-
import
|
|
17159
|
+
import chalk39 from "chalk";
|
|
17152
17160
|
var DeleteCommand3 = {
|
|
17153
17161
|
command: "delete <name>",
|
|
17154
17162
|
describe: "删除 agent 配置文件",
|
|
@@ -17190,7 +17198,7 @@ var DeleteCommand3 = {
|
|
|
17190
17198
|
}
|
|
17191
17199
|
const filePath = registry.getAgentFilePath(args.name);
|
|
17192
17200
|
if (!args.yes) {
|
|
17193
|
-
output.log(
|
|
17201
|
+
output.log(chalk39.yellow(`Delete agent '${args.name}'? This removes ${filePath} (use --yes to skip confirmation)`));
|
|
17194
17202
|
process.exit(1);
|
|
17195
17203
|
}
|
|
17196
17204
|
const deleted = await registry.deleteAgent(args.name);
|
|
@@ -17201,7 +17209,7 @@ var DeleteCommand3 = {
|
|
|
17201
17209
|
if (args.json) {
|
|
17202
17210
|
output.json({ deleted: true, name: args.name, filePath });
|
|
17203
17211
|
} else {
|
|
17204
|
-
output.log(
|
|
17212
|
+
output.log(chalk39.green(`✓ Agent '${args.name}' deleted`));
|
|
17205
17213
|
}
|
|
17206
17214
|
} catch (error) {
|
|
17207
17215
|
output.error(`Failed to delete agent: ${error}`);
|
|
@@ -17213,7 +17221,7 @@ var DeleteCommand3 = {
|
|
|
17213
17221
|
};
|
|
17214
17222
|
|
|
17215
17223
|
// src/commands/agents/config-dir.ts
|
|
17216
|
-
import
|
|
17224
|
+
import chalk40 from "chalk";
|
|
17217
17225
|
var ConfigDirCommand = {
|
|
17218
17226
|
command: "config-dir",
|
|
17219
17227
|
describe: "显示 agent 配置目录路径",
|
|
@@ -17244,8 +17252,8 @@ var ConfigDirCommand = {
|
|
|
17244
17252
|
if (args.json) {
|
|
17245
17253
|
output.json({ configDir, exists });
|
|
17246
17254
|
} else {
|
|
17247
|
-
output.log(`${
|
|
17248
|
-
output.log(`${
|
|
17255
|
+
output.log(`${chalk40.cyan("Agent Config Directory:")} ${configDir}`);
|
|
17256
|
+
output.log(`${chalk40.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
17249
17257
|
}
|
|
17250
17258
|
} catch (error) {
|
|
17251
17259
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -17268,7 +17276,7 @@ var AgentsCommand = {
|
|
|
17268
17276
|
};
|
|
17269
17277
|
|
|
17270
17278
|
// src/commands/prompt/list.ts
|
|
17271
|
-
import
|
|
17279
|
+
import chalk41 from "chalk";
|
|
17272
17280
|
var ListCommand5 = {
|
|
17273
17281
|
command: "list",
|
|
17274
17282
|
aliases: ["ls"],
|
|
@@ -17337,17 +17345,17 @@ var ListCommand5 = {
|
|
|
17337
17345
|
output.log(hint);
|
|
17338
17346
|
} else {
|
|
17339
17347
|
const header = [
|
|
17340
|
-
|
|
17341
|
-
|
|
17348
|
+
chalk41.bold("Name"),
|
|
17349
|
+
chalk41.bold("Source")
|
|
17342
17350
|
].join(" | ");
|
|
17343
17351
|
const rows = prompts.map((p) => {
|
|
17344
17352
|
return [
|
|
17345
|
-
|
|
17346
|
-
|
|
17353
|
+
chalk41.cyan(p.name),
|
|
17354
|
+
chalk41.gray(`[${p.source}]`)
|
|
17347
17355
|
].join(" | ");
|
|
17348
17356
|
});
|
|
17349
17357
|
if (rows.length === 0) {
|
|
17350
|
-
output.log(
|
|
17358
|
+
output.log(chalk41.yellow("No prompts found."));
|
|
17351
17359
|
} else {
|
|
17352
17360
|
output.log([
|
|
17353
17361
|
`┌─ Prompts ${"─".repeat(50)}┐`,
|
|
@@ -17378,7 +17386,7 @@ var ListCommand5 = {
|
|
|
17378
17386
|
};
|
|
17379
17387
|
|
|
17380
17388
|
// src/commands/prompt/get.ts
|
|
17381
|
-
import
|
|
17389
|
+
import chalk42 from "chalk";
|
|
17382
17390
|
var GetCommand5 = {
|
|
17383
17391
|
command: "get <name>",
|
|
17384
17392
|
describe: "获取指定 prompt 的内容",
|
|
@@ -17425,16 +17433,16 @@ var GetCommand5 = {
|
|
|
17425
17433
|
variables: vars
|
|
17426
17434
|
});
|
|
17427
17435
|
} else {
|
|
17428
|
-
output.log(
|
|
17436
|
+
output.log(chalk42.bold.cyan(`# Prompt: ${args.name}`));
|
|
17429
17437
|
output.log("");
|
|
17430
17438
|
if (Object.keys(vars).length > 0) {
|
|
17431
|
-
output.log(
|
|
17439
|
+
output.log(chalk42.gray("Variables:"));
|
|
17432
17440
|
for (const [key, value] of Object.entries(vars)) {
|
|
17433
|
-
output.log(` ${
|
|
17441
|
+
output.log(` ${chalk42.cyan(key + ":")} ${value}`);
|
|
17434
17442
|
}
|
|
17435
17443
|
output.log("");
|
|
17436
17444
|
}
|
|
17437
|
-
output.log(
|
|
17445
|
+
output.log(chalk42.bold("Content:"));
|
|
17438
17446
|
output.log("─".repeat(60));
|
|
17439
17447
|
output.log(prompt);
|
|
17440
17448
|
output.log("─".repeat(60));
|
|
@@ -17464,7 +17472,7 @@ function parseVars(vars) {
|
|
|
17464
17472
|
|
|
17465
17473
|
// src/commands/prompt/add.ts
|
|
17466
17474
|
import { readFile as readFile2 } from "fs/promises";
|
|
17467
|
-
import
|
|
17475
|
+
import chalk43 from "chalk";
|
|
17468
17476
|
var AddCommand2 = {
|
|
17469
17477
|
command: "add <name>",
|
|
17470
17478
|
describe: "添加 prompt 并持久化到 ~/.local/share/roy-agent/prompts/",
|
|
@@ -17515,8 +17523,8 @@ var AddCommand2 = {
|
|
|
17515
17523
|
length: content.trim().length
|
|
17516
17524
|
});
|
|
17517
17525
|
} else {
|
|
17518
|
-
output.log(
|
|
17519
|
-
output.log(
|
|
17526
|
+
output.log(chalk43.green(`✓ Prompt '${args.name}' saved`));
|
|
17527
|
+
output.log(chalk43.gray(` ${filePath}`));
|
|
17520
17528
|
}
|
|
17521
17529
|
} catch (error) {
|
|
17522
17530
|
output.error(`Failed to add prompt: ${error}`);
|
|
@@ -17528,7 +17536,7 @@ var AddCommand2 = {
|
|
|
17528
17536
|
};
|
|
17529
17537
|
|
|
17530
17538
|
// src/commands/prompt/config-dir.ts
|
|
17531
|
-
import
|
|
17539
|
+
import chalk44 from "chalk";
|
|
17532
17540
|
var ConfigDirCommand2 = {
|
|
17533
17541
|
command: "config-dir",
|
|
17534
17542
|
describe: "显示 prompt 持久化目录路径",
|
|
@@ -17558,8 +17566,8 @@ var ConfigDirCommand2 = {
|
|
|
17558
17566
|
if (args.json) {
|
|
17559
17567
|
output.json({ configDir, exists });
|
|
17560
17568
|
} else {
|
|
17561
|
-
output.log(`${
|
|
17562
|
-
output.log(`${
|
|
17569
|
+
output.log(`${chalk44.cyan("Prompt Config Directory:")} ${configDir}`);
|
|
17570
|
+
output.log(`${chalk44.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
17563
17571
|
}
|
|
17564
17572
|
} catch (error) {
|
|
17565
17573
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -17581,7 +17589,7 @@ var PromptCommand = {
|
|
|
17581
17589
|
};
|
|
17582
17590
|
|
|
17583
17591
|
// src/commands/commands-list.ts
|
|
17584
|
-
import
|
|
17592
|
+
import chalk45 from "chalk";
|
|
17585
17593
|
function truncateVisual(str, maxWidth) {
|
|
17586
17594
|
let result = "";
|
|
17587
17595
|
let width = 0;
|
|
@@ -17596,16 +17604,16 @@ function truncateVisual(str, maxWidth) {
|
|
|
17596
17604
|
}
|
|
17597
17605
|
function formatCommandsTable(commands) {
|
|
17598
17606
|
if (commands.length === 0) {
|
|
17599
|
-
return
|
|
17607
|
+
return chalk45.yellow("命令目录为空,使用 'roy-agent commands add' 添加命令");
|
|
17600
17608
|
}
|
|
17601
17609
|
const NAME_WIDTH = 20;
|
|
17602
17610
|
const SOURCE_WIDTH = 10;
|
|
17603
17611
|
const DESC_WIDTH = 50;
|
|
17604
17612
|
const GAP = " ";
|
|
17605
17613
|
const headerLine = [
|
|
17606
|
-
|
|
17607
|
-
|
|
17608
|
-
|
|
17614
|
+
chalk45.bold("NAME".padEnd(NAME_WIDTH)),
|
|
17615
|
+
chalk45.bold("SOURCE".padEnd(SOURCE_WIDTH)),
|
|
17616
|
+
chalk45.bold("DESCRIPTION")
|
|
17609
17617
|
].join(GAP);
|
|
17610
17618
|
const sepLine = "─".repeat(NAME_WIDTH + SOURCE_WIDTH + DESC_WIDTH + GAP.length * 2);
|
|
17611
17619
|
const formatRow = (cmd) => {
|
|
@@ -17713,7 +17721,7 @@ var CommandsListCommand = {
|
|
|
17713
17721
|
};
|
|
17714
17722
|
|
|
17715
17723
|
// src/commands/commands-add.ts
|
|
17716
|
-
import
|
|
17724
|
+
import chalk46 from "chalk";
|
|
17717
17725
|
var CommandsAddCommand = {
|
|
17718
17726
|
command: "add <name> <target>",
|
|
17719
17727
|
describe: "添加收藏命令(自动创建 symlink)",
|
|
@@ -17774,10 +17782,10 @@ var CommandsAddCommand = {
|
|
|
17774
17782
|
});
|
|
17775
17783
|
const dirs = await commandsComponent.getCommandDirs();
|
|
17776
17784
|
const targetDir = source === "user" ? dirs.user : dirs.project;
|
|
17777
|
-
output.log(
|
|
17778
|
-
output.log(
|
|
17779
|
-
output.log(
|
|
17780
|
-
output.log(
|
|
17785
|
+
output.log(chalk46.green(`✅ 已添加命令 '${args.name}'`));
|
|
17786
|
+
output.log(chalk46.gray(` 目标: ${args.target}`));
|
|
17787
|
+
output.log(chalk46.gray(` 位置: ${targetDir}/${args.name}`));
|
|
17788
|
+
output.log(chalk46.gray(` 级别: ${source === "user" ? "USER" : "PROJECT"}`));
|
|
17781
17789
|
} catch (error) {
|
|
17782
17790
|
output.error(`添加失败: ${error.message}`);
|
|
17783
17791
|
process.exit(1);
|
|
@@ -17788,7 +17796,7 @@ var CommandsAddCommand = {
|
|
|
17788
17796
|
};
|
|
17789
17797
|
|
|
17790
17798
|
// src/commands/commands-remove.ts
|
|
17791
|
-
import
|
|
17799
|
+
import chalk47 from "chalk";
|
|
17792
17800
|
var CommandsRemoveCommand = {
|
|
17793
17801
|
command: "remove <name>",
|
|
17794
17802
|
aliases: ["rm"],
|
|
@@ -17832,7 +17840,7 @@ var CommandsRemoveCommand = {
|
|
|
17832
17840
|
name: args.name,
|
|
17833
17841
|
source: "user"
|
|
17834
17842
|
});
|
|
17835
|
-
output.log(
|
|
17843
|
+
output.log(chalk47.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
17836
17844
|
} catch (error) {
|
|
17837
17845
|
if (!error.message?.includes("不存在")) {
|
|
17838
17846
|
throw error;
|
|
@@ -17845,7 +17853,7 @@ var CommandsRemoveCommand = {
|
|
|
17845
17853
|
name: args.name,
|
|
17846
17854
|
source: "project"
|
|
17847
17855
|
});
|
|
17848
|
-
output.log(
|
|
17856
|
+
output.log(chalk47.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
17849
17857
|
} catch (error) {
|
|
17850
17858
|
if (!error.message?.includes("不存在")) {
|
|
17851
17859
|
throw error;
|
|
@@ -17859,7 +17867,7 @@ var CommandsRemoveCommand = {
|
|
|
17859
17867
|
name: args.name,
|
|
17860
17868
|
source: "user"
|
|
17861
17869
|
});
|
|
17862
|
-
output.log(
|
|
17870
|
+
output.log(chalk47.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
17863
17871
|
removed = true;
|
|
17864
17872
|
} catch (error) {
|
|
17865
17873
|
if (!error.message?.includes("不存在")) {
|
|
@@ -17871,7 +17879,7 @@ var CommandsRemoveCommand = {
|
|
|
17871
17879
|
name: args.name,
|
|
17872
17880
|
source: "project"
|
|
17873
17881
|
});
|
|
17874
|
-
output.log(
|
|
17882
|
+
output.log(chalk47.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
17875
17883
|
removed = true;
|
|
17876
17884
|
} catch (error) {
|
|
17877
17885
|
if (!error.message?.includes("不存在")) {
|
|
@@ -17893,7 +17901,7 @@ var CommandsRemoveCommand = {
|
|
|
17893
17901
|
};
|
|
17894
17902
|
|
|
17895
17903
|
// src/commands/commands-info.ts
|
|
17896
|
-
import
|
|
17904
|
+
import chalk48 from "chalk";
|
|
17897
17905
|
import { exec as exec2 } from "child_process";
|
|
17898
17906
|
import { promisify as promisify2 } from "util";
|
|
17899
17907
|
var execAsync2 = promisify2(exec2);
|
|
@@ -17928,12 +17936,12 @@ var CommandsInfoCommand = {
|
|
|
17928
17936
|
output.error(`命令 '${args.name}' 不存在`);
|
|
17929
17937
|
process.exit(1);
|
|
17930
17938
|
}
|
|
17931
|
-
output.log(
|
|
17932
|
-
output.log(
|
|
17933
|
-
output.log(
|
|
17934
|
-
output.log(
|
|
17939
|
+
output.log(chalk48.bold("Name:") + ` ${info.name}`);
|
|
17940
|
+
output.log(chalk48.bold("Path:") + ` ${info.path}`);
|
|
17941
|
+
output.log(chalk48.bold("Source:") + ` ${info.source.toUpperCase()}`);
|
|
17942
|
+
output.log(chalk48.bold("Description:") + ` ${info.shortDescription || "-"}`);
|
|
17935
17943
|
output.log();
|
|
17936
|
-
output.log(
|
|
17944
|
+
output.log(chalk48.gray("─".repeat(50)));
|
|
17937
17945
|
output.log();
|
|
17938
17946
|
try {
|
|
17939
17947
|
const { stdout } = await execAsync2(`${info.path} --help`, { timeout: 5000 });
|
|
@@ -17943,7 +17951,7 @@ var CommandsInfoCommand = {
|
|
|
17943
17951
|
const { stdout } = await execAsync2(`${info.path} -h`, { timeout: 5000 });
|
|
17944
17952
|
output.log(stdout);
|
|
17945
17953
|
} catch {
|
|
17946
|
-
output.log(
|
|
17954
|
+
output.log(chalk48.gray("(无法获取帮助信息)"));
|
|
17947
17955
|
}
|
|
17948
17956
|
}
|
|
17949
17957
|
} catch (error) {
|
|
@@ -17956,7 +17964,7 @@ var CommandsInfoCommand = {
|
|
|
17956
17964
|
};
|
|
17957
17965
|
|
|
17958
17966
|
// src/commands/commands-dirs.ts
|
|
17959
|
-
import
|
|
17967
|
+
import chalk49 from "chalk";
|
|
17960
17968
|
var CommandsDirsCommand = {
|
|
17961
17969
|
command: "dirs",
|
|
17962
17970
|
describe: "显示命令目录",
|
|
@@ -17988,10 +17996,10 @@ var CommandsDirsCommand = {
|
|
|
17988
17996
|
if (args.json) {
|
|
17989
17997
|
output.json(dirs);
|
|
17990
17998
|
} else {
|
|
17991
|
-
output.log(
|
|
17999
|
+
output.log(chalk49.bold("命令目录:"));
|
|
17992
18000
|
output.log();
|
|
17993
|
-
output.log(
|
|
17994
|
-
output.log(
|
|
18001
|
+
output.log(chalk49.cyan("USER:") + ` ${dirs.user}`);
|
|
18002
|
+
output.log(chalk49.cyan("PROJECT:") + ` ${dirs.project}`);
|
|
17995
18003
|
}
|
|
17996
18004
|
} catch (error) {
|
|
17997
18005
|
output.error(`错误: ${error.message}`);
|
|
@@ -18011,7 +18019,7 @@ var CommandsCommand = {
|
|
|
18011
18019
|
};
|
|
18012
18020
|
|
|
18013
18021
|
// src/commands/config/list.ts
|
|
18014
|
-
import
|
|
18022
|
+
import chalk50 from "chalk";
|
|
18015
18023
|
|
|
18016
18024
|
// src/commands/config/config-service.ts
|
|
18017
18025
|
import * as fsSync from "fs";
|
|
@@ -18315,7 +18323,7 @@ var ConfigListCommand = {
|
|
|
18315
18323
|
output.log("");
|
|
18316
18324
|
output.log("Supported components:");
|
|
18317
18325
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
18318
|
-
output.log(` ${
|
|
18326
|
+
output.log(` ${chalk50.cyan(comp.padEnd(15))} ${COMPONENT_DESCRIPTIONS[comp] || ""}`);
|
|
18319
18327
|
}
|
|
18320
18328
|
process.exit(1);
|
|
18321
18329
|
}
|
|
@@ -18333,27 +18341,27 @@ var ConfigListCommand = {
|
|
|
18333
18341
|
}
|
|
18334
18342
|
};
|
|
18335
18343
|
function showHelp(output) {
|
|
18336
|
-
output.log(
|
|
18344
|
+
output.log(chalk50.bold.cyan("# roy-agent config list"));
|
|
18337
18345
|
output.log("");
|
|
18338
18346
|
output.log("查看 roy-agent 组件配置信息");
|
|
18339
18347
|
output.log("");
|
|
18340
|
-
output.log(
|
|
18341
|
-
output.log(` ${
|
|
18348
|
+
output.log(chalk50.bold("Usage:"));
|
|
18349
|
+
output.log(` ${chalk50.cyan("roy-agent config list [component] [options]")}`);
|
|
18342
18350
|
output.log("");
|
|
18343
|
-
output.log(
|
|
18351
|
+
output.log(chalk50.bold("Components:"));
|
|
18344
18352
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
18345
|
-
output.log(` ${
|
|
18353
|
+
output.log(` ${chalk50.cyan(comp.padEnd(15))} ${chalk50.gray(COMPONENT_DESCRIPTIONS[comp] || "")}`);
|
|
18346
18354
|
}
|
|
18347
|
-
output.log(` ${
|
|
18355
|
+
output.log(` ${chalk50.cyan("all".padEnd(15))} 显示所有 components 概览`);
|
|
18348
18356
|
output.log("");
|
|
18349
|
-
output.log(
|
|
18350
|
-
output.log(` ${
|
|
18351
|
-
output.log(` ${
|
|
18352
|
-
output.log(` ${
|
|
18357
|
+
output.log(chalk50.bold("Options:"));
|
|
18358
|
+
output.log(` ${chalk50.cyan("-j, --json")} JSON 格式输出`);
|
|
18359
|
+
output.log(` ${chalk50.cyan("-k, --keys")} 只显示配置键`);
|
|
18360
|
+
output.log(` ${chalk50.cyan("-s, --sources")} 只显示配置源`);
|
|
18353
18361
|
output.log("");
|
|
18354
|
-
output.log(
|
|
18362
|
+
output.log(chalk50.bold("Examples:"));
|
|
18355
18363
|
for (const { command: command2, description } of USAGE_COMMANDS) {
|
|
18356
|
-
output.log(` ${
|
|
18364
|
+
output.log(` ${chalk50.cyan(command2.padEnd(40))} ${chalk50.gray(description)}`);
|
|
18357
18365
|
}
|
|
18358
18366
|
}
|
|
18359
18367
|
async function showAllComponents(output, configService) {
|
|
@@ -18362,13 +18370,13 @@ async function showAllComponents(output, configService) {
|
|
|
18362
18370
|
const config = configService.getComponentConfig(compName);
|
|
18363
18371
|
components.push({ name: compName, config });
|
|
18364
18372
|
}
|
|
18365
|
-
output.log(
|
|
18373
|
+
output.log(chalk50.bold.cyan("# All Components Overview"));
|
|
18366
18374
|
output.log("");
|
|
18367
|
-
output.log(` ${
|
|
18368
|
-
output.log(` ${
|
|
18375
|
+
output.log(` ${chalk50.cyan("Component".padEnd(15))} ${chalk50.cyan("Keys".padEnd(10))} ${chalk50.gray("Description")}`);
|
|
18376
|
+
output.log(` ${chalk50.gray("─".repeat(60))}`);
|
|
18369
18377
|
for (const comp of components) {
|
|
18370
18378
|
const keyCount = Object.keys(comp.config).length;
|
|
18371
|
-
output.log(` ${
|
|
18379
|
+
output.log(` ${chalk50.cyan(comp.name.padEnd(15))} ${keyCount.toString().padEnd(10)} ${chalk50.gray(COMPONENT_DESCRIPTIONS[comp.name] || "")}`);
|
|
18372
18380
|
}
|
|
18373
18381
|
}
|
|
18374
18382
|
async function showComponentConfig(componentName, output, configService, options) {
|
|
@@ -18390,22 +18398,22 @@ async function showComponentConfig(componentName, output, configService, options
|
|
|
18390
18398
|
});
|
|
18391
18399
|
return;
|
|
18392
18400
|
}
|
|
18393
|
-
output.log(
|
|
18401
|
+
output.log(chalk50.bold.cyan(`# ${componentName} Component Configuration`));
|
|
18394
18402
|
output.log("");
|
|
18395
18403
|
if (filePath) {
|
|
18396
|
-
output.log(
|
|
18397
|
-
output.log(` ${
|
|
18404
|
+
output.log(chalk50.bold("File:"));
|
|
18405
|
+
output.log(` ${chalk50.cyan(filePath)}`);
|
|
18398
18406
|
output.log("");
|
|
18399
18407
|
}
|
|
18400
18408
|
if (!options.sources) {
|
|
18401
|
-
output.log(
|
|
18409
|
+
output.log(chalk50.bold("Configuration:"));
|
|
18402
18410
|
if (Object.keys(config).length === 0) {
|
|
18403
|
-
output.log(` ${
|
|
18411
|
+
output.log(` ${chalk50.gray("(无配置)")}`);
|
|
18404
18412
|
} else {
|
|
18405
18413
|
const flatConfig = flattenConfig(config);
|
|
18406
18414
|
for (const [key, value] of flatConfig) {
|
|
18407
18415
|
const displayValue = formatValue(value);
|
|
18408
|
-
output.log(` ${
|
|
18416
|
+
output.log(` ${chalk50.cyan(key + ":")} ${displayValue}`);
|
|
18409
18417
|
}
|
|
18410
18418
|
}
|
|
18411
18419
|
output.log("");
|
|
@@ -18420,17 +18428,17 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
18420
18428
|
});
|
|
18421
18429
|
return;
|
|
18422
18430
|
}
|
|
18423
|
-
output.log(
|
|
18431
|
+
output.log(chalk50.bold.cyan("# Agent Component Configuration"));
|
|
18424
18432
|
output.log("");
|
|
18425
18433
|
if (!options.sources) {
|
|
18426
|
-
output.log(
|
|
18434
|
+
output.log(chalk50.bold("Configuration:"));
|
|
18427
18435
|
if (Object.keys(config).length === 0) {
|
|
18428
|
-
output.log(` ${
|
|
18436
|
+
output.log(` ${chalk50.gray("(无配置,使用默认值)")}`);
|
|
18429
18437
|
} else {
|
|
18430
18438
|
const flatConfig = flattenConfig(config);
|
|
18431
18439
|
for (const [key, value] of flatConfig) {
|
|
18432
18440
|
const displayValue = formatValue(value);
|
|
18433
|
-
output.log(` ${
|
|
18441
|
+
output.log(` ${chalk50.cyan(key + ":")} ${displayValue}`);
|
|
18434
18442
|
}
|
|
18435
18443
|
}
|
|
18436
18444
|
output.log("");
|
|
@@ -18444,10 +18452,10 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
18444
18452
|
const configDir = registry.getConfigDir();
|
|
18445
18453
|
const exists = registry.configDirExists();
|
|
18446
18454
|
const agentCount = registry.list().length;
|
|
18447
|
-
output.log(
|
|
18448
|
-
output.log(` ${
|
|
18449
|
-
output.log(` ${
|
|
18450
|
-
output.log(` ${
|
|
18455
|
+
output.log(chalk50.bold("Agent Config Directory:"));
|
|
18456
|
+
output.log(` ${chalk50.cyan("path:")} ${configDir}`);
|
|
18457
|
+
output.log(` ${chalk50.cyan("exists:")} ${exists ? chalk50.green("yes") : chalk50.red("no")}`);
|
|
18458
|
+
output.log(` ${chalk50.cyan("agents:")} ${agentCount} loaded`);
|
|
18451
18459
|
output.log("");
|
|
18452
18460
|
}
|
|
18453
18461
|
}
|
|
@@ -18463,41 +18471,41 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
18463
18471
|
});
|
|
18464
18472
|
return;
|
|
18465
18473
|
}
|
|
18466
|
-
output.log(
|
|
18474
|
+
output.log(chalk50.bold.cyan("# Prompt Component Configuration"));
|
|
18467
18475
|
output.log("");
|
|
18468
18476
|
if (filePath) {
|
|
18469
|
-
output.log(
|
|
18470
|
-
output.log(` ${
|
|
18477
|
+
output.log(chalk50.bold("File:"));
|
|
18478
|
+
output.log(` ${chalk50.cyan(filePath)}`);
|
|
18471
18479
|
output.log("");
|
|
18472
18480
|
}
|
|
18473
18481
|
if (!options.sources) {
|
|
18474
|
-
output.log(
|
|
18482
|
+
output.log(chalk50.bold("Configuration:"));
|
|
18475
18483
|
if (Object.keys(config).length === 0) {
|
|
18476
|
-
output.log(` ${
|
|
18484
|
+
output.log(` ${chalk50.gray("(无配置,使用默认值)")}`);
|
|
18477
18485
|
} else {
|
|
18478
18486
|
const flatConfig = flattenConfig(config);
|
|
18479
18487
|
for (const [key, value] of flatConfig) {
|
|
18480
18488
|
const displayValue = formatValue(value);
|
|
18481
|
-
output.log(` ${
|
|
18489
|
+
output.log(` ${chalk50.cyan(key + ":")} ${displayValue}`);
|
|
18482
18490
|
}
|
|
18483
18491
|
}
|
|
18484
18492
|
output.log("");
|
|
18485
18493
|
}
|
|
18486
|
-
output.log(
|
|
18487
|
-
output.log(` ${
|
|
18494
|
+
output.log(chalk50.bold("Prompts:"));
|
|
18495
|
+
output.log(` ${chalk50.gray("- 内置: 5 个(default, coding, review, project-memory, global-memory)")}`);
|
|
18488
18496
|
const promptPaths = config?.promptPaths;
|
|
18489
18497
|
if (promptPaths && Array.isArray(promptPaths) && promptPaths.length > 0) {
|
|
18490
|
-
output.log(` ${
|
|
18498
|
+
output.log(` ${chalk50.gray("- 外部: " + promptPaths.length + " 个路径")}`);
|
|
18491
18499
|
for (const p of promptPaths) {
|
|
18492
|
-
output.log(` ${
|
|
18500
|
+
output.log(` ${chalk50.cyan(p.path)} ${chalk50.gray("(type: " + p.type + ")")}`);
|
|
18493
18501
|
}
|
|
18494
18502
|
} else {
|
|
18495
|
-
output.log(` ${
|
|
18503
|
+
output.log(` ${chalk50.gray("- 外部: 0 个(未配置 promptPaths)")}`);
|
|
18496
18504
|
}
|
|
18497
18505
|
output.log("");
|
|
18498
18506
|
const defaultName = config?.defaultName || "default";
|
|
18499
|
-
output.log(
|
|
18500
|
-
output.log(` ${
|
|
18507
|
+
output.log(chalk50.bold("Default Prompt:"));
|
|
18508
|
+
output.log(` ${chalk50.cyan("defaultName:")} ${defaultName}`);
|
|
18501
18509
|
output.log("");
|
|
18502
18510
|
const env = envService?.getEnvironment?.();
|
|
18503
18511
|
if (env) {
|
|
@@ -18512,10 +18520,10 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
18512
18520
|
const stored = await store?.loadAll?.();
|
|
18513
18521
|
promptCount = Array.isArray(stored) ? stored.length : 0;
|
|
18514
18522
|
} catch {}
|
|
18515
|
-
output.log(
|
|
18516
|
-
output.log(` ${
|
|
18517
|
-
output.log(` ${
|
|
18518
|
-
output.log(` ${
|
|
18523
|
+
output.log(chalk50.bold("Prompt Storage Directory:"));
|
|
18524
|
+
output.log(` ${chalk50.cyan("path:")} ${configDir}`);
|
|
18525
|
+
output.log(` ${chalk50.cyan("exists:")} ${exists ? chalk50.green("yes") : chalk50.red("no")}`);
|
|
18526
|
+
output.log(` ${chalk50.cyan("prompts:")} ${promptCount} loaded`);
|
|
18519
18527
|
output.log("");
|
|
18520
18528
|
}
|
|
18521
18529
|
}
|
|
@@ -18541,19 +18549,19 @@ function flattenConfig(obj, prefix = "") {
|
|
|
18541
18549
|
}
|
|
18542
18550
|
function formatValue(value) {
|
|
18543
18551
|
if (value === undefined) {
|
|
18544
|
-
return
|
|
18552
|
+
return chalk50.gray("undefined");
|
|
18545
18553
|
}
|
|
18546
18554
|
if (value === null) {
|
|
18547
|
-
return
|
|
18555
|
+
return chalk50.gray("null");
|
|
18548
18556
|
}
|
|
18549
18557
|
if (typeof value === "object") {
|
|
18550
|
-
return
|
|
18558
|
+
return chalk50.gray(JSON.stringify(value));
|
|
18551
18559
|
}
|
|
18552
18560
|
return String(value);
|
|
18553
18561
|
}
|
|
18554
18562
|
|
|
18555
18563
|
// src/commands/config/export.ts
|
|
18556
|
-
import
|
|
18564
|
+
import chalk51 from "chalk";
|
|
18557
18565
|
var ConfigExportCommand = {
|
|
18558
18566
|
command: "export <component>",
|
|
18559
18567
|
describe: "导出组件配置到文件",
|
|
@@ -18598,7 +18606,7 @@ var ConfigExportCommand = {
|
|
|
18598
18606
|
output.log("");
|
|
18599
18607
|
output.log("Supported components:");
|
|
18600
18608
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
18601
|
-
output.log(` ${
|
|
18609
|
+
output.log(` ${chalk51.cyan(comp)}`);
|
|
18602
18610
|
}
|
|
18603
18611
|
process.exit(1);
|
|
18604
18612
|
}
|
|
@@ -18616,7 +18624,7 @@ var ConfigExportCommand = {
|
|
|
18616
18624
|
};
|
|
18617
18625
|
|
|
18618
18626
|
// src/commands/config/import.ts
|
|
18619
|
-
import
|
|
18627
|
+
import chalk52 from "chalk";
|
|
18620
18628
|
var ConfigImportCommand = {
|
|
18621
18629
|
command: "import <component>",
|
|
18622
18630
|
describe: "从文件导入配置到组件的 file source",
|
|
@@ -18666,7 +18674,7 @@ var ConfigImportCommand = {
|
|
|
18666
18674
|
output.log("");
|
|
18667
18675
|
output.log("Supported components:");
|
|
18668
18676
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
18669
|
-
output.log(` ${
|
|
18677
|
+
output.log(` ${chalk52.cyan(comp)}`);
|
|
18670
18678
|
}
|
|
18671
18679
|
process.exit(1);
|
|
18672
18680
|
}
|
|
@@ -18681,7 +18689,7 @@ var ConfigImportCommand = {
|
|
|
18681
18689
|
}
|
|
18682
18690
|
if (result.merged && result.changes.length > 0 && args.verbose) {
|
|
18683
18691
|
output.log("");
|
|
18684
|
-
output.log(
|
|
18692
|
+
output.log(chalk52.bold("变更详情:"));
|
|
18685
18693
|
for (const change of result.changes) {
|
|
18686
18694
|
output.log(` ${change.key}: ${JSON.stringify(change.oldValue)} → ${JSON.stringify(change.newValue)}`);
|
|
18687
18695
|
}
|
|
@@ -18705,7 +18713,7 @@ var ConfigCommand = {
|
|
|
18705
18713
|
};
|
|
18706
18714
|
|
|
18707
18715
|
// src/commands/mcp/list.ts
|
|
18708
|
-
import
|
|
18716
|
+
import chalk53 from "chalk";
|
|
18709
18717
|
var ListCommand6 = {
|
|
18710
18718
|
command: "list",
|
|
18711
18719
|
aliases: ["ls"],
|
|
@@ -18765,30 +18773,30 @@ var ListCommand6 = {
|
|
|
18765
18773
|
output.log(hint);
|
|
18766
18774
|
} else {
|
|
18767
18775
|
if (servers.length === 0) {
|
|
18768
|
-
output.log(
|
|
18776
|
+
output.log(chalk53.yellow("No MCP servers configured"));
|
|
18769
18777
|
return;
|
|
18770
18778
|
}
|
|
18771
18779
|
const statusColor = (status) => {
|
|
18772
18780
|
switch (status) {
|
|
18773
18781
|
case "connected":
|
|
18774
|
-
return
|
|
18782
|
+
return chalk53.green;
|
|
18775
18783
|
case "connecting":
|
|
18776
|
-
return
|
|
18784
|
+
return chalk53.yellow;
|
|
18777
18785
|
case "error":
|
|
18778
|
-
return
|
|
18786
|
+
return chalk53.red;
|
|
18779
18787
|
case "disconnected":
|
|
18780
|
-
return
|
|
18788
|
+
return chalk53.gray;
|
|
18781
18789
|
default:
|
|
18782
|
-
return
|
|
18790
|
+
return chalk53.white;
|
|
18783
18791
|
}
|
|
18784
18792
|
};
|
|
18785
18793
|
const header = [
|
|
18786
|
-
|
|
18787
|
-
|
|
18788
|
-
|
|
18794
|
+
chalk53.bold("Name"),
|
|
18795
|
+
chalk53.bold("Status"),
|
|
18796
|
+
chalk53.bold("Tools")
|
|
18789
18797
|
].join(" | ");
|
|
18790
18798
|
const rows = servers.map((s) => [
|
|
18791
|
-
|
|
18799
|
+
chalk53.cyan(s.name),
|
|
18792
18800
|
statusColor(s.status)(`[${s.status}]`),
|
|
18793
18801
|
s.toolsCount !== undefined ? String(s.toolsCount) : "-"
|
|
18794
18802
|
].join(" | "));
|
|
@@ -18819,7 +18827,7 @@ var ListCommand6 = {
|
|
|
18819
18827
|
};
|
|
18820
18828
|
|
|
18821
18829
|
// src/commands/mcp/tools.ts
|
|
18822
|
-
import
|
|
18830
|
+
import chalk54 from "chalk";
|
|
18823
18831
|
var ToolsCommand = {
|
|
18824
18832
|
command: "tools",
|
|
18825
18833
|
aliases: ["t"],
|
|
@@ -18872,7 +18880,7 @@ var ToolsCommand = {
|
|
|
18872
18880
|
tools.forEach((t) => output.log(t.name));
|
|
18873
18881
|
} else {
|
|
18874
18882
|
if (tools.length === 0) {
|
|
18875
|
-
output.log(
|
|
18883
|
+
output.log(chalk54.yellow("No MCP tools available"));
|
|
18876
18884
|
return;
|
|
18877
18885
|
}
|
|
18878
18886
|
const byServer = new Map;
|
|
@@ -18884,15 +18892,15 @@ var ToolsCommand = {
|
|
|
18884
18892
|
byServer.get(serverName).push(tool);
|
|
18885
18893
|
}
|
|
18886
18894
|
for (const [serverName, serverTools] of byServer) {
|
|
18887
|
-
output.log(
|
|
18895
|
+
output.log(chalk54.bold.cyan(`
|
|
18888
18896
|
[${serverName}] ${serverTools.length} tools`));
|
|
18889
18897
|
for (const tool of serverTools) {
|
|
18890
18898
|
const desc2 = tool.description.length > 80 ? tool.description.slice(0, 77) + "..." : tool.description;
|
|
18891
|
-
output.log(` ${
|
|
18892
|
-
output.log(` ${
|
|
18899
|
+
output.log(` ${chalk54.green("+")} ${chalk54.white(tool.name)}`);
|
|
18900
|
+
output.log(` ${chalk54.gray(desc2)}`);
|
|
18893
18901
|
}
|
|
18894
18902
|
}
|
|
18895
|
-
output.log(
|
|
18903
|
+
output.log(chalk54.gray(`
|
|
18896
18904
|
Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
18897
18905
|
}
|
|
18898
18906
|
} catch (error) {
|
|
@@ -18905,7 +18913,7 @@ Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
|
18905
18913
|
};
|
|
18906
18914
|
|
|
18907
18915
|
// src/commands/mcp/reload.ts
|
|
18908
|
-
import
|
|
18916
|
+
import chalk55 from "chalk";
|
|
18909
18917
|
var ReloadCommand2 = {
|
|
18910
18918
|
command: "reload",
|
|
18911
18919
|
aliases: ["r"],
|
|
@@ -18926,19 +18934,19 @@ var ReloadCommand2 = {
|
|
|
18926
18934
|
output.error("McpComponent not available");
|
|
18927
18935
|
process.exit(1);
|
|
18928
18936
|
}
|
|
18929
|
-
output.log(
|
|
18937
|
+
output.log(chalk55.cyan("Reloading MCP servers..."));
|
|
18930
18938
|
await mcpComponent.reload();
|
|
18931
18939
|
const servers = mcpComponent.listServers();
|
|
18932
18940
|
const connected = servers.filter((s) => s.status === "connected").length;
|
|
18933
18941
|
const errors = servers.filter((s) => s.status === "error").length;
|
|
18934
|
-
output.log(
|
|
18942
|
+
output.log(chalk55.green(`✓ Reloaded ${servers.length} servers`));
|
|
18935
18943
|
if (connected > 0) {
|
|
18936
|
-
output.log(
|
|
18944
|
+
output.log(chalk55.green(` • ${connected} connected`));
|
|
18937
18945
|
}
|
|
18938
18946
|
if (errors > 0) {
|
|
18939
18947
|
output.warn(` • ${errors} failed`);
|
|
18940
18948
|
for (const server of servers.filter((s) => s.status === "error")) {
|
|
18941
|
-
output.log(
|
|
18949
|
+
output.log(chalk55.gray(` - ${server.name}: ${server.error}`));
|
|
18942
18950
|
}
|
|
18943
18951
|
}
|
|
18944
18952
|
} catch (error) {
|
|
@@ -18959,7 +18967,7 @@ var McpCommand = {
|
|
|
18959
18967
|
};
|
|
18960
18968
|
|
|
18961
18969
|
// src/commands/tools/list.ts
|
|
18962
|
-
import
|
|
18970
|
+
import chalk56 from "chalk";
|
|
18963
18971
|
var ListCommand7 = {
|
|
18964
18972
|
command: "list",
|
|
18965
18973
|
aliases: ["ls"],
|
|
@@ -19018,16 +19026,16 @@ var ListCommand7 = {
|
|
|
19018
19026
|
output.log(hint);
|
|
19019
19027
|
} else {
|
|
19020
19028
|
const header = [
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19029
|
+
chalk56.bold("Name"),
|
|
19030
|
+
chalk56.bold("Description"),
|
|
19031
|
+
chalk56.bold("Category")
|
|
19024
19032
|
].join(" | ");
|
|
19025
19033
|
const rows = tools.map((t) => {
|
|
19026
19034
|
const desc2 = t.description.length > 40 ? t.description.slice(0, 37) + "..." : t.description;
|
|
19027
19035
|
return [
|
|
19028
|
-
|
|
19036
|
+
chalk56.cyan(t.name),
|
|
19029
19037
|
desc2,
|
|
19030
|
-
t.metadata?.category ?
|
|
19038
|
+
t.metadata?.category ? chalk56.gray(`[${t.metadata.category}]`) : "-"
|
|
19031
19039
|
].join(" | ");
|
|
19032
19040
|
});
|
|
19033
19041
|
output.log([
|
|
@@ -19057,7 +19065,7 @@ var ListCommand7 = {
|
|
|
19057
19065
|
};
|
|
19058
19066
|
|
|
19059
19067
|
// src/commands/tools/get.ts
|
|
19060
|
-
import
|
|
19068
|
+
import chalk57 from "chalk";
|
|
19061
19069
|
|
|
19062
19070
|
// src/commands/tools/shared/schema-helper.ts
|
|
19063
19071
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -19132,8 +19140,8 @@ var GetCommand6 = {
|
|
|
19132
19140
|
}))
|
|
19133
19141
|
});
|
|
19134
19142
|
} else {
|
|
19135
|
-
output.log(
|
|
19136
|
-
output.log(
|
|
19143
|
+
output.log(chalk57.bold.cyan(`Tool: ${tool.name}`));
|
|
19144
|
+
output.log(chalk57.gray("─".repeat(60)));
|
|
19137
19145
|
output.log(`Description: ${tool.description}`);
|
|
19138
19146
|
if (tool.metadata?.category) {
|
|
19139
19147
|
output.log(`Category: ${tool.metadata.category}`);
|
|
@@ -19142,9 +19150,9 @@ var GetCommand6 = {
|
|
|
19142
19150
|
output.log(`Tags: ${tool.metadata.tags.join(", ")}`);
|
|
19143
19151
|
}
|
|
19144
19152
|
output.log("");
|
|
19145
|
-
output.log(
|
|
19153
|
+
output.log(chalk57.bold("Parameters:"));
|
|
19146
19154
|
for (const param of params) {
|
|
19147
|
-
const required = param.required ?
|
|
19155
|
+
const required = param.required ? chalk57.red("(required)") : chalk57.gray("(optional)");
|
|
19148
19156
|
const defaultVal = param.default !== undefined ? ` [default: ${JSON.stringify(param.default)}]` : "";
|
|
19149
19157
|
output.log(` --${param.name} <${param.type}> ${required}`);
|
|
19150
19158
|
output.log(` ${param.description}${defaultVal}`);
|
|
@@ -19253,14 +19261,14 @@ var ToolsCommand2 = {
|
|
|
19253
19261
|
};
|
|
19254
19262
|
|
|
19255
19263
|
// src/commands/memory/record.ts
|
|
19256
|
-
import
|
|
19264
|
+
import chalk58 from "chalk";
|
|
19257
19265
|
import { createMemoryAgentTools, getBuiltInPrompt } from "@ai-setting/roy-agent-core";
|
|
19258
19266
|
import { bashTool, globTool, readFileTool } from "@ai-setting/roy-agent-core";
|
|
19259
19267
|
async function runExtractMode(output, memoryComponent, agentComponent, sessionComponent, env, options) {
|
|
19260
19268
|
const { scope, sessionId, require: userRequirement } = options;
|
|
19261
|
-
output.log(
|
|
19269
|
+
output.log(chalk58.blue(`
|
|
19262
19270
|
\uD83D\uDD0D Memory Extract Mode (${scope})`));
|
|
19263
|
-
output.log(
|
|
19271
|
+
output.log(chalk58.gray(`正在分析会话历史,生成记忆...
|
|
19264
19272
|
`));
|
|
19265
19273
|
try {
|
|
19266
19274
|
const currentMemory = await memoryComponent.recallMemory(scope) || "(无现有记忆)";
|
|
@@ -19306,13 +19314,13 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
19306
19314
|
for (const tool of agentTools) {
|
|
19307
19315
|
try {
|
|
19308
19316
|
toolComponent.register(tool);
|
|
19309
|
-
output.log(
|
|
19317
|
+
output.log(chalk58.gray(`Tool registered: ${tool.name}`));
|
|
19310
19318
|
} catch (err) {
|
|
19311
|
-
output.log(
|
|
19319
|
+
output.log(chalk58.gray(`Tool already registered: ${tool.name}`));
|
|
19312
19320
|
}
|
|
19313
19321
|
}
|
|
19314
19322
|
}
|
|
19315
|
-
output.log(
|
|
19323
|
+
output.log(chalk58.gray(`Agent "${agentName}" registered with ${agentTools.length} tools`));
|
|
19316
19324
|
const query = `请分析会话历史,提炼${scope === "project" ? "项目" : "全局"}记忆并写入记忆文件。`;
|
|
19317
19325
|
let result;
|
|
19318
19326
|
try {
|
|
@@ -19326,12 +19334,12 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
19326
19334
|
if (result && result.startsWith("执行失败")) {
|
|
19327
19335
|
output.error(`提取失败: ${result}`);
|
|
19328
19336
|
} else if (result) {
|
|
19329
|
-
output.log(
|
|
19337
|
+
output.log(chalk58.green(`
|
|
19330
19338
|
✅ 记忆提取完成`));
|
|
19331
|
-
output.log(
|
|
19339
|
+
output.log(chalk58.gray(`记忆已保存到 memory 文件。
|
|
19332
19340
|
`));
|
|
19333
19341
|
if (result.length > 0 && result !== "✅ 记忆提取完成") {
|
|
19334
|
-
output.log(
|
|
19342
|
+
output.log(chalk58.gray(`执行摘要: ${result.substring(0, 200)}${result.length > 200 ? "..." : ""}`));
|
|
19335
19343
|
}
|
|
19336
19344
|
}
|
|
19337
19345
|
agentComponent.unregisterAgent(agentName);
|
|
@@ -19449,11 +19457,11 @@ var RecordCommand = {
|
|
|
19449
19457
|
prepend: "已插入内容到记忆文件开头",
|
|
19450
19458
|
delete: "已删除记忆文件"
|
|
19451
19459
|
};
|
|
19452
|
-
output.log(
|
|
19453
|
-
output.log(
|
|
19460
|
+
output.log(chalk58.green(`✓ ${actionMessages[result.action]}`));
|
|
19461
|
+
output.log(chalk58.gray(`路径: ${result.path}`));
|
|
19454
19462
|
if (result.action !== "delete" && a.content) {
|
|
19455
19463
|
const preview = a.content.substring(0, 100);
|
|
19456
|
-
output.log(
|
|
19464
|
+
output.log(chalk58.gray(`内容预览: ${preview}${a.content.length > 100 ? "..." : ""}`));
|
|
19457
19465
|
}
|
|
19458
19466
|
} catch (error) {
|
|
19459
19467
|
output.error(`Failed to record memory: ${error}`);
|
|
@@ -19465,7 +19473,7 @@ var RecordCommand = {
|
|
|
19465
19473
|
};
|
|
19466
19474
|
|
|
19467
19475
|
// src/commands/memory/recall.ts
|
|
19468
|
-
import
|
|
19476
|
+
import chalk59 from "chalk";
|
|
19469
19477
|
var RecallCommand = {
|
|
19470
19478
|
command: "recall",
|
|
19471
19479
|
aliases: ["load"],
|
|
@@ -19501,7 +19509,7 @@ var RecallCommand = {
|
|
|
19501
19509
|
}
|
|
19502
19510
|
const content = await memoryComponent.recallMemory(a.scope);
|
|
19503
19511
|
if (!content) {
|
|
19504
|
-
output.log(
|
|
19512
|
+
output.log(chalk59.gray("(No memory files found)"));
|
|
19505
19513
|
return;
|
|
19506
19514
|
}
|
|
19507
19515
|
if (a.json) {
|
|
@@ -19527,7 +19535,7 @@ var MemoryCommand = {
|
|
|
19527
19535
|
handler: () => {}
|
|
19528
19536
|
};
|
|
19529
19537
|
// src/commands/eventsource/list.ts
|
|
19530
|
-
import
|
|
19538
|
+
import chalk60 from "chalk";
|
|
19531
19539
|
function truncateVisual2(str, maxWidth) {
|
|
19532
19540
|
let result = "";
|
|
19533
19541
|
let width = 0;
|
|
@@ -19542,7 +19550,7 @@ function truncateVisual2(str, maxWidth) {
|
|
|
19542
19550
|
}
|
|
19543
19551
|
function formatSourcesTable(sources) {
|
|
19544
19552
|
if (sources.length === 0) {
|
|
19545
|
-
return
|
|
19553
|
+
return chalk60.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加");
|
|
19546
19554
|
}
|
|
19547
19555
|
const ID_WIDTH = 10;
|
|
19548
19556
|
const NAME_WIDTH = 20;
|
|
@@ -19551,11 +19559,11 @@ function formatSourcesTable(sources) {
|
|
|
19551
19559
|
const ENABLED_WIDTH = 8;
|
|
19552
19560
|
const GAP = " ";
|
|
19553
19561
|
const headerLine = [
|
|
19554
|
-
|
|
19555
|
-
|
|
19556
|
-
|
|
19557
|
-
|
|
19558
|
-
|
|
19562
|
+
chalk60.bold("ID".padEnd(ID_WIDTH)),
|
|
19563
|
+
chalk60.bold("NAME".padEnd(NAME_WIDTH)),
|
|
19564
|
+
chalk60.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
19565
|
+
chalk60.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
19566
|
+
chalk60.bold("ENABLED".padEnd(ENABLED_WIDTH))
|
|
19559
19567
|
].join(GAP);
|
|
19560
19568
|
const sepLine = "─".repeat(ID_WIDTH + NAME_WIDTH + TYPE_WIDTH + STATUS_WIDTH + ENABLED_WIDTH + GAP.length * 4);
|
|
19561
19569
|
const formatRow = (src) => {
|
|
@@ -19613,7 +19621,7 @@ var EventSourceListCommand = {
|
|
|
19613
19621
|
sources: []
|
|
19614
19622
|
});
|
|
19615
19623
|
} else {
|
|
19616
|
-
output.log(
|
|
19624
|
+
output.log(chalk60.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加"));
|
|
19617
19625
|
}
|
|
19618
19626
|
return;
|
|
19619
19627
|
}
|
|
@@ -19648,21 +19656,21 @@ var EventSourceListCommand = {
|
|
|
19648
19656
|
const rows = sources.map((s) => {
|
|
19649
19657
|
const status = esComponent.getStatus(s.id) || "unknown";
|
|
19650
19658
|
const statusColorMap = {
|
|
19651
|
-
running:
|
|
19652
|
-
stopped:
|
|
19653
|
-
error:
|
|
19654
|
-
starting:
|
|
19655
|
-
created:
|
|
19656
|
-
stopping:
|
|
19657
|
-
unknown:
|
|
19659
|
+
running: chalk60.green,
|
|
19660
|
+
stopped: chalk60.gray,
|
|
19661
|
+
error: chalk60.red,
|
|
19662
|
+
starting: chalk60.yellow,
|
|
19663
|
+
created: chalk60.gray,
|
|
19664
|
+
stopping: chalk60.yellow,
|
|
19665
|
+
unknown: chalk60.gray
|
|
19658
19666
|
};
|
|
19659
|
-
const statusColor = statusColorMap[status] ||
|
|
19667
|
+
const statusColor = statusColorMap[status] || chalk60.gray;
|
|
19660
19668
|
return {
|
|
19661
19669
|
id: s.id.substring(0, 8),
|
|
19662
19670
|
name: s.name,
|
|
19663
19671
|
type: s.type,
|
|
19664
19672
|
status: statusColor(status),
|
|
19665
|
-
enabled: s.enabled ?
|
|
19673
|
+
enabled: s.enabled ? chalk60.green("✓") : chalk60.gray("✗")
|
|
19666
19674
|
};
|
|
19667
19675
|
});
|
|
19668
19676
|
output.log(formatSourcesTable(rows));
|
|
@@ -19684,11 +19692,11 @@ var EventSourceListCommand = {
|
|
|
19684
19692
|
};
|
|
19685
19693
|
|
|
19686
19694
|
// src/commands/eventsource/add.ts
|
|
19687
|
-
import
|
|
19695
|
+
import chalk62 from "chalk";
|
|
19688
19696
|
import { generateId } from "@ai-setting/roy-agent-core";
|
|
19689
19697
|
|
|
19690
19698
|
// src/commands/eventsource/server-url-option.ts
|
|
19691
|
-
import
|
|
19699
|
+
import chalk61 from "chalk";
|
|
19692
19700
|
function addServerUrlOption(yargs) {
|
|
19693
19701
|
return yargs.option("server-url", {
|
|
19694
19702
|
alias: "s",
|
|
@@ -19704,7 +19712,7 @@ function resolveServerUrl(serverUrl, fallback) {
|
|
|
19704
19712
|
return fallback;
|
|
19705
19713
|
const trimmed = serverUrl.replace(/\/+$/, "");
|
|
19706
19714
|
if (!/^(https?|wss?):\/\//.test(trimmed)) {
|
|
19707
|
-
console.error(
|
|
19715
|
+
console.error(chalk61.red(`
|
|
19708
19716
|
✗ Invalid --server-url: "${serverUrl}". Must start with http://, https://, ws://, or wss://
|
|
19709
19717
|
`));
|
|
19710
19718
|
process.exit(1);
|
|
@@ -19823,7 +19831,7 @@ var EventSourceAddCommand = {
|
|
|
19823
19831
|
let profileApiBase;
|
|
19824
19832
|
if (a.type === "bounty-im") {
|
|
19825
19833
|
if (a.email && a.profile) {
|
|
19826
|
-
output.error(
|
|
19834
|
+
output.error(chalk62.red(`
|
|
19827
19835
|
✗ --email 和 --profile 互斥(profile 文件已包含 email)。请选择其一。
|
|
19828
19836
|
`));
|
|
19829
19837
|
process.exit(1);
|
|
@@ -19831,7 +19839,7 @@ var EventSourceAddCommand = {
|
|
|
19831
19839
|
if (a.profile) {
|
|
19832
19840
|
const profile = readBountyProfile(a.profile);
|
|
19833
19841
|
if (!profile) {
|
|
19834
|
-
output.error(
|
|
19842
|
+
output.error(chalk62.red(`
|
|
19835
19843
|
✗ Profile '${a.profile}' 不存在或格式错误。期望路径:~/.config/bounty/profiles/${a.profile}.json
|
|
19836
19844
|
`));
|
|
19837
19845
|
process.exit(1);
|
|
@@ -19867,39 +19875,39 @@ var EventSourceAddCommand = {
|
|
|
19867
19875
|
options: a.prompt ? { prompt: a.prompt } : undefined
|
|
19868
19876
|
};
|
|
19869
19877
|
esComponent.register(config);
|
|
19870
|
-
output.success(
|
|
19878
|
+
output.success(chalk62.green(`事件源 '${a.name}' 添加成功!`));
|
|
19871
19879
|
output.log("");
|
|
19872
|
-
output.log(` ID: ${
|
|
19873
|
-
output.log(` Type: ${
|
|
19880
|
+
output.log(` ID: ${chalk62.gray(config.id)}`);
|
|
19881
|
+
output.log(` Type: ${chalk62.cyan(a.type)}`);
|
|
19874
19882
|
if (eventTypes?.length) {
|
|
19875
|
-
output.log(` Event Types: ${
|
|
19883
|
+
output.log(` Event Types: ${chalk62.gray(eventTypes.join(", "))}`);
|
|
19876
19884
|
}
|
|
19877
19885
|
if (a.command) {
|
|
19878
|
-
output.log(` Command: ${
|
|
19886
|
+
output.log(` Command: ${chalk62.gray(a.command)}`);
|
|
19879
19887
|
}
|
|
19880
19888
|
if (a.interval) {
|
|
19881
|
-
output.log(` Interval: ${
|
|
19889
|
+
output.log(` Interval: ${chalk62.gray(`${a.interval}ms`)}`);
|
|
19882
19890
|
}
|
|
19883
19891
|
if (resolvedProfileName) {
|
|
19884
|
-
output.log(` Profile: ${
|
|
19892
|
+
output.log(` Profile: ${chalk62.gray(resolvedProfileName)}`);
|
|
19885
19893
|
}
|
|
19886
19894
|
if (resolvedEmail) {
|
|
19887
|
-
output.log(` Email: ${
|
|
19895
|
+
output.log(` Email: ${chalk62.gray(resolvedEmail)}`);
|
|
19888
19896
|
}
|
|
19889
19897
|
if (a.imServerUrl) {
|
|
19890
|
-
output.log(` IM Server URL: ${
|
|
19898
|
+
output.log(` IM Server URL: ${chalk62.gray(a.imServerUrl)}`);
|
|
19891
19899
|
}
|
|
19892
19900
|
if (resolvedServerUrl) {
|
|
19893
|
-
output.log(` Server URL: ${
|
|
19901
|
+
output.log(` Server URL: ${chalk62.gray(resolvedServerUrl)}`);
|
|
19894
19902
|
}
|
|
19895
19903
|
if (a.tlsSkipVerify) {
|
|
19896
|
-
output.log(` TLS Skip Verify: ${
|
|
19904
|
+
output.log(` TLS Skip Verify: ${chalk62.yellow("⚠ true (自签名场景)")}`);
|
|
19897
19905
|
}
|
|
19898
19906
|
if (a.prompt) {
|
|
19899
|
-
output.log(` Prompt: ${
|
|
19907
|
+
output.log(` Prompt: ${chalk62.gray(a.prompt.length > 60 ? a.prompt.slice(0, 60) + "..." : a.prompt)}`);
|
|
19900
19908
|
}
|
|
19901
19909
|
output.log("");
|
|
19902
|
-
output.log(
|
|
19910
|
+
output.log(chalk62.gray(`使用 'roy-agent eventsource start ${config.id.substring(0, 8)}' 启动它。`));
|
|
19903
19911
|
} finally {
|
|
19904
19912
|
await envService.dispose();
|
|
19905
19913
|
}
|
|
@@ -19907,7 +19915,7 @@ var EventSourceAddCommand = {
|
|
|
19907
19915
|
};
|
|
19908
19916
|
|
|
19909
19917
|
// src/commands/eventsource/update.ts
|
|
19910
|
-
import
|
|
19918
|
+
import chalk63 from "chalk";
|
|
19911
19919
|
function findSource(esComponent, id) {
|
|
19912
19920
|
const sources = esComponent.list();
|
|
19913
19921
|
const matched = sources.find((s) => s.id === id || s.id.startsWith(id));
|
|
@@ -19982,7 +19990,7 @@ var EventSourceUpdateCommand = {
|
|
|
19982
19990
|
const all = esComponent.list();
|
|
19983
19991
|
if (all.length > 0) {
|
|
19984
19992
|
output.info("");
|
|
19985
|
-
output.info(
|
|
19993
|
+
output.info(chalk63.gray("可用的事件源:"));
|
|
19986
19994
|
for (const s of all) {
|
|
19987
19995
|
output.info(` - ${s.id.substring(0, 8)}: ${s.name} (${s.type})`);
|
|
19988
19996
|
}
|
|
@@ -19990,7 +19998,7 @@ var EventSourceUpdateCommand = {
|
|
|
19990
19998
|
process.exit(1);
|
|
19991
19999
|
}
|
|
19992
20000
|
if (match.source.type === "bounty-im" && a.email && a.profile) {
|
|
19993
|
-
output.error(
|
|
20001
|
+
output.error(chalk63.red(`
|
|
19994
20002
|
✗ --email 和 --profile 互斥(profile 文件已包含 email)。请选择其一。
|
|
19995
20003
|
`));
|
|
19996
20004
|
process.exit(1);
|
|
@@ -20000,7 +20008,7 @@ var EventSourceUpdateCommand = {
|
|
|
20000
20008
|
if (a.profile && match.source.type === "bounty-im") {
|
|
20001
20009
|
const profile = readBountyProfile(a.profile);
|
|
20002
20010
|
if (!profile) {
|
|
20003
|
-
output.error(
|
|
20011
|
+
output.error(chalk63.red(`
|
|
20004
20012
|
✗ Profile '${a.profile}' 不存在或格式错误。期望路径:~/.config/bounty/profiles/${a.profile}.json
|
|
20005
20013
|
`));
|
|
20006
20014
|
process.exit(1);
|
|
@@ -20049,19 +20057,19 @@ var EventSourceUpdateCommand = {
|
|
|
20049
20057
|
}
|
|
20050
20058
|
try {
|
|
20051
20059
|
const result = await esComponent.update(match.fullId, partial);
|
|
20052
|
-
output.success(
|
|
20060
|
+
output.success(chalk63.green(`✅ 事件源已更新: ${match.source.name}`));
|
|
20053
20061
|
output.log("");
|
|
20054
|
-
output.log(
|
|
20062
|
+
output.log(chalk63.bold("修改字段:"));
|
|
20055
20063
|
const before = match.source;
|
|
20056
20064
|
const after = result.updated;
|
|
20057
20065
|
for (const field of result.fields) {
|
|
20058
20066
|
const beforeVal = JSON.stringify(before[field] ?? before.options?.[field]);
|
|
20059
20067
|
const afterVal = JSON.stringify(after[field] ?? after.options?.[field]);
|
|
20060
|
-
output.log(` ${
|
|
20068
|
+
output.log(` ${chalk63.cyan(field)}: ${chalk63.gray(beforeVal)} ${chalk63.gray("→")} ${chalk63.green(afterVal)}`);
|
|
20061
20069
|
}
|
|
20062
20070
|
output.log("");
|
|
20063
20071
|
if (result.wasRunning) {
|
|
20064
|
-
output.info(
|
|
20072
|
+
output.info(chalk63.yellow(`⚠️ 事件源在更新前正在运行,已自动停止。请使用 'roy-agent eventsource start ${match.fullId.substring(0, 8)}' 手动启动以应用新配置。`));
|
|
20065
20073
|
}
|
|
20066
20074
|
} catch (error) {
|
|
20067
20075
|
output.error(`❌ 更新失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -20074,7 +20082,7 @@ var EventSourceUpdateCommand = {
|
|
|
20074
20082
|
};
|
|
20075
20083
|
|
|
20076
20084
|
// src/commands/eventsource/remove.ts
|
|
20077
|
-
import
|
|
20085
|
+
import chalk64 from "chalk";
|
|
20078
20086
|
var EventSourceRemoveCommand = {
|
|
20079
20087
|
command: "remove <id>",
|
|
20080
20088
|
aliases: ["rm"],
|
|
@@ -20113,7 +20121,7 @@ var EventSourceRemoveCommand = {
|
|
|
20113
20121
|
const status = esComponent.getStatus(matchedSource.id);
|
|
20114
20122
|
if (status === "running" && !args.force) {
|
|
20115
20123
|
output.error(`事件源正在运行中,请先停止: ${matchedSource.name} (${status})`);
|
|
20116
|
-
output.log(
|
|
20124
|
+
output.log(chalk64.gray(`使用 --force 强制移除或 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' 先停止`));
|
|
20117
20125
|
process.exit(1);
|
|
20118
20126
|
}
|
|
20119
20127
|
if (status === "running") {
|
|
@@ -20122,7 +20130,7 @@ var EventSourceRemoveCommand = {
|
|
|
20122
20130
|
}
|
|
20123
20131
|
const result = esComponent.unregister(matchedSource.id);
|
|
20124
20132
|
if (result) {
|
|
20125
|
-
output.success(
|
|
20133
|
+
output.success(chalk64.green(`事件源已移除: ${matchedSource.name}`));
|
|
20126
20134
|
} else {
|
|
20127
20135
|
output.error("移除失败");
|
|
20128
20136
|
process.exit(1);
|
|
@@ -20134,7 +20142,7 @@ var EventSourceRemoveCommand = {
|
|
|
20134
20142
|
};
|
|
20135
20143
|
|
|
20136
20144
|
// src/commands/eventsource/start.ts
|
|
20137
|
-
import
|
|
20145
|
+
import chalk65 from "chalk";
|
|
20138
20146
|
var EventSourceStartCommand = {
|
|
20139
20147
|
command: "start <id>",
|
|
20140
20148
|
describe: "启动指定的事件源",
|
|
@@ -20171,15 +20179,15 @@ var EventSourceStartCommand = {
|
|
|
20171
20179
|
}
|
|
20172
20180
|
const status = esComponent.getStatus(matchedSource.id);
|
|
20173
20181
|
if (status === "running") {
|
|
20174
|
-
output.log(
|
|
20182
|
+
output.log(chalk65.yellow(`事件源已在运行: ${matchedSource.name}`));
|
|
20175
20183
|
return;
|
|
20176
20184
|
}
|
|
20177
20185
|
output.info(`正在启动事件源 '${matchedSource.name}'...`);
|
|
20178
20186
|
try {
|
|
20179
20187
|
await esComponent.startSource(matchedSource.id);
|
|
20180
|
-
output.success(
|
|
20188
|
+
output.success(chalk65.green(`事件源已启动: ${matchedSource.name}`));
|
|
20181
20189
|
if (!args.background) {
|
|
20182
|
-
output.log(
|
|
20190
|
+
output.log(chalk65.gray("按 Ctrl+C 停止..."));
|
|
20183
20191
|
await new Promise((resolve) => {
|
|
20184
20192
|
const cleanup = () => {
|
|
20185
20193
|
process.removeListener("SIGINT", cleanup);
|
|
@@ -20201,7 +20209,7 @@ var EventSourceStartCommand = {
|
|
|
20201
20209
|
};
|
|
20202
20210
|
|
|
20203
20211
|
// src/commands/eventsource/stop.ts
|
|
20204
|
-
import
|
|
20212
|
+
import chalk66 from "chalk";
|
|
20205
20213
|
var EventSourceStopCommand = {
|
|
20206
20214
|
command: "stop <id>",
|
|
20207
20215
|
aliases: ["kill"],
|
|
@@ -20239,13 +20247,13 @@ var EventSourceStopCommand = {
|
|
|
20239
20247
|
}
|
|
20240
20248
|
const status = esComponent.getStatus(matchedSource.id);
|
|
20241
20249
|
if (status !== "running") {
|
|
20242
|
-
output.log(
|
|
20250
|
+
output.log(chalk66.yellow(`事件源未运行: ${matchedSource.name} (${status || "unknown"})`));
|
|
20243
20251
|
return;
|
|
20244
20252
|
}
|
|
20245
20253
|
output.info(`正在停止事件源 '${matchedSource.name}'...`);
|
|
20246
20254
|
try {
|
|
20247
20255
|
await esComponent.stopSource(matchedSource.id);
|
|
20248
|
-
output.success(
|
|
20256
|
+
output.success(chalk66.green(`事件源已停止: ${matchedSource.name}`));
|
|
20249
20257
|
} catch (error) {
|
|
20250
20258
|
output.error(`停止失败: ${error}`);
|
|
20251
20259
|
process.exit(1);
|
|
@@ -20257,14 +20265,14 @@ var EventSourceStopCommand = {
|
|
|
20257
20265
|
};
|
|
20258
20266
|
|
|
20259
20267
|
// src/commands/eventsource/status.ts
|
|
20260
|
-
import
|
|
20268
|
+
import chalk67 from "chalk";
|
|
20261
20269
|
var STATUS_COLORS = {
|
|
20262
|
-
created:
|
|
20263
|
-
starting:
|
|
20264
|
-
running:
|
|
20265
|
-
stopping:
|
|
20266
|
-
stopped:
|
|
20267
|
-
error:
|
|
20270
|
+
created: chalk67.gray,
|
|
20271
|
+
starting: chalk67.yellow,
|
|
20272
|
+
running: chalk67.green,
|
|
20273
|
+
stopping: chalk67.yellow,
|
|
20274
|
+
stopped: chalk67.gray,
|
|
20275
|
+
error: chalk67.red
|
|
20268
20276
|
};
|
|
20269
20277
|
var STATUS_ICONS = {
|
|
20270
20278
|
created: "○",
|
|
@@ -20318,7 +20326,7 @@ var EventSourceStatusCommand = {
|
|
|
20318
20326
|
process.exit(1);
|
|
20319
20327
|
}
|
|
20320
20328
|
const status = esComponent.getStatus(matchedSource.id) || "unknown";
|
|
20321
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
20329
|
+
const statusColor = STATUS_COLORS[status] || chalk67.gray;
|
|
20322
20330
|
if (args.json) {
|
|
20323
20331
|
output.json({
|
|
20324
20332
|
id: matchedSource.id,
|
|
@@ -20335,31 +20343,31 @@ var EventSourceStatusCommand = {
|
|
|
20335
20343
|
});
|
|
20336
20344
|
return;
|
|
20337
20345
|
}
|
|
20338
|
-
output.log(
|
|
20346
|
+
output.log(chalk67.bold("事件源详情"));
|
|
20339
20347
|
output.log("─".repeat(50));
|
|
20340
|
-
output.log(` ID: ${
|
|
20341
|
-
output.log(` Name: ${
|
|
20342
|
-
output.log(` Type: ${
|
|
20348
|
+
output.log(` ID: ${chalk67.gray(matchedSource.id)}`);
|
|
20349
|
+
output.log(` Name: ${chalk67.cyan(matchedSource.name)}`);
|
|
20350
|
+
output.log(` Type: ${chalk67.cyan(matchedSource.type)}`);
|
|
20343
20351
|
output.log(` Status: ${statusColor(`${STATUS_ICONS[status]} ${STATUS_LABELS[status]}`)}`);
|
|
20344
|
-
output.log(` Enabled: ${matchedSource.enabled ?
|
|
20352
|
+
output.log(` Enabled: ${matchedSource.enabled ? chalk67.green("是") : chalk67.gray("否")}`);
|
|
20345
20353
|
if (matchedSource.eventTypes?.length) {
|
|
20346
|
-
output.log(` Events: ${
|
|
20354
|
+
output.log(` Events: ${chalk67.gray(matchedSource.eventTypes.join(", "))}`);
|
|
20347
20355
|
}
|
|
20348
20356
|
if (matchedSource.command) {
|
|
20349
|
-
output.log(` Command: ${
|
|
20357
|
+
output.log(` Command: ${chalk67.gray(matchedSource.command)}`);
|
|
20350
20358
|
}
|
|
20351
20359
|
if (matchedSource.interval) {
|
|
20352
|
-
output.log(` Interval: ${
|
|
20360
|
+
output.log(` Interval: ${chalk67.gray(`${matchedSource.interval}ms`)}`);
|
|
20353
20361
|
}
|
|
20354
20362
|
if (matchedSource.url) {
|
|
20355
|
-
output.log(` URL: ${
|
|
20363
|
+
output.log(` URL: ${chalk67.gray(matchedSource.url)}`);
|
|
20356
20364
|
}
|
|
20357
20365
|
output.log("");
|
|
20358
20366
|
return;
|
|
20359
20367
|
}
|
|
20360
20368
|
const sources = esComponent.list();
|
|
20361
20369
|
if (sources.length === 0) {
|
|
20362
|
-
output.log(
|
|
20370
|
+
output.log(chalk67.yellow("没有配置的事件源"));
|
|
20363
20371
|
return;
|
|
20364
20372
|
}
|
|
20365
20373
|
if (args.json) {
|
|
@@ -20373,21 +20381,21 @@ var EventSourceStatusCommand = {
|
|
|
20373
20381
|
output.json({ sources: sourcesWithStatus, count: sources.length });
|
|
20374
20382
|
return;
|
|
20375
20383
|
}
|
|
20376
|
-
output.log(
|
|
20384
|
+
output.log(chalk67.bold("事件源状态概览"));
|
|
20377
20385
|
output.log("─".repeat(60));
|
|
20378
20386
|
for (const source of sources) {
|
|
20379
20387
|
const status = esComponent.getStatus(source.id) || "unknown";
|
|
20380
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
20388
|
+
const statusColor = STATUS_COLORS[status] || chalk67.gray;
|
|
20381
20389
|
const icon = STATUS_ICONS[status] || "?";
|
|
20382
20390
|
const label = STATUS_LABELS[status] || status;
|
|
20383
20391
|
output.log("");
|
|
20384
|
-
output.log(` ${
|
|
20392
|
+
output.log(` ${chalk67.cyan(source.name)} ${chalk67.gray(`(${source.type})`)}`);
|
|
20385
20393
|
output.log(` └─ Status: ${statusColor(`${icon} ${label}`)}`);
|
|
20386
|
-
output.log(` ID: ${
|
|
20394
|
+
output.log(` ID: ${chalk67.gray(source.id.substring(0, 8))}...`);
|
|
20387
20395
|
}
|
|
20388
20396
|
output.log("");
|
|
20389
20397
|
const runningCount = sources.filter((s) => esComponent.getStatus(s.id) === "running").length;
|
|
20390
|
-
output.log(
|
|
20398
|
+
output.log(chalk67.green(`✅ ${runningCount}/${sources.length} 运行中`));
|
|
20391
20399
|
} finally {
|
|
20392
20400
|
await envService.dispose();
|
|
20393
20401
|
}
|
|
@@ -20700,7 +20708,7 @@ var DebugCommand = {
|
|
|
20700
20708
|
};
|
|
20701
20709
|
|
|
20702
20710
|
// src/commands/workflow/renderers.ts
|
|
20703
|
-
import
|
|
20711
|
+
import chalk68 from "chalk";
|
|
20704
20712
|
function truncateVisual3(str, maxWidth) {
|
|
20705
20713
|
if (!str)
|
|
20706
20714
|
return "-";
|
|
@@ -20735,18 +20743,18 @@ function formatDuration(ms) {
|
|
|
20735
20743
|
function statusColor(status) {
|
|
20736
20744
|
switch (status) {
|
|
20737
20745
|
case "completed":
|
|
20738
|
-
return
|
|
20746
|
+
return chalk68.green;
|
|
20739
20747
|
case "running":
|
|
20740
20748
|
case "idle":
|
|
20741
|
-
return
|
|
20749
|
+
return chalk68.blue;
|
|
20742
20750
|
case "paused":
|
|
20743
|
-
return
|
|
20751
|
+
return chalk68.yellow;
|
|
20744
20752
|
case "failed":
|
|
20745
|
-
return
|
|
20753
|
+
return chalk68.red;
|
|
20746
20754
|
case "stopped":
|
|
20747
|
-
return
|
|
20755
|
+
return chalk68.gray;
|
|
20748
20756
|
default:
|
|
20749
|
-
return
|
|
20757
|
+
return chalk68.white;
|
|
20750
20758
|
}
|
|
20751
20759
|
}
|
|
20752
20760
|
function renderWorkflowList(workflows, options) {
|
|
@@ -20765,7 +20773,7 @@ function renderWorkflowList(workflows, options) {
|
|
|
20765
20773
|
}, null, 2);
|
|
20766
20774
|
}
|
|
20767
20775
|
if (workflows.length === 0) {
|
|
20768
|
-
return
|
|
20776
|
+
return chalk68.yellow("No workflows found");
|
|
20769
20777
|
}
|
|
20770
20778
|
const NAME_WIDTH = 30;
|
|
20771
20779
|
const VERSION_WIDTH = 10;
|
|
@@ -20773,10 +20781,10 @@ function renderWorkflowList(workflows, options) {
|
|
|
20773
20781
|
const UPDATED_WIDTH = 20;
|
|
20774
20782
|
const GAP = " ";
|
|
20775
20783
|
const headerLine = [
|
|
20776
|
-
|
|
20777
|
-
|
|
20778
|
-
|
|
20779
|
-
|
|
20784
|
+
chalk68.bold("NAME".padEnd(NAME_WIDTH)),
|
|
20785
|
+
chalk68.bold("VER".padEnd(VERSION_WIDTH)),
|
|
20786
|
+
chalk68.bold("TAGS".padEnd(TAGS_WIDTH)),
|
|
20787
|
+
chalk68.bold("UPDATED")
|
|
20780
20788
|
].join(GAP);
|
|
20781
20789
|
const sepLine = "─".repeat(NAME_WIDTH + VERSION_WIDTH + TAGS_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
20782
20790
|
const rows = workflows.map((w) => {
|
|
@@ -20791,18 +20799,18 @@ function renderWorkflowList(workflows, options) {
|
|
|
20791
20799
|
}
|
|
20792
20800
|
function renderWorkflowDetail(workflow, options) {
|
|
20793
20801
|
const lines = [];
|
|
20794
|
-
lines.push(
|
|
20802
|
+
lines.push(chalk68.bold(`
|
|
20795
20803
|
\uD83D\uDCCB Workflow Details
|
|
20796
20804
|
`));
|
|
20797
|
-
lines.push(` ${
|
|
20798
|
-
lines.push(` ${
|
|
20799
|
-
lines.push(` ${
|
|
20800
|
-
lines.push(` ${
|
|
20801
|
-
lines.push(` ${
|
|
20802
|
-
lines.push(` ${
|
|
20803
|
-
lines.push(` ${
|
|
20805
|
+
lines.push(` ${chalk68.cyan("ID:")} ${workflow.id}`);
|
|
20806
|
+
lines.push(` ${chalk68.cyan("Name:")} ${workflow.name}`);
|
|
20807
|
+
lines.push(` ${chalk68.cyan("Version:")} ${workflow.version}`);
|
|
20808
|
+
lines.push(` ${chalk68.cyan("Description:")} ${workflow.description || "-"}`);
|
|
20809
|
+
lines.push(` ${chalk68.cyan("Tags:")} ${workflow.tags.join(", ") || "-"}`);
|
|
20810
|
+
lines.push(` ${chalk68.cyan("Created:")} ${formatDate(workflow.createdAt)}`);
|
|
20811
|
+
lines.push(` ${chalk68.cyan("Updated:")} ${formatDate(workflow.updatedAt)}`);
|
|
20804
20812
|
const nodeCount = workflow.definition.nodes.length;
|
|
20805
|
-
lines.push(
|
|
20813
|
+
lines.push(chalk68.bold(`
|
|
20806
20814
|
\uD83D\uDCCA Nodes Summary
|
|
20807
20815
|
`));
|
|
20808
20816
|
lines.push(` Total: ${nodeCount} nodes`);
|
|
@@ -20814,7 +20822,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
20814
20822
|
lines.push(` - ${type}: ${count}`);
|
|
20815
20823
|
}
|
|
20816
20824
|
if (workflow.definition.config) {
|
|
20817
|
-
lines.push(
|
|
20825
|
+
lines.push(chalk68.bold(`
|
|
20818
20826
|
⚙️ Configuration
|
|
20819
20827
|
`));
|
|
20820
20828
|
if (workflow.definition.config.parallel_limit !== undefined) {
|
|
@@ -20828,7 +20836,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
20828
20836
|
}
|
|
20829
20837
|
}
|
|
20830
20838
|
if (options?.includeRuns && options.includeRuns.length > 0) {
|
|
20831
|
-
lines.push(
|
|
20839
|
+
lines.push(chalk68.bold(`
|
|
20832
20840
|
\uD83D\uDCDC Recent Runs
|
|
20833
20841
|
`));
|
|
20834
20842
|
lines.push(renderRunsList(options.includeRuns.slice(0, 5)));
|
|
@@ -20852,7 +20860,7 @@ function renderRunsList(runs, options) {
|
|
|
20852
20860
|
}, null, 2);
|
|
20853
20861
|
}
|
|
20854
20862
|
if (runs.length === 0) {
|
|
20855
|
-
return
|
|
20863
|
+
return chalk68.yellow("No runs found");
|
|
20856
20864
|
}
|
|
20857
20865
|
const ID_WIDTH = 20;
|
|
20858
20866
|
const STATUS_WIDTH = 12;
|
|
@@ -20860,10 +20868,10 @@ function renderRunsList(runs, options) {
|
|
|
20860
20868
|
const UPDATED_WIDTH = 20;
|
|
20861
20869
|
const GAP = " ";
|
|
20862
20870
|
const headerLine = [
|
|
20863
|
-
|
|
20864
|
-
|
|
20865
|
-
|
|
20866
|
-
|
|
20871
|
+
chalk68.bold("RUN ID".padEnd(ID_WIDTH)),
|
|
20872
|
+
chalk68.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
20873
|
+
chalk68.bold("DURATION".padEnd(DURATION_WIDTH)),
|
|
20874
|
+
chalk68.bold("STARTED")
|
|
20867
20875
|
].join(GAP);
|
|
20868
20876
|
const sepLine = "─".repeat(ID_WIDTH + STATUS_WIDTH + DURATION_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
20869
20877
|
const rows = runs.map((r) => {
|
|
@@ -20878,34 +20886,34 @@ function renderRunsList(runs, options) {
|
|
|
20878
20886
|
}
|
|
20879
20887
|
function renderRunDetail(run) {
|
|
20880
20888
|
const lines = [];
|
|
20881
|
-
lines.push(
|
|
20889
|
+
lines.push(chalk68.bold(`
|
|
20882
20890
|
\uD83C\uDFC3 Run Details
|
|
20883
20891
|
`));
|
|
20884
|
-
lines.push(` ${
|
|
20885
|
-
lines.push(` ${
|
|
20886
|
-
lines.push(` ${
|
|
20887
|
-
lines.push(` ${
|
|
20892
|
+
lines.push(` ${chalk68.cyan("Run ID:")} ${run.id}`);
|
|
20893
|
+
lines.push(` ${chalk68.cyan("Workflow:")} ${run.workflowId}`);
|
|
20894
|
+
lines.push(` ${chalk68.cyan("Status:")} ${statusColor(run.status)(run.status)}`);
|
|
20895
|
+
lines.push(` ${chalk68.cyan("Started:")} ${formatDate(run.startedAt)}`);
|
|
20888
20896
|
if (run.pausedAt) {
|
|
20889
|
-
lines.push(` ${
|
|
20897
|
+
lines.push(` ${chalk68.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
|
|
20890
20898
|
}
|
|
20891
20899
|
if (run.resumedAt) {
|
|
20892
|
-
lines.push(` ${
|
|
20900
|
+
lines.push(` ${chalk68.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
|
|
20893
20901
|
}
|
|
20894
20902
|
if (run.stoppedAt) {
|
|
20895
|
-
lines.push(` ${
|
|
20903
|
+
lines.push(` ${chalk68.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
|
|
20896
20904
|
}
|
|
20897
20905
|
if (run.completedAt) {
|
|
20898
|
-
lines.push(` ${
|
|
20906
|
+
lines.push(` ${chalk68.cyan("Completed:")} ${formatDate(run.completedAt)}`);
|
|
20899
20907
|
}
|
|
20900
|
-
lines.push(` ${
|
|
20908
|
+
lines.push(` ${chalk68.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
|
|
20901
20909
|
if (run.error) {
|
|
20902
|
-
lines.push(
|
|
20910
|
+
lines.push(chalk68.bold(`
|
|
20903
20911
|
❌ Error
|
|
20904
20912
|
`));
|
|
20905
|
-
lines.push(` ${
|
|
20913
|
+
lines.push(` ${chalk68.red(run.error)}`);
|
|
20906
20914
|
}
|
|
20907
20915
|
if (run.output) {
|
|
20908
|
-
lines.push(
|
|
20916
|
+
lines.push(chalk68.bold(`
|
|
20909
20917
|
\uD83D\uDCE4 Output
|
|
20910
20918
|
`));
|
|
20911
20919
|
lines.push(" " + JSON.stringify(run.output, null, 2).split(`
|
|
@@ -20916,49 +20924,49 @@ function renderRunDetail(run) {
|
|
|
20916
20924
|
`);
|
|
20917
20925
|
}
|
|
20918
20926
|
function renderWorkflowAdded(workflow) {
|
|
20919
|
-
return
|
|
20927
|
+
return chalk68.green(`
|
|
20920
20928
|
✅ Workflow '${workflow.name}' added successfully
|
|
20921
20929
|
`) + ` ID: ${workflow.id}
|
|
20922
20930
|
` + ` Version: ${workflow.version}
|
|
20923
20931
|
`;
|
|
20924
20932
|
}
|
|
20925
20933
|
function renderWorkflowUpdated(workflow) {
|
|
20926
|
-
return
|
|
20934
|
+
return chalk68.green(`
|
|
20927
20935
|
✅ Workflow '${workflow.name}' updated successfully
|
|
20928
20936
|
`) + ` ID: ${workflow.id}
|
|
20929
20937
|
`;
|
|
20930
20938
|
}
|
|
20931
20939
|
function renderWorkflowDeleted(name) {
|
|
20932
|
-
return
|
|
20940
|
+
return chalk68.green(`
|
|
20933
20941
|
✅ Workflow '${name}' deleted successfully
|
|
20934
20942
|
`);
|
|
20935
20943
|
}
|
|
20936
20944
|
function renderRunResult(result) {
|
|
20937
20945
|
const lines = [];
|
|
20938
20946
|
if (result.status === "completed") {
|
|
20939
|
-
lines.push(
|
|
20947
|
+
lines.push(chalk68.green(`
|
|
20940
20948
|
✅ Workflow completed successfully`));
|
|
20941
20949
|
} else if (result.status === "failed") {
|
|
20942
|
-
lines.push(
|
|
20950
|
+
lines.push(chalk68.red(`
|
|
20943
20951
|
❌ Workflow failed`));
|
|
20944
20952
|
} else if (result.status === "stopped") {
|
|
20945
|
-
lines.push(
|
|
20953
|
+
lines.push(chalk68.yellow(`
|
|
20946
20954
|
⚠️ Workflow stopped`));
|
|
20947
20955
|
} else if (result.status === "paused") {
|
|
20948
|
-
lines.push(
|
|
20956
|
+
lines.push(chalk68.yellow(`
|
|
20949
20957
|
⏸️ Workflow paused`));
|
|
20950
20958
|
if (result.pendingNodeId) {
|
|
20951
|
-
lines.push(
|
|
20959
|
+
lines.push(chalk68.gray(` Pending node: ${result.pendingNodeId}`));
|
|
20952
20960
|
}
|
|
20953
20961
|
if (result.query) {
|
|
20954
20962
|
lines.push("");
|
|
20955
|
-
lines.push(
|
|
20963
|
+
lines.push(chalk68.bold("\uD83D\uDCAC Agent asked: ") + chalk68.white(result.query));
|
|
20956
20964
|
}
|
|
20957
20965
|
if (result.agentSessionId) {
|
|
20958
|
-
lines.push(
|
|
20966
|
+
lines.push(chalk68.gray(` Agent sub-session: ${result.agentSessionId}`));
|
|
20959
20967
|
}
|
|
20960
20968
|
} else {
|
|
20961
|
-
lines.push(
|
|
20969
|
+
lines.push(chalk68.blue(`
|
|
20962
20970
|
\uD83D\uDD04 Workflow ${result.status}`));
|
|
20963
20971
|
}
|
|
20964
20972
|
lines.push(` Run ID: ${result.runId}`);
|
|
@@ -20966,11 +20974,11 @@ function renderRunResult(result) {
|
|
|
20966
20974
|
lines.push(` Duration: ${formatDuration(result.durationMs)}`);
|
|
20967
20975
|
}
|
|
20968
20976
|
if (result.error) {
|
|
20969
|
-
lines.push(
|
|
20977
|
+
lines.push(chalk68.red(`
|
|
20970
20978
|
Error: ${result.error}`));
|
|
20971
20979
|
}
|
|
20972
20980
|
if (result.output) {
|
|
20973
|
-
lines.push(
|
|
20981
|
+
lines.push(chalk68.bold(`
|
|
20974
20982
|
\uD83D\uDCE4 Output:`));
|
|
20975
20983
|
lines.push(JSON.stringify(result.output, null, 2));
|
|
20976
20984
|
}
|
|
@@ -20984,10 +20992,10 @@ function renderNodesList(nodes) {
|
|
|
20984
20992
|
const DEPS_WIDTH = 20;
|
|
20985
20993
|
const GAP = " ";
|
|
20986
20994
|
const headerLine = [
|
|
20987
|
-
|
|
20988
|
-
|
|
20989
|
-
|
|
20990
|
-
|
|
20995
|
+
chalk68.bold("NODE ID".padEnd(ID_WIDTH)),
|
|
20996
|
+
chalk68.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
20997
|
+
chalk68.bold("NAME".padEnd(NAME_WIDTH)),
|
|
20998
|
+
chalk68.bold("DEPENDS ON")
|
|
20991
20999
|
].join(GAP);
|
|
20992
21000
|
const sepLine = "─".repeat(ID_WIDTH + TYPE_WIDTH + NAME_WIDTH + DEPS_WIDTH + GAP.length * 3);
|
|
20993
21001
|
const rows = nodes.map((n) => {
|
|
@@ -21002,7 +21010,7 @@ function renderNodesList(nodes) {
|
|
|
21002
21010
|
}
|
|
21003
21011
|
|
|
21004
21012
|
// src/commands/workflow/commands/list.ts
|
|
21005
|
-
import
|
|
21013
|
+
import chalk69 from "chalk";
|
|
21006
21014
|
import { createWorkflowListTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
21007
21015
|
function buildListWorkflowsJson(workflows, total, args, availableTags) {
|
|
21008
21016
|
const output = {
|
|
@@ -21162,20 +21170,20 @@ var WorkflowListCommand = {
|
|
|
21162
21170
|
if (total > workflows.length) {
|
|
21163
21171
|
const start = finalOffset + 1;
|
|
21164
21172
|
const end = finalOffset + workflows.length;
|
|
21165
|
-
output.log(
|
|
21173
|
+
output.log(chalk69.green(`
|
|
21166
21174
|
✅ 显示 ${start}-${end} / 共 ${total} 个 Workflow`));
|
|
21167
21175
|
const totalPages = Math.ceil(total / pageSize);
|
|
21168
21176
|
const currentPage = Math.floor(finalOffset / pageSize) + 1;
|
|
21169
21177
|
if (totalPages > 1) {
|
|
21170
|
-
output.log(
|
|
21178
|
+
output.log(chalk69.cyan(`\uD83D\uDCC4 第 ${currentPage} / ${totalPages} 页`));
|
|
21171
21179
|
}
|
|
21172
21180
|
} else {
|
|
21173
|
-
output.log(
|
|
21181
|
+
output.log(chalk69.green(`
|
|
21174
21182
|
✅ 共 ${total} 个 Workflow`));
|
|
21175
21183
|
}
|
|
21176
21184
|
if (availableTags.length > 0) {
|
|
21177
21185
|
const tagsLine = availableTags.map((t) => `${t.name}(${t.count})`).join(", ");
|
|
21178
|
-
output.log(
|
|
21186
|
+
output.log(chalk69.cyan(`
|
|
21179
21187
|
\uD83C\uDFF7️ Available tags: ${tagsLine}`));
|
|
21180
21188
|
}
|
|
21181
21189
|
}
|
|
@@ -21895,7 +21903,7 @@ class WorkflowValidator {
|
|
|
21895
21903
|
|
|
21896
21904
|
// src/commands/workflow/commands/add.ts
|
|
21897
21905
|
import { validateWorkflowDefinition } from "@ai-setting/roy-agent-core/env/workflow/utils";
|
|
21898
|
-
import
|
|
21906
|
+
import chalk70 from "chalk";
|
|
21899
21907
|
import fs3 from "fs";
|
|
21900
21908
|
import path6 from "path";
|
|
21901
21909
|
async function parseWorkflowContent(content, filename) {
|
|
@@ -22037,7 +22045,7 @@ var WorkflowAddCommand = {
|
|
|
22037
22045
|
definition = await parseWorkflowContent(content, filePath);
|
|
22038
22046
|
workflowName = a.name || definition.name || path6.basename(filePath);
|
|
22039
22047
|
if (a.validate) {
|
|
22040
|
-
output.log(
|
|
22048
|
+
output.log(chalk70.blue("\uD83D\uDD0D Validating workflow..."));
|
|
22041
22049
|
const dagResult = validateWorkflowDefinition(definition);
|
|
22042
22050
|
if (!dagResult.valid) {
|
|
22043
22051
|
output.error(`
|
|
@@ -22061,11 +22069,11 @@ var WorkflowAddCommand = {
|
|
|
22061
22069
|
});
|
|
22062
22070
|
process.exit(1);
|
|
22063
22071
|
}
|
|
22064
|
-
output.log(
|
|
22072
|
+
output.log(chalk70.green(`✅ Workflow validation passed
|
|
22065
22073
|
`));
|
|
22066
22074
|
}
|
|
22067
22075
|
} else if (a.desc) {
|
|
22068
|
-
output.log(
|
|
22076
|
+
output.log(chalk70.blue(`\uD83E\uDD16 Generating workflow from description...
|
|
22069
22077
|
`));
|
|
22070
22078
|
const agentComponent = env.getComponent("agent");
|
|
22071
22079
|
if (!agentComponent) {
|
|
@@ -22087,20 +22095,20 @@ ${a.desc}
|
|
|
22087
22095
|
1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
|
|
22088
22096
|
2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
|
|
22089
22097
|
3. 验证通过后才输出最终 YAML`;
|
|
22090
|
-
output.log(
|
|
22098
|
+
output.log(chalk70.gray("Running workflow-extract agent..."));
|
|
22091
22099
|
const result = await agentComponent.run("workflow-extract", prompt);
|
|
22092
22100
|
const agentOutput = result.finalText || "";
|
|
22093
22101
|
definition = parseYamlFromAgentOutput(agentOutput);
|
|
22094
22102
|
if (definition === null) {
|
|
22095
22103
|
output.error("Failed to parse workflow from agent output");
|
|
22096
|
-
output.log(
|
|
22104
|
+
output.log(chalk70.gray(`
|
|
22097
22105
|
Agent output:
|
|
22098
22106
|
` + agentOutput.slice(0, 500)));
|
|
22099
22107
|
process.exit(1);
|
|
22100
22108
|
}
|
|
22101
22109
|
workflowName = a.name || definition.name;
|
|
22102
22110
|
if (a.validate) {
|
|
22103
|
-
output.log(
|
|
22111
|
+
output.log(chalk70.blue(`
|
|
22104
22112
|
\uD83D\uDD0D Validating generated workflow...`));
|
|
22105
22113
|
const dagResult = validateWorkflowDefinition(definition);
|
|
22106
22114
|
if (!dagResult.valid) {
|
|
@@ -22109,7 +22117,7 @@ Agent output:
|
|
|
22109
22117
|
dagResult.errors.forEach((msg, i) => {
|
|
22110
22118
|
output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
|
|
22111
22119
|
});
|
|
22112
|
-
output.log(
|
|
22120
|
+
output.log(chalk70.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
22113
22121
|
process.exit(1);
|
|
22114
22122
|
}
|
|
22115
22123
|
const validator = new WorkflowValidator;
|
|
@@ -22124,16 +22132,16 @@ Agent output:
|
|
|
22124
22132
|
output.error(` Fix: ${error.fix}
|
|
22125
22133
|
`);
|
|
22126
22134
|
});
|
|
22127
|
-
output.log(
|
|
22135
|
+
output.log(chalk70.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
22128
22136
|
process.exit(1);
|
|
22129
22137
|
}
|
|
22130
|
-
output.log(
|
|
22138
|
+
output.log(chalk70.green(`✅ Generated workflow validation passed
|
|
22131
22139
|
`));
|
|
22132
22140
|
}
|
|
22133
22141
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
22134
|
-
output.log(
|
|
22142
|
+
output.log(chalk70.gray("--- Generated YAML ---"));
|
|
22135
22143
|
output.log(yaml.stringify(definition));
|
|
22136
|
-
output.log(
|
|
22144
|
+
output.log(chalk70.gray(`------------------------
|
|
22137
22145
|
`));
|
|
22138
22146
|
} else {
|
|
22139
22147
|
output.error("Please provide --file or --desc option");
|
|
@@ -22159,10 +22167,10 @@ Agent output:
|
|
|
22159
22167
|
force: a.force
|
|
22160
22168
|
});
|
|
22161
22169
|
output.log(renderWorkflowAdded(workflow));
|
|
22162
|
-
output.log(
|
|
22170
|
+
output.log(chalk70.bold(`
|
|
22163
22171
|
\uD83D\uDCCA Nodes Summary:`));
|
|
22164
22172
|
output.log(renderNodesList(definition.nodes));
|
|
22165
|
-
output.log(
|
|
22173
|
+
output.log(chalk70.green(`
|
|
22166
22174
|
✅ Workflow '${workflowName}' added successfully`));
|
|
22167
22175
|
} catch (error) {
|
|
22168
22176
|
if (error.message?.includes("already exists") && !a.force) {
|
|
@@ -22179,7 +22187,7 @@ Agent output:
|
|
|
22179
22187
|
};
|
|
22180
22188
|
|
|
22181
22189
|
// src/commands/workflow/commands/get.ts
|
|
22182
|
-
import
|
|
22190
|
+
import chalk71 from "chalk";
|
|
22183
22191
|
import { createWorkflowGetTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
22184
22192
|
var WorkflowGetCommand = {
|
|
22185
22193
|
command: "get <identifier>",
|
|
@@ -22317,15 +22325,15 @@ var WorkflowGetCommand = {
|
|
|
22317
22325
|
} else {
|
|
22318
22326
|
output.log(renderWorkflowDetail(workflow, { includeRuns: runs }));
|
|
22319
22327
|
if (args.includeNodes) {
|
|
22320
|
-
output.log(
|
|
22328
|
+
output.log(chalk71.bold(`
|
|
22321
22329
|
\uD83D\uDCCB All Nodes:`));
|
|
22322
22330
|
output.log(renderNodesList(data.nodes || []));
|
|
22323
22331
|
}
|
|
22324
22332
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
22325
22333
|
const defYaml = yaml.stringify(data.definition || {}, { indent: 2 });
|
|
22326
|
-
output.log(
|
|
22334
|
+
output.log(chalk71.bold(`
|
|
22327
22335
|
\uD83D\uDCC4 Definition (YAML):`));
|
|
22328
|
-
output.log(
|
|
22336
|
+
output.log(chalk71.gray(defYaml));
|
|
22329
22337
|
}
|
|
22330
22338
|
}
|
|
22331
22339
|
} catch (error) {
|
|
@@ -22338,7 +22346,7 @@ var WorkflowGetCommand = {
|
|
|
22338
22346
|
};
|
|
22339
22347
|
|
|
22340
22348
|
// src/commands/workflow/commands/update.ts
|
|
22341
|
-
import
|
|
22349
|
+
import chalk72 from "chalk";
|
|
22342
22350
|
import fs4 from "fs";
|
|
22343
22351
|
import path7 from "path";
|
|
22344
22352
|
import { parseWorkflowFile } from "@ai-setting/roy-agent-core/env/workflow/types";
|
|
@@ -22411,7 +22419,7 @@ var WorkflowUpdateCommand = {
|
|
|
22411
22419
|
const tags = a.tags ? a.tags.split(",").map((t) => t.trim()) : undefined;
|
|
22412
22420
|
const workflow = await service.updateWorkflow(a.name, updates, { tags });
|
|
22413
22421
|
output.log(renderWorkflowUpdated(workflow));
|
|
22414
|
-
output.log(
|
|
22422
|
+
output.log(chalk72.green(`
|
|
22415
22423
|
✅ Workflow '${a.name}' updated successfully`));
|
|
22416
22424
|
} catch (error) {
|
|
22417
22425
|
output.error(`Failed to update workflow: ${error}`);
|
|
@@ -22423,7 +22431,7 @@ var WorkflowUpdateCommand = {
|
|
|
22423
22431
|
};
|
|
22424
22432
|
|
|
22425
22433
|
// src/commands/workflow/commands/remove.ts
|
|
22426
|
-
import
|
|
22434
|
+
import chalk73 from "chalk";
|
|
22427
22435
|
var WorkflowRemoveCommand = {
|
|
22428
22436
|
command: "remove <name>",
|
|
22429
22437
|
describe: "删除 Workflow",
|
|
@@ -22462,8 +22470,8 @@ var WorkflowRemoveCommand = {
|
|
|
22462
22470
|
process.exit(1);
|
|
22463
22471
|
}
|
|
22464
22472
|
if (!args.force) {
|
|
22465
|
-
output.log(
|
|
22466
|
-
output.log(
|
|
22473
|
+
output.log(chalk73.yellow(`Are you sure you want to delete workflow '${args.name}'?`));
|
|
22474
|
+
output.log(chalk73.gray("Use --force to skip confirmation"));
|
|
22467
22475
|
process.exit(1);
|
|
22468
22476
|
}
|
|
22469
22477
|
const deleted = await service.deleteWorkflow(args.name);
|
|
@@ -22483,7 +22491,7 @@ var WorkflowRemoveCommand = {
|
|
|
22483
22491
|
|
|
22484
22492
|
// src/commands/workflow/commands/run.ts
|
|
22485
22493
|
var import_yaml = __toESM(require_dist(), 1);
|
|
22486
|
-
import
|
|
22494
|
+
import chalk74 from "chalk";
|
|
22487
22495
|
import fs5 from "fs";
|
|
22488
22496
|
import path8 from "path";
|
|
22489
22497
|
import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
@@ -22585,7 +22593,7 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22585
22593
|
}
|
|
22586
22594
|
if (args.session) {
|
|
22587
22595
|
const sessionId = args.session;
|
|
22588
|
-
output.log(
|
|
22596
|
+
output.log(chalk74.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
22589
22597
|
try {
|
|
22590
22598
|
const resumeInput = typeof input === "string" ? { userQuery: input } : input;
|
|
22591
22599
|
const result = await service.resumeSession(sessionId, {
|
|
@@ -22631,17 +22639,17 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22631
22639
|
definition = { ...definition, name: args.name };
|
|
22632
22640
|
}
|
|
22633
22641
|
const workflow = await service.createWorkflow(definition, { force: true });
|
|
22634
|
-
output.log(
|
|
22635
|
-
output.log(
|
|
22642
|
+
output.log(chalk74.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
|
|
22643
|
+
output.log(chalk74.green(`✅ Workflow registered: ${workflow.name} (${workflow.id})`));
|
|
22636
22644
|
if (args.registerOnly) {
|
|
22637
|
-
output.log(
|
|
22645
|
+
output.log(chalk74.gray("ℹ️ Use --register-only, skipping execution"));
|
|
22638
22646
|
if (workflowSpan) {
|
|
22639
22647
|
workflowSpan.end();
|
|
22640
22648
|
}
|
|
22641
22649
|
await envService.dispose();
|
|
22642
22650
|
process.exit(0);
|
|
22643
22651
|
}
|
|
22644
|
-
output.log(
|
|
22652
|
+
output.log(chalk74.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
|
|
22645
22653
|
const fileBranchInput = typeof input === "string" ? undefined : input;
|
|
22646
22654
|
const result = await service.runWorkflow(definition, fileBranchInput, runOptions);
|
|
22647
22655
|
output.log(renderRunResult({
|
|
@@ -22655,7 +22663,7 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22655
22663
|
...result.agentSessionId ? { agentSessionId: result.agentSessionId } : {}
|
|
22656
22664
|
}));
|
|
22657
22665
|
if (result.status === "paused") {
|
|
22658
|
-
output.log(
|
|
22666
|
+
output.log(chalk74.gray(`
|
|
22659
22667
|
\uD83D\uDCA1 Resume with: roy-agent workflow run ${result.runId} --session ${result.runId} --input "<your answer>"`));
|
|
22660
22668
|
}
|
|
22661
22669
|
} else {
|
|
@@ -22672,7 +22680,7 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22672
22680
|
output.error(toolResult.error || `Failed to run workflow: ${args.identifier}`);
|
|
22673
22681
|
if (runId) {
|
|
22674
22682
|
output.error(`Run ID: ${runId}`);
|
|
22675
|
-
output.error(
|
|
22683
|
+
output.error(chalk74.gray(`
|
|
22676
22684
|
\uD83D\uDCA1 Use "roy-agent workflow status ${runId}" to check progress, or "roy-agent workflow run ${args.identifier} --session ${runId}" to resume`));
|
|
22677
22685
|
}
|
|
22678
22686
|
process.exit(1);
|
|
@@ -22689,7 +22697,7 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22689
22697
|
...runData.agent_session_id ? { agentSessionId: runData.agent_session_id } : {}
|
|
22690
22698
|
}));
|
|
22691
22699
|
if (runData.status === "paused") {
|
|
22692
|
-
output.log(
|
|
22700
|
+
output.log(chalk74.gray(`
|
|
22693
22701
|
\uD83D\uDCA1 Resume with: roy-agent workflow run ${args.identifier} --session ${runData.run_id} --input "<your answer>"`));
|
|
22694
22702
|
}
|
|
22695
22703
|
}
|
|
@@ -22764,7 +22772,7 @@ var WorkflowRunCommand = {
|
|
|
22764
22772
|
};
|
|
22765
22773
|
|
|
22766
22774
|
// src/commands/workflow/commands/stop.ts
|
|
22767
|
-
import
|
|
22775
|
+
import chalk75 from "chalk";
|
|
22768
22776
|
import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
22769
22777
|
import { wrapFunction as wrapFunction3 } from "@ai-setting/roy-agent-core";
|
|
22770
22778
|
var stopWorkflow = wrapFunction3(async function stopWorkflowImpl(args) {
|
|
@@ -22789,7 +22797,7 @@ var stopWorkflow = wrapFunction3(async function stopWorkflowImpl(args) {
|
|
|
22789
22797
|
output.error(result.error || `Failed to stop workflow: ${args.runId}`);
|
|
22790
22798
|
process.exit(1);
|
|
22791
22799
|
}
|
|
22792
|
-
output.log(
|
|
22800
|
+
output.log(chalk75.red(`
|
|
22793
22801
|
⏹️ Workflow stopped: ${args.runId}`));
|
|
22794
22802
|
} catch (error) {
|
|
22795
22803
|
output.error(`Failed to stop workflow: ${error}`);
|
|
@@ -22813,7 +22821,7 @@ var WorkflowStopCommand = {
|
|
|
22813
22821
|
};
|
|
22814
22822
|
|
|
22815
22823
|
// src/commands/workflow/commands/status.ts
|
|
22816
|
-
import
|
|
22824
|
+
import chalk76 from "chalk";
|
|
22817
22825
|
import { createWorkflowRunStatusTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
22818
22826
|
var WorkflowStatusCommand = {
|
|
22819
22827
|
command: "status <runId>",
|
|
@@ -22906,7 +22914,7 @@ var WorkflowStatusCommand = {
|
|
|
22906
22914
|
stopped: "⏹️"
|
|
22907
22915
|
};
|
|
22908
22916
|
const emoji = statusEmoji[status] || "❓";
|
|
22909
|
-
output.log(
|
|
22917
|
+
output.log(chalk76.bold(`
|
|
22910
22918
|
${emoji} Status: ${status.toUpperCase()}`));
|
|
22911
22919
|
}
|
|
22912
22920
|
} catch (error) {
|
|
@@ -22919,7 +22927,7 @@ ${emoji} Status: ${status.toUpperCase()}`));
|
|
|
22919
22927
|
};
|
|
22920
22928
|
|
|
22921
22929
|
// src/commands/workflow/commands/nodes.ts
|
|
22922
|
-
import
|
|
22930
|
+
import chalk77 from "chalk";
|
|
22923
22931
|
var BUILT_IN_NODES = [
|
|
22924
22932
|
{
|
|
22925
22933
|
name: "ToolNode",
|
|
@@ -23256,7 +23264,7 @@ nodes:
|
|
|
23256
23264
|
];
|
|
23257
23265
|
function renderNodeTypesTable(nodes) {
|
|
23258
23266
|
const lines = [];
|
|
23259
|
-
lines.push(
|
|
23267
|
+
lines.push(chalk77.bold(`
|
|
23260
23268
|
\uD83D\uDCE6 Built-in Node Types
|
|
23261
23269
|
`));
|
|
23262
23270
|
lines.push("┌────────────┬────────────────────┬─────────────────────────────────────────────────────────────┐");
|
|
@@ -23274,29 +23282,29 @@ function renderNodeTypesTable(nodes) {
|
|
|
23274
23282
|
}
|
|
23275
23283
|
function renderNodeDetail(node) {
|
|
23276
23284
|
const lines = [];
|
|
23277
|
-
lines.push(
|
|
23285
|
+
lines.push(chalk77.bold(`
|
|
23278
23286
|
[${node.type}] ${node.name}`));
|
|
23279
|
-
lines.push(
|
|
23287
|
+
lines.push(chalk77.dim("─".repeat(60)) + `
|
|
23280
23288
|
`);
|
|
23281
|
-
lines.push(
|
|
23289
|
+
lines.push(chalk77.bold("Description:"));
|
|
23282
23290
|
lines.push(` ${node.description}
|
|
23283
23291
|
`);
|
|
23284
|
-
lines.push(
|
|
23292
|
+
lines.push(chalk77.bold("Configuration:"));
|
|
23285
23293
|
lines.push(' type: "' + node.type + '"');
|
|
23286
23294
|
lines.push(" config:");
|
|
23287
23295
|
for (const input of node.inputs) {
|
|
23288
|
-
const required = input.required ?
|
|
23296
|
+
const required = input.required ? chalk77.red("*") : " ";
|
|
23289
23297
|
lines.push(` ${input.name} (${input.type})${required}`);
|
|
23290
23298
|
lines.push(` ${input.description}`);
|
|
23291
23299
|
}
|
|
23292
23300
|
lines.push(`
|
|
23293
|
-
${
|
|
23301
|
+
${chalk77.bold("Output:")} ${node.output}`);
|
|
23294
23302
|
if (node.example) {
|
|
23295
|
-
lines.push(
|
|
23303
|
+
lines.push(chalk77.bold(`
|
|
23296
23304
|
Example:`));
|
|
23297
|
-
lines.push(
|
|
23305
|
+
lines.push(chalk77.gray("```yaml"));
|
|
23298
23306
|
lines.push(node.example);
|
|
23299
|
-
lines.push(
|
|
23307
|
+
lines.push(chalk77.gray("```"));
|
|
23300
23308
|
}
|
|
23301
23309
|
return lines.join(`
|
|
23302
23310
|
`);
|
|
@@ -23312,16 +23320,16 @@ var WorkflowNodesCommand = {
|
|
|
23312
23320
|
const nodeType = args.type?.toLowerCase();
|
|
23313
23321
|
if (!nodeType) {
|
|
23314
23322
|
console.log(renderNodeTypesTable(BUILT_IN_NODES));
|
|
23315
|
-
console.log(
|
|
23316
|
-
Use `) +
|
|
23317
|
-
console.log(
|
|
23323
|
+
console.log(chalk77.gray(`
|
|
23324
|
+
Use `) + chalk77.cyan("roy-agent workflow nodes <type>") + chalk77.gray(" for detailed information"));
|
|
23325
|
+
console.log(chalk77.gray("Available types: ") + chalk77.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
23318
23326
|
return;
|
|
23319
23327
|
}
|
|
23320
23328
|
const node = BUILT_IN_NODES.find((n) => n.type === nodeType);
|
|
23321
23329
|
if (!node) {
|
|
23322
|
-
console.log(
|
|
23330
|
+
console.log(chalk77.red(`
|
|
23323
23331
|
❌ Unknown node type: ${nodeType}`));
|
|
23324
|
-
console.log(
|
|
23332
|
+
console.log(chalk77.gray("Available types: ") + chalk77.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
23325
23333
|
process.exit(1);
|
|
23326
23334
|
}
|
|
23327
23335
|
console.log(renderNodeDetail(node));
|
|
@@ -23329,7 +23337,7 @@ Use `) + chalk76.cyan("roy-agent workflow nodes <type>") + chalk76.gray(" for de
|
|
|
23329
23337
|
};
|
|
23330
23338
|
|
|
23331
23339
|
// src/commands/workflow/commands/validate.ts
|
|
23332
|
-
import
|
|
23340
|
+
import chalk78 from "chalk";
|
|
23333
23341
|
import { readFileSync as readFileSync2 } from "fs";
|
|
23334
23342
|
async function parseWorkflowInput(input, yamlStr) {
|
|
23335
23343
|
const parseYaml = async (content) => {
|
|
@@ -23362,25 +23370,25 @@ function renderResult(result, options) {
|
|
|
23362
23370
|
return;
|
|
23363
23371
|
}
|
|
23364
23372
|
if (result.valid) {
|
|
23365
|
-
console.log(
|
|
23373
|
+
console.log(chalk78.green(`
|
|
23366
23374
|
✅ Workflow validation PASSED
|
|
23367
23375
|
`));
|
|
23368
|
-
console.log(
|
|
23376
|
+
console.log(chalk78.bold(`Workflow: ${result.workflowName}`));
|
|
23369
23377
|
console.log(`Nodes: ${result.nodeCount}`);
|
|
23370
23378
|
console.log(`
|
|
23371
23379
|
Valid nodes:`);
|
|
23372
|
-
console.log(
|
|
23380
|
+
console.log(chalk78.green(" ✓ All nodes passed validation"));
|
|
23373
23381
|
} else {
|
|
23374
|
-
console.log(
|
|
23382
|
+
console.log(chalk78.red(`
|
|
23375
23383
|
❌ Workflow validation FAILED (${result.errors.length} errors found)
|
|
23376
23384
|
`));
|
|
23377
23385
|
result.errors.forEach((error, index) => {
|
|
23378
|
-
console.log(
|
|
23379
|
-
console.log(` ${
|
|
23380
|
-
console.log(` ${
|
|
23381
|
-
console.log(` ${
|
|
23382
|
-
console.log(` ${
|
|
23383
|
-
console.log(` ${
|
|
23386
|
+
console.log(chalk78.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
|
|
23387
|
+
console.log(` ${chalk78.bold("Type:")} ${error.type}`);
|
|
23388
|
+
console.log(` ${chalk78.bold("Description:")} ${error.description}`);
|
|
23389
|
+
console.log(` ${chalk78.bold("Expected:")} ${error.expected}`);
|
|
23390
|
+
console.log(` ${chalk78.bold("Actual:")} ${error.actual}`);
|
|
23391
|
+
console.log(` ${chalk78.green("Fix:")} ${error.fix}`);
|
|
23384
23392
|
console.log();
|
|
23385
23393
|
});
|
|
23386
23394
|
}
|
|
@@ -23405,7 +23413,7 @@ var WorkflowValidateCommand = {
|
|
|
23405
23413
|
try {
|
|
23406
23414
|
const workflow = await parseWorkflowInput(options.input, options.yaml);
|
|
23407
23415
|
if (!workflow) {
|
|
23408
|
-
console.error(
|
|
23416
|
+
console.error(chalk78.red("Failed to parse workflow input"));
|
|
23409
23417
|
process.exit(1);
|
|
23410
23418
|
}
|
|
23411
23419
|
const validator = new WorkflowValidator;
|
|
@@ -23413,7 +23421,7 @@ var WorkflowValidateCommand = {
|
|
|
23413
23421
|
renderResult(result, options);
|
|
23414
23422
|
process.exit(result.valid ? 0 : 1);
|
|
23415
23423
|
} catch (error) {
|
|
23416
|
-
console.error(
|
|
23424
|
+
console.error(chalk78.red(`
|
|
23417
23425
|
Error: ${error.message}`));
|
|
23418
23426
|
process.exit(1);
|
|
23419
23427
|
}
|
|
@@ -23421,7 +23429,7 @@ Error: ${error.message}`));
|
|
|
23421
23429
|
};
|
|
23422
23430
|
|
|
23423
23431
|
// src/commands/workflow/commands/search.ts
|
|
23424
|
-
import
|
|
23432
|
+
import chalk79 from "chalk";
|
|
23425
23433
|
import { wrapFunction as wrapFunction4 } from "@ai-setting/roy-agent-core";
|
|
23426
23434
|
var WorkflowSearchCommand = {
|
|
23427
23435
|
command: "search",
|
|
@@ -23578,22 +23586,22 @@ var _runWorkflowSearchImpl = async function(opts) {
|
|
|
23578
23586
|
metadata: {}
|
|
23579
23587
|
}));
|
|
23580
23588
|
if (renderWorkflows.length === 0) {
|
|
23581
|
-
output.log(
|
|
23582
|
-
output.log(
|
|
23583
|
-
output.log(
|
|
23589
|
+
output.log(chalk79.yellow("\uD83D\uDD0D No workflows matched the search criteria."));
|
|
23590
|
+
output.log(chalk79.gray(` keyword: ${keyword || "(none)"}`));
|
|
23591
|
+
output.log(chalk79.gray(` tags: ${tags && tags.length > 0 ? tags.join(", ") : "(none)"}`));
|
|
23584
23592
|
} else {
|
|
23585
|
-
output.log(
|
|
23593
|
+
output.log(chalk79.bold(`\uD83D\uDD0D Search results (${renderWorkflows.length}):`));
|
|
23586
23594
|
output.log(renderWorkflowList(renderWorkflows));
|
|
23587
|
-
output.log(
|
|
23595
|
+
output.log(chalk79.green(`
|
|
23588
23596
|
✅ Found ${renderWorkflows.length} workflow(s)`));
|
|
23589
23597
|
}
|
|
23590
23598
|
if (availableTags.length > 0) {
|
|
23591
23599
|
output.log("");
|
|
23592
|
-
output.log(
|
|
23600
|
+
output.log(chalk79.bold("\uD83D\uDCDA Available tags (sorted by usage_count):"));
|
|
23593
23601
|
for (const t of availableTags) {
|
|
23594
23602
|
const name = t.name ?? t.tag;
|
|
23595
23603
|
const count = t.count ?? t.usage_count;
|
|
23596
|
-
output.log(
|
|
23604
|
+
output.log(chalk79.gray(` - ${name} (${count})`));
|
|
23597
23605
|
}
|
|
23598
23606
|
}
|
|
23599
23607
|
};
|
|
@@ -23605,7 +23613,7 @@ var runWorkflowSearch = wrapFunction4(_runWorkflowSearchImpl, "workflow.cli.sear
|
|
|
23605
23613
|
|
|
23606
23614
|
// src/commands/workflow/commands/tag.ts
|
|
23607
23615
|
import { wrapFunction as wrapFunction5 } from "@ai-setting/roy-agent-core";
|
|
23608
|
-
import
|
|
23616
|
+
import chalk80 from "chalk";
|
|
23609
23617
|
var WorkflowTagListCommand = {
|
|
23610
23618
|
command: "list",
|
|
23611
23619
|
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.",
|
|
@@ -23726,17 +23734,17 @@ var _runWorkflowTagListImpl = async function(opts) {
|
|
|
23726
23734
|
return;
|
|
23727
23735
|
}
|
|
23728
23736
|
if (result.tags.length === 0) {
|
|
23729
|
-
output.log(
|
|
23730
|
-
output.log(
|
|
23737
|
+
output.log(chalk80.yellow("\uD83C\uDFF7️ No tags in the workflow_tags table yet."));
|
|
23738
|
+
output.log(chalk80.gray(" Tags are created automatically when you run `workflow add --tags <name>`."));
|
|
23731
23739
|
return;
|
|
23732
23740
|
}
|
|
23733
|
-
output.log(
|
|
23734
|
-
output.log(
|
|
23741
|
+
output.log(chalk80.bold(`\uD83C\uDFF7️ Workflow tags (${result.total}):`));
|
|
23742
|
+
output.log(chalk80.gray(` ${padRight("NAME", 24)}${padRight("USAGE", 8)}${padRight("CREATED", 22)}`));
|
|
23735
23743
|
for (const t of result.tags) {
|
|
23736
23744
|
const line = ` ${padRight(t.name, 24)}${padRight(String(t.usage_count), 8)}${padRight(formatDate2(t.created_at), 22)}`;
|
|
23737
23745
|
output.log(line);
|
|
23738
23746
|
}
|
|
23739
|
-
output.log(
|
|
23747
|
+
output.log(chalk80.gray(`
|
|
23740
23748
|
\uD83D\uDCA1 Tip: when adding a new workflow, prefer tags from this list to ensure semantic consistency.`));
|
|
23741
23749
|
};
|
|
23742
23750
|
var _runWorkflowTagGetImpl = async function(opts) {
|
|
@@ -23763,7 +23771,7 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
23763
23771
|
output.json({ error: "Tag not found", name: opts.name });
|
|
23764
23772
|
} else {
|
|
23765
23773
|
output.error(`Tag "${opts.name}" not found in the workflow_tags table.`);
|
|
23766
|
-
output.log(
|
|
23774
|
+
output.log(chalk80.gray(`Tip: run \`roy-agent workflow tag list\` to see available tags.`));
|
|
23767
23775
|
}
|
|
23768
23776
|
process.exitCode = 1;
|
|
23769
23777
|
return;
|
|
@@ -23772,10 +23780,10 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
23772
23780
|
output.json(tag);
|
|
23773
23781
|
return;
|
|
23774
23782
|
}
|
|
23775
|
-
output.log(
|
|
23776
|
-
output.log(
|
|
23777
|
-
output.log(
|
|
23778
|
-
output.log(
|
|
23783
|
+
output.log(chalk80.bold(`\uD83C\uDFF7️ Tag: ${tag.name}`));
|
|
23784
|
+
output.log(chalk80.gray(` usage_count: ${tag.usage_count}`));
|
|
23785
|
+
output.log(chalk80.gray(` created_at: ${tag.created_at}`));
|
|
23786
|
+
output.log(chalk80.gray(` updated_at: ${tag.updated_at}`));
|
|
23779
23787
|
};
|
|
23780
23788
|
async function callListTags(service, options) {
|
|
23781
23789
|
if (typeof service.listTags !== "function") {
|