jinzd-ai-cli 0.4.255 → 0.4.257

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.
Files changed (43) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/dist/{batch-OWBKG6XZ.js → batch-HCTZJMGR.js} +3 -3
  4. package/dist/{chunk-X2V76VPG.js → chunk-4VWME5CO.js} +1 -1
  5. package/dist/{chunk-SVWIUNOA.js → chunk-5DLLJ67Q.js} +1 -1
  6. package/dist/{chunk-U6OV523Y.js → chunk-BQXVQKMH.js} +1 -1
  7. package/dist/{chunk-IRSNREEO.js → chunk-DFV7F6S7.js} +3 -3
  8. package/dist/{chunk-B42HK6GL.js → chunk-DGMSS565.js} +1 -1
  9. package/dist/{chunk-EWLXBTSC.js → chunk-DQY2DDGS.js} +1 -1
  10. package/dist/{chunk-3WKUKMBG.js → chunk-ELYDRIKV.js} +4 -4
  11. package/dist/{chunk-GUOLPI33.js → chunk-EZ6QLHOS.js} +9 -3
  12. package/dist/{chunk-7QWFFLKV.js → chunk-GOGDUA4G.js} +4 -4
  13. package/dist/{chunk-PSXIVQ3N.js → chunk-HOS7CGBI.js} +8 -3
  14. package/dist/{chunk-SMIQ6CBX.js → chunk-HPPK4IA3.js} +1 -1
  15. package/dist/{chunk-ZRBGH245.js → chunk-MJ6JLSPR.js} +42 -4
  16. package/dist/{chunk-YJ7VL7VL.js → chunk-NRTYNGEZ.js} +1 -1
  17. package/dist/{chunk-2UZ23L5P.js → chunk-NX55D52V.js} +2 -2
  18. package/dist/{chunk-CU5ZNAIX.js → chunk-QEVXWHWN.js} +1 -1
  19. package/dist/{chunk-PSP4W2MG.js → chunk-QI4AJPRD.js} +38 -20
  20. package/dist/{chunk-5ULLIOVC.js → chunk-TU3L3PW7.js} +5 -2
  21. package/dist/{chunk-FOC2YWOF.js → chunk-X2ZXQMN2.js} +1 -1
  22. package/dist/ci-OGJDKUEN.js +19 -0
  23. package/dist/{ci-format-CTGDLJTS.js → ci-format-CG6US3KX.js} +2 -2
  24. package/dist/{constants-LJRYL7IN.js → constants-3UC2F5GC.js} +1 -1
  25. package/dist/doctor-cli-FPYSCH5H.js +17 -0
  26. package/dist/electron-server.js +103 -31
  27. package/dist/{hub-4EEDUJED.js → hub-5NRTE7PL.js} +2 -2
  28. package/dist/{hub-server-XA7HTVLD.js → hub-server-QGUSMN22.js} +3 -0
  29. package/dist/index.js +47 -31
  30. package/dist/{persistent-memory-DMN76UB5.js → persistent-memory-CHPNGWN2.js} +2 -2
  31. package/dist/{persistent-memory-EEAGHDFR.js → persistent-memory-PNJCHP33.js} +2 -2
  32. package/dist/{pr-Q74YHWN2.js → pr-KAEI2IK3.js} +7 -7
  33. package/dist/{run-tests-ADZQ2JWI.js → run-tests-EOHLRWQC.js} +2 -2
  34. package/dist/{run-tests-N3ES4YMU.js → run-tests-F7Y6POVK.js} +2 -2
  35. package/dist/{server-HUWVPJKQ.js → server-4NP2ZVLA.js} +7 -7
  36. package/dist/{server-PMEZ3HDO.js → server-REZPCUHW.js} +17 -15
  37. package/dist/{task-orchestrator-KLCN25OY.js → task-orchestrator-LTPRJVLH.js} +13 -7
  38. package/dist/{usage-MNMRX5OE.js → usage-XPBLQ4FZ.js} +5 -5
  39. package/dist/web/client/app.js +3329 -3312
  40. package/dist/web/client/index.html +70 -70
  41. package/package.json +19 -9
  42. package/dist/ci-V5GVGYZO.js +0 -19
  43. package/dist/doctor-cli-GOM2GQUK.js +0 -17
@@ -34,14 +34,14 @@ import {
34
34
  touchMemoryReferences,
35
35
  updateMemoryApproval,
36
36
  updateMemoryEntry
37
- } from "./chunk-YJ7VL7VL.js";
37
+ } from "./chunk-NRTYNGEZ.js";
38
38
  import {
39
39
  redactJson,
40
40
  scanString
41
41
  } from "./chunk-YVTASHS5.js";
42
42
  import {
43
43
  runTestsTool
44
- } from "./chunk-B42HK6GL.js";
44
+ } from "./chunk-DGMSS565.js";
45
45
  import {
46
46
  AGENTIC_BEHAVIOR_GUIDELINE,
47
47
  APP_NAME,
@@ -73,7 +73,7 @@ import {
73
73
  SUBAGENT_MAX_ROUNDS_LIMIT,
74
74
  VERSION,
75
75
  buildUserIdentityPrompt
76
- } from "./chunk-CU5ZNAIX.js";
76
+ } from "./chunk-QEVXWHWN.js";
77
77
  import {
78
78
  hasSemanticIndex,
79
79
  semanticSearch
@@ -473,10 +473,11 @@ var ProviderError = class extends AiCliError {
473
473
  this.providerId = providerId;
474
474
  this.name = "ProviderError";
475
475
  }
476
+ providerId;
476
477
  };
477
478
  var AuthError = class extends ProviderError {
478
479
  constructor(providerId) {
479
- super(providerId, "Invalid or missing API key. Run: ai-cli config");
480
+ super(providerId, "Invalid or missing API key. Run: aicli config");
480
481
  this.name = "AuthError";
481
482
  }
482
483
  };
@@ -495,7 +496,7 @@ var ConfigError = class extends AiCliError {
495
496
  var ProviderNotFoundError = class extends AiCliError {
496
497
  constructor(providerId) {
497
498
  super(
498
- `Provider '${providerId}' is not configured. Run: ai-cli config`
499
+ `Provider '${providerId}' is not configured. Run: aicli config`
499
500
  );
500
501
  this.name = "ProviderNotFoundError";
501
502
  }
@@ -506,6 +507,7 @@ var ToolError = class extends AiCliError {
506
507
  this.toolName = toolName;
507
508
  this.name = "ToolError";
508
509
  }
510
+ toolName;
509
511
  };
510
512
  var NetworkError = class extends AiCliError {
511
513
  constructor(message, statusCode, cause) {
@@ -513,6 +515,7 @@ var NetworkError = class extends AiCliError {
513
515
  this.statusCode = statusCode;
514
516
  this.name = "NetworkError";
515
517
  }
518
+ statusCode;
516
519
  };
517
520
 
518
521
  // src/config/config-manager.ts
@@ -537,7 +540,7 @@ var ConfigManager = class {
537
540
  return ConfigSchema.parse(raw);
538
541
  } catch (err) {
539
542
  throw new ConfigError(
540
- `Config file at ${this.configPath} is invalid. Delete it and run 'ai-cli config' to recreate.
543
+ `Config file at ${this.configPath} is invalid. Delete it and run 'aicli config' to recreate.
541
544
  ${err}`
542
545
  );
543
546
  }
@@ -2444,6 +2447,7 @@ var BudgetWarner = class {
2444
2447
  this.lowAt = Math.min(lowRaw, this.noteAt - 1);
2445
2448
  this.criticalAt = Math.min(criticalRaw, this.lowAt - 1);
2446
2449
  }
2450
+ maxToolRounds;
2447
2451
  noteAt;
2448
2452
  lowAt;
2449
2453
  criticalAt;
@@ -2478,6 +2482,7 @@ var BudgetWarner = class {
2478
2482
  }
2479
2483
  };
2480
2484
  var EMPTY_RESPONSE_NUDGE = "Your previous response was empty \u2014 no text and no tool calls. This usually means the context window is nearly full. Please either: (1) continue the task by calling the next tool you need, or (2) give a concise final text summary of what has been accomplished so far and what remains. Do NOT repeat earlier long outputs.";
2485
+ var LENGTH_LIMIT_NUDGE = "Your previous attempt hit the model output token limit (finish_reason=length) before producing ANY answer text or tool call \u2014 the entire output budget was consumed by extended reasoning. Retrying the same way will fail identically. Do NOT reason at length again: start producing output immediately. If the deliverable is long, do NOT try to emit it in one response \u2014 write it to disk in several smaller write_file calls (part 1, part 2, ...), each well under the output limit, and keep any thinking short.";
2481
2486
  function describeFinishReason(fr) {
2482
2487
  if (fr === "length") return "output limit reached (finish_reason=length)";
2483
2488
  if (fr === "content_filter") return "content blocked (finish_reason=content_filter)";
@@ -2485,7 +2490,9 @@ function describeFinishReason(fr) {
2485
2490
  return "empty response";
2486
2491
  }
2487
2492
  function emptyResponseHint(fr) {
2488
- if (fr === "length") return "Output token limit hit \u2014 try /compact to reduce context, raise maxTokens, or /model to switch.";
2493
+ if (fr === "length") {
2494
+ return "Output token budget exhausted before any answer \u2014 on thinking models max_tokens covers reasoning + answer. Try: raise config.modelParams.<model>.maxTokens, ask for the deliverable in parts, or /model to switch.";
2495
+ }
2489
2496
  if (fr === "content_filter") return "Content was blocked by the provider filter.";
2490
2497
  return "Context window may be exhausted or max_tokens too low.";
2491
2498
  }
@@ -2494,10 +2501,11 @@ var EmptyResponseGuard = class {
2494
2501
  onEmpty(canRetry, finishReason) {
2495
2502
  if (this.retries === 0 && canRetry) {
2496
2503
  this.retries++;
2504
+ const isLength = finishReason === "length";
2497
2505
  return {
2498
2506
  action: "nudge",
2499
- injectMessage: EMPTY_RESPONSE_NUDGE,
2500
- displayMessage: `\u26A0 ${describeFinishReason(finishReason)} \u2014 nudging AI to continue...`
2507
+ injectMessage: isLength ? LENGTH_LIMIT_NUDGE : EMPTY_RESPONSE_NUDGE,
2508
+ displayMessage: isLength ? `\u26A0 ${describeFinishReason(finishReason)} \u2014 the whole output budget went to reasoning; asking AI to write directly in smaller parts...` : `\u26A0 ${describeFinishReason(finishReason)} \u2014 nudging AI to continue...`
2501
2509
  };
2502
2510
  }
2503
2511
  return {
@@ -2782,20 +2790,49 @@ function isLoopbackBaseUrl(baseUrl) {
2782
2790
  if (host === "localhost" || host === "::1" || host === "0.0.0.0") return true;
2783
2791
  return /^127(?:\.\d{1,3}){3}$/.test(host);
2784
2792
  }
2793
+ function readRetryCount(headers) {
2794
+ if (!headers) return 0;
2795
+ const KEY = "x-stainless-retry-count";
2796
+ let raw;
2797
+ const getter = headers.get;
2798
+ if (typeof getter === "function") {
2799
+ raw = getter.call(headers, KEY) ?? void 0;
2800
+ } else if (Array.isArray(headers)) {
2801
+ raw = headers.find(([k]) => k.toLowerCase() === KEY)?.[1];
2802
+ } else {
2803
+ const entry = Object.entries(headers).find(
2804
+ ([k]) => k.toLowerCase() === KEY
2805
+ );
2806
+ raw = entry?.[1];
2807
+ }
2808
+ const n = Number(raw);
2809
+ return Number.isFinite(n) && n > 0 ? n : 0;
2810
+ }
2785
2811
  var OpenAICompatibleProvider = class extends BaseProvider {
2786
2812
  client;
2787
2813
  defaultTimeout = 6e4;
2788
2814
  // ms
2815
+ /**
2816
+ * openai-node 的默认 `maxRetries` 是 **2**,且**超时也算可重试错误**。
2817
+ * 对普通 REST 请求这没问题,但 LLM 调用的超时是分钟级:东叔配 `timeouts.deepseek=300000`
2818
+ * (5 分钟)本意是「最多等 5 分钟」,实际最坏是 5min × 3 次 = **15 分钟以上的完全静默**
2819
+ * ——尤其 DeepSeek/Kimi 走 `enableStreamingToolCalls=false` 的非流式回退路径时,
2820
+ * 屏幕上连一个字都不会动,看起来就是卡死(实战:一次 skill 任务空转近 20 分钟)。
2821
+ * 故显式降到 1(仍保留一次对瞬时网络抖动的重试),并在 fetch 包装里把重试**打印出来**。
2822
+ */
2823
+ defaultMaxRetries = 1;
2789
2824
  /** 子类设为 false 可禁用流式工具调用(虚假声明检测需要完整响应) */
2790
2825
  enableStreamingToolCalls = true;
2791
2826
  async initialize(apiKey, options) {
2792
2827
  if (options?.timeout !== void 0) {
2793
2828
  this.defaultTimeout = options.timeout;
2794
2829
  }
2830
+ const maxRetries = typeof options?.maxRetries === "number" ? options.maxRetries : this.defaultMaxRetries;
2795
2831
  const clientOptions = {
2796
2832
  apiKey,
2797
2833
  baseURL: options?.baseUrl ?? this.defaultBaseUrl,
2798
- timeout: this.defaultTimeout
2834
+ timeout: this.defaultTimeout,
2835
+ maxRetries
2799
2836
  };
2800
2837
  const proxyUrl = isLoopbackBaseUrl(clientOptions.baseURL) ? void 0 : options?.proxy;
2801
2838
  try {
@@ -2810,7 +2847,16 @@ var OpenAICompatibleProvider = class extends BaseProvider {
2810
2847
  bodyTimeout: STREAM_BODY_TIMEOUT,
2811
2848
  headersTimeout: STREAM_HEADERS_TIMEOUT
2812
2849
  });
2813
- clientOptions.fetch = ((url, init) => undiciFetch(url, { ...init, dispatcher }));
2850
+ clientOptions.fetch = ((url, init) => {
2851
+ const retryCount = readRetryCount(init?.headers);
2852
+ if (retryCount > 0) {
2853
+ process.stderr.write(
2854
+ `[${this.info.id}] \u27F3 request retry ${retryCount}/${maxRetries} \u2014 previous attempt failed or timed out
2855
+ `
2856
+ );
2857
+ }
2858
+ return undiciFetch(url, { ...init, dispatcher });
2859
+ });
2814
2860
  } catch {
2815
2861
  }
2816
2862
  this.client = new OpenAI(clientOptions);
@@ -5032,6 +5078,7 @@ async function execInPool(sessionKey, command, timeout, cwd, abortSignal) {
5032
5078
  let resolved = false;
5033
5079
  const markerStartPattern = `AICLI_MARKER_START:${id}`;
5034
5080
  const markerEndPattern = `AICLI_MARKER_END:${id}`;
5081
+ const proc = entry.proc;
5035
5082
  const onData = (chunk) => {
5036
5083
  stdout += IS_WINDOWS2 ? decodeWindowsBuffer(chunk) : chunk.toString("utf-8");
5037
5084
  if (!resolved && stdout.includes(markerEndPattern)) {
@@ -5046,9 +5093,26 @@ async function execInPool(sessionKey, command, timeout, cwd, abortSignal) {
5046
5093
  const onErr = (chunk) => {
5047
5094
  stderr += IS_WINDOWS2 ? decodeWindowsBuffer(chunk) : chunk.toString("utf-8");
5048
5095
  };
5049
- const proc = entry.proc;
5096
+ const finishPoolFailure = (message, exitCode = null) => {
5097
+ if (resolved) return;
5098
+ resolved = true;
5099
+ stdout = stripMarkerOutput(stdout, markerStartPattern, markerEndPattern);
5100
+ stderr += `${stderr ? "\n" : ""}[pool terminated] ${message}`;
5101
+ cleanup();
5102
+ pool.delete(sessionKey);
5103
+ resolve11({ stdout, stderr, exitCode: exitCode === 0 ? null : exitCode, timedOut, aborted });
5104
+ };
5105
+ const onClose = (code, signal) => {
5106
+ const detail = signal ? `signal ${signal}` : `exit code ${code ?? "unknown"}`;
5107
+ finishPoolFailure(`Shell exited before the completion marker (${detail}).`, code);
5108
+ };
5109
+ const onStdinError = (err) => {
5110
+ finishPoolFailure(`Shell stdin failed: ${err.message}`);
5111
+ };
5050
5112
  proc.stdout?.on("data", onData);
5051
5113
  proc.stderr?.on("data", onErr);
5114
+ proc.once("close", onClose);
5115
+ proc.stdin?.once("error", onStdinError);
5052
5116
  const timeoutTimer = setTimeout(() => {
5053
5117
  if (resolved) return;
5054
5118
  timedOut = true;
@@ -5075,29 +5139,26 @@ async function execInPool(sessionKey, command, timeout, cwd, abortSignal) {
5075
5139
  abortSignal?.addEventListener("abort", onAbort, { once: true });
5076
5140
  }
5077
5141
  const onError = (err) => {
5078
- if (resolved) return;
5079
- resolved = true;
5080
- stderr += `
5081
- [pool error] ${err.message}`;
5082
- cleanup();
5083
- resolve11({ stdout, stderr, exitCode: null, timedOut, aborted });
5084
- pool.delete(sessionKey);
5142
+ finishPoolFailure(`Shell process error: ${err.message}`);
5085
5143
  };
5086
- proc.on("error", onError);
5144
+ proc.once("error", onError);
5087
5145
  function cleanup() {
5088
5146
  clearTimeout(timeoutTimer);
5089
5147
  abortSignal?.removeEventListener("abort", onAbort);
5090
5148
  proc.stdout?.removeListener("data", onData);
5091
5149
  proc.stderr?.removeListener("data", onErr);
5150
+ proc.removeListener("close", onClose);
5092
5151
  proc.removeListener("error", onError);
5152
+ proc.stdin?.removeListener("error", onStdinError);
5093
5153
  }
5094
5154
  try {
5095
- proc.stdin?.write(wrappedCmd + "\n");
5096
- } catch {
5097
- if (!resolved) {
5098
- cleanup();
5099
- pool.delete(sessionKey);
5155
+ if (!proc.stdin) {
5156
+ finishPoolFailure("Shell stdin is unavailable.");
5157
+ } else {
5158
+ proc.stdin.write(wrappedCmd + "\n");
5100
5159
  }
5160
+ } catch (err) {
5161
+ finishPoolFailure(`Shell stdin write failed: ${err instanceof Error ? err.message : String(err)}`);
5101
5162
  }
5102
5163
  });
5103
5164
  }
@@ -7080,6 +7141,7 @@ var ToolExecutor = class {
7080
7141
  constructor(registry) {
7081
7142
  this.registry = registry;
7082
7143
  }
7144
+ registry;
7083
7145
  /** 当前 session 消息索引,由 repl.ts / session-handler.ts 在每轮工具执行前设置 */
7084
7146
  static currentMessageIndex = 0;
7085
7147
  round = 0;
@@ -10700,6 +10762,8 @@ var SubAgentExecutor = class {
10700
10762
  this.runId = runId;
10701
10763
  this.prefix = agentPrefix(agentIndex);
10702
10764
  }
10765
+ registry;
10766
+ runId;
10703
10767
  round = 0;
10704
10768
  totalRounds = 0;
10705
10769
  prefix = PREFIX;
@@ -12955,6 +13019,8 @@ var ToolExecutorWeb = class _ToolExecutorWeb {
12955
13019
  this.registry = registry;
12956
13020
  this.ws = ws;
12957
13021
  }
13022
+ registry;
13023
+ ws;
12958
13024
  round = 0;
12959
13025
  totalRounds = 0;
12960
13026
  hookConfig;
@@ -13512,9 +13578,15 @@ var PRICING_TABLE = {
13512
13578
  "gemini-1.5-flash": { input: 0.075, output: 0.3 },
13513
13579
  // ── DeepSeek ──────────────────────────────────────────────────
13514
13580
  // V4 family (2026-04-23+):1M context, Thinking / Non-Thinking dual-mode, 384K max output
13515
- "deepseek-v4-pro": { input: 1.74, output: 3.48, cacheRead: 0.145 },
13516
- "deepseek-v4-flash": { input: 0.14, output: 0.28, cacheRead: 0.028 },
13517
- // Legacy aliases:retires 2026-07-24 UTC 15:59,官方 route 到 V4 Flash
13581
+ // 费率 2026-08-01 对 api-docs.deepseek.com/quick_start/pricing 官方 USD 表逐项核对。
13582
+ // 修正前 pro 三项整齐高 4×(官方降过价未跟)、flash cacheRead 高 10×(像是按 input 的
13583
+ // 20% 拍脑袋而非抄文档)——`aicli usage` 因此系统性高报 DeepSeek 成本。
13584
+ // 待办:官方已公告峰谷定价(北京时间 9-12 点、14-18 点为平时 2 倍),本表仍是单一费率,
13585
+ // 届时高峰时段会低报;等该策略实际生效后再决定是否引入时段维度。
13586
+ "deepseek-v4-pro": { input: 0.435, output: 0.87, cacheRead: 3625e-6 },
13587
+ "deepseek-v4-flash": { input: 0.14, output: 0.28, cacheRead: 28e-4 },
13588
+ // Legacy aliases:retires 2026-07-24 UTC 15:59,官方 route 到 V4 Flash。
13589
+ // 这几条只服务历史 session 的成本回算,保留当时的费率口径,不随现价改动。
13518
13590
  "deepseek-chat": { input: 0.14, output: 0.28, cacheRead: 0.028 },
13519
13591
  "deepseek-reasoner": { input: 0.14, output: 0.28, cacheRead: 0.028 },
13520
13592
  "deepseek-v3": { input: 0.27, output: 1.1, cacheRead: 0.07 },
@@ -15213,7 +15285,7 @@ Cache: write=${cacheCreate} read=${cacheRead}` : "";
15213
15285
  Cost: ${formatCost(cost)}` : "";
15214
15286
  let memoryLine = "";
15215
15287
  try {
15216
- const { countPendingMemories } = await import("./persistent-memory-EEAGHDFR.js");
15288
+ const { countPendingMemories } = await import("./persistent-memory-PNJCHP33.js");
15217
15289
  const pending = countPendingMemories(ctx.config.getConfigDir());
15218
15290
  if (pending > 0) memoryLine = `
15219
15291
  Memory: \u26A0 ${pending} pending approval \u2014 see the Memory panel or /memory`;
@@ -16022,7 +16094,7 @@ async function handleSecurityReview(args, ctx) {
16022
16094
  async function handleTest(args, ctx) {
16023
16095
  ctx.send({ type: "info", message: "\u{1F9EA} Running tests..." });
16024
16096
  try {
16025
- const { executeTests } = await import("./run-tests-N3ES4YMU.js");
16097
+ const { executeTests } = await import("./run-tests-F7Y6POVK.js");
16026
16098
  const argStr = args.join(" ").trim();
16027
16099
  let testArgs = {};
16028
16100
  if (argStr) {
@@ -16286,7 +16358,7 @@ async function handleMemory(args, ctx) {
16286
16358
  ctx.handleMemoryManage(sub, args[1], sub === "expire" ? args[2] : void 0);
16287
16359
  } else if (sub === "export") {
16288
16360
  if (args[1] === "md") {
16289
- const { exportMemoryEntries: exportMemoryEntries2 } = await import("./persistent-memory-EEAGHDFR.js");
16361
+ const { exportMemoryEntries: exportMemoryEntries2 } = await import("./persistent-memory-PNJCHP33.js");
16290
16362
  ctx.send({
16291
16363
  type: "export_data",
16292
16364
  format: "md",
@@ -154,7 +154,7 @@ ${content}`);
154
154
  }
155
155
  }
156
156
  async function runTaskMode(config, providers, configManager, topic) {
157
- const { TaskOrchestrator } = await import("./task-orchestrator-KLCN25OY.js");
157
+ const { TaskOrchestrator } = await import("./task-orchestrator-LTPRJVLH.js");
158
158
  const orchestrator = new TaskOrchestrator(config, providers, configManager);
159
159
  let interrupted = false;
160
160
  const onSigint = () => {
@@ -190,7 +190,7 @@ async function runTaskMode(config, providers, configManager, topic) {
190
190
  }
191
191
  }
192
192
  async function runDistributedDiscussion(config, providers, topic, port) {
193
- const { HubServer } = await import("./hub-server-XA7HTVLD.js");
193
+ const { HubServer } = await import("./hub-server-QGUSMN22.js");
194
194
  const hub = new HubServer(config, providers, port);
195
195
  let interrupted = false;
196
196
  const onSigint = () => {
@@ -26,6 +26,9 @@ var HubServer = class {
26
26
  this.port = port;
27
27
  this.unassignedRoles = [...config.roles];
28
28
  }
29
+ config;
30
+ providers;
31
+ port;
29
32
  wss = null;
30
33
  httpServer = null;
31
34
  agents = /* @__PURE__ */ new Map();
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CostTracker
4
- } from "./chunk-EWLXBTSC.js";
4
+ } from "./chunk-DQY2DDGS.js";
5
5
  import {
6
6
  McpManager,
7
7
  SNAPSHOT_PROMPT,
@@ -17,12 +17,12 @@ import {
17
17
  scanProject,
18
18
  sessionHasMeaningfulContent,
19
19
  setupProxy
20
- } from "./chunk-2UZ23L5P.js";
20
+ } from "./chunk-NX55D52V.js";
21
21
  import {
22
22
  computeCost,
23
23
  formatCost,
24
24
  getPricing
25
- } from "./chunk-GUOLPI33.js";
25
+ } from "./chunk-EZ6QLHOS.js";
26
26
  import {
27
27
  buildReviewPrompt,
28
28
  buildSecurityReviewPrompt
@@ -50,7 +50,7 @@ import {
50
50
  spawnAgentContext,
51
51
  theme,
52
52
  undoStack
53
- } from "./chunk-PSP4W2MG.js";
53
+ } from "./chunk-QI4AJPRD.js";
54
54
  import {
55
55
  addMemoryEntry,
56
56
  backupMemoryStore,
@@ -76,7 +76,7 @@ import {
76
76
  touchMemoryReferences,
77
77
  updateMemoryApproval,
78
78
  updateMemoryEntry
79
- } from "./chunk-X2V76VPG.js";
79
+ } from "./chunk-4VWME5CO.js";
80
80
  import "./chunk-GLSR2NR3.js";
81
81
  import "./chunk-UUSRWSSX.js";
82
82
  import "./chunk-CKH4KQ4E.js";
@@ -90,13 +90,13 @@ import {
90
90
  formatDoctorReport,
91
91
  loadContextFiles,
92
92
  writeCrashLog
93
- } from "./chunk-3WKUKMBG.js";
93
+ } from "./chunk-ELYDRIKV.js";
94
94
  import {
95
95
  ProviderRegistry
96
- } from "./chunk-ZRBGH245.js";
96
+ } from "./chunk-MJ6JLSPR.js";
97
97
  import {
98
98
  ConfigManager
99
- } from "./chunk-IRSNREEO.js";
99
+ } from "./chunk-DFV7F6S7.js";
100
100
  import {
101
101
  describePlugin,
102
102
  getActivePluginAssets,
@@ -113,7 +113,7 @@ import {
113
113
  trustHook,
114
114
  trustPlugin,
115
115
  untrustHook
116
- } from "./chunk-FOC2YWOF.js";
116
+ } from "./chunk-X2ZXQMN2.js";
117
117
  import {
118
118
  CONTENT_ONLY_STREAM_REMINDER,
119
119
  TEE_FINAL_USER_NUDGE,
@@ -132,12 +132,12 @@ import {
132
132
  stripOuterCodeFence,
133
133
  stripToolCallReminder,
134
134
  teeStreamErrorSummary
135
- } from "./chunk-PSXIVQ3N.js";
135
+ } from "./chunk-HOS7CGBI.js";
136
136
  import {
137
137
  AuthError,
138
138
  ProviderError,
139
139
  RateLimitError
140
- } from "./chunk-5ULLIOVC.js";
140
+ } from "./chunk-TU3L3PW7.js";
141
141
  import {
142
142
  formatGitContextForPrompt,
143
143
  getGitContext,
@@ -146,7 +146,7 @@ import {
146
146
  import {
147
147
  fileCheckpoints
148
148
  } from "./chunk-4BKXL7SM.js";
149
- import "./chunk-U6OV523Y.js";
149
+ import "./chunk-BQXVQKMH.js";
150
150
  import {
151
151
  AGENTIC_BEHAVIOR_GUIDELINE,
152
152
  AUTHOR,
@@ -165,7 +165,7 @@ import {
165
165
  SKILLS_DIR_NAME,
166
166
  VERSION,
167
167
  buildUserIdentityPrompt
168
- } from "./chunk-SVWIUNOA.js";
168
+ } from "./chunk-5DLLJ67Q.js";
169
169
  import {
170
170
  buildChatIndex,
171
171
  clearChatIndex,
@@ -330,6 +330,14 @@ var ABOUT_FEATURES = [
330
330
  "Standalone executable packaging (no Node.js required), Electron desktop app"
331
331
  ];
332
332
  var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
333
+ function formatSpinnerElapsed(startedAt, now = Date.now()) {
334
+ const sec = Math.floor((now - startedAt) / 1e3);
335
+ if (sec < 10) return "";
336
+ if (sec < 60) return ` (${sec}s)`;
337
+ const m = Math.floor(sec / 60);
338
+ const s = sec % 60;
339
+ return ` (${m}m${String(s).padStart(2, "0")}s)`;
340
+ }
333
341
  function createSpinner(text) {
334
342
  if (!process.stdout.isTTY) {
335
343
  return {
@@ -342,10 +350,11 @@ function createSpinner(text) {
342
350
  let frameIdx = 0;
343
351
  let currentText = text;
344
352
  let timer = null;
353
+ let startedAt = Date.now();
345
354
  const render = () => {
346
355
  const frame = SPINNER_FRAMES[frameIdx % SPINNER_FRAMES.length];
347
356
  frameIdx++;
348
- process.stdout.write(`\r${theme.accent(frame)} ${currentText} `);
357
+ process.stdout.write(`\r${theme.accent(frame)} ${currentText}${formatSpinnerElapsed(startedAt)} `);
349
358
  };
350
359
  const clear = () => {
351
360
  process.stdout.write("\r\x1B[2K");
@@ -362,6 +371,7 @@ function createSpinner(text) {
362
371
  },
363
372
  start(t) {
364
373
  currentText = t;
374
+ startedAt = Date.now();
365
375
  if (!timer) {
366
376
  frameIdx = 0;
367
377
  timer = setInterval(render, 80);
@@ -944,7 +954,7 @@ function createProviderCommands() {
944
954
  targetId = args[0];
945
955
  }
946
956
  if (!ctx.providers.has(targetId)) {
947
- ctx.renderer.renderError(`Provider '${targetId}' is not configured. Run: ai-cli config`);
957
+ ctx.renderer.renderError(`Provider '${targetId}' is not configured. Run: aicli config`);
948
958
  return;
949
959
  }
950
960
  const targetProvider = ctx.providers.get(targetId);
@@ -1387,7 +1397,7 @@ No tools match "${filter}".
1387
1397
  const { join: join6 } = await import("path");
1388
1398
  const { existsSync: existsSync6 } = await import("fs");
1389
1399
  const { getGitRoot: getGitRoot2 } = await import("./git-context-EXOEHQSF.js");
1390
- const { MCP_PROJECT_CONFIG_NAME: MCP_PROJECT_CONFIG_NAME2 } = await import("./constants-LJRYL7IN.js");
1400
+ const { MCP_PROJECT_CONFIG_NAME: MCP_PROJECT_CONFIG_NAME2 } = await import("./constants-3UC2F5GC.js");
1391
1401
  const { approveProject, hashMcpFile } = await import("./project-trust-NKYHL3VZ.js");
1392
1402
  const cwd = process.cwd();
1393
1403
  const projectRoot = getGitRoot2(cwd) ?? cwd;
@@ -2366,7 +2376,7 @@ function createReviewCommands() {
2366
2376
  usage: "/test [command|filter]",
2367
2377
  async execute(args, ctx) {
2368
2378
  try {
2369
- const { executeTests } = await import("./run-tests-ADZQ2JWI.js");
2379
+ const { executeTests } = await import("./run-tests-EOHLRWQC.js");
2370
2380
  const argStr = args.join(" ").trim();
2371
2381
  let testArgs = {};
2372
2382
  if (argStr) {
@@ -4483,6 +4493,7 @@ var SetupWizard = class {
4483
4493
  constructor(config) {
4484
4494
  this.config = config;
4485
4495
  }
4496
+ config;
4486
4497
  async runFirstRun() {
4487
4498
  console.log(theme.heading("\nWelcome to ai-cli!\n"));
4488
4499
  console.log("Let's get to know you first, then set up your AI provider.\n");
@@ -4982,6 +4993,7 @@ var CustomCommandManager = class {
4982
4993
  constructor(commandsDir) {
4983
4994
  this.commandsDir = commandsDir;
4984
4995
  }
4996
+ commandsDir;
4985
4997
  commands = /* @__PURE__ */ new Map();
4986
4998
  loadCommands(extraDirs = []) {
4987
4999
  this.commands.clear();
@@ -5579,6 +5591,10 @@ var Repl = class {
5579
5591
  if (options?.maxToolRoundsOverride !== void 0) this.maxToolRoundsOverride = options.maxToolRoundsOverride;
5580
5592
  this.costTracker = new CostTracker(this.config.getConfigDir());
5581
5593
  }
5594
+ providers;
5595
+ sessions;
5596
+ config;
5597
+ events;
5582
5598
  rl;
5583
5599
  currentProvider;
5584
5600
  currentModel;
@@ -7969,7 +7985,7 @@ process.on("unhandledRejection", (reason) => {
7969
7985
  `);
7970
7986
  process.exit(1);
7971
7987
  });
7972
- program.name("ai-cli").description("Cross-platform REPL-style AI CLI with multi-provider support").version(VERSION);
7988
+ program.name("aicli").description("Cross-platform REPL-style AI CLI with multi-provider support").version(VERSION);
7973
7989
  program.option("--provider <name>", "AI provider to use (claude/gemini/deepseek/zhipu/kimi or any custom provider)").option("-m, --model <name>", "Model to use").option("-p, --prompt <text>", "Headless mode: send a single prompt and exit (reads stdin as context if piped)").option("--system <prompt>", "System prompt override (headless mode)").option("--json", "Output result as JSON object (headless mode only)").option("--output-format <format>", "Output format: text (default) | streaming-json (NDJSON per-chunk, headless only)").option("--no-stream", "Disable streaming output").option("--allowed-tools <tools>", "Comma-separated whitelist of tools (e.g. bash,read_file)").option("--blocked-tools <tools>", "Comma-separated blacklist of tools (e.g. bash,write_file)").option("--resume <id>", "Resume a previous session by ID (prefix match supported)").option("--max-tool-rounds <n>", "Max agentic tool-call rounds per conversation (default: 200)").action(async (options) => {
7974
7990
  if (options.prompt !== void 0) {
7975
7991
  await runHeadless(options);
@@ -8017,7 +8033,7 @@ program.command("web").description("Start Web UI server with browser-based chat
8017
8033
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
8018
8034
  process.exit(1);
8019
8035
  }
8020
- const { startWebServer } = await import("./server-PMEZ3HDO.js");
8036
+ const { startWebServer } = await import("./server-REZPCUHW.js");
8021
8037
  await startWebServer({ port, host: options.host });
8022
8038
  });
8023
8039
  program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | logout-all <name> | migrate <name>)").action(async (action, username) => {
@@ -8184,11 +8200,11 @@ program.command("sessions").description("List recent conversation sessions").opt
8184
8200
  console.log(footer + "\n");
8185
8201
  });
8186
8202
  program.command("usage").description("Show token + cost usage grouped by provider/model (cross-session)").option("--days <n>", "Only the last N days (inclusive of today)").option("--month <ym>", "Only a specific month, format YYYY-MM (e.g. 2026-06)").option("--json", "Output as JSON (for scripting)").action(async (options) => {
8187
- const { runUsageCli } = await import("./usage-MNMRX5OE.js");
8203
+ const { runUsageCli } = await import("./usage-XPBLQ4FZ.js");
8188
8204
  await runUsageCli(options);
8189
8205
  });
8190
8206
  program.command("doctor").description("Health check: API keys, config, MCP, recent crashes, tool usage, disk usage").option("--json", "Output as JSON (for scripting)").option("--reset-stats", "Reset accumulated tool usage statistics").action(async (options) => {
8191
- const { runDoctorCli } = await import("./doctor-cli-GOM2GQUK.js");
8207
+ const { runDoctorCli } = await import("./doctor-cli-FPYSCH5H.js");
8192
8208
  const argv = process.argv.slice(2);
8193
8209
  await runDoctorCli({
8194
8210
  json: !!options.json || argv.includes("--json"),
@@ -8197,7 +8213,7 @@ program.command("doctor").description("Health check: API keys, config, MCP, rece
8197
8213
  });
8198
8214
  program.command("batch <action> [arg] [arg2]").description("Anthropic Message Batches: submit | list | status <id> | results <id> [out] | cancel <id>").option("--dry-run", "Parse and validate input without submitting (submit only)").action(async (action, arg, arg2, options) => {
8199
8215
  try {
8200
- const batch = await import("./batch-OWBKG6XZ.js");
8216
+ const batch = await import("./batch-HCTZJMGR.js");
8201
8217
  switch (action) {
8202
8218
  case "submit":
8203
8219
  if (!arg) {
@@ -8240,7 +8256,7 @@ program.command("batch <action> [arg] [arg2]").description("Anthropic Message Ba
8240
8256
  }
8241
8257
  });
8242
8258
  program.command("mcp-serve").description("Start an MCP server over STDIO, exposing aicli's built-in tools to Claude Desktop / Cursor / other MCP clients").option("--allow-destructive", "Allow bash / run_interactive / task_create (always destructive in MCP mode)").option("--allow-outside-cwd", "Allow tool path arguments to escape the sandbox root \u2014 disabled by default").option("--tools <list>", "Comma-separated whitelist of tools to expose (default: all eligible tools)").option("--cwd <path>", "Working directory AND sandbox root (default: current directory)").action(async (options) => {
8243
- const { startMcpServer } = await import("./server-HUWVPJKQ.js");
8259
+ const { startMcpServer } = await import("./server-4NP2ZVLA.js");
8244
8260
  await startMcpServer({
8245
8261
  allowDestructive: !!options.allowDestructive,
8246
8262
  allowOutsideCwd: !!options.allowOutsideCwd,
@@ -8253,7 +8269,7 @@ program.command("pr <action> [target]").description("PR review helpers: review |
8253
8269
  console.error(`Unknown pr action: ${action}. Use review | security-review | summarize.`);
8254
8270
  process.exit(1);
8255
8271
  }
8256
- const { runPrCli } = await import("./pr-Q74YHWN2.js");
8272
+ const { runPrCli } = await import("./pr-KAEI2IK3.js");
8257
8273
  const result = await runPrCli({
8258
8274
  action,
8259
8275
  target,
@@ -8273,8 +8289,8 @@ program.command("pr <action> [target]").description("PR review helpers: review |
8273
8289
  process.exit(result.exitCode);
8274
8290
  });
8275
8291
  program.command("ci").description("Headless PR review (code + security) \u2014 reads git/gh diff, optionally posts to PR. Designed for GitHub Actions.").option("--pr <num>", "PR number or URL; diff fetched via gh pr diff <value>", (v) => /^#?\d+$/.test(v) ? parseInt(v.replace(/^#/, ""), 10) : v).option("--base <ref>", "Base ref for git diff <ref>...HEAD (ignored when --pr set)").option("--post", "Post review as a PR comment (requires gh CLI + GH_TOKEN, needs --pr)").option("--no-update", "Always create a new comment instead of updating the previous aicli review").option("--skip-code", "Skip the code review section").option("--skip-security", "Skip the security review section").option("--detailed", "Use the detailed code-review prompt").option("--max-diff <n>", "Max diff chars sent to the model (default 30000)", (v) => parseInt(v, 10)).option("--provider <id>", "Override provider (default: config.defaultProvider)").option("--model <id>", "Override model").option("--dry-run", "Print result to stdout instead of posting (overrides --post)").option("--json", "Output a structured JSON report").option("--markdown", "Output Markdown report (default)").option("--sarif", "Output SARIF 2.1.0 for code scanning artifacts").option("--fail-on-security-high", "Fail when the security review contains HIGH/CRITICAL findings (default)").option("--no-fail-on-security-high", "Do not fail on security HIGH/CRITICAL findings").option("--fail-on-test-failure", "Fail when the report mentions test failures (default)").option("--no-fail-on-test-failure", "Do not fail on test failure findings").option("--fail-on-lint-failure", "Fail when the report mentions lint/typecheck failures (default)").option("--no-fail-on-lint-failure", "Do not fail on lint/typecheck failure findings").action(async (options) => {
8276
- const { runCi } = await import("./ci-V5GVGYZO.js");
8277
- const { formatCiResult } = await import("./ci-format-CTGDLJTS.js");
8292
+ const { runCi } = await import("./ci-OGJDKUEN.js");
8293
+ const { formatCiResult } = await import("./ci-format-CG6US3KX.js");
8278
8294
  const formats = [options.json, options.markdown, options.sarif].filter(Boolean).length;
8279
8295
  if (formats > 1) {
8280
8296
  console.error("Choose only one output format: --json, --markdown, or --sarif.");
@@ -8432,7 +8448,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
8432
8448
  config.get("customProviders"),
8433
8449
  config.getConfigDir()
8434
8450
  );
8435
- const { startHub } = await import("./hub-4EEDUJED.js");
8451
+ const { startHub } = await import("./hub-5NRTE7PL.js");
8436
8452
  await startHub(
8437
8453
  {
8438
8454
  topic: topic ?? "",
@@ -8513,7 +8529,7 @@ async function runHeadless(options) {
8513
8529
  const providerId = options.provider ?? config.getDefaultProvider();
8514
8530
  if (!providers.has(providerId)) {
8515
8531
  process.stderr.write(
8516
- `Error: Provider '${providerId}' is not configured. Run: ai-cli config
8532
+ `Error: Provider '${providerId}' is not configured. Run: aicli config
8517
8533
  `
8518
8534
  );
8519
8535
  process.exit(1);
@@ -8647,7 +8663,7 @@ async function startRepl(options) {
8647
8663
  const wizard = new SetupWizard(config);
8648
8664
  const configured = await wizard.runFirstRun();
8649
8665
  if (!configured) {
8650
- console.log('\nSetup cancelled. Run "ai-cli config" to configure later.');
8666
+ console.log('\nSetup cancelled. Run "aicli config" to configure later.');
8651
8667
  process.exit(0);
8652
8668
  }
8653
8669
  }
@@ -8672,14 +8688,14 @@ async function startRepl(options) {
8672
8688
  );
8673
8689
  if (providers.listAvailable().length === 0) {
8674
8690
  console.error(
8675
- "\nNo providers configured. Run: ai-cli config\n"
8691
+ "\nNo providers configured. Run: aicli config\n"
8676
8692
  );
8677
8693
  process.exit(1);
8678
8694
  }
8679
8695
  if (options.provider && !providers.has(options.provider)) {
8680
8696
  console.error(
8681
8697
  `
8682
- Provider '${options.provider}' is not configured. Run: ai-cli config
8698
+ Provider '${options.provider}' is not configured. Run: aicli config
8683
8699
  `
8684
8700
  );
8685
8701
  process.exit(1);
@@ -28,9 +28,9 @@ import {
28
28
  touchMemoryReferences,
29
29
  updateMemoryApproval,
30
30
  updateMemoryEntry
31
- } from "./chunk-X2V76VPG.js";
31
+ } from "./chunk-4VWME5CO.js";
32
32
  import "./chunk-HOSJZMQS.js";
33
- import "./chunk-SVWIUNOA.js";
33
+ import "./chunk-5DLLJ67Q.js";
34
34
  import "./chunk-B5TYJO7V.js";
35
35
  import "./chunk-IW3Q7AE5.js";
36
36
  export {