mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-21 12:20:48 +02:00
24 lines
981 B
Bash
Executable File
24 lines
981 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# gstack-review-log — atomically log a review result
|
|
# Usage: gstack-review-log '{"skill":"...","timestamp":"...","status":"..."}'
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}"
|
|
eval "$(GSTACK_HOME="$GSTACK_HOME" "$SCRIPT_DIR/gstack-slug" 2>/dev/null)"
|
|
PROJECT_ID="${PROJECT_ID:?gstack project identity unavailable}"
|
|
PROJECT_DIR="$GSTACK_HOME/projects/$PROJECT_ID"
|
|
mkdir -p "$PROJECT_DIR"
|
|
|
|
# Validate: input must be parseable JSON (reject malformed or injection attempts)
|
|
INPUT="$1"
|
|
if ! printf '%s' "$INPUT" | bun -e "JSON.parse(await Bun.stdin.text())" 2>/dev/null; then
|
|
# Not valid JSON — refuse to append
|
|
echo "gstack-review-log: invalid JSON, skipping" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "$INPUT" >> "$PROJECT_DIR/$BRANCH-reviews.jsonl"
|
|
|
|
# gbrain-sync: enqueue for cross-machine sync (no-op if sync is off).
|
|
"$SCRIPT_DIR/gstack-brain-enqueue" "projects/$PROJECT_ID/$BRANCH-reviews.jsonl" 2>/dev/null &
|