@jspg-ai/coding-bb 0.0.1 → 0.0.2-beta.23

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 (145) hide show
  1. package/cbb/bin/cbb.js +6 -0
  2. package/cbb/bin/cbbm.js +6 -0
  3. package/cbb/dev-standards/rules/cbb-ai-behavior.md +103 -103
  4. package/cbb/dev-standards/rules/cbb-priority.md +55 -55
  5. package/cbb/lib/install/claude-code.js +2 -0
  6. package/cbb/lib/install/init.js +496 -290
  7. package/cbb/lib/install/opencode.js +31 -0
  8. package/cbb/lib/install/qoder.js +2 -0
  9. package/cbb/lib/install/workspaces.js +53 -13
  10. package/cbb/lib/openspec/index.js +3 -3
  11. package/cbb/lib/superpowers/index.js +1 -1
  12. package/cbb/lib/utils/check-update.js +16 -14
  13. package/cbb/lib/utils/gitignore.js +2 -1
  14. package/cbb/lib/utils/output.js +92 -4
  15. package/cbb/lib/utils/version.js +2 -31
  16. package/cbb/lib/wiki/cli.js +25 -25
  17. package/cbb/lib/wiki/index.js +16 -16
  18. package/cbb/tools/cbb-design-to-wiki/SKILL.md +14 -14
  19. package/cbb/tools/cbb-wiki-ops/SKILL.md +22 -22
  20. package/cbb/worktrees/_shared/scripts/find-target-worktree.js +2 -2
  21. package/cbb/worktrees/_shared/scripts/find-workspace-root.js +7 -7
  22. package/cbb/worktrees/_shared/scripts/push-core.js +18 -0
  23. package/cbb/worktrees/commands/{close.md → worktree-close.md} +8 -8
  24. package/cbb/worktrees/commands/{init.md → worktree-init.md} +9 -9
  25. package/cbb/worktrees/commands/{push.md → worktree-push.md} +3 -3
  26. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/SKILL.md +20 -20
  27. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/check-env.js +4 -4
  28. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/check-unarchived.js +1 -1
  29. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/delete-branches.js +3 -3
  30. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/discover-apps.js +6 -6
  31. package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-close}/scripts/find-target-worktree.js +2 -2
  32. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-close}/scripts/find-workspace-root.js +7 -7
  33. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/remove-worktrees.js +4 -4
  34. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/safety-check.js +4 -4
  35. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/SKILL.md +81 -107
  36. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/auto-open.js +1 -1
  37. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-env-deep.js +4 -4
  38. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-env.js +6 -6
  39. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-repos.js +4 -4
  40. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/create-branches.js +4 -4
  41. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/create-worktrees.js +8 -7
  42. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-init}/scripts/find-workspace-root.js +7 -7
  43. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/install-ai.js +33 -33
  44. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/parse-config.js +7 -7
  45. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/push-branches.js +9 -7
  46. package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-init}/scripts/push-core.js +18 -0
  47. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/sync-repos.js +10 -12
  48. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/update-gitignore.js +19 -6
  49. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/SKILL.md +16 -16
  50. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/commit-worktrees.js +2 -2
  51. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/find-target-worktree.js +2 -2
  52. package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-push}/scripts/find-workspace-root.js +7 -7
  53. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/push-core.js +18 -0
  54. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/push-worktrees.js +7 -5
  55. package/config/workspace-config.sample.json +18 -0
  56. package/config/workspaces.json +11 -6
  57. package/openspec/.version +6 -6
  58. package/openspec/commands/apply.md +7 -7
  59. package/openspec/commands/archive.md +7 -7
  60. package/openspec/commands/bulk-archive.md +7 -7
  61. package/openspec/commands/continue.md +7 -7
  62. package/openspec/commands/explore.md +7 -7
  63. package/openspec/commands/ff.md +7 -7
  64. package/openspec/commands/new.md +7 -7
  65. package/openspec/commands/onboard.md +7 -7
  66. package/openspec/commands/propose.md +7 -7
  67. package/openspec/commands/sync.md +7 -7
  68. package/openspec/commands/update.md +7 -7
  69. package/openspec/commands/verify.md +7 -7
  70. package/openspec/skills/openspec-apply-change/SKILL.md +187 -187
  71. package/openspec/skills/openspec-archive-change/SKILL.md +181 -181
  72. package/openspec/skills/openspec-bulk-archive-change/SKILL.md +338 -338
  73. package/openspec/skills/openspec-continue-change/SKILL.md +117 -117
  74. package/openspec/skills/openspec-explore/SKILL.md +342 -342
  75. package/openspec/skills/openspec-ff-change/SKILL.md +116 -116
  76. package/openspec/skills/openspec-new-change/SKILL.md +76 -76
  77. package/openspec/skills/openspec-onboard/SKILL.md +560 -560
  78. package/openspec/skills/openspec-propose/SKILL.md +162 -162
  79. package/openspec/skills/openspec-sync-specs/SKILL.md +261 -261
  80. package/openspec/skills/openspec-update-change/SKILL.md +90 -90
  81. package/openspec/skills/openspec-verify-change/SKILL.md +174 -174
  82. package/package.json +4 -3
  83. package/superpowers/.version +6 -6
  84. package/superpowers/skills/brainstorming/SKILL.md +250 -250
  85. package/superpowers/skills/brainstorming/scripts/helper.js +167 -167
  86. package/superpowers/skills/brainstorming/scripts/start-server.sh +209 -209
  87. package/superpowers/skills/brainstorming/scripts/stop-server.sh +120 -120
  88. package/superpowers/skills/brainstorming/spec-document-reviewer-prompt.md +49 -49
  89. package/superpowers/skills/brainstorming/visual-companion.md +299 -299
  90. package/superpowers/skills/dispatching-parallel-agents/SKILL.md +167 -167
  91. package/superpowers/skills/executing-plans/SKILL.md +64 -64
  92. package/superpowers/skills/finishing-a-development-branch/SKILL.md +225 -225
  93. package/superpowers/skills/receiving-code-review/SKILL.md +205 -205
  94. package/superpowers/skills/requesting-code-review/SKILL.md +95 -95
  95. package/superpowers/skills/requesting-code-review/code-reviewer.md +181 -181
  96. package/superpowers/skills/subagent-driven-development/SKILL.md +568 -568
  97. package/superpowers/skills/subagent-driven-development/implementer-prompt.md +154 -154
  98. package/superpowers/skills/subagent-driven-development/re-review-prompt.md +115 -115
  99. package/superpowers/skills/subagent-driven-development/task-reviewer-prompt.md +207 -207
  100. package/superpowers/skills/systematic-debugging/CREATION-LOG.md +119 -119
  101. package/superpowers/skills/systematic-debugging/SKILL.md +283 -283
  102. package/superpowers/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
  103. package/superpowers/skills/systematic-debugging/condition-based-waiting.md +115 -115
  104. package/superpowers/skills/systematic-debugging/defense-in-depth.md +122 -122
  105. package/superpowers/skills/systematic-debugging/find-polluter.sh +72 -72
  106. package/superpowers/skills/systematic-debugging/root-cause-tracing.md +169 -169
  107. package/superpowers/skills/systematic-debugging/test-academic.md +14 -14
  108. package/superpowers/skills/systematic-debugging/test-pressure-1.md +58 -58
  109. package/superpowers/skills/systematic-debugging/test-pressure-2.md +68 -68
  110. package/superpowers/skills/systematic-debugging/test-pressure-3.md +69 -69
  111. package/superpowers/skills/test-driven-development/SKILL.md +320 -320
  112. package/superpowers/skills/test-driven-development/writing-good-tests.md +198 -198
  113. package/superpowers/skills/using-git-worktrees/SKILL.md +167 -167
  114. package/superpowers/skills/using-superpowers/SKILL.md +63 -63
  115. package/superpowers/skills/using-superpowers/references/antigravity-tools.md +23 -23
  116. package/superpowers/skills/using-superpowers/references/codex-tools.md +108 -108
  117. package/superpowers/skills/using-superpowers/references/gemini-tools.md +63 -63
  118. package/superpowers/skills/using-superpowers/references/hermes-tools.md +56 -56
  119. package/superpowers/skills/using-superpowers/references/pi-tools.md +16 -16
  120. package/superpowers/skills/verification-before-completion/SKILL.md +120 -120
  121. package/superpowers/skills/writing-plans/SKILL.md +171 -171
  122. package/superpowers/skills/writing-plans/plan-document-reviewer-prompt.md +49 -49
  123. package/superpowers/skills/writing-skills/SKILL.md +679 -679
  124. package/superpowers/skills/writing-skills/anthropic-best-practices.md +1150 -1150
  125. package/superpowers/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -189
  126. package/superpowers/skills/writing-skills/persuasion-principles.md +187 -187
  127. package/superpowers/skills/writing-skills/render-graphs.js +169 -169
  128. package/superpowers/skills/writing-skills/testing-skills-with-subagents.md +384 -384
  129. package/cbb/worktrees/commands/extend.md +0 -65
  130. package/cbb/worktrees/skills/openspec-close-worktree/scripts/find-target-worktree.js +0 -96
  131. package/cbb/worktrees/skills/openspec-extend-worktree/SKILL.md +0 -390
  132. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/check-env.js +0 -95
  133. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/check-repos.js +0 -98
  134. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/create-branches-and-worktrees.js +0 -135
  135. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/install-ai.js +0 -150
  136. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/list-available-apps.js +0 -88
  137. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/sync-repos.js +0 -93
  138. package/cbb/worktrees/skills/openspec-init-worktree/scripts/find-workspace-root.js +0 -67
  139. package/cbb/worktrees/skills/openspec-init-worktree/scripts/generate-app-options.js +0 -93
  140. package/cbb/worktrees/skills/openspec-init-worktree/scripts/push-core.js +0 -136
  141. package/cbb/worktrees/skills/openspec-push-worktrees/scripts/silence-popup.js +0 -23
  142. package/config/config.sample.json +0 -16
  143. /package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/silence-popup.js +0 -0
  144. /package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-init}/scripts/silence-popup.js +0 -0
  145. /package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-push}/scripts/silence-popup.js +0 -0
@@ -1,299 +1,299 @@
1
- # Visual Companion Guide
2
-
3
- Browser-based visual brainstorming companion for showing mockups, diagrams, and options.
4
-
5
- ## When to Use
6
-
7
- Decide per-question, not per-session. The test: **would the user understand this better by seeing it than reading it?**
8
-
9
- **Use the browser** when the content itself is visual:
10
-
11
- - **UI mockups** — wireframes, layouts, navigation structures, component designs
12
- - **Architecture diagrams** — system components, data flow, relationship maps
13
- - **Side-by-side visual comparisons** — comparing two layouts, two color schemes, two design directions
14
- - **Design polish** — when the question is about look and feel, spacing, visual hierarchy
15
- - **Spatial relationships** — state machines, flowcharts, entity relationships rendered as diagrams
16
-
17
- **Use the terminal** when the content is text or tabular:
18
-
19
- - **Requirements and scope questions** — "what does X mean?", "which features are in scope?"
20
- - **Conceptual A/B/C choices** — picking between approaches described in words
21
- - **Tradeoff lists** — pros/cons, comparison tables
22
- - **Technical decisions** — API design, data modeling, architectural approach selection
23
- - **Clarifying questions** — anything where the answer is words, not a visual preference
24
-
25
- A question *about* a UI topic is not automatically a visual question. "What kind of wizard do you want?" is conceptual — use the terminal. "Which of these wizard layouts feels right?" is visual — use the browser.
26
-
27
- ## How It Works
28
-
29
- The server watches a directory for HTML files and serves the newest one to the browser. You write HTML content to `screen_dir`, the user sees it in their browser and can click to select options. Selections are recorded to `state_dir/events` that you read on your next turn.
30
-
31
- **Content fragments vs full documents:** If your HTML file starts with `<!DOCTYPE` or `<html`, the server serves it as-is (just injects the helper script). Otherwise, the server automatically wraps your content in the frame template — adding the header, CSS theme, connection status, and all interactive infrastructure. **Write content fragments by default.** Only write full documents when you need complete control over the page.
32
-
33
- ## Starting a Session
34
-
35
- ```bash
36
- # Start AFTER the user approves the companion. --open auto-opens their browser on
37
- # the first screen; --project-dir persists mockups and enables same-port restart.
38
- scripts/start-server.sh --project-dir /path/to/project --open
39
-
40
- # Returns: {"type":"server-started","port":52341,
41
- # "url":"http://localhost:52341/?key=ab12…",
42
- # "screen_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/content",
43
- # "state_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/state"}
44
- ```
45
-
46
- Save `screen_dir` and `state_dir` from the response. With `--open`, the browser opens itself when you push the first screen — you don't need to ask the user to open it, but still share the URL as a fallback (headless/remote setups won't auto-open).
47
-
48
- **The URL contains a session key (`?key=…`).** The server rejects any request
49
- without it, so always give the user the **complete** URL from the `url` field —
50
- never strip the query string, and never hand out a bare `http://host:port`. The
51
- key gates HTTP and WebSocket access so a stray browser tab or another machine on
52
- the network can't read the screens or inject events. After the first load the
53
- browser remembers the key via a cookie, so reloads and `/files/*` assets work
54
- without repeating it.
55
-
56
- **Finding connection info:** The server writes its startup JSON to `$STATE_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.
57
-
58
- **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.
59
-
60
- **Launching the server by platform:**
61
-
62
- **Claude Code:**
63
- ```bash
64
- # Default mode works — the script backgrounds the server itself.
65
- scripts/start-server.sh --project-dir /path/to/project --open
66
- ```
67
-
68
- On Windows, the script auto-detects and switches to foreground mode (which blocks the tool call). Use `run_in_background: true` on the Bash tool call so the server survives across conversation turns, then read `$STATE_DIR/server-info` on the next turn to get the URL and port.
69
-
70
- **Codex:**
71
- ```bash
72
- # Codex reaps background processes. The script auto-detects CODEX_CI and
73
- # switches to foreground mode. Run it normally — no extra flags needed.
74
- scripts/start-server.sh --project-dir /path/to/project --open
75
- ```
76
-
77
- **Gemini CLI:**
78
- ```bash
79
- # Use --foreground and set is_background: true on your shell tool call
80
- # so the process survives across turns
81
- scripts/start-server.sh --project-dir /path/to/project --open --foreground
82
- ```
83
-
84
- **Copilot CLI:**
85
- ```bash
86
- # Start it with Copilot CLI's non-blocking/background shell mechanism so the
87
- # server survives across turns. Keep --foreground so the harness, not the
88
- # script, owns backgrounding. The launcher is a .sh, so invoke it via bash
89
- # (on Windows, call Git Bash's bash.exe from the PowerShell tool).
90
- bash scripts/start-server.sh --project-dir /path/to/project --open --foreground
91
- ```
92
-
93
- **Other environments:** The server must keep running in the background across conversation turns. If your environment reaps detached processes, use `--foreground` and launch the command with your platform's background execution mechanism.
94
-
95
- If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:
96
-
97
- ```bash
98
- scripts/start-server.sh \
99
- --project-dir /path/to/project \
100
- --host 0.0.0.0 \
101
- --url-host localhost
102
- ```
103
-
104
- Use `--url-host` to control what hostname is printed in the returned URL JSON.
105
-
106
- ## The Loop
107
-
108
- 1. **Check server is alive**, then **write HTML** to a new file in `screen_dir`:
109
- - **Required: confirm the server is alive before referring to the URL or pushing a screen.** Check that `$STATE_DIR/server-info` exists and `$STATE_DIR/server-stopped` does not. If it has shut down, restart it with `start-server.sh` using the **same `--project-dir`** — it reuses the same port, so the user's open tab reconnects on its own (it shows a "paused" overlay while the server is down) and you don't need to send a new URL. The server auto-exits after 4 hours idle (configurable with `--idle-timeout-minutes`).
110
- - Use semantic filenames: `platform.html`, `visual-style.html`, `layout.html`
111
- - **Never reuse filenames** — each screen gets a fresh file
112
- - Use your file-creation tool — **never use cat/heredoc** (dumps noise into terminal)
113
- - Server automatically serves the newest file
114
-
115
- 2. **Tell user what to expect and end your turn:**
116
- - Remind them of the URL (every step, not just first)
117
- - Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")
118
- - Ask them to respond in the terminal: "Take a look and let me know what you think. Click to select an option if you'd like."
119
-
120
- 3. **On your next turn** — after the user responds in the terminal:
121
- - Read `$STATE_DIR/events` if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines
122
- - Merge with the user's terminal text to get the full picture
123
- - The terminal message is the primary feedback; `state_dir/events` provides structured interaction data
124
-
125
- 4. **Iterate or advance** — if feedback changes current screen, write a new file (e.g., `layout-v2.html`). Only move to the next question when the current step is validated.
126
-
127
- 5. **Unload when returning to terminal** — when the next step doesn't need the browser (e.g., a clarifying question, a tradeoff discussion), push a waiting screen to clear the stale content:
128
-
129
- ```html
130
- <!-- filename: waiting.html (or waiting-2.html, etc.) -->
131
- <div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
132
- <p class="subtitle">Continuing in terminal...</p>
133
- </div>
134
- ```
135
-
136
- This prevents the user from staring at a resolved choice while the conversation has moved on. When the next visual question comes up, push a new content file as usual.
137
-
138
- 6. Repeat until done.
139
-
140
- ## Writing Content Fragments
141
-
142
- Write just the content that goes inside the page. The server wraps it in the frame template automatically (header, theme CSS, connection status, and all interactive infrastructure).
143
-
144
- **Minimal example:**
145
-
146
- ```html
147
- <h2>Which layout works better?</h2>
148
- <p class="subtitle">Consider readability and visual hierarchy</p>
149
-
150
- <div class="options">
151
- <div class="option" data-choice="a" onclick="toggleSelect(this)">
152
- <div class="letter">A</div>
153
- <div class="content">
154
- <h3>Single Column</h3>
155
- <p>Clean, focused reading experience</p>
156
- </div>
157
- </div>
158
- <div class="option" data-choice="b" onclick="toggleSelect(this)">
159
- <div class="letter">B</div>
160
- <div class="content">
161
- <h3>Two Column</h3>
162
- <p>Sidebar navigation with main content</p>
163
- </div>
164
- </div>
165
- </div>
166
- ```
167
-
168
- That's it. No `<html>`, no CSS, no `<script>` tags needed. The server provides all of that.
169
-
170
- ## CSS Classes Available
171
-
172
- The frame template provides these CSS classes for your content:
173
-
174
- ### Options (A/B/C choices)
175
-
176
- ```html
177
- <div class="options">
178
- <div class="option" data-choice="a" onclick="toggleSelect(this)">
179
- <div class="letter">A</div>
180
- <div class="content">
181
- <h3>Title</h3>
182
- <p>Description</p>
183
- </div>
184
- </div>
185
- </div>
186
- ```
187
-
188
- **Multi-select:** Add `data-multiselect` to the container to let users select multiple options. Each click toggles the item's selected styling.
189
-
190
- ```html
191
- <div class="options" data-multiselect>
192
- <!-- same option markup — users can select/deselect multiple -->
193
- </div>
194
- ```
195
-
196
- ### Cards (visual designs)
197
-
198
- ```html
199
- <div class="cards">
200
- <div class="card" data-choice="design1" onclick="toggleSelect(this)">
201
- <div class="card-image"><!-- mockup content --></div>
202
- <div class="card-body">
203
- <h3>Name</h3>
204
- <p>Description</p>
205
- </div>
206
- </div>
207
- </div>
208
- ```
209
-
210
- ### Mockup container
211
-
212
- ```html
213
- <div class="mockup">
214
- <div class="mockup-header">Preview: Dashboard Layout</div>
215
- <div class="mockup-body"><!-- your mockup HTML --></div>
216
- </div>
217
- ```
218
-
219
- ### Split view (side-by-side)
220
-
221
- ```html
222
- <div class="split">
223
- <div class="mockup"><!-- left --></div>
224
- <div class="mockup"><!-- right --></div>
225
- </div>
226
- ```
227
-
228
- ### Pros/Cons
229
-
230
- ```html
231
- <div class="pros-cons">
232
- <div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>
233
- <div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>
234
- </div>
235
- ```
236
-
237
- ### Mock elements (wireframe building blocks)
238
-
239
- ```html
240
- <div class="mock-nav">Logo | Home | About | Contact</div>
241
- <div style="display: flex;">
242
- <div class="mock-sidebar">Navigation</div>
243
- <div class="mock-content">Main content area</div>
244
- </div>
245
- <button class="mock-button">Action Button</button>
246
- <input class="mock-input" placeholder="Input field">
247
- <div class="placeholder">Placeholder area</div>
248
- ```
249
-
250
- ### Typography and sections
251
-
252
- - `h2` — page title
253
- - `h3` — section heading
254
- - `.subtitle` — secondary text below title
255
- - `.section` — content block with bottom margin
256
- - `.label` — small uppercase label text
257
-
258
- ## Browser Events Format
259
-
260
- When the user clicks options in the browser, their interactions are recorded to `$STATE_DIR/events` (one JSON object per line). The file is cleared automatically when you push a new screen.
261
-
262
- ```jsonl
263
- {"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}
264
- {"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}
265
- {"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}
266
- ```
267
-
268
- The full event stream shows the user's exploration path — they may click multiple options before settling. The last `choice` event is typically the final selection, but the pattern of clicks can reveal hesitation or preferences worth asking about.
269
-
270
- If `$STATE_DIR/events` doesn't exist, the user didn't interact with the browser — use only their terminal text.
271
-
272
- ## Design Tips
273
-
274
- - **Scale fidelity to the question** — wireframes for layout, polish for polish questions
275
- - **Explain the question on each page** — "Which layout feels more professional?" not just "Pick one"
276
- - **Iterate before advancing** — if feedback changes current screen, write a new version
277
- - **2-4 options max** per screen
278
- - **Use real content when it matters** — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.
279
- - **Keep mockups simple** — focus on layout and structure, not pixel-perfect design
280
-
281
- ## File Naming
282
-
283
- - Use semantic names: `platform.html`, `visual-style.html`, `layout.html`
284
- - Never reuse filenames — each screen must be a new file
285
- - For iterations: append version suffix like `layout-v2.html`, `layout-v3.html`
286
- - Server serves newest file by modification time
287
-
288
- ## Cleaning Up
289
-
290
- ```bash
291
- scripts/stop-server.sh $SESSION_DIR
292
- ```
293
-
294
- If the session used `--project-dir`, mockup files persist in `.superpowers/brainstorm/` for later reference. Only `/tmp` sessions get deleted on stop.
295
-
296
- ## Reference
297
-
298
- - Frame template (CSS reference): `scripts/frame-template.html`
299
- - Helper script (client-side): `scripts/helper.js`
1
+ # Visual Companion Guide
2
+
3
+ Browser-based visual brainstorming companion for showing mockups, diagrams, and options.
4
+
5
+ ## When to Use
6
+
7
+ Decide per-question, not per-session. The test: **would the user understand this better by seeing it than reading it?**
8
+
9
+ **Use the browser** when the content itself is visual:
10
+
11
+ - **UI mockups** — wireframes, layouts, navigation structures, component designs
12
+ - **Architecture diagrams** — system components, data flow, relationship maps
13
+ - **Side-by-side visual comparisons** — comparing two layouts, two color schemes, two design directions
14
+ - **Design polish** — when the question is about look and feel, spacing, visual hierarchy
15
+ - **Spatial relationships** — state machines, flowcharts, entity relationships rendered as diagrams
16
+
17
+ **Use the terminal** when the content is text or tabular:
18
+
19
+ - **Requirements and scope questions** — "what does X mean?", "which features are in scope?"
20
+ - **Conceptual A/B/C choices** — picking between approaches described in words
21
+ - **Tradeoff lists** — pros/cons, comparison tables
22
+ - **Technical decisions** — API design, data modeling, architectural approach selection
23
+ - **Clarifying questions** — anything where the answer is words, not a visual preference
24
+
25
+ A question *about* a UI topic is not automatically a visual question. "What kind of wizard do you want?" is conceptual — use the terminal. "Which of these wizard layouts feels right?" is visual — use the browser.
26
+
27
+ ## How It Works
28
+
29
+ The server watches a directory for HTML files and serves the newest one to the browser. You write HTML content to `screen_dir`, the user sees it in their browser and can click to select options. Selections are recorded to `state_dir/events` that you read on your next turn.
30
+
31
+ **Content fragments vs full documents:** If your HTML file starts with `<!DOCTYPE` or `<html`, the server serves it as-is (just injects the helper script). Otherwise, the server automatically wraps your content in the frame template — adding the header, CSS theme, connection status, and all interactive infrastructure. **Write content fragments by default.** Only write full documents when you need complete control over the page.
32
+
33
+ ## Starting a Session
34
+
35
+ ```bash
36
+ # Start AFTER the user approves the companion. --open auto-opens their browser on
37
+ # the first screen; --project-dir persists mockups and enables same-port restart.
38
+ scripts/start-server.sh --project-dir /path/to/project --open
39
+
40
+ # Returns: {"type":"server-started","port":52341,
41
+ # "url":"http://localhost:52341/?key=ab12…",
42
+ # "screen_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/content",
43
+ # "state_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/state"}
44
+ ```
45
+
46
+ Save `screen_dir` and `state_dir` from the response. With `--open`, the browser opens itself when you push the first screen — you don't need to ask the user to open it, but still share the URL as a fallback (headless/remote setups won't auto-open).
47
+
48
+ **The URL contains a session key (`?key=…`).** The server rejects any request
49
+ without it, so always give the user the **complete** URL from the `url` field —
50
+ never strip the query string, and never hand out a bare `http://host:port`. The
51
+ key gates HTTP and WebSocket access so a stray browser tab or another machine on
52
+ the network can't read the screens or inject events. After the first load the
53
+ browser remembers the key via a cookie, so reloads and `/files/*` assets work
54
+ without repeating it.
55
+
56
+ **Finding connection info:** The server writes its startup JSON to `$STATE_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.
57
+
58
+ **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.
59
+
60
+ **Launching the server by platform:**
61
+
62
+ **Claude Code:**
63
+ ```bash
64
+ # Default mode works — the script backgrounds the server itself.
65
+ scripts/start-server.sh --project-dir /path/to/project --open
66
+ ```
67
+
68
+ On Windows, the script auto-detects and switches to foreground mode (which blocks the tool call). Use `run_in_background: true` on the Bash tool call so the server survives across conversation turns, then read `$STATE_DIR/server-info` on the next turn to get the URL and port.
69
+
70
+ **Codex:**
71
+ ```bash
72
+ # Codex reaps background processes. The script auto-detects CODEX_CI and
73
+ # switches to foreground mode. Run it normally — no extra flags needed.
74
+ scripts/start-server.sh --project-dir /path/to/project --open
75
+ ```
76
+
77
+ **Gemini CLI:**
78
+ ```bash
79
+ # Use --foreground and set is_background: true on your shell tool call
80
+ # so the process survives across turns
81
+ scripts/start-server.sh --project-dir /path/to/project --open --foreground
82
+ ```
83
+
84
+ **Copilot CLI:**
85
+ ```bash
86
+ # Start it with Copilot CLI's non-blocking/background shell mechanism so the
87
+ # server survives across turns. Keep --foreground so the harness, not the
88
+ # script, owns backgrounding. The launcher is a .sh, so invoke it via bash
89
+ # (on Windows, call Git Bash's bash.exe from the PowerShell tool).
90
+ bash scripts/start-server.sh --project-dir /path/to/project --open --foreground
91
+ ```
92
+
93
+ **Other environments:** The server must keep running in the background across conversation turns. If your environment reaps detached processes, use `--foreground` and launch the command with your platform's background execution mechanism.
94
+
95
+ If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:
96
+
97
+ ```bash
98
+ scripts/start-server.sh \
99
+ --project-dir /path/to/project \
100
+ --host 0.0.0.0 \
101
+ --url-host localhost
102
+ ```
103
+
104
+ Use `--url-host` to control what hostname is printed in the returned URL JSON.
105
+
106
+ ## The Loop
107
+
108
+ 1. **Check server is alive**, then **write HTML** to a new file in `screen_dir`:
109
+ - **Required: confirm the server is alive before referring to the URL or pushing a screen.** Check that `$STATE_DIR/server-info` exists and `$STATE_DIR/server-stopped` does not. If it has shut down, restart it with `start-server.sh` using the **same `--project-dir`** — it reuses the same port, so the user's open tab reconnects on its own (it shows a "paused" overlay while the server is down) and you don't need to send a new URL. The server auto-exits after 4 hours idle (configurable with `--idle-timeout-minutes`).
110
+ - Use semantic filenames: `platform.html`, `visual-style.html`, `layout.html`
111
+ - **Never reuse filenames** — each screen gets a fresh file
112
+ - Use your file-creation tool — **never use cat/heredoc** (dumps noise into terminal)
113
+ - Server automatically serves the newest file
114
+
115
+ 2. **Tell user what to expect and end your turn:**
116
+ - Remind them of the URL (every step, not just first)
117
+ - Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")
118
+ - Ask them to respond in the terminal: "Take a look and let me know what you think. Click to select an option if you'd like."
119
+
120
+ 3. **On your next turn** — after the user responds in the terminal:
121
+ - Read `$STATE_DIR/events` if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines
122
+ - Merge with the user's terminal text to get the full picture
123
+ - The terminal message is the primary feedback; `state_dir/events` provides structured interaction data
124
+
125
+ 4. **Iterate or advance** — if feedback changes current screen, write a new file (e.g., `layout-v2.html`). Only move to the next question when the current step is validated.
126
+
127
+ 5. **Unload when returning to terminal** — when the next step doesn't need the browser (e.g., a clarifying question, a tradeoff discussion), push a waiting screen to clear the stale content:
128
+
129
+ ```html
130
+ <!-- filename: waiting.html (or waiting-2.html, etc.) -->
131
+ <div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
132
+ <p class="subtitle">Continuing in terminal...</p>
133
+ </div>
134
+ ```
135
+
136
+ This prevents the user from staring at a resolved choice while the conversation has moved on. When the next visual question comes up, push a new content file as usual.
137
+
138
+ 6. Repeat until done.
139
+
140
+ ## Writing Content Fragments
141
+
142
+ Write just the content that goes inside the page. The server wraps it in the frame template automatically (header, theme CSS, connection status, and all interactive infrastructure).
143
+
144
+ **Minimal example:**
145
+
146
+ ```html
147
+ <h2>Which layout works better?</h2>
148
+ <p class="subtitle">Consider readability and visual hierarchy</p>
149
+
150
+ <div class="options">
151
+ <div class="option" data-choice="a" onclick="toggleSelect(this)">
152
+ <div class="letter">A</div>
153
+ <div class="content">
154
+ <h3>Single Column</h3>
155
+ <p>Clean, focused reading experience</p>
156
+ </div>
157
+ </div>
158
+ <div class="option" data-choice="b" onclick="toggleSelect(this)">
159
+ <div class="letter">B</div>
160
+ <div class="content">
161
+ <h3>Two Column</h3>
162
+ <p>Sidebar navigation with main content</p>
163
+ </div>
164
+ </div>
165
+ </div>
166
+ ```
167
+
168
+ That's it. No `<html>`, no CSS, no `<script>` tags needed. The server provides all of that.
169
+
170
+ ## CSS Classes Available
171
+
172
+ The frame template provides these CSS classes for your content:
173
+
174
+ ### Options (A/B/C choices)
175
+
176
+ ```html
177
+ <div class="options">
178
+ <div class="option" data-choice="a" onclick="toggleSelect(this)">
179
+ <div class="letter">A</div>
180
+ <div class="content">
181
+ <h3>Title</h3>
182
+ <p>Description</p>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ ```
187
+
188
+ **Multi-select:** Add `data-multiselect` to the container to let users select multiple options. Each click toggles the item's selected styling.
189
+
190
+ ```html
191
+ <div class="options" data-multiselect>
192
+ <!-- same option markup — users can select/deselect multiple -->
193
+ </div>
194
+ ```
195
+
196
+ ### Cards (visual designs)
197
+
198
+ ```html
199
+ <div class="cards">
200
+ <div class="card" data-choice="design1" onclick="toggleSelect(this)">
201
+ <div class="card-image"><!-- mockup content --></div>
202
+ <div class="card-body">
203
+ <h3>Name</h3>
204
+ <p>Description</p>
205
+ </div>
206
+ </div>
207
+ </div>
208
+ ```
209
+
210
+ ### Mockup container
211
+
212
+ ```html
213
+ <div class="mockup">
214
+ <div class="mockup-header">Preview: Dashboard Layout</div>
215
+ <div class="mockup-body"><!-- your mockup HTML --></div>
216
+ </div>
217
+ ```
218
+
219
+ ### Split view (side-by-side)
220
+
221
+ ```html
222
+ <div class="split">
223
+ <div class="mockup"><!-- left --></div>
224
+ <div class="mockup"><!-- right --></div>
225
+ </div>
226
+ ```
227
+
228
+ ### Pros/Cons
229
+
230
+ ```html
231
+ <div class="pros-cons">
232
+ <div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>
233
+ <div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>
234
+ </div>
235
+ ```
236
+
237
+ ### Mock elements (wireframe building blocks)
238
+
239
+ ```html
240
+ <div class="mock-nav">Logo | Home | About | Contact</div>
241
+ <div style="display: flex;">
242
+ <div class="mock-sidebar">Navigation</div>
243
+ <div class="mock-content">Main content area</div>
244
+ </div>
245
+ <button class="mock-button">Action Button</button>
246
+ <input class="mock-input" placeholder="Input field">
247
+ <div class="placeholder">Placeholder area</div>
248
+ ```
249
+
250
+ ### Typography and sections
251
+
252
+ - `h2` — page title
253
+ - `h3` — section heading
254
+ - `.subtitle` — secondary text below title
255
+ - `.section` — content block with bottom margin
256
+ - `.label` — small uppercase label text
257
+
258
+ ## Browser Events Format
259
+
260
+ When the user clicks options in the browser, their interactions are recorded to `$STATE_DIR/events` (one JSON object per line). The file is cleared automatically when you push a new screen.
261
+
262
+ ```jsonl
263
+ {"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}
264
+ {"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}
265
+ {"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}
266
+ ```
267
+
268
+ The full event stream shows the user's exploration path — they may click multiple options before settling. The last `choice` event is typically the final selection, but the pattern of clicks can reveal hesitation or preferences worth asking about.
269
+
270
+ If `$STATE_DIR/events` doesn't exist, the user didn't interact with the browser — use only their terminal text.
271
+
272
+ ## Design Tips
273
+
274
+ - **Scale fidelity to the question** — wireframes for layout, polish for polish questions
275
+ - **Explain the question on each page** — "Which layout feels more professional?" not just "Pick one"
276
+ - **Iterate before advancing** — if feedback changes current screen, write a new version
277
+ - **2-4 options max** per screen
278
+ - **Use real content when it matters** — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.
279
+ - **Keep mockups simple** — focus on layout and structure, not pixel-perfect design
280
+
281
+ ## File Naming
282
+
283
+ - Use semantic names: `platform.html`, `visual-style.html`, `layout.html`
284
+ - Never reuse filenames — each screen must be a new file
285
+ - For iterations: append version suffix like `layout-v2.html`, `layout-v3.html`
286
+ - Server serves newest file by modification time
287
+
288
+ ## Cleaning Up
289
+
290
+ ```bash
291
+ scripts/stop-server.sh $SESSION_DIR
292
+ ```
293
+
294
+ If the session used `--project-dir`, mockup files persist in `.superpowers/brainstorm/` for later reference. Only `/tmp` sessions get deleted on stop.
295
+
296
+ ## Reference
297
+
298
+ - Frame template (CSS reference): `scripts/frame-template.html`
299
+ - Helper script (client-side): `scripts/helper.js`