@shirlytaylor73/superharness 1.5.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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +202 -0
  3. package/bin/lib/codex-installer.js +228 -0
  4. package/bin/lib/interactive-select.js +96 -0
  5. package/bin/superharness.js +67 -0
  6. package/package.json +52 -0
  7. package/plugins/superharness/.claude-plugin/plugin.json +19 -0
  8. package/plugins/superharness/.codex-plugin/plugin.json +31 -0
  9. package/plugins/superharness/.mcp.json +9 -0
  10. package/plugins/superharness/CODE_OF_CONDUCT.md +79 -0
  11. package/plugins/superharness/LICENSE +21 -0
  12. package/plugins/superharness/README.md +57 -0
  13. package/plugins/superharness/agents/code-reviewer.md +48 -0
  14. package/plugins/superharness/archived-skills/using-superpowers/SKILL.md +140 -0
  15. package/plugins/superharness/archived-skills/using-superpowers/references/codex-tools.md +25 -0
  16. package/plugins/superharness/archived-skills/using-superpowers/references/copilot-tools.md +52 -0
  17. package/plugins/superharness/archived-skills/using-superpowers/references/gemini-tools.md +33 -0
  18. package/plugins/superharness/archived-skills/using-superpowers/references/hermes-tools.md +44 -0
  19. package/plugins/superharness/commands/free.md +6 -0
  20. package/plugins/superharness/commands/rollback.md +30 -0
  21. package/plugins/superharness/commands-codex/free.md +29 -0
  22. package/plugins/superharness/commands-codex/rollback.md +33 -0
  23. package/plugins/superharness/hooks/hooks-codex.json +50 -0
  24. package/plugins/superharness/hooks/hooks.json +50 -0
  25. package/plugins/superharness/hooks/lib/free-mode-check.mjs +27 -0
  26. package/plugins/superharness/hooks/run-hook.cmd +58 -0
  27. package/plugins/superharness/hooks/workflow-context +4 -0
  28. package/plugins/superharness/hooks/workflow-context.mjs +184 -0
  29. package/plugins/superharness/hooks/workflow-post-transition +4 -0
  30. package/plugins/superharness/hooks/workflow-post-transition.mjs +89 -0
  31. package/plugins/superharness/hooks/workflow-pre-tool-use +4 -0
  32. package/plugins/superharness/hooks/workflow-pre-tool-use.mjs +97 -0
  33. package/plugins/superharness/hooks/workflow-stop +4 -0
  34. package/plugins/superharness/hooks/workflow-stop.mjs +136 -0
  35. package/plugins/superharness/scripts/rollback.mjs +86 -0
  36. package/plugins/superharness/scripts/set-free-mode.mjs +77 -0
  37. package/plugins/superharness/skills/brainstorming/SKILL.md +182 -0
  38. package/plugins/superharness/skills/brainstorming/scripts/frame-template.html +214 -0
  39. package/plugins/superharness/skills/brainstorming/scripts/helper.js +88 -0
  40. package/plugins/superharness/skills/brainstorming/scripts/server.cjs +338 -0
  41. package/plugins/superharness/skills/brainstorming/scripts/start-server.sh +153 -0
  42. package/plugins/superharness/skills/brainstorming/scripts/stop-server.sh +55 -0
  43. package/plugins/superharness/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  44. package/plugins/superharness/skills/brainstorming/visual-companion.md +286 -0
  45. package/plugins/superharness/skills/chinese-code-review/SKILL.md +277 -0
  46. package/plugins/superharness/skills/chinese-commit-conventions/SKILL.md +364 -0
  47. package/plugins/superharness/skills/chinese-documentation/SKILL.md +448 -0
  48. package/plugins/superharness/skills/chinese-git-workflow/SKILL.md +547 -0
  49. package/plugins/superharness/skills/dispatching-parallel-agents/SKILL.md +186 -0
  50. package/plugins/superharness/skills/exploration/SKILL.md +197 -0
  51. package/plugins/superharness/skills/finishing/SKILL.md +200 -0
  52. package/plugins/superharness/skills/intake/SKILL.md +134 -0
  53. package/plugins/superharness/skills/mcp-builder/SKILL.md +255 -0
  54. package/plugins/superharness/skills/parallel-execution/SKILL.md +368 -0
  55. package/plugins/superharness/skills/parallel-execution/implementer-prompt.md +144 -0
  56. package/plugins/superharness/skills/parallel-execution/spec-reviewer-prompt.md +84 -0
  57. package/plugins/superharness/skills/parallel-execution/wave-final-manual-qa-prompt.md +61 -0
  58. package/plugins/superharness/skills/parallel-execution/wave-final-quality-prompt.md +59 -0
  59. package/plugins/superharness/skills/parallel-execution/wave-final-scope-fidelity-prompt.md +69 -0
  60. package/plugins/superharness/skills/parallel-execution/wave-final-spec-prompt.md +56 -0
  61. package/plugins/superharness/skills/planning/SKILL.md +265 -0
  62. package/plugins/superharness/skills/planning/plan-document-reviewer-prompt.md +80 -0
  63. package/plugins/superharness/skills/receiving-code-review/SKILL.md +213 -0
  64. package/plugins/superharness/skills/requesting-code-review/SKILL.md +107 -0
  65. package/plugins/superharness/skills/requesting-code-review/code-reviewer.md +146 -0
  66. package/plugins/superharness/skills/serial-execution/SKILL.md +183 -0
  67. package/plugins/superharness/skills/systematic-debugging/CREATION-LOG.md +119 -0
  68. package/plugins/superharness/skills/systematic-debugging/SKILL.md +320 -0
  69. package/plugins/superharness/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  70. package/plugins/superharness/skills/systematic-debugging/condition-based-waiting.md +115 -0
  71. package/plugins/superharness/skills/systematic-debugging/defense-in-depth.md +122 -0
  72. package/plugins/superharness/skills/systematic-debugging/find-polluter.sh +63 -0
  73. package/plugins/superharness/skills/systematic-debugging/root-cause-tracing.md +169 -0
  74. package/plugins/superharness/skills/systematic-debugging/test-academic.md +14 -0
  75. package/plugins/superharness/skills/systematic-debugging/test-pressure-1.md +58 -0
  76. package/plugins/superharness/skills/systematic-debugging/test-pressure-2.md +68 -0
  77. package/plugins/superharness/skills/systematic-debugging/test-pressure-3.md +69 -0
  78. package/plugins/superharness/skills/test-driven-development/SKILL.md +371 -0
  79. package/plugins/superharness/skills/test-driven-development/testing-anti-patterns.md +299 -0
  80. package/plugins/superharness/skills/trivial/SKILL.md +118 -0
  81. package/plugins/superharness/skills/using-git-worktrees/SKILL.md +218 -0
  82. package/plugins/superharness/skills/verification/SKILL.md +139 -0
  83. package/plugins/superharness/skills/workflow-runner/SKILL.md +172 -0
  84. package/plugins/superharness/skills/writing-skills/SKILL.md +655 -0
  85. package/plugins/superharness/skills/writing-skills/anthropic-best-practices.md +1149 -0
  86. package/plugins/superharness/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  87. package/plugins/superharness/skills/writing-skills/graphviz-conventions.dot +172 -0
  88. package/plugins/superharness/skills/writing-skills/persuasion-principles.md +187 -0
  89. package/plugins/superharness/skills/writing-skills/render-graphs.js +168 -0
  90. package/plugins/superharness/skills/writing-skills/testing-skills-with-subagents.md +385 -0
  91. package/plugins/superharness/workflow/default-workflow.yaml +84 -0
  92. package/plugins/superharness/workflow-state-server/bootstrap.js +44 -0
  93. package/plugins/superharness/workflow-state-server/package-lock.json +2853 -0
  94. package/plugins/superharness/workflow-state-server/package.json +22 -0
  95. package/plugins/superharness/workflow-state-server/render-context.js +124 -0
  96. package/plugins/superharness/workflow-state-server/schema.sql +39 -0
  97. package/plugins/superharness/workflow-state-server/server.js +290 -0
  98. package/plugins/superharness/workflow-state-server/state.js +424 -0
  99. package/plugins/superharness/workflow-state-server/validate-workflow.js +165 -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>/.superharness/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}/.superharness/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 (.superharness/) 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
+ # 规格文档审查员提示模板
2
+
3
+ 调度规格文档审查员子代理时使用此模板。
4
+
5
+ **用途:** 验证规格是否完整、一致,并为实现计划做好准备。
6
+
7
+ **调度时机:** 规格文档写入 docs/superharness/specs/ 之后
8
+
9
+ ```
10
+ Task tool(通用):
11
+ description: "审查规格文档"
12
+ prompt: |
13
+ 你是一名规格文档审查员。验证此规格是否完整并准备好进行计划编写。
14
+
15
+ **待审查规格:** [SPEC_FILE_PATH]
16
+
17
+ ## 检查内容
18
+
19
+ | 类别 | 检查要点 |
20
+ |------|----------|
21
+ | 完整性 | TODO、占位符、"TBD"、不完整的章节 |
22
+ | 一致性 | 内部矛盾、相互冲突的需求 |
23
+ | 清晰度 | 需求模糊到可能导致构建出错误的东西 |
24
+ | 范围 | 是否足够聚焦以用于单个计划——而非涵盖多个独立子系统 |
25
+ | YAGNI | 未请求的功能、过度设计 |
26
+
27
+ ## 校准标准
28
+
29
+ **只标记会在实现计划阶段造成实际问题的事项。**
30
+ 缺失的章节、矛盾之处、或者模糊到可能被两种不同方式理解的需求——
31
+ 这些才是问题。措辞上的小改进、风格偏好、以及"某些章节不如其他章节详细"则不是。
32
+
33
+ 除非存在会导致计划出错的严重缺陷,否则应予以通过。
34
+
35
+ ## 输出格式
36
+
37
+ ## 规格审查
38
+
39
+ **状态:** 通过 | 发现问题
40
+
41
+ **问题(如有):**
42
+ - [章节 X]:[具体问题] - [为什么这对计划编写很重要]
43
+
44
+ **建议(仅供参考,不阻止通过):**
45
+ - [改进建议]
46
+ ```
47
+
48
+ **审查员返回:** 状态、问题(如有)、建议
49
+
@@ -0,0 +1,286 @@
1
+ # 视觉伴侣指南
2
+
3
+ 基于浏览器的视觉头脑风暴伴侣,用于展示原型、图表和选项。
4
+
5
+ ## 何时使用
6
+
7
+ 逐问题决定,而非按会话决定。判断标准:**用户看到它是否比读到它更容易理解?**
8
+
9
+ **使用浏览器** 当内容本身是视觉的:
10
+
11
+ - **UI 原型** — 线框图、布局、导航结构、组件设计
12
+ - **架构图** — 系统组件、数据流、关系图
13
+ - **并排视觉对比** — 对比两种布局、两种配色方案、两种设计方向
14
+ - **设计细节打磨** — 当问题涉及外观感受、间距、视觉层次
15
+ - **空间关系** — 状态机、流程图、实体关系图
16
+
17
+ **使用终端** 当内容是文字或表格的:
18
+
19
+ - **需求和范围问题** — "X 是什么意思?"、"哪些功能在范围内?"
20
+ - **概念性 A/B/C 选择** — 在用文字描述的方案之间做选择
21
+ - **权衡列表** — 优缺点、对比表
22
+ - **技术决策** — API 设计、数据建模、架构方案选择
23
+ - **澄清问题** — 任何回答是文字而非视觉偏好的问题
24
+
25
+ 关于 UI 主题的问题不一定是视觉问题。"你想要什么样的向导?"是概念性的——使用终端。"这些向导布局中哪个感觉对?"是视觉性的——使用浏览器。
26
+
27
+ ## 工作原理
28
+
29
+ 服务器监视一个目录中的 HTML 文件,将最新的文件提供给浏览器。你写入 HTML 内容,用户在浏览器中看到它,并可以点击选择选项。选择结果被记录到一个 `.events` 文件中,你在下一轮会话中读取它。
30
+
31
+ **内容片段 vs 完整文档:** 如果你的 HTML 文件以 `<!DOCTYPE` 或 `<html` 开头,服务器会原样提供(仅注入辅助脚本)。否则,服务器会自动将你的内容包裹在框架模板中——添加头部、CSS 主题、选择指示器和所有交互基础设施。**默认写内容片段即可。** 只有当你需要完全控制页面时才写完整文档。
32
+
33
+ ## 启动会话
34
+
35
+ ```bash
36
+ # 启动服务器并持久化(原型保存到项目中)
37
+ scripts/start-server.sh --project-dir /path/to/project
38
+
39
+ # 返回:{"type":"server-started","port":52341,"url":"http://localhost:52341",
40
+ # "screen_dir":"/path/to/project/.superharness/brainstorm/12345-1706000000"}
41
+ ```
42
+
43
+ 保存响应中的 `screen_dir`。告诉用户打开该 URL。
44
+
45
+ **查找连接信息:** 服务器将其启动 JSON 写入 `$SCREEN_DIR/.server-info`。如果你在后台启动了服务器且没有捕获 stdout,读取该文件以获取 URL 和端口。使用 `--project-dir` 时,检查 `<project>/.superharness/brainstorm/` 获取会话目录。
46
+
47
+ **注意:** 传入项目根目录作为 `--project-dir`,这样原型会持久化在 `.superharness/brainstorm/` 中,不会因服务器重启而丢失。不传的话,文件会保存到 `/tmp` 并在清理时被删除。提醒用户将 `.superharness/` 添加到 `.gitignore`(如果尚未添加)。
48
+
49
+ **按平台启动服务器:**
50
+
51
+ **Claude Code (macOS / Linux):**
52
+ ```bash
53
+ # 默认模式即可——脚本会自动将服务器放到后台
54
+ scripts/start-server.sh --project-dir /path/to/project
55
+ ```
56
+
57
+ **Claude Code (Windows):**
58
+ ```bash
59
+ # Windows 会自动检测并使用前台模式,这会阻塞工具调用。
60
+ # 在 Bash 工具调用上设置 run_in_background: true,
61
+ # 让服务器在会话轮次之间存活。
62
+ scripts/start-server.sh --project-dir /path/to/project
63
+ ```
64
+ 通过 Bash 工具调用时,设置 `run_in_background: true`。然后在下一轮读取 `$SCREEN_DIR/.server-info` 获取 URL 和端口。
65
+
66
+ **Codex:**
67
+ ```bash
68
+ # Codex 会回收后台进程。脚本会自动检测 CODEX_CI 并
69
+ # 切换到前台模式。正常运行即可——不需要额外标志。
70
+ scripts/start-server.sh --project-dir /path/to/project
71
+ ```
72
+
73
+ **Gemini CLI:**
74
+ ```bash
75
+ # 使用 --foreground 并在 shell 工具调用上设置 is_background: true,
76
+ # 让进程在轮次之间存活
77
+ scripts/start-server.sh --project-dir /path/to/project --foreground
78
+ ```
79
+
80
+ **其他环境:** 服务器必须在会话轮次之间持续在后台运行。如果你的环境会回收分离的进程,使用 `--foreground` 并通过平台的后台执行机制启动命令。
81
+
82
+ 如果浏览器无法访问该 URL(在远程/容器化环境中常见),绑定一个非回环主机:
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
+ 使用 `--url-host` 控制返回的 URL JSON 中显示的主机名。
92
+
93
+ ## 工作循环
94
+
95
+ 1. **检查服务器存活**,然后**将 HTML 写入** `screen_dir` 中的新文件:
96
+ - 每次写入前,检查 `$SCREEN_DIR/.server-info` 是否存在。如果不存在(或 `.server-stopped` 存在),服务器已关闭——在继续之前用 `start-server.sh` 重启。服务器在 30 分钟无活动后会自动退出。
97
+ - 使用语义化文件名:`platform.html`、`visual-style.html`、`layout.html`
98
+ - **绝不复用文件名** — 每个屏幕用一个新文件
99
+ - 使用 Write 工具 — **绝不使用 cat/heredoc**(会在终端产生噪音)
100
+ - 服务器自动提供最新的文件
101
+
102
+ 2. **告诉用户预期内容并结束你的回合:**
103
+ - 每一步都提醒他们 URL(不仅仅是第一次)
104
+ - 简要文字说明屏幕上的内容(例如"展示了 3 个首页布局选项")
105
+ - 请他们在终端中回复:"看一下,告诉我你的想法。如果你愿意,可以点击选择一个选项。"
106
+
107
+ 3. **在你的下一轮** — 用户在终端回复后:
108
+ - 如果存在 `$SCREEN_DIR/.events`,读取它——其中包含用户的浏览器交互(点击、选择),格式为 JSON 行
109
+ - 将终端文字和事件合并以获得完整信息
110
+ - 终端消息是主要反馈;`.events` 提供结构化的交互数据
111
+
112
+ 4. **迭代或推进** — 如果反馈要求修改当前屏幕,写入新文件(例如 `layout-v2.html`)。只有当前步骤验证通过后才进入下一个问题。
113
+
114
+ 5. **回到终端时卸载** — 当下一步不需要浏览器时(例如澄清问题、权衡讨论),推送一个等待屏幕以清除过时内容:
115
+
116
+ ```html
117
+ <!-- 文件名:waiting.html(或 waiting-2.html 等)-->
118
+ <div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
119
+ <p class="subtitle">在终端中继续...</p>
120
+ </div>
121
+ ```
122
+
123
+ 这样可以防止用户盯着一个已经解决的选择,而对话已经继续了。当下一个视觉问题出现时,照常推送新的内容文件。
124
+
125
+ 6. 重复直到完成。
126
+
127
+ ## 编写内容片段
128
+
129
+ 只写放在页面内部的内容。服务器会自动用框架模板包裹它(头部、主题 CSS、选择指示器和所有交互基础设施)。
130
+
131
+ **最简示例:**
132
+
133
+ ```html
134
+ <h2>哪种布局更好?</h2>
135
+ <p class="subtitle">考虑可读性和视觉层次</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>单栏</h3>
142
+ <p>简洁、专注的阅读体验</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>双栏</h3>
149
+ <p>侧边栏导航加主内容区</p>
150
+ </div>
151
+ </div>
152
+ </div>
153
+ ```
154
+
155
+ 就这些。不需要 `<html>`,不需要 CSS,不需要 `<script>` 标签。服务器会提供这一切。
156
+
157
+ ## 可用的 CSS 类
158
+
159
+ 框架模板为你的内容提供以下 CSS 类:
160
+
161
+ ### 选项(A/B/C 选择)
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>标题</h3>
169
+ <p>描述</p>
170
+ </div>
171
+ </div>
172
+ </div>
173
+ ```
174
+
175
+ **多选:** 在容器上添加 `data-multiselect` 让用户选择多个选项。每次点击切换选中状态。指示栏显示数量。
176
+
177
+ ```html
178
+ <div class="options" data-multiselect>
179
+ <!-- 相同的选项标记——用户可以选择/取消选择多个 -->
180
+ </div>
181
+ ```
182
+
183
+ ### 卡片(视觉设计)
184
+
185
+ ```html
186
+ <div class="cards">
187
+ <div class="card" data-choice="design1" onclick="toggleSelect(this)">
188
+ <div class="card-image"><!-- 原型内容 --></div>
189
+ <div class="card-body">
190
+ <h3>名称</h3>
191
+ <p>描述</p>
192
+ </div>
193
+ </div>
194
+ </div>
195
+ ```
196
+
197
+ ### 原型容器
198
+
199
+ ```html
200
+ <div class="mockup">
201
+ <div class="mockup-header">预览:仪表盘布局</div>
202
+ <div class="mockup-body"><!-- 你的原型 HTML --></div>
203
+ </div>
204
+ ```
205
+
206
+ ### 分屏视图(并排)
207
+
208
+ ```html
209
+ <div class="split">
210
+ <div class="mockup"><!-- 左侧 --></div>
211
+ <div class="mockup"><!-- 右侧 --></div>
212
+ </div>
213
+ ```
214
+
215
+ ### 优缺点
216
+
217
+ ```html
218
+ <div class="pros-cons">
219
+ <div class="pros"><h4>优点</h4><ul><li>好处</li></ul></div>
220
+ <div class="cons"><h4>缺点</h4><ul><li>不足</li></ul></div>
221
+ </div>
222
+ ```
223
+
224
+ ### 模拟元素(线框图构建块)
225
+
226
+ ```html
227
+ <div class="mock-nav">Logo | 首页 | 关于 | 联系我们</div>
228
+ <div style="display: flex;">
229
+ <div class="mock-sidebar">导航</div>
230
+ <div class="mock-content">主内容区域</div>
231
+ </div>
232
+ <button class="mock-button">操作按钮</button>
233
+ <input class="mock-input" placeholder="输入框">
234
+ <div class="placeholder">占位区域</div>
235
+ ```
236
+
237
+ ### 排版和区块
238
+
239
+ - `h2` — 页面标题
240
+ - `h3` — 章节标题
241
+ - `.subtitle` — 标题下方的辅助文字
242
+ - `.section` — 带底部边距的内容块
243
+ - `.label` — 小号大写标签文字
244
+
245
+ ## 浏览器事件格式
246
+
247
+ 当用户在浏览器中点击选项时,交互记录会保存到 `$SCREEN_DIR/.events`(每行一个 JSON 对象)。推送新屏幕时文件会自动清空。
248
+
249
+ ```jsonl
250
+ {"type":"click","choice":"a","text":"选项 A - 简单布局","timestamp":1706000101}
251
+ {"type":"click","choice":"c","text":"选项 C - 复杂网格","timestamp":1706000108}
252
+ {"type":"click","choice":"b","text":"选项 B - 混合方案","timestamp":1706000115}
253
+ ```
254
+
255
+ 完整的事件流展示了用户的探索路径——他们可能在确定之前点击了多个选项。最后一个 `choice` 事件通常是最终选择,但点击模式可以揭示犹豫或值得询问的偏好。
256
+
257
+ 如果 `.events` 不存在,说明用户没有与浏览器交互——仅使用他们的终端文字。
258
+
259
+ ## 设计技巧
260
+
261
+ - **保真度匹配问题** — 布局问题用线框图,细节打磨问题用精细设计
262
+ - **在每个页面上解释问题** — "哪种布局看起来更专业?"而不仅仅是"选一个"
263
+ - **推进前先迭代** — 如果反馈修改了当前屏幕,写入新版本
264
+ - 每个屏幕最多 **2-4 个选项**
265
+ - **必要时使用真实内容** — 对于摄影作品集,使用实际图片(Unsplash)。占位内容会掩盖设计问题。
266
+ - **保持原型简洁** — 专注于布局和结构,而非像素级精确的设计
267
+
268
+ ## 文件命名
269
+
270
+ - 使用语义化名称:`platform.html`、`visual-style.html`、`layout.html`
271
+ - 绝不复用文件名——每个屏幕必须是新文件
272
+ - 迭代版本:添加版本后缀如 `layout-v2.html`、`layout-v3.html`
273
+ - 服务器按修改时间提供最新文件
274
+
275
+ ## 清理
276
+
277
+ ```bash
278
+ scripts/stop-server.sh $SCREEN_DIR
279
+ ```
280
+
281
+ 如果会话使用了 `--project-dir`,原型文件会持久化在 `.superharness/brainstorm/` 中以供日后参考。只有 `/tmp` 会话会在停止时被删除。
282
+
283
+ ## 参考
284
+
285
+ - 框架模板(CSS 参考):`scripts/frame-template.html`
286
+ - 辅助脚本(客户端):`scripts/helper.js`