zen-gitsync 2.11.39 → 2.12.3

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 (58) hide show
  1. package/LICENSE +190 -21
  2. package/README.md +695 -695
  3. package/index.js +25 -11
  4. package/package.json +2 -2
  5. package/scripts/convert-colors-to-vars.cjs +286 -272
  6. package/scripts/convert-fontsize-to-vars.cjs +221 -207
  7. package/scripts/convert-spacing-to-vars.cjs +256 -242
  8. package/scripts/convert-to-standard-vars.cjs +282 -268
  9. package/scripts/release.js +599 -585
  10. package/src/config.js +350 -336
  11. package/src/gitCommit.js +455 -440
  12. package/src/ui/public/assets/EditorView-CbqSI9nw.css +1 -0
  13. package/src/ui/public/assets/EditorView-GS5cmh99.js +21 -0
  14. package/src/ui/public/assets/SourceMapView-DyMK80hS.css +1 -0
  15. package/src/ui/public/assets/SourceMapView-_YRtzmZZ.js +3 -0
  16. package/src/ui/public/assets/index-ML5Y-5lO.css +1 -0
  17. package/src/ui/public/assets/index-yky0Sd13.js +73 -0
  18. package/src/ui/public/assets/{ts.worker-Dth06zuC.js → ts.worker-METxwbDZ.js} +1 -16
  19. package/src/ui/public/assets/{vendor-B1T2uxYO.js → vendor-DITsiaGj.js} +294 -287
  20. package/src/ui/public/assets/vendor-q83wvJns.css +1 -0
  21. package/src/ui/public/index.html +4 -4
  22. package/src/ui/server/.claude/codediff.txt +6 -0
  23. package/src/ui/server/index.js +410 -396
  24. package/src/ui/server/middleware/requestLogger.js +51 -37
  25. package/src/ui/server/routes/branchStatus.js +101 -87
  26. package/src/ui/server/routes/code.js +110 -96
  27. package/src/ui/server/routes/codeAnalysis.js +995 -981
  28. package/src/ui/server/routes/config.js +1172 -1158
  29. package/src/ui/server/routes/exec.js +272 -258
  30. package/src/ui/server/routes/fileOpen.js +279 -265
  31. package/src/ui/server/routes/fs.js +701 -699
  32. package/src/ui/server/routes/git/diff.js +352 -338
  33. package/src/ui/server/routes/git/diffUtils.js +128 -114
  34. package/src/ui/server/routes/git/stash.js +552 -538
  35. package/src/ui/server/routes/git/tags.js +172 -158
  36. package/src/ui/server/routes/git.js +190 -176
  37. package/src/ui/server/routes/gitOps.js +1179 -1165
  38. package/src/ui/server/routes/instances.js +38 -24
  39. package/src/ui/server/routes/npm.js +1023 -1009
  40. package/src/ui/server/routes/process.js +82 -68
  41. package/src/ui/server/routes/status.js +67 -53
  42. package/src/ui/server/routes/terminal.js +319 -305
  43. package/src/ui/server/socket/registerUiSocketHandlers.js +226 -212
  44. package/src/ui/server/utils/createSavePortToFile.js +46 -32
  45. package/src/ui/server/utils/instanceRegistry.js +270 -256
  46. package/src/ui/server/utils/pathGuard.js +155 -0
  47. package/src/ui/server/utils/pathGuard.test.js +138 -0
  48. package/src/ui/server/utils/randomStartPort.js +51 -37
  49. package/src/ui/server/utils/startServerOnAvailablePort.js +101 -87
  50. package/src/utils/index.js +1058 -1044
  51. package/src/ui/public/assets/devopicons-QN4QXivI.woff2 +0 -0
  52. package/src/ui/public/assets/file-icons-C0jOugUK.woff2 +0 -0
  53. package/src/ui/public/assets/fontawesome-B-jkhYfk.woff2 +0 -0
  54. package/src/ui/public/assets/index-BvVl-092.js +0 -95
  55. package/src/ui/public/assets/index-DXO3Lvqi.css +0 -1
  56. package/src/ui/public/assets/mfixx-CpAhKOZz.woff2 +0 -0
  57. package/src/ui/public/assets/octicons-CaZ_fok2.woff2 +0 -0
  58. package/src/ui/public/assets/vendor-hOO_r_AU.css +0 -1
@@ -1,68 +1,82 @@
1
- export function registerProcessRoutes({
2
- app,
3
- runningProcesses,
4
- exec
5
- }) {
6
- // 停止正在运行的进程
7
- app.post('/api/kill-process', async (req, res) => {
8
- try {
9
- const { processId } = req.body || {};
10
- if (!processId || typeof processId !== 'number') {
11
- return res.status(400).json({ success: false, error: 'processId 必须是数字' });
12
- }
13
-
14
- const processInfo = runningProcesses.get(processId);
15
- if (!processInfo) {
16
- return res.status(404).json({
17
- success: false,
18
- error: `进程 #${processId} 不存在或已结束`
19
- });
20
- }
21
-
22
- console.log(`[进程管理] 尝试停止进程 #${processId}: ${processInfo.command}`);
23
-
24
- try {
25
- // Windows 上需要使用 taskkill 来杀死整个进程树
26
- if (process.platform === 'win32') {
27
- // 使用已导入的 exec
28
- // /F 强制终止, /T 终止进程树
29
- exec(`taskkill /pid ${processInfo.childProcess.pid} /T /F`, (error) => {
30
- if (error) {
31
- console.error(`[进程管理] taskkill 失败:`, error);
32
- }
33
- });
34
- } else {
35
- // Unix/Linux/Mac 使用 SIGTERM
36
- processInfo.childProcess.kill('SIGTERM');
37
-
38
- // 如果 2 秒后还没结束,使用 SIGKILL 强制终止
39
- setTimeout(() => {
40
- if (runningProcesses.has(processId)) {
41
- console.log(`[进程管理] 进程 #${processId} 未响应 SIGTERM,使用 SIGKILL 强制终止`);
42
- processInfo.childProcess.kill('SIGKILL');
43
- }
44
- }, 2000);
45
- }
46
-
47
- res.json({
48
- success: true,
49
- message: `已发送停止信号到进程 #${processId}`,
50
- processId,
51
- command: processInfo.command
52
- });
53
- } catch (killError) {
54
- console.error(`[进程管理] 停止进程失败:`, killError);
55
- res.status(500).json({
56
- success: false,
57
- error: `停止进程失败: ${killError.message}`
58
- });
59
- }
60
- } catch (error) {
61
- console.error('停止进程接口失败:', error);
62
- res.status(500).json({
63
- success: false,
64
- error: `停止进程失败: ${error.message}`
65
- });
66
- }
67
- });
68
- }
1
+ // Copyright 2026 xz333221
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ export function registerProcessRoutes({
16
+ app,
17
+ runningProcesses,
18
+ exec
19
+ }) {
20
+ // 停止正在运行的进程
21
+ app.post('/api/kill-process', async (req, res) => {
22
+ try {
23
+ const { processId } = req.body || {};
24
+ if (!processId || typeof processId !== 'number') {
25
+ return res.status(400).json({ success: false, error: 'processId 必须是数字' });
26
+ }
27
+
28
+ const processInfo = runningProcesses.get(processId);
29
+ if (!processInfo) {
30
+ return res.status(404).json({
31
+ success: false,
32
+ error: `进程 #${processId} 不存在或已结束`
33
+ });
34
+ }
35
+
36
+ console.log(`[进程管理] 尝试停止进程 #${processId}: ${processInfo.command}`);
37
+
38
+ try {
39
+ // Windows 上需要使用 taskkill 来杀死整个进程树
40
+ if (process.platform === 'win32') {
41
+ // 使用已导入的 exec
42
+ // /F 强制终止, /T 终止进程树
43
+ exec(`taskkill /pid ${processInfo.childProcess.pid} /T /F`, (error) => {
44
+ if (error) {
45
+ console.error(`[进程管理] taskkill 失败:`, error);
46
+ }
47
+ });
48
+ } else {
49
+ // Unix/Linux/Mac 使用 SIGTERM
50
+ processInfo.childProcess.kill('SIGTERM');
51
+
52
+ // 如果 2 秒后还没结束,使用 SIGKILL 强制终止
53
+ setTimeout(() => {
54
+ if (runningProcesses.has(processId)) {
55
+ console.log(`[进程管理] 进程 #${processId} 未响应 SIGTERM,使用 SIGKILL 强制终止`);
56
+ processInfo.childProcess.kill('SIGKILL');
57
+ }
58
+ }, 2000);
59
+ }
60
+
61
+ res.json({
62
+ success: true,
63
+ message: `已发送停止信号到进程 #${processId}`,
64
+ processId,
65
+ command: processInfo.command
66
+ });
67
+ } catch (killError) {
68
+ console.error(`[进程管理] 停止进程失败:`, killError);
69
+ res.status(500).json({
70
+ success: false,
71
+ error: `停止进程失败: ${killError.message}`
72
+ });
73
+ }
74
+ } catch (error) {
75
+ console.error('停止进程接口失败:', error);
76
+ res.status(500).json({
77
+ success: false,
78
+ error: `停止进程失败: ${error.message}`
79
+ });
80
+ }
81
+ });
82
+ }
@@ -1,53 +1,67 @@
1
- import { promises as fs } from 'fs';
2
- import path from 'path';
3
-
4
- export function registerStatusRoutes({
5
- app,
6
- getCommandHistory,
7
- execGitCommand
8
- }) {
9
- // Add new endpoint for command history
10
- app.get('/api/command-history', async (req, res) => {
11
- try {
12
- const history = getCommandHistory();
13
- res.json({ success: true, history });
14
- } catch (error) {
15
- res.status(500).json({ success: false, error: error.message });
16
- }
17
- });
18
-
19
- app.get('/api/status_porcelain', async (req, res) => {
20
- try {
21
- const { stdout } = await execGitCommand('git status --porcelain --untracked-files=all');
22
- // 检测是否处于 MERGING 状态(MERGE_HEAD 文件存在)
23
- let isMergeInProgress = false;
24
- let mergeMessage = '';
25
- try {
26
- const { stdout: mergeHead } = await execGitCommand('git rev-parse -q --verify MERGE_HEAD');
27
- isMergeInProgress = mergeHead.trim().length > 0;
28
- if (isMergeInProgress) {
29
- // 读取 Git 自动生成的合并提交信息
30
- try {
31
- const { stdout: gitDir } = await execGitCommand('git rev-parse --git-dir');
32
- const mergeMsgPath = path.resolve(gitDir.trim(), 'MERGE_MSG');
33
- const raw = await fs.readFile(mergeMsgPath, 'utf-8');
34
- // 过滤掉以 # 开头的注释行,取第一个非空行
35
- mergeMessage = raw
36
- .split('\n')
37
- .filter(line => line.trim() && !line.startsWith('#'))
38
- .join('\n')
39
- .trim();
40
- } catch (_) {
41
- // MERGE_MSG 不存在时忽略
42
- }
43
- }
44
- } catch (_) {
45
- // MERGE_HEAD 不存在时命令会报错,属正常情况
46
- isMergeInProgress = false;
47
- }
48
- res.json({ status: stdout, isMergeInProgress, mergeMessage });
49
- } catch (error) {
50
- res.status(500).json({ error: error.message });
51
- }
52
- });
53
- }
1
+ // Copyright 2026 xz333221
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ import { promises as fs } from 'fs';
16
+ import path from 'path';
17
+
18
+ export function registerStatusRoutes({
19
+ app,
20
+ getCommandHistory,
21
+ execGitCommand
22
+ }) {
23
+ // Add new endpoint for command history
24
+ app.get('/api/command-history', async (req, res) => {
25
+ try {
26
+ const history = getCommandHistory();
27
+ res.json({ success: true, history });
28
+ } catch (error) {
29
+ res.status(500).json({ success: false, error: error.message });
30
+ }
31
+ });
32
+
33
+ app.get('/api/status_porcelain', async (req, res) => {
34
+ try {
35
+ const { stdout } = await execGitCommand('git status --porcelain --untracked-files=all');
36
+ // 检测是否处于 MERGING 状态(MERGE_HEAD 文件存在)
37
+ let isMergeInProgress = false;
38
+ let mergeMessage = '';
39
+ try {
40
+ const { stdout: mergeHead } = await execGitCommand('git rev-parse -q --verify MERGE_HEAD');
41
+ isMergeInProgress = mergeHead.trim().length > 0;
42
+ if (isMergeInProgress) {
43
+ // 读取 Git 自动生成的合并提交信息
44
+ try {
45
+ const { stdout: gitDir } = await execGitCommand('git rev-parse --git-dir');
46
+ const mergeMsgPath = path.resolve(gitDir.trim(), 'MERGE_MSG');
47
+ const raw = await fs.readFile(mergeMsgPath, 'utf-8');
48
+ // 过滤掉以 # 开头的注释行,取第一个非空行
49
+ mergeMessage = raw
50
+ .split('\n')
51
+ .filter(line => line.trim() && !line.startsWith('#'))
52
+ .join('\n')
53
+ .trim();
54
+ } catch (_) {
55
+ // MERGE_MSG 不存在时忽略
56
+ }
57
+ }
58
+ } catch (_) {
59
+ // MERGE_HEAD 不存在时命令会报错,属正常情况
60
+ isMergeInProgress = false;
61
+ }
62
+ res.json({ status: stdout, isMergeInProgress, mergeMessage });
63
+ } catch (error) {
64
+ res.status(500).json({ error: error.message });
65
+ }
66
+ });
67
+ }