@bytedance/doubao-cli 2.31.4 → 2.36.2

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/artifacts.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
- "version": "2.31.4",
2
+ "version": "2.36.2",
3
3
  "platforms": {
4
4
  "linux-x64": {
5
- "url": "https://lf-flow-web-cdn.doubao.com/obj/flow-doubao/doubao_cli/2.31.4/doubao-cli-2.31.4-linux-x64-signed.tar.gz",
6
- "sha256": "b498c091b01b56b5d1905c01791e7f015f7b8a4b8b38e1430408096edf2f74cc",
7
- "root": "doubao-cli-2.31.4-linux-x64"
5
+ "url": "https://lf-flow-web-cdn.doubao.com/obj/flow-doubao/doubao_cli/2.36.2/doubao-cli-2.36.2-linux-x64-signed.tar.gz",
6
+ "sha256": "439e45db14ba9f4138772848e1fbdac6ee3477c9a60b92ea3ef91102eb85e6b7",
7
+ "root": "doubao-cli-2.36.2-linux-x64"
8
8
  },
9
9
  "darwin-arm64": {
10
- "url": "https://lf-flow-web-cdn.doubao.com/obj/flow-doubao/doubao_cli/2.31.4/doubao-cli-2.31.4-darwin-arm64-signed-signed.tar.gz",
11
- "sha256": "9039cfe36abb3671cffc2f81779a242fba71d571cedad9efb698f7bc66a92799",
12
- "root": "doubao-cli-2.31.4-darwin-arm64"
10
+ "url": "https://lf-flow-web-cdn.doubao.com/obj/flow-doubao/doubao_cli/2.36.2/doubao-cli-2.36.2-darwin-arm64-signed-signed.tar.gz",
11
+ "sha256": "bc111662e714b9e4666fb43783f3bc0993ab6aed7325533ec32421fece74094f",
12
+ "root": "doubao-cli-2.36.2-darwin-arm64"
13
13
  },
14
14
  "win32-x64": {
15
- "url": "https://lf-flow-web-cdn.doubao.com/obj/flow-doubao/doubao_cli/2.31.4/doubao-cli-2.31.4-win-x64-signed.zip",
16
- "sha256": "ff7a4ce043c093b4c164074ca7168ec1f4e59b42052e79e8080b5d7f22245ce5",
17
- "root": "doubao-cli-2.31.4-win-x64"
15
+ "url": "https://lf-flow-web-cdn.doubao.com/obj/flow-doubao/doubao_cli/2.36.2/doubao-cli-2.36.2-win-x64-signed.zip",
16
+ "sha256": "a60c7f4b18d56001cf8867e2d197814f09e049dbbb6d0585e0ad77d351b5e9cd",
17
+ "root": "doubao-cli-2.36.2-win-x64"
18
18
  }
19
19
  }
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytedance/doubao-cli",
3
- "version": "2.31.4",
3
+ "version": "2.36.2",
4
4
  "description": "Doubao CLI for terminal and automation workflows",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "bin": {
@@ -5,36 +5,37 @@ const path = require('node:path');
5
5
  const crypto = require('node:crypto');
6
6
  const { execFileSync } = require('node:child_process');
7
7
  const { pipeline } = require('node:stream/promises');
8
+ const { setTimeout: delay } = require('node:timers/promises');
8
9
  const packageRoot = path.resolve(__dirname, '..');
9
10
  const platforms = ['win32-x64', 'darwin-arm64', 'linux-x64'];
10
11
 
11
12
  function validateConfig(config, version) {
12
- if (config.version !== version) throw new Error('Artifact version must match package.json.');
13
+ if (config.version !== version) throw new Error('下载清单版本必须与 package.json 一致。');
13
14
  for (const platform of platforms) {
14
15
  const artifact = config.platforms[platform];
15
16
  if (!artifact || !/^[a-f0-9]{64}$/i.test(artifact.sha256)) {
16
- throw new Error(`Missing SHA-256 for ${platform}.`);
17
+ throw new Error(`缺少 ${platform} 的 SHA-256 校验值。`);
17
18
  }
18
19
  const url = new URL(artifact.url);
19
20
  if (url.protocol !== 'https:' || url.username || url.password) {
20
- throw new Error(`Expected an HTTPS artifact URL for ${platform}.`);
21
+ throw new Error(`${platform} 的下载地址必须使用 HTTPS,且不能包含用户名或密码。`);
21
22
  }
22
23
  validatePath(artifact.root);
23
- if (artifact.root.includes('/')) throw new Error('Archive root must be one directory.');
24
+ if (artifact.root.includes('/')) throw new Error('压缩包顶层目录必须是单个目录。');
24
25
  }
25
26
  }
26
27
 
27
28
  function validatePath(name) {
28
29
  if (!name || /[\\:\x00-\x1f]/.test(name) || name.startsWith('/') ||
29
30
  name.split('/').some((part) => part === '..' || part === '.')) {
30
- throw new Error(`Unsafe archive path: ${name}`);
31
+ throw new Error(`压缩包路径不安全:${name}`);
31
32
  }
32
33
  }
33
34
 
34
35
  async function verifyChecksum(file, expected) {
35
36
  const hash = crypto.createHash('sha256');
36
37
  await pipeline(fs.createReadStream(file), hash);
37
- if (hash.digest('hex') !== expected.toLowerCase()) throw new Error('Artifact SHA-256 mismatch.');
38
+ if (hash.digest('hex') !== expected.toLowerCase()) throw new Error('安装包 SHA-256 不匹配');
38
39
  }
39
40
 
40
41
  function extract(archive, destination, root) {
@@ -42,7 +43,7 @@ function extract(archive, destination, root) {
42
43
  ? path.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'tar.exe')
43
44
  : 'tar';
44
45
  if (process.platform === 'win32' && !fs.existsSync(tar)) {
45
- throw new Error(`Windows system tar.exe is required to extract ZIP archives: ${tar}`);
46
+ throw new Error(`解压 ZIP 安装包需要 Windows 系统 tar.exe:${tar}`);
46
47
  }
47
48
  const options = { encoding: 'utf8', maxBuffer: 32 * 1024 * 1024 };
48
49
  const names = execFileSync(tar, ['-tf', archive], options).trim().split(/\r?\n/);
@@ -51,12 +52,12 @@ function extract(archive, destination, root) {
51
52
  const name = entryName.replace(/^(?:\.\/)+/, '');
52
53
  validatePath(name);
53
54
  if (name !== root && !name.startsWith(`${root}/`)) {
54
- throw new Error(`Unexpected archive root: ${name}`);
55
+ throw new Error(`压缩包顶层目录与配置不一致:${name}`);
55
56
  }
56
57
  }
57
58
  const entries = execFileSync(tar, ['-tvf', archive], options).trim().split(/\r?\n/);
58
59
  if (entries.some((entry) => !/^[-d]/.test(entry))) {
59
- throw new Error('Archive links and special files are not supported.');
60
+ throw new Error('压缩包不支持链接或特殊文件。');
60
61
  }
61
62
  execFileSync(tar, ['-xf', archive, '-C', destination], { stdio: 'inherit' });
62
63
  }
@@ -67,12 +68,12 @@ function validateRuntime(root, platform, version) {
67
68
  const target = platform === 'win32-x64' ? 'win-x64' : platform;
68
69
  if (manifest.schema_version !== 1 || manifest.target !== target ||
69
70
  typeof manifest.version !== 'string' || !manifest.version ||
70
- (version && manifest.version !== version)) throw new Error('Unexpected runtime manifest version or target.');
71
- if (manifest.entrypoint !== binary) throw new Error('Unexpected manifest entrypoint.');
72
- if (!Array.isArray(manifest.files) || !manifest.files.length) throw new Error('Missing runtime file manifest.');
71
+ (version && manifest.version !== version)) throw new Error('运行时清单的版本或平台不匹配。');
72
+ if (manifest.entrypoint !== binary) throw new Error('运行时清单的程序入口不匹配。');
73
+ if (!Array.isArray(manifest.files) || !manifest.files.length) throw new Error('缺少运行时文件清单。');
73
74
  for (const name of [binary, 'resources/js_app/cli-manifest.json', ...manifest.files.map((file) => file.path)]) {
74
75
  validatePath(name);
75
- if (!fs.statSync(path.join(root, name)).isFile()) throw new Error(`Missing runtime file: ${name}`);
76
+ if (!fs.statSync(path.join(root, name)).isFile()) throw new Error(`缺少运行时文件:${name}`);
76
77
  }
77
78
  if (platform !== 'win32-x64') fs.accessSync(path.join(root, binary), fs.constants.X_OK);
78
79
  }
@@ -86,14 +87,14 @@ async function cachedArchive(app, temporary, artifact) {
86
87
  const archive = path.join(temporary, 'package');
87
88
  try {
88
89
  const info = fs.lstatSync(stored);
89
- if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1) throw new Error('Unsafe cached archive.');
90
+ if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1) throw new Error('下载缓存不安全。');
90
91
  // Verify a private snapshot; concurrent cache replacement cannot change extraction input.
91
92
  fs.copyFileSync(stored, archive, fs.constants.COPYFILE_EXCL);
92
93
  await verifyChecksum(archive, name);
93
- console.log('Using verified cached Doubao CLI archive.');
94
+ console.log('已使用验证通过的豆包 CLI 缓存包。');
94
95
  return archive;
95
96
  } catch (error) {
96
- if (error.message === 'Unsafe cached archive.') throw error;
97
+ if (error.message === '下载缓存不安全。') throw error;
97
98
  if (error.code && error.code !== 'ENOENT') throw error;
98
99
  fs.rmSync(archive, { force: true });
99
100
  }
@@ -106,14 +107,26 @@ async function cachedArchive(app, temporary, artifact) {
106
107
  fs.copyFileSync(archive, pending, fs.constants.COPYFILE_EXCL);
107
108
  fs.renameSync(pending, stored);
108
109
  } catch (error) {
109
- console.warn('Could not save the verified download cache: ' + error.message);
110
+ console.warn('无法保存已验证的下载缓存:' + error.message);
110
111
  } finally {
111
112
  try { fs.rmSync(pending, { force: true }); }
112
- catch (error) { console.warn('Temporary download cache could not be removed: ' + error.message); }
113
+ catch (error) { console.warn('无法删除临时下载缓存:' + error.message); }
113
114
  }
114
115
  return archive;
115
116
  }
116
117
 
118
+ async function renameStaged(from, to) {
119
+ for (let retries = 0; ; retries++) {
120
+ try {
121
+ fs.renameSync(from, to);
122
+ return;
123
+ } catch (error) {
124
+ if (retries === 3 || !['EPERM', 'EACCES', 'EBUSY'].includes(error.code)) throw error;
125
+ await delay(2000);
126
+ }
127
+ }
128
+ }
129
+
117
130
  async function install(root = packageRoot, applicationRoot) {
118
131
  const config = JSON.parse(fs.readFileSync(path.join(root, 'artifacts.json'), 'utf8'));
119
132
  const version = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).version;
@@ -122,14 +135,14 @@ async function install(root = packageRoot, applicationRoot) {
122
135
  if (process.platform !== 'win32') fs.chmodSync(path.join(root, 'scripts/run.cjs'), 0o755);
123
136
  const support = require('./runtime.cjs');
124
137
  const platform = support.platform;
125
- if (!platforms.includes(platform)) throw new Error('Unsupported platform: ' + platform);
138
+ if (!platforms.includes(platform)) throw new Error('不支持的平台:' + platform);
126
139
  const artifact = config.platforms[platform];
127
140
  support.directory(applicationRoot || support.appRoot());
128
141
  const app = fs.realpathSync(applicationRoot || support.appRoot());
129
142
  const temporary = fs.mkdtempSync(path.join(app, '.staging-'));
130
143
  let runner;
131
144
  try {
132
- console.log('Preparing Doubao CLI ' + version + ' (' + platform + ')...');
145
+ console.log('正在准备豆包 CLI ' + version + ' (' + platform + ')...');
133
146
  const archive = await cachedArchive(app, temporary, artifact);
134
147
  const unpacked = path.join(temporary, 'unpacked');
135
148
  fs.mkdirSync(unpacked);
@@ -137,18 +150,18 @@ async function install(root = packageRoot, applicationRoot) {
137
150
  const staged = path.join(unpacked, artifact.root);
138
151
  const executable = path.join(staged, support.updaterName);
139
152
  const info = fs.lstatSync(executable, { throwIfNoEntry: false });
140
- if (!info || !info.isFile() || info.isSymbolicLink() || info.nlink !== 1) throw new Error('Missing or unsafe standalone updater. Build a new Native package.');
153
+ if (!info || !info.isFile() || info.isSymbolicLink() || info.nlink !== 1) throw new Error('独立更新程序缺失或不安全,请使用重新构建的原生安装包。');
141
154
  if (process.platform !== 'win32') {
142
155
  const binary = path.join(staged, 'doubao');
143
156
  const binaryInfo = fs.lstatSync(binary);
144
- if (!binaryInfo.isFile() || binaryInfo.isSymbolicLink() || binaryInfo.nlink !== 1) throw new Error('Missing or unsafe runtime executable.');
157
+ if (!binaryInfo.isFile() || binaryInfo.isSymbolicLink() || binaryInfo.nlink !== 1) throw new Error('运行时程序缺失或不安全。');
145
158
  fs.chmodSync(binary, 0o755);
146
159
  fs.chmodSync(executable, 0o755);
147
160
  }
148
161
  validateRuntime(staged, platform, version);
149
162
  if (process.platform !== 'win32') fs.accessSync(executable, fs.constants.X_OK);
150
163
  const payload = path.join(temporary, 'payload');
151
- fs.renameSync(staged, payload);
164
+ await renameStaged(staged, payload);
152
165
  runner = support.prepareUpdater(payload, app);
153
166
  // Reporting metadata only: an unreadable old manifest must not block repair.
154
167
  let fromVersion = '';
@@ -160,10 +173,10 @@ async function install(root = packageRoot, applicationRoot) {
160
173
  support.invokeUpdater(path.join(runner, support.updaterName), app,
161
174
  ['--staging=' + path.basename(temporary), '--from-version=' + fromVersion,
162
175
  '--to-version=' + version, '--operation=' + operation]);
163
- console.log('Doubao CLI ' + version + ' installed.');
176
+ console.log('豆包 CLI ' + version + ' 已安装。');
164
177
  try { fs.unlinkSync(path.join(app, 'downloads', artifact.sha256.toLowerCase())); }
165
178
  catch (error) {
166
- if (error.code !== 'ENOENT') console.warn('Download cache could not be removed: ' + error.message);
179
+ if (error.code !== 'ENOENT') console.warn('无法删除下载缓存:' + error.message);
167
180
  }
168
181
  } finally {
169
182
  const record = path.join(app, 'update-state.json');
@@ -179,11 +192,14 @@ async function install(root = packageRoot, applicationRoot) {
179
192
  // Cleanup errors must not turn an already committed install into a failure.
180
193
  for (const file of [temporary, runner].filter(Boolean)) {
181
194
  try { fs.rmSync(file, { recursive: true, force: true }); }
182
- catch (error) { console.warn('Temporary files could not be removed: ' + error.message); }
195
+ catch (error) { console.warn('无法删除临时文件:' + error.message); }
183
196
  }
184
197
  }
185
198
  }
186
199
  }
187
200
 
188
- module.exports = { validateConfig, validatePath, verifyChecksum, extract, validateRuntime, cachedArchive, install };
189
- if (require.main === module) install().catch(error => { console.error('Doubao CLI installation failed: ' + error.message); process.exitCode = 1; });
201
+ module.exports = { validateConfig, validatePath, verifyChecksum, extract, validateRuntime, cachedArchive, renameStaged, install };
202
+ if (require.main === module) install().catch(error => {
203
+ if (!error.reported) console.error('豆包 CLI 安装失败:' + error.message);
204
+ process.exitCode = 1;
205
+ });
package/scripts/run.cjs CHANGED
@@ -16,10 +16,10 @@ function confirmUpdate() {
16
16
  resolve(null);
17
17
  });
18
18
  input.on('SIGINT', () => input.close());
19
- const ask = () => input.question('Update now? [Y/N] ', (answer) => {
19
+ const ask = () => input.question('是否现在更新?[Y/N] ', (answer) => {
20
20
  const choice = answer.trim().toLowerCase();
21
21
  if (choice !== 'y' && choice !== 'n') {
22
- console.error('Please enter Y to update or N to continue.');
22
+ console.error('请输入 Y 开始更新,或输入 N 跳过并继续。');
23
23
  ask();
24
24
  return;
25
25
  }
@@ -32,7 +32,7 @@ function confirmUpdate() {
32
32
 
33
33
  async function run(args = process.argv.slice(2), root = runtime.appRoot()) {
34
34
  if (args[0] === 'update') {
35
- if (args.length !== 1) throw new Error('Usage: doubao update');
35
+ if (args.length !== 1) throw new Error('用法:doubao update');
36
36
  return updates.update(root);
37
37
  }
38
38
  const current = path.join(root, 'current');
@@ -45,7 +45,7 @@ async function run(args = process.argv.slice(2), root = runtime.appRoot()) {
45
45
  if (confirmed) {
46
46
  try { return await updates.update(root); }
47
47
  catch (error) {
48
- console.error(`Cannot update doubao: ${error.message}`);
48
+ console.error(`无法更新豆包 CLI:${error.message}`);
49
49
  return 1;
50
50
  }
51
51
  }
@@ -80,8 +80,8 @@ function isInfoQuery(args) {
80
80
  if (require.main === module) {
81
81
  run().then((code) => { process.exitCode = code; }).catch((error) => {
82
82
  console.error(process.argv[2] === 'update'
83
- ? `Cannot update doubao: ${error.message}`
84
- : `Cannot start doubao: ${error.message}. If an update is running, wait and retry. Reinstall with install scripts enabled if files remain missing.`);
83
+ ? `无法更新豆包 CLI:${error.message}`
84
+ : `无法启动豆包 CLI:${error.message}`);
85
85
  process.exitCode = 1;
86
86
  });
87
87
  }
@@ -16,20 +16,20 @@ function appRoot() {
16
16
  if (process.env.XDG_DATA_HOME) parent = process.env.XDG_DATA_HOME;
17
17
  else {
18
18
  // Native uses HOME directly; do not silently choose a different passwd fallback.
19
- if (!process.env.HOME || !path.isAbsolute(process.env.HOME)) throw new Error('Set an absolute HOME or XDG_DATA_HOME directory.');
19
+ if (!process.env.HOME || !path.isAbsolute(process.env.HOME)) throw new Error('请将 HOME 或 XDG_DATA_HOME 设置为绝对路径。');
20
20
  parent = path.join(process.env.HOME, '.local/share');
21
21
  }
22
22
  }
23
- if (!parent || !path.isAbsolute(parent)) throw new Error('Cannot resolve the OS user application-data directory.');
23
+ if (!parent || !path.isAbsolute(parent)) throw new Error('无法确定系统用户的应用数据目录。');
24
24
  return path.join(parent, 'doubao_cli', 'app');
25
25
  }
26
26
 
27
27
  function directory(file) {
28
28
  fs.mkdirSync(file, { recursive: true, mode: 0o700 });
29
29
  const info = fs.lstatSync(file);
30
- if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`Unsafe application directory: ${file}`);
30
+ if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`应用目录不安全:${file}`);
31
31
  if (process.platform !== 'win32' && (info.uid !== process.getuid() || (info.mode & 0o022))) {
32
- throw new Error(`Application directory must be owned by the current user and not writable by others: ${file}`);
32
+ throw new Error(`应用目录必须属于当前用户,且其他用户不能写入:${file}`);
33
33
  }
34
34
  }
35
35
 
@@ -37,11 +37,11 @@ function checkCurrent(root) {
37
37
  const current = path.join(root, 'current');
38
38
  try {
39
39
  const info = fs.lstatSync(current);
40
- if (!info.isDirectory() || info.isSymbolicLink()) throw new Error('Unsafe current runtime directory.');
40
+ if (!info.isDirectory() || info.isSymbolicLink()) throw new Error('当前运行时目录不安全。');
41
41
  require('./install.cjs').validateRuntime(current, platform);
42
42
  return JSON.parse(fs.readFileSync(path.join(current, 'manifest.json'), 'utf8')).version;
43
43
  } catch (error) {
44
- throw new Error(`The installed runtime is missing or invalid: ${error.message}. If an update is running, wait and retry; otherwise reinstall through npm with install scripts enabled.`, { cause: error });
44
+ throw new Error(`已安装的运行时缺失或无效:${error.message}。若正在执行更新,请等待完成后重试;否则请通过启用安装脚本的 npm 重新安装。`, { cause: error });
45
45
  }
46
46
  }
47
47
 
@@ -55,8 +55,10 @@ function invokeUpdater(executable, root, args) {
55
55
  } catch (error) {
56
56
  if (error.status === 10) return;
57
57
  if (error.status === 3) throw Object.assign(new Error(
58
- 'Cannot acquire runtime lock. Exit other instances or wait for the update to finish, then retry. If this persists, check directory permissions.'), { code: 'ELOCKED' });
59
- throw new Error('Updater failed (' + (error.status ?? error.code) + '). Preserve update files and retry.', { cause: error });
58
+ '无法获取运行锁。请退出其他实例,或等待当前更新完成后重试;若问题持续,请检查目录权限。'), { code: 'ELOCKED', reported: true });
59
+ // Native reports its defined failure results through inherited stderr.
60
+ throw Object.assign(new Error('更新程序失败(' + (error.status ?? error.code ?? error.signal) + ')。请保留更新文件后重试。', { cause: error }),
61
+ { reported: [2, 4, 5].includes(error.status) });
60
62
  }
61
63
  }
62
64
 
@@ -9,11 +9,11 @@ function distribution() {
9
9
  const { name, publishConfig } = require('../package.json');
10
10
  if (!/^@[a-z0-9-]+\/[a-z0-9-]+$/.test(name || '') ||
11
11
  !publishConfig || !/^[a-z][a-z0-9-]*$/.test(publishConfig.tag || '')) {
12
- throw new Error('Invalid npm update package or tag. Reinstall the package.');
12
+ throw new Error('npm 更新包或标签配置无效,请重新安装。');
13
13
  }
14
14
  const url = new URL(publishConfig.registry);
15
15
  if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash) {
16
- throw new Error('Expected an HTTPS npm update registry without credentials.');
16
+ throw new Error('npm 更新源必须使用 HTTPS,且不能包含登录信息或查询参数。');
17
17
  }
18
18
  return { packageName: name, registry: publishConfig.registry, tag: publishConfig.tag };
19
19
  }
@@ -33,7 +33,7 @@ function npmCli() {
33
33
  if (path.basename(resolved) === 'npm-cli.js' && fs.statSync(resolved).isFile()) return resolved;
34
34
  } catch { /* Try the next installed npm location. */ }
35
35
  }
36
- throw new Error('Cannot locate npm-cli.js. Update using npm install -g with this package\'s registry.');
36
+ throw new Error('找不到 npm-cli.js,请通过 npm install -g 并指定本渠道的源进行更新。');
37
37
  }
38
38
 
39
39
  function parseVersion(version) {
@@ -68,28 +68,28 @@ function latest({ packageName, registry, tag }, timeout = 15000) {
68
68
  '--json', '--prefer-online', `--registry=${registry}`], { encoding: 'utf8', timeout, maxBuffer: 16384,
69
69
  stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
70
70
  const version = JSON.parse(output);
71
- if (!parseVersion(version)) throw new Error('The npm registry returned an invalid version.');
71
+ if (!parseVersion(version)) throw new Error('npm 源返回的版本号无效。');
72
72
  return version;
73
73
  }
74
74
 
75
75
  async function update(root = runtime.appRoot()) {
76
76
  const installed = runtime.checkCurrent(root);
77
77
  const config = distribution();
78
- const { packageName, registry, tag } = config;
78
+ const { packageName, registry } = config;
79
79
  const version = latest(config);
80
80
  // Always update the installation containing this launcher, including custom prefixes.
81
81
  const modules = path.resolve(runtime.packageRoot, '../..');
82
- if (path.basename(modules) !== 'node_modules') throw new Error('doubao update requires an npm global installation.');
82
+ if (path.basename(modules) !== 'node_modules') throw new Error('doubao update 仅支持通过 npm 全局安装的豆包 CLI。');
83
83
  let prefix = path.dirname(modules);
84
84
  if (process.platform !== 'win32') {
85
- if (path.basename(prefix) !== 'lib') throw new Error('Cannot determine the npm global prefix.');
85
+ if (path.basename(prefix) !== 'lib') throw new Error('无法确定 npm 全局安装目录。');
86
86
  prefix = path.dirname(prefix);
87
87
  }
88
- if (!parseVersion(installed)) throw new Error('The installed runtime has an invalid version. Repair the installation.');
88
+ if (!parseVersion(installed)) throw new Error('已安装的运行时版本号无效,请重新安装以修复。');
89
89
  if (!newer(version, installed)) {
90
90
  console.log(installed === version
91
- ? `Doubao CLI ${installed} is already up to date.`
92
- : `Doubao CLI ${installed} is not older than ${tag} (${version}); keeping the installed version.`);
91
+ ? `豆包 CLI ${installed} 已是最新版本。`
92
+ : `当前版本 ${installed} 不低于远端版本 (${version}),无需更新。`);
93
93
  return 0;
94
94
  }
95
95
  const child = spawn(process.execPath, [npmCli(), 'install', '-g', `${packageName}@${version}`,
@@ -101,7 +101,7 @@ async function update(root = runtime.appRoot()) {
101
101
  if (code !== 0) return resolve(code ?? 1);
102
102
  try {
103
103
  const installed = runtime.checkCurrent(root);
104
- if (installed !== version) throw new Error(`npm completed but the runtime is still ${installed}; expected ${version}. Enable install scripts and retry.`);
104
+ if (installed !== version) throw new Error(`npm 已完成,但运行时仍为 ${installed},预期为 ${version}。请启用安装脚本后重试`);
105
105
  resolve(0);
106
106
  } catch (error) { reject(error); }
107
107
  });
@@ -114,7 +114,7 @@ function notifier(installed) {
114
114
  try {
115
115
  const version = latest(distribution(), 3000);
116
116
  return newer(version, installed)
117
- ? `Doubao CLI update available: ${installed} -> ${version}.` : null;
117
+ ? `检测到豆包 CLI 有可用的新版本:${installed} -> ${version}。` : null;
118
118
  } catch { return null; }
119
119
  }
120
120