@ai-setting/roy-agent-cli 1.4.6 → 1.4.8
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/index.js +666 -528
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -7219,7 +7219,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7219
7219
|
var require_package = __commonJS((exports, module) => {
|
|
7220
7220
|
module.exports = {
|
|
7221
7221
|
name: "@ai-setting/roy-agent-cli",
|
|
7222
|
-
version: "1.4.
|
|
7222
|
+
version: "1.4.8",
|
|
7223
7223
|
type: "module",
|
|
7224
7224
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7225
7225
|
main: "./dist/index.js",
|
|
@@ -8460,7 +8460,7 @@ var ActCommand = {
|
|
|
8460
8460
|
|
|
8461
8461
|
// packages/cli/src/commands/interactive.ts
|
|
8462
8462
|
import * as readline from "readline";
|
|
8463
|
-
import
|
|
8463
|
+
import chalk4 from "chalk";
|
|
8464
8464
|
|
|
8465
8465
|
// packages/cli/src/commands/shared/session-manager.ts
|
|
8466
8466
|
class SessionManager {
|
|
@@ -8964,7 +8964,65 @@ class InputHandler {
|
|
|
8964
8964
|
}
|
|
8965
8965
|
}
|
|
8966
8966
|
|
|
8967
|
+
// packages/cli/src/commands/shared/ask-user-handler.ts
|
|
8968
|
+
import chalk3 from "chalk";
|
|
8969
|
+
function parseOptionsFromQuery(query) {
|
|
8970
|
+
const optionsMatch = query.match(/\(\u9009\u9879:\s*(.+)\)/);
|
|
8971
|
+
if (optionsMatch) {
|
|
8972
|
+
const optionsStr = optionsMatch[1];
|
|
8973
|
+
const options = optionsStr.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
|
|
8974
|
+
const question = query.replace(/\s*\(\u9009\u9879:.+\)/, "").trim();
|
|
8975
|
+
return { question, options };
|
|
8976
|
+
}
|
|
8977
|
+
return { question: query };
|
|
8978
|
+
}
|
|
8979
|
+
function formatAskUserOutput(errorInfo) {
|
|
8980
|
+
const parts = [];
|
|
8981
|
+
parts.push(chalk3.bold(`
|
|
8982
|
+
\uD83E\uDD14 ` + chalk3.cyan("\u9700\u8981\u60A8\u7684\u8F93\u5165")) + `
|
|
8983
|
+
`);
|
|
8984
|
+
const { question, options } = parseOptionsFromQuery(errorInfo.query);
|
|
8985
|
+
parts.push(chalk3.white(question) + `
|
|
8986
|
+
`);
|
|
8987
|
+
if (options && options.length > 0) {
|
|
8988
|
+
parts.push(`
|
|
8989
|
+
` + chalk3.bold("\u8BF7\u9009\u62E9\uFF1A") + `
|
|
8990
|
+
`);
|
|
8991
|
+
options.forEach((opt, i) => {
|
|
8992
|
+
parts.push(chalk3.cyan(` ${i + 1}. `) + chalk3.white(opt));
|
|
8993
|
+
});
|
|
8994
|
+
parts.push("");
|
|
8995
|
+
}
|
|
8996
|
+
if (errorInfo.requiredConfirm) {
|
|
8997
|
+
parts.push(chalk3.yellow(`\u26A0\uFE0F \u6B64\u64CD\u4F5C\u9700\u8981\u786E\u8BA4\uFF0C\u8BF7\u4ED4\u7EC6\u9605\u8BFB\u540E\u518D\u505A\u51B3\u5B9A
|
|
8998
|
+
`));
|
|
8999
|
+
}
|
|
9000
|
+
parts.push(chalk3.dim(`\u8BF7\u8F93\u5165\u60A8\u7684\u56DE\u7B54\uFF0C\u6216\u6309 Ctrl+C \u9000\u51FA
|
|
9001
|
+
`));
|
|
9002
|
+
return parts.join(`
|
|
9003
|
+
`);
|
|
9004
|
+
}
|
|
9005
|
+
function parseUserInput(input, options) {
|
|
9006
|
+
const trimmedInput = input.trim();
|
|
9007
|
+
if (options && options.length > 0) {
|
|
9008
|
+
const index = parseInt(trimmedInput, 10) - 1;
|
|
9009
|
+
if (!isNaN(index) && index >= 0 && index < options.length) {
|
|
9010
|
+
return { type: "option", value: index };
|
|
9011
|
+
}
|
|
9012
|
+
const exactMatch = options.findIndex((opt) => opt.toLowerCase() === trimmedInput.toLowerCase());
|
|
9013
|
+
if (exactMatch >= 0) {
|
|
9014
|
+
return { type: "option", value: exactMatch };
|
|
9015
|
+
}
|
|
9016
|
+
const prefixMatch = options.findIndex((opt) => opt.toLowerCase().startsWith(trimmedInput.toLowerCase()));
|
|
9017
|
+
if (prefixMatch >= 0) {
|
|
9018
|
+
return { type: "option", value: prefixMatch };
|
|
9019
|
+
}
|
|
9020
|
+
}
|
|
9021
|
+
return { type: "text", value: trimmedInput };
|
|
9022
|
+
}
|
|
9023
|
+
|
|
8967
9024
|
// packages/cli/src/commands/interactive.ts
|
|
9025
|
+
import { AskUserError } from "@ai-setting/roy-agent-core";
|
|
8968
9026
|
var logger4 = createLogger4("cli:interactive");
|
|
8969
9027
|
var USER_PROMPT = COLORS.userInput("\u276F ");
|
|
8970
9028
|
|
|
@@ -9152,10 +9210,15 @@ ${COLORS.system("[\u901A\u77E5] \u276F " + message.replace(/\n/g, `
|
|
|
9152
9210
|
try {
|
|
9153
9211
|
await this.options.onExecute(message, traceId);
|
|
9154
9212
|
} catch (error) {
|
|
9155
|
-
|
|
9213
|
+
const askUserError = this.parseAskUserError(error);
|
|
9214
|
+
if (askUserError) {
|
|
9215
|
+
await this.handleAskUserInteraction(askUserError);
|
|
9216
|
+
} else {
|
|
9217
|
+
console.error(`
|
|
9156
9218
|
${COLORS.error("\u274C \u6267\u884C\u5931\u8D25: " + error)}
|
|
9157
9219
|
`);
|
|
9158
|
-
|
|
9220
|
+
rootSpan.setAttribute("error", String(error));
|
|
9221
|
+
}
|
|
9159
9222
|
} finally {
|
|
9160
9223
|
provider.setGlobalContext(undefined);
|
|
9161
9224
|
rootSpan.end();
|
|
@@ -9165,6 +9228,81 @@ ${COLORS.error("\u274C \u6267\u884C\u5931\u8D25: " + error)}
|
|
|
9165
9228
|
}
|
|
9166
9229
|
}
|
|
9167
9230
|
}
|
|
9231
|
+
parseAskUserError(error) {
|
|
9232
|
+
if (error instanceof AskUserError) {
|
|
9233
|
+
return {
|
|
9234
|
+
query: error.query,
|
|
9235
|
+
sessionId: error.sessionId,
|
|
9236
|
+
agentSessionId: error.agentSessionId,
|
|
9237
|
+
nodeId: error.nodeId,
|
|
9238
|
+
nodeType: error.nodeType
|
|
9239
|
+
};
|
|
9240
|
+
}
|
|
9241
|
+
if (error instanceof Error && error.name === "AskUserError") {
|
|
9242
|
+
const askError = error;
|
|
9243
|
+
return {
|
|
9244
|
+
query: askError.query,
|
|
9245
|
+
sessionId: askError.sessionId,
|
|
9246
|
+
agentSessionId: askError.agentSessionId,
|
|
9247
|
+
nodeId: askError.nodeId,
|
|
9248
|
+
nodeType: askError.nodeType
|
|
9249
|
+
};
|
|
9250
|
+
}
|
|
9251
|
+
if (error instanceof Error) {
|
|
9252
|
+
const errorStr = error.message;
|
|
9253
|
+
const prefix = "__ASK_USER_ERROR__:";
|
|
9254
|
+
if (errorStr.includes(prefix)) {
|
|
9255
|
+
try {
|
|
9256
|
+
const jsonPart = errorStr.substring(errorStr.indexOf(prefix) + prefix.length);
|
|
9257
|
+
const parsed = JSON.parse(jsonPart);
|
|
9258
|
+
return {
|
|
9259
|
+
query: parsed.query,
|
|
9260
|
+
sessionId: parsed.sessionId,
|
|
9261
|
+
agentSessionId: parsed.agentSessionId,
|
|
9262
|
+
nodeId: parsed.nodeId,
|
|
9263
|
+
nodeType: parsed.nodeType
|
|
9264
|
+
};
|
|
9265
|
+
} catch {}
|
|
9266
|
+
}
|
|
9267
|
+
}
|
|
9268
|
+
return null;
|
|
9269
|
+
}
|
|
9270
|
+
async handleAskUserInteraction(errorInfo) {
|
|
9271
|
+
const { question, options } = parseOptionsFromQuery(errorInfo.query);
|
|
9272
|
+
console.log(formatAskUserOutput({ ...errorInfo, query: question, options }));
|
|
9273
|
+
const userResponse = await this.promptUser(question, options);
|
|
9274
|
+
console.log(COLORS.userInput(`\u276F ${userResponse.replace(/\n/g, `
|
|
9275
|
+
` + COLORS.userInput("\u276F "))}`));
|
|
9276
|
+
await this.executeInternal(userResponse, { showPrompt: false });
|
|
9277
|
+
}
|
|
9278
|
+
promptUser(question, options) {
|
|
9279
|
+
return new Promise((resolve) => {
|
|
9280
|
+
this.rl.setPrompt(COLORS.userInput("\u276F "));
|
|
9281
|
+
this.rl.prompt(true);
|
|
9282
|
+
const handleLine = (input) => {
|
|
9283
|
+
this.rl.removeListener("line", handleLine);
|
|
9284
|
+
const trimmedInput = input.trim();
|
|
9285
|
+
if (!trimmedInput) {
|
|
9286
|
+
console.log(chalk4.yellow(`\u26A0\uFE0F \u8F93\u5165\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165
|
|
9287
|
+
`));
|
|
9288
|
+
this.promptUser(question, options).then(resolve);
|
|
9289
|
+
return;
|
|
9290
|
+
}
|
|
9291
|
+
const parsed = parseUserInput(trimmedInput, options);
|
|
9292
|
+
if (parsed.type === "option" && options) {
|
|
9293
|
+
const selectedOption = options[parsed.value];
|
|
9294
|
+
console.log(chalk4.green(`\u2713 \u60A8\u9009\u62E9\u4E86: ${selectedOption}
|
|
9295
|
+
`));
|
|
9296
|
+
resolve(selectedOption);
|
|
9297
|
+
} else {
|
|
9298
|
+
console.log(chalk4.green(`\u2713 \u60A8\u7684\u56DE\u7B54: ${parsed.value}
|
|
9299
|
+
`));
|
|
9300
|
+
resolve(parsed.value);
|
|
9301
|
+
}
|
|
9302
|
+
};
|
|
9303
|
+
this.rl.on("line", handleLine);
|
|
9304
|
+
});
|
|
9305
|
+
}
|
|
9168
9306
|
handleSigint() {
|
|
9169
9307
|
if (this.isShuttingDown) {
|
|
9170
9308
|
return;
|
|
@@ -9208,61 +9346,61 @@ ${COLORS.error("\u274C \u6267\u884C\u5931\u8D25: " + error)}
|
|
|
9208
9346
|
}
|
|
9209
9347
|
}
|
|
9210
9348
|
printHeader() {
|
|
9211
|
-
console.log(
|
|
9349
|
+
console.log(chalk4.bold(`
|
|
9212
9350
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557`));
|
|
9213
|
-
console.log(
|
|
9214
|
-
console.log(
|
|
9351
|
+
console.log(chalk4.bold("\u2551 ") + chalk4.green.bold("roy-agent") + chalk4.bold(" Interactive Mode") + chalk4.bold(" \u2551"));
|
|
9352
|
+
console.log(chalk4.bold(`\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
9215
9353
|
`));
|
|
9216
|
-
console.log(`${
|
|
9217
|
-
console.log(`${
|
|
9354
|
+
console.log(`${chalk4.dim("\u4F1A\u8BDD:")} ${this.options.sessionTitle}`);
|
|
9355
|
+
console.log(`${chalk4.dim("\u8F93\u5165 ")} ${COLORS.userInput("/help")} ${chalk4.dim("\u67E5\u770B\u53EF\u7528\u547D\u4EE4")}
|
|
9218
9356
|
`);
|
|
9219
9357
|
}
|
|
9220
9358
|
printHelp() {
|
|
9221
9359
|
console.log(`
|
|
9222
|
-
${
|
|
9223
|
-
${
|
|
9224
|
-
${
|
|
9225
|
-
${
|
|
9226
|
-
${
|
|
9227
|
-
${
|
|
9228
|
-
${
|
|
9229
|
-
${
|
|
9230
|
-
${
|
|
9231
|
-
${
|
|
9232
|
-
${
|
|
9233
|
-
${
|
|
9234
|
-
${
|
|
9235
|
-
${
|
|
9236
|
-
${
|
|
9237
|
-
${
|
|
9360
|
+
${chalk4.bold("\u256D")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u256E")}
|
|
9361
|
+
${chalk4.bold("\u2502")} ${chalk4.bold("\u5FEB\u6377\u547D\u4EE4")} ${chalk4.bold("\u2502")}
|
|
9362
|
+
${chalk4.bold("\u251C")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u251C")}
|
|
9363
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("/help")}, ${COLORS.userInput("/h")} \u663E\u793A\u5E2E\u52A9 ${chalk4.bold("\u2502")}
|
|
9364
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("/status")}, ${COLORS.userInput("/st")} \u663E\u793A\u72B6\u6001 ${chalk4.bold("\u2502")}
|
|
9365
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("/sessions")}, ${COLORS.userInput("/s")} \u5207\u6362\u4F1A\u8BDD ${chalk4.bold("\u2502")}
|
|
9366
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("/compact")}, ${COLORS.userInput("/c")} \u538B\u7F29\u4E0A\u4E0B\u6587 ${chalk4.bold("\u2502")}
|
|
9367
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("/abort")} \u4E2D\u65AD\u5F53\u524D\u6D41\u5F0F\u8F93\u51FA ${chalk4.bold("\u2502")}
|
|
9368
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("/clear")}, ${COLORS.userInput("/cls")} \u6E05\u5C4F ${chalk4.bold("\u2502")}
|
|
9369
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("/exit")}, ${COLORS.userInput("/q")} \u9000\u51FA ${chalk4.bold("\u2502")}
|
|
9370
|
+
${chalk4.bold("\u251C")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u251C")}
|
|
9371
|
+
${chalk4.bold("\u2502")} ${chalk4.bold("\u591A\u884C\u8F93\u5165")} ${chalk4.bold("\u2502")}
|
|
9372
|
+
${chalk4.bold("\u251C")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u251C")}
|
|
9373
|
+
${chalk4.bold("\u2502")} \u8F93\u5165\u591A\u884C\u5185\u5BB9\u540E\uFF0CAlt+Enter \u7ED3\u675F\u8F93\u5165\u3002 ${chalk4.bold("\u2502")}
|
|
9374
|
+
${chalk4.bold("\u2502")} Ctrl+C \u53EF\u53D6\u6D88\u591A\u884C\u8F93\u5165\u3002 ${chalk4.bold("\u2502")}
|
|
9375
|
+
${chalk4.bold("\u2570")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u256F")}
|
|
9238
9376
|
`);
|
|
9239
9377
|
}
|
|
9240
9378
|
async printStatus() {
|
|
9241
9379
|
const status = await this.options.onStatus();
|
|
9242
9380
|
console.log(`
|
|
9243
|
-
${
|
|
9244
|
-
${
|
|
9245
|
-
${
|
|
9246
|
-
${
|
|
9247
|
-
${
|
|
9248
|
-
${
|
|
9249
|
-
${
|
|
9250
|
-
${
|
|
9381
|
+
${chalk4.bold("\u256D")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u256E")}
|
|
9382
|
+
${chalk4.bold("\u2502")} ${chalk4.bold("\u4F1A\u8BDD\u72B6\u6001")} ${chalk4.bold("\u2502")}
|
|
9383
|
+
${chalk4.bold("\u251C")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u251C")}
|
|
9384
|
+
${chalk4.bold("\u2502")} ${chalk4.dim("\u4F1A\u8BDD:")} ${status.sessionTitle.padEnd(35)} ${chalk4.bold("\u2502")}
|
|
9385
|
+
${chalk4.bold("\u2502")} ${chalk4.dim("ID:")} ${status.sessionId.padEnd(37)} ${chalk4.bold("\u2502")}
|
|
9386
|
+
${chalk4.bold("\u2502")} ${chalk4.dim("\u6D88\u606F:")} ${String(status.messageCount).padEnd(34)} ${chalk4.bold("\u2502")}
|
|
9387
|
+
${chalk4.bold("\u2502")} ${chalk4.dim("Token:")} ${String(status.tokenCount).padEnd(33)} ${chalk4.bold("\u2502")}
|
|
9388
|
+
${chalk4.bold("\u2570")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u256F")}
|
|
9251
9389
|
`);
|
|
9252
9390
|
}
|
|
9253
9391
|
printSessionsHelp() {
|
|
9254
9392
|
console.log(`
|
|
9255
|
-
${
|
|
9256
|
-
${
|
|
9257
|
-
${
|
|
9258
|
-
${
|
|
9259
|
-
${
|
|
9260
|
-
${
|
|
9261
|
-
${
|
|
9262
|
-
${
|
|
9263
|
-
${
|
|
9264
|
-
${
|
|
9265
|
-
${
|
|
9393
|
+
${chalk4.bold("\u256D")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u256E")}
|
|
9394
|
+
${chalk4.bold("\u2502")} ${chalk4.bold("\u5207\u6362\u4F1A\u8BDD")} ${chalk4.bold("\u2502")}
|
|
9395
|
+
${chalk4.bold("\u251C")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u251C")}
|
|
9396
|
+
${chalk4.bold("\u2502")} \u9000\u51FA\u5F53\u524D\u4EA4\u4E92\u6A21\u5F0F\u540E\uFF0C\u4F7F\u7528\u4EE5\u4E0B\u547D\u4EE4\u5207\u6362\u4F1A\u8BDD\uFF1A ${chalk4.bold("\u2502")}
|
|
9397
|
+
${chalk4.bold("\u2502")} ${chalk4.bold("\u2502")}
|
|
9398
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("roy-agent sessions list")} \u5217\u51FA\u6240\u6709\u4F1A\u8BDD ${chalk4.bold("\u2502")}
|
|
9399
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("roy-agent sessions use <id>")} \u5207\u6362\u5230\u6307\u5B9A\u4F1A\u8BDD ${chalk4.bold("\u2502")}
|
|
9400
|
+
${chalk4.bold("\u2502")} ${chalk4.bold("\u2502")}
|
|
9401
|
+
${chalk4.bold("\u2502")} \u6216\u76F4\u63A5\u6307\u5B9A\u4F1A\u8BDD\u542F\u52A8\uFF1A ${chalk4.bold("\u2502")}
|
|
9402
|
+
${chalk4.bold("\u2502")} ${COLORS.userInput("roy-agent interactive -s <session-id>")} ${chalk4.bold("\u2502")}
|
|
9403
|
+
${chalk4.bold("\u2570")}${chalk4.dim("\u2500".repeat(49))}${chalk4.bold("\u256F")}
|
|
9266
9404
|
`);
|
|
9267
9405
|
}
|
|
9268
9406
|
}
|
|
@@ -9619,7 +9757,7 @@ var InteractiveCommand = {
|
|
|
9619
9757
|
};
|
|
9620
9758
|
|
|
9621
9759
|
// packages/cli/src/commands/sessions/list.ts
|
|
9622
|
-
import
|
|
9760
|
+
import chalk5 from "chalk";
|
|
9623
9761
|
var ListCommand = {
|
|
9624
9762
|
command: "list [options]",
|
|
9625
9763
|
aliases: ["ls"],
|
|
@@ -9693,15 +9831,15 @@ var ListCommand = {
|
|
|
9693
9831
|
const hasTypeFilter = !!args.type;
|
|
9694
9832
|
const hasStatusFilter = !!args.status;
|
|
9695
9833
|
const header = [
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
hasTypeFilter || hasStatusFilter ?
|
|
9700
|
-
|
|
9701
|
-
|
|
9834
|
+
chalk5.bold("#"),
|
|
9835
|
+
chalk5.bold("Title"),
|
|
9836
|
+
chalk5.bold("ID"),
|
|
9837
|
+
hasTypeFilter || hasStatusFilter ? chalk5.bold("Status") : null,
|
|
9838
|
+
chalk5.bold("Msgs"),
|
|
9839
|
+
chalk5.bold("CP")
|
|
9702
9840
|
].filter(Boolean).join(" \u2502 ");
|
|
9703
9841
|
const rows = sessions.map((s, i) => {
|
|
9704
|
-
const marker = s.id === activeSessionId ?
|
|
9842
|
+
const marker = s.id === activeSessionId ? chalk5.green("\u25B6") : " ";
|
|
9705
9843
|
const hasCp = (s.metadata?.checkpoints?.checkpoints?.length ?? 0) > 0;
|
|
9706
9844
|
const title = s.title.length > 20 ? s.title.slice(0, 17) + "..." : s.title;
|
|
9707
9845
|
const idStr = s.id;
|
|
@@ -9711,18 +9849,18 @@ var ListCommand = {
|
|
|
9711
9849
|
let statusDisplay = "";
|
|
9712
9850
|
if (hasTypeFilter || hasStatusFilter) {
|
|
9713
9851
|
if (workflowMeta) {
|
|
9714
|
-
statusDisplay = workflowMeta.status === "running" ?
|
|
9852
|
+
statusDisplay = workflowMeta.status === "running" ? chalk5.green("running") : workflowMeta.status === "paused" ? chalk5.yellow("paused") : workflowMeta.status === "completed" ? chalk5.gray("completed") : workflowMeta.status === "failed" ? chalk5.red("failed") : statusStr;
|
|
9715
9853
|
}
|
|
9716
9854
|
}
|
|
9717
9855
|
const cells = [
|
|
9718
9856
|
marker + " " + (args.offset + i + 1),
|
|
9719
9857
|
title,
|
|
9720
|
-
|
|
9858
|
+
chalk5.gray(idStr)
|
|
9721
9859
|
];
|
|
9722
9860
|
if (hasTypeFilter || hasStatusFilter) {
|
|
9723
|
-
cells.push(statusDisplay ||
|
|
9861
|
+
cells.push(statusDisplay || chalk5.gray("-"));
|
|
9724
9862
|
}
|
|
9725
|
-
cells.push(s.messageCount.toString(), hasCp ?
|
|
9863
|
+
cells.push(s.messageCount.toString(), hasCp ? chalk5.green("\u2713") : chalk5.gray("-"));
|
|
9726
9864
|
return cells.join(" \u2502 ");
|
|
9727
9865
|
});
|
|
9728
9866
|
const showingInfo = totalCount > sessions.length ? `Showing ${sessions.length} of ${totalCount} sessions` : `${totalCount} sessions`;
|
|
@@ -9733,7 +9871,7 @@ var ListCommand = {
|
|
|
9733
9871
|
...rows.map((r) => `\u2502${r}\u2502`),
|
|
9734
9872
|
"\u2514" + "\u2500".repeat(header.length + 2) + "\u2518",
|
|
9735
9873
|
"",
|
|
9736
|
-
|
|
9874
|
+
chalk5.gray(showingInfo)
|
|
9737
9875
|
].join(`
|
|
9738
9876
|
`));
|
|
9739
9877
|
}
|
|
@@ -9747,7 +9885,7 @@ var ListCommand = {
|
|
|
9747
9885
|
};
|
|
9748
9886
|
|
|
9749
9887
|
// packages/cli/src/commands/sessions/get.ts
|
|
9750
|
-
import
|
|
9888
|
+
import chalk6 from "chalk";
|
|
9751
9889
|
var GetCommand = {
|
|
9752
9890
|
command: "get <session-id>",
|
|
9753
9891
|
aliases: ["show"],
|
|
@@ -9803,29 +9941,29 @@ var GetCommand = {
|
|
|
9803
9941
|
});
|
|
9804
9942
|
} else {
|
|
9805
9943
|
const lines = [
|
|
9806
|
-
|
|
9944
|
+
chalk6.bold("\u250C\u2500 Session Details \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),
|
|
9807
9945
|
`\u2502 ID: ${session.id}`,
|
|
9808
9946
|
`\u2502 Title: ${session.title}`,
|
|
9809
9947
|
`\u2502 Directory: ${session.directory}`,
|
|
9810
9948
|
`\u2502 Messages: ${session.messageCount}`,
|
|
9811
|
-
`\u2502 Active: ${session.id === activeSessionId ?
|
|
9949
|
+
`\u2502 Active: ${session.id === activeSessionId ? chalk6.green("\u2713") : chalk6.gray("-")}`,
|
|
9812
9950
|
`\u2502 Created: ${new Date(session.createdAt).toLocaleString("zh-CN")}`,
|
|
9813
9951
|
`\u2502 Updated: ${new Date(session.updatedAt).toLocaleString("zh-CN")}`
|
|
9814
9952
|
];
|
|
9815
9953
|
const workflowMeta = session.metadata?.type === "workflow" ? session.metadata : null;
|
|
9816
9954
|
if (workflowMeta) {
|
|
9817
9955
|
lines.push("\u251C\u2500 Workflow Info \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
9818
|
-
lines.push(`\u2502 Type: ${
|
|
9956
|
+
lines.push(`\u2502 Type: ${chalk6.cyan("workflow")}`);
|
|
9819
9957
|
lines.push(`\u2502 Workflow: ${workflowMeta.workflowName}`);
|
|
9820
9958
|
if (workflowMeta.workflowId) {
|
|
9821
9959
|
lines.push(`\u2502 Workflow ID: ${workflowMeta.workflowId}`);
|
|
9822
9960
|
}
|
|
9823
|
-
const statusColor = workflowMeta.status === "running" ?
|
|
9961
|
+
const statusColor = workflowMeta.status === "running" ? chalk6.green : workflowMeta.status === "paused" ? chalk6.yellow : workflowMeta.status === "completed" ? chalk6.gray : chalk6.red;
|
|
9824
9962
|
lines.push(`\u2502 Status: ${statusColor(workflowMeta.status)}`);
|
|
9825
9963
|
if (workflowMeta.agentSessions && workflowMeta.agentSessions.length > 0) {
|
|
9826
9964
|
lines.push("\u251C\u2500 Agent Sub-sessions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
9827
9965
|
workflowMeta.agentSessions.forEach((agent) => {
|
|
9828
|
-
const agentStatusColor = agent.status === "active" ?
|
|
9966
|
+
const agentStatusColor = agent.status === "active" ? chalk6.green : agent.status === "paused" ? chalk6.yellow : chalk6.gray;
|
|
9829
9967
|
lines.push(`\u2502 ${agent.nodeId}: ${agent.sessionId} (${agentStatusColor(agent.status)})`);
|
|
9830
9968
|
});
|
|
9831
9969
|
}
|
|
@@ -9852,7 +9990,7 @@ var GetCommand = {
|
|
|
9852
9990
|
};
|
|
9853
9991
|
|
|
9854
9992
|
// packages/cli/src/commands/sessions/new.ts
|
|
9855
|
-
import
|
|
9993
|
+
import chalk7 from "chalk";
|
|
9856
9994
|
var NewCommand = {
|
|
9857
9995
|
command: "new [options]",
|
|
9858
9996
|
aliases: ["create"],
|
|
@@ -9891,7 +10029,7 @@ var NewCommand = {
|
|
|
9891
10029
|
}
|
|
9892
10030
|
});
|
|
9893
10031
|
} else {
|
|
9894
|
-
output.success(
|
|
10032
|
+
output.success(chalk7.green("\u2713") + " Session created: " + session.id);
|
|
9895
10033
|
output.info("Title: " + session.title);
|
|
9896
10034
|
output.info("Directory: " + session.directory);
|
|
9897
10035
|
}
|
|
@@ -9905,7 +10043,7 @@ var NewCommand = {
|
|
|
9905
10043
|
};
|
|
9906
10044
|
|
|
9907
10045
|
// packages/cli/src/commands/sessions/rename.ts
|
|
9908
|
-
import
|
|
10046
|
+
import chalk8 from "chalk";
|
|
9909
10047
|
var RenameCommand = {
|
|
9910
10048
|
command: "rename <session-id> <title>",
|
|
9911
10049
|
aliases: ["mv"],
|
|
@@ -9960,7 +10098,7 @@ var RenameCommand = {
|
|
|
9960
10098
|
}
|
|
9961
10099
|
});
|
|
9962
10100
|
} else {
|
|
9963
|
-
output.success(`Session renamed: ${
|
|
10101
|
+
output.success(`Session renamed: ${chalk8.green(a.title)}`);
|
|
9964
10102
|
output.info(`ID: ${a.sessionId}`);
|
|
9965
10103
|
}
|
|
9966
10104
|
} catch (error) {
|
|
@@ -9973,7 +10111,7 @@ var RenameCommand = {
|
|
|
9973
10111
|
};
|
|
9974
10112
|
|
|
9975
10113
|
// packages/cli/src/commands/sessions/delete.ts
|
|
9976
|
-
import
|
|
10114
|
+
import chalk9 from "chalk";
|
|
9977
10115
|
var DeleteCommand = {
|
|
9978
10116
|
command: "delete [session-ids...]",
|
|
9979
10117
|
aliases: ["rm"],
|
|
@@ -10052,7 +10190,7 @@ var DeleteCommand = {
|
|
|
10052
10190
|
return true;
|
|
10053
10191
|
});
|
|
10054
10192
|
if (a.keepActive && sessionsToDelete.length > 0) {
|
|
10055
|
-
output.log(
|
|
10193
|
+
output.log(chalk9.yellow(`Keeping active session: ${activeSessionId}`));
|
|
10056
10194
|
}
|
|
10057
10195
|
} else if (a.olderThan !== undefined) {
|
|
10058
10196
|
const cutoffDate = new Date;
|
|
@@ -10069,7 +10207,7 @@ var DeleteCommand = {
|
|
|
10069
10207
|
}
|
|
10070
10208
|
return false;
|
|
10071
10209
|
});
|
|
10072
|
-
output.log(
|
|
10210
|
+
output.log(chalk9.gray(`Deleting sessions not updated since ${cutoffDate.toISOString().split("T")[0]} (${a.olderThan} days ago)`));
|
|
10073
10211
|
} else {
|
|
10074
10212
|
output.log("No sessions to delete");
|
|
10075
10213
|
return;
|
|
@@ -10079,10 +10217,10 @@ var DeleteCommand = {
|
|
|
10079
10217
|
return;
|
|
10080
10218
|
}
|
|
10081
10219
|
if (a.dryRun) {
|
|
10082
|
-
output.log(
|
|
10220
|
+
output.log(chalk9.yellow(`[DRY RUN] Would delete ${sessionsToDelete.length} session(s):
|
|
10083
10221
|
`));
|
|
10084
10222
|
sessionsToDelete.forEach((s, i) => {
|
|
10085
|
-
const marker = s.id === activeSessionId ?
|
|
10223
|
+
const marker = s.id === activeSessionId ? chalk9.green("\u25B6") : " ";
|
|
10086
10224
|
output.log(` ${marker} ${s.id}`);
|
|
10087
10225
|
output.log(` Title: ${s.title}`);
|
|
10088
10226
|
output.log(` Updated: ${new Date(s.updatedAt).toLocaleString()}`);
|
|
@@ -10092,11 +10230,11 @@ var DeleteCommand = {
|
|
|
10092
10230
|
return;
|
|
10093
10231
|
}
|
|
10094
10232
|
if (!a.force) {
|
|
10095
|
-
output.log(
|
|
10233
|
+
output.log(chalk9.red(`
|
|
10096
10234
|
\u26A0\uFE0F About to delete ${sessionsToDelete.length} session(s):
|
|
10097
10235
|
`));
|
|
10098
10236
|
sessionsToDelete.forEach((s, i) => {
|
|
10099
|
-
const marker = s.id === activeSessionId ?
|
|
10237
|
+
const marker = s.id === activeSessionId ? chalk9.green("\u25B6") : " ";
|
|
10100
10238
|
output.log(` ${marker} ${s.id} - ${s.title}`);
|
|
10101
10239
|
});
|
|
10102
10240
|
output.log("");
|
|
@@ -10106,7 +10244,7 @@ var DeleteCommand = {
|
|
|
10106
10244
|
input: process.stdin,
|
|
10107
10245
|
output: process.stdout
|
|
10108
10246
|
});
|
|
10109
|
-
rl.question(
|
|
10247
|
+
rl.question(chalk9.red("Type 'yes' to confirm deletion: "), (res) => {
|
|
10110
10248
|
rl.close();
|
|
10111
10249
|
resolve(res);
|
|
10112
10250
|
});
|
|
@@ -10134,7 +10272,7 @@ var DeleteCommand = {
|
|
|
10134
10272
|
}
|
|
10135
10273
|
}
|
|
10136
10274
|
if (successCount > 0) {
|
|
10137
|
-
output.success(
|
|
10275
|
+
output.success(chalk9.green(`\u2713`) + ` Deleted ${successCount} session(s)`);
|
|
10138
10276
|
}
|
|
10139
10277
|
if (failCount > 0) {
|
|
10140
10278
|
output.error(`\u2717 Failed to delete ${failCount} session(s)`);
|
|
@@ -10153,7 +10291,7 @@ var DeleteCommand = {
|
|
|
10153
10291
|
};
|
|
10154
10292
|
|
|
10155
10293
|
// packages/cli/src/commands/sessions/messages.ts
|
|
10156
|
-
import
|
|
10294
|
+
import chalk10 from "chalk";
|
|
10157
10295
|
var MessagesCommand = {
|
|
10158
10296
|
command: "messages <session-id>",
|
|
10159
10297
|
aliases: ["msgs"],
|
|
@@ -10221,10 +10359,10 @@ var MessagesCommand = {
|
|
|
10221
10359
|
...` : "");
|
|
10222
10360
|
};
|
|
10223
10361
|
const roleColors = {
|
|
10224
|
-
user:
|
|
10225
|
-
assistant:
|
|
10226
|
-
system:
|
|
10227
|
-
tool:
|
|
10362
|
+
user: chalk10.blue,
|
|
10363
|
+
assistant: chalk10.green,
|
|
10364
|
+
system: chalk10.gray,
|
|
10365
|
+
tool: chalk10.yellow
|
|
10228
10366
|
};
|
|
10229
10367
|
const formatMessageContent = (m) => {
|
|
10230
10368
|
const lines = [];
|
|
@@ -10235,64 +10373,64 @@ var MessagesCommand = {
|
|
|
10235
10373
|
lines.push(...text.split(`
|
|
10236
10374
|
`).map((l) => l || " "));
|
|
10237
10375
|
} else if (part.type === "tool-call") {
|
|
10238
|
-
lines.push(
|
|
10376
|
+
lines.push(chalk10.cyan(`[Tool Call] ${part.toolName}`));
|
|
10239
10377
|
const argsStr = typeof part.arguments === "string" ? part.arguments : JSON.stringify(part.arguments ?? null, null, 2);
|
|
10240
10378
|
if (argsStr && argsStr.length > 200) {
|
|
10241
10379
|
lines.push(...argsStr.slice(0, 197).split(`
|
|
10242
|
-
`).map((l) =>
|
|
10243
|
-
lines.push(
|
|
10380
|
+
`).map((l) => chalk10.gray(l)));
|
|
10381
|
+
lines.push(chalk10.gray("..."));
|
|
10244
10382
|
} else if (argsStr) {
|
|
10245
10383
|
lines.push(...argsStr.split(`
|
|
10246
|
-
`).map((l) =>
|
|
10384
|
+
`).map((l) => chalk10.gray(l)));
|
|
10247
10385
|
}
|
|
10248
10386
|
} else if (part.type === "tool-result") {
|
|
10249
|
-
lines.push(
|
|
10387
|
+
lines.push(chalk10.yellow(`[Tool Result] ${part.toolName}`));
|
|
10250
10388
|
const output2 = part.output?.length > 200 ? part.output.slice(0, 197) + "..." : part.output || "No output";
|
|
10251
10389
|
lines.push(...output2.split(`
|
|
10252
|
-
`).map((l) =>
|
|
10390
|
+
`).map((l) => chalk10.gray(l)));
|
|
10253
10391
|
} else if (part.type === "reasoning") {
|
|
10254
|
-
lines.push(
|
|
10392
|
+
lines.push(chalk10.magenta(`[Reasoning]`));
|
|
10255
10393
|
lines.push(...(part.content || "").split(`
|
|
10256
|
-
`).slice(0, 5).map((l) =>
|
|
10394
|
+
`).slice(0, 5).map((l) => chalk10.gray(l)));
|
|
10257
10395
|
} else if (part.type === "checkpoint") {
|
|
10258
|
-
lines.push(
|
|
10396
|
+
lines.push(chalk10.cyan(`[Checkpoint]`));
|
|
10259
10397
|
} else if (part.type === "workflow-node-call") {
|
|
10260
|
-
lines.push(
|
|
10398
|
+
lines.push(chalk10.blue(`[Node Call] ${part.nodeType}: ${part.nodeId}`));
|
|
10261
10399
|
if (part.input && Object.keys(part.input).length > 0) {
|
|
10262
10400
|
const inputSummary = Object.entries(part.input).slice(0, 3).map(([k, v]) => `${k}: ${JSON.stringify(v).slice(0, 50)}`).join(", ");
|
|
10263
10401
|
lines.push(...inputSummary.split(`
|
|
10264
|
-
`).map((l) =>
|
|
10402
|
+
`).map((l) => chalk10.gray(` ${l}`)));
|
|
10265
10403
|
}
|
|
10266
10404
|
if (part.agentSessionId) {
|
|
10267
|
-
lines.push(
|
|
10405
|
+
lines.push(chalk10.gray(` agentSessionId: ${part.agentSessionId}`));
|
|
10268
10406
|
}
|
|
10269
10407
|
} else if (part.type === "workflow-node-interrupt") {
|
|
10270
|
-
lines.push(
|
|
10271
|
-
lines.push(
|
|
10408
|
+
lines.push(chalk10.yellow(`[Node Interrupt] ${part.nodeType}: ${part.nodeId}`));
|
|
10409
|
+
lines.push(chalk10.bold(` Query: ${part.query}`));
|
|
10272
10410
|
if (part.options && part.options.length > 0) {
|
|
10273
|
-
lines.push(
|
|
10411
|
+
lines.push(chalk10.gray(` Options: ${part.options.join(", ")}`));
|
|
10274
10412
|
}
|
|
10275
10413
|
if (part.agentSessionId) {
|
|
10276
|
-
lines.push(
|
|
10414
|
+
lines.push(chalk10.gray(` agentSessionId: ${part.agentSessionId}`));
|
|
10277
10415
|
}
|
|
10278
10416
|
} else if (part.type === "workflow-node-result") {
|
|
10279
10417
|
const status = part.error ? "\u274C" : "\u2705";
|
|
10280
|
-
lines.push(
|
|
10418
|
+
lines.push(chalk10.green(`${status} [Node Result] ${part.nodeType}: ${part.nodeId}`));
|
|
10281
10419
|
if (part.output) {
|
|
10282
10420
|
const outputStr = typeof part.output === "string" ? part.output : JSON.stringify(part.output).slice(0, 200);
|
|
10283
10421
|
lines.push(...outputStr.split(`
|
|
10284
|
-
`).slice(0, 5).map((l) =>
|
|
10422
|
+
`).slice(0, 5).map((l) => chalk10.gray(` ${l}`)));
|
|
10285
10423
|
}
|
|
10286
10424
|
if (part.error) {
|
|
10287
|
-
lines.push(
|
|
10425
|
+
lines.push(chalk10.red(` Error: ${part.error}`));
|
|
10288
10426
|
}
|
|
10289
10427
|
if (part.durationMs !== undefined) {
|
|
10290
|
-
lines.push(
|
|
10428
|
+
lines.push(chalk10.gray(` Duration: ${part.durationMs}ms`));
|
|
10291
10429
|
}
|
|
10292
10430
|
} else if (part.type === "workflow-node-resume") {
|
|
10293
|
-
lines.push(
|
|
10431
|
+
lines.push(chalk10.green(`[Node Resume] Response: ${part.response}`));
|
|
10294
10432
|
} else if (part.type === "workflow-node-start") {
|
|
10295
|
-
lines.push(
|
|
10433
|
+
lines.push(chalk10.blue(`[Node Start] ${part.nodeId}`));
|
|
10296
10434
|
}
|
|
10297
10435
|
}
|
|
10298
10436
|
} else if (m.content) {
|
|
@@ -10302,28 +10440,28 @@ var MessagesCommand = {
|
|
|
10302
10440
|
}
|
|
10303
10441
|
return lines.length > 0 ? lines : ["(empty)"];
|
|
10304
10442
|
};
|
|
10305
|
-
output.log(
|
|
10443
|
+
output.log(chalk10.bold(`\u250C\u2500 Messages (${a.sessionId}) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510`));
|
|
10306
10444
|
messages.forEach((m, i) => {
|
|
10307
|
-
const roleColor = roleColors[m.role] ||
|
|
10445
|
+
const roleColor = roleColors[m.role] || chalk10.white;
|
|
10308
10446
|
const time = new Date(m.timestamp).toLocaleTimeString("zh-CN", {
|
|
10309
10447
|
hour: "2-digit",
|
|
10310
10448
|
minute: "2-digit"
|
|
10311
10449
|
});
|
|
10312
10450
|
if (m.metadata?.isCheckpoint) {
|
|
10313
|
-
output.log(
|
|
10451
|
+
output.log(chalk10.cyan("\u251C\u2500 #" + (a.offset + i + 1) + " checkpoint") + " " + chalk10.gray(time));
|
|
10314
10452
|
output.log("\u2502");
|
|
10315
10453
|
output.log("\u2502 " + checkpointStyle(m.content).split(`
|
|
10316
10454
|
`).join(`
|
|
10317
10455
|
\u2502 `));
|
|
10318
10456
|
output.log("\u2502");
|
|
10319
10457
|
} else {
|
|
10320
|
-
output.log(
|
|
10458
|
+
output.log(chalk10.cyan("\u251C\u2500 #" + (a.offset + i + 1) + " ") + roleColor(m.role.padEnd(10)) + " " + chalk10.gray(time));
|
|
10321
10459
|
const contentLines = formatMessageContent(m);
|
|
10322
10460
|
for (const line of contentLines.slice(0, 20)) {
|
|
10323
10461
|
output.log("\u2502 " + line);
|
|
10324
10462
|
}
|
|
10325
10463
|
if (contentLines.length > 20) {
|
|
10326
|
-
output.log("\u2502 " +
|
|
10464
|
+
output.log("\u2502 " + chalk10.gray("... (truncated)"));
|
|
10327
10465
|
}
|
|
10328
10466
|
output.log("\u2502");
|
|
10329
10467
|
}
|
|
@@ -10331,7 +10469,7 @@ var MessagesCommand = {
|
|
|
10331
10469
|
output.log("\u2514" + "\u2500".repeat(51) + "\u2518");
|
|
10332
10470
|
const hasMore = a.offset + a.limit < totalMessages;
|
|
10333
10471
|
const showingEnd = Math.min(a.offset + a.limit, totalMessages);
|
|
10334
|
-
output.log(
|
|
10472
|
+
output.log(chalk10.gray(`Showing ${a.offset + 1}-${showingEnd} of ${totalMessages} messages` + (hasMore ? " (more available)" : "")));
|
|
10335
10473
|
}
|
|
10336
10474
|
} catch (error) {
|
|
10337
10475
|
output.error(`Failed to get messages: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -10343,7 +10481,7 @@ var MessagesCommand = {
|
|
|
10343
10481
|
};
|
|
10344
10482
|
|
|
10345
10483
|
// packages/cli/src/commands/sessions/compact.ts
|
|
10346
|
-
import
|
|
10484
|
+
import chalk11 from "chalk";
|
|
10347
10485
|
var CompactCommand = {
|
|
10348
10486
|
command: "compact <session-id>",
|
|
10349
10487
|
aliases: ["compress", "checkpoint"],
|
|
@@ -10399,13 +10537,13 @@ var CompactCommand = {
|
|
|
10399
10537
|
dryRun: true
|
|
10400
10538
|
});
|
|
10401
10539
|
} else {
|
|
10402
|
-
output.log(
|
|
10540
|
+
output.log(chalk11.bold("\u250C\u2500 Compact Preview \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
|
|
10403
10541
|
output.log(`\u2502 Session: ${session.title}`);
|
|
10404
|
-
output.log(`\u2502 Messages to compact: ${
|
|
10542
|
+
output.log(`\u2502 Messages to compact: ${chalk11.yellow(preview.messageCountToCompact)}`);
|
|
10405
10543
|
output.log(`\u2502 Estimated checkpoint tokens: ${preview.estimatedCheckpointTokens}`);
|
|
10406
|
-
output.log(`\u2502 Would trigger: ${preview.wouldTrigger ?
|
|
10544
|
+
output.log(`\u2502 Would trigger: ${preview.wouldTrigger ? chalk11.green("Yes") : chalk11.gray("No")}`);
|
|
10407
10545
|
output.log("\u2502");
|
|
10408
|
-
output.log("\u2502 " +
|
|
10546
|
+
output.log("\u2502 " + chalk11.gray("(Dry run - no changes made)"));
|
|
10409
10547
|
output.log("\u2514" + "\u2500".repeat(51) + "\u2518");
|
|
10410
10548
|
}
|
|
10411
10549
|
return;
|
|
@@ -10420,10 +10558,10 @@ var CompactCommand = {
|
|
|
10420
10558
|
try {
|
|
10421
10559
|
scenarioHint = await sessionComponent.generateCompactHint(a.sessionId);
|
|
10422
10560
|
if (!a.json) {
|
|
10423
|
-
output.log(
|
|
10424
|
-
output.log("\u2502 " +
|
|
10561
|
+
output.log(chalk11.bold("\u251C\u2500 Auto-generated Scenario Hint \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"));
|
|
10562
|
+
output.log("\u2502 " + chalk11.cyan(scenarioHint.substring(0, 70)));
|
|
10425
10563
|
if (scenarioHint.length > 70) {
|
|
10426
|
-
output.log(
|
|
10564
|
+
output.log(chalk11.gray("\u2502 ") + scenarioHint.substring(70, 140));
|
|
10427
10565
|
}
|
|
10428
10566
|
}
|
|
10429
10567
|
} catch (hintError) {
|
|
@@ -10470,29 +10608,29 @@ var CompactCommand = {
|
|
|
10470
10608
|
}
|
|
10471
10609
|
});
|
|
10472
10610
|
} else {
|
|
10473
|
-
output.log(
|
|
10611
|
+
output.log(chalk11.bold.green("\u250C\u2500 Checkpoint Created \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
|
|
10474
10612
|
output.log(`\u2502 ID: ${result.checkpoint.id}`);
|
|
10475
10613
|
output.log(`\u2502 Title: ${result.checkpoint.title}`);
|
|
10476
10614
|
output.log(`\u2502 Type: compact`);
|
|
10477
10615
|
output.log(`\u2502 Created: ${new Date(result.checkpoint.createdAt).toLocaleString("zh-CN")}`);
|
|
10478
|
-
output.log(
|
|
10616
|
+
output.log(chalk11.bold("\u251C\u2500 Scenario Hint \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"));
|
|
10479
10617
|
if (scenarioHint) {
|
|
10480
10618
|
const hintLines = scenarioHint.split(`
|
|
10481
10619
|
`);
|
|
10482
10620
|
hintLines.forEach((line, i) => {
|
|
10483
10621
|
if (i === 0) {
|
|
10484
|
-
output.log(
|
|
10622
|
+
output.log(chalk11.cyan("\u2502 " + line.substring(0, 48)));
|
|
10485
10623
|
if (line.length > 48) {
|
|
10486
10624
|
for (let j = 48;j < line.length; j += 48) {
|
|
10487
|
-
output.log(
|
|
10625
|
+
output.log(chalk11.gray("\u2502 ") + line.substring(j, j + 48));
|
|
10488
10626
|
}
|
|
10489
10627
|
}
|
|
10490
10628
|
} else {
|
|
10491
|
-
output.log(
|
|
10629
|
+
output.log(chalk11.gray("\u2502 ") + line);
|
|
10492
10630
|
}
|
|
10493
10631
|
});
|
|
10494
10632
|
} else {
|
|
10495
|
-
output.log(
|
|
10633
|
+
output.log(chalk11.gray("\u2502 (no hint)"));
|
|
10496
10634
|
}
|
|
10497
10635
|
output.log("\u251C\u2500 Process Key Points \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
10498
10636
|
result.checkpoint.processKeyPoints.forEach((p, i) => {
|
|
@@ -10517,11 +10655,11 @@ var CompactCommand = {
|
|
|
10517
10655
|
result.checkpoint.recentMessages.forEach((msg) => {
|
|
10518
10656
|
const prefix = msg.role === "user" ? "\uD83D\uDC64" : "\uD83E\uDD16";
|
|
10519
10657
|
const content = msg.content.length > 60 ? msg.content.substring(0, 60) + "..." : msg.content;
|
|
10520
|
-
output.log(
|
|
10658
|
+
output.log(chalk11.gray(`\u2502 ${prefix} [${msg.role}] ${content}`));
|
|
10521
10659
|
});
|
|
10522
10660
|
}
|
|
10523
10661
|
output.log("\u251C\u2500 Stats \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
10524
|
-
output.log(`\u2502 Messages compacted: ${
|
|
10662
|
+
output.log(`\u2502 Messages compacted: ${chalk11.yellow(result.deletedMessageCount)}`);
|
|
10525
10663
|
output.log(`\u2502 Remaining messages: ${result.remainingMessageCount}`);
|
|
10526
10664
|
output.log(`\u2502 Total checkpoints: ${result.checkpointCount}`);
|
|
10527
10665
|
output.log("\u2514" + "\u2500".repeat(51) + "\u2518");
|
|
@@ -10539,7 +10677,7 @@ var CompactCommand = {
|
|
|
10539
10677
|
};
|
|
10540
10678
|
|
|
10541
10679
|
// packages/cli/src/commands/sessions/checkpoints.ts
|
|
10542
|
-
import
|
|
10680
|
+
import chalk12 from "chalk";
|
|
10543
10681
|
var CheckpointsCommand = {
|
|
10544
10682
|
command: "checkpoints <session-id>",
|
|
10545
10683
|
aliases: ["cps"],
|
|
@@ -10572,7 +10710,7 @@ var CheckpointsCommand = {
|
|
|
10572
10710
|
}
|
|
10573
10711
|
const checkpoints = await sessionComponent.getCheckpoints(a.sessionId);
|
|
10574
10712
|
if (checkpoints.length === 0) {
|
|
10575
|
-
output.log(
|
|
10713
|
+
output.log(chalk12.gray("No checkpoints for this session"));
|
|
10576
10714
|
return;
|
|
10577
10715
|
}
|
|
10578
10716
|
if (a.json) {
|
|
@@ -10597,7 +10735,7 @@ var CheckpointsCommand = {
|
|
|
10597
10735
|
if (a.detail) {
|
|
10598
10736
|
checkpoints.reverse().forEach((cp, i) => {
|
|
10599
10737
|
const isLatest = i === 0;
|
|
10600
|
-
output.log(
|
|
10738
|
+
output.log(chalk12.bold(`\u250C\u2500 Checkpoint: ${cp.title} ${isLatest ? chalk12.green("\u2713") : ""} \u2500\u2500\u2500\u2500\u2500\u2500` + "\u2500".repeat(Math.max(0, 30 - cp.title.length)) + "\u2510"));
|
|
10601
10739
|
output.log(`\u2502 ID: ${cp.id}`);
|
|
10602
10740
|
output.log(`\u2502 Type: ${cp.type}`);
|
|
10603
10741
|
output.log(`\u2502 Message Index: ${cp.messageIndex} (${cp.messageCountBefore} messages)`);
|
|
@@ -10625,18 +10763,18 @@ var CheckpointsCommand = {
|
|
|
10625
10763
|
});
|
|
10626
10764
|
} else {
|
|
10627
10765
|
const header = [
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10766
|
+
chalk12.bold("#"),
|
|
10767
|
+
chalk12.bold("Title"),
|
|
10768
|
+
chalk12.bold("Type"),
|
|
10769
|
+
chalk12.bold("Messages"),
|
|
10770
|
+
chalk12.bold("Created")
|
|
10633
10771
|
].join(" \u2502 ");
|
|
10634
10772
|
output.log(`\u250C\u2500 Checkpoints (${checkpoints.length}) ${"\u2500".repeat(40)}\u2510`);
|
|
10635
10773
|
output.log(`\u2502${header}\u2502`);
|
|
10636
10774
|
output.log("\u251C" + "\u2500".repeat(header.length + 2) + "\u2524");
|
|
10637
10775
|
checkpoints.reverse().forEach((cp, i) => {
|
|
10638
10776
|
const isLatest = i === 0;
|
|
10639
|
-
const marker = isLatest ?
|
|
10777
|
+
const marker = isLatest ? chalk12.green("\u2713 ") : " ";
|
|
10640
10778
|
const title = cp.title.length > 25 ? cp.title.slice(0, 22) + "..." : cp.title;
|
|
10641
10779
|
const created = new Date(cp.createdAt).toLocaleString("zh-CN", {
|
|
10642
10780
|
month: "2-digit",
|
|
@@ -10644,7 +10782,7 @@ var CheckpointsCommand = {
|
|
|
10644
10782
|
hour: "2-digit",
|
|
10645
10783
|
minute: "2-digit"
|
|
10646
10784
|
});
|
|
10647
|
-
output.log(`\u2502${marker}${i + 1} ${title.padEnd(25)} \u2502 ${cp.type.padEnd(5)} \u2502 ${cp.messageCountBefore.toString().padStart(8)} \u2502 ${
|
|
10785
|
+
output.log(`\u2502${marker}${i + 1} ${title.padEnd(25)} \u2502 ${cp.type.padEnd(5)} \u2502 ${cp.messageCountBefore.toString().padStart(8)} \u2502 ${chalk12.gray(created)}\u2502`);
|
|
10648
10786
|
});
|
|
10649
10787
|
output.log("\u2514" + "\u2500".repeat(header.length + 2) + "\u2518");
|
|
10650
10788
|
}
|
|
@@ -10658,7 +10796,7 @@ var CheckpointsCommand = {
|
|
|
10658
10796
|
};
|
|
10659
10797
|
|
|
10660
10798
|
// packages/cli/src/commands/sessions/active.ts
|
|
10661
|
-
import
|
|
10799
|
+
import chalk13 from "chalk";
|
|
10662
10800
|
var ActiveCommand = {
|
|
10663
10801
|
command: "active",
|
|
10664
10802
|
aliases: ["current"],
|
|
@@ -10685,7 +10823,7 @@ var ActiveCommand = {
|
|
|
10685
10823
|
return;
|
|
10686
10824
|
}
|
|
10687
10825
|
if (!activeId) {
|
|
10688
|
-
output.log(
|
|
10826
|
+
output.log(chalk13.gray("No active session set"));
|
|
10689
10827
|
return;
|
|
10690
10828
|
}
|
|
10691
10829
|
const session = await sessionComponent.get(activeId);
|
|
@@ -10703,10 +10841,10 @@ var ActiveCommand = {
|
|
|
10703
10841
|
});
|
|
10704
10842
|
} else {
|
|
10705
10843
|
if (!session) {
|
|
10706
|
-
output.log(
|
|
10844
|
+
output.log(chalk13.gray("Active session not found: " + activeId));
|
|
10707
10845
|
return;
|
|
10708
10846
|
}
|
|
10709
|
-
output.log(
|
|
10847
|
+
output.log(chalk13.bold.green("\u250C\u2500 Active Session \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
|
|
10710
10848
|
output.log(`\u2502 ID: ${session.id}`);
|
|
10711
10849
|
output.log(`\u2502 Title: ${session.title}`);
|
|
10712
10850
|
output.log(`\u2502 Directory: ${session.directory}`);
|
|
@@ -10788,7 +10926,7 @@ var AddMessageCommand = {
|
|
|
10788
10926
|
};
|
|
10789
10927
|
|
|
10790
10928
|
// packages/cli/src/commands/sessions/mock.ts
|
|
10791
|
-
import
|
|
10929
|
+
import chalk14 from "chalk";
|
|
10792
10930
|
var MOCK_SEQUENCES = [
|
|
10793
10931
|
{
|
|
10794
10932
|
name: "\u6587\u4EF6\u64CD\u4F5C\u6D41\u7A0B",
|
|
@@ -10921,7 +11059,7 @@ var MockCommand = {
|
|
|
10921
11059
|
for (let seqIdx = 0;seqIdx < count; seqIdx++) {
|
|
10922
11060
|
const sequence = MOCK_SEQUENCES[seqIdx];
|
|
10923
11061
|
if (!a.json) {
|
|
10924
|
-
output.log(
|
|
11062
|
+
output.log(chalk14.bold(`
|
|
10925
11063
|
\uD83D\uDCDD Sequence ${seqIdx + 1}: ${sequence.name}`));
|
|
10926
11064
|
}
|
|
10927
11065
|
for (const msg of sequence.messages) {
|
|
@@ -10939,7 +11077,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
10939
11077
|
if (assistantMsgId)
|
|
10940
11078
|
addedMessages.push(assistantMsgId);
|
|
10941
11079
|
if (!a.json) {
|
|
10942
|
-
output.log(
|
|
11080
|
+
output.log(chalk14.cyan(` [${addedMessages.length}] assistant: \uD83D\uDD27 Tool call`));
|
|
10943
11081
|
}
|
|
10944
11082
|
const toolMsgId = await sessionComponent.addMessage(a.sessionId, {
|
|
10945
11083
|
role: "tool",
|
|
@@ -10948,7 +11086,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
10948
11086
|
if (toolMsgId)
|
|
10949
11087
|
addedMessages.push(toolMsgId);
|
|
10950
11088
|
if (!a.json) {
|
|
10951
|
-
output.log(
|
|
11089
|
+
output.log(chalk14.yellow(` [${addedMessages.length}] tool: ${msg.content.substring(0, 50)}...`));
|
|
10952
11090
|
}
|
|
10953
11091
|
} else {
|
|
10954
11092
|
const msgId = await sessionComponent.addMessage(a.sessionId, {
|
|
@@ -10958,7 +11096,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
10958
11096
|
if (msgId)
|
|
10959
11097
|
addedMessages.push(msgId);
|
|
10960
11098
|
if (!a.json) {
|
|
10961
|
-
const roleColor = msg.role === "user" ?
|
|
11099
|
+
const roleColor = msg.role === "user" ? chalk14.green : msg.role === "assistant" ? chalk14.cyan : chalk14.gray;
|
|
10962
11100
|
output.log(roleColor(` [${addedMessages.length}] ${msg.role}: ${msg.content.substring(0, 50)}...`));
|
|
10963
11101
|
}
|
|
10964
11102
|
}
|
|
@@ -10974,14 +11112,14 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
10974
11112
|
});
|
|
10975
11113
|
} else {
|
|
10976
11114
|
output.log(`
|
|
10977
|
-
` +
|
|
11115
|
+
` + chalk14.bold.green("\u2705 Mock data inserted successfully!"));
|
|
10978
11116
|
output.log(` Session: ${a.sessionId}`);
|
|
10979
11117
|
output.log(` Sequences: ${count}`);
|
|
10980
11118
|
output.log(` Messages: ${addedMessages.length}`);
|
|
10981
11119
|
output.log("");
|
|
10982
|
-
output.log(
|
|
10983
|
-
output.log(
|
|
10984
|
-
output.log(
|
|
11120
|
+
output.log(chalk14.gray(" Now run: "));
|
|
11121
|
+
output.log(chalk14.gray(` roy-agent sessions compact ${a.sessionId}`));
|
|
11122
|
+
output.log(chalk14.gray(" to trigger checkpoint generation"));
|
|
10985
11123
|
}
|
|
10986
11124
|
} finally {
|
|
10987
11125
|
await envService.dispose();
|
|
@@ -10990,7 +11128,7 @@ ${JSON.stringify(tc.args, null, 2)}
|
|
|
10990
11128
|
};
|
|
10991
11129
|
|
|
10992
11130
|
// packages/cli/src/commands/sessions/grep.ts
|
|
10993
|
-
import
|
|
11131
|
+
import chalk15 from "chalk";
|
|
10994
11132
|
var GrepCommand = {
|
|
10995
11133
|
command: "grep <query...>",
|
|
10996
11134
|
aliases: ["search"],
|
|
@@ -11070,7 +11208,7 @@ var GrepCommand = {
|
|
|
11070
11208
|
const results = await sessionComponent.searchMessages(searchOptions);
|
|
11071
11209
|
if (results.length === 0) {
|
|
11072
11210
|
if (!a.quiet) {
|
|
11073
|
-
output.log(
|
|
11211
|
+
output.log(chalk15.yellow(`No results found for: ${query}`));
|
|
11074
11212
|
}
|
|
11075
11213
|
return;
|
|
11076
11214
|
}
|
|
@@ -11097,7 +11235,7 @@ var GrepCommand = {
|
|
|
11097
11235
|
for (const result of results) {
|
|
11098
11236
|
for (const match of result.matches) {
|
|
11099
11237
|
const time = new Date(match.timestamp).toLocaleString("zh-CN");
|
|
11100
|
-
output.log(`${
|
|
11238
|
+
output.log(`${chalk15.gray(result.sessionId)} ${chalk15.blue(result.sessionTitle)} ${chalk15.gray(time)}`);
|
|
11101
11239
|
output.log(` ${match.content}`);
|
|
11102
11240
|
output.log("");
|
|
11103
11241
|
}
|
|
@@ -11109,40 +11247,40 @@ var GrepCommand = {
|
|
|
11109
11247
|
totalMatches += result.matches.length;
|
|
11110
11248
|
const time = new Date(result.updatedAt).toLocaleString("zh-CN");
|
|
11111
11249
|
const titleStr = `\u2500 ${result.sessionTitle} (${result.sessionId})`;
|
|
11112
|
-
output.log(
|
|
11250
|
+
output.log(chalk15.bold(`
|
|
11113
11251
|
\u250C${titleStr}${"\u2500".repeat(Math.max(0, 50 - titleStr.length))}\u2510`));
|
|
11114
|
-
output.log(`\u2502 ${
|
|
11252
|
+
output.log(`\u2502 ${chalk15.gray(`Updated: ${time} | ${result.messageCount} messages | ${result.matches.length} matches`)}${" ".repeat(Math.max(0, 50 - 60))}\u2502`);
|
|
11115
11253
|
for (let i = 0;i < result.matches.length; i++) {
|
|
11116
11254
|
const match = result.matches[i];
|
|
11117
|
-
const roleColor = match.role === "user" ?
|
|
11255
|
+
const roleColor = match.role === "user" ? chalk15.blue : match.role === "assistant" ? chalk15.green : chalk15.gray;
|
|
11118
11256
|
const msgTime = new Date(match.timestamp).toLocaleTimeString("zh-CN", {
|
|
11119
11257
|
hour: "2-digit",
|
|
11120
11258
|
minute: "2-digit"
|
|
11121
11259
|
});
|
|
11122
|
-
output.log(`\u251C\u2500 #${i + 1} ${roleColor(match.role.padEnd(10))} ${
|
|
11260
|
+
output.log(`\u251C\u2500 #${i + 1} ${roleColor(match.role.padEnd(10))} ${chalk15.gray(msgTime)}`);
|
|
11123
11261
|
output.log("\u2502");
|
|
11124
11262
|
const lines = match.content.split(`
|
|
11125
11263
|
`).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
11126
11264
|
const maxLines = 5;
|
|
11127
11265
|
const displayLines = lines.slice(0, maxLines);
|
|
11128
11266
|
if (displayLines.length === 0) {
|
|
11129
|
-
output.log("\u2502 " +
|
|
11267
|
+
output.log("\u2502 " + chalk15.gray("(empty content)"));
|
|
11130
11268
|
} else {
|
|
11131
11269
|
for (const line of displayLines) {
|
|
11132
11270
|
const truncated = line.length > 76 ? line.slice(0, 73) + "..." : line;
|
|
11133
|
-
output.log(`\u2502 ${
|
|
11271
|
+
output.log(`\u2502 ${chalk15.gray(truncated)}`);
|
|
11134
11272
|
}
|
|
11135
11273
|
}
|
|
11136
11274
|
if (lines.length > maxLines) {
|
|
11137
|
-
output.log("\u2502 " +
|
|
11275
|
+
output.log("\u2502 " + chalk15.gray(`... (${lines.length - maxLines} more lines)`));
|
|
11138
11276
|
}
|
|
11139
11277
|
output.log("\u2502");
|
|
11140
11278
|
}
|
|
11141
11279
|
output.log(`\u2514${"\u2500".repeat(52)}\u2518`);
|
|
11142
11280
|
}
|
|
11143
11281
|
output.log(`
|
|
11144
|
-
${
|
|
11145
|
-
output.log(
|
|
11282
|
+
${chalk15.green("\u2713")} Found ${chalk15.bold(totalMatches.toString())} matches in ${chalk15.bold(results.length.toString())} sessions`);
|
|
11283
|
+
output.log(chalk15.gray(`Query: "${query}"`));
|
|
11146
11284
|
}
|
|
11147
11285
|
} catch (error) {
|
|
11148
11286
|
output.error(`Search failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -11181,7 +11319,7 @@ var SessionsCommand = {
|
|
|
11181
11319
|
};
|
|
11182
11320
|
|
|
11183
11321
|
// packages/cli/src/commands/tasks/list.ts
|
|
11184
|
-
import
|
|
11322
|
+
import chalk16 from "chalk";
|
|
11185
11323
|
var ListCommand2 = {
|
|
11186
11324
|
command: "list",
|
|
11187
11325
|
aliases: ["ls"],
|
|
@@ -11237,15 +11375,15 @@ var ListCommand2 = {
|
|
|
11237
11375
|
tasks.forEach((t) => output.log(t.id.toString()));
|
|
11238
11376
|
} else {
|
|
11239
11377
|
const header = [
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11378
|
+
chalk16.bold("#"),
|
|
11379
|
+
chalk16.bold("Title"),
|
|
11380
|
+
chalk16.bold("Status"),
|
|
11381
|
+
chalk16.bold("Priority"),
|
|
11382
|
+
chalk16.bold("Progress")
|
|
11245
11383
|
].join(" \u2502 ");
|
|
11246
11384
|
const rows = tasks.map((t, i) => {
|
|
11247
|
-
const statusColor = t.status === "completed" ?
|
|
11248
|
-
const priorityColor = t.priority === "high" ?
|
|
11385
|
+
const statusColor = t.status === "completed" ? chalk16.green : t.status === "active" ? chalk16.blue : t.status === "paused" ? chalk16.yellow : t.status === "cancelled" ? chalk16.strikethrough : chalk16.gray;
|
|
11386
|
+
const priorityColor = t.priority === "high" ? chalk16.red : t.priority === "medium" ? chalk16.yellow : chalk16.gray;
|
|
11249
11387
|
return [
|
|
11250
11388
|
(args.offset + i + 1).toString(),
|
|
11251
11389
|
t.title.length > 30 ? t.title.slice(0, 27) + "..." : t.title,
|
|
@@ -11261,7 +11399,7 @@ var ListCommand2 = {
|
|
|
11261
11399
|
...rows.map((r) => `\u2502${r}\u2502`),
|
|
11262
11400
|
"\u2514" + "\u2500".repeat(header.length + 2) + "\u2518",
|
|
11263
11401
|
"",
|
|
11264
|
-
|
|
11402
|
+
chalk16.gray(`Total: ${tasks.length} tasks`)
|
|
11265
11403
|
].join(`
|
|
11266
11404
|
`));
|
|
11267
11405
|
}
|
|
@@ -11275,7 +11413,7 @@ var ListCommand2 = {
|
|
|
11275
11413
|
};
|
|
11276
11414
|
|
|
11277
11415
|
// packages/cli/src/commands/tasks/get.ts
|
|
11278
|
-
import
|
|
11416
|
+
import chalk17 from "chalk";
|
|
11279
11417
|
var GetCommand2 = {
|
|
11280
11418
|
command: "get <id>",
|
|
11281
11419
|
aliases: ["show"],
|
|
@@ -11314,16 +11452,16 @@ var GetCommand2 = {
|
|
|
11314
11452
|
if (args.json) {
|
|
11315
11453
|
output.json(result);
|
|
11316
11454
|
} else {
|
|
11317
|
-
output.log(
|
|
11455
|
+
output.log(chalk17.bold(`
|
|
11318
11456
|
Task #${result.task.id}: ${result.task.title}
|
|
11319
11457
|
`));
|
|
11320
|
-
output.log(`Status: ${
|
|
11458
|
+
output.log(`Status: ${chalk17.blue(result.task.status)} | Priority: ${result.task.priority} | Progress: ${result.task.progress}%`);
|
|
11321
11459
|
output.log(`Created: ${result.task.createdAt} | Updated: ${result.task.updatedAt}`);
|
|
11322
11460
|
if (result.task.current_status) {
|
|
11323
11461
|
output.log(`
|
|
11324
11462
|
Current Status: ${result.task.current_status}`);
|
|
11325
11463
|
}
|
|
11326
|
-
output.log(
|
|
11464
|
+
output.log(chalk17.bold(`
|
|
11327
11465
|
Operations (${result.operations.length}):
|
|
11328
11466
|
`));
|
|
11329
11467
|
result.operations.forEach((op, i) => {
|
|
@@ -11343,10 +11481,10 @@ Operations (${result.operations.length}):
|
|
|
11343
11481
|
if (args.json) {
|
|
11344
11482
|
output.json(task);
|
|
11345
11483
|
} else {
|
|
11346
|
-
output.log(
|
|
11484
|
+
output.log(chalk17.bold(`
|
|
11347
11485
|
Task #${task.id}: ${task.title}
|
|
11348
11486
|
`));
|
|
11349
|
-
output.log(`Status: ${
|
|
11487
|
+
output.log(`Status: ${chalk17.blue(task.status)} | Priority: ${task.priority} | Progress: ${task.progress}%`);
|
|
11350
11488
|
output.log(`Created: ${task.createdAt} | Updated: ${task.updatedAt}`);
|
|
11351
11489
|
if (task.current_status) {
|
|
11352
11490
|
output.log(`
|
|
@@ -11368,7 +11506,7 @@ Description: ${task.description}`);
|
|
|
11368
11506
|
};
|
|
11369
11507
|
|
|
11370
11508
|
// packages/cli/src/commands/tasks/create.ts
|
|
11371
|
-
import
|
|
11509
|
+
import chalk18 from "chalk";
|
|
11372
11510
|
var CreateCommand = {
|
|
11373
11511
|
command: "create <title>",
|
|
11374
11512
|
aliases: ["add", "new"],
|
|
@@ -11428,7 +11566,7 @@ var CreateCommand = {
|
|
|
11428
11566
|
if (args.json) {
|
|
11429
11567
|
output.json(task);
|
|
11430
11568
|
} else {
|
|
11431
|
-
output.log(
|
|
11569
|
+
output.log(chalk18.green(`
|
|
11432
11570
|
\u2713 Task created: #${task.id}`));
|
|
11433
11571
|
output.log(` Title: ${task.title}`);
|
|
11434
11572
|
output.log(` Status: ${task.status}`);
|
|
@@ -11445,7 +11583,7 @@ var CreateCommand = {
|
|
|
11445
11583
|
};
|
|
11446
11584
|
|
|
11447
11585
|
// packages/cli/src/commands/tasks/update.ts
|
|
11448
|
-
import
|
|
11586
|
+
import chalk19 from "chalk";
|
|
11449
11587
|
var UpdateCommand = {
|
|
11450
11588
|
command: "update <id>",
|
|
11451
11589
|
aliases: ["set"],
|
|
@@ -11500,7 +11638,7 @@ var UpdateCommand = {
|
|
|
11500
11638
|
if (args.json) {
|
|
11501
11639
|
output.json(task);
|
|
11502
11640
|
} else {
|
|
11503
|
-
output.log(
|
|
11641
|
+
output.log(chalk19.green(`
|
|
11504
11642
|
\u2713 Task updated: #${task.id}`));
|
|
11505
11643
|
output.log(` Title: ${task.title}`);
|
|
11506
11644
|
output.log(` Status: ${task.status}`);
|
|
@@ -11520,7 +11658,7 @@ var UpdateCommand = {
|
|
|
11520
11658
|
};
|
|
11521
11659
|
|
|
11522
11660
|
// packages/cli/src/commands/tasks/delete.ts
|
|
11523
|
-
import
|
|
11661
|
+
import chalk20 from "chalk";
|
|
11524
11662
|
var DeleteCommand2 = {
|
|
11525
11663
|
command: "delete <id>",
|
|
11526
11664
|
aliases: ["remove", "rm", "del"],
|
|
@@ -11556,16 +11694,16 @@ var DeleteCommand2 = {
|
|
|
11556
11694
|
process.exit(1);
|
|
11557
11695
|
}
|
|
11558
11696
|
if (!args.force) {
|
|
11559
|
-
output.log(
|
|
11560
|
-
output.log(
|
|
11561
|
-
output.log(
|
|
11562
|
-
output.log(
|
|
11697
|
+
output.log(chalk20.yellow(`Are you sure you want to delete task #${args.id}?`));
|
|
11698
|
+
output.log(chalk20.yellow(` Title: ${task.title}`));
|
|
11699
|
+
output.log(chalk20.yellow(` Status: ${task.status}`));
|
|
11700
|
+
output.log(chalk20.yellow(`
|
|
11563
11701
|
Use --force to skip this confirmation`));
|
|
11564
11702
|
process.exit(1);
|
|
11565
11703
|
}
|
|
11566
11704
|
const deleted = await taskComponent.deleteTask(args.id);
|
|
11567
11705
|
if (deleted) {
|
|
11568
|
-
output.log(
|
|
11706
|
+
output.log(chalk20.green(`
|
|
11569
11707
|
\u2713 Task deleted: #${args.id}`));
|
|
11570
11708
|
} else {
|
|
11571
11709
|
output.error(`Failed to delete task: ${args.id}`);
|
|
@@ -11581,7 +11719,7 @@ Use --force to skip this confirmation`));
|
|
|
11581
11719
|
};
|
|
11582
11720
|
|
|
11583
11721
|
// packages/cli/src/commands/tasks/complete.ts
|
|
11584
|
-
import
|
|
11722
|
+
import chalk21 from "chalk";
|
|
11585
11723
|
var CompleteCommand = {
|
|
11586
11724
|
command: "complete <id>",
|
|
11587
11725
|
aliases: ["done", "finish"],
|
|
@@ -11624,7 +11762,7 @@ var CompleteCommand = {
|
|
|
11624
11762
|
if (args.json) {
|
|
11625
11763
|
output.json(task);
|
|
11626
11764
|
} else {
|
|
11627
|
-
output.log(
|
|
11765
|
+
output.log(chalk21.green(`
|
|
11628
11766
|
\u2713 Task completed: #${task.id}`));
|
|
11629
11767
|
output.log(` Title: ${task.title}`);
|
|
11630
11768
|
output.log(` Progress: ${task.progress}%`);
|
|
@@ -11640,7 +11778,7 @@ var CompleteCommand = {
|
|
|
11640
11778
|
};
|
|
11641
11779
|
|
|
11642
11780
|
// packages/cli/src/commands/tasks/operations.ts
|
|
11643
|
-
import
|
|
11781
|
+
import chalk22 from "chalk";
|
|
11644
11782
|
var OperationsCommand = {
|
|
11645
11783
|
command: "operations <task-id>",
|
|
11646
11784
|
aliases: ["ops", "log"],
|
|
@@ -11690,23 +11828,23 @@ var OperationsCommand = {
|
|
|
11690
11828
|
count: operations.length
|
|
11691
11829
|
});
|
|
11692
11830
|
} else {
|
|
11693
|
-
output.log(
|
|
11831
|
+
output.log(chalk22.bold(`
|
|
11694
11832
|
Operations for Task #${task.id}: ${task.title}
|
|
11695
11833
|
`));
|
|
11696
11834
|
if (operations.length === 0) {
|
|
11697
|
-
output.log(
|
|
11835
|
+
output.log(chalk22.gray("No operations found."));
|
|
11698
11836
|
} else {
|
|
11699
11837
|
operations.forEach((op, i) => {
|
|
11700
|
-
const actionColor = op.actionType === "completed" ?
|
|
11701
|
-
output.log(`${
|
|
11702
|
-
output.log(` Session: ${
|
|
11838
|
+
const actionColor = op.actionType === "completed" ? chalk22.green : op.actionType === "milestone" ? chalk22.blue : op.actionType === "problem" ? chalk22.red : chalk22.gray;
|
|
11839
|
+
output.log(`${chalk22.bold(a.offset + i + 1)}. ` + actionColor(`[${op.actionType}]`) + ` ${op.actionTitle}`);
|
|
11840
|
+
output.log(` Session: ${chalk22.cyan(op.sessionId)} | Time: ${op.timestamp}`);
|
|
11703
11841
|
if (op.actionDescription) {
|
|
11704
11842
|
output.log(` ${op.actionDescription}`);
|
|
11705
11843
|
}
|
|
11706
11844
|
output.log("");
|
|
11707
11845
|
});
|
|
11708
11846
|
}
|
|
11709
|
-
output.log(
|
|
11847
|
+
output.log(chalk22.gray(`Total: ${operations.length} operations`));
|
|
11710
11848
|
}
|
|
11711
11849
|
} catch (error) {
|
|
11712
11850
|
output.error(`Failed to list operations: ${error}`);
|
|
@@ -11734,7 +11872,7 @@ var TasksCommand = {
|
|
|
11734
11872
|
};
|
|
11735
11873
|
|
|
11736
11874
|
// packages/cli/src/commands/skills/list.ts
|
|
11737
|
-
import
|
|
11875
|
+
import chalk23 from "chalk";
|
|
11738
11876
|
var ListCommand3 = {
|
|
11739
11877
|
command: "list",
|
|
11740
11878
|
aliases: ["ls"],
|
|
@@ -11787,26 +11925,26 @@ var ListCommand3 = {
|
|
|
11787
11925
|
filtered.forEach((s) => output.log(s.name));
|
|
11788
11926
|
} else {
|
|
11789
11927
|
const header = [
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11928
|
+
chalk23.bold("Name"),
|
|
11929
|
+
chalk23.bold("Description"),
|
|
11930
|
+
chalk23.bold("Source")
|
|
11793
11931
|
].join(" | ");
|
|
11794
11932
|
const sourceColor = (source) => {
|
|
11795
11933
|
switch (source) {
|
|
11796
11934
|
case "project":
|
|
11797
|
-
return
|
|
11935
|
+
return chalk23.green;
|
|
11798
11936
|
case "user":
|
|
11799
|
-
return
|
|
11937
|
+
return chalk23.blue;
|
|
11800
11938
|
case "built-in":
|
|
11801
|
-
return
|
|
11939
|
+
return chalk23.gray;
|
|
11802
11940
|
default:
|
|
11803
|
-
return
|
|
11941
|
+
return chalk23.white;
|
|
11804
11942
|
}
|
|
11805
11943
|
};
|
|
11806
11944
|
const rows = filtered.map((s) => {
|
|
11807
11945
|
const desc = s.description.length > 50 ? s.description.slice(0, 47) + "..." : s.description;
|
|
11808
11946
|
return [
|
|
11809
|
-
|
|
11947
|
+
chalk23.cyan(s.name),
|
|
11810
11948
|
desc,
|
|
11811
11949
|
sourceColor(s.source)(`[${s.source}]`)
|
|
11812
11950
|
].join(" | ");
|
|
@@ -11818,7 +11956,7 @@ var ListCommand3 = {
|
|
|
11818
11956
|
...rows.map((r) => `\u2502${r}\u2502`),
|
|
11819
11957
|
"\u2514" + "\u2500".repeat(header.length + 2) + "\u2518",
|
|
11820
11958
|
"",
|
|
11821
|
-
|
|
11959
|
+
chalk23.gray(`Total: ${filtered.length} skills`)
|
|
11822
11960
|
].join(`
|
|
11823
11961
|
`));
|
|
11824
11962
|
}
|
|
@@ -11832,7 +11970,7 @@ var ListCommand3 = {
|
|
|
11832
11970
|
};
|
|
11833
11971
|
|
|
11834
11972
|
// packages/cli/src/commands/skills/get.ts
|
|
11835
|
-
import
|
|
11973
|
+
import chalk24 from "chalk";
|
|
11836
11974
|
var GetCommand3 = {
|
|
11837
11975
|
command: "get <name>",
|
|
11838
11976
|
describe: "\u83B7\u53D6\u6307\u5B9A\u6280\u80FD\u5185\u5BB9",
|
|
@@ -11876,13 +12014,13 @@ var GetCommand3 = {
|
|
|
11876
12014
|
content: skill.content
|
|
11877
12015
|
});
|
|
11878
12016
|
} else {
|
|
11879
|
-
output.log(
|
|
12017
|
+
output.log(chalk24.bold.cyan(`# ${skill.name}`));
|
|
11880
12018
|
output.log("");
|
|
11881
|
-
output.log(`${
|
|
11882
|
-
output.log(`${
|
|
11883
|
-
output.log(`${
|
|
12019
|
+
output.log(`${chalk24.gray("Description:")} ${skill.description}`);
|
|
12020
|
+
output.log(`${chalk24.gray("Source:")} ${skill.source}`);
|
|
12021
|
+
output.log(`${chalk24.gray("File:")} ${skill.filePath}`);
|
|
11884
12022
|
output.log("");
|
|
11885
|
-
output.log(
|
|
12023
|
+
output.log(chalk24.bold("--- Content ---"));
|
|
11886
12024
|
output.log("");
|
|
11887
12025
|
output.log(skill.content);
|
|
11888
12026
|
}
|
|
@@ -11896,7 +12034,7 @@ var GetCommand3 = {
|
|
|
11896
12034
|
};
|
|
11897
12035
|
|
|
11898
12036
|
// packages/cli/src/commands/skills/search.ts
|
|
11899
|
-
import
|
|
12037
|
+
import chalk25 from "chalk";
|
|
11900
12038
|
var SearchCommand = {
|
|
11901
12039
|
command: "search <term>",
|
|
11902
12040
|
aliases: ["find"],
|
|
@@ -11935,7 +12073,7 @@ var SearchCommand = {
|
|
|
11935
12073
|
const term = args.term.toLowerCase();
|
|
11936
12074
|
const results = allSkills.filter((s) => s.name.toLowerCase().includes(term) || s.description.toLowerCase().includes(term));
|
|
11937
12075
|
if (results.length === 0) {
|
|
11938
|
-
output.log(
|
|
12076
|
+
output.log(chalk25.yellow(`No skills found matching: ${args.term}`));
|
|
11939
12077
|
return;
|
|
11940
12078
|
}
|
|
11941
12079
|
if (args.json) {
|
|
@@ -11952,19 +12090,19 @@ var SearchCommand = {
|
|
|
11952
12090
|
} else if (args.quiet) {
|
|
11953
12091
|
results.forEach((s) => output.log(s.name));
|
|
11954
12092
|
} else {
|
|
11955
|
-
output.log(
|
|
12093
|
+
output.log(chalk25.bold(`Search results for "${args.term}":`));
|
|
11956
12094
|
output.log("");
|
|
11957
12095
|
const header = [
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
12096
|
+
chalk25.bold("Name"),
|
|
12097
|
+
chalk25.bold("Description"),
|
|
12098
|
+
chalk25.bold("Match")
|
|
11961
12099
|
].join(" | ");
|
|
11962
12100
|
const rows = results.map((s) => {
|
|
11963
12101
|
const matchedIn = s.name.toLowerCase().includes(term) ? "name" : "description";
|
|
11964
|
-
const matchColor = matchedIn === "name" ?
|
|
12102
|
+
const matchColor = matchedIn === "name" ? chalk25.green : chalk25.blue;
|
|
11965
12103
|
const desc = s.description.length > 40 ? s.description.slice(0, 37) + "..." : s.description;
|
|
11966
12104
|
return [
|
|
11967
|
-
|
|
12105
|
+
chalk25.cyan(s.name),
|
|
11968
12106
|
desc,
|
|
11969
12107
|
matchColor(`[${matchedIn}]`)
|
|
11970
12108
|
].join(" | ");
|
|
@@ -11976,7 +12114,7 @@ var SearchCommand = {
|
|
|
11976
12114
|
...rows.map((r) => `\u2502${r}\u2502`),
|
|
11977
12115
|
"\u2514" + "\u2500".repeat(header.length + 2) + "\u2518",
|
|
11978
12116
|
"",
|
|
11979
|
-
|
|
12117
|
+
chalk25.gray(`${results.length} matching skill(s) found.`)
|
|
11980
12118
|
].join(`
|
|
11981
12119
|
`));
|
|
11982
12120
|
}
|
|
@@ -11990,7 +12128,7 @@ var SearchCommand = {
|
|
|
11990
12128
|
};
|
|
11991
12129
|
|
|
11992
12130
|
// packages/cli/src/commands/skills/reload.ts
|
|
11993
|
-
import
|
|
12131
|
+
import chalk26 from "chalk";
|
|
11994
12132
|
var ReloadCommand = {
|
|
11995
12133
|
command: "reload",
|
|
11996
12134
|
describe: "\u91CD\u65B0\u626B\u63CF\u5E76\u66F4\u65B0 SkillTool",
|
|
@@ -12013,10 +12151,10 @@ var ReloadCommand = {
|
|
|
12013
12151
|
output.error("SkillComponent not available");
|
|
12014
12152
|
process.exit(1);
|
|
12015
12153
|
}
|
|
12016
|
-
output.log(
|
|
12154
|
+
output.log(chalk26.blue("Reloading skills..."));
|
|
12017
12155
|
await skillComponent.reload();
|
|
12018
12156
|
const skills = skillComponent.getSkillList();
|
|
12019
|
-
output.log(
|
|
12157
|
+
output.log(chalk26.green(`Successfully reloaded ${skills.length} skills`));
|
|
12020
12158
|
} catch (error) {
|
|
12021
12159
|
output.error(`Failed to reload skills: ${error}`);
|
|
12022
12160
|
process.exit(1);
|
|
@@ -12027,7 +12165,7 @@ var ReloadCommand = {
|
|
|
12027
12165
|
};
|
|
12028
12166
|
|
|
12029
12167
|
// packages/cli/src/commands/skills/show-config.ts
|
|
12030
|
-
import
|
|
12168
|
+
import chalk27 from "chalk";
|
|
12031
12169
|
var ShowConfigCommand = {
|
|
12032
12170
|
command: "show-config",
|
|
12033
12171
|
aliases: ["config"],
|
|
@@ -12052,38 +12190,38 @@ var ShowConfigCommand = {
|
|
|
12052
12190
|
process.exit(1);
|
|
12053
12191
|
}
|
|
12054
12192
|
const defaultConfig = skillComponent.getConfig?.();
|
|
12055
|
-
output.log(
|
|
12193
|
+
output.log(chalk27.bold.cyan(`# Skills Configuration
|
|
12056
12194
|
`));
|
|
12057
|
-
output.log(
|
|
12195
|
+
output.log(chalk27.bold(`## Scan Paths
|
|
12058
12196
|
`));
|
|
12059
12197
|
const paths = [
|
|
12060
12198
|
{ type: "user", desc: "\u7528\u6237\u8DEF\u5F84", path: "~/.config/roy-agent/skills/" },
|
|
12061
12199
|
{ type: "project", desc: "\u9879\u76EE\u8DEF\u5F84", path: ".roy/skills/" }
|
|
12062
12200
|
];
|
|
12063
12201
|
for (const p of paths) {
|
|
12064
|
-
const typeColor = p.type === "project" ?
|
|
12065
|
-
output.log(` ${typeColor("[ " + p.type + " ]")} ${
|
|
12066
|
-
output.log(` ${
|
|
12202
|
+
const typeColor = p.type === "project" ? chalk27.green : chalk27.blue;
|
|
12203
|
+
output.log(` ${typeColor("[ " + p.type + " ]")} ${chalk27.gray(p.desc)}`);
|
|
12204
|
+
output.log(` ${chalk27.cyan(p.path)}
|
|
12067
12205
|
`);
|
|
12068
12206
|
}
|
|
12069
|
-
output.log(
|
|
12207
|
+
output.log(chalk27.bold(`## Scan Rules
|
|
12070
12208
|
`));
|
|
12071
|
-
output.log(` ${
|
|
12072
|
-
output.log(` ${
|
|
12073
|
-
output.log(` ${
|
|
12209
|
+
output.log(` ${chalk27.gray("Pattern:")} ${chalk27.cyan("**/SKILL.md")}`);
|
|
12210
|
+
output.log(` ${chalk27.gray("Recursive:")} ${chalk27.green("true")}`);
|
|
12211
|
+
output.log(` ${chalk27.gray("Ignore:")} ${chalk27.cyan("**/node_modules/**")}
|
|
12074
12212
|
`);
|
|
12075
|
-
output.log(
|
|
12213
|
+
output.log(chalk27.bold(`## Priority (High to Low)
|
|
12076
12214
|
`));
|
|
12077
|
-
output.log(` ${
|
|
12078
|
-
output.log(` ${
|
|
12079
|
-
output.log(` ${
|
|
12215
|
+
output.log(` ${chalk27.green("1. project")} - \u9879\u76EE\u8DEF\u5F84\uFF08\u6700\u9AD8\u4F18\u5148\u7EA7\uFF09`);
|
|
12216
|
+
output.log(` ${chalk27.blue("2. user")} - \u7528\u6237\u8DEF\u5F84`);
|
|
12217
|
+
output.log(` ${chalk27.gray("3. built-in")} - \u5185\u7F6E\u8DEF\u5F84\uFF08\u9884\u7559\uFF09
|
|
12080
12218
|
`);
|
|
12081
|
-
output.log(
|
|
12219
|
+
output.log(chalk27.bold(`## Usage
|
|
12082
12220
|
`));
|
|
12083
|
-
output.log(` ${
|
|
12084
|
-
output.log(` ${
|
|
12085
|
-
output.log(` ${
|
|
12086
|
-
output.log(` ${
|
|
12221
|
+
output.log(` ${chalk27.cyan("roy-agent skills list")} ${chalk27.gray("- \u5217\u51FA\u6240\u6709\u6280\u80FD")}`);
|
|
12222
|
+
output.log(` ${chalk27.cyan("roy-agent skills get <name>")} ${chalk27.gray("- \u83B7\u53D6\u6280\u80FD\u5185\u5BB9")}`);
|
|
12223
|
+
output.log(` ${chalk27.cyan("roy-agent skills search <term>")} ${chalk27.gray("- \u641C\u7D22\u6280\u80FD")}`);
|
|
12224
|
+
output.log(` ${chalk27.cyan("roy-agent skills reload")} ${chalk27.gray("- \u91CD\u65B0\u626B\u63CF\u6280\u80FD")}`);
|
|
12087
12225
|
} catch (error) {
|
|
12088
12226
|
output.error(`Failed to show config: ${error}`);
|
|
12089
12227
|
process.exit(1);
|
|
@@ -12104,7 +12242,7 @@ var SkillsCommand = {
|
|
|
12104
12242
|
};
|
|
12105
12243
|
|
|
12106
12244
|
// packages/cli/src/commands/commands-list.ts
|
|
12107
|
-
import
|
|
12245
|
+
import chalk28 from "chalk";
|
|
12108
12246
|
function truncateVisual(str, maxWidth) {
|
|
12109
12247
|
let result = "";
|
|
12110
12248
|
let width = 0;
|
|
@@ -12119,16 +12257,16 @@ function truncateVisual(str, maxWidth) {
|
|
|
12119
12257
|
}
|
|
12120
12258
|
function formatCommandsTable(commands) {
|
|
12121
12259
|
if (commands.length === 0) {
|
|
12122
|
-
return
|
|
12260
|
+
return chalk28.yellow("\u547D\u4EE4\u76EE\u5F55\u4E3A\u7A7A\uFF0C\u4F7F\u7528 'roy-agent commands add' \u6DFB\u52A0\u547D\u4EE4");
|
|
12123
12261
|
}
|
|
12124
12262
|
const NAME_WIDTH = 20;
|
|
12125
12263
|
const SOURCE_WIDTH = 10;
|
|
12126
12264
|
const DESC_WIDTH = 50;
|
|
12127
12265
|
const GAP = " ";
|
|
12128
12266
|
const headerLine = [
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12267
|
+
chalk28.bold("NAME".padEnd(NAME_WIDTH)),
|
|
12268
|
+
chalk28.bold("SOURCE".padEnd(SOURCE_WIDTH)),
|
|
12269
|
+
chalk28.bold("DESCRIPTION")
|
|
12132
12270
|
].join(GAP);
|
|
12133
12271
|
const sepLine = "\u2500".repeat(NAME_WIDTH + SOURCE_WIDTH + DESC_WIDTH + GAP.length * 2);
|
|
12134
12272
|
const formatRow = (cmd) => {
|
|
@@ -12191,7 +12329,7 @@ var CommandsListCommand = {
|
|
|
12191
12329
|
}));
|
|
12192
12330
|
output.log(formatCommandsTable(rows));
|
|
12193
12331
|
output.info("");
|
|
12194
|
-
output.log(
|
|
12332
|
+
output.log(chalk28.green(`\u2705 \u5171 ${result.commands.length} \u4E2A\u547D\u4EE4`) + chalk28.gray(` (user: ${result.stats.userCount}, project: ${result.stats.projectCount})`));
|
|
12195
12333
|
}
|
|
12196
12334
|
} catch (error) {
|
|
12197
12335
|
output.error(`Failed to list commands: ${error}`);
|
|
@@ -12203,7 +12341,7 @@ var CommandsListCommand = {
|
|
|
12203
12341
|
};
|
|
12204
12342
|
|
|
12205
12343
|
// packages/cli/src/commands/commands-add.ts
|
|
12206
|
-
import
|
|
12344
|
+
import chalk29 from "chalk";
|
|
12207
12345
|
var CommandsAddCommand = {
|
|
12208
12346
|
command: "add <name> <target>",
|
|
12209
12347
|
describe: "\u6DFB\u52A0\u6536\u85CF\u547D\u4EE4\uFF08\u81EA\u52A8\u521B\u5EFA symlink\uFF09",
|
|
@@ -12264,10 +12402,10 @@ var CommandsAddCommand = {
|
|
|
12264
12402
|
});
|
|
12265
12403
|
const dirs = await commandsComponent.getCommandDirs();
|
|
12266
12404
|
const targetDir = source === "user" ? dirs.user : dirs.project;
|
|
12267
|
-
output.log(
|
|
12268
|
-
output.log(
|
|
12269
|
-
output.log(
|
|
12270
|
-
output.log(
|
|
12405
|
+
output.log(chalk29.green(`\u2705 \u5DF2\u6DFB\u52A0\u547D\u4EE4 '${args.name}'`));
|
|
12406
|
+
output.log(chalk29.gray(` \u76EE\u6807: ${args.target}`));
|
|
12407
|
+
output.log(chalk29.gray(` \u4F4D\u7F6E: ${targetDir}/${args.name}`));
|
|
12408
|
+
output.log(chalk29.gray(` \u7EA7\u522B: ${source === "user" ? "USER" : "PROJECT"}`));
|
|
12271
12409
|
} catch (error) {
|
|
12272
12410
|
output.error(`\u6DFB\u52A0\u5931\u8D25: ${error.message}`);
|
|
12273
12411
|
process.exit(1);
|
|
@@ -12278,7 +12416,7 @@ var CommandsAddCommand = {
|
|
|
12278
12416
|
};
|
|
12279
12417
|
|
|
12280
12418
|
// packages/cli/src/commands/commands-remove.ts
|
|
12281
|
-
import
|
|
12419
|
+
import chalk30 from "chalk";
|
|
12282
12420
|
var CommandsRemoveCommand = {
|
|
12283
12421
|
command: "remove <name>",
|
|
12284
12422
|
aliases: ["rm"],
|
|
@@ -12322,7 +12460,7 @@ var CommandsRemoveCommand = {
|
|
|
12322
12460
|
name: args.name,
|
|
12323
12461
|
source: "user"
|
|
12324
12462
|
});
|
|
12325
|
-
output.log(
|
|
12463
|
+
output.log(chalk30.green(`\u2705 \u5DF2\u4ECE\u7528\u6237\u76EE\u5F55\u79FB\u9664\u547D\u4EE4 '${args.name}'`));
|
|
12326
12464
|
} catch (error) {
|
|
12327
12465
|
if (!error.message?.includes("\u4E0D\u5B58\u5728")) {
|
|
12328
12466
|
throw error;
|
|
@@ -12335,7 +12473,7 @@ var CommandsRemoveCommand = {
|
|
|
12335
12473
|
name: args.name,
|
|
12336
12474
|
source: "project"
|
|
12337
12475
|
});
|
|
12338
|
-
output.log(
|
|
12476
|
+
output.log(chalk30.green(`\u2705 \u5DF2\u4ECE\u9879\u76EE\u76EE\u5F55\u79FB\u9664\u547D\u4EE4 '${args.name}'`));
|
|
12339
12477
|
} catch (error) {
|
|
12340
12478
|
if (!error.message?.includes("\u4E0D\u5B58\u5728")) {
|
|
12341
12479
|
throw error;
|
|
@@ -12349,7 +12487,7 @@ var CommandsRemoveCommand = {
|
|
|
12349
12487
|
name: args.name,
|
|
12350
12488
|
source: "user"
|
|
12351
12489
|
});
|
|
12352
|
-
output.log(
|
|
12490
|
+
output.log(chalk30.green(`\u2705 \u5DF2\u4ECE\u7528\u6237\u76EE\u5F55\u79FB\u9664\u547D\u4EE4 '${args.name}'`));
|
|
12353
12491
|
removed = true;
|
|
12354
12492
|
} catch (error) {
|
|
12355
12493
|
if (!error.message?.includes("\u4E0D\u5B58\u5728")) {
|
|
@@ -12361,7 +12499,7 @@ var CommandsRemoveCommand = {
|
|
|
12361
12499
|
name: args.name,
|
|
12362
12500
|
source: "project"
|
|
12363
12501
|
});
|
|
12364
|
-
output.log(
|
|
12502
|
+
output.log(chalk30.green(`\u2705 \u5DF2\u4ECE\u9879\u76EE\u76EE\u5F55\u79FB\u9664\u547D\u4EE4 '${args.name}'`));
|
|
12365
12503
|
removed = true;
|
|
12366
12504
|
} catch (error) {
|
|
12367
12505
|
if (!error.message?.includes("\u4E0D\u5B58\u5728")) {
|
|
@@ -12383,7 +12521,7 @@ var CommandsRemoveCommand = {
|
|
|
12383
12521
|
};
|
|
12384
12522
|
|
|
12385
12523
|
// packages/cli/src/commands/commands-info.ts
|
|
12386
|
-
import
|
|
12524
|
+
import chalk31 from "chalk";
|
|
12387
12525
|
import { exec } from "child_process";
|
|
12388
12526
|
import { promisify } from "util";
|
|
12389
12527
|
var execAsync = promisify(exec);
|
|
@@ -12418,12 +12556,12 @@ var CommandsInfoCommand = {
|
|
|
12418
12556
|
output.error(`\u547D\u4EE4 '${args.name}' \u4E0D\u5B58\u5728`);
|
|
12419
12557
|
process.exit(1);
|
|
12420
12558
|
}
|
|
12421
|
-
output.log(
|
|
12422
|
-
output.log(
|
|
12423
|
-
output.log(
|
|
12424
|
-
output.log(
|
|
12559
|
+
output.log(chalk31.bold("Name:") + ` ${info.name}`);
|
|
12560
|
+
output.log(chalk31.bold("Path:") + ` ${info.path}`);
|
|
12561
|
+
output.log(chalk31.bold("Source:") + ` ${info.source.toUpperCase()}`);
|
|
12562
|
+
output.log(chalk31.bold("Description:") + ` ${info.shortDescription || "-"}`);
|
|
12425
12563
|
output.log();
|
|
12426
|
-
output.log(
|
|
12564
|
+
output.log(chalk31.gray("\u2500".repeat(50)));
|
|
12427
12565
|
output.log();
|
|
12428
12566
|
try {
|
|
12429
12567
|
const { stdout } = await execAsync(`${info.path} --help`, { timeout: 5000 });
|
|
@@ -12433,7 +12571,7 @@ var CommandsInfoCommand = {
|
|
|
12433
12571
|
const { stdout } = await execAsync(`${info.path} -h`, { timeout: 5000 });
|
|
12434
12572
|
output.log(stdout);
|
|
12435
12573
|
} catch {
|
|
12436
|
-
output.log(
|
|
12574
|
+
output.log(chalk31.gray("\uFF08\u65E0\u6CD5\u83B7\u53D6\u5E2E\u52A9\u4FE1\u606F\uFF09"));
|
|
12437
12575
|
}
|
|
12438
12576
|
}
|
|
12439
12577
|
} catch (error) {
|
|
@@ -12446,7 +12584,7 @@ var CommandsInfoCommand = {
|
|
|
12446
12584
|
};
|
|
12447
12585
|
|
|
12448
12586
|
// packages/cli/src/commands/commands-dirs.ts
|
|
12449
|
-
import
|
|
12587
|
+
import chalk32 from "chalk";
|
|
12450
12588
|
var CommandsDirsCommand = {
|
|
12451
12589
|
command: "dirs",
|
|
12452
12590
|
describe: "\u663E\u793A\u547D\u4EE4\u76EE\u5F55",
|
|
@@ -12478,10 +12616,10 @@ var CommandsDirsCommand = {
|
|
|
12478
12616
|
if (args.json) {
|
|
12479
12617
|
output.json(dirs);
|
|
12480
12618
|
} else {
|
|
12481
|
-
output.log(
|
|
12619
|
+
output.log(chalk32.bold("\u547D\u4EE4\u76EE\u5F55:"));
|
|
12482
12620
|
output.log();
|
|
12483
|
-
output.log(
|
|
12484
|
-
output.log(
|
|
12621
|
+
output.log(chalk32.cyan("USER:") + ` ${dirs.user}`);
|
|
12622
|
+
output.log(chalk32.cyan("PROJECT:") + ` ${dirs.project}`);
|
|
12485
12623
|
}
|
|
12486
12624
|
} catch (error) {
|
|
12487
12625
|
output.error(`\u9519\u8BEF: ${error.message}`);
|
|
@@ -12501,7 +12639,7 @@ var CommandsCommand = {
|
|
|
12501
12639
|
};
|
|
12502
12640
|
|
|
12503
12641
|
// packages/cli/src/commands/config/list.ts
|
|
12504
|
-
import
|
|
12642
|
+
import chalk33 from "chalk";
|
|
12505
12643
|
|
|
12506
12644
|
// packages/cli/src/commands/config/config-service.ts
|
|
12507
12645
|
import * as fsSync from "fs";
|
|
@@ -12797,7 +12935,7 @@ var ConfigListCommand = {
|
|
|
12797
12935
|
output.log("");
|
|
12798
12936
|
output.log("Supported components:");
|
|
12799
12937
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
12800
|
-
output.log(` ${
|
|
12938
|
+
output.log(` ${chalk33.cyan(comp.padEnd(15))} ${COMPONENT_DESCRIPTIONS[comp] || ""}`);
|
|
12801
12939
|
}
|
|
12802
12940
|
process.exit(1);
|
|
12803
12941
|
}
|
|
@@ -12815,27 +12953,27 @@ var ConfigListCommand = {
|
|
|
12815
12953
|
}
|
|
12816
12954
|
};
|
|
12817
12955
|
function showHelp(output) {
|
|
12818
|
-
output.log(
|
|
12956
|
+
output.log(chalk33.bold.cyan("# roy-agent config list"));
|
|
12819
12957
|
output.log("");
|
|
12820
12958
|
output.log("\u67E5\u770B roy-agent \u7EC4\u4EF6\u914D\u7F6E\u4FE1\u606F");
|
|
12821
12959
|
output.log("");
|
|
12822
|
-
output.log(
|
|
12823
|
-
output.log(` ${
|
|
12960
|
+
output.log(chalk33.bold("Usage:"));
|
|
12961
|
+
output.log(` ${chalk33.cyan("roy-agent config list [component] [options]")}`);
|
|
12824
12962
|
output.log("");
|
|
12825
|
-
output.log(
|
|
12963
|
+
output.log(chalk33.bold("Components:"));
|
|
12826
12964
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
12827
|
-
output.log(` ${
|
|
12965
|
+
output.log(` ${chalk33.cyan(comp.padEnd(15))} ${chalk33.gray(COMPONENT_DESCRIPTIONS[comp] || "")}`);
|
|
12828
12966
|
}
|
|
12829
|
-
output.log(` ${
|
|
12967
|
+
output.log(` ${chalk33.cyan("all".padEnd(15))} \u663E\u793A\u6240\u6709 components \u6982\u89C8`);
|
|
12830
12968
|
output.log("");
|
|
12831
|
-
output.log(
|
|
12832
|
-
output.log(` ${
|
|
12833
|
-
output.log(` ${
|
|
12834
|
-
output.log(` ${
|
|
12969
|
+
output.log(chalk33.bold("Options:"));
|
|
12970
|
+
output.log(` ${chalk33.cyan("-j, --json")} JSON \u683C\u5F0F\u8F93\u51FA`);
|
|
12971
|
+
output.log(` ${chalk33.cyan("-k, --keys")} \u53EA\u663E\u793A\u914D\u7F6E\u952E`);
|
|
12972
|
+
output.log(` ${chalk33.cyan("-s, --sources")} \u53EA\u663E\u793A\u914D\u7F6E\u6E90`);
|
|
12835
12973
|
output.log("");
|
|
12836
|
-
output.log(
|
|
12974
|
+
output.log(chalk33.bold("Examples:"));
|
|
12837
12975
|
for (const { command, description } of USAGE_COMMANDS) {
|
|
12838
|
-
output.log(` ${
|
|
12976
|
+
output.log(` ${chalk33.cyan(command.padEnd(40))} ${chalk33.gray(description)}`);
|
|
12839
12977
|
}
|
|
12840
12978
|
}
|
|
12841
12979
|
async function showAllComponents(output, configService) {
|
|
@@ -12844,13 +12982,13 @@ async function showAllComponents(output, configService) {
|
|
|
12844
12982
|
const config = configService.getComponentConfig(compName);
|
|
12845
12983
|
components.push({ name: compName, config });
|
|
12846
12984
|
}
|
|
12847
|
-
output.log(
|
|
12985
|
+
output.log(chalk33.bold.cyan("# All Components Overview"));
|
|
12848
12986
|
output.log("");
|
|
12849
|
-
output.log(` ${
|
|
12850
|
-
output.log(` ${
|
|
12987
|
+
output.log(` ${chalk33.cyan("Component".padEnd(15))} ${chalk33.cyan("Keys".padEnd(10))} ${chalk33.gray("Description")}`);
|
|
12988
|
+
output.log(` ${chalk33.gray("\u2500".repeat(60))}`);
|
|
12851
12989
|
for (const comp of components) {
|
|
12852
12990
|
const keyCount = Object.keys(comp.config).length;
|
|
12853
|
-
output.log(` ${
|
|
12991
|
+
output.log(` ${chalk33.cyan(comp.name.padEnd(15))} ${keyCount.toString().padEnd(10)} ${chalk33.gray(COMPONENT_DESCRIPTIONS[comp.name] || "")}`);
|
|
12854
12992
|
}
|
|
12855
12993
|
}
|
|
12856
12994
|
async function showComponentConfig(componentName, output, configService, options) {
|
|
@@ -12864,22 +13002,22 @@ async function showComponentConfig(componentName, output, configService, options
|
|
|
12864
13002
|
});
|
|
12865
13003
|
return;
|
|
12866
13004
|
}
|
|
12867
|
-
output.log(
|
|
13005
|
+
output.log(chalk33.bold.cyan(`# ${componentName} Component Configuration`));
|
|
12868
13006
|
output.log("");
|
|
12869
13007
|
if (filePath) {
|
|
12870
|
-
output.log(
|
|
12871
|
-
output.log(` ${
|
|
13008
|
+
output.log(chalk33.bold("File:"));
|
|
13009
|
+
output.log(` ${chalk33.cyan(filePath)}`);
|
|
12872
13010
|
output.log("");
|
|
12873
13011
|
}
|
|
12874
13012
|
if (!options.sources) {
|
|
12875
|
-
output.log(
|
|
13013
|
+
output.log(chalk33.bold("Configuration:"));
|
|
12876
13014
|
if (Object.keys(config).length === 0) {
|
|
12877
|
-
output.log(` ${
|
|
13015
|
+
output.log(` ${chalk33.gray("\uFF08\u65E0\u914D\u7F6E\uFF09")}`);
|
|
12878
13016
|
} else {
|
|
12879
13017
|
const flatConfig = flattenConfig(config);
|
|
12880
13018
|
for (const [key, value] of flatConfig) {
|
|
12881
13019
|
const displayValue = formatValue(value);
|
|
12882
|
-
output.log(` ${
|
|
13020
|
+
output.log(` ${chalk33.cyan(key + ":")} ${displayValue}`);
|
|
12883
13021
|
}
|
|
12884
13022
|
}
|
|
12885
13023
|
output.log("");
|
|
@@ -12905,19 +13043,19 @@ function flattenConfig(obj, prefix = "") {
|
|
|
12905
13043
|
}
|
|
12906
13044
|
function formatValue(value) {
|
|
12907
13045
|
if (value === undefined) {
|
|
12908
|
-
return
|
|
13046
|
+
return chalk33.gray("undefined");
|
|
12909
13047
|
}
|
|
12910
13048
|
if (value === null) {
|
|
12911
|
-
return
|
|
13049
|
+
return chalk33.gray("null");
|
|
12912
13050
|
}
|
|
12913
13051
|
if (typeof value === "object") {
|
|
12914
|
-
return
|
|
13052
|
+
return chalk33.gray(JSON.stringify(value));
|
|
12915
13053
|
}
|
|
12916
13054
|
return String(value);
|
|
12917
13055
|
}
|
|
12918
13056
|
|
|
12919
13057
|
// packages/cli/src/commands/config/export.ts
|
|
12920
|
-
import
|
|
13058
|
+
import chalk34 from "chalk";
|
|
12921
13059
|
var ConfigExportCommand = {
|
|
12922
13060
|
command: "export <component>",
|
|
12923
13061
|
describe: "\u5BFC\u51FA\u7EC4\u4EF6\u914D\u7F6E\u5230\u6587\u4EF6",
|
|
@@ -12962,7 +13100,7 @@ var ConfigExportCommand = {
|
|
|
12962
13100
|
output.log("");
|
|
12963
13101
|
output.log("Supported components:");
|
|
12964
13102
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
12965
|
-
output.log(` ${
|
|
13103
|
+
output.log(` ${chalk34.cyan(comp)}`);
|
|
12966
13104
|
}
|
|
12967
13105
|
process.exit(1);
|
|
12968
13106
|
}
|
|
@@ -12980,7 +13118,7 @@ var ConfigExportCommand = {
|
|
|
12980
13118
|
};
|
|
12981
13119
|
|
|
12982
13120
|
// packages/cli/src/commands/config/import.ts
|
|
12983
|
-
import
|
|
13121
|
+
import chalk35 from "chalk";
|
|
12984
13122
|
var ConfigImportCommand = {
|
|
12985
13123
|
command: "import <component>",
|
|
12986
13124
|
describe: "\u4ECE\u6587\u4EF6\u5BFC\u5165\u914D\u7F6E\u5230\u7EC4\u4EF6\u7684 file source",
|
|
@@ -13030,7 +13168,7 @@ var ConfigImportCommand = {
|
|
|
13030
13168
|
output.log("");
|
|
13031
13169
|
output.log("Supported components:");
|
|
13032
13170
|
for (const comp of SUPPORTED_COMPONENTS) {
|
|
13033
|
-
output.log(` ${
|
|
13171
|
+
output.log(` ${chalk35.cyan(comp)}`);
|
|
13034
13172
|
}
|
|
13035
13173
|
process.exit(1);
|
|
13036
13174
|
}
|
|
@@ -13045,7 +13183,7 @@ var ConfigImportCommand = {
|
|
|
13045
13183
|
}
|
|
13046
13184
|
if (result.merged && result.changes.length > 0 && args.verbose) {
|
|
13047
13185
|
output.log("");
|
|
13048
|
-
output.log(
|
|
13186
|
+
output.log(chalk35.bold("\u53D8\u66F4\u8BE6\u60C5:"));
|
|
13049
13187
|
for (const change of result.changes) {
|
|
13050
13188
|
output.log(` ${change.key}: ${JSON.stringify(change.oldValue)} \u2192 ${JSON.stringify(change.newValue)}`);
|
|
13051
13189
|
}
|
|
@@ -13069,7 +13207,7 @@ var ConfigCommand = {
|
|
|
13069
13207
|
};
|
|
13070
13208
|
|
|
13071
13209
|
// packages/cli/src/commands/mcp/list.ts
|
|
13072
|
-
import
|
|
13210
|
+
import chalk36 from "chalk";
|
|
13073
13211
|
var ListCommand4 = {
|
|
13074
13212
|
command: "list",
|
|
13075
13213
|
aliases: ["ls"],
|
|
@@ -13115,30 +13253,30 @@ var ListCommand4 = {
|
|
|
13115
13253
|
servers.forEach((s) => output.log(s.name));
|
|
13116
13254
|
} else {
|
|
13117
13255
|
if (servers.length === 0) {
|
|
13118
|
-
output.log(
|
|
13256
|
+
output.log(chalk36.yellow("No MCP servers configured"));
|
|
13119
13257
|
return;
|
|
13120
13258
|
}
|
|
13121
13259
|
const statusColor = (status) => {
|
|
13122
13260
|
switch (status) {
|
|
13123
13261
|
case "connected":
|
|
13124
|
-
return
|
|
13262
|
+
return chalk36.green;
|
|
13125
13263
|
case "connecting":
|
|
13126
|
-
return
|
|
13264
|
+
return chalk36.yellow;
|
|
13127
13265
|
case "error":
|
|
13128
|
-
return
|
|
13266
|
+
return chalk36.red;
|
|
13129
13267
|
case "disconnected":
|
|
13130
|
-
return
|
|
13268
|
+
return chalk36.gray;
|
|
13131
13269
|
default:
|
|
13132
|
-
return
|
|
13270
|
+
return chalk36.white;
|
|
13133
13271
|
}
|
|
13134
13272
|
};
|
|
13135
13273
|
const header = [
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13274
|
+
chalk36.bold("Name"),
|
|
13275
|
+
chalk36.bold("Status"),
|
|
13276
|
+
chalk36.bold("Tools")
|
|
13139
13277
|
].join(" | ");
|
|
13140
13278
|
const rows = servers.map((s) => [
|
|
13141
|
-
|
|
13279
|
+
chalk36.cyan(s.name),
|
|
13142
13280
|
statusColor(s.status)(`[${s.status}]`),
|
|
13143
13281
|
s.toolsCount !== undefined ? String(s.toolsCount) : "-"
|
|
13144
13282
|
].join(" | "));
|
|
@@ -13149,7 +13287,7 @@ var ListCommand4 = {
|
|
|
13149
13287
|
...rows.map((r) => `\u2502${r}\u2502`),
|
|
13150
13288
|
"\u2514" + "\u2500".repeat(header.length + 2) + "\u2518",
|
|
13151
13289
|
"",
|
|
13152
|
-
|
|
13290
|
+
chalk36.gray(`Total: ${servers.length} servers`)
|
|
13153
13291
|
].join(`
|
|
13154
13292
|
`));
|
|
13155
13293
|
}
|
|
@@ -13163,7 +13301,7 @@ var ListCommand4 = {
|
|
|
13163
13301
|
};
|
|
13164
13302
|
|
|
13165
13303
|
// packages/cli/src/commands/mcp/tools.ts
|
|
13166
|
-
import
|
|
13304
|
+
import chalk37 from "chalk";
|
|
13167
13305
|
var ToolsCommand = {
|
|
13168
13306
|
command: "tools",
|
|
13169
13307
|
aliases: ["t"],
|
|
@@ -13216,7 +13354,7 @@ var ToolsCommand = {
|
|
|
13216
13354
|
tools.forEach((t) => output.log(t.name));
|
|
13217
13355
|
} else {
|
|
13218
13356
|
if (tools.length === 0) {
|
|
13219
|
-
output.log(
|
|
13357
|
+
output.log(chalk37.yellow("No MCP tools available"));
|
|
13220
13358
|
return;
|
|
13221
13359
|
}
|
|
13222
13360
|
const byServer = new Map;
|
|
@@ -13228,15 +13366,15 @@ var ToolsCommand = {
|
|
|
13228
13366
|
byServer.get(serverName).push(tool);
|
|
13229
13367
|
}
|
|
13230
13368
|
for (const [serverName, serverTools] of byServer) {
|
|
13231
|
-
output.log(
|
|
13369
|
+
output.log(chalk37.bold.cyan(`
|
|
13232
13370
|
[${serverName}] ${serverTools.length} tools`));
|
|
13233
13371
|
for (const tool of serverTools) {
|
|
13234
13372
|
const desc = tool.description.length > 80 ? tool.description.slice(0, 77) + "..." : tool.description;
|
|
13235
|
-
output.log(` ${
|
|
13236
|
-
output.log(` ${
|
|
13373
|
+
output.log(` ${chalk37.green("+")} ${chalk37.white(tool.name)}`);
|
|
13374
|
+
output.log(` ${chalk37.gray(desc)}`);
|
|
13237
13375
|
}
|
|
13238
13376
|
}
|
|
13239
|
-
output.log(
|
|
13377
|
+
output.log(chalk37.gray(`
|
|
13240
13378
|
Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
13241
13379
|
}
|
|
13242
13380
|
} catch (error) {
|
|
@@ -13249,7 +13387,7 @@ Total: ${tools.length} tools across ${byServer.size} servers`));
|
|
|
13249
13387
|
};
|
|
13250
13388
|
|
|
13251
13389
|
// packages/cli/src/commands/mcp/reload.ts
|
|
13252
|
-
import
|
|
13390
|
+
import chalk38 from "chalk";
|
|
13253
13391
|
var ReloadCommand2 = {
|
|
13254
13392
|
command: "reload",
|
|
13255
13393
|
aliases: ["r"],
|
|
@@ -13270,19 +13408,19 @@ var ReloadCommand2 = {
|
|
|
13270
13408
|
output.error("McpComponent not available");
|
|
13271
13409
|
process.exit(1);
|
|
13272
13410
|
}
|
|
13273
|
-
output.log(
|
|
13411
|
+
output.log(chalk38.cyan("Reloading MCP servers..."));
|
|
13274
13412
|
await mcpComponent.reload();
|
|
13275
13413
|
const servers = mcpComponent.listServers();
|
|
13276
13414
|
const connected = servers.filter((s) => s.status === "connected").length;
|
|
13277
13415
|
const errors = servers.filter((s) => s.status === "error").length;
|
|
13278
|
-
output.log(
|
|
13416
|
+
output.log(chalk38.green(`\u2713 Reloaded ${servers.length} servers`));
|
|
13279
13417
|
if (connected > 0) {
|
|
13280
|
-
output.log(
|
|
13418
|
+
output.log(chalk38.green(` \u2022 ${connected} connected`));
|
|
13281
13419
|
}
|
|
13282
13420
|
if (errors > 0) {
|
|
13283
13421
|
output.warn(` \u2022 ${errors} failed`);
|
|
13284
13422
|
for (const server of servers.filter((s) => s.status === "error")) {
|
|
13285
|
-
output.log(
|
|
13423
|
+
output.log(chalk38.gray(` - ${server.name}: ${server.error}`));
|
|
13286
13424
|
}
|
|
13287
13425
|
}
|
|
13288
13426
|
} catch (error) {
|
|
@@ -13303,7 +13441,7 @@ var McpCommand = {
|
|
|
13303
13441
|
};
|
|
13304
13442
|
|
|
13305
13443
|
// packages/cli/src/commands/tools/list.ts
|
|
13306
|
-
import
|
|
13444
|
+
import chalk39 from "chalk";
|
|
13307
13445
|
var ListCommand5 = {
|
|
13308
13446
|
command: "list",
|
|
13309
13447
|
aliases: ["ls"],
|
|
@@ -13348,16 +13486,16 @@ var ListCommand5 = {
|
|
|
13348
13486
|
tools.forEach((t) => output.log(t.name));
|
|
13349
13487
|
} else {
|
|
13350
13488
|
const header = [
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13489
|
+
chalk39.bold("Name"),
|
|
13490
|
+
chalk39.bold("Description"),
|
|
13491
|
+
chalk39.bold("Category")
|
|
13354
13492
|
].join(" | ");
|
|
13355
13493
|
const rows = tools.map((t) => {
|
|
13356
13494
|
const desc = t.description.length > 40 ? t.description.slice(0, 37) + "..." : t.description;
|
|
13357
13495
|
return [
|
|
13358
|
-
|
|
13496
|
+
chalk39.cyan(t.name),
|
|
13359
13497
|
desc,
|
|
13360
|
-
t.metadata?.category ?
|
|
13498
|
+
t.metadata?.category ? chalk39.gray(`[${t.metadata.category}]`) : "-"
|
|
13361
13499
|
].join(" | ");
|
|
13362
13500
|
});
|
|
13363
13501
|
output.log([
|
|
@@ -13367,7 +13505,7 @@ var ListCommand5 = {
|
|
|
13367
13505
|
...rows.map((r) => `\u2502${r}\u2502`),
|
|
13368
13506
|
"\u2514" + "\u2500".repeat(header.length + 2) + "\u2518",
|
|
13369
13507
|
"",
|
|
13370
|
-
|
|
13508
|
+
chalk39.gray(`Total: ${tools.length} tools`)
|
|
13371
13509
|
].join(`
|
|
13372
13510
|
`));
|
|
13373
13511
|
}
|
|
@@ -13381,7 +13519,7 @@ var ListCommand5 = {
|
|
|
13381
13519
|
};
|
|
13382
13520
|
|
|
13383
13521
|
// packages/cli/src/commands/tools/get.ts
|
|
13384
|
-
import
|
|
13522
|
+
import chalk40 from "chalk";
|
|
13385
13523
|
|
|
13386
13524
|
// packages/cli/src/commands/tools/shared/schema-helper.ts
|
|
13387
13525
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -13456,8 +13594,8 @@ var GetCommand4 = {
|
|
|
13456
13594
|
}))
|
|
13457
13595
|
});
|
|
13458
13596
|
} else {
|
|
13459
|
-
output.log(
|
|
13460
|
-
output.log(
|
|
13597
|
+
output.log(chalk40.bold.cyan(`Tool: ${tool.name}`));
|
|
13598
|
+
output.log(chalk40.gray("\u2500".repeat(60)));
|
|
13461
13599
|
output.log(`Description: ${tool.description}`);
|
|
13462
13600
|
if (tool.metadata?.category) {
|
|
13463
13601
|
output.log(`Category: ${tool.metadata.category}`);
|
|
@@ -13466,9 +13604,9 @@ var GetCommand4 = {
|
|
|
13466
13604
|
output.log(`Tags: ${tool.metadata.tags.join(", ")}`);
|
|
13467
13605
|
}
|
|
13468
13606
|
output.log("");
|
|
13469
|
-
output.log(
|
|
13607
|
+
output.log(chalk40.bold("Parameters:"));
|
|
13470
13608
|
for (const param of params) {
|
|
13471
|
-
const required = param.required ?
|
|
13609
|
+
const required = param.required ? chalk40.red("(required)") : chalk40.gray("(optional)");
|
|
13472
13610
|
const defaultVal = param.default !== undefined ? ` [default: ${JSON.stringify(param.default)}]` : "";
|
|
13473
13611
|
output.log(` --${param.name} <${param.type}> ${required}`);
|
|
13474
13612
|
output.log(` ${param.description}${defaultVal}`);
|
|
@@ -13577,14 +13715,14 @@ var ToolsCommand2 = {
|
|
|
13577
13715
|
};
|
|
13578
13716
|
|
|
13579
13717
|
// packages/cli/src/commands/memory/record.ts
|
|
13580
|
-
import
|
|
13718
|
+
import chalk41 from "chalk";
|
|
13581
13719
|
import { createMemoryAgentTools, getBuiltInPrompt } from "@ai-setting/roy-agent-core";
|
|
13582
13720
|
import { bashTool, globTool, readFileTool } from "@ai-setting/roy-agent-core";
|
|
13583
13721
|
async function runExtractMode(output, memoryComponent, agentComponent, sessionComponent, env, options) {
|
|
13584
13722
|
const { scope, sessionId, require: userRequirement } = options;
|
|
13585
|
-
output.log(
|
|
13723
|
+
output.log(chalk41.blue(`
|
|
13586
13724
|
\uD83D\uDD0D Memory Extract Mode (${scope})`));
|
|
13587
|
-
output.log(
|
|
13725
|
+
output.log(chalk41.gray(`\u6B63\u5728\u5206\u6790\u4F1A\u8BDD\u5386\u53F2\uFF0C\u751F\u6210\u8BB0\u5FC6...
|
|
13588
13726
|
`));
|
|
13589
13727
|
try {
|
|
13590
13728
|
const currentMemory = await memoryComponent.recallMemory(scope) || "(\u65E0\u73B0\u6709\u8BB0\u5FC6)";
|
|
@@ -13630,13 +13768,13 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
13630
13768
|
for (const tool of agentTools) {
|
|
13631
13769
|
try {
|
|
13632
13770
|
toolComponent.register(tool);
|
|
13633
|
-
output.log(
|
|
13771
|
+
output.log(chalk41.gray(`Tool registered: ${tool.name}`));
|
|
13634
13772
|
} catch (err) {
|
|
13635
|
-
output.log(
|
|
13773
|
+
output.log(chalk41.gray(`Tool already registered: ${tool.name}`));
|
|
13636
13774
|
}
|
|
13637
13775
|
}
|
|
13638
13776
|
}
|
|
13639
|
-
output.log(
|
|
13777
|
+
output.log(chalk41.gray(`Agent "${agentName}" registered with ${agentTools.length} tools`));
|
|
13640
13778
|
const query = `\u8BF7\u5206\u6790\u4F1A\u8BDD\u5386\u53F2\uFF0C\u63D0\u70BC${scope === "project" ? "\u9879\u76EE" : "\u5168\u5C40"}\u8BB0\u5FC6\u5E76\u5199\u5165\u8BB0\u5FC6\u6587\u4EF6\u3002`;
|
|
13641
13779
|
let result;
|
|
13642
13780
|
try {
|
|
@@ -13650,12 +13788,12 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
|
|
|
13650
13788
|
if (result && result.startsWith("\u6267\u884C\u5931\u8D25")) {
|
|
13651
13789
|
output.error(`\u63D0\u53D6\u5931\u8D25: ${result}`);
|
|
13652
13790
|
} else if (result) {
|
|
13653
|
-
output.log(
|
|
13791
|
+
output.log(chalk41.green(`
|
|
13654
13792
|
\u2705 \u8BB0\u5FC6\u63D0\u53D6\u5B8C\u6210`));
|
|
13655
|
-
output.log(
|
|
13793
|
+
output.log(chalk41.gray(`\u8BB0\u5FC6\u5DF2\u4FDD\u5B58\u5230 memory \u6587\u4EF6\u3002
|
|
13656
13794
|
`));
|
|
13657
13795
|
if (result.length > 0 && result !== "\u2705 \u8BB0\u5FC6\u63D0\u53D6\u5B8C\u6210") {
|
|
13658
|
-
output.log(
|
|
13796
|
+
output.log(chalk41.gray(`\u6267\u884C\u6458\u8981: ${result.substring(0, 200)}${result.length > 200 ? "..." : ""}`));
|
|
13659
13797
|
}
|
|
13660
13798
|
}
|
|
13661
13799
|
agentComponent.unregisterAgent(agentName);
|
|
@@ -13773,11 +13911,11 @@ var RecordCommand = {
|
|
|
13773
13911
|
prepend: "\u5DF2\u63D2\u5165\u5185\u5BB9\u5230\u8BB0\u5FC6\u6587\u4EF6\u5F00\u5934",
|
|
13774
13912
|
delete: "\u5DF2\u5220\u9664\u8BB0\u5FC6\u6587\u4EF6"
|
|
13775
13913
|
};
|
|
13776
|
-
output.log(
|
|
13777
|
-
output.log(
|
|
13914
|
+
output.log(chalk41.green(`\u2713 ${actionMessages[result.action]}`));
|
|
13915
|
+
output.log(chalk41.gray(`\u8DEF\u5F84: ${result.path}`));
|
|
13778
13916
|
if (result.action !== "delete" && a.content) {
|
|
13779
13917
|
const preview = a.content.substring(0, 100);
|
|
13780
|
-
output.log(
|
|
13918
|
+
output.log(chalk41.gray(`\u5185\u5BB9\u9884\u89C8: ${preview}${a.content.length > 100 ? "..." : ""}`));
|
|
13781
13919
|
}
|
|
13782
13920
|
} catch (error) {
|
|
13783
13921
|
output.error(`Failed to record memory: ${error}`);
|
|
@@ -13789,7 +13927,7 @@ var RecordCommand = {
|
|
|
13789
13927
|
};
|
|
13790
13928
|
|
|
13791
13929
|
// packages/cli/src/commands/memory/recall.ts
|
|
13792
|
-
import
|
|
13930
|
+
import chalk42 from "chalk";
|
|
13793
13931
|
var RecallCommand = {
|
|
13794
13932
|
command: "recall",
|
|
13795
13933
|
aliases: ["load"],
|
|
@@ -13825,7 +13963,7 @@ var RecallCommand = {
|
|
|
13825
13963
|
}
|
|
13826
13964
|
const content = await memoryComponent.recallMemory(a.scope);
|
|
13827
13965
|
if (!content) {
|
|
13828
|
-
output.log(
|
|
13966
|
+
output.log(chalk42.gray("(No memory files found)"));
|
|
13829
13967
|
return;
|
|
13830
13968
|
}
|
|
13831
13969
|
if (a.json) {
|
|
@@ -13851,7 +13989,7 @@ var MemoryCommand = {
|
|
|
13851
13989
|
handler: () => {}
|
|
13852
13990
|
};
|
|
13853
13991
|
// packages/cli/src/commands/eventsource/list.ts
|
|
13854
|
-
import
|
|
13992
|
+
import chalk43 from "chalk";
|
|
13855
13993
|
function truncateVisual2(str, maxWidth) {
|
|
13856
13994
|
let result = "";
|
|
13857
13995
|
let width = 0;
|
|
@@ -13866,7 +14004,7 @@ function truncateVisual2(str, maxWidth) {
|
|
|
13866
14004
|
}
|
|
13867
14005
|
function formatSourcesTable(sources) {
|
|
13868
14006
|
if (sources.length === 0) {
|
|
13869
|
-
return
|
|
14007
|
+
return chalk43.yellow("\u6CA1\u6709\u914D\u7F6E\u7684\u4E8B\u4EF6\u6E90\uFF0C\u4F7F\u7528 'roy-agent eventsource add' \u6DFB\u52A0");
|
|
13870
14008
|
}
|
|
13871
14009
|
const ID_WIDTH = 10;
|
|
13872
14010
|
const NAME_WIDTH = 20;
|
|
@@ -13875,11 +14013,11 @@ function formatSourcesTable(sources) {
|
|
|
13875
14013
|
const ENABLED_WIDTH = 8;
|
|
13876
14014
|
const GAP = " ";
|
|
13877
14015
|
const headerLine = [
|
|
13878
|
-
|
|
13879
|
-
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
|
|
14016
|
+
chalk43.bold("ID".padEnd(ID_WIDTH)),
|
|
14017
|
+
chalk43.bold("NAME".padEnd(NAME_WIDTH)),
|
|
14018
|
+
chalk43.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
14019
|
+
chalk43.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
14020
|
+
chalk43.bold("ENABLED".padEnd(ENABLED_WIDTH))
|
|
13883
14021
|
].join(GAP);
|
|
13884
14022
|
const sepLine = "\u2500".repeat(ID_WIDTH + NAME_WIDTH + TYPE_WIDTH + STATUS_WIDTH + ENABLED_WIDTH + GAP.length * 4);
|
|
13885
14023
|
const formatRow = (src) => {
|
|
@@ -13932,7 +14070,7 @@ var EventSourceListCommand = {
|
|
|
13932
14070
|
if (args.json) {
|
|
13933
14071
|
output.json({ sources: [], count: 0 });
|
|
13934
14072
|
} else {
|
|
13935
|
-
output.log(
|
|
14073
|
+
output.log(chalk43.yellow("\u6CA1\u6709\u914D\u7F6E\u7684\u4E8B\u4EF6\u6E90\uFF0C\u4F7F\u7528 'roy-agent eventsource add' \u6DFB\u52A0"));
|
|
13936
14074
|
}
|
|
13937
14075
|
return;
|
|
13938
14076
|
}
|
|
@@ -13947,26 +14085,26 @@ var EventSourceListCommand = {
|
|
|
13947
14085
|
const rows = sources.map((s) => {
|
|
13948
14086
|
const status = esComponent.getStatus(s.id) || "unknown";
|
|
13949
14087
|
const statusColorMap = {
|
|
13950
|
-
running:
|
|
13951
|
-
stopped:
|
|
13952
|
-
error:
|
|
13953
|
-
starting:
|
|
13954
|
-
created:
|
|
13955
|
-
stopping:
|
|
13956
|
-
unknown:
|
|
14088
|
+
running: chalk43.green,
|
|
14089
|
+
stopped: chalk43.gray,
|
|
14090
|
+
error: chalk43.red,
|
|
14091
|
+
starting: chalk43.yellow,
|
|
14092
|
+
created: chalk43.gray,
|
|
14093
|
+
stopping: chalk43.yellow,
|
|
14094
|
+
unknown: chalk43.gray
|
|
13957
14095
|
};
|
|
13958
|
-
const statusColor = statusColorMap[status] ||
|
|
14096
|
+
const statusColor = statusColorMap[status] || chalk43.gray;
|
|
13959
14097
|
return {
|
|
13960
14098
|
id: s.id.substring(0, 8),
|
|
13961
14099
|
name: s.name,
|
|
13962
14100
|
type: s.type,
|
|
13963
14101
|
status: statusColor(status),
|
|
13964
|
-
enabled: s.enabled ?
|
|
14102
|
+
enabled: s.enabled ? chalk43.green("\u2713") : chalk43.gray("\u2717")
|
|
13965
14103
|
};
|
|
13966
14104
|
});
|
|
13967
14105
|
output.log(formatSourcesTable(rows));
|
|
13968
14106
|
output.info("");
|
|
13969
|
-
output.log(
|
|
14107
|
+
output.log(chalk43.green(`\u2705 \u5171 ${sources.length} \u4E2A\u4E8B\u4EF6\u6E90`));
|
|
13970
14108
|
} catch (error) {
|
|
13971
14109
|
output.error(`Failed to list event sources: ${error}`);
|
|
13972
14110
|
process.exit(1);
|
|
@@ -13977,7 +14115,7 @@ var EventSourceListCommand = {
|
|
|
13977
14115
|
};
|
|
13978
14116
|
|
|
13979
14117
|
// packages/cli/src/commands/eventsource/add.ts
|
|
13980
|
-
import
|
|
14118
|
+
import chalk44 from "chalk";
|
|
13981
14119
|
import { generateId } from "@ai-setting/roy-agent-core";
|
|
13982
14120
|
function uuid() {
|
|
13983
14121
|
return generateId();
|
|
@@ -14043,21 +14181,21 @@ var EventSourceAddCommand = {
|
|
|
14043
14181
|
cron: a.cron
|
|
14044
14182
|
};
|
|
14045
14183
|
esComponent.register(config);
|
|
14046
|
-
output.success(
|
|
14184
|
+
output.success(chalk44.green(`\u4E8B\u4EF6\u6E90 '${a.name}' \u6DFB\u52A0\u6210\u529F\uFF01`));
|
|
14047
14185
|
output.log("");
|
|
14048
|
-
output.log(` ID: ${
|
|
14049
|
-
output.log(` Type: ${
|
|
14186
|
+
output.log(` ID: ${chalk44.gray(config.id)}`);
|
|
14187
|
+
output.log(` Type: ${chalk44.cyan(a.type)}`);
|
|
14050
14188
|
if (eventTypes?.length) {
|
|
14051
|
-
output.log(` Event Types: ${
|
|
14189
|
+
output.log(` Event Types: ${chalk44.gray(eventTypes.join(", "))}`);
|
|
14052
14190
|
}
|
|
14053
14191
|
if (a.command) {
|
|
14054
|
-
output.log(` Command: ${
|
|
14192
|
+
output.log(` Command: ${chalk44.gray(a.command)}`);
|
|
14055
14193
|
}
|
|
14056
14194
|
if (a.interval) {
|
|
14057
|
-
output.log(` Interval: ${
|
|
14195
|
+
output.log(` Interval: ${chalk44.gray(`${a.interval}ms`)}`);
|
|
14058
14196
|
}
|
|
14059
14197
|
output.log("");
|
|
14060
|
-
output.log(
|
|
14198
|
+
output.log(chalk44.gray(`\u4F7F\u7528 'roy-agent eventsource start ${config.id.substring(0, 8)}' \u542F\u52A8\u5B83\u3002`));
|
|
14061
14199
|
} finally {
|
|
14062
14200
|
await envService.dispose();
|
|
14063
14201
|
}
|
|
@@ -14065,7 +14203,7 @@ var EventSourceAddCommand = {
|
|
|
14065
14203
|
};
|
|
14066
14204
|
|
|
14067
14205
|
// packages/cli/src/commands/eventsource/remove.ts
|
|
14068
|
-
import
|
|
14206
|
+
import chalk45 from "chalk";
|
|
14069
14207
|
var EventSourceRemoveCommand = {
|
|
14070
14208
|
command: "remove <id>",
|
|
14071
14209
|
aliases: ["rm"],
|
|
@@ -14104,7 +14242,7 @@ var EventSourceRemoveCommand = {
|
|
|
14104
14242
|
const status = esComponent.getStatus(matchedSource.id);
|
|
14105
14243
|
if (status === "running" && !args.force) {
|
|
14106
14244
|
output.error(`\u4E8B\u4EF6\u6E90\u6B63\u5728\u8FD0\u884C\u4E2D\uFF0C\u8BF7\u5148\u505C\u6B62: ${matchedSource.name} (${status})`);
|
|
14107
|
-
output.log(
|
|
14245
|
+
output.log(chalk45.gray(`\u4F7F\u7528 --force \u5F3A\u5236\u79FB\u9664\u6216 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' \u5148\u505C\u6B62`));
|
|
14108
14246
|
process.exit(1);
|
|
14109
14247
|
}
|
|
14110
14248
|
if (status === "running") {
|
|
@@ -14113,7 +14251,7 @@ var EventSourceRemoveCommand = {
|
|
|
14113
14251
|
}
|
|
14114
14252
|
const result = esComponent.unregister(matchedSource.id);
|
|
14115
14253
|
if (result) {
|
|
14116
|
-
output.success(
|
|
14254
|
+
output.success(chalk45.green(`\u4E8B\u4EF6\u6E90\u5DF2\u79FB\u9664: ${matchedSource.name}`));
|
|
14117
14255
|
} else {
|
|
14118
14256
|
output.error("\u79FB\u9664\u5931\u8D25");
|
|
14119
14257
|
process.exit(1);
|
|
@@ -14125,7 +14263,7 @@ var EventSourceRemoveCommand = {
|
|
|
14125
14263
|
};
|
|
14126
14264
|
|
|
14127
14265
|
// packages/cli/src/commands/eventsource/start.ts
|
|
14128
|
-
import
|
|
14266
|
+
import chalk46 from "chalk";
|
|
14129
14267
|
var EventSourceStartCommand = {
|
|
14130
14268
|
command: "start <id>",
|
|
14131
14269
|
describe: "\u542F\u52A8\u6307\u5B9A\u7684\u4E8B\u4EF6\u6E90",
|
|
@@ -14162,15 +14300,15 @@ var EventSourceStartCommand = {
|
|
|
14162
14300
|
}
|
|
14163
14301
|
const status = esComponent.getStatus(matchedSource.id);
|
|
14164
14302
|
if (status === "running") {
|
|
14165
|
-
output.log(
|
|
14303
|
+
output.log(chalk46.yellow(`\u4E8B\u4EF6\u6E90\u5DF2\u5728\u8FD0\u884C: ${matchedSource.name}`));
|
|
14166
14304
|
return;
|
|
14167
14305
|
}
|
|
14168
14306
|
output.info(`\u6B63\u5728\u542F\u52A8\u4E8B\u4EF6\u6E90 '${matchedSource.name}'...`);
|
|
14169
14307
|
try {
|
|
14170
14308
|
await esComponent.startSource(matchedSource.id);
|
|
14171
|
-
output.success(
|
|
14309
|
+
output.success(chalk46.green(`\u4E8B\u4EF6\u6E90\u5DF2\u542F\u52A8: ${matchedSource.name}`));
|
|
14172
14310
|
if (!args.background) {
|
|
14173
|
-
output.log(
|
|
14311
|
+
output.log(chalk46.gray("\u6309 Ctrl+C \u505C\u6B62..."));
|
|
14174
14312
|
await new Promise((resolve) => {
|
|
14175
14313
|
const cleanup = () => {
|
|
14176
14314
|
process.removeListener("SIGINT", cleanup);
|
|
@@ -14192,7 +14330,7 @@ var EventSourceStartCommand = {
|
|
|
14192
14330
|
};
|
|
14193
14331
|
|
|
14194
14332
|
// packages/cli/src/commands/eventsource/stop.ts
|
|
14195
|
-
import
|
|
14333
|
+
import chalk47 from "chalk";
|
|
14196
14334
|
var EventSourceStopCommand = {
|
|
14197
14335
|
command: "stop <id>",
|
|
14198
14336
|
aliases: ["kill"],
|
|
@@ -14230,13 +14368,13 @@ var EventSourceStopCommand = {
|
|
|
14230
14368
|
}
|
|
14231
14369
|
const status = esComponent.getStatus(matchedSource.id);
|
|
14232
14370
|
if (status !== "running") {
|
|
14233
|
-
output.log(
|
|
14371
|
+
output.log(chalk47.yellow(`\u4E8B\u4EF6\u6E90\u672A\u8FD0\u884C: ${matchedSource.name} (${status || "unknown"})`));
|
|
14234
14372
|
return;
|
|
14235
14373
|
}
|
|
14236
14374
|
output.info(`\u6B63\u5728\u505C\u6B62\u4E8B\u4EF6\u6E90 '${matchedSource.name}'...`);
|
|
14237
14375
|
try {
|
|
14238
14376
|
await esComponent.stopSource(matchedSource.id);
|
|
14239
|
-
output.success(
|
|
14377
|
+
output.success(chalk47.green(`\u4E8B\u4EF6\u6E90\u5DF2\u505C\u6B62: ${matchedSource.name}`));
|
|
14240
14378
|
} catch (error) {
|
|
14241
14379
|
output.error(`\u505C\u6B62\u5931\u8D25: ${error}`);
|
|
14242
14380
|
process.exit(1);
|
|
@@ -14248,14 +14386,14 @@ var EventSourceStopCommand = {
|
|
|
14248
14386
|
};
|
|
14249
14387
|
|
|
14250
14388
|
// packages/cli/src/commands/eventsource/status.ts
|
|
14251
|
-
import
|
|
14389
|
+
import chalk48 from "chalk";
|
|
14252
14390
|
var STATUS_COLORS = {
|
|
14253
|
-
created:
|
|
14254
|
-
starting:
|
|
14255
|
-
running:
|
|
14256
|
-
stopping:
|
|
14257
|
-
stopped:
|
|
14258
|
-
error:
|
|
14391
|
+
created: chalk48.gray,
|
|
14392
|
+
starting: chalk48.yellow,
|
|
14393
|
+
running: chalk48.green,
|
|
14394
|
+
stopping: chalk48.yellow,
|
|
14395
|
+
stopped: chalk48.gray,
|
|
14396
|
+
error: chalk48.red
|
|
14259
14397
|
};
|
|
14260
14398
|
var STATUS_ICONS = {
|
|
14261
14399
|
created: "\u25CB",
|
|
@@ -14309,7 +14447,7 @@ var EventSourceStatusCommand = {
|
|
|
14309
14447
|
process.exit(1);
|
|
14310
14448
|
}
|
|
14311
14449
|
const status = esComponent.getStatus(matchedSource.id) || "unknown";
|
|
14312
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
14450
|
+
const statusColor = STATUS_COLORS[status] || chalk48.gray;
|
|
14313
14451
|
if (args.json) {
|
|
14314
14452
|
output.json({
|
|
14315
14453
|
id: matchedSource.id,
|
|
@@ -14326,31 +14464,31 @@ var EventSourceStatusCommand = {
|
|
|
14326
14464
|
});
|
|
14327
14465
|
return;
|
|
14328
14466
|
}
|
|
14329
|
-
output.log(
|
|
14467
|
+
output.log(chalk48.bold("\u4E8B\u4EF6\u6E90\u8BE6\u60C5"));
|
|
14330
14468
|
output.log("\u2500".repeat(50));
|
|
14331
|
-
output.log(` ID: ${
|
|
14332
|
-
output.log(` Name: ${
|
|
14333
|
-
output.log(` Type: ${
|
|
14469
|
+
output.log(` ID: ${chalk48.gray(matchedSource.id)}`);
|
|
14470
|
+
output.log(` Name: ${chalk48.cyan(matchedSource.name)}`);
|
|
14471
|
+
output.log(` Type: ${chalk48.cyan(matchedSource.type)}`);
|
|
14334
14472
|
output.log(` Status: ${statusColor(`${STATUS_ICONS[status]} ${STATUS_LABELS[status]}`)}`);
|
|
14335
|
-
output.log(` Enabled: ${matchedSource.enabled ?
|
|
14473
|
+
output.log(` Enabled: ${matchedSource.enabled ? chalk48.green("\u662F") : chalk48.gray("\u5426")}`);
|
|
14336
14474
|
if (matchedSource.eventTypes?.length) {
|
|
14337
|
-
output.log(` Events: ${
|
|
14475
|
+
output.log(` Events: ${chalk48.gray(matchedSource.eventTypes.join(", "))}`);
|
|
14338
14476
|
}
|
|
14339
14477
|
if (matchedSource.command) {
|
|
14340
|
-
output.log(` Command: ${
|
|
14478
|
+
output.log(` Command: ${chalk48.gray(matchedSource.command)}`);
|
|
14341
14479
|
}
|
|
14342
14480
|
if (matchedSource.interval) {
|
|
14343
|
-
output.log(` Interval: ${
|
|
14481
|
+
output.log(` Interval: ${chalk48.gray(`${matchedSource.interval}ms`)}`);
|
|
14344
14482
|
}
|
|
14345
14483
|
if (matchedSource.url) {
|
|
14346
|
-
output.log(` URL: ${
|
|
14484
|
+
output.log(` URL: ${chalk48.gray(matchedSource.url)}`);
|
|
14347
14485
|
}
|
|
14348
14486
|
output.log("");
|
|
14349
14487
|
return;
|
|
14350
14488
|
}
|
|
14351
14489
|
const sources = esComponent.list();
|
|
14352
14490
|
if (sources.length === 0) {
|
|
14353
|
-
output.log(
|
|
14491
|
+
output.log(chalk48.yellow("\u6CA1\u6709\u914D\u7F6E\u7684\u4E8B\u4EF6\u6E90"));
|
|
14354
14492
|
return;
|
|
14355
14493
|
}
|
|
14356
14494
|
if (args.json) {
|
|
@@ -14364,21 +14502,21 @@ var EventSourceStatusCommand = {
|
|
|
14364
14502
|
output.json({ sources: sourcesWithStatus, count: sources.length });
|
|
14365
14503
|
return;
|
|
14366
14504
|
}
|
|
14367
|
-
output.log(
|
|
14505
|
+
output.log(chalk48.bold("\u4E8B\u4EF6\u6E90\u72B6\u6001\u6982\u89C8"));
|
|
14368
14506
|
output.log("\u2500".repeat(60));
|
|
14369
14507
|
for (const source of sources) {
|
|
14370
14508
|
const status = esComponent.getStatus(source.id) || "unknown";
|
|
14371
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
14509
|
+
const statusColor = STATUS_COLORS[status] || chalk48.gray;
|
|
14372
14510
|
const icon = STATUS_ICONS[status] || "?";
|
|
14373
14511
|
const label = STATUS_LABELS[status] || status;
|
|
14374
14512
|
output.log("");
|
|
14375
|
-
output.log(` ${
|
|
14513
|
+
output.log(` ${chalk48.cyan(source.name)} ${chalk48.gray(`(${source.type})`)}`);
|
|
14376
14514
|
output.log(` \u2514\u2500 Status: ${statusColor(`${icon} ${label}`)}`);
|
|
14377
|
-
output.log(` ID: ${
|
|
14515
|
+
output.log(` ID: ${chalk48.gray(source.id.substring(0, 8))}...`);
|
|
14378
14516
|
}
|
|
14379
14517
|
output.log("");
|
|
14380
14518
|
const runningCount = sources.filter((s) => esComponent.getStatus(s.id) === "running").length;
|
|
14381
|
-
output.log(
|
|
14519
|
+
output.log(chalk48.green(`\u2705 ${runningCount}/${sources.length} \u8FD0\u884C\u4E2D`));
|
|
14382
14520
|
} finally {
|
|
14383
14521
|
await envService.dispose();
|
|
14384
14522
|
}
|
|
@@ -14691,7 +14829,7 @@ var DebugCommand = {
|
|
|
14691
14829
|
};
|
|
14692
14830
|
|
|
14693
14831
|
// packages/cli/src/commands/workflow/renderers.ts
|
|
14694
|
-
import
|
|
14832
|
+
import chalk49 from "chalk";
|
|
14695
14833
|
function truncateVisual3(str, maxWidth) {
|
|
14696
14834
|
if (!str)
|
|
14697
14835
|
return "-";
|
|
@@ -14726,18 +14864,18 @@ function formatDuration(ms) {
|
|
|
14726
14864
|
function statusColor(status) {
|
|
14727
14865
|
switch (status) {
|
|
14728
14866
|
case "completed":
|
|
14729
|
-
return
|
|
14867
|
+
return chalk49.green;
|
|
14730
14868
|
case "running":
|
|
14731
14869
|
case "idle":
|
|
14732
|
-
return
|
|
14870
|
+
return chalk49.blue;
|
|
14733
14871
|
case "paused":
|
|
14734
|
-
return
|
|
14872
|
+
return chalk49.yellow;
|
|
14735
14873
|
case "failed":
|
|
14736
|
-
return
|
|
14874
|
+
return chalk49.red;
|
|
14737
14875
|
case "stopped":
|
|
14738
|
-
return
|
|
14876
|
+
return chalk49.gray;
|
|
14739
14877
|
default:
|
|
14740
|
-
return
|
|
14878
|
+
return chalk49.white;
|
|
14741
14879
|
}
|
|
14742
14880
|
}
|
|
14743
14881
|
function renderWorkflowList(workflows, options) {
|
|
@@ -14756,7 +14894,7 @@ function renderWorkflowList(workflows, options) {
|
|
|
14756
14894
|
}, null, 2);
|
|
14757
14895
|
}
|
|
14758
14896
|
if (workflows.length === 0) {
|
|
14759
|
-
return
|
|
14897
|
+
return chalk49.yellow("No workflows found");
|
|
14760
14898
|
}
|
|
14761
14899
|
const NAME_WIDTH = 30;
|
|
14762
14900
|
const VERSION_WIDTH = 10;
|
|
@@ -14764,10 +14902,10 @@ function renderWorkflowList(workflows, options) {
|
|
|
14764
14902
|
const UPDATED_WIDTH = 20;
|
|
14765
14903
|
const GAP = " ";
|
|
14766
14904
|
const headerLine = [
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14905
|
+
chalk49.bold("NAME".padEnd(NAME_WIDTH)),
|
|
14906
|
+
chalk49.bold("VER".padEnd(VERSION_WIDTH)),
|
|
14907
|
+
chalk49.bold("TAGS".padEnd(TAGS_WIDTH)),
|
|
14908
|
+
chalk49.bold("UPDATED")
|
|
14771
14909
|
].join(GAP);
|
|
14772
14910
|
const sepLine = "\u2500".repeat(NAME_WIDTH + VERSION_WIDTH + TAGS_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
14773
14911
|
const rows = workflows.map((w) => {
|
|
@@ -14782,18 +14920,18 @@ function renderWorkflowList(workflows, options) {
|
|
|
14782
14920
|
}
|
|
14783
14921
|
function renderWorkflowDetail(workflow, options) {
|
|
14784
14922
|
const lines = [];
|
|
14785
|
-
lines.push(
|
|
14923
|
+
lines.push(chalk49.bold(`
|
|
14786
14924
|
\uD83D\uDCCB Workflow Details
|
|
14787
14925
|
`));
|
|
14788
|
-
lines.push(` ${
|
|
14789
|
-
lines.push(` ${
|
|
14790
|
-
lines.push(` ${
|
|
14791
|
-
lines.push(` ${
|
|
14792
|
-
lines.push(` ${
|
|
14793
|
-
lines.push(` ${
|
|
14794
|
-
lines.push(` ${
|
|
14926
|
+
lines.push(` ${chalk49.cyan("ID:")} ${workflow.id}`);
|
|
14927
|
+
lines.push(` ${chalk49.cyan("Name:")} ${workflow.name}`);
|
|
14928
|
+
lines.push(` ${chalk49.cyan("Version:")} ${workflow.version}`);
|
|
14929
|
+
lines.push(` ${chalk49.cyan("Description:")} ${workflow.description || "-"}`);
|
|
14930
|
+
lines.push(` ${chalk49.cyan("Tags:")} ${workflow.tags.join(", ") || "-"}`);
|
|
14931
|
+
lines.push(` ${chalk49.cyan("Created:")} ${formatDate(workflow.createdAt)}`);
|
|
14932
|
+
lines.push(` ${chalk49.cyan("Updated:")} ${formatDate(workflow.updatedAt)}`);
|
|
14795
14933
|
const nodeCount = workflow.definition.nodes.length;
|
|
14796
|
-
lines.push(
|
|
14934
|
+
lines.push(chalk49.bold(`
|
|
14797
14935
|
\uD83D\uDCCA Nodes Summary
|
|
14798
14936
|
`));
|
|
14799
14937
|
lines.push(` Total: ${nodeCount} nodes`);
|
|
@@ -14805,7 +14943,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
14805
14943
|
lines.push(` - ${type}: ${count}`);
|
|
14806
14944
|
}
|
|
14807
14945
|
if (workflow.definition.config) {
|
|
14808
|
-
lines.push(
|
|
14946
|
+
lines.push(chalk49.bold(`
|
|
14809
14947
|
\u2699\uFE0F Configuration
|
|
14810
14948
|
`));
|
|
14811
14949
|
if (workflow.definition.config.parallel_limit !== undefined) {
|
|
@@ -14819,7 +14957,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
14819
14957
|
}
|
|
14820
14958
|
}
|
|
14821
14959
|
if (options?.includeRuns && options.includeRuns.length > 0) {
|
|
14822
|
-
lines.push(
|
|
14960
|
+
lines.push(chalk49.bold(`
|
|
14823
14961
|
\uD83D\uDCDC Recent Runs
|
|
14824
14962
|
`));
|
|
14825
14963
|
lines.push(renderRunsList(options.includeRuns.slice(0, 5)));
|
|
@@ -14843,7 +14981,7 @@ function renderRunsList(runs, options) {
|
|
|
14843
14981
|
}, null, 2);
|
|
14844
14982
|
}
|
|
14845
14983
|
if (runs.length === 0) {
|
|
14846
|
-
return
|
|
14984
|
+
return chalk49.yellow("No runs found");
|
|
14847
14985
|
}
|
|
14848
14986
|
const ID_WIDTH = 20;
|
|
14849
14987
|
const STATUS_WIDTH = 12;
|
|
@@ -14851,10 +14989,10 @@ function renderRunsList(runs, options) {
|
|
|
14851
14989
|
const UPDATED_WIDTH = 20;
|
|
14852
14990
|
const GAP = " ";
|
|
14853
14991
|
const headerLine = [
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
|
|
14857
|
-
|
|
14992
|
+
chalk49.bold("RUN ID".padEnd(ID_WIDTH)),
|
|
14993
|
+
chalk49.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
14994
|
+
chalk49.bold("DURATION".padEnd(DURATION_WIDTH)),
|
|
14995
|
+
chalk49.bold("STARTED")
|
|
14858
14996
|
].join(GAP);
|
|
14859
14997
|
const sepLine = "\u2500".repeat(ID_WIDTH + STATUS_WIDTH + DURATION_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
14860
14998
|
const rows = runs.map((r) => {
|
|
@@ -14869,34 +15007,34 @@ function renderRunsList(runs, options) {
|
|
|
14869
15007
|
}
|
|
14870
15008
|
function renderRunDetail(run) {
|
|
14871
15009
|
const lines = [];
|
|
14872
|
-
lines.push(
|
|
15010
|
+
lines.push(chalk49.bold(`
|
|
14873
15011
|
\uD83C\uDFC3 Run Details
|
|
14874
15012
|
`));
|
|
14875
|
-
lines.push(` ${
|
|
14876
|
-
lines.push(` ${
|
|
14877
|
-
lines.push(` ${
|
|
14878
|
-
lines.push(` ${
|
|
15013
|
+
lines.push(` ${chalk49.cyan("Run ID:")} ${run.id}`);
|
|
15014
|
+
lines.push(` ${chalk49.cyan("Workflow:")} ${run.workflowId}`);
|
|
15015
|
+
lines.push(` ${chalk49.cyan("Status:")} ${statusColor(run.status)(run.status)}`);
|
|
15016
|
+
lines.push(` ${chalk49.cyan("Started:")} ${formatDate(run.startedAt)}`);
|
|
14879
15017
|
if (run.pausedAt) {
|
|
14880
|
-
lines.push(` ${
|
|
15018
|
+
lines.push(` ${chalk49.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
|
|
14881
15019
|
}
|
|
14882
15020
|
if (run.resumedAt) {
|
|
14883
|
-
lines.push(` ${
|
|
15021
|
+
lines.push(` ${chalk49.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
|
|
14884
15022
|
}
|
|
14885
15023
|
if (run.stoppedAt) {
|
|
14886
|
-
lines.push(` ${
|
|
15024
|
+
lines.push(` ${chalk49.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
|
|
14887
15025
|
}
|
|
14888
15026
|
if (run.completedAt) {
|
|
14889
|
-
lines.push(` ${
|
|
15027
|
+
lines.push(` ${chalk49.cyan("Completed:")} ${formatDate(run.completedAt)}`);
|
|
14890
15028
|
}
|
|
14891
|
-
lines.push(` ${
|
|
15029
|
+
lines.push(` ${chalk49.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
|
|
14892
15030
|
if (run.error) {
|
|
14893
|
-
lines.push(
|
|
15031
|
+
lines.push(chalk49.bold(`
|
|
14894
15032
|
\u274C Error
|
|
14895
15033
|
`));
|
|
14896
|
-
lines.push(` ${
|
|
15034
|
+
lines.push(` ${chalk49.red(run.error)}`);
|
|
14897
15035
|
}
|
|
14898
15036
|
if (run.output) {
|
|
14899
|
-
lines.push(
|
|
15037
|
+
lines.push(chalk49.bold(`
|
|
14900
15038
|
\uD83D\uDCE4 Output
|
|
14901
15039
|
`));
|
|
14902
15040
|
lines.push(" " + JSON.stringify(run.output, null, 2).split(`
|
|
@@ -14907,36 +15045,36 @@ function renderRunDetail(run) {
|
|
|
14907
15045
|
`);
|
|
14908
15046
|
}
|
|
14909
15047
|
function renderWorkflowAdded(workflow) {
|
|
14910
|
-
return
|
|
15048
|
+
return chalk49.green(`
|
|
14911
15049
|
\u2705 Workflow '${workflow.name}' added successfully
|
|
14912
15050
|
`) + ` ID: ${workflow.id}
|
|
14913
15051
|
` + ` Version: ${workflow.version}
|
|
14914
15052
|
`;
|
|
14915
15053
|
}
|
|
14916
15054
|
function renderWorkflowUpdated(workflow) {
|
|
14917
|
-
return
|
|
15055
|
+
return chalk49.green(`
|
|
14918
15056
|
\u2705 Workflow '${workflow.name}' updated successfully
|
|
14919
15057
|
`) + ` ID: ${workflow.id}
|
|
14920
15058
|
`;
|
|
14921
15059
|
}
|
|
14922
15060
|
function renderWorkflowDeleted(name) {
|
|
14923
|
-
return
|
|
15061
|
+
return chalk49.green(`
|
|
14924
15062
|
\u2705 Workflow '${name}' deleted successfully
|
|
14925
15063
|
`);
|
|
14926
15064
|
}
|
|
14927
15065
|
function renderRunResult(result) {
|
|
14928
15066
|
const lines = [];
|
|
14929
15067
|
if (result.status === "completed") {
|
|
14930
|
-
lines.push(
|
|
15068
|
+
lines.push(chalk49.green(`
|
|
14931
15069
|
\u2705 Workflow completed successfully`));
|
|
14932
15070
|
} else if (result.status === "failed") {
|
|
14933
|
-
lines.push(
|
|
15071
|
+
lines.push(chalk49.red(`
|
|
14934
15072
|
\u274C Workflow failed`));
|
|
14935
15073
|
} else if (result.status === "stopped") {
|
|
14936
|
-
lines.push(
|
|
15074
|
+
lines.push(chalk49.yellow(`
|
|
14937
15075
|
\u26A0\uFE0F Workflow stopped`));
|
|
14938
15076
|
} else {
|
|
14939
|
-
lines.push(
|
|
15077
|
+
lines.push(chalk49.blue(`
|
|
14940
15078
|
\uD83D\uDD04 Workflow ${result.status}`));
|
|
14941
15079
|
}
|
|
14942
15080
|
lines.push(` Run ID: ${result.runId}`);
|
|
@@ -14944,11 +15082,11 @@ function renderRunResult(result) {
|
|
|
14944
15082
|
lines.push(` Duration: ${formatDuration(result.durationMs)}`);
|
|
14945
15083
|
}
|
|
14946
15084
|
if (result.error) {
|
|
14947
|
-
lines.push(
|
|
15085
|
+
lines.push(chalk49.red(`
|
|
14948
15086
|
Error: ${result.error}`));
|
|
14949
15087
|
}
|
|
14950
15088
|
if (result.output) {
|
|
14951
|
-
lines.push(
|
|
15089
|
+
lines.push(chalk49.bold(`
|
|
14952
15090
|
\uD83D\uDCE4 Output:`));
|
|
14953
15091
|
lines.push(JSON.stringify(result.output, null, 2));
|
|
14954
15092
|
}
|
|
@@ -14962,10 +15100,10 @@ function renderNodesList(nodes) {
|
|
|
14962
15100
|
const DEPS_WIDTH = 20;
|
|
14963
15101
|
const GAP = " ";
|
|
14964
15102
|
const headerLine = [
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14968
|
-
|
|
15103
|
+
chalk49.bold("NODE ID".padEnd(ID_WIDTH)),
|
|
15104
|
+
chalk49.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
15105
|
+
chalk49.bold("NAME".padEnd(NAME_WIDTH)),
|
|
15106
|
+
chalk49.bold("DEPENDS ON")
|
|
14969
15107
|
].join(GAP);
|
|
14970
15108
|
const sepLine = "\u2500".repeat(ID_WIDTH + TYPE_WIDTH + NAME_WIDTH + DEPS_WIDTH + GAP.length * 3);
|
|
14971
15109
|
const rows = nodes.map((n) => {
|
|
@@ -14980,7 +15118,7 @@ function renderNodesList(nodes) {
|
|
|
14980
15118
|
}
|
|
14981
15119
|
|
|
14982
15120
|
// packages/cli/src/commands/workflow/commands/list.ts
|
|
14983
|
-
import
|
|
15121
|
+
import chalk50 from "chalk";
|
|
14984
15122
|
var WorkflowListCommand = {
|
|
14985
15123
|
command: "list",
|
|
14986
15124
|
describe: "\u5217\u51FA\u6240\u6709\u5DF2\u6CE8\u518C\u7684 Workflow",
|
|
@@ -15063,7 +15201,7 @@ var WorkflowListCommand = {
|
|
|
15063
15201
|
});
|
|
15064
15202
|
} else {
|
|
15065
15203
|
output.log(renderWorkflowList(workflows));
|
|
15066
|
-
output.log(
|
|
15204
|
+
output.log(chalk50.green(`
|
|
15067
15205
|
\u2705 \u5171 ${workflows.length} \u4E2A Workflow`));
|
|
15068
15206
|
}
|
|
15069
15207
|
} catch (error) {
|
|
@@ -15612,7 +15750,7 @@ class WorkflowValidator {
|
|
|
15612
15750
|
}
|
|
15613
15751
|
|
|
15614
15752
|
// packages/cli/src/commands/workflow/commands/add.ts
|
|
15615
|
-
import
|
|
15753
|
+
import chalk51 from "chalk";
|
|
15616
15754
|
import fs3 from "fs";
|
|
15617
15755
|
import path6 from "path";
|
|
15618
15756
|
import { createWorkflowExtractorAgent } from "@ai-setting/roy-agent-core/env/task/plugins";
|
|
@@ -15726,7 +15864,7 @@ var WorkflowAddCommand = {
|
|
|
15726
15864
|
definition = await parseWorkflowContent(content, filePath);
|
|
15727
15865
|
workflowName = a.name || definition.name || path6.basename(filePath);
|
|
15728
15866
|
if (a.validate) {
|
|
15729
|
-
output.log(
|
|
15867
|
+
output.log(chalk51.blue("\uD83D\uDD0D Validating workflow..."));
|
|
15730
15868
|
const validator = new WorkflowValidator;
|
|
15731
15869
|
const result = validator.validate(definition);
|
|
15732
15870
|
if (!result.valid) {
|
|
@@ -15741,11 +15879,11 @@ var WorkflowAddCommand = {
|
|
|
15741
15879
|
});
|
|
15742
15880
|
process.exit(1);
|
|
15743
15881
|
}
|
|
15744
|
-
output.log(
|
|
15882
|
+
output.log(chalk51.green(`\u2705 Workflow validation passed
|
|
15745
15883
|
`));
|
|
15746
15884
|
}
|
|
15747
15885
|
} else if (a.desc) {
|
|
15748
|
-
output.log(
|
|
15886
|
+
output.log(chalk51.blue(`\uD83E\uDD16 Generating workflow from description...
|
|
15749
15887
|
`));
|
|
15750
15888
|
const agentComponent = env.getComponent("agent");
|
|
15751
15889
|
if (!agentComponent) {
|
|
@@ -15753,10 +15891,10 @@ var WorkflowAddCommand = {
|
|
|
15753
15891
|
process.exit(1);
|
|
15754
15892
|
}
|
|
15755
15893
|
if (!agentComponent.getAgent("workflow-extractor")) {
|
|
15756
|
-
output.log(
|
|
15894
|
+
output.log(chalk51.gray("Auto-registering workflow-extractor agent..."));
|
|
15757
15895
|
const extractorConfig = createWorkflowExtractorAgent();
|
|
15758
15896
|
agentComponent.registerAgent(extractorConfig.name, extractorConfig);
|
|
15759
|
-
output.log(
|
|
15897
|
+
output.log(chalk51.green(`\u2705 workflow-extractor agent registered
|
|
15760
15898
|
`));
|
|
15761
15899
|
}
|
|
15762
15900
|
const prompt = `## \u4EFB\u52A1
|
|
@@ -15770,20 +15908,20 @@ ${a.desc}
|
|
|
15770
15908
|
1. \u5148\u7528 \`roy-agent workflow nodes\` \u67E5\u770B\u53EF\u7528\u7684\u8282\u70B9\u7C7B\u578B
|
|
15771
15909
|
2. \u751F\u6210\u7684 YAML \u5FC5\u987B\u901A\u8FC7 \`roy-agent workflow validate --yaml "<yaml>"\` \u9A8C\u8BC1
|
|
15772
15910
|
3. \u9A8C\u8BC1\u901A\u8FC7\u540E\u624D\u8F93\u51FA\u6700\u7EC8 YAML`;
|
|
15773
|
-
output.log(
|
|
15911
|
+
output.log(chalk51.gray("Running workflow-extractor agent..."));
|
|
15774
15912
|
const result = await agentComponent.run("workflow-extractor", prompt);
|
|
15775
15913
|
const agentOutput = result.finalText || "";
|
|
15776
15914
|
definition = parseYamlFromAgentOutput(agentOutput);
|
|
15777
15915
|
if (definition === null) {
|
|
15778
15916
|
output.error("Failed to parse workflow from agent output");
|
|
15779
|
-
output.log(
|
|
15917
|
+
output.log(chalk51.gray(`
|
|
15780
15918
|
Agent output:
|
|
15781
15919
|
` + agentOutput.slice(0, 500)));
|
|
15782
15920
|
process.exit(1);
|
|
15783
15921
|
}
|
|
15784
15922
|
workflowName = a.name || definition.name;
|
|
15785
15923
|
if (a.validate) {
|
|
15786
|
-
output.log(
|
|
15924
|
+
output.log(chalk51.blue(`
|
|
15787
15925
|
\uD83D\uDD0D Validating generated workflow...`));
|
|
15788
15926
|
const validator = new WorkflowValidator;
|
|
15789
15927
|
const result2 = validator.validate(definition);
|
|
@@ -15797,16 +15935,16 @@ Agent output:
|
|
|
15797
15935
|
output.error(` Fix: ${error.fix}
|
|
15798
15936
|
`);
|
|
15799
15937
|
});
|
|
15800
|
-
output.log(
|
|
15938
|
+
output.log(chalk51.yellow("\u8BF7\u4FEE\u6B63\u63CF\u8FF0\u540E\u91CD\u65B0\u5C1D\u8BD5\uFF0C\u6216\u4F7F\u7528 --file \u9009\u9879\u76F4\u63A5\u63D0\u4F9B YAML"));
|
|
15801
15939
|
process.exit(1);
|
|
15802
15940
|
}
|
|
15803
|
-
output.log(
|
|
15941
|
+
output.log(chalk51.green(`\u2705 Generated workflow validation passed
|
|
15804
15942
|
`));
|
|
15805
15943
|
}
|
|
15806
15944
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
15807
|
-
output.log(
|
|
15945
|
+
output.log(chalk51.gray("--- Generated YAML ---"));
|
|
15808
15946
|
output.log(yaml.stringify(definition));
|
|
15809
|
-
output.log(
|
|
15947
|
+
output.log(chalk51.gray(`------------------------
|
|
15810
15948
|
`));
|
|
15811
15949
|
} else {
|
|
15812
15950
|
output.error("Please provide --file or --desc option");
|
|
@@ -15820,10 +15958,10 @@ Agent output:
|
|
|
15820
15958
|
force: a.force
|
|
15821
15959
|
});
|
|
15822
15960
|
output.log(renderWorkflowAdded(workflow));
|
|
15823
|
-
output.log(
|
|
15961
|
+
output.log(chalk51.bold(`
|
|
15824
15962
|
\uD83D\uDCCA Nodes Summary:`));
|
|
15825
15963
|
output.log(renderNodesList(definition.nodes));
|
|
15826
|
-
output.log(
|
|
15964
|
+
output.log(chalk51.green(`
|
|
15827
15965
|
\u2705 Workflow '${workflowName}' added successfully`));
|
|
15828
15966
|
} catch (error) {
|
|
15829
15967
|
if (error.message?.includes("already exists") && !a.force) {
|
|
@@ -15840,7 +15978,7 @@ Agent output:
|
|
|
15840
15978
|
};
|
|
15841
15979
|
|
|
15842
15980
|
// packages/cli/src/commands/workflow/commands/get.ts
|
|
15843
|
-
import
|
|
15981
|
+
import chalk52 from "chalk";
|
|
15844
15982
|
var WorkflowGetCommand = {
|
|
15845
15983
|
command: "get <identifier>",
|
|
15846
15984
|
describe: "\u83B7\u53D6 Workflow \u6216 Run \u8BE6\u60C5",
|
|
@@ -15964,7 +16102,7 @@ var WorkflowGetCommand = {
|
|
|
15964
16102
|
} else {
|
|
15965
16103
|
output.log(renderWorkflowDetail(workflow, { includeRuns: runs }));
|
|
15966
16104
|
if (args.includeNodes) {
|
|
15967
|
-
output.log(
|
|
16105
|
+
output.log(chalk52.bold(`
|
|
15968
16106
|
\uD83D\uDCCB All Nodes:`));
|
|
15969
16107
|
output.log(renderNodesList(workflow.definition.nodes));
|
|
15970
16108
|
}
|
|
@@ -15980,7 +16118,7 @@ var WorkflowGetCommand = {
|
|
|
15980
16118
|
};
|
|
15981
16119
|
|
|
15982
16120
|
// packages/cli/src/commands/workflow/commands/update.ts
|
|
15983
|
-
import
|
|
16121
|
+
import chalk53 from "chalk";
|
|
15984
16122
|
import fs4 from "fs";
|
|
15985
16123
|
import path7 from "path";
|
|
15986
16124
|
var WorkflowUpdateCommand = {
|
|
@@ -16052,7 +16190,7 @@ var WorkflowUpdateCommand = {
|
|
|
16052
16190
|
const tags = a.tags ? a.tags.split(",").map((t) => t.trim()) : undefined;
|
|
16053
16191
|
const workflow = await service.updateWorkflow(a.name, updates, { tags });
|
|
16054
16192
|
output.log(renderWorkflowUpdated(workflow));
|
|
16055
|
-
output.log(
|
|
16193
|
+
output.log(chalk53.green(`
|
|
16056
16194
|
\u2705 Workflow '${a.name}' updated successfully`));
|
|
16057
16195
|
} catch (error) {
|
|
16058
16196
|
output.error(`Failed to update workflow: ${error}`);
|
|
@@ -16064,7 +16202,7 @@ var WorkflowUpdateCommand = {
|
|
|
16064
16202
|
};
|
|
16065
16203
|
|
|
16066
16204
|
// packages/cli/src/commands/workflow/commands/remove.ts
|
|
16067
|
-
import
|
|
16205
|
+
import chalk54 from "chalk";
|
|
16068
16206
|
var WorkflowRemoveCommand = {
|
|
16069
16207
|
command: "remove <name>",
|
|
16070
16208
|
describe: "\u5220\u9664 Workflow",
|
|
@@ -16103,8 +16241,8 @@ var WorkflowRemoveCommand = {
|
|
|
16103
16241
|
process.exit(1);
|
|
16104
16242
|
}
|
|
16105
16243
|
if (!args.force) {
|
|
16106
|
-
output.log(
|
|
16107
|
-
output.log(
|
|
16244
|
+
output.log(chalk54.yellow(`Are you sure you want to delete workflow '${args.name}'?`));
|
|
16245
|
+
output.log(chalk54.gray("Use --force to skip confirmation"));
|
|
16108
16246
|
process.exit(1);
|
|
16109
16247
|
}
|
|
16110
16248
|
const deleted = await service.deleteWorkflow(args.name);
|
|
@@ -16124,7 +16262,7 @@ var WorkflowRemoveCommand = {
|
|
|
16124
16262
|
|
|
16125
16263
|
// packages/cli/src/commands/workflow/commands/run.ts
|
|
16126
16264
|
var import_yaml = __toESM(require_dist(), 1);
|
|
16127
|
-
import
|
|
16265
|
+
import chalk55 from "chalk";
|
|
16128
16266
|
import fs5 from "fs";
|
|
16129
16267
|
import path8 from "path";
|
|
16130
16268
|
import { getTracerProvider as getTracerProvider5, propagation, wrapFunction } from "@ai-setting/roy-agent-core";
|
|
@@ -16198,7 +16336,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
16198
16336
|
};
|
|
16199
16337
|
if (args.sessionId) {
|
|
16200
16338
|
const sessionId = args.sessionId.startsWith("workflow_") ? args.sessionId : `workflow_${args.sessionId}`;
|
|
16201
|
-
output.log(
|
|
16339
|
+
output.log(chalk55.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
16202
16340
|
const sessionComponent = workflowComponent.sessionComponent;
|
|
16203
16341
|
if (!sessionComponent) {
|
|
16204
16342
|
output.error("SessionComponent not available");
|
|
@@ -16260,17 +16398,17 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
16260
16398
|
definition = { ...definition, name: args.name };
|
|
16261
16399
|
}
|
|
16262
16400
|
const workflow = await service.createWorkflow(definition, { force: true });
|
|
16263
|
-
output.log(
|
|
16264
|
-
output.log(
|
|
16401
|
+
output.log(chalk55.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
|
|
16402
|
+
output.log(chalk55.green(`\u2705 Workflow registered: ${workflow.name} (${workflow.id})`));
|
|
16265
16403
|
if (args.registerOnly) {
|
|
16266
|
-
output.log(
|
|
16404
|
+
output.log(chalk55.gray("\u2139\uFE0F Use --register-only, skipping execution"));
|
|
16267
16405
|
if (workflowSpan) {
|
|
16268
16406
|
workflowSpan.end();
|
|
16269
16407
|
}
|
|
16270
16408
|
await envService.dispose();
|
|
16271
16409
|
process.exit(0);
|
|
16272
16410
|
}
|
|
16273
|
-
output.log(
|
|
16411
|
+
output.log(chalk55.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
|
|
16274
16412
|
const result = await service.runWorkflow(definition, input, runOptions);
|
|
16275
16413
|
output.log(renderRunResult({
|
|
16276
16414
|
runId: result.runId,
|
|
@@ -16280,11 +16418,11 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
16280
16418
|
durationMs: result.durationMs
|
|
16281
16419
|
}));
|
|
16282
16420
|
if (result.status === "paused") {
|
|
16283
|
-
output.log(
|
|
16421
|
+
output.log(chalk55.gray(`
|
|
16284
16422
|
\uD83D\uDCA1 Use "roy-agent workflow run -s ${result.runId}" to resume`));
|
|
16285
16423
|
}
|
|
16286
16424
|
} else {
|
|
16287
|
-
output.log(
|
|
16425
|
+
output.log(chalk55.blue(`\uD83D\uDE80 Running workflow: ${args.identifier}`));
|
|
16288
16426
|
const result = await service.runWorkflow(args.identifier, input, runOptions);
|
|
16289
16427
|
output.log(renderRunResult({
|
|
16290
16428
|
runId: result.runId,
|
|
@@ -16294,7 +16432,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
16294
16432
|
durationMs: result.durationMs
|
|
16295
16433
|
}));
|
|
16296
16434
|
if (result.status === "paused") {
|
|
16297
|
-
output.log(
|
|
16435
|
+
output.log(chalk55.gray(`
|
|
16298
16436
|
\uD83D\uDCA1 Use "roy-agent workflow run -s ${result.runId}" to resume`));
|
|
16299
16437
|
}
|
|
16300
16438
|
}
|
|
@@ -16366,7 +16504,7 @@ var WorkflowRunCommand = {
|
|
|
16366
16504
|
};
|
|
16367
16505
|
|
|
16368
16506
|
// packages/cli/src/commands/workflow/commands/stop.ts
|
|
16369
|
-
import
|
|
16507
|
+
import chalk56 from "chalk";
|
|
16370
16508
|
import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
|
|
16371
16509
|
var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
16372
16510
|
const output = new OutputService;
|
|
@@ -16395,7 +16533,7 @@ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
|
16395
16533
|
process.exit(1);
|
|
16396
16534
|
}
|
|
16397
16535
|
await service.stopRun(args.runId);
|
|
16398
|
-
output.log(
|
|
16536
|
+
output.log(chalk56.red(`
|
|
16399
16537
|
\u23F9\uFE0F Workflow stopped: ${args.runId}`));
|
|
16400
16538
|
} catch (error) {
|
|
16401
16539
|
output.error(`Failed to stop workflow: ${error}`);
|
|
@@ -16419,7 +16557,7 @@ var WorkflowStopCommand = {
|
|
|
16419
16557
|
};
|
|
16420
16558
|
|
|
16421
16559
|
// packages/cli/src/commands/workflow/commands/status.ts
|
|
16422
|
-
import
|
|
16560
|
+
import chalk57 from "chalk";
|
|
16423
16561
|
var WorkflowStatusCommand = {
|
|
16424
16562
|
command: "status <runId>",
|
|
16425
16563
|
describe: "\u67E5\u770B Workflow \u8FD0\u884C\u72B6\u6001",
|
|
@@ -16510,7 +16648,7 @@ var WorkflowStatusCommand = {
|
|
|
16510
16648
|
stopped: "\u23F9\uFE0F"
|
|
16511
16649
|
};
|
|
16512
16650
|
const emoji = statusEmoji[status] || "\u2753";
|
|
16513
|
-
output.log(
|
|
16651
|
+
output.log(chalk57.bold(`
|
|
16514
16652
|
${emoji} Status: ${status.toUpperCase()}`));
|
|
16515
16653
|
}
|
|
16516
16654
|
} catch (error) {
|
|
@@ -16523,7 +16661,7 @@ ${emoji} Status: ${status.toUpperCase()}`));
|
|
|
16523
16661
|
};
|
|
16524
16662
|
|
|
16525
16663
|
// packages/cli/src/commands/workflow/commands/nodes.ts
|
|
16526
|
-
import
|
|
16664
|
+
import chalk58 from "chalk";
|
|
16527
16665
|
var BUILT_IN_NODES = [
|
|
16528
16666
|
{
|
|
16529
16667
|
name: "ToolNode",
|
|
@@ -16860,7 +16998,7 @@ nodes:
|
|
|
16860
16998
|
];
|
|
16861
16999
|
function renderNodeTypesTable(nodes) {
|
|
16862
17000
|
const lines = [];
|
|
16863
|
-
lines.push(
|
|
17001
|
+
lines.push(chalk58.bold(`
|
|
16864
17002
|
\uD83D\uDCE6 Built-in Node Types
|
|
16865
17003
|
`));
|
|
16866
17004
|
lines.push("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
|
|
@@ -16878,29 +17016,29 @@ function renderNodeTypesTable(nodes) {
|
|
|
16878
17016
|
}
|
|
16879
17017
|
function renderNodeDetail(node) {
|
|
16880
17018
|
const lines = [];
|
|
16881
|
-
lines.push(
|
|
17019
|
+
lines.push(chalk58.bold(`
|
|
16882
17020
|
[${node.type}] ${node.name}`));
|
|
16883
|
-
lines.push(
|
|
17021
|
+
lines.push(chalk58.dim("\u2500".repeat(60)) + `
|
|
16884
17022
|
`);
|
|
16885
|
-
lines.push(
|
|
17023
|
+
lines.push(chalk58.bold("Description:"));
|
|
16886
17024
|
lines.push(` ${node.description}
|
|
16887
17025
|
`);
|
|
16888
|
-
lines.push(
|
|
17026
|
+
lines.push(chalk58.bold("Configuration:"));
|
|
16889
17027
|
lines.push(' type: "' + node.type + '"');
|
|
16890
17028
|
lines.push(" config:");
|
|
16891
17029
|
for (const input of node.inputs) {
|
|
16892
|
-
const required = input.required ?
|
|
17030
|
+
const required = input.required ? chalk58.red("*") : " ";
|
|
16893
17031
|
lines.push(` ${input.name} (${input.type})${required}`);
|
|
16894
17032
|
lines.push(` ${input.description}`);
|
|
16895
17033
|
}
|
|
16896
17034
|
lines.push(`
|
|
16897
|
-
${
|
|
17035
|
+
${chalk58.bold("Output:")} ${node.output}`);
|
|
16898
17036
|
if (node.example) {
|
|
16899
|
-
lines.push(
|
|
17037
|
+
lines.push(chalk58.bold(`
|
|
16900
17038
|
Example:`));
|
|
16901
|
-
lines.push(
|
|
17039
|
+
lines.push(chalk58.gray("```yaml"));
|
|
16902
17040
|
lines.push(node.example);
|
|
16903
|
-
lines.push(
|
|
17041
|
+
lines.push(chalk58.gray("```"));
|
|
16904
17042
|
}
|
|
16905
17043
|
return lines.join(`
|
|
16906
17044
|
`);
|
|
@@ -16916,16 +17054,16 @@ var WorkflowNodesCommand = {
|
|
|
16916
17054
|
const nodeType = args.type?.toLowerCase();
|
|
16917
17055
|
if (!nodeType) {
|
|
16918
17056
|
console.log(renderNodeTypesTable(BUILT_IN_NODES));
|
|
16919
|
-
console.log(
|
|
16920
|
-
Use `) +
|
|
16921
|
-
console.log(
|
|
17057
|
+
console.log(chalk58.gray(`
|
|
17058
|
+
Use `) + chalk58.cyan("roy-agent workflow nodes <type>") + chalk58.gray(" for detailed information"));
|
|
17059
|
+
console.log(chalk58.gray("Available types: ") + chalk58.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
16922
17060
|
return;
|
|
16923
17061
|
}
|
|
16924
17062
|
const node = BUILT_IN_NODES.find((n) => n.type === nodeType);
|
|
16925
17063
|
if (!node) {
|
|
16926
|
-
console.log(
|
|
17064
|
+
console.log(chalk58.red(`
|
|
16927
17065
|
\u274C Unknown node type: ${nodeType}`));
|
|
16928
|
-
console.log(
|
|
17066
|
+
console.log(chalk58.gray("Available types: ") + chalk58.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
16929
17067
|
process.exit(1);
|
|
16930
17068
|
}
|
|
16931
17069
|
console.log(renderNodeDetail(node));
|
|
@@ -16933,7 +17071,7 @@ Use `) + chalk57.cyan("roy-agent workflow nodes <type>") + chalk57.gray(" for de
|
|
|
16933
17071
|
};
|
|
16934
17072
|
|
|
16935
17073
|
// packages/cli/src/commands/workflow/commands/validate.ts
|
|
16936
|
-
import
|
|
17074
|
+
import chalk59 from "chalk";
|
|
16937
17075
|
import { readFileSync } from "fs";
|
|
16938
17076
|
async function parseWorkflowInput(input, yamlStr) {
|
|
16939
17077
|
const parseYaml = async (content) => {
|
|
@@ -16966,25 +17104,25 @@ function renderResult(result, options) {
|
|
|
16966
17104
|
return;
|
|
16967
17105
|
}
|
|
16968
17106
|
if (result.valid) {
|
|
16969
|
-
console.log(
|
|
17107
|
+
console.log(chalk59.green(`
|
|
16970
17108
|
\u2705 Workflow validation PASSED
|
|
16971
17109
|
`));
|
|
16972
|
-
console.log(
|
|
17110
|
+
console.log(chalk59.bold(`Workflow: ${result.workflowName}`));
|
|
16973
17111
|
console.log(`Nodes: ${result.nodeCount}`);
|
|
16974
17112
|
console.log(`
|
|
16975
17113
|
Valid nodes:`);
|
|
16976
|
-
console.log(
|
|
17114
|
+
console.log(chalk59.green(" \u2713 All nodes passed validation"));
|
|
16977
17115
|
} else {
|
|
16978
|
-
console.log(
|
|
17116
|
+
console.log(chalk59.red(`
|
|
16979
17117
|
\u274C Workflow validation FAILED (${result.errors.length} errors found)
|
|
16980
17118
|
`));
|
|
16981
17119
|
result.errors.forEach((error, index) => {
|
|
16982
|
-
console.log(
|
|
16983
|
-
console.log(` ${
|
|
16984
|
-
console.log(` ${
|
|
16985
|
-
console.log(` ${
|
|
16986
|
-
console.log(` ${
|
|
16987
|
-
console.log(` ${
|
|
17120
|
+
console.log(chalk59.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
|
|
17121
|
+
console.log(` ${chalk59.bold("Type:")} ${error.type}`);
|
|
17122
|
+
console.log(` ${chalk59.bold("Description:")} ${error.description}`);
|
|
17123
|
+
console.log(` ${chalk59.bold("Expected:")} ${error.expected}`);
|
|
17124
|
+
console.log(` ${chalk59.bold("Actual:")} ${error.actual}`);
|
|
17125
|
+
console.log(` ${chalk59.green("Fix:")} ${error.fix}`);
|
|
16988
17126
|
console.log();
|
|
16989
17127
|
});
|
|
16990
17128
|
}
|
|
@@ -17009,7 +17147,7 @@ var WorkflowValidateCommand = {
|
|
|
17009
17147
|
try {
|
|
17010
17148
|
const workflow = await parseWorkflowInput(options.input, options.yaml);
|
|
17011
17149
|
if (!workflow) {
|
|
17012
|
-
console.error(
|
|
17150
|
+
console.error(chalk59.red("Failed to parse workflow input"));
|
|
17013
17151
|
process.exit(1);
|
|
17014
17152
|
}
|
|
17015
17153
|
const validator = new WorkflowValidator;
|
|
@@ -17017,7 +17155,7 @@ var WorkflowValidateCommand = {
|
|
|
17017
17155
|
renderResult(result, options);
|
|
17018
17156
|
process.exit(result.valid ? 0 : 1);
|
|
17019
17157
|
} catch (error) {
|
|
17020
|
-
console.error(
|
|
17158
|
+
console.error(chalk59.red(`
|
|
17021
17159
|
Error: ${error.message}`));
|
|
17022
17160
|
process.exit(1);
|
|
17023
17161
|
}
|