@qwen-code/qwen-code 0.16.0-preview.0 → 0.16.1-nightly.20260524.84f408017

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 (89) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +39 -37
  2. package/bundled/qc-helper/docs/features/_meta.ts +2 -0
  3. package/bundled/qc-helper/docs/features/approval-mode.md +119 -2
  4. package/bundled/qc-helper/docs/features/auto-mode.md +263 -0
  5. package/bundled/qc-helper/docs/features/commands.md +11 -10
  6. package/bundled/qc-helper/docs/features/skills.md +3 -0
  7. package/bundled/qc-helper/docs/features/structured-output.md +309 -0
  8. package/bundled/qc-helper/docs/features/sub-agents.md +47 -5
  9. package/bundled/qc-helper/docs/qwen-serve.md +119 -14
  10. package/bundled/review/SKILL.md +12 -3
  11. package/chunks/{agent-ZNQPH67I.js → agent-QFQGDV7B.js} +9 -11
  12. package/chunks/{anthropicContentGenerator-ICBDZ6R2.js → anthropicContentGenerator-RQJNXJIY.js} +6 -3
  13. package/chunks/{askUserQuestion-WQILGUSQ.js → askUserQuestion-PQPMPNM3.js} +1 -1
  14. package/chunks/{ca-S3XJMT6P.js → ca-UZ7BANMN.js} +3 -3
  15. package/chunks/{chunk-XVHR7ATJ.js → chunk-4AOCVI6J.js} +1 -0
  16. package/chunks/{chunk-MNPZ2WO6.js → chunk-6JQC5PYU.js} +9104 -3955
  17. package/chunks/{chunk-AEJ2DKLP.js → chunk-C6WMLUNB.js} +1 -1
  18. package/chunks/{chunk-PPHYLJSS.js → chunk-CAVZVZX6.js} +2 -2
  19. package/chunks/{chunk-VTPOO6GV.js → chunk-CSWBPY3P.js} +1 -1
  20. package/chunks/{chunk-NAID3ZWF.js → chunk-DMIMF3CG.js} +1 -1
  21. package/chunks/{chunk-2B7UBDY5.js → chunk-GGNTZ2NH.js} +90 -19
  22. package/chunks/{chunk-C3LHPHN2.js → chunk-JUAMIT3V.js} +1227 -657
  23. package/chunks/{chunk-EDYSNFEM.js → chunk-L5E26RN6.js} +2 -2
  24. package/chunks/{chunk-7QXHXMC6.js → chunk-LKSMYCUK.js} +96 -20
  25. package/chunks/chunk-M2TQETH7.js +379 -0
  26. package/chunks/{chunk-CW44BRRA.js → chunk-MAY32HXD.js} +375 -0
  27. package/chunks/{chunk-FZIUV27X.js → chunk-PVVL5Q3W.js} +31 -0
  28. package/chunks/chunk-TEES5V4K.js +956 -0
  29. package/chunks/chunk-UL4NCM6X.js +19126 -0
  30. package/chunks/{chunk-YHEAJFCI.js → chunk-USE2VQ5P.js} +3 -0
  31. package/chunks/{chunk-JYQUJ5DS.js → chunk-YJLGXDQJ.js} +1 -1
  32. package/chunks/{contextCommand-IGBCEXI4.js → contextCommand-3FI5VRHY.js} +11 -13
  33. package/chunks/{cron-create-AVI3Q267.js → cron-create-IGYXQVG4.js} +27 -1
  34. package/chunks/{cron-delete-ZCEGDXXV.js → cron-delete-ETKIZCWT.js} +1 -1
  35. package/chunks/{cron-list-VN653OK5.js → cron-list-BVCUSWRU.js} +1 -1
  36. package/chunks/{de-MNR4SMAI.js → de-V4IE2OOZ.js} +3 -3
  37. package/chunks/{dist-RRYNPBOE.js → dist-4L54HRX2.js} +2 -2
  38. package/chunks/{dist-WP4AH3VK.js → dist-BXDUQ2QY.js} +1 -1
  39. package/chunks/{dist-M6GFCZ7S.js → dist-MN2PDDPR.js} +1 -1
  40. package/chunks/{edit-74Q4AFHQ.js → edit-JXJILHZW.js} +22 -12
  41. package/chunks/{en-FIUWJSZR.js → en-HGJ2SPLM.js} +4 -3
  42. package/chunks/{enter-worktree-H72HXC7D.js → enter-worktree-HQ3RBRIA.js} +35 -11
  43. package/chunks/{exit-worktree-FGIQO3S3.js → exit-worktree-73TYZY5X.js} +35 -11
  44. package/chunks/{exitPlanMode-NBR2PK2D.js → exitPlanMode-WEETA2GM.js} +9 -11
  45. package/chunks/{fr-OFJFHLCR.js → fr-CJULI7ZX.js} +3 -3
  46. package/chunks/{geminiContentGenerator-33RP4WKD.js → geminiContentGenerator-TVVMIHRE.js} +1 -1
  47. package/chunks/{glob-WEE3CJL6.js → glob-HZYBHMPB.js} +9 -11
  48. package/chunks/{grep-DZKSBFZK.js → grep-RO7NJDWP.js} +9 -11
  49. package/chunks/{ja-V6OQ6VL7.js → ja-L7CHRQEW.js} +3 -3
  50. package/chunks/{ls-6F3VSP6S.js → ls-7HD6XG3V.js} +1 -1
  51. package/chunks/{lsp-67Y7DJN5.js → lsp-ZZSFCIWD.js} +1 -1
  52. package/chunks/{monitor-EDZWEZVS.js → monitor-IOU376UD.js} +21 -11
  53. package/chunks/notebook-edit-7NXIUSLW.js +756 -0
  54. package/chunks/{openaiContentGenerator-5NQG3W64.js → openaiContentGenerator-BXS7CQJ2.js} +9 -8
  55. package/chunks/{pt-ZLE6SA4A.js → pt-M6JULLEQ.js} +3 -3
  56. package/chunks/{qwenContentGenerator-4DPUUS6R.js → qwenContentGenerator-7VOJGPBD.js} +11 -13
  57. package/chunks/{qwenOAuth2-JE7H47TE.js → qwenOAuth2-EEJGROP7.js} +7 -1
  58. package/chunks/{read-file-CQOF7BQ2.js → read-file-G4TFJFZ2.js} +4 -5
  59. package/chunks/{ripGrep-KR5LKGTI.js → ripGrep-IMMYV3HQ.js} +9 -11
  60. package/chunks/{ru-A4OHIUNN.js → ru-QILM4HBC.js} +3 -3
  61. package/chunks/{send-message-GB4AQZNC.js → send-message-ULK4MQXJ.js} +22 -1
  62. package/chunks/{serve-GAD2PEST.js → serve-5EHHVHBV.js} +13728 -3026
  63. package/chunks/{shell-E2HMCBGR.js → shell-AXZQIDDU.js} +9 -11
  64. package/chunks/{skill-KDZH6UZ6.js → skill-IMUVSRRZ.js} +19 -6
  65. package/chunks/{src-LY4RU5AI.js → src-VYNNTRVU.js} +205 -13
  66. package/chunks/{syntheticOutput-HFL3DE7R.js → syntheticOutput-IS2X5OZ2.js} +2 -2
  67. package/chunks/{task-stop-ZQF26RXS.js → task-stop-7QSJGSSP.js} +1 -1
  68. package/chunks/{todoWrite-U4SC643O.js → todoWrite-7CVACFUX.js} +2 -2
  69. package/chunks/{tool-search-U4XQVLFU.js → tool-search-BTGLGBDQ.js} +4 -5
  70. package/chunks/{web-fetch-BRWZ4WSE.js → web-fetch-ENQ2I5JA.js} +5 -2
  71. package/chunks/{write-file-NBLRMNGB.js → write-file-BNUIFGU4.js} +19 -12
  72. package/chunks/{zh-V32QONGV.js → zh-PWL2NKY3.js} +4 -3
  73. package/chunks/{zh-TW-552S24LR.js → zh-TW-S3YGWICZ.js} +4 -3
  74. package/cli.js +14841 -49052
  75. package/locales/ca.js +4 -5
  76. package/locales/de.js +4 -5
  77. package/locales/en.js +6 -5
  78. package/locales/fr.js +4 -5
  79. package/locales/ja.js +4 -5
  80. package/locales/pt.js +4 -5
  81. package/locales/ru.js +4 -5
  82. package/locales/zh-TW.js +5 -4
  83. package/locales/zh.js +5 -4
  84. package/package.json +2 -2
  85. package/chunks/chunk-3MBY4GKN.js +0 -350
  86. package/chunks/chunk-5P5XGNYH.js +0 -93
  87. package/chunks/chunk-JHMX4QTD.js +0 -2306
  88. package/chunks/chunk-SYCJMSIJ.js +0 -82
  89. package/chunks/chunk-Y6Z2O3WR.js +0 -33
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  import {
4
4
  ToolNames
5
- } from "./chunk-FZIUV27X.js";
5
+ } from "./chunk-PVVL5Q3W.js";
6
6
  import {
7
7
  init_esbuild_shims
8
8
  } from "./chunk-A4BMJM77.js";
@@ -85,7 +85,7 @@ async function checkPriorRead(cache, filePath, verb, options = {}) {
85
85
  }
86
86
  if (status.state === "fresh" && status.entry.lastReadAt !== void 0 && !status.entry.lastReadCacheable) {
87
87
  const verbBare2 = verb === "editing" ? "edit" : "overwrite";
88
- const raw2 = `File ${filePath} is a binary / image / audio / video / PDF / notebook payload that the ${ToolNames.READ_FILE} tool returns as a structured value rather than as plain text. The Edit / WriteFile tools cannot mutate that payload safely \u2014 re-reading it would not change this. Use a different mechanism (e.g. shell tool with a binary-aware writer) if you need to ${verbBare2} it.`;
88
+ const raw2 = `File ${filePath} is a binary / image / audio / video / PDF / notebook payload that the ${ToolNames.READ_FILE} tool returns as a structured value rather than as plain text. The Edit / WriteFile tools cannot mutate that payload safely \u2014 re-reading it would not change this. If this is a Jupyter notebook (.ipynb), use the ${ToolNames.NOTEBOOK_EDIT} tool for cell-level edits after reading it. For other non-text files, use a different mechanism (e.g. shell tool with an appropriate writer) if you need to ${verbBare2} it.`;
89
89
  return {
90
90
  ok: false,
91
91
  type: "edit_requires_prior_read" /* EDIT_REQUIRES_PRIOR_READ */,
@@ -2,16 +2,16 @@
2
2
  "use strict";
3
3
  import {
4
4
  RequestTokenizer
5
- } from "./chunk-NAID3ZWF.js";
5
+ } from "./chunk-DMIMF3CG.js";
6
6
  import {
7
7
  buildRuntimeFetchOptions,
8
8
  redactProxyError
9
- } from "./chunk-VTPOO6GV.js";
9
+ } from "./chunk-CSWBPY3P.js";
10
10
  import {
11
11
  OpenAIContentConverter,
12
12
  TaggedThinkingParser,
13
13
  openaiRequestCaptureContext
14
- } from "./chunk-C3LHPHN2.js";
14
+ } from "./chunk-JUAMIT3V.js";
15
15
  import {
16
16
  CAPPED_DEFAULT_MAX_TOKENS,
17
17
  DASHSCOPE_PROXY_BASE_URL,
@@ -19,9 +19,10 @@ import {
19
19
  DEFAULT_MAX_RETRIES,
20
20
  DEFAULT_TIMEOUT,
21
21
  hasExplicitOutputLimit,
22
+ runtimeDiagnostics,
22
23
  safeJsonParse,
23
24
  tokenLimit
24
- } from "./chunk-CW44BRRA.js";
25
+ } from "./chunk-MAY32HXD.js";
25
26
  import {
26
27
  GenerateContentResponse
27
28
  } from "./chunk-T4VD6OJ4.js";
@@ -6902,6 +6903,24 @@ OpenAI.Containers = Containers;
6902
6903
  init_esbuild_shims();
6903
6904
 
6904
6905
  // packages/core/src/core/openaiContentGenerator/provider/default.ts
6906
+ function shouldMirrorReasoningContentForQwen3(model) {
6907
+ return model.toLowerCase().includes("qwen3");
6908
+ }
6909
+ __name(shouldMirrorReasoningContentForQwen3, "shouldMirrorReasoningContentForQwen3");
6910
+ function mirrorReasoningContentToReasoning(message) {
6911
+ if (message.role !== "assistant") {
6912
+ return message;
6913
+ }
6914
+ const assistant = message;
6915
+ if (typeof assistant.reasoning_content !== "string" || assistant.reasoning_content.length === 0 || typeof assistant.reasoning === "string") {
6916
+ return message;
6917
+ }
6918
+ return {
6919
+ ...assistant,
6920
+ reasoning: assistant.reasoning_content
6921
+ };
6922
+ }
6923
+ __name(mirrorReasoningContentToReasoning, "mirrorReasoningContentToReasoning");
6905
6924
  var DefaultOpenAICompatibleProvider = class {
6906
6925
  static {
6907
6926
  __name(this, "DefaultOpenAICompatibleProvider");
@@ -6945,8 +6964,10 @@ var DefaultOpenAICompatibleProvider = class {
6945
6964
  buildRequest(request, _userPromptId) {
6946
6965
  const extraBody = this.contentGeneratorConfig.extra_body;
6947
6966
  const requestWithTokenLimits = this.applyOutputTokenLimit(request);
6967
+ const messages = shouldMirrorReasoningContentForQwen3(request.model) ? requestWithTokenLimits.messages.map(mirrorReasoningContentToReasoning) : requestWithTokenLimits.messages;
6948
6968
  return {
6949
6969
  ...requestWithTokenLimits,
6970
+ messages,
6950
6971
  ...extraBody ? extraBody : {}
6951
6972
  };
6952
6973
  }
@@ -7296,6 +7317,25 @@ var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider
7296
7317
 
7297
7318
  // packages/core/src/core/openaiContentGenerator/provider/deepseek.ts
7298
7319
  init_esbuild_shims();
7320
+
7321
+ // packages/core/src/core/openaiContentGenerator/provider/utils.ts
7322
+ init_esbuild_shims();
7323
+ function ensureReasoningContentOnAssistantMessage(message) {
7324
+ if (message.role !== "assistant") {
7325
+ return message;
7326
+ }
7327
+ const assistant = message;
7328
+ if (typeof assistant.reasoning_content === "string") {
7329
+ return message;
7330
+ }
7331
+ return {
7332
+ ...assistant,
7333
+ reasoning_content: ""
7334
+ };
7335
+ }
7336
+ __name(ensureReasoningContentOnAssistantMessage, "ensureReasoningContentOnAssistantMessage");
7337
+
7338
+ // packages/core/src/core/openaiContentGenerator/provider/deepseek.ts
7299
7339
  function isDeepSeekHostname(contentGeneratorConfig) {
7300
7340
  const baseUrl = contentGeneratorConfig.baseUrl ?? "";
7301
7341
  if (!baseUrl) return false;
@@ -7347,7 +7387,7 @@ var DeepSeekOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProv
7347
7387
  }
7348
7388
  const messages = reshaped.messages.map((message) => {
7349
7389
  const flattened = flattenContentParts(message);
7350
- return ensureReasoningContentOnToolCalls(flattened);
7390
+ return ensureReasoningContentOnAssistantMessage(flattened);
7351
7391
  });
7352
7392
  return {
7353
7393
  ...reshaped,
@@ -7409,20 +7449,6 @@ function translateReasoningEffort(request) {
7409
7449
  return next;
7410
7450
  }
7411
7451
  __name(translateReasoningEffort, "translateReasoningEffort");
7412
- function ensureReasoningContentOnToolCalls(message) {
7413
- if (message.role !== "assistant") {
7414
- return message;
7415
- }
7416
- const extended = message;
7417
- if (typeof extended.reasoning_content === "string" && extended.reasoning_content.length > 0) {
7418
- return message;
7419
- }
7420
- return {
7421
- ...extended,
7422
- reasoning_content: ""
7423
- };
7424
- }
7425
- __name(ensureReasoningContentOnToolCalls, "ensureReasoningContentOnToolCalls");
7426
7452
 
7427
7453
  // packages/core/src/core/openaiContentGenerator/provider/openrouter.ts
7428
7454
  init_esbuild_shims();
@@ -7524,6 +7550,50 @@ function stripReasoningContent(message) {
7524
7550
  }
7525
7551
  __name(stripReasoningContent, "stripReasoningContent");
7526
7552
 
7553
+ // packages/core/src/core/openaiContentGenerator/provider/mimo.ts
7554
+ init_esbuild_shims();
7555
+ function isMiMoProvider(contentGeneratorConfig) {
7556
+ const baseUrl = contentGeneratorConfig.baseUrl ?? "";
7557
+ if (baseUrl) {
7558
+ try {
7559
+ const hostname = new URL(baseUrl).hostname.toLowerCase();
7560
+ if (hostname === "xiaomimimo.com" || hostname.endsWith(".xiaomimimo.com")) {
7561
+ return true;
7562
+ }
7563
+ } catch {
7564
+ }
7565
+ }
7566
+ const model = contentGeneratorConfig.model ?? "";
7567
+ return model.toLowerCase().startsWith("mimo-");
7568
+ }
7569
+ __name(isMiMoProvider, "isMiMoProvider");
7570
+ var MiMoOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProvider {
7571
+ static {
7572
+ __name(this, "MiMoOpenAICompatibleProvider");
7573
+ }
7574
+ constructor(contentGeneratorConfig, cliConfig) {
7575
+ super(contentGeneratorConfig, cliConfig);
7576
+ }
7577
+ static isMiMoProvider = isMiMoProvider;
7578
+ buildRequest(request, userPromptId) {
7579
+ const baseRequest = super.buildRequest(request, userPromptId);
7580
+ if (!baseRequest.messages?.length) {
7581
+ return baseRequest;
7582
+ }
7583
+ return {
7584
+ ...baseRequest,
7585
+ messages: baseRequest.messages.map(
7586
+ ensureReasoningContentOnAssistantMessage
7587
+ )
7588
+ };
7589
+ }
7590
+ getRequestContextOverrides() {
7591
+ return {
7592
+ splitToolMedia: this.contentGeneratorConfig.splitToolMedia ?? true
7593
+ };
7594
+ }
7595
+ };
7596
+
7527
7597
  // packages/core/src/core/openaiContentGenerator/pipeline.ts
7528
7598
  init_esbuild_shims();
7529
7599
  import { setMaxListeners } from "node:events";
@@ -8120,6 +8190,7 @@ var ContentGenerationPipeline = class {
8120
8190
  isStreaming
8121
8191
  );
8122
8192
  openaiRequestCaptureContext.getStore()?.(openaiRequest);
8193
+ runtimeDiagnostics.recordOpenAIWireRequest(openaiRequest);
8123
8194
  const result = await executor(openaiRequest, context);
8124
8195
  return result;
8125
8196
  } catch (error) {
@@ -8138,6 +8209,7 @@ var ContentGenerationPipeline = class {
8138
8209
  */
8139
8210
  createRequestContext(request, isStreaming) {
8140
8211
  const effectiveModel = request.model || this.contentGeneratorConfig.model;
8212
+ const providerOverrides = this.config.provider.getRequestContextOverrides?.() ?? {};
8141
8213
  const toolCallParser = isStreaming ? new StreamingToolCallParser() : void 0;
8142
8214
  const responseParsingOptions = this.config.provider.getResponseParsingOptions?.();
8143
8215
  const taggedThinkingParser = isStreaming && responseParsingOptions?.taggedThinkingTags ? new TaggedThinkingParser() : void 0;
@@ -8145,7 +8217,7 @@ var ContentGenerationPipeline = class {
8145
8217
  model: effectiveModel,
8146
8218
  modalities: this.contentGeneratorConfig.modalities ?? {},
8147
8219
  startTime: Date.now(),
8148
- splitToolMedia: this.contentGeneratorConfig.splitToolMedia ?? false,
8220
+ splitToolMedia: providerOverrides.splitToolMedia ?? this.contentGeneratorConfig.splitToolMedia ?? false,
8149
8221
  ...toolCallParser ? { toolCallParser } : {},
8150
8222
  ...responseParsingOptions ? { responseParsingOptions } : {},
8151
8223
  ...taggedThinkingParser ? { taggedThinkingParser } : {}
@@ -8337,6 +8409,9 @@ function determineProvider(contentGeneratorConfig, cliConfig) {
8337
8409
  cliConfig
8338
8410
  );
8339
8411
  }
8412
+ if (MiMoOpenAICompatibleProvider.isMiMoProvider(config)) {
8413
+ return new MiMoOpenAICompatibleProvider(contentGeneratorConfig, cliConfig);
8414
+ }
8340
8415
  if (OpenRouterOpenAICompatibleProvider.isOpenRouterProvider(config)) {
8341
8416
  return new OpenRouterOpenAICompatibleProvider(
8342
8417
  contentGeneratorConfig,
@@ -8371,6 +8446,7 @@ export {
8371
8446
  OpenRouterOpenAICompatibleProvider,
8372
8447
  MiniMaxOpenAICompatibleProvider,
8373
8448
  MistralOpenAICompatibleProvider,
8449
+ MiMoOpenAICompatibleProvider,
8374
8450
  ContentGenerationPipeline,
8375
8451
  EnhancedErrorHandler,
8376
8452
  OpenAIContentGenerator,
@@ -0,0 +1,379 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import {
4
+ resolveBundleDir
5
+ } from "./chunk-6JQC5PYU.js";
6
+ import {
7
+ Storage
8
+ } from "./chunk-XP27SJMH.js";
9
+ import {
10
+ init_esbuild_shims
11
+ } from "./chunk-A4BMJM77.js";
12
+ import {
13
+ __glob,
14
+ __name
15
+ } from "./chunk-J2S4EL5Y.js";
16
+
17
+ // packages/cli/src/utils/stdioHelpers.ts
18
+ init_esbuild_shims();
19
+ var writeStdoutLine = /* @__PURE__ */ __name((message) => {
20
+ process.stdout.write(message.endsWith("\n") ? message : `${message}
21
+ `);
22
+ }, "writeStdoutLine");
23
+ var writeStderrLine = /* @__PURE__ */ __name((message) => {
24
+ process.stderr.write(message.endsWith("\n") ? message : `${message}
25
+ `);
26
+ }, "writeStderrLine");
27
+ var clearScreen = /* @__PURE__ */ __name(() => {
28
+ console.clear();
29
+ }, "clearScreen");
30
+
31
+ // packages/cli/src/i18n/index.ts
32
+ init_esbuild_shims();
33
+ import * as fs from "node:fs";
34
+ import * as path from "node:path";
35
+ import { pathToFileURL } from "node:url";
36
+
37
+ // packages/cli/src/i18n/languages.ts
38
+ init_esbuild_shims();
39
+ var SUPPORTED_LANGUAGES = [
40
+ {
41
+ code: "en",
42
+ id: "en-US",
43
+ fullName: "English",
44
+ nativeName: "English"
45
+ },
46
+ {
47
+ code: "zh-TW",
48
+ id: "zh-TW",
49
+ fullName: "Traditional Chinese",
50
+ nativeName: "\u7E41\u9AD4\u4E2D\u6587",
51
+ strictParity: true
52
+ },
53
+ {
54
+ code: "zh",
55
+ id: "zh-CN",
56
+ fullName: "Chinese",
57
+ nativeName: "\u4E2D\u6587",
58
+ strictParity: true
59
+ },
60
+ {
61
+ code: "ru",
62
+ id: "ru-RU",
63
+ fullName: "Russian",
64
+ nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439"
65
+ },
66
+ {
67
+ code: "de",
68
+ id: "de-DE",
69
+ fullName: "German",
70
+ nativeName: "Deutsch"
71
+ },
72
+ {
73
+ code: "ja",
74
+ id: "ja-JP",
75
+ fullName: "Japanese",
76
+ nativeName: "\u65E5\u672C\u8A9E"
77
+ },
78
+ {
79
+ code: "pt",
80
+ id: "pt-BR",
81
+ fullName: "Portuguese",
82
+ nativeName: "Portugu\xEAs"
83
+ },
84
+ {
85
+ code: "fr",
86
+ id: "fr-FR",
87
+ fullName: "French",
88
+ nativeName: "Fran\xE7ais"
89
+ },
90
+ {
91
+ code: "ca",
92
+ id: "ca-ES",
93
+ fullName: "Catalan",
94
+ nativeName: "Catal\xE0"
95
+ }
96
+ ];
97
+ function normalizeLanguageCandidate(input) {
98
+ return input.trim().replace(/_/g, "-").toLowerCase();
99
+ }
100
+ __name(normalizeLanguageCandidate, "normalizeLanguageCandidate");
101
+ function matchesLocaleToken(candidate, token) {
102
+ return candidate === token || candidate.startsWith(`${token}-`) || candidate.startsWith(`${token}.`) || candidate.startsWith(`${token}@`);
103
+ }
104
+ __name(matchesLocaleToken, "matchesLocaleToken");
105
+ function getMatchedLocaleTokenLength(candidate, language) {
106
+ const code = language.code.toLowerCase();
107
+ const id = language.id.toLowerCase();
108
+ if (matchesLocaleToken(candidate, id)) {
109
+ return id.length;
110
+ }
111
+ if (matchesLocaleToken(candidate, code)) {
112
+ return code.length;
113
+ }
114
+ return void 0;
115
+ }
116
+ __name(getMatchedLocaleTokenLength, "getMatchedLocaleTokenLength");
117
+ function resolveSupportedLanguage(input) {
118
+ const normalized = normalizeLanguageCandidate(input);
119
+ if (!normalized) {
120
+ return void 0;
121
+ }
122
+ let bestMatch;
123
+ for (const language of SUPPORTED_LANGUAGES) {
124
+ if (normalized === language.fullName.toLowerCase() || language.nativeName && normalized === language.nativeName.toLowerCase()) {
125
+ return language.code;
126
+ }
127
+ const tokenLength = getMatchedLocaleTokenLength(normalized, language);
128
+ if (tokenLength !== void 0 && (!bestMatch || tokenLength > bestMatch.tokenLength)) {
129
+ bestMatch = { code: language.code, tokenLength };
130
+ }
131
+ }
132
+ return bestMatch?.code;
133
+ }
134
+ __name(resolveSupportedLanguage, "resolveSupportedLanguage");
135
+ function getLanguageNameFromLocale(locale) {
136
+ const resolved = resolveSupportedLanguage(locale);
137
+ const lang = resolved ? SUPPORTED_LANGUAGES.find((language) => language.code === resolved) : void 0;
138
+ return lang?.fullName || "English";
139
+ }
140
+ __name(getLanguageNameFromLocale, "getLanguageNameFromLocale");
141
+ function getLanguageSettingsOptions() {
142
+ return [
143
+ { value: "auto", label: "Auto (detect from system)" },
144
+ ...SUPPORTED_LANGUAGES.map((l) => ({
145
+ value: l.code,
146
+ label: l.nativeName ? `${l.nativeName} (${l.fullName})` : `${l.fullName} (${l.id})`
147
+ }))
148
+ ];
149
+ }
150
+ __name(getLanguageSettingsOptions, "getLanguageSettingsOptions");
151
+ function getSupportedLanguageIds(separator = "|") {
152
+ return SUPPORTED_LANGUAGES.map((l) => l.id).join(separator);
153
+ }
154
+ __name(getSupportedLanguageIds, "getSupportedLanguageIds");
155
+
156
+ // packages/cli/src/i18n/translationDict.ts
157
+ init_esbuild_shims();
158
+ function getTranslationModuleExport(module) {
159
+ return Object.prototype.hasOwnProperty.call(module, "default") ? module["default"] : module;
160
+ }
161
+ __name(getTranslationModuleExport, "getTranslationModuleExport");
162
+ function isTranslationDict(value) {
163
+ return value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0;
164
+ }
165
+ __name(isTranslationDict, "isTranslationDict");
166
+
167
+ // packages/cli/src/i18n/mustTranslateKeys.ts
168
+ init_esbuild_shims();
169
+
170
+ // import("./locales/**/*.js") in packages/cli/src/i18n/index.ts
171
+ var globImport_locales_js = __glob({
172
+ "./locales/ca.js": () => import("./ca-UZ7BANMN.js"),
173
+ "./locales/de.js": () => import("./de-V4IE2OOZ.js"),
174
+ "./locales/en.js": () => import("./en-HGJ2SPLM.js"),
175
+ "./locales/fr.js": () => import("./fr-CJULI7ZX.js"),
176
+ "./locales/ja.js": () => import("./ja-L7CHRQEW.js"),
177
+ "./locales/pt.js": () => import("./pt-M6JULLEQ.js"),
178
+ "./locales/ru.js": () => import("./ru-QILM4HBC.js"),
179
+ "./locales/zh-TW.js": () => import("./zh-TW-S3YGWICZ.js"),
180
+ "./locales/zh.js": () => import("./zh-PWL2NKY3.js")
181
+ });
182
+
183
+ // packages/cli/src/i18n/index.ts
184
+ var currentLanguage = "en";
185
+ var translations = {};
186
+ var translationCache = {};
187
+ var loadingPromises = {};
188
+ var getBuiltinLocalesDir = /* @__PURE__ */ __name(() => path.join(resolveBundleDir(import.meta.url), "locales"), "getBuiltinLocalesDir");
189
+ var getUserLocalesDir = /* @__PURE__ */ __name(() => path.join(Storage.getGlobalQwenDir(), "locales"), "getUserLocalesDir");
190
+ var getLocalePath = /* @__PURE__ */ __name((lang, useUserDir = false) => {
191
+ const baseDir = useUserDir ? getUserLocalesDir() : getBuiltinLocalesDir();
192
+ return path.join(baseDir, `${lang}.js`);
193
+ }, "getLocalePath");
194
+ function detectSystemLanguage() {
195
+ const envLang = process.env["QWEN_CODE_LANG"] || process.env["LANG"];
196
+ if (envLang) {
197
+ const resolved = resolveSupportedLanguage(envLang);
198
+ if (resolved) {
199
+ return resolved;
200
+ }
201
+ }
202
+ try {
203
+ const locale = Intl.DateTimeFormat().resolvedOptions().locale;
204
+ const resolved = resolveSupportedLanguage(locale);
205
+ if (resolved) {
206
+ return resolved;
207
+ }
208
+ } catch {
209
+ }
210
+ return "en";
211
+ }
212
+ __name(detectSystemLanguage, "detectSystemLanguage");
213
+ async function tryImportTranslations(moduleSpecifier) {
214
+ try {
215
+ const module = await import(moduleSpecifier);
216
+ const result = getTranslationModuleExport(module);
217
+ if (isTranslationDict(result)) {
218
+ return { translations: result };
219
+ }
220
+ return {
221
+ error: new Error("Module loaded but result is empty or invalid")
222
+ };
223
+ } catch (error) {
224
+ return {
225
+ error: error instanceof Error ? error : new Error(String(error))
226
+ };
227
+ }
228
+ }
229
+ __name(tryImportTranslations, "tryImportTranslations");
230
+ async function tryImportBundledTranslations(lang) {
231
+ try {
232
+ const module = await globImport_locales_js(`./locales/${lang}.js`);
233
+ const result = getTranslationModuleExport(module);
234
+ if (isTranslationDict(result)) {
235
+ return { translations: result };
236
+ }
237
+ return {
238
+ error: new Error("Module loaded but result is empty or invalid")
239
+ };
240
+ } catch (error) {
241
+ return {
242
+ error: error instanceof Error ? error : new Error(String(error))
243
+ };
244
+ }
245
+ }
246
+ __name(tryImportBundledTranslations, "tryImportBundledTranslations");
247
+ async function loadTranslationsAsync(lang) {
248
+ if (translationCache[lang]) {
249
+ return translationCache[lang];
250
+ }
251
+ const existingPromise = loadingPromises[lang];
252
+ if (existingPromise) {
253
+ return existingPromise;
254
+ }
255
+ const loadPromise = (async () => {
256
+ const userJsPath = getLocalePath(lang, true);
257
+ if (fs.existsSync(getUserLocalesDir()) && fs.existsSync(userJsPath)) {
258
+ const userResult = await tryImportTranslations(
259
+ pathToFileURL(userJsPath).href
260
+ );
261
+ if (userResult.translations) {
262
+ translationCache[lang] = userResult.translations;
263
+ return userResult.translations;
264
+ }
265
+ writeStderrLine(
266
+ `Failed to load translations from user directory for ${lang}: ${userResult.error.message}`
267
+ );
268
+ }
269
+ const builtinJsPath = getLocalePath(lang, false);
270
+ const builtinModuleSpecifiers = [];
271
+ if (fs.existsSync(getBuiltinLocalesDir()) && fs.existsSync(builtinJsPath)) {
272
+ builtinModuleSpecifiers.push(pathToFileURL(builtinJsPath).href);
273
+ }
274
+ let lastBuiltinError;
275
+ for (const moduleSpecifier of builtinModuleSpecifiers) {
276
+ const builtinResult = await tryImportTranslations(moduleSpecifier);
277
+ if (builtinResult.translations) {
278
+ translationCache[lang] = builtinResult.translations;
279
+ return builtinResult.translations;
280
+ }
281
+ lastBuiltinError = builtinResult.error;
282
+ }
283
+ const bundledBuiltinResult = await tryImportBundledTranslations(lang);
284
+ if (bundledBuiltinResult.translations) {
285
+ translationCache[lang] = bundledBuiltinResult.translations;
286
+ return bundledBuiltinResult.translations;
287
+ }
288
+ lastBuiltinError = bundledBuiltinResult.error;
289
+ if (lastBuiltinError) {
290
+ writeStderrLine(
291
+ `Failed to load JS translations for ${lang}: ${lastBuiltinError.message}`
292
+ );
293
+ }
294
+ translationCache[lang] = {};
295
+ return {};
296
+ })();
297
+ loadingPromises[lang] = loadPromise;
298
+ loadPromise.finally(() => {
299
+ delete loadingPromises[lang];
300
+ });
301
+ return loadPromise;
302
+ }
303
+ __name(loadTranslationsAsync, "loadTranslationsAsync");
304
+ function interpolate(template, params) {
305
+ if (!params) return template;
306
+ return template.replace(
307
+ /\{\{(\w+)\}\}/g,
308
+ (match, key) => params[key] ?? match
309
+ );
310
+ }
311
+ __name(interpolate, "interpolate");
312
+ function resolveLanguage(lang) {
313
+ if (lang === "auto") {
314
+ return detectSystemLanguage();
315
+ }
316
+ return resolveSupportedLanguage(lang) ?? lang;
317
+ }
318
+ __name(resolveLanguage, "resolveLanguage");
319
+ async function setLanguageAsync(lang) {
320
+ currentLanguage = resolveLanguage(lang);
321
+ translations = await loadTranslationsAsync(currentLanguage);
322
+ }
323
+ __name(setLanguageAsync, "setLanguageAsync");
324
+ function getCurrentLanguage() {
325
+ return currentLanguage;
326
+ }
327
+ __name(getCurrentLanguage, "getCurrentLanguage");
328
+ function t(key, params) {
329
+ const translation = translations[key] ?? key;
330
+ if (Array.isArray(translation)) {
331
+ return key;
332
+ }
333
+ return interpolate(translation, params);
334
+ }
335
+ __name(t, "t");
336
+ function ta(key) {
337
+ const translation = translations[key];
338
+ if (Array.isArray(translation)) {
339
+ return translation;
340
+ }
341
+ return [];
342
+ }
343
+ __name(ta, "ta");
344
+ async function initializeI18n(lang) {
345
+ await setLanguageAsync(lang ?? "auto");
346
+ }
347
+ __name(initializeI18n, "initializeI18n");
348
+
349
+ export {
350
+ writeStdoutLine,
351
+ writeStderrLine,
352
+ clearScreen,
353
+ SUPPORTED_LANGUAGES,
354
+ resolveSupportedLanguage,
355
+ getLanguageNameFromLocale,
356
+ getLanguageSettingsOptions,
357
+ getSupportedLanguageIds,
358
+ detectSystemLanguage,
359
+ setLanguageAsync,
360
+ getCurrentLanguage,
361
+ t,
362
+ ta,
363
+ initializeI18n
364
+ };
365
+ /**
366
+ * @license
367
+ * Copyright 2025 Qwen Team
368
+ * SPDX-License-Identifier: Apache-2.0
369
+ */
370
+ /**
371
+ * @license
372
+ * Copyright 2025 Qwen team
373
+ * SPDX-License-Identifier: Apache-2.0
374
+ */
375
+ /**
376
+ * @license
377
+ * Copyright 2026 Qwen Team
378
+ * SPDX-License-Identifier: Apache-2.0
379
+ */