terraproof 0.0.0-stage → 0.4.1
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/LICENSE +21 -0
- package/README.md +356 -2
- package/bin/terraproof.js +4 -0
- package/dist/router/apply.js +147 -0
- package/dist/router/classify.js +111 -0
- package/dist/router/explain.js +9 -0
- package/dist/router/index.js +272 -0
- package/dist/router/resolve.js +239 -0
- package/dist/router/score.js +60 -0
- package/dist/router/types.js +1 -0
- package/dist/router/validate.js +81 -0
- package/instructions/engineering.md +14 -0
- package/instructions/security.md +14 -0
- package/instructions/simplicity.md +13 -0
- package/package.json +65 -4
- package/routing/DOMAIN_ROUTING.md +161 -0
- package/routing/ROUTER_DESIGN.md +173 -0
- package/routing/SKILL_MANIFEST.md +86 -0
- package/routing/checks.json +121 -0
- package/routing/collections.json +47 -0
- package/routing/registry.json +2211 -0
- package/routing/rules.json +64 -0
- package/skills/accuracy-assessment/SKILL.md +213 -0
- package/skills/accuracy-assessment/UPSTREAM.md +7 -0
- package/skills/accuracy-assessment/references/stratified-estimator.md +127 -0
- package/skills/accuracy-assessment/skill.json +103 -0
- package/skills/brainstorming/SKILL.md +250 -0
- package/skills/brainstorming/UPSTREAM.md +29 -0
- package/skills/brainstorming/scripts/frame-template.html +213 -0
- package/skills/brainstorming/scripts/helper.js +167 -0
- package/skills/brainstorming/scripts/server.cjs +723 -0
- package/skills/brainstorming/scripts/start-server.sh +209 -0
- package/skills/brainstorming/scripts/stop-server.sh +120 -0
- package/skills/brainstorming/skill.json +73 -0
- package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/skills/brainstorming/visual-companion.md +299 -0
- package/skills/crs-and-units/SKILL.md +200 -0
- package/skills/crs-and-units/UPSTREAM.md +7 -0
- package/skills/crs-and-units/skill.json +74 -0
- package/skills/design-postgis-tables/SKILL.md +494 -0
- package/skills/design-postgis-tables/UPSTREAM.md +21 -0
- package/skills/design-postgis-tables/skill.json +90 -0
- package/skills/gdal/SKILL.md +125 -0
- package/skills/gdal/UPSTREAM.md +22 -0
- package/skills/gdal/references/gdal-recipes.md +103 -0
- package/skills/gdal/skill.json +66 -0
- package/skills/geomaster/README.md +105 -0
- package/skills/geomaster/SKILL.md +366 -0
- package/skills/geomaster/UPSTREAM.md +21 -0
- package/skills/geomaster/references/advanced-gis.md +376 -0
- package/skills/geomaster/references/big-data.md +363 -0
- package/skills/geomaster/references/code-examples.md +531 -0
- package/skills/geomaster/references/coordinate-systems.md +364 -0
- package/skills/geomaster/references/core-libraries.md +273 -0
- package/skills/geomaster/references/data-sources.md +330 -0
- package/skills/geomaster/references/gis-software.md +369 -0
- package/skills/geomaster/references/industry-applications.md +420 -0
- package/skills/geomaster/references/machine-learning.md +462 -0
- package/skills/geomaster/references/programming-languages.md +456 -0
- package/skills/geomaster/references/remote-sensing.md +370 -0
- package/skills/geomaster/references/scientific-domains.md +416 -0
- package/skills/geomaster/references/specialized-topics.md +428 -0
- package/skills/geomaster/references/troubleshooting.md +439 -0
- package/skills/geomaster/skill.json +157 -0
- package/skills/geopandas/SKILL.md +250 -0
- package/skills/geopandas/UPSTREAM.md +22 -0
- package/skills/geopandas/references/crs-management.md +231 -0
- package/skills/geopandas/references/data-io.md +323 -0
- package/skills/geopandas/references/data-structures.md +207 -0
- package/skills/geopandas/references/geometric-operations.md +262 -0
- package/skills/geopandas/references/spatial-analysis.md +294 -0
- package/skills/geopandas/references/visualization.md +230 -0
- package/skills/geopandas/scripts/_common.py +605 -0
- package/skills/geopandas/scripts/crs_reprojection_plan.py +210 -0
- package/skills/geopandas/scripts/export_plan.py +305 -0
- package/skills/geopandas/scripts/geometry_validity_report.py +227 -0
- package/skills/geopandas/scripts/sensitive_coordinates_checklist.py +230 -0
- package/skills/geopandas/scripts/spatial_join_audit.py +368 -0
- package/skills/geopandas/scripts/vector_inventory.py +140 -0
- package/skills/geopandas/skill.json +116 -0
- package/skills/geoparquet-validation/SKILL.md +125 -0
- package/skills/geoparquet-validation/UPSTREAM.md +24 -0
- package/skills/geoparquet-validation/references/distribution-best-practices.md +118 -0
- package/skills/geoparquet-validation/references/gpio-commands.md +264 -0
- package/skills/geoparquet-validation/references/tool-comparison.md +155 -0
- package/skills/geoparquet-validation/skill.json +71 -0
- package/skills/geospatial-data-discovery/SKILL.md +49 -0
- package/skills/geospatial-data-discovery/UPSTREAM.md +15 -0
- package/skills/geospatial-data-discovery/skill.json +51 -0
- package/skills/geospatial-frontend/SKILL.md +86 -0
- package/skills/geospatial-frontend/UPSTREAM.md +23 -0
- package/skills/geospatial-frontend/references/design-system.md +283 -0
- package/skills/geospatial-frontend/references/user-preferences.md +96 -0
- package/skills/geospatial-frontend/skill.json +87 -0
- package/skills/geozarr/SKILL.md +244 -0
- package/skills/geozarr/UPSTREAM.md +21 -0
- package/skills/geozarr/skill.json +97 -0
- package/skills/networkx/SKILL.md +440 -0
- package/skills/networkx/UPSTREAM.md +22 -0
- package/skills/networkx/references/algorithms.md +384 -0
- package/skills/networkx/references/generators.md +385 -0
- package/skills/networkx/references/graph-basics.md +284 -0
- package/skills/networkx/references/io.md +457 -0
- package/skills/networkx/references/visualization.md +531 -0
- package/skills/networkx/skill.json +93 -0
- package/skills/raster-processing/SKILL.md +222 -0
- package/skills/raster-processing/UPSTREAM.md +7 -0
- package/skills/raster-processing/skill.json +81 -0
- package/skills/sar-basics/SKILL.md +202 -0
- package/skills/sar-basics/UPSTREAM.md +7 -0
- package/skills/sar-basics/references/calibration-lut.md +98 -0
- package/skills/sar-basics/skill.json +97 -0
- package/skills/satellite-preprocessing/SKILL.md +241 -0
- package/skills/satellite-preprocessing/UPSTREAM.md +7 -0
- package/skills/satellite-preprocessing/skill.json +84 -0
- package/skills/scientific-visualization/SKILL.md +285 -0
- package/skills/scientific-visualization/UPSTREAM.md +25 -0
- package/skills/scientific-visualization/assets/color_palettes.py +263 -0
- package/skills/scientific-visualization/assets/nature.mplstyle +68 -0
- package/skills/scientific-visualization/assets/presentation.mplstyle +68 -0
- package/skills/scientific-visualization/assets/publication.mplstyle +77 -0
- package/skills/scientific-visualization/assets/publisher_profiles.json +269 -0
- package/skills/scientific-visualization/references/color_palettes.md +227 -0
- package/skills/scientific-visualization/references/journal_requirements.md +169 -0
- package/skills/scientific-visualization/references/matplotlib_examples.md +336 -0
- package/skills/scientific-visualization/references/publication_guidelines.md +196 -0
- package/skills/scientific-visualization/references/sources.md +76 -0
- package/skills/scientific-visualization/scripts/_common.py +136 -0
- package/skills/scientific-visualization/scripts/export_plan.py +493 -0
- package/skills/scientific-visualization/scripts/figure_export.py +642 -0
- package/skills/scientific-visualization/scripts/image_metadata.py +731 -0
- package/skills/scientific-visualization/scripts/palette_audit.py +327 -0
- package/skills/scientific-visualization/scripts/style_presets.py +501 -0
- package/skills/scientific-visualization/scripts/style_preview.py +232 -0
- package/skills/scientific-visualization/skill.json +95 -0
- package/skills/spectral-indices/SKILL.md +235 -0
- package/skills/spectral-indices/UPSTREAM.md +7 -0
- package/skills/spectral-indices/skill.json +88 -0
- package/skills/stac-and-cloud-access/SKILL.md +209 -0
- package/skills/stac-and-cloud-access/UPSTREAM.md +7 -0
- package/skills/stac-and-cloud-access/references/run-manifest.md +94 -0
- package/skills/stac-and-cloud-access/skill.json +98 -0
- package/skills/statistical-analysis/SKILL.md +446 -0
- package/skills/statistical-analysis/UPSTREAM.md +24 -0
- package/skills/statistical-analysis/references/assumptions_and_diagnostics.md +379 -0
- package/skills/statistical-analysis/references/bayesian_statistics.md +686 -0
- package/skills/statistical-analysis/references/effect_sizes_and_power.md +649 -0
- package/skills/statistical-analysis/references/reporting_standards.md +482 -0
- package/skills/statistical-analysis/references/test_selection_guide.md +129 -0
- package/skills/statistical-analysis/scripts/assumption_checks.py +652 -0
- package/skills/statistical-analysis/skill.json +127 -0
- package/skills/systematic-debugging/SKILL.md +283 -0
- package/skills/systematic-debugging/UPSTREAM.md +28 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +72 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/systematic-debugging/skill.json +88 -0
- package/skills/time-series-and-change/SKILL.md +217 -0
- package/skills/time-series-and-change/UPSTREAM.md +7 -0
- package/skills/time-series-and-change/references/change-methods.md +42 -0
- package/skills/time-series-and-change/skill.json +116 -0
- package/skills/vector-quality/SKILL.md +204 -0
- package/skills/vector-quality/UPSTREAM.md +7 -0
- package/skills/vector-quality/skill.json +82 -0
- package/skills/verification/SKILL.md +120 -0
- package/skills/verification/UPSTREAM.md +31 -0
- package/skills/verification/skill.json +67 -0
- package/skills/writing-plans/SKILL.md +171 -0
- package/skills/writing-plans/UPSTREAM.md +23 -0
- package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/skills/writing-plans/skill.json +80 -0
- package/sources/SOURCES.md +374 -0
- package/third_party/isaaccorley-geospatial-skills/LICENSE +176 -0
- package/third_party/isaaccorley-geospatial-skills/NOTICE.md +17 -0
- package/third_party/kdense-scientific-agent-skills/LICENSE +21 -0
- package/third_party/kdense-scientific-agent-skills/NOTICE.md +19 -0
- package/third_party/superpowers/LICENSE +21 -0
- package/third_party/superpowers/NOTICE.md +17 -0
- package/third_party/timescale-pg-aiguide/LICENSE +176 -0
- package/third_party/timescale-pg-aiguide/NOTICE.md +14 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Start the brainstorm server and output connection info
|
|
3
|
+
# Usage: start-server.sh [--project-dir <path>] [--host <bind-host>] [--url-host <display-host>] [--foreground] [--background]
|
|
4
|
+
#
|
|
5
|
+
# Starts server on a random high port, outputs JSON with URL.
|
|
6
|
+
# Each session gets its own directory to avoid conflicts.
|
|
7
|
+
#
|
|
8
|
+
# Options:
|
|
9
|
+
# --project-dir <path> Store session files under <path>/.superpowers/brainstorm/
|
|
10
|
+
# instead of /tmp. Files persist after server stops.
|
|
11
|
+
# --host <bind-host> Host/interface to bind (default: 127.0.0.1).
|
|
12
|
+
# Use 0.0.0.0 in remote/containerized environments.
|
|
13
|
+
# --url-host <host> Hostname shown in returned URL JSON.
|
|
14
|
+
# --idle-timeout-minutes <n> Shut down after n minutes idle (default 240 = 4h).
|
|
15
|
+
# --open Auto-open the browser on the first screen (use only
|
|
16
|
+
# after the user approves the visual companion).
|
|
17
|
+
# --foreground Run server in the current terminal (no backgrounding).
|
|
18
|
+
# --background Force background mode (overrides Codex auto-foreground).
|
|
19
|
+
|
|
20
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
21
|
+
|
|
22
|
+
# Parse arguments
|
|
23
|
+
PROJECT_DIR=""
|
|
24
|
+
FOREGROUND="false"
|
|
25
|
+
FORCE_BACKGROUND="false"
|
|
26
|
+
BIND_HOST="127.0.0.1"
|
|
27
|
+
URL_HOST=""
|
|
28
|
+
IDLE_TIMEOUT_MINUTES=""
|
|
29
|
+
while [[ $# -gt 0 ]]; do
|
|
30
|
+
case "$1" in
|
|
31
|
+
--project-dir)
|
|
32
|
+
PROJECT_DIR="$2"
|
|
33
|
+
shift 2
|
|
34
|
+
;;
|
|
35
|
+
--host)
|
|
36
|
+
BIND_HOST="$2"
|
|
37
|
+
shift 2
|
|
38
|
+
;;
|
|
39
|
+
--url-host)
|
|
40
|
+
URL_HOST="$2"
|
|
41
|
+
shift 2
|
|
42
|
+
;;
|
|
43
|
+
--idle-timeout-minutes)
|
|
44
|
+
IDLE_TIMEOUT_MINUTES="$2"
|
|
45
|
+
shift 2
|
|
46
|
+
;;
|
|
47
|
+
--open)
|
|
48
|
+
export BRAINSTORM_OPEN=1
|
|
49
|
+
shift
|
|
50
|
+
;;
|
|
51
|
+
--foreground|--no-daemon)
|
|
52
|
+
FOREGROUND="true"
|
|
53
|
+
shift
|
|
54
|
+
;;
|
|
55
|
+
--background|--daemon)
|
|
56
|
+
FORCE_BACKGROUND="true"
|
|
57
|
+
shift
|
|
58
|
+
;;
|
|
59
|
+
*)
|
|
60
|
+
echo "{\"error\": \"Unknown argument: $1\"}"
|
|
61
|
+
exit 1
|
|
62
|
+
;;
|
|
63
|
+
esac
|
|
64
|
+
done
|
|
65
|
+
|
|
66
|
+
if [[ -z "$URL_HOST" ]]; then
|
|
67
|
+
if [[ "$BIND_HOST" == "127.0.0.1" || "$BIND_HOST" == "localhost" ]]; then
|
|
68
|
+
URL_HOST="localhost"
|
|
69
|
+
else
|
|
70
|
+
URL_HOST="$BIND_HOST"
|
|
71
|
+
fi
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
if [[ -n "$IDLE_TIMEOUT_MINUTES" ]]; then
|
|
75
|
+
if ! [[ "$IDLE_TIMEOUT_MINUTES" =~ ^[0-9]+$ ]] || [[ "$IDLE_TIMEOUT_MINUTES" -lt 1 ]]; then
|
|
76
|
+
echo "{\"error\": \"--idle-timeout-minutes must be a positive integer\"}"
|
|
77
|
+
exit 1
|
|
78
|
+
fi
|
|
79
|
+
export BRAINSTORM_IDLE_TIMEOUT_MS=$(( IDLE_TIMEOUT_MINUTES * 60 * 1000 ))
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
is_windows_like_shell() {
|
|
83
|
+
case "${OSTYPE:-}" in
|
|
84
|
+
msys*|cygwin*|mingw*) return 0 ;;
|
|
85
|
+
esac
|
|
86
|
+
if [[ -n "${MSYSTEM:-}" ]]; then
|
|
87
|
+
return 0
|
|
88
|
+
fi
|
|
89
|
+
local uname_s
|
|
90
|
+
uname_s="$(uname -s 2>/dev/null || true)"
|
|
91
|
+
case "$uname_s" in
|
|
92
|
+
MSYS*|MINGW*|CYGWIN*) return 0 ;;
|
|
93
|
+
esac
|
|
94
|
+
return 1
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# Some environments reap detached/background processes. Auto-foreground when detected.
|
|
98
|
+
if [[ -n "${CODEX_CI:-}" && "$FOREGROUND" != "true" && "$FORCE_BACKGROUND" != "true" ]]; then
|
|
99
|
+
FOREGROUND="true"
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
# Windows/Git Bash reaps nohup background processes. Auto-foreground when detected.
|
|
103
|
+
if [[ "$FOREGROUND" != "true" && "$FORCE_BACKGROUND" != "true" ]]; then
|
|
104
|
+
if is_windows_like_shell; then
|
|
105
|
+
FOREGROUND="true"
|
|
106
|
+
fi
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
# Session files (server.log, server-info, .last-token) embed the session key —
|
|
110
|
+
# keep everything this script and the server create owner-only.
|
|
111
|
+
umask 077
|
|
112
|
+
|
|
113
|
+
# Generate unique session directory
|
|
114
|
+
SESSION_ID="$$-$(date +%s)"
|
|
115
|
+
|
|
116
|
+
if [[ -n "$PROJECT_DIR" ]]; then
|
|
117
|
+
SESSION_DIR="${PROJECT_DIR}/.superpowers/brainstorm/${SESSION_ID}"
|
|
118
|
+
# Persist the bound port and key per project so a restart reuses them and an
|
|
119
|
+
# already-open browser tab reconnects to the same URL with a valid cookie.
|
|
120
|
+
export BRAINSTORM_PORT_FILE="${PROJECT_DIR}/.superpowers/brainstorm/.last-port"
|
|
121
|
+
export BRAINSTORM_TOKEN_FILE="${PROJECT_DIR}/.superpowers/brainstorm/.last-token"
|
|
122
|
+
else
|
|
123
|
+
SESSION_DIR="/tmp/brainstorm-${SESSION_ID}"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
STATE_DIR="${SESSION_DIR}/state"
|
|
127
|
+
PID_FILE="${STATE_DIR}/server.pid"
|
|
128
|
+
LOG_FILE="${STATE_DIR}/server.log"
|
|
129
|
+
SERVER_ID_FILE="${STATE_DIR}/server-instance-id"
|
|
130
|
+
|
|
131
|
+
# Create fresh session directory with content and state peers
|
|
132
|
+
mkdir -p "${SESSION_DIR}/content" "$STATE_DIR"
|
|
133
|
+
|
|
134
|
+
SERVER_ID=""
|
|
135
|
+
if [[ -r /dev/urandom ]]; then
|
|
136
|
+
SERVER_ID="$(od -An -N24 -tx1 /dev/urandom 2>/dev/null | tr -d ' \n' || true)"
|
|
137
|
+
fi
|
|
138
|
+
if ! [[ "$SERVER_ID" =~ ^[A-Za-z0-9_-]{32,64}$ ]]; then
|
|
139
|
+
SERVER_ID="$(printf '%08x%08x%08x%08x' "$$" "$(date +%s)" "${RANDOM:-0}" "${RANDOM:-0}")"
|
|
140
|
+
fi
|
|
141
|
+
printf '%s\n' "$SERVER_ID" > "$SERVER_ID_FILE"
|
|
142
|
+
chmod 600 "$SERVER_ID_FILE" 2>/dev/null || true
|
|
143
|
+
|
|
144
|
+
# Kill any existing server
|
|
145
|
+
if [[ -f "$PID_FILE" ]]; then
|
|
146
|
+
old_pid=$(cat "$PID_FILE")
|
|
147
|
+
kill "$old_pid" 2>/dev/null
|
|
148
|
+
rm -f "$PID_FILE"
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
cd "$SCRIPT_DIR" || exit 1
|
|
152
|
+
|
|
153
|
+
# Resolve the harness PID (grandparent of this script).
|
|
154
|
+
# $PPID is the ephemeral shell the harness spawned to run us — it dies
|
|
155
|
+
# when this script exits. The harness itself is $PPID's parent.
|
|
156
|
+
OWNER_PID="$(ps -o ppid= -p "$PPID" 2>/dev/null | tr -d ' ')"
|
|
157
|
+
if [[ -z "$OWNER_PID" || "$OWNER_PID" == "1" ]]; then
|
|
158
|
+
OWNER_PID="$PPID"
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
# Windows/MSYS2: Node.js cannot see POSIX PIDs from the MSYS2 namespace.
|
|
162
|
+
# Passing a PID node cannot verify causes server to log owner-pid-invalid
|
|
163
|
+
# and self-terminate at the 60-second lifecycle check. Clear it so the
|
|
164
|
+
# watchdog is disabled and the idle timeout becomes the only shutdown trigger.
|
|
165
|
+
if is_windows_like_shell; then
|
|
166
|
+
OWNER_PID=""
|
|
167
|
+
fi
|
|
168
|
+
|
|
169
|
+
# Foreground mode for environments that reap detached/background processes.
|
|
170
|
+
if [[ "$FOREGROUND" == "true" ]]; then
|
|
171
|
+
env BRAINSTORM_DIR="$SESSION_DIR" BRAINSTORM_HOST="$BIND_HOST" BRAINSTORM_URL_HOST="$URL_HOST" BRAINSTORM_OWNER_PID="$OWNER_PID" node server.cjs "--brainstorm-server-id=$SERVER_ID" &
|
|
172
|
+
SERVER_PID=$!
|
|
173
|
+
echo "$SERVER_PID" > "$PID_FILE"
|
|
174
|
+
wait "$SERVER_PID"
|
|
175
|
+
exit $?
|
|
176
|
+
fi
|
|
177
|
+
|
|
178
|
+
# Start server, capturing output to log file
|
|
179
|
+
# Use nohup to survive shell exit; disown to remove from job table
|
|
180
|
+
nohup env BRAINSTORM_DIR="$SESSION_DIR" BRAINSTORM_HOST="$BIND_HOST" BRAINSTORM_URL_HOST="$URL_HOST" BRAINSTORM_OWNER_PID="$OWNER_PID" node server.cjs "--brainstorm-server-id=$SERVER_ID" > "$LOG_FILE" 2>&1 &
|
|
181
|
+
SERVER_PID=$!
|
|
182
|
+
disown "$SERVER_PID" 2>/dev/null
|
|
183
|
+
echo "$SERVER_PID" > "$PID_FILE"
|
|
184
|
+
|
|
185
|
+
# Wait for server-started message (check log file)
|
|
186
|
+
for _ in {1..50}; do
|
|
187
|
+
if grep -q "server-started" "$LOG_FILE" 2>/dev/null; then
|
|
188
|
+
# Verify server is still alive after a short window (catches process reapers)
|
|
189
|
+
alive="true"
|
|
190
|
+
for _ in {1..20}; do
|
|
191
|
+
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
|
192
|
+
alive="false"
|
|
193
|
+
break
|
|
194
|
+
fi
|
|
195
|
+
sleep 0.1
|
|
196
|
+
done
|
|
197
|
+
if [[ "$alive" != "true" ]]; then
|
|
198
|
+
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\"}"
|
|
199
|
+
exit 1
|
|
200
|
+
fi
|
|
201
|
+
grep "server-started" "$LOG_FILE" | head -1
|
|
202
|
+
exit 0
|
|
203
|
+
fi
|
|
204
|
+
sleep 0.1
|
|
205
|
+
done
|
|
206
|
+
|
|
207
|
+
# Timeout - server didn't start
|
|
208
|
+
echo '{"error": "Server failed to start within 5 seconds"}'
|
|
209
|
+
exit 1
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Stop the brainstorm server and clean up
|
|
3
|
+
# Usage: stop-server.sh <session_dir>
|
|
4
|
+
#
|
|
5
|
+
# Kills the server process. Only deletes session directory if it's
|
|
6
|
+
# under /tmp (ephemeral). Persistent directories (.superpowers/) are
|
|
7
|
+
# kept so mockups can be reviewed later.
|
|
8
|
+
|
|
9
|
+
SESSION_DIR="$1"
|
|
10
|
+
|
|
11
|
+
if [[ -z "$SESSION_DIR" ]]; then
|
|
12
|
+
echo '{"error": "Usage: stop-server.sh <session_dir>"}'
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
STATE_DIR="${SESSION_DIR}/state"
|
|
17
|
+
PID_FILE="${STATE_DIR}/server.pid"
|
|
18
|
+
SERVER_ID_FILE="${STATE_DIR}/server-instance-id"
|
|
19
|
+
|
|
20
|
+
mark_stopped() {
|
|
21
|
+
local reason="$1"
|
|
22
|
+
rm -f "${STATE_DIR}/server-info"
|
|
23
|
+
printf '{"reason":"%s","timestamp":%s}\n' "$reason" "$(date +%s)" > "${STATE_DIR}/server-stopped"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
read_expected_server_id() {
|
|
27
|
+
[[ -f "$SERVER_ID_FILE" ]] || return 1
|
|
28
|
+
local id
|
|
29
|
+
id="$(tr -d '\r\n' < "$SERVER_ID_FILE" 2>/dev/null || true)"
|
|
30
|
+
[[ "$id" =~ ^[A-Za-z0-9_-]{32,64}$ ]] || return 1
|
|
31
|
+
printf '%s\n' "$id"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
command_line_for_pid() {
|
|
35
|
+
local pid="$1"
|
|
36
|
+
if [[ -r "/proc/$pid/cmdline" ]]; then
|
|
37
|
+
tr '\0' '\n' < "/proc/$pid/cmdline" 2>/dev/null || true
|
|
38
|
+
return 0
|
|
39
|
+
fi
|
|
40
|
+
ps -ww -p "$pid" -o command= 2>/dev/null || ps -f -p "$pid" 2>/dev/null | sed '1d' || true
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
command_has_server_id() {
|
|
44
|
+
local pid="$1"
|
|
45
|
+
local expected="$2"
|
|
46
|
+
local expected_arg="--brainstorm-server-id=$expected"
|
|
47
|
+
if [[ -r "/proc/$pid/cmdline" ]]; then
|
|
48
|
+
local arg
|
|
49
|
+
while IFS= read -r -d '' arg || [[ -n "$arg" ]]; do
|
|
50
|
+
[[ "$arg" == "$expected_arg" ]] && return 0
|
|
51
|
+
done < "/proc/$pid/cmdline"
|
|
52
|
+
return 1
|
|
53
|
+
fi
|
|
54
|
+
local command_line
|
|
55
|
+
command_line="$(command_line_for_pid "$pid")"
|
|
56
|
+
[[ -n "$command_line" ]] || return 1
|
|
57
|
+
case " $command_line " in
|
|
58
|
+
*" $expected_arg "*) return 0 ;;
|
|
59
|
+
*) return 1 ;;
|
|
60
|
+
esac
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# Confirm a PID has this session's per-start instance id, not just a familiar
|
|
64
|
+
# process name. Ambiguous or legacy metadata fails closed as stale_pid.
|
|
65
|
+
is_brainstorm_server() {
|
|
66
|
+
kill -0 "$1" 2>/dev/null || return 1
|
|
67
|
+
local expected_id
|
|
68
|
+
expected_id="$(read_expected_server_id)" || return 1
|
|
69
|
+
command_has_server_id "$1" "$expected_id" || return 1
|
|
70
|
+
return 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if [[ -f "$PID_FILE" ]]; then
|
|
74
|
+
pid=$(cat "$PID_FILE")
|
|
75
|
+
|
|
76
|
+
# Refuse to signal a PID we can't prove is our server. A stale pid file may
|
|
77
|
+
# point at an unrelated process after a reboot/PID wraparound.
|
|
78
|
+
if ! is_brainstorm_server "$pid"; then
|
|
79
|
+
rm -f "$PID_FILE" "$SERVER_ID_FILE"
|
|
80
|
+
mark_stopped "stale_pid"
|
|
81
|
+
echo '{"status": "stale_pid"}'
|
|
82
|
+
exit 0
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
# Try to stop gracefully, fallback to force if still alive
|
|
86
|
+
kill "$pid" 2>/dev/null || true
|
|
87
|
+
|
|
88
|
+
# Wait for graceful shutdown (up to ~2s)
|
|
89
|
+
for _ in {1..20}; do
|
|
90
|
+
if ! kill -0 "$pid" 2>/dev/null; then
|
|
91
|
+
break
|
|
92
|
+
fi
|
|
93
|
+
sleep 0.1
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
# If still running, escalate to SIGKILL
|
|
97
|
+
if kill -0 "$pid" 2>/dev/null; then
|
|
98
|
+
kill -9 "$pid" 2>/dev/null || true
|
|
99
|
+
|
|
100
|
+
# Give SIGKILL a moment to take effect
|
|
101
|
+
sleep 0.1
|
|
102
|
+
fi
|
|
103
|
+
|
|
104
|
+
if kill -0 "$pid" 2>/dev/null; then
|
|
105
|
+
echo '{"status": "failed", "error": "process still running"}'
|
|
106
|
+
exit 1
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
rm -f "$PID_FILE" "$SERVER_ID_FILE" "${STATE_DIR}/server.log"
|
|
110
|
+
mark_stopped "stop-server.sh"
|
|
111
|
+
|
|
112
|
+
# Only delete ephemeral /tmp directories
|
|
113
|
+
if [[ "$SESSION_DIR" == /tmp/* ]]; then
|
|
114
|
+
rm -rf "$SESSION_DIR"
|
|
115
|
+
fi
|
|
116
|
+
|
|
117
|
+
echo '{"status": "stopped"}'
|
|
118
|
+
else
|
|
119
|
+
echo '{"status": "not_running"}'
|
|
120
|
+
fi
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "brainstorming",
|
|
3
|
+
"layer": "process",
|
|
4
|
+
"domains": [
|
|
5
|
+
"general",
|
|
6
|
+
"architecture",
|
|
7
|
+
"planning"
|
|
8
|
+
],
|
|
9
|
+
"capabilities": [
|
|
10
|
+
"requirements-exploration",
|
|
11
|
+
"design-options",
|
|
12
|
+
"intent-clarification"
|
|
13
|
+
],
|
|
14
|
+
"triggers": [
|
|
15
|
+
"brainstorm",
|
|
16
|
+
"explore",
|
|
17
|
+
"design",
|
|
18
|
+
"new feature",
|
|
19
|
+
"create app",
|
|
20
|
+
"build",
|
|
21
|
+
"scaffold",
|
|
22
|
+
"from scratch"
|
|
23
|
+
],
|
|
24
|
+
"recommended": [
|
|
25
|
+
"writing-plans"
|
|
26
|
+
],
|
|
27
|
+
"requires": [],
|
|
28
|
+
"conflicts": [],
|
|
29
|
+
"explanation": "Explores intent, requirements, and design choices before initiating construction.",
|
|
30
|
+
"sections": [
|
|
31
|
+
{
|
|
32
|
+
"id": "three-paths",
|
|
33
|
+
"title": "Three Paths",
|
|
34
|
+
"source": "SKILL.md#three-paths"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "anti-pattern-too-simple-to-need-approval",
|
|
38
|
+
"title": "Anti-Pattern: \"Too Simple To Need Approval\"",
|
|
39
|
+
"source": "SKILL.md#anti-pattern-too-simple-to-need-approval"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "red-flags",
|
|
43
|
+
"title": "Red Flags",
|
|
44
|
+
"source": "SKILL.md#red-flags"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "checklist",
|
|
48
|
+
"title": "Checklist",
|
|
49
|
+
"source": "SKILL.md#checklist"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "process-flow",
|
|
53
|
+
"title": "Process Flow",
|
|
54
|
+
"source": "SKILL.md#process-flow"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "the-process",
|
|
58
|
+
"title": "The Process",
|
|
59
|
+
"source": "SKILL.md#the-process"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "after-the-design-architectural-path",
|
|
63
|
+
"title": "After the Design (architectural path)",
|
|
64
|
+
"source": "SKILL.md#after-the-design-architectural-path"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "visual-companion",
|
|
68
|
+
"title": "Visual Companion",
|
|
69
|
+
"source": "SKILL.md#visual-companion"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"checks": []
|
|
73
|
+
}
|
|
@@ -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
|