@qwen-code/qwen-code 0.15.12-preview.3 → 0.16.0
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/bundled/qc-helper/docs/configuration/settings.md +59 -61
- package/bundled/qc-helper/docs/features/_meta.ts +2 -0
- package/bundled/qc-helper/docs/features/approval-mode.md +119 -2
- package/bundled/qc-helper/docs/features/auto-mode.md +263 -0
- package/bundled/qc-helper/docs/features/commands.md +11 -10
- package/bundled/qc-helper/docs/features/skills.md +3 -0
- package/bundled/qc-helper/docs/features/structured-output.md +309 -0
- package/bundled/qc-helper/docs/features/sub-agents.md +47 -5
- package/bundled/qc-helper/docs/qwen-serve.md +134 -10
- package/bundled/review/SKILL.md +12 -3
- package/chunks/{agent-LIAWUWAO.js → agent-K6OWOMBN.js} +15 -17
- package/chunks/{anthropicContentGenerator-4QE6LTVV.js → anthropicContentGenerator-RQJNXJIY.js} +7 -4
- package/chunks/{askUserQuestion-QFSCBTUO.js → askUserQuestion-PQPMPNM3.js} +2 -2
- package/chunks/{ca-S3XJMT6P.js → ca-UZ7BANMN.js} +3 -3
- package/chunks/{chunk-AJSOD5IR.js → chunk-3T4ZT63H.js} +8833 -3600
- package/chunks/{chunk-B7ZL7HUA.js → chunk-4AOCVI6J.js} +2 -1
- package/chunks/{chunk-AOJ3BBY7.js → chunk-4J63U5QO.js} +17 -349
- package/chunks/{chunk-AEJ2DKLP.js → chunk-C6WMLUNB.js} +1 -1
- package/chunks/{chunk-JMZQICAL.js → chunk-CAVZVZX6.js} +2 -2
- package/chunks/{chunk-CAWKL3UC.js → chunk-CSWBPY3P.js} +2 -2
- package/chunks/{chunk-G27O2LD2.js → chunk-D5NTAHYL.js} +1 -1
- package/chunks/{chunk-BXNCPI75.js → chunk-DMIMF3CG.js} +2 -2
- package/chunks/{chunk-OCC4MZRS.js → chunk-F23NCRJ2.js} +1 -1
- package/chunks/{chunk-5QQ5FGTU.js → chunk-G7YTSRES.js} +1 -1
- package/chunks/{chunk-SQNQIOD5.js → chunk-GGNTZ2NH.js} +92 -21
- package/chunks/{chunk-FKVKVE6N.js → chunk-KXZ4TJB4.js} +1 -1
- package/chunks/chunk-L34E6AGL.js +19126 -0
- package/chunks/{chunk-CBVB66WY.js → chunk-L5E26RN6.js} +2 -2
- package/chunks/{chunk-UXW7MYAW.js → chunk-MAY32HXD.js} +376 -1
- package/chunks/{chunk-GC5RXNL2.js → chunk-NOAHME6A.js} +115 -23
- package/chunks/{chunk-CM2IESUE.js → chunk-PR4T27R7.js} +1 -1
- package/chunks/{chunk-FYMSCRHM.js → chunk-PVVL5Q3W.js} +32 -1
- package/chunks/{chunk-YHEAJFCI.js → chunk-USE2VQ5P.js} +3 -0
- package/chunks/chunk-VMOAQVBP.js +379 -0
- package/chunks/{chunk-XLQ4E5PS.js → chunk-WCZWAKFG.js} +795 -142
- package/chunks/{chunk-GJXIKCKL.js → chunk-XP27SJMH.js} +76 -5
- package/chunks/{chunk-TPGOGCWM.js → chunk-YJLGXDQJ.js} +1 -1
- package/chunks/{contextCommand-SVLAZMQL.js → contextCommand-7CPNXBLO.js} +17 -19
- package/chunks/{cron-create-WUTD5ZTH.js → cron-create-IGYXQVG4.js} +28 -2
- package/chunks/{cron-delete-N3UQYCRA.js → cron-delete-ETKIZCWT.js} +2 -2
- package/chunks/{cron-list-Z6RJJ4YH.js → cron-list-BVCUSWRU.js} +2 -2
- package/chunks/{de-MNR4SMAI.js → de-V4IE2OOZ.js} +3 -3
- package/chunks/{dist-RRYNPBOE.js → dist-4L54HRX2.js} +2 -2
- package/chunks/{dist-WP4AH3VK.js → dist-BXDUQ2QY.js} +1 -1
- package/chunks/{dist-M6GFCZ7S.js → dist-MN2PDDPR.js} +1 -1
- package/chunks/{edit-VNAZBIZR.js → edit-CBM5NDVK.js} +28 -18
- package/chunks/{en-NRN4QBAT.js → en-HGJ2SPLM.js} +5 -3
- package/chunks/{enter-worktree-FOF5YZIV.js → enter-worktree-XABKPLO6.js} +41 -17
- package/chunks/{exit-worktree-Y6QVAO3C.js → exit-worktree-56MN2PCL.js} +41 -17
- package/chunks/{exitPlanMode-QZKO7GH7.js → exitPlanMode-YDNPCSCJ.js} +15 -17
- package/chunks/{fr-OFJFHLCR.js → fr-CJULI7ZX.js} +3 -3
- package/chunks/{geminiContentGenerator-DYHZPKJX.js → geminiContentGenerator-ZGPNBFDS.js} +3 -3
- package/chunks/{glob-G7XATELV.js → glob-ZHA35VO5.js} +15 -17
- package/chunks/{grep-4SETMY47.js → grep-RV6V6T52.js} +15 -17
- package/chunks/{ja-V6OQ6VL7.js → ja-L7CHRQEW.js} +3 -3
- package/chunks/{keychain-token-storage-DMFP5IJM.js → keychain-token-storage-335UOLJ6.js} +2 -2
- package/chunks/{ls-SUILOZZB.js → ls-7HD6XG3V.js} +3 -3
- package/chunks/{lsp-6TQBWVMZ.js → lsp-ZZSFCIWD.js} +2 -2
- package/chunks/{monitor-JTLJBJ7H.js → monitor-5G2OBGE5.js} +27 -17
- package/chunks/notebook-edit-XUBTCT6L.js +756 -0
- package/chunks/{openaiContentGenerator-3H7XOZBW.js → openaiContentGenerator-POYAZQ6I.js} +12 -11
- package/chunks/{pt-ZLE6SA4A.js → pt-M6JULLEQ.js} +3 -3
- package/chunks/{qwenContentGenerator-FAU3QPYO.js → qwenContentGenerator-2E4H56DK.js} +17 -19
- package/chunks/{qwenOAuth2-JSQ7EPR3.js → qwenOAuth2-EEJGROP7.js} +9 -3
- package/chunks/{read-file-WWUQVNCZ.js → read-file-3JIOOXFT.js} +7 -8
- package/chunks/{ripGrep-WCOAIWL6.js → ripGrep-LEI3L6PM.js} +15 -17
- package/chunks/{ru-A4OHIUNN.js → ru-QILM4HBC.js} +3 -3
- package/chunks/{send-message-Q2JRAC3J.js → send-message-ULK4MQXJ.js} +23 -2
- package/chunks/{serve-VJEEEXA6.js → serve-CFVRMD4W.js} +8500 -1663
- package/chunks/{shell-IAOKGIJ6.js → shell-3B5DZ437.js} +15 -17
- package/chunks/{skill-NHW6222K.js → skill-STSZUBXR.js} +23 -10
- package/chunks/{src-OWV5HVQQ.js → src-ROFXAPEP.js} +211 -19
- package/chunks/{syntheticOutput-S4DRGMQM.js → syntheticOutput-IS2X5OZ2.js} +3 -3
- package/chunks/{task-stop-7THHVAQS.js → task-stop-7QSJGSSP.js} +2 -2
- package/chunks/{todoWrite-WKUGUTPX.js → todoWrite-7CVACFUX.js} +3 -3
- package/chunks/{tool-search-MSJ6SXLI.js → tool-search-ARWOD3GD.js} +7 -8
- package/chunks/{web-fetch-OZE6ZQUF.js → web-fetch-ENQ2I5JA.js} +7 -4
- package/chunks/{write-file-RKCENFZ5.js → write-file-6MRT7TEW.js} +25 -18
- package/chunks/{zh-RN3JULHO.js → zh-PWL2NKY3.js} +5 -3
- package/chunks/{zh-TW-XZEHEV5S.js → zh-TW-S3YGWICZ.js} +5 -3
- package/cli.js +58070 -75930
- package/locales/ca.js +4 -5
- package/locales/de.js +4 -5
- package/locales/en.js +8 -5
- package/locales/fr.js +4 -5
- package/locales/ja.js +4 -5
- package/locales/pt.js +4 -5
- package/locales/ru.js +4 -5
- package/locales/zh-TW.js +6 -4
- package/locales/zh.js +6 -4
- package/package.json +2 -2
- package/chunks/chunk-5P5XGNYH.js +0 -93
- package/chunks/chunk-SYCJMSIJ.js +0 -82
- package/chunks/chunk-Y6Z2O3WR.js +0 -33
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
import {
|
|
4
4
|
createDebugLogger
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XP27SJMH.js";
|
|
6
6
|
import {
|
|
7
7
|
init_esbuild_shims
|
|
8
8
|
} from "./chunk-A4BMJM77.js";
|
|
@@ -14155,6 +14155,10 @@ var ToolErrorType = /* @__PURE__ */ ((ToolErrorType2) => {
|
|
|
14155
14155
|
ToolErrorType2["EDIT_REQUIRES_PRIOR_READ"] = "edit_requires_prior_read";
|
|
14156
14156
|
ToolErrorType2["FILE_CHANGED_SINCE_READ"] = "file_changed_since_read";
|
|
14157
14157
|
ToolErrorType2["PRIOR_READ_VERIFICATION_FAILED"] = "prior_read_verification_failed";
|
|
14158
|
+
ToolErrorType2["TARGET_NOT_REGULAR_FILE"] = "target_not_regular_file";
|
|
14159
|
+
ToolErrorType2["NOTEBOOK_EDIT_FAILURE"] = "notebook_edit_failure";
|
|
14160
|
+
ToolErrorType2["NOTEBOOK_INVALID_JSON"] = "notebook_invalid_json";
|
|
14161
|
+
ToolErrorType2["NOTEBOOK_CELL_NOT_FOUND"] = "notebook_cell_not_found";
|
|
14158
14162
|
ToolErrorType2["GLOB_EXECUTION_ERROR"] = "glob_execution_error";
|
|
14159
14163
|
ToolErrorType2["GREP_EXECUTION_ERROR"] = "grep_execution_error";
|
|
14160
14164
|
ToolErrorType2["LS_EXECUTION_ERROR"] = "ls_execution_error";
|
|
@@ -14608,6 +14612,31 @@ var DeclarativeTool = class {
|
|
|
14608
14612
|
parametersJsonSchema: this.parameterSchema
|
|
14609
14613
|
};
|
|
14610
14614
|
}
|
|
14615
|
+
/**
|
|
14616
|
+
* Projects tool params for the AUTO approval mode classifier.
|
|
14617
|
+
*
|
|
14618
|
+
* Tools with security-relevant parameters (file paths, shell commands,
|
|
14619
|
+
* URLs) should override this to redact voluminous or sensitive fields
|
|
14620
|
+
* (full content, secrets) while exposing enough for the classifier to
|
|
14621
|
+
* judge safety.
|
|
14622
|
+
*
|
|
14623
|
+
* Returns:
|
|
14624
|
+
* - object: projected params to send to the classifier
|
|
14625
|
+
* - empty string: signals "no security relevance" — the classifier
|
|
14626
|
+
* transcript will record only the tool name
|
|
14627
|
+
* - undefined: fall back to raw params (only safe when the tool is
|
|
14628
|
+
* known to have no sensitive params)
|
|
14629
|
+
*
|
|
14630
|
+
* Default is the empty-string sentinel — fail-closed: a third-party
|
|
14631
|
+
* MCP tool (or any tool that has not opted in) does not leak its raw
|
|
14632
|
+
* parameters (potentially containing API keys, tokens, file contents)
|
|
14633
|
+
* into the classifier LLM prompt. Tools that want their args inspected
|
|
14634
|
+
* by the classifier for safety judgement should override this and
|
|
14635
|
+
* return an object with only the security-relevant fields.
|
|
14636
|
+
*/
|
|
14637
|
+
toAutoClassifierInput(_params) {
|
|
14638
|
+
return "";
|
|
14639
|
+
}
|
|
14611
14640
|
/**
|
|
14612
14641
|
* Validates the raw tool parameters.
|
|
14613
14642
|
* Subclasses should override this to add custom validation logic
|
|
@@ -14832,6 +14861,7 @@ var ToolNames = {
|
|
|
14832
14861
|
SEND_MESSAGE: "send_message",
|
|
14833
14862
|
STRUCTURED_OUTPUT: "structured_output",
|
|
14834
14863
|
MONITOR: "monitor",
|
|
14864
|
+
NOTEBOOK_EDIT: "notebook_edit",
|
|
14835
14865
|
TOOL_SEARCH: "tool_search",
|
|
14836
14866
|
ENTER_WORKTREE: "enter_worktree",
|
|
14837
14867
|
EXIT_WORKTREE: "exit_worktree"
|
|
@@ -14859,6 +14889,7 @@ var ToolDisplayNames = {
|
|
|
14859
14889
|
SEND_MESSAGE: "SendMessage",
|
|
14860
14890
|
STRUCTURED_OUTPUT: "StructuredOutput",
|
|
14861
14891
|
MONITOR: "Monitor",
|
|
14892
|
+
NOTEBOOK_EDIT: "NotebookEdit",
|
|
14862
14893
|
TOOL_SEARCH: "ToolSearch",
|
|
14863
14894
|
ENTER_WORKTREE: "EnterWorktree",
|
|
14864
14895
|
EXIT_WORKTREE: "ExitWorktree"
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import {
|
|
4
|
+
resolveBundleDir
|
|
5
|
+
} from "./chunk-3T4ZT63H.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
|
+
*/
|