brainstorm-companion 1.1.3 → 1.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rafael Maya / Foresight AI Partners
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -26,17 +26,22 @@ brainstorm-companion start --project-dir .
26
26
  # → Server started: http://127.0.0.1:54321
27
27
  # → Session ID: 1234-1700000000000
28
28
 
29
- # 2. Push content
29
+ # 2. Push content — browser updates instantly
30
30
  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>'
31
31
 
32
- # 3. Read user's selection
32
+ # 3. Update content — same browser, no restart needed
33
+ brainstorm-companion push --html '<h2>Updated Layout</h2><p>Refined version based on feedback</p>'
34
+
35
+ # 4. Read user's selection
33
36
  brainstorm-companion events
34
37
  # → [{"type":"click","choice":"grid","text":"A Grid Layout Cards in a responsive grid","timestamp":1700000001234}]
35
38
 
36
- # 4. Stop when done
39
+ # 5. Stop when done
37
40
  brainstorm-companion stop
38
41
  ```
39
42
 
43
+ **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.
44
+
40
45
  ### Side-by-Side Comparison
41
46
 
42
47
  Push to named slots for comparison mode with tabs and preference selection:
@@ -49,6 +54,24 @@ brainstorm-companion push --html '<h2>Hybrid</h2><p>Collapsible sidebar + top ba
49
54
 
50
55
  Browser shows all three side-by-side with tabs, keyboard shortcuts (1/2/3), and a preference bar.
51
56
 
57
+ ### Updating Content In-Place
58
+
59
+ The browser auto-reloads whenever content is pushed. No need to restart the session or manually refresh:
60
+
61
+ ```bash
62
+ # Initial mockup
63
+ brainstorm-companion push --html '<h2>v1</h2><p>First draft</p>'
64
+ # → Browser shows v1
65
+
66
+ # Refined mockup — same browser window updates automatically
67
+ brainstorm-companion push --html '<h2>v2</h2><p>Improved based on feedback</p>'
68
+ # → Browser shows v2
69
+
70
+ # Update a single slot in comparison mode
71
+ brainstorm-companion push --html '<h2>Updated Option A</h2>' --slot a --label "Revised"
72
+ # → Only slot A updates, others stay
73
+ ```
74
+
52
75
  ### From Files or Stdin
53
76
 
54
77
  ```bash
@@ -59,15 +82,15 @@ cat design.html | brainstorm-companion push -
59
82
 
60
83
  ### Parallel Instances
61
84
 
62
- Multiple agents can run simultaneously on the same project without interference:
85
+ Multiple agents can run simultaneously on the same project. Use `--new` to force a separate session:
63
86
 
64
87
  ```bash
65
88
  # Agent A
66
- brainstorm-companion start --project-dir .
89
+ brainstorm-companion start --project-dir . --new
67
90
  # → Session ID: 1111-000
68
91
 
69
92
  # Agent B
70
- brainstorm-companion start --project-dir .
93
+ brainstorm-companion start --project-dir . --new
71
94
  # → Session ID: 2222-000
72
95
 
73
96
  # Each targets its own session
@@ -77,6 +100,8 @@ brainstorm-companion events --session 1111-000
77
100
  brainstorm-companion stop --session 1111-000
78
101
  ```
79
102
 
103
+ Without `--new`, `start` reuses the existing session (the default for single-agent use).
104
+
80
105
  ## MCP Server
81
106
 
82
107
  Brainstorm Companion runs as an [MCP](https://modelcontextprotocol.io) server for direct integration with AI coding tools.
@@ -100,8 +125,8 @@ Add to `~/.claude/settings.json`:
100
125
 
101
126
  | Tool | Description |
102
127
  |------|-------------|
103
- | `brainstorm_start_session` | Start server and open browser. Returns URL and session directory. |
104
- | `brainstorm_push_screen` | Push HTML content. Use `slot` + `label` for comparison mode. |
128
+ | `brainstorm_start_session` | Start server (or reuse existing). Returns URL. Always pass `project_dir`. |
129
+ | `brainstorm_push_screen` | Push HTML content. Browser auto-reloads. Use `slot` + `label` for comparison. |
105
130
  | `brainstorm_read_events` | Read user interaction events. Option to clear after reading. |
106
131
  | `brainstorm_clear_screen` | Clear a specific slot or all content. |
107
132
  | `brainstorm_stop_session` | Stop server and clean up session files. |
@@ -118,17 +143,22 @@ Add to `~/.claude/settings.json`:
118
143
  3. brainstorm_read_events({})
119
144
  → { events: [{ type: "preference", choice: "a" }], count: 1 }
120
145
 
121
- 4. brainstorm_stop_session({})
146
+ // Update content — same browser, no restart
147
+ 4. brainstorm_push_screen({ html: "<h2>Revised A</h2>...", slot: "a", label: "Minimal v2" })
148
+
149
+ 5. brainstorm_stop_session({})
122
150
  ```
123
151
 
152
+ **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.
153
+
124
154
  ## CLI Reference
125
155
 
126
156
  ```
127
157
  brainstorm-companion <command> [options]
128
158
 
129
159
  Commands:
130
- start Start the brainstorm server and open browser
131
- push Push HTML content to the browser
160
+ start Start the brainstorm server (reuses existing session by default)
161
+ push Push HTML content to the browser (auto-reloads)
132
162
  events Read user interaction events
133
163
  clear Clear content or events
134
164
  stop Stop the server
@@ -144,10 +174,10 @@ Global Options:
144
174
  ### `start`
145
175
 
146
176
  ```
147
- brainstorm-companion start [--project-dir <path>] [--port <N>] [--host <H>] [--foreground] [--no-open]
177
+ brainstorm-companion start [--project-dir <path>] [--port <N>] [--host <H>] [--foreground] [--no-open] [--new]
148
178
  ```
149
179
 
150
- Creates a new session, starts the HTTP+WebSocket server on a random port, and opens the default browser. Prints the URL and Session ID.
180
+ If a session is already running, prints its URL and reuses it. Use `--new` to force a separate parallel session.
151
181
 
152
182
  ### `push`
153
183
 
@@ -155,7 +185,7 @@ Creates a new session, starts the HTTP+WebSocket server on a random port, and op
155
185
  brainstorm-companion push [<file|->] [--html <content>] [--slot a|b|c] [--label <name>]
156
186
  ```
157
187
 
158
- Three input methods: file path, stdin (`-`), or inline (`--html`). Use `--slot` for comparison mode.
188
+ Three input methods: file path, stdin (`-`), or inline (`--html`). Use `--slot` for comparison mode. The browser auto-reloads on every push — no restart needed.
159
189
 
160
190
  ### `events`
161
191
 
@@ -240,13 +270,18 @@ graph TD
240
270
 
241
271
  ## How It Works
242
272
 
243
- 1. `start` creates an isolated session directory and spawns an HTTP+WebSocket server on a random port
244
- 2. `push` writes HTML files to the session directory; the file watcher detects changes and broadcasts reload to connected browsers via WebSocket
245
- 3. The browser renders content in a themed frame with click capture on `[data-choice]` elements
273
+ 1. `start` checks for an existing active session reuses it if found, otherwise creates a new one with its own port and directory
274
+ 2. `push` writes HTML files to the session directory; the file watcher detects changes and broadcasts reload to the browser via WebSocket
275
+ 3. The browser auto-reloads and renders content in a themed frame with click capture on `[data-choice]` elements
246
276
  4. Click events are sent over WebSocket to the server and appended to a `.events` JSONL file
247
277
  5. `events` reads the JSONL file and returns structured JSON
248
278
  6. Each session is fully isolated: own port, own directory, own event log
279
+ 7. Server runs independently with a 30-minute idle timeout; `stop` cleans up immediately
280
+
281
+ ## Author
282
+
283
+ Created by [Rafael Maya](https://github.com/rafaforesightai) at [Foresight AI Partners](https://github.com/rafaforesightai).
249
284
 
250
285
  ## License
251
286
 
252
- MIT
287
+ MIT License. See [LICENSE](LICENSE) for details.
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "brainstorm-companion",
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
4
4
  "description": "AI-assisted visual brainstorming companion",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
+ "author": "Rafael Maya <rafa@foresightaipartners.com> (https://github.com/rafaforesightai)",
7
8
  "keywords": [
8
9
  "brainstorm",
9
10
  "visual",
package/skill/SKILL.md CHANGED
@@ -20,7 +20,7 @@ Use this tool when you need to:
20
20
 
21
21
  ### brainstorm_start_session
22
22
 
23
- Start the server and open a browser window.
23
+ Start the server and open a browser window. If a session is already running, it reuses it — no duplicate browsers.
24
24
 
25
25
  ```
26
26
  brainstorm_start_session({
@@ -33,11 +33,13 @@ brainstorm_start_session({
33
33
 
34
34
  **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.
35
35
 
36
- The server runs independently in the background with a 30-minute idle timeout. It survives the calling process exiting.
36
+ **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.
37
+
38
+ The server runs independently in the background with a 30-minute idle timeout.
37
39
 
38
40
  ### brainstorm_push_screen
39
41
 
40
- Push HTML content to the browser. The browser auto-reloads — no manual refresh needed.
42
+ Push HTML content to the browser. **The browser auto-reloads instantly** — no manual refresh needed. Call this repeatedly to update the same browser window with new content. You do NOT need to restart the session.
41
43
 
42
44
  **Single screen mode:**
43
45
  ```
@@ -376,12 +378,22 @@ All events include a `timestamp` field (Unix ms).
376
378
  ## Best Practices
377
379
 
378
380
  1. **Always pass `project_dir`** to `brainstorm_start_session` — avoids cross-agent conflicts
379
- 2. **Push fragments, not full documents** — the frame template handles `<html>`, theming, and scroll
380
- 3. **Start with a heading** — `<h2>` describes what the user is looking at
381
- 4. **Add a `.subtitle`**describes the decision being made
382
- 5. **One decision per screen** — don't combine unrelated choices
383
- 6. **Use slot labels**`label` makes comparison tabs readable
384
- 7. **Use `data-choice` for interaction** — the built-in `toggleSelect` emits events automatically
385
- 8. **Tell the user to interact** — after pushing content, let them know the browser is ready
386
- 9. **Read events after user has time** — don't immediately read; wait for user to respond
387
- 10. **Clean up with `brainstorm_stop_session`**frees the port and removes temp files
381
+ 2. **Never restart to update content** — just call `brainstorm_push_screen` again; the browser auto-reloads
382
+ 3. **One `brainstorm_start_session` per workflow** — it reuses the existing session automatically
383
+ 4. **Push fragments, not full documents** — the frame template handles `<html>`, theming, and scroll
384
+ 5. **Start with a heading** — `<h2>` describes what the user is looking at
385
+ 6. **Add a `.subtitle`**describes the decision being made
386
+ 7. **One decision per screen** — don't combine unrelated choices
387
+ 8. **Use slot labels** — `label` makes comparison tabs readable
388
+ 9. **Use `data-choice` for interaction** — the built-in `toggleSelect` emits events automatically
389
+ 10. **Tell the user to interact** after pushing content, let them know the browser is ready
390
+ 11. **Read events after user has time** — don't immediately read; wait for user to respond
391
+ 12. **Clean up with `brainstorm_stop_session`** — frees the port and removes temp files
392
+
393
+ ## Common Mistakes
394
+
395
+ - **Starting a new session for each update** — DON'T. Call `push_screen` to update the existing browser.
396
+ - **Omitting `project_dir`** — leads to `/tmp` collisions between agents.
397
+ - **Pushing full HTML documents** — push fragments; the frame template adds theming and structure.
398
+ - **Reading events immediately after push** — give the user time to interact first.
399
+ - **Forgetting to stop** — always call `brainstorm_stop_session` when done.
@@ -78,6 +78,26 @@
78
78
  font-size: 0.875rem;
79
79
  color: var(--text-secondary);
80
80
  z-index: 100;
81
+ transition: transform 0.2s ease;
82
+ }
83
+ .indicator-bar.hidden {
84
+ transform: translateY(100%);
85
+ }
86
+ .indicator-bar .dismiss {
87
+ position: absolute;
88
+ right: 0.75rem;
89
+ top: 50%;
90
+ transform: translateY(-50%);
91
+ background: none;
92
+ border: none;
93
+ color: var(--text-secondary);
94
+ cursor: pointer;
95
+ font-size: 1rem;
96
+ padding: 0.25rem 0.5rem;
97
+ opacity: 0.6;
98
+ }
99
+ .indicator-bar .dismiss:hover {
100
+ opacity: 1;
81
101
  }
82
102
 
83
103
  .selected-text {
@@ -276,8 +296,9 @@
276
296
  <!-- CONTENT -->
277
297
  </div>
278
298
  </div>
279
- <div class="indicator-bar">
299
+ <div class="indicator-bar" id="indicator-bar">
280
300
  <span id="indicator-text">Click an option above, then return to the terminal</span>
301
+ <button class="dismiss" onclick="document.getElementById('indicator-bar').classList.add('hidden')" title="Dismiss">&times;</button>
281
302
  </div>
282
303
  </body>
283
304
  </html>
@@ -74,5 +74,13 @@
74
74
  choice: (value, metadata = {}) => sendEvent({ type: 'choice', value, ...metadata })
75
75
  };
76
76
 
77
+ // Auto-hide indicator bar if no interactive elements exist
78
+ document.addEventListener('DOMContentLoaded', () => {
79
+ const bar = document.getElementById('indicator-bar');
80
+ if (bar && !document.querySelector('[data-choice]')) {
81
+ bar.classList.add('hidden');
82
+ }
83
+ });
84
+
77
85
  connect();
78
86
  })();