@adversity/coding-tool-x 2.4.2 → 2.5.1
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/CHANGELOG.md +23 -0
- package/dist/web/assets/{icons-BkBtk3H1.js → icons-BALJo7bE.js} +1 -1
- package/dist/web/assets/{index-Cgq2DyzS.css → index-CvHZsWbE.css} +3 -3
- package/dist/web/assets/index-DZjidyED.js +14 -0
- package/dist/web/assets/{naive-ui-D-gb0WfN.js → naive-ui-sh0u_0bf.js} +1 -1
- package/dist/web/assets/{vendors-Bd5vxA1-.js → vendors-CzcvkTIS.js} +1 -1
- package/dist/web/assets/{vue-vendor-hRp8vsrL.js → vue-vendor-CEeI-Azr.js} +1 -1
- package/dist/web/index.html +6 -6
- package/package.json +2 -1
- package/src/commands/security.js +36 -0
- package/src/index.js +19 -3
- package/src/server/api/config-export.js +122 -32
- package/src/server/api/security.js +53 -0
- package/src/server/api/terminal.js +5 -1
- package/src/server/index.js +1 -0
- package/src/server/services/config-export-service.js +611 -38
- package/src/server/services/pty-manager.js +250 -28
- package/src/server/services/security-config.js +131 -0
- package/src/server/services/terminal-config.js +81 -1
- package/src/server/services/terminal-detector.js +76 -1
- package/src/server/services/ui-config.js +2 -0
- package/src/server/websocket-server.js +14 -3
- package/dist/web/assets/index-DOsR4qc6.js +0 -14
|
@@ -18,6 +18,61 @@ function detectAvailableTerminals() {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* 获取系统 Shell 路径
|
|
23
|
+
*/
|
|
24
|
+
function getSystemShell() {
|
|
25
|
+
if (process.platform === 'win32') {
|
|
26
|
+
const candidates = [];
|
|
27
|
+
if (process.env.COMSPEC) {
|
|
28
|
+
candidates.push(process.env.COMSPEC);
|
|
29
|
+
}
|
|
30
|
+
const systemRoot = process.env.SystemRoot || process.env.windir;
|
|
31
|
+
if (systemRoot) {
|
|
32
|
+
candidates.push(path.join(systemRoot, 'System32', 'cmd.exe'));
|
|
33
|
+
}
|
|
34
|
+
return candidates.find((candidate) => candidate && fs.existsSync(candidate)) || null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (process.env.SHELL && fs.existsSync(process.env.SHELL)) {
|
|
38
|
+
return process.env.SHELL;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const commonShells = [
|
|
42
|
+
'/bin/zsh',
|
|
43
|
+
'/bin/bash',
|
|
44
|
+
'/bin/sh',
|
|
45
|
+
'/usr/bin/zsh',
|
|
46
|
+
'/usr/bin/bash',
|
|
47
|
+
'/usr/bin/sh'
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
for (const shell of commonShells) {
|
|
51
|
+
if (fs.existsSync(shell)) {
|
|
52
|
+
return shell;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function createSystemShellEntry(isDefault = false) {
|
|
60
|
+
const shell = getSystemShell();
|
|
61
|
+
if (!shell) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
id: 'system-shell',
|
|
67
|
+
name: '系统 Shell',
|
|
68
|
+
available: true,
|
|
69
|
+
isDefault,
|
|
70
|
+
command: 'Web 终端(系统 Shell)',
|
|
71
|
+
supportsLocalLaunch: false,
|
|
72
|
+
shell
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
21
76
|
/**
|
|
22
77
|
* Windows 终端检测
|
|
23
78
|
* 只保留经过验证、确定能自动执行命令的终端
|
|
@@ -82,6 +137,11 @@ function detectWindowsTerminals() {
|
|
|
82
137
|
}
|
|
83
138
|
}
|
|
84
139
|
|
|
140
|
+
const systemShell = createSystemShellEntry(false);
|
|
141
|
+
if (systemShell) {
|
|
142
|
+
terminals.push(systemShell);
|
|
143
|
+
}
|
|
144
|
+
|
|
85
145
|
return terminals;
|
|
86
146
|
}
|
|
87
147
|
|
|
@@ -245,6 +305,11 @@ function detectMacTerminals() {
|
|
|
245
305
|
// Rio 不可用
|
|
246
306
|
}
|
|
247
307
|
|
|
308
|
+
const systemShell = createSystemShellEntry(false);
|
|
309
|
+
if (systemShell) {
|
|
310
|
+
terminals.push(systemShell);
|
|
311
|
+
}
|
|
312
|
+
|
|
248
313
|
return terminals;
|
|
249
314
|
}
|
|
250
315
|
|
|
@@ -254,6 +319,8 @@ function detectMacTerminals() {
|
|
|
254
319
|
function detectLinuxTerminals() {
|
|
255
320
|
const terminals = [];
|
|
256
321
|
|
|
322
|
+
const systemShell = createSystemShellEntry(false);
|
|
323
|
+
|
|
257
324
|
const terminalConfigs = [
|
|
258
325
|
{ id: 'gnome-terminal', name: 'GNOME Terminal', cmd: 'gnome-terminal', args: '-- bash -c "cd \'{cwd}\' && claude -r {sessionId}; exec bash"' },
|
|
259
326
|
{ id: 'konsole', name: 'Konsole', cmd: 'konsole', args: '-e bash -c "cd \'{cwd}\' && claude -r {sessionId}; exec bash"' },
|
|
@@ -288,6 +355,13 @@ function detectLinuxTerminals() {
|
|
|
288
355
|
}
|
|
289
356
|
});
|
|
290
357
|
|
|
358
|
+
if (systemShell) {
|
|
359
|
+
if (!terminals.find(t => t.isDefault)) {
|
|
360
|
+
systemShell.isDefault = true;
|
|
361
|
+
}
|
|
362
|
+
terminals.push(systemShell);
|
|
363
|
+
}
|
|
364
|
+
|
|
291
365
|
return terminals;
|
|
292
366
|
}
|
|
293
367
|
|
|
@@ -302,5 +376,6 @@ function getDefaultTerminal() {
|
|
|
302
376
|
|
|
303
377
|
module.exports = {
|
|
304
378
|
detectAvailableTerminals,
|
|
305
|
-
getDefaultTerminal
|
|
379
|
+
getDefaultTerminal,
|
|
380
|
+
getSystemShell
|
|
306
381
|
};
|
|
@@ -53,6 +53,8 @@ function readUIConfigFromFile() {
|
|
|
53
53
|
const data = JSON.parse(content);
|
|
54
54
|
// Merge with defaults to ensure all keys exist
|
|
55
55
|
return {
|
|
56
|
+
...DEFAULT_UI_CONFIG,
|
|
57
|
+
...data,
|
|
56
58
|
theme: data.theme || DEFAULT_UI_CONFIG.theme,
|
|
57
59
|
panelVisibility: { ...DEFAULT_UI_CONFIG.panelVisibility, ...data.panelVisibility },
|
|
58
60
|
channelLocks: { ...DEFAULT_UI_CONFIG.channelLocks, ...data.channelLocks },
|
|
@@ -392,6 +392,7 @@ function broadcastSchedulerState(source, schedulerState) {
|
|
|
392
392
|
// ============ 终端 WebSocket 消息处理 ============
|
|
393
393
|
|
|
394
394
|
const { getCommandForChannel } = require('./services/terminal-commands');
|
|
395
|
+
const { getWebTerminalShellConfig } = require('./services/terminal-config');
|
|
395
396
|
|
|
396
397
|
/**
|
|
397
398
|
* 处理终端相关的 WebSocket 消息
|
|
@@ -444,13 +445,16 @@ function handleTerminalCreate(ws, message) {
|
|
|
444
445
|
// 获取启动命令
|
|
445
446
|
const startCommand = getCommandForChannel(channel, sessionId, workDir);
|
|
446
447
|
|
|
448
|
+
const shellConfig = getWebTerminalShellConfig();
|
|
449
|
+
|
|
447
450
|
// 创建终端
|
|
448
451
|
const terminal = ptyManager.create({
|
|
449
452
|
cwd: workDir,
|
|
450
453
|
channel,
|
|
451
454
|
sessionId,
|
|
452
455
|
projectName,
|
|
453
|
-
startCommand
|
|
456
|
+
startCommand,
|
|
457
|
+
...shellConfig
|
|
454
458
|
});
|
|
455
459
|
|
|
456
460
|
// 绑定 WebSocket
|
|
@@ -476,7 +480,7 @@ function handleTerminalCreate(ws, message) {
|
|
|
476
480
|
* 绑定到已有终端
|
|
477
481
|
*/
|
|
478
482
|
function handleTerminalAttach(ws, message) {
|
|
479
|
-
const { terminalId } = message;
|
|
483
|
+
const { terminalId, includeHistory, cols, rows } = message;
|
|
480
484
|
|
|
481
485
|
if (!terminalId) {
|
|
482
486
|
ws.send(JSON.stringify({
|
|
@@ -498,7 +502,14 @@ function handleTerminalAttach(ws, message) {
|
|
|
498
502
|
|
|
499
503
|
// 绑定 WebSocket
|
|
500
504
|
ws.terminalId = terminalId;
|
|
501
|
-
|
|
505
|
+
const shouldIncludeHistory = typeof includeHistory === 'boolean' ? includeHistory : true;
|
|
506
|
+
if (Number.isFinite(cols) && Number.isFinite(rows) && cols > 0 && rows > 0) {
|
|
507
|
+
ptyManager.resize(terminalId, cols, rows);
|
|
508
|
+
}
|
|
509
|
+
ptyManager.attachWebSocket(terminalId, ws, {
|
|
510
|
+
includeHistory: shouldIncludeHistory,
|
|
511
|
+
trimLastLine: true
|
|
512
|
+
});
|
|
502
513
|
|
|
503
514
|
ws.send(JSON.stringify({
|
|
504
515
|
type: 'terminal:attached',
|