mnfst-run 1.0.16 → 1.0.18

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 (2) hide show
  1. package/package.json +1 -1
  2. package/serve.mjs +30 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst-run",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Zero-dependency dev server for Manifest projects",
5
5
  "type": "module",
6
6
  "bin": {
package/serve.mjs CHANGED
@@ -4,6 +4,7 @@
4
4
  *
5
5
  * Usage:
6
6
  * npx mnfst-run [dir] [--port 5001] [--idle-shutdown 30] [--no-idle-shutdown]
7
+ * [--open | --no-open]
7
8
  * npx mnfst-run --list
8
9
  *
9
10
  * dir Directory to serve (default: current directory). Any
@@ -23,6 +24,13 @@
23
24
  * overnight with the preview tab still open.
24
25
  * --no-idle-shutdown Disable auto-shutdown (useful in CI / headless cases
25
26
  * where no browser will connect).
27
+ * --open / --no-open Force / suppress auto-opening an OS browser tab on
28
+ * start. Default: open for manual runs, but SUPPRESSED
29
+ * under CI and Claude Code (CLAUDECODE /
30
+ * CLAUDE_CODE_ENTRYPOINT) — there the LLM app's preview
31
+ * panel already shows the page, so a second browser tab
32
+ * is just noise. Put `--no-open` in an LLM preview's
33
+ * launch config to guarantee suppression.
26
34
  * --list Print all mnfst-run servers currently running on this
27
35
  * machine and exit.
28
36
  *
@@ -192,12 +200,26 @@ let idleShutdownEnabled = !(
192
200
  process.env.CLAUDECODE
193
201
  );
194
202
 
203
+ // Auto-open a browser tab on start — a convenience for manual terminal/IDE
204
+ // runs (saves copy-pasting the URL). Suppressed by default under CI / Claude
205
+ // Code, where an LLM app's preview panel IS the browser and already shows the
206
+ // page — popping a second OS browser tab is just noise. Override either way
207
+ // with `--open` / `--no-open` (and `--no-open` belongs in an LLM preview's
208
+ // launch config to guarantee suppression regardless of env detection).
209
+ let openBrowserEnabled = !(
210
+ process.env.CI === 'true' ||
211
+ process.env.CLAUDE_CODE_ENTRYPOINT ||
212
+ process.env.CLAUDECODE
213
+ );
214
+
195
215
  let listMode = false;
196
216
 
197
217
  for (let i = 0; i < args.length; i++) {
198
218
  if ((args[i] === '--port' || args[i] === '-p') && args[i + 1]) { port = parseInt(args[++i], 10); continue; }
199
219
  if (args[i] === '--no-idle-shutdown') { idleShutdownEnabled = false; continue; }
200
220
  if (args[i] === '--idle-shutdown' && args[i + 1]) { idleShutdownSec = parseInt(args[++i], 10); continue; }
221
+ if (args[i] === '--no-open') { openBrowserEnabled = false; continue; }
222
+ if (args[i] === '--open') { openBrowserEnabled = true; continue; }
201
223
  if (args[i] === '--list' || args[i] === '-l') { listMode = true; continue; }
202
224
  if (!args[i].startsWith('-')) dir = args[i];
203
225
  }
@@ -326,10 +348,13 @@ if (existing) {
326
348
  const label0 = dir === '.' ? basename(process.cwd()) : dir.replace(/\\/g, '/');
327
349
  console.log(`\n${label0} already running at ${url} (pid ${existing.pid})\n`);
328
350
  // Open the browser anyway — matches the experience of starting fresh.
329
- const cmd = process.platform === 'win32' ? `start ${url}`
330
- : process.platform === 'darwin' ? `open ${url}`
331
- : `xdg-open ${url}`;
332
- exec(cmd);
351
+ // (Skipped under --no-open / Claude Code, where the preview panel is the browser.)
352
+ if (openBrowserEnabled) {
353
+ const cmd = process.platform === 'win32' ? `start ${url}`
354
+ : process.platform === 'darwin' ? `open ${url}`
355
+ : `xdg-open ${url}`;
356
+ exec(cmd);
357
+ }
333
358
  process.exit(0);
334
359
  }
335
360
 
@@ -621,7 +646,7 @@ function tryListen(p, attempt = 0) {
621
646
  const url = `http://localhost:${p}`;
622
647
  writeRegistry(root, p);
623
648
  console.log(`\n${label} running at ${url}\n`);
624
- openBrowser(url);
649
+ if (openBrowserEnabled) openBrowser(url);
625
650
  };
626
651
  const onError = err => {
627
652
  server.removeListener('listening', onListening);