@ai-setting/roy-agent-cli 1.5.93 → 1.5.95

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.
@@ -270,12 +270,16 @@ ${COLORS.system("[已中断]")}
270
270
  providerId,
271
271
  promptTokens: metadata.usage?.promptTokens,
272
272
  completionTokens: metadata.usage?.completionTokens,
273
- totalTokens: metadata.usage?.totalTokens
273
+ totalTokens: metadata.usage?.totalTokens,
274
+ cacheRead: metadata.usage?.cacheRead,
275
+ cacheWrite: metadata.usage?.cacheWrite
274
276
  };
275
277
  const logData = {
276
278
  promptTokens: this.usageInfo.promptTokens,
277
279
  completionTokens: this.usageInfo.completionTokens,
278
- totalTokens: this.usageInfo.totalTokens
280
+ totalTokens: this.usageInfo.totalTokens,
281
+ cacheRead: this.usageInfo.cacheRead,
282
+ cacheWrite: this.usageInfo.cacheWrite
279
283
  };
280
284
  if (this.contextWindow !== undefined) {
281
285
  logData.contextWindow = this.contextWindow;
@@ -326,6 +330,109 @@ var init_stream_output_service = __esm(() => {
326
330
  };
327
331
  });
328
332
 
333
+ // src/commands/shared/clipboard-helper.ts
334
+ var exports_clipboard_helper = {};
335
+ __export(exports_clipboard_helper, {
336
+ readClipboardImage: () => readClipboardImage,
337
+ isClipboardMockActive: () => isClipboardMockActive
338
+ });
339
+ import { exec } from "node:child_process";
340
+ import { readFile } from "node:fs/promises";
341
+ import { sniffMimeType } from "@ai-setting/roy-agent-core";
342
+ function isClipboardMockActive() {
343
+ return Boolean(process.env.ROY_CLIPBOARD_MOCK_PATH || process.env.ROY_CLIPBOARD_MOCK_FAIL);
344
+ }
345
+ function pickClipboardCommand() {
346
+ const platform = process.platform;
347
+ if (platform === "darwin") {
348
+ return { cmd: "pngpaste", args: [] };
349
+ }
350
+ if (platform === "linux") {
351
+ return {
352
+ cmd: "xclip",
353
+ args: ["-selection", "clipboard", "-t", "image/png", "-o"]
354
+ };
355
+ }
356
+ return null;
357
+ }
358
+ async function readClipboardImage() {
359
+ if (process.env.ROY_CLIPBOARD_MOCK_FAIL === "true") {
360
+ return null;
361
+ }
362
+ if (process.env.ROY_CLIPBOARD_MOCK_PATH) {
363
+ return await readMockFromPath(process.env.ROY_CLIPBOARD_MOCK_PATH);
364
+ }
365
+ const cmdSpec = pickClipboardCommand();
366
+ if (!cmdSpec) {
367
+ return null;
368
+ }
369
+ const stdout = await execAsync(cmdSpec.cmd, cmdSpec.args).catch(() => null);
370
+ if (!stdout || stdout.length === 0) {
371
+ return null;
372
+ }
373
+ const buffer = Buffer.from(stdout);
374
+ const mime = sniffMimeType(buffer);
375
+ if (!mime.startsWith("image/")) {
376
+ return null;
377
+ }
378
+ return { buffer, mime };
379
+ }
380
+ async function readMockFromPath(filePath) {
381
+ try {
382
+ const buffer = await readFile(filePath);
383
+ const mime = sniffMimeType(buffer, filePath);
384
+ if (!mime.startsWith("image/")) {
385
+ return null;
386
+ }
387
+ return { buffer, mime };
388
+ } catch {
389
+ return null;
390
+ }
391
+ }
392
+ function execAsync(cmd, args) {
393
+ return new Promise((resolve) => {
394
+ exec(`${cmd} ${args.map((a) => a.includes(" ") ? `"${a}"` : a).join(" ")}`, { encoding: "buffer", maxBuffer: 10 * 1024 * 1024 }, (err, stdout) => {
395
+ if (err) {
396
+ resolve(null);
397
+ return;
398
+ }
399
+ if (!stdout) {
400
+ resolve(null);
401
+ return;
402
+ }
403
+ resolve(stdout);
404
+ });
405
+ });
406
+ }
407
+ var init_clipboard_helper = () => {};
408
+
409
+ // src/commands/shared/slash-commands.ts
410
+ var exports_slash_commands = {};
411
+ __export(exports_slash_commands, {
412
+ parseSlashCommand: () => parseSlashCommand
413
+ });
414
+ function parseSlashCommand(input) {
415
+ const trimmed = input.trim();
416
+ if (!trimmed.startsWith("/")) {
417
+ return null;
418
+ }
419
+ const spaceIdx = trimmed.indexOf(" ");
420
+ const cmdRaw = (spaceIdx === -1 ? trimmed : trimmed.slice(0, spaceIdx)).toLowerCase();
421
+ const argsRaw = spaceIdx === -1 ? "" : trimmed.slice(spaceIdx + 1).trim();
422
+ switch (cmdRaw) {
423
+ case "/attach":
424
+ return { type: "attach", path: argsRaw };
425
+ case "/list":
426
+ return { type: "list" };
427
+ case "/clear":
428
+ return { type: "clear" };
429
+ case "/paste":
430
+ return { type: "paste" };
431
+ default:
432
+ return null;
433
+ }
434
+ }
435
+
329
436
  // ../../node_modules/.bun/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
330
437
  var require_identity = __commonJS((exports) => {
331
438
  var ALIAS = Symbol.for("yaml.alias");
@@ -7320,7 +7427,7 @@ var require_dist = __commonJS((exports) => {
7320
7427
  var require_package = __commonJS((exports, module) => {
7321
7428
  module.exports = {
7322
7429
  name: "@ai-setting/roy-agent-cli",
7323
- version: "1.5.93",
7430
+ version: "1.5.95",
7324
7431
  type: "module",
7325
7432
  description: "CLI for roy-agent - Non-interactive command execution",
7326
7433
  main: "./dist/index.js",
@@ -8034,9 +8141,11 @@ class ContextHandlerService {
8034
8141
  const traceId = context?.metadata?.traceId;
8035
8142
  const sessionId = context?.sessionId;
8036
8143
  const tracer = this.getTracerInstance();
8144
+ const queryForTrace = typeof query === "string" ? query : JSON.stringify(query).substring(0, 200);
8037
8145
  const span = tracer?.startSpan("handleQueryWithContext", {
8038
8146
  attributes: {
8039
- query: query.substring(0, 200),
8147
+ query: queryForTrace,
8148
+ queryKind: typeof query === "string" ? "text" : "multimodal",
8040
8149
  sessionId,
8041
8150
  traceId
8042
8151
  }
@@ -8149,8 +8258,9 @@ class ContextHandlerService {
8149
8258
  hintPreview: scenarioHint.substring(0, 200)
8150
8259
  }
8151
8260
  });
8261
+ const queryText = typeof originalQuery === "string" ? originalQuery : Array.isArray(originalQuery) ? originalQuery.filter((p) => p?.type === "text").map((p) => p.text ?? "").join(" ") : "";
8152
8262
  const result = await this.sessionComponent.compact(sessionId, {
8153
- summary: originalQuery ? `Auto-compacted. Original query: ${originalQuery.substring(0, 200)}${originalQuery.length > 200 ? "..." : ""}` : "Auto-compacted due to context threshold",
8263
+ summary: queryText ? `Auto-compacted. Original query: ${queryText.substring(0, 200)}${queryText.length > 200 ? "..." : ""}` : "Auto-compacted due to context threshold",
8154
8264
  scenarioHint
8155
8265
  });
8156
8266
  this.env.pushEnvEvent({
@@ -8162,7 +8272,7 @@ class ContextHandlerService {
8162
8272
  scenarioHintUsed: !!scenarioHint
8163
8273
  }
8164
8274
  });
8165
- const newQuery = this.constructQueryWithCheckpoint(result.checkpoint, originalQuery);
8275
+ const newQuery = Array.isArray(originalQuery) ? originalQuery : this.constructQueryWithCheckpoint(result.checkpoint, originalQuery);
8166
8276
  logger3.info("[Phase 2] Compact completed", {
8167
8277
  checkpointId: result.checkpoint.id,
8168
8278
  deletedMessageCount: result.deletedMessageCount,
@@ -8200,7 +8310,7 @@ __legacyDecorateClassTS([
8200
8310
  __legacyMetadataTS("design:type", Function),
8201
8311
  __legacyMetadataTS("design:paramtypes", [
8202
8312
  String,
8203
- String
8313
+ Object
8204
8314
  ]),
8205
8315
  __legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
8206
8316
  ], ContextHandlerService.prototype, "compactSessionWithTwoPhases", null);
@@ -8348,6 +8458,99 @@ function isWorkflowPausedActResult(result) {
8348
8458
  }
8349
8459
  }
8350
8460
 
8461
+ // src/commands/shared/multimodal-message.ts
8462
+ import { parseImageInput } from "@ai-setting/roy-agent-core";
8463
+ function parseActImageArgs(raw) {
8464
+ if (raw === undefined || raw === null)
8465
+ return [];
8466
+ if (typeof raw === "string") {
8467
+ return raw.length > 0 ? [raw] : [];
8468
+ }
8469
+ if (!Array.isArray(raw))
8470
+ return [];
8471
+ const cleaned = [];
8472
+ const seen = new Set;
8473
+ for (const item of raw) {
8474
+ if (typeof item !== "string")
8475
+ continue;
8476
+ const trimmed = item.trim();
8477
+ if (!trimmed)
8478
+ continue;
8479
+ if (seen.has(trimmed))
8480
+ continue;
8481
+ seen.add(trimmed);
8482
+ cleaned.push(trimmed);
8483
+ }
8484
+ return cleaned;
8485
+ }
8486
+ function assembleMultimodalMessage(text, imageArgs) {
8487
+ if (!imageArgs || imageArgs.length === 0) {
8488
+ return text;
8489
+ }
8490
+ const imageParts = Promise.all(imageArgs.map((raw) => parseImageInput(raw))).then((parts) => [
8491
+ { type: "text", text },
8492
+ ...parts
8493
+ ]);
8494
+ return imageParts;
8495
+ }
8496
+
8497
+ // src/commands/act-shutdown.ts
8498
+ import { TempFileManager } from "@ai-setting/roy-agent-core/utils/temp-file-manager";
8499
+ async function runActShutdownCleanup(deps) {
8500
+ const {
8501
+ stopTaskEventHandlerCleanup: stopTaskEventHandlerCleanupFn,
8502
+ lspManagerDispose,
8503
+ pluginAdapterDispose,
8504
+ envService,
8505
+ shouldDisposeEnvService,
8506
+ output,
8507
+ logger: logger4
8508
+ } = deps;
8509
+ const log = logger4 ?? {
8510
+ debug: () => {},
8511
+ warn: (msg) => console.warn(msg)
8512
+ };
8513
+ try {
8514
+ if (typeof stopTaskEventHandlerCleanupFn === "function") {
8515
+ stopTaskEventHandlerCleanupFn();
8516
+ }
8517
+ } catch (err) {
8518
+ log.warn(`[Act-Shutdown] Task Event Handler stop failed: ${err}`);
8519
+ }
8520
+ if (lspManagerDispose) {
8521
+ try {
8522
+ await lspManagerDispose();
8523
+ } catch (err) {
8524
+ log.warn(`[Act-Shutdown] LSP Manager dispose failed: ${err}`);
8525
+ }
8526
+ }
8527
+ if (pluginAdapterDispose) {
8528
+ try {
8529
+ await pluginAdapterDispose();
8530
+ } catch (err) {
8531
+ log.warn(`[Act-Shutdown] PluginAdapter dispose failed: ${err}`);
8532
+ }
8533
+ }
8534
+ if (shouldDisposeEnvService) {
8535
+ try {
8536
+ await envService.dispose();
8537
+ } catch (err) {
8538
+ log.warn(`[Act-Shutdown] envService.dispose failed: ${err}`);
8539
+ }
8540
+ }
8541
+ try {
8542
+ await TempFileManager.getInstance().cleanupAll();
8543
+ log.debug?.("[Act-Shutdown] TempFileManager cleaned up");
8544
+ } catch (err) {
8545
+ log.warn(`[Act-Shutdown] TempFileManager cleanup failed: ${err}`);
8546
+ if (output)
8547
+ output.warn(`⚠ TempFileManager cleanup failed: ${err}`);
8548
+ }
8549
+ if (shouldDisposeEnvService && typeof process !== "undefined" && process.env.ROY_AGENT_NO_EXIT !== "1") {
8550
+ process.exit(0);
8551
+ }
8552
+ }
8553
+
8351
8554
  // src/commands/act.ts
8352
8555
  function createActCommand(externalEnvService) {
8353
8556
  return {
@@ -8398,6 +8601,11 @@ function createActCommand(externalEnvService) {
8398
8601
  alias: "a",
8399
8602
  describe: "指定要使用的 agent(如 explore, markdown-ontology-extractor)",
8400
8603
  type: "string"
8604
+ }).option("image", {
8605
+ alias: "i",
8606
+ describe: "附加图片到消息(可多次传入;支持本地路径 / http(s) URL / data:base64)",
8607
+ type: "array",
8608
+ string: true
8401
8609
  }),
8402
8610
  async handler(args) {
8403
8611
  const quiet = args.quiet ?? true;
@@ -8409,10 +8617,16 @@ function createActCommand(externalEnvService) {
8409
8617
  output.info('示例:roy-agent act "帮我写一个 hello world"');
8410
8618
  process.exit(1);
8411
8619
  }
8620
+ const imageArgs = parseActImageArgs(args.image);
8621
+ const hasImages = imageArgs.length > 0;
8622
+ if (hasImages && !quiet) {
8623
+ output.info(`\uD83D\uDCCE 附加 ${imageArgs.length} 张图片`);
8624
+ }
8412
8625
  const shouldDisposeEnvService = !externalEnvService;
8413
8626
  const envService = externalEnvService ?? new EnvironmentService(output);
8414
8627
  let pluginAdapterDispose = null;
8415
8628
  let lspManagerDispose = null;
8629
+ let stopTaskEventHandlerCleanup = null;
8416
8630
  const rawPlugins = args.plugin;
8417
8631
  const pluginNames = Array.isArray(rawPlugins) ? rawPlugins : rawPlugins ? [rawPlugins] : [];
8418
8632
  const CODER_HARNESS_PLUGINS = new Set([
@@ -8470,7 +8684,7 @@ function createActCommand(externalEnvService) {
8470
8684
  env,
8471
8685
  enabled: true
8472
8686
  });
8473
- const stopTaskEventHandlerCleanup2 = taskEventHandlerForCleanup.start();
8687
+ stopTaskEventHandlerCleanup = taskEventHandlerForCleanup.start();
8474
8688
  let sessionId = args.session;
8475
8689
  if (args.continue && !sessionId) {
8476
8690
  const activeSession = await sessionComponent.getActiveSession();
@@ -8632,12 +8846,14 @@ function createActCommand(externalEnvService) {
8632
8846
  model: args.model,
8633
8847
  metadata: {
8634
8848
  originalQuery: args.message,
8635
- traceId
8849
+ traceId,
8850
+ queryKind: hasImages ? "multimodal" : "text"
8636
8851
  }
8637
8852
  };
8853
+ const finalQuery = hasImages ? await assembleMultimodalMessage(args.message, imageArgs) : args.message;
8638
8854
  let result;
8639
8855
  try {
8640
- result = await contextHandler.handleQueryWithContext(args.message, context);
8856
+ result = await contextHandler.handleQueryWithContext(finalQuery, context);
8641
8857
  rootSpan.end(result);
8642
8858
  } catch (error) {
8643
8859
  rootSpan.setAttribute("error", String(error));
@@ -8668,21 +8884,15 @@ function createActCommand(externalEnvService) {
8668
8884
  }
8669
8885
  process.exit(1);
8670
8886
  } finally {
8671
- if (typeof stopTaskEventHandlerCleanup === "function") {
8672
- stopTaskEventHandlerCleanup();
8673
- }
8674
- if (lspManagerDispose) {
8675
- await lspManagerDispose();
8676
- }
8677
- if (pluginAdapterDispose) {
8678
- await pluginAdapterDispose();
8679
- }
8680
- if (shouldDisposeEnvService) {
8681
- await envService.dispose();
8682
- if (process.env.ROY_AGENT_NO_EXIT !== "1") {
8683
- process.exit(0);
8684
- }
8685
- }
8887
+ await runActShutdownCleanup({
8888
+ stopTaskEventHandlerCleanup,
8889
+ lspManagerDispose,
8890
+ pluginAdapterDispose,
8891
+ envService,
8892
+ shouldDisposeEnvService,
8893
+ output,
8894
+ logger: { debug: () => {}, warn: console.warn }
8895
+ });
8686
8896
  }
8687
8897
  }
8688
8898
  };
@@ -8691,13 +8901,16 @@ var ActCommand = createActCommand();
8691
8901
 
8692
8902
  // src/commands/interactive.ts
8693
8903
  import * as readline2 from "readline";
8694
- import chalk4 from "chalk";
8904
+ import chalk5 from "chalk";
8695
8905
 
8696
8906
  // src/commands/shared/session-manager.ts
8907
+ import { parseImageInput as parseImageInput2 } from "@ai-setting/roy-agent-core";
8908
+
8697
8909
  class SessionManager {
8698
8910
  sessionComponent;
8699
8911
  output;
8700
8912
  quiet;
8913
+ attachedImagesMap = new Map;
8701
8914
  constructor(options) {
8702
8915
  this.sessionComponent = options.sessionComponent;
8703
8916
  this.output = options.output;
@@ -8740,6 +8953,7 @@ class SessionManager {
8740
8953
  this.output.info(`创建新会话: ${newSession.title} (${targetSessionId})`);
8741
8954
  }
8742
8955
  }
8956
+ this.clearAttachments();
8743
8957
  const session = await this.sessionComponent.get(targetSessionId);
8744
8958
  return {
8745
8959
  sessionId: targetSessionId,
@@ -8753,6 +8967,34 @@ class SessionManager {
8753
8967
  async getCurrentSession() {
8754
8968
  return this.sessionComponent.getActiveSession();
8755
8969
  }
8970
+ async attachImage(rawPath) {
8971
+ const normalized = rawPath.trim();
8972
+ if (!normalized) {
8973
+ throw new Error("attachImage: empty path");
8974
+ }
8975
+ const existing = this.attachedImagesMap.get(normalized);
8976
+ if (existing) {
8977
+ return existing;
8978
+ }
8979
+ const part = await parseImageInput2(normalized);
8980
+ this.attachedImagesMap.set(normalized, part);
8981
+ return part;
8982
+ }
8983
+ listAttachments() {
8984
+ return Array.from(this.attachedImagesMap.values());
8985
+ }
8986
+ clearAttachments() {
8987
+ this.attachedImagesMap.clear();
8988
+ }
8989
+ async getQueryPayload(text) {
8990
+ if (this.attachedImagesMap.size === 0) {
8991
+ return text;
8992
+ }
8993
+ return [
8994
+ { type: "text", text },
8995
+ ...this.listAttachments()
8996
+ ];
8997
+ }
8756
8998
  }
8757
8999
 
8758
9000
  // src/commands/shared/query-executor.ts
@@ -8868,6 +9110,9 @@ class QueryExecutor {
8868
9110
  getFullText() {
8869
9111
  return this.streamService?.getFullText() ?? "";
8870
9112
  }
9113
+ getLastUsage() {
9114
+ return this.streamService?.getUsageInfo() ?? null;
9115
+ }
8871
9116
  resetStream() {
8872
9117
  this.streamService?.reset();
8873
9118
  }
@@ -8913,7 +9158,7 @@ __legacyDecorateClassTS([
8913
9158
  TracedAs2("cli.query-executor.execute", { recordParams: true, log: true }),
8914
9159
  __legacyMetadataTS("design:type", Function),
8915
9160
  __legacyMetadataTS("design:paramtypes", [
8916
- String,
9161
+ Object,
8917
9162
  String,
8918
9163
  typeof Partial === "undefined" ? Object : Partial,
8919
9164
  String,
@@ -9433,8 +9678,136 @@ function parseUserInput(input, options) {
9433
9678
  return { type: "text", value: trimmedInput };
9434
9679
  }
9435
9680
 
9681
+ // src/commands/interactive-shutdown.ts
9682
+ import { TempFileManager as TempFileManager2 } from "@ai-setting/roy-agent-core/utils/temp-file-manager";
9683
+ async function shutdownInteractiveSteps(deps) {
9684
+ const {
9685
+ memoryPluginDispose,
9686
+ memoryPluginInstance,
9687
+ lspManagerDispose,
9688
+ pluginAdapterDispose,
9689
+ eventHandler,
9690
+ queryExecutor,
9691
+ env,
9692
+ envService,
9693
+ shouldDisposeEnvService,
9694
+ output,
9695
+ logger: logger4,
9696
+ console: consoleLike
9697
+ } = deps;
9698
+ const log = (msg) => consoleLike?.log?.(msg) ?? console.log(msg);
9699
+ if (memoryPluginDispose) {
9700
+ try {
9701
+ if (memoryPluginInstance?.hasPendingTasks?.()) {
9702
+ log("\uD83D\uDCBE 正在保存记忆,请稍候...");
9703
+ await memoryPluginInstance.waitForCompletion?.();
9704
+ }
9705
+ await memoryPluginDispose();
9706
+ log("\uD83D\uDCBE 记忆已保存完毕");
9707
+ } catch (err) {
9708
+ logger4.warn(`[Shutdown] MemoryPlugin dispose failed: ${err}`);
9709
+ output.warn(`⚠️ 记忆保存失败: ${err}`);
9710
+ }
9711
+ }
9712
+ if (lspManagerDispose) {
9713
+ try {
9714
+ await lspManagerDispose();
9715
+ } catch (err) {
9716
+ logger4.warn(`[Shutdown] LSP Manager dispose failed: ${err}`);
9717
+ }
9718
+ }
9719
+ if (pluginAdapterDispose) {
9720
+ try {
9721
+ await pluginAdapterDispose();
9722
+ } catch (err) {
9723
+ logger4.warn(`[Shutdown] PluginAdapter dispose failed: ${err}`);
9724
+ }
9725
+ }
9726
+ try {
9727
+ eventHandler.stop();
9728
+ } catch (err) {
9729
+ logger4.warn(`[Shutdown] EventHandler.stop failed: ${err}`);
9730
+ }
9731
+ try {
9732
+ queryExecutor.dispose();
9733
+ } catch (err) {
9734
+ logger4.warn(`[Shutdown] QueryExecutor.dispose failed: ${err}`);
9735
+ }
9736
+ try {
9737
+ const eventSourceComponent = env.getComponent("event-source");
9738
+ if (eventSourceComponent) {
9739
+ const sources = eventSourceComponent.list?.();
9740
+ if (sources && sources.length > 0) {
9741
+ for (const source of sources) {
9742
+ const status = eventSourceComponent.getStatus?.(source.id);
9743
+ logger4.debug(`[Shutdown] 检查事件源: ${source.id}, 状态: ${status}`);
9744
+ if (status !== "stopped" && status !== "created") {
9745
+ try {
9746
+ await eventSourceComponent.stopSource(source.id);
9747
+ output.info(`✓ 已停止事件源: ${source.name} (${status})`);
9748
+ } catch (error) {
9749
+ output.warn(`⚠️ 停止事件源 ${source.name} 失败: ${error}`);
9750
+ }
9751
+ }
9752
+ }
9753
+ }
9754
+ }
9755
+ } catch (err) {
9756
+ logger4.warn(`[Shutdown] EventSource cleanup failed: ${err}`);
9757
+ }
9758
+ if (shouldDisposeEnvService) {
9759
+ try {
9760
+ await envService.dispose();
9761
+ } catch (err) {
9762
+ logger4.warn(`[Shutdown] envService.dispose failed: ${err}`);
9763
+ }
9764
+ }
9765
+ try {
9766
+ await TempFileManager2.getInstance().cleanupAll();
9767
+ logger4.debug("[Shutdown] TempFileManager cleaned up");
9768
+ } catch (err) {
9769
+ logger4.warn(`[Shutdown] TempFileManager cleanup failed: ${err}`);
9770
+ }
9771
+ }
9772
+
9436
9773
  // src/commands/interactive.ts
9437
9774
  import { AskUserError } from "@ai-setting/roy-agent-core";
9775
+
9776
+ // src/commands/shared/usage-formatter.ts
9777
+ import chalk4 from "chalk";
9778
+ var PRICING = {
9779
+ regularPerToken: 3 / 1e6,
9780
+ cacheReadPerToken: 0.3 / 1e6,
9781
+ cacheWritePerToken: 3.75 / 1e6
9782
+ };
9783
+ function formatCacheLine(usage, options = {}) {
9784
+ const { colorize = true } = options;
9785
+ if (!usage)
9786
+ return null;
9787
+ const cacheRead = usage.cacheRead ?? 0;
9788
+ const cacheWrite = usage.cacheWrite ?? 0;
9789
+ if (usage.cacheRead === undefined && usage.cacheWrite === undefined && cacheRead === 0 && cacheWrite === 0) {
9790
+ return null;
9791
+ }
9792
+ if (cacheRead === 0 && cacheWrite === 0) {
9793
+ if (!colorize)
9794
+ return "\uD83D\uDCB0 Cache: read 0 / write 0 (saved ~$0.000 / 0% hit rate)";
9795
+ return chalk4.gray("\uD83D\uDCB0 Cache: read 0 / write 0 (saved ~$0.000 / 0% hit rate)");
9796
+ }
9797
+ const saved = cacheRead * (PRICING.regularPerToken - PRICING.cacheReadPerToken);
9798
+ const denom = cacheRead + cacheWrite;
9799
+ const hitRate = denom > 0 ? (cacheRead / denom * 100).toFixed(0) : "0";
9800
+ const text = `\uD83D\uDCB0 Cache: read ${cacheRead} / write ${cacheWrite} (saved ~$${saved.toFixed(3)} / ${hitRate}% hit rate)`;
9801
+ if (!colorize)
9802
+ return text;
9803
+ if (cacheRead > 0 && cacheWrite === 0)
9804
+ return chalk4.green(text);
9805
+ if (cacheRead === 0 && cacheWrite > 0)
9806
+ return chalk4.yellow(text);
9807
+ return chalk4.yellow(text);
9808
+ }
9809
+
9810
+ // src/commands/interactive.ts
9438
9811
  var logger4 = createLogger4("cli:interactive");
9439
9812
  var USER_PROMPT = COLORS.userInput("❯ ");
9440
9813
 
@@ -9447,6 +9820,12 @@ class REPL {
9447
9820
  env = null;
9448
9821
  inputHandler;
9449
9822
  keypressHandler;
9823
+ sessionManager = null;
9824
+ lastAttachPath = undefined;
9825
+ lastUsage = null;
9826
+ setLastUsage(usage) {
9827
+ this.lastUsage = usage;
9828
+ }
9450
9829
  constructor(options, env) {
9451
9830
  this.options = options;
9452
9831
  this.env = env ?? null;
@@ -9501,10 +9880,12 @@ class REPL {
9501
9880
  this.commandRegistry.set("clear", async () => {
9502
9881
  console.clear();
9503
9882
  this.printHeader();
9883
+ this.sessionManager?.clearAttachments();
9504
9884
  });
9505
9885
  this.commandRegistry.set("cls", async () => {
9506
9886
  console.clear();
9507
9887
  this.printHeader();
9888
+ this.sessionManager?.clearAttachments();
9508
9889
  });
9509
9890
  this.commandRegistry.set("sessions", async () => {
9510
9891
  this.printSessionsHelp();
@@ -9516,6 +9897,61 @@ class REPL {
9516
9897
  this.commandRegistry.set("c", async () => {
9517
9898
  await this.options.onCompact();
9518
9899
  });
9900
+ this.commandRegistry.set("attach", async () => {
9901
+ const path2 = this.lastAttachPath;
9902
+ this.lastAttachPath = undefined;
9903
+ if (!path2) {
9904
+ console.log(`
9905
+ ${COLORS.error("用法: /attach <path|url>")}`);
9906
+ return;
9907
+ }
9908
+ try {
9909
+ await this.sessionManager.attachImage(path2);
9910
+ const list = this.sessionManager.listAttachments();
9911
+ console.log(`
9912
+ ${COLORS.system(`\uD83D\uDCCE 已添加 (共 ${list.length} 张)`)}`);
9913
+ } catch (err) {
9914
+ console.log(`
9915
+ ${COLORS.error("❌ 附加失败: " + (err instanceof Error ? err.message : String(err)))}`);
9916
+ }
9917
+ });
9918
+ this.commandRegistry.set("list", async () => {
9919
+ const list = this.sessionManager?.listAttachments() ?? [];
9920
+ if (list.length === 0) {
9921
+ console.log(`
9922
+ ${COLORS.system("\uD83D\uDCCE 当前没有 attach 图片 (使用 /attach <path> 添加)")}`);
9923
+ return;
9924
+ }
9925
+ console.log(`
9926
+ ${COLORS.system(`\uD83D\uDCCE 当前 attach 列表 (${list.length} 张):`)}`);
9927
+ list.forEach((p, i) => {
9928
+ if (p.type === "image") {
9929
+ const desc = typeof p.image === "string" ? p.image : `<buffer ${p.image.byteLength ?? 0} bytes>`;
9930
+ console.log(` ${i + 1}. ${desc}`);
9931
+ }
9932
+ });
9933
+ });
9934
+ this.commandRegistry.set("paste", async () => {
9935
+ const { readClipboardImage: readClipboardImage2 } = await Promise.resolve().then(() => (init_clipboard_helper(), exports_clipboard_helper));
9936
+ const result = await readClipboardImage2();
9937
+ if (!result) {
9938
+ console.log(`
9939
+ ${COLORS.error("❌ 剪贴板中没有图片,或剪贴板工具不可用")}`);
9940
+ return;
9941
+ }
9942
+ const tmpPath = `/tmp/roy-paste-${Date.now()}.${result.mime.split("/")[1] || "png"}`;
9943
+ try {
9944
+ const fs2 = await import("node:fs/promises");
9945
+ await fs2.writeFile(tmpPath, result.buffer);
9946
+ await this.sessionManager.attachImage(tmpPath);
9947
+ const list = this.sessionManager.listAttachments();
9948
+ console.log(`
9949
+ ${COLORS.system(`\uD83D\uDCCE 已粘贴 (共 ${list.length} 张): ${tmpPath}`)}`);
9950
+ } catch (err) {
9951
+ console.log(`
9952
+ ${COLORS.error("❌ 粘贴失败: " + (err instanceof Error ? err.message : String(err)))}`);
9953
+ }
9954
+ });
9519
9955
  this.commandRegistry.set("abort", async () => {
9520
9956
  if (this.isExecuting) {
9521
9957
  console.log(`
@@ -9576,6 +10012,11 @@ ${COLORS.system("[没有正在执行的请求]")}`);
9576
10012
  return;
9577
10013
  }
9578
10014
  if (line.startsWith("/") && this.inputHandler.getBuffer() === "") {
10015
+ const { parseSlashCommand: parseSlashCommand2 } = await Promise.resolve().then(() => exports_slash_commands);
10016
+ const slash = parseSlashCommand2(line);
10017
+ if (slash?.type === "attach") {
10018
+ this.lastAttachPath = slash.path;
10019
+ }
9579
10020
  await this.handleCommand(line.slice(1));
9580
10021
  this.inputHandler.reset();
9581
10022
  this.updatePrompt();
@@ -9618,7 +10059,8 @@ ${COLORS.system("⏳ 上一次请求尚未完成,请稍候...")}
9618
10059
  `);
9619
10060
  return;
9620
10061
  }
9621
- await this.executeInternal(message, { showPrompt: false });
10062
+ const payload = this.sessionManager ? await this.sessionManager.getQueryPayload(message) : message;
10063
+ await this.executeInternal(payload, { showPrompt: false });
9622
10064
  }
9623
10065
  async handleEventMessage(message) {
9624
10066
  console.log(`
@@ -9680,6 +10122,13 @@ ${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
9680
10122
  console.log(`${COLORS.progress("[thinking...]")}`);
9681
10123
  try {
9682
10124
  await this.options.onExecute(message, traceId, agentContext);
10125
+ if (this.options.onAfterExecute) {
10126
+ try {
10127
+ await this.options.onAfterExecute(this.lastUsage);
10128
+ } catch (hookError) {
10129
+ logger4.warn("onAfterExecute hook failed", { error: String(hookError) });
10130
+ }
10131
+ }
9683
10132
  } catch (error) {
9684
10133
  const askUserError = this.parseAskUserError(error);
9685
10134
  if (askUserError) {
@@ -9758,7 +10207,7 @@ ${COLORS.error("❌ 执行失败: " + error)}
9758
10207
  this.rl.removeListener("line", handleLine);
9759
10208
  const trimmedInput = input.trim();
9760
10209
  if (!trimmedInput) {
9761
- console.log(chalk4.yellow(`⚠️ 输入不能为空,请重新输入
10210
+ console.log(chalk5.yellow(`⚠️ 输入不能为空,请重新输入
9762
10211
  `));
9763
10212
  this.promptUser(question, options).then(resolve);
9764
10213
  return;
@@ -9766,11 +10215,11 @@ ${COLORS.error("❌ 执行失败: " + error)}
9766
10215
  const parsed = parseUserInput(trimmedInput, options);
9767
10216
  if (parsed.type === "option" && options) {
9768
10217
  const selectedOption = options[parsed.value];
9769
- console.log(chalk4.green(`✓ 您选择了: ${selectedOption}
10218
+ console.log(chalk5.green(`✓ 您选择了: ${selectedOption}
9770
10219
  `));
9771
10220
  resolve(selectedOption);
9772
10221
  } else {
9773
- console.log(chalk4.green(`✓ 您的回答: ${parsed.value}
10222
+ console.log(chalk5.green(`✓ 您的回答: ${parsed.value}
9774
10223
  `));
9775
10224
  resolve(parsed.value);
9776
10225
  }
@@ -9824,61 +10273,61 @@ ${COLORS.error("❌ 执行失败: " + error)}
9824
10273
  }
9825
10274
  }
9826
10275
  printHeader() {
9827
- console.log(chalk4.bold(`
10276
+ console.log(chalk5.bold(`
9828
10277
  ╔══════════════════════════════════════════════════╗`));
9829
- console.log(chalk4.bold("║ ") + chalk4.green.bold("roy-agent") + chalk4.bold(" Interactive Mode") + chalk4.bold(" ║"));
9830
- console.log(chalk4.bold(`╚══════════════════════════════════════════════════╝
10278
+ console.log(chalk5.bold("║ ") + chalk5.green.bold("roy-agent") + chalk5.bold(" Interactive Mode") + chalk5.bold(" ║"));
10279
+ console.log(chalk5.bold(`╚══════════════════════════════════════════════════╝
9831
10280
  `));
9832
- console.log(`${chalk4.dim("会话:")} ${this.options.sessionTitle}`);
9833
- console.log(`${chalk4.dim("输入 ")} ${COLORS.userInput("/help")} ${chalk4.dim("查看可用命令")}
10281
+ console.log(`${chalk5.dim("会话:")} ${this.options.sessionTitle}`);
10282
+ console.log(`${chalk5.dim("输入 ")} ${COLORS.userInput("/help")} ${chalk5.dim("查看可用命令")}
9834
10283
  `);
9835
10284
  }
9836
10285
  printHelp() {
9837
10286
  console.log(`
9838
- ${chalk4.bold("╭")}${chalk4.dim("─".repeat(49))}${chalk4.bold("╮")}
9839
- ${chalk4.bold("│")} ${chalk4.bold("快捷命令")} ${chalk4.bold("│")}
9840
- ${chalk4.bold("├")}${chalk4.dim("─".repeat(49))}${chalk4.bold("├")}
9841
- ${chalk4.bold("│")} ${COLORS.userInput("/help")}, ${COLORS.userInput("/h")} 显示帮助 ${chalk4.bold("│")}
9842
- ${chalk4.bold("│")} ${COLORS.userInput("/status")}, ${COLORS.userInput("/st")} 显示状态 ${chalk4.bold("│")}
9843
- ${chalk4.bold("│")} ${COLORS.userInput("/sessions")}, ${COLORS.userInput("/s")} 切换会话 ${chalk4.bold("│")}
9844
- ${chalk4.bold("│")} ${COLORS.userInput("/compact")}, ${COLORS.userInput("/c")} 压缩上下文 ${chalk4.bold("│")}
9845
- ${chalk4.bold("│")} ${COLORS.userInput("/abort")} 中断当前流式输出 ${chalk4.bold("│")}
9846
- ${chalk4.bold("│")} ${COLORS.userInput("/clear")}, ${COLORS.userInput("/cls")} 清屏 ${chalk4.bold("│")}
9847
- ${chalk4.bold("│")} ${COLORS.userInput("/exit")}, ${COLORS.userInput("/q")} 退出 ${chalk4.bold("│")}
9848
- ${chalk4.bold("├")}${chalk4.dim("─".repeat(49))}${chalk4.bold("├")}
9849
- ${chalk4.bold("│")} ${chalk4.bold("多行输入")} ${chalk4.bold("│")}
9850
- ${chalk4.bold("├")}${chalk4.dim("─".repeat(49))}${chalk4.bold("├")}
9851
- ${chalk4.bold("│")} 输入多行内容后,Alt+Enter 结束输入。 ${chalk4.bold("│")}
9852
- ${chalk4.bold("│")} Ctrl+C 可取消多行输入。 ${chalk4.bold("│")}
9853
- ${chalk4.bold("╰")}${chalk4.dim("─".repeat(49))}${chalk4.bold("╯")}
10287
+ ${chalk5.bold("╭")}${chalk5.dim("─".repeat(49))}${chalk5.bold("╮")}
10288
+ ${chalk5.bold("│")} ${chalk5.bold("快捷命令")} ${chalk5.bold("│")}
10289
+ ${chalk5.bold("├")}${chalk5.dim("─".repeat(49))}${chalk5.bold("├")}
10290
+ ${chalk5.bold("│")} ${COLORS.userInput("/help")}, ${COLORS.userInput("/h")} 显示帮助 ${chalk5.bold("│")}
10291
+ ${chalk5.bold("│")} ${COLORS.userInput("/status")}, ${COLORS.userInput("/st")} 显示状态 ${chalk5.bold("│")}
10292
+ ${chalk5.bold("│")} ${COLORS.userInput("/sessions")}, ${COLORS.userInput("/s")} 切换会话 ${chalk5.bold("│")}
10293
+ ${chalk5.bold("│")} ${COLORS.userInput("/compact")}, ${COLORS.userInput("/c")} 压缩上下文 ${chalk5.bold("│")}
10294
+ ${chalk5.bold("│")} ${COLORS.userInput("/abort")} 中断当前流式输出 ${chalk5.bold("│")}
10295
+ ${chalk5.bold("│")} ${COLORS.userInput("/clear")}, ${COLORS.userInput("/cls")} 清屏 ${chalk5.bold("│")}
10296
+ ${chalk5.bold("│")} ${COLORS.userInput("/exit")}, ${COLORS.userInput("/q")} 退出 ${chalk5.bold("│")}
10297
+ ${chalk5.bold("├")}${chalk5.dim("─".repeat(49))}${chalk5.bold("├")}
10298
+ ${chalk5.bold("│")} ${chalk5.bold("多行输入")} ${chalk5.bold("│")}
10299
+ ${chalk5.bold("├")}${chalk5.dim("─".repeat(49))}${chalk5.bold("├")}
10300
+ ${chalk5.bold("│")} 输入多行内容后,Alt+Enter 结束输入。 ${chalk5.bold("│")}
10301
+ ${chalk5.bold("│")} Ctrl+C 可取消多行输入。 ${chalk5.bold("│")}
10302
+ ${chalk5.bold("╰")}${chalk5.dim("─".repeat(49))}${chalk5.bold("╯")}
9854
10303
  `);
9855
10304
  }
9856
10305
  async printStatus() {
9857
10306
  const status = await this.options.onStatus();
9858
10307
  console.log(`
9859
- ${chalk4.bold("╭")}${chalk4.dim("─".repeat(49))}${chalk4.bold("╮")}
9860
- ${chalk4.bold("│")} ${chalk4.bold("会话状态")} ${chalk4.bold("│")}
9861
- ${chalk4.bold("├")}${chalk4.dim("─".repeat(49))}${chalk4.bold("├")}
9862
- ${chalk4.bold("│")} ${chalk4.dim("会话:")} ${status.sessionTitle.padEnd(35)} ${chalk4.bold("│")}
9863
- ${chalk4.bold("│")} ${chalk4.dim("ID:")} ${status.sessionId.padEnd(37)} ${chalk4.bold("│")}
9864
- ${chalk4.bold("│")} ${chalk4.dim("消息:")} ${String(status.messageCount).padEnd(34)} ${chalk4.bold("│")}
9865
- ${chalk4.bold("│")} ${chalk4.dim("Token:")} ${String(status.tokenCount).padEnd(33)} ${chalk4.bold("│")}
9866
- ${chalk4.bold("╰")}${chalk4.dim("─".repeat(49))}${chalk4.bold("╯")}
10308
+ ${chalk5.bold("╭")}${chalk5.dim("─".repeat(49))}${chalk5.bold("╮")}
10309
+ ${chalk5.bold("│")} ${chalk5.bold("会话状态")} ${chalk5.bold("│")}
10310
+ ${chalk5.bold("├")}${chalk5.dim("─".repeat(49))}${chalk5.bold("├")}
10311
+ ${chalk5.bold("│")} ${chalk5.dim("会话:")} ${status.sessionTitle.padEnd(35)} ${chalk5.bold("│")}
10312
+ ${chalk5.bold("│")} ${chalk5.dim("ID:")} ${status.sessionId.padEnd(37)} ${chalk5.bold("│")}
10313
+ ${chalk5.bold("│")} ${chalk5.dim("消息:")} ${String(status.messageCount).padEnd(34)} ${chalk5.bold("│")}
10314
+ ${chalk5.bold("│")} ${chalk5.dim("Token:")} ${String(status.tokenCount).padEnd(33)} ${chalk5.bold("│")}
10315
+ ${chalk5.bold("╰")}${chalk5.dim("─".repeat(49))}${chalk5.bold("╯")}
9867
10316
  `);
9868
10317
  }
9869
10318
  printSessionsHelp() {
9870
10319
  console.log(`
9871
- ${chalk4.bold("╭")}${chalk4.dim("─".repeat(49))}${chalk4.bold("╮")}
9872
- ${chalk4.bold("│")} ${chalk4.bold("切换会话")} ${chalk4.bold("│")}
9873
- ${chalk4.bold("├")}${chalk4.dim("─".repeat(49))}${chalk4.bold("├")}
9874
- ${chalk4.bold("│")} 退出当前交互模式后,使用以下命令切换会话: ${chalk4.bold("│")}
9875
- ${chalk4.bold("│")} ${chalk4.bold("│")}
9876
- ${chalk4.bold("│")} ${COLORS.userInput("roy-agent sessions list")} 列出所有会话 ${chalk4.bold("│")}
9877
- ${chalk4.bold("│")} ${COLORS.userInput("roy-agent sessions use <id>")} 切换到指定会话 ${chalk4.bold("│")}
9878
- ${chalk4.bold("│")} ${chalk4.bold("│")}
9879
- ${chalk4.bold("│")} 或直接指定会话启动: ${chalk4.bold("│")}
9880
- ${chalk4.bold("│")} ${COLORS.userInput("roy-agent interactive -s <session-id>")} ${chalk4.bold("│")}
9881
- ${chalk4.bold("╰")}${chalk4.dim("─".repeat(49))}${chalk4.bold("╯")}
10320
+ ${chalk5.bold("╭")}${chalk5.dim("─".repeat(49))}${chalk5.bold("╮")}
10321
+ ${chalk5.bold("│")} ${chalk5.bold("切换会话")} ${chalk5.bold("│")}
10322
+ ${chalk5.bold("├")}${chalk5.dim("─".repeat(49))}${chalk5.bold("├")}
10323
+ ${chalk5.bold("│")} 退出当前交互模式后,使用以下命令切换会话: ${chalk5.bold("│")}
10324
+ ${chalk5.bold("│")} ${chalk5.bold("│")}
10325
+ ${chalk5.bold("│")} ${COLORS.userInput("roy-agent sessions list")} 列出所有会话 ${chalk5.bold("│")}
10326
+ ${chalk5.bold("│")} ${COLORS.userInput("roy-agent sessions use <id>")} 切换到指定会话 ${chalk5.bold("│")}
10327
+ ${chalk5.bold("│")} ${chalk5.bold("│")}
10328
+ ${chalk5.bold("│")} 或直接指定会话启动: ${chalk5.bold("│")}
10329
+ ${chalk5.bold("│")} ${COLORS.userInput("roy-agent interactive -s <session-id>")} ${chalk5.bold("│")}
10330
+ ${chalk5.bold("╰")}${chalk5.dim("─".repeat(49))}${chalk5.bold("╯")}
9882
10331
  `);
9883
10332
  }
9884
10333
  }
@@ -10095,11 +10544,22 @@ function createInteractiveCommand(externalEnvService) {
10095
10544
  model: args.model,
10096
10545
  ...agentContext
10097
10546
  };
10098
- return queryExecutor.execute(message, sessionId, {
10547
+ const result = await queryExecutor.execute(message, sessionId, {
10099
10548
  showReasoning: args.reasoning,
10100
10549
  showToolCalls: args.toolCalls,
10101
10550
  showToolResults: args.toolResults
10102
10551
  }, traceId, mergedContext);
10552
+ repl.setLastUsage(queryExecutor.getLastUsage());
10553
+ return result;
10554
+ },
10555
+ onAfterExecute: (usage) => {
10556
+ if (usage) {
10557
+ const line = formatCacheLine(usage);
10558
+ if (line) {
10559
+ console.log(`
10560
+ ` + line);
10561
+ }
10562
+ }
10103
10563
  },
10104
10564
  onStatus: async () => {
10105
10565
  const session = await sessionComponent.get(sessionId);
@@ -10125,43 +10585,20 @@ function createInteractiveCommand(externalEnvService) {
10125
10585
  }
10126
10586
  },
10127
10587
  onShutdown: async () => {
10128
- if (memoryPluginDispose) {
10129
- if (memoryPluginInstance && memoryPluginInstance.hasPendingTasks()) {
10130
- console.log("\uD83D\uDCBE 正在保存记忆,请稍候...");
10131
- await memoryPluginInstance.waitForCompletion();
10132
- }
10133
- await memoryPluginDispose();
10134
- console.log("\uD83D\uDCBE 记忆已保存完毕");
10135
- }
10136
- if (lspManagerDispose) {
10137
- await lspManagerDispose();
10138
- }
10139
- if (pluginAdapterDispose) {
10140
- await pluginAdapterDispose();
10141
- }
10142
- eventHandler.stop();
10143
- queryExecutor.dispose();
10144
- const eventSourceComponent = env.getComponent("event-source");
10145
- if (eventSourceComponent) {
10146
- const sources = eventSourceComponent.list?.();
10147
- if (sources && sources.length > 0) {
10148
- for (const source of sources) {
10149
- const status = eventSourceComponent.getStatus?.(source.id);
10150
- logger4.debug(`[Shutdown] 检查事件源: ${source.id}, 状态: ${status}`);
10151
- if (status !== "stopped" && status !== "created") {
10152
- try {
10153
- await eventSourceComponent.stopSource(source.id);
10154
- output.info(`✓ 已停止事件源: ${source.name} (${status})`);
10155
- } catch (error) {
10156
- output.warn(`⚠️ 停止事件源 ${source.name} 失败: ${error}`);
10157
- }
10158
- }
10159
- }
10160
- }
10161
- }
10162
- if (shouldDisposeEnvService) {
10163
- await envService.dispose();
10164
- }
10588
+ await shutdownInteractiveSteps({
10589
+ memoryPluginDispose,
10590
+ memoryPluginInstance,
10591
+ lspManagerDispose,
10592
+ pluginAdapterDispose,
10593
+ eventHandler,
10594
+ queryExecutor,
10595
+ env,
10596
+ envService,
10597
+ shouldDisposeEnvService,
10598
+ output,
10599
+ logger: logger4,
10600
+ console
10601
+ });
10165
10602
  }
10166
10603
  }, env);
10167
10604
  const eventHandler = new EventHandler({
@@ -10196,6 +10633,7 @@ function createInteractiveCommand(externalEnvService) {
10196
10633
  repl.handleSigint();
10197
10634
  };
10198
10635
  process.on("SIGINT", sigintHandler);
10636
+ repl.sessionManager = sessionManager;
10199
10637
  await repl.start();
10200
10638
  process.removeListener("SIGINT", sigintHandler);
10201
10639
  console.log("正在清理资源...");
@@ -10241,7 +10679,7 @@ function createInteractiveCommand(externalEnvService) {
10241
10679
  var InteractiveCommand = createInteractiveCommand();
10242
10680
 
10243
10681
  // src/commands/sessions/list.ts
10244
- import chalk5 from "chalk";
10682
+ import chalk6 from "chalk";
10245
10683
  var ListCommand = {
10246
10684
  command: "list [options]",
10247
10685
  aliases: ["ls"],
@@ -10315,15 +10753,15 @@ var ListCommand = {
10315
10753
  const hasTypeFilter = !!args.type;
10316
10754
  const hasStatusFilter = !!args.status;
10317
10755
  const header = [
10318
- chalk5.bold("#"),
10319
- chalk5.bold("Title"),
10320
- chalk5.bold("ID"),
10321
- hasTypeFilter || hasStatusFilter ? chalk5.bold("Status") : null,
10322
- chalk5.bold("Msgs"),
10323
- chalk5.bold("CP")
10756
+ chalk6.bold("#"),
10757
+ chalk6.bold("Title"),
10758
+ chalk6.bold("ID"),
10759
+ hasTypeFilter || hasStatusFilter ? chalk6.bold("Status") : null,
10760
+ chalk6.bold("Msgs"),
10761
+ chalk6.bold("CP")
10324
10762
  ].filter(Boolean).join(" │ ");
10325
10763
  const rows = sessions.map((s, i) => {
10326
- const marker = s.id === activeSessionId ? chalk5.green("▶") : " ";
10764
+ const marker = s.id === activeSessionId ? chalk6.green("▶") : " ";
10327
10765
  const hasCp = (s.metadata?.checkpoints?.checkpoints?.length ?? 0) > 0;
10328
10766
  const title = s.title.length > 20 ? s.title.slice(0, 17) + "..." : s.title;
10329
10767
  const idStr = s.id;
@@ -10333,18 +10771,18 @@ var ListCommand = {
10333
10771
  let statusDisplay = "";
10334
10772
  if (hasTypeFilter || hasStatusFilter) {
10335
10773
  if (workflowMeta) {
10336
- 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;
10774
+ statusDisplay = workflowMeta.status === "running" ? chalk6.green("running") : workflowMeta.status === "paused" ? chalk6.yellow("paused") : workflowMeta.status === "completed" ? chalk6.gray("completed") : workflowMeta.status === "failed" ? chalk6.red("failed") : statusStr;
10337
10775
  }
10338
10776
  }
10339
10777
  const cells = [
10340
10778
  marker + " " + (args.offset + i + 1),
10341
10779
  title,
10342
- chalk5.gray(idStr)
10780
+ chalk6.gray(idStr)
10343
10781
  ];
10344
10782
  if (hasTypeFilter || hasStatusFilter) {
10345
- cells.push(statusDisplay || chalk5.gray("-"));
10783
+ cells.push(statusDisplay || chalk6.gray("-"));
10346
10784
  }
10347
- cells.push(s.messageCount.toString(), hasCp ? chalk5.green("✓") : chalk5.gray("-"));
10785
+ cells.push(s.messageCount.toString(), hasCp ? chalk6.green("✓") : chalk6.gray("-"));
10348
10786
  return cells.join(" │ ");
10349
10787
  });
10350
10788
  const showingInfo = totalCount > sessions.length ? `Showing ${sessions.length} of ${totalCount} sessions` : `${totalCount} sessions`;
@@ -10355,7 +10793,7 @@ var ListCommand = {
10355
10793
  ...rows.map((r) => `│${r}│`),
10356
10794
  "└" + "─".repeat(header.length + 2) + "┘",
10357
10795
  "",
10358
- chalk5.gray(showingInfo)
10796
+ chalk6.gray(showingInfo)
10359
10797
  ].join(`
10360
10798
  `));
10361
10799
  }
@@ -10369,7 +10807,7 @@ var ListCommand = {
10369
10807
  };
10370
10808
 
10371
10809
  // src/commands/sessions/get.ts
10372
- import chalk6 from "chalk";
10810
+ import chalk7 from "chalk";
10373
10811
  var GetCommand = {
10374
10812
  command: "get <session-id>",
10375
10813
  aliases: ["show"],
@@ -10425,29 +10863,29 @@ var GetCommand = {
10425
10863
  });
10426
10864
  } else {
10427
10865
  const lines = [
10428
- chalk6.bold("┌─ Session Details ─────────────────────────────────┐"),
10866
+ chalk7.bold("┌─ Session Details ─────────────────────────────────┐"),
10429
10867
  `│ ID: ${session.id}`,
10430
10868
  `│ Title: ${session.title}`,
10431
10869
  `│ Directory: ${session.directory}`,
10432
10870
  `│ Messages: ${session.messageCount}`,
10433
- `│ Active: ${session.id === activeSessionId ? chalk6.green("✓") : chalk6.gray("-")}`,
10871
+ `│ Active: ${session.id === activeSessionId ? chalk7.green("✓") : chalk7.gray("-")}`,
10434
10872
  `│ Created: ${new Date(session.createdAt).toLocaleString("zh-CN")}`,
10435
10873
  `│ Updated: ${new Date(session.updatedAt).toLocaleString("zh-CN")}`
10436
10874
  ];
10437
10875
  const workflowMeta = session.metadata?.type === "workflow" ? session.metadata : null;
10438
10876
  if (workflowMeta) {
10439
10877
  lines.push("├─ Workflow Info ─────────────────────────────────────┤");
10440
- lines.push(`│ Type: ${chalk6.cyan("workflow")}`);
10878
+ lines.push(`│ Type: ${chalk7.cyan("workflow")}`);
10441
10879
  lines.push(`│ Workflow: ${workflowMeta.workflowName}`);
10442
10880
  if (workflowMeta.workflowId) {
10443
10881
  lines.push(`│ Workflow ID: ${workflowMeta.workflowId}`);
10444
10882
  }
10445
- const statusColor = workflowMeta.status === "running" ? chalk6.green : workflowMeta.status === "paused" ? chalk6.yellow : workflowMeta.status === "completed" ? chalk6.gray : chalk6.red;
10883
+ const statusColor = workflowMeta.status === "running" ? chalk7.green : workflowMeta.status === "paused" ? chalk7.yellow : workflowMeta.status === "completed" ? chalk7.gray : chalk7.red;
10446
10884
  lines.push(`│ Status: ${statusColor(workflowMeta.status)}`);
10447
10885
  if (workflowMeta.agentSessions && workflowMeta.agentSessions.length > 0) {
10448
10886
  lines.push("├─ Agent Sub-sessions ─────────────────────────────────┤");
10449
10887
  workflowMeta.agentSessions.forEach((agent) => {
10450
- const agentStatusColor = agent.status === "active" ? chalk6.green : agent.status === "paused" ? chalk6.yellow : chalk6.gray;
10888
+ const agentStatusColor = agent.status === "active" ? chalk7.green : agent.status === "paused" ? chalk7.yellow : chalk7.gray;
10451
10889
  lines.push(`│ ${agent.nodeId}: ${agent.sessionId} (${agentStatusColor(agent.status)})`);
10452
10890
  });
10453
10891
  }
@@ -10474,7 +10912,7 @@ var GetCommand = {
10474
10912
  };
10475
10913
 
10476
10914
  // src/commands/sessions/new.ts
10477
- import chalk7 from "chalk";
10915
+ import chalk8 from "chalk";
10478
10916
  var NewCommand = {
10479
10917
  command: "new [options]",
10480
10918
  aliases: ["create"],
@@ -10513,7 +10951,7 @@ var NewCommand = {
10513
10951
  }
10514
10952
  });
10515
10953
  } else {
10516
- output.success(chalk7.green("✓") + " Session created: " + session.id);
10954
+ output.success(chalk8.green("✓") + " Session created: " + session.id);
10517
10955
  output.info("Title: " + session.title);
10518
10956
  output.info("Directory: " + session.directory);
10519
10957
  }
@@ -10527,7 +10965,7 @@ var NewCommand = {
10527
10965
  };
10528
10966
 
10529
10967
  // src/commands/sessions/rename.ts
10530
- import chalk8 from "chalk";
10968
+ import chalk9 from "chalk";
10531
10969
  var RenameCommand = {
10532
10970
  command: "rename <session-id> <title>",
10533
10971
  aliases: ["mv"],
@@ -10582,7 +11020,7 @@ var RenameCommand = {
10582
11020
  }
10583
11021
  });
10584
11022
  } else {
10585
- output.success(`Session renamed: ${chalk8.green(a.title)}`);
11023
+ output.success(`Session renamed: ${chalk9.green(a.title)}`);
10586
11024
  output.info(`ID: ${a.sessionId}`);
10587
11025
  }
10588
11026
  } catch (error) {
@@ -10595,7 +11033,7 @@ var RenameCommand = {
10595
11033
  };
10596
11034
 
10597
11035
  // src/commands/sessions/delete.ts
10598
- import chalk9 from "chalk";
11036
+ import chalk10 from "chalk";
10599
11037
  var DeleteCommand = {
10600
11038
  command: "delete [session-ids...]",
10601
11039
  aliases: ["rm"],
@@ -10674,7 +11112,7 @@ var DeleteCommand = {
10674
11112
  return true;
10675
11113
  });
10676
11114
  if (a.keepActive && sessionsToDelete.length > 0) {
10677
- output.log(chalk9.yellow(`Keeping active session: ${activeSessionId}`));
11115
+ output.log(chalk10.yellow(`Keeping active session: ${activeSessionId}`));
10678
11116
  }
10679
11117
  } else if (a.olderThan !== undefined) {
10680
11118
  const cutoffDate = new Date;
@@ -10691,7 +11129,7 @@ var DeleteCommand = {
10691
11129
  }
10692
11130
  return false;
10693
11131
  });
10694
- output.log(chalk9.gray(`Deleting sessions not updated since ${cutoffDate.toISOString().split("T")[0]} (${a.olderThan} days ago)`));
11132
+ output.log(chalk10.gray(`Deleting sessions not updated since ${cutoffDate.toISOString().split("T")[0]} (${a.olderThan} days ago)`));
10695
11133
  } else {
10696
11134
  output.log("No sessions to delete");
10697
11135
  return;
@@ -10701,10 +11139,10 @@ var DeleteCommand = {
10701
11139
  return;
10702
11140
  }
10703
11141
  if (a.dryRun) {
10704
- output.log(chalk9.yellow(`[DRY RUN] Would delete ${sessionsToDelete.length} session(s):
11142
+ output.log(chalk10.yellow(`[DRY RUN] Would delete ${sessionsToDelete.length} session(s):
10705
11143
  `));
10706
11144
  sessionsToDelete.forEach((s, i) => {
10707
- const marker = s.id === activeSessionId ? chalk9.green("▶") : " ";
11145
+ const marker = s.id === activeSessionId ? chalk10.green("▶") : " ";
10708
11146
  output.log(` ${marker} ${s.id}`);
10709
11147
  output.log(` Title: ${s.title}`);
10710
11148
  output.log(` Updated: ${new Date(s.updatedAt).toLocaleString()}`);
@@ -10714,11 +11152,11 @@ var DeleteCommand = {
10714
11152
  return;
10715
11153
  }
10716
11154
  if (!a.force) {
10717
- output.log(chalk9.red(`
11155
+ output.log(chalk10.red(`
10718
11156
  ⚠️ About to delete ${sessionsToDelete.length} session(s):
10719
11157
  `));
10720
11158
  sessionsToDelete.forEach((s, i) => {
10721
- const marker = s.id === activeSessionId ? chalk9.green("▶") : " ";
11159
+ const marker = s.id === activeSessionId ? chalk10.green("▶") : " ";
10722
11160
  output.log(` ${marker} ${s.id} - ${s.title}`);
10723
11161
  });
10724
11162
  output.log("");
@@ -10728,7 +11166,7 @@ var DeleteCommand = {
10728
11166
  input: process.stdin,
10729
11167
  output: process.stdout
10730
11168
  });
10731
- rl.question(chalk9.red("Type 'yes' to confirm deletion: "), (res) => {
11169
+ rl.question(chalk10.red("Type 'yes' to confirm deletion: "), (res) => {
10732
11170
  rl.close();
10733
11171
  resolve(res);
10734
11172
  });
@@ -10756,7 +11194,7 @@ var DeleteCommand = {
10756
11194
  }
10757
11195
  }
10758
11196
  if (successCount > 0) {
10759
- output.success(chalk9.green(`✓`) + ` Deleted ${successCount} session(s)`);
11197
+ output.success(chalk10.green(`✓`) + ` Deleted ${successCount} session(s)`);
10760
11198
  }
10761
11199
  if (failCount > 0) {
10762
11200
  output.error(`✗ Failed to delete ${failCount} session(s)`);
@@ -10775,7 +11213,7 @@ var DeleteCommand = {
10775
11213
  };
10776
11214
 
10777
11215
  // src/commands/sessions/messages.ts
10778
- import chalk10 from "chalk";
11216
+ import chalk11 from "chalk";
10779
11217
  var MessagesCommand = {
10780
11218
  command: "messages <session-id>",
10781
11219
  aliases: ["msgs"],
@@ -10843,10 +11281,10 @@ var MessagesCommand = {
10843
11281
  ...` : "");
10844
11282
  };
10845
11283
  const roleColors = {
10846
- user: chalk10.blue,
10847
- assistant: chalk10.green,
10848
- system: chalk10.gray,
10849
- tool: chalk10.yellow
11284
+ user: chalk11.blue,
11285
+ assistant: chalk11.green,
11286
+ system: chalk11.gray,
11287
+ tool: chalk11.yellow
10850
11288
  };
10851
11289
  const formatMessageContent = (m) => {
10852
11290
  const lines = [];
@@ -10857,79 +11295,79 @@ var MessagesCommand = {
10857
11295
  lines.push(...text.split(`
10858
11296
  `).map((l) => l || " "));
10859
11297
  } else if (part.type === "tool-call") {
10860
- lines.push(chalk10.cyan(`[Tool Call] ${part.toolName}`));
11298
+ lines.push(chalk11.cyan(`[Tool Call] ${part.toolName}`));
10861
11299
  const argsStr = typeof part.arguments === "string" ? part.arguments : JSON.stringify(part.arguments ?? null, null, 2);
10862
11300
  if (argsStr && argsStr.length > 200) {
10863
11301
  lines.push(...argsStr.slice(0, 197).split(`
10864
- `).map((l) => chalk10.gray(l)));
10865
- lines.push(chalk10.gray("..."));
11302
+ `).map((l) => chalk11.gray(l)));
11303
+ lines.push(chalk11.gray("..."));
10866
11304
  } else if (argsStr) {
10867
11305
  lines.push(...argsStr.split(`
10868
- `).map((l) => chalk10.gray(l)));
11306
+ `).map((l) => chalk11.gray(l)));
10869
11307
  }
10870
11308
  } else if (part.type === "tool-result") {
10871
- lines.push(chalk10.yellow(`[Tool Result] ${part.toolName}`));
11309
+ lines.push(chalk11.yellow(`[Tool Result] ${part.toolName}`));
10872
11310
  const output2 = part.output?.length > 200 ? part.output.slice(0, 197) + "..." : part.output || "No output";
10873
11311
  lines.push(...output2.split(`
10874
- `).map((l) => chalk10.gray(l)));
11312
+ `).map((l) => chalk11.gray(l)));
10875
11313
  } else if (part.type === "reasoning") {
10876
- lines.push(chalk10.magenta(`[Reasoning]`));
11314
+ lines.push(chalk11.magenta(`[Reasoning]`));
10877
11315
  lines.push(...(part.content || "").split(`
10878
- `).slice(0, 5).map((l) => chalk10.gray(l)));
11316
+ `).slice(0, 5).map((l) => chalk11.gray(l)));
10879
11317
  } else if (part.type === "checkpoint") {
10880
- lines.push(chalk10.cyan(`[Checkpoint]`));
11318
+ lines.push(chalk11.cyan(`[Checkpoint]`));
10881
11319
  } else if (part.type === "workflow-node-call") {
10882
- lines.push(chalk10.blue(`[Node Call] ${part.nodeType}: ${part.nodeId}`));
11320
+ lines.push(chalk11.blue(`[Node Call] ${part.nodeType}: ${part.nodeId}`));
10883
11321
  if (part.input && Object.keys(part.input).length > 0) {
10884
11322
  const inputSummary = Object.entries(part.input).slice(0, 3).map(([k, v]) => `${k}: ${JSON.stringify(v).slice(0, 50)}`).join(", ");
10885
11323
  lines.push(...inputSummary.split(`
10886
- `).map((l) => chalk10.gray(` ${l}`)));
11324
+ `).map((l) => chalk11.gray(` ${l}`)));
10887
11325
  }
10888
11326
  if (part.agentSessionId) {
10889
- lines.push(chalk10.gray(` agentSessionId: ${part.agentSessionId}`));
11327
+ lines.push(chalk11.gray(` agentSessionId: ${part.agentSessionId}`));
10890
11328
  }
10891
11329
  } else if (part.type === "workflow-node-interrupt") {
10892
- lines.push(chalk10.yellow(`[Node Interrupt] ${part.nodeType}: ${part.nodeId}`));
10893
- lines.push(chalk10.bold(` Query: ${part.query}`));
11330
+ lines.push(chalk11.yellow(`[Node Interrupt] ${part.nodeType}: ${part.nodeId}`));
11331
+ lines.push(chalk11.bold(` Query: ${part.query}`));
10894
11332
  if (part.options && part.options.length > 0) {
10895
- lines.push(chalk10.gray(` Options: ${part.options.join(", ")}`));
11333
+ lines.push(chalk11.gray(` Options: ${part.options.join(", ")}`));
10896
11334
  }
10897
11335
  if (part.agentSessionId) {
10898
- lines.push(chalk10.gray(` agentSessionId: ${part.agentSessionId}`));
11336
+ lines.push(chalk11.gray(` agentSessionId: ${part.agentSessionId}`));
10899
11337
  }
10900
11338
  } else if (part.type === "workflow-node-result") {
10901
11339
  const status = part.error ? "❌" : "✅";
10902
- lines.push(chalk10.green(`${status} [Node Result] ${part.nodeType}: ${part.nodeId}`));
11340
+ lines.push(chalk11.green(`${status} [Node Result] ${part.nodeType}: ${part.nodeId}`));
10903
11341
  if (part.output) {
10904
11342
  const outputStr = typeof part.output === "string" ? part.output : JSON.stringify(part.output).slice(0, 200);
10905
11343
  lines.push(...outputStr.split(`
10906
- `).slice(0, 5).map((l) => chalk10.gray(` ${l}`)));
11344
+ `).slice(0, 5).map((l) => chalk11.gray(` ${l}`)));
10907
11345
  }
10908
11346
  if (part.error) {
10909
- lines.push(chalk10.red(` Error: ${part.error}`));
11347
+ lines.push(chalk11.red(` Error: ${part.error}`));
10910
11348
  }
10911
11349
  if (part.durationMs !== undefined) {
10912
- lines.push(chalk10.gray(` Duration: ${part.durationMs}ms`));
11350
+ lines.push(chalk11.gray(` Duration: ${part.durationMs}ms`));
10913
11351
  }
10914
11352
  } else if (part.type === "workflow-node-resume") {
10915
- lines.push(chalk10.green(`[Node Resume] Response: ${part.response}`));
11353
+ lines.push(chalk11.green(`[Node Resume] Response: ${part.response}`));
10916
11354
  } else if (part.type === "workflow-node-start") {
10917
- lines.push(chalk10.blue(`[Node Start] ${part.nodeId}`));
11355
+ lines.push(chalk11.blue(`[Node Start] ${part.nodeId}`));
10918
11356
  } else if (part.type === "workflow-node-end") {
10919
11357
  const status = part.error ? "❌" : "✅";
10920
- lines.push(chalk10.green(`${status} [Node End] ${part.nodeId}`));
11358
+ lines.push(chalk11.green(`${status} [Node End] ${part.nodeId}`));
10921
11359
  if (part.output) {
10922
11360
  const outputStr = typeof part.output === "string" ? part.output.slice(0, 300) : JSON.stringify(part.output, null, 2).slice(0, 300);
10923
11361
  lines.push(...outputStr.split(`
10924
- `).slice(0, 6).map((l) => chalk10.gray(` ${l}`)));
11362
+ `).slice(0, 6).map((l) => chalk11.gray(` ${l}`)));
10925
11363
  if (outputStr.length >= 300)
10926
- lines.push(chalk10.gray(" ..."));
11364
+ lines.push(chalk11.gray(" ..."));
10927
11365
  }
10928
11366
  if (part.error) {
10929
- lines.push(chalk10.red(` Error: ${part.error}`));
11367
+ lines.push(chalk11.red(` Error: ${part.error}`));
10930
11368
  }
10931
11369
  if (part.durationMs !== undefined) {
10932
- lines.push(chalk10.gray(` Duration: ${part.durationMs}ms`));
11370
+ lines.push(chalk11.gray(` Duration: ${part.durationMs}ms`));
10933
11371
  }
10934
11372
  }
10935
11373
  }
@@ -10940,28 +11378,28 @@ var MessagesCommand = {
10940
11378
  }
10941
11379
  return lines.length > 0 ? lines : ["(empty)"];
10942
11380
  };
10943
- output.log(chalk10.bold(`┌─ Messages (${a.sessionId}) ────────────────────────┐`));
11381
+ output.log(chalk11.bold(`┌─ Messages (${a.sessionId}) ────────────────────────┐`));
10944
11382
  messages.forEach((m, i) => {
10945
- const roleColor = roleColors[m.role] || chalk10.white;
11383
+ const roleColor = roleColors[m.role] || chalk11.white;
10946
11384
  const time = new Date(m.timestamp).toLocaleTimeString("zh-CN", {
10947
11385
  hour: "2-digit",
10948
11386
  minute: "2-digit"
10949
11387
  });
10950
11388
  if (m.metadata?.isCheckpoint) {
10951
- output.log(chalk10.cyan("├─ #" + (a.offset + i + 1) + " checkpoint") + " " + chalk10.gray(time));
11389
+ output.log(chalk11.cyan("├─ #" + (a.offset + i + 1) + " checkpoint") + " " + chalk11.gray(time));
10952
11390
  output.log("│");
10953
11391
  output.log("│ " + checkpointStyle(m.content).split(`
10954
11392
  `).join(`
10955
11393
  │ `));
10956
11394
  output.log("│");
10957
11395
  } else {
10958
- output.log(chalk10.cyan("├─ #" + (a.offset + i + 1) + " ") + roleColor(m.role.padEnd(10)) + " " + chalk10.gray(time));
11396
+ output.log(chalk11.cyan("├─ #" + (a.offset + i + 1) + " ") + roleColor(m.role.padEnd(10)) + " " + chalk11.gray(time));
10959
11397
  const contentLines = formatMessageContent(m);
10960
11398
  for (const line of contentLines.slice(0, 20)) {
10961
11399
  output.log("│ " + line);
10962
11400
  }
10963
11401
  if (contentLines.length > 20) {
10964
- output.log("│ " + chalk10.gray("... (truncated)"));
11402
+ output.log("│ " + chalk11.gray("... (truncated)"));
10965
11403
  }
10966
11404
  output.log("│");
10967
11405
  }
@@ -10969,7 +11407,7 @@ var MessagesCommand = {
10969
11407
  output.log("└" + "─".repeat(51) + "┘");
10970
11408
  const hasMore = a.offset + a.limit < totalMessages;
10971
11409
  const showingEnd = Math.min(a.offset + a.limit, totalMessages);
10972
- output.log(chalk10.gray(`Showing ${a.offset + 1}-${showingEnd} of ${totalMessages} messages` + (hasMore ? " (more available)" : "")));
11410
+ output.log(chalk11.gray(`Showing ${a.offset + 1}-${showingEnd} of ${totalMessages} messages` + (hasMore ? " (more available)" : "")));
10973
11411
  }
10974
11412
  } catch (error) {
10975
11413
  output.error(`Failed to get messages: ${error instanceof Error ? error.message : String(error)}`);
@@ -10981,7 +11419,7 @@ var MessagesCommand = {
10981
11419
  };
10982
11420
 
10983
11421
  // src/commands/sessions/compact.ts
10984
- import chalk11 from "chalk";
11422
+ import chalk12 from "chalk";
10985
11423
  var CompactCommand = {
10986
11424
  command: "compact <session-id>",
10987
11425
  aliases: ["compress", "checkpoint"],
@@ -11035,13 +11473,13 @@ var CompactCommand = {
11035
11473
  dryRun: true
11036
11474
  });
11037
11475
  } else {
11038
- output.log(chalk11.bold("┌─ Compact Preview ─────────────────────────────────┐"));
11476
+ output.log(chalk12.bold("┌─ Compact Preview ─────────────────────────────────┐"));
11039
11477
  output.log(`│ Session: ${session.title}`);
11040
- output.log(`│ Messages to compact: ${chalk11.yellow(preview.messageCountToCompact)}`);
11478
+ output.log(`│ Messages to compact: ${chalk12.yellow(preview.messageCountToCompact)}`);
11041
11479
  output.log(`│ Estimated checkpoint tokens: ${preview.estimatedCheckpointTokens}`);
11042
- output.log(`│ Would trigger: ${preview.wouldTrigger ? chalk11.green("Yes") : chalk11.gray("No")}`);
11480
+ output.log(`│ Would trigger: ${preview.wouldTrigger ? chalk12.green("Yes") : chalk12.gray("No")}`);
11043
11481
  output.log("│");
11044
- output.log("│ " + chalk11.gray("(Dry run - no changes made)"));
11482
+ output.log("│ " + chalk12.gray("(Dry run - no changes made)"));
11045
11483
  output.log("└" + "─".repeat(51) + "┘");
11046
11484
  }
11047
11485
  return;
@@ -11056,10 +11494,10 @@ var CompactCommand = {
11056
11494
  try {
11057
11495
  scenarioHint = await sessionComponent.generateCompactHint(a.sessionId);
11058
11496
  if (!a.json) {
11059
- output.log(chalk11.bold("├─ Auto-generated Scenario Hint ──────────────────────────┤"));
11060
- output.log("│ " + chalk11.cyan(scenarioHint.substring(0, 70)));
11497
+ output.log(chalk12.bold("├─ Auto-generated Scenario Hint ──────────────────────────┤"));
11498
+ output.log("│ " + chalk12.cyan(scenarioHint.substring(0, 70)));
11061
11499
  if (scenarioHint.length > 70) {
11062
- output.log(chalk11.gray("│ ") + scenarioHint.substring(70, 140));
11500
+ output.log(chalk12.gray("│ ") + scenarioHint.substring(70, 140));
11063
11501
  }
11064
11502
  }
11065
11503
  } catch (hintError) {
@@ -11106,29 +11544,29 @@ var CompactCommand = {
11106
11544
  }
11107
11545
  });
11108
11546
  } else {
11109
- output.log(chalk11.bold.green("┌─ Checkpoint Created ────────────────────────────────┐"));
11547
+ output.log(chalk12.bold.green("┌─ Checkpoint Created ────────────────────────────────┐"));
11110
11548
  output.log(`│ ID: ${result.checkpoint.id}`);
11111
11549
  output.log(`│ Title: ${result.checkpoint.title}`);
11112
11550
  output.log(`│ Type: compact`);
11113
11551
  output.log(`│ Created: ${new Date(result.checkpoint.createdAt).toLocaleString("zh-CN")}`);
11114
- output.log(chalk11.bold("├─ Scenario Hint ────────────────────────────────────┤"));
11552
+ output.log(chalk12.bold("├─ Scenario Hint ────────────────────────────────────┤"));
11115
11553
  if (scenarioHint) {
11116
11554
  const hintLines = scenarioHint.split(`
11117
11555
  `);
11118
11556
  hintLines.forEach((line, i) => {
11119
11557
  if (i === 0) {
11120
- output.log(chalk11.cyan("│ " + line.substring(0, 48)));
11558
+ output.log(chalk12.cyan("│ " + line.substring(0, 48)));
11121
11559
  if (line.length > 48) {
11122
11560
  for (let j = 48;j < line.length; j += 48) {
11123
- output.log(chalk11.gray("│ ") + line.substring(j, j + 48));
11561
+ output.log(chalk12.gray("│ ") + line.substring(j, j + 48));
11124
11562
  }
11125
11563
  }
11126
11564
  } else {
11127
- output.log(chalk11.gray("│ ") + line);
11565
+ output.log(chalk12.gray("│ ") + line);
11128
11566
  }
11129
11567
  });
11130
11568
  } else {
11131
- output.log(chalk11.gray("│ (no hint)"));
11569
+ output.log(chalk12.gray("│ (no hint)"));
11132
11570
  }
11133
11571
  output.log("├─ Process Key Points ─────────────────────────────────┤");
11134
11572
  result.checkpoint.processKeyPoints.forEach((p, i) => {
@@ -11153,11 +11591,11 @@ var CompactCommand = {
11153
11591
  result.checkpoint.recentMessages.forEach((msg) => {
11154
11592
  const prefix = msg.role === "user" ? "\uD83D\uDC64" : "\uD83E\uDD16";
11155
11593
  const content = msg.content.length > 60 ? msg.content.substring(0, 60) + "..." : msg.content;
11156
- output.log(chalk11.gray(`│ ${prefix} [${msg.role}] ${content}`));
11594
+ output.log(chalk12.gray(`│ ${prefix} [${msg.role}] ${content}`));
11157
11595
  });
11158
11596
  }
11159
11597
  output.log("├─ Stats ─────────────────────────────────────────────┤");
11160
- output.log(`│ Messages compacted: ${chalk11.yellow(result.deletedMessageCount)}`);
11598
+ output.log(`│ Messages compacted: ${chalk12.yellow(result.deletedMessageCount)}`);
11161
11599
  output.log(`│ Remaining messages: ${result.remainingMessageCount}`);
11162
11600
  output.log(`│ Total checkpoints: ${result.checkpointCount}`);
11163
11601
  output.log("└" + "─".repeat(51) + "┘");
@@ -11175,7 +11613,7 @@ var CompactCommand = {
11175
11613
  };
11176
11614
 
11177
11615
  // src/commands/sessions/checkpoints.ts
11178
- import chalk12 from "chalk";
11616
+ import chalk13 from "chalk";
11179
11617
  var CheckpointsCommand = {
11180
11618
  command: "checkpoints <session-id>",
11181
11619
  aliases: ["cps"],
@@ -11208,7 +11646,7 @@ var CheckpointsCommand = {
11208
11646
  }
11209
11647
  const checkpoints = await sessionComponent.getCheckpoints(a.sessionId);
11210
11648
  if (checkpoints.length === 0) {
11211
- output.log(chalk12.gray("No checkpoints for this session"));
11649
+ output.log(chalk13.gray("No checkpoints for this session"));
11212
11650
  return;
11213
11651
  }
11214
11652
  if (a.json) {
@@ -11233,7 +11671,7 @@ var CheckpointsCommand = {
11233
11671
  if (a.detail) {
11234
11672
  checkpoints.reverse().forEach((cp, i) => {
11235
11673
  const isLatest = i === 0;
11236
- output.log(chalk12.bold(`┌─ Checkpoint: ${cp.title} ${isLatest ? chalk12.green("✓") : ""} ──────` + "─".repeat(Math.max(0, 30 - cp.title.length)) + "┐"));
11674
+ output.log(chalk13.bold(`┌─ Checkpoint: ${cp.title} ${isLatest ? chalk13.green("✓") : ""} ──────` + "─".repeat(Math.max(0, 30 - cp.title.length)) + "┐"));
11237
11675
  output.log(`│ ID: ${cp.id}`);
11238
11676
  output.log(`│ Type: ${cp.type}`);
11239
11677
  output.log(`│ Message Index: ${cp.messageIndex} (${cp.messageCountBefore} messages)`);
@@ -11261,18 +11699,18 @@ var CheckpointsCommand = {
11261
11699
  });
11262
11700
  } else {
11263
11701
  const header = [
11264
- chalk12.bold("#"),
11265
- chalk12.bold("Title"),
11266
- chalk12.bold("Type"),
11267
- chalk12.bold("Messages"),
11268
- chalk12.bold("Created")
11702
+ chalk13.bold("#"),
11703
+ chalk13.bold("Title"),
11704
+ chalk13.bold("Type"),
11705
+ chalk13.bold("Messages"),
11706
+ chalk13.bold("Created")
11269
11707
  ].join(" │ ");
11270
11708
  output.log(`┌─ Checkpoints (${checkpoints.length}) ${"─".repeat(40)}┐`);
11271
11709
  output.log(`│${header}│`);
11272
11710
  output.log("├" + "─".repeat(header.length + 2) + "┤");
11273
11711
  checkpoints.reverse().forEach((cp, i) => {
11274
11712
  const isLatest = i === 0;
11275
- const marker = isLatest ? chalk12.green("✓ ") : " ";
11713
+ const marker = isLatest ? chalk13.green("✓ ") : " ";
11276
11714
  const title = cp.title.length > 25 ? cp.title.slice(0, 22) + "..." : cp.title;
11277
11715
  const created = new Date(cp.createdAt).toLocaleString("zh-CN", {
11278
11716
  month: "2-digit",
@@ -11280,7 +11718,7 @@ var CheckpointsCommand = {
11280
11718
  hour: "2-digit",
11281
11719
  minute: "2-digit"
11282
11720
  });
11283
- output.log(`│${marker}${i + 1} ${title.padEnd(25)} │ ${cp.type.padEnd(5)} │ ${cp.messageCountBefore.toString().padStart(8)} │ ${chalk12.gray(created)}│`);
11721
+ output.log(`│${marker}${i + 1} ${title.padEnd(25)} │ ${cp.type.padEnd(5)} │ ${cp.messageCountBefore.toString().padStart(8)} │ ${chalk13.gray(created)}│`);
11284
11722
  });
11285
11723
  output.log("└" + "─".repeat(header.length + 2) + "┘");
11286
11724
  }
@@ -11294,7 +11732,7 @@ var CheckpointsCommand = {
11294
11732
  };
11295
11733
 
11296
11734
  // src/commands/sessions/active.ts
11297
- import chalk13 from "chalk";
11735
+ import chalk14 from "chalk";
11298
11736
  var ActiveCommand = {
11299
11737
  command: "active",
11300
11738
  aliases: ["current"],
@@ -11321,7 +11759,7 @@ var ActiveCommand = {
11321
11759
  return;
11322
11760
  }
11323
11761
  if (!activeId) {
11324
- output.log(chalk13.gray("No active session set"));
11762
+ output.log(chalk14.gray("No active session set"));
11325
11763
  return;
11326
11764
  }
11327
11765
  const session = await sessionComponent.get(activeId);
@@ -11339,10 +11777,10 @@ var ActiveCommand = {
11339
11777
  });
11340
11778
  } else {
11341
11779
  if (!session) {
11342
- output.log(chalk13.gray("Active session not found: " + activeId));
11780
+ output.log(chalk14.gray("Active session not found: " + activeId));
11343
11781
  return;
11344
11782
  }
11345
- output.log(chalk13.bold.green("┌─ Active Session ─────────────────────────────────┐"));
11783
+ output.log(chalk14.bold.green("┌─ Active Session ─────────────────────────────────┐"));
11346
11784
  output.log(`│ ID: ${session.id}`);
11347
11785
  output.log(`│ Title: ${session.title}`);
11348
11786
  output.log(`│ Directory: ${session.directory}`);
@@ -11424,7 +11862,7 @@ var AddMessageCommand = {
11424
11862
  };
11425
11863
 
11426
11864
  // src/commands/sessions/mock.ts
11427
- import chalk14 from "chalk";
11865
+ import chalk15 from "chalk";
11428
11866
  var MOCK_SEQUENCES = [
11429
11867
  {
11430
11868
  name: "文件操作流程",
@@ -11557,7 +11995,7 @@ var MockCommand = {
11557
11995
  for (let seqIdx = 0;seqIdx < count; seqIdx++) {
11558
11996
  const sequence = MOCK_SEQUENCES[seqIdx];
11559
11997
  if (!a.json) {
11560
- output.log(chalk14.bold(`
11998
+ output.log(chalk15.bold(`
11561
11999
  \uD83D\uDCDD Sequence ${seqIdx + 1}: ${sequence.name}`));
11562
12000
  }
11563
12001
  for (const msg of sequence.messages) {
@@ -11575,7 +12013,7 @@ ${JSON.stringify(tc.args, null, 2)}
11575
12013
  if (assistantMsgId)
11576
12014
  addedMessages.push(assistantMsgId);
11577
12015
  if (!a.json) {
11578
- output.log(chalk14.cyan(` [${addedMessages.length}] assistant: \uD83D\uDD27 Tool call`));
12016
+ output.log(chalk15.cyan(` [${addedMessages.length}] assistant: \uD83D\uDD27 Tool call`));
11579
12017
  }
11580
12018
  const toolMsgId = await sessionComponent.addMessage(a.sessionId, {
11581
12019
  role: "tool",
@@ -11584,7 +12022,7 @@ ${JSON.stringify(tc.args, null, 2)}
11584
12022
  if (toolMsgId)
11585
12023
  addedMessages.push(toolMsgId);
11586
12024
  if (!a.json) {
11587
- output.log(chalk14.yellow(` [${addedMessages.length}] tool: ${msg.content.substring(0, 50)}...`));
12025
+ output.log(chalk15.yellow(` [${addedMessages.length}] tool: ${msg.content.substring(0, 50)}...`));
11588
12026
  }
11589
12027
  } else {
11590
12028
  const msgId = await sessionComponent.addMessage(a.sessionId, {
@@ -11594,7 +12032,7 @@ ${JSON.stringify(tc.args, null, 2)}
11594
12032
  if (msgId)
11595
12033
  addedMessages.push(msgId);
11596
12034
  if (!a.json) {
11597
- const roleColor = msg.role === "user" ? chalk14.green : msg.role === "assistant" ? chalk14.cyan : chalk14.gray;
12035
+ const roleColor = msg.role === "user" ? chalk15.green : msg.role === "assistant" ? chalk15.cyan : chalk15.gray;
11598
12036
  output.log(roleColor(` [${addedMessages.length}] ${msg.role}: ${msg.content.substring(0, 50)}...`));
11599
12037
  }
11600
12038
  }
@@ -11610,14 +12048,14 @@ ${JSON.stringify(tc.args, null, 2)}
11610
12048
  });
11611
12049
  } else {
11612
12050
  output.log(`
11613
- ` + chalk14.bold.green("✅ Mock data inserted successfully!"));
12051
+ ` + chalk15.bold.green("✅ Mock data inserted successfully!"));
11614
12052
  output.log(` Session: ${a.sessionId}`);
11615
12053
  output.log(` Sequences: ${count}`);
11616
12054
  output.log(` Messages: ${addedMessages.length}`);
11617
12055
  output.log("");
11618
- output.log(chalk14.gray(" Now run: "));
11619
- output.log(chalk14.gray(` roy-agent sessions compact ${a.sessionId}`));
11620
- output.log(chalk14.gray(" to trigger checkpoint generation"));
12056
+ output.log(chalk15.gray(" Now run: "));
12057
+ output.log(chalk15.gray(` roy-agent sessions compact ${a.sessionId}`));
12058
+ output.log(chalk15.gray(" to trigger checkpoint generation"));
11621
12059
  }
11622
12060
  } finally {
11623
12061
  await envService.dispose();
@@ -11626,7 +12064,7 @@ ${JSON.stringify(tc.args, null, 2)}
11626
12064
  };
11627
12065
 
11628
12066
  // src/commands/sessions/grep.ts
11629
- import chalk15 from "chalk";
12067
+ import chalk16 from "chalk";
11630
12068
  var GrepCommand = {
11631
12069
  command: "grep <query...>",
11632
12070
  aliases: ["search"],
@@ -11706,7 +12144,7 @@ var GrepCommand = {
11706
12144
  const results = await sessionComponent.searchMessages(searchOptions);
11707
12145
  if (results.length === 0) {
11708
12146
  if (!a.quiet) {
11709
- output.log(chalk15.yellow(`No results found for: ${query}`));
12147
+ output.log(chalk16.yellow(`No results found for: ${query}`));
11710
12148
  }
11711
12149
  return;
11712
12150
  }
@@ -11733,7 +12171,7 @@ var GrepCommand = {
11733
12171
  for (const result of results) {
11734
12172
  for (const match of result.matches) {
11735
12173
  const time = new Date(match.timestamp).toLocaleString("zh-CN");
11736
- output.log(`${chalk15.gray(result.sessionId)} ${chalk15.blue(result.sessionTitle)} ${chalk15.gray(time)}`);
12174
+ output.log(`${chalk16.gray(result.sessionId)} ${chalk16.blue(result.sessionTitle)} ${chalk16.gray(time)}`);
11737
12175
  output.log(` ${match.content}`);
11738
12176
  output.log("");
11739
12177
  }
@@ -11745,40 +12183,40 @@ var GrepCommand = {
11745
12183
  totalMatches += result.matches.length;
11746
12184
  const time = new Date(result.updatedAt).toLocaleString("zh-CN");
11747
12185
  const titleStr = `─ ${result.sessionTitle} (${result.sessionId})`;
11748
- output.log(chalk15.bold(`
12186
+ output.log(chalk16.bold(`
11749
12187
  ┌${titleStr}${"─".repeat(Math.max(0, 50 - titleStr.length))}┐`));
11750
- output.log(`│ ${chalk15.gray(`Updated: ${time} | ${result.messageCount} messages | ${result.matches.length} matches`)}${" ".repeat(Math.max(0, 50 - 60))}│`);
12188
+ output.log(`│ ${chalk16.gray(`Updated: ${time} | ${result.messageCount} messages | ${result.matches.length} matches`)}${" ".repeat(Math.max(0, 50 - 60))}│`);
11751
12189
  for (let i = 0;i < result.matches.length; i++) {
11752
12190
  const match = result.matches[i];
11753
- const roleColor = match.role === "user" ? chalk15.blue : match.role === "assistant" ? chalk15.green : chalk15.gray;
12191
+ const roleColor = match.role === "user" ? chalk16.blue : match.role === "assistant" ? chalk16.green : chalk16.gray;
11754
12192
  const msgTime = new Date(match.timestamp).toLocaleTimeString("zh-CN", {
11755
12193
  hour: "2-digit",
11756
12194
  minute: "2-digit"
11757
12195
  });
11758
- output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${chalk15.gray(msgTime)}`);
12196
+ output.log(`├─ #${i + 1} ${roleColor(match.role.padEnd(10))} ${chalk16.gray(msgTime)}`);
11759
12197
  output.log("│");
11760
12198
  const lines = match.content.split(`
11761
12199
  `).map((line) => line.trim()).filter((line) => line.length > 0);
11762
12200
  const maxLines = 5;
11763
12201
  const displayLines = lines.slice(0, maxLines);
11764
12202
  if (displayLines.length === 0) {
11765
- output.log("│ " + chalk15.gray("(empty content)"));
12203
+ output.log("│ " + chalk16.gray("(empty content)"));
11766
12204
  } else {
11767
12205
  for (const line of displayLines) {
11768
12206
  const truncated = line.length > 76 ? line.slice(0, 73) + "..." : line;
11769
- output.log(`│ ${chalk15.gray(truncated)}`);
12207
+ output.log(`│ ${chalk16.gray(truncated)}`);
11770
12208
  }
11771
12209
  }
11772
12210
  if (lines.length > maxLines) {
11773
- output.log("│ " + chalk15.gray(`... (${lines.length - maxLines} more lines)`));
12211
+ output.log("│ " + chalk16.gray(`... (${lines.length - maxLines} more lines)`));
11774
12212
  }
11775
12213
  output.log("│");
11776
12214
  }
11777
12215
  output.log(`└${"─".repeat(52)}┘`);
11778
12216
  }
11779
12217
  output.log(`
11780
- ${chalk15.green("✓")} Found ${chalk15.bold(totalMatches.toString())} matches in ${chalk15.bold(results.length.toString())} sessions`);
11781
- output.log(chalk15.gray(`Query: "${query}"`));
12218
+ ${chalk16.green("✓")} Found ${chalk16.bold(totalMatches.toString())} matches in ${chalk16.bold(results.length.toString())} sessions`);
12219
+ output.log(chalk16.gray(`Query: "${query}"`));
11782
12220
  }
11783
12221
  } catch (error) {
11784
12222
  output.error(`Search failed: ${error instanceof Error ? error.message : String(error)}`);
@@ -11817,7 +12255,7 @@ var SessionsCommand = {
11817
12255
  };
11818
12256
 
11819
12257
  // src/commands/tasks/list.ts
11820
- import chalk16 from "chalk";
12258
+ import chalk17 from "chalk";
11821
12259
 
11822
12260
  // src/commands/tasks/_build-list-json.ts
11823
12261
  function buildListTasksJson(tasks, total, args, extras) {
@@ -11906,17 +12344,17 @@ var ListCommand2 = {
11906
12344
  tasks.forEach((t) => output.log(t.id.toString()));
11907
12345
  } else {
11908
12346
  const header = [
11909
- chalk16.bold("#"),
11910
- chalk16.bold("Title"),
11911
- chalk16.bold("Status"),
11912
- chalk16.bold("Priority"),
11913
- chalk16.bold("Type"),
11914
- chalk16.bold("Progress"),
11915
- chalk16.bold("Parent")
12347
+ chalk17.bold("#"),
12348
+ chalk17.bold("Title"),
12349
+ chalk17.bold("Status"),
12350
+ chalk17.bold("Priority"),
12351
+ chalk17.bold("Type"),
12352
+ chalk17.bold("Progress"),
12353
+ chalk17.bold("Parent")
11916
12354
  ].join(" │ ");
11917
12355
  const rows = tasks.map((t, i) => {
11918
- const statusColor = t.status === "completed" ? chalk16.green : t.status === "active" ? chalk16.blue : t.status === "paused" ? chalk16.yellow : t.status === "cancelled" ? chalk16.strikethrough : chalk16.gray;
11919
- const priorityColor = t.priority === "high" ? chalk16.red : t.priority === "medium" ? chalk16.yellow : chalk16.gray;
12356
+ const statusColor = t.status === "completed" ? chalk17.green : t.status === "active" ? chalk17.blue : t.status === "paused" ? chalk17.yellow : t.status === "cancelled" ? chalk17.strikethrough : chalk17.gray;
12357
+ const priorityColor = t.priority === "high" ? chalk17.red : t.priority === "medium" ? chalk17.yellow : chalk17.gray;
11920
12358
  return [
11921
12359
  (args.offset + i + 1).toString(),
11922
12360
  t.title.length > 30 ? t.title.slice(0, 27) + "..." : t.title,
@@ -11924,11 +12362,11 @@ var ListCommand2 = {
11924
12362
  priorityColor(t.priority),
11925
12363
  t.type || "normal",
11926
12364
  `${t.progress}%`,
11927
- t.parent_task_id ? `#${t.parent_task_id}` : chalk16.gray("root")
12365
+ t.parent_task_id ? `#${t.parent_task_id}` : chalk17.gray("root")
11928
12366
  ].join(" │ ");
11929
12367
  });
11930
- const depthNote = args.depth !== undefined ? chalk16.gray(` depth=${args.depth}`) : "";
11931
- const archivedNote = args.includeArchived ? chalk16.gray(" include-archived") : "";
12368
+ const depthNote = args.depth !== undefined ? chalk17.gray(` depth=${args.depth}`) : "";
12369
+ const archivedNote = args.includeArchived ? chalk17.gray(" include-archived") : "";
11932
12370
  output.log([
11933
12371
  `┌─ Tasks ${"─".repeat(55)}┐`,
11934
12372
  `│${header}│`,
@@ -11936,7 +12374,7 @@ var ListCommand2 = {
11936
12374
  ...rows.map((r) => `│${r}│`),
11937
12375
  "└" + "─".repeat(header.length + 2) + "┘",
11938
12376
  "",
11939
- chalk16.gray(`Showing ${tasks.length} of ${total} tasks (offset=${args.offset}, limit=${args.limit})${depthNote}${archivedNote}`)
12377
+ chalk17.gray(`Showing ${tasks.length} of ${total} tasks (offset=${args.offset}, limit=${args.limit})${depthNote}${archivedNote}`)
11940
12378
  ].join(`
11941
12379
  `));
11942
12380
  }
@@ -11950,7 +12388,7 @@ var ListCommand2 = {
11950
12388
  };
11951
12389
 
11952
12390
  // src/commands/tasks/get.ts
11953
- import chalk17 from "chalk";
12391
+ import chalk18 from "chalk";
11954
12392
  var GetCommand2 = {
11955
12393
  command: "get <id>",
11956
12394
  aliases: ["show"],
@@ -11989,10 +12427,10 @@ var GetCommand2 = {
11989
12427
  if (args.json) {
11990
12428
  output.json(result);
11991
12429
  } else {
11992
- output.log(chalk17.bold(`
12430
+ output.log(chalk18.bold(`
11993
12431
  Task #${result.task.id}: ${result.task.title}
11994
12432
  `));
11995
- output.log(`Status: ${chalk17.blue(result.task.status)} | Priority: ${result.task.priority} | Type: ${result.task.type} | Progress: ${result.task.progress}%`);
12433
+ output.log(`Status: ${chalk18.blue(result.task.status)} | Priority: ${result.task.priority} | Type: ${result.task.type} | Progress: ${result.task.progress}%`);
11996
12434
  output.log(`Created: ${result.task.createdAt} | Updated: ${result.task.updatedAt}`);
11997
12435
  output.log(`Project Path: ${result.task.project_path}`);
11998
12436
  output.log(`Context: ${result.task.context}`);
@@ -12000,7 +12438,7 @@ Task #${result.task.id}: ${result.task.title}
12000
12438
  output.log(`
12001
12439
  Current Status: ${result.task.current_status}`);
12002
12440
  }
12003
- output.log(chalk17.bold(`
12441
+ output.log(chalk18.bold(`
12004
12442
  Operations (${result.operations.length}):
12005
12443
  `));
12006
12444
  result.operations.forEach((op, i) => {
@@ -12020,10 +12458,10 @@ Operations (${result.operations.length}):
12020
12458
  if (args.json) {
12021
12459
  output.json(task);
12022
12460
  } else {
12023
- output.log(chalk17.bold(`
12461
+ output.log(chalk18.bold(`
12024
12462
  Task #${task.id}: ${task.title}
12025
12463
  `));
12026
- output.log(`Status: ${chalk17.blue(task.status)} | Priority: ${task.priority} | Type: ${task.type} | Progress: ${task.progress}%`);
12464
+ output.log(`Status: ${chalk18.blue(task.status)} | Priority: ${task.priority} | Type: ${task.type} | Progress: ${task.progress}%`);
12027
12465
  output.log(`Created: ${task.createdAt} | Updated: ${task.updatedAt}`);
12028
12466
  output.log(`Project Path: ${task.project_path}`);
12029
12467
  output.log(`Context: ${task.context}`);
@@ -12047,7 +12485,7 @@ Description: ${task.description}`);
12047
12485
  };
12048
12486
 
12049
12487
  // src/commands/tasks/create.ts
12050
- import chalk18 from "chalk";
12488
+ import chalk19 from "chalk";
12051
12489
  var CreateCommand = {
12052
12490
  command: "create <title>",
12053
12491
  aliases: ["add", "new"],
@@ -12125,7 +12563,7 @@ var CreateCommand = {
12125
12563
  if (args.json) {
12126
12564
  output.json(task);
12127
12565
  } else {
12128
- output.log(chalk18.green(`
12566
+ output.log(chalk19.green(`
12129
12567
  ✓ Task created: #${task.id}`));
12130
12568
  output.log(` Title: ${task.title}`);
12131
12569
  output.log(` Status: ${task.status}`);
@@ -12143,7 +12581,7 @@ var CreateCommand = {
12143
12581
  };
12144
12582
 
12145
12583
  // src/commands/tasks/update.ts
12146
- import chalk19 from "chalk";
12584
+ import chalk20 from "chalk";
12147
12585
  var UpdateCommand = {
12148
12586
  command: "update <id>",
12149
12587
  aliases: ["set"],
@@ -12201,7 +12639,7 @@ var UpdateCommand = {
12201
12639
  if (args.json) {
12202
12640
  output.json(task);
12203
12641
  } else {
12204
- output.log(chalk19.green(`
12642
+ output.log(chalk20.green(`
12205
12643
  ✓ Task updated: #${task.id}`));
12206
12644
  output.log(` Title: ${task.title}`);
12207
12645
  output.log(` Status: ${task.status}`);
@@ -12224,7 +12662,7 @@ var UpdateCommand = {
12224
12662
  };
12225
12663
 
12226
12664
  // src/commands/tasks/delete.ts
12227
- import chalk20 from "chalk";
12665
+ import chalk21 from "chalk";
12228
12666
  var DeleteCommand2 = {
12229
12667
  command: "delete <id>",
12230
12668
  aliases: ["remove", "rm", "del"],
@@ -12260,16 +12698,16 @@ var DeleteCommand2 = {
12260
12698
  process.exit(1);
12261
12699
  }
12262
12700
  if (!args.force) {
12263
- output.log(chalk20.yellow(`Are you sure you want to delete task #${args.id}?`));
12264
- output.log(chalk20.yellow(` Title: ${task.title}`));
12265
- output.log(chalk20.yellow(` Status: ${task.status}`));
12266
- output.log(chalk20.yellow(`
12701
+ output.log(chalk21.yellow(`Are you sure you want to delete task #${args.id}?`));
12702
+ output.log(chalk21.yellow(` Title: ${task.title}`));
12703
+ output.log(chalk21.yellow(` Status: ${task.status}`));
12704
+ output.log(chalk21.yellow(`
12267
12705
  Use --force to skip this confirmation`));
12268
12706
  process.exit(1);
12269
12707
  }
12270
12708
  const deleted = await taskComponent.deleteTask(args.id);
12271
12709
  if (deleted) {
12272
- output.log(chalk20.green(`
12710
+ output.log(chalk21.green(`
12273
12711
  ✓ Task deleted: #${args.id}`));
12274
12712
  } else {
12275
12713
  output.error(`Failed to delete task: ${args.id}`);
@@ -12285,7 +12723,7 @@ Use --force to skip this confirmation`));
12285
12723
  };
12286
12724
 
12287
12725
  // src/commands/tasks/complete.ts
12288
- import chalk21 from "chalk";
12726
+ import chalk22 from "chalk";
12289
12727
  var CompleteCommand = {
12290
12728
  command: "complete <id>",
12291
12729
  aliases: ["done", "finish"],
@@ -12342,7 +12780,7 @@ var CompleteCommand = {
12342
12780
  if (args.json) {
12343
12781
  output.json(task);
12344
12782
  } else {
12345
- output.log(chalk21.green(`
12783
+ output.log(chalk22.green(`
12346
12784
  ✓ Task completed: #${task.id}`));
12347
12785
  output.log(` Title: ${task.title}`);
12348
12786
  output.log(` Progress: ${task.progress}%`);
@@ -12358,7 +12796,7 @@ var CompleteCommand = {
12358
12796
  };
12359
12797
 
12360
12798
  // src/commands/tasks/operations.ts
12361
- import chalk22 from "chalk";
12799
+ import chalk23 from "chalk";
12362
12800
  var OperationsCommand = {
12363
12801
  command: "operations <task-id>",
12364
12802
  aliases: ["ops", "log"],
@@ -12408,23 +12846,23 @@ var OperationsCommand = {
12408
12846
  operations
12409
12847
  });
12410
12848
  } else {
12411
- output.log(chalk22.bold(`
12849
+ output.log(chalk23.bold(`
12412
12850
  Operations for Task #${task.id}: ${task.title}
12413
12851
  `));
12414
12852
  if (operations.length === 0) {
12415
- output.log(chalk22.gray("No operations found."));
12853
+ output.log(chalk23.gray("No operations found."));
12416
12854
  } else {
12417
12855
  operations.forEach((op, i) => {
12418
- const actionColor = op.actionType === "completed" ? chalk22.green : op.actionType === "milestone" ? chalk22.blue : op.actionType === "problem" ? chalk22.red : chalk22.gray;
12419
- output.log(`${chalk22.bold(a.offset + i + 1)}. ` + actionColor(`[${op.actionType}]`) + ` ${op.actionTitle}`);
12420
- output.log(` Session: ${chalk22.cyan(op.sessionId)} | Time: ${op.timestamp}`);
12856
+ const actionColor = op.actionType === "completed" ? chalk23.green : op.actionType === "milestone" ? chalk23.blue : op.actionType === "problem" ? chalk23.red : chalk23.gray;
12857
+ output.log(`${chalk23.bold(a.offset + i + 1)}. ` + actionColor(`[${op.actionType}]`) + ` ${op.actionTitle}`);
12858
+ output.log(` Session: ${chalk23.cyan(op.sessionId)} | Time: ${op.timestamp}`);
12421
12859
  if (op.actionDescription) {
12422
12860
  output.log(` ${op.actionDescription}`);
12423
12861
  }
12424
12862
  output.log("");
12425
12863
  });
12426
12864
  }
12427
- output.log(chalk22.gray(`Total: ${operations.length} operations`));
12865
+ output.log(chalk23.gray(`Total: ${operations.length} operations`));
12428
12866
  }
12429
12867
  } catch (error) {
12430
12868
  output.error(`Failed to list operations: ${error}`);
@@ -12436,7 +12874,7 @@ Operations for Task #${task.id}: ${task.title}
12436
12874
  };
12437
12875
 
12438
12876
  // src/commands/tasks/tree.ts
12439
- import chalk23 from "chalk";
12877
+ import chalk24 from "chalk";
12440
12878
  function buildTree(tasks) {
12441
12879
  const byParent = new Map;
12442
12880
  const nodeById = new Map;
@@ -12471,7 +12909,7 @@ function printTree(nodes, prefix, isRoot, output, currentDepth, maxDepth) {
12471
12909
  const statusColor = colorByStatus(node.task.status);
12472
12910
  const typeLabel = node.task.type ? ` [${node.task.type}]` : "";
12473
12911
  const progressLabel = node.task.progress > 0 ? ` (${node.task.progress}%)` : "";
12474
- const header = `#${node.task.id}${typeLabel} ${node.task.title} ${chalk23.gray("[" + node.task.status + "]")}${progressLabel}`;
12912
+ const header = `#${node.task.id}${typeLabel} ${node.task.title} ${chalk24.gray("[" + node.task.status + "]")}${progressLabel}`;
12475
12913
  output.log(prefix + connector + statusColor(header));
12476
12914
  if (node.children.length > 0) {
12477
12915
  const childPrefix = isRoot ? prefix : prefix + (isLast ? " " : "│ ");
@@ -12482,15 +12920,15 @@ function printTree(nodes, prefix, isRoot, output, currentDepth, maxDepth) {
12482
12920
  function colorByStatus(status) {
12483
12921
  switch (status) {
12484
12922
  case "completed":
12485
- return chalk23.green;
12923
+ return chalk24.green;
12486
12924
  case "active":
12487
- return chalk23.blue;
12925
+ return chalk24.blue;
12488
12926
  case "paused":
12489
- return chalk23.yellow;
12927
+ return chalk24.yellow;
12490
12928
  case "cancelled":
12491
- return chalk23.strikethrough;
12929
+ return chalk24.strikethrough;
12492
12930
  default:
12493
- return chalk23.gray;
12931
+ return chalk24.gray;
12494
12932
  }
12495
12933
  }
12496
12934
  var TreeCommand = {
@@ -12577,10 +13015,10 @@ var TreeCommand = {
12577
13015
  }
12578
13016
  const tree = buildTree(tasks);
12579
13017
  if (tree.length === 0) {
12580
- output.log(chalk23.gray("No tasks to display."));
13018
+ output.log(chalk24.gray("No tasks to display."));
12581
13019
  return;
12582
13020
  }
12583
- output.log(chalk23.bold(`Task Tree (${tasks.length} tasks, ${tree.length} roots)`) + (args.rootId !== undefined ? chalk23.gray(` — subtree of #${args.rootId}`) : ""));
13021
+ output.log(chalk24.bold(`Task Tree (${tasks.length} tasks, ${tree.length} roots)`) + (args.rootId !== undefined ? chalk24.gray(` — subtree of #${args.rootId}`) : ""));
12584
13022
  output.log("");
12585
13023
  printTree(tree, "", true, output, 0, args.maxDepth);
12586
13024
  } catch (error) {
@@ -12593,7 +13031,7 @@ var TreeCommand = {
12593
13031
  };
12594
13032
 
12595
13033
  // src/commands/tasks/search.ts
12596
- import chalk24 from "chalk";
13034
+ import chalk25 from "chalk";
12597
13035
  var SearchCommand = {
12598
13036
  command: "search <keywords..>",
12599
13037
  aliases: ["find", "grep"],
@@ -12657,26 +13095,26 @@ var SearchCommand = {
12657
13095
  tasks.forEach((t) => output.log(t.id.toString()));
12658
13096
  } else {
12659
13097
  const keywordStr = args.keywords.join(" ");
12660
- output.log(chalk24.bold(`
13098
+ output.log(chalk25.bold(`
12661
13099
  \uD83D\uDD0D Search: "${keywordStr}" — ${total} results
12662
13100
  `));
12663
13101
  if (tasks.length === 0) {
12664
- output.log(chalk24.gray(" No matching tasks found."));
13102
+ output.log(chalk25.gray(" No matching tasks found."));
12665
13103
  return;
12666
13104
  }
12667
13105
  for (const t of tasks) {
12668
- const statusColor = t.status === "completed" ? chalk24.green : t.status === "active" ? chalk24.blue : t.status === "paused" ? chalk24.yellow : t.status === "cancelled" ? chalk24.strikethrough : t.status === "archived" ? chalk24.gray : chalk24.gray;
12669
- const pid = t.parent_task_id ? chalk24.gray(` (#${t.parent_task_id})`) : "";
13106
+ const statusColor = t.status === "completed" ? chalk25.green : t.status === "active" ? chalk25.blue : t.status === "paused" ? chalk25.yellow : t.status === "cancelled" ? chalk25.strikethrough : t.status === "archived" ? chalk25.gray : chalk25.gray;
13107
+ const pid = t.parent_task_id ? chalk25.gray(` (#${t.parent_task_id})`) : "";
12670
13108
  output.log(` #${t.id} ${statusColor("[" + t.status + "]")} ${t.title}${pid}`);
12671
13109
  if (t.current_status) {
12672
- output.log(` ${chalk24.gray(t.current_status.slice(0, 80))}`);
13110
+ output.log(` ${chalk25.gray(t.current_status.slice(0, 80))}`);
12673
13111
  }
12674
13112
  }
12675
13113
  if (total > tasks.length) {
12676
- output.log(chalk24.gray(`
13114
+ output.log(chalk25.gray(`
12677
13115
  ... and ${total - tasks.length} more. Use --offset and --limit to paginate.`));
12678
13116
  }
12679
- output.log(chalk24.gray(` Page: ${Math.floor((args.offset || 0) / (args.limit || 20)) + 1}/${Math.ceil(total / (args.limit || 20))}`));
13117
+ output.log(chalk25.gray(` Page: ${Math.floor((args.offset || 0) / (args.limit || 20)) + 1}/${Math.ceil(total / (args.limit || 20))}`));
12680
13118
  }
12681
13119
  } catch (error) {
12682
13120
  output.error(`Failed to search tasks: ${error}`);
@@ -12936,7 +13374,7 @@ var TasksCommand = {
12936
13374
  };
12937
13375
 
12938
13376
  // src/commands/skills/list.ts
12939
- import chalk25 from "chalk";
13377
+ import chalk26 from "chalk";
12940
13378
  var ListCommand3 = {
12941
13379
  command: "list",
12942
13380
  aliases: ["ls"],
@@ -12989,26 +13427,26 @@ var ListCommand3 = {
12989
13427
  filtered.forEach((s) => output.log(s.name));
12990
13428
  } else {
12991
13429
  const header = [
12992
- chalk25.bold("Name"),
12993
- chalk25.bold("Description"),
12994
- chalk25.bold("Source")
13430
+ chalk26.bold("Name"),
13431
+ chalk26.bold("Description"),
13432
+ chalk26.bold("Source")
12995
13433
  ].join(" | ");
12996
13434
  const sourceColor = (source) => {
12997
13435
  switch (source) {
12998
13436
  case "project":
12999
- return chalk25.green;
13437
+ return chalk26.green;
13000
13438
  case "user":
13001
- return chalk25.blue;
13439
+ return chalk26.blue;
13002
13440
  case "built-in":
13003
- return chalk25.gray;
13441
+ return chalk26.gray;
13004
13442
  default:
13005
- return chalk25.white;
13443
+ return chalk26.white;
13006
13444
  }
13007
13445
  };
13008
13446
  const rows = filtered.map((s) => {
13009
13447
  const desc2 = s.description.length > 50 ? s.description.slice(0, 47) + "..." : s.description;
13010
13448
  return [
13011
- chalk25.cyan(s.name),
13449
+ chalk26.cyan(s.name),
13012
13450
  desc2,
13013
13451
  sourceColor(s.source)(`[${s.source}]`)
13014
13452
  ].join(" | ");
@@ -13020,7 +13458,7 @@ var ListCommand3 = {
13020
13458
  ...rows.map((r) => `│${r}│`),
13021
13459
  "└" + "─".repeat(header.length + 2) + "┘",
13022
13460
  "",
13023
- chalk25.gray(`Total: ${filtered.length} skills`)
13461
+ chalk26.gray(`Total: ${filtered.length} skills`)
13024
13462
  ].join(`
13025
13463
  `));
13026
13464
  }
@@ -13034,7 +13472,7 @@ var ListCommand3 = {
13034
13472
  };
13035
13473
 
13036
13474
  // src/commands/skills/get.ts
13037
- import chalk26 from "chalk";
13475
+ import chalk27 from "chalk";
13038
13476
  var GetCommand3 = {
13039
13477
  command: "get <name>",
13040
13478
  describe: "获取指定技能内容",
@@ -13078,13 +13516,13 @@ var GetCommand3 = {
13078
13516
  content: skill.content
13079
13517
  });
13080
13518
  } else {
13081
- output.log(chalk26.bold.cyan(`# ${skill.name}`));
13519
+ output.log(chalk27.bold.cyan(`# ${skill.name}`));
13082
13520
  output.log("");
13083
- output.log(`${chalk26.gray("Description:")} ${skill.description}`);
13084
- output.log(`${chalk26.gray("Source:")} ${skill.source}`);
13085
- output.log(`${chalk26.gray("File:")} ${skill.filePath}`);
13521
+ output.log(`${chalk27.gray("Description:")} ${skill.description}`);
13522
+ output.log(`${chalk27.gray("Source:")} ${skill.source}`);
13523
+ output.log(`${chalk27.gray("File:")} ${skill.filePath}`);
13086
13524
  output.log("");
13087
- output.log(chalk26.bold("--- Content ---"));
13525
+ output.log(chalk27.bold("--- Content ---"));
13088
13526
  output.log("");
13089
13527
  output.log(skill.content);
13090
13528
  }
@@ -13098,7 +13536,7 @@ var GetCommand3 = {
13098
13536
  };
13099
13537
 
13100
13538
  // src/commands/skills/search.ts
13101
- import chalk27 from "chalk";
13539
+ import chalk28 from "chalk";
13102
13540
  var SearchCommand2 = {
13103
13541
  command: "search <term>",
13104
13542
  aliases: ["find"],
@@ -13137,7 +13575,7 @@ var SearchCommand2 = {
13137
13575
  const term = args.term.toLowerCase();
13138
13576
  const results = allSkills.filter((s) => s.name.toLowerCase().includes(term) || s.description.toLowerCase().includes(term));
13139
13577
  if (results.length === 0) {
13140
- output.log(chalk27.yellow(`No skills found matching: ${args.term}`));
13578
+ output.log(chalk28.yellow(`No skills found matching: ${args.term}`));
13141
13579
  return;
13142
13580
  }
13143
13581
  if (args.json) {
@@ -13154,19 +13592,19 @@ var SearchCommand2 = {
13154
13592
  } else if (args.quiet) {
13155
13593
  results.forEach((s) => output.log(s.name));
13156
13594
  } else {
13157
- output.log(chalk27.bold(`Search results for "${args.term}":`));
13595
+ output.log(chalk28.bold(`Search results for "${args.term}":`));
13158
13596
  output.log("");
13159
13597
  const header = [
13160
- chalk27.bold("Name"),
13161
- chalk27.bold("Description"),
13162
- chalk27.bold("Match")
13598
+ chalk28.bold("Name"),
13599
+ chalk28.bold("Description"),
13600
+ chalk28.bold("Match")
13163
13601
  ].join(" | ");
13164
13602
  const rows = results.map((s) => {
13165
13603
  const matchedIn = s.name.toLowerCase().includes(term) ? "name" : "description";
13166
- const matchColor = matchedIn === "name" ? chalk27.green : chalk27.blue;
13604
+ const matchColor = matchedIn === "name" ? chalk28.green : chalk28.blue;
13167
13605
  const desc2 = s.description.length > 40 ? s.description.slice(0, 37) + "..." : s.description;
13168
13606
  return [
13169
- chalk27.cyan(s.name),
13607
+ chalk28.cyan(s.name),
13170
13608
  desc2,
13171
13609
  matchColor(`[${matchedIn}]`)
13172
13610
  ].join(" | ");
@@ -13178,7 +13616,7 @@ var SearchCommand2 = {
13178
13616
  ...rows.map((r) => `│${r}│`),
13179
13617
  "└" + "─".repeat(header.length + 2) + "┘",
13180
13618
  "",
13181
- chalk27.gray(`${results.length} matching skill(s) found.`)
13619
+ chalk28.gray(`${results.length} matching skill(s) found.`)
13182
13620
  ].join(`
13183
13621
  `));
13184
13622
  }
@@ -13192,7 +13630,7 @@ var SearchCommand2 = {
13192
13630
  };
13193
13631
 
13194
13632
  // src/commands/skills/reload.ts
13195
- import chalk28 from "chalk";
13633
+ import chalk29 from "chalk";
13196
13634
  var ReloadCommand = {
13197
13635
  command: "reload",
13198
13636
  describe: "重新扫描并更新 SkillTool",
@@ -13215,10 +13653,10 @@ var ReloadCommand = {
13215
13653
  output.error("SkillComponent not available");
13216
13654
  process.exit(1);
13217
13655
  }
13218
- output.log(chalk28.blue("Reloading skills..."));
13656
+ output.log(chalk29.blue("Reloading skills..."));
13219
13657
  await skillComponent.reload();
13220
13658
  const skills = skillComponent.getSkillList();
13221
- output.log(chalk28.green(`Successfully reloaded ${skills.length} skills`));
13659
+ output.log(chalk29.green(`Successfully reloaded ${skills.length} skills`));
13222
13660
  } catch (error) {
13223
13661
  output.error(`Failed to reload skills: ${error}`);
13224
13662
  process.exit(1);
@@ -13229,7 +13667,7 @@ var ReloadCommand = {
13229
13667
  };
13230
13668
 
13231
13669
  // src/commands/skills/show-config.ts
13232
- import chalk29 from "chalk";
13670
+ import chalk30 from "chalk";
13233
13671
  var ShowConfigCommand = {
13234
13672
  command: "show-config",
13235
13673
  aliases: ["config"],
@@ -13254,38 +13692,38 @@ var ShowConfigCommand = {
13254
13692
  process.exit(1);
13255
13693
  }
13256
13694
  const defaultConfig = skillComponent.getConfig?.();
13257
- output.log(chalk29.bold.cyan(`# Skills Configuration
13695
+ output.log(chalk30.bold.cyan(`# Skills Configuration
13258
13696
  `));
13259
- output.log(chalk29.bold(`## Scan Paths
13697
+ output.log(chalk30.bold(`## Scan Paths
13260
13698
  `));
13261
13699
  const paths = [
13262
13700
  { type: "user", desc: "用户路径", path: "~/.config/roy-agent/skills/" },
13263
13701
  { type: "project", desc: "项目路径", path: ".roy/skills/" }
13264
13702
  ];
13265
13703
  for (const p of paths) {
13266
- const typeColor = p.type === "project" ? chalk29.green : chalk29.blue;
13267
- output.log(` ${typeColor("[ " + p.type + " ]")} ${chalk29.gray(p.desc)}`);
13268
- output.log(` ${chalk29.cyan(p.path)}
13704
+ const typeColor = p.type === "project" ? chalk30.green : chalk30.blue;
13705
+ output.log(` ${typeColor("[ " + p.type + " ]")} ${chalk30.gray(p.desc)}`);
13706
+ output.log(` ${chalk30.cyan(p.path)}
13269
13707
  `);
13270
13708
  }
13271
- output.log(chalk29.bold(`## Scan Rules
13709
+ output.log(chalk30.bold(`## Scan Rules
13272
13710
  `));
13273
- output.log(` ${chalk29.gray("Pattern:")} ${chalk29.cyan("**/SKILL.md")}`);
13274
- output.log(` ${chalk29.gray("Recursive:")} ${chalk29.green("true")}`);
13275
- output.log(` ${chalk29.gray("Ignore:")} ${chalk29.cyan("**/node_modules/**")}
13711
+ output.log(` ${chalk30.gray("Pattern:")} ${chalk30.cyan("**/SKILL.md")}`);
13712
+ output.log(` ${chalk30.gray("Recursive:")} ${chalk30.green("true")}`);
13713
+ output.log(` ${chalk30.gray("Ignore:")} ${chalk30.cyan("**/node_modules/**")}
13276
13714
  `);
13277
- output.log(chalk29.bold(`## Priority (High to Low)
13715
+ output.log(chalk30.bold(`## Priority (High to Low)
13278
13716
  `));
13279
- output.log(` ${chalk29.green("1. project")} - 项目路径(最高优先级)`);
13280
- output.log(` ${chalk29.blue("2. user")} - 用户路径`);
13281
- output.log(` ${chalk29.gray("3. built-in")} - 内置路径(预留)
13717
+ output.log(` ${chalk30.green("1. project")} - 项目路径(最高优先级)`);
13718
+ output.log(` ${chalk30.blue("2. user")} - 用户路径`);
13719
+ output.log(` ${chalk30.gray("3. built-in")} - 内置路径(预留)
13282
13720
  `);
13283
- output.log(chalk29.bold(`## Usage
13721
+ output.log(chalk30.bold(`## Usage
13284
13722
  `));
13285
- output.log(` ${chalk29.cyan("roy-agent skills list")} ${chalk29.gray("- 列出所有技能")}`);
13286
- output.log(` ${chalk29.cyan("roy-agent skills get <name>")} ${chalk29.gray("- 获取技能内容")}`);
13287
- output.log(` ${chalk29.cyan("roy-agent skills search <term>")} ${chalk29.gray("- 搜索技能")}`);
13288
- output.log(` ${chalk29.cyan("roy-agent skills reload")} ${chalk29.gray("- 重新扫描技能")}`);
13723
+ output.log(` ${chalk30.cyan("roy-agent skills list")} ${chalk30.gray("- 列出所有技能")}`);
13724
+ output.log(` ${chalk30.cyan("roy-agent skills get <name>")} ${chalk30.gray("- 获取技能内容")}`);
13725
+ output.log(` ${chalk30.cyan("roy-agent skills search <term>")} ${chalk30.gray("- 搜索技能")}`);
13726
+ output.log(` ${chalk30.cyan("roy-agent skills reload")} ${chalk30.gray("- 重新扫描技能")}`);
13289
13727
  } catch (error) {
13290
13728
  output.error(`Failed to show config: ${error}`);
13291
13729
  process.exit(1);
@@ -13306,7 +13744,7 @@ var SkillsCommand = {
13306
13744
  };
13307
13745
 
13308
13746
  // src/commands/agents/list.ts
13309
- import chalk30 from "chalk";
13747
+ import chalk31 from "chalk";
13310
13748
  var ListCommand4 = {
13311
13749
  command: "list",
13312
13750
  aliases: ["ls"],
@@ -13371,25 +13809,25 @@ var ListCommand4 = {
13371
13809
  agents.forEach((a) => output.log(a.name));
13372
13810
  } else {
13373
13811
  const header = [
13374
- chalk30.bold("Name"),
13375
- chalk30.bold("Type"),
13376
- chalk30.bold("Model"),
13377
- chalk30.bold("Workflow"),
13378
- chalk30.bold("Description")
13812
+ chalk31.bold("Name"),
13813
+ chalk31.bold("Type"),
13814
+ chalk31.bold("Model"),
13815
+ chalk31.bold("Workflow"),
13816
+ chalk31.bold("Description")
13379
13817
  ].join(" | ");
13380
13818
  const typeColor = (type) => {
13381
13819
  if (type === "primary")
13382
- return chalk30.yellow;
13820
+ return chalk31.yellow;
13383
13821
  if (type === "workflow")
13384
- return chalk30.magenta;
13385
- return chalk30.blue;
13822
+ return chalk31.magenta;
13823
+ return chalk31.blue;
13386
13824
  };
13387
13825
  const rows = agents.map((a) => {
13388
13826
  const desc2 = (a.description || "").length > 40 ? (a.description || "").slice(0, 37) + "..." : a.description || "-";
13389
- const workflowDisplay = a.type === "workflow" && a.workflow ? chalk30.cyan(a.workflow.length > 30 ? a.workflow.slice(0, 27) + "..." : a.workflow) : chalk30.gray("-");
13390
- const modelDisplay = a.model ? chalk30.yellow(a.model.length > 20 ? a.model.slice(0, 17) + "..." : a.model) : chalk30.gray("-");
13827
+ const workflowDisplay = a.type === "workflow" && a.workflow ? chalk31.cyan(a.workflow.length > 30 ? a.workflow.slice(0, 27) + "..." : a.workflow) : chalk31.gray("-");
13828
+ const modelDisplay = a.model ? chalk31.yellow(a.model.length > 20 ? a.model.slice(0, 17) + "..." : a.model) : chalk31.gray("-");
13391
13829
  return [
13392
- chalk30.cyan(a.name),
13830
+ chalk31.cyan(a.name),
13393
13831
  typeColor(a.type)(a.type),
13394
13832
  modelDisplay,
13395
13833
  workflowDisplay,
@@ -13397,9 +13835,9 @@ var ListCommand4 = {
13397
13835
  ].join(" | ");
13398
13836
  });
13399
13837
  if (rows.length === 0) {
13400
- output.log(chalk30.yellow("No agents found."));
13838
+ output.log(chalk31.yellow("No agents found."));
13401
13839
  output.log("");
13402
- output.log(chalk30.gray("Tip: Create agent configs in ~/.local/share/roy-agent/agents/"));
13840
+ output.log(chalk31.gray("Tip: Create agent configs in ~/.local/share/roy-agent/agents/"));
13403
13841
  } else {
13404
13842
  output.log([
13405
13843
  `┌─ Agents ${"─".repeat(50)}┐`,
@@ -13408,7 +13846,7 @@ var ListCommand4 = {
13408
13846
  ...rows.map((r) => `│${r}│`),
13409
13847
  "└" + "─".repeat(header.length + 2) + "┘",
13410
13848
  "",
13411
- chalk30.gray(`Total: ${agents.length} agents`)
13849
+ chalk31.gray(`Total: ${agents.length} agents`)
13412
13850
  ].join(`
13413
13851
  `));
13414
13852
  }
@@ -13423,7 +13861,7 @@ var ListCommand4 = {
13423
13861
  };
13424
13862
 
13425
13863
  // src/commands/agents/get.ts
13426
- import chalk31 from "chalk";
13864
+ import chalk32 from "chalk";
13427
13865
  var GetCommand4 = {
13428
13866
  command: "get <name>",
13429
13867
  describe: "获取指定 agent 的详细信息",
@@ -13482,69 +13920,69 @@ var GetCommand4 = {
13482
13920
  filterHistory: agent.filterHistory
13483
13921
  });
13484
13922
  } else {
13485
- output.log(chalk31.bold.cyan(`# Agent: ${agent.name}`));
13923
+ output.log(chalk32.bold.cyan(`# Agent: ${agent.name}`));
13486
13924
  output.log("");
13487
- output.log(chalk31.bold("Basic Info:"));
13488
- output.log(` ${chalk31.cyan("name:")} ${agent.name}`);
13489
- output.log(` ${chalk31.cyan("type:")} ${agent.type}`);
13925
+ output.log(chalk32.bold("Basic Info:"));
13926
+ output.log(` ${chalk32.cyan("name:")} ${agent.name}`);
13927
+ output.log(` ${chalk32.cyan("type:")} ${agent.type}`);
13490
13928
  if (agent.description) {
13491
- output.log(` ${chalk31.cyan("description:")} ${agent.description}`);
13929
+ output.log(` ${chalk32.cyan("description:")} ${agent.description}`);
13492
13930
  }
13493
13931
  output.log("");
13494
13932
  if (agent.type === "workflow") {
13495
- output.log(chalk31.bold("Workflow:"));
13933
+ output.log(chalk32.bold("Workflow:"));
13496
13934
  if (agent.workflow) {
13497
- output.log(` ${chalk31.cyan("workflow:")} ${agent.workflow}`);
13498
- output.log(` ${chalk31.gray("→")} ${chalk31.gray(`roy-agent workflow run ${agent.workflow} --input '{"query":"..."}'`)}`);
13935
+ output.log(` ${chalk32.cyan("workflow:")} ${agent.workflow}`);
13936
+ output.log(` ${chalk32.gray("→")} ${chalk32.gray(`roy-agent workflow run ${agent.workflow} --input '{"query":"..."}'`)}`);
13499
13937
  } else {
13500
- output.log(` ${chalk31.gray("(no workflow configured)")}`);
13938
+ output.log(` ${chalk32.gray("(no workflow configured)")}`);
13501
13939
  }
13502
13940
  output.log("");
13503
13941
  }
13504
- output.log(chalk31.bold("System Prompt:"));
13942
+ output.log(chalk32.bold("System Prompt:"));
13505
13943
  if (agent.systemPromptRef) {
13506
- output.log(` ${chalk31.green("[ref]")} ${chalk31.cyan("systemPromptRef:")} ${agent.systemPromptRef}`);
13944
+ output.log(` ${chalk32.green("[ref]")} ${chalk32.cyan("systemPromptRef:")} ${agent.systemPromptRef}`);
13507
13945
  }
13508
13946
  if (agent.systemPrompt && !agent.systemPromptRef) {
13509
13947
  const promptPreview = agent.systemPrompt.length > 100 ? agent.systemPrompt.slice(0, 97) + "..." : agent.systemPrompt;
13510
- output.log(` ${chalk31.gray("[inline]")}`);
13511
- output.log(` ${chalk31.gray(promptPreview.split(`
13948
+ output.log(` ${chalk32.gray("[inline]")}`);
13949
+ output.log(` ${chalk32.gray(promptPreview.split(`
13512
13950
  `).join(`
13513
13951
  `))}`);
13514
13952
  }
13515
13953
  if (resolvedSystemPrompt) {
13516
13954
  const resolvedPreview = resolvedSystemPrompt.length > 200 ? resolvedSystemPrompt.slice(0, 197) + "..." : resolvedSystemPrompt;
13517
- output.log(` ${chalk31.green("[resolved]")}`);
13518
- output.log(` ${chalk31.gray(resolvedPreview.split(`
13955
+ output.log(` ${chalk32.green("[resolved]")}`);
13956
+ output.log(` ${chalk32.gray(resolvedPreview.split(`
13519
13957
  `).join(`
13520
13958
  `))}`);
13521
13959
  }
13522
13960
  if (!agent.systemPromptRef && !agent.systemPrompt && !resolvedSystemPrompt) {
13523
- output.log(` ${chalk31.gray("(none)")}`);
13961
+ output.log(` ${chalk32.gray("(none)")}`);
13524
13962
  }
13525
13963
  output.log("");
13526
13964
  const hasOptions = agent.model || agent.maxIterations || agent.toolTimeout;
13527
13965
  if (hasOptions) {
13528
- output.log(chalk31.bold("Options:"));
13966
+ output.log(chalk32.bold("Options:"));
13529
13967
  if (agent.model) {
13530
- output.log(` ${chalk31.cyan("model:")} ${agent.model}`);
13968
+ output.log(` ${chalk32.cyan("model:")} ${agent.model}`);
13531
13969
  }
13532
13970
  if (agent.maxIterations) {
13533
- output.log(` ${chalk31.cyan("maxIterations:")} ${agent.maxIterations}`);
13971
+ output.log(` ${chalk32.cyan("maxIterations:")} ${agent.maxIterations}`);
13534
13972
  }
13535
13973
  if (agent.toolTimeout) {
13536
- output.log(` ${chalk31.cyan("toolTimeout:")} ${agent.toolTimeout}ms`);
13974
+ output.log(` ${chalk32.cyan("toolTimeout:")} ${agent.toolTimeout}ms`);
13537
13975
  }
13538
13976
  output.log("");
13539
13977
  }
13540
13978
  const hasTools = agent.allowedTools?.length || agent.deniedTools?.length;
13541
13979
  if (hasTools) {
13542
- output.log(chalk31.bold("Tool Permissions:"));
13980
+ output.log(chalk32.bold("Tool Permissions:"));
13543
13981
  if (agent.allowedTools?.length) {
13544
- output.log(` ${chalk31.green("allowed:")} ${agent.allowedTools.join(", ")}`);
13982
+ output.log(` ${chalk32.green("allowed:")} ${agent.allowedTools.join(", ")}`);
13545
13983
  }
13546
13984
  if (agent.deniedTools?.length) {
13547
- output.log(` ${chalk31.red("denied:")} ${agent.deniedTools.join(", ")}`);
13985
+ output.log(` ${chalk32.red("denied:")} ${agent.deniedTools.join(", ")}`);
13548
13986
  }
13549
13987
  output.log("");
13550
13988
  }
@@ -13559,7 +13997,7 @@ var GetCommand4 = {
13559
13997
  };
13560
13998
 
13561
13999
  // src/commands/agents/add.ts
13562
- import chalk32 from "chalk";
14000
+ import chalk33 from "chalk";
13563
14001
  function parseToolList(value) {
13564
14002
  if (!value?.trim()) {
13565
14003
  return;
@@ -13651,8 +14089,8 @@ var AddCommand = {
13651
14089
  if (args.json) {
13652
14090
  output.json({ agent, filePath });
13653
14091
  } else {
13654
- output.log(chalk32.green(`✓ Agent '${args.name}' created`));
13655
- output.log(chalk32.gray(` ${filePath}`));
14092
+ output.log(chalk33.green(`✓ Agent '${args.name}' created`));
14093
+ output.log(chalk33.gray(` ${filePath}`));
13656
14094
  }
13657
14095
  } catch (error) {
13658
14096
  output.error(`Failed to add agent: ${error}`);
@@ -13664,7 +14102,7 @@ var AddCommand = {
13664
14102
  };
13665
14103
 
13666
14104
  // src/commands/agents/delete.ts
13667
- import chalk33 from "chalk";
14105
+ import chalk34 from "chalk";
13668
14106
  var DeleteCommand3 = {
13669
14107
  command: "delete <name>",
13670
14108
  describe: "删除 agent 配置文件",
@@ -13706,7 +14144,7 @@ var DeleteCommand3 = {
13706
14144
  }
13707
14145
  const filePath = registry.getAgentFilePath(args.name);
13708
14146
  if (!args.yes) {
13709
- output.log(chalk33.yellow(`Delete agent '${args.name}'? This removes ${filePath} (use --yes to skip confirmation)`));
14147
+ output.log(chalk34.yellow(`Delete agent '${args.name}'? This removes ${filePath} (use --yes to skip confirmation)`));
13710
14148
  process.exit(1);
13711
14149
  }
13712
14150
  const deleted = await registry.deleteAgent(args.name);
@@ -13717,7 +14155,7 @@ var DeleteCommand3 = {
13717
14155
  if (args.json) {
13718
14156
  output.json({ deleted: true, name: args.name, filePath });
13719
14157
  } else {
13720
- output.log(chalk33.green(`✓ Agent '${args.name}' deleted`));
14158
+ output.log(chalk34.green(`✓ Agent '${args.name}' deleted`));
13721
14159
  }
13722
14160
  } catch (error) {
13723
14161
  output.error(`Failed to delete agent: ${error}`);
@@ -13729,7 +14167,7 @@ var DeleteCommand3 = {
13729
14167
  };
13730
14168
 
13731
14169
  // src/commands/agents/config-dir.ts
13732
- import chalk34 from "chalk";
14170
+ import chalk35 from "chalk";
13733
14171
  var ConfigDirCommand = {
13734
14172
  command: "config-dir",
13735
14173
  describe: "显示 agent 配置目录路径",
@@ -13760,8 +14198,8 @@ var ConfigDirCommand = {
13760
14198
  if (args.json) {
13761
14199
  output.json({ configDir, exists });
13762
14200
  } else {
13763
- output.log(`${chalk34.cyan("Agent Config Directory:")} ${configDir}`);
13764
- output.log(`${chalk34.gray("Exists:")} ${exists ? "yes" : "no"}`);
14201
+ output.log(`${chalk35.cyan("Agent Config Directory:")} ${configDir}`);
14202
+ output.log(`${chalk35.gray("Exists:")} ${exists ? "yes" : "no"}`);
13765
14203
  }
13766
14204
  } catch (error) {
13767
14205
  output.error(`Failed to get config dir: ${error}`);
@@ -13784,7 +14222,7 @@ var AgentsCommand = {
13784
14222
  };
13785
14223
 
13786
14224
  // src/commands/prompt/list.ts
13787
- import chalk35 from "chalk";
14225
+ import chalk36 from "chalk";
13788
14226
  var ListCommand5 = {
13789
14227
  command: "list",
13790
14228
  aliases: ["ls"],
@@ -13840,17 +14278,17 @@ var ListCommand5 = {
13840
14278
  prompts.forEach((p) => output.log(p.name));
13841
14279
  } else {
13842
14280
  const header = [
13843
- chalk35.bold("Name"),
13844
- chalk35.bold("Source")
14281
+ chalk36.bold("Name"),
14282
+ chalk36.bold("Source")
13845
14283
  ].join(" | ");
13846
14284
  const rows = prompts.map((p) => {
13847
14285
  return [
13848
- chalk35.cyan(p.name),
13849
- chalk35.gray(`[${p.source}]`)
14286
+ chalk36.cyan(p.name),
14287
+ chalk36.gray(`[${p.source}]`)
13850
14288
  ].join(" | ");
13851
14289
  });
13852
14290
  if (rows.length === 0) {
13853
- output.log(chalk35.yellow("No prompts found."));
14291
+ output.log(chalk36.yellow("No prompts found."));
13854
14292
  } else {
13855
14293
  output.log([
13856
14294
  `┌─ Prompts ${"─".repeat(50)}┐`,
@@ -13859,7 +14297,7 @@ var ListCommand5 = {
13859
14297
  ...rows.map((r) => `│${r}│`),
13860
14298
  "└" + "─".repeat(header.length + 2) + "┘",
13861
14299
  "",
13862
- chalk35.gray(`Total: ${prompts.length} prompts`)
14300
+ chalk36.gray(`Total: ${prompts.length} prompts`)
13863
14301
  ].join(`
13864
14302
  `));
13865
14303
  }
@@ -13874,7 +14312,7 @@ var ListCommand5 = {
13874
14312
  };
13875
14313
 
13876
14314
  // src/commands/prompt/get.ts
13877
- import chalk36 from "chalk";
14315
+ import chalk37 from "chalk";
13878
14316
  var GetCommand5 = {
13879
14317
  command: "get <name>",
13880
14318
  describe: "获取指定 prompt 的内容",
@@ -13921,16 +14359,16 @@ var GetCommand5 = {
13921
14359
  variables: vars
13922
14360
  });
13923
14361
  } else {
13924
- output.log(chalk36.bold.cyan(`# Prompt: ${args.name}`));
14362
+ output.log(chalk37.bold.cyan(`# Prompt: ${args.name}`));
13925
14363
  output.log("");
13926
14364
  if (Object.keys(vars).length > 0) {
13927
- output.log(chalk36.gray("Variables:"));
14365
+ output.log(chalk37.gray("Variables:"));
13928
14366
  for (const [key, value] of Object.entries(vars)) {
13929
- output.log(` ${chalk36.cyan(key + ":")} ${value}`);
14367
+ output.log(` ${chalk37.cyan(key + ":")} ${value}`);
13930
14368
  }
13931
14369
  output.log("");
13932
14370
  }
13933
- output.log(chalk36.bold("Content:"));
14371
+ output.log(chalk37.bold("Content:"));
13934
14372
  output.log("─".repeat(60));
13935
14373
  output.log(prompt);
13936
14374
  output.log("─".repeat(60));
@@ -13959,8 +14397,8 @@ function parseVars(vars) {
13959
14397
  }
13960
14398
 
13961
14399
  // src/commands/prompt/add.ts
13962
- import { readFile } from "fs/promises";
13963
- import chalk37 from "chalk";
14400
+ import { readFile as readFile2 } from "fs/promises";
14401
+ import chalk38 from "chalk";
13964
14402
  var AddCommand2 = {
13965
14403
  command: "add <name>",
13966
14404
  describe: "添加 prompt 并持久化到 ~/.local/share/roy-agent/prompts/",
@@ -14001,7 +14439,7 @@ var AddCommand2 = {
14001
14439
  output.error("PromptComponent not available");
14002
14440
  process.exit(1);
14003
14441
  }
14004
- const content = args.file ? await readFile(args.file, "utf-8") : args.content;
14442
+ const content = args.file ? await readFile2(args.file, "utf-8") : args.content;
14005
14443
  const filePath = await promptComponent.savePrompt(args.name, content);
14006
14444
  if (args.json) {
14007
14445
  output.json({
@@ -14011,8 +14449,8 @@ var AddCommand2 = {
14011
14449
  length: content.trim().length
14012
14450
  });
14013
14451
  } else {
14014
- output.log(chalk37.green(`✓ Prompt '${args.name}' saved`));
14015
- output.log(chalk37.gray(` ${filePath}`));
14452
+ output.log(chalk38.green(`✓ Prompt '${args.name}' saved`));
14453
+ output.log(chalk38.gray(` ${filePath}`));
14016
14454
  }
14017
14455
  } catch (error) {
14018
14456
  output.error(`Failed to add prompt: ${error}`);
@@ -14024,7 +14462,7 @@ var AddCommand2 = {
14024
14462
  };
14025
14463
 
14026
14464
  // src/commands/prompt/config-dir.ts
14027
- import chalk38 from "chalk";
14465
+ import chalk39 from "chalk";
14028
14466
  var ConfigDirCommand2 = {
14029
14467
  command: "config-dir",
14030
14468
  describe: "显示 prompt 持久化目录路径",
@@ -14054,8 +14492,8 @@ var ConfigDirCommand2 = {
14054
14492
  if (args.json) {
14055
14493
  output.json({ configDir, exists });
14056
14494
  } else {
14057
- output.log(`${chalk38.cyan("Prompt Config Directory:")} ${configDir}`);
14058
- output.log(`${chalk38.gray("Exists:")} ${exists ? "yes" : "no"}`);
14495
+ output.log(`${chalk39.cyan("Prompt Config Directory:")} ${configDir}`);
14496
+ output.log(`${chalk39.gray("Exists:")} ${exists ? "yes" : "no"}`);
14059
14497
  }
14060
14498
  } catch (error) {
14061
14499
  output.error(`Failed to get config dir: ${error}`);
@@ -14077,7 +14515,7 @@ var PromptCommand = {
14077
14515
  };
14078
14516
 
14079
14517
  // src/commands/commands-list.ts
14080
- import chalk39 from "chalk";
14518
+ import chalk40 from "chalk";
14081
14519
  function truncateVisual(str, maxWidth) {
14082
14520
  let result = "";
14083
14521
  let width = 0;
@@ -14092,16 +14530,16 @@ function truncateVisual(str, maxWidth) {
14092
14530
  }
14093
14531
  function formatCommandsTable(commands) {
14094
14532
  if (commands.length === 0) {
14095
- return chalk39.yellow("命令目录为空,使用 'roy-agent commands add' 添加命令");
14533
+ return chalk40.yellow("命令目录为空,使用 'roy-agent commands add' 添加命令");
14096
14534
  }
14097
14535
  const NAME_WIDTH = 20;
14098
14536
  const SOURCE_WIDTH = 10;
14099
14537
  const DESC_WIDTH = 50;
14100
14538
  const GAP = " ";
14101
14539
  const headerLine = [
14102
- chalk39.bold("NAME".padEnd(NAME_WIDTH)),
14103
- chalk39.bold("SOURCE".padEnd(SOURCE_WIDTH)),
14104
- chalk39.bold("DESCRIPTION")
14540
+ chalk40.bold("NAME".padEnd(NAME_WIDTH)),
14541
+ chalk40.bold("SOURCE".padEnd(SOURCE_WIDTH)),
14542
+ chalk40.bold("DESCRIPTION")
14105
14543
  ].join(GAP);
14106
14544
  const sepLine = "─".repeat(NAME_WIDTH + SOURCE_WIDTH + DESC_WIDTH + GAP.length * 2);
14107
14545
  const formatRow = (cmd) => {
@@ -14164,7 +14602,7 @@ var CommandsListCommand = {
14164
14602
  }));
14165
14603
  output.log(formatCommandsTable(rows));
14166
14604
  output.info("");
14167
- output.log(chalk39.green(`✅ 共 ${result.commands.length} 个命令`) + chalk39.gray(` (user: ${result.stats.userCount}, project: ${result.stats.projectCount})`));
14605
+ output.log(chalk40.green(`✅ 共 ${result.commands.length} 个命令`) + chalk40.gray(` (user: ${result.stats.userCount}, project: ${result.stats.projectCount})`));
14168
14606
  }
14169
14607
  } catch (error) {
14170
14608
  output.error(`Failed to list commands: ${error}`);
@@ -14176,7 +14614,7 @@ var CommandsListCommand = {
14176
14614
  };
14177
14615
 
14178
14616
  // src/commands/commands-add.ts
14179
- import chalk40 from "chalk";
14617
+ import chalk41 from "chalk";
14180
14618
  var CommandsAddCommand = {
14181
14619
  command: "add <name> <target>",
14182
14620
  describe: "添加收藏命令(自动创建 symlink)",
@@ -14237,10 +14675,10 @@ var CommandsAddCommand = {
14237
14675
  });
14238
14676
  const dirs = await commandsComponent.getCommandDirs();
14239
14677
  const targetDir = source === "user" ? dirs.user : dirs.project;
14240
- output.log(chalk40.green(`✅ 已添加命令 '${args.name}'`));
14241
- output.log(chalk40.gray(` 目标: ${args.target}`));
14242
- output.log(chalk40.gray(` 位置: ${targetDir}/${args.name}`));
14243
- output.log(chalk40.gray(` 级别: ${source === "user" ? "USER" : "PROJECT"}`));
14678
+ output.log(chalk41.green(`✅ 已添加命令 '${args.name}'`));
14679
+ output.log(chalk41.gray(` 目标: ${args.target}`));
14680
+ output.log(chalk41.gray(` 位置: ${targetDir}/${args.name}`));
14681
+ output.log(chalk41.gray(` 级别: ${source === "user" ? "USER" : "PROJECT"}`));
14244
14682
  } catch (error) {
14245
14683
  output.error(`添加失败: ${error.message}`);
14246
14684
  process.exit(1);
@@ -14251,7 +14689,7 @@ var CommandsAddCommand = {
14251
14689
  };
14252
14690
 
14253
14691
  // src/commands/commands-remove.ts
14254
- import chalk41 from "chalk";
14692
+ import chalk42 from "chalk";
14255
14693
  var CommandsRemoveCommand = {
14256
14694
  command: "remove <name>",
14257
14695
  aliases: ["rm"],
@@ -14295,7 +14733,7 @@ var CommandsRemoveCommand = {
14295
14733
  name: args.name,
14296
14734
  source: "user"
14297
14735
  });
14298
- output.log(chalk41.green(`✅ 已从用户目录移除命令 '${args.name}'`));
14736
+ output.log(chalk42.green(`✅ 已从用户目录移除命令 '${args.name}'`));
14299
14737
  } catch (error) {
14300
14738
  if (!error.message?.includes("不存在")) {
14301
14739
  throw error;
@@ -14308,7 +14746,7 @@ var CommandsRemoveCommand = {
14308
14746
  name: args.name,
14309
14747
  source: "project"
14310
14748
  });
14311
- output.log(chalk41.green(`✅ 已从项目目录移除命令 '${args.name}'`));
14749
+ output.log(chalk42.green(`✅ 已从项目目录移除命令 '${args.name}'`));
14312
14750
  } catch (error) {
14313
14751
  if (!error.message?.includes("不存在")) {
14314
14752
  throw error;
@@ -14322,7 +14760,7 @@ var CommandsRemoveCommand = {
14322
14760
  name: args.name,
14323
14761
  source: "user"
14324
14762
  });
14325
- output.log(chalk41.green(`✅ 已从用户目录移除命令 '${args.name}'`));
14763
+ output.log(chalk42.green(`✅ 已从用户目录移除命令 '${args.name}'`));
14326
14764
  removed = true;
14327
14765
  } catch (error) {
14328
14766
  if (!error.message?.includes("不存在")) {
@@ -14334,7 +14772,7 @@ var CommandsRemoveCommand = {
14334
14772
  name: args.name,
14335
14773
  source: "project"
14336
14774
  });
14337
- output.log(chalk41.green(`✅ 已从项目目录移除命令 '${args.name}'`));
14775
+ output.log(chalk42.green(`✅ 已从项目目录移除命令 '${args.name}'`));
14338
14776
  removed = true;
14339
14777
  } catch (error) {
14340
14778
  if (!error.message?.includes("不存在")) {
@@ -14356,10 +14794,10 @@ var CommandsRemoveCommand = {
14356
14794
  };
14357
14795
 
14358
14796
  // src/commands/commands-info.ts
14359
- import chalk42 from "chalk";
14360
- import { exec } from "child_process";
14797
+ import chalk43 from "chalk";
14798
+ import { exec as exec2 } from "child_process";
14361
14799
  import { promisify } from "util";
14362
- var execAsync = promisify(exec);
14800
+ var execAsync2 = promisify(exec2);
14363
14801
  var CommandsInfoCommand = {
14364
14802
  command: "info <name>",
14365
14803
  describe: "显示命令详细信息",
@@ -14391,22 +14829,22 @@ var CommandsInfoCommand = {
14391
14829
  output.error(`命令 '${args.name}' 不存在`);
14392
14830
  process.exit(1);
14393
14831
  }
14394
- output.log(chalk42.bold("Name:") + ` ${info.name}`);
14395
- output.log(chalk42.bold("Path:") + ` ${info.path}`);
14396
- output.log(chalk42.bold("Source:") + ` ${info.source.toUpperCase()}`);
14397
- output.log(chalk42.bold("Description:") + ` ${info.shortDescription || "-"}`);
14832
+ output.log(chalk43.bold("Name:") + ` ${info.name}`);
14833
+ output.log(chalk43.bold("Path:") + ` ${info.path}`);
14834
+ output.log(chalk43.bold("Source:") + ` ${info.source.toUpperCase()}`);
14835
+ output.log(chalk43.bold("Description:") + ` ${info.shortDescription || "-"}`);
14398
14836
  output.log();
14399
- output.log(chalk42.gray("─".repeat(50)));
14837
+ output.log(chalk43.gray("─".repeat(50)));
14400
14838
  output.log();
14401
14839
  try {
14402
- const { stdout } = await execAsync(`${info.path} --help`, { timeout: 5000 });
14840
+ const { stdout } = await execAsync2(`${info.path} --help`, { timeout: 5000 });
14403
14841
  output.log(stdout);
14404
14842
  } catch {
14405
14843
  try {
14406
- const { stdout } = await execAsync(`${info.path} -h`, { timeout: 5000 });
14844
+ const { stdout } = await execAsync2(`${info.path} -h`, { timeout: 5000 });
14407
14845
  output.log(stdout);
14408
14846
  } catch {
14409
- output.log(chalk42.gray("(无法获取帮助信息)"));
14847
+ output.log(chalk43.gray("(无法获取帮助信息)"));
14410
14848
  }
14411
14849
  }
14412
14850
  } catch (error) {
@@ -14419,7 +14857,7 @@ var CommandsInfoCommand = {
14419
14857
  };
14420
14858
 
14421
14859
  // src/commands/commands-dirs.ts
14422
- import chalk43 from "chalk";
14860
+ import chalk44 from "chalk";
14423
14861
  var CommandsDirsCommand = {
14424
14862
  command: "dirs",
14425
14863
  describe: "显示命令目录",
@@ -14451,10 +14889,10 @@ var CommandsDirsCommand = {
14451
14889
  if (args.json) {
14452
14890
  output.json(dirs);
14453
14891
  } else {
14454
- output.log(chalk43.bold("命令目录:"));
14892
+ output.log(chalk44.bold("命令目录:"));
14455
14893
  output.log();
14456
- output.log(chalk43.cyan("USER:") + ` ${dirs.user}`);
14457
- output.log(chalk43.cyan("PROJECT:") + ` ${dirs.project}`);
14894
+ output.log(chalk44.cyan("USER:") + ` ${dirs.user}`);
14895
+ output.log(chalk44.cyan("PROJECT:") + ` ${dirs.project}`);
14458
14896
  }
14459
14897
  } catch (error) {
14460
14898
  output.error(`错误: ${error.message}`);
@@ -14474,7 +14912,7 @@ var CommandsCommand = {
14474
14912
  };
14475
14913
 
14476
14914
  // src/commands/config/list.ts
14477
- import chalk44 from "chalk";
14915
+ import chalk45 from "chalk";
14478
14916
 
14479
14917
  // src/commands/config/config-service.ts
14480
14918
  import * as fsSync from "fs";
@@ -14778,7 +15216,7 @@ var ConfigListCommand = {
14778
15216
  output.log("");
14779
15217
  output.log("Supported components:");
14780
15218
  for (const comp of SUPPORTED_COMPONENTS) {
14781
- output.log(` ${chalk44.cyan(comp.padEnd(15))} ${COMPONENT_DESCRIPTIONS[comp] || ""}`);
15219
+ output.log(` ${chalk45.cyan(comp.padEnd(15))} ${COMPONENT_DESCRIPTIONS[comp] || ""}`);
14782
15220
  }
14783
15221
  process.exit(1);
14784
15222
  }
@@ -14796,27 +15234,27 @@ var ConfigListCommand = {
14796
15234
  }
14797
15235
  };
14798
15236
  function showHelp(output) {
14799
- output.log(chalk44.bold.cyan("# roy-agent config list"));
15237
+ output.log(chalk45.bold.cyan("# roy-agent config list"));
14800
15238
  output.log("");
14801
15239
  output.log("查看 roy-agent 组件配置信息");
14802
15240
  output.log("");
14803
- output.log(chalk44.bold("Usage:"));
14804
- output.log(` ${chalk44.cyan("roy-agent config list [component] [options]")}`);
15241
+ output.log(chalk45.bold("Usage:"));
15242
+ output.log(` ${chalk45.cyan("roy-agent config list [component] [options]")}`);
14805
15243
  output.log("");
14806
- output.log(chalk44.bold("Components:"));
15244
+ output.log(chalk45.bold("Components:"));
14807
15245
  for (const comp of SUPPORTED_COMPONENTS) {
14808
- output.log(` ${chalk44.cyan(comp.padEnd(15))} ${chalk44.gray(COMPONENT_DESCRIPTIONS[comp] || "")}`);
15246
+ output.log(` ${chalk45.cyan(comp.padEnd(15))} ${chalk45.gray(COMPONENT_DESCRIPTIONS[comp] || "")}`);
14809
15247
  }
14810
- output.log(` ${chalk44.cyan("all".padEnd(15))} 显示所有 components 概览`);
15248
+ output.log(` ${chalk45.cyan("all".padEnd(15))} 显示所有 components 概览`);
14811
15249
  output.log("");
14812
- output.log(chalk44.bold("Options:"));
14813
- output.log(` ${chalk44.cyan("-j, --json")} JSON 格式输出`);
14814
- output.log(` ${chalk44.cyan("-k, --keys")} 只显示配置键`);
14815
- output.log(` ${chalk44.cyan("-s, --sources")} 只显示配置源`);
15250
+ output.log(chalk45.bold("Options:"));
15251
+ output.log(` ${chalk45.cyan("-j, --json")} JSON 格式输出`);
15252
+ output.log(` ${chalk45.cyan("-k, --keys")} 只显示配置键`);
15253
+ output.log(` ${chalk45.cyan("-s, --sources")} 只显示配置源`);
14816
15254
  output.log("");
14817
- output.log(chalk44.bold("Examples:"));
15255
+ output.log(chalk45.bold("Examples:"));
14818
15256
  for (const { command: command2, description } of USAGE_COMMANDS) {
14819
- output.log(` ${chalk44.cyan(command2.padEnd(40))} ${chalk44.gray(description)}`);
15257
+ output.log(` ${chalk45.cyan(command2.padEnd(40))} ${chalk45.gray(description)}`);
14820
15258
  }
14821
15259
  }
14822
15260
  async function showAllComponents(output, configService) {
@@ -14825,13 +15263,13 @@ async function showAllComponents(output, configService) {
14825
15263
  const config = configService.getComponentConfig(compName);
14826
15264
  components.push({ name: compName, config });
14827
15265
  }
14828
- output.log(chalk44.bold.cyan("# All Components Overview"));
15266
+ output.log(chalk45.bold.cyan("# All Components Overview"));
14829
15267
  output.log("");
14830
- output.log(` ${chalk44.cyan("Component".padEnd(15))} ${chalk44.cyan("Keys".padEnd(10))} ${chalk44.gray("Description")}`);
14831
- output.log(` ${chalk44.gray("─".repeat(60))}`);
15268
+ output.log(` ${chalk45.cyan("Component".padEnd(15))} ${chalk45.cyan("Keys".padEnd(10))} ${chalk45.gray("Description")}`);
15269
+ output.log(` ${chalk45.gray("─".repeat(60))}`);
14832
15270
  for (const comp of components) {
14833
15271
  const keyCount = Object.keys(comp.config).length;
14834
- output.log(` ${chalk44.cyan(comp.name.padEnd(15))} ${keyCount.toString().padEnd(10)} ${chalk44.gray(COMPONENT_DESCRIPTIONS[comp.name] || "")}`);
15272
+ output.log(` ${chalk45.cyan(comp.name.padEnd(15))} ${keyCount.toString().padEnd(10)} ${chalk45.gray(COMPONENT_DESCRIPTIONS[comp.name] || "")}`);
14835
15273
  }
14836
15274
  }
14837
15275
  async function showComponentConfig(componentName, output, configService, options) {
@@ -14853,22 +15291,22 @@ async function showComponentConfig(componentName, output, configService, options
14853
15291
  });
14854
15292
  return;
14855
15293
  }
14856
- output.log(chalk44.bold.cyan(`# ${componentName} Component Configuration`));
15294
+ output.log(chalk45.bold.cyan(`# ${componentName} Component Configuration`));
14857
15295
  output.log("");
14858
15296
  if (filePath) {
14859
- output.log(chalk44.bold("File:"));
14860
- output.log(` ${chalk44.cyan(filePath)}`);
15297
+ output.log(chalk45.bold("File:"));
15298
+ output.log(` ${chalk45.cyan(filePath)}`);
14861
15299
  output.log("");
14862
15300
  }
14863
15301
  if (!options.sources) {
14864
- output.log(chalk44.bold("Configuration:"));
15302
+ output.log(chalk45.bold("Configuration:"));
14865
15303
  if (Object.keys(config).length === 0) {
14866
- output.log(` ${chalk44.gray("(无配置)")}`);
15304
+ output.log(` ${chalk45.gray("(无配置)")}`);
14867
15305
  } else {
14868
15306
  const flatConfig = flattenConfig(config);
14869
15307
  for (const [key, value] of flatConfig) {
14870
15308
  const displayValue = formatValue(value);
14871
- output.log(` ${chalk44.cyan(key + ":")} ${displayValue}`);
15309
+ output.log(` ${chalk45.cyan(key + ":")} ${displayValue}`);
14872
15310
  }
14873
15311
  }
14874
15312
  output.log("");
@@ -14883,17 +15321,17 @@ async function showAgentComponentConfig(output, configService, options) {
14883
15321
  });
14884
15322
  return;
14885
15323
  }
14886
- output.log(chalk44.bold.cyan("# Agent Component Configuration"));
15324
+ output.log(chalk45.bold.cyan("# Agent Component Configuration"));
14887
15325
  output.log("");
14888
15326
  if (!options.sources) {
14889
- output.log(chalk44.bold("Configuration:"));
15327
+ output.log(chalk45.bold("Configuration:"));
14890
15328
  if (Object.keys(config).length === 0) {
14891
- output.log(` ${chalk44.gray("(无配置,使用默认值)")}`);
15329
+ output.log(` ${chalk45.gray("(无配置,使用默认值)")}`);
14892
15330
  } else {
14893
15331
  const flatConfig = flattenConfig(config);
14894
15332
  for (const [key, value] of flatConfig) {
14895
15333
  const displayValue = formatValue(value);
14896
- output.log(` ${chalk44.cyan(key + ":")} ${displayValue}`);
15334
+ output.log(` ${chalk45.cyan(key + ":")} ${displayValue}`);
14897
15335
  }
14898
15336
  }
14899
15337
  output.log("");
@@ -14907,10 +15345,10 @@ async function showAgentComponentConfig(output, configService, options) {
14907
15345
  const configDir = registry.getConfigDir();
14908
15346
  const exists = registry.configDirExists();
14909
15347
  const agentCount = registry.list().length;
14910
- output.log(chalk44.bold("Agent Config Directory:"));
14911
- output.log(` ${chalk44.cyan("path:")} ${configDir}`);
14912
- output.log(` ${chalk44.cyan("exists:")} ${exists ? chalk44.green("yes") : chalk44.red("no")}`);
14913
- output.log(` ${chalk44.cyan("agents:")} ${agentCount} loaded`);
15348
+ output.log(chalk45.bold("Agent Config Directory:"));
15349
+ output.log(` ${chalk45.cyan("path:")} ${configDir}`);
15350
+ output.log(` ${chalk45.cyan("exists:")} ${exists ? chalk45.green("yes") : chalk45.red("no")}`);
15351
+ output.log(` ${chalk45.cyan("agents:")} ${agentCount} loaded`);
14914
15352
  output.log("");
14915
15353
  }
14916
15354
  }
@@ -14926,41 +15364,41 @@ async function showPromptComponentConfig(output, configService, options, envServ
14926
15364
  });
14927
15365
  return;
14928
15366
  }
14929
- output.log(chalk44.bold.cyan("# Prompt Component Configuration"));
15367
+ output.log(chalk45.bold.cyan("# Prompt Component Configuration"));
14930
15368
  output.log("");
14931
15369
  if (filePath) {
14932
- output.log(chalk44.bold("File:"));
14933
- output.log(` ${chalk44.cyan(filePath)}`);
15370
+ output.log(chalk45.bold("File:"));
15371
+ output.log(` ${chalk45.cyan(filePath)}`);
14934
15372
  output.log("");
14935
15373
  }
14936
15374
  if (!options.sources) {
14937
- output.log(chalk44.bold("Configuration:"));
15375
+ output.log(chalk45.bold("Configuration:"));
14938
15376
  if (Object.keys(config).length === 0) {
14939
- output.log(` ${chalk44.gray("(无配置,使用默认值)")}`);
15377
+ output.log(` ${chalk45.gray("(无配置,使用默认值)")}`);
14940
15378
  } else {
14941
15379
  const flatConfig = flattenConfig(config);
14942
15380
  for (const [key, value] of flatConfig) {
14943
15381
  const displayValue = formatValue(value);
14944
- output.log(` ${chalk44.cyan(key + ":")} ${displayValue}`);
15382
+ output.log(` ${chalk45.cyan(key + ":")} ${displayValue}`);
14945
15383
  }
14946
15384
  }
14947
15385
  output.log("");
14948
15386
  }
14949
- output.log(chalk44.bold("Prompts:"));
14950
- output.log(` ${chalk44.gray("- 内置: 5 个(default, coding, review, project-memory, global-memory)")}`);
15387
+ output.log(chalk45.bold("Prompts:"));
15388
+ output.log(` ${chalk45.gray("- 内置: 5 个(default, coding, review, project-memory, global-memory)")}`);
14951
15389
  const promptPaths = config?.promptPaths;
14952
15390
  if (promptPaths && Array.isArray(promptPaths) && promptPaths.length > 0) {
14953
- output.log(` ${chalk44.gray("- 外部: " + promptPaths.length + " 个路径")}`);
15391
+ output.log(` ${chalk45.gray("- 外部: " + promptPaths.length + " 个路径")}`);
14954
15392
  for (const p of promptPaths) {
14955
- output.log(` ${chalk44.cyan(p.path)} ${chalk44.gray("(type: " + p.type + ")")}`);
15393
+ output.log(` ${chalk45.cyan(p.path)} ${chalk45.gray("(type: " + p.type + ")")}`);
14956
15394
  }
14957
15395
  } else {
14958
- output.log(` ${chalk44.gray("- 外部: 0 个(未配置 promptPaths)")}`);
15396
+ output.log(` ${chalk45.gray("- 外部: 0 个(未配置 promptPaths)")}`);
14959
15397
  }
14960
15398
  output.log("");
14961
15399
  const defaultName = config?.defaultName || "default";
14962
- output.log(chalk44.bold("Default Prompt:"));
14963
- output.log(` ${chalk44.cyan("defaultName:")} ${defaultName}`);
15400
+ output.log(chalk45.bold("Default Prompt:"));
15401
+ output.log(` ${chalk45.cyan("defaultName:")} ${defaultName}`);
14964
15402
  output.log("");
14965
15403
  const env = envService?.getEnvironment?.();
14966
15404
  if (env) {
@@ -14975,10 +15413,10 @@ async function showPromptComponentConfig(output, configService, options, envServ
14975
15413
  const stored = await store?.loadAll?.();
14976
15414
  promptCount = Array.isArray(stored) ? stored.length : 0;
14977
15415
  } catch {}
14978
- output.log(chalk44.bold("Prompt Storage Directory:"));
14979
- output.log(` ${chalk44.cyan("path:")} ${configDir}`);
14980
- output.log(` ${chalk44.cyan("exists:")} ${exists ? chalk44.green("yes") : chalk44.red("no")}`);
14981
- output.log(` ${chalk44.cyan("prompts:")} ${promptCount} loaded`);
15416
+ output.log(chalk45.bold("Prompt Storage Directory:"));
15417
+ output.log(` ${chalk45.cyan("path:")} ${configDir}`);
15418
+ output.log(` ${chalk45.cyan("exists:")} ${exists ? chalk45.green("yes") : chalk45.red("no")}`);
15419
+ output.log(` ${chalk45.cyan("prompts:")} ${promptCount} loaded`);
14982
15420
  output.log("");
14983
15421
  }
14984
15422
  }
@@ -15004,19 +15442,19 @@ function flattenConfig(obj, prefix = "") {
15004
15442
  }
15005
15443
  function formatValue(value) {
15006
15444
  if (value === undefined) {
15007
- return chalk44.gray("undefined");
15445
+ return chalk45.gray("undefined");
15008
15446
  }
15009
15447
  if (value === null) {
15010
- return chalk44.gray("null");
15448
+ return chalk45.gray("null");
15011
15449
  }
15012
15450
  if (typeof value === "object") {
15013
- return chalk44.gray(JSON.stringify(value));
15451
+ return chalk45.gray(JSON.stringify(value));
15014
15452
  }
15015
15453
  return String(value);
15016
15454
  }
15017
15455
 
15018
15456
  // src/commands/config/export.ts
15019
- import chalk45 from "chalk";
15457
+ import chalk46 from "chalk";
15020
15458
  var ConfigExportCommand = {
15021
15459
  command: "export <component>",
15022
15460
  describe: "导出组件配置到文件",
@@ -15061,7 +15499,7 @@ var ConfigExportCommand = {
15061
15499
  output.log("");
15062
15500
  output.log("Supported components:");
15063
15501
  for (const comp of SUPPORTED_COMPONENTS) {
15064
- output.log(` ${chalk45.cyan(comp)}`);
15502
+ output.log(` ${chalk46.cyan(comp)}`);
15065
15503
  }
15066
15504
  process.exit(1);
15067
15505
  }
@@ -15079,7 +15517,7 @@ var ConfigExportCommand = {
15079
15517
  };
15080
15518
 
15081
15519
  // src/commands/config/import.ts
15082
- import chalk46 from "chalk";
15520
+ import chalk47 from "chalk";
15083
15521
  var ConfigImportCommand = {
15084
15522
  command: "import <component>",
15085
15523
  describe: "从文件导入配置到组件的 file source",
@@ -15129,7 +15567,7 @@ var ConfigImportCommand = {
15129
15567
  output.log("");
15130
15568
  output.log("Supported components:");
15131
15569
  for (const comp of SUPPORTED_COMPONENTS) {
15132
- output.log(` ${chalk46.cyan(comp)}`);
15570
+ output.log(` ${chalk47.cyan(comp)}`);
15133
15571
  }
15134
15572
  process.exit(1);
15135
15573
  }
@@ -15144,7 +15582,7 @@ var ConfigImportCommand = {
15144
15582
  }
15145
15583
  if (result.merged && result.changes.length > 0 && args.verbose) {
15146
15584
  output.log("");
15147
- output.log(chalk46.bold("变更详情:"));
15585
+ output.log(chalk47.bold("变更详情:"));
15148
15586
  for (const change of result.changes) {
15149
15587
  output.log(` ${change.key}: ${JSON.stringify(change.oldValue)} → ${JSON.stringify(change.newValue)}`);
15150
15588
  }
@@ -15168,7 +15606,7 @@ var ConfigCommand = {
15168
15606
  };
15169
15607
 
15170
15608
  // src/commands/mcp/list.ts
15171
- import chalk47 from "chalk";
15609
+ import chalk48 from "chalk";
15172
15610
  var ListCommand6 = {
15173
15611
  command: "list",
15174
15612
  aliases: ["ls"],
@@ -15214,30 +15652,30 @@ var ListCommand6 = {
15214
15652
  servers.forEach((s) => output.log(s.name));
15215
15653
  } else {
15216
15654
  if (servers.length === 0) {
15217
- output.log(chalk47.yellow("No MCP servers configured"));
15655
+ output.log(chalk48.yellow("No MCP servers configured"));
15218
15656
  return;
15219
15657
  }
15220
15658
  const statusColor = (status) => {
15221
15659
  switch (status) {
15222
15660
  case "connected":
15223
- return chalk47.green;
15661
+ return chalk48.green;
15224
15662
  case "connecting":
15225
- return chalk47.yellow;
15663
+ return chalk48.yellow;
15226
15664
  case "error":
15227
- return chalk47.red;
15665
+ return chalk48.red;
15228
15666
  case "disconnected":
15229
- return chalk47.gray;
15667
+ return chalk48.gray;
15230
15668
  default:
15231
- return chalk47.white;
15669
+ return chalk48.white;
15232
15670
  }
15233
15671
  };
15234
15672
  const header = [
15235
- chalk47.bold("Name"),
15236
- chalk47.bold("Status"),
15237
- chalk47.bold("Tools")
15673
+ chalk48.bold("Name"),
15674
+ chalk48.bold("Status"),
15675
+ chalk48.bold("Tools")
15238
15676
  ].join(" | ");
15239
15677
  const rows = servers.map((s) => [
15240
- chalk47.cyan(s.name),
15678
+ chalk48.cyan(s.name),
15241
15679
  statusColor(s.status)(`[${s.status}]`),
15242
15680
  s.toolsCount !== undefined ? String(s.toolsCount) : "-"
15243
15681
  ].join(" | "));
@@ -15248,7 +15686,7 @@ var ListCommand6 = {
15248
15686
  ...rows.map((r) => `│${r}│`),
15249
15687
  "└" + "─".repeat(header.length + 2) + "┘",
15250
15688
  "",
15251
- chalk47.gray(`Total: ${servers.length} servers`)
15689
+ chalk48.gray(`Total: ${servers.length} servers`)
15252
15690
  ].join(`
15253
15691
  `));
15254
15692
  }
@@ -15262,7 +15700,7 @@ var ListCommand6 = {
15262
15700
  };
15263
15701
 
15264
15702
  // src/commands/mcp/tools.ts
15265
- import chalk48 from "chalk";
15703
+ import chalk49 from "chalk";
15266
15704
  var ToolsCommand = {
15267
15705
  command: "tools",
15268
15706
  aliases: ["t"],
@@ -15315,7 +15753,7 @@ var ToolsCommand = {
15315
15753
  tools.forEach((t) => output.log(t.name));
15316
15754
  } else {
15317
15755
  if (tools.length === 0) {
15318
- output.log(chalk48.yellow("No MCP tools available"));
15756
+ output.log(chalk49.yellow("No MCP tools available"));
15319
15757
  return;
15320
15758
  }
15321
15759
  const byServer = new Map;
@@ -15327,15 +15765,15 @@ var ToolsCommand = {
15327
15765
  byServer.get(serverName).push(tool);
15328
15766
  }
15329
15767
  for (const [serverName, serverTools] of byServer) {
15330
- output.log(chalk48.bold.cyan(`
15768
+ output.log(chalk49.bold.cyan(`
15331
15769
  [${serverName}] ${serverTools.length} tools`));
15332
15770
  for (const tool of serverTools) {
15333
15771
  const desc2 = tool.description.length > 80 ? tool.description.slice(0, 77) + "..." : tool.description;
15334
- output.log(` ${chalk48.green("+")} ${chalk48.white(tool.name)}`);
15335
- output.log(` ${chalk48.gray(desc2)}`);
15772
+ output.log(` ${chalk49.green("+")} ${chalk49.white(tool.name)}`);
15773
+ output.log(` ${chalk49.gray(desc2)}`);
15336
15774
  }
15337
15775
  }
15338
- output.log(chalk48.gray(`
15776
+ output.log(chalk49.gray(`
15339
15777
  Total: ${tools.length} tools across ${byServer.size} servers`));
15340
15778
  }
15341
15779
  } catch (error) {
@@ -15348,7 +15786,7 @@ Total: ${tools.length} tools across ${byServer.size} servers`));
15348
15786
  };
15349
15787
 
15350
15788
  // src/commands/mcp/reload.ts
15351
- import chalk49 from "chalk";
15789
+ import chalk50 from "chalk";
15352
15790
  var ReloadCommand2 = {
15353
15791
  command: "reload",
15354
15792
  aliases: ["r"],
@@ -15369,19 +15807,19 @@ var ReloadCommand2 = {
15369
15807
  output.error("McpComponent not available");
15370
15808
  process.exit(1);
15371
15809
  }
15372
- output.log(chalk49.cyan("Reloading MCP servers..."));
15810
+ output.log(chalk50.cyan("Reloading MCP servers..."));
15373
15811
  await mcpComponent.reload();
15374
15812
  const servers = mcpComponent.listServers();
15375
15813
  const connected = servers.filter((s) => s.status === "connected").length;
15376
15814
  const errors = servers.filter((s) => s.status === "error").length;
15377
- output.log(chalk49.green(`✓ Reloaded ${servers.length} servers`));
15815
+ output.log(chalk50.green(`✓ Reloaded ${servers.length} servers`));
15378
15816
  if (connected > 0) {
15379
- output.log(chalk49.green(` • ${connected} connected`));
15817
+ output.log(chalk50.green(` • ${connected} connected`));
15380
15818
  }
15381
15819
  if (errors > 0) {
15382
15820
  output.warn(` • ${errors} failed`);
15383
15821
  for (const server of servers.filter((s) => s.status === "error")) {
15384
- output.log(chalk49.gray(` - ${server.name}: ${server.error}`));
15822
+ output.log(chalk50.gray(` - ${server.name}: ${server.error}`));
15385
15823
  }
15386
15824
  }
15387
15825
  } catch (error) {
@@ -15402,7 +15840,7 @@ var McpCommand = {
15402
15840
  };
15403
15841
 
15404
15842
  // src/commands/tools/list.ts
15405
- import chalk50 from "chalk";
15843
+ import chalk51 from "chalk";
15406
15844
  var ListCommand7 = {
15407
15845
  command: "list",
15408
15846
  aliases: ["ls"],
@@ -15447,16 +15885,16 @@ var ListCommand7 = {
15447
15885
  tools.forEach((t) => output.log(t.name));
15448
15886
  } else {
15449
15887
  const header = [
15450
- chalk50.bold("Name"),
15451
- chalk50.bold("Description"),
15452
- chalk50.bold("Category")
15888
+ chalk51.bold("Name"),
15889
+ chalk51.bold("Description"),
15890
+ chalk51.bold("Category")
15453
15891
  ].join(" | ");
15454
15892
  const rows = tools.map((t) => {
15455
15893
  const desc2 = t.description.length > 40 ? t.description.slice(0, 37) + "..." : t.description;
15456
15894
  return [
15457
- chalk50.cyan(t.name),
15895
+ chalk51.cyan(t.name),
15458
15896
  desc2,
15459
- t.metadata?.category ? chalk50.gray(`[${t.metadata.category}]`) : "-"
15897
+ t.metadata?.category ? chalk51.gray(`[${t.metadata.category}]`) : "-"
15460
15898
  ].join(" | ");
15461
15899
  });
15462
15900
  output.log([
@@ -15466,7 +15904,7 @@ var ListCommand7 = {
15466
15904
  ...rows.map((r) => `│${r}│`),
15467
15905
  "└" + "─".repeat(header.length + 2) + "┘",
15468
15906
  "",
15469
- chalk50.gray(`Total: ${tools.length} tools`)
15907
+ chalk51.gray(`Total: ${tools.length} tools`)
15470
15908
  ].join(`
15471
15909
  `));
15472
15910
  }
@@ -15480,7 +15918,7 @@ var ListCommand7 = {
15480
15918
  };
15481
15919
 
15482
15920
  // src/commands/tools/get.ts
15483
- import chalk51 from "chalk";
15921
+ import chalk52 from "chalk";
15484
15922
 
15485
15923
  // src/commands/tools/shared/schema-helper.ts
15486
15924
  import { zodToJsonSchema } from "zod-to-json-schema";
@@ -15555,8 +15993,8 @@ var GetCommand6 = {
15555
15993
  }))
15556
15994
  });
15557
15995
  } else {
15558
- output.log(chalk51.bold.cyan(`Tool: ${tool.name}`));
15559
- output.log(chalk51.gray("─".repeat(60)));
15996
+ output.log(chalk52.bold.cyan(`Tool: ${tool.name}`));
15997
+ output.log(chalk52.gray("─".repeat(60)));
15560
15998
  output.log(`Description: ${tool.description}`);
15561
15999
  if (tool.metadata?.category) {
15562
16000
  output.log(`Category: ${tool.metadata.category}`);
@@ -15565,9 +16003,9 @@ var GetCommand6 = {
15565
16003
  output.log(`Tags: ${tool.metadata.tags.join(", ")}`);
15566
16004
  }
15567
16005
  output.log("");
15568
- output.log(chalk51.bold("Parameters:"));
16006
+ output.log(chalk52.bold("Parameters:"));
15569
16007
  for (const param of params) {
15570
- const required = param.required ? chalk51.red("(required)") : chalk51.gray("(optional)");
16008
+ const required = param.required ? chalk52.red("(required)") : chalk52.gray("(optional)");
15571
16009
  const defaultVal = param.default !== undefined ? ` [default: ${JSON.stringify(param.default)}]` : "";
15572
16010
  output.log(` --${param.name} <${param.type}> ${required}`);
15573
16011
  output.log(` ${param.description}${defaultVal}`);
@@ -15676,14 +16114,14 @@ var ToolsCommand2 = {
15676
16114
  };
15677
16115
 
15678
16116
  // src/commands/memory/record.ts
15679
- import chalk52 from "chalk";
16117
+ import chalk53 from "chalk";
15680
16118
  import { createMemoryAgentTools, getBuiltInPrompt } from "@ai-setting/roy-agent-core";
15681
16119
  import { bashTool, globTool, readFileTool } from "@ai-setting/roy-agent-core";
15682
16120
  async function runExtractMode(output, memoryComponent, agentComponent, sessionComponent, env, options) {
15683
16121
  const { scope, sessionId, require: userRequirement } = options;
15684
- output.log(chalk52.blue(`
16122
+ output.log(chalk53.blue(`
15685
16123
  \uD83D\uDD0D Memory Extract Mode (${scope})`));
15686
- output.log(chalk52.gray(`正在分析会话历史,生成记忆...
16124
+ output.log(chalk53.gray(`正在分析会话历史,生成记忆...
15687
16125
  `));
15688
16126
  try {
15689
16127
  const currentMemory = await memoryComponent.recallMemory(scope) || "(无现有记忆)";
@@ -15729,13 +16167,13 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
15729
16167
  for (const tool of agentTools) {
15730
16168
  try {
15731
16169
  toolComponent.register(tool);
15732
- output.log(chalk52.gray(`Tool registered: ${tool.name}`));
16170
+ output.log(chalk53.gray(`Tool registered: ${tool.name}`));
15733
16171
  } catch (err) {
15734
- output.log(chalk52.gray(`Tool already registered: ${tool.name}`));
16172
+ output.log(chalk53.gray(`Tool already registered: ${tool.name}`));
15735
16173
  }
15736
16174
  }
15737
16175
  }
15738
- output.log(chalk52.gray(`Agent "${agentName}" registered with ${agentTools.length} tools`));
16176
+ output.log(chalk53.gray(`Agent "${agentName}" registered with ${agentTools.length} tools`));
15739
16177
  const query = `请分析会话历史,提炼${scope === "project" ? "项目" : "全局"}记忆并写入记忆文件。`;
15740
16178
  let result;
15741
16179
  try {
@@ -15749,12 +16187,12 @@ async function runExtractMode(output, memoryComponent, agentComponent, sessionCo
15749
16187
  if (result && result.startsWith("执行失败")) {
15750
16188
  output.error(`提取失败: ${result}`);
15751
16189
  } else if (result) {
15752
- output.log(chalk52.green(`
16190
+ output.log(chalk53.green(`
15753
16191
  ✅ 记忆提取完成`));
15754
- output.log(chalk52.gray(`记忆已保存到 memory 文件。
16192
+ output.log(chalk53.gray(`记忆已保存到 memory 文件。
15755
16193
  `));
15756
16194
  if (result.length > 0 && result !== "✅ 记忆提取完成") {
15757
- output.log(chalk52.gray(`执行摘要: ${result.substring(0, 200)}${result.length > 200 ? "..." : ""}`));
16195
+ output.log(chalk53.gray(`执行摘要: ${result.substring(0, 200)}${result.length > 200 ? "..." : ""}`));
15758
16196
  }
15759
16197
  }
15760
16198
  agentComponent.unregisterAgent(agentName);
@@ -15872,11 +16310,11 @@ var RecordCommand = {
15872
16310
  prepend: "已插入内容到记忆文件开头",
15873
16311
  delete: "已删除记忆文件"
15874
16312
  };
15875
- output.log(chalk52.green(`✓ ${actionMessages[result.action]}`));
15876
- output.log(chalk52.gray(`路径: ${result.path}`));
16313
+ output.log(chalk53.green(`✓ ${actionMessages[result.action]}`));
16314
+ output.log(chalk53.gray(`路径: ${result.path}`));
15877
16315
  if (result.action !== "delete" && a.content) {
15878
16316
  const preview = a.content.substring(0, 100);
15879
- output.log(chalk52.gray(`内容预览: ${preview}${a.content.length > 100 ? "..." : ""}`));
16317
+ output.log(chalk53.gray(`内容预览: ${preview}${a.content.length > 100 ? "..." : ""}`));
15880
16318
  }
15881
16319
  } catch (error) {
15882
16320
  output.error(`Failed to record memory: ${error}`);
@@ -15888,7 +16326,7 @@ var RecordCommand = {
15888
16326
  };
15889
16327
 
15890
16328
  // src/commands/memory/recall.ts
15891
- import chalk53 from "chalk";
16329
+ import chalk54 from "chalk";
15892
16330
  var RecallCommand = {
15893
16331
  command: "recall",
15894
16332
  aliases: ["load"],
@@ -15924,7 +16362,7 @@ var RecallCommand = {
15924
16362
  }
15925
16363
  const content = await memoryComponent.recallMemory(a.scope);
15926
16364
  if (!content) {
15927
- output.log(chalk53.gray("(No memory files found)"));
16365
+ output.log(chalk54.gray("(No memory files found)"));
15928
16366
  return;
15929
16367
  }
15930
16368
  if (a.json) {
@@ -15950,7 +16388,7 @@ var MemoryCommand = {
15950
16388
  handler: () => {}
15951
16389
  };
15952
16390
  // src/commands/eventsource/list.ts
15953
- import chalk54 from "chalk";
16391
+ import chalk55 from "chalk";
15954
16392
  function truncateVisual2(str, maxWidth) {
15955
16393
  let result = "";
15956
16394
  let width = 0;
@@ -15965,7 +16403,7 @@ function truncateVisual2(str, maxWidth) {
15965
16403
  }
15966
16404
  function formatSourcesTable(sources) {
15967
16405
  if (sources.length === 0) {
15968
- return chalk54.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加");
16406
+ return chalk55.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加");
15969
16407
  }
15970
16408
  const ID_WIDTH = 10;
15971
16409
  const NAME_WIDTH = 20;
@@ -15974,11 +16412,11 @@ function formatSourcesTable(sources) {
15974
16412
  const ENABLED_WIDTH = 8;
15975
16413
  const GAP = " ";
15976
16414
  const headerLine = [
15977
- chalk54.bold("ID".padEnd(ID_WIDTH)),
15978
- chalk54.bold("NAME".padEnd(NAME_WIDTH)),
15979
- chalk54.bold("TYPE".padEnd(TYPE_WIDTH)),
15980
- chalk54.bold("STATUS".padEnd(STATUS_WIDTH)),
15981
- chalk54.bold("ENABLED".padEnd(ENABLED_WIDTH))
16415
+ chalk55.bold("ID".padEnd(ID_WIDTH)),
16416
+ chalk55.bold("NAME".padEnd(NAME_WIDTH)),
16417
+ chalk55.bold("TYPE".padEnd(TYPE_WIDTH)),
16418
+ chalk55.bold("STATUS".padEnd(STATUS_WIDTH)),
16419
+ chalk55.bold("ENABLED".padEnd(ENABLED_WIDTH))
15982
16420
  ].join(GAP);
15983
16421
  const sepLine = "─".repeat(ID_WIDTH + NAME_WIDTH + TYPE_WIDTH + STATUS_WIDTH + ENABLED_WIDTH + GAP.length * 4);
15984
16422
  const formatRow = (src) => {
@@ -16031,7 +16469,7 @@ var EventSourceListCommand = {
16031
16469
  if (args.json) {
16032
16470
  output.json({ sources: [], count: 0 });
16033
16471
  } else {
16034
- output.log(chalk54.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加"));
16472
+ output.log(chalk55.yellow("没有配置的事件源,使用 'roy-agent eventsource add' 添加"));
16035
16473
  }
16036
16474
  return;
16037
16475
  }
@@ -16046,26 +16484,26 @@ var EventSourceListCommand = {
16046
16484
  const rows = sources.map((s) => {
16047
16485
  const status = esComponent.getStatus(s.id) || "unknown";
16048
16486
  const statusColorMap = {
16049
- running: chalk54.green,
16050
- stopped: chalk54.gray,
16051
- error: chalk54.red,
16052
- starting: chalk54.yellow,
16053
- created: chalk54.gray,
16054
- stopping: chalk54.yellow,
16055
- unknown: chalk54.gray
16487
+ running: chalk55.green,
16488
+ stopped: chalk55.gray,
16489
+ error: chalk55.red,
16490
+ starting: chalk55.yellow,
16491
+ created: chalk55.gray,
16492
+ stopping: chalk55.yellow,
16493
+ unknown: chalk55.gray
16056
16494
  };
16057
- const statusColor = statusColorMap[status] || chalk54.gray;
16495
+ const statusColor = statusColorMap[status] || chalk55.gray;
16058
16496
  return {
16059
16497
  id: s.id.substring(0, 8),
16060
16498
  name: s.name,
16061
16499
  type: s.type,
16062
16500
  status: statusColor(status),
16063
- enabled: s.enabled ? chalk54.green("✓") : chalk54.gray("✗")
16501
+ enabled: s.enabled ? chalk55.green("✓") : chalk55.gray("✗")
16064
16502
  };
16065
16503
  });
16066
16504
  output.log(formatSourcesTable(rows));
16067
16505
  output.info("");
16068
- output.log(chalk54.green(`✅ 共 ${sources.length} 个事件源`));
16506
+ output.log(chalk55.green(`✅ 共 ${sources.length} 个事件源`));
16069
16507
  } catch (error) {
16070
16508
  output.error(`Failed to list event sources: ${error}`);
16071
16509
  process.exit(1);
@@ -16076,7 +16514,7 @@ var EventSourceListCommand = {
16076
16514
  };
16077
16515
 
16078
16516
  // src/commands/eventsource/add.ts
16079
- import chalk55 from "chalk";
16517
+ import chalk56 from "chalk";
16080
16518
  import { generateId } from "@ai-setting/roy-agent-core";
16081
16519
  function uuid() {
16082
16520
  return generateId();
@@ -16111,6 +16549,19 @@ var EventSourceAddCommand = {
16111
16549
  }).option("cron", {
16112
16550
  describe: "Cron 表达式",
16113
16551
  type: "string"
16552
+ }).option("profile", {
16553
+ describe: "lark-cli profile(lark-cli 类型用,多 appId 场景必要,参考 #1637)",
16554
+ type: "string"
16555
+ }).option("address", {
16556
+ describe: "Agent IM 地址(bounty-im 类型用,格式:agent-id@host)",
16557
+ type: "string"
16558
+ }).option("im-server-url", {
16559
+ describe: "IM Server WebSocket URL(bounty-im 类型用,如 ws://localhost:4005/ws)",
16560
+ type: "string"
16561
+ }).option("tls-skip-verify", {
16562
+ describe: "跳过 TLS 证书校验(bounty-im 类型用,wss:// 自签名场景,生产环境不推荐)",
16563
+ type: "boolean",
16564
+ default: false
16114
16565
  }).option("prompt", {
16115
16566
  describe: "自定义 prompt 消息(timer 类型,替换默认 SelfReminder 内容)",
16116
16567
  type: "string"
@@ -16142,27 +16593,43 @@ var EventSourceAddCommand = {
16142
16593
  url: a.url,
16143
16594
  interval: a.interval,
16144
16595
  cron: a.cron,
16596
+ profile: a.profile,
16597
+ address: a.address,
16598
+ imServerUrl: a.imServerUrl,
16599
+ tlsSkipVerify: a.tlsSkipVerify === true,
16145
16600
  options: a.prompt ? { prompt: a.prompt } : undefined
16146
16601
  };
16147
16602
  esComponent.register(config);
16148
- output.success(chalk55.green(`事件源 '${a.name}' 添加成功!`));
16603
+ output.success(chalk56.green(`事件源 '${a.name}' 添加成功!`));
16149
16604
  output.log("");
16150
- output.log(` ID: ${chalk55.gray(config.id)}`);
16151
- output.log(` Type: ${chalk55.cyan(a.type)}`);
16605
+ output.log(` ID: ${chalk56.gray(config.id)}`);
16606
+ output.log(` Type: ${chalk56.cyan(a.type)}`);
16152
16607
  if (eventTypes?.length) {
16153
- output.log(` Event Types: ${chalk55.gray(eventTypes.join(", "))}`);
16608
+ output.log(` Event Types: ${chalk56.gray(eventTypes.join(", "))}`);
16154
16609
  }
16155
16610
  if (a.command) {
16156
- output.log(` Command: ${chalk55.gray(a.command)}`);
16611
+ output.log(` Command: ${chalk56.gray(a.command)}`);
16157
16612
  }
16158
16613
  if (a.interval) {
16159
- output.log(` Interval: ${chalk55.gray(`${a.interval}ms`)}`);
16614
+ output.log(` Interval: ${chalk56.gray(`${a.interval}ms`)}`);
16615
+ }
16616
+ if (a.profile) {
16617
+ output.log(` Profile: ${chalk56.gray(a.profile)}`);
16618
+ }
16619
+ if (a.address) {
16620
+ output.log(` Address: ${chalk56.gray(a.address)}`);
16621
+ }
16622
+ if (a.imServerUrl) {
16623
+ output.log(` IM Server URL: ${chalk56.gray(a.imServerUrl)}`);
16624
+ }
16625
+ if (a.tlsSkipVerify) {
16626
+ output.log(` TLS Skip Verify: ${chalk56.yellow("⚠ true (自签名场景)")}`);
16160
16627
  }
16161
16628
  if (a.prompt) {
16162
- output.log(` Prompt: ${chalk55.gray(a.prompt.length > 60 ? a.prompt.slice(0, 60) + "..." : a.prompt)}`);
16629
+ output.log(` Prompt: ${chalk56.gray(a.prompt.length > 60 ? a.prompt.slice(0, 60) + "..." : a.prompt)}`);
16163
16630
  }
16164
16631
  output.log("");
16165
- output.log(chalk55.gray(`使用 'roy-agent eventsource start ${config.id.substring(0, 8)}' 启动它。`));
16632
+ output.log(chalk56.gray(`使用 'roy-agent eventsource start ${config.id.substring(0, 8)}' 启动它。`));
16166
16633
  } finally {
16167
16634
  await envService.dispose();
16168
16635
  }
@@ -16170,7 +16637,7 @@ var EventSourceAddCommand = {
16170
16637
  };
16171
16638
 
16172
16639
  // src/commands/eventsource/update.ts
16173
- import chalk56 from "chalk";
16640
+ import chalk57 from "chalk";
16174
16641
  function findSource(esComponent, id) {
16175
16642
  const sources = esComponent.list();
16176
16643
  const matched = sources.find((s) => s.id === id || s.id.startsWith(id));
@@ -16213,6 +16680,15 @@ var EventSourceUpdateCommand = {
16213
16680
  }).option("enabled", {
16214
16681
  describe: "是否启用",
16215
16682
  type: "boolean"
16683
+ }).option("address", {
16684
+ describe: "Agent IM 地址(bounty-im 类型用,格式:agent-id@host)",
16685
+ type: "string"
16686
+ }).option("im-server-url", {
16687
+ describe: "IM Server WebSocket URL(bounty-im 类型用,如 ws://localhost:4005/ws)",
16688
+ type: "string"
16689
+ }).option("tls-skip-verify", {
16690
+ describe: "跳过 TLS 证书校验(bounty-im 类型用,wss:// 自签名场景,生产环境不推荐)",
16691
+ type: "boolean"
16216
16692
  }),
16217
16693
  async handler(args) {
16218
16694
  const a = args;
@@ -16236,7 +16712,7 @@ var EventSourceUpdateCommand = {
16236
16712
  const all = esComponent.list();
16237
16713
  if (all.length > 0) {
16238
16714
  output.info("");
16239
- output.info(chalk56.gray("可用的事件源:"));
16715
+ output.info(chalk57.gray("可用的事件源:"));
16240
16716
  for (const s of all) {
16241
16717
  output.info(` - ${s.id.substring(0, 8)}: ${s.name} (${s.type})`);
16242
16718
  }
@@ -16259,6 +16735,12 @@ var EventSourceUpdateCommand = {
16259
16735
  partial.cron = a.cron;
16260
16736
  if (a.enabled !== undefined)
16261
16737
  partial.enabled = a.enabled;
16738
+ if (a.address !== undefined)
16739
+ partial.address = a.address;
16740
+ if (a.imServerUrl !== undefined)
16741
+ partial.imServerUrl = a.imServerUrl;
16742
+ if (a.tlsSkipVerify !== undefined)
16743
+ partial.tlsSkipVerify = a.tlsSkipVerify === true;
16262
16744
  if (a.prompt !== undefined) {
16263
16745
  const existingOptions = match.source.options ?? {};
16264
16746
  partial.options = { ...existingOptions, prompt: a.prompt };
@@ -16269,19 +16751,19 @@ var EventSourceUpdateCommand = {
16269
16751
  }
16270
16752
  try {
16271
16753
  const result = await esComponent.update(match.fullId, partial);
16272
- output.success(chalk56.green(`✅ 事件源已更新: ${match.source.name}`));
16754
+ output.success(chalk57.green(`✅ 事件源已更新: ${match.source.name}`));
16273
16755
  output.log("");
16274
- output.log(chalk56.bold("修改字段:"));
16756
+ output.log(chalk57.bold("修改字段:"));
16275
16757
  const before = match.source;
16276
16758
  const after = result.updated;
16277
16759
  for (const field of result.fields) {
16278
16760
  const beforeVal = JSON.stringify(before[field] ?? before.options?.[field]);
16279
16761
  const afterVal = JSON.stringify(after[field] ?? after.options?.[field]);
16280
- output.log(` ${chalk56.cyan(field)}: ${chalk56.gray(beforeVal)} ${chalk56.gray("→")} ${chalk56.green(afterVal)}`);
16762
+ output.log(` ${chalk57.cyan(field)}: ${chalk57.gray(beforeVal)} ${chalk57.gray("→")} ${chalk57.green(afterVal)}`);
16281
16763
  }
16282
16764
  output.log("");
16283
16765
  if (result.wasRunning) {
16284
- output.info(chalk56.yellow(`⚠️ 事件源在更新前正在运行,已自动停止。请使用 'roy-agent eventsource start ${match.fullId.substring(0, 8)}' 手动启动以应用新配置。`));
16766
+ output.info(chalk57.yellow(`⚠️ 事件源在更新前正在运行,已自动停止。请使用 'roy-agent eventsource start ${match.fullId.substring(0, 8)}' 手动启动以应用新配置。`));
16285
16767
  }
16286
16768
  } catch (error) {
16287
16769
  output.error(`❌ 更新失败: ${error instanceof Error ? error.message : String(error)}`);
@@ -16294,7 +16776,7 @@ var EventSourceUpdateCommand = {
16294
16776
  };
16295
16777
 
16296
16778
  // src/commands/eventsource/remove.ts
16297
- import chalk57 from "chalk";
16779
+ import chalk58 from "chalk";
16298
16780
  var EventSourceRemoveCommand = {
16299
16781
  command: "remove <id>",
16300
16782
  aliases: ["rm"],
@@ -16333,7 +16815,7 @@ var EventSourceRemoveCommand = {
16333
16815
  const status = esComponent.getStatus(matchedSource.id);
16334
16816
  if (status === "running" && !args.force) {
16335
16817
  output.error(`事件源正在运行中,请先停止: ${matchedSource.name} (${status})`);
16336
- output.log(chalk57.gray(`使用 --force 强制移除或 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' 先停止`));
16818
+ output.log(chalk58.gray(`使用 --force 强制移除或 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' 先停止`));
16337
16819
  process.exit(1);
16338
16820
  }
16339
16821
  if (status === "running") {
@@ -16342,7 +16824,7 @@ var EventSourceRemoveCommand = {
16342
16824
  }
16343
16825
  const result = esComponent.unregister(matchedSource.id);
16344
16826
  if (result) {
16345
- output.success(chalk57.green(`事件源已移除: ${matchedSource.name}`));
16827
+ output.success(chalk58.green(`事件源已移除: ${matchedSource.name}`));
16346
16828
  } else {
16347
16829
  output.error("移除失败");
16348
16830
  process.exit(1);
@@ -16354,7 +16836,7 @@ var EventSourceRemoveCommand = {
16354
16836
  };
16355
16837
 
16356
16838
  // src/commands/eventsource/start.ts
16357
- import chalk58 from "chalk";
16839
+ import chalk59 from "chalk";
16358
16840
  var EventSourceStartCommand = {
16359
16841
  command: "start <id>",
16360
16842
  describe: "启动指定的事件源",
@@ -16391,15 +16873,15 @@ var EventSourceStartCommand = {
16391
16873
  }
16392
16874
  const status = esComponent.getStatus(matchedSource.id);
16393
16875
  if (status === "running") {
16394
- output.log(chalk58.yellow(`事件源已在运行: ${matchedSource.name}`));
16876
+ output.log(chalk59.yellow(`事件源已在运行: ${matchedSource.name}`));
16395
16877
  return;
16396
16878
  }
16397
16879
  output.info(`正在启动事件源 '${matchedSource.name}'...`);
16398
16880
  try {
16399
16881
  await esComponent.startSource(matchedSource.id);
16400
- output.success(chalk58.green(`事件源已启动: ${matchedSource.name}`));
16882
+ output.success(chalk59.green(`事件源已启动: ${matchedSource.name}`));
16401
16883
  if (!args.background) {
16402
- output.log(chalk58.gray("按 Ctrl+C 停止..."));
16884
+ output.log(chalk59.gray("按 Ctrl+C 停止..."));
16403
16885
  await new Promise((resolve) => {
16404
16886
  const cleanup = () => {
16405
16887
  process.removeListener("SIGINT", cleanup);
@@ -16421,7 +16903,7 @@ var EventSourceStartCommand = {
16421
16903
  };
16422
16904
 
16423
16905
  // src/commands/eventsource/stop.ts
16424
- import chalk59 from "chalk";
16906
+ import chalk60 from "chalk";
16425
16907
  var EventSourceStopCommand = {
16426
16908
  command: "stop <id>",
16427
16909
  aliases: ["kill"],
@@ -16459,13 +16941,13 @@ var EventSourceStopCommand = {
16459
16941
  }
16460
16942
  const status = esComponent.getStatus(matchedSource.id);
16461
16943
  if (status !== "running") {
16462
- output.log(chalk59.yellow(`事件源未运行: ${matchedSource.name} (${status || "unknown"})`));
16944
+ output.log(chalk60.yellow(`事件源未运行: ${matchedSource.name} (${status || "unknown"})`));
16463
16945
  return;
16464
16946
  }
16465
16947
  output.info(`正在停止事件源 '${matchedSource.name}'...`);
16466
16948
  try {
16467
16949
  await esComponent.stopSource(matchedSource.id);
16468
- output.success(chalk59.green(`事件源已停止: ${matchedSource.name}`));
16950
+ output.success(chalk60.green(`事件源已停止: ${matchedSource.name}`));
16469
16951
  } catch (error) {
16470
16952
  output.error(`停止失败: ${error}`);
16471
16953
  process.exit(1);
@@ -16477,14 +16959,14 @@ var EventSourceStopCommand = {
16477
16959
  };
16478
16960
 
16479
16961
  // src/commands/eventsource/status.ts
16480
- import chalk60 from "chalk";
16962
+ import chalk61 from "chalk";
16481
16963
  var STATUS_COLORS = {
16482
- created: chalk60.gray,
16483
- starting: chalk60.yellow,
16484
- running: chalk60.green,
16485
- stopping: chalk60.yellow,
16486
- stopped: chalk60.gray,
16487
- error: chalk60.red
16964
+ created: chalk61.gray,
16965
+ starting: chalk61.yellow,
16966
+ running: chalk61.green,
16967
+ stopping: chalk61.yellow,
16968
+ stopped: chalk61.gray,
16969
+ error: chalk61.red
16488
16970
  };
16489
16971
  var STATUS_ICONS = {
16490
16972
  created: "○",
@@ -16538,7 +17020,7 @@ var EventSourceStatusCommand = {
16538
17020
  process.exit(1);
16539
17021
  }
16540
17022
  const status = esComponent.getStatus(matchedSource.id) || "unknown";
16541
- const statusColor = STATUS_COLORS[status] || chalk60.gray;
17023
+ const statusColor = STATUS_COLORS[status] || chalk61.gray;
16542
17024
  if (args.json) {
16543
17025
  output.json({
16544
17026
  id: matchedSource.id,
@@ -16555,31 +17037,31 @@ var EventSourceStatusCommand = {
16555
17037
  });
16556
17038
  return;
16557
17039
  }
16558
- output.log(chalk60.bold("事件源详情"));
17040
+ output.log(chalk61.bold("事件源详情"));
16559
17041
  output.log("─".repeat(50));
16560
- output.log(` ID: ${chalk60.gray(matchedSource.id)}`);
16561
- output.log(` Name: ${chalk60.cyan(matchedSource.name)}`);
16562
- output.log(` Type: ${chalk60.cyan(matchedSource.type)}`);
17042
+ output.log(` ID: ${chalk61.gray(matchedSource.id)}`);
17043
+ output.log(` Name: ${chalk61.cyan(matchedSource.name)}`);
17044
+ output.log(` Type: ${chalk61.cyan(matchedSource.type)}`);
16563
17045
  output.log(` Status: ${statusColor(`${STATUS_ICONS[status]} ${STATUS_LABELS[status]}`)}`);
16564
- output.log(` Enabled: ${matchedSource.enabled ? chalk60.green("是") : chalk60.gray("否")}`);
17046
+ output.log(` Enabled: ${matchedSource.enabled ? chalk61.green("是") : chalk61.gray("否")}`);
16565
17047
  if (matchedSource.eventTypes?.length) {
16566
- output.log(` Events: ${chalk60.gray(matchedSource.eventTypes.join(", "))}`);
17048
+ output.log(` Events: ${chalk61.gray(matchedSource.eventTypes.join(", "))}`);
16567
17049
  }
16568
17050
  if (matchedSource.command) {
16569
- output.log(` Command: ${chalk60.gray(matchedSource.command)}`);
17051
+ output.log(` Command: ${chalk61.gray(matchedSource.command)}`);
16570
17052
  }
16571
17053
  if (matchedSource.interval) {
16572
- output.log(` Interval: ${chalk60.gray(`${matchedSource.interval}ms`)}`);
17054
+ output.log(` Interval: ${chalk61.gray(`${matchedSource.interval}ms`)}`);
16573
17055
  }
16574
17056
  if (matchedSource.url) {
16575
- output.log(` URL: ${chalk60.gray(matchedSource.url)}`);
17057
+ output.log(` URL: ${chalk61.gray(matchedSource.url)}`);
16576
17058
  }
16577
17059
  output.log("");
16578
17060
  return;
16579
17061
  }
16580
17062
  const sources = esComponent.list();
16581
17063
  if (sources.length === 0) {
16582
- output.log(chalk60.yellow("没有配置的事件源"));
17064
+ output.log(chalk61.yellow("没有配置的事件源"));
16583
17065
  return;
16584
17066
  }
16585
17067
  if (args.json) {
@@ -16593,21 +17075,21 @@ var EventSourceStatusCommand = {
16593
17075
  output.json({ sources: sourcesWithStatus, count: sources.length });
16594
17076
  return;
16595
17077
  }
16596
- output.log(chalk60.bold("事件源状态概览"));
17078
+ output.log(chalk61.bold("事件源状态概览"));
16597
17079
  output.log("─".repeat(60));
16598
17080
  for (const source of sources) {
16599
17081
  const status = esComponent.getStatus(source.id) || "unknown";
16600
- const statusColor = STATUS_COLORS[status] || chalk60.gray;
17082
+ const statusColor = STATUS_COLORS[status] || chalk61.gray;
16601
17083
  const icon = STATUS_ICONS[status] || "?";
16602
17084
  const label = STATUS_LABELS[status] || status;
16603
17085
  output.log("");
16604
- output.log(` ${chalk60.cyan(source.name)} ${chalk60.gray(`(${source.type})`)}`);
17086
+ output.log(` ${chalk61.cyan(source.name)} ${chalk61.gray(`(${source.type})`)}`);
16605
17087
  output.log(` └─ Status: ${statusColor(`${icon} ${label}`)}`);
16606
- output.log(` ID: ${chalk60.gray(source.id.substring(0, 8))}...`);
17088
+ output.log(` ID: ${chalk61.gray(source.id.substring(0, 8))}...`);
16607
17089
  }
16608
17090
  output.log("");
16609
17091
  const runningCount = sources.filter((s) => esComponent.getStatus(s.id) === "running").length;
16610
- output.log(chalk60.green(`✅ ${runningCount}/${sources.length} 运行中`));
17092
+ output.log(chalk61.green(`✅ ${runningCount}/${sources.length} 运行中`));
16611
17093
  } finally {
16612
17094
  await envService.dispose();
16613
17095
  }
@@ -16920,7 +17402,7 @@ var DebugCommand = {
16920
17402
  };
16921
17403
 
16922
17404
  // src/commands/workflow/renderers.ts
16923
- import chalk61 from "chalk";
17405
+ import chalk62 from "chalk";
16924
17406
  function truncateVisual3(str, maxWidth) {
16925
17407
  if (!str)
16926
17408
  return "-";
@@ -16955,18 +17437,18 @@ function formatDuration(ms) {
16955
17437
  function statusColor(status) {
16956
17438
  switch (status) {
16957
17439
  case "completed":
16958
- return chalk61.green;
17440
+ return chalk62.green;
16959
17441
  case "running":
16960
17442
  case "idle":
16961
- return chalk61.blue;
17443
+ return chalk62.blue;
16962
17444
  case "paused":
16963
- return chalk61.yellow;
17445
+ return chalk62.yellow;
16964
17446
  case "failed":
16965
- return chalk61.red;
17447
+ return chalk62.red;
16966
17448
  case "stopped":
16967
- return chalk61.gray;
17449
+ return chalk62.gray;
16968
17450
  default:
16969
- return chalk61.white;
17451
+ return chalk62.white;
16970
17452
  }
16971
17453
  }
16972
17454
  function renderWorkflowList(workflows, options) {
@@ -16985,7 +17467,7 @@ function renderWorkflowList(workflows, options) {
16985
17467
  }, null, 2);
16986
17468
  }
16987
17469
  if (workflows.length === 0) {
16988
- return chalk61.yellow("No workflows found");
17470
+ return chalk62.yellow("No workflows found");
16989
17471
  }
16990
17472
  const NAME_WIDTH = 30;
16991
17473
  const VERSION_WIDTH = 10;
@@ -16993,10 +17475,10 @@ function renderWorkflowList(workflows, options) {
16993
17475
  const UPDATED_WIDTH = 20;
16994
17476
  const GAP = " ";
16995
17477
  const headerLine = [
16996
- chalk61.bold("NAME".padEnd(NAME_WIDTH)),
16997
- chalk61.bold("VER".padEnd(VERSION_WIDTH)),
16998
- chalk61.bold("TAGS".padEnd(TAGS_WIDTH)),
16999
- chalk61.bold("UPDATED")
17478
+ chalk62.bold("NAME".padEnd(NAME_WIDTH)),
17479
+ chalk62.bold("VER".padEnd(VERSION_WIDTH)),
17480
+ chalk62.bold("TAGS".padEnd(TAGS_WIDTH)),
17481
+ chalk62.bold("UPDATED")
17000
17482
  ].join(GAP);
17001
17483
  const sepLine = "─".repeat(NAME_WIDTH + VERSION_WIDTH + TAGS_WIDTH + UPDATED_WIDTH + GAP.length * 3);
17002
17484
  const rows = workflows.map((w) => {
@@ -17011,18 +17493,18 @@ function renderWorkflowList(workflows, options) {
17011
17493
  }
17012
17494
  function renderWorkflowDetail(workflow, options) {
17013
17495
  const lines = [];
17014
- lines.push(chalk61.bold(`
17496
+ lines.push(chalk62.bold(`
17015
17497
  \uD83D\uDCCB Workflow Details
17016
17498
  `));
17017
- lines.push(` ${chalk61.cyan("ID:")} ${workflow.id}`);
17018
- lines.push(` ${chalk61.cyan("Name:")} ${workflow.name}`);
17019
- lines.push(` ${chalk61.cyan("Version:")} ${workflow.version}`);
17020
- lines.push(` ${chalk61.cyan("Description:")} ${workflow.description || "-"}`);
17021
- lines.push(` ${chalk61.cyan("Tags:")} ${workflow.tags.join(", ") || "-"}`);
17022
- lines.push(` ${chalk61.cyan("Created:")} ${formatDate(workflow.createdAt)}`);
17023
- lines.push(` ${chalk61.cyan("Updated:")} ${formatDate(workflow.updatedAt)}`);
17499
+ lines.push(` ${chalk62.cyan("ID:")} ${workflow.id}`);
17500
+ lines.push(` ${chalk62.cyan("Name:")} ${workflow.name}`);
17501
+ lines.push(` ${chalk62.cyan("Version:")} ${workflow.version}`);
17502
+ lines.push(` ${chalk62.cyan("Description:")} ${workflow.description || "-"}`);
17503
+ lines.push(` ${chalk62.cyan("Tags:")} ${workflow.tags.join(", ") || "-"}`);
17504
+ lines.push(` ${chalk62.cyan("Created:")} ${formatDate(workflow.createdAt)}`);
17505
+ lines.push(` ${chalk62.cyan("Updated:")} ${formatDate(workflow.updatedAt)}`);
17024
17506
  const nodeCount = workflow.definition.nodes.length;
17025
- lines.push(chalk61.bold(`
17507
+ lines.push(chalk62.bold(`
17026
17508
  \uD83D\uDCCA Nodes Summary
17027
17509
  `));
17028
17510
  lines.push(` Total: ${nodeCount} nodes`);
@@ -17034,7 +17516,7 @@ function renderWorkflowDetail(workflow, options) {
17034
17516
  lines.push(` - ${type}: ${count}`);
17035
17517
  }
17036
17518
  if (workflow.definition.config) {
17037
- lines.push(chalk61.bold(`
17519
+ lines.push(chalk62.bold(`
17038
17520
  ⚙️ Configuration
17039
17521
  `));
17040
17522
  if (workflow.definition.config.parallel_limit !== undefined) {
@@ -17048,7 +17530,7 @@ function renderWorkflowDetail(workflow, options) {
17048
17530
  }
17049
17531
  }
17050
17532
  if (options?.includeRuns && options.includeRuns.length > 0) {
17051
- lines.push(chalk61.bold(`
17533
+ lines.push(chalk62.bold(`
17052
17534
  \uD83D\uDCDC Recent Runs
17053
17535
  `));
17054
17536
  lines.push(renderRunsList(options.includeRuns.slice(0, 5)));
@@ -17072,7 +17554,7 @@ function renderRunsList(runs, options) {
17072
17554
  }, null, 2);
17073
17555
  }
17074
17556
  if (runs.length === 0) {
17075
- return chalk61.yellow("No runs found");
17557
+ return chalk62.yellow("No runs found");
17076
17558
  }
17077
17559
  const ID_WIDTH = 20;
17078
17560
  const STATUS_WIDTH = 12;
@@ -17080,10 +17562,10 @@ function renderRunsList(runs, options) {
17080
17562
  const UPDATED_WIDTH = 20;
17081
17563
  const GAP = " ";
17082
17564
  const headerLine = [
17083
- chalk61.bold("RUN ID".padEnd(ID_WIDTH)),
17084
- chalk61.bold("STATUS".padEnd(STATUS_WIDTH)),
17085
- chalk61.bold("DURATION".padEnd(DURATION_WIDTH)),
17086
- chalk61.bold("STARTED")
17565
+ chalk62.bold("RUN ID".padEnd(ID_WIDTH)),
17566
+ chalk62.bold("STATUS".padEnd(STATUS_WIDTH)),
17567
+ chalk62.bold("DURATION".padEnd(DURATION_WIDTH)),
17568
+ chalk62.bold("STARTED")
17087
17569
  ].join(GAP);
17088
17570
  const sepLine = "─".repeat(ID_WIDTH + STATUS_WIDTH + DURATION_WIDTH + UPDATED_WIDTH + GAP.length * 3);
17089
17571
  const rows = runs.map((r) => {
@@ -17098,34 +17580,34 @@ function renderRunsList(runs, options) {
17098
17580
  }
17099
17581
  function renderRunDetail(run) {
17100
17582
  const lines = [];
17101
- lines.push(chalk61.bold(`
17583
+ lines.push(chalk62.bold(`
17102
17584
  \uD83C\uDFC3 Run Details
17103
17585
  `));
17104
- lines.push(` ${chalk61.cyan("Run ID:")} ${run.id}`);
17105
- lines.push(` ${chalk61.cyan("Workflow:")} ${run.workflowId}`);
17106
- lines.push(` ${chalk61.cyan("Status:")} ${statusColor(run.status)(run.status)}`);
17107
- lines.push(` ${chalk61.cyan("Started:")} ${formatDate(run.startedAt)}`);
17586
+ lines.push(` ${chalk62.cyan("Run ID:")} ${run.id}`);
17587
+ lines.push(` ${chalk62.cyan("Workflow:")} ${run.workflowId}`);
17588
+ lines.push(` ${chalk62.cyan("Status:")} ${statusColor(run.status)(run.status)}`);
17589
+ lines.push(` ${chalk62.cyan("Started:")} ${formatDate(run.startedAt)}`);
17108
17590
  if (run.pausedAt) {
17109
- lines.push(` ${chalk61.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
17591
+ lines.push(` ${chalk62.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
17110
17592
  }
17111
17593
  if (run.resumedAt) {
17112
- lines.push(` ${chalk61.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
17594
+ lines.push(` ${chalk62.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
17113
17595
  }
17114
17596
  if (run.stoppedAt) {
17115
- lines.push(` ${chalk61.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
17597
+ lines.push(` ${chalk62.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
17116
17598
  }
17117
17599
  if (run.completedAt) {
17118
- lines.push(` ${chalk61.cyan("Completed:")} ${formatDate(run.completedAt)}`);
17600
+ lines.push(` ${chalk62.cyan("Completed:")} ${formatDate(run.completedAt)}`);
17119
17601
  }
17120
- lines.push(` ${chalk61.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
17602
+ lines.push(` ${chalk62.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
17121
17603
  if (run.error) {
17122
- lines.push(chalk61.bold(`
17604
+ lines.push(chalk62.bold(`
17123
17605
  ❌ Error
17124
17606
  `));
17125
- lines.push(` ${chalk61.red(run.error)}`);
17607
+ lines.push(` ${chalk62.red(run.error)}`);
17126
17608
  }
17127
17609
  if (run.output) {
17128
- lines.push(chalk61.bold(`
17610
+ lines.push(chalk62.bold(`
17129
17611
  \uD83D\uDCE4 Output
17130
17612
  `));
17131
17613
  lines.push(" " + JSON.stringify(run.output, null, 2).split(`
@@ -17136,36 +17618,36 @@ function renderRunDetail(run) {
17136
17618
  `);
17137
17619
  }
17138
17620
  function renderWorkflowAdded(workflow) {
17139
- return chalk61.green(`
17621
+ return chalk62.green(`
17140
17622
  ✅ Workflow '${workflow.name}' added successfully
17141
17623
  `) + ` ID: ${workflow.id}
17142
17624
  ` + ` Version: ${workflow.version}
17143
17625
  `;
17144
17626
  }
17145
17627
  function renderWorkflowUpdated(workflow) {
17146
- return chalk61.green(`
17628
+ return chalk62.green(`
17147
17629
  ✅ Workflow '${workflow.name}' updated successfully
17148
17630
  `) + ` ID: ${workflow.id}
17149
17631
  `;
17150
17632
  }
17151
17633
  function renderWorkflowDeleted(name) {
17152
- return chalk61.green(`
17634
+ return chalk62.green(`
17153
17635
  ✅ Workflow '${name}' deleted successfully
17154
17636
  `);
17155
17637
  }
17156
17638
  function renderRunResult(result) {
17157
17639
  const lines = [];
17158
17640
  if (result.status === "completed") {
17159
- lines.push(chalk61.green(`
17641
+ lines.push(chalk62.green(`
17160
17642
  ✅ Workflow completed successfully`));
17161
17643
  } else if (result.status === "failed") {
17162
- lines.push(chalk61.red(`
17644
+ lines.push(chalk62.red(`
17163
17645
  ❌ Workflow failed`));
17164
17646
  } else if (result.status === "stopped") {
17165
- lines.push(chalk61.yellow(`
17647
+ lines.push(chalk62.yellow(`
17166
17648
  ⚠️ Workflow stopped`));
17167
17649
  } else {
17168
- lines.push(chalk61.blue(`
17650
+ lines.push(chalk62.blue(`
17169
17651
  \uD83D\uDD04 Workflow ${result.status}`));
17170
17652
  }
17171
17653
  lines.push(` Run ID: ${result.runId}`);
@@ -17173,11 +17655,11 @@ function renderRunResult(result) {
17173
17655
  lines.push(` Duration: ${formatDuration(result.durationMs)}`);
17174
17656
  }
17175
17657
  if (result.error) {
17176
- lines.push(chalk61.red(`
17658
+ lines.push(chalk62.red(`
17177
17659
  Error: ${result.error}`));
17178
17660
  }
17179
17661
  if (result.output) {
17180
- lines.push(chalk61.bold(`
17662
+ lines.push(chalk62.bold(`
17181
17663
  \uD83D\uDCE4 Output:`));
17182
17664
  lines.push(JSON.stringify(result.output, null, 2));
17183
17665
  }
@@ -17191,10 +17673,10 @@ function renderNodesList(nodes) {
17191
17673
  const DEPS_WIDTH = 20;
17192
17674
  const GAP = " ";
17193
17675
  const headerLine = [
17194
- chalk61.bold("NODE ID".padEnd(ID_WIDTH)),
17195
- chalk61.bold("TYPE".padEnd(TYPE_WIDTH)),
17196
- chalk61.bold("NAME".padEnd(NAME_WIDTH)),
17197
- chalk61.bold("DEPENDS ON")
17676
+ chalk62.bold("NODE ID".padEnd(ID_WIDTH)),
17677
+ chalk62.bold("TYPE".padEnd(TYPE_WIDTH)),
17678
+ chalk62.bold("NAME".padEnd(NAME_WIDTH)),
17679
+ chalk62.bold("DEPENDS ON")
17198
17680
  ].join(GAP);
17199
17681
  const sepLine = "─".repeat(ID_WIDTH + TYPE_WIDTH + NAME_WIDTH + DEPS_WIDTH + GAP.length * 3);
17200
17682
  const rows = nodes.map((n) => {
@@ -17209,7 +17691,7 @@ function renderNodesList(nodes) {
17209
17691
  }
17210
17692
 
17211
17693
  // src/commands/workflow/commands/list.ts
17212
- import chalk62 from "chalk";
17694
+ import chalk63 from "chalk";
17213
17695
  import { createWorkflowListTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
17214
17696
  function buildListWorkflowsJson(workflows, total, args, availableTags) {
17215
17697
  const output = {
@@ -17357,20 +17839,20 @@ var WorkflowListCommand = {
17357
17839
  if (total > workflows.length) {
17358
17840
  const start = finalOffset + 1;
17359
17841
  const end = finalOffset + workflows.length;
17360
- output.log(chalk62.green(`
17842
+ output.log(chalk63.green(`
17361
17843
  ✅ 显示 ${start}-${end} / 共 ${total} 个 Workflow`));
17362
17844
  const totalPages = Math.ceil(total / pageSize);
17363
17845
  const currentPage = Math.floor(finalOffset / pageSize) + 1;
17364
17846
  if (totalPages > 1) {
17365
- output.log(chalk62.cyan(`\uD83D\uDCC4 第 ${currentPage} / ${totalPages} 页`));
17847
+ output.log(chalk63.cyan(`\uD83D\uDCC4 第 ${currentPage} / ${totalPages} 页`));
17366
17848
  }
17367
17849
  } else {
17368
- output.log(chalk62.green(`
17850
+ output.log(chalk63.green(`
17369
17851
  ✅ 共 ${total} 个 Workflow`));
17370
17852
  }
17371
17853
  if (availableTags.length > 0) {
17372
17854
  const tagsLine = availableTags.map((t) => `${t.name}(${t.count})`).join(", ");
17373
- output.log(chalk62.cyan(`
17855
+ output.log(chalk63.cyan(`
17374
17856
  \uD83C\uDFF7️ Available tags: ${tagsLine}`));
17375
17857
  }
17376
17858
  }
@@ -17974,7 +18456,7 @@ class WorkflowValidator {
17974
18456
 
17975
18457
  // src/commands/workflow/commands/add.ts
17976
18458
  import { validateWorkflowDefinition } from "@ai-setting/roy-agent-core/env/workflow/utils";
17977
- import chalk63 from "chalk";
18459
+ import chalk64 from "chalk";
17978
18460
  import fs3 from "fs";
17979
18461
  import path6 from "path";
17980
18462
  async function parseWorkflowContent(content, filename) {
@@ -18116,7 +18598,7 @@ var WorkflowAddCommand = {
18116
18598
  definition = await parseWorkflowContent(content, filePath);
18117
18599
  workflowName = a.name || definition.name || path6.basename(filePath);
18118
18600
  if (a.validate) {
18119
- output.log(chalk63.blue("\uD83D\uDD0D Validating workflow..."));
18601
+ output.log(chalk64.blue("\uD83D\uDD0D Validating workflow..."));
18120
18602
  const dagResult = validateWorkflowDefinition(definition);
18121
18603
  if (!dagResult.valid) {
18122
18604
  output.error(`
@@ -18140,11 +18622,11 @@ var WorkflowAddCommand = {
18140
18622
  });
18141
18623
  process.exit(1);
18142
18624
  }
18143
- output.log(chalk63.green(`✅ Workflow validation passed
18625
+ output.log(chalk64.green(`✅ Workflow validation passed
18144
18626
  `));
18145
18627
  }
18146
18628
  } else if (a.desc) {
18147
- output.log(chalk63.blue(`\uD83E\uDD16 Generating workflow from description...
18629
+ output.log(chalk64.blue(`\uD83E\uDD16 Generating workflow from description...
18148
18630
  `));
18149
18631
  const agentComponent = env.getComponent("agent");
18150
18632
  if (!agentComponent) {
@@ -18166,20 +18648,20 @@ ${a.desc}
18166
18648
  1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
18167
18649
  2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
18168
18650
  3. 验证通过后才输出最终 YAML`;
18169
- output.log(chalk63.gray("Running workflow-extract agent..."));
18651
+ output.log(chalk64.gray("Running workflow-extract agent..."));
18170
18652
  const result = await agentComponent.run("workflow-extract", prompt);
18171
18653
  const agentOutput = result.finalText || "";
18172
18654
  definition = parseYamlFromAgentOutput(agentOutput);
18173
18655
  if (definition === null) {
18174
18656
  output.error("Failed to parse workflow from agent output");
18175
- output.log(chalk63.gray(`
18657
+ output.log(chalk64.gray(`
18176
18658
  Agent output:
18177
18659
  ` + agentOutput.slice(0, 500)));
18178
18660
  process.exit(1);
18179
18661
  }
18180
18662
  workflowName = a.name || definition.name;
18181
18663
  if (a.validate) {
18182
- output.log(chalk63.blue(`
18664
+ output.log(chalk64.blue(`
18183
18665
  \uD83D\uDD0D Validating generated workflow...`));
18184
18666
  const dagResult = validateWorkflowDefinition(definition);
18185
18667
  if (!dagResult.valid) {
@@ -18188,7 +18670,7 @@ Agent output:
18188
18670
  dagResult.errors.forEach((msg, i) => {
18189
18671
  output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
18190
18672
  });
18191
- output.log(chalk63.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
18673
+ output.log(chalk64.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
18192
18674
  process.exit(1);
18193
18675
  }
18194
18676
  const validator = new WorkflowValidator;
@@ -18203,16 +18685,16 @@ Agent output:
18203
18685
  output.error(` Fix: ${error.fix}
18204
18686
  `);
18205
18687
  });
18206
- output.log(chalk63.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
18688
+ output.log(chalk64.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
18207
18689
  process.exit(1);
18208
18690
  }
18209
- output.log(chalk63.green(`✅ Generated workflow validation passed
18691
+ output.log(chalk64.green(`✅ Generated workflow validation passed
18210
18692
  `));
18211
18693
  }
18212
18694
  const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
18213
- output.log(chalk63.gray("--- Generated YAML ---"));
18695
+ output.log(chalk64.gray("--- Generated YAML ---"));
18214
18696
  output.log(yaml.stringify(definition));
18215
- output.log(chalk63.gray(`------------------------
18697
+ output.log(chalk64.gray(`------------------------
18216
18698
  `));
18217
18699
  } else {
18218
18700
  output.error("Please provide --file or --desc option");
@@ -18238,10 +18720,10 @@ Agent output:
18238
18720
  force: a.force
18239
18721
  });
18240
18722
  output.log(renderWorkflowAdded(workflow));
18241
- output.log(chalk63.bold(`
18723
+ output.log(chalk64.bold(`
18242
18724
  \uD83D\uDCCA Nodes Summary:`));
18243
18725
  output.log(renderNodesList(definition.nodes));
18244
- output.log(chalk63.green(`
18726
+ output.log(chalk64.green(`
18245
18727
  ✅ Workflow '${workflowName}' added successfully`));
18246
18728
  } catch (error) {
18247
18729
  if (error.message?.includes("already exists") && !a.force) {
@@ -18258,7 +18740,7 @@ Agent output:
18258
18740
  };
18259
18741
 
18260
18742
  // src/commands/workflow/commands/get.ts
18261
- import chalk64 from "chalk";
18743
+ import chalk65 from "chalk";
18262
18744
  import { createWorkflowGetTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
18263
18745
  var WorkflowGetCommand = {
18264
18746
  command: "get <identifier>",
@@ -18396,15 +18878,15 @@ var WorkflowGetCommand = {
18396
18878
  } else {
18397
18879
  output.log(renderWorkflowDetail(workflow, { includeRuns: runs }));
18398
18880
  if (args.includeNodes) {
18399
- output.log(chalk64.bold(`
18881
+ output.log(chalk65.bold(`
18400
18882
  \uD83D\uDCCB All Nodes:`));
18401
18883
  output.log(renderNodesList(data.nodes || []));
18402
18884
  }
18403
18885
  const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
18404
18886
  const defYaml = yaml.stringify(data.definition || {}, { indent: 2 });
18405
- output.log(chalk64.bold(`
18887
+ output.log(chalk65.bold(`
18406
18888
  \uD83D\uDCC4 Definition (YAML):`));
18407
- output.log(chalk64.gray(defYaml));
18889
+ output.log(chalk65.gray(defYaml));
18408
18890
  }
18409
18891
  }
18410
18892
  } catch (error) {
@@ -18417,7 +18899,7 @@ var WorkflowGetCommand = {
18417
18899
  };
18418
18900
 
18419
18901
  // src/commands/workflow/commands/update.ts
18420
- import chalk65 from "chalk";
18902
+ import chalk66 from "chalk";
18421
18903
  import fs4 from "fs";
18422
18904
  import path7 from "path";
18423
18905
  import { parseWorkflowFile } from "@ai-setting/roy-agent-core/env/workflow/types";
@@ -18490,7 +18972,7 @@ var WorkflowUpdateCommand = {
18490
18972
  const tags = a.tags ? a.tags.split(",").map((t) => t.trim()) : undefined;
18491
18973
  const workflow = await service.updateWorkflow(a.name, updates, { tags });
18492
18974
  output.log(renderWorkflowUpdated(workflow));
18493
- output.log(chalk65.green(`
18975
+ output.log(chalk66.green(`
18494
18976
  ✅ Workflow '${a.name}' updated successfully`));
18495
18977
  } catch (error) {
18496
18978
  output.error(`Failed to update workflow: ${error}`);
@@ -18502,7 +18984,7 @@ var WorkflowUpdateCommand = {
18502
18984
  };
18503
18985
 
18504
18986
  // src/commands/workflow/commands/remove.ts
18505
- import chalk66 from "chalk";
18987
+ import chalk67 from "chalk";
18506
18988
  var WorkflowRemoveCommand = {
18507
18989
  command: "remove <name>",
18508
18990
  describe: "删除 Workflow",
@@ -18541,8 +19023,8 @@ var WorkflowRemoveCommand = {
18541
19023
  process.exit(1);
18542
19024
  }
18543
19025
  if (!args.force) {
18544
- output.log(chalk66.yellow(`Are you sure you want to delete workflow '${args.name}'?`));
18545
- output.log(chalk66.gray("Use --force to skip confirmation"));
19026
+ output.log(chalk67.yellow(`Are you sure you want to delete workflow '${args.name}'?`));
19027
+ output.log(chalk67.gray("Use --force to skip confirmation"));
18546
19028
  process.exit(1);
18547
19029
  }
18548
19030
  const deleted = await service.deleteWorkflow(args.name);
@@ -18562,7 +19044,7 @@ var WorkflowRemoveCommand = {
18562
19044
 
18563
19045
  // src/commands/workflow/commands/run.ts
18564
19046
  var import_yaml = __toESM(require_dist(), 1);
18565
- import chalk67 from "chalk";
19047
+ import chalk68 from "chalk";
18566
19048
  import fs5 from "fs";
18567
19049
  import path8 from "path";
18568
19050
  import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
@@ -18626,17 +19108,21 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
18626
19108
  try {
18627
19109
  input = JSON.parse(args.input);
18628
19110
  } catch {
18629
- input = args.sessionId ? args.input : undefined;
19111
+ input = args.session ? args.input : undefined;
18630
19112
  }
18631
19113
  }
19114
+ if (args.session && !args.session.startsWith("workflow_")) {
19115
+ output.error(`Invalid session ID: must start with 'workflow_' (got: ${args.session})`);
19116
+ process.exit(1);
19117
+ }
18632
19118
  const runOptions = {
18633
19119
  debug: args.debug,
18634
19120
  parallelLimit: args.parallelLimit,
18635
19121
  timeout: args.timeout
18636
19122
  };
18637
- if (args.sessionId) {
18638
- const sessionId = args.sessionId.startsWith("workflow_") ? args.sessionId : `workflow_${args.sessionId}`;
18639
- output.log(chalk67.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
19123
+ if (args.session) {
19124
+ const sessionId = args.session;
19125
+ output.log(chalk68.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
18640
19126
  const sessionComponent = workflowComponent.sessionComponent;
18641
19127
  if (!sessionComponent) {
18642
19128
  output.error("SessionComponent not available");
@@ -18698,17 +19184,17 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
18698
19184
  definition = { ...definition, name: args.name };
18699
19185
  }
18700
19186
  const workflow = await service.createWorkflow(definition, { force: true });
18701
- output.log(chalk67.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
18702
- output.log(chalk67.green(`✅ Workflow registered: ${workflow.name} (${workflow.id})`));
19187
+ output.log(chalk68.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
19188
+ output.log(chalk68.green(`✅ Workflow registered: ${workflow.name} (${workflow.id})`));
18703
19189
  if (args.registerOnly) {
18704
- output.log(chalk67.gray("ℹ️ Use --register-only, skipping execution"));
19190
+ output.log(chalk68.gray("ℹ️ Use --register-only, skipping execution"));
18705
19191
  if (workflowSpan) {
18706
19192
  workflowSpan.end();
18707
19193
  }
18708
19194
  await envService.dispose();
18709
19195
  process.exit(0);
18710
19196
  }
18711
- output.log(chalk67.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
19197
+ output.log(chalk68.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
18712
19198
  const result = await service.runWorkflow(definition, input, runOptions);
18713
19199
  output.log(renderRunResult({
18714
19200
  runId: result.runId,
@@ -18718,8 +19204,8 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
18718
19204
  durationMs: result.durationMs
18719
19205
  }));
18720
19206
  if (result.status === "paused") {
18721
- output.log(chalk67.gray(`
18722
- \uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session-id ${result.runId} --input '<response>'" to resume`));
19207
+ output.log(chalk68.gray(`
19208
+ \uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session ${result.runId} --input '<response>'" to resume`));
18723
19209
  }
18724
19210
  } else {
18725
19211
  const tool = createRunWorkflowTool(service);
@@ -18741,8 +19227,8 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
18741
19227
  durationMs: runData.duration_ms
18742
19228
  }));
18743
19229
  if (runData.status === "paused") {
18744
- output.log(chalk67.gray(`
18745
- \uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session-id ${runData.run_id} --input '<response>'" to resume`));
19230
+ output.log(chalk68.gray(`
19231
+ \uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session ${runData.run_id} --input '<response>'" to resume`));
18746
19232
  }
18747
19233
  }
18748
19234
  if (workflowSpan) {
@@ -18804,16 +19290,16 @@ var WorkflowRunCommand = {
18804
19290
  }).option("config", {
18805
19291
  describe: "配置文件路径",
18806
19292
  type: "string"
18807
- }).option("session-id", {
19293
+ }).option("session", {
18808
19294
  alias: "s",
18809
- describe: "从已有 session 恢复运行(支持 workflow pause/interrupt 恢复)",
19295
+ describe: "从已有 session 恢复运行(支持 workflow pause/interrupt 恢复,session ID 必须以 workflow_ 开头)",
18810
19296
  type: "string"
18811
19297
  }),
18812
19298
  handler: runWorkflow
18813
19299
  };
18814
19300
 
18815
19301
  // src/commands/workflow/commands/stop.ts
18816
- import chalk68 from "chalk";
19302
+ import chalk69 from "chalk";
18817
19303
  import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
18818
19304
  import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
18819
19305
  var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
@@ -18838,7 +19324,7 @@ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
18838
19324
  output.error(result.error || `Failed to stop workflow: ${args.runId}`);
18839
19325
  process.exit(1);
18840
19326
  }
18841
- output.log(chalk68.red(`
19327
+ output.log(chalk69.red(`
18842
19328
  ⏹️ Workflow stopped: ${args.runId}`));
18843
19329
  } catch (error) {
18844
19330
  output.error(`Failed to stop workflow: ${error}`);
@@ -18862,7 +19348,7 @@ var WorkflowStopCommand = {
18862
19348
  };
18863
19349
 
18864
19350
  // src/commands/workflow/commands/status.ts
18865
- import chalk69 from "chalk";
19351
+ import chalk70 from "chalk";
18866
19352
  import { createWorkflowRunStatusTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
18867
19353
  var WorkflowStatusCommand = {
18868
19354
  command: "status <runId>",
@@ -18955,7 +19441,7 @@ var WorkflowStatusCommand = {
18955
19441
  stopped: "⏹️"
18956
19442
  };
18957
19443
  const emoji = statusEmoji[status] || "❓";
18958
- output.log(chalk69.bold(`
19444
+ output.log(chalk70.bold(`
18959
19445
  ${emoji} Status: ${status.toUpperCase()}`));
18960
19446
  }
18961
19447
  } catch (error) {
@@ -18968,7 +19454,7 @@ ${emoji} Status: ${status.toUpperCase()}`));
18968
19454
  };
18969
19455
 
18970
19456
  // src/commands/workflow/commands/nodes.ts
18971
- import chalk70 from "chalk";
19457
+ import chalk71 from "chalk";
18972
19458
  var BUILT_IN_NODES = [
18973
19459
  {
18974
19460
  name: "ToolNode",
@@ -19305,7 +19791,7 @@ nodes:
19305
19791
  ];
19306
19792
  function renderNodeTypesTable(nodes) {
19307
19793
  const lines = [];
19308
- lines.push(chalk70.bold(`
19794
+ lines.push(chalk71.bold(`
19309
19795
  \uD83D\uDCE6 Built-in Node Types
19310
19796
  `));
19311
19797
  lines.push("┌────────────┬────────────────────┬─────────────────────────────────────────────────────────────┐");
@@ -19323,29 +19809,29 @@ function renderNodeTypesTable(nodes) {
19323
19809
  }
19324
19810
  function renderNodeDetail(node) {
19325
19811
  const lines = [];
19326
- lines.push(chalk70.bold(`
19812
+ lines.push(chalk71.bold(`
19327
19813
  [${node.type}] ${node.name}`));
19328
- lines.push(chalk70.dim("─".repeat(60)) + `
19814
+ lines.push(chalk71.dim("─".repeat(60)) + `
19329
19815
  `);
19330
- lines.push(chalk70.bold("Description:"));
19816
+ lines.push(chalk71.bold("Description:"));
19331
19817
  lines.push(` ${node.description}
19332
19818
  `);
19333
- lines.push(chalk70.bold("Configuration:"));
19819
+ lines.push(chalk71.bold("Configuration:"));
19334
19820
  lines.push(' type: "' + node.type + '"');
19335
19821
  lines.push(" config:");
19336
19822
  for (const input of node.inputs) {
19337
- const required = input.required ? chalk70.red("*") : " ";
19823
+ const required = input.required ? chalk71.red("*") : " ";
19338
19824
  lines.push(` ${input.name} (${input.type})${required}`);
19339
19825
  lines.push(` ${input.description}`);
19340
19826
  }
19341
19827
  lines.push(`
19342
- ${chalk70.bold("Output:")} ${node.output}`);
19828
+ ${chalk71.bold("Output:")} ${node.output}`);
19343
19829
  if (node.example) {
19344
- lines.push(chalk70.bold(`
19830
+ lines.push(chalk71.bold(`
19345
19831
  Example:`));
19346
- lines.push(chalk70.gray("```yaml"));
19832
+ lines.push(chalk71.gray("```yaml"));
19347
19833
  lines.push(node.example);
19348
- lines.push(chalk70.gray("```"));
19834
+ lines.push(chalk71.gray("```"));
19349
19835
  }
19350
19836
  return lines.join(`
19351
19837
  `);
@@ -19361,16 +19847,16 @@ var WorkflowNodesCommand = {
19361
19847
  const nodeType = args.type?.toLowerCase();
19362
19848
  if (!nodeType) {
19363
19849
  console.log(renderNodeTypesTable(BUILT_IN_NODES));
19364
- console.log(chalk70.gray(`
19365
- Use `) + chalk70.cyan("roy-agent workflow nodes <type>") + chalk70.gray(" for detailed information"));
19366
- console.log(chalk70.gray("Available types: ") + chalk70.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
19850
+ console.log(chalk71.gray(`
19851
+ Use `) + chalk71.cyan("roy-agent workflow nodes <type>") + chalk71.gray(" for detailed information"));
19852
+ console.log(chalk71.gray("Available types: ") + chalk71.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
19367
19853
  return;
19368
19854
  }
19369
19855
  const node = BUILT_IN_NODES.find((n) => n.type === nodeType);
19370
19856
  if (!node) {
19371
- console.log(chalk70.red(`
19857
+ console.log(chalk71.red(`
19372
19858
  ❌ Unknown node type: ${nodeType}`));
19373
- console.log(chalk70.gray("Available types: ") + chalk70.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
19859
+ console.log(chalk71.gray("Available types: ") + chalk71.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
19374
19860
  process.exit(1);
19375
19861
  }
19376
19862
  console.log(renderNodeDetail(node));
@@ -19378,7 +19864,7 @@ Use `) + chalk70.cyan("roy-agent workflow nodes <type>") + chalk70.gray(" for de
19378
19864
  };
19379
19865
 
19380
19866
  // src/commands/workflow/commands/validate.ts
19381
- import chalk71 from "chalk";
19867
+ import chalk72 from "chalk";
19382
19868
  import { readFileSync } from "fs";
19383
19869
  async function parseWorkflowInput(input, yamlStr) {
19384
19870
  const parseYaml = async (content) => {
@@ -19411,25 +19897,25 @@ function renderResult(result, options) {
19411
19897
  return;
19412
19898
  }
19413
19899
  if (result.valid) {
19414
- console.log(chalk71.green(`
19900
+ console.log(chalk72.green(`
19415
19901
  ✅ Workflow validation PASSED
19416
19902
  `));
19417
- console.log(chalk71.bold(`Workflow: ${result.workflowName}`));
19903
+ console.log(chalk72.bold(`Workflow: ${result.workflowName}`));
19418
19904
  console.log(`Nodes: ${result.nodeCount}`);
19419
19905
  console.log(`
19420
19906
  Valid nodes:`);
19421
- console.log(chalk71.green(" ✓ All nodes passed validation"));
19907
+ console.log(chalk72.green(" ✓ All nodes passed validation"));
19422
19908
  } else {
19423
- console.log(chalk71.red(`
19909
+ console.log(chalk72.red(`
19424
19910
  ❌ Workflow validation FAILED (${result.errors.length} errors found)
19425
19911
  `));
19426
19912
  result.errors.forEach((error, index) => {
19427
- console.log(chalk71.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
19428
- console.log(` ${chalk71.bold("Type:")} ${error.type}`);
19429
- console.log(` ${chalk71.bold("Description:")} ${error.description}`);
19430
- console.log(` ${chalk71.bold("Expected:")} ${error.expected}`);
19431
- console.log(` ${chalk71.bold("Actual:")} ${error.actual}`);
19432
- console.log(` ${chalk71.green("Fix:")} ${error.fix}`);
19913
+ console.log(chalk72.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
19914
+ console.log(` ${chalk72.bold("Type:")} ${error.type}`);
19915
+ console.log(` ${chalk72.bold("Description:")} ${error.description}`);
19916
+ console.log(` ${chalk72.bold("Expected:")} ${error.expected}`);
19917
+ console.log(` ${chalk72.bold("Actual:")} ${error.actual}`);
19918
+ console.log(` ${chalk72.green("Fix:")} ${error.fix}`);
19433
19919
  console.log();
19434
19920
  });
19435
19921
  }
@@ -19454,7 +19940,7 @@ var WorkflowValidateCommand = {
19454
19940
  try {
19455
19941
  const workflow = await parseWorkflowInput(options.input, options.yaml);
19456
19942
  if (!workflow) {
19457
- console.error(chalk71.red("Failed to parse workflow input"));
19943
+ console.error(chalk72.red("Failed to parse workflow input"));
19458
19944
  process.exit(1);
19459
19945
  }
19460
19946
  const validator = new WorkflowValidator;
@@ -19462,7 +19948,7 @@ var WorkflowValidateCommand = {
19462
19948
  renderResult(result, options);
19463
19949
  process.exit(result.valid ? 0 : 1);
19464
19950
  } catch (error) {
19465
- console.error(chalk71.red(`
19951
+ console.error(chalk72.red(`
19466
19952
  Error: ${error.message}`));
19467
19953
  process.exit(1);
19468
19954
  }
@@ -19470,7 +19956,7 @@ Error: ${error.message}`));
19470
19956
  };
19471
19957
 
19472
19958
  // src/commands/workflow/commands/search.ts
19473
- import chalk72 from "chalk";
19959
+ import chalk73 from "chalk";
19474
19960
  import { wrapFunction as wrapFunction3 } from "@ai-setting/roy-agent-core";
19475
19961
  var WorkflowSearchCommand = {
19476
19962
  command: "search",
@@ -19627,22 +20113,22 @@ var _runWorkflowSearchImpl = async function(opts) {
19627
20113
  metadata: {}
19628
20114
  }));
19629
20115
  if (renderWorkflows.length === 0) {
19630
- output.log(chalk72.yellow("\uD83D\uDD0D No workflows matched the search criteria."));
19631
- output.log(chalk72.gray(` keyword: ${keyword || "(none)"}`));
19632
- output.log(chalk72.gray(` tags: ${tags && tags.length > 0 ? tags.join(", ") : "(none)"}`));
20116
+ output.log(chalk73.yellow("\uD83D\uDD0D No workflows matched the search criteria."));
20117
+ output.log(chalk73.gray(` keyword: ${keyword || "(none)"}`));
20118
+ output.log(chalk73.gray(` tags: ${tags && tags.length > 0 ? tags.join(", ") : "(none)"}`));
19633
20119
  } else {
19634
- output.log(chalk72.bold(`\uD83D\uDD0D Search results (${renderWorkflows.length}):`));
20120
+ output.log(chalk73.bold(`\uD83D\uDD0D Search results (${renderWorkflows.length}):`));
19635
20121
  output.log(renderWorkflowList(renderWorkflows));
19636
- output.log(chalk72.green(`
20122
+ output.log(chalk73.green(`
19637
20123
  ✅ Found ${renderWorkflows.length} workflow(s)`));
19638
20124
  }
19639
20125
  if (availableTags.length > 0) {
19640
20126
  output.log("");
19641
- output.log(chalk72.bold("\uD83D\uDCDA Available tags (sorted by usage_count):"));
20127
+ output.log(chalk73.bold("\uD83D\uDCDA Available tags (sorted by usage_count):"));
19642
20128
  for (const t of availableTags) {
19643
20129
  const name = t.name ?? t.tag;
19644
20130
  const count = t.count ?? t.usage_count;
19645
- output.log(chalk72.gray(` - ${name} (${count})`));
20131
+ output.log(chalk73.gray(` - ${name} (${count})`));
19646
20132
  }
19647
20133
  }
19648
20134
  };
@@ -19654,7 +20140,7 @@ var runWorkflowSearch = wrapFunction3(_runWorkflowSearchImpl, "workflow.cli.sear
19654
20140
 
19655
20141
  // src/commands/workflow/commands/tag.ts
19656
20142
  import { wrapFunction as wrapFunction4 } from "@ai-setting/roy-agent-core";
19657
- import chalk73 from "chalk";
20143
+ import chalk74 from "chalk";
19658
20144
  var WorkflowTagListCommand = {
19659
20145
  command: "list",
19660
20146
  describe: "List all workflow tags from the workflow_tags table (sorted by usage_count DESC by default). Use this BEFORE `workflow add` to discover existing tags and reuse them for semantic consistency.",
@@ -19775,17 +20261,17 @@ var _runWorkflowTagListImpl = async function(opts) {
19775
20261
  return;
19776
20262
  }
19777
20263
  if (result.tags.length === 0) {
19778
- output.log(chalk73.yellow("\uD83C\uDFF7️ No tags in the workflow_tags table yet."));
19779
- output.log(chalk73.gray(" Tags are created automatically when you run `workflow add --tags <name>`."));
20264
+ output.log(chalk74.yellow("\uD83C\uDFF7️ No tags in the workflow_tags table yet."));
20265
+ output.log(chalk74.gray(" Tags are created automatically when you run `workflow add --tags <name>`."));
19780
20266
  return;
19781
20267
  }
19782
- output.log(chalk73.bold(`\uD83C\uDFF7️ Workflow tags (${result.total}):`));
19783
- output.log(chalk73.gray(` ${padRight("NAME", 24)}${padRight("USAGE", 8)}${padRight("CREATED", 22)}`));
20268
+ output.log(chalk74.bold(`\uD83C\uDFF7️ Workflow tags (${result.total}):`));
20269
+ output.log(chalk74.gray(` ${padRight("NAME", 24)}${padRight("USAGE", 8)}${padRight("CREATED", 22)}`));
19784
20270
  for (const t of result.tags) {
19785
20271
  const line = ` ${padRight(t.name, 24)}${padRight(String(t.usage_count), 8)}${padRight(formatDate2(t.created_at), 22)}`;
19786
20272
  output.log(line);
19787
20273
  }
19788
- output.log(chalk73.gray(`
20274
+ output.log(chalk74.gray(`
19789
20275
  \uD83D\uDCA1 Tip: when adding a new workflow, prefer tags from this list to ensure semantic consistency.`));
19790
20276
  };
19791
20277
  var _runWorkflowTagGetImpl = async function(opts) {
@@ -19812,7 +20298,7 @@ var _runWorkflowTagGetImpl = async function(opts) {
19812
20298
  output.json({ error: "Tag not found", name: opts.name });
19813
20299
  } else {
19814
20300
  output.error(`Tag "${opts.name}" not found in the workflow_tags table.`);
19815
- output.log(chalk73.gray(`Tip: run \`roy-agent workflow tag list\` to see available tags.`));
20301
+ output.log(chalk74.gray(`Tip: run \`roy-agent workflow tag list\` to see available tags.`));
19816
20302
  }
19817
20303
  process.exitCode = 1;
19818
20304
  return;
@@ -19821,10 +20307,10 @@ var _runWorkflowTagGetImpl = async function(opts) {
19821
20307
  output.json(tag);
19822
20308
  return;
19823
20309
  }
19824
- output.log(chalk73.bold(`\uD83C\uDFF7️ Tag: ${tag.name}`));
19825
- output.log(chalk73.gray(` usage_count: ${tag.usage_count}`));
19826
- output.log(chalk73.gray(` created_at: ${tag.created_at}`));
19827
- output.log(chalk73.gray(` updated_at: ${tag.updated_at}`));
20310
+ output.log(chalk74.bold(`\uD83C\uDFF7️ Tag: ${tag.name}`));
20311
+ output.log(chalk74.gray(` usage_count: ${tag.usage_count}`));
20312
+ output.log(chalk74.gray(` created_at: ${tag.created_at}`));
20313
+ output.log(chalk74.gray(` updated_at: ${tag.updated_at}`));
19828
20314
  };
19829
20315
  async function callListTags(service, options) {
19830
20316
  if (typeof service.listTags !== "function") {