mirror of
https://github.com/obra/superpowers.git
synced 2026-04-23 18:09:05 +08:00
feat: add sendToClaude helper and wait-for-event tool
- Add sendToClaude() function to browser helper that shows confirmation - Add wait-for-event.sh script for watching server output (tail -f | grep -m 1) - Enables clean event-driven loop: background bash waits for event, completion triggers Claude's turn
This commit is contained in:
20
lib/brainstorm-server/wait-for-event.sh
Executable file
20
lib/brainstorm-server/wait-for-event.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# Wait for a browser event from the brainstorm server
|
||||
# Usage: wait-for-event.sh <output-file> [event-type]
|
||||
#
|
||||
# Blocks until a matching event arrives, then prints it and exits.
|
||||
# Default event type: "send-to-claude"
|
||||
|
||||
OUTPUT_FILE="${1:?Usage: wait-for-event.sh <output-file> [event-type]}"
|
||||
EVENT_TYPE="${2:-send-to-claude}"
|
||||
|
||||
if [[ ! -f "$OUTPUT_FILE" ]]; then
|
||||
echo "Error: Output file not found: $OUTPUT_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Wait for new lines matching the event type
|
||||
# -n 0: start at end (only new content)
|
||||
# -f: follow
|
||||
# grep -m 1: exit after first match
|
||||
tail -n 0 -f "$OUTPUT_FILE" | grep -m 1 "$EVENT_TYPE"
|
||||
Reference in New Issue
Block a user