brainstorm-companion 2.0.0 → 2.0.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/README.md CHANGED
@@ -4,7 +4,7 @@ Visual brainstorming tool for AI coding sessions. Opens a browser window where a
4
4
 
5
5
  Zero dependencies. Node.js >= 18 only.
6
6
 
7
- **Sessions are persistent** — they never time out. Sessions stay alive until you explicitly stop them with `stop` or `brainstorm_stop_session`.
7
+ **Sessions are persistent** — they stay alive until you explicitly stop them with `stop` or `brainstorm_stop_session`. Use `--timeout <minutes>` if you want auto-cleanup.
8
8
 
9
9
  ## Install
10
10
 
@@ -39,34 +39,44 @@ Once configured, the agent has access to 5 tools: `brainstorm_start_session`, `b
39
39
 
40
40
  ## Complete Usage Guide
41
41
 
42
- ### Quick Start (CLI)
42
+ ### Quick Start (CLI) — 3 commands, zero config
43
43
 
44
44
  ```bash
45
- # 1. Start server (opens browser automatically)
46
- brainstorm-companion start --project-dir .
45
+ brainstorm-companion start # opens browser
46
+ brainstorm-companion push --html '<h2>Hello World</h2>' # shows content
47
+ brainstorm-companion stop # cleans up
48
+ ```
49
+
50
+ That's it. No arguments required. Now a fuller example:
51
+
52
+ ```bash
53
+ # Start (opens browser, prints URL)
54
+ brainstorm-companion start
47
55
  # → Server started: http://127.0.0.1:54321
48
- # → Session ID: 1234-1700000000000
49
56
 
50
- # 2. Push content — browser updates instantly
51
- brainstorm-companion push --html '<h2>Dashboard Layout</h2><div class="options"><div class="option" data-choice="grid" onclick="toggleSelect(this)"><div class="letter">A</div><div class="content"><h3>Grid Layout</h3><p>Cards in a responsive grid</p></div></div><div class="option" data-choice="list" onclick="toggleSelect(this)"><div class="letter">B</div><div class="content"><h3>List Layout</h3><p>Vertical scrolling list</p></div></div></div>'
57
+ # Push content — browser updates instantly
58
+ brainstorm-companion push --html '<h2>Dashboard</h2><p>First draft</p>'
52
59
 
53
- # 3. Update content — same browser, no restart needed
54
- brainstorm-companion push --html '<h2>Updated Layout</h2><p>Refined version based on feedback</p>'
60
+ # Update — same browser, auto-reloads
61
+ brainstorm-companion push --html '<h2>Dashboard v2</h2><p>Refined</p>'
55
62
 
56
- # 4. Read user's selection
63
+ # Read what user clicked
57
64
  brainstorm-companion events
58
- # → [{"type":"click","choice":"grid","text":"A Grid Layout Cards in a responsive grid","timestamp":1700000001234}]
59
65
 
60
- # 5. Stop when done
66
+ # Done
61
67
  brainstorm-companion stop
62
68
  ```
63
69
 
64
- **Key behavior:** Calling `start` when a session is already running reuses it — no duplicate browsers. Just keep calling `push` to update the same window. The browser auto-reloads on every push.
70
+ **Key behaviors:**
71
+ - `start` with no args works immediately (stores in `/tmp/brainstorm-companion/`)
72
+ - `start` reuses an existing session — never opens duplicate browsers
73
+ - `push` auto-reloads the browser every time — no restart or refresh needed
74
+ - Add `--project-dir .` for project-local storage
65
75
 
66
- ### Quick Start (MCP / Agent)
76
+ ### Quick Start (MCP / Agent) — 3 calls, zero config
67
77
 
68
78
  ```
69
- 1. brainstorm_start_session({ project_dir: "/path/to/project" })
79
+ 1. brainstorm_start_session()
70
80
  → { url: "http://127.0.0.1:54321", session_dir: "..." }
71
81
 
72
82
  2. brainstorm_push_screen({ html: "<h2>Option A</h2>...", slot: "a", label: "Minimal" })
@@ -80,7 +90,7 @@ brainstorm-companion stop
80
90
  5. brainstorm_stop_session({})
81
91
  ```
82
92
 
83
- **Important:** Call `brainstorm_start_session` once. It returns the existing session if already running. Update content by calling `brainstorm_push_screen` repeatedly the browser auto-reloads each time. Sessions never time out.
93
+ **No arguments required.** `brainstorm_start_session()` works with zero config. Pass `project_dir` for project-local storage or when multiple agents run simultaneously. Sessions persist until `brainstorm_stop_session()` — use `idle_timeout_minutes` for auto-cleanup.
84
94
 
85
95
  ---
86
96
 
@@ -318,10 +328,10 @@ Global Options:
318
328
  ### `start`
319
329
 
320
330
  ```
321
- brainstorm-companion start [--project-dir <path>] [--port <N>] [--host <H>] [--foreground] [--no-open] [--new]
331
+ brainstorm-companion start [--project-dir <path>] [--port <N>] [--host <H>] [--timeout <min>] [--foreground] [--no-open] [--new]
322
332
  ```
323
333
 
324
- If a session is already running, prints its URL and reuses it. Use `--new` to force a separate parallel session.
334
+ If a session is already running, prints its URL and reuses it. Use `--new` to force a separate parallel session. Use `--timeout 30` for auto-cleanup after 30 minutes idle (default: no timeout).
325
335
 
326
336
  ### `push`
327
337
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainstorm-companion",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "AI-assisted visual brainstorming companion",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
package/skill/SKILL.md CHANGED
@@ -5,24 +5,32 @@ description: Visual brainstorming companion — opens a browser window for compa
5
5
 
6
6
  # Brainstorm Companion — Complete Agent Reference
7
7
 
8
+ ## Quickstart (3 calls, no setup)
9
+
10
+ ```
11
+ brainstorm_start_session()
12
+ brainstorm_push_screen({ html: "<h2>Hello World</h2><p>Your content here</p>" })
13
+ brainstorm_stop_session()
14
+ ```
15
+
16
+ That's it. No arguments required. A browser opens, your HTML appears, and cleanup happens automatically.
17
+
8
18
  ## When to Use
9
19
 
10
- Use this tool when you need to:
11
- - Show visual mockups, UI designs, or layout options to the user
12
- - Compare multiple design alternatives side-by-side (A/B/C comparison)
20
+ - Show visual mockups, UI designs, or layout options
21
+ - Compare design alternatives side-by-side (A/B/C)
13
22
  - Present architecture diagrams (Mermaid), code samples (Prism), or math (KaTeX)
14
- - Get visual feedback — user clicks and preferences are captured as events
15
- - Show interactive prototypes or wireframes
23
+ - Get visual feedback — user clicks and preferences captured as events
16
24
 
17
- **Don't use** for plain text output, simple data, or anything that works fine in the terminal.
25
+ **Don't use** for plain text, simple data, or anything fine in the terminal.
18
26
 
19
27
  ## Session Lifecycle
20
28
 
21
- Sessions are **persistent**they never time out. A session stays alive until explicitly stopped via `brainstorm_stop_session`. This means:
22
- - No 30-minute idle timeout
23
- - Sessions survive long user breaks
24
- - You only need to start once per workflow
25
- - Always clean up with `brainstorm_stop_session` when done
29
+ - **No setup needed** — `brainstorm_start_session()` works with zero arguments
30
+ - **Sessions are persistent** — they stay alive until you call `brainstorm_stop_session`
31
+ - **Safe to call start multiple times** — reuses existing session, never duplicates
32
+ - **Optional timeout** pass `idle_timeout_minutes` for auto-cleanup
33
+ - **Always stop when done** `brainstorm_stop_session()` frees port and cleans up
26
34
 
27
35
  ---
28
36
 
@@ -30,20 +38,24 @@ Sessions are **persistent** — they never time out. A session stays alive until
30
38
 
31
39
  ### brainstorm_start_session
32
40
 
33
- Start the server and open a browser window. If a session is already running, it reuses it no duplicate browsers.
41
+ Start the server and open a browser. Works with no arguments. Reuses existing session if one is running.
34
42
 
35
43
  ```
44
+ // Simplest — no args needed:
45
+ brainstorm_start_session()
46
+ → { url: "http://127.0.0.1:54321", session_dir: "..." }
47
+
48
+ // With options:
36
49
  brainstorm_start_session({
37
- project_dir: "/path/to/project", // ALWAYS pass this — use the current working directory
50
+ project_dir: "/path/to/project", // optional — use cwd for project-local storage
38
51
  open_browser: true, // default: true
39
- port: 0 // default: random
52
+ idle_timeout_minutes: 0 // default: 0 = no timeout. Set 30 for auto-cleanup.
40
53
  })
41
- → { url: "http://127.0.0.1:54321", session_dir: "..." }
42
54
  ```
43
55
 
44
- **Always pass `project_dir`** this keeps session files with the project and avoids conflicts between agents. Without it, all sessions go to `/tmp/brainstorm-companion/` and may collide.
56
+ **`project_dir` is optional.** Without it, sessions go to `/tmp/brainstorm-companion/`. Pass the current working directory for project-local storage or when multiple agents may run simultaneously.
45
57
 
46
- **Calling `brainstorm_start_session` multiple times is safe** — it returns the existing session URL if one is already running. You do NOT need to stop and restart to update content. Just call `brainstorm_push_screen` to update the same browser window.
58
+ **Calling it multiple times is safe** — returns the existing session. Just call `brainstorm_push_screen` to update content.
47
59
 
48
60
  ### brainstorm_push_screen
49
61
 
package/src/cli.js CHANGED
@@ -14,30 +14,44 @@ const { SessionManager } = require('./session');
14
14
  const HELP = {
15
15
  main: `Usage: brainstorm-companion <command> [options]
16
16
 
17
- Opens a browser window for visual brainstorming alongside AI coding sessions.
18
- Agents push HTML content and users interact visually.
17
+ Visual brainstorming tool. Opens a browser, you push HTML, users interact.
18
+
19
+ Quickstart (3 commands):
20
+ brainstorm-companion start
21
+ brainstorm-companion push --html '<h2>Hello World</h2>'
22
+ brainstorm-companion stop
23
+
24
+ How it works:
25
+ 1. "start" opens a browser (reuses existing session if one is running)
26
+ 2. "push" sends HTML to the browser — auto-reloads instantly, every time
27
+ 3. "events" reads what the user clicked (choices, preferences)
28
+ 4. "stop" ends the session
19
29
 
20
30
  Commands:
21
- start Start the brainstorm server and open browser
22
- push Push HTML content to the browser
23
- events Read user interaction events
31
+ start Start server and open browser (or reuse existing session)
32
+ push Push HTML content browser auto-reloads each time
33
+ events Read user interaction events (clicks, preferences)
24
34
  clear Clear content or events
25
- stop Stop the server
26
- status Show server status
35
+ stop Stop the server and clean up
36
+ status Show session info (URL, uptime, slots, events)
27
37
 
28
38
  Global Options:
29
- --project-dir <path> Session storage location (default: /tmp/brainstorm-companion/)
30
- --session <id> Target a specific session (required for parallel instances)
39
+ --project-dir <path> Session storage (default: /tmp/brainstorm-companion/)
40
+ --session <id> Target a specific session (for parallel use)
31
41
  --mcp Run as MCP server (stdio JSON-RPC)
32
- --help, -h Show help (use "<command> --help" for command details)
42
+ --help, -h Show help (use "<command> --help" for details)
33
43
 
34
- Examples:
35
- brainstorm-companion start
36
- brainstorm-companion push --html '<h2>Hello</h2>'
37
- brainstorm-companion push mockup.html --slot a --label "Option A"
38
- echo '<h2>World</h2>' | brainstorm-companion push -
39
- brainstorm-companion events --format json
40
- brainstorm-companion stop`,
44
+ Comparison mode (side-by-side with tabs):
45
+ brainstorm-companion push --html '<h2>A</h2>' --slot a --label "Grid"
46
+ brainstorm-companion push --html '<h2>B</h2>' --slot b --label "List"
47
+
48
+ Key concepts:
49
+ - No setup needed — "start" works with zero arguments
50
+ - Push HTML fragments (not full documents) — theming is automatic
51
+ - Use --slot a/b/c + --label for side-by-side comparison
52
+ - Add data-choice="val" onclick="toggleSelect(this)" for clickable elements
53
+ - class="mermaid", class="language-*", $$math$$ auto-detected
54
+ - Sessions persist until stopped — use --timeout <min> for auto-cleanup`,
41
55
 
42
56
  start: `Usage: brainstorm-companion start [options]
43
57
 
@@ -46,12 +60,13 @@ Start the brainstorm server and open a browser window.
46
60
  If a session is already running for this project, it reuses it (prints the
47
61
  existing URL). Use --new to force a separate session.
48
62
 
49
- Sessions are persistent they never time out. Stop explicitly with "stop".
63
+ Sessions persist until explicitly stopped no timeout by default.
50
64
 
51
65
  Options:
52
66
  --project-dir <path> Session storage location (default: /tmp/brainstorm-companion/)
53
67
  --port <number> Bind to specific port (default: random ephemeral)
54
68
  --host <address> Bind address (default: 127.0.0.1)
69
+ --timeout <minutes> Auto-stop after N minutes of inactivity (default: none)
55
70
  --foreground Run server in foreground (don't background)
56
71
  --no-open Don't auto-open browser
57
72
  --new Force a new session even if one is already running
@@ -62,8 +77,9 @@ Output:
62
77
 
63
78
  Examples:
64
79
  brainstorm-companion start
65
- brainstorm-companion start --project-dir ./my-project --no-open
66
- brainstorm-companion start --new # force separate parallel session`,
80
+ brainstorm-companion start --project-dir .
81
+ brainstorm-companion start --timeout 30 # auto-stop after 30min idle
82
+ brainstorm-companion start --new --no-open # parallel session, no browser`,
67
83
 
68
84
  push: `Usage: brainstorm-companion push [<file|->] [options]
69
85
 
@@ -231,6 +247,7 @@ async function start(argv) {
231
247
  'project-dir': { type: 'string' },
232
248
  'port': { type: 'string', default: '0' },
233
249
  'host': { type: 'string', default: '127.0.0.1' },
250
+ 'timeout': { type: 'string' },
234
251
  'foreground': { type: 'boolean', default: false },
235
252
  'no-open': { type: 'boolean', default: false },
236
253
  'new': { type: 'boolean', default: false },
@@ -241,6 +258,8 @@ async function start(argv) {
241
258
  const projectDir = values['project-dir'] || null;
242
259
  const host = values['host'];
243
260
  const port = parseInt(values['port'], 10) || 0;
261
+ const timeoutMin = values['timeout'] ? parseInt(values['timeout'], 10) : 0;
262
+ const idleTimeoutMs = timeoutMin > 0 ? timeoutMin * 60 * 1000 : 0;
244
263
  const foreground = values['foreground'];
245
264
  const noOpen = values['no-open'];
246
265
  const forceNew = values['new'];
@@ -269,6 +288,7 @@ async function start(argv) {
269
288
  host,
270
289
  port,
271
290
  ownerPid: process.pid,
291
+ idleTimeoutMs,
272
292
  });
273
293
 
274
294
  instance.server.once('listening', () => {
@@ -304,9 +324,7 @@ async function start(argv) {
304
324
  BRAINSTORM_DIR: sessionDir,
305
325
  BRAINSTORM_HOST: host,
306
326
  BRAINSTORM_PORT: String(port),
307
- // No BRAINSTORM_OWNER_PID in background mode — the CLI process
308
- // exits immediately, so the server must live independently.
309
- // No idle timeout — session persists until explicitly stopped.
327
+ BRAINSTORM_IDLE_TIMEOUT: String(idleTimeoutMs),
310
328
  },
311
329
  });
312
330
  child.unref();
package/src/mcp.js CHANGED
@@ -50,7 +50,7 @@ class McpServer {
50
50
  this.respond(id, {
51
51
  protocolVersion: '2024-11-05',
52
52
  capabilities: { tools: {} },
53
- serverInfo: { name: 'brainstorm-companion', version: '2.0.0' }
53
+ serverInfo: { name: 'brainstorm-companion', version: '2.0.1' }
54
54
  });
55
55
  break;
56
56
 
@@ -126,67 +126,54 @@ class McpServer {
126
126
  return [
127
127
  {
128
128
  name: 'brainstorm_start_session',
129
- description: `Start a visual brainstorming session opens a browser window where you push HTML content and the user interacts visually. Returns the session URL. Sessions have NO timeout and persist until explicitly stopped.
129
+ description: `Start a visual brainstorming session. Opens a browser window where you push HTML and users interact visually.
130
130
 
131
- COMPLETE USAGE GUIDE:
132
- 1. Call brainstorm_start_session ONCE with project_dir set to the current working directory. It returns { url, session_dir }.
133
- 2. Call brainstorm_push_screen to send HTML content — the browser auto-reloads instantly. Call it as many times as needed to update content without restarting.
134
- 3. Call brainstorm_read_events to get user clicks/preferences. Use clear_after_read:true between rounds.
135
- 4. Call brainstorm_stop_session when done to free the port and clean up.
131
+ QUICKSTART just these 3 calls:
132
+ brainstorm_start_session() → opens browser
133
+ brainstorm_push_screen({ html: "<h2>Hello</h2><p>Content</p>" }) → shows content
134
+ brainstorm_stop_session() → cleans up
136
135
 
137
- SINGLE SCREEN MODE: Push HTML fragments (not full documents). The frame template wraps content with themed CSS (auto light/dark mode).
136
+ FULL WORKFLOW:
137
+ 1. Call brainstorm_start_session ONCE (no args required — works immediately). Returns { url, session_dir }.
138
+ 2. Call brainstorm_push_screen with HTML — browser auto-reloads. Call as many times as needed.
139
+ 3. Call brainstorm_read_events to get user clicks/preferences.
140
+ 4. Call brainstorm_stop_session when done.
138
141
 
139
- COMPARISON MODE: Push to slots a/b/c with labels for side-by-side comparison with tabs and preference buttons.
142
+ If a session is already running, this returns the existing URL (safe to call repeatedly).
143
+ Sessions persist until explicitly stopped — no timeout by default.
140
144
 
141
- BUILT-IN CSS CLASSES (themed light/dark):
142
- .options + .option Selectable vertical option cards with .letter (A/B/C badge) and .content
145
+ COMPARISON MODE: Push to slots a/b/c with labels for side-by-side view:
146
+ brainstorm_push_screen({ html: "...", slot: "a", label: "Option A" })
147
+ brainstorm_push_screen({ html: "...", slot: "b", label: "Option B" })
148
+
149
+ CSS CLASSES (themed light/dark, push fragments not full docs):
150
+ .options + .option — Selectable cards with .letter (A/B/C) and .content
143
151
  .cards + .card — Grid cards with .card-image and .card-body
144
- .mockup — Browser-window container with .mockup-header and .mockup-body
145
- .split — Two-column 50/50 side-by-side layout
146
- .pros-cons Pros/cons grid with .pros (green) and .cons (red)
147
- .placeholder — Dashed placeholder area
148
- .mock-nav, .mock-sidebar, .mock-content, .mock-button, .mock-input — UI mockup blocks
149
- .subtitle Muted text below headings
150
- .section — Block with top margin spacing
151
- .label — Small uppercase badge
152
-
153
- MAKING ELEMENTS INTERACTIVE:
154
- Add data-choice="value" and onclick="toggleSelect(this)" to any element to capture clicks as events.
155
- For multi-select, add data-multiselect to the container.
152
+ .mockup — Browser-window container (.mockup-header + .mockup-body)
153
+ .split — Two-column layout | .pros-cons — Tradeoff grid (.pros/.cons)
154
+ .mock-nav, .mock-sidebar, .mock-content, .mock-button, .mock-input
155
+
156
+ INTERACTIVE ELEMENTS:
157
+ Add data-choice="value" onclick="toggleSelect(this)" to capture clicks.
156
158
  Example: <div class="option" data-choice="grid" onclick="toggleSelect(this)"><div class="letter">A</div><div class="content"><h3>Grid</h3></div></div>
157
159
 
158
- AUTO-DETECTED LIBRARIES (CDN injected automatically):
159
- class="mermaid" → Mermaid diagrams (flowchart, sequence, class, state, ER, Gantt, pie)
160
- class="language-*" Prism.js syntax highlighting
161
- $$...$$ or class="math" → KaTeX math rendering
162
-
163
- EVENT TYPES returned by brainstorm_read_events:
164
- click — User clicked a [data-choice] element. Fields: choice, text, id, timestamp
165
- preference User picked a preferred slot in comparison mode. Fields: choice (slot id), timestamp
166
- tab-switch — User switched tabs. Fields: slot, timestamp
167
- view-change — User toggled view mode. Fields: mode, timestamp
168
-
169
- WORKFLOW PATTERNS:
170
- Single Decision: start → push (options with data-choice) → tell user to select → read_events → use choice → stop
171
- A/B/C Comparison: start → push slot a → push slot b → tell user to compare → read_events → look for preference → stop
172
- Multi-Round: start → push round 1 → read_events(clear_after_read:true) → clear_screen → push round 2 → read_events → stop
173
- Progressive Refinement: start → push v1 → get feedback → push v2 (same browser updates) → iterate → stop
174
-
175
- BEST PRACTICES:
176
- - ALWAYS pass project_dir (use cwd) to avoid cross-agent conflicts
177
- - NEVER restart to update content — just call push_screen again
178
- - Push HTML fragments, not full documents
179
- - Start with <h2> heading + .subtitle describing the decision
180
- - One decision per screen
181
- - Tell the user the browser is ready after pushing
160
+ AUTO-DETECTED (CDN injected): class="mermaid" (diagrams), class="language-*" (syntax), $$...$$ (math)
161
+
162
+ EVENTS: click (choice,text), preference (choice), tab-switch (slot), view-change (mode)
163
+
164
+ RULES:
165
+ - NEVER restart to update — just push_screen again
166
+ - Push HTML fragments, not full <html> documents
167
+ - Tell user the browser is ready after pushing
182
168
  - Give user time before reading events
183
- - Always call stop_session when done`,
169
+ - Always stop_session when done`,
184
170
  inputSchema: {
185
171
  type: 'object',
186
172
  properties: {
187
- project_dir: { type: 'string', description: 'Project directory for session storage (ALWAYS pass this use cwd)' },
173
+ project_dir: { type: 'string', description: 'Project directory for session storage. Optional defaults to /tmp/brainstorm-companion/. Pass cwd for project-local storage.' },
188
174
  port: { type: 'number', description: 'Port to bind to (default: random ephemeral)' },
189
- open_browser: { type: 'boolean', description: 'Whether to open the browser automatically (default: true)' }
175
+ open_browser: { type: 'boolean', description: 'Open browser automatically (default: true)' },
176
+ idle_timeout_minutes: { type: 'number', description: 'Auto-stop after N minutes idle (default: 0 = no timeout)' }
190
177
  }
191
178
  }
192
179
  },
@@ -255,7 +242,7 @@ Give the user time to interact before reading — don't read immediately after p
255
242
  return { url: this.serverInstance.url, session_dir: this.sessionDir };
256
243
  }
257
244
 
258
- const { project_dir, port = 0, open_browser = true } = args;
245
+ const { project_dir, port = 0, open_browser = true, idle_timeout_minutes = 0 } = args;
259
246
 
260
247
  // Determine base directory and create session dir
261
248
  const baseDir = project_dir
@@ -271,6 +258,7 @@ Give the user time to interact before reading — don't read immediately after p
271
258
  host: '127.0.0.1',
272
259
  port: port || 0,
273
260
  ownerPid: process.pid,
261
+ idleTimeoutMs: idle_timeout_minutes > 0 ? idle_timeout_minutes * 60 * 1000 : 0,
274
262
  logFn: (...a) => console.error(...a),
275
263
  });
276
264