@liangjie559567/ultrapower 5.1.0 → 5.2.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.
Files changed (78) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/__tests__/skills.test.js +3 -2
  3. package/dist/__tests__/skills.test.js.map +1 -1
  4. package/dist/hooks/nexus/__tests__/config.test.d.ts +2 -0
  5. package/dist/hooks/nexus/__tests__/config.test.d.ts.map +1 -0
  6. package/dist/hooks/nexus/__tests__/config.test.js +38 -0
  7. package/dist/hooks/nexus/__tests__/config.test.js.map +1 -0
  8. package/dist/hooks/nexus/__tests__/consciousness-sync.test.d.ts +2 -0
  9. package/dist/hooks/nexus/__tests__/consciousness-sync.test.d.ts.map +1 -0
  10. package/dist/hooks/nexus/__tests__/consciousness-sync.test.js +28 -0
  11. package/dist/hooks/nexus/__tests__/consciousness-sync.test.js.map +1 -0
  12. package/dist/hooks/nexus/__tests__/data-collector.test.d.ts +2 -0
  13. package/dist/hooks/nexus/__tests__/data-collector.test.d.ts.map +1 -0
  14. package/dist/hooks/nexus/__tests__/data-collector.test.js +61 -0
  15. package/dist/hooks/nexus/__tests__/data-collector.test.js.map +1 -0
  16. package/dist/hooks/nexus/__tests__/improvement-puller.test.d.ts +2 -0
  17. package/dist/hooks/nexus/__tests__/improvement-puller.test.d.ts.map +1 -0
  18. package/dist/hooks/nexus/__tests__/improvement-puller.test.js +49 -0
  19. package/dist/hooks/nexus/__tests__/improvement-puller.test.js.map +1 -0
  20. package/dist/hooks/nexus/__tests__/session-end-hook.test.d.ts +2 -0
  21. package/dist/hooks/nexus/__tests__/session-end-hook.test.d.ts.map +1 -0
  22. package/dist/hooks/nexus/__tests__/session-end-hook.test.js +39 -0
  23. package/dist/hooks/nexus/__tests__/session-end-hook.test.js.map +1 -0
  24. package/dist/hooks/nexus/config.d.ts +5 -0
  25. package/dist/hooks/nexus/config.d.ts.map +1 -0
  26. package/dist/hooks/nexus/config.js +35 -0
  27. package/dist/hooks/nexus/config.js.map +1 -0
  28. package/dist/hooks/nexus/consciousness-sync.d.ts +8 -0
  29. package/dist/hooks/nexus/consciousness-sync.d.ts.map +1 -0
  30. package/dist/hooks/nexus/consciousness-sync.js +57 -0
  31. package/dist/hooks/nexus/consciousness-sync.js.map +1 -0
  32. package/dist/hooks/nexus/data-collector.d.ts +4 -0
  33. package/dist/hooks/nexus/data-collector.d.ts.map +1 -0
  34. package/dist/hooks/nexus/data-collector.js +23 -0
  35. package/dist/hooks/nexus/data-collector.js.map +1 -0
  36. package/dist/hooks/nexus/improvement-puller.d.ts +9 -0
  37. package/dist/hooks/nexus/improvement-puller.d.ts.map +1 -0
  38. package/dist/hooks/nexus/improvement-puller.js +42 -0
  39. package/dist/hooks/nexus/improvement-puller.js.map +1 -0
  40. package/dist/hooks/nexus/session-end-hook.d.ts +16 -0
  41. package/dist/hooks/nexus/session-end-hook.d.ts.map +1 -0
  42. package/dist/hooks/nexus/session-end-hook.js +49 -0
  43. package/dist/hooks/nexus/session-end-hook.js.map +1 -0
  44. package/dist/hooks/nexus/types.d.ts +54 -0
  45. package/dist/hooks/nexus/types.d.ts.map +1 -0
  46. package/dist/hooks/nexus/types.js +2 -0
  47. package/dist/hooks/nexus/types.js.map +1 -0
  48. package/dist/hooks/session-end/__tests__/nexus-integration.test.d.ts +2 -0
  49. package/dist/hooks/session-end/__tests__/nexus-integration.test.d.ts.map +1 -0
  50. package/dist/hooks/session-end/__tests__/nexus-integration.test.js +30 -0
  51. package/dist/hooks/session-end/__tests__/nexus-integration.test.js.map +1 -0
  52. package/dist/hooks/session-end/index.d.ts.map +1 -1
  53. package/dist/hooks/session-end/index.js +15 -0
  54. package/dist/hooks/session-end/index.js.map +1 -1
  55. package/docs/CLAUDE.md +1 -1
  56. package/docs/README.codex.md +6 -0
  57. package/docs/plans/2026-01-17-visual-brainstorming.md +571 -0
  58. package/docs/plans/2026-02-26-nexus-design.md +354 -0
  59. package/docs/plans/2026-02-26-nexus-implementation-plan.md +2538 -0
  60. package/docs/plans/2026-02-26-phase2-active-learning-design.md +377 -0
  61. package/docs/standards/contribution-guide.md +52 -1
  62. package/docs/superpowers/plans/2026-01-22-document-review-system.md +301 -0
  63. package/docs/superpowers/plans/2026-02-19-visual-brainstorming-refactor.md +523 -0
  64. package/docs/superpowers/specs/2026-01-22-document-review-system-design.md +136 -0
  65. package/docs/superpowers/specs/2026-02-19-visual-brainstorming-refactor-design.md +162 -0
  66. package/hooks/run-hook.cmd +32 -29
  67. package/package.json +4 -2
  68. package/skills/brainstorming/spec-document-reviewer-prompt.md +50 -0
  69. package/skills/brainstorming/visual-companion.md +249 -0
  70. package/skills/nexus/SKILL.md +35 -0
  71. package/skills/nexus/nexus-evolve/SKILL.md +31 -0
  72. package/skills/nexus/nexus-review/SKILL.md +39 -0
  73. package/skills/nexus/nexus-status/SKILL.md +31 -0
  74. package/skills/release/SKILL.md +3 -0
  75. package/skills/requesting-code-review/SKILL.md +1 -1
  76. package/skills/using-superpowers/references/codex-tools.md +25 -0
  77. package/skills/writing-plans/plan-document-reviewer-prompt.md +52 -0
  78. /package/hooks/{session-start.sh → session-start} +0 -0
@@ -0,0 +1,162 @@
1
+ # Visual Brainstorming Refactor: Browser Displays, Terminal Commands
2
+
3
+ **Date:** 2026-02-19
4
+ **Status:** Approved
5
+ **Scope:** `lib/brainstorm-server/`, `skills/brainstorming/visual-companion.md`, `tests/brainstorm-server/`
6
+
7
+ ## Problem
8
+
9
+ During visual brainstorming, Claude runs `wait-for-feedback.sh` as a background task and blocks on `TaskOutput(block=true, timeout=600s)`. This seizes the TUI entirely — the user cannot type to Claude while visual brainstorming is running. The browser becomes the only input channel.
10
+
11
+ Claude Code's execution model is turn-based. There is no way for Claude to listen on two channels simultaneously within a single turn. The blocking `TaskOutput` pattern was the wrong primitive — it simulates event-driven behavior the platform doesn't support.
12
+
13
+ ## Design
14
+
15
+ ### Core Model
16
+
17
+ **Browser = interactive display.** Shows mockups, lets the user click to select options. Selections are recorded server-side.
18
+
19
+ **Terminal = conversation channel.** Always unblocked, always available. The user talks to Claude here.
20
+
21
+ ### The Loop
22
+
23
+ 1. Claude writes an HTML file to the session directory
24
+ 2. Server detects it via chokidar, pushes WebSocket reload to the browser (unchanged)
25
+ 3. Claude ends its turn — tells the user to check the browser and respond in the terminal
26
+ 4. User looks at browser, optionally clicks to select an option, then types feedback in the terminal
27
+ 5. On the next turn, Claude reads `$SCREEN_DIR/.events` for the browser interaction stream (clicks, selections), merges with the terminal text
28
+ 6. Iterate or advance
29
+
30
+ No background tasks. No `TaskOutput` blocking. No polling scripts.
31
+
32
+ ### Key Deletion: `wait-for-feedback.sh`
33
+
34
+ Deleted entirely. Its purpose was to bridge "server logs events to stdout" and "Claude needs to receive those events." The `.events` file replaces this — the server writes user interaction events directly, and Claude reads them with whatever file-reading mechanism the platform provides.
35
+
36
+ ### Key Addition: `.events` File (Per-Screen Event Stream)
37
+
38
+ The server writes all user interaction events to `$SCREEN_DIR/.events`, one JSON object per line. This gives Claude the full interaction stream for the current screen — not just the final selection, but the user's exploration path (clicked A, then B, settled on C).
39
+
40
+ Example contents after a user explores options:
41
+
42
+ ```jsonl
43
+ {"type":"click","choice":"a","text":"Option A - Preset-First Wizard","timestamp":1706000101}
44
+ {"type":"click","choice":"c","text":"Option C - Manual Config","timestamp":1706000108}
45
+ {"type":"click","choice":"b","text":"Option B - Hybrid Approach","timestamp":1706000115}
46
+ ```
47
+
48
+ - Append-only within a screen. Each user event is appended as a new line.
49
+ - The file is cleared (deleted) when chokidar detects a new HTML file (new screen pushed), preventing stale events from carrying over.
50
+ - If the file doesn't exist when Claude reads it, no browser interaction occurred — Claude uses only the terminal text.
51
+ - The file contains only user events (`click`, etc.) — not server lifecycle events (`server-started`, `screen-added`). This keeps it small and focused.
52
+ - Claude can read the full stream to understand the user's exploration pattern, or just look at the last `choice` event for the final selection.
53
+
54
+ ## Changes by File
55
+
56
+ ### `index.js` (server)
57
+
58
+ **A. Write user events to `.events` file.**
59
+
60
+ In the WebSocket `message` handler, after logging the event to stdout: append the event as a JSON line to `$SCREEN_DIR/.events` via `fs.appendFileSync`. Only write user interaction events (those with `source: 'user-event'`), not server lifecycle events.
61
+
62
+ **B. Clear `.events` on new screen.**
63
+
64
+ In the chokidar `add` handler (new `.html` file detected), delete `$SCREEN_DIR/.events` if it exists. This is the definitive "new screen" signal — better than clearing on GET `/` which fires on every reload.
65
+
66
+ **C. Replace `wrapInFrame` content injection.**
67
+
68
+ The current regex anchors on `<div class="feedback-footer">`, which is being removed. Replace with a comment placeholder: remove the existing default content inside `#claude-content` (the `<h2>Visual Brainstorming</h2>` and subtitle paragraph) and replace with a single `<!-- CONTENT -->` marker. Content injection becomes `frameTemplate.replace('<!-- CONTENT -->', content)`. Simpler and won't break if template formatting changes.
69
+
70
+ ### `frame-template.html` (UI frame)
71
+
72
+ **Remove:**
73
+ - The `feedback-footer` div (textarea, Send button, label, `.feedback-row`)
74
+ - Associated CSS (`.feedback-footer`, `.feedback-footer label`, `.feedback-row`, textarea and button styles within it)
75
+
76
+ **Add:**
77
+ - `<!-- CONTENT -->` placeholder inside `#claude-content`, replacing the default text
78
+ - A selection indicator bar where the footer was, with two states:
79
+ - Default: "Click an option above, then return to the terminal"
80
+ - After selection: "Option B selected — return to terminal to continue"
81
+ - CSS for the indicator bar (subtle, similar visual weight to the existing header)
82
+
83
+ **Keep unchanged:**
84
+ - Header bar with "Brainstorm Companion" title and connection status
85
+ - `.main` wrapper and `#claude-content` container
86
+ - All component CSS (`.options`, `.cards`, `.mockup`, `.split`, `.pros-cons`, placeholders, mock elements)
87
+ - Dark/light theme variables and media query
88
+
89
+ ### `helper.js` (client-side script)
90
+
91
+ **Remove:**
92
+ - `sendToClaude()` function and the "Sent to Claude" page takeover
93
+ - `window.send()` function (was tied to the removed Send button)
94
+ - Form submission handler — no purpose without the feedback textarea, adds log noise
95
+ - Input change handler — same reason
96
+ - `pageshow` event listener (was added to fix textarea persistence — no textarea anymore)
97
+
98
+ **Keep:**
99
+ - WebSocket connection, reconnect logic, event queue
100
+ - Reload handler (`window.location.reload()` on server push)
101
+ - `window.toggleSelect()` for selection highlighting
102
+ - `window.selectedChoice` tracking
103
+ - `window.brainstorm.send()` and `window.brainstorm.choice()` — these are distinct from the removed `window.send()`. They call `sendEvent` which logs to the server via WebSocket. Useful for custom full-document pages.
104
+
105
+ **Narrow:**
106
+ - Click handler: capture only `[data-choice]` clicks, not all buttons/links. The broad capture was needed when the browser was a feedback channel; now it's just for selection tracking.
107
+
108
+ **Add:**
109
+ - On `data-choice` click, update the selection indicator bar text to show which option was selected.
110
+
111
+ **Remove from `window.brainstorm` API:**
112
+ - `brainstorm.sendToClaude` — no longer exists
113
+
114
+ ### `visual-companion.md` (skill instructions)
115
+
116
+ **Rewrite "The Loop" section** to the non-blocking flow described above. Remove all references to:
117
+ - `wait-for-feedback.sh`
118
+ - `TaskOutput` blocking
119
+ - Timeout/retry logic (600s timeout, 30-minute cap)
120
+ - "User Feedback Format" section describing `send-to-claude` JSON
121
+
122
+ **Replace with:**
123
+ - The new loop (write HTML → end turn → user responds in terminal → read `.events` → iterate)
124
+ - `.events` file format documentation
125
+ - Guidance that the terminal message is the primary feedback; `.events` provides the full browser interaction stream for additional context
126
+
127
+ **Keep:**
128
+ - Server startup/shutdown instructions
129
+ - Content fragment vs full document guidance
130
+ - CSS class reference and available components
131
+ - Design tips (scale fidelity to the question, 2-4 options per screen, etc.)
132
+
133
+ ### `wait-for-feedback.sh`
134
+
135
+ **Deleted entirely.**
136
+
137
+ ### `tests/brainstorm-server/server.test.js`
138
+
139
+ Tests that need updating:
140
+ - Test asserting `feedback-footer` presence in fragment responses — update to assert the selection indicator bar or `<!-- CONTENT -->` replacement
141
+ - Test asserting `helper.js` contains `send` — update to reflect narrowed API
142
+ - Test asserting `sendToClaude` CSS variable usage — remove (function no longer exists)
143
+
144
+ ## Platform Compatibility
145
+
146
+ The server code (`index.js`, `helper.js`, `frame-template.html`) is fully platform-agnostic — pure Node.js and browser JavaScript. No Claude Code-specific references. Already proven to work on Codex via background terminal interaction.
147
+
148
+ The skill instructions (`visual-companion.md`) are the platform-adaptive layer. Each platform's Claude uses its own tools to start the server, read `.events`, etc. The non-blocking model works naturally across platforms since it doesn't depend on any platform-specific blocking primitive.
149
+
150
+ ## What This Enables
151
+
152
+ - **TUI always responsive** during visual brainstorming
153
+ - **Mixed input** — click in browser + type in terminal, naturally merged
154
+ - **Graceful degradation** — browser down or user doesn't open it? Terminal still works
155
+ - **Simpler architecture** — no background tasks, no polling scripts, no timeout management
156
+ - **Cross-platform** — same server code works on Claude Code, Codex, and any future platform
157
+
158
+ ## What This Drops
159
+
160
+ - **Pure-browser feedback workflow** — user must return to the terminal to continue. The selection indicator bar guides them, but it's one extra step compared to the old click-Send-and-wait flow.
161
+ - **Inline text feedback from browser** — the textarea is gone. All text feedback goes through the terminal. This is intentional — the terminal is a better text input channel than a small textarea in a frame.
162
+ - **Immediate response on browser Send** — the old system had Claude respond the moment the user clicked Send. Now there's a gap while the user switches to the terminal. In practice this is seconds, and the user gets to add context in their terminal message.
@@ -1,43 +1,46 @@
1
1
  : << 'CMDBLOCK'
2
2
  @echo off
3
- REM ============================================================================
4
- REM DEPRECATED: This polyglot wrapper is no longer used as of Claude Code 2.1.x
5
- REM ============================================================================
3
+ REM Cross-platform polyglot wrapper for hook scripts.
4
+ REM On Windows: cmd.exe runs the batch portion, which finds and calls bash.
5
+ REM On Unix: the shell interprets this as a script (: is a no-op in bash).
6
6
  REM
7
- REM Claude Code 2.1.x changed the Windows execution model for hooks:
7
+ REM Hook scripts use extensionless filenames (e.g. "session-start" not
8
+ REM "session-start.sh") so Claude Code's Windows auto-detection -- which
9
+ REM prepends "bash" to any command containing .sh -- doesn't interfere.
8
10
  REM
9
- REM Before (2.0.x): Hooks ran with shell:true, using the system default shell.
10
- REM This wrapper provided cross-platform compatibility by
11
- REM being both a valid .cmd file (Windows) and bash script.
12
- REM
13
- REM After (2.1.x): Claude Code now auto-detects .sh files in hook commands
14
- REM and prepends "bash " on Windows. This broke the wrapper
15
- REM because the command:
16
- REM "run-hook.cmd" session-start.sh
17
- REM became:
18
- REM bash "run-hook.cmd" session-start.sh
19
- REM ...and bash cannot execute a .cmd file.
20
- REM
21
- REM The fix: hooks.json now calls session-start.sh directly. Claude Code 2.1.x
22
- REM handles the bash invocation automatically on Windows.
23
- REM
24
- REM This file is kept for reference and potential backward compatibility.
25
- REM ============================================================================
26
- REM
27
- REM Original purpose: Polyglot wrapper to run .sh scripts cross-platform
28
11
  REM Usage: run-hook.cmd <script-name> [args...]
29
- REM The script should be in the same directory as this wrapper
30
12
 
31
13
  if "%~1"=="" (
32
14
  echo run-hook.cmd: missing script name >&2
33
15
  exit /b 1
34
16
  )
35
- "C:\Program Files\Git\bin\bash.exe" -l "%~dp0%~1" %2 %3 %4 %5 %6 %7 %8 %9
36
- exit /b
17
+
18
+ set "HOOK_DIR=%~dp0"
19
+
20
+ REM Try Git for Windows bash in standard locations
21
+ if exist "C:\Program Files\Git\bin\bash.exe" (
22
+ "C:\Program Files\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
23
+ exit /b %ERRORLEVEL%
24
+ )
25
+ if exist "C:\Program Files (x86)\Git\bin\bash.exe" (
26
+ "C:\Program Files (x86)\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
27
+ exit /b %ERRORLEVEL%
28
+ )
29
+
30
+ REM Try bash on PATH (e.g. user-installed Git Bash, MSYS2, Cygwin)
31
+ where bash >nul 2>nul
32
+ if %ERRORLEVEL% equ 0 (
33
+ bash "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
34
+ exit /b %ERRORLEVEL%
35
+ )
36
+
37
+ REM No bash found - exit silently rather than error
38
+ REM (plugin still works, just without SessionStart context injection)
39
+ exit /b 0
37
40
  CMDBLOCK
38
41
 
39
- # Unix shell runs from here
40
- SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
42
+ # Unix: run the named script directly
43
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
41
44
  SCRIPT_NAME="$1"
42
45
  shift
43
- "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@"
46
+ exec bash "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liangjie559567/ultrapower",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "Disciplined multi-agent orchestration: workflow enforcement + parallel execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -76,6 +76,7 @@
76
76
  "devDependencies": {
77
77
  "@eslint/js": "^9.39.2",
78
78
  "@types/node": "^22.19.7",
79
+ "@types/ws": "^8.18.1",
79
80
  "@typescript-eslint/eslint-plugin": "^8.18.2",
80
81
  "@typescript-eslint/parser": "^8.18.2",
81
82
  "@vitest/ui": "^4.0.17",
@@ -85,7 +86,8 @@
85
86
  "tsx": "^4.19.2",
86
87
  "typescript": "^5.7.2",
87
88
  "typescript-eslint": "^8.53.0",
88
- "vitest": "^4.0.17"
89
+ "vitest": "^4.0.17",
90
+ "ws": "^8.19.0"
89
91
  },
90
92
  "engines": {
91
93
  "node": ">=20.0.0"
@@ -0,0 +1,50 @@
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
+ | Coverage | Missing error handling, edge cases, integration points |
23
+ | Consistency | Internal contradictions, conflicting requirements |
24
+ | Clarity | Ambiguous requirements |
25
+ | YAGNI | Unrequested features, over-engineering |
26
+ | Scope | Focused enough for a single plan — not covering multiple independent subsystems |
27
+ | Architecture | Units with clear boundaries, well-defined interfaces, independently understandable and testable |
28
+
29
+ ## CRITICAL
30
+
31
+ Look especially hard for:
32
+ - Any TODO markers or placeholder text
33
+ - Sections saying "to be defined later" or "will spec when X is done"
34
+ - Sections noticeably less detailed than others
35
+ - Units that lack clear boundaries or interfaces — can you understand what each unit does without reading its internals?
36
+
37
+ ## Output Format
38
+
39
+ ## Spec Review
40
+
41
+ **Status:** ✅ Approved | ❌ Issues Found
42
+
43
+ **Issues (if any):**
44
+ - [Section X]: [specific issue] - [why it matters]
45
+
46
+ **Recommendations (advisory):**
47
+ - [suggestions that don't block approval]
48
+ ```
49
+
50
+ **Reviewer returns:** Status, Issues (if any), Recommendations
@@ -0,0 +1,249 @@
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
+ ${CLAUDE_PLUGIN_ROOT}/lib/brainstorm-server/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
+ **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.
46
+
47
+ **Codex behavior:** In Codex (`CODEX_CI=1`), `start-server.sh` auto-switches to foreground mode by default because background jobs may be reaped. Use `--background` only if your environment reliably preserves detached processes.
48
+
49
+ **If background processes are reaped in your environment:** run in foreground from a persistent terminal session:
50
+
51
+ ```bash
52
+ ${CLAUDE_PLUGIN_ROOT}/lib/brainstorm-server/start-server.sh --project-dir /path/to/project --foreground
53
+ ```
54
+
55
+ In `--foreground` mode, the command stays attached and serves until interrupted.
56
+
57
+ If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:
58
+
59
+ ```bash
60
+ ${CLAUDE_PLUGIN_ROOT}/lib/brainstorm-server/start-server.sh \
61
+ --project-dir /path/to/project \
62
+ --host 0.0.0.0 \
63
+ --url-host localhost
64
+ ```
65
+
66
+ Use `--url-host` to control what hostname is printed in the returned URL JSON.
67
+
68
+ ## The Loop
69
+
70
+ 1. **Write HTML** to a new file in `screen_dir`:
71
+ - Use semantic filenames: `platform.html`, `visual-style.html`, `layout.html`
72
+ - **Never reuse filenames** — each screen gets a fresh file
73
+ - Use Write tool — **never use cat/heredoc** (dumps noise into terminal)
74
+ - Server automatically serves the newest file
75
+
76
+ 2. **Tell user what to expect and end your turn:**
77
+ - Remind them of the URL (every step, not just first)
78
+ - Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")
79
+ - 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."
80
+
81
+ 3. **On your next turn** — after the user responds in the terminal:
82
+ - Read `$SCREEN_DIR/.events` if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines
83
+ - Merge with the user's terminal text to get the full picture
84
+ - The terminal message is the primary feedback; `.events` provides structured interaction data
85
+
86
+ 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.
87
+
88
+ 5. Repeat until done.
89
+
90
+ ## Writing Content Fragments
91
+
92
+ 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).
93
+
94
+ **Minimal example:**
95
+
96
+ ```html
97
+ <h2>Which layout works better?</h2>
98
+ <p class="subtitle">Consider readability and visual hierarchy</p>
99
+
100
+ <div class="options">
101
+ <div class="option" data-choice="a" onclick="toggleSelect(this)">
102
+ <div class="letter">A</div>
103
+ <div class="content">
104
+ <h3>Single Column</h3>
105
+ <p>Clean, focused reading experience</p>
106
+ </div>
107
+ </div>
108
+ <div class="option" data-choice="b" onclick="toggleSelect(this)">
109
+ <div class="letter">B</div>
110
+ <div class="content">
111
+ <h3>Two Column</h3>
112
+ <p>Sidebar navigation with main content</p>
113
+ </div>
114
+ </div>
115
+ </div>
116
+ ```
117
+
118
+ That's it. No `<html>`, no CSS, no `<script>` tags needed. The server provides all of that.
119
+
120
+ ## CSS Classes Available
121
+
122
+ The frame template provides these CSS classes for your content:
123
+
124
+ ### Options (A/B/C choices)
125
+
126
+ ```html
127
+ <div class="options">
128
+ <div class="option" data-choice="a" onclick="toggleSelect(this)">
129
+ <div class="letter">A</div>
130
+ <div class="content">
131
+ <h3>Title</h3>
132
+ <p>Description</p>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ ```
137
+
138
+ **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.
139
+
140
+ ```html
141
+ <div class="options" data-multiselect>
142
+ <!-- same option markup — users can select/deselect multiple -->
143
+ </div>
144
+ ```
145
+
146
+ ### Cards (visual designs)
147
+
148
+ ```html
149
+ <div class="cards">
150
+ <div class="card" data-choice="design1" onclick="toggleSelect(this)">
151
+ <div class="card-image"><!-- mockup content --></div>
152
+ <div class="card-body">
153
+ <h3>Name</h3>
154
+ <p>Description</p>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ ```
159
+
160
+ ### Mockup container
161
+
162
+ ```html
163
+ <div class="mockup">
164
+ <div class="mockup-header">Preview: Dashboard Layout</div>
165
+ <div class="mockup-body"><!-- your mockup HTML --></div>
166
+ </div>
167
+ ```
168
+
169
+ ### Split view (side-by-side)
170
+
171
+ ```html
172
+ <div class="split">
173
+ <div class="mockup"><!-- left --></div>
174
+ <div class="mockup"><!-- right --></div>
175
+ </div>
176
+ ```
177
+
178
+ ### Pros/Cons
179
+
180
+ ```html
181
+ <div class="pros-cons">
182
+ <div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>
183
+ <div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>
184
+ </div>
185
+ ```
186
+
187
+ ### Mock elements (wireframe building blocks)
188
+
189
+ ```html
190
+ <div class="mock-nav">Logo | Home | About | Contact</div>
191
+ <div style="display: flex;">
192
+ <div class="mock-sidebar">Navigation</div>
193
+ <div class="mock-content">Main content area</div>
194
+ </div>
195
+ <button class="mock-button">Action Button</button>
196
+ <input class="mock-input" placeholder="Input field">
197
+ <div class="placeholder">Placeholder area</div>
198
+ ```
199
+
200
+ ### Typography and sections
201
+
202
+ - `h2` — page title
203
+ - `h3` — section heading
204
+ - `.subtitle` — secondary text below title
205
+ - `.section` — content block with bottom margin
206
+ - `.label` — small uppercase label text
207
+
208
+ ## Browser Events Format
209
+
210
+ 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.
211
+
212
+ ```jsonl
213
+ {"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}
214
+ {"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}
215
+ {"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}
216
+ ```
217
+
218
+ 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.
219
+
220
+ If `.events` doesn't exist, the user didn't interact with the browser — use only their terminal text.
221
+
222
+ ## Design Tips
223
+
224
+ - **Scale fidelity to the question** — wireframes for layout, polish for polish questions
225
+ - **Explain the question on each page** — "Which layout feels more professional?" not just "Pick one"
226
+ - **Iterate before advancing** — if feedback changes current screen, write a new version
227
+ - **2-4 options max** per screen
228
+ - **Use real content when it matters** — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.
229
+ - **Keep mockups simple** — focus on layout and structure, not pixel-perfect design
230
+
231
+ ## File Naming
232
+
233
+ - Use semantic names: `platform.html`, `visual-style.html`, `layout.html`
234
+ - Never reuse filenames — each screen must be a new file
235
+ - For iterations: append version suffix like `layout-v2.html`, `layout-v3.html`
236
+ - Server serves newest file by modification time
237
+
238
+ ## Cleaning Up
239
+
240
+ ```bash
241
+ ${CLAUDE_PLUGIN_ROOT}/lib/brainstorm-server/stop-server.sh $SCREEN_DIR
242
+ ```
243
+
244
+ If the session used `--project-dir`, mockup files persist in `.superpowers/brainstorm/` for later reference. Only `/tmp` sessions get deleted on stop.
245
+
246
+ ## Reference
247
+
248
+ - Frame template (CSS reference): `${CLAUDE_PLUGIN_ROOT}/lib/brainstorm-server/frame-template.html`
249
+ - Helper script (client-side): `${CLAUDE_PLUGIN_ROOT}/lib/brainstorm-server/helper.js`
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: nexus
3
+ description: nexus 自我改进系统 - 管理 nexus 子命令的入口
4
+ triggers:
5
+ - nexus
6
+ - nexus help
7
+ ---
8
+
9
+ # nexus
10
+
11
+ nexus 是 ultrapower 的自我改进系统,通过收集会话数据并在 VPS 端运行进化引擎来持续优化 agent 行为。
12
+
13
+ ## 子命令
14
+
15
+ | 命令 | 用途 |
16
+ |------|------|
17
+ | `/nexus-status` | 查看 nexus 系统状态 |
18
+ | `/nexus-evolve` | 手动触发进化引擎 |
19
+ | `/nexus-review` | 审批待处理的改进建议 |
20
+
21
+ ## 快速开始
22
+
23
+ 1. 配置 nexus:编辑 `.omc/nexus/config.json`,设置 `enabled: true` 和 `gitRemote`
24
+ 2. 查看状态:`/nexus-status`
25
+ 3. 触发进化:`/nexus-evolve`
26
+ 4. 审批改进:`/nexus-review`
27
+
28
+ ## 架构
29
+
30
+ nexus 由以下组件组成:
31
+
32
+ - **data-collector hook**:在每次会话结束时收集工具使用数据
33
+ - **consciousness-sync hook**:将事件推送到 nexus-daemon 仓库
34
+ - **improvement-puller hook**:拉取 VPS 端生成的改进建议
35
+ - **nexus-daemon**(VPS 端):Python 守护进程,分析数据并生成优化建议
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: nexus-evolve
3
+ description: 手动触发 nexus 进化引擎
4
+ triggers:
5
+ - nexus evolve
6
+ - nexus-evolve
7
+ - trigger evolution
8
+ ---
9
+
10
+ # nexus Evolve
11
+
12
+ 手动触发 nexus 进化引擎,立即处理积累的会话数据。
13
+
14
+ ## 执行步骤
15
+
16
+ 1. 检查 `.omc/nexus/events/` 是否有未处理事件。如果没有未处理事件,显示 'No pending events to push.' 并退出。
17
+ 2. 执行 `git push nexus-daemon HEAD:main` 将事件推送到 nexus-daemon 仓库(远端 `nexus-daemon` 必须在 `.omc/nexus/config.json` 的 `gitRemote` 字段中配置)。
18
+ 3. 提示用户:进化引擎将在 VPS 端处理这些事件
19
+ 4. 等待约 2 分钟后,执行 `git pull nexus-daemon main` 拉取改进建议。如果 pull 失败或超时,显示警告:'VPS may be unavailable. Run /nexus-status to check.'
20
+ 5. 如果有新的 `.omc/nexus/improvements/` 文件,显示摘要
21
+
22
+ ## 输出格式
23
+
24
+ ```
25
+ nexus Evolve triggered
26
+ ======================
27
+ Events pushed: N
28
+ Waiting for VPS processing...
29
+ Improvements received: N
30
+ Run /nexus-review to review pending improvements.
31
+ ```
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: nexus-review
3
+ description: 查看并审批 nexus 生成的改进建议
4
+ triggers:
5
+ - nexus review
6
+ - nexus-review
7
+ - review improvements
8
+ ---
9
+
10
+ # nexus Review
11
+
12
+ 查看 nexus 系统生成的待审批改进建议。
13
+
14
+ ## 执行步骤
15
+
16
+ 改进文件为 JSON 格式,包含以下字段:id、type、targetFile、confidence、newContent、reason、status。
17
+
18
+ 1. 读取 `.omc/nexus/improvements/` 下所有 `status === "pending"` 的文件
19
+ 2. 按置信度降序排列
20
+ 3. 对每个改进建议显示:
21
+ - ID、类型、目标文件
22
+ - 置信度(≥80 标记为 AUTO-APPLY)
23
+ - 原因和证据摘要
24
+ - diff 内容
25
+
26
+ 4. 询问用户对每个建议的操作:
27
+ - `apply`:将改进 JSON 中的 `newContent` 字段内容写入 `targetFile` 路径。然后将该改进 JSON 文件中的 `status` 更新为 `applied`。
28
+ - `skip`:跳过,更新 status 为 `rejected`
29
+ - `auto`:在批量应用前,显示所有置信度 ≥80 的改进列表,并询问:'Apply all N improvements with confidence ≥80? (yes/no)'。用户确认后,对每个改进执行与 `apply` 相同的操作。
30
+
31
+ ## 输出格式
32
+
33
+ ```
34
+ nexus Improvements (N pending)
35
+ ==============================
36
+ [1] skill_update | skills/learner/SKILL.md | confidence: 87 [AUTO-APPLY]
37
+ Reason: 触发词 'learn' 在过去 10 次会话中出现 23 次但未触发
38
+ Action? (apply/skip/auto):
39
+ ```