From 756525100c97f645e50272dc06eb7d3afef33ec9 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 22 Apr 2026 13:58:41 -0700 Subject: [PATCH] chore: regenerate SKILL.md files for gbrain-sync preamble block Re-runs bun run gen:skill-docs after adding generateBrainSyncBlock to scripts/resolvers/preamble.ts in a2aa8a07. CI check-freshness caught the drift. All 36 SKILL.md files regenerated with the new skill-start bash block + privacy-gate prose + skill-end sync instructions baked in. --- SKILL.md | 99 ++++++++++++++++++++++++++++++++++ autoplan/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ benchmark-models/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ benchmark/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ browse/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ canary/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ codex/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ context-restore/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ context-save/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ cso/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ design-consultation/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ design-html/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ design-review/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ design-shotgun/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ devex-review/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ document-release/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ health/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ investigate/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ land-and-deploy/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ learn/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ make-pdf/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ office-hours/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ open-gstack-browser/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ pair-agent/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ plan-ceo-review/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ plan-design-review/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ plan-devex-review/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ plan-eng-review/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ plan-tune/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ qa-only/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ qa/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ retro/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ review/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ setup-browser-cookies/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ setup-deploy/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ ship/SKILL.md | 99 ++++++++++++++++++++++++++++++++++ 36 files changed, 3564 insertions(+) diff --git a/SKILL.md b/SKILL.md index 95f22604..ec979715 100644 --- a/SKILL.md +++ b/SKILL.md @@ -349,6 +349,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/autoplan/SKILL.md b/autoplan/SKILL.md index 9b7c7f32..5bde59fd 100644 --- a/autoplan/SKILL.md +++ b/autoplan/SKILL.md @@ -358,6 +358,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/benchmark-models/SKILL.md b/benchmark-models/SKILL.md index 078c5c92..516dc4bd 100644 --- a/benchmark-models/SKILL.md +++ b/benchmark-models/SKILL.md @@ -351,6 +351,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/benchmark/SKILL.md b/benchmark/SKILL.md index ae22b509..9e7f12cc 100644 --- a/benchmark/SKILL.md +++ b/benchmark/SKILL.md @@ -351,6 +351,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/browse/SKILL.md b/browse/SKILL.md index 864644a0..64f68246 100644 --- a/browse/SKILL.md +++ b/browse/SKILL.md @@ -350,6 +350,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/canary/SKILL.md b/canary/SKILL.md index af8c7dd4..11502d60 100644 --- a/canary/SKILL.md +++ b/canary/SKILL.md @@ -350,6 +350,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/codex/SKILL.md b/codex/SKILL.md index 4eda87fd..2c11fda5 100644 --- a/codex/SKILL.md +++ b/codex/SKILL.md @@ -352,6 +352,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/context-restore/SKILL.md b/context-restore/SKILL.md index 8e3bf814..996abc3a 100644 --- a/context-restore/SKILL.md +++ b/context-restore/SKILL.md @@ -354,6 +354,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/context-save/SKILL.md b/context-save/SKILL.md index 04370e7e..3e179a49 100644 --- a/context-save/SKILL.md +++ b/context-save/SKILL.md @@ -354,6 +354,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/cso/SKILL.md b/cso/SKILL.md index b020255f..36d68530 100644 --- a/cso/SKILL.md +++ b/cso/SKILL.md @@ -355,6 +355,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/design-consultation/SKILL.md b/design-consultation/SKILL.md index c05f240c..70e6900e 100644 --- a/design-consultation/SKILL.md +++ b/design-consultation/SKILL.md @@ -355,6 +355,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/design-html/SKILL.md b/design-html/SKILL.md index 44e9b788..2ba7c3fe 100644 --- a/design-html/SKILL.md +++ b/design-html/SKILL.md @@ -357,6 +357,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/design-review/SKILL.md b/design-review/SKILL.md index 6cbe3c45..555658b3 100644 --- a/design-review/SKILL.md +++ b/design-review/SKILL.md @@ -355,6 +355,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/design-shotgun/SKILL.md b/design-shotgun/SKILL.md index e078d683..63d330bf 100644 --- a/design-shotgun/SKILL.md +++ b/design-shotgun/SKILL.md @@ -352,6 +352,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/devex-review/SKILL.md b/devex-review/SKILL.md index 790c97b7..91f0f687 100644 --- a/devex-review/SKILL.md +++ b/devex-review/SKILL.md @@ -355,6 +355,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/document-release/SKILL.md b/document-release/SKILL.md index 999e4ffe..04afd8a4 100644 --- a/document-release/SKILL.md +++ b/document-release/SKILL.md @@ -352,6 +352,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/health/SKILL.md b/health/SKILL.md index ac9bc4b2..1bb4f800 100644 --- a/health/SKILL.md +++ b/health/SKILL.md @@ -352,6 +352,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/investigate/SKILL.md b/investigate/SKILL.md index 31c66149..e740cfbb 100644 --- a/investigate/SKILL.md +++ b/investigate/SKILL.md @@ -369,6 +369,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/land-and-deploy/SKILL.md b/land-and-deploy/SKILL.md index 2fd7a7d9..974194f5 100644 --- a/land-and-deploy/SKILL.md +++ b/land-and-deploy/SKILL.md @@ -349,6 +349,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/learn/SKILL.md b/learn/SKILL.md index bac6abd6..62501d7d 100644 --- a/learn/SKILL.md +++ b/learn/SKILL.md @@ -352,6 +352,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/make-pdf/SKILL.md b/make-pdf/SKILL.md index 8414a346..0d74fb1a 100644 --- a/make-pdf/SKILL.md +++ b/make-pdf/SKILL.md @@ -350,6 +350,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/office-hours/SKILL.md b/office-hours/SKILL.md index 7d3be39d..ff8f700e 100644 --- a/office-hours/SKILL.md +++ b/office-hours/SKILL.md @@ -360,6 +360,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/open-gstack-browser/SKILL.md b/open-gstack-browser/SKILL.md index 9867e8a4..9ed9bcb7 100644 --- a/open-gstack-browser/SKILL.md +++ b/open-gstack-browser/SKILL.md @@ -349,6 +349,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/pair-agent/SKILL.md b/pair-agent/SKILL.md index e8e4e941..0c3a4602 100644 --- a/pair-agent/SKILL.md +++ b/pair-agent/SKILL.md @@ -350,6 +350,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/plan-ceo-review/SKILL.md b/plan-ceo-review/SKILL.md index f01e8404..07b201f8 100644 --- a/plan-ceo-review/SKILL.md +++ b/plan-ceo-review/SKILL.md @@ -356,6 +356,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/plan-design-review/SKILL.md b/plan-design-review/SKILL.md index 6a7303ff..84987cac 100644 --- a/plan-design-review/SKILL.md +++ b/plan-design-review/SKILL.md @@ -353,6 +353,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/plan-devex-review/SKILL.md b/plan-devex-review/SKILL.md index b66ed978..ed34fcde 100644 --- a/plan-devex-review/SKILL.md +++ b/plan-devex-review/SKILL.md @@ -357,6 +357,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/plan-eng-review/SKILL.md b/plan-eng-review/SKILL.md index 4fba0494..91470563 100644 --- a/plan-eng-review/SKILL.md +++ b/plan-eng-review/SKILL.md @@ -355,6 +355,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/plan-tune/SKILL.md b/plan-tune/SKILL.md index 9d69bf3b..c21f5a69 100644 --- a/plan-tune/SKILL.md +++ b/plan-tune/SKILL.md @@ -363,6 +363,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/qa-only/SKILL.md b/qa-only/SKILL.md index 9f2f5e88..5f69d327 100644 --- a/qa-only/SKILL.md +++ b/qa-only/SKILL.md @@ -351,6 +351,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/qa/SKILL.md b/qa/SKILL.md index a64c074c..41aa3654 100644 --- a/qa/SKILL.md +++ b/qa/SKILL.md @@ -357,6 +357,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/retro/SKILL.md b/retro/SKILL.md index 92f7a962..8084fca7 100644 --- a/retro/SKILL.md +++ b/retro/SKILL.md @@ -350,6 +350,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/review/SKILL.md b/review/SKILL.md index df1bcf70..a198fb8a 100644 --- a/review/SKILL.md +++ b/review/SKILL.md @@ -354,6 +354,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/setup-browser-cookies/SKILL.md b/setup-browser-cookies/SKILL.md index 3b0160e0..64890e09 100644 --- a/setup-browser-cookies/SKILL.md +++ b/setup-browser-cookies/SKILL.md @@ -347,6 +347,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/setup-deploy/SKILL.md b/setup-deploy/SKILL.md index 6411bde9..d085e7b3 100644 --- a/setup-deploy/SKILL.md +++ b/setup-deploy/SKILL.md @@ -353,6 +353,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are diff --git a/ship/SKILL.md b/ship/SKILL.md index 540a62a1..0ae9ca64 100644 --- a/ship/SKILL.md +++ b/ship/SKILL.md @@ -355,6 +355,105 @@ AI orchestrator (e.g., OpenClaw). In spawned sessions: - Focus on completing the task and reporting results via prose output. - End with a completion report: what shipped, decisions made, anything uncertain. +## GBrain Sync (skill start) + +```bash +# gbrain-sync: drain pending writes, pull once per day. Silent no-op when +# the feature isn't initialized or gbrain_sync_mode is "off". See +# docs/gbrain-sync.md. + +_GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" +_BRAIN_REMOTE_FILE="$HOME/.gstack-brain-remote.txt" +_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync" +_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config" + +_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) + +# New-machine hint: URL file present, local .git missing, sync not yet enabled. +if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then + _BRAIN_NEW_URL=$(head -1 "$_BRAIN_REMOTE_FILE" 2>/dev/null | tr -d '[:space:]') + if [ -n "$_BRAIN_NEW_URL" ]; then + echo "BRAIN_SYNC: brain repo detected: $_BRAIN_NEW_URL" + echo "BRAIN_SYNC: run 'gstack-brain-restore' to pull your cross-machine memory (or 'gstack-config set gbrain_sync_mode off' to dismiss forever)" + fi +fi + +# Active-sync path. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + # Once-per-day pull. + _BRAIN_LAST_PULL_FILE="$_GSTACK_HOME/.brain-last-pull" + _BRAIN_NOW=$(date +%s) + _BRAIN_DO_PULL=1 + if [ -f "$_BRAIN_LAST_PULL_FILE" ]; then + _BRAIN_LAST=$(cat "$_BRAIN_LAST_PULL_FILE" 2>/dev/null || echo 0) + _BRAIN_AGE=$(( _BRAIN_NOW - _BRAIN_LAST )) + [ "$_BRAIN_AGE" -lt 86400 ] && _BRAIN_DO_PULL=0 + fi + if [ "$_BRAIN_DO_PULL" = "1" ]; then + ( cd "$_GSTACK_HOME" && git fetch origin >/dev/null 2>&1 && git merge --ff-only "origin/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1 ) || true + echo "$_BRAIN_NOW" > "$_BRAIN_LAST_PULL_FILE" + fi + # Drain pending queue, push. + "$_BRAIN_SYNC_BIN" --once 2>/dev/null || true +fi + +# Status line — always emitted, easy to grep. +if [ -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" != "off" ]; then + _BRAIN_QUEUE_DEPTH=0 + [ -f "$_GSTACK_HOME/.brain-queue.jsonl" ] && _BRAIN_QUEUE_DEPTH=$(wc -l < "$_GSTACK_HOME/.brain-queue.jsonl" | tr -d ' ') + _BRAIN_LAST_PUSH="never" + [ -f "$_GSTACK_HOME/.brain-last-push" ] && _BRAIN_LAST_PUSH=$(cat "$_GSTACK_HOME/.brain-last-push" 2>/dev/null || echo never) + echo "BRAIN_SYNC: mode=$_BRAIN_SYNC_MODE | last_push=$_BRAIN_LAST_PUSH | queue=$_BRAIN_QUEUE_DEPTH" +else + echo "BRAIN_SYNC: off" +fi +``` + + + +**Privacy stop-gate (fires ONCE per machine).** + +If the bash output shows `BRAIN_SYNC: off` AND the config value +`gbrain_sync_mode_prompted` is `false` AND gbrain is detected on this host +(either `gbrain doctor --fast --json` succeeds or the `gbrain` binary is in PATH), +fire a one-time privacy gate via AskUserQuestion: + +> gstack can publish your session memory (learnings, plans, designs, retros) to a +> private GitHub repo that GBrain indexes across your machines. Higher tiers +> include behavioral data (session timelines, developer profile). How much do you +> want to sync? + +Options: +- A) Everything allowlisted (recommended — maximum cross-machine memory) +- B) Only artifacts (plans, designs, retros, learnings) — skip timelines and profile +- C) Decline — keep everything local + +After the user answers, run (substituting the chosen value): + +```bash +# Chosen mode: full | artifacts-only | off +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode +"$_BRAIN_CONFIG_BIN" set gbrain_sync_mode_prompted true +``` + +If A or B was chosen AND `~/.gstack/.git` doesn't exist, ask a follow-up: +"Set up the GBrain sync repo now? (runs `gstack-brain-init`)" +- A) Yes, run it now +- B) Show me the command, I'll run it myself + +Do not block the skill. Emit the question, continue the skill workflow. The +next skill run picks up wherever this left off. + +**At skill END (before the telemetry block),** run these bash commands to +catch artifact writes (design docs, plans, retros) that skipped the writer +shims, plus drain any still-pending queue entries: + +```bash +"~/.claude/skills/gstack/bin/gstack-brain-sync" --discover-new 2>/dev/null || true +"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true +``` + + ## Model-Specific Behavioral Patch (claude) The following nudges are tuned for the claude model family. They are