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