workerssuper 5.0.4

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 (135) hide show
  1. package/.claude-plugin/marketplace.json +20 -0
  2. package/.claude-plugin/plugin.json +13 -0
  3. package/.codex/INSTALL.md +67 -0
  4. package/.cursor-plugin/plugin.json +18 -0
  5. package/.gitattributes +18 -0
  6. package/.github/FUNDING.yml +3 -0
  7. package/.github/ISSUE_TEMPLATE/bug_report.md +52 -0
  8. package/.github/ISSUE_TEMPLATE/config.yml +5 -0
  9. package/.github/ISSUE_TEMPLATE/feature_request.md +34 -0
  10. package/.github/ISSUE_TEMPLATE/platform_support.md +23 -0
  11. package/.github/PULL_REQUEST_TEMPLATE.md +87 -0
  12. package/.opencode/INSTALL.md +83 -0
  13. package/.opencode/plugins/superpowers.js +107 -0
  14. package/CHANGELOG.md +13 -0
  15. package/CODE_OF_CONDUCT.md +128 -0
  16. package/GEMINI.md +2 -0
  17. package/LICENSE +21 -0
  18. package/README.md +187 -0
  19. package/RELEASE-NOTES.md +1057 -0
  20. package/agents/code-reviewer.md +48 -0
  21. package/commands/brainstorm.md +5 -0
  22. package/commands/execute-plan.md +5 -0
  23. package/commands/write-plan.md +5 -0
  24. package/docs/README.codex.md +126 -0
  25. package/docs/README.opencode.md +130 -0
  26. package/docs/plans/2025-11-22-opencode-support-design.md +294 -0
  27. package/docs/plans/2025-11-22-opencode-support-implementation.md +1095 -0
  28. package/docs/plans/2025-11-28-skills-improvements-from-user-feedback.md +711 -0
  29. package/docs/plans/2026-01-17-visual-brainstorming.md +571 -0
  30. package/docs/superpowers/plans/2026-01-22-document-review-system.md +301 -0
  31. package/docs/superpowers/plans/2026-02-19-visual-brainstorming-refactor.md +523 -0
  32. package/docs/superpowers/plans/2026-03-11-zero-dep-brainstorm-server.md +479 -0
  33. package/docs/superpowers/specs/2026-01-22-document-review-system-design.md +136 -0
  34. package/docs/superpowers/specs/2026-02-19-visual-brainstorming-refactor-design.md +162 -0
  35. package/docs/superpowers/specs/2026-03-11-zero-dep-brainstorm-server-design.md +118 -0
  36. package/docs/testing.md +303 -0
  37. package/docs/windows/polyglot-hooks.md +212 -0
  38. package/gemini-extension.json +6 -0
  39. package/hooks/hooks-cursor.json +10 -0
  40. package/hooks/hooks.json +16 -0
  41. package/hooks/run-hook.cmd +46 -0
  42. package/hooks/session-start +57 -0
  43. package/package.json +5 -0
  44. package/skills/brainstorming/SKILL.md +164 -0
  45. package/skills/brainstorming/scripts/frame-template.html +214 -0
  46. package/skills/brainstorming/scripts/helper.js +88 -0
  47. package/skills/brainstorming/scripts/server.cjs +338 -0
  48. package/skills/brainstorming/scripts/start-server.sh +153 -0
  49. package/skills/brainstorming/scripts/stop-server.sh +55 -0
  50. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  51. package/skills/brainstorming/visual-companion.md +286 -0
  52. package/skills/dispatching-parallel-agents/SKILL.md +182 -0
  53. package/skills/executing-plans/SKILL.md +70 -0
  54. package/skills/finishing-a-development-branch/SKILL.md +200 -0
  55. package/skills/receiving-code-review/SKILL.md +213 -0
  56. package/skills/requesting-code-review/SKILL.md +105 -0
  57. package/skills/requesting-code-review/code-reviewer.md +146 -0
  58. package/skills/subagent-driven-development/SKILL.md +277 -0
  59. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  60. package/skills/subagent-driven-development/implementer-prompt.md +113 -0
  61. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  62. package/skills/systematic-debugging/CREATION-LOG.md +119 -0
  63. package/skills/systematic-debugging/SKILL.md +296 -0
  64. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  65. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  66. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  67. package/skills/systematic-debugging/find-polluter.sh +63 -0
  68. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  69. package/skills/systematic-debugging/test-academic.md +14 -0
  70. package/skills/systematic-debugging/test-pressure-1.md +58 -0
  71. package/skills/systematic-debugging/test-pressure-2.md +68 -0
  72. package/skills/systematic-debugging/test-pressure-3.md +69 -0
  73. package/skills/test-driven-development/SKILL.md +371 -0
  74. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  75. package/skills/using-git-worktrees/SKILL.md +218 -0
  76. package/skills/using-superpowers/SKILL.md +115 -0
  77. package/skills/using-superpowers/references/codex-tools.md +25 -0
  78. package/skills/using-superpowers/references/gemini-tools.md +33 -0
  79. package/skills/verification-before-completion/SKILL.md +139 -0
  80. package/skills/writing-plans/SKILL.md +145 -0
  81. package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  82. package/skills/writing-skills/SKILL.md +655 -0
  83. package/skills/writing-skills/anthropic-best-practices.md +1150 -0
  84. package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  85. package/skills/writing-skills/graphviz-conventions.dot +172 -0
  86. package/skills/writing-skills/persuasion-principles.md +187 -0
  87. package/skills/writing-skills/render-graphs.js +168 -0
  88. package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  89. package/tests/brainstorm-server/package-lock.json +36 -0
  90. package/tests/brainstorm-server/package.json +10 -0
  91. package/tests/brainstorm-server/server.test.js +424 -0
  92. package/tests/brainstorm-server/windows-lifecycle.test.sh +351 -0
  93. package/tests/brainstorm-server/ws-protocol.test.js +392 -0
  94. package/tests/claude-code/README.md +158 -0
  95. package/tests/claude-code/analyze-token-usage.py +168 -0
  96. package/tests/claude-code/run-skill-tests.sh +187 -0
  97. package/tests/claude-code/test-document-review-system.sh +177 -0
  98. package/tests/claude-code/test-helpers.sh +202 -0
  99. package/tests/claude-code/test-subagent-driven-development-integration.sh +314 -0
  100. package/tests/claude-code/test-subagent-driven-development.sh +165 -0
  101. package/tests/explicit-skill-requests/prompts/action-oriented.txt +3 -0
  102. package/tests/explicit-skill-requests/prompts/after-planning-flow.txt +17 -0
  103. package/tests/explicit-skill-requests/prompts/claude-suggested-it.txt +11 -0
  104. package/tests/explicit-skill-requests/prompts/i-know-what-sdd-means.txt +8 -0
  105. package/tests/explicit-skill-requests/prompts/mid-conversation-execute-plan.txt +3 -0
  106. package/tests/explicit-skill-requests/prompts/please-use-brainstorming.txt +1 -0
  107. package/tests/explicit-skill-requests/prompts/skip-formalities.txt +3 -0
  108. package/tests/explicit-skill-requests/prompts/subagent-driven-development-please.txt +1 -0
  109. package/tests/explicit-skill-requests/prompts/use-systematic-debugging.txt +1 -0
  110. package/tests/explicit-skill-requests/run-all.sh +70 -0
  111. package/tests/explicit-skill-requests/run-claude-describes-sdd.sh +100 -0
  112. package/tests/explicit-skill-requests/run-extended-multiturn-test.sh +113 -0
  113. package/tests/explicit-skill-requests/run-haiku-test.sh +144 -0
  114. package/tests/explicit-skill-requests/run-multiturn-test.sh +143 -0
  115. package/tests/explicit-skill-requests/run-test.sh +136 -0
  116. package/tests/opencode/run-tests.sh +163 -0
  117. package/tests/opencode/setup.sh +73 -0
  118. package/tests/opencode/test-plugin-loading.sh +72 -0
  119. package/tests/opencode/test-priority.sh +198 -0
  120. package/tests/opencode/test-tools.sh +104 -0
  121. package/tests/skill-triggering/prompts/dispatching-parallel-agents.txt +8 -0
  122. package/tests/skill-triggering/prompts/executing-plans.txt +1 -0
  123. package/tests/skill-triggering/prompts/requesting-code-review.txt +3 -0
  124. package/tests/skill-triggering/prompts/systematic-debugging.txt +11 -0
  125. package/tests/skill-triggering/prompts/test-driven-development.txt +7 -0
  126. package/tests/skill-triggering/prompts/writing-plans.txt +10 -0
  127. package/tests/skill-triggering/run-all.sh +60 -0
  128. package/tests/skill-triggering/run-test.sh +88 -0
  129. package/tests/subagent-driven-dev/go-fractals/design.md +81 -0
  130. package/tests/subagent-driven-dev/go-fractals/plan.md +172 -0
  131. package/tests/subagent-driven-dev/go-fractals/scaffold.sh +45 -0
  132. package/tests/subagent-driven-dev/run-test.sh +106 -0
  133. package/tests/subagent-driven-dev/svelte-todo/design.md +70 -0
  134. package/tests/subagent-driven-dev/svelte-todo/plan.md +222 -0
  135. package/tests/subagent-driven-dev/svelte-todo/scaffold.sh +46 -0
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env bash
2
+ # Start the brainstorm server and output connection info
3
+ # Usage: start-server.sh [--project-dir <path>] [--host <bind-host>] [--url-host <display-host>] [--foreground] [--background]
4
+ #
5
+ # Starts server on a random high port, outputs JSON with URL.
6
+ # Each session gets its own directory to avoid conflicts.
7
+ #
8
+ # Options:
9
+ # --project-dir <path> Store session files under <path>/.superpowers/brainstorm/
10
+ # instead of /tmp. Files persist after server stops.
11
+ # --host <bind-host> Host/interface to bind (default: 127.0.0.1).
12
+ # Use 0.0.0.0 in remote/containerized environments.
13
+ # --url-host <host> Hostname shown in returned URL JSON.
14
+ # --foreground Run server in the current terminal (no backgrounding).
15
+ # --background Force background mode (overrides Codex auto-foreground).
16
+
17
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
18
+
19
+ # Parse arguments
20
+ PROJECT_DIR=""
21
+ FOREGROUND="false"
22
+ FORCE_BACKGROUND="false"
23
+ BIND_HOST="127.0.0.1"
24
+ URL_HOST=""
25
+ while [[ $# -gt 0 ]]; do
26
+ case "$1" in
27
+ --project-dir)
28
+ PROJECT_DIR="$2"
29
+ shift 2
30
+ ;;
31
+ --host)
32
+ BIND_HOST="$2"
33
+ shift 2
34
+ ;;
35
+ --url-host)
36
+ URL_HOST="$2"
37
+ shift 2
38
+ ;;
39
+ --foreground|--no-daemon)
40
+ FOREGROUND="true"
41
+ shift
42
+ ;;
43
+ --background|--daemon)
44
+ FORCE_BACKGROUND="true"
45
+ shift
46
+ ;;
47
+ *)
48
+ echo "{\"error\": \"Unknown argument: $1\"}"
49
+ exit 1
50
+ ;;
51
+ esac
52
+ done
53
+
54
+ if [[ -z "$URL_HOST" ]]; then
55
+ if [[ "$BIND_HOST" == "127.0.0.1" || "$BIND_HOST" == "localhost" ]]; then
56
+ URL_HOST="localhost"
57
+ else
58
+ URL_HOST="$BIND_HOST"
59
+ fi
60
+ fi
61
+
62
+ # Some environments reap detached/background processes. Auto-foreground when detected.
63
+ if [[ -n "${CODEX_CI:-}" && "$FOREGROUND" != "true" && "$FORCE_BACKGROUND" != "true" ]]; then
64
+ FOREGROUND="true"
65
+ fi
66
+
67
+ # Windows/Git Bash reaps nohup background processes. Auto-foreground when detected.
68
+ if [[ "$FOREGROUND" != "true" && "$FORCE_BACKGROUND" != "true" ]]; then
69
+ case "${OSTYPE:-}" in
70
+ msys*|cygwin*|mingw*) FOREGROUND="true" ;;
71
+ esac
72
+ if [[ -n "${MSYSTEM:-}" ]]; then
73
+ FOREGROUND="true"
74
+ fi
75
+ fi
76
+
77
+ # Generate unique session directory
78
+ SESSION_ID="$$-$(date +%s)"
79
+
80
+ if [[ -n "$PROJECT_DIR" ]]; then
81
+ SCREEN_DIR="${PROJECT_DIR}/.superpowers/brainstorm/${SESSION_ID}"
82
+ else
83
+ SCREEN_DIR="/tmp/brainstorm-${SESSION_ID}"
84
+ fi
85
+
86
+ PID_FILE="${SCREEN_DIR}/.server.pid"
87
+ LOG_FILE="${SCREEN_DIR}/.server.log"
88
+
89
+ # Create fresh session directory
90
+ mkdir -p "$SCREEN_DIR"
91
+
92
+ # Kill any existing server
93
+ if [[ -f "$PID_FILE" ]]; then
94
+ old_pid=$(cat "$PID_FILE")
95
+ kill "$old_pid" 2>/dev/null
96
+ rm -f "$PID_FILE"
97
+ fi
98
+
99
+ cd "$SCRIPT_DIR"
100
+
101
+ # Resolve the harness PID (grandparent of this script).
102
+ # $PPID is the ephemeral shell the harness spawned to run us — it dies
103
+ # when this script exits. The harness itself is $PPID's parent.
104
+ OWNER_PID="$(ps -o ppid= -p "$PPID" 2>/dev/null | tr -d ' ')"
105
+ if [[ -z "$OWNER_PID" || "$OWNER_PID" == "1" ]]; then
106
+ OWNER_PID="$PPID"
107
+ fi
108
+
109
+ # On Windows/MSYS2, the MSYS2 PID namespace is invisible to Node.js.
110
+ # Skip owner-PID monitoring — the 30-minute idle timeout prevents orphans.
111
+ case "${OSTYPE:-}" in
112
+ msys*|cygwin*|mingw*) OWNER_PID="" ;;
113
+ esac
114
+
115
+ # Foreground mode for environments that reap detached/background processes.
116
+ if [[ "$FOREGROUND" == "true" ]]; then
117
+ echo "$$" > "$PID_FILE"
118
+ env BRAINSTORM_DIR="$SCREEN_DIR" BRAINSTORM_HOST="$BIND_HOST" BRAINSTORM_URL_HOST="$URL_HOST" BRAINSTORM_OWNER_PID="$OWNER_PID" node server.cjs
119
+ exit $?
120
+ fi
121
+
122
+ # Start server, capturing output to log file
123
+ # Use nohup to survive shell exit; disown to remove from job table
124
+ nohup env BRAINSTORM_DIR="$SCREEN_DIR" BRAINSTORM_HOST="$BIND_HOST" BRAINSTORM_URL_HOST="$URL_HOST" BRAINSTORM_OWNER_PID="$OWNER_PID" node server.cjs > "$LOG_FILE" 2>&1 &
125
+ SERVER_PID=$!
126
+ disown "$SERVER_PID" 2>/dev/null
127
+ echo "$SERVER_PID" > "$PID_FILE"
128
+
129
+ # Wait for server-started message (check log file)
130
+ for i in {1..50}; do
131
+ if grep -q "server-started" "$LOG_FILE" 2>/dev/null; then
132
+ # Verify server is still alive after a short window (catches process reapers)
133
+ alive="true"
134
+ for _ in {1..20}; do
135
+ if ! kill -0 "$SERVER_PID" 2>/dev/null; then
136
+ alive="false"
137
+ break
138
+ fi
139
+ sleep 0.1
140
+ done
141
+ if [[ "$alive" != "true" ]]; then
142
+ echo "{\"error\": \"Server started but was killed. Retry in a persistent terminal with: $SCRIPT_DIR/start-server.sh${PROJECT_DIR:+ --project-dir $PROJECT_DIR} --host $BIND_HOST --url-host $URL_HOST --foreground\"}"
143
+ exit 1
144
+ fi
145
+ grep "server-started" "$LOG_FILE" | head -1
146
+ exit 0
147
+ fi
148
+ sleep 0.1
149
+ done
150
+
151
+ # Timeout - server didn't start
152
+ echo '{"error": "Server failed to start within 5 seconds"}'
153
+ exit 1
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+ # Stop the brainstorm server and clean up
3
+ # Usage: stop-server.sh <screen_dir>
4
+ #
5
+ # Kills the server process. Only deletes session directory if it's
6
+ # under /tmp (ephemeral). Persistent directories (.superpowers/) are
7
+ # kept so mockups can be reviewed later.
8
+
9
+ SCREEN_DIR="$1"
10
+
11
+ if [[ -z "$SCREEN_DIR" ]]; then
12
+ echo '{"error": "Usage: stop-server.sh <screen_dir>"}'
13
+ exit 1
14
+ fi
15
+
16
+ PID_FILE="${SCREEN_DIR}/.server.pid"
17
+
18
+ if [[ -f "$PID_FILE" ]]; then
19
+ pid=$(cat "$PID_FILE")
20
+
21
+ # Try to stop gracefully, fallback to force if still alive
22
+ kill "$pid" 2>/dev/null || true
23
+
24
+ # Wait for graceful shutdown (up to ~2s)
25
+ for i in {1..20}; do
26
+ if ! kill -0 "$pid" 2>/dev/null; then
27
+ break
28
+ fi
29
+ sleep 0.1
30
+ done
31
+
32
+ # If still running, escalate to SIGKILL
33
+ if kill -0 "$pid" 2>/dev/null; then
34
+ kill -9 "$pid" 2>/dev/null || true
35
+
36
+ # Give SIGKILL a moment to take effect
37
+ sleep 0.1
38
+ fi
39
+
40
+ if kill -0 "$pid" 2>/dev/null; then
41
+ echo '{"status": "failed", "error": "process still running"}'
42
+ exit 1
43
+ fi
44
+
45
+ rm -f "$PID_FILE" "${SCREEN_DIR}/.server.log"
46
+
47
+ # Only delete ephemeral /tmp directories
48
+ if [[ "$SCREEN_DIR" == /tmp/* ]]; then
49
+ rm -rf "$SCREEN_DIR"
50
+ fi
51
+
52
+ echo '{"status": "stopped"}'
53
+ else
54
+ echo '{"status": "not_running"}'
55
+ fi
@@ -0,0 +1,49 @@
1
+ # Spec Document Reviewer Prompt Template
2
+
3
+ Use this template when dispatching a spec document reviewer subagent.
4
+
5
+ **Purpose:** Verify the spec is complete, consistent, and ready for implementation planning.
6
+
7
+ **Dispatch after:** Spec document is written to docs/superpowers/specs/
8
+
9
+ ```
10
+ Task tool (general-purpose):
11
+ description: "Review spec document"
12
+ prompt: |
13
+ You are a spec document reviewer. Verify this spec is complete and ready for planning.
14
+
15
+ **Spec to review:** [SPEC_FILE_PATH]
16
+
17
+ ## What to Check
18
+
19
+ | Category | What to Look For |
20
+ |----------|------------------|
21
+ | Completeness | TODOs, placeholders, "TBD", incomplete sections |
22
+ | Consistency | Internal contradictions, conflicting requirements |
23
+ | Clarity | Requirements ambiguous enough to cause someone to build the wrong thing |
24
+ | Scope | Focused enough for a single plan — not covering multiple independent subsystems |
25
+ | YAGNI | Unrequested features, over-engineering |
26
+
27
+ ## Calibration
28
+
29
+ **Only flag issues that would cause real problems during implementation planning.**
30
+ A missing section, a contradiction, or a requirement so ambiguous it could be
31
+ interpreted two different ways — those are issues. Minor wording improvements,
32
+ stylistic preferences, and "sections less detailed than others" are not.
33
+
34
+ Approve unless there are serious gaps that would lead to a flawed plan.
35
+
36
+ ## Output Format
37
+
38
+ ## Spec Review
39
+
40
+ **Status:** Approved | Issues Found
41
+
42
+ **Issues (if any):**
43
+ - [Section X]: [specific issue] - [why it matters for planning]
44
+
45
+ **Recommendations (advisory, do not block approval):**
46
+ - [suggestions for improvement]
47
+ ```
48
+
49
+ **Reviewer returns:** Status, Issues (if any), Recommendations
@@ -0,0 +1,286 @@
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, the user sees it in their browser and can click to select options. Selections are recorded to a `.events` file 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, selection indicator, 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 server with persistence (mockups saved to project)
37
+ scripts/start-server.sh --project-dir /path/to/project
38
+
39
+ # Returns: {"type":"server-started","port":52341,"url":"http://localhost:52341",
40
+ # "screen_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000"}
41
+ ```
42
+
43
+ Save `screen_dir` from the response. Tell user to open the URL.
44
+
45
+ **Finding connection info:** The server writes its startup JSON to `$SCREEN_DIR/.server-info`. If you launched the server in the background and didn't capture stdout, read that file to get the URL and port. When using `--project-dir`, check `<project>/.superpowers/brainstorm/` for the session directory.
46
+
47
+ **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.
48
+
49
+ **Launching the server by platform:**
50
+
51
+ **Claude Code (macOS / Linux):**
52
+ ```bash
53
+ # Default mode works — the script backgrounds the server itself
54
+ scripts/start-server.sh --project-dir /path/to/project
55
+ ```
56
+
57
+ **Claude Code (Windows):**
58
+ ```bash
59
+ # Windows auto-detects and uses foreground mode, which blocks the tool call.
60
+ # Use run_in_background: true on the Bash tool call so the server survives
61
+ # across conversation turns.
62
+ scripts/start-server.sh --project-dir /path/to/project
63
+ ```
64
+ When calling this via the Bash tool, set `run_in_background: true`. Then read `$SCREEN_DIR/.server-info` on the next turn to get the URL and port.
65
+
66
+ **Codex:**
67
+ ```bash
68
+ # Codex reaps background processes. The script auto-detects CODEX_CI and
69
+ # switches to foreground mode. Run it normally — no extra flags needed.
70
+ scripts/start-server.sh --project-dir /path/to/project
71
+ ```
72
+
73
+ **Gemini CLI:**
74
+ ```bash
75
+ # Use --foreground and set is_background: true on your shell tool call
76
+ # so the process survives across turns
77
+ scripts/start-server.sh --project-dir /path/to/project --foreground
78
+ ```
79
+
80
+ **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.
81
+
82
+ If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:
83
+
84
+ ```bash
85
+ scripts/start-server.sh \
86
+ --project-dir /path/to/project \
87
+ --host 0.0.0.0 \
88
+ --url-host localhost
89
+ ```
90
+
91
+ Use `--url-host` to control what hostname is printed in the returned URL JSON.
92
+
93
+ ## The Loop
94
+
95
+ 1. **Check server is alive**, then **write HTML** to a new file in `screen_dir`:
96
+ - Before each write, check that `$SCREEN_DIR/.server-info` exists. If it doesn't (or `.server-stopped` exists), the server has shut down — restart it with `start-server.sh` before continuing. The server auto-exits after 30 minutes of inactivity.
97
+ - Use semantic filenames: `platform.html`, `visual-style.html`, `layout.html`
98
+ - **Never reuse filenames** — each screen gets a fresh file
99
+ - Use Write tool — **never use cat/heredoc** (dumps noise into terminal)
100
+ - Server automatically serves the newest file
101
+
102
+ 2. **Tell user what to expect and end your turn:**
103
+ - Remind them of the URL (every step, not just first)
104
+ - Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")
105
+ - 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."
106
+
107
+ 3. **On your next turn** — after the user responds in the terminal:
108
+ - Read `$SCREEN_DIR/.events` if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines
109
+ - Merge with the user's terminal text to get the full picture
110
+ - The terminal message is the primary feedback; `.events` provides structured interaction data
111
+
112
+ 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.
113
+
114
+ 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:
115
+
116
+ ```html
117
+ <!-- filename: waiting.html (or waiting-2.html, etc.) -->
118
+ <div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
119
+ <p class="subtitle">Continuing in terminal...</p>
120
+ </div>
121
+ ```
122
+
123
+ 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.
124
+
125
+ 6. Repeat until done.
126
+
127
+ ## Writing Content Fragments
128
+
129
+ Write just the content that goes inside the page. The server wraps it in the frame template automatically (header, theme CSS, selection indicator, and all interactive infrastructure).
130
+
131
+ **Minimal example:**
132
+
133
+ ```html
134
+ <h2>Which layout works better?</h2>
135
+ <p class="subtitle">Consider readability and visual hierarchy</p>
136
+
137
+ <div class="options">
138
+ <div class="option" data-choice="a" onclick="toggleSelect(this)">
139
+ <div class="letter">A</div>
140
+ <div class="content">
141
+ <h3>Single Column</h3>
142
+ <p>Clean, focused reading experience</p>
143
+ </div>
144
+ </div>
145
+ <div class="option" data-choice="b" onclick="toggleSelect(this)">
146
+ <div class="letter">B</div>
147
+ <div class="content">
148
+ <h3>Two Column</h3>
149
+ <p>Sidebar navigation with main content</p>
150
+ </div>
151
+ </div>
152
+ </div>
153
+ ```
154
+
155
+ That's it. No `<html>`, no CSS, no `<script>` tags needed. The server provides all of that.
156
+
157
+ ## CSS Classes Available
158
+
159
+ The frame template provides these CSS classes for your content:
160
+
161
+ ### Options (A/B/C choices)
162
+
163
+ ```html
164
+ <div class="options">
165
+ <div class="option" data-choice="a" onclick="toggleSelect(this)">
166
+ <div class="letter">A</div>
167
+ <div class="content">
168
+ <h3>Title</h3>
169
+ <p>Description</p>
170
+ </div>
171
+ </div>
172
+ </div>
173
+ ```
174
+
175
+ **Multi-select:** Add `data-multiselect` to the container to let users select multiple options. Each click toggles the item. The indicator bar shows the count.
176
+
177
+ ```html
178
+ <div class="options" data-multiselect>
179
+ <!-- same option markup — users can select/deselect multiple -->
180
+ </div>
181
+ ```
182
+
183
+ ### Cards (visual designs)
184
+
185
+ ```html
186
+ <div class="cards">
187
+ <div class="card" data-choice="design1" onclick="toggleSelect(this)">
188
+ <div class="card-image"><!-- mockup content --></div>
189
+ <div class="card-body">
190
+ <h3>Name</h3>
191
+ <p>Description</p>
192
+ </div>
193
+ </div>
194
+ </div>
195
+ ```
196
+
197
+ ### Mockup container
198
+
199
+ ```html
200
+ <div class="mockup">
201
+ <div class="mockup-header">Preview: Dashboard Layout</div>
202
+ <div class="mockup-body"><!-- your mockup HTML --></div>
203
+ </div>
204
+ ```
205
+
206
+ ### Split view (side-by-side)
207
+
208
+ ```html
209
+ <div class="split">
210
+ <div class="mockup"><!-- left --></div>
211
+ <div class="mockup"><!-- right --></div>
212
+ </div>
213
+ ```
214
+
215
+ ### Pros/Cons
216
+
217
+ ```html
218
+ <div class="pros-cons">
219
+ <div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>
220
+ <div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>
221
+ </div>
222
+ ```
223
+
224
+ ### Mock elements (wireframe building blocks)
225
+
226
+ ```html
227
+ <div class="mock-nav">Logo | Home | About | Contact</div>
228
+ <div style="display: flex;">
229
+ <div class="mock-sidebar">Navigation</div>
230
+ <div class="mock-content">Main content area</div>
231
+ </div>
232
+ <button class="mock-button">Action Button</button>
233
+ <input class="mock-input" placeholder="Input field">
234
+ <div class="placeholder">Placeholder area</div>
235
+ ```
236
+
237
+ ### Typography and sections
238
+
239
+ - `h2` — page title
240
+ - `h3` — section heading
241
+ - `.subtitle` — secondary text below title
242
+ - `.section` — content block with bottom margin
243
+ - `.label` — small uppercase label text
244
+
245
+ ## Browser Events Format
246
+
247
+ When the user clicks options in the browser, their interactions are recorded to `$SCREEN_DIR/.events` (one JSON object per line). The file is cleared automatically when you push a new screen.
248
+
249
+ ```jsonl
250
+ {"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}
251
+ {"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}
252
+ {"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}
253
+ ```
254
+
255
+ 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.
256
+
257
+ If `.events` doesn't exist, the user didn't interact with the browser — use only their terminal text.
258
+
259
+ ## Design Tips
260
+
261
+ - **Scale fidelity to the question** — wireframes for layout, polish for polish questions
262
+ - **Explain the question on each page** — "Which layout feels more professional?" not just "Pick one"
263
+ - **Iterate before advancing** — if feedback changes current screen, write a new version
264
+ - **2-4 options max** per screen
265
+ - **Use real content when it matters** — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.
266
+ - **Keep mockups simple** — focus on layout and structure, not pixel-perfect design
267
+
268
+ ## File Naming
269
+
270
+ - Use semantic names: `platform.html`, `visual-style.html`, `layout.html`
271
+ - Never reuse filenames — each screen must be a new file
272
+ - For iterations: append version suffix like `layout-v2.html`, `layout-v3.html`
273
+ - Server serves newest file by modification time
274
+
275
+ ## Cleaning Up
276
+
277
+ ```bash
278
+ scripts/stop-server.sh $SCREEN_DIR
279
+ ```
280
+
281
+ If the session used `--project-dir`, mockup files persist in `.superpowers/brainstorm/` for later reference. Only `/tmp` sessions get deleted on stop.
282
+
283
+ ## Reference
284
+
285
+ - Frame template (CSS reference): `scripts/frame-template.html`
286
+ - Helper script (client-side): `scripts/helper.js`