bonzai-tools 1.0.97 → 1.0.99

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.
@@ -7,15 +7,60 @@ const fs = require('fs');
7
7
  const path = require('path');
8
8
  const { ROOT } = require('./config');
9
9
 
10
+ const port = 3001;
10
11
  const app = express();
11
12
  const server = http.createServer(app);
12
13
 
13
14
  app.use(cors());
14
15
  app.use(express.json());
15
16
 
16
- // Root route
17
+ // Serve static build files
18
+ const buildDir = path.join(__dirname, 'build');
19
+ app.use('/static', express.static(path.join(buildDir, 'static')));
20
+
21
+ // Embed shell - serves HTML that loads bundled app
17
22
  app.get('/', (req, res) => {
18
23
  const repoName = path.basename(ROOT);
24
+
25
+ // Read asset manifest to get hashed filenames
26
+ const manifestPath = path.join(buildDir, 'asset-manifest.json');
27
+ let cssFile = '';
28
+ let jsFile = '';
29
+
30
+ try {
31
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
32
+ cssFile = manifest.files['main.css'] || '';
33
+ jsFile = manifest.files['main.js'] || '';
34
+ } catch (e) {
35
+ console.error('Could not read asset-manifest.json:', e.message);
36
+ }
37
+
38
+ res.send(`<!DOCTYPE html>
39
+ <html>
40
+ <head>
41
+ <meta charset="UTF-8">
42
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
43
+ <title>Bonzai - ${repoName}</title>
44
+ ${cssFile ? `<link rel="stylesheet" href="${cssFile}">` : ''}
45
+ <style>
46
+ * { margin: 0; padding: 0; box-sizing: border-box; }
47
+ html, body, #root { height: 100%; }
48
+ </style>
49
+ </head>
50
+ <body>
51
+ <div id="root"></div>
52
+ <script>
53
+ window.BONZAI_REPO = "${repoName}";
54
+ window.BONZAI_API = "http://localhost:${port}";
55
+ </script>
56
+ ${jsFile ? `<script src="${jsFile}"></script>` : '<p>Build not found. Run npm run build in the frontend.</p>'}
57
+ </body>
58
+ </html>`);
59
+ });
60
+
61
+ // Health check
62
+ app.get('/health', (req, res) => {
63
+ const repoName = path.basename(ROOT);
19
64
  res.json({ message: 'Bonzai Server', status: 'running', repoName });
20
65
  });
21
66
 
@@ -53,7 +98,6 @@ if (terminalHandlers) {
53
98
  app.get('/terminal', terminalHandlers.terminalHandler);
54
99
  }
55
100
 
56
- const port = 3001;
57
101
  server.listen(port, () => {
58
102
  console.log('File server running on http://localhost:' + port);
59
103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bonzai-tools",
3
- "version": "1.0.97",
3
+ "version": "1.0.99",
4
4
  "description": "Visualization and file management tools for codebases",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",