Browse Source

Write server-info to file so agents can find URL after background launch

The server now writes its startup JSON to $SCREEN_DIR/.server-info.
Agents that launch the server via background execution (where stdout is
hidden) can read this file to get the URL, port, and screen_dir.
Jesse Vincent 6 months ago
parent
commit
7f8edd9c12
2 changed files with 10 additions and 2 deletions
  1. 8 2
      skills/brainstorming/scripts/index.js
  2. 2 0
      skills/brainstorming/visual-companion.md

+ 8 - 2
skills/brainstorming/scripts/index.js

@@ -130,12 +130,18 @@ chokidar.watch(SCREEN_DIR, { ignoreInitial: true })
   });
 
 server.listen(PORT, HOST, () => {
-  console.log(JSON.stringify({
+  const info = JSON.stringify({
     type: 'server-started',
     port: PORT,
     host: HOST,
     url_host: URL_HOST,
     url: `http://${URL_HOST}:${PORT}`,
     screen_dir: SCREEN_DIR
-  }));
+  });
+  console.log(info);
+  // Write to .server-info so agents can find connection details
+  // even when stdout is hidden (e.g. background execution)
+  const fs = require('fs');
+  const path = require('path');
+  fs.writeFileSync(path.join(SCREEN_DIR, '.server-info'), info + '\n');
 });

+ 2 - 0
skills/brainstorming/visual-companion.md

@@ -42,6 +42,8 @@ scripts/start-server.sh --project-dir /path/to/project
 
 Save `screen_dir` from the response. Tell user to open the URL.
 
+**Finding connection info:** The server writes its startup JSON to `$SCREEN_DIR/.server-info`. If you launched the server in the background and didn't capture stdout, read that file to get the URL and port. When using `--project-dir`, check `<project>/.superpowers/brainstorm/` for the session directory.
+
 **Note:** Pass the project root as `--project-dir` so mockups persist in `.superpowers/brainstorm/` and survive server restarts. Without it, files go to `/tmp` and get cleaned up. Remind the user to add `.superpowers/` to `.gitignore` if it's not already there.
 
 **Launching the server by platform:**