zen-gitsync 2.7.13 → 2.7.14

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.
@@ -6,10 +6,10 @@
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
8
  <title>Zen GitSync</title>
9
- <script type="module" crossorigin src="/assets/index-Dn7gn8cE.js"></script>
10
- <link rel="modulepreload" crossorigin href="/assets/vendor-VAJ9QkGT.js">
9
+ <script type="module" crossorigin src="/assets/index-DThWgJlp.js"></script>
10
+ <link rel="modulepreload" crossorigin href="/assets/vendor-xDks5a75.js">
11
11
  <link rel="stylesheet" crossorigin href="/assets/vendor-BWT9SBHo.css">
12
- <link rel="stylesheet" crossorigin href="/assets/index-C3qoeiHs.css">
12
+ <link rel="stylesheet" crossorigin href="/assets/index-BPL9XG20.css">
13
13
  </head>
14
14
  <body>
15
15
  <div id="app"></div>
@@ -190,14 +190,17 @@ async function startUIServer(noOpen = false, savePort = false) {
190
190
  shell: true, // 通过 shell 执行,支持 Windows 内置命令
191
191
  env: {
192
192
  ...process.env,
193
- GIT_CONFIG_PARAMETERS: "'core.quotepath=false'",
194
- // 强制 npm/yarn 等工具实时输出,禁用缓冲
195
- FORCE_COLOR: '1',
193
+ // Git 配置:启用颜色输出和禁用路径引用
194
+ GIT_CONFIG_PARAMETERS: "'color.ui=always' 'color.status=always' 'core.quotepath=false'",
195
+ // 强制启用颜色输出 - 多种工具的配置
196
+ FORCE_COLOR: '3', // 使用级别3(最强),支持 chalk 等库
196
197
  NPM_CONFIG_COLOR: 'always',
197
- // 禁用进度条和其他交互式输出
198
- CI: 'true',
198
+ TERM: 'xterm-256color', // 模拟256色终端环境
199
+ COLORTERM: 'truecolor', // 支持真彩色
200
+ CLICOLOR_FORCE: '1', // 强制启用颜色(某些工具检测此变量)
199
201
  // 确保输出不被缓冲
200
202
  PYTHONUNBUFFERED: '1'
203
+ // 注意:不设置 CI=true 和 NO_COLOR,避免禁用颜色输出
201
204
  }
202
205
  });
203
206
 
@@ -256,15 +259,35 @@ async function startUIServer(noOpen = false, savePort = false) {
256
259
  childProcess.stderr?.on('data', (data) => {
257
260
  // data 是 Buffer 对象
258
261
  let output;
259
- if (needsGbkConversion) {
260
- // Windows CMD 内置命令,从 GBK 转换为 UTF-8
261
- output = iconv.decode(data, 'gbk');
262
- console.log(`[流式输出] 收到stderr(GBK转UTF8):`, output.substring(0, 200));
262
+
263
+ if (isWindows) {
264
+ // Windows 平台需要智能检测编码
265
+ // 先尝试 UTF-8 解码
266
+ const utf8Output = data.toString('utf8');
267
+
268
+ // 检测是否包含 UTF-8 替换字符(�),这通常表示解码失败
269
+ // 如果没有替换字符且包含正常字符,说明是有效的 UTF-8
270
+ if (!utf8Output.includes('�') || utf8Output.match(/[\u4e00-\u9fa5]/)) {
271
+ // UTF-8 解码成功(包含有效中文或没有替换字符)
272
+ output = utf8Output;
273
+ console.log(`[流式输出] 收到stderr(UTF8):`, output.substring(0, 200));
274
+ } else {
275
+ // UTF-8 解码失败,尝试 GBK(可能是 CMD shell 的系统消息)
276
+ try {
277
+ output = iconv.decode(data, 'gbk');
278
+ console.log(`[流式输出] 收到stderr(GBK转UTF8):`, output.substring(0, 200));
279
+ } catch (e) {
280
+ // GBK 也失败,使用原始 UTF-8 结果
281
+ output = utf8Output;
282
+ console.log(`[流式输出] GBK解码失败,使用UTF8:`, output.substring(0, 200));
283
+ }
284
+ }
263
285
  } else {
264
- // 现代工具或 Unix 系统,直接使用 UTF-8
286
+ // Unix系统,直接使用 UTF-8
265
287
  output = data.toString('utf8');
266
288
  console.log(`[流式输出] 收到stderr(UTF8):`, output.substring(0, 200));
267
289
  }
290
+
268
291
  outputReceived = true;
269
292
  collectedStderr += output; // 收集错误输出用于历史记录
270
293
  // 不再自动标记为错误,只显示 stderr 输出
@@ -4835,10 +4858,15 @@ async function startUIServer(noOpen = false, savePort = false) {
4835
4858
  shell: true,
4836
4859
  env: {
4837
4860
  ...process.env,
4838
- GIT_CONFIG_PARAMETERS: "'core.quotepath=false'",
4839
- FORCE_COLOR: '1',
4861
+ // Git 配置:启用颜色输出和禁用路径引用
4862
+ GIT_CONFIG_PARAMETERS: "'color.ui=always' 'color.status=always' 'core.quotepath=false'",
4863
+ // 强制启用颜色输出 - 多种工具的配置
4864
+ FORCE_COLOR: '3', // 使用级别3(最强),支持 chalk 等库
4840
4865
  NPM_CONFIG_COLOR: 'always',
4841
- // 不设置 CI=true,允许交互式输入
4866
+ TERM: 'xterm-256color', // 模拟256色终端环境
4867
+ COLORTERM: 'truecolor', // 支持真彩色
4868
+ CLICOLOR_FORCE: '1', // 强制启用颜色(某些工具检测此变量)
4869
+ // 确保输出不被缓冲(不设置 CI=true,允许交互式输入和颜色输出)
4842
4870
  PYTHONUNBUFFERED: '1'
4843
4871
  }
4844
4872
  });
@@ -4874,7 +4902,31 @@ async function startUIServer(noOpen = false, savePort = false) {
4874
4902
 
4875
4903
  // 监听标准错误输出
4876
4904
  childProcess.stderr?.on('data', (data) => {
4877
- let output = needsGbkConversion ? iconv.decode(data, 'gbk') : data.toString('utf8');
4905
+ let output;
4906
+
4907
+ if (isWindows) {
4908
+ // Windows 平台需要智能检测编码
4909
+ // 先尝试 UTF-8 解码
4910
+ const utf8Output = data.toString('utf8');
4911
+
4912
+ // 检测是否包含 UTF-8 替换字符(�),这通常表示解码失败
4913
+ // 如果没有替换字符且包含正常字符,说明是有效的 UTF-8
4914
+ if (!utf8Output.includes('�') || utf8Output.match(/[\u4e00-\u9fa5]/)) {
4915
+ // UTF-8 解码成功(包含有效中文或没有替换字符)
4916
+ output = utf8Output;
4917
+ } else {
4918
+ // UTF-8 解码失败,尝试 GBK(可能是 CMD shell 的系统消息)
4919
+ try {
4920
+ output = iconv.decode(data, 'gbk');
4921
+ } catch (e) {
4922
+ // GBK 也失败,使用原始 UTF-8 结果
4923
+ output = utf8Output;
4924
+ }
4925
+ }
4926
+ } else {
4927
+ output = data.toString('utf8');
4928
+ }
4929
+
4878
4930
  collectedStderr += output;
4879
4931
  socket.emit('interactive_stderr', { sessionId, data: output });
4880
4932
  });