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