mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 11:45:20 +02:00
45638297ba
Adds bin/gstack-brain-enqueue (atomic append to sync queue) and bin/gstack-jsonl-merge (git merge driver, ts-sort with SHA-256 fallback). Wires one backgrounded enqueue call into learnings-log, timeline-log, review-log, and developer-profile --migrate. question-log and question-preferences stay local per Codex v2 decision. gstack-config gains gbrain_sync_mode (off/artifacts-only/full) and gbrain_sync_mode_prompted keys, plus GSTACK_HOME env alignment so tests don't leak into real ~/.gstack/config.yaml.
41 lines
1.6 KiB
Bash
Executable File
41 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# gstack-timeline-log — append a timeline event to the project timeline
|
|
# Usage: gstack-timeline-log '{"skill":"review","event":"started","branch":"main"}'
|
|
#
|
|
# Session timeline: local by default. If the user enables `gbrain_sync_mode`
|
|
# with the `full` (not `artifacts-only`) privacy tier — via the first-run
|
|
# stop-gate from `gstack-brain-init` or the preamble — timeline events are
|
|
# published to the user's private GBrain sync repo. See docs/gbrain-sync.md.
|
|
# Required fields: skill, event (started|completed).
|
|
# Optional: branch, outcome, duration_s, session, ts.
|
|
# Validation failure → skip silently (non-blocking).
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
eval "$("$SCRIPT_DIR/gstack-slug" 2>/dev/null)"
|
|
GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}"
|
|
mkdir -p "$GSTACK_HOME/projects/$SLUG"
|
|
|
|
INPUT="$1"
|
|
|
|
# Validate: input must be parseable JSON with required fields
|
|
if ! printf '%s' "$INPUT" | bun -e "
|
|
const j = JSON.parse(await Bun.stdin.text());
|
|
if (!j.skill || !j.event) process.exit(1);
|
|
" 2>/dev/null; then
|
|
exit 0 # skip silently, non-blocking
|
|
fi
|
|
|
|
# Inject timestamp if not present
|
|
if ! printf '%s' "$INPUT" | bun -e "const j=JSON.parse(await Bun.stdin.text()); if(!j.ts) process.exit(1)" 2>/dev/null; then
|
|
INPUT=$(printf '%s' "$INPUT" | bun -e "
|
|
const j = JSON.parse(await Bun.stdin.text());
|
|
j.ts = new Date().toISOString();
|
|
console.log(JSON.stringify(j));
|
|
" 2>/dev/null) || true
|
|
fi
|
|
|
|
echo "$INPUT" >> "$GSTACK_HOME/projects/$SLUG/timeline.jsonl"
|
|
|
|
# gbrain-sync: enqueue for cross-machine sync (no-op if sync is off).
|
|
"$SCRIPT_DIR/gstack-brain-enqueue" "projects/$SLUG/timeline.jsonl" 2>/dev/null &
|