@leocm/flowcraft 0.0.0-stage → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +855 -3
- package/bin/cli.js +108 -0
- package/flowcraft.yaml +30 -0
- package/install.sh +24 -0
- package/lib/args.js +38 -0
- package/lib/config.js +20 -0
- package/lib/copy.js +131 -0
- package/lib/fix.js +110 -0
- package/lib/fsutil.js +104 -0
- package/lib/global.js +229 -0
- package/lib/init.js +43 -0
- package/lib/runtime.js +84 -0
- package/lib/version.js +55 -0
- package/lib/wizard.js +125 -0
- package/package.json +31 -4
- package/presets/backend.yaml +20 -0
- package/presets/default.yaml +15 -0
- package/presets/frontend.yaml +20 -0
- package/presets/quick-fix.yaml +15 -0
- package/setup/.claude/commands/P0.5.md +1 -0
- package/setup/.claude/commands/P0.md +1 -0
- package/setup/.claude/commands/P1.md +1 -0
- package/setup/.claude/commands/P2.md +1 -0
- package/setup/.claude/commands/P3.md +1 -0
- package/setup/.claude/commands/P4.md +1 -0
- package/setup/.claude/commands/P5.md +1 -0
- package/setup/.claude/commands/code-analysis-init.md +1 -0
- package/setup/.claude/commands/code-analysis-rebuild.md +1 -0
- package/setup/.claude/commands/code-analysis-show-memory.md +1 -0
- package/setup/.claude/commands/code-analysis-update.md +1 -0
- package/setup/.claude/hooks/check-phase-advancement.py +180 -0
- package/setup/.claude/hooks/check-phase-test.py +152 -0
- package/setup/.claude/hooks/check-phase-write.py +235 -0
- package/setup/.claude/hooks/dispatch.py +67 -0
- package/setup/.claude/hooks/file-suggestion.py +45 -0
- package/setup/.claude/hooks/flowcraft_env.py +137 -0
- package/setup/.claude/hooks/log_session.py +93 -0
- package/setup/.claude/hooks/permission-request.py +125 -0
- package/setup/.claude/hooks/post-tool-failure.py +36 -0
- package/setup/.claude/hooks/pre-compact.py +66 -0
- package/setup/.claude/hooks/review-runner.py +846 -0
- package/setup/.claude/hooks/session-end.py +184 -0
- package/setup/.claude/hooks/session-start.py +188 -0
- package/setup/.claude/hooks/settings.json +0 -0
- package/setup/.claude/hooks/setup-keys.py +282 -0
- package/setup/.claude/hooks/statusline.py +63 -0
- package/setup/.claude/hooks/stop-check.py +171 -0
- package/setup/.claude/hooks/subagent-start.py +50 -0
- package/setup/.claude/hooks/subagent-stop.py +63 -0
- package/setup/.claude/hooks/task-completed.py +57 -0
- package/setup/.claude/hooks/task_manager.py +592 -0
- package/setup/.claude/hooks/user-prompt-submit.py +85 -0
- package/setup/.claude/project-state.md +109 -0
- package/setup/.claude/settings.json +237 -0
- package/setup/.claude/settings.local.json +13 -0
- package/setup/.claude/skills/P5report/SKILL.md +77 -0
- package/setup/.claude/skills/Pstatus/SKILL.md +68 -0
- package/setup/.claude/skills/archive/SKILL.md +196 -0
- package/setup/.claude/skills/brainstorming/SKILL.md +155 -0
- package/setup/.claude/skills/brainstorming/scripts/frame-template.html +213 -0
- package/setup/.claude/skills/brainstorming/scripts/helper.js +167 -0
- package/setup/.claude/skills/brainstorming/scripts/server.cjs +723 -0
- package/setup/.claude/skills/brainstorming/scripts/start-server.py +245 -0
- package/setup/.claude/skills/brainstorming/scripts/stop-server.py +178 -0
- package/setup/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/setup/.claude/skills/brainstorming/visual-companion.md +298 -0
- package/setup/.claude/skills/checkpoint/SKILL.md +42 -0
- package/setup/.claude/skills/chrome-integration/SKILL.md +67 -0
- package/setup/.claude/skills/code-analysis/SKILL.md +1243 -0
- package/setup/.claude/skills/code-review/SKILL.md +265 -0
- package/setup/.claude/skills/cross-review/SKILL.md +41 -0
- package/setup/.claude/skills/executing-plans/SKILL.md +64 -0
- package/setup/.claude/skills/git-prep/SKILL.md +50 -0
- package/setup/.claude/skills/gitnexus/gitnexus-cli/SKILL.md +67 -0
- package/setup/.claude/skills/gitnexus/gitnexus-debugging/SKILL.md +89 -0
- package/setup/.claude/skills/gitnexus/gitnexus-exploring/SKILL.md +78 -0
- package/setup/.claude/skills/gitnexus/gitnexus-guide/SKILL.md +66 -0
- package/setup/.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md +97 -0
- package/setup/.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md +121 -0
- package/setup/.claude/skills/graphify/SKILL.md +49 -0
- package/setup/.claude/skills/openspec-apply-change/SKILL.md +185 -0
- package/setup/.claude/skills/openspec-archive-change/SKILL.md +182 -0
- package/setup/.claude/skills/openspec-bulk-archive-change/SKILL.md +339 -0
- package/setup/.claude/skills/openspec-continue-change/SKILL.md +118 -0
- package/setup/.claude/skills/openspec-explore/SKILL.md +311 -0
- package/setup/.claude/skills/openspec-ff-change/SKILL.md +113 -0
- package/setup/.claude/skills/openspec-new-change/SKILL.md +77 -0
- package/setup/.claude/skills/openspec-onboard/SKILL.md +573 -0
- package/setup/.claude/skills/openspec-propose/SKILL.md +149 -0
- package/setup/.claude/skills/openspec-sync-specs/SKILL.md +262 -0
- package/setup/.claude/skills/openspec-update-change/SKILL.md +91 -0
- package/setup/.claude/skills/openspec-verify-change/SKILL.md +175 -0
- package/setup/.claude/skills/oss-version-check/SKILL.md +71 -0
- package/setup/.claude/skills/oss-version-check/check_oss_version.py +205 -0
- package/setup/.claude/skills/phase/SKILL.md +63 -0
- package/setup/.claude/skills/playwright/SKILL.md +86 -0
- package/setup/.claude/skills/playwright-cli/SKILL.md +420 -0
- package/setup/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
- package/setup/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/setup/.claude/skills/playwright-cli/references/references/element-attributes.md +23 -0
- package/setup/.claude/skills/playwright-cli/references/references/playwright-tests.md +39 -0
- package/setup/.claude/skills/playwright-cli/references/references/request-mocking.md +87 -0
- package/setup/.claude/skills/playwright-cli/references/references/running-code.md +241 -0
- package/setup/.claude/skills/playwright-cli/references/references/session-management.md +225 -0
- package/setup/.claude/skills/playwright-cli/references/references/storage-state.md +275 -0
- package/setup/.claude/skills/playwright-cli/references/references/test-generation.md +433 -0
- package/setup/.claude/skills/playwright-cli/references/references/tracing.md +139 -0
- package/setup/.claude/skills/playwright-cli/references/references/video-recording.md +143 -0
- package/setup/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
- package/setup/.claude/skills/playwright-cli/references/running-code.md +241 -0
- package/setup/.claude/skills/playwright-cli/references/session-management.md +225 -0
- package/setup/.claude/skills/playwright-cli/references/storage-state.md +275 -0
- package/setup/.claude/skills/playwright-cli/references/test-generation.md +433 -0
- package/setup/.claude/skills/playwright-cli/references/tracing.md +139 -0
- package/setup/.claude/skills/playwright-cli/references/video-recording.md +143 -0
- package/setup/.claude/skills/review/SKILL.md +98 -0
- package/setup/.claude/skills/review-tools/SKILL.md +76 -0
- package/setup/.claude/skills/subagent-driven-development/SKILL.md +94 -0
- package/setup/.claude/skills/task/SKILL.md +26 -0
- package/setup/.claude/skills/test-driven-development/SKILL.md +320 -0
- package/setup/.claude/skills/test-driven-development/writing-good-tests.md +198 -0
- package/setup/.claude/skills/ui-ux-pro-max/SKILL.md +377 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/setup/.claude/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/setup/.claude/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/setup/.claude/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/setup/.claude/skills/ui-ux-pro-max/scripts/search.py +114 -0
- package/setup/.claude/skills/ui-ux-standards/SKILL.md +154 -0
- package/setup/.claude/skills/verification-before-completion/SKILL.md +120 -0
- package/setup/.claude/skills/wiki-read/SKILL.md +190 -0
- package/setup/.claude/skills/writing-plans/SKILL.md +168 -0
- package/setup/.claude/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/setup/.claude/tasks/.last-session +1 -0
- package/setup/.codex/.agents/skills/P5report/SKILL.md +77 -0
- package/setup/.codex/.agents/skills/Pstatus/SKILL.md +30 -0
- package/setup/.codex/.agents/skills/archive/SKILL.md +196 -0
- package/setup/.codex/.agents/skills/brainstorming/SKILL.md +155 -0
- package/setup/.codex/.agents/skills/brainstorming/scripts/frame-template.html +213 -0
- package/setup/.codex/.agents/skills/brainstorming/scripts/helper.js +167 -0
- package/setup/.codex/.agents/skills/brainstorming/scripts/server.cjs +723 -0
- package/setup/.codex/.agents/skills/brainstorming/scripts/start-server.py +245 -0
- package/setup/.codex/.agents/skills/brainstorming/scripts/stop-server.py +178 -0
- package/setup/.codex/.agents/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/setup/.codex/.agents/skills/brainstorming/visual-companion.md +298 -0
- package/setup/.codex/.agents/skills/checkpoint/SKILL.md +42 -0
- package/setup/.codex/.agents/skills/chrome-integration/SKILL.md +67 -0
- package/setup/.codex/.agents/skills/code-analysis/SKILL.md +1243 -0
- package/setup/.codex/.agents/skills/code-review/SKILL.md +265 -0
- package/setup/.codex/.agents/skills/cross-review/SKILL.md +42 -0
- package/setup/.codex/.agents/skills/executing-plans/SKILL.md +64 -0
- package/setup/.codex/.agents/skills/git-prep/SKILL.md +50 -0
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-cli/SKILL.md +67 -0
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-debugging/SKILL.md +89 -0
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-exploring/SKILL.md +78 -0
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-guide/SKILL.md +66 -0
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-impact-analysis/SKILL.md +97 -0
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-refactoring/SKILL.md +121 -0
- package/setup/.codex/.agents/skills/graphify/SKILL.md +49 -0
- package/setup/.codex/.agents/skills/openspec-apply-change/SKILL.md +185 -0
- package/setup/.codex/.agents/skills/openspec-archive-change/SKILL.md +182 -0
- package/setup/.codex/.agents/skills/openspec-bulk-archive-change/SKILL.md +339 -0
- package/setup/.codex/.agents/skills/openspec-continue-change/SKILL.md +118 -0
- package/setup/.codex/.agents/skills/openspec-explore/SKILL.md +311 -0
- package/setup/.codex/.agents/skills/openspec-ff-change/SKILL.md +113 -0
- package/setup/.codex/.agents/skills/openspec-new-change/SKILL.md +77 -0
- package/setup/.codex/.agents/skills/openspec-onboard/SKILL.md +573 -0
- package/setup/.codex/.agents/skills/openspec-propose/SKILL.md +149 -0
- package/setup/.codex/.agents/skills/openspec-sync-specs/SKILL.md +262 -0
- package/setup/.codex/.agents/skills/openspec-update-change/SKILL.md +91 -0
- package/setup/.codex/.agents/skills/openspec-verify-change/SKILL.md +175 -0
- package/setup/.codex/.agents/skills/oss-version-check/SKILL.md +71 -0
- package/setup/.codex/.agents/skills/oss-version-check/check_oss_version.py +205 -0
- package/setup/.codex/.agents/skills/phase/SKILL.md +63 -0
- package/setup/.codex/.agents/skills/playwright/SKILL.md +86 -0
- package/setup/.codex/.agents/skills/playwright-cli/SKILL.md +420 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/element-attributes.md +23 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/element-attributes.md +23 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/playwright-tests.md +39 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/request-mocking.md +87 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/running-code.md +241 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/session-management.md +225 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/storage-state.md +275 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/test-generation.md +433 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/tracing.md +139 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/references/video-recording.md +143 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/request-mocking.md +87 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/running-code.md +241 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/session-management.md +225 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/storage-state.md +275 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/test-generation.md +433 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/tracing.md +139 -0
- package/setup/.codex/.agents/skills/playwright-cli/references/video-recording.md +143 -0
- package/setup/.codex/.agents/skills/review/SKILL.md +98 -0
- package/setup/.codex/.agents/skills/review-tools/SKILL.md +76 -0
- package/setup/.codex/.agents/skills/subagent-driven-development/SKILL.md +94 -0
- package/setup/.codex/.agents/skills/task/SKILL.md +27 -0
- package/setup/.codex/.agents/skills/test-driven-development/SKILL.md +320 -0
- package/setup/.codex/.agents/skills/test-driven-development/writing-good-tests.md +198 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/SKILL.md +377 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/setup/.codex/.agents/skills/ui-ux-pro-max/scripts/search.py +114 -0
- package/setup/.codex/.agents/skills/ui-ux-standards/SKILL.md +154 -0
- package/setup/.codex/.agents/skills/verification-before-completion/SKILL.md +120 -0
- package/setup/.codex/.agents/skills/wiki-read/SKILL.md +190 -0
- package/setup/.codex/.agents/skills/writing-plans/SKILL.md +168 -0
- package/setup/.codex/.agents/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/setup/.codex/config.toml +10 -0
- package/setup/.codex/hooks/log_session.py +92 -0
- package/setup/.codex/hooks/review-runner.py +851 -0
- package/setup/.codex/hooks/sdlc-codex-hook.cjs +1039 -0
- package/setup/.codex/hooks/setup-keys.py +287 -0
- package/setup/.codex/hooks.json +121 -0
- package/setup/.codex/model-catalog.json +154 -0
- package/setup/.codex/project-state.md +103 -0
- package/setup/AGENTS.md +722 -0
- package/setup/CLAUDE.md +717 -0
- package/setup/install.sh +24 -0
- package/setup/tests/test_decision_timeout.py +241 -0
- package/setup/tests/test_hook_guards.py +357 -0
- package/setup/tests/test_sdlc_bootstrap.py +167 -0
- package/setup/tests/test_task_manager.py +148 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Start the brainstorm server and output connection info.
|
|
3
|
+
|
|
4
|
+
Usage: start-server.py [--project-dir <path>] [--host <bind-host>] [--url-host <display-host>] [--foreground] [--background]
|
|
5
|
+
|
|
6
|
+
Starts server on a random high port, outputs JSON with URL.
|
|
7
|
+
Each session gets its own directory to avoid conflicts.
|
|
8
|
+
|
|
9
|
+
Options:
|
|
10
|
+
--project-dir <path> Store session files under <path>/.superpowers/brainstorm/
|
|
11
|
+
instead of the temp dir. Files persist after the server stops.
|
|
12
|
+
--host <bind-host> Host/interface to bind (default: 127.0.0.1).
|
|
13
|
+
Use 0.0.0.0 in remote/containerized environments.
|
|
14
|
+
--url-host <host> Hostname shown in returned URL JSON.
|
|
15
|
+
--idle-timeout-minutes <n> Shut down after n minutes idle (default 240 = 4h).
|
|
16
|
+
--open Auto-open the browser on the first screen (use only
|
|
17
|
+
after the user approves the visual companion).
|
|
18
|
+
--foreground Run server in the current terminal (no backgrounding).
|
|
19
|
+
--background Force background mode.
|
|
20
|
+
"""
|
|
21
|
+
import os
|
|
22
|
+
import random
|
|
23
|
+
import re
|
|
24
|
+
import shutil
|
|
25
|
+
import signal
|
|
26
|
+
import subprocess
|
|
27
|
+
import sys
|
|
28
|
+
import tempfile
|
|
29
|
+
import time
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def is_windows() -> bool:
|
|
34
|
+
return os.name == "nt"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def server_id_value() -> str:
|
|
38
|
+
"""Generate a 32-64 char [A-Za-z0-9_-] server instance id."""
|
|
39
|
+
sid = os.urandom(24).hex() # 48 hex chars
|
|
40
|
+
if re.fullmatch(r"[A-Za-z0-9_-]{32,64}", sid):
|
|
41
|
+
return sid
|
|
42
|
+
return f"{os.getpid():08x}{int(time.time()):08x}{random.getrandbits(32):08x}{random.getrandbits(32):08x}"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def resolve_owner_pid() -> str:
|
|
46
|
+
"""Resolve the harness PID (grandparent of this script)."""
|
|
47
|
+
if is_windows():
|
|
48
|
+
return ""
|
|
49
|
+
try:
|
|
50
|
+
# grandparent of this process
|
|
51
|
+
r = subprocess.run(
|
|
52
|
+
["ps", "-o", "ppid=", "-p", str(os.getppid())],
|
|
53
|
+
capture_output=True, text=True, timeout=5,
|
|
54
|
+
)
|
|
55
|
+
pp = r.stdout.strip()
|
|
56
|
+
if pp and pp != "1":
|
|
57
|
+
return pp
|
|
58
|
+
except Exception:
|
|
59
|
+
pass
|
|
60
|
+
return str(os.getppid())
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def main(argv=None) -> int:
|
|
64
|
+
argv = sys.argv[1:] if argv is None else argv
|
|
65
|
+
project_dir = ""
|
|
66
|
+
foreground = False
|
|
67
|
+
force_background = False
|
|
68
|
+
bind_host = "127.0.0.1"
|
|
69
|
+
url_host = ""
|
|
70
|
+
idle_timeout_minutes = ""
|
|
71
|
+
do_open = False
|
|
72
|
+
|
|
73
|
+
i = 0
|
|
74
|
+
while i < len(argv):
|
|
75
|
+
a = argv[i]
|
|
76
|
+
if a == "--project-dir" and i + 1 < len(argv):
|
|
77
|
+
project_dir = argv[i + 1]; i += 2
|
|
78
|
+
elif a == "--host" and i + 1 < len(argv):
|
|
79
|
+
bind_host = argv[i + 1]; i += 2
|
|
80
|
+
elif a == "--url-host" and i + 1 < len(argv):
|
|
81
|
+
url_host = argv[i + 1]; i += 2
|
|
82
|
+
elif a == "--idle-timeout-minutes" and i + 1 < len(argv):
|
|
83
|
+
idle_timeout_minutes = argv[i + 1]; i += 2
|
|
84
|
+
elif a == "--open":
|
|
85
|
+
do_open = True; i += 1
|
|
86
|
+
elif a in ("--foreground", "--no-daemon"):
|
|
87
|
+
foreground = True; i += 1
|
|
88
|
+
elif a in ("--background", "--daemon"):
|
|
89
|
+
force_background = True; i += 1
|
|
90
|
+
else:
|
|
91
|
+
print(json_dumps({"error": f"Unknown argument: {a}"}))
|
|
92
|
+
return 1
|
|
93
|
+
|
|
94
|
+
if not url_host:
|
|
95
|
+
url_host = "localhost" if bind_host in ("127.0.0.1", "localhost") else bind_host
|
|
96
|
+
|
|
97
|
+
if idle_timeout_minutes:
|
|
98
|
+
if not idle_timeout_minutes.isdigit() or int(idle_timeout_minutes) < 1:
|
|
99
|
+
print(json_dumps({"error": "--idle-timeout-minutes must be a positive integer"}))
|
|
100
|
+
return 1
|
|
101
|
+
idle_timeout_ms = int(idle_timeout_minutes) * 60 * 1000
|
|
102
|
+
else:
|
|
103
|
+
idle_timeout_ms = None
|
|
104
|
+
|
|
105
|
+
# Some environments reap detached/background processes: auto-foreground.
|
|
106
|
+
if os.environ.get("CODEX_CI") and not foreground and not force_background:
|
|
107
|
+
foreground = True
|
|
108
|
+
if is_windows() and not foreground and not force_background:
|
|
109
|
+
foreground = True
|
|
110
|
+
|
|
111
|
+
# Generate a unique session directory
|
|
112
|
+
session_id = f"{os.getpid()}-{int(time.time())}"
|
|
113
|
+
if project_dir:
|
|
114
|
+
session_dir = Path(project_dir) / ".superpowers" / "brainstorm" / session_id
|
|
115
|
+
# Persist the bound port and key per project so a restart reuses them.
|
|
116
|
+
port_file = Path(project_dir) / ".superpowers" / "brainstorm" / ".last-port"
|
|
117
|
+
token_file = Path(project_dir) / ".superpowers" / "brainstorm" / ".last-token"
|
|
118
|
+
else:
|
|
119
|
+
session_dir = Path(tempfile.gettempdir()) / f"brainstorm-{session_id}"
|
|
120
|
+
port_file = token_file = None
|
|
121
|
+
|
|
122
|
+
state_dir = session_dir / "state"
|
|
123
|
+
pid_file = state_dir / "server.pid"
|
|
124
|
+
log_file = state_dir / "server.log"
|
|
125
|
+
server_id_file = state_dir / "server-instance-id"
|
|
126
|
+
|
|
127
|
+
# Create fresh session directory with content and state peers (owner-only)
|
|
128
|
+
for d in (session_dir / "content", state_dir):
|
|
129
|
+
d.mkdir(parents=True, exist_ok=True)
|
|
130
|
+
try:
|
|
131
|
+
os.chmod(session_dir, 0o700)
|
|
132
|
+
os.chmod(state_dir, 0o700)
|
|
133
|
+
except Exception:
|
|
134
|
+
pass
|
|
135
|
+
|
|
136
|
+
server_id = server_id_value()
|
|
137
|
+
server_id_file.write_text(server_id + "\n", encoding="utf-8")
|
|
138
|
+
try:
|
|
139
|
+
os.chmod(server_id_file, 0o600)
|
|
140
|
+
except Exception:
|
|
141
|
+
pass
|
|
142
|
+
|
|
143
|
+
# Kill any existing server
|
|
144
|
+
if pid_file.is_file():
|
|
145
|
+
try:
|
|
146
|
+
old_pid = int(pid_file.read_text(encoding="utf-8").strip() or "0")
|
|
147
|
+
except Exception:
|
|
148
|
+
old_pid = 0
|
|
149
|
+
if old_pid > 0:
|
|
150
|
+
try:
|
|
151
|
+
os.kill(old_pid, signal.SIGTERM)
|
|
152
|
+
except Exception:
|
|
153
|
+
pass
|
|
154
|
+
try:
|
|
155
|
+
pid_file.unlink()
|
|
156
|
+
except OSError:
|
|
157
|
+
pass
|
|
158
|
+
|
|
159
|
+
script_dir = Path(__file__).resolve().parent
|
|
160
|
+
owner_pid = resolve_owner_pid()
|
|
161
|
+
|
|
162
|
+
# Build the node invocation
|
|
163
|
+
node = shutil.which("node") or "node"
|
|
164
|
+
env = dict(os.environ)
|
|
165
|
+
env["BRAINSTORM_DIR"] = str(session_dir)
|
|
166
|
+
env["BRAINSTORM_HOST"] = bind_host
|
|
167
|
+
env["BRAINSTORM_URL_HOST"] = url_host
|
|
168
|
+
env["BRAINSTORM_OWNER_PID"] = owner_pid or ""
|
|
169
|
+
if port_file is not None:
|
|
170
|
+
env["BRAINSTORM_PORT_FILE"] = str(port_file)
|
|
171
|
+
env["BRAINSTORM_TOKEN_FILE"] = str(token_file)
|
|
172
|
+
if idle_timeout_ms is not None:
|
|
173
|
+
env["BRAINSTORM_IDLE_TIMEOUT_MS"] = str(idle_timeout_ms)
|
|
174
|
+
if do_open:
|
|
175
|
+
env["BRAINSTORM_OPEN"] = "1"
|
|
176
|
+
cmd = [node, "server.cjs", f"--brainstorm-server-id={server_id}"]
|
|
177
|
+
|
|
178
|
+
if foreground:
|
|
179
|
+
proc = subprocess.Popen(cmd, cwd=str(script_dir), env=env)
|
|
180
|
+
pid_file.write_text(str(proc.pid) + "\n", encoding="utf-8")
|
|
181
|
+
return proc.wait()
|
|
182
|
+
|
|
183
|
+
# Background mode: capture output to the log file
|
|
184
|
+
try:
|
|
185
|
+
lf = open(log_file, "wb")
|
|
186
|
+
except Exception as e:
|
|
187
|
+
print(json_dumps({"error": f"Cannot open log file: {e}"}))
|
|
188
|
+
return 1
|
|
189
|
+
try:
|
|
190
|
+
proc = subprocess.Popen(cmd, cwd=str(script_dir), env=env, stdout=lf, stderr=subprocess.STDOUT)
|
|
191
|
+
except Exception as e:
|
|
192
|
+
lf.close()
|
|
193
|
+
print(json_dumps({"error": f"Failed to start server: {e}"}))
|
|
194
|
+
return 1
|
|
195
|
+
pid_file.write_text(str(proc.pid) + "\n", encoding="utf-8")
|
|
196
|
+
|
|
197
|
+
# Wait for the server-started message (check the log file)
|
|
198
|
+
for _ in range(50):
|
|
199
|
+
if log_file.is_file():
|
|
200
|
+
try:
|
|
201
|
+
log_text = log_file.read_text(encoding="utf-8", errors="replace")
|
|
202
|
+
except Exception:
|
|
203
|
+
log_text = ""
|
|
204
|
+
if "server-started" in log_text:
|
|
205
|
+
# Verify the server is still alive after a short window
|
|
206
|
+
alive = True
|
|
207
|
+
for _ in range(20):
|
|
208
|
+
if not is_alive(proc.pid):
|
|
209
|
+
alive = False
|
|
210
|
+
break
|
|
211
|
+
time.sleep(0.1)
|
|
212
|
+
if not alive:
|
|
213
|
+
retry = f"{script_dir}/start-server.py"
|
|
214
|
+
if project_dir:
|
|
215
|
+
retry += f" --project-dir {project_dir}"
|
|
216
|
+
retry += f" --host {bind_host} --url-host {url_host} --foreground"
|
|
217
|
+
print(json_dumps({"error": f"Server started but was killed. Retry in a persistent terminal with: {retry}"}))
|
|
218
|
+
return 1
|
|
219
|
+
for line in log_text.splitlines():
|
|
220
|
+
if "server-started" in line:
|
|
221
|
+
print(line)
|
|
222
|
+
break
|
|
223
|
+
return 0
|
|
224
|
+
time.sleep(0.1)
|
|
225
|
+
|
|
226
|
+
# Timeout - server didn't start
|
|
227
|
+
print(json_dumps({"error": "Server failed to start within 5 seconds"}))
|
|
228
|
+
return 1
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def is_alive(pid: int) -> bool:
|
|
232
|
+
try:
|
|
233
|
+
os.kill(pid, 0)
|
|
234
|
+
return True
|
|
235
|
+
except OSError:
|
|
236
|
+
return False
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def json_dumps(obj) -> str:
|
|
240
|
+
import json
|
|
241
|
+
return json.dumps(obj, ensure_ascii=False)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
if __name__ == "__main__":
|
|
245
|
+
sys.exit(main())
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Stop the brainstorm server and clean up.
|
|
3
|
+
|
|
4
|
+
Usage: stop-server.py <session_dir>
|
|
5
|
+
|
|
6
|
+
Kills the server process. Only deletes the session directory if it is
|
|
7
|
+
ephemeral (under the temp dir). Persistent directories (.superpowers/) are
|
|
8
|
+
kept so mockups can be reviewed later.
|
|
9
|
+
"""
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import re
|
|
13
|
+
import signal
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
import tempfile
|
|
17
|
+
import time
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def mark_stopped(state_dir: Path, reason: str) -> None:
|
|
22
|
+
info = state_dir / "server-info"
|
|
23
|
+
try:
|
|
24
|
+
info.unlink()
|
|
25
|
+
except OSError:
|
|
26
|
+
pass
|
|
27
|
+
stopped = state_dir / "server-stopped"
|
|
28
|
+
stopped.write_text(json.dumps({"reason": reason, "timestamp": int(time.time())}) + "\n", encoding="utf-8")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def read_expected_server_id(server_id_file: Path) -> str:
|
|
32
|
+
if not server_id_file.is_file():
|
|
33
|
+
return ""
|
|
34
|
+
try:
|
|
35
|
+
sid = server_id_file.read_text(encoding="utf-8").strip("\r\n")
|
|
36
|
+
except Exception:
|
|
37
|
+
return ""
|
|
38
|
+
if re.fullmatch(r"[A-Za-z0-9_-]{32,64}", sid):
|
|
39
|
+
return sid
|
|
40
|
+
return ""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def command_has_server_id(pid: int, expected: str) -> bool:
|
|
44
|
+
expected_arg = f"--brainstorm-server-id={expected}"
|
|
45
|
+
if os.name != "nt":
|
|
46
|
+
try:
|
|
47
|
+
with open(f"/proc/{pid}/cmdline", "rb") as f:
|
|
48
|
+
args = f.read().split(b"\0")
|
|
49
|
+
return expected_arg.encode("utf-8") in args
|
|
50
|
+
except Exception:
|
|
51
|
+
pass
|
|
52
|
+
try:
|
|
53
|
+
r = subprocess.run(
|
|
54
|
+
["ps", "-ww", "-p", str(pid), "-o", "command="],
|
|
55
|
+
capture_output=True, text=True, timeout=5,
|
|
56
|
+
)
|
|
57
|
+
return expected_arg in r.stdout
|
|
58
|
+
except Exception:
|
|
59
|
+
return False
|
|
60
|
+
# Windows: query the command line via PowerShell, fall back to wmic
|
|
61
|
+
for cmdline in (
|
|
62
|
+
["powershell", "-NoProfile", "-Command",
|
|
63
|
+
f"(Get-CimInstance Win32_Process -Filter \"ProcessId={pid}\").CommandLine"],
|
|
64
|
+
["wmic", "process", "where", f"processid={pid}", "get", "commandline"],
|
|
65
|
+
):
|
|
66
|
+
try:
|
|
67
|
+
r = subprocess.run(cmdline, capture_output=True, text=True, timeout=10)
|
|
68
|
+
if expected_arg in r.stdout:
|
|
69
|
+
return True
|
|
70
|
+
except Exception:
|
|
71
|
+
continue
|
|
72
|
+
return False
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def is_brainstorm_server(pid: int, server_id_file: Path) -> bool:
|
|
76
|
+
if not is_alive(pid):
|
|
77
|
+
return False
|
|
78
|
+
expected = read_expected_server_id(server_id_file)
|
|
79
|
+
if not expected:
|
|
80
|
+
return False
|
|
81
|
+
return command_has_server_id(pid, expected)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def is_alive(pid: int) -> bool:
|
|
85
|
+
try:
|
|
86
|
+
os.kill(pid, 0)
|
|
87
|
+
return True
|
|
88
|
+
except OSError:
|
|
89
|
+
return False
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def main(argv=None) -> int:
|
|
93
|
+
argv = sys.argv[1:] if argv is None else argv
|
|
94
|
+
if not argv:
|
|
95
|
+
print(json_dumps({"error": "Usage: stop-server.py <session_dir>"}))
|
|
96
|
+
return 1
|
|
97
|
+
session_dir = Path(argv[0])
|
|
98
|
+
|
|
99
|
+
state_dir = session_dir / "state"
|
|
100
|
+
pid_file = state_dir / "server.pid"
|
|
101
|
+
server_id_file = state_dir / "server-instance-id"
|
|
102
|
+
|
|
103
|
+
if not pid_file.is_file():
|
|
104
|
+
print(json_dumps({"status": "not_running"}))
|
|
105
|
+
return 0
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
pid = int(pid_file.read_text(encoding="utf-8").strip() or "0")
|
|
109
|
+
except Exception:
|
|
110
|
+
pid = 0
|
|
111
|
+
|
|
112
|
+
# Refuse to signal a PID we cannot prove is our server.
|
|
113
|
+
if pid <= 0 or not is_brainstorm_server(pid, server_id_file):
|
|
114
|
+
for f in (pid_file, server_id_file):
|
|
115
|
+
try:
|
|
116
|
+
f.unlink()
|
|
117
|
+
except OSError:
|
|
118
|
+
pass
|
|
119
|
+
mark_stopped(state_dir, "stale_pid")
|
|
120
|
+
print(json_dumps({"status": "stale_pid"}))
|
|
121
|
+
return 0
|
|
122
|
+
|
|
123
|
+
# Try to stop gracefully, fall back to force if still alive
|
|
124
|
+
try:
|
|
125
|
+
os.kill(pid, signal.SIGTERM)
|
|
126
|
+
except Exception:
|
|
127
|
+
pass
|
|
128
|
+
|
|
129
|
+
for _ in range(20):
|
|
130
|
+
if not is_alive(pid):
|
|
131
|
+
break
|
|
132
|
+
time.sleep(0.1)
|
|
133
|
+
|
|
134
|
+
if is_alive(pid):
|
|
135
|
+
try:
|
|
136
|
+
os.kill(pid, getattr(signal, "SIGKILL", signal.SIGTERM))
|
|
137
|
+
except Exception:
|
|
138
|
+
pass
|
|
139
|
+
time.sleep(0.1)
|
|
140
|
+
|
|
141
|
+
if is_alive(pid):
|
|
142
|
+
print(json_dumps({"status": "failed", "error": "process still running"}))
|
|
143
|
+
return 1
|
|
144
|
+
|
|
145
|
+
log_file = state_dir / "server.log"
|
|
146
|
+
for f in (pid_file, server_id_file, log_file):
|
|
147
|
+
try:
|
|
148
|
+
f.unlink()
|
|
149
|
+
except OSError:
|
|
150
|
+
pass
|
|
151
|
+
mark_stopped(state_dir, "stop-server.py")
|
|
152
|
+
|
|
153
|
+
# Only delete ephemeral temp directories
|
|
154
|
+
tmp_base = Path(tempfile.gettempdir()).resolve()
|
|
155
|
+
try:
|
|
156
|
+
is_ephemeral = (
|
|
157
|
+
str(session_dir).startswith("/tmp/")
|
|
158
|
+
or session_dir.resolve().is_relative_to(tmp_base)
|
|
159
|
+
)
|
|
160
|
+
except Exception:
|
|
161
|
+
is_ephemeral = str(session_dir).startswith("/tmp/")
|
|
162
|
+
if is_ephemeral and session_dir.exists():
|
|
163
|
+
try:
|
|
164
|
+
import shutil
|
|
165
|
+
shutil.rmtree(session_dir)
|
|
166
|
+
except Exception:
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
print(json_dumps({"status": "stopped"}))
|
|
170
|
+
return 0
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def json_dumps(obj) -> str:
|
|
174
|
+
return json.dumps(obj, ensure_ascii=False)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
if __name__ == "__main__":
|
|
178
|
+
sys.exit(main())
|
|
@@ -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
|
+
Subagent (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
|