@ai-setting/roy-agent-cli 1.6.17 → 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 +784 -726
- package/dist/index.js +784 -726
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +1 -1
package/dist/bin/roy-agent.js
CHANGED
|
@@ -705,8 +705,20 @@ ${COLORS.system("[已中断]")}
|
|
|
705
705
|
], StreamOutputService.prototype, "handleText", null);
|
|
706
706
|
});
|
|
707
707
|
|
|
708
|
-
// src/commands/ui/
|
|
708
|
+
// src/commands/ui/mascot/glasses-girl.ts
|
|
709
709
|
import chalk5 from "chalk";
|
|
710
|
+
var GLASSES_GIRL_RAW_LINES;
|
|
711
|
+
var init_glasses_girl = __esm(() => {
|
|
712
|
+
GLASSES_GIRL_RAW_LINES = [
|
|
713
|
+
" ▟♥▀▀♥▀▌ ",
|
|
714
|
+
" ◐◑ ◐◑ ",
|
|
715
|
+
" ▄ ▙▀▀▀▀▀▀▟ ▄ ",
|
|
716
|
+
" Roy mascot "
|
|
717
|
+
];
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
// src/commands/ui/welcome-card.ts
|
|
721
|
+
import chalk6 from "chalk";
|
|
710
722
|
function visibleLength(s) {
|
|
711
723
|
return s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
712
724
|
}
|
|
@@ -769,12 +781,8 @@ function printWelcomeCard(ctx) {
|
|
|
769
781
|
var PIXEL_LOGO_LINES, TIPS_LINES, WHATS_NEW_LINES;
|
|
770
782
|
var init_welcome_card = __esm(() => {
|
|
771
783
|
init_stream_output_service();
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
" ▝▜███▛▘ ",
|
|
775
|
-
" ▔▔▔ ",
|
|
776
|
-
" R.O.Y mascot "
|
|
777
|
-
];
|
|
784
|
+
init_glasses_girl();
|
|
785
|
+
PIXEL_LOGO_LINES = GLASSES_GIRL_RAW_LINES;
|
|
778
786
|
TIPS_LINES = [
|
|
779
787
|
"/help Show all commands",
|
|
780
788
|
"/init Create memory file",
|
|
@@ -904,7 +912,7 @@ var init_status_bar = __esm(() => {
|
|
|
904
912
|
var require_package = __commonJS((exports, module) => {
|
|
905
913
|
module.exports = {
|
|
906
914
|
name: "@ai-setting/roy-agent-cli",
|
|
907
|
-
version: "1.6.
|
|
915
|
+
version: "1.6.19",
|
|
908
916
|
type: "module",
|
|
909
917
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
910
918
|
main: "./dist/index.js",
|
|
@@ -1245,7 +1253,7 @@ var init_slash_command_popup = __esm(() => {
|
|
|
1245
1253
|
// src/commands/markdown-renderer.tsx
|
|
1246
1254
|
import * as React2 from "react";
|
|
1247
1255
|
import { Box as Box2, Text as Text2 } from "ink";
|
|
1248
|
-
import
|
|
1256
|
+
import chalk7 from "chalk";
|
|
1249
1257
|
import { wrapFunction } from "@ai-setting/roy-agent-core";
|
|
1250
1258
|
function parseInline(text, keyPrefix) {
|
|
1251
1259
|
const nodes = [];
|
|
@@ -1278,6 +1286,26 @@ function parseInline(text, keyPrefix) {
|
|
|
1278
1286
|
}
|
|
1279
1287
|
return nodes;
|
|
1280
1288
|
}
|
|
1289
|
+
function tableCacheKey(header) {
|
|
1290
|
+
return header.join("\x01");
|
|
1291
|
+
}
|
|
1292
|
+
function lockColumnWidths(header, currentWidths) {
|
|
1293
|
+
const key = tableCacheKey(header);
|
|
1294
|
+
const prev = tableMaxWidthsCache.get(key);
|
|
1295
|
+
if (!prev) {
|
|
1296
|
+
tableMaxWidthsCache.set(key, currentWidths);
|
|
1297
|
+
return currentWidths;
|
|
1298
|
+
}
|
|
1299
|
+
const maxLen = Math.max(prev.length, currentWidths.length);
|
|
1300
|
+
const merged = [];
|
|
1301
|
+
for (let i = 0;i < maxLen; i++) {
|
|
1302
|
+
const a = prev[i] ?? 0;
|
|
1303
|
+
const b = currentWidths[i] ?? 0;
|
|
1304
|
+
merged.push(Math.max(a, b));
|
|
1305
|
+
}
|
|
1306
|
+
tableMaxWidthsCache.set(key, merged);
|
|
1307
|
+
return merged;
|
|
1308
|
+
}
|
|
1281
1309
|
function splitTableRow(rawLine) {
|
|
1282
1310
|
let s = rawLine.trim();
|
|
1283
1311
|
if (s.startsWith("|"))
|
|
@@ -1354,7 +1382,7 @@ function parseTableBlock(lines, startIndex) {
|
|
|
1354
1382
|
}
|
|
1355
1383
|
function renderTableBlock(tbl, key) {
|
|
1356
1384
|
const colCount = Math.max(tbl.header.length, ...tbl.rows.map((r) => r.length));
|
|
1357
|
-
const
|
|
1385
|
+
const rawWidths = [];
|
|
1358
1386
|
for (let c = 0;c < colCount; c++) {
|
|
1359
1387
|
const headerW = (tbl.header[c] ?? "").length;
|
|
1360
1388
|
let dataW = 0;
|
|
@@ -1363,8 +1391,9 @@ function renderTableBlock(tbl, key) {
|
|
|
1363
1391
|
if (cell.length > dataW)
|
|
1364
1392
|
dataW = cell.length;
|
|
1365
1393
|
}
|
|
1366
|
-
|
|
1394
|
+
rawWidths.push(Math.max(headerW, dataW));
|
|
1367
1395
|
}
|
|
1396
|
+
const widths = lockColumnWidths(tbl.header, rawWidths);
|
|
1368
1397
|
const alignments = [];
|
|
1369
1398
|
for (let c = 0;c < colCount; c++) {
|
|
1370
1399
|
alignments.push(tbl.alignments[c] ?? "left");
|
|
@@ -1429,10 +1458,10 @@ function renderMarkdownLegacyImpl(content) {
|
|
|
1429
1458
|
const level = headingMatch[1].length;
|
|
1430
1459
|
const text = headingMatch[2];
|
|
1431
1460
|
if (level === 1) {
|
|
1432
|
-
const styled =
|
|
1461
|
+
const styled = chalk7.cyan.bold.underline(`▌ ${text}`);
|
|
1433
1462
|
blocks.push(React2.createElement(Box2, { key: `blk-h1-${blockKey++}`, marginY: 1 }, React2.createElement(Text2, {}, styled)));
|
|
1434
1463
|
} else if (level === 2) {
|
|
1435
|
-
const styled =
|
|
1464
|
+
const styled = chalk7.green.bold(`▶ ${text}`);
|
|
1436
1465
|
blocks.push(React2.createElement(Box2, { key: `blk-h2-${blockKey++}`, marginY: 1 }, React2.createElement(Text2, {}, styled)));
|
|
1437
1466
|
} else {
|
|
1438
1467
|
const colors = {
|
|
@@ -1508,9 +1537,26 @@ function renderMarkdownLegacyImpl(content) {
|
|
|
1508
1537
|
}
|
|
1509
1538
|
return blocks;
|
|
1510
1539
|
}
|
|
1511
|
-
var
|
|
1540
|
+
var tableMaxWidthsCache, MARKDOWN_CACHE_MAX = 16, markdownParseCache, renderMarkdownWithCache = (content) => {
|
|
1541
|
+
const cached = markdownParseCache.get(content);
|
|
1542
|
+
if (cached !== undefined) {
|
|
1543
|
+
markdownParseCache.delete(content);
|
|
1544
|
+
markdownParseCache.set(content, cached);
|
|
1545
|
+
return cached;
|
|
1546
|
+
}
|
|
1547
|
+
const parsed = renderMarkdownLegacyImpl(content);
|
|
1548
|
+
if (markdownParseCache.size >= MARKDOWN_CACHE_MAX) {
|
|
1549
|
+
const firstKey = markdownParseCache.keys().next().value;
|
|
1550
|
+
if (firstKey !== undefined)
|
|
1551
|
+
markdownParseCache.delete(firstKey);
|
|
1552
|
+
}
|
|
1553
|
+
markdownParseCache.set(content, parsed);
|
|
1554
|
+
return parsed;
|
|
1555
|
+
}, renderMarkdown;
|
|
1512
1556
|
var init_markdown_renderer2 = __esm(() => {
|
|
1513
|
-
|
|
1557
|
+
tableMaxWidthsCache = new Map;
|
|
1558
|
+
markdownParseCache = new Map;
|
|
1559
|
+
renderMarkdown = wrapFunction(renderMarkdownWithCache, "markdown.render", {
|
|
1514
1560
|
recordParams: true,
|
|
1515
1561
|
recordResult: false,
|
|
1516
1562
|
paramFilter: (args) => ({
|
|
@@ -10664,7 +10710,7 @@ var ActCommand = createActCommand();
|
|
|
10664
10710
|
|
|
10665
10711
|
// src/commands/interactive.ts
|
|
10666
10712
|
import * as readline2 from "readline";
|
|
10667
|
-
import
|
|
10713
|
+
import chalk8 from "chalk";
|
|
10668
10714
|
|
|
10669
10715
|
// src/commands/shared/session-manager.ts
|
|
10670
10716
|
import { parseImageInput as parseImageInput2 } from "@ai-setting/roy-agent-core";
|
|
@@ -11596,6 +11642,9 @@ function createAskUserTimeoutSentinel(errorInfo, timeoutMs, extra) {
|
|
|
11596
11642
|
}
|
|
11597
11643
|
function withAskUserTimeoutRace(opts) {
|
|
11598
11644
|
const { rl, timeoutMs, onLine, onTimeout } = opts;
|
|
11645
|
+
if (!rl) {
|
|
11646
|
+
return { cancel: () => {} };
|
|
11647
|
+
}
|
|
11599
11648
|
let resolved = false;
|
|
11600
11649
|
let timer = null;
|
|
11601
11650
|
const handleLine = (input) => {
|
|
@@ -12507,7 +12556,7 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12507
12556
|
console.log(formatAskUserOutput({ ...errorInfo, query: question, options }));
|
|
12508
12557
|
const userResponse = await this.promptUser(question, options, errorInfo);
|
|
12509
12558
|
if (isAskUserTimeoutSentinel(userResponse)) {
|
|
12510
|
-
console.log(
|
|
12559
|
+
console.log(chalk8.dim(`
|
|
12511
12560
|
请直接输入新指令继续,或使用 /abort 中断当前工作流。`));
|
|
12512
12561
|
return;
|
|
12513
12562
|
}
|
|
@@ -12528,7 +12577,7 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12528
12577
|
const finishWithUserInput = (input) => {
|
|
12529
12578
|
const trimmedInput = input.trim();
|
|
12530
12579
|
if (!trimmedInput) {
|
|
12531
|
-
console.log(
|
|
12580
|
+
console.log(chalk8.yellow(`⚠️ 输入不能为空,请重新输入
|
|
12532
12581
|
`));
|
|
12533
12582
|
this.promptUser(question, options, errorInfo, opts).then(resolve);
|
|
12534
12583
|
return;
|
|
@@ -12536,30 +12585,37 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12536
12585
|
const parsed = parseUserInput(trimmedInput, options);
|
|
12537
12586
|
if (parsed.type === "option" && options) {
|
|
12538
12587
|
const selectedOption = options[parsed.value];
|
|
12539
|
-
console.log(
|
|
12588
|
+
console.log(chalk8.green(`✓ 您选择了: ${selectedOption}
|
|
12540
12589
|
`));
|
|
12541
12590
|
resolve(selectedOption);
|
|
12542
12591
|
} else {
|
|
12543
|
-
console.log(
|
|
12592
|
+
console.log(chalk8.green(`✓ 您的回答: ${parsed.value}
|
|
12544
12593
|
`));
|
|
12545
12594
|
resolve(parsed.value);
|
|
12546
12595
|
}
|
|
12547
12596
|
};
|
|
12548
|
-
|
|
12549
|
-
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
|
|
12553
|
-
|
|
12554
|
-
|
|
12555
|
-
|
|
12597
|
+
if (this.rl) {
|
|
12598
|
+
withAskUserTimeoutRace({
|
|
12599
|
+
rl: this.rl,
|
|
12600
|
+
timeoutMs,
|
|
12601
|
+
onLine: (input) => {
|
|
12602
|
+
finishWithUserInput(input);
|
|
12603
|
+
},
|
|
12604
|
+
onTimeout: () => {
|
|
12605
|
+
console.log(chalk8.yellow(`
|
|
12556
12606
|
⏱ ask_user 超时:${timeoutMs}ms 内未收到回应,已自动解除等待。`));
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
|
|
12607
|
+
resolve(createAskUserTimeoutSentinel(errorInfo, timeoutMs, {
|
|
12608
|
+
source: "repl",
|
|
12609
|
+
question
|
|
12610
|
+
}));
|
|
12611
|
+
}
|
|
12612
|
+
});
|
|
12613
|
+
} else {
|
|
12614
|
+
resolve(createAskUserTimeoutSentinel(errorInfo, timeoutMs, {
|
|
12615
|
+
source: "repl",
|
|
12616
|
+
question
|
|
12617
|
+
}));
|
|
12618
|
+
}
|
|
12563
12619
|
});
|
|
12564
12620
|
}
|
|
12565
12621
|
handleSigint() {
|
|
@@ -12646,10 +12702,12 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12646
12702
|
this.isExecuting = false;
|
|
12647
12703
|
}
|
|
12648
12704
|
this.setMode("ready");
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12705
|
+
if (this.rl) {
|
|
12706
|
+
try {
|
|
12707
|
+
this.redrawInputArea();
|
|
12708
|
+
this.rl.prompt(true);
|
|
12709
|
+
} catch {}
|
|
12710
|
+
}
|
|
12653
12711
|
}
|
|
12654
12712
|
printHeader() {
|
|
12655
12713
|
if (process.stdout.isTTY) {
|
|
@@ -12668,61 +12726,61 @@ ${COLORS.error("❌ 执行失败: " + error)}
|
|
|
12668
12726
|
});
|
|
12669
12727
|
return;
|
|
12670
12728
|
}
|
|
12671
|
-
console.log(
|
|
12729
|
+
console.log(chalk8.bold(`
|
|
12672
12730
|
╔══════════════════════════════════════════════════╗`));
|
|
12673
|
-
console.log(
|
|
12674
|
-
console.log(
|
|
12731
|
+
console.log(chalk8.bold("║ ") + chalk8.green.bold("roy-agent") + chalk8.bold(" Interactive Mode") + chalk8.bold(" ║"));
|
|
12732
|
+
console.log(chalk8.bold(`╚══════════════════════════════════════════════════╝
|
|
12675
12733
|
`));
|
|
12676
|
-
console.log(`${
|
|
12677
|
-
console.log(`${
|
|
12734
|
+
console.log(`${chalk8.dim("会话:")} ${this.options.sessionTitle}`);
|
|
12735
|
+
console.log(`${chalk8.dim("输入 ")} ${COLORS.userInput("/help")} ${chalk8.dim("查看可用命令")}
|
|
12678
12736
|
`);
|
|
12679
12737
|
}
|
|
12680
12738
|
printHelp() {
|
|
12681
12739
|
console.log(`
|
|
12682
|
-
${
|
|
12683
|
-
${
|
|
12684
|
-
${
|
|
12685
|
-
${
|
|
12686
|
-
${
|
|
12687
|
-
${
|
|
12688
|
-
${
|
|
12689
|
-
${
|
|
12690
|
-
${
|
|
12691
|
-
${
|
|
12692
|
-
${
|
|
12693
|
-
${
|
|
12694
|
-
${
|
|
12695
|
-
${
|
|
12696
|
-
${
|
|
12697
|
-
${
|
|
12740
|
+
${chalk8.bold("╭")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╮")}
|
|
12741
|
+
${chalk8.bold("│")} ${chalk8.bold("快捷命令")} ${chalk8.bold("│")}
|
|
12742
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12743
|
+
${chalk8.bold("│")} ${COLORS.userInput("/help")}, ${COLORS.userInput("/h")} 显示帮助 ${chalk8.bold("│")}
|
|
12744
|
+
${chalk8.bold("│")} ${COLORS.userInput("/status")}, ${COLORS.userInput("/st")} 显示状态 ${chalk8.bold("│")}
|
|
12745
|
+
${chalk8.bold("│")} ${COLORS.userInput("/sessions")}, ${COLORS.userInput("/s")} 切换会话 ${chalk8.bold("│")}
|
|
12746
|
+
${chalk8.bold("│")} ${COLORS.userInput("/compact")}, ${COLORS.userInput("/c")} 压缩上下文 ${chalk8.bold("│")}
|
|
12747
|
+
${chalk8.bold("│")} ${COLORS.userInput("/abort")} 中断当前流式输出 ${chalk8.bold("│")}
|
|
12748
|
+
${chalk8.bold("│")} ${COLORS.userInput("/clear")}, ${COLORS.userInput("/cls")} 清屏 ${chalk8.bold("│")}
|
|
12749
|
+
${chalk8.bold("│")} ${COLORS.userInput("/exit")}, ${COLORS.userInput("/q")} 退出 ${chalk8.bold("│")}
|
|
12750
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12751
|
+
${chalk8.bold("│")} ${chalk8.bold("多行输入")} ${chalk8.bold("│")}
|
|
12752
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12753
|
+
${chalk8.bold("│")} 输入多行内容后,Alt+Enter 结束输入。 ${chalk8.bold("│")}
|
|
12754
|
+
${chalk8.bold("│")} Ctrl+C 可取消多行输入。 ${chalk8.bold("│")}
|
|
12755
|
+
${chalk8.bold("╰")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╯")}
|
|
12698
12756
|
`);
|
|
12699
12757
|
}
|
|
12700
12758
|
async printStatus() {
|
|
12701
12759
|
const status = await this.options.onStatus();
|
|
12702
12760
|
console.log(`
|
|
12703
|
-
${
|
|
12704
|
-
${
|
|
12705
|
-
${
|
|
12706
|
-
${
|
|
12707
|
-
${
|
|
12708
|
-
${
|
|
12709
|
-
${
|
|
12710
|
-
${
|
|
12761
|
+
${chalk8.bold("╭")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╮")}
|
|
12762
|
+
${chalk8.bold("│")} ${chalk8.bold("会话状态")} ${chalk8.bold("│")}
|
|
12763
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12764
|
+
${chalk8.bold("│")} ${chalk8.dim("会话:")} ${status.sessionTitle.padEnd(35)} ${chalk8.bold("│")}
|
|
12765
|
+
${chalk8.bold("│")} ${chalk8.dim("ID:")} ${status.sessionId.padEnd(37)} ${chalk8.bold("│")}
|
|
12766
|
+
${chalk8.bold("│")} ${chalk8.dim("消息:")} ${String(status.messageCount).padEnd(34)} ${chalk8.bold("│")}
|
|
12767
|
+
${chalk8.bold("│")} ${chalk8.dim("Token:")} ${String(status.tokenCount).padEnd(33)} ${chalk8.bold("│")}
|
|
12768
|
+
${chalk8.bold("╰")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╯")}
|
|
12711
12769
|
`);
|
|
12712
12770
|
}
|
|
12713
12771
|
printSessionsHelp() {
|
|
12714
12772
|
console.log(`
|
|
12715
|
-
${
|
|
12716
|
-
${
|
|
12717
|
-
${
|
|
12718
|
-
${
|
|
12719
|
-
${
|
|
12720
|
-
${
|
|
12721
|
-
${
|
|
12722
|
-
${
|
|
12723
|
-
${
|
|
12724
|
-
${
|
|
12725
|
-
${
|
|
12773
|
+
${chalk8.bold("╭")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╮")}
|
|
12774
|
+
${chalk8.bold("│")} ${chalk8.bold("切换会话")} ${chalk8.bold("│")}
|
|
12775
|
+
${chalk8.bold("├")}${chalk8.dim("─".repeat(49))}${chalk8.bold("├")}
|
|
12776
|
+
${chalk8.bold("│")} 退出当前交互模式后,使用以下命令切换会话: ${chalk8.bold("│")}
|
|
12777
|
+
${chalk8.bold("│")} ${chalk8.bold("│")}
|
|
12778
|
+
${chalk8.bold("│")} ${COLORS.userInput("roy-agent sessions list")} 列出所有会话 ${chalk8.bold("│")}
|
|
12779
|
+
${chalk8.bold("│")} ${COLORS.userInput("roy-agent sessions use <id>")} 切换到指定会话 ${chalk8.bold("│")}
|
|
12780
|
+
${chalk8.bold("│")} ${chalk8.bold("│")}
|
|
12781
|
+
${chalk8.bold("│")} 或直接指定会话启动: ${chalk8.bold("│")}
|
|
12782
|
+
${chalk8.bold("│")} ${COLORS.userInput("roy-agent interactive -s <session-id>")} ${chalk8.bold("│")}
|
|
12783
|
+
${chalk8.bold("╰")}${chalk8.dim("─".repeat(49))}${chalk8.bold("╯")}
|
|
12726
12784
|
`);
|
|
12727
12785
|
}
|
|
12728
12786
|
}
|
|
@@ -13100,7 +13158,7 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
13100
13158
|
var InteractiveCommand = createInteractiveCommand();
|
|
13101
13159
|
|
|
13102
13160
|
// src/commands/shared/list-output.ts
|
|
13103
|
-
import
|
|
13161
|
+
import chalk9 from "chalk";
|
|
13104
13162
|
var PAGINATION_OPTIONS = {
|
|
13105
13163
|
limit: {
|
|
13106
13164
|
alias: "n",
|
|
@@ -13127,8 +13185,8 @@ function renderPaginationFooter(opts) {
|
|
|
13127
13185
|
const items = `${itemName}${count === 1 ? "" : "s"}`;
|
|
13128
13186
|
const base = `Showing ${start}-${end} of ${total} ${items}`;
|
|
13129
13187
|
const suffix = extras.length > 0 ? ` (${extras.join(", ")})` : "";
|
|
13130
|
-
const truncatedHint = total > count && offset + count < total ?
|
|
13131
|
-
return
|
|
13188
|
+
const truncatedHint = total > count && offset + count < total ? chalk9.cyan(` — use -o ${offset + limit} for next page`) : "";
|
|
13189
|
+
return chalk9.gray(base + suffix + truncatedHint);
|
|
13132
13190
|
}
|
|
13133
13191
|
function renderQuietHeader(total, itemName) {
|
|
13134
13192
|
const items = `${itemName}${total === 1 ? "" : "s"}`;
|
|
@@ -13148,7 +13206,7 @@ function renderQuietPaginationHint(opts) {
|
|
|
13148
13206
|
}
|
|
13149
13207
|
|
|
13150
13208
|
// src/commands/sessions/list.ts
|
|
13151
|
-
import
|
|
13209
|
+
import chalk10 from "chalk";
|
|
13152
13210
|
|
|
13153
13211
|
// src/commands/sessions/session-graph.ts
|
|
13154
13212
|
function buildSessionTree(sessions) {
|
|
@@ -13433,39 +13491,39 @@ var ListCommand = {
|
|
|
13433
13491
|
const hasTypeFilter = !!args.type;
|
|
13434
13492
|
const hasStatusFilter = !!args.status;
|
|
13435
13493
|
const header = [
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
hasTypeFilter || hasStatusFilter ?
|
|
13441
|
-
|
|
13442
|
-
|
|
13494
|
+
chalk10.bold("#"),
|
|
13495
|
+
chalk10.bold("Title"),
|
|
13496
|
+
chalk10.bold("ID"),
|
|
13497
|
+
chalk10.bold("Parent"),
|
|
13498
|
+
hasTypeFilter || hasStatusFilter ? chalk10.bold("Status") : null,
|
|
13499
|
+
chalk10.bold("Msgs"),
|
|
13500
|
+
chalk10.bold("CP")
|
|
13443
13501
|
].filter(Boolean).join(" │ ");
|
|
13444
13502
|
const rows = sessions.map((s, i) => {
|
|
13445
|
-
const marker = s.id === activeSessionId ?
|
|
13503
|
+
const marker = s.id === activeSessionId ? chalk10.green("▶") : " ";
|
|
13446
13504
|
const hasCp = (s.metadata?.checkpoints?.checkpoints?.length ?? 0) > 0;
|
|
13447
13505
|
const title = s.title.length > 20 ? s.title.slice(0, 17) + "..." : s.title;
|
|
13448
13506
|
const idStr = s.id;
|
|
13449
13507
|
const useShortId = args.shortId === true;
|
|
13450
|
-
const parentStr = s.parentSessionId ?
|
|
13508
|
+
const parentStr = s.parentSessionId ? chalk10.gray(useShortId ? shortSessionId(s.parentSessionId) : s.parentSessionId) : chalk10.gray("-");
|
|
13451
13509
|
const workflowMeta = s.metadata?.type === "workflow" ? s.metadata : null;
|
|
13452
13510
|
const statusStr = workflowMeta?.status || "";
|
|
13453
13511
|
let statusDisplay = "";
|
|
13454
13512
|
if (hasTypeFilter || hasStatusFilter) {
|
|
13455
13513
|
if (workflowMeta) {
|
|
13456
|
-
statusDisplay = workflowMeta.status === "running" ?
|
|
13514
|
+
statusDisplay = workflowMeta.status === "running" ? chalk10.green("running") : workflowMeta.status === "paused" ? chalk10.yellow("paused") : workflowMeta.status === "completed" ? chalk10.gray("completed") : workflowMeta.status === "failed" ? chalk10.red("failed") : statusStr;
|
|
13457
13515
|
}
|
|
13458
13516
|
}
|
|
13459
13517
|
const cells = [
|
|
13460
13518
|
marker + " " + (args.offset + i + 1),
|
|
13461
13519
|
title,
|
|
13462
|
-
|
|
13520
|
+
chalk10.gray(idStr),
|
|
13463
13521
|
parentStr
|
|
13464
13522
|
];
|
|
13465
13523
|
if (hasTypeFilter || hasStatusFilter) {
|
|
13466
|
-
cells.push(statusDisplay ||
|
|
13524
|
+
cells.push(statusDisplay || chalk10.gray("-"));
|
|
13467
13525
|
}
|
|
13468
|
-
cells.push(s.messageCount.toString(), hasCp ?
|
|
13526
|
+
cells.push(s.messageCount.toString(), hasCp ? chalk10.green("✓") : chalk10.gray("-"));
|
|
13469
13527
|
return cells.join(" │ ");
|
|
13470
13528
|
});
|
|
13471
13529
|
output.log([
|
|
@@ -13499,37 +13557,37 @@ var ListCommand = {
|
|
|
13499
13557
|
};
|
|
13500
13558
|
|
|
13501
13559
|
// src/commands/sessions/get.ts
|
|
13502
|
-
import
|
|
13560
|
+
import chalk11 from "chalk";
|
|
13503
13561
|
function colorWorkflowStatus(status) {
|
|
13504
13562
|
switch (status) {
|
|
13505
13563
|
case "running":
|
|
13506
|
-
return
|
|
13564
|
+
return chalk11.green;
|
|
13507
13565
|
case "paused":
|
|
13508
|
-
return
|
|
13566
|
+
return chalk11.yellow;
|
|
13509
13567
|
case "completed":
|
|
13510
|
-
return
|
|
13568
|
+
return chalk11.gray;
|
|
13511
13569
|
case "failed":
|
|
13512
|
-
return
|
|
13570
|
+
return chalk11.red;
|
|
13513
13571
|
case "stopped":
|
|
13514
|
-
return
|
|
13572
|
+
return chalk11.magenta;
|
|
13515
13573
|
default:
|
|
13516
|
-
return
|
|
13574
|
+
return chalk11.gray;
|
|
13517
13575
|
}
|
|
13518
13576
|
}
|
|
13519
13577
|
function colorAgentSessionStatus(status) {
|
|
13520
13578
|
switch (status) {
|
|
13521
13579
|
case "active":
|
|
13522
|
-
return
|
|
13580
|
+
return chalk11.green;
|
|
13523
13581
|
case "paused":
|
|
13524
|
-
return
|
|
13582
|
+
return chalk11.yellow;
|
|
13525
13583
|
case "completed":
|
|
13526
|
-
return
|
|
13584
|
+
return chalk11.gray;
|
|
13527
13585
|
case "failed":
|
|
13528
|
-
return
|
|
13586
|
+
return chalk11.red;
|
|
13529
13587
|
case "stopped":
|
|
13530
|
-
return
|
|
13588
|
+
return chalk11.magenta;
|
|
13531
13589
|
default:
|
|
13532
|
-
return
|
|
13590
|
+
return chalk11.gray;
|
|
13533
13591
|
}
|
|
13534
13592
|
}
|
|
13535
13593
|
var GetCommand = {
|
|
@@ -13587,19 +13645,19 @@ var GetCommand = {
|
|
|
13587
13645
|
});
|
|
13588
13646
|
} else {
|
|
13589
13647
|
const lines = [
|
|
13590
|
-
|
|
13648
|
+
chalk11.bold("┌─ Session Details ─────────────────────────────────┐"),
|
|
13591
13649
|
`│ ID: ${session.id}`,
|
|
13592
13650
|
`│ Title: ${session.title}`,
|
|
13593
13651
|
`│ Directory: ${session.directory}`,
|
|
13594
13652
|
`│ Messages: ${session.messageCount}`,
|
|
13595
|
-
`│ Active: ${session.id === activeSessionId ?
|
|
13653
|
+
`│ Active: ${session.id === activeSessionId ? chalk11.green("✓") : chalk11.gray("-")}`,
|
|
13596
13654
|
`│ Created: ${new Date(session.createdAt).toLocaleString("zh-CN")}`,
|
|
13597
13655
|
`│ Updated: ${new Date(session.updatedAt).toLocaleString("zh-CN")}`
|
|
13598
13656
|
];
|
|
13599
13657
|
const workflowMeta = session.metadata?.type === "workflow" ? session.metadata : null;
|
|
13600
13658
|
if (workflowMeta) {
|
|
13601
13659
|
lines.push("├─ Workflow Info ─────────────────────────────────────┤");
|
|
13602
|
-
lines.push(`│ Type: ${
|
|
13660
|
+
lines.push(`│ Type: ${chalk11.cyan("workflow")}`);
|
|
13603
13661
|
lines.push(`│ Workflow: ${workflowMeta.workflowName}`);
|
|
13604
13662
|
if (workflowMeta.workflowId) {
|
|
13605
13663
|
lines.push(`│ Workflow ID: ${workflowMeta.workflowId}`);
|
|
@@ -13636,7 +13694,7 @@ var GetCommand = {
|
|
|
13636
13694
|
};
|
|
13637
13695
|
|
|
13638
13696
|
// src/commands/sessions/new.ts
|
|
13639
|
-
import
|
|
13697
|
+
import chalk12 from "chalk";
|
|
13640
13698
|
var NewCommand = {
|
|
13641
13699
|
command: "new [options]",
|
|
13642
13700
|
aliases: ["create"],
|
|
@@ -13675,7 +13733,7 @@ var NewCommand = {
|
|
|
13675
13733
|
}
|
|
13676
13734
|
});
|
|
13677
13735
|
} else {
|
|
13678
|
-
output.success(
|
|
13736
|
+
output.success(chalk12.green("✓") + " Session created: " + session.id);
|
|
13679
13737
|
output.info("Title: " + session.title);
|
|
13680
13738
|
output.info("Directory: " + session.directory);
|
|
13681
13739
|
}
|
|
@@ -13689,7 +13747,7 @@ var NewCommand = {
|
|
|
13689
13747
|
};
|
|
13690
13748
|
|
|
13691
13749
|
// src/commands/sessions/rename.ts
|
|
13692
|
-
import
|
|
13750
|
+
import chalk13 from "chalk";
|
|
13693
13751
|
var RenameCommand = {
|
|
13694
13752
|
command: "rename <session-id> <title>",
|
|
13695
13753
|
aliases: ["mv"],
|
|
@@ -13744,7 +13802,7 @@ var RenameCommand = {
|
|
|
13744
13802
|
}
|
|
13745
13803
|
});
|
|
13746
13804
|
} else {
|
|
13747
|
-
output.success(`Session renamed: ${
|
|
13805
|
+
output.success(`Session renamed: ${chalk13.green(a.title)}`);
|
|
13748
13806
|
output.info(`ID: ${a.sessionId}`);
|
|
13749
13807
|
}
|
|
13750
13808
|
} catch (error) {
|
|
@@ -13757,7 +13815,7 @@ var RenameCommand = {
|
|
|
13757
13815
|
};
|
|
13758
13816
|
|
|
13759
13817
|
// src/commands/sessions/delete.ts
|
|
13760
|
-
import
|
|
13818
|
+
import chalk14 from "chalk";
|
|
13761
13819
|
var DeleteCommand = {
|
|
13762
13820
|
command: "delete [session-ids...]",
|
|
13763
13821
|
aliases: ["rm"],
|
|
@@ -13836,7 +13894,7 @@ var DeleteCommand = {
|
|
|
13836
13894
|
return true;
|
|
13837
13895
|
});
|
|
13838
13896
|
if (a.keepActive && sessionsToDelete.length > 0) {
|
|
13839
|
-
output.log(
|
|
13897
|
+
output.log(chalk14.yellow(`Keeping active session: ${activeSessionId}`));
|
|
13840
13898
|
}
|
|
13841
13899
|
} else if (a.olderThan !== undefined) {
|
|
13842
13900
|
const cutoffDate = new Date;
|
|
@@ -13853,7 +13911,7 @@ var DeleteCommand = {
|
|
|
13853
13911
|
}
|
|
13854
13912
|
return false;
|
|
13855
13913
|
});
|
|
13856
|
-
output.log(
|
|
13914
|
+
output.log(chalk14.gray(`Deleting sessions not updated since ${cutoffDate.toISOString().split("T")[0]} (${a.olderThan} days ago)`));
|
|
13857
13915
|
} else {
|
|
13858
13916
|
output.log("No sessions to delete");
|
|
13859
13917
|
return;
|
|
@@ -13863,10 +13921,10 @@ var DeleteCommand = {
|
|
|
13863
13921
|
return;
|
|
13864
13922
|
}
|
|
13865
13923
|
if (a.dryRun) {
|
|
13866
|
-
output.log(
|
|
13924
|
+
output.log(chalk14.yellow(`[DRY RUN] Would delete ${sessionsToDelete.length} session(s):
|
|
13867
13925
|
`));
|
|
13868
13926
|
sessionsToDelete.forEach((s, i) => {
|
|
13869
|
-
const marker = s.id === activeSessionId ?
|
|
13927
|
+
const marker = s.id === activeSessionId ? chalk14.green("▶") : " ";
|
|
13870
13928
|
output.log(` ${marker} ${s.id}`);
|
|
13871
13929
|
output.log(` Title: ${s.title}`);
|
|
13872
13930
|
output.log(` Updated: ${new Date(s.updatedAt).toLocaleString()}`);
|
|
@@ -13876,11 +13934,11 @@ var DeleteCommand = {
|
|
|
13876
13934
|
return;
|
|
13877
13935
|
}
|
|
13878
13936
|
if (!a.force) {
|
|
13879
|
-
output.log(
|
|
13937
|
+
output.log(chalk14.red(`
|
|
13880
13938
|
⚠️ About to delete ${sessionsToDelete.length} session(s):
|
|
13881
13939
|
`));
|
|
13882
13940
|
sessionsToDelete.forEach((s, i) => {
|
|
13883
|
-
const marker = s.id === activeSessionId ?
|
|
13941
|
+
const marker = s.id === activeSessionId ? chalk14.green("▶") : " ";
|
|
13884
13942
|
output.log(` ${marker} ${s.id} - ${s.title}`);
|
|
13885
13943
|
});
|
|
13886
13944
|
output.log("");
|
|
@@ -13890,7 +13948,7 @@ var DeleteCommand = {
|
|
|
13890
13948
|
input: process.stdin,
|
|
13891
13949
|
output: process.stdout
|
|
13892
13950
|
});
|
|
13893
|
-
rl.question(
|
|
13951
|
+
rl.question(chalk14.red("Type 'yes' to confirm deletion: "), (res) => {
|
|
13894
13952
|
rl.close();
|
|
13895
13953
|
resolve(res);
|
|
13896
13954
|
});
|
|
@@ -13918,7 +13976,7 @@ var DeleteCommand = {
|
|
|
13918
13976
|
}
|
|
13919
13977
|
}
|
|
13920
13978
|
if (successCount > 0) {
|
|
13921
|
-
output.success(
|
|
13979
|
+
output.success(chalk14.green(`✓`) + ` Deleted ${successCount} session(s)`);
|
|
13922
13980
|
}
|
|
13923
13981
|
if (failCount > 0) {
|
|
13924
13982
|
output.error(`✗ Failed to delete ${failCount} session(s)`);
|
|
@@ -13937,7 +13995,7 @@ var DeleteCommand = {
|
|
|
13937
13995
|
};
|
|
13938
13996
|
|
|
13939
13997
|
// src/commands/sessions/messages.ts
|
|
13940
|
-
import
|
|
13998
|
+
import chalk15 from "chalk";
|
|
13941
13999
|
|
|
13942
14000
|
// src/commands/sessions/format-message-content.ts
|
|
13943
14001
|
var TEXT_MAX_CHARS = 300;
|
|
@@ -14149,20 +14207,20 @@ var MessagesCommand = {
|
|
|
14149
14207
|
} else {
|
|
14150
14208
|
const detail = a.detail === true;
|
|
14151
14209
|
const roleColors = {
|
|
14152
|
-
user:
|
|
14153
|
-
assistant:
|
|
14154
|
-
system:
|
|
14155
|
-
tool:
|
|
14210
|
+
user: chalk15.blue,
|
|
14211
|
+
assistant: chalk15.green,
|
|
14212
|
+
system: chalk15.gray,
|
|
14213
|
+
tool: chalk15.yellow
|
|
14156
14214
|
};
|
|
14157
|
-
output.log(
|
|
14215
|
+
output.log(chalk15.bold(`┌─ Messages (${a.sessionId}) ────────────────────────┐`));
|
|
14158
14216
|
messages.forEach((m, i) => {
|
|
14159
|
-
const roleColor = roleColors[m.role] ||
|
|
14217
|
+
const roleColor = roleColors[m.role] || chalk15.white;
|
|
14160
14218
|
const time = new Date(m.timestamp).toLocaleTimeString("zh-CN", {
|
|
14161
14219
|
hour: "2-digit",
|
|
14162
14220
|
minute: "2-digit"
|
|
14163
14221
|
});
|
|
14164
14222
|
if (m.metadata?.isCheckpoint) {
|
|
14165
|
-
output.log(
|
|
14223
|
+
output.log(chalk15.cyan("├─ #" + (a.offset + i + 1) + " checkpoint") + " " + chalk15.gray(time));
|
|
14166
14224
|
output.log("│");
|
|
14167
14225
|
const checkpointContent = formatCheckpointContent(m.content, { detail });
|
|
14168
14226
|
output.log("│ " + checkpointContent.split(`
|
|
@@ -14170,7 +14228,7 @@ var MessagesCommand = {
|
|
|
14170
14228
|
│ `));
|
|
14171
14229
|
output.log("│");
|
|
14172
14230
|
} else {
|
|
14173
|
-
output.log(
|
|
14231
|
+
output.log(chalk15.cyan("├─ #" + (a.offset + i + 1) + " ") + roleColor(m.role.padEnd(10)) + " " + chalk15.gray(time));
|
|
14174
14232
|
const rawLines = formatMessageContent(m, { detail });
|
|
14175
14233
|
const contentLines = colorizeContentLines(rawLines, m);
|
|
14176
14234
|
const finalLines = detail ? contentLines : contentLines.slice(0, MAX_CONTENT_LINES);
|
|
@@ -14178,7 +14236,7 @@ var MessagesCommand = {
|
|
|
14178
14236
|
output.log("│ " + line);
|
|
14179
14237
|
}
|
|
14180
14238
|
if (!detail && contentLines.length > MAX_CONTENT_LINES) {
|
|
14181
|
-
output.log("│ " +
|
|
14239
|
+
output.log("│ " + chalk15.gray(`... (truncated, total ${contentLines.length} lines)`));
|
|
14182
14240
|
}
|
|
14183
14241
|
output.log("│");
|
|
14184
14242
|
}
|
|
@@ -14186,7 +14244,7 @@ var MessagesCommand = {
|
|
|
14186
14244
|
output.log("└" + "─".repeat(51) + "┘");
|
|
14187
14245
|
const hasMore = a.offset + a.limit < totalMessages;
|
|
14188
14246
|
const showingEnd = Math.min(a.offset + a.limit, totalMessages);
|
|
14189
|
-
output.log(
|
|
14247
|
+
output.log(chalk15.gray(`Showing ${a.offset + 1}-${showingEnd} of ${totalMessages} messages` + (hasMore ? " (more available)" : "")));
|
|
14190
14248
|
}
|
|
14191
14249
|
} catch (error) {
|
|
14192
14250
|
output.error(`Failed to get messages: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -14199,43 +14257,43 @@ var MessagesCommand = {
|
|
|
14199
14257
|
function colorizeContentLines(lines, _m) {
|
|
14200
14258
|
return lines.map((line) => {
|
|
14201
14259
|
if (line.startsWith("[Tool Call]"))
|
|
14202
|
-
return
|
|
14260
|
+
return chalk15.cyan(line);
|
|
14203
14261
|
if (line.startsWith("[Tool Result]"))
|
|
14204
|
-
return
|
|
14262
|
+
return chalk15.yellow(line);
|
|
14205
14263
|
if (line === "[Reasoning]")
|
|
14206
|
-
return
|
|
14264
|
+
return chalk15.magenta(line);
|
|
14207
14265
|
if (line === "[Checkpoint]")
|
|
14208
|
-
return
|
|
14266
|
+
return chalk15.cyan(line);
|
|
14209
14267
|
if (line.startsWith("[Node Call]"))
|
|
14210
|
-
return
|
|
14268
|
+
return chalk15.blue(line);
|
|
14211
14269
|
if (line.startsWith("[Node Interrupt]"))
|
|
14212
|
-
return
|
|
14270
|
+
return chalk15.yellow(line);
|
|
14213
14271
|
if (line.startsWith("[Node Resume]"))
|
|
14214
|
-
return
|
|
14272
|
+
return chalk15.green(line);
|
|
14215
14273
|
if (line.startsWith("[Node Start]"))
|
|
14216
|
-
return
|
|
14274
|
+
return chalk15.blue(line);
|
|
14217
14275
|
if (line.startsWith("✅") || line.startsWith("❌")) {
|
|
14218
14276
|
if (line.includes("[Node Result]"))
|
|
14219
|
-
return
|
|
14277
|
+
return chalk15.green(line);
|
|
14220
14278
|
if (line.includes("[Node End]"))
|
|
14221
|
-
return
|
|
14279
|
+
return chalk15.green(line);
|
|
14222
14280
|
return line;
|
|
14223
14281
|
}
|
|
14224
14282
|
if (line.startsWith(" ")) {
|
|
14225
14283
|
if (line.startsWith(" Error:"))
|
|
14226
|
-
return
|
|
14284
|
+
return chalk15.red(line);
|
|
14227
14285
|
if (line.startsWith(" Query:"))
|
|
14228
|
-
return
|
|
14286
|
+
return chalk15.bold(line);
|
|
14229
14287
|
if (line.startsWith(" Options:") || line.startsWith(" agentSessionId:") || line.startsWith(" Duration:"))
|
|
14230
|
-
return
|
|
14231
|
-
return
|
|
14288
|
+
return chalk15.gray(line);
|
|
14289
|
+
return chalk15.gray(line);
|
|
14232
14290
|
}
|
|
14233
14291
|
return line;
|
|
14234
14292
|
});
|
|
14235
14293
|
}
|
|
14236
14294
|
|
|
14237
14295
|
// src/commands/sessions/compact.ts
|
|
14238
|
-
import
|
|
14296
|
+
import chalk16 from "chalk";
|
|
14239
14297
|
var CompactCommand = {
|
|
14240
14298
|
command: "compact <session-id>",
|
|
14241
14299
|
aliases: ["compress", "checkpoint"],
|
|
@@ -14289,13 +14347,13 @@ var CompactCommand = {
|
|
|
14289
14347
|
dryRun: true
|
|
14290
14348
|
});
|
|
14291
14349
|
} else {
|
|
14292
|
-
output.log(
|
|
14350
|
+
output.log(chalk16.bold("┌─ Compact Preview ─────────────────────────────────┐"));
|
|
14293
14351
|
output.log(`│ Session: ${session.title}`);
|
|
14294
|
-
output.log(`│ Messages to compact: ${
|
|
14352
|
+
output.log(`│ Messages to compact: ${chalk16.yellow(preview.messageCountToCompact)}`);
|
|
14295
14353
|
output.log(`│ Estimated checkpoint tokens: ${preview.estimatedCheckpointTokens}`);
|
|
14296
|
-
output.log(`│ Would trigger: ${preview.wouldTrigger ?
|
|
14354
|
+
output.log(`│ Would trigger: ${preview.wouldTrigger ? chalk16.green("Yes") : chalk16.gray("No")}`);
|
|
14297
14355
|
output.log("│");
|
|
14298
|
-
output.log("│ " +
|
|
14356
|
+
output.log("│ " + chalk16.gray("(Dry run - no changes made)"));
|
|
14299
14357
|
output.log("└" + "─".repeat(51) + "┘");
|
|
14300
14358
|
}
|
|
14301
14359
|
return;
|
|
@@ -14310,10 +14368,10 @@ var CompactCommand = {
|
|
|
14310
14368
|
try {
|
|
14311
14369
|
scenarioHint = await sessionComponent.generateCompactHint(a.sessionId);
|
|
14312
14370
|
if (!a.json) {
|
|
14313
|
-
output.log(
|
|
14314
|
-
output.log("│ " +
|
|
14371
|
+
output.log(chalk16.bold("├─ Auto-generated Scenario Hint ──────────────────────────┤"));
|
|
14372
|
+
output.log("│ " + chalk16.cyan(scenarioHint.substring(0, 70)));
|
|
14315
14373
|
if (scenarioHint.length > 70) {
|
|
14316
|
-
output.log(
|
|
14374
|
+
output.log(chalk16.gray("│ ") + scenarioHint.substring(70, 140));
|
|
14317
14375
|
}
|
|
14318
14376
|
}
|
|
14319
14377
|
} catch (hintError) {
|
|
@@ -14360,29 +14418,29 @@ var CompactCommand = {
|
|
|
14360
14418
|
}
|
|
14361
14419
|
});
|
|
14362
14420
|
} else {
|
|
14363
|
-
output.log(
|
|
14421
|
+
output.log(chalk16.bold.green("┌─ Checkpoint Created ────────────────────────────────┐"));
|
|
14364
14422
|
output.log(`│ ID: ${result.checkpoint.id}`);
|
|
14365
14423
|
output.log(`│ Title: ${result.checkpoint.title}`);
|
|
14366
14424
|
output.log(`│ Type: compact`);
|
|
14367
14425
|
output.log(`│ Created: ${new Date(result.checkpoint.createdAt).toLocaleString("zh-CN")}`);
|
|
14368
|
-
output.log(
|
|
14426
|
+
output.log(chalk16.bold("├─ Scenario Hint ────────────────────────────────────┤"));
|
|
14369
14427
|
if (scenarioHint) {
|
|
14370
14428
|
const hintLines = scenarioHint.split(`
|
|
14371
14429
|
`);
|
|
14372
14430
|
hintLines.forEach((line, i) => {
|
|
14373
14431
|
if (i === 0) {
|
|
14374
|
-
output.log(
|
|
14432
|
+
output.log(chalk16.cyan("│ " + line.substring(0, 48)));
|
|
14375
14433
|
if (line.length > 48) {
|
|
14376
14434
|
for (let j = 48;j < line.length; j += 48) {
|
|
14377
|
-
output.log(
|
|
14435
|
+
output.log(chalk16.gray("│ ") + line.substring(j, j + 48));
|
|
14378
14436
|
}
|
|
14379
14437
|
}
|
|
14380
14438
|
} else {
|
|
14381
|
-
output.log(
|
|
14439
|
+
output.log(chalk16.gray("│ ") + line);
|
|
14382
14440
|
}
|
|
14383
14441
|
});
|
|
14384
14442
|
} else {
|
|
14385
|
-
output.log(
|
|
14443
|
+
output.log(chalk16.gray("│ (no hint)"));
|
|
14386
14444
|
}
|
|
14387
14445
|
output.log("├─ Process Key Points ─────────────────────────────────┤");
|
|
14388
14446
|
result.checkpoint.processKeyPoints.forEach((p, i) => {
|
|
@@ -14407,11 +14465,11 @@ var CompactCommand = {
|
|
|
14407
14465
|
result.checkpoint.recentMessages.forEach((msg) => {
|
|
14408
14466
|
const prefix = msg.role === "user" ? "\uD83D\uDC64" : "\uD83E\uDD16";
|
|
14409
14467
|
const content = msg.content.length > 60 ? msg.content.substring(0, 60) + "..." : msg.content;
|
|
14410
|
-
output.log(
|
|
14468
|
+
output.log(chalk16.gray(`│ ${prefix} [${msg.role}] ${content}`));
|
|
14411
14469
|
});
|
|
14412
14470
|
}
|
|
14413
14471
|
output.log("├─ Stats ─────────────────────────────────────────────┤");
|
|
14414
|
-
output.log(`│ Messages compacted: ${
|
|
14472
|
+
output.log(`│ Messages compacted: ${chalk16.yellow(result.deletedMessageCount)}`);
|
|
14415
14473
|
output.log(`│ Remaining messages: ${result.remainingMessageCount}`);
|
|
14416
14474
|
output.log(`│ Total checkpoints: ${result.checkpointCount}`);
|
|
14417
14475
|
output.log("└" + "─".repeat(51) + "┘");
|
|
@@ -14429,7 +14487,7 @@ var CompactCommand = {
|
|
|
14429
14487
|
};
|
|
14430
14488
|
|
|
14431
14489
|
// src/commands/sessions/checkpoints.ts
|
|
14432
|
-
import
|
|
14490
|
+
import chalk17 from "chalk";
|
|
14433
14491
|
var CheckpointsCommand = {
|
|
14434
14492
|
command: "checkpoints <session-id>",
|
|
14435
14493
|
aliases: ["cps"],
|
|
@@ -14462,7 +14520,7 @@ var CheckpointsCommand = {
|
|
|
14462
14520
|
}
|
|
14463
14521
|
const checkpoints = await sessionComponent.getCheckpoints(a.sessionId);
|
|
14464
14522
|
if (checkpoints.length === 0) {
|
|
14465
|
-
output.log(
|
|
14523
|
+
output.log(chalk17.gray("No checkpoints for this session"));
|
|
14466
14524
|
return;
|
|
14467
14525
|
}
|
|
14468
14526
|
if (a.json) {
|
|
@@ -14487,7 +14545,7 @@ var CheckpointsCommand = {
|
|
|
14487
14545
|
if (a.detail) {
|
|
14488
14546
|
checkpoints.reverse().forEach((cp, i) => {
|
|
14489
14547
|
const isLatest = i === 0;
|
|
14490
|
-
output.log(
|
|
14548
|
+
output.log(chalk17.bold(`┌─ Checkpoint: ${cp.title} ${isLatest ? chalk17.green("✓") : ""} ──────` + "─".repeat(Math.max(0, 30 - cp.title.length)) + "┐"));
|
|
14491
14549
|
output.log(`│ ID: ${cp.id}`);
|
|
14492
14550
|
output.log(`│ Type: ${cp.type}`);
|
|
14493
14551
|
output.log(`│ Message Index: ${cp.messageIndex} (${cp.messageCountBefore} messages)`);
|
|
@@ -14515,18 +14573,18 @@ var CheckpointsCommand = {
|
|
|
14515
14573
|
});
|
|
14516
14574
|
} else {
|
|
14517
14575
|
const header = [
|
|
14518
|
-
|
|
14519
|
-
|
|
14520
|
-
|
|
14521
|
-
|
|
14522
|
-
|
|
14576
|
+
chalk17.bold("#"),
|
|
14577
|
+
chalk17.bold("Title"),
|
|
14578
|
+
chalk17.bold("Type"),
|
|
14579
|
+
chalk17.bold("Messages"),
|
|
14580
|
+
chalk17.bold("Created")
|
|
14523
14581
|
].join(" │ ");
|
|
14524
14582
|
output.log(`┌─ Checkpoints (${checkpoints.length}) ${"─".repeat(40)}┐`);
|
|
14525
14583
|
output.log(`│${header}│`);
|
|
14526
14584
|
output.log("├" + "─".repeat(header.length + 2) + "┤");
|
|
14527
14585
|
checkpoints.reverse().forEach((cp, i) => {
|
|
14528
14586
|
const isLatest = i === 0;
|
|
14529
|
-
const marker = isLatest ?
|
|
14587
|
+
const marker = isLatest ? chalk17.green("✓ ") : " ";
|
|
14530
14588
|
const title = cp.title.length > 25 ? cp.title.slice(0, 22) + "..." : cp.title;
|
|
14531
14589
|
const created = new Date(cp.createdAt).toLocaleString("zh-CN", {
|
|
14532
14590
|
month: "2-digit",
|
|
@@ -14534,7 +14592,7 @@ var CheckpointsCommand = {
|
|
|
14534
14592
|
hour: "2-digit",
|
|
14535
14593
|
minute: "2-digit"
|
|
14536
14594
|
});
|
|
14537
|
-
output.log(`│${marker}${i + 1} ${title.padEnd(25)} │ ${cp.type.padEnd(5)} │ ${cp.messageCountBefore.toString().padStart(8)} │ ${
|
|
14595
|
+
output.log(`│${marker}${i + 1} ${title.padEnd(25)} │ ${cp.type.padEnd(5)} │ ${cp.messageCountBefore.toString().padStart(8)} │ ${chalk17.gray(created)}│`);
|
|
14538
14596
|
});
|
|
14539
14597
|
output.log("└" + "─".repeat(header.length + 2) + "┘");
|
|
14540
14598
|
}
|
|
@@ -14548,7 +14606,7 @@ var CheckpointsCommand = {
|
|
|
14548
14606
|
};
|
|
14549
14607
|
|
|
14550
14608
|
// src/commands/sessions/active.ts
|
|
14551
|
-
import
|
|
14609
|
+
import chalk18 from "chalk";
|
|
14552
14610
|
var ActiveCommand = {
|
|
14553
14611
|
command: "active",
|
|
14554
14612
|
aliases: ["current"],
|
|
@@ -14575,7 +14633,7 @@ var ActiveCommand = {
|
|
|
14575
14633
|
return;
|
|
14576
14634
|
}
|
|
14577
14635
|
if (!activeId) {
|
|
14578
|
-
output.log(
|
|
14636
|
+
output.log(chalk18.gray("No active session set"));
|
|
14579
14637
|
return;
|
|
14580
14638
|
}
|
|
14581
14639
|
const session = await sessionComponent.get(activeId);
|
|
@@ -14593,10 +14651,10 @@ var ActiveCommand = {
|
|
|
14593
14651
|
});
|
|
14594
14652
|
} else {
|
|
14595
14653
|
if (!session) {
|
|
14596
|
-
output.log(
|
|
14654
|
+
output.log(chalk18.gray("Active session not found: " + activeId));
|
|
14597
14655
|
return;
|
|
14598
14656
|
}
|
|
14599
|
-
output.log(
|
|
14657
|
+
output.log(chalk18.bold.green("┌─ Active Session ─────────────────────────────────┐"));
|
|
14600
14658
|
output.log(`│ ID: ${session.id}`);
|
|
14601
14659
|
output.log(`│ Title: ${session.title}`);
|
|
14602
14660
|
output.log(`│ Directory: ${session.directory}`);
|
|
@@ -14678,7 +14736,7 @@ var AddMessageCommand = {
|
|
|
14678
14736
|
};
|
|
14679
14737
|
|
|
14680
14738
|
// src/commands/sessions/mock.ts
|
|
14681
|
-
import
|
|
14739
|
+
import chalk19 from "chalk";
|
|
14682
14740
|
var MOCK_SEQUENCES = [
|
|
14683
14741
|
{
|
|
14684
14742
|
name: "文件操作流程",
|
|
@@ -14811,7 +14869,7 @@ var MockCommand = {
|
|
|
14811
14869
|
for (let seqIdx = 0;seqIdx < count; seqIdx++) {
|
|
14812
14870
|
const sequence = MOCK_SEQUENCES[seqIdx];
|
|
14813
14871
|
if (!a.json) {
|
|
14814
|
-
output.log(
|
|
14872
|
+
output.log(chalk19.bold(`
|
|
14815
14873
|
\uD83D\uDCDD Sequence ${seqIdx + 1}: ${sequence.name}`));
|
|
14816
14874
|
}
|
|
14817
14875
|
for (const msg of sequence.messages) {
|
|
@@ -14829,7 +14887,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14829
14887
|
if (assistantMsgId)
|
|
14830
14888
|
addedMessages.push(assistantMsgId);
|
|
14831
14889
|
if (!a.json) {
|
|
14832
|
-
output.log(
|
|
14890
|
+
output.log(chalk19.cyan(` [${addedMessages.length}] assistant: \uD83D\uDD27 Tool call`));
|
|
14833
14891
|
}
|
|
14834
14892
|
const toolMsgId = await sessionComponent.addMessage(a.sessionId, {
|
|
14835
14893
|
role: "tool",
|
|
@@ -14838,7 +14896,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14838
14896
|
if (toolMsgId)
|
|
14839
14897
|
addedMessages.push(toolMsgId);
|
|
14840
14898
|
if (!a.json) {
|
|
14841
|
-
output.log(
|
|
14899
|
+
output.log(chalk19.yellow(` [${addedMessages.length}] tool: ${msg.content.substring(0, 50)}...`));
|
|
14842
14900
|
}
|
|
14843
14901
|
} else {
|
|
14844
14902
|
const msgId = await sessionComponent.addMessage(a.sessionId, {
|
|
@@ -14848,7 +14906,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14848
14906
|
if (msgId)
|
|
14849
14907
|
addedMessages.push(msgId);
|
|
14850
14908
|
if (!a.json) {
|
|
14851
|
-
const roleColor = msg.role === "user" ?
|
|
14909
|
+
const roleColor = msg.role === "user" ? chalk19.green : msg.role === "assistant" ? chalk19.cyan : chalk19.gray;
|
|
14852
14910
|
output.log(roleColor(` [${addedMessages.length}] ${msg.role}: ${msg.content.substring(0, 50)}...`));
|
|
14853
14911
|
}
|
|
14854
14912
|
}
|
|
@@ -14864,14 +14922,14 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14864
14922
|
});
|
|
14865
14923
|
} else {
|
|
14866
14924
|
output.log(`
|
|
14867
|
-
` +
|
|
14925
|
+
` + chalk19.bold.green("✅ Mock data inserted successfully!"));
|
|
14868
14926
|
output.log(` Session: ${a.sessionId}`);
|
|
14869
14927
|
output.log(` Sequences: ${count}`);
|
|
14870
14928
|
output.log(` Messages: ${addedMessages.length}`);
|
|
14871
14929
|
output.log("");
|
|
14872
|
-
output.log(
|
|
14873
|
-
output.log(
|
|
14874
|
-
output.log(
|
|
14930
|
+
output.log(chalk19.gray(" Now run: "));
|
|
14931
|
+
output.log(chalk19.gray(` roy-agent sessions compact ${a.sessionId}`));
|
|
14932
|
+
output.log(chalk19.gray(" to trigger checkpoint generation"));
|
|
14875
14933
|
}
|
|
14876
14934
|
} finally {
|
|
14877
14935
|
await envService.dispose();
|
|
@@ -14880,7 +14938,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
14880
14938
|
};
|
|
14881
14939
|
|
|
14882
14940
|
// src/commands/sessions/grep.ts
|
|
14883
|
-
import
|
|
14941
|
+
import chalk20 from "chalk";
|
|
14884
14942
|
var GrepCommand = {
|
|
14885
14943
|
command: "grep <query...>",
|
|
14886
14944
|
aliases: ["search"],
|
|
@@ -14960,7 +15018,7 @@ var GrepCommand = {
|
|
|
14960
15018
|
const results = await sessionComponent.searchMessages(searchOptions);
|
|
14961
15019
|
if (results.length === 0) {
|
|
14962
15020
|
if (!a.quiet) {
|
|
14963
|
-
output.log(
|
|
15021
|
+
output.log(chalk20.yellow(`No results found for: ${query}`));
|
|
14964
15022
|
}
|
|
14965
15023
|
return;
|
|
14966
15024
|
}
|
|
@@ -14987,7 +15045,7 @@ var GrepCommand = {
|
|
|
14987
15045
|
for (const result of results) {
|
|
14988
15046
|
for (const match of result.matches) {
|
|
14989
15047
|
const time = new Date(match.timestamp).toLocaleString("zh-CN");
|
|
14990
|
-
output.log(`${
|
|
15048
|
+
output.log(`${chalk20.gray(result.sessionId)} ${chalk20.blue(result.sessionTitle)} ${chalk20.gray(time)}`);
|
|
14991
15049
|
output.log(` ${match.content}`);
|
|
14992
15050
|
output.log("");
|
|
14993
15051
|
}
|
|
@@ -14999,40 +15057,40 @@ var GrepCommand = {
|
|
|
14999
15057
|
totalMatches += result.matches.length;
|
|
15000
15058
|
const time = new Date(result.updatedAt).toLocaleString("zh-CN");
|
|
15001
15059
|
const titleStr = `─ ${result.sessionTitle} (${result.sessionId})`;
|
|
15002
|
-
output.log(
|
|
15060
|
+
output.log(chalk20.bold(`
|
|
15003
15061
|
┌${titleStr}${"─".repeat(Math.max(0, 50 - titleStr.length))}┐`));
|
|
15004
|
-
output.log(`│ ${
|
|
15062
|
+
output.log(`│ ${chalk20.gray(`Updated: ${time} | ${result.messageCount} messages | ${result.matches.length} matches`)}${" ".repeat(Math.max(0, 50 - 60))}│`);
|
|
15005
15063
|
for (let i = 0;i < result.matches.length; i++) {
|
|
15006
15064
|
const match = result.matches[i];
|
|
15007
|
-
const roleColor = match.role === "user" ?
|
|
15065
|
+
const roleColor = match.role === "user" ? chalk20.blue : match.role === "assistant" ? chalk20.green : chalk20.gray;
|
|
15008
15066
|
const msgTime = new Date(match.timestamp).toLocaleTimeString("zh-CN", {
|
|
15009
15067
|
hour: "2-digit",
|
|
15010
15068
|
minute: "2-digit"
|
|
15011
15069
|
});
|
|
15012
|
-
output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${
|
|
15070
|
+
output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${chalk20.gray(msgTime)}`);
|
|
15013
15071
|
output.log("│");
|
|
15014
15072
|
const lines = match.content.split(`
|
|
15015
15073
|
`).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
15016
15074
|
const maxLines = 5;
|
|
15017
15075
|
const displayLines = lines.slice(0, maxLines);
|
|
15018
15076
|
if (displayLines.length === 0) {
|
|
15019
|
-
output.log("│ " +
|
|
15077
|
+
output.log("│ " + chalk20.gray("(empty content)"));
|
|
15020
15078
|
} else {
|
|
15021
15079
|
for (const line of displayLines) {
|
|
15022
15080
|
const truncated = line.length > 76 ? line.slice(0, 73) + "..." : line;
|
|
15023
|
-
output.log(`│ ${
|
|
15081
|
+
output.log(`│ ${chalk20.gray(truncated)}`);
|
|
15024
15082
|
}
|
|
15025
15083
|
}
|
|
15026
15084
|
if (lines.length > maxLines) {
|
|
15027
|
-
output.log("│ " +
|
|
15085
|
+
output.log("│ " + chalk20.gray(`... (${lines.length - maxLines} more lines)`));
|
|
15028
15086
|
}
|
|
15029
15087
|
output.log("│");
|
|
15030
15088
|
}
|
|
15031
15089
|
output.log(`└${"─".repeat(52)}┘`);
|
|
15032
15090
|
}
|
|
15033
15091
|
output.log(`
|
|
15034
|
-
${
|
|
15035
|
-
output.log(
|
|
15092
|
+
${chalk20.green("✓")} Found ${chalk20.bold(totalMatches.toString())} matches in ${chalk20.bold(results.length.toString())} sessions`);
|
|
15093
|
+
output.log(chalk20.gray(`Query: "${query}"`));
|
|
15036
15094
|
}
|
|
15037
15095
|
} catch (error) {
|
|
15038
15096
|
output.error(`Search failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -15071,7 +15129,7 @@ var SessionsCommand = {
|
|
|
15071
15129
|
};
|
|
15072
15130
|
|
|
15073
15131
|
// src/commands/tasks/list.ts
|
|
15074
|
-
import
|
|
15132
|
+
import chalk22 from "chalk";
|
|
15075
15133
|
|
|
15076
15134
|
// src/commands/tasks/_build-list-json.ts
|
|
15077
15135
|
function buildListTasksJson(tasks, total, args, extras) {
|
|
@@ -15101,7 +15159,7 @@ function buildListTasksJson(tasks, total, args, extras) {
|
|
|
15101
15159
|
}
|
|
15102
15160
|
|
|
15103
15161
|
// src/commands/tasks/task-graph.ts
|
|
15104
|
-
import
|
|
15162
|
+
import chalk21 from "chalk";
|
|
15105
15163
|
function buildTaskTree(tasks) {
|
|
15106
15164
|
const nodeById = new Map;
|
|
15107
15165
|
const byParent = new Map;
|
|
@@ -15184,9 +15242,9 @@ function renderTaskTree(roots, options = {}) {
|
|
|
15184
15242
|
}
|
|
15185
15243
|
const maxDepth = options.maxDepth !== undefined && options.maxDepth < 0 ? undefined : options.maxDepth;
|
|
15186
15244
|
const totalCount = countDeep(roots);
|
|
15187
|
-
const headerSuffix = options.rootId !== undefined ?
|
|
15245
|
+
const headerSuffix = options.rootId !== undefined ? chalk21.gray(` — subtree of #${options.rootId}`) : "";
|
|
15188
15246
|
const lines = [
|
|
15189
|
-
|
|
15247
|
+
chalk21.bold(`Task Tree (${totalCount} tasks, ${roots.length} roots)`) + headerSuffix,
|
|
15190
15248
|
""
|
|
15191
15249
|
];
|
|
15192
15250
|
for (let i = 0;i < roots.length; i++) {
|
|
@@ -15227,20 +15285,20 @@ function formatTaskLabel(task) {
|
|
|
15227
15285
|
const idStr = `#${task.id}`;
|
|
15228
15286
|
const typeLabel = task.type && task.type !== "normal" ? ` [${task.type}]` : "";
|
|
15229
15287
|
const progressLabel = task.progress > 0 ? ` (${task.progress}%)` : "";
|
|
15230
|
-
return `${idStr}${typeLabel} ${task.title} ${
|
|
15288
|
+
return `${idStr}${typeLabel} ${task.title} ${chalk21.gray("[" + task.status + "]")}${progressLabel}`;
|
|
15231
15289
|
}
|
|
15232
15290
|
function colorByStatus(status) {
|
|
15233
15291
|
switch (status) {
|
|
15234
15292
|
case "completed":
|
|
15235
|
-
return
|
|
15293
|
+
return chalk21.green;
|
|
15236
15294
|
case "active":
|
|
15237
|
-
return
|
|
15295
|
+
return chalk21.blue;
|
|
15238
15296
|
case "paused":
|
|
15239
|
-
return
|
|
15297
|
+
return chalk21.yellow;
|
|
15240
15298
|
case "cancelled":
|
|
15241
|
-
return
|
|
15299
|
+
return chalk21.strikethrough;
|
|
15242
15300
|
default:
|
|
15243
|
-
return
|
|
15301
|
+
return chalk21.gray;
|
|
15244
15302
|
}
|
|
15245
15303
|
}
|
|
15246
15304
|
|
|
@@ -15319,17 +15377,17 @@ var ListCommand2 = {
|
|
|
15319
15377
|
output.log(hint);
|
|
15320
15378
|
} else {
|
|
15321
15379
|
const header = [
|
|
15322
|
-
|
|
15323
|
-
|
|
15324
|
-
|
|
15325
|
-
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
|
|
15380
|
+
chalk22.bold("#"),
|
|
15381
|
+
chalk22.bold("Title"),
|
|
15382
|
+
chalk22.bold("Status"),
|
|
15383
|
+
chalk22.bold("Priority"),
|
|
15384
|
+
chalk22.bold("Type"),
|
|
15385
|
+
chalk22.bold("Progress"),
|
|
15386
|
+
chalk22.bold("Parent")
|
|
15329
15387
|
].join(" │ ");
|
|
15330
15388
|
const rows = tasks.map((t, i) => {
|
|
15331
|
-
const statusColor = t.status === "completed" ?
|
|
15332
|
-
const priorityColor = t.priority === "high" ?
|
|
15389
|
+
const statusColor = t.status === "completed" ? chalk22.green : t.status === "active" ? chalk22.blue : t.status === "paused" ? chalk22.yellow : t.status === "cancelled" ? chalk22.strikethrough : chalk22.gray;
|
|
15390
|
+
const priorityColor = t.priority === "high" ? chalk22.red : t.priority === "medium" ? chalk22.yellow : chalk22.gray;
|
|
15333
15391
|
return [
|
|
15334
15392
|
(args.offset + i + 1).toString(),
|
|
15335
15393
|
t.title.length > 30 ? t.title.slice(0, 27) + "..." : t.title,
|
|
@@ -15337,11 +15395,11 @@ var ListCommand2 = {
|
|
|
15337
15395
|
priorityColor(t.priority),
|
|
15338
15396
|
t.type || "normal",
|
|
15339
15397
|
`${t.progress}%`,
|
|
15340
|
-
t.parent_task_id ? `#${t.parent_task_id}` :
|
|
15398
|
+
t.parent_task_id ? `#${t.parent_task_id}` : chalk22.gray("root")
|
|
15341
15399
|
].join(" │ ");
|
|
15342
15400
|
});
|
|
15343
|
-
const depthNote = args.depth !== undefined ?
|
|
15344
|
-
const archivedNote = args.includeArchived ?
|
|
15401
|
+
const depthNote = args.depth !== undefined ? chalk22.gray(` depth=${args.depth}`) : "";
|
|
15402
|
+
const archivedNote = args.includeArchived ? chalk22.gray(" include-archived") : "";
|
|
15345
15403
|
output.log([
|
|
15346
15404
|
`┌─ Tasks ${"─".repeat(55)}┐`,
|
|
15347
15405
|
`│${header}│`,
|
|
@@ -15349,7 +15407,7 @@ var ListCommand2 = {
|
|
|
15349
15407
|
...rows.map((r) => `│${r}│`),
|
|
15350
15408
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
15351
15409
|
"",
|
|
15352
|
-
|
|
15410
|
+
chalk22.gray(`Showing ${tasks.length} of ${total} tasks (offset=${args.offset}, limit=${args.limit})${depthNote}${archivedNote}`)
|
|
15353
15411
|
].join(`
|
|
15354
15412
|
`));
|
|
15355
15413
|
}
|
|
@@ -15363,7 +15421,7 @@ var ListCommand2 = {
|
|
|
15363
15421
|
};
|
|
15364
15422
|
|
|
15365
15423
|
// src/commands/tasks/get.ts
|
|
15366
|
-
import
|
|
15424
|
+
import chalk23 from "chalk";
|
|
15367
15425
|
var GetCommand2 = {
|
|
15368
15426
|
command: "get <id>",
|
|
15369
15427
|
aliases: ["show"],
|
|
@@ -15402,10 +15460,10 @@ var GetCommand2 = {
|
|
|
15402
15460
|
if (args.json) {
|
|
15403
15461
|
output.json(result);
|
|
15404
15462
|
} else {
|
|
15405
|
-
output.log(
|
|
15463
|
+
output.log(chalk23.bold(`
|
|
15406
15464
|
Task #${result.task.id}: ${result.task.title}
|
|
15407
15465
|
`));
|
|
15408
|
-
output.log(`Status: ${
|
|
15466
|
+
output.log(`Status: ${chalk23.blue(result.task.status)} | Priority: ${result.task.priority} | Type: ${result.task.type} | Progress: ${result.task.progress}%`);
|
|
15409
15467
|
output.log(`Created: ${result.task.createdAt} | Updated: ${result.task.updatedAt}`);
|
|
15410
15468
|
output.log(`Project Path: ${result.task.project_path}`);
|
|
15411
15469
|
output.log(`Context: ${result.task.context}`);
|
|
@@ -15413,18 +15471,18 @@ Task #${result.task.id}: ${result.task.title}
|
|
|
15413
15471
|
output.log(`
|
|
15414
15472
|
Current Status: ${result.task.current_status}`);
|
|
15415
15473
|
}
|
|
15416
|
-
output.log(
|
|
15474
|
+
output.log(chalk23.bold(`
|
|
15417
15475
|
Operations (${result.operations.length}):
|
|
15418
15476
|
`));
|
|
15419
15477
|
result.operations.forEach((op, i) => {
|
|
15420
|
-
const actionColor = op.milestoneType === "completed" ?
|
|
15478
|
+
const actionColor = op.milestoneType === "completed" ? chalk23.green : op.milestoneType === "milestone" ? chalk23.blue : op.milestoneType === "problem" ? chalk23.red : chalk23.gray;
|
|
15421
15479
|
output.log(` ${i + 1}. ` + actionColor(`[${op.milestoneType}]`) + ` ${op.milestoneTitle}`);
|
|
15422
15480
|
output.log(` Session: ${op.sessionId} | Time: ${op.timestamp}`);
|
|
15423
15481
|
if (op.milestoneDescription) {
|
|
15424
15482
|
output.log(` ${op.milestoneDescription}`);
|
|
15425
15483
|
}
|
|
15426
15484
|
if (op.processDescription) {
|
|
15427
|
-
output.log(
|
|
15485
|
+
output.log(chalk23.gray(` \uD83D\uDCCB 过程概要: ${op.processDescription}`));
|
|
15428
15486
|
}
|
|
15429
15487
|
});
|
|
15430
15488
|
}
|
|
@@ -15437,10 +15495,10 @@ Operations (${result.operations.length}):
|
|
|
15437
15495
|
if (args.json) {
|
|
15438
15496
|
output.json(task);
|
|
15439
15497
|
} else {
|
|
15440
|
-
output.log(
|
|
15498
|
+
output.log(chalk23.bold(`
|
|
15441
15499
|
Task #${task.id}: ${task.title}
|
|
15442
15500
|
`));
|
|
15443
|
-
output.log(`Status: ${
|
|
15501
|
+
output.log(`Status: ${chalk23.blue(task.status)} | Priority: ${task.priority} | Type: ${task.type} | Progress: ${task.progress}%`);
|
|
15444
15502
|
output.log(`Created: ${task.createdAt} | Updated: ${task.updatedAt}`);
|
|
15445
15503
|
output.log(`Project Path: ${task.project_path}`);
|
|
15446
15504
|
output.log(`Context: ${task.context}`);
|
|
@@ -15464,7 +15522,7 @@ Description: ${task.description}`);
|
|
|
15464
15522
|
};
|
|
15465
15523
|
|
|
15466
15524
|
// src/commands/tasks/create.ts
|
|
15467
|
-
import
|
|
15525
|
+
import chalk24 from "chalk";
|
|
15468
15526
|
var CreateCommand = {
|
|
15469
15527
|
command: "create <title>",
|
|
15470
15528
|
aliases: ["add", "new"],
|
|
@@ -15542,7 +15600,7 @@ var CreateCommand = {
|
|
|
15542
15600
|
if (args.json) {
|
|
15543
15601
|
output.json(task);
|
|
15544
15602
|
} else {
|
|
15545
|
-
output.log(
|
|
15603
|
+
output.log(chalk24.green(`
|
|
15546
15604
|
✓ Task created: #${task.id}`));
|
|
15547
15605
|
output.log(` Title: ${task.title}`);
|
|
15548
15606
|
output.log(` Status: ${task.status}`);
|
|
@@ -15560,7 +15618,7 @@ var CreateCommand = {
|
|
|
15560
15618
|
};
|
|
15561
15619
|
|
|
15562
15620
|
// src/commands/tasks/update.ts
|
|
15563
|
-
import
|
|
15621
|
+
import chalk25 from "chalk";
|
|
15564
15622
|
var UpdateCommand = {
|
|
15565
15623
|
command: "update <id>",
|
|
15566
15624
|
aliases: ["set"],
|
|
@@ -15620,7 +15678,7 @@ var UpdateCommand = {
|
|
|
15620
15678
|
if (args.json) {
|
|
15621
15679
|
output.json(task);
|
|
15622
15680
|
} else {
|
|
15623
|
-
output.log(
|
|
15681
|
+
output.log(chalk25.green(`
|
|
15624
15682
|
✓ Task updated: #${task.id}`));
|
|
15625
15683
|
output.log(` Title: ${task.title}`);
|
|
15626
15684
|
output.log(` Status: ${task.status}`);
|
|
@@ -15643,7 +15701,7 @@ var UpdateCommand = {
|
|
|
15643
15701
|
};
|
|
15644
15702
|
|
|
15645
15703
|
// src/commands/tasks/delete.ts
|
|
15646
|
-
import
|
|
15704
|
+
import chalk26 from "chalk";
|
|
15647
15705
|
var DeleteCommand2 = {
|
|
15648
15706
|
command: "delete <id>",
|
|
15649
15707
|
aliases: ["remove", "rm", "del"],
|
|
@@ -15679,16 +15737,16 @@ var DeleteCommand2 = {
|
|
|
15679
15737
|
process.exit(1);
|
|
15680
15738
|
}
|
|
15681
15739
|
if (!args.force) {
|
|
15682
|
-
output.log(
|
|
15683
|
-
output.log(
|
|
15684
|
-
output.log(
|
|
15685
|
-
output.log(
|
|
15740
|
+
output.log(chalk26.yellow(`Are you sure you want to delete task #${args.id}?`));
|
|
15741
|
+
output.log(chalk26.yellow(` Title: ${task.title}`));
|
|
15742
|
+
output.log(chalk26.yellow(` Status: ${task.status}`));
|
|
15743
|
+
output.log(chalk26.yellow(`
|
|
15686
15744
|
Use --force to skip this confirmation`));
|
|
15687
15745
|
process.exit(1);
|
|
15688
15746
|
}
|
|
15689
15747
|
const deleted = await taskComponent.deleteTask(args.id);
|
|
15690
15748
|
if (deleted) {
|
|
15691
|
-
output.log(
|
|
15749
|
+
output.log(chalk26.green(`
|
|
15692
15750
|
✓ Task deleted: #${args.id}`));
|
|
15693
15751
|
} else {
|
|
15694
15752
|
output.error(`Failed to delete task: ${args.id}`);
|
|
@@ -15704,7 +15762,7 @@ Use --force to skip this confirmation`));
|
|
|
15704
15762
|
};
|
|
15705
15763
|
|
|
15706
15764
|
// src/commands/tasks/complete.ts
|
|
15707
|
-
import
|
|
15765
|
+
import chalk27 from "chalk";
|
|
15708
15766
|
var CompleteCommand = {
|
|
15709
15767
|
command: "complete <id>",
|
|
15710
15768
|
aliases: ["done", "finish"],
|
|
@@ -15763,7 +15821,7 @@ var CompleteCommand = {
|
|
|
15763
15821
|
if (args.json) {
|
|
15764
15822
|
output.json(task);
|
|
15765
15823
|
} else {
|
|
15766
|
-
output.log(
|
|
15824
|
+
output.log(chalk27.green(`
|
|
15767
15825
|
✓ Task completed: #${task.id}`));
|
|
15768
15826
|
output.log(` Title: ${task.title}`);
|
|
15769
15827
|
output.log(` Progress: ${task.progress}%`);
|
|
@@ -15779,7 +15837,7 @@ var CompleteCommand = {
|
|
|
15779
15837
|
};
|
|
15780
15838
|
|
|
15781
15839
|
// src/commands/tasks/operations.ts
|
|
15782
|
-
import
|
|
15840
|
+
import chalk28 from "chalk";
|
|
15783
15841
|
var OperationsCommand = {
|
|
15784
15842
|
command: "operations <task-id>",
|
|
15785
15843
|
aliases: ["ops", "log"],
|
|
@@ -15829,26 +15887,26 @@ var OperationsCommand = {
|
|
|
15829
15887
|
operations
|
|
15830
15888
|
});
|
|
15831
15889
|
} else {
|
|
15832
|
-
output.log(
|
|
15890
|
+
output.log(chalk28.bold(`
|
|
15833
15891
|
Operations for Task #${task.id}: ${task.title}
|
|
15834
15892
|
`));
|
|
15835
15893
|
if (operations.length === 0) {
|
|
15836
|
-
output.log(
|
|
15894
|
+
output.log(chalk28.gray("No operations found."));
|
|
15837
15895
|
} else {
|
|
15838
15896
|
operations.forEach((op, i) => {
|
|
15839
|
-
const actionColor = op.milestoneType === "completed" ?
|
|
15840
|
-
output.log(`${
|
|
15841
|
-
output.log(` Session: ${
|
|
15897
|
+
const actionColor = op.milestoneType === "completed" ? chalk28.green : op.milestoneType === "milestone" ? chalk28.blue : op.milestoneType === "problem" ? chalk28.red : chalk28.gray;
|
|
15898
|
+
output.log(`${chalk28.bold(a.offset + i + 1)}. ` + actionColor(`[${op.milestoneType}]`) + ` ${op.milestoneTitle}`);
|
|
15899
|
+
output.log(` Session: ${chalk28.cyan(op.sessionId)} | Time: ${op.timestamp}`);
|
|
15842
15900
|
if (op.milestoneDescription) {
|
|
15843
15901
|
output.log(` ${op.milestoneDescription}`);
|
|
15844
15902
|
}
|
|
15845
15903
|
if (op.processDescription) {
|
|
15846
|
-
output.log(
|
|
15904
|
+
output.log(chalk28.gray(` \uD83D\uDCCB 过程概要: ${op.processDescription}`));
|
|
15847
15905
|
}
|
|
15848
15906
|
output.log("");
|
|
15849
15907
|
});
|
|
15850
15908
|
}
|
|
15851
|
-
output.log(
|
|
15909
|
+
output.log(chalk28.gray(`Total: ${operations.length} operations`));
|
|
15852
15910
|
}
|
|
15853
15911
|
} catch (error) {
|
|
15854
15912
|
output.error(`Failed to list operations: ${error}`);
|
|
@@ -15860,7 +15918,7 @@ Operations for Task #${task.id}: ${task.title}
|
|
|
15860
15918
|
};
|
|
15861
15919
|
|
|
15862
15920
|
// src/commands/tasks/tree.ts
|
|
15863
|
-
import
|
|
15921
|
+
import chalk29 from "chalk";
|
|
15864
15922
|
var TreeCommand = {
|
|
15865
15923
|
command: "tree",
|
|
15866
15924
|
describe: "以树形结构展示所有任务(基于 parent_task_id)",
|
|
@@ -15950,7 +16008,7 @@ var TreeCommand = {
|
|
|
15950
16008
|
return;
|
|
15951
16009
|
}
|
|
15952
16010
|
if (tree.length === 0) {
|
|
15953
|
-
output.log(
|
|
16011
|
+
output.log(chalk29.gray("No tasks to display."));
|
|
15954
16012
|
return;
|
|
15955
16013
|
}
|
|
15956
16014
|
output.log(renderTaskTree(tree, { maxDepth: args.depth, rootId: args.rootId }));
|
|
@@ -15964,7 +16022,7 @@ var TreeCommand = {
|
|
|
15964
16022
|
};
|
|
15965
16023
|
|
|
15966
16024
|
// src/commands/tasks/search.ts
|
|
15967
|
-
import
|
|
16025
|
+
import chalk30 from "chalk";
|
|
15968
16026
|
var SearchCommand = {
|
|
15969
16027
|
command: "search <keywords..>",
|
|
15970
16028
|
aliases: ["find", "grep"],
|
|
@@ -16037,26 +16095,26 @@ var SearchCommand = {
|
|
|
16037
16095
|
output.log(hint);
|
|
16038
16096
|
} else {
|
|
16039
16097
|
const keywordStr = args.keywords.join(" ");
|
|
16040
|
-
output.log(
|
|
16098
|
+
output.log(chalk30.bold(`
|
|
16041
16099
|
\uD83D\uDD0D Search: "${keywordStr}" — ${total} results
|
|
16042
16100
|
`));
|
|
16043
16101
|
if (tasks.length === 0) {
|
|
16044
|
-
output.log(
|
|
16102
|
+
output.log(chalk30.gray(" No matching tasks found."));
|
|
16045
16103
|
return;
|
|
16046
16104
|
}
|
|
16047
16105
|
for (const t of tasks) {
|
|
16048
|
-
const statusColor = t.status === "completed" ?
|
|
16049
|
-
const pid = t.parent_task_id ?
|
|
16106
|
+
const statusColor = t.status === "completed" ? chalk30.green : t.status === "active" ? chalk30.blue : t.status === "paused" ? chalk30.yellow : t.status === "cancelled" ? chalk30.strikethrough : t.status === "archived" ? chalk30.gray : chalk30.gray;
|
|
16107
|
+
const pid = t.parent_task_id ? chalk30.gray(` (#${t.parent_task_id})`) : "";
|
|
16050
16108
|
output.log(` #${t.id} ${statusColor("[" + t.status + "]")} ${t.title}${pid}`);
|
|
16051
16109
|
if (t.current_status) {
|
|
16052
|
-
output.log(` ${
|
|
16110
|
+
output.log(` ${chalk30.gray(t.current_status.slice(0, 80))}`);
|
|
16053
16111
|
}
|
|
16054
16112
|
}
|
|
16055
16113
|
if (total > tasks.length) {
|
|
16056
|
-
output.log(
|
|
16114
|
+
output.log(chalk30.gray(`
|
|
16057
16115
|
... and ${total - tasks.length} more. Use --offset and --limit to paginate.`));
|
|
16058
16116
|
}
|
|
16059
|
-
output.log(
|
|
16117
|
+
output.log(chalk30.gray(` Page: ${Math.floor((args.offset || 0) / (args.limit || 20)) + 1}/${Math.ceil(total / (args.limit || 20))}`));
|
|
16060
16118
|
}
|
|
16061
16119
|
} catch (error) {
|
|
16062
16120
|
output.error(`Failed to search tasks: ${error}`);
|
|
@@ -16316,7 +16374,7 @@ var TasksCommand = {
|
|
|
16316
16374
|
};
|
|
16317
16375
|
|
|
16318
16376
|
// src/commands/skills/list.ts
|
|
16319
|
-
import
|
|
16377
|
+
import chalk31 from "chalk";
|
|
16320
16378
|
var ListCommand3 = {
|
|
16321
16379
|
command: "list",
|
|
16322
16380
|
aliases: ["ls"],
|
|
@@ -16384,26 +16442,26 @@ var ListCommand3 = {
|
|
|
16384
16442
|
output.log(hint);
|
|
16385
16443
|
} else {
|
|
16386
16444
|
const header = [
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
|
|
16445
|
+
chalk31.bold("Name"),
|
|
16446
|
+
chalk31.bold("Description"),
|
|
16447
|
+
chalk31.bold("Source")
|
|
16390
16448
|
].join(" | ");
|
|
16391
16449
|
const sourceColor = (source) => {
|
|
16392
16450
|
switch (source) {
|
|
16393
16451
|
case "project":
|
|
16394
|
-
return
|
|
16452
|
+
return chalk31.green;
|
|
16395
16453
|
case "user":
|
|
16396
|
-
return
|
|
16454
|
+
return chalk31.blue;
|
|
16397
16455
|
case "built-in":
|
|
16398
|
-
return
|
|
16456
|
+
return chalk31.gray;
|
|
16399
16457
|
default:
|
|
16400
|
-
return
|
|
16458
|
+
return chalk31.white;
|
|
16401
16459
|
}
|
|
16402
16460
|
};
|
|
16403
16461
|
const rows = skills.map((s) => {
|
|
16404
16462
|
const desc2 = s.description.length > 50 ? s.description.slice(0, 47) + "..." : s.description;
|
|
16405
16463
|
return [
|
|
16406
|
-
|
|
16464
|
+
chalk31.cyan(s.name),
|
|
16407
16465
|
desc2,
|
|
16408
16466
|
sourceColor(s.source)(`[${s.source}]`)
|
|
16409
16467
|
].join(" | ");
|
|
@@ -16436,7 +16494,7 @@ var ListCommand3 = {
|
|
|
16436
16494
|
};
|
|
16437
16495
|
|
|
16438
16496
|
// src/commands/skills/get.ts
|
|
16439
|
-
import
|
|
16497
|
+
import chalk32 from "chalk";
|
|
16440
16498
|
var GetCommand3 = {
|
|
16441
16499
|
command: "get <name>",
|
|
16442
16500
|
describe: "获取指定技能内容",
|
|
@@ -16480,13 +16538,13 @@ var GetCommand3 = {
|
|
|
16480
16538
|
content: skill.content
|
|
16481
16539
|
});
|
|
16482
16540
|
} else {
|
|
16483
|
-
output.log(
|
|
16541
|
+
output.log(chalk32.bold.cyan(`# ${skill.name}`));
|
|
16484
16542
|
output.log("");
|
|
16485
|
-
output.log(`${
|
|
16486
|
-
output.log(`${
|
|
16487
|
-
output.log(`${
|
|
16543
|
+
output.log(`${chalk32.gray("Description:")} ${skill.description}`);
|
|
16544
|
+
output.log(`${chalk32.gray("Source:")} ${skill.source}`);
|
|
16545
|
+
output.log(`${chalk32.gray("File:")} ${skill.filePath}`);
|
|
16488
16546
|
output.log("");
|
|
16489
|
-
output.log(
|
|
16547
|
+
output.log(chalk32.bold("--- Content ---"));
|
|
16490
16548
|
output.log("");
|
|
16491
16549
|
output.log(skill.content);
|
|
16492
16550
|
}
|
|
@@ -16500,7 +16558,7 @@ var GetCommand3 = {
|
|
|
16500
16558
|
};
|
|
16501
16559
|
|
|
16502
16560
|
// src/commands/skills/search.ts
|
|
16503
|
-
import
|
|
16561
|
+
import chalk33 from "chalk";
|
|
16504
16562
|
var SearchCommand2 = {
|
|
16505
16563
|
command: "search <term>",
|
|
16506
16564
|
aliases: ["find"],
|
|
@@ -16539,7 +16597,7 @@ var SearchCommand2 = {
|
|
|
16539
16597
|
const term = args.term.toLowerCase();
|
|
16540
16598
|
const results = allSkills.filter((s) => s.name.toLowerCase().includes(term) || s.description.toLowerCase().includes(term));
|
|
16541
16599
|
if (results.length === 0) {
|
|
16542
|
-
output.log(
|
|
16600
|
+
output.log(chalk33.yellow(`No skills found matching: ${args.term}`));
|
|
16543
16601
|
return;
|
|
16544
16602
|
}
|
|
16545
16603
|
if (args.json) {
|
|
@@ -16556,19 +16614,19 @@ var SearchCommand2 = {
|
|
|
16556
16614
|
} else if (args.quiet) {
|
|
16557
16615
|
results.forEach((s) => output.log(s.name));
|
|
16558
16616
|
} else {
|
|
16559
|
-
output.log(
|
|
16617
|
+
output.log(chalk33.bold(`Search results for "${args.term}":`));
|
|
16560
16618
|
output.log("");
|
|
16561
16619
|
const header = [
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16620
|
+
chalk33.bold("Name"),
|
|
16621
|
+
chalk33.bold("Description"),
|
|
16622
|
+
chalk33.bold("Match")
|
|
16565
16623
|
].join(" | ");
|
|
16566
16624
|
const rows = results.map((s) => {
|
|
16567
16625
|
const matchedIn = s.name.toLowerCase().includes(term) ? "name" : "description";
|
|
16568
|
-
const matchColor = matchedIn === "name" ?
|
|
16626
|
+
const matchColor = matchedIn === "name" ? chalk33.green : chalk33.blue;
|
|
16569
16627
|
const desc2 = s.description.length > 40 ? s.description.slice(0, 37) + "..." : s.description;
|
|
16570
16628
|
return [
|
|
16571
|
-
|
|
16629
|
+
chalk33.cyan(s.name),
|
|
16572
16630
|
desc2,
|
|
16573
16631
|
matchColor(`[${matchedIn}]`)
|
|
16574
16632
|
].join(" | ");
|
|
@@ -16580,7 +16638,7 @@ var SearchCommand2 = {
|
|
|
16580
16638
|
...rows.map((r) => `│${r}│`),
|
|
16581
16639
|
"└" + "─".repeat(header.length + 2) + "┘",
|
|
16582
16640
|
"",
|
|
16583
|
-
|
|
16641
|
+
chalk33.gray(`${results.length} matching skill(s) found.`)
|
|
16584
16642
|
].join(`
|
|
16585
16643
|
`));
|
|
16586
16644
|
}
|
|
@@ -16594,7 +16652,7 @@ var SearchCommand2 = {
|
|
|
16594
16652
|
};
|
|
16595
16653
|
|
|
16596
16654
|
// src/commands/skills/reload.ts
|
|
16597
|
-
import
|
|
16655
|
+
import chalk34 from "chalk";
|
|
16598
16656
|
var ReloadCommand = {
|
|
16599
16657
|
command: "reload",
|
|
16600
16658
|
describe: "重新扫描并更新 SkillTool",
|
|
@@ -16617,10 +16675,10 @@ var ReloadCommand = {
|
|
|
16617
16675
|
output.error("SkillComponent not available");
|
|
16618
16676
|
process.exit(1);
|
|
16619
16677
|
}
|
|
16620
|
-
output.log(
|
|
16678
|
+
output.log(chalk34.blue("Reloading skills..."));
|
|
16621
16679
|
await skillComponent.reload();
|
|
16622
16680
|
const skills = skillComponent.getSkillList();
|
|
16623
|
-
output.log(
|
|
16681
|
+
output.log(chalk34.green(`Successfully reloaded ${skills.length} skills`));
|
|
16624
16682
|
} catch (error) {
|
|
16625
16683
|
output.error(`Failed to reload skills: ${error}`);
|
|
16626
16684
|
process.exit(1);
|
|
@@ -16631,7 +16689,7 @@ var ReloadCommand = {
|
|
|
16631
16689
|
};
|
|
16632
16690
|
|
|
16633
16691
|
// src/commands/skills/show-config.ts
|
|
16634
|
-
import
|
|
16692
|
+
import chalk35 from "chalk";
|
|
16635
16693
|
var ShowConfigCommand = {
|
|
16636
16694
|
command: "show-config",
|
|
16637
16695
|
aliases: ["config"],
|
|
@@ -16656,38 +16714,38 @@ var ShowConfigCommand = {
|
|
|
16656
16714
|
process.exit(1);
|
|
16657
16715
|
}
|
|
16658
16716
|
const defaultConfig = skillComponent.getConfig?.();
|
|
16659
|
-
output.log(
|
|
16717
|
+
output.log(chalk35.bold.cyan(`# Skills Configuration
|
|
16660
16718
|
`));
|
|
16661
|
-
output.log(
|
|
16719
|
+
output.log(chalk35.bold(`## Scan Paths
|
|
16662
16720
|
`));
|
|
16663
16721
|
const paths = [
|
|
16664
16722
|
{ type: "user", desc: "用户路径", path: "~/.config/roy-agent/skills/" },
|
|
16665
16723
|
{ type: "project", desc: "项目路径", path: ".roy/skills/" }
|
|
16666
16724
|
];
|
|
16667
16725
|
for (const p of paths) {
|
|
16668
|
-
const typeColor = p.type === "project" ?
|
|
16669
|
-
output.log(` ${typeColor("[ " + p.type + " ]")} ${
|
|
16670
|
-
output.log(` ${
|
|
16726
|
+
const typeColor = p.type === "project" ? chalk35.green : chalk35.blue;
|
|
16727
|
+
output.log(` ${typeColor("[ " + p.type + " ]")} ${chalk35.gray(p.desc)}`);
|
|
16728
|
+
output.log(` ${chalk35.cyan(p.path)}
|
|
16671
16729
|
`);
|
|
16672
16730
|
}
|
|
16673
|
-
output.log(
|
|
16731
|
+
output.log(chalk35.bold(`## Scan Rules
|
|
16674
16732
|
`));
|
|
16675
|
-
output.log(` ${
|
|
16676
|
-
output.log(` ${
|
|
16677
|
-
output.log(` ${
|
|
16733
|
+
output.log(` ${chalk35.gray("Pattern:")} ${chalk35.cyan("**/SKILL.md")}`);
|
|
16734
|
+
output.log(` ${chalk35.gray("Recursive:")} ${chalk35.green("true")}`);
|
|
16735
|
+
output.log(` ${chalk35.gray("Ignore:")} ${chalk35.cyan("**/node_modules/**")}
|
|
16678
16736
|
`);
|
|
16679
|
-
output.log(
|
|
16737
|
+
output.log(chalk35.bold(`## Priority (High to Low)
|
|
16680
16738
|
`));
|
|
16681
|
-
output.log(` ${
|
|
16682
|
-
output.log(` ${
|
|
16683
|
-
output.log(` ${
|
|
16739
|
+
output.log(` ${chalk35.green("1. project")} - 项目路径(最高优先级)`);
|
|
16740
|
+
output.log(` ${chalk35.blue("2. user")} - 用户路径`);
|
|
16741
|
+
output.log(` ${chalk35.gray("3. built-in")} - 内置路径(预留)
|
|
16684
16742
|
`);
|
|
16685
|
-
output.log(
|
|
16743
|
+
output.log(chalk35.bold(`## Usage
|
|
16686
16744
|
`));
|
|
16687
|
-
output.log(` ${
|
|
16688
|
-
output.log(` ${
|
|
16689
|
-
output.log(` ${
|
|
16690
|
-
output.log(` ${
|
|
16745
|
+
output.log(` ${chalk35.cyan("roy-agent skills list")} ${chalk35.gray("- 列出所有技能")}`);
|
|
16746
|
+
output.log(` ${chalk35.cyan("roy-agent skills get <name>")} ${chalk35.gray("- 获取技能内容")}`);
|
|
16747
|
+
output.log(` ${chalk35.cyan("roy-agent skills search <term>")} ${chalk35.gray("- 搜索技能")}`);
|
|
16748
|
+
output.log(` ${chalk35.cyan("roy-agent skills reload")} ${chalk35.gray("- 重新扫描技能")}`);
|
|
16691
16749
|
} catch (error) {
|
|
16692
16750
|
output.error(`Failed to show config: ${error}`);
|
|
16693
16751
|
process.exit(1);
|
|
@@ -16708,7 +16766,7 @@ var SkillsCommand = {
|
|
|
16708
16766
|
};
|
|
16709
16767
|
|
|
16710
16768
|
// src/commands/agents/list.ts
|
|
16711
|
-
import
|
|
16769
|
+
import chalk36 from "chalk";
|
|
16712
16770
|
var ListCommand4 = {
|
|
16713
16771
|
command: "list",
|
|
16714
16772
|
aliases: ["ls"],
|
|
@@ -16795,27 +16853,27 @@ var ListCommand4 = {
|
|
|
16795
16853
|
output.log(hint);
|
|
16796
16854
|
} else {
|
|
16797
16855
|
const header = [
|
|
16798
|
-
|
|
16799
|
-
|
|
16800
|
-
|
|
16801
|
-
|
|
16802
|
-
|
|
16803
|
-
|
|
16856
|
+
chalk36.bold("Name"),
|
|
16857
|
+
chalk36.bold("Type"),
|
|
16858
|
+
chalk36.bold("Source"),
|
|
16859
|
+
chalk36.bold("Model"),
|
|
16860
|
+
chalk36.bold("Workflow"),
|
|
16861
|
+
chalk36.bold("Description")
|
|
16804
16862
|
].join(" | ");
|
|
16805
16863
|
const typeColor = (type) => {
|
|
16806
16864
|
if (type === "primary")
|
|
16807
|
-
return
|
|
16865
|
+
return chalk36.yellow;
|
|
16808
16866
|
if (type === "workflow")
|
|
16809
|
-
return
|
|
16810
|
-
return
|
|
16867
|
+
return chalk36.magenta;
|
|
16868
|
+
return chalk36.blue;
|
|
16811
16869
|
};
|
|
16812
16870
|
const rows = pagedAgents.map((a) => {
|
|
16813
16871
|
const desc2 = (a.description || "").length > 40 ? (a.description || "").slice(0, 37) + "..." : a.description || "-";
|
|
16814
|
-
const workflowDisplay = a.type === "workflow" && a.workflow ?
|
|
16815
|
-
const modelDisplay = a.model ?
|
|
16816
|
-
const sourceDisplay = builtInSubAgentNames.has(a.name) ?
|
|
16872
|
+
const workflowDisplay = a.type === "workflow" && a.workflow ? chalk36.cyan(a.workflow.length > 30 ? a.workflow.slice(0, 27) + "..." : a.workflow) : chalk36.gray("-");
|
|
16873
|
+
const modelDisplay = a.model ? chalk36.yellow(a.model.length > 20 ? a.model.slice(0, 17) + "..." : a.model) : chalk36.gray("-");
|
|
16874
|
+
const sourceDisplay = builtInSubAgentNames.has(a.name) ? chalk36.green("built-in") : chalk36.gray("user");
|
|
16817
16875
|
return [
|
|
16818
|
-
|
|
16876
|
+
chalk36.cyan(a.name),
|
|
16819
16877
|
typeColor(a.type)(a.type),
|
|
16820
16878
|
sourceDisplay,
|
|
16821
16879
|
modelDisplay,
|
|
@@ -16824,9 +16882,9 @@ var ListCommand4 = {
|
|
|
16824
16882
|
].join(" | ");
|
|
16825
16883
|
});
|
|
16826
16884
|
if (rows.length === 0) {
|
|
16827
|
-
output.log(
|
|
16885
|
+
output.log(chalk36.yellow("No agents found."));
|
|
16828
16886
|
output.log("");
|
|
16829
|
-
output.log(
|
|
16887
|
+
output.log(chalk36.gray("Tip: Create agent configs in ~/.local/share/roy-agent/agents/"));
|
|
16830
16888
|
} else {
|
|
16831
16889
|
output.log([
|
|
16832
16890
|
`┌─ Agents ${"─".repeat(50)}┐`,
|
|
@@ -16857,7 +16915,7 @@ var ListCommand4 = {
|
|
|
16857
16915
|
};
|
|
16858
16916
|
|
|
16859
16917
|
// src/commands/agents/get.ts
|
|
16860
|
-
import
|
|
16918
|
+
import chalk37 from "chalk";
|
|
16861
16919
|
var GetCommand4 = {
|
|
16862
16920
|
command: "get <name>",
|
|
16863
16921
|
describe: "获取指定 agent 的详细信息",
|
|
@@ -16916,69 +16974,69 @@ var GetCommand4 = {
|
|
|
16916
16974
|
filterHistory: agent.filterHistory
|
|
16917
16975
|
});
|
|
16918
16976
|
} else {
|
|
16919
|
-
output.log(
|
|
16977
|
+
output.log(chalk37.bold.cyan(`# Agent: ${agent.name}`));
|
|
16920
16978
|
output.log("");
|
|
16921
|
-
output.log(
|
|
16922
|
-
output.log(` ${
|
|
16923
|
-
output.log(` ${
|
|
16979
|
+
output.log(chalk37.bold("Basic Info:"));
|
|
16980
|
+
output.log(` ${chalk37.cyan("name:")} ${agent.name}`);
|
|
16981
|
+
output.log(` ${chalk37.cyan("type:")} ${agent.type}`);
|
|
16924
16982
|
if (agent.description) {
|
|
16925
|
-
output.log(` ${
|
|
16983
|
+
output.log(` ${chalk37.cyan("description:")} ${agent.description}`);
|
|
16926
16984
|
}
|
|
16927
16985
|
output.log("");
|
|
16928
16986
|
if (agent.type === "workflow") {
|
|
16929
|
-
output.log(
|
|
16987
|
+
output.log(chalk37.bold("Workflow:"));
|
|
16930
16988
|
if (agent.workflow) {
|
|
16931
|
-
output.log(` ${
|
|
16932
|
-
output.log(` ${
|
|
16989
|
+
output.log(` ${chalk37.cyan("workflow:")} ${agent.workflow}`);
|
|
16990
|
+
output.log(` ${chalk37.gray("→")} ${chalk37.gray(`roy-agent workflow run ${agent.workflow} --input '{"query":"..."}'`)}`);
|
|
16933
16991
|
} else {
|
|
16934
|
-
output.log(` ${
|
|
16992
|
+
output.log(` ${chalk37.gray("(no workflow configured)")}`);
|
|
16935
16993
|
}
|
|
16936
16994
|
output.log("");
|
|
16937
16995
|
}
|
|
16938
|
-
output.log(
|
|
16996
|
+
output.log(chalk37.bold("System Prompt:"));
|
|
16939
16997
|
if (agent.systemPromptRef) {
|
|
16940
|
-
output.log(` ${
|
|
16998
|
+
output.log(` ${chalk37.green("[ref]")} ${chalk37.cyan("systemPromptRef:")} ${agent.systemPromptRef}`);
|
|
16941
16999
|
}
|
|
16942
17000
|
if (agent.systemPrompt && !agent.systemPromptRef) {
|
|
16943
17001
|
const promptPreview = agent.systemPrompt.length > 100 ? agent.systemPrompt.slice(0, 97) + "..." : agent.systemPrompt;
|
|
16944
|
-
output.log(` ${
|
|
16945
|
-
output.log(` ${
|
|
17002
|
+
output.log(` ${chalk37.gray("[inline]")}`);
|
|
17003
|
+
output.log(` ${chalk37.gray(promptPreview.split(`
|
|
16946
17004
|
`).join(`
|
|
16947
17005
|
`))}`);
|
|
16948
17006
|
}
|
|
16949
17007
|
if (resolvedSystemPrompt) {
|
|
16950
17008
|
const resolvedPreview = resolvedSystemPrompt.length > 200 ? resolvedSystemPrompt.slice(0, 197) + "..." : resolvedSystemPrompt;
|
|
16951
|
-
output.log(` ${
|
|
16952
|
-
output.log(` ${
|
|
17009
|
+
output.log(` ${chalk37.green("[resolved]")}`);
|
|
17010
|
+
output.log(` ${chalk37.gray(resolvedPreview.split(`
|
|
16953
17011
|
`).join(`
|
|
16954
17012
|
`))}`);
|
|
16955
17013
|
}
|
|
16956
17014
|
if (!agent.systemPromptRef && !agent.systemPrompt && !resolvedSystemPrompt) {
|
|
16957
|
-
output.log(` ${
|
|
17015
|
+
output.log(` ${chalk37.gray("(none)")}`);
|
|
16958
17016
|
}
|
|
16959
17017
|
output.log("");
|
|
16960
17018
|
const hasOptions = agent.model || agent.maxIterations || agent.toolTimeout;
|
|
16961
17019
|
if (hasOptions) {
|
|
16962
|
-
output.log(
|
|
17020
|
+
output.log(chalk37.bold("Options:"));
|
|
16963
17021
|
if (agent.model) {
|
|
16964
|
-
output.log(` ${
|
|
17022
|
+
output.log(` ${chalk37.cyan("model:")} ${agent.model}`);
|
|
16965
17023
|
}
|
|
16966
17024
|
if (agent.maxIterations) {
|
|
16967
|
-
output.log(` ${
|
|
17025
|
+
output.log(` ${chalk37.cyan("maxIterations:")} ${agent.maxIterations}`);
|
|
16968
17026
|
}
|
|
16969
17027
|
if (agent.toolTimeout) {
|
|
16970
|
-
output.log(` ${
|
|
17028
|
+
output.log(` ${chalk37.cyan("toolTimeout:")} ${agent.toolTimeout}ms`);
|
|
16971
17029
|
}
|
|
16972
17030
|
output.log("");
|
|
16973
17031
|
}
|
|
16974
17032
|
const hasTools = agent.allowedTools?.length || agent.deniedTools?.length;
|
|
16975
17033
|
if (hasTools) {
|
|
16976
|
-
output.log(
|
|
17034
|
+
output.log(chalk37.bold("Tool Permissions:"));
|
|
16977
17035
|
if (agent.allowedTools?.length) {
|
|
16978
|
-
output.log(` ${
|
|
17036
|
+
output.log(` ${chalk37.green("allowed:")} ${agent.allowedTools.join(", ")}`);
|
|
16979
17037
|
}
|
|
16980
17038
|
if (agent.deniedTools?.length) {
|
|
16981
|
-
output.log(` ${
|
|
17039
|
+
output.log(` ${chalk37.red("denied:")} ${agent.deniedTools.join(", ")}`);
|
|
16982
17040
|
}
|
|
16983
17041
|
output.log("");
|
|
16984
17042
|
}
|
|
@@ -16993,7 +17051,7 @@ var GetCommand4 = {
|
|
|
16993
17051
|
};
|
|
16994
17052
|
|
|
16995
17053
|
// src/commands/agents/add.ts
|
|
16996
|
-
import
|
|
17054
|
+
import chalk38 from "chalk";
|
|
16997
17055
|
function parseToolList(value) {
|
|
16998
17056
|
if (!value?.trim()) {
|
|
16999
17057
|
return;
|
|
@@ -17085,8 +17143,8 @@ var AddCommand = {
|
|
|
17085
17143
|
if (args.json) {
|
|
17086
17144
|
output.json({ agent, filePath });
|
|
17087
17145
|
} else {
|
|
17088
|
-
output.log(
|
|
17089
|
-
output.log(
|
|
17146
|
+
output.log(chalk38.green(`✓ Agent '${args.name}' created`));
|
|
17147
|
+
output.log(chalk38.gray(` ${filePath}`));
|
|
17090
17148
|
}
|
|
17091
17149
|
} catch (error) {
|
|
17092
17150
|
output.error(`Failed to add agent: ${error}`);
|
|
@@ -17098,7 +17156,7 @@ var AddCommand = {
|
|
|
17098
17156
|
};
|
|
17099
17157
|
|
|
17100
17158
|
// src/commands/agents/delete.ts
|
|
17101
|
-
import
|
|
17159
|
+
import chalk39 from "chalk";
|
|
17102
17160
|
var DeleteCommand3 = {
|
|
17103
17161
|
command: "delete <name>",
|
|
17104
17162
|
describe: "删除 agent 配置文件",
|
|
@@ -17140,7 +17198,7 @@ var DeleteCommand3 = {
|
|
|
17140
17198
|
}
|
|
17141
17199
|
const filePath = registry.getAgentFilePath(args.name);
|
|
17142
17200
|
if (!args.yes) {
|
|
17143
|
-
output.log(
|
|
17201
|
+
output.log(chalk39.yellow(`Delete agent '${args.name}'? This removes ${filePath} (use --yes to skip confirmation)`));
|
|
17144
17202
|
process.exit(1);
|
|
17145
17203
|
}
|
|
17146
17204
|
const deleted = await registry.deleteAgent(args.name);
|
|
@@ -17151,7 +17209,7 @@ var DeleteCommand3 = {
|
|
|
17151
17209
|
if (args.json) {
|
|
17152
17210
|
output.json({ deleted: true, name: args.name, filePath });
|
|
17153
17211
|
} else {
|
|
17154
|
-
output.log(
|
|
17212
|
+
output.log(chalk39.green(`✓ Agent '${args.name}' deleted`));
|
|
17155
17213
|
}
|
|
17156
17214
|
} catch (error) {
|
|
17157
17215
|
output.error(`Failed to delete agent: ${error}`);
|
|
@@ -17163,7 +17221,7 @@ var DeleteCommand3 = {
|
|
|
17163
17221
|
};
|
|
17164
17222
|
|
|
17165
17223
|
// src/commands/agents/config-dir.ts
|
|
17166
|
-
import
|
|
17224
|
+
import chalk40 from "chalk";
|
|
17167
17225
|
var ConfigDirCommand = {
|
|
17168
17226
|
command: "config-dir",
|
|
17169
17227
|
describe: "显示 agent 配置目录路径",
|
|
@@ -17194,8 +17252,8 @@ var ConfigDirCommand = {
|
|
|
17194
17252
|
if (args.json) {
|
|
17195
17253
|
output.json({ configDir, exists });
|
|
17196
17254
|
} else {
|
|
17197
|
-
output.log(`${
|
|
17198
|
-
output.log(`${
|
|
17255
|
+
output.log(`${chalk40.cyan("Agent Config Directory:")} ${configDir}`);
|
|
17256
|
+
output.log(`${chalk40.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
17199
17257
|
}
|
|
17200
17258
|
} catch (error) {
|
|
17201
17259
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -17218,7 +17276,7 @@ var AgentsCommand = {
|
|
|
17218
17276
|
};
|
|
17219
17277
|
|
|
17220
17278
|
// src/commands/prompt/list.ts
|
|
17221
|
-
import
|
|
17279
|
+
import chalk41 from "chalk";
|
|
17222
17280
|
var ListCommand5 = {
|
|
17223
17281
|
command: "list",
|
|
17224
17282
|
aliases: ["ls"],
|
|
@@ -17287,17 +17345,17 @@ var ListCommand5 = {
|
|
|
17287
17345
|
output.log(hint);
|
|
17288
17346
|
} else {
|
|
17289
17347
|
const header = [
|
|
17290
|
-
|
|
17291
|
-
|
|
17348
|
+
chalk41.bold("Name"),
|
|
17349
|
+
chalk41.bold("Source")
|
|
17292
17350
|
].join(" | ");
|
|
17293
17351
|
const rows = prompts.map((p) => {
|
|
17294
17352
|
return [
|
|
17295
|
-
|
|
17296
|
-
|
|
17353
|
+
chalk41.cyan(p.name),
|
|
17354
|
+
chalk41.gray(`[${p.source}]`)
|
|
17297
17355
|
].join(" | ");
|
|
17298
17356
|
});
|
|
17299
17357
|
if (rows.length === 0) {
|
|
17300
|
-
output.log(
|
|
17358
|
+
output.log(chalk41.yellow("No prompts found."));
|
|
17301
17359
|
} else {
|
|
17302
17360
|
output.log([
|
|
17303
17361
|
`┌─ Prompts ${"─".repeat(50)}┐`,
|
|
@@ -17328,7 +17386,7 @@ var ListCommand5 = {
|
|
|
17328
17386
|
};
|
|
17329
17387
|
|
|
17330
17388
|
// src/commands/prompt/get.ts
|
|
17331
|
-
import
|
|
17389
|
+
import chalk42 from "chalk";
|
|
17332
17390
|
var GetCommand5 = {
|
|
17333
17391
|
command: "get <name>",
|
|
17334
17392
|
describe: "获取指定 prompt 的内容",
|
|
@@ -17375,16 +17433,16 @@ var GetCommand5 = {
|
|
|
17375
17433
|
variables: vars
|
|
17376
17434
|
});
|
|
17377
17435
|
} else {
|
|
17378
|
-
output.log(
|
|
17436
|
+
output.log(chalk42.bold.cyan(`# Prompt: ${args.name}`));
|
|
17379
17437
|
output.log("");
|
|
17380
17438
|
if (Object.keys(vars).length > 0) {
|
|
17381
|
-
output.log(
|
|
17439
|
+
output.log(chalk42.gray("Variables:"));
|
|
17382
17440
|
for (const [key, value] of Object.entries(vars)) {
|
|
17383
|
-
output.log(` ${
|
|
17441
|
+
output.log(` ${chalk42.cyan(key + ":")} ${value}`);
|
|
17384
17442
|
}
|
|
17385
17443
|
output.log("");
|
|
17386
17444
|
}
|
|
17387
|
-
output.log(
|
|
17445
|
+
output.log(chalk42.bold("Content:"));
|
|
17388
17446
|
output.log("─".repeat(60));
|
|
17389
17447
|
output.log(prompt);
|
|
17390
17448
|
output.log("─".repeat(60));
|
|
@@ -17414,7 +17472,7 @@ function parseVars(vars) {
|
|
|
17414
17472
|
|
|
17415
17473
|
// src/commands/prompt/add.ts
|
|
17416
17474
|
import { readFile as readFile2 } from "fs/promises";
|
|
17417
|
-
import
|
|
17475
|
+
import chalk43 from "chalk";
|
|
17418
17476
|
var AddCommand2 = {
|
|
17419
17477
|
command: "add <name>",
|
|
17420
17478
|
describe: "添加 prompt 并持久化到 ~/.local/share/roy-agent/prompts/",
|
|
@@ -17465,8 +17523,8 @@ var AddCommand2 = {
|
|
|
17465
17523
|
length: content.trim().length
|
|
17466
17524
|
});
|
|
17467
17525
|
} else {
|
|
17468
|
-
output.log(
|
|
17469
|
-
output.log(
|
|
17526
|
+
output.log(chalk43.green(`✓ Prompt '${args.name}' saved`));
|
|
17527
|
+
output.log(chalk43.gray(` ${filePath}`));
|
|
17470
17528
|
}
|
|
17471
17529
|
} catch (error) {
|
|
17472
17530
|
output.error(`Failed to add prompt: ${error}`);
|
|
@@ -17478,7 +17536,7 @@ var AddCommand2 = {
|
|
|
17478
17536
|
};
|
|
17479
17537
|
|
|
17480
17538
|
// src/commands/prompt/config-dir.ts
|
|
17481
|
-
import
|
|
17539
|
+
import chalk44 from "chalk";
|
|
17482
17540
|
var ConfigDirCommand2 = {
|
|
17483
17541
|
command: "config-dir",
|
|
17484
17542
|
describe: "显示 prompt 持久化目录路径",
|
|
@@ -17508,8 +17566,8 @@ var ConfigDirCommand2 = {
|
|
|
17508
17566
|
if (args.json) {
|
|
17509
17567
|
output.json({ configDir, exists });
|
|
17510
17568
|
} else {
|
|
17511
|
-
output.log(`${
|
|
17512
|
-
output.log(`${
|
|
17569
|
+
output.log(`${chalk44.cyan("Prompt Config Directory:")} ${configDir}`);
|
|
17570
|
+
output.log(`${chalk44.gray("Exists:")} ${exists ? "yes" : "no"}`);
|
|
17513
17571
|
}
|
|
17514
17572
|
} catch (error) {
|
|
17515
17573
|
output.error(`Failed to get config dir: ${error}`);
|
|
@@ -17531,7 +17589,7 @@ var PromptCommand = {
|
|
|
17531
17589
|
};
|
|
17532
17590
|
|
|
17533
17591
|
// src/commands/commands-list.ts
|
|
17534
|
-
import
|
|
17592
|
+
import chalk45 from "chalk";
|
|
17535
17593
|
function truncateVisual(str, maxWidth) {
|
|
17536
17594
|
let result = "";
|
|
17537
17595
|
let width = 0;
|
|
@@ -17546,16 +17604,16 @@ function truncateVisual(str, maxWidth) {
|
|
|
17546
17604
|
}
|
|
17547
17605
|
function formatCommandsTable(commands) {
|
|
17548
17606
|
if (commands.length === 0) {
|
|
17549
|
-
return
|
|
17607
|
+
return chalk45.yellow("命令目录为空,使用 'roy-agent commands add' 添加命令");
|
|
17550
17608
|
}
|
|
17551
17609
|
const NAME_WIDTH = 20;
|
|
17552
17610
|
const SOURCE_WIDTH = 10;
|
|
17553
17611
|
const DESC_WIDTH = 50;
|
|
17554
17612
|
const GAP = " ";
|
|
17555
17613
|
const headerLine = [
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17614
|
+
chalk45.bold("NAME".padEnd(NAME_WIDTH)),
|
|
17615
|
+
chalk45.bold("SOURCE".padEnd(SOURCE_WIDTH)),
|
|
17616
|
+
chalk45.bold("DESCRIPTION")
|
|
17559
17617
|
].join(GAP);
|
|
17560
17618
|
const sepLine = "─".repeat(NAME_WIDTH + SOURCE_WIDTH + DESC_WIDTH + GAP.length * 2);
|
|
17561
17619
|
const formatRow = (cmd) => {
|
|
@@ -17663,7 +17721,7 @@ var CommandsListCommand = {
|
|
|
17663
17721
|
};
|
|
17664
17722
|
|
|
17665
17723
|
// src/commands/commands-add.ts
|
|
17666
|
-
import
|
|
17724
|
+
import chalk46 from "chalk";
|
|
17667
17725
|
var CommandsAddCommand = {
|
|
17668
17726
|
command: "add <name> <target>",
|
|
17669
17727
|
describe: "添加收藏命令(自动创建 symlink)",
|
|
@@ -17724,10 +17782,10 @@ var CommandsAddCommand = {
|
|
|
17724
17782
|
});
|
|
17725
17783
|
const dirs = await commandsComponent.getCommandDirs();
|
|
17726
17784
|
const targetDir = source === "user" ? dirs.user : dirs.project;
|
|
17727
|
-
output.log(
|
|
17728
|
-
output.log(
|
|
17729
|
-
output.log(
|
|
17730
|
-
output.log(
|
|
17785
|
+
output.log(chalk46.green(`✅ 已添加命令 '${args.name}'`));
|
|
17786
|
+
output.log(chalk46.gray(` 目标: ${args.target}`));
|
|
17787
|
+
output.log(chalk46.gray(` 位置: ${targetDir}/${args.name}`));
|
|
17788
|
+
output.log(chalk46.gray(` 级别: ${source === "user" ? "USER" : "PROJECT"}`));
|
|
17731
17789
|
} catch (error) {
|
|
17732
17790
|
output.error(`添加失败: ${error.message}`);
|
|
17733
17791
|
process.exit(1);
|
|
@@ -17738,7 +17796,7 @@ var CommandsAddCommand = {
|
|
|
17738
17796
|
};
|
|
17739
17797
|
|
|
17740
17798
|
// src/commands/commands-remove.ts
|
|
17741
|
-
import
|
|
17799
|
+
import chalk47 from "chalk";
|
|
17742
17800
|
var CommandsRemoveCommand = {
|
|
17743
17801
|
command: "remove <name>",
|
|
17744
17802
|
aliases: ["rm"],
|
|
@@ -17782,7 +17840,7 @@ var CommandsRemoveCommand = {
|
|
|
17782
17840
|
name: args.name,
|
|
17783
17841
|
source: "user"
|
|
17784
17842
|
});
|
|
17785
|
-
output.log(
|
|
17843
|
+
output.log(chalk47.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
17786
17844
|
} catch (error) {
|
|
17787
17845
|
if (!error.message?.includes("不存在")) {
|
|
17788
17846
|
throw error;
|
|
@@ -17795,7 +17853,7 @@ var CommandsRemoveCommand = {
|
|
|
17795
17853
|
name: args.name,
|
|
17796
17854
|
source: "project"
|
|
17797
17855
|
});
|
|
17798
|
-
output.log(
|
|
17856
|
+
output.log(chalk47.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
17799
17857
|
} catch (error) {
|
|
17800
17858
|
if (!error.message?.includes("不存在")) {
|
|
17801
17859
|
throw error;
|
|
@@ -17809,7 +17867,7 @@ var CommandsRemoveCommand = {
|
|
|
17809
17867
|
name: args.name,
|
|
17810
17868
|
source: "user"
|
|
17811
17869
|
});
|
|
17812
|
-
output.log(
|
|
17870
|
+
output.log(chalk47.green(`✅ 已从用户目录移除命令 '${args.name}'`));
|
|
17813
17871
|
removed = true;
|
|
17814
17872
|
} catch (error) {
|
|
17815
17873
|
if (!error.message?.includes("不存在")) {
|
|
@@ -17821,7 +17879,7 @@ var CommandsRemoveCommand = {
|
|
|
17821
17879
|
name: args.name,
|
|
17822
17880
|
source: "project"
|
|
17823
17881
|
});
|
|
17824
|
-
output.log(
|
|
17882
|
+
output.log(chalk47.green(`✅ 已从项目目录移除命令 '${args.name}'`));
|
|
17825
17883
|
removed = true;
|
|
17826
17884
|
} catch (error) {
|
|
17827
17885
|
if (!error.message?.includes("不存在")) {
|
|
@@ -17843,7 +17901,7 @@ var CommandsRemoveCommand = {
|
|
|
17843
17901
|
};
|
|
17844
17902
|
|
|
17845
17903
|
// src/commands/commands-info.ts
|
|
17846
|
-
import
|
|
17904
|
+
import chalk48 from "chalk";
|
|
17847
17905
|
import { exec as exec2 } from "child_process";
|
|
17848
17906
|
import { promisify as promisify2 } from "util";
|
|
17849
17907
|
var execAsync2 = promisify2(exec2);
|
|
@@ -17878,12 +17936,12 @@ var CommandsInfoCommand = {
|
|
|
17878
17936
|
output.error(`命令 '${args.name}' 不存在`);
|
|
17879
17937
|
process.exit(1);
|
|
17880
17938
|
}
|
|
17881
|
-
output.log(
|
|
17882
|
-
output.log(
|
|
17883
|
-
output.log(
|
|
17884
|
-
output.log(
|
|
17939
|
+
output.log(chalk48.bold("Name:") + ` ${info.name}`);
|
|
17940
|
+
output.log(chalk48.bold("Path:") + ` ${info.path}`);
|
|
17941
|
+
output.log(chalk48.bold("Source:") + ` ${info.source.toUpperCase()}`);
|
|
17942
|
+
output.log(chalk48.bold("Description:") + ` ${info.shortDescription || "-"}`);
|
|
17885
17943
|
output.log();
|
|
17886
|
-
output.log(
|
|
17944
|
+
output.log(chalk48.gray("─".repeat(50)));
|
|
17887
17945
|
output.log();
|
|
17888
17946
|
try {
|
|
17889
17947
|
const { stdout } = await execAsync2(`${info.path} --help`, { timeout: 5000 });
|
|
@@ -17893,7 +17951,7 @@ var CommandsInfoCommand = {
|
|
|
17893
17951
|
const { stdout } = await execAsync2(`${info.path} -h`, { timeout: 5000 });
|
|
17894
17952
|
output.log(stdout);
|
|
17895
17953
|
} catch {
|
|
17896
|
-
output.log(
|
|
17954
|
+
output.log(chalk48.gray("(无法获取帮助信息)"));
|
|
17897
17955
|
}
|
|
17898
17956
|
}
|
|
17899
17957
|
} catch (error) {
|
|
@@ -17906,7 +17964,7 @@ var CommandsInfoCommand = {
|
|
|
17906
17964
|
};
|
|
17907
17965
|
|
|
17908
17966
|
// src/commands/commands-dirs.ts
|
|
17909
|
-
import
|
|
17967
|
+
import chalk49 from "chalk";
|
|
17910
17968
|
var CommandsDirsCommand = {
|
|
17911
17969
|
command: "dirs",
|
|
17912
17970
|
describe: "显示命令目录",
|
|
@@ -17938,10 +17996,10 @@ var CommandsDirsCommand = {
|
|
|
17938
17996
|
if (args.json) {
|
|
17939
17997
|
output.json(dirs);
|
|
17940
17998
|
} else {
|
|
17941
|
-
output.log(
|
|
17999
|
+
output.log(chalk49.bold("命令目录:"));
|
|
17942
18000
|
output.log();
|
|
17943
|
-
output.log(
|
|
17944
|
-
output.log(
|
|
18001
|
+
output.log(chalk49.cyan("USER:") + ` ${dirs.user}`);
|
|
18002
|
+
output.log(chalk49.cyan("PROJECT:") + ` ${dirs.project}`);
|
|
17945
18003
|
}
|
|
17946
18004
|
} catch (error) {
|
|
17947
18005
|
output.error(`错误: ${error.message}`);
|
|
@@ -17961,7 +18019,7 @@ var CommandsCommand = {
|
|
|
17961
18019
|
};
|
|
17962
18020
|
|
|
17963
18021
|
// src/commands/config/list.ts
|
|
17964
|
-
import
|
|
18022
|
+
import chalk50 from "chalk";
|
|
17965
18023
|
|
|
17966
18024
|
// src/commands/config/config-service.ts
|
|
17967
18025
|
import * as fsSync from "fs";
|
|
@@ -18265,7 +18323,7 @@ var ConfigListCommand = {
|
|
|
18265
18323
|
output.log("");
|
|
18266
18324
|
output.log("Supported components:");
|
|
18267
18325
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
18268
|
-
output.log(` ${
|
|
18326
|
+
output.log(` ${chalk50.cyan(comp.padEnd(15))} ${COMPONENT_DESCRIPTIONS[comp] || ""}`);
|
|
18269
18327
|
}
|
|
18270
18328
|
process.exit(1);
|
|
18271
18329
|
}
|
|
@@ -18283,27 +18341,27 @@ var ConfigListCommand = {
|
|
|
18283
18341
|
}
|
|
18284
18342
|
};
|
|
18285
18343
|
function showHelp(output) {
|
|
18286
|
-
output.log(
|
|
18344
|
+
output.log(chalk50.bold.cyan("# roy-agent config list"));
|
|
18287
18345
|
output.log("");
|
|
18288
18346
|
output.log("查看 roy-agent 组件配置信息");
|
|
18289
18347
|
output.log("");
|
|
18290
|
-
output.log(
|
|
18291
|
-
output.log(` ${
|
|
18348
|
+
output.log(chalk50.bold("Usage:"));
|
|
18349
|
+
output.log(` ${chalk50.cyan("roy-agent config list [component] [options]")}`);
|
|
18292
18350
|
output.log("");
|
|
18293
|
-
output.log(
|
|
18351
|
+
output.log(chalk50.bold("Components:"));
|
|
18294
18352
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
18295
|
-
output.log(` ${
|
|
18353
|
+
output.log(` ${chalk50.cyan(comp.padEnd(15))} ${chalk50.gray(COMPONENT_DESCRIPTIONS[comp] || "")}`);
|
|
18296
18354
|
}
|
|
18297
|
-
output.log(` ${
|
|
18355
|
+
output.log(` ${chalk50.cyan("all".padEnd(15))} 显示所有 components 概览`);
|
|
18298
18356
|
output.log("");
|
|
18299
|
-
output.log(
|
|
18300
|
-
output.log(` ${
|
|
18301
|
-
output.log(` ${
|
|
18302
|
-
output.log(` ${
|
|
18357
|
+
output.log(chalk50.bold("Options:"));
|
|
18358
|
+
output.log(` ${chalk50.cyan("-j, --json")} JSON 格式输出`);
|
|
18359
|
+
output.log(` ${chalk50.cyan("-k, --keys")} 只显示配置键`);
|
|
18360
|
+
output.log(` ${chalk50.cyan("-s, --sources")} 只显示配置源`);
|
|
18303
18361
|
output.log("");
|
|
18304
|
-
output.log(
|
|
18362
|
+
output.log(chalk50.bold("Examples:"));
|
|
18305
18363
|
for (const { command: command2, description } of USAGE_COMMANDS) {
|
|
18306
|
-
output.log(` ${
|
|
18364
|
+
output.log(` ${chalk50.cyan(command2.padEnd(40))} ${chalk50.gray(description)}`);
|
|
18307
18365
|
}
|
|
18308
18366
|
}
|
|
18309
18367
|
async function showAllComponents(output, configService) {
|
|
@@ -18312,13 +18370,13 @@ async function showAllComponents(output, configService) {
|
|
|
18312
18370
|
const config = configService.getComponentConfig(compName);
|
|
18313
18371
|
components.push({ name: compName, config });
|
|
18314
18372
|
}
|
|
18315
|
-
output.log(
|
|
18373
|
+
output.log(chalk50.bold.cyan("# All Components Overview"));
|
|
18316
18374
|
output.log("");
|
|
18317
|
-
output.log(` ${
|
|
18318
|
-
output.log(` ${
|
|
18375
|
+
output.log(` ${chalk50.cyan("Component".padEnd(15))} ${chalk50.cyan("Keys".padEnd(10))} ${chalk50.gray("Description")}`);
|
|
18376
|
+
output.log(` ${chalk50.gray("─".repeat(60))}`);
|
|
18319
18377
|
for (const comp of components) {
|
|
18320
18378
|
const keyCount = Object.keys(comp.config).length;
|
|
18321
|
-
output.log(` ${
|
|
18379
|
+
output.log(` ${chalk50.cyan(comp.name.padEnd(15))} ${keyCount.toString().padEnd(10)} ${chalk50.gray(COMPONENT_DESCRIPTIONS[comp.name] || "")}`);
|
|
18322
18380
|
}
|
|
18323
18381
|
}
|
|
18324
18382
|
async function showComponentConfig(componentName, output, configService, options) {
|
|
@@ -18340,22 +18398,22 @@ async function showComponentConfig(componentName, output, configService, options
|
|
|
18340
18398
|
});
|
|
18341
18399
|
return;
|
|
18342
18400
|
}
|
|
18343
|
-
output.log(
|
|
18401
|
+
output.log(chalk50.bold.cyan(`# ${componentName} Component Configuration`));
|
|
18344
18402
|
output.log("");
|
|
18345
18403
|
if (filePath) {
|
|
18346
|
-
output.log(
|
|
18347
|
-
output.log(` ${
|
|
18404
|
+
output.log(chalk50.bold("File:"));
|
|
18405
|
+
output.log(` ${chalk50.cyan(filePath)}`);
|
|
18348
18406
|
output.log("");
|
|
18349
18407
|
}
|
|
18350
18408
|
if (!options.sources) {
|
|
18351
|
-
output.log(
|
|
18409
|
+
output.log(chalk50.bold("Configuration:"));
|
|
18352
18410
|
if (Object.keys(config).length === 0) {
|
|
18353
|
-
output.log(` ${
|
|
18411
|
+
output.log(` ${chalk50.gray("(无配置)")}`);
|
|
18354
18412
|
} else {
|
|
18355
18413
|
const flatConfig = flattenConfig(config);
|
|
18356
18414
|
for (const [key, value] of flatConfig) {
|
|
18357
18415
|
const displayValue = formatValue(value);
|
|
18358
|
-
output.log(` ${
|
|
18416
|
+
output.log(` ${chalk50.cyan(key + ":")} ${displayValue}`);
|
|
18359
18417
|
}
|
|
18360
18418
|
}
|
|
18361
18419
|
output.log("");
|
|
@@ -18370,17 +18428,17 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
18370
18428
|
});
|
|
18371
18429
|
return;
|
|
18372
18430
|
}
|
|
18373
|
-
output.log(
|
|
18431
|
+
output.log(chalk50.bold.cyan("# Agent Component Configuration"));
|
|
18374
18432
|
output.log("");
|
|
18375
18433
|
if (!options.sources) {
|
|
18376
|
-
output.log(
|
|
18434
|
+
output.log(chalk50.bold("Configuration:"));
|
|
18377
18435
|
if (Object.keys(config).length === 0) {
|
|
18378
|
-
output.log(` ${
|
|
18436
|
+
output.log(` ${chalk50.gray("(无配置,使用默认值)")}`);
|
|
18379
18437
|
} else {
|
|
18380
18438
|
const flatConfig = flattenConfig(config);
|
|
18381
18439
|
for (const [key, value] of flatConfig) {
|
|
18382
18440
|
const displayValue = formatValue(value);
|
|
18383
|
-
output.log(` ${
|
|
18441
|
+
output.log(` ${chalk50.cyan(key + ":")} ${displayValue}`);
|
|
18384
18442
|
}
|
|
18385
18443
|
}
|
|
18386
18444
|
output.log("");
|
|
@@ -18394,10 +18452,10 @@ async function showAgentComponentConfig(output, configService, options) {
|
|
|
18394
18452
|
const configDir = registry.getConfigDir();
|
|
18395
18453
|
const exists = registry.configDirExists();
|
|
18396
18454
|
const agentCount = registry.list().length;
|
|
18397
|
-
output.log(
|
|
18398
|
-
output.log(` ${
|
|
18399
|
-
output.log(` ${
|
|
18400
|
-
output.log(` ${
|
|
18455
|
+
output.log(chalk50.bold("Agent Config Directory:"));
|
|
18456
|
+
output.log(` ${chalk50.cyan("path:")} ${configDir}`);
|
|
18457
|
+
output.log(` ${chalk50.cyan("exists:")} ${exists ? chalk50.green("yes") : chalk50.red("no")}`);
|
|
18458
|
+
output.log(` ${chalk50.cyan("agents:")} ${agentCount} loaded`);
|
|
18401
18459
|
output.log("");
|
|
18402
18460
|
}
|
|
18403
18461
|
}
|
|
@@ -18413,41 +18471,41 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
18413
18471
|
});
|
|
18414
18472
|
return;
|
|
18415
18473
|
}
|
|
18416
|
-
output.log(
|
|
18474
|
+
output.log(chalk50.bold.cyan("# Prompt Component Configuration"));
|
|
18417
18475
|
output.log("");
|
|
18418
18476
|
if (filePath) {
|
|
18419
|
-
output.log(
|
|
18420
|
-
output.log(` ${
|
|
18477
|
+
output.log(chalk50.bold("File:"));
|
|
18478
|
+
output.log(` ${chalk50.cyan(filePath)}`);
|
|
18421
18479
|
output.log("");
|
|
18422
18480
|
}
|
|
18423
18481
|
if (!options.sources) {
|
|
18424
|
-
output.log(
|
|
18482
|
+
output.log(chalk50.bold("Configuration:"));
|
|
18425
18483
|
if (Object.keys(config).length === 0) {
|
|
18426
|
-
output.log(` ${
|
|
18484
|
+
output.log(` ${chalk50.gray("(无配置,使用默认值)")}`);
|
|
18427
18485
|
} else {
|
|
18428
18486
|
const flatConfig = flattenConfig(config);
|
|
18429
18487
|
for (const [key, value] of flatConfig) {
|
|
18430
18488
|
const displayValue = formatValue(value);
|
|
18431
|
-
output.log(` ${
|
|
18489
|
+
output.log(` ${chalk50.cyan(key + ":")} ${displayValue}`);
|
|
18432
18490
|
}
|
|
18433
18491
|
}
|
|
18434
18492
|
output.log("");
|
|
18435
18493
|
}
|
|
18436
|
-
output.log(
|
|
18437
|
-
output.log(` ${
|
|
18494
|
+
output.log(chalk50.bold("Prompts:"));
|
|
18495
|
+
output.log(` ${chalk50.gray("- 内置: 5 个(default, coding, review, project-memory, global-memory)")}`);
|
|
18438
18496
|
const promptPaths = config?.promptPaths;
|
|
18439
18497
|
if (promptPaths && Array.isArray(promptPaths) && promptPaths.length > 0) {
|
|
18440
|
-
output.log(` ${
|
|
18498
|
+
output.log(` ${chalk50.gray("- 外部: " + promptPaths.length + " 个路径")}`);
|
|
18441
18499
|
for (const p of promptPaths) {
|
|
18442
|
-
output.log(` ${
|
|
18500
|
+
output.log(` ${chalk50.cyan(p.path)} ${chalk50.gray("(type: " + p.type + ")")}`);
|
|
18443
18501
|
}
|
|
18444
18502
|
} else {
|
|
18445
|
-
output.log(` ${
|
|
18503
|
+
output.log(` ${chalk50.gray("- 外部: 0 个(未配置 promptPaths)")}`);
|
|
18446
18504
|
}
|
|
18447
18505
|
output.log("");
|
|
18448
18506
|
const defaultName = config?.defaultName || "default";
|
|
18449
|
-
output.log(
|
|
18450
|
-
output.log(` ${
|
|
18507
|
+
output.log(chalk50.bold("Default Prompt:"));
|
|
18508
|
+
output.log(` ${chalk50.cyan("defaultName:")} ${defaultName}`);
|
|
18451
18509
|
output.log("");
|
|
18452
18510
|
const env = envService?.getEnvironment?.();
|
|
18453
18511
|
if (env) {
|
|
@@ -18462,10 +18520,10 @@ async function showPromptComponentConfig(output, configService, options, envServ
|
|
|
18462
18520
|
const stored = await store?.loadAll?.();
|
|
18463
18521
|
promptCount = Array.isArray(stored) ? stored.length : 0;
|
|
18464
18522
|
} catch {}
|
|
18465
|
-
output.log(
|
|
18466
|
-
output.log(` ${
|
|
18467
|
-
output.log(` ${
|
|
18468
|
-
output.log(` ${
|
|
18523
|
+
output.log(chalk50.bold("Prompt Storage Directory:"));
|
|
18524
|
+
output.log(` ${chalk50.cyan("path:")} ${configDir}`);
|
|
18525
|
+
output.log(` ${chalk50.cyan("exists:")} ${exists ? chalk50.green("yes") : chalk50.red("no")}`);
|
|
18526
|
+
output.log(` ${chalk50.cyan("prompts:")} ${promptCount} loaded`);
|
|
18469
18527
|
output.log("");
|
|
18470
18528
|
}
|
|
18471
18529
|
}
|
|
@@ -18491,19 +18549,19 @@ function flattenConfig(obj, prefix = "") {
|
|
|
18491
18549
|
}
|
|
18492
18550
|
function formatValue(value) {
|
|
18493
18551
|
if (value === undefined) {
|
|
18494
|
-
return
|
|
18552
|
+
return chalk50.gray("undefined");
|
|
18495
18553
|
}
|
|
18496
18554
|
if (value === null) {
|
|
18497
|
-
return
|
|
18555
|
+
return chalk50.gray("null");
|
|
18498
18556
|
}
|
|
18499
18557
|
if (typeof value === "object") {
|
|
18500
|
-
return
|
|
18558
|
+
return chalk50.gray(JSON.stringify(value));
|
|
18501
18559
|
}
|
|
18502
18560
|
return String(value);
|
|
18503
18561
|
}
|
|
18504
18562
|
|
|
18505
18563
|
// src/commands/config/export.ts
|
|
18506
|
-
import
|
|
18564
|
+
import chalk51 from "chalk";
|
|
18507
18565
|
var ConfigExportCommand = {
|
|
18508
18566
|
command: "export <component>",
|
|
18509
18567
|
describe: "导出组件配置到文件",
|
|
@@ -18548,7 +18606,7 @@ var ConfigExportCommand = {
|
|
|
18548
18606
|
output.log("");
|
|
18549
18607
|
output.log("Supported components:");
|
|
18550
18608
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
18551
|
-
output.log(` ${
|
|
18609
|
+
output.log(` ${chalk51.cyan(comp)}`);
|
|
18552
18610
|
}
|
|
18553
18611
|
process.exit(1);
|
|
18554
18612
|
}
|
|
@@ -18566,7 +18624,7 @@ var ConfigExportCommand = {
|
|
|
18566
18624
|
};
|
|
18567
18625
|
|
|
18568
18626
|
// src/commands/config/import.ts
|
|
18569
|
-
import
|
|
18627
|
+
import chalk52 from "chalk";
|
|
18570
18628
|
var ConfigImportCommand = {
|
|
18571
18629
|
command: "import <component>",
|
|
18572
18630
|
describe: "从文件导入配置到组件的 file source",
|
|
@@ -18616,7 +18674,7 @@ var ConfigImportCommand = {
|
|
|
18616
18674
|
output.log("");
|
|
18617
18675
|
output.log("Supported components:");
|
|
18618
18676
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
18619
|
-
output.log(` ${
|
|
18677
|
+
output.log(` ${chalk52.cyan(comp)}`);
|
|
18620
18678
|
}
|
|
18621
18679
|
process.exit(1);
|
|
18622
18680
|
}
|
|
@@ -18631,7 +18689,7 @@ var ConfigImportCommand = {
|
|
|
18631
18689
|
}
|
|
18632
18690
|
if (result.merged && result.changes.length > 0 && args.verbose) {
|
|
18633
18691
|
output.log("");
|
|
18634
|
-
output.log(
|
|
18692
|
+
output.log(chalk52.bold("变更详情:"));
|
|
18635
18693
|
for (const change of result.changes) {
|
|
18636
18694
|
output.log(` ${change.key}: ${JSON.stringify(change.oldValue)} → ${JSON.stringify(change.newValue)}`);
|
|
18637
18695
|
}
|
|
@@ -18655,7 +18713,7 @@ var ConfigCommand = {
|
|
|
18655
18713
|
};
|
|
18656
18714
|
|
|
18657
18715
|
// src/commands/mcp/list.ts
|
|
18658
|
-
import
|
|
18716
|
+
import chalk53 from "chalk";
|
|
18659
18717
|
var ListCommand6 = {
|
|
18660
18718
|
command: "list",
|
|
18661
18719
|
aliases: ["ls"],
|
|
@@ -18715,30 +18773,30 @@ var ListCommand6 = {
|
|
|
18715
18773
|
output.log(hint);
|
|
18716
18774
|
} else {
|
|
18717
18775
|
if (servers.length === 0) {
|
|
18718
|
-
output.log(
|
|
18776
|
+
output.log(chalk53.yellow("No MCP servers configured"));
|
|
18719
18777
|
return;
|
|
18720
18778
|
}
|
|
18721
18779
|
const statusColor = (status) => {
|
|
18722
18780
|
switch (status) {
|
|
18723
18781
|
case "connected":
|
|
18724
|
-
return
|
|
18782
|
+
return chalk53.green;
|
|
18725
18783
|
case "connecting":
|
|
18726
|
-
return
|
|
18784
|
+
return chalk53.yellow;
|
|
18727
18785
|
case "error":
|
|
18728
|
-
return
|
|
18786
|
+
return chalk53.red;
|
|
18729
18787
|
case "disconnected":
|
|
18730
|
-
return
|
|
18788
|
+
return chalk53.gray;
|
|
18731
18789
|
default:
|
|
18732
|
-
return
|
|
18790
|
+
return chalk53.white;
|
|
18733
18791
|
}
|
|
18734
18792
|
};
|
|
18735
18793
|
const header = [
|
|
18736
|
-
|
|
18737
|
-
|
|
18738
|
-
|
|
18794
|
+
chalk53.bold("Name"),
|
|
18795
|
+
chalk53.bold("Status"),
|
|
18796
|
+
chalk53.bold("Tools")
|
|
18739
18797
|
].join(" | ");
|
|
18740
18798
|
const rows = servers.map((s) => [
|
|
18741
|
-
|
|
18799
|
+
chalk53.cyan(s.name),
|
|
18742
18800
|
statusColor(s.status)(`[${s.status}]`),
|
|
18743
18801
|
s.toolsCount !== undefined ? String(s.toolsCount) : "-"
|
|
18744
18802
|
].join(" | "));
|
|
@@ -18769,7 +18827,7 @@ var ListCommand6 = {
|
|
|
18769
18827
|
};
|
|
18770
18828
|
|
|
18771
18829
|
// src/commands/mcp/tools.ts
|
|
18772
|
-
import
|
|
18830
|
+
import chalk54 from "chalk";
|
|
18773
18831
|
var ToolsCommand = {
|
|
18774
18832
|
command: "tools",
|
|
18775
18833
|
aliases: ["t"],
|
|
@@ -18822,7 +18880,7 @@ var ToolsCommand = {
|
|
|
18822
18880
|
tools.forEach((t) => output.log(t.name));
|
|
18823
18881
|
} else {
|
|
18824
18882
|
if (tools.length === 0) {
|
|
18825
|
-
output.log(
|
|
18883
|
+
output.log(chalk54.yellow("No MCP tools available"));
|
|
18826
18884
|
return;
|
|
18827
18885
|
}
|
|
18828
18886
|
const byServer = new Map;
|
|
@@ -18834,15 +18892,15 @@ var ToolsCommand = {
|
|
|
18834
18892
|
byServer.get(serverName).push(tool);
|
|
18835
18893
|
}
|
|
18836
18894
|
for (const [serverName, serverTools] of byServer) {
|
|
18837
|
-
output.log(
|
|
18895
|
+
output.log(chalk54.bold.cyan(`
|
|
18838
18896
|
[${serverName}] ${serverTools.length} tools`));
|
|
18839
18897
|
for (const tool of serverTools) {
|
|
18840
18898
|
const desc2 = tool.description.length > 80 ? tool.description.slice(0, 77) + "..." : tool.description;
|
|
18841
|
-
output.log(` ${
|
|
18842
|
-
output.log(` ${
|
|
18899
|
+
output.log(` ${chalk54.green("+")} ${chalk54.white(tool.name)}`);
|
|
18900
|
+
output.log(` ${chalk54.gray(desc2)}`);
|
|
18843
18901
|
}
|
|
18844
18902
|
}
|
|
18845
|
-
output.log(
|
|
18903
|
+
output.log(chalk54.gray(`
|
|
18846
18904
|
Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
18847
18905
|
}
|
|
18848
18906
|
} catch (error) {
|
|
@@ -18855,7 +18913,7 @@ Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
|
18855
18913
|
};
|
|
18856
18914
|
|
|
18857
18915
|
// src/commands/mcp/reload.ts
|
|
18858
|
-
import
|
|
18916
|
+
import chalk55 from "chalk";
|
|
18859
18917
|
var ReloadCommand2 = {
|
|
18860
18918
|
command: "reload",
|
|
18861
18919
|
aliases: ["r"],
|
|
@@ -18876,19 +18934,19 @@ var ReloadCommand2 = {
|
|
|
18876
18934
|
output.error("McpComponent not available");
|
|
18877
18935
|
process.exit(1);
|
|
18878
18936
|
}
|
|
18879
|
-
output.log(
|
|
18937
|
+
output.log(chalk55.cyan("Reloading MCP servers..."));
|
|
18880
18938
|
await mcpComponent.reload();
|
|
18881
18939
|
const servers = mcpComponent.listServers();
|
|
18882
18940
|
const connected = servers.filter((s) => s.status === "connected").length;
|
|
18883
18941
|
const errors = servers.filter((s) => s.status === "error").length;
|
|
18884
|
-
output.log(
|
|
18942
|
+
output.log(chalk55.green(`✓ Reloaded ${servers.length} servers`));
|
|
18885
18943
|
if (connected > 0) {
|
|
18886
|
-
output.log(
|
|
18944
|
+
output.log(chalk55.green(` • ${connected} connected`));
|
|
18887
18945
|
}
|
|
18888
18946
|
if (errors > 0) {
|
|
18889
18947
|
output.warn(` • ${errors} failed`);
|
|
18890
18948
|
for (const server of servers.filter((s) => s.status === "error")) {
|
|
18891
|
-
output.log(
|
|
18949
|
+
output.log(chalk55.gray(` - ${server.name}: ${server.error}`));
|
|
18892
18950
|
}
|
|
18893
18951
|
}
|
|
18894
18952
|
} catch (error) {
|
|
@@ -18909,7 +18967,7 @@ var McpCommand = {
|
|
|
18909
18967
|
};
|
|
18910
18968
|
|
|
18911
18969
|
// src/commands/tools/list.ts
|
|
18912
|
-
import
|
|
18970
|
+
import chalk56 from "chalk";
|
|
18913
18971
|
var ListCommand7 = {
|
|
18914
18972
|
command: "list",
|
|
18915
18973
|
aliases: ["ls"],
|
|
@@ -18968,16 +19026,16 @@ var ListCommand7 = {
|
|
|
18968
19026
|
output.log(hint);
|
|
18969
19027
|
} else {
|
|
18970
19028
|
const header = [
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
|
|
19029
|
+
chalk56.bold("Name"),
|
|
19030
|
+
chalk56.bold("Description"),
|
|
19031
|
+
chalk56.bold("Category")
|
|
18974
19032
|
].join(" | ");
|
|
18975
19033
|
const rows = tools.map((t) => {
|
|
18976
19034
|
const desc2 = t.description.length > 40 ? t.description.slice(0, 37) + "..." : t.description;
|
|
18977
19035
|
return [
|
|
18978
|
-
|
|
19036
|
+
chalk56.cyan(t.name),
|
|
18979
19037
|
desc2,
|
|
18980
|
-
t.metadata?.category ?
|
|
19038
|
+
t.metadata?.category ? chalk56.gray(`[${t.metadata.category}]`) : "-"
|
|
18981
19039
|
].join(" | ");
|
|
18982
19040
|
});
|
|
18983
19041
|
output.log([
|
|
@@ -19007,7 +19065,7 @@ var ListCommand7 = {
|
|
|
19007
19065
|
};
|
|
19008
19066
|
|
|
19009
19067
|
// src/commands/tools/get.ts
|
|
19010
|
-
import
|
|
19068
|
+
import chalk57 from "chalk";
|
|
19011
19069
|
|
|
19012
19070
|
// src/commands/tools/shared/schema-helper.ts
|
|
19013
19071
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -19082,8 +19140,8 @@ var GetCommand6 = {
|
|
|
19082
19140
|
}))
|
|
19083
19141
|
});
|
|
19084
19142
|
} else {
|
|
19085
|
-
output.log(
|
|
19086
|
-
output.log(
|
|
19143
|
+
output.log(chalk57.bold.cyan(`Tool: ${tool.name}`));
|
|
19144
|
+
output.log(chalk57.gray("─".repeat(60)));
|
|
19087
19145
|
output.log(`Description: ${tool.description}`);
|
|
19088
19146
|
if (tool.metadata?.category) {
|
|
19089
19147
|
output.log(`Category: ${tool.metadata.category}`);
|
|
@@ -19092,9 +19150,9 @@ var GetCommand6 = {
|
|
|
19092
19150
|
output.log(`Tags: ${tool.metadata.tags.join(", ")}`);
|
|
19093
19151
|
}
|
|
19094
19152
|
output.log("");
|
|
19095
|
-
output.log(
|
|
19153
|
+
output.log(chalk57.bold("Parameters:"));
|
|
19096
19154
|
for (const param of params) {
|
|
19097
|
-
const required = param.required ?
|
|
19155
|
+
const required = param.required ? chalk57.red("(required)") : chalk57.gray("(optional)");
|
|
19098
19156
|
const defaultVal = param.default !== undefined ? ` [default: ${JSON.stringify(param.default)}]` : "";
|
|
19099
19157
|
output.log(` --${param.name} <${param.type}> ${required}`);
|
|
19100
19158
|
output.log(` ${param.description}${defaultVal}`);
|
|
@@ -19203,14 +19261,14 @@ var ToolsCommand2 = {
|
|
|
19203
19261
|
};
|
|
19204
19262
|
|
|
19205
19263
|
// src/commands/memory/record.ts
|
|
19206
|
-
import
|
|
19264
|
+
import chalk58 from "chalk";
|
|
19207
19265
|
import { createMemoryAgentTools, getBuiltInPrompt } from "@ai-setting/roy-agent-core";
|
|
19208
19266
|
import { bashTool, globTool, readFileTool } from "@ai-setting/roy-agent-core";
|
|
19209
19267
|
async function runExtractMode(output, memoryComponent, agentComponent, sessionComponent, env, options) {
|
|
19210
19268
|
const { scope, sessionId, require: userRequirement } = options;
|
|
19211
|
-
output.log(
|
|
19269
|
+
output.log(chalk58.blue(`
|
|
19212
19270
|
\uD83D\uDD0D Memory Extract Mode (${scope})`));
|
|
19213
|
-
output.log(
|
|
19271
|
+
output.log(chalk58.gray(`正在分析会话历史,生成记忆...
|
|
19214
19272
|
`));
|
|
19215
19273
|
try {
|
|
19216
19274
|
const currentMemory = await memoryComponent.recallMemory(scope) || "(无现有记忆)";
|
|
@@ -19256,13 +19314,13 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
19256
19314
|
for (const tool of agentTools) {
|
|
19257
19315
|
try {
|
|
19258
19316
|
toolComponent.register(tool);
|
|
19259
|
-
output.log(
|
|
19317
|
+
output.log(chalk58.gray(`Tool registered: ${tool.name}`));
|
|
19260
19318
|
} catch (err) {
|
|
19261
|
-
output.log(
|
|
19319
|
+
output.log(chalk58.gray(`Tool already registered: ${tool.name}`));
|
|
19262
19320
|
}
|
|
19263
19321
|
}
|
|
19264
19322
|
}
|
|
19265
|
-
output.log(
|
|
19323
|
+
output.log(chalk58.gray(`Agent "${agentName}" registered with ${agentTools.length} tools`));
|
|
19266
19324
|
const query = `请分析会话历史,提炼${scope === "project" ? "项目" : "全局"}记忆并写入记忆文件。`;
|
|
19267
19325
|
let result;
|
|
19268
19326
|
try {
|
|
@@ -19276,12 +19334,12 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
19276
19334
|
if (result && result.startsWith("执行失败")) {
|
|
19277
19335
|
output.error(`提取失败: ${result}`);
|
|
19278
19336
|
} else if (result) {
|
|
19279
|
-
output.log(
|
|
19337
|
+
output.log(chalk58.green(`
|
|
19280
19338
|
✅ 记忆提取完成`));
|
|
19281
|
-
output.log(
|
|
19339
|
+
output.log(chalk58.gray(`记忆已保存到 memory 文件。
|
|
19282
19340
|
`));
|
|
19283
19341
|
if (result.length > 0 && result !== "✅ 记忆提取完成") {
|
|
19284
|
-
output.log(
|
|
19342
|
+
output.log(chalk58.gray(`执行摘要: ${result.substring(0, 200)}${result.length > 200 ? "..." : ""}`));
|
|
19285
19343
|
}
|
|
19286
19344
|
}
|
|
19287
19345
|
agentComponent.unregisterAgent(agentName);
|
|
@@ -19399,11 +19457,11 @@ var RecordCommand = {
|
|
|
19399
19457
|
prepend: "已插入内容到记忆文件开头",
|
|
19400
19458
|
delete: "已删除记忆文件"
|
|
19401
19459
|
};
|
|
19402
|
-
output.log(
|
|
19403
|
-
output.log(
|
|
19460
|
+
output.log(chalk58.green(`✓ ${actionMessages[result.action]}`));
|
|
19461
|
+
output.log(chalk58.gray(`路径: ${result.path}`));
|
|
19404
19462
|
if (result.action !== "delete" && a.content) {
|
|
19405
19463
|
const preview = a.content.substring(0, 100);
|
|
19406
|
-
output.log(
|
|
19464
|
+
output.log(chalk58.gray(`内容预览: ${preview}${a.content.length > 100 ? "..." : ""}`));
|
|
19407
19465
|
}
|
|
19408
19466
|
} catch (error) {
|
|
19409
19467
|
output.error(`Failed to record memory: ${error}`);
|
|
@@ -19415,7 +19473,7 @@ var RecordCommand = {
|
|
|
19415
19473
|
};
|
|
19416
19474
|
|
|
19417
19475
|
// src/commands/memory/recall.ts
|
|
19418
|
-
import
|
|
19476
|
+
import chalk59 from "chalk";
|
|
19419
19477
|
var RecallCommand = {
|
|
19420
19478
|
command: "recall",
|
|
19421
19479
|
aliases: ["load"],
|
|
@@ -19451,7 +19509,7 @@ var RecallCommand = {
|
|
|
19451
19509
|
}
|
|
19452
19510
|
const content = await memoryComponent.recallMemory(a.scope);
|
|
19453
19511
|
if (!content) {
|
|
19454
|
-
output.log(
|
|
19512
|
+
output.log(chalk59.gray("(No memory files found)"));
|
|
19455
19513
|
return;
|
|
19456
19514
|
}
|
|
19457
19515
|
if (a.json) {
|
|
@@ -19477,7 +19535,7 @@ var MemoryCommand = {
|
|
|
19477
19535
|
handler: () => {}
|
|
19478
19536
|
};
|
|
19479
19537
|
// src/commands/eventsource/list.ts
|
|
19480
|
-
import
|
|
19538
|
+
import chalk60 from "chalk";
|
|
19481
19539
|
function truncateVisual2(str, maxWidth) {
|
|
19482
19540
|
let result = "";
|
|
19483
19541
|
let width = 0;
|
|
@@ -19492,7 +19550,7 @@ function truncateVisual2(str, maxWidth) {
|
|
|
19492
19550
|
}
|
|
19493
19551
|
function formatSourcesTable(sources) {
|
|
19494
19552
|
if (sources.length === 0) {
|
|
19495
|
-
return
|
|
19553
|
+
return chalk60.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加");
|
|
19496
19554
|
}
|
|
19497
19555
|
const ID_WIDTH = 10;
|
|
19498
19556
|
const NAME_WIDTH = 20;
|
|
@@ -19501,11 +19559,11 @@ function formatSourcesTable(sources) {
|
|
|
19501
19559
|
const ENABLED_WIDTH = 8;
|
|
19502
19560
|
const GAP = " ";
|
|
19503
19561
|
const headerLine = [
|
|
19504
|
-
|
|
19505
|
-
|
|
19506
|
-
|
|
19507
|
-
|
|
19508
|
-
|
|
19562
|
+
chalk60.bold("ID".padEnd(ID_WIDTH)),
|
|
19563
|
+
chalk60.bold("NAME".padEnd(NAME_WIDTH)),
|
|
19564
|
+
chalk60.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
19565
|
+
chalk60.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
19566
|
+
chalk60.bold("ENABLED".padEnd(ENABLED_WIDTH))
|
|
19509
19567
|
].join(GAP);
|
|
19510
19568
|
const sepLine = "─".repeat(ID_WIDTH + NAME_WIDTH + TYPE_WIDTH + STATUS_WIDTH + ENABLED_WIDTH + GAP.length * 4);
|
|
19511
19569
|
const formatRow = (src) => {
|
|
@@ -19563,7 +19621,7 @@ var EventSourceListCommand = {
|
|
|
19563
19621
|
sources: []
|
|
19564
19622
|
});
|
|
19565
19623
|
} else {
|
|
19566
|
-
output.log(
|
|
19624
|
+
output.log(chalk60.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加"));
|
|
19567
19625
|
}
|
|
19568
19626
|
return;
|
|
19569
19627
|
}
|
|
@@ -19598,21 +19656,21 @@ var EventSourceListCommand = {
|
|
|
19598
19656
|
const rows = sources.map((s) => {
|
|
19599
19657
|
const status = esComponent.getStatus(s.id) || "unknown";
|
|
19600
19658
|
const statusColorMap = {
|
|
19601
|
-
running:
|
|
19602
|
-
stopped:
|
|
19603
|
-
error:
|
|
19604
|
-
starting:
|
|
19605
|
-
created:
|
|
19606
|
-
stopping:
|
|
19607
|
-
unknown:
|
|
19659
|
+
running: chalk60.green,
|
|
19660
|
+
stopped: chalk60.gray,
|
|
19661
|
+
error: chalk60.red,
|
|
19662
|
+
starting: chalk60.yellow,
|
|
19663
|
+
created: chalk60.gray,
|
|
19664
|
+
stopping: chalk60.yellow,
|
|
19665
|
+
unknown: chalk60.gray
|
|
19608
19666
|
};
|
|
19609
|
-
const statusColor = statusColorMap[status] ||
|
|
19667
|
+
const statusColor = statusColorMap[status] || chalk60.gray;
|
|
19610
19668
|
return {
|
|
19611
19669
|
id: s.id.substring(0, 8),
|
|
19612
19670
|
name: s.name,
|
|
19613
19671
|
type: s.type,
|
|
19614
19672
|
status: statusColor(status),
|
|
19615
|
-
enabled: s.enabled ?
|
|
19673
|
+
enabled: s.enabled ? chalk60.green("✓") : chalk60.gray("✗")
|
|
19616
19674
|
};
|
|
19617
19675
|
});
|
|
19618
19676
|
output.log(formatSourcesTable(rows));
|
|
@@ -19634,11 +19692,11 @@ var EventSourceListCommand = {
|
|
|
19634
19692
|
};
|
|
19635
19693
|
|
|
19636
19694
|
// src/commands/eventsource/add.ts
|
|
19637
|
-
import
|
|
19695
|
+
import chalk62 from "chalk";
|
|
19638
19696
|
import { generateId } from "@ai-setting/roy-agent-core";
|
|
19639
19697
|
|
|
19640
19698
|
// src/commands/eventsource/server-url-option.ts
|
|
19641
|
-
import
|
|
19699
|
+
import chalk61 from "chalk";
|
|
19642
19700
|
function addServerUrlOption(yargs) {
|
|
19643
19701
|
return yargs.option("server-url", {
|
|
19644
19702
|
alias: "s",
|
|
@@ -19654,7 +19712,7 @@ function resolveServerUrl(serverUrl, fallback) {
|
|
|
19654
19712
|
return fallback;
|
|
19655
19713
|
const trimmed = serverUrl.replace(/\/+$/, "");
|
|
19656
19714
|
if (!/^(https?|wss?):\/\//.test(trimmed)) {
|
|
19657
|
-
console.error(
|
|
19715
|
+
console.error(chalk61.red(`
|
|
19658
19716
|
✗ Invalid --server-url: "${serverUrl}". Must start with http://, https://, ws://, or wss://
|
|
19659
19717
|
`));
|
|
19660
19718
|
process.exit(1);
|
|
@@ -19773,7 +19831,7 @@ var EventSourceAddCommand = {
|
|
|
19773
19831
|
let profileApiBase;
|
|
19774
19832
|
if (a.type === "bounty-im") {
|
|
19775
19833
|
if (a.email && a.profile) {
|
|
19776
|
-
output.error(
|
|
19834
|
+
output.error(chalk62.red(`
|
|
19777
19835
|
✗ --email 和 --profile 互斥(profile 文件已包含 email)。请选择其一。
|
|
19778
19836
|
`));
|
|
19779
19837
|
process.exit(1);
|
|
@@ -19781,7 +19839,7 @@ var EventSourceAddCommand = {
|
|
|
19781
19839
|
if (a.profile) {
|
|
19782
19840
|
const profile = readBountyProfile(a.profile);
|
|
19783
19841
|
if (!profile) {
|
|
19784
|
-
output.error(
|
|
19842
|
+
output.error(chalk62.red(`
|
|
19785
19843
|
✗ Profile '${a.profile}' 不存在或格式错误。期望路径:~/.config/bounty/profiles/${a.profile}.json
|
|
19786
19844
|
`));
|
|
19787
19845
|
process.exit(1);
|
|
@@ -19817,39 +19875,39 @@ var EventSourceAddCommand = {
|
|
|
19817
19875
|
options: a.prompt ? { prompt: a.prompt } : undefined
|
|
19818
19876
|
};
|
|
19819
19877
|
esComponent.register(config);
|
|
19820
|
-
output.success(
|
|
19878
|
+
output.success(chalk62.green(`事件源 '${a.name}' 添加成功!`));
|
|
19821
19879
|
output.log("");
|
|
19822
|
-
output.log(` ID: ${
|
|
19823
|
-
output.log(` Type: ${
|
|
19880
|
+
output.log(` ID: ${chalk62.gray(config.id)}`);
|
|
19881
|
+
output.log(` Type: ${chalk62.cyan(a.type)}`);
|
|
19824
19882
|
if (eventTypes?.length) {
|
|
19825
|
-
output.log(` Event Types: ${
|
|
19883
|
+
output.log(` Event Types: ${chalk62.gray(eventTypes.join(", "))}`);
|
|
19826
19884
|
}
|
|
19827
19885
|
if (a.command) {
|
|
19828
|
-
output.log(` Command: ${
|
|
19886
|
+
output.log(` Command: ${chalk62.gray(a.command)}`);
|
|
19829
19887
|
}
|
|
19830
19888
|
if (a.interval) {
|
|
19831
|
-
output.log(` Interval: ${
|
|
19889
|
+
output.log(` Interval: ${chalk62.gray(`${a.interval}ms`)}`);
|
|
19832
19890
|
}
|
|
19833
19891
|
if (resolvedProfileName) {
|
|
19834
|
-
output.log(` Profile: ${
|
|
19892
|
+
output.log(` Profile: ${chalk62.gray(resolvedProfileName)}`);
|
|
19835
19893
|
}
|
|
19836
19894
|
if (resolvedEmail) {
|
|
19837
|
-
output.log(` Email: ${
|
|
19895
|
+
output.log(` Email: ${chalk62.gray(resolvedEmail)}`);
|
|
19838
19896
|
}
|
|
19839
19897
|
if (a.imServerUrl) {
|
|
19840
|
-
output.log(` IM Server URL: ${
|
|
19898
|
+
output.log(` IM Server URL: ${chalk62.gray(a.imServerUrl)}`);
|
|
19841
19899
|
}
|
|
19842
19900
|
if (resolvedServerUrl) {
|
|
19843
|
-
output.log(` Server URL: ${
|
|
19901
|
+
output.log(` Server URL: ${chalk62.gray(resolvedServerUrl)}`);
|
|
19844
19902
|
}
|
|
19845
19903
|
if (a.tlsSkipVerify) {
|
|
19846
|
-
output.log(` TLS Skip Verify: ${
|
|
19904
|
+
output.log(` TLS Skip Verify: ${chalk62.yellow("⚠ true (自签名场景)")}`);
|
|
19847
19905
|
}
|
|
19848
19906
|
if (a.prompt) {
|
|
19849
|
-
output.log(` Prompt: ${
|
|
19907
|
+
output.log(` Prompt: ${chalk62.gray(a.prompt.length > 60 ? a.prompt.slice(0, 60) + "..." : a.prompt)}`);
|
|
19850
19908
|
}
|
|
19851
19909
|
output.log("");
|
|
19852
|
-
output.log(
|
|
19910
|
+
output.log(chalk62.gray(`使用 'roy-agent eventsource start ${config.id.substring(0, 8)}' 启动它。`));
|
|
19853
19911
|
} finally {
|
|
19854
19912
|
await envService.dispose();
|
|
19855
19913
|
}
|
|
@@ -19857,7 +19915,7 @@ var EventSourceAddCommand = {
|
|
|
19857
19915
|
};
|
|
19858
19916
|
|
|
19859
19917
|
// src/commands/eventsource/update.ts
|
|
19860
|
-
import
|
|
19918
|
+
import chalk63 from "chalk";
|
|
19861
19919
|
function findSource(esComponent, id) {
|
|
19862
19920
|
const sources = esComponent.list();
|
|
19863
19921
|
const matched = sources.find((s) => s.id === id || s.id.startsWith(id));
|
|
@@ -19932,7 +19990,7 @@ var EventSourceUpdateCommand = {
|
|
|
19932
19990
|
const all = esComponent.list();
|
|
19933
19991
|
if (all.length > 0) {
|
|
19934
19992
|
output.info("");
|
|
19935
|
-
output.info(
|
|
19993
|
+
output.info(chalk63.gray("可用的事件源:"));
|
|
19936
19994
|
for (const s of all) {
|
|
19937
19995
|
output.info(` - ${s.id.substring(0, 8)}: ${s.name} (${s.type})`);
|
|
19938
19996
|
}
|
|
@@ -19940,7 +19998,7 @@ var EventSourceUpdateCommand = {
|
|
|
19940
19998
|
process.exit(1);
|
|
19941
19999
|
}
|
|
19942
20000
|
if (match.source.type === "bounty-im" && a.email && a.profile) {
|
|
19943
|
-
output.error(
|
|
20001
|
+
output.error(chalk63.red(`
|
|
19944
20002
|
✗ --email 和 --profile 互斥(profile 文件已包含 email)。请选择其一。
|
|
19945
20003
|
`));
|
|
19946
20004
|
process.exit(1);
|
|
@@ -19950,7 +20008,7 @@ var EventSourceUpdateCommand = {
|
|
|
19950
20008
|
if (a.profile && match.source.type === "bounty-im") {
|
|
19951
20009
|
const profile = readBountyProfile(a.profile);
|
|
19952
20010
|
if (!profile) {
|
|
19953
|
-
output.error(
|
|
20011
|
+
output.error(chalk63.red(`
|
|
19954
20012
|
✗ Profile '${a.profile}' 不存在或格式错误。期望路径:~/.config/bounty/profiles/${a.profile}.json
|
|
19955
20013
|
`));
|
|
19956
20014
|
process.exit(1);
|
|
@@ -19999,19 +20057,19 @@ var EventSourceUpdateCommand = {
|
|
|
19999
20057
|
}
|
|
20000
20058
|
try {
|
|
20001
20059
|
const result = await esComponent.update(match.fullId, partial);
|
|
20002
|
-
output.success(
|
|
20060
|
+
output.success(chalk63.green(`✅ 事件源已更新: ${match.source.name}`));
|
|
20003
20061
|
output.log("");
|
|
20004
|
-
output.log(
|
|
20062
|
+
output.log(chalk63.bold("修改字段:"));
|
|
20005
20063
|
const before = match.source;
|
|
20006
20064
|
const after = result.updated;
|
|
20007
20065
|
for (const field of result.fields) {
|
|
20008
20066
|
const beforeVal = JSON.stringify(before[field] ?? before.options?.[field]);
|
|
20009
20067
|
const afterVal = JSON.stringify(after[field] ?? after.options?.[field]);
|
|
20010
|
-
output.log(` ${
|
|
20068
|
+
output.log(` ${chalk63.cyan(field)}: ${chalk63.gray(beforeVal)} ${chalk63.gray("→")} ${chalk63.green(afterVal)}`);
|
|
20011
20069
|
}
|
|
20012
20070
|
output.log("");
|
|
20013
20071
|
if (result.wasRunning) {
|
|
20014
|
-
output.info(
|
|
20072
|
+
output.info(chalk63.yellow(`⚠️ 事件源在更新前正在运行,已自动停止。请使用 'roy-agent eventsource start ${match.fullId.substring(0, 8)}' 手动启动以应用新配置。`));
|
|
20015
20073
|
}
|
|
20016
20074
|
} catch (error) {
|
|
20017
20075
|
output.error(`❌ 更新失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -20024,7 +20082,7 @@ var EventSourceUpdateCommand = {
|
|
|
20024
20082
|
};
|
|
20025
20083
|
|
|
20026
20084
|
// src/commands/eventsource/remove.ts
|
|
20027
|
-
import
|
|
20085
|
+
import chalk64 from "chalk";
|
|
20028
20086
|
var EventSourceRemoveCommand = {
|
|
20029
20087
|
command: "remove <id>",
|
|
20030
20088
|
aliases: ["rm"],
|
|
@@ -20063,7 +20121,7 @@ var EventSourceRemoveCommand = {
|
|
|
20063
20121
|
const status = esComponent.getStatus(matchedSource.id);
|
|
20064
20122
|
if (status === "running" && !args.force) {
|
|
20065
20123
|
output.error(`事件源正在运行中,请先停止: ${matchedSource.name} (${status})`);
|
|
20066
|
-
output.log(
|
|
20124
|
+
output.log(chalk64.gray(`使用 --force 强制移除或 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' 先停止`));
|
|
20067
20125
|
process.exit(1);
|
|
20068
20126
|
}
|
|
20069
20127
|
if (status === "running") {
|
|
@@ -20072,7 +20130,7 @@ var EventSourceRemoveCommand = {
|
|
|
20072
20130
|
}
|
|
20073
20131
|
const result = esComponent.unregister(matchedSource.id);
|
|
20074
20132
|
if (result) {
|
|
20075
|
-
output.success(
|
|
20133
|
+
output.success(chalk64.green(`事件源已移除: ${matchedSource.name}`));
|
|
20076
20134
|
} else {
|
|
20077
20135
|
output.error("移除失败");
|
|
20078
20136
|
process.exit(1);
|
|
@@ -20084,7 +20142,7 @@ var EventSourceRemoveCommand = {
|
|
|
20084
20142
|
};
|
|
20085
20143
|
|
|
20086
20144
|
// src/commands/eventsource/start.ts
|
|
20087
|
-
import
|
|
20145
|
+
import chalk65 from "chalk";
|
|
20088
20146
|
var EventSourceStartCommand = {
|
|
20089
20147
|
command: "start <id>",
|
|
20090
20148
|
describe: "启动指定的事件源",
|
|
@@ -20121,15 +20179,15 @@ var EventSourceStartCommand = {
|
|
|
20121
20179
|
}
|
|
20122
20180
|
const status = esComponent.getStatus(matchedSource.id);
|
|
20123
20181
|
if (status === "running") {
|
|
20124
|
-
output.log(
|
|
20182
|
+
output.log(chalk65.yellow(`事件源已在运行: ${matchedSource.name}`));
|
|
20125
20183
|
return;
|
|
20126
20184
|
}
|
|
20127
20185
|
output.info(`正在启动事件源 '${matchedSource.name}'...`);
|
|
20128
20186
|
try {
|
|
20129
20187
|
await esComponent.startSource(matchedSource.id);
|
|
20130
|
-
output.success(
|
|
20188
|
+
output.success(chalk65.green(`事件源已启动: ${matchedSource.name}`));
|
|
20131
20189
|
if (!args.background) {
|
|
20132
|
-
output.log(
|
|
20190
|
+
output.log(chalk65.gray("按 Ctrl+C 停止..."));
|
|
20133
20191
|
await new Promise((resolve) => {
|
|
20134
20192
|
const cleanup = () => {
|
|
20135
20193
|
process.removeListener("SIGINT", cleanup);
|
|
@@ -20151,7 +20209,7 @@ var EventSourceStartCommand = {
|
|
|
20151
20209
|
};
|
|
20152
20210
|
|
|
20153
20211
|
// src/commands/eventsource/stop.ts
|
|
20154
|
-
import
|
|
20212
|
+
import chalk66 from "chalk";
|
|
20155
20213
|
var EventSourceStopCommand = {
|
|
20156
20214
|
command: "stop <id>",
|
|
20157
20215
|
aliases: ["kill"],
|
|
@@ -20189,13 +20247,13 @@ var EventSourceStopCommand = {
|
|
|
20189
20247
|
}
|
|
20190
20248
|
const status = esComponent.getStatus(matchedSource.id);
|
|
20191
20249
|
if (status !== "running") {
|
|
20192
|
-
output.log(
|
|
20250
|
+
output.log(chalk66.yellow(`事件源未运行: ${matchedSource.name} (${status || "unknown"})`));
|
|
20193
20251
|
return;
|
|
20194
20252
|
}
|
|
20195
20253
|
output.info(`正在停止事件源 '${matchedSource.name}'...`);
|
|
20196
20254
|
try {
|
|
20197
20255
|
await esComponent.stopSource(matchedSource.id);
|
|
20198
|
-
output.success(
|
|
20256
|
+
output.success(chalk66.green(`事件源已停止: ${matchedSource.name}`));
|
|
20199
20257
|
} catch (error) {
|
|
20200
20258
|
output.error(`停止失败: ${error}`);
|
|
20201
20259
|
process.exit(1);
|
|
@@ -20207,14 +20265,14 @@ var EventSourceStopCommand = {
|
|
|
20207
20265
|
};
|
|
20208
20266
|
|
|
20209
20267
|
// src/commands/eventsource/status.ts
|
|
20210
|
-
import
|
|
20268
|
+
import chalk67 from "chalk";
|
|
20211
20269
|
var STATUS_COLORS = {
|
|
20212
|
-
created:
|
|
20213
|
-
starting:
|
|
20214
|
-
running:
|
|
20215
|
-
stopping:
|
|
20216
|
-
stopped:
|
|
20217
|
-
error:
|
|
20270
|
+
created: chalk67.gray,
|
|
20271
|
+
starting: chalk67.yellow,
|
|
20272
|
+
running: chalk67.green,
|
|
20273
|
+
stopping: chalk67.yellow,
|
|
20274
|
+
stopped: chalk67.gray,
|
|
20275
|
+
error: chalk67.red
|
|
20218
20276
|
};
|
|
20219
20277
|
var STATUS_ICONS = {
|
|
20220
20278
|
created: "○",
|
|
@@ -20268,7 +20326,7 @@ var EventSourceStatusCommand = {
|
|
|
20268
20326
|
process.exit(1);
|
|
20269
20327
|
}
|
|
20270
20328
|
const status = esComponent.getStatus(matchedSource.id) || "unknown";
|
|
20271
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
20329
|
+
const statusColor = STATUS_COLORS[status] || chalk67.gray;
|
|
20272
20330
|
if (args.json) {
|
|
20273
20331
|
output.json({
|
|
20274
20332
|
id: matchedSource.id,
|
|
@@ -20285,31 +20343,31 @@ var EventSourceStatusCommand = {
|
|
|
20285
20343
|
});
|
|
20286
20344
|
return;
|
|
20287
20345
|
}
|
|
20288
|
-
output.log(
|
|
20346
|
+
output.log(chalk67.bold("事件源详情"));
|
|
20289
20347
|
output.log("─".repeat(50));
|
|
20290
|
-
output.log(` ID: ${
|
|
20291
|
-
output.log(` Name: ${
|
|
20292
|
-
output.log(` Type: ${
|
|
20348
|
+
output.log(` ID: ${chalk67.gray(matchedSource.id)}`);
|
|
20349
|
+
output.log(` Name: ${chalk67.cyan(matchedSource.name)}`);
|
|
20350
|
+
output.log(` Type: ${chalk67.cyan(matchedSource.type)}`);
|
|
20293
20351
|
output.log(` Status: ${statusColor(`${STATUS_ICONS[status]} ${STATUS_LABELS[status]}`)}`);
|
|
20294
|
-
output.log(` Enabled: ${matchedSource.enabled ?
|
|
20352
|
+
output.log(` Enabled: ${matchedSource.enabled ? chalk67.green("是") : chalk67.gray("否")}`);
|
|
20295
20353
|
if (matchedSource.eventTypes?.length) {
|
|
20296
|
-
output.log(` Events: ${
|
|
20354
|
+
output.log(` Events: ${chalk67.gray(matchedSource.eventTypes.join(", "))}`);
|
|
20297
20355
|
}
|
|
20298
20356
|
if (matchedSource.command) {
|
|
20299
|
-
output.log(` Command: ${
|
|
20357
|
+
output.log(` Command: ${chalk67.gray(matchedSource.command)}`);
|
|
20300
20358
|
}
|
|
20301
20359
|
if (matchedSource.interval) {
|
|
20302
|
-
output.log(` Interval: ${
|
|
20360
|
+
output.log(` Interval: ${chalk67.gray(`${matchedSource.interval}ms`)}`);
|
|
20303
20361
|
}
|
|
20304
20362
|
if (matchedSource.url) {
|
|
20305
|
-
output.log(` URL: ${
|
|
20363
|
+
output.log(` URL: ${chalk67.gray(matchedSource.url)}`);
|
|
20306
20364
|
}
|
|
20307
20365
|
output.log("");
|
|
20308
20366
|
return;
|
|
20309
20367
|
}
|
|
20310
20368
|
const sources = esComponent.list();
|
|
20311
20369
|
if (sources.length === 0) {
|
|
20312
|
-
output.log(
|
|
20370
|
+
output.log(chalk67.yellow("没有配置的事件源"));
|
|
20313
20371
|
return;
|
|
20314
20372
|
}
|
|
20315
20373
|
if (args.json) {
|
|
@@ -20323,21 +20381,21 @@ var EventSourceStatusCommand = {
|
|
|
20323
20381
|
output.json({ sources: sourcesWithStatus, count: sources.length });
|
|
20324
20382
|
return;
|
|
20325
20383
|
}
|
|
20326
|
-
output.log(
|
|
20384
|
+
output.log(chalk67.bold("事件源状态概览"));
|
|
20327
20385
|
output.log("─".repeat(60));
|
|
20328
20386
|
for (const source of sources) {
|
|
20329
20387
|
const status = esComponent.getStatus(source.id) || "unknown";
|
|
20330
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
20388
|
+
const statusColor = STATUS_COLORS[status] || chalk67.gray;
|
|
20331
20389
|
const icon = STATUS_ICONS[status] || "?";
|
|
20332
20390
|
const label = STATUS_LABELS[status] || status;
|
|
20333
20391
|
output.log("");
|
|
20334
|
-
output.log(` ${
|
|
20392
|
+
output.log(` ${chalk67.cyan(source.name)} ${chalk67.gray(`(${source.type})`)}`);
|
|
20335
20393
|
output.log(` └─ Status: ${statusColor(`${icon} ${label}`)}`);
|
|
20336
|
-
output.log(` ID: ${
|
|
20394
|
+
output.log(` ID: ${chalk67.gray(source.id.substring(0, 8))}...`);
|
|
20337
20395
|
}
|
|
20338
20396
|
output.log("");
|
|
20339
20397
|
const runningCount = sources.filter((s) => esComponent.getStatus(s.id) === "running").length;
|
|
20340
|
-
output.log(
|
|
20398
|
+
output.log(chalk67.green(`✅ ${runningCount}/${sources.length} 运行中`));
|
|
20341
20399
|
} finally {
|
|
20342
20400
|
await envService.dispose();
|
|
20343
20401
|
}
|
|
@@ -20650,7 +20708,7 @@ var DebugCommand = {
|
|
|
20650
20708
|
};
|
|
20651
20709
|
|
|
20652
20710
|
// src/commands/workflow/renderers.ts
|
|
20653
|
-
import
|
|
20711
|
+
import chalk68 from "chalk";
|
|
20654
20712
|
function truncateVisual3(str, maxWidth) {
|
|
20655
20713
|
if (!str)
|
|
20656
20714
|
return "-";
|
|
@@ -20685,18 +20743,18 @@ function formatDuration(ms) {
|
|
|
20685
20743
|
function statusColor(status) {
|
|
20686
20744
|
switch (status) {
|
|
20687
20745
|
case "completed":
|
|
20688
|
-
return
|
|
20746
|
+
return chalk68.green;
|
|
20689
20747
|
case "running":
|
|
20690
20748
|
case "idle":
|
|
20691
|
-
return
|
|
20749
|
+
return chalk68.blue;
|
|
20692
20750
|
case "paused":
|
|
20693
|
-
return
|
|
20751
|
+
return chalk68.yellow;
|
|
20694
20752
|
case "failed":
|
|
20695
|
-
return
|
|
20753
|
+
return chalk68.red;
|
|
20696
20754
|
case "stopped":
|
|
20697
|
-
return
|
|
20755
|
+
return chalk68.gray;
|
|
20698
20756
|
default:
|
|
20699
|
-
return
|
|
20757
|
+
return chalk68.white;
|
|
20700
20758
|
}
|
|
20701
20759
|
}
|
|
20702
20760
|
function renderWorkflowList(workflows, options) {
|
|
@@ -20715,7 +20773,7 @@ function renderWorkflowList(workflows, options) {
|
|
|
20715
20773
|
}, null, 2);
|
|
20716
20774
|
}
|
|
20717
20775
|
if (workflows.length === 0) {
|
|
20718
|
-
return
|
|
20776
|
+
return chalk68.yellow("No workflows found");
|
|
20719
20777
|
}
|
|
20720
20778
|
const NAME_WIDTH = 30;
|
|
20721
20779
|
const VERSION_WIDTH = 10;
|
|
@@ -20723,10 +20781,10 @@ function renderWorkflowList(workflows, options) {
|
|
|
20723
20781
|
const UPDATED_WIDTH = 20;
|
|
20724
20782
|
const GAP = " ";
|
|
20725
20783
|
const headerLine = [
|
|
20726
|
-
|
|
20727
|
-
|
|
20728
|
-
|
|
20729
|
-
|
|
20784
|
+
chalk68.bold("NAME".padEnd(NAME_WIDTH)),
|
|
20785
|
+
chalk68.bold("VER".padEnd(VERSION_WIDTH)),
|
|
20786
|
+
chalk68.bold("TAGS".padEnd(TAGS_WIDTH)),
|
|
20787
|
+
chalk68.bold("UPDATED")
|
|
20730
20788
|
].join(GAP);
|
|
20731
20789
|
const sepLine = "─".repeat(NAME_WIDTH + VERSION_WIDTH + TAGS_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
20732
20790
|
const rows = workflows.map((w) => {
|
|
@@ -20741,18 +20799,18 @@ function renderWorkflowList(workflows, options) {
|
|
|
20741
20799
|
}
|
|
20742
20800
|
function renderWorkflowDetail(workflow, options) {
|
|
20743
20801
|
const lines = [];
|
|
20744
|
-
lines.push(
|
|
20802
|
+
lines.push(chalk68.bold(`
|
|
20745
20803
|
\uD83D\uDCCB Workflow Details
|
|
20746
20804
|
`));
|
|
20747
|
-
lines.push(` ${
|
|
20748
|
-
lines.push(` ${
|
|
20749
|
-
lines.push(` ${
|
|
20750
|
-
lines.push(` ${
|
|
20751
|
-
lines.push(` ${
|
|
20752
|
-
lines.push(` ${
|
|
20753
|
-
lines.push(` ${
|
|
20805
|
+
lines.push(` ${chalk68.cyan("ID:")} ${workflow.id}`);
|
|
20806
|
+
lines.push(` ${chalk68.cyan("Name:")} ${workflow.name}`);
|
|
20807
|
+
lines.push(` ${chalk68.cyan("Version:")} ${workflow.version}`);
|
|
20808
|
+
lines.push(` ${chalk68.cyan("Description:")} ${workflow.description || "-"}`);
|
|
20809
|
+
lines.push(` ${chalk68.cyan("Tags:")} ${workflow.tags.join(", ") || "-"}`);
|
|
20810
|
+
lines.push(` ${chalk68.cyan("Created:")} ${formatDate(workflow.createdAt)}`);
|
|
20811
|
+
lines.push(` ${chalk68.cyan("Updated:")} ${formatDate(workflow.updatedAt)}`);
|
|
20754
20812
|
const nodeCount = workflow.definition.nodes.length;
|
|
20755
|
-
lines.push(
|
|
20813
|
+
lines.push(chalk68.bold(`
|
|
20756
20814
|
\uD83D\uDCCA Nodes Summary
|
|
20757
20815
|
`));
|
|
20758
20816
|
lines.push(` Total: ${nodeCount} nodes`);
|
|
@@ -20764,7 +20822,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
20764
20822
|
lines.push(` - ${type}: ${count}`);
|
|
20765
20823
|
}
|
|
20766
20824
|
if (workflow.definition.config) {
|
|
20767
|
-
lines.push(
|
|
20825
|
+
lines.push(chalk68.bold(`
|
|
20768
20826
|
⚙️ Configuration
|
|
20769
20827
|
`));
|
|
20770
20828
|
if (workflow.definition.config.parallel_limit !== undefined) {
|
|
@@ -20778,7 +20836,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
20778
20836
|
}
|
|
20779
20837
|
}
|
|
20780
20838
|
if (options?.includeRuns && options.includeRuns.length > 0) {
|
|
20781
|
-
lines.push(
|
|
20839
|
+
lines.push(chalk68.bold(`
|
|
20782
20840
|
\uD83D\uDCDC Recent Runs
|
|
20783
20841
|
`));
|
|
20784
20842
|
lines.push(renderRunsList(options.includeRuns.slice(0, 5)));
|
|
@@ -20802,7 +20860,7 @@ function renderRunsList(runs, options) {
|
|
|
20802
20860
|
}, null, 2);
|
|
20803
20861
|
}
|
|
20804
20862
|
if (runs.length === 0) {
|
|
20805
|
-
return
|
|
20863
|
+
return chalk68.yellow("No runs found");
|
|
20806
20864
|
}
|
|
20807
20865
|
const ID_WIDTH = 20;
|
|
20808
20866
|
const STATUS_WIDTH = 12;
|
|
@@ -20810,10 +20868,10 @@ function renderRunsList(runs, options) {
|
|
|
20810
20868
|
const UPDATED_WIDTH = 20;
|
|
20811
20869
|
const GAP = " ";
|
|
20812
20870
|
const headerLine = [
|
|
20813
|
-
|
|
20814
|
-
|
|
20815
|
-
|
|
20816
|
-
|
|
20871
|
+
chalk68.bold("RUN ID".padEnd(ID_WIDTH)),
|
|
20872
|
+
chalk68.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
20873
|
+
chalk68.bold("DURATION".padEnd(DURATION_WIDTH)),
|
|
20874
|
+
chalk68.bold("STARTED")
|
|
20817
20875
|
].join(GAP);
|
|
20818
20876
|
const sepLine = "─".repeat(ID_WIDTH + STATUS_WIDTH + DURATION_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
20819
20877
|
const rows = runs.map((r) => {
|
|
@@ -20828,34 +20886,34 @@ function renderRunsList(runs, options) {
|
|
|
20828
20886
|
}
|
|
20829
20887
|
function renderRunDetail(run) {
|
|
20830
20888
|
const lines = [];
|
|
20831
|
-
lines.push(
|
|
20889
|
+
lines.push(chalk68.bold(`
|
|
20832
20890
|
\uD83C\uDFC3 Run Details
|
|
20833
20891
|
`));
|
|
20834
|
-
lines.push(` ${
|
|
20835
|
-
lines.push(` ${
|
|
20836
|
-
lines.push(` ${
|
|
20837
|
-
lines.push(` ${
|
|
20892
|
+
lines.push(` ${chalk68.cyan("Run ID:")} ${run.id}`);
|
|
20893
|
+
lines.push(` ${chalk68.cyan("Workflow:")} ${run.workflowId}`);
|
|
20894
|
+
lines.push(` ${chalk68.cyan("Status:")} ${statusColor(run.status)(run.status)}`);
|
|
20895
|
+
lines.push(` ${chalk68.cyan("Started:")} ${formatDate(run.startedAt)}`);
|
|
20838
20896
|
if (run.pausedAt) {
|
|
20839
|
-
lines.push(` ${
|
|
20897
|
+
lines.push(` ${chalk68.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
|
|
20840
20898
|
}
|
|
20841
20899
|
if (run.resumedAt) {
|
|
20842
|
-
lines.push(` ${
|
|
20900
|
+
lines.push(` ${chalk68.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
|
|
20843
20901
|
}
|
|
20844
20902
|
if (run.stoppedAt) {
|
|
20845
|
-
lines.push(` ${
|
|
20903
|
+
lines.push(` ${chalk68.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
|
|
20846
20904
|
}
|
|
20847
20905
|
if (run.completedAt) {
|
|
20848
|
-
lines.push(` ${
|
|
20906
|
+
lines.push(` ${chalk68.cyan("Completed:")} ${formatDate(run.completedAt)}`);
|
|
20849
20907
|
}
|
|
20850
|
-
lines.push(` ${
|
|
20908
|
+
lines.push(` ${chalk68.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
|
|
20851
20909
|
if (run.error) {
|
|
20852
|
-
lines.push(
|
|
20910
|
+
lines.push(chalk68.bold(`
|
|
20853
20911
|
❌ Error
|
|
20854
20912
|
`));
|
|
20855
|
-
lines.push(` ${
|
|
20913
|
+
lines.push(` ${chalk68.red(run.error)}`);
|
|
20856
20914
|
}
|
|
20857
20915
|
if (run.output) {
|
|
20858
|
-
lines.push(
|
|
20916
|
+
lines.push(chalk68.bold(`
|
|
20859
20917
|
\uD83D\uDCE4 Output
|
|
20860
20918
|
`));
|
|
20861
20919
|
lines.push(" " + JSON.stringify(run.output, null, 2).split(`
|
|
@@ -20866,49 +20924,49 @@ function renderRunDetail(run) {
|
|
|
20866
20924
|
`);
|
|
20867
20925
|
}
|
|
20868
20926
|
function renderWorkflowAdded(workflow) {
|
|
20869
|
-
return
|
|
20927
|
+
return chalk68.green(`
|
|
20870
20928
|
✅ Workflow '${workflow.name}' added successfully
|
|
20871
20929
|
`) + ` ID: ${workflow.id}
|
|
20872
20930
|
` + ` Version: ${workflow.version}
|
|
20873
20931
|
`;
|
|
20874
20932
|
}
|
|
20875
20933
|
function renderWorkflowUpdated(workflow) {
|
|
20876
|
-
return
|
|
20934
|
+
return chalk68.green(`
|
|
20877
20935
|
✅ Workflow '${workflow.name}' updated successfully
|
|
20878
20936
|
`) + ` ID: ${workflow.id}
|
|
20879
20937
|
`;
|
|
20880
20938
|
}
|
|
20881
20939
|
function renderWorkflowDeleted(name) {
|
|
20882
|
-
return
|
|
20940
|
+
return chalk68.green(`
|
|
20883
20941
|
✅ Workflow '${name}' deleted successfully
|
|
20884
20942
|
`);
|
|
20885
20943
|
}
|
|
20886
20944
|
function renderRunResult(result) {
|
|
20887
20945
|
const lines = [];
|
|
20888
20946
|
if (result.status === "completed") {
|
|
20889
|
-
lines.push(
|
|
20947
|
+
lines.push(chalk68.green(`
|
|
20890
20948
|
✅ Workflow completed successfully`));
|
|
20891
20949
|
} else if (result.status === "failed") {
|
|
20892
|
-
lines.push(
|
|
20950
|
+
lines.push(chalk68.red(`
|
|
20893
20951
|
❌ Workflow failed`));
|
|
20894
20952
|
} else if (result.status === "stopped") {
|
|
20895
|
-
lines.push(
|
|
20953
|
+
lines.push(chalk68.yellow(`
|
|
20896
20954
|
⚠️ Workflow stopped`));
|
|
20897
20955
|
} else if (result.status === "paused") {
|
|
20898
|
-
lines.push(
|
|
20956
|
+
lines.push(chalk68.yellow(`
|
|
20899
20957
|
⏸️ Workflow paused`));
|
|
20900
20958
|
if (result.pendingNodeId) {
|
|
20901
|
-
lines.push(
|
|
20959
|
+
lines.push(chalk68.gray(` Pending node: ${result.pendingNodeId}`));
|
|
20902
20960
|
}
|
|
20903
20961
|
if (result.query) {
|
|
20904
20962
|
lines.push("");
|
|
20905
|
-
lines.push(
|
|
20963
|
+
lines.push(chalk68.bold("\uD83D\uDCAC Agent asked: ") + chalk68.white(result.query));
|
|
20906
20964
|
}
|
|
20907
20965
|
if (result.agentSessionId) {
|
|
20908
|
-
lines.push(
|
|
20966
|
+
lines.push(chalk68.gray(` Agent sub-session: ${result.agentSessionId}`));
|
|
20909
20967
|
}
|
|
20910
20968
|
} else {
|
|
20911
|
-
lines.push(
|
|
20969
|
+
lines.push(chalk68.blue(`
|
|
20912
20970
|
\uD83D\uDD04 Workflow ${result.status}`));
|
|
20913
20971
|
}
|
|
20914
20972
|
lines.push(` Run ID: ${result.runId}`);
|
|
@@ -20916,11 +20974,11 @@ function renderRunResult(result) {
|
|
|
20916
20974
|
lines.push(` Duration: ${formatDuration(result.durationMs)}`);
|
|
20917
20975
|
}
|
|
20918
20976
|
if (result.error) {
|
|
20919
|
-
lines.push(
|
|
20977
|
+
lines.push(chalk68.red(`
|
|
20920
20978
|
Error: ${result.error}`));
|
|
20921
20979
|
}
|
|
20922
20980
|
if (result.output) {
|
|
20923
|
-
lines.push(
|
|
20981
|
+
lines.push(chalk68.bold(`
|
|
20924
20982
|
\uD83D\uDCE4 Output:`));
|
|
20925
20983
|
lines.push(JSON.stringify(result.output, null, 2));
|
|
20926
20984
|
}
|
|
@@ -20934,10 +20992,10 @@ function renderNodesList(nodes) {
|
|
|
20934
20992
|
const DEPS_WIDTH = 20;
|
|
20935
20993
|
const GAP = " ";
|
|
20936
20994
|
const headerLine = [
|
|
20937
|
-
|
|
20938
|
-
|
|
20939
|
-
|
|
20940
|
-
|
|
20995
|
+
chalk68.bold("NODE ID".padEnd(ID_WIDTH)),
|
|
20996
|
+
chalk68.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
20997
|
+
chalk68.bold("NAME".padEnd(NAME_WIDTH)),
|
|
20998
|
+
chalk68.bold("DEPENDS ON")
|
|
20941
20999
|
].join(GAP);
|
|
20942
21000
|
const sepLine = "─".repeat(ID_WIDTH + TYPE_WIDTH + NAME_WIDTH + DEPS_WIDTH + GAP.length * 3);
|
|
20943
21001
|
const rows = nodes.map((n) => {
|
|
@@ -20952,7 +21010,7 @@ function renderNodesList(nodes) {
|
|
|
20952
21010
|
}
|
|
20953
21011
|
|
|
20954
21012
|
// src/commands/workflow/commands/list.ts
|
|
20955
|
-
import
|
|
21013
|
+
import chalk69 from "chalk";
|
|
20956
21014
|
import { createWorkflowListTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
20957
21015
|
function buildListWorkflowsJson(workflows, total, args, availableTags) {
|
|
20958
21016
|
const output = {
|
|
@@ -21112,20 +21170,20 @@ var WorkflowListCommand = {
|
|
|
21112
21170
|
if (total > workflows.length) {
|
|
21113
21171
|
const start = finalOffset + 1;
|
|
21114
21172
|
const end = finalOffset + workflows.length;
|
|
21115
|
-
output.log(
|
|
21173
|
+
output.log(chalk69.green(`
|
|
21116
21174
|
✅ 显示 ${start}-${end} / 共 ${total} 个 Workflow`));
|
|
21117
21175
|
const totalPages = Math.ceil(total / pageSize);
|
|
21118
21176
|
const currentPage = Math.floor(finalOffset / pageSize) + 1;
|
|
21119
21177
|
if (totalPages > 1) {
|
|
21120
|
-
output.log(
|
|
21178
|
+
output.log(chalk69.cyan(`\uD83D\uDCC4 第 ${currentPage} / ${totalPages} 页`));
|
|
21121
21179
|
}
|
|
21122
21180
|
} else {
|
|
21123
|
-
output.log(
|
|
21181
|
+
output.log(chalk69.green(`
|
|
21124
21182
|
✅ 共 ${total} 个 Workflow`));
|
|
21125
21183
|
}
|
|
21126
21184
|
if (availableTags.length > 0) {
|
|
21127
21185
|
const tagsLine = availableTags.map((t) => `${t.name}(${t.count})`).join(", ");
|
|
21128
|
-
output.log(
|
|
21186
|
+
output.log(chalk69.cyan(`
|
|
21129
21187
|
\uD83C\uDFF7️ Available tags: ${tagsLine}`));
|
|
21130
21188
|
}
|
|
21131
21189
|
}
|
|
@@ -21845,7 +21903,7 @@ class WorkflowValidator {
|
|
|
21845
21903
|
|
|
21846
21904
|
// src/commands/workflow/commands/add.ts
|
|
21847
21905
|
import { validateWorkflowDefinition } from "@ai-setting/roy-agent-core/env/workflow/utils";
|
|
21848
|
-
import
|
|
21906
|
+
import chalk70 from "chalk";
|
|
21849
21907
|
import fs3 from "fs";
|
|
21850
21908
|
import path6 from "path";
|
|
21851
21909
|
async function parseWorkflowContent(content, filename) {
|
|
@@ -21987,7 +22045,7 @@ var WorkflowAddCommand = {
|
|
|
21987
22045
|
definition = await parseWorkflowContent(content, filePath);
|
|
21988
22046
|
workflowName = a.name || definition.name || path6.basename(filePath);
|
|
21989
22047
|
if (a.validate) {
|
|
21990
|
-
output.log(
|
|
22048
|
+
output.log(chalk70.blue("\uD83D\uDD0D Validating workflow..."));
|
|
21991
22049
|
const dagResult = validateWorkflowDefinition(definition);
|
|
21992
22050
|
if (!dagResult.valid) {
|
|
21993
22051
|
output.error(`
|
|
@@ -22011,11 +22069,11 @@ var WorkflowAddCommand = {
|
|
|
22011
22069
|
});
|
|
22012
22070
|
process.exit(1);
|
|
22013
22071
|
}
|
|
22014
|
-
output.log(
|
|
22072
|
+
output.log(chalk70.green(`✅ Workflow validation passed
|
|
22015
22073
|
`));
|
|
22016
22074
|
}
|
|
22017
22075
|
} else if (a.desc) {
|
|
22018
|
-
output.log(
|
|
22076
|
+
output.log(chalk70.blue(`\uD83E\uDD16 Generating workflow from description...
|
|
22019
22077
|
`));
|
|
22020
22078
|
const agentComponent = env.getComponent("agent");
|
|
22021
22079
|
if (!agentComponent) {
|
|
@@ -22037,20 +22095,20 @@ ${a.desc}
|
|
|
22037
22095
|
1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
|
|
22038
22096
|
2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
|
|
22039
22097
|
3. 验证通过后才输出最终 YAML`;
|
|
22040
|
-
output.log(
|
|
22098
|
+
output.log(chalk70.gray("Running workflow-extract agent..."));
|
|
22041
22099
|
const result = await agentComponent.run("workflow-extract", prompt);
|
|
22042
22100
|
const agentOutput = result.finalText || "";
|
|
22043
22101
|
definition = parseYamlFromAgentOutput(agentOutput);
|
|
22044
22102
|
if (definition === null) {
|
|
22045
22103
|
output.error("Failed to parse workflow from agent output");
|
|
22046
|
-
output.log(
|
|
22104
|
+
output.log(chalk70.gray(`
|
|
22047
22105
|
Agent output:
|
|
22048
22106
|
` + agentOutput.slice(0, 500)));
|
|
22049
22107
|
process.exit(1);
|
|
22050
22108
|
}
|
|
22051
22109
|
workflowName = a.name || definition.name;
|
|
22052
22110
|
if (a.validate) {
|
|
22053
|
-
output.log(
|
|
22111
|
+
output.log(chalk70.blue(`
|
|
22054
22112
|
\uD83D\uDD0D Validating generated workflow...`));
|
|
22055
22113
|
const dagResult = validateWorkflowDefinition(definition);
|
|
22056
22114
|
if (!dagResult.valid) {
|
|
@@ -22059,7 +22117,7 @@ Agent output:
|
|
|
22059
22117
|
dagResult.errors.forEach((msg, i) => {
|
|
22060
22118
|
output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
|
|
22061
22119
|
});
|
|
22062
|
-
output.log(
|
|
22120
|
+
output.log(chalk70.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
22063
22121
|
process.exit(1);
|
|
22064
22122
|
}
|
|
22065
22123
|
const validator = new WorkflowValidator;
|
|
@@ -22074,16 +22132,16 @@ Agent output:
|
|
|
22074
22132
|
output.error(` Fix: ${error.fix}
|
|
22075
22133
|
`);
|
|
22076
22134
|
});
|
|
22077
|
-
output.log(
|
|
22135
|
+
output.log(chalk70.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
22078
22136
|
process.exit(1);
|
|
22079
22137
|
}
|
|
22080
|
-
output.log(
|
|
22138
|
+
output.log(chalk70.green(`✅ Generated workflow validation passed
|
|
22081
22139
|
`));
|
|
22082
22140
|
}
|
|
22083
22141
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
22084
|
-
output.log(
|
|
22142
|
+
output.log(chalk70.gray("--- Generated YAML ---"));
|
|
22085
22143
|
output.log(yaml.stringify(definition));
|
|
22086
|
-
output.log(
|
|
22144
|
+
output.log(chalk70.gray(`------------------------
|
|
22087
22145
|
`));
|
|
22088
22146
|
} else {
|
|
22089
22147
|
output.error("Please provide --file or --desc option");
|
|
@@ -22109,10 +22167,10 @@ Agent output:
|
|
|
22109
22167
|
force: a.force
|
|
22110
22168
|
});
|
|
22111
22169
|
output.log(renderWorkflowAdded(workflow));
|
|
22112
|
-
output.log(
|
|
22170
|
+
output.log(chalk70.bold(`
|
|
22113
22171
|
\uD83D\uDCCA Nodes Summary:`));
|
|
22114
22172
|
output.log(renderNodesList(definition.nodes));
|
|
22115
|
-
output.log(
|
|
22173
|
+
output.log(chalk70.green(`
|
|
22116
22174
|
✅ Workflow '${workflowName}' added successfully`));
|
|
22117
22175
|
} catch (error) {
|
|
22118
22176
|
if (error.message?.includes("already exists") && !a.force) {
|
|
@@ -22129,7 +22187,7 @@ Agent output:
|
|
|
22129
22187
|
};
|
|
22130
22188
|
|
|
22131
22189
|
// src/commands/workflow/commands/get.ts
|
|
22132
|
-
import
|
|
22190
|
+
import chalk71 from "chalk";
|
|
22133
22191
|
import { createWorkflowGetTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
22134
22192
|
var WorkflowGetCommand = {
|
|
22135
22193
|
command: "get <identifier>",
|
|
@@ -22267,15 +22325,15 @@ var WorkflowGetCommand = {
|
|
|
22267
22325
|
} else {
|
|
22268
22326
|
output.log(renderWorkflowDetail(workflow, { includeRuns: runs }));
|
|
22269
22327
|
if (args.includeNodes) {
|
|
22270
|
-
output.log(
|
|
22328
|
+
output.log(chalk71.bold(`
|
|
22271
22329
|
\uD83D\uDCCB All Nodes:`));
|
|
22272
22330
|
output.log(renderNodesList(data.nodes || []));
|
|
22273
22331
|
}
|
|
22274
22332
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
22275
22333
|
const defYaml = yaml.stringify(data.definition || {}, { indent: 2 });
|
|
22276
|
-
output.log(
|
|
22334
|
+
output.log(chalk71.bold(`
|
|
22277
22335
|
\uD83D\uDCC4 Definition (YAML):`));
|
|
22278
|
-
output.log(
|
|
22336
|
+
output.log(chalk71.gray(defYaml));
|
|
22279
22337
|
}
|
|
22280
22338
|
}
|
|
22281
22339
|
} catch (error) {
|
|
@@ -22288,7 +22346,7 @@ var WorkflowGetCommand = {
|
|
|
22288
22346
|
};
|
|
22289
22347
|
|
|
22290
22348
|
// src/commands/workflow/commands/update.ts
|
|
22291
|
-
import
|
|
22349
|
+
import chalk72 from "chalk";
|
|
22292
22350
|
import fs4 from "fs";
|
|
22293
22351
|
import path7 from "path";
|
|
22294
22352
|
import { parseWorkflowFile } from "@ai-setting/roy-agent-core/env/workflow/types";
|
|
@@ -22361,7 +22419,7 @@ var WorkflowUpdateCommand = {
|
|
|
22361
22419
|
const tags = a.tags ? a.tags.split(",").map((t) => t.trim()) : undefined;
|
|
22362
22420
|
const workflow = await service.updateWorkflow(a.name, updates, { tags });
|
|
22363
22421
|
output.log(renderWorkflowUpdated(workflow));
|
|
22364
|
-
output.log(
|
|
22422
|
+
output.log(chalk72.green(`
|
|
22365
22423
|
✅ Workflow '${a.name}' updated successfully`));
|
|
22366
22424
|
} catch (error) {
|
|
22367
22425
|
output.error(`Failed to update workflow: ${error}`);
|
|
@@ -22373,7 +22431,7 @@ var WorkflowUpdateCommand = {
|
|
|
22373
22431
|
};
|
|
22374
22432
|
|
|
22375
22433
|
// src/commands/workflow/commands/remove.ts
|
|
22376
|
-
import
|
|
22434
|
+
import chalk73 from "chalk";
|
|
22377
22435
|
var WorkflowRemoveCommand = {
|
|
22378
22436
|
command: "remove <name>",
|
|
22379
22437
|
describe: "删除 Workflow",
|
|
@@ -22412,8 +22470,8 @@ var WorkflowRemoveCommand = {
|
|
|
22412
22470
|
process.exit(1);
|
|
22413
22471
|
}
|
|
22414
22472
|
if (!args.force) {
|
|
22415
|
-
output.log(
|
|
22416
|
-
output.log(
|
|
22473
|
+
output.log(chalk73.yellow(`Are you sure you want to delete workflow '${args.name}'?`));
|
|
22474
|
+
output.log(chalk73.gray("Use --force to skip confirmation"));
|
|
22417
22475
|
process.exit(1);
|
|
22418
22476
|
}
|
|
22419
22477
|
const deleted = await service.deleteWorkflow(args.name);
|
|
@@ -22433,7 +22491,7 @@ var WorkflowRemoveCommand = {
|
|
|
22433
22491
|
|
|
22434
22492
|
// src/commands/workflow/commands/run.ts
|
|
22435
22493
|
var import_yaml = __toESM(require_dist(), 1);
|
|
22436
|
-
import
|
|
22494
|
+
import chalk74 from "chalk";
|
|
22437
22495
|
import fs5 from "fs";
|
|
22438
22496
|
import path8 from "path";
|
|
22439
22497
|
import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
@@ -22535,7 +22593,7 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22535
22593
|
}
|
|
22536
22594
|
if (args.session) {
|
|
22537
22595
|
const sessionId = args.session;
|
|
22538
|
-
output.log(
|
|
22596
|
+
output.log(chalk74.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
22539
22597
|
try {
|
|
22540
22598
|
const resumeInput = typeof input === "string" ? { userQuery: input } : input;
|
|
22541
22599
|
const result = await service.resumeSession(sessionId, {
|
|
@@ -22581,17 +22639,17 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22581
22639
|
definition = { ...definition, name: args.name };
|
|
22582
22640
|
}
|
|
22583
22641
|
const workflow = await service.createWorkflow(definition, { force: true });
|
|
22584
|
-
output.log(
|
|
22585
|
-
output.log(
|
|
22642
|
+
output.log(chalk74.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
|
|
22643
|
+
output.log(chalk74.green(`✅ Workflow registered: ${workflow.name} (${workflow.id})`));
|
|
22586
22644
|
if (args.registerOnly) {
|
|
22587
|
-
output.log(
|
|
22645
|
+
output.log(chalk74.gray("ℹ️ Use --register-only, skipping execution"));
|
|
22588
22646
|
if (workflowSpan) {
|
|
22589
22647
|
workflowSpan.end();
|
|
22590
22648
|
}
|
|
22591
22649
|
await envService.dispose();
|
|
22592
22650
|
process.exit(0);
|
|
22593
22651
|
}
|
|
22594
|
-
output.log(
|
|
22652
|
+
output.log(chalk74.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
|
|
22595
22653
|
const fileBranchInput = typeof input === "string" ? undefined : input;
|
|
22596
22654
|
const result = await service.runWorkflow(definition, fileBranchInput, runOptions);
|
|
22597
22655
|
output.log(renderRunResult({
|
|
@@ -22605,7 +22663,7 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22605
22663
|
...result.agentSessionId ? { agentSessionId: result.agentSessionId } : {}
|
|
22606
22664
|
}));
|
|
22607
22665
|
if (result.status === "paused") {
|
|
22608
|
-
output.log(
|
|
22666
|
+
output.log(chalk74.gray(`
|
|
22609
22667
|
\uD83D\uDCA1 Resume with: roy-agent workflow run ${result.runId} --session ${result.runId} --input "<your answer>"`));
|
|
22610
22668
|
}
|
|
22611
22669
|
} else {
|
|
@@ -22622,7 +22680,7 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22622
22680
|
output.error(toolResult.error || `Failed to run workflow: ${args.identifier}`);
|
|
22623
22681
|
if (runId) {
|
|
22624
22682
|
output.error(`Run ID: ${runId}`);
|
|
22625
|
-
output.error(
|
|
22683
|
+
output.error(chalk74.gray(`
|
|
22626
22684
|
\uD83D\uDCA1 Use "roy-agent workflow status ${runId}" to check progress, or "roy-agent workflow run ${args.identifier} --session ${runId}" to resume`));
|
|
22627
22685
|
}
|
|
22628
22686
|
process.exit(1);
|
|
@@ -22639,7 +22697,7 @@ var runWorkflow = wrapFunction2(async function runWorkflowImpl(args) {
|
|
|
22639
22697
|
...runData.agent_session_id ? { agentSessionId: runData.agent_session_id } : {}
|
|
22640
22698
|
}));
|
|
22641
22699
|
if (runData.status === "paused") {
|
|
22642
|
-
output.log(
|
|
22700
|
+
output.log(chalk74.gray(`
|
|
22643
22701
|
\uD83D\uDCA1 Resume with: roy-agent workflow run ${args.identifier} --session ${runData.run_id} --input "<your answer>"`));
|
|
22644
22702
|
}
|
|
22645
22703
|
}
|
|
@@ -22714,7 +22772,7 @@ var WorkflowRunCommand = {
|
|
|
22714
22772
|
};
|
|
22715
22773
|
|
|
22716
22774
|
// src/commands/workflow/commands/stop.ts
|
|
22717
|
-
import
|
|
22775
|
+
import chalk75 from "chalk";
|
|
22718
22776
|
import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
22719
22777
|
import { wrapFunction as wrapFunction3 } from "@ai-setting/roy-agent-core";
|
|
22720
22778
|
var stopWorkflow = wrapFunction3(async function stopWorkflowImpl(args) {
|
|
@@ -22739,7 +22797,7 @@ var stopWorkflow = wrapFunction3(async function stopWorkflowImpl(args) {
|
|
|
22739
22797
|
output.error(result.error || `Failed to stop workflow: ${args.runId}`);
|
|
22740
22798
|
process.exit(1);
|
|
22741
22799
|
}
|
|
22742
|
-
output.log(
|
|
22800
|
+
output.log(chalk75.red(`
|
|
22743
22801
|
⏹️ Workflow stopped: ${args.runId}`));
|
|
22744
22802
|
} catch (error) {
|
|
22745
22803
|
output.error(`Failed to stop workflow: ${error}`);
|
|
@@ -22763,7 +22821,7 @@ var WorkflowStopCommand = {
|
|
|
22763
22821
|
};
|
|
22764
22822
|
|
|
22765
22823
|
// src/commands/workflow/commands/status.ts
|
|
22766
|
-
import
|
|
22824
|
+
import chalk76 from "chalk";
|
|
22767
22825
|
import { createWorkflowRunStatusTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
22768
22826
|
var WorkflowStatusCommand = {
|
|
22769
22827
|
command: "status <runId>",
|
|
@@ -22856,7 +22914,7 @@ var WorkflowStatusCommand = {
|
|
|
22856
22914
|
stopped: "⏹️"
|
|
22857
22915
|
};
|
|
22858
22916
|
const emoji = statusEmoji[status] || "❓";
|
|
22859
|
-
output.log(
|
|
22917
|
+
output.log(chalk76.bold(`
|
|
22860
22918
|
${emoji} Status: ${status.toUpperCase()}`));
|
|
22861
22919
|
}
|
|
22862
22920
|
} catch (error) {
|
|
@@ -22869,7 +22927,7 @@ ${emoji} Status: ${status.toUpperCase()}`));
|
|
|
22869
22927
|
};
|
|
22870
22928
|
|
|
22871
22929
|
// src/commands/workflow/commands/nodes.ts
|
|
22872
|
-
import
|
|
22930
|
+
import chalk77 from "chalk";
|
|
22873
22931
|
var BUILT_IN_NODES = [
|
|
22874
22932
|
{
|
|
22875
22933
|
name: "ToolNode",
|
|
@@ -23206,7 +23264,7 @@ nodes:
|
|
|
23206
23264
|
];
|
|
23207
23265
|
function renderNodeTypesTable(nodes) {
|
|
23208
23266
|
const lines = [];
|
|
23209
|
-
lines.push(
|
|
23267
|
+
lines.push(chalk77.bold(`
|
|
23210
23268
|
\uD83D\uDCE6 Built-in Node Types
|
|
23211
23269
|
`));
|
|
23212
23270
|
lines.push("┌────────────┬────────────────────┬─────────────────────────────────────────────────────────────┐");
|
|
@@ -23224,29 +23282,29 @@ function renderNodeTypesTable(nodes) {
|
|
|
23224
23282
|
}
|
|
23225
23283
|
function renderNodeDetail(node) {
|
|
23226
23284
|
const lines = [];
|
|
23227
|
-
lines.push(
|
|
23285
|
+
lines.push(chalk77.bold(`
|
|
23228
23286
|
[${node.type}] ${node.name}`));
|
|
23229
|
-
lines.push(
|
|
23287
|
+
lines.push(chalk77.dim("─".repeat(60)) + `
|
|
23230
23288
|
`);
|
|
23231
|
-
lines.push(
|
|
23289
|
+
lines.push(chalk77.bold("Description:"));
|
|
23232
23290
|
lines.push(` ${node.description}
|
|
23233
23291
|
`);
|
|
23234
|
-
lines.push(
|
|
23292
|
+
lines.push(chalk77.bold("Configuration:"));
|
|
23235
23293
|
lines.push(' type: "' + node.type + '"');
|
|
23236
23294
|
lines.push(" config:");
|
|
23237
23295
|
for (const input of node.inputs) {
|
|
23238
|
-
const required = input.required ?
|
|
23296
|
+
const required = input.required ? chalk77.red("*") : " ";
|
|
23239
23297
|
lines.push(` ${input.name} (${input.type})${required}`);
|
|
23240
23298
|
lines.push(` ${input.description}`);
|
|
23241
23299
|
}
|
|
23242
23300
|
lines.push(`
|
|
23243
|
-
${
|
|
23301
|
+
${chalk77.bold("Output:")} ${node.output}`);
|
|
23244
23302
|
if (node.example) {
|
|
23245
|
-
lines.push(
|
|
23303
|
+
lines.push(chalk77.bold(`
|
|
23246
23304
|
Example:`));
|
|
23247
|
-
lines.push(
|
|
23305
|
+
lines.push(chalk77.gray("```yaml"));
|
|
23248
23306
|
lines.push(node.example);
|
|
23249
|
-
lines.push(
|
|
23307
|
+
lines.push(chalk77.gray("```"));
|
|
23250
23308
|
}
|
|
23251
23309
|
return lines.join(`
|
|
23252
23310
|
`);
|
|
@@ -23262,16 +23320,16 @@ var WorkflowNodesCommand = {
|
|
|
23262
23320
|
const nodeType = args.type?.toLowerCase();
|
|
23263
23321
|
if (!nodeType) {
|
|
23264
23322
|
console.log(renderNodeTypesTable(BUILT_IN_NODES));
|
|
23265
|
-
console.log(
|
|
23266
|
-
Use `) +
|
|
23267
|
-
console.log(
|
|
23323
|
+
console.log(chalk77.gray(`
|
|
23324
|
+
Use `) + chalk77.cyan("roy-agent workflow nodes <type>") + chalk77.gray(" for detailed information"));
|
|
23325
|
+
console.log(chalk77.gray("Available types: ") + chalk77.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
23268
23326
|
return;
|
|
23269
23327
|
}
|
|
23270
23328
|
const node = BUILT_IN_NODES.find((n) => n.type === nodeType);
|
|
23271
23329
|
if (!node) {
|
|
23272
|
-
console.log(
|
|
23330
|
+
console.log(chalk77.red(`
|
|
23273
23331
|
❌ Unknown node type: ${nodeType}`));
|
|
23274
|
-
console.log(
|
|
23332
|
+
console.log(chalk77.gray("Available types: ") + chalk77.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
23275
23333
|
process.exit(1);
|
|
23276
23334
|
}
|
|
23277
23335
|
console.log(renderNodeDetail(node));
|
|
@@ -23279,7 +23337,7 @@ Use `) + chalk76.cyan("roy-agent workflow nodes <type>") + chalk76.gray(" for de
|
|
|
23279
23337
|
};
|
|
23280
23338
|
|
|
23281
23339
|
// src/commands/workflow/commands/validate.ts
|
|
23282
|
-
import
|
|
23340
|
+
import chalk78 from "chalk";
|
|
23283
23341
|
import { readFileSync as readFileSync2 } from "fs";
|
|
23284
23342
|
async function parseWorkflowInput(input, yamlStr) {
|
|
23285
23343
|
const parseYaml = async (content) => {
|
|
@@ -23312,25 +23370,25 @@ function renderResult(result, options) {
|
|
|
23312
23370
|
return;
|
|
23313
23371
|
}
|
|
23314
23372
|
if (result.valid) {
|
|
23315
|
-
console.log(
|
|
23373
|
+
console.log(chalk78.green(`
|
|
23316
23374
|
✅ Workflow validation PASSED
|
|
23317
23375
|
`));
|
|
23318
|
-
console.log(
|
|
23376
|
+
console.log(chalk78.bold(`Workflow: ${result.workflowName}`));
|
|
23319
23377
|
console.log(`Nodes: ${result.nodeCount}`);
|
|
23320
23378
|
console.log(`
|
|
23321
23379
|
Valid nodes:`);
|
|
23322
|
-
console.log(
|
|
23380
|
+
console.log(chalk78.green(" ✓ All nodes passed validation"));
|
|
23323
23381
|
} else {
|
|
23324
|
-
console.log(
|
|
23382
|
+
console.log(chalk78.red(`
|
|
23325
23383
|
❌ Workflow validation FAILED (${result.errors.length} errors found)
|
|
23326
23384
|
`));
|
|
23327
23385
|
result.errors.forEach((error, index) => {
|
|
23328
|
-
console.log(
|
|
23329
|
-
console.log(` ${
|
|
23330
|
-
console.log(` ${
|
|
23331
|
-
console.log(` ${
|
|
23332
|
-
console.log(` ${
|
|
23333
|
-
console.log(` ${
|
|
23386
|
+
console.log(chalk78.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
|
|
23387
|
+
console.log(` ${chalk78.bold("Type:")} ${error.type}`);
|
|
23388
|
+
console.log(` ${chalk78.bold("Description:")} ${error.description}`);
|
|
23389
|
+
console.log(` ${chalk78.bold("Expected:")} ${error.expected}`);
|
|
23390
|
+
console.log(` ${chalk78.bold("Actual:")} ${error.actual}`);
|
|
23391
|
+
console.log(` ${chalk78.green("Fix:")} ${error.fix}`);
|
|
23334
23392
|
console.log();
|
|
23335
23393
|
});
|
|
23336
23394
|
}
|
|
@@ -23355,7 +23413,7 @@ var WorkflowValidateCommand = {
|
|
|
23355
23413
|
try {
|
|
23356
23414
|
const workflow = await parseWorkflowInput(options.input, options.yaml);
|
|
23357
23415
|
if (!workflow) {
|
|
23358
|
-
console.error(
|
|
23416
|
+
console.error(chalk78.red("Failed to parse workflow input"));
|
|
23359
23417
|
process.exit(1);
|
|
23360
23418
|
}
|
|
23361
23419
|
const validator = new WorkflowValidator;
|
|
@@ -23363,7 +23421,7 @@ var WorkflowValidateCommand = {
|
|
|
23363
23421
|
renderResult(result, options);
|
|
23364
23422
|
process.exit(result.valid ? 0 : 1);
|
|
23365
23423
|
} catch (error) {
|
|
23366
|
-
console.error(
|
|
23424
|
+
console.error(chalk78.red(`
|
|
23367
23425
|
Error: ${error.message}`));
|
|
23368
23426
|
process.exit(1);
|
|
23369
23427
|
}
|
|
@@ -23371,7 +23429,7 @@ Error: ${error.message}`));
|
|
|
23371
23429
|
};
|
|
23372
23430
|
|
|
23373
23431
|
// src/commands/workflow/commands/search.ts
|
|
23374
|
-
import
|
|
23432
|
+
import chalk79 from "chalk";
|
|
23375
23433
|
import { wrapFunction as wrapFunction4 } from "@ai-setting/roy-agent-core";
|
|
23376
23434
|
var WorkflowSearchCommand = {
|
|
23377
23435
|
command: "search",
|
|
@@ -23528,22 +23586,22 @@ var _runWorkflowSearchImpl = async function(opts) {
|
|
|
23528
23586
|
metadata: {}
|
|
23529
23587
|
}));
|
|
23530
23588
|
if (renderWorkflows.length === 0) {
|
|
23531
|
-
output.log(
|
|
23532
|
-
output.log(
|
|
23533
|
-
output.log(
|
|
23589
|
+
output.log(chalk79.yellow("\uD83D\uDD0D No workflows matched the search criteria."));
|
|
23590
|
+
output.log(chalk79.gray(` keyword: ${keyword || "(none)"}`));
|
|
23591
|
+
output.log(chalk79.gray(` tags: ${tags && tags.length > 0 ? tags.join(", ") : "(none)"}`));
|
|
23534
23592
|
} else {
|
|
23535
|
-
output.log(
|
|
23593
|
+
output.log(chalk79.bold(`\uD83D\uDD0D Search results (${renderWorkflows.length}):`));
|
|
23536
23594
|
output.log(renderWorkflowList(renderWorkflows));
|
|
23537
|
-
output.log(
|
|
23595
|
+
output.log(chalk79.green(`
|
|
23538
23596
|
✅ Found ${renderWorkflows.length} workflow(s)`));
|
|
23539
23597
|
}
|
|
23540
23598
|
if (availableTags.length > 0) {
|
|
23541
23599
|
output.log("");
|
|
23542
|
-
output.log(
|
|
23600
|
+
output.log(chalk79.bold("\uD83D\uDCDA Available tags (sorted by usage_count):"));
|
|
23543
23601
|
for (const t of availableTags) {
|
|
23544
23602
|
const name = t.name ?? t.tag;
|
|
23545
23603
|
const count = t.count ?? t.usage_count;
|
|
23546
|
-
output.log(
|
|
23604
|
+
output.log(chalk79.gray(` - ${name} (${count})`));
|
|
23547
23605
|
}
|
|
23548
23606
|
}
|
|
23549
23607
|
};
|
|
@@ -23555,7 +23613,7 @@ var runWorkflowSearch = wrapFunction4(_runWorkflowSearchImpl, "workflow.cli.sear
|
|
|
23555
23613
|
|
|
23556
23614
|
// src/commands/workflow/commands/tag.ts
|
|
23557
23615
|
import { wrapFunction as wrapFunction5 } from "@ai-setting/roy-agent-core";
|
|
23558
|
-
import
|
|
23616
|
+
import chalk80 from "chalk";
|
|
23559
23617
|
var WorkflowTagListCommand = {
|
|
23560
23618
|
command: "list",
|
|
23561
23619
|
describe: "List all workflow tags from the workflow_tags table (sorted by usage_count DESC by default). Use this BEFORE `workflow add` to discover existing tags and reuse them for semantic consistency.",
|
|
@@ -23676,17 +23734,17 @@ var _runWorkflowTagListImpl = async function(opts) {
|
|
|
23676
23734
|
return;
|
|
23677
23735
|
}
|
|
23678
23736
|
if (result.tags.length === 0) {
|
|
23679
|
-
output.log(
|
|
23680
|
-
output.log(
|
|
23737
|
+
output.log(chalk80.yellow("\uD83C\uDFF7️ No tags in the workflow_tags table yet."));
|
|
23738
|
+
output.log(chalk80.gray(" Tags are created automatically when you run `workflow add --tags <name>`."));
|
|
23681
23739
|
return;
|
|
23682
23740
|
}
|
|
23683
|
-
output.log(
|
|
23684
|
-
output.log(
|
|
23741
|
+
output.log(chalk80.bold(`\uD83C\uDFF7️ Workflow tags (${result.total}):`));
|
|
23742
|
+
output.log(chalk80.gray(` ${padRight("NAME", 24)}${padRight("USAGE", 8)}${padRight("CREATED", 22)}`));
|
|
23685
23743
|
for (const t of result.tags) {
|
|
23686
23744
|
const line = ` ${padRight(t.name, 24)}${padRight(String(t.usage_count), 8)}${padRight(formatDate2(t.created_at), 22)}`;
|
|
23687
23745
|
output.log(line);
|
|
23688
23746
|
}
|
|
23689
|
-
output.log(
|
|
23747
|
+
output.log(chalk80.gray(`
|
|
23690
23748
|
\uD83D\uDCA1 Tip: when adding a new workflow, prefer tags from this list to ensure semantic consistency.`));
|
|
23691
23749
|
};
|
|
23692
23750
|
var _runWorkflowTagGetImpl = async function(opts) {
|
|
@@ -23713,7 +23771,7 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
23713
23771
|
output.json({ error: "Tag not found", name: opts.name });
|
|
23714
23772
|
} else {
|
|
23715
23773
|
output.error(`Tag "${opts.name}" not found in the workflow_tags table.`);
|
|
23716
|
-
output.log(
|
|
23774
|
+
output.log(chalk80.gray(`Tip: run \`roy-agent workflow tag list\` to see available tags.`));
|
|
23717
23775
|
}
|
|
23718
23776
|
process.exitCode = 1;
|
|
23719
23777
|
return;
|
|
@@ -23722,10 +23780,10 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
23722
23780
|
output.json(tag);
|
|
23723
23781
|
return;
|
|
23724
23782
|
}
|
|
23725
|
-
output.log(
|
|
23726
|
-
output.log(
|
|
23727
|
-
output.log(
|
|
23728
|
-
output.log(
|
|
23783
|
+
output.log(chalk80.bold(`\uD83C\uDFF7️ Tag: ${tag.name}`));
|
|
23784
|
+
output.log(chalk80.gray(` usage_count: ${tag.usage_count}`));
|
|
23785
|
+
output.log(chalk80.gray(` created_at: ${tag.created_at}`));
|
|
23786
|
+
output.log(chalk80.gray(` updated_at: ${tag.updated_at}`));
|
|
23729
23787
|
};
|
|
23730
23788
|
async function callListTags(service, options) {
|
|
23731
23789
|
if (typeof service.listTags !== "function") {
|