devbonzai 2.2.306 → 2.2.307

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/cli.js CHANGED
@@ -109,8 +109,6 @@ async function main() {
109
109
  packageJson.dependencies.express = "^4.18.2";
110
110
  packageJson.dependencies.cors = "^2.8.5";
111
111
  packageJson.dependencies["@babel/parser"] = "^7.23.0";
112
- packageJson.dependencies["node-pty"] = "^1.0.0";
113
- packageJson.dependencies.ws = "^8.16.0";
114
112
 
115
113
  // Add script to run receiver
116
114
  if (!packageJson.scripts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devbonzai",
3
- "version": "2.2.306",
3
+ "version": "2.2.307",
4
4
  "description": "Quickly set up a local file server in any repository for browser-based file access",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -24,8 +24,6 @@
24
24
  "dependencies": {
25
25
  "express": "^4.18.2",
26
26
  "cors": "^2.8.5",
27
- "@babel/parser": "^7.23.0",
28
- "node-pty": "^1.0.0",
29
- "ws": "^8.16.0"
27
+ "@babel/parser": "^7.23.0"
30
28
  }
31
29
  }
@@ -8,8 +8,7 @@ function indexHandler(req, res) {
8
8
  'POST /delete': 'Delete file or directory (body: {path})',
9
9
  'POST /open-cursor': 'Open Cursor (body: {path, line?})',
10
10
  'POST /shutdown': 'Gracefully shutdown the server',
11
- 'POST /scan_code_quality': 'Scan code quality (body: {projectPath})',
12
- 'WS /terminal?cwd=<path>': 'WebSocket terminal connection (optional cwd query param)'
11
+ 'POST /scan_code_quality': 'Scan code quality (body: {projectPath})'
13
12
  },
14
13
  example: 'Try: /list or /read?path=README.md'
15
14
  });
@@ -2,8 +2,6 @@
2
2
 
3
3
  const express = require('./node_modules/express');
4
4
  const cors = require('./node_modules/cors');
5
- const WebSocket = require('./node_modules/ws');
6
- const { ROOT } = require('./config');
7
5
 
8
6
  // Import handlers
9
7
  const indexHandler = require('./handlers/index');
@@ -13,7 +11,6 @@ const deleteHandler = require('./handlers/delete');
13
11
  const openCursorHandler = require('./handlers/open-cursor');
14
12
  const shutdownHandler = require('./handlers/shutdown');
15
13
  const scanCodeQualityHandler = require('./handlers/scan_code_quality');
16
- const { handleTerminalConnection } = require('./handlers/terminal');
17
14
 
18
15
  const app = express();
19
16
 
@@ -30,30 +27,6 @@ app.post('/shutdown', shutdownHandler);
30
27
  app.post('/scan_code_quality', scanCodeQualityHandler);
31
28
 
32
29
  const port = 3001;
33
- const server = app.listen(port, () => {
30
+ app.listen(port, () => {
34
31
  console.log('📂 File server running on http://localhost:' + port);
35
32
  });
36
-
37
- // WebSocket server for terminal
38
- const wss = new WebSocket.Server({
39
- server,
40
- path: '/terminal'
41
- });
42
-
43
- wss.on('connection', (ws, req) => {
44
- // Extract working directory from query string if provided
45
- let workingDirectory = ROOT;
46
-
47
- if (req.url) {
48
- const urlMatch = req.url.match(/[?&]cwd=([^&]+)/);
49
- if (urlMatch) {
50
- try {
51
- workingDirectory = decodeURIComponent(urlMatch[1]);
52
- } catch (e) {
53
- console.warn('Invalid cwd parameter, using default:', e.message);
54
- }
55
- }
56
- }
57
-
58
- handleTerminalConnection(ws, workingDirectory);
59
- });
@@ -1,97 +0,0 @@
1
- const pty = require('node-pty');
2
- const fs = require('fs');
3
-
4
- // Store active terminal sessions
5
- const terminals = new Map();
6
-
7
- function handleTerminalConnection(ws, workingDirectory) {
8
- // Use user's default shell, fallback to /bin/zsh
9
- const shell = process.platform === 'win32' ? 'powershell.exe' : (process.env.SHELL || '/bin/zsh');
10
- const cwd = workingDirectory || process.env.HOME;
11
-
12
- // Debug logging
13
- console.log('🖥️ Terminal session starting...');
14
- console.log(' Shell:', shell, '| Exists:', fs.existsSync(shell));
15
- console.log(' CWD:', cwd, '| Exists:', fs.existsSync(cwd));
16
-
17
- const ptyProcess = pty.spawn(shell, [], {
18
- name: 'xterm-256color',
19
- cols: 80,
20
- rows: 24,
21
- cwd: cwd,
22
- env: {
23
- ...process.env,
24
- TERM: 'xterm-256color',
25
- COLORTERM: 'truecolor',
26
- },
27
- });
28
-
29
- const terminalId = Date.now().toString();
30
- terminals.set(terminalId, { pty: ptyProcess, ws });
31
-
32
- // Send PTY output to WebSocket
33
- ptyProcess.onData((data) => {
34
- try {
35
- if (ws.readyState === 1) { // WebSocket.OPEN
36
- ws.send(data);
37
- }
38
- } catch (err) {
39
- console.error('Error sending to WebSocket:', err);
40
- }
41
- });
42
-
43
- // Handle incoming messages from WebSocket
44
- ws.on('message', (msg) => {
45
- try {
46
- const message = msg.toString();
47
-
48
- // Check if it's a resize command
49
- if (message.startsWith('\x1b[8;')) {
50
- // Parse resize: ESC[8;rows;colst
51
- const match = message.match(/\x1b\[8;(\d+);(\d+)t/);
52
- if (match) {
53
- const rows = parseInt(match[1], 10);
54
- const cols = parseInt(match[2], 10);
55
- ptyProcess.resize(cols, rows);
56
- return;
57
- }
58
- }
59
-
60
- // Check for JSON resize command
61
- if (message.startsWith('{')) {
62
- try {
63
- const json = JSON.parse(message);
64
- if (json.type === 'resize' && json.cols && json.rows) {
65
- ptyProcess.resize(json.cols, json.rows);
66
- return;
67
- }
68
- } catch (e) {
69
- // Not JSON, treat as regular input
70
- }
71
- }
72
-
73
- // Regular terminal input
74
- ptyProcess.write(message);
75
- } catch (err) {
76
- console.error('Error processing message:', err);
77
- }
78
- });
79
-
80
- // Clean up on WebSocket close
81
- ws.on('close', () => {
82
- console.log('🖥️ Terminal session closed');
83
- ptyProcess.kill();
84
- terminals.delete(terminalId);
85
- });
86
-
87
- // Handle PTY exit
88
- ptyProcess.onExit(({ exitCode, signal }) => {
89
- console.log(`🖥️ Terminal process exited (code: ${exitCode}, signal: ${signal})`);
90
- terminals.delete(terminalId);
91
- if (ws.readyState === 1) {
92
- ws.close();
93
- }
94
- });
95
- }
96
-
97
- module.exports = { handleTerminalConnection };