mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 11:45:20 +02:00
a64d70ba35
Rebumped v1.8.0.0 -> v1.11.0.0 (minor-past main's v1.10.1.0) using bin/gstack-next-version — the same queue-aware path this branch introduces. CHANGELOG repositioned so v1.11.0.0 sits above main's new entries (v1.10.1.0 / v1.10.0.0 / v1.9.0.0). Conflicts resolved: - VERSION, package.json: rebumped to v1.11.0.0 (util-picked) - bin/gstack-config: merged both lists (workspace_root + gbrain keys) - CHANGELOG.md: hoisted v1.11.0.0 entry above main's new entries Pre-existing failures in main (4) documented but not fixed in this PR: 1. gstack-brain-sync secret scan > blocks bearer-json (brain-sync tests) 2. no files larger than 2MB (security-bench fixture, already TODO'd) 3. selectTests > skill-specific change (touchfiles scoping) 4. Opus 4.7 overlay pacing directive (expectation stale after v1.10.1.0 removed the Fan out nudge) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
56 lines
1.9 KiB
Bash
Executable File
56 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# gstack-brain-enqueue — atomically append a path to the GBrain sync queue.
|
|
#
|
|
# Usage:
|
|
# gstack-brain-enqueue <file-path>
|
|
#
|
|
# Called by writer scripts (gstack-learnings-log, gstack-timeline-log, etc.)
|
|
# after their local write. Fire-and-forget; failures are silent (never blocks
|
|
# the writer). Queue is drained by `gstack-brain-sync --once` invoked from the
|
|
# preamble at skill START and END boundaries.
|
|
#
|
|
# No-op when:
|
|
# - gbrain_sync_mode is off (the default)
|
|
# - ~/.gstack/.git doesn't exist (feature not initialized)
|
|
# - <file-path> matches a line in ~/.gstack/.brain-skip.txt
|
|
#
|
|
# Env:
|
|
# GSTACK_HOME — override ~/.gstack state directory (aligns with writers).
|
|
# Tests use GSTACK_HOME=/tmp/test-$$ for isolation.
|
|
#
|
|
# Concurrency: POSIX append is atomic up to PIPE_BUF (~4KB Linux, 512 BSD).
|
|
# Queue lines are ~200 bytes, safe under concurrent callers.
|
|
|
|
# No `-e` — writer shims rely on this never failing loudly.
|
|
set -uo pipefail
|
|
|
|
FILE="${1:-}"
|
|
[ -z "$FILE" ] && exit 0
|
|
|
|
GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}"
|
|
QUEUE="$GSTACK_HOME/.brain-queue.jsonl"
|
|
SKIP_FILE="$GSTACK_HOME/.brain-skip.txt"
|
|
|
|
# Fast exits: no git repo, no sync.
|
|
[ ! -d "$GSTACK_HOME/.git" ] && exit 0
|
|
|
|
# Check sync mode. off → silent no-op.
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)"
|
|
MODE=$("$SCRIPT_DIR/gstack-config" get gbrain_sync_mode 2>/dev/null || echo off)
|
|
[ "$MODE" = "off" ] && exit 0
|
|
|
|
# User-maintained skip list (for secret-scan false positives).
|
|
if [ -f "$SKIP_FILE" ]; then
|
|
if grep -Fxq "$FILE" "$SKIP_FILE" 2>/dev/null; then
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# JSON-escape the file path (backslash + quotes only; paths shouldn't have other specials).
|
|
ESC_FILE=$(printf '%s' "$FILE" | sed 's/\\/\\\\/g; s/"/\\"/g')
|
|
TS=$(date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || echo "")
|
|
|
|
printf '{"file":"%s","ts":"%s"}\n' "$ESC_FILE" "$TS" >> "$QUEUE" 2>/dev/null
|
|
|
|
exit 0
|