brainstorm-companion 1.0.0

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 ADDED
@@ -0,0 +1,66 @@
1
+ # Brainstorm Companion
2
+
3
+ AI-assisted visual brainstorming tool. Opens a browser window alongside AI coding sessions for comparing design mockups, architecture options, and UI prototypes.
4
+
5
+ Zero dependencies. Node.js only.
6
+
7
+ ## Quick Start
8
+
9
+ ### As CLI
10
+ ```bash
11
+ npx brainstorm-companion start
12
+ # Browser opens → push content → get feedback
13
+
14
+ echo '<h2>Hello</h2>' | npx brainstorm-companion push -
15
+ npx brainstorm-companion events
16
+ npx brainstorm-companion stop
17
+ ```
18
+
19
+ ### As MCP Server (Claude Code)
20
+ Add to `~/.claude/settings.json`:
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "brainstorm": {
25
+ "command": "npx",
26
+ "args": ["brainstorm-companion", "--mcp"]
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ ## Features
33
+ - **Single screen mode**: Push HTML content, auto-reloads on changes
34
+ - **Comparison mode**: Push to slots A/B/C for side-by-side comparison
35
+ - **Event capture**: User clicks and preferences flow back as structured events
36
+ - **Auto-detection**: Mermaid diagrams, Prism syntax highlighting, KaTeX math
37
+ - **Dark/light theme**: Auto-detects OS preference
38
+
39
+ ## CLI Commands
40
+
41
+ | Command | Description |
42
+ |---------|-------------|
43
+ | `start` | Start server and open browser |
44
+ | `push <file\|->` | Push HTML content |
45
+ | `events` | Read interaction events |
46
+ | `clear` | Clear content or events |
47
+ | `stop` | Stop the server |
48
+ | `status` | Show server status |
49
+
50
+ ## MCP Tools
51
+
52
+ | Tool | Description |
53
+ |------|-------------|
54
+ | `brainstorm_start_session` | Start server, open browser |
55
+ | `brainstorm_push_screen` | Push HTML (with optional slot) |
56
+ | `brainstorm_read_events` | Read user interactions |
57
+ | `brainstorm_clear_screen` | Clear content |
58
+ | `brainstorm_stop_session` | Stop and clean up |
59
+
60
+ ## Requirements
61
+
62
+ Node.js >= 18. No external dependencies.
63
+
64
+ ## License
65
+
66
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../src/cli.js');
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "brainstorm-companion",
3
+ "version": "1.0.0",
4
+ "description": "AI-assisted visual brainstorming companion",
5
+ "type": "commonjs",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "brainstorm",
9
+ "visual",
10
+ "mcp",
11
+ "claude",
12
+ "ai",
13
+ "prototyping",
14
+ "comparison",
15
+ "design"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/rafaforesightai/Brainstorming-Companion.git"
20
+ },
21
+ "homepage": "https://github.com/rafaforesightai/Brainstorming-Companion#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/rafaforesightai/Brainstorming-Companion/issues"
24
+ },
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "bin": {
29
+ "brainstorm-companion": "bin/brainstorm.js"
30
+ },
31
+ "scripts": {
32
+ "test": "node --test 'test/**/*.test.js'"
33
+ },
34
+ "files": [
35
+ "bin/",
36
+ "src/",
37
+ "skill/"
38
+ ]
39
+ }
package/skill/SKILL.md ADDED
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: brainstorm-companion
3
+ description: Visual brainstorming companion — opens a browser window for comparing design mockups, architecture options, and UI prototypes. Agents push HTML content and users interact visually.
4
+ ---
5
+
6
+ # Brainstorm Companion
7
+
8
+ ## When to Use
9
+
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)
13
+ - Present architecture diagrams (Mermaid), code samples (Prism), or math (KaTeX)
14
+ - Get visual feedback — user clicks and preferences are captured as events
15
+
16
+ ## Quick Start
17
+
18
+ 1. Call `brainstorm_start_session` to start the server and open the browser
19
+ 2. Call `brainstorm_push_screen` with HTML content to display
20
+ 3. For comparisons, use the `slot` parameter (a, b, c) with labels
21
+ 4. Call `brainstorm_read_events` to get user interactions
22
+ 5. Call `brainstorm_stop_session` when done
23
+
24
+ ## HTML Content Patterns
25
+
26
+ ### Single Option Display
27
+ ```html
28
+ <h2>Dashboard Layout</h2>
29
+ <p class="subtitle">Proposed navigation structure</p>
30
+ <div class="mockup">
31
+ <div class="mockup-header">Desktop View</div>
32
+ <div class="mockup-body">
33
+ <!-- Your mockup content -->
34
+ </div>
35
+ </div>
36
+ ```
37
+
38
+ ### A/B/C Choice Options
39
+ Push to separate slots for comparison mode:
40
+ ```
41
+ brainstorm_push_screen({ html: "<h2>Minimal Nav</h2>...", slot: "a", label: "Minimal" })
42
+ brainstorm_push_screen({ html: "<h2>Full Sidebar</h2>...", slot: "b", label: "Sidebar" })
43
+ ```
44
+
45
+ ### Available CSS Classes
46
+
47
+ **Layout:** `.options`, `.option`, `.cards`, `.card`, `.split`, `.mockup`, `.mockup-header`, `.mockup-body`
48
+ **Interactive:** Add `data-choice="value"` and `onclick="toggleSelect(this)"` to make elements clickable
49
+ **Styling:** `.pros-cons`, `.pros`, `.cons`, `.placeholder`, `.subtitle`, `.section`, `.label`
50
+ **Mock UI:** `.mock-nav`, `.mock-sidebar`, `.mock-content`, `.mock-button`, `.mock-input`
51
+
52
+ ### Auto-detected Libraries
53
+ Content is automatically enhanced when these patterns are found:
54
+ - **Mermaid diagrams:** `<div class="mermaid">graph TD; A-->B</div>`
55
+ - **Syntax highlighting:** `<pre><code class="language-typescript">...</code></pre>`
56
+ - **Math (KaTeX):** `$$E = mc^2$$`
57
+
58
+ ## Event Format
59
+
60
+ Events are JSON objects:
61
+ ```json
62
+ {"type": "click", "choice": "a", "text": "Option A", "timestamp": 1234567890}
63
+ {"type": "preference", "choice": "b", "timestamp": 1234567890}
64
+ ```
65
+
66
+ ## Tips
67
+ - Use the frame template's built-in dark/light theme — it auto-detects OS preference
68
+ - For mockups, use the `.mockup` container with `.mockup-header` for context
69
+ - For comparisons, always use slots — they enable side-by-side iframe comparison
70
+ - Check events after giving the user time to interact
71
+ - The browser auto-reloads when content changes
@@ -0,0 +1,331 @@
1
+ # Visual Companion — Detailed Usage Guide
2
+
3
+ This guide covers advanced usage patterns for the Brainstorm Companion tool.
4
+
5
+ ---
6
+
7
+ ## When to Use Browser vs Terminal
8
+
9
+ | Content Type | Use Browser | Use Terminal |
10
+ |---|---|---|
11
+ | UI mockups / wireframes | Yes | No |
12
+ | A/B/C design comparisons | Yes | No |
13
+ | Architecture diagrams (Mermaid) | Yes | No |
14
+ | Code review / diffs | Maybe | Yes |
15
+ | Plain text output | No | Yes |
16
+ | Data tables | Maybe | Yes |
17
+ | Math / equations (KaTeX) | Yes | No |
18
+ | Syntax-highlighted code examples | Yes | No |
19
+ | Interactive prototypes | Yes | No |
20
+
21
+ **Rule of thumb:** If it benefits from visual layout or user click-interaction, use the browser. If it's just information delivery, use the terminal.
22
+
23
+ ---
24
+
25
+ ## Complete CSS Class Reference
26
+
27
+ ### Layout Classes
28
+
29
+ **`.options`** — Flex container for side-by-side option cards. Use as a wrapper around multiple `.option` elements.
30
+
31
+ **`.option`** — Individual option card with border and padding. Becomes highlighted on click when paired with `data-choice` and `onclick="toggleSelect(this)"`.
32
+
33
+ **`.cards`** — Grid container for card layouts. Responds to 1–4 children with appropriate column widths.
34
+
35
+ **`.card`** — Individual card with shadow and rounded corners. Good for feature tiles or comparison items.
36
+
37
+ **`.split`** — Two-column 50/50 split layout. First child goes left, second goes right.
38
+
39
+ **`.mockup`** — Framed browser-window-style container. Gives content a realistic viewport feel.
40
+
41
+ **`.mockup-header`** — Title bar for the mockup frame. Shows the "browser chrome" header row.
42
+
43
+ **`.mockup-body`** — Content area inside the mockup frame. Scrollable, padded content region.
44
+
45
+ ### Interactive Classes
46
+
47
+ Elements with `data-choice="value"` and `onclick="toggleSelect(this)"` become selectable. When clicked:
48
+ - A visual highlight ring appears
49
+ - A `preference` event is emitted with the choice value
50
+ - Clicking again deselects
51
+
52
+ ```html
53
+ <div class="option" data-choice="minimal" onclick="toggleSelect(this)">
54
+ <h3>Minimal Nav</h3>
55
+ <p>Clean top bar only</p>
56
+ </div>
57
+ ```
58
+
59
+ ### Styling Classes
60
+
61
+ **`.pros-cons`** — Two-column pros/cons container.
62
+
63
+ **`.pros`** — Green-tinted column for positive points. Prefix items with `+`.
64
+
65
+ **`.cons`** — Red-tinted column for negative points. Prefix items with `-`.
66
+
67
+ **`.placeholder`** — Gray placeholder block. Use to represent images, media, or unfinished sections.
68
+
69
+ **`.subtitle`** — Muted smaller text below headings.
70
+
71
+ **`.section`** — Section block with top border separator.
72
+
73
+ **`.label`** — Small uppercase badge/tag for categorizing content.
74
+
75
+ ### Mock UI Classes
76
+
77
+ **`.mock-nav`** — Horizontal navigation bar mockup.
78
+
79
+ **`.mock-sidebar`** — Left sidebar mockup column.
80
+
81
+ **`.mock-content`** — Main content area mockup.
82
+
83
+ **`.mock-button`** — Styled button placeholder.
84
+
85
+ **`.mock-input`** — Styled input field placeholder.
86
+
87
+ ---
88
+
89
+ ## Auto-detected Libraries
90
+
91
+ The frame automatically injects CDN libraries when it detects matching content patterns. No setup required.
92
+
93
+ ### Mermaid Diagrams
94
+
95
+ Wrap diagram syntax in a `<div class="mermaid">` block:
96
+
97
+ ```html
98
+ <div class="mermaid">
99
+ graph TD
100
+ A[User Request] --> B{Auth Check}
101
+ B -->|Pass| C[Route Handler]
102
+ B -->|Fail| D[401 Response]
103
+ C --> E[Database Query]
104
+ E --> F[JSON Response]
105
+ </div>
106
+ ```
107
+
108
+ Supported diagram types: flowchart, sequence, class, state, ER, Gantt, pie.
109
+
110
+ ### Syntax Highlighting (Prism)
111
+
112
+ Wrap code in `<pre><code>` with a `language-*` class:
113
+
114
+ ```html
115
+ <pre><code class="language-typescript">
116
+ interface BrainstormEvent {
117
+ type: "click" | "preference";
118
+ choice: string;
119
+ text?: string;
120
+ timestamp: number;
121
+ }
122
+ </code></pre>
123
+ ```
124
+
125
+ Supported languages include: javascript, typescript, python, rust, go, bash, json, css, html, sql.
126
+
127
+ ### Math (KaTeX)
128
+
129
+ Inline math with `$...$`, display math with `$$...$$`:
130
+
131
+ ```html
132
+ <p>The loss function is $$L = -\sum_{i} y_i \log(\hat{y}_i)$$</p>
133
+ <p>Where inline <span>$\hat{y} = \sigma(Wx + b)$</span> is the prediction.</p>
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Event Handling Patterns
139
+
140
+ ### Basic Polling
141
+
142
+ After pushing content, give the user time to interact, then read events:
143
+
144
+ ```
145
+ brainstorm_push_screen({ html: "..." })
146
+ // ... wait for user to interact ...
147
+ brainstorm_read_events()
148
+ ```
149
+
150
+ ### Clearing Events Between Rounds
151
+
152
+ When running multi-round comparisons, clear events between rounds to avoid stale data:
153
+
154
+ ```
155
+ brainstorm_read_events() // read current events
156
+ brainstorm_clear_screen({ target: "events" }) // clear event queue
157
+ brainstorm_push_screen({ html: "Round 2..." }) // push next round
158
+ ```
159
+
160
+ ### Interpreting Events
161
+
162
+ ```json
163
+ // User clicked an element with data-choice="sidebar"
164
+ {"type": "click", "choice": "sidebar", "text": "Full Sidebar Layout", "timestamp": 1710000000}
165
+
166
+ // User used the built-in preference buttons (A/B/C buttons in comparison mode)
167
+ {"type": "preference", "choice": "b", "timestamp": 1710000001}
168
+ ```
169
+
170
+ - `click` events are triggered by `data-choice` elements the user clicks
171
+ - `preference` events are triggered by the slot comparison buttons (A, B, C labels in comparison view)
172
+ - Multiple events may arrive — look for the most recent or most frequent choice
173
+
174
+ ---
175
+
176
+ ## Content Design Best Practices
177
+
178
+ 1. **Keep HTML focused.** The frame provides the outer shell (theme, fonts, scrolling). Push only the inner content — no `<html>`, `<head>`, or `<body>` tags needed.
179
+
180
+ 2. **Use headings for context.** Start with an `<h2>` that names what the user is looking at.
181
+
182
+ 3. **Add a `.subtitle`** below the heading to describe the decision being made.
183
+
184
+ 4. **Label pros and cons explicitly.** Users make better decisions when trade-offs are surfaced.
185
+
186
+ 5. **One decision per screen.** Don't push multiple unrelated choices at once. Push one question per `push_screen` call.
187
+
188
+ 6. **Use slot labels.** When using comparison slots, always include a `label` parameter so the slot tabs are readable.
189
+
190
+ 7. **Prefer data-choice over custom JS.** The built-in `toggleSelect` + `data-choice` pattern automatically emits events. Custom `onclick` handlers don't.
191
+
192
+ ---
193
+
194
+ ## Mermaid Diagram Examples
195
+
196
+ ### System Architecture
197
+
198
+ ```html
199
+ <h2>Proposed Architecture</h2>
200
+ <div class="mermaid">
201
+ graph LR
202
+ CLI[CLI / npx] --> Server[HTTP Server :7891]
203
+ MCP[MCP Tools] --> Server
204
+ Server --> State[State Store]
205
+ Server --> SSE[SSE /events]
206
+ Browser[Browser] -->|polls| Server
207
+ Browser -->|clicks| Server
208
+ </div>
209
+ ```
210
+
211
+ ### Sequence Diagram
212
+
213
+ ```html
214
+ <h2>Auth Flow</h2>
215
+ <div class="mermaid">
216
+ sequenceDiagram
217
+ participant User
218
+ participant Client
219
+ participant API
220
+ participant DB
221
+
222
+ User->>Client: Login form submit
223
+ Client->>API: POST /auth/login
224
+ API->>DB: SELECT user WHERE email=?
225
+ DB-->>API: User record
226
+ API-->>Client: JWT token
227
+ Client-->>User: Redirect to dashboard
228
+ </div>
229
+ ```
230
+
231
+ ### State Machine
232
+
233
+ ```html
234
+ <h2>Order States</h2>
235
+ <div class="mermaid">
236
+ stateDiagram-v2
237
+ [*] --> Pending
238
+ Pending --> Confirmed: payment_success
239
+ Pending --> Cancelled: timeout
240
+ Confirmed --> Shipped: fulfillment
241
+ Shipped --> Delivered: delivery_scan
242
+ Delivered --> [*]
243
+ Cancelled --> [*]
244
+ </div>
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Multi-step Brainstorming Workflow Example
250
+
251
+ This example shows a full workflow for choosing a navigation pattern for a new app.
252
+
253
+ ### Step 1: Present the question
254
+
255
+ ```
256
+ brainstorm_start_session()
257
+
258
+ brainstorm_push_screen({
259
+ html: `
260
+ <h2>Navigation Pattern Decision</h2>
261
+ <p class="subtitle">Choose the nav structure for the mobile app</p>
262
+ <p class="section">We have three options to evaluate. Click each to learn more, then use the A/B/C buttons to vote.</p>
263
+ `
264
+ })
265
+ ```
266
+
267
+ ### Step 2: Push comparison options
268
+
269
+ ```
270
+ brainstorm_push_screen({
271
+ slot: "a",
272
+ label: "Bottom Tabs",
273
+ html: `
274
+ <h2>Bottom Tab Bar</h2>
275
+ <p class="subtitle">iOS-style fixed bottom navigation</p>
276
+ <div class="mockup">
277
+ <div class="mockup-header">Mobile — 390px</div>
278
+ <div class="mockup-body">
279
+ <div class="mock-content">Main content area</div>
280
+ <div class="mock-nav">Home | Search | Profile | Settings</div>
281
+ </div>
282
+ </div>
283
+ <div class="pros-cons">
284
+ <div class="pros"><b>Pros</b><br>+ Thumb-friendly<br>+ Always visible<br>+ Familiar pattern</div>
285
+ <div class="cons"><b>Cons</b><br>- Max 5 items<br>- Takes vertical space</div>
286
+ </div>
287
+ `
288
+ })
289
+
290
+ brainstorm_push_screen({
291
+ slot: "b",
292
+ label: "Hamburger",
293
+ html: `
294
+ <h2>Hamburger Menu</h2>
295
+ <p class="subtitle">Slide-out drawer navigation</p>
296
+ <div class="mockup">
297
+ <div class="mockup-header">Mobile — 390px</div>
298
+ <div class="mockup-body">
299
+ <div class="mock-nav">☰ App Name</div>
300
+ <div class="mock-content">Main content area</div>
301
+ </div>
302
+ </div>
303
+ <div class="pros-cons">
304
+ <div class="pros"><b>Pros</b><br>+ Unlimited items<br>+ Clean default view</div>
305
+ <div class="cons"><b>Cons</b><br>- Hidden by default<br>- Extra tap required</div>
306
+ </div>
307
+ `
308
+ })
309
+ ```
310
+
311
+ ### Step 3: Read the result
312
+
313
+ ```
314
+ brainstorm_read_events()
315
+ // → [{"type": "preference", "choice": "a", "timestamp": ...}]
316
+ // User preferred Option A: Bottom Tabs
317
+ ```
318
+
319
+ ### Step 4: Confirm and continue
320
+
321
+ ```
322
+ brainstorm_push_screen({
323
+ html: `
324
+ <h2>Decision: Bottom Tab Bar</h2>
325
+ <p class="subtitle">Moving forward with bottom tab navigation</p>
326
+ <p>Next: define the 4-5 tab items and their icons.</p>
327
+ `
328
+ })
329
+
330
+ brainstorm_stop_session()
331
+ ```