@yunhozz/arc 0.3.3 → 0.3.5
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/MANIFEST.sha256 +80 -122
- package/README.md +3 -3
- package/claude/skill/SKILL.md +1 -0
- package/claude/skill/references/coordination.md +5 -3
- package/claude/skill/references/git-recovery.md +5 -0
- package/claude/skill/references/handoff-prep.md +6 -8
- package/claude/skill/references/handoff.md +4 -4
- package/claude/skill/references/planning.md +5 -0
- package/claude/skill/references/worktree-creation.md +14 -0
- package/codex/skill/references/coordination.md +5 -3
- package/codex/skill/references/git-recovery.md +1 -5
- package/codex/skill/references/worktree-creation.md +20 -0
- package/lib/installer/manifest.mjs +10 -9
- package/lib/installer/package-references.mjs +2 -2
- package/lib/installer/plan.mjs +3 -1
- package/lib/installer/skill-sources.mjs +23 -0
- package/lib/installer/superpowers.mjs +5 -5
- package/lib/runtime/bootstrap.mjs +1 -1
- package/lib/runtime/local-cli.mjs +10 -20
- package/lib/runtime/role-bridge.mjs +2 -4
- package/lib/runtime/role-dispatch-policy.mjs +4 -9
- package/lib/runtime/role-routing.mjs +1 -2
- package/lib/watch/dispatch.mjs +10 -2
- package/lib/watch/git.mjs +4 -2
- package/lib/watch/index.mjs +16 -8
- package/lib/watch/model.mjs +8 -4
- package/lib/watch/normalize-claude.mjs +83 -6
- package/lib/watch/normalize-codex.mjs +15 -11
- package/lib/watch/render.mjs +73 -19
- package/lib/watch/scope.mjs +5 -5
- package/lib/watch/watcher.mjs +110 -10
- package/package.json +2 -1
- package/scripts/check-installer-parity.mjs +3 -1
- package/scripts/update-manifest.mjs +1 -1
- package/scripts/update-runtime-assets.mjs +1 -1
- package/{codex → shared}/skill/references/handoff-worktree.md +17 -16
- package/{codex → shared}/skill/runtime/bootstrap.mjs +1 -1
- package/{codex → shared}/skill/runtime/local-cli.mjs +10 -20
- package/{codex → shared}/skill/runtime/role-bridge.mjs +2 -4
- package/{claude → shared}/skill/runtime/role-dispatch-policy.mjs +4 -9
- package/{claude → shared}/skill/runtime/role-routing.mjs +1 -2
- package/claude/skill/runtime/bootstrap.mjs +0 -38
- package/claude/skill/runtime/local-cli.mjs +0 -248
- package/claude/skill/runtime/role-bridge.mjs +0 -227
- package/codex/skill/references/brainstorming.md +0 -316
- package/codex/skill/references/builder-check-prompt.md +0 -23
- package/codex/skill/references/scripts/frame-template.html +0 -213
- package/codex/skill/references/scripts/helper.js +0 -167
- package/codex/skill/references/scripts/server.cjs +0 -723
- package/codex/skill/references/scripts/start-server.sh +0 -216
- package/codex/skill/references/scripts/stop-server.sh +0 -120
- package/codex/skill/references/superpowers-LICENSE +0 -21
- package/codex/skill/references/superpowers-provenance.json +0 -26
- package/codex/skill/references/test-driven-development.md +0 -330
- package/codex/skill/references/visual-companion.md +0 -299
- package/codex/skill/references/writing-good-tests.md +0 -198
- package/codex/skill/references/writing-plans.md +0 -204
- package/codex/skill/runtime/acceptance.mjs +0 -68
- package/codex/skill/runtime/adapters/claude.mjs +0 -86
- package/codex/skill/runtime/adapters/codex.mjs +0 -65
- package/codex/skill/runtime/assignment.mjs +0 -42
- package/codex/skill/runtime/capabilities.mjs +0 -44
- package/codex/skill/runtime/cli.mjs +0 -8
- package/codex/skill/runtime/command.mjs +0 -38
- package/codex/skill/runtime/cooperative-schema.mjs +0 -87
- package/codex/skill/runtime/cooperative.mjs +0 -239
- package/codex/skill/runtime/evaluate.mjs +0 -331
- package/codex/skill/runtime/external.mjs +0 -51
- package/codex/skill/runtime/gate.mjs +0 -71
- package/codex/skill/runtime/git-evidence.mjs +0 -258
- package/codex/skill/runtime/git-query.mjs +0 -88
- package/codex/skill/runtime/identity.mjs +0 -49
- package/codex/skill/runtime/operations.mjs +0 -6
- package/codex/skill/runtime/role-bridge-args.mjs +0 -148
- package/codex/skill/runtime/role-dispatch-policy.mjs +0 -110
- package/codex/skill/runtime/role-dispatch-store.mjs +0 -134
- package/codex/skill/runtime/role-observe.mjs +0 -299
- package/codex/skill/runtime/role-policy.json +0 -654
- package/codex/skill/runtime/role-routing-config.mjs +0 -19
- package/codex/skill/runtime/role-routing.mjs +0 -233
- package/codex/skill/runtime/role-supervisor.mjs +0 -356
- package/codex/skill/runtime/schema.mjs +0 -98
- package/codex/skill/runtime/scope.mjs +0 -36
- package/codex/skill/runtime/store.mjs +0 -94
- package/codex/skill/runtime/target-preparation.mjs +0 -110
- package/codex/skill/runtime/verification.mjs +0 -125
- /package/{claude → shared}/skill/references/brainstorming.md +0 -0
- /package/{claude → shared}/skill/references/builder-check-prompt.md +0 -0
- /package/{claude → shared}/skill/references/scripts/frame-template.html +0 -0
- /package/{claude → shared}/skill/references/scripts/helper.js +0 -0
- /package/{claude → shared}/skill/references/scripts/server.cjs +0 -0
- /package/{claude → shared}/skill/references/scripts/start-server.sh +0 -0
- /package/{claude → shared}/skill/references/scripts/stop-server.sh +0 -0
- /package/{claude → shared}/skill/references/superpowers-LICENSE +0 -0
- /package/{claude → shared}/skill/references/superpowers-provenance.json +0 -0
- /package/{claude → shared}/skill/references/test-driven-development.md +0 -0
- /package/{claude → shared}/skill/references/visual-companion.md +0 -0
- /package/{claude → shared}/skill/references/writing-good-tests.md +0 -0
- /package/{claude → shared}/skill/references/writing-plans.md +0 -0
- /package/{claude → shared}/skill/runtime/acceptance.mjs +0 -0
- /package/{claude → shared}/skill/runtime/adapters/claude.mjs +0 -0
- /package/{claude → shared}/skill/runtime/adapters/codex.mjs +0 -0
- /package/{claude → shared}/skill/runtime/assignment.mjs +0 -0
- /package/{claude → shared}/skill/runtime/capabilities.mjs +0 -0
- /package/{claude → shared}/skill/runtime/cli.mjs +0 -0
- /package/{claude → shared}/skill/runtime/command.mjs +0 -0
- /package/{claude → shared}/skill/runtime/cooperative-schema.mjs +0 -0
- /package/{claude → shared}/skill/runtime/cooperative.mjs +0 -0
- /package/{claude → shared}/skill/runtime/evaluate.mjs +0 -0
- /package/{claude → shared}/skill/runtime/external.mjs +0 -0
- /package/{claude → shared}/skill/runtime/gate.mjs +0 -0
- /package/{claude → shared}/skill/runtime/git-evidence.mjs +0 -0
- /package/{claude → shared}/skill/runtime/git-query.mjs +0 -0
- /package/{claude → shared}/skill/runtime/identity.mjs +0 -0
- /package/{claude → shared}/skill/runtime/operations.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-bridge-args.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-dispatch-store.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-observe.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-policy.json +0 -0
- /package/{claude → shared}/skill/runtime/role-routing-config.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-supervisor.mjs +0 -0
- /package/{claude → shared}/skill/runtime/schema.mjs +0 -0
- /package/{claude → shared}/skill/runtime/scope.mjs +0 -0
- /package/{claude → shared}/skill/runtime/store.mjs +0 -0
- /package/{claude → shared}/skill/runtime/target-preparation.mjs +0 -0
- /package/{claude → shared}/skill/runtime/verification.mjs +0 -0
|
@@ -1,216 +0,0 @@
|
|
|
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
|
-
# Make the project dir absolute now: the script cds into its own directory
|
|
118
|
-
# before starting the server, which would re-root a relative path there.
|
|
119
|
-
# mkdir -p keeps the existing behavior of creating a missing project dir.
|
|
120
|
-
if ! PROJECT_DIR="$(mkdir -p -- "$PROJECT_DIR" && CDPATH='' cd -- "$PROJECT_DIR" && pwd)"; then
|
|
121
|
-
echo "{\"error\": \"Cannot create or enter --project-dir\"}"
|
|
122
|
-
exit 1
|
|
123
|
-
fi
|
|
124
|
-
SESSION_DIR="${PROJECT_DIR}/.superpowers/brainstorm/${SESSION_ID}"
|
|
125
|
-
# Persist the bound port and key per project so a restart reuses them and an
|
|
126
|
-
# already-open browser tab reconnects to the same URL with a valid cookie.
|
|
127
|
-
export BRAINSTORM_PORT_FILE="${PROJECT_DIR}/.superpowers/brainstorm/.last-port"
|
|
128
|
-
export BRAINSTORM_TOKEN_FILE="${PROJECT_DIR}/.superpowers/brainstorm/.last-token"
|
|
129
|
-
else
|
|
130
|
-
SESSION_DIR="/tmp/brainstorm-${SESSION_ID}"
|
|
131
|
-
fi
|
|
132
|
-
|
|
133
|
-
STATE_DIR="${SESSION_DIR}/state"
|
|
134
|
-
PID_FILE="${STATE_DIR}/server.pid"
|
|
135
|
-
LOG_FILE="${STATE_DIR}/server.log"
|
|
136
|
-
SERVER_ID_FILE="${STATE_DIR}/server-instance-id"
|
|
137
|
-
|
|
138
|
-
# Create fresh session directory with content and state peers
|
|
139
|
-
mkdir -p "${SESSION_DIR}/content" "$STATE_DIR"
|
|
140
|
-
|
|
141
|
-
SERVER_ID=""
|
|
142
|
-
if [[ -r /dev/urandom ]]; then
|
|
143
|
-
SERVER_ID="$(od -An -N24 -tx1 /dev/urandom 2>/dev/null | tr -d ' \n' || true)"
|
|
144
|
-
fi
|
|
145
|
-
if ! [[ "$SERVER_ID" =~ ^[A-Za-z0-9_-]{32,64}$ ]]; then
|
|
146
|
-
SERVER_ID="$(printf '%08x%08x%08x%08x' "$$" "$(date +%s)" "${RANDOM:-0}" "${RANDOM:-0}")"
|
|
147
|
-
fi
|
|
148
|
-
printf '%s\n' "$SERVER_ID" > "$SERVER_ID_FILE"
|
|
149
|
-
chmod 600 "$SERVER_ID_FILE" 2>/dev/null || true
|
|
150
|
-
|
|
151
|
-
# Kill any existing server
|
|
152
|
-
if [[ -f "$PID_FILE" ]]; then
|
|
153
|
-
old_pid=$(cat "$PID_FILE")
|
|
154
|
-
kill "$old_pid" 2>/dev/null
|
|
155
|
-
rm -f "$PID_FILE"
|
|
156
|
-
fi
|
|
157
|
-
|
|
158
|
-
cd "$SCRIPT_DIR" || exit 1
|
|
159
|
-
|
|
160
|
-
# Resolve the harness PID (grandparent of this script).
|
|
161
|
-
# $PPID is the ephemeral shell the harness spawned to run us — it dies
|
|
162
|
-
# when this script exits. The harness itself is $PPID's parent.
|
|
163
|
-
OWNER_PID="$(ps -o ppid= -p "$PPID" 2>/dev/null | tr -d ' ')"
|
|
164
|
-
if [[ -z "$OWNER_PID" || "$OWNER_PID" == "1" ]]; then
|
|
165
|
-
OWNER_PID="$PPID"
|
|
166
|
-
fi
|
|
167
|
-
|
|
168
|
-
# Windows/MSYS2: Node.js cannot see POSIX PIDs from the MSYS2 namespace.
|
|
169
|
-
# Passing a PID node cannot verify causes server to log owner-pid-invalid
|
|
170
|
-
# and self-terminate at the 60-second lifecycle check. Clear it so the
|
|
171
|
-
# watchdog is disabled and the idle timeout becomes the only shutdown trigger.
|
|
172
|
-
if is_windows_like_shell; then
|
|
173
|
-
OWNER_PID=""
|
|
174
|
-
fi
|
|
175
|
-
|
|
176
|
-
# Foreground mode for environments that reap detached/background processes.
|
|
177
|
-
if [[ "$FOREGROUND" == "true" ]]; then
|
|
178
|
-
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" &
|
|
179
|
-
SERVER_PID=$!
|
|
180
|
-
echo "$SERVER_PID" > "$PID_FILE"
|
|
181
|
-
wait "$SERVER_PID"
|
|
182
|
-
exit $?
|
|
183
|
-
fi
|
|
184
|
-
|
|
185
|
-
# Start server, capturing output to log file
|
|
186
|
-
# Use nohup to survive shell exit; disown to remove from job table
|
|
187
|
-
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 &
|
|
188
|
-
SERVER_PID=$!
|
|
189
|
-
disown "$SERVER_PID" 2>/dev/null
|
|
190
|
-
echo "$SERVER_PID" > "$PID_FILE"
|
|
191
|
-
|
|
192
|
-
# Wait for server-started message (check log file)
|
|
193
|
-
for _ in {1..50}; do
|
|
194
|
-
if grep -q "server-started" "$LOG_FILE" 2>/dev/null; then
|
|
195
|
-
# Verify server is still alive after a short window (catches process reapers)
|
|
196
|
-
alive="true"
|
|
197
|
-
for _ in {1..20}; do
|
|
198
|
-
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
|
199
|
-
alive="false"
|
|
200
|
-
break
|
|
201
|
-
fi
|
|
202
|
-
sleep 0.1
|
|
203
|
-
done
|
|
204
|
-
if [[ "$alive" != "true" ]]; then
|
|
205
|
-
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\"}"
|
|
206
|
-
exit 1
|
|
207
|
-
fi
|
|
208
|
-
grep "server-started" "$LOG_FILE" | head -1
|
|
209
|
-
exit 0
|
|
210
|
-
fi
|
|
211
|
-
sleep 0.1
|
|
212
|
-
done
|
|
213
|
-
|
|
214
|
-
# Timeout - server didn't start
|
|
215
|
-
echo '{"error": "Server failed to start within 5 seconds"}'
|
|
216
|
-
exit 1
|
|
@@ -1,120 +0,0 @@
|
|
|
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
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Jesse Vincent
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": 1,
|
|
3
|
-
"repository": "https://github.com/obra/superpowers",
|
|
4
|
-
"revision": "22f0b463e7a5e579904dd6211a520321035526f7",
|
|
5
|
-
"fetchedAt": "2026-11-06T16:48:59.704Z",
|
|
6
|
-
"skills": [
|
|
7
|
-
"brainstorming",
|
|
8
|
-
"writing-plans",
|
|
9
|
-
"test-driven-development"
|
|
10
|
-
],
|
|
11
|
-
"files": {
|
|
12
|
-
"LICENSE": "a37e0e9697144819e1d965176ac4ae5bc3fa02d11e7812036bbcadf6dafe2400",
|
|
13
|
-
"brainstorming/SKILL.md": "2c9ca71f94886f9ca9f4aef055f7cafb3e1a9bdf3aeebf8f4cb547c69405d207",
|
|
14
|
-
"brainstorming/builder-check-prompt.md": "36d51a4723d6f0a3ce5811a0ea3b3a8424f07533947e1355f5d8cb8cce40c55e",
|
|
15
|
-
"brainstorming/scripts/frame-template.html": "6a8a4e58bd6a44b904e2e3c57de774481d909204597e1498de53f1b2fecc4c4e",
|
|
16
|
-
"brainstorming/scripts/helper.js": "43c6d69954a46ec34a2a262bcc62a9a7e83e839c739f199cb72646d397c686e3",
|
|
17
|
-
"brainstorming/scripts/server.cjs": "763abf96510e0b892a1141397b31aa82ef900cf87ed34dde94bc8782baf4a7ca",
|
|
18
|
-
"brainstorming/scripts/start-server.sh": "314dd68dc00e8dd94c7491aca8a5f004c7fddffc161e2b07482f29f48d13659a",
|
|
19
|
-
"brainstorming/scripts/stop-server.sh": "0b5ccbbd57f62d3ed88993f7940b5ee0e5c0fc9b21c550c623da4f6292e47daf",
|
|
20
|
-
"brainstorming/visual-companion.md": "6ffcb038b53254bd31debaa15e12dcd4ff24bd63d690e0b644ac6396701cf2e2",
|
|
21
|
-
"writing-plans/SKILL.md": "a6c67c1900064347c2a329990dd3c555657c51c3ec53b259a08aa01a2c26139a",
|
|
22
|
-
"test-driven-development/SKILL.md": "64b03fce4aee5a97a93160cea8111f3ba13a17b7c001db4bd5836d67fd10705d",
|
|
23
|
-
"test-driven-development/writing-good-tests.md": "51471c853306ff92ca8bb41dcaea05f31c0e46b03651f8f3c99754b7172f4ae1"
|
|
24
|
-
},
|
|
25
|
-
"links": {}
|
|
26
|
-
}
|