From a351fb56775731b412795b372495001783197947 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sun, 3 May 2026 20:43:04 -0700 Subject: [PATCH] chore: regenerate SKILL.md across all hosts (gen:skill-docs) Mechanical regeneration after preamble + setup-gbrain template + new sync-gbrain skill. Run via: bun run gen:skill-docs --host all. Co-Authored-By: Claude Opus 4.7 (1M context) --- SKILL.md | 29 +++++++++++++++++++++++++++++ autoplan/SKILL.md | 29 +++++++++++++++++++++++++++++ benchmark-models/SKILL.md | 29 +++++++++++++++++++++++++++++ benchmark/SKILL.md | 29 +++++++++++++++++++++++++++++ browse/SKILL.md | 29 +++++++++++++++++++++++++++++ canary/SKILL.md | 29 +++++++++++++++++++++++++++++ codex/SKILL.md | 29 +++++++++++++++++++++++++++++ context-restore/SKILL.md | 29 +++++++++++++++++++++++++++++ context-save/SKILL.md | 29 +++++++++++++++++++++++++++++ cso/SKILL.md | 29 +++++++++++++++++++++++++++++ design-consultation/SKILL.md | 29 +++++++++++++++++++++++++++++ design-html/SKILL.md | 29 +++++++++++++++++++++++++++++ design-review/SKILL.md | 29 +++++++++++++++++++++++++++++ design-shotgun/SKILL.md | 29 +++++++++++++++++++++++++++++ devex-review/SKILL.md | 29 +++++++++++++++++++++++++++++ document-release/SKILL.md | 29 +++++++++++++++++++++++++++++ health/SKILL.md | 29 +++++++++++++++++++++++++++++ investigate/SKILL.md | 29 +++++++++++++++++++++++++++++ land-and-deploy/SKILL.md | 29 +++++++++++++++++++++++++++++ landing-report/SKILL.md | 29 +++++++++++++++++++++++++++++ learn/SKILL.md | 29 +++++++++++++++++++++++++++++ make-pdf/SKILL.md | 29 +++++++++++++++++++++++++++++ office-hours/SKILL.md | 29 +++++++++++++++++++++++++++++ open-gstack-browser/SKILL.md | 29 +++++++++++++++++++++++++++++ pair-agent/SKILL.md | 29 +++++++++++++++++++++++++++++ plan-ceo-review/SKILL.md | 29 +++++++++++++++++++++++++++++ plan-design-review/SKILL.md | 29 +++++++++++++++++++++++++++++ plan-devex-review/SKILL.md | 29 +++++++++++++++++++++++++++++ plan-eng-review/SKILL.md | 29 +++++++++++++++++++++++++++++ plan-tune/SKILL.md | 29 +++++++++++++++++++++++++++++ qa-only/SKILL.md | 29 +++++++++++++++++++++++++++++ qa/SKILL.md | 29 +++++++++++++++++++++++++++++ retro/SKILL.md | 29 +++++++++++++++++++++++++++++ review/SKILL.md | 29 +++++++++++++++++++++++++++++ scrape/SKILL.md | 29 +++++++++++++++++++++++++++++ setup-browser-cookies/SKILL.md | 29 +++++++++++++++++++++++++++++ setup-deploy/SKILL.md | 29 +++++++++++++++++++++++++++++ ship/SKILL.md | 29 +++++++++++++++++++++++++++++ skillify/SKILL.md | 29 +++++++++++++++++++++++++++++ 39 files changed, 1131 insertions(+) diff --git a/SKILL.md b/SKILL.md index 4f428fb8b..bfa730ca5 100644 --- a/SKILL.md +++ b/SKILL.md @@ -278,6 +278,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/autoplan/SKILL.md b/autoplan/SKILL.md index 628c36ee7..8ec891462 100644 --- a/autoplan/SKILL.md +++ b/autoplan/SKILL.md @@ -346,6 +346,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/benchmark-models/SKILL.md b/benchmark-models/SKILL.md index 6f52cdeae..a774d2c0d 100644 --- a/benchmark-models/SKILL.md +++ b/benchmark-models/SKILL.md @@ -280,6 +280,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/benchmark/SKILL.md b/benchmark/SKILL.md index 3f0d4fff9..b7e135f58 100644 --- a/benchmark/SKILL.md +++ b/benchmark/SKILL.md @@ -280,6 +280,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/browse/SKILL.md b/browse/SKILL.md index 8aa6ac2f1..9a48cd437 100644 --- a/browse/SKILL.md +++ b/browse/SKILL.md @@ -279,6 +279,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/canary/SKILL.md b/canary/SKILL.md index 55837e01f..eb4dc50b6 100644 --- a/canary/SKILL.md +++ b/canary/SKILL.md @@ -338,6 +338,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/codex/SKILL.md b/codex/SKILL.md index 60820dd20..44b5f0ed3 100644 --- a/codex/SKILL.md +++ b/codex/SKILL.md @@ -340,6 +340,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/context-restore/SKILL.md b/context-restore/SKILL.md index a510adbfb..0b8462067 100644 --- a/context-restore/SKILL.md +++ b/context-restore/SKILL.md @@ -342,6 +342,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/context-save/SKILL.md b/context-save/SKILL.md index 45f7a33aa..88e5909ef 100644 --- a/context-save/SKILL.md +++ b/context-save/SKILL.md @@ -342,6 +342,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/cso/SKILL.md b/cso/SKILL.md index 44850ff75..75a9df707 100644 --- a/cso/SKILL.md +++ b/cso/SKILL.md @@ -343,6 +343,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/design-consultation/SKILL.md b/design-consultation/SKILL.md index cf2f852f2..ec1ef026e 100644 --- a/design-consultation/SKILL.md +++ b/design-consultation/SKILL.md @@ -366,6 +366,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/design-html/SKILL.md b/design-html/SKILL.md index ec9f84033..b997772de 100644 --- a/design-html/SKILL.md +++ b/design-html/SKILL.md @@ -345,6 +345,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/design-review/SKILL.md b/design-review/SKILL.md index 96f232350..da5190cef 100644 --- a/design-review/SKILL.md +++ b/design-review/SKILL.md @@ -343,6 +343,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/design-shotgun/SKILL.md b/design-shotgun/SKILL.md index 41d2da137..eb09b2770 100644 --- a/design-shotgun/SKILL.md +++ b/design-shotgun/SKILL.md @@ -360,6 +360,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/devex-review/SKILL.md b/devex-review/SKILL.md index 2854789d3..530300274 100644 --- a/devex-review/SKILL.md +++ b/devex-review/SKILL.md @@ -343,6 +343,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/document-release/SKILL.md b/document-release/SKILL.md index 3394ce40c..d863a99de 100644 --- a/document-release/SKILL.md +++ b/document-release/SKILL.md @@ -340,6 +340,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/health/SKILL.md b/health/SKILL.md index a4c63c00f..39bc7e8fe 100644 --- a/health/SKILL.md +++ b/health/SKILL.md @@ -340,6 +340,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/investigate/SKILL.md b/investigate/SKILL.md index 44f9a4032..00de65935 100644 --- a/investigate/SKILL.md +++ b/investigate/SKILL.md @@ -379,6 +379,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/land-and-deploy/SKILL.md b/land-and-deploy/SKILL.md index 04ed85c06..afb47cbe0 100644 --- a/land-and-deploy/SKILL.md +++ b/land-and-deploy/SKILL.md @@ -337,6 +337,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/landing-report/SKILL.md b/landing-report/SKILL.md index 3aec38e71..111cbbf81 100644 --- a/landing-report/SKILL.md +++ b/landing-report/SKILL.md @@ -338,6 +338,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/learn/SKILL.md b/learn/SKILL.md index c921c5f93..9e0d739e6 100644 --- a/learn/SKILL.md +++ b/learn/SKILL.md @@ -340,6 +340,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/make-pdf/SKILL.md b/make-pdf/SKILL.md index 4e9a3c398..cc2e5f68d 100644 --- a/make-pdf/SKILL.md +++ b/make-pdf/SKILL.md @@ -279,6 +279,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/office-hours/SKILL.md b/office-hours/SKILL.md index 836a041fb..ed160ea61 100644 --- a/office-hours/SKILL.md +++ b/office-hours/SKILL.md @@ -375,6 +375,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/open-gstack-browser/SKILL.md b/open-gstack-browser/SKILL.md index 86ce4ece2..d927c042b 100644 --- a/open-gstack-browser/SKILL.md +++ b/open-gstack-browser/SKILL.md @@ -337,6 +337,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/pair-agent/SKILL.md b/pair-agent/SKILL.md index 0fa3f98eb..2e028e8e2 100644 --- a/pair-agent/SKILL.md +++ b/pair-agent/SKILL.md @@ -338,6 +338,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/plan-ceo-review/SKILL.md b/plan-ceo-review/SKILL.md index 6543257d6..42344be3b 100644 --- a/plan-ceo-review/SKILL.md +++ b/plan-ceo-review/SKILL.md @@ -369,6 +369,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/plan-design-review/SKILL.md b/plan-design-review/SKILL.md index 5afbedbec..d6ae70135 100644 --- a/plan-design-review/SKILL.md +++ b/plan-design-review/SKILL.md @@ -342,6 +342,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/plan-devex-review/SKILL.md b/plan-devex-review/SKILL.md index ff059c4ab..22c508b38 100644 --- a/plan-devex-review/SKILL.md +++ b/plan-devex-review/SKILL.md @@ -346,6 +346,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/plan-eng-review/SKILL.md b/plan-eng-review/SKILL.md index 53da6b237..b57693ca0 100644 --- a/plan-eng-review/SKILL.md +++ b/plan-eng-review/SKILL.md @@ -344,6 +344,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/plan-tune/SKILL.md b/plan-tune/SKILL.md index bfdfbaeea..f2f9d769c 100644 --- a/plan-tune/SKILL.md +++ b/plan-tune/SKILL.md @@ -351,6 +351,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/qa-only/SKILL.md b/qa-only/SKILL.md index bfa697642..ee683d851 100644 --- a/qa-only/SKILL.md +++ b/qa-only/SKILL.md @@ -339,6 +339,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/qa/SKILL.md b/qa/SKILL.md index 85b1598a5..b02157236 100644 --- a/qa/SKILL.md +++ b/qa/SKILL.md @@ -345,6 +345,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/retro/SKILL.md b/retro/SKILL.md index 2b7385118..0cef5a25d 100644 --- a/retro/SKILL.md +++ b/retro/SKILL.md @@ -357,6 +357,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/review/SKILL.md b/review/SKILL.md index 112e3c53d..921905d3d 100644 --- a/review/SKILL.md +++ b/review/SKILL.md @@ -342,6 +342,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/scrape/SKILL.md b/scrape/SKILL.md index 1a7c9072b..60a8f2942 100644 --- a/scrape/SKILL.md +++ b/scrape/SKILL.md @@ -338,6 +338,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/setup-browser-cookies/SKILL.md b/setup-browser-cookies/SKILL.md index 5cf4d4a6d..308dd18bd 100644 --- a/setup-browser-cookies/SKILL.md +++ b/setup-browser-cookies/SKILL.md @@ -276,6 +276,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/setup-deploy/SKILL.md b/setup-deploy/SKILL.md index f28b9914e..466e362b2 100644 --- a/setup-deploy/SKILL.md +++ b/setup-deploy/SKILL.md @@ -341,6 +341,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/ship/SKILL.md b/ship/SKILL.md index 8815ebadc..c7a74dd73 100644 --- a/ship/SKILL.md +++ b/ship/SKILL.md @@ -343,6 +343,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then diff --git a/skillify/SKILL.md b/skillify/SKILL.md index feb765d91..7dd70a958 100644 --- a/skillify/SKILL.md +++ b/skillify/SKILL.md @@ -339,6 +339,35 @@ _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" +# /sync-gbrain context-load: teach the agent to use gbrain when it's available. +# Mutually exclusive variants per /plan-eng-review §4. Empty string when gbrain +# is not configured (zero context cost for non-gbrain users). +_GBRAIN_CONFIG="$HOME/.gbrain/config.json" +if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then + _GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0) + if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then + _SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json" + _CWD_PAGES=0 + if [ -f "$_SYNC_STATE" ]; then + # Flatten newlines so the regex works against pretty-printed JSON too. + _CWD_PAGES=$(tr -d '\n' < "$_SYNC_STATE" 2>/dev/null \ + | grep -o '"name": *"code"[^}]*"detail": *{[^}]*"page_count": *[0-9]*' \ + | grep -o '"page_count": *[0-9]*' | grep -o '[0-9]\+' | head -1) + _CWD_PAGES=${_CWD_PAGES:-0} + fi + if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then + echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for" + echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for" + echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md." + echo "Run /sync-gbrain to refresh." + else + echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`" + echo "before relying on \`gbrain search\` for code questions in this repo." + echo "Falls back to Grep until indexed." + fi + fi +fi + _BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo off) if [ -f "$_BRAIN_REMOTE_FILE" ] && [ ! -d "$_GSTACK_HOME/.git" ] && [ "$_BRAIN_SYNC_MODE" = "off" ]; then