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