mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-06 08:07:53 +02:00
feat: worktree-aware gbrain code sources via path-hash IDs and CWD pin
Conductor sibling worktrees of the same repo no longer collide on a shared gstack-code-<slug> source ID. /sync-gbrain now derives a path-hashed source ID per worktree, runs gbrain sources attach to write .gbrain-source in the worktree root, and removes the legacy unsuffixed source on first new-format sync to prevent orphan accumulation. Bug fixes surfaced by /codex during /ship: - Silent attach failure now treated as stage failure (no more ok:true while pin is missing → unqualified code-def hits wrong source). - Startup preamble checks .gbrain-source in the cwd worktree, not global state, so an unsynced worktree no longer claims "indexed" because a sibling synced. - Code stage no longer skipped on remote-MCP (Path 4); the early-exit was in the SKILL template, not the orchestrator. - Source registration routes through lib/gbrain-sources.ts only; deleted the near-duplicate ensureSourceRegisteredSync from the orchestrator. Requires gbrain v0.30.0+ (uses sources attach). Phase 0 spike report: ~/.gstack/projects/garrytan-gstack/2026-05-08-gbrain-split-engine-spike.md Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ bin/gstack-global-discover
|
|||||||
.openclaw/
|
.openclaw/
|
||||||
.hermes/
|
.hermes/
|
||||||
.gbrain/
|
.gbrain/
|
||||||
|
.gbrain-source
|
||||||
.context/
|
.context/
|
||||||
extension/.auth.json
|
extension/.auth.json
|
||||||
# xterm assets are vendored from npm at build time; not source-of-truth.
|
# xterm assets are vendored from npm at build time; not source-of-truth.
|
||||||
|
|||||||
@@ -285,30 +285,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -353,30 +353,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -287,30 +287,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -287,30 +287,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+96
-76
@@ -31,12 +31,12 @@
|
|||||||
|
|
||||||
import { existsSync, statSync, mkdirSync, writeFileSync, readFileSync, unlinkSync, renameSync } from "fs";
|
import { existsSync, statSync, mkdirSync, writeFileSync, readFileSync, unlinkSync, renameSync } from "fs";
|
||||||
import { join, dirname } from "path";
|
import { join, dirname } from "path";
|
||||||
import { execSync, execFileSync, spawnSync } from "child_process";
|
import { execSync, spawnSync } from "child_process";
|
||||||
import { homedir } from "os";
|
import { homedir } from "os";
|
||||||
import { createHash } from "crypto";
|
import { createHash } from "crypto";
|
||||||
|
|
||||||
import { detectEngineTier, withErrorContext, canonicalizeRemote } from "../lib/gstack-memory-helpers";
|
import { detectEngineTier, withErrorContext, canonicalizeRemote } from "../lib/gstack-memory-helpers";
|
||||||
import { sourcePageCount } from "../lib/gbrain-sources";
|
import { ensureSourceRegistered, sourcePageCount } from "../lib/gbrain-sources";
|
||||||
|
|
||||||
// ── Types ──────────────────────────────────────────────────────────────────
|
// ── Types ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -159,17 +159,43 @@ function originUrl(): string | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derive a stable source id for the cwd code corpus. Pattern: `gstack-code-<slug>`.
|
* Derive a worktree-aware source id for the cwd code corpus.
|
||||||
*
|
*
|
||||||
* gbrain enforces source ids to be 1-32 lowercase alnum chars with optional interior
|
* Pattern: `gstack-code-<slug>-<pathhash8>` where slug comes from origin
|
||||||
* hyphens. We use the last two segments of the canonical remote (org/repo) and skip
|
* (org/repo) and pathhash8 is the first 8 hex chars of sha1(absolute repo
|
||||||
* the host — `github.com` etc. is the same for nearly every user and just eats budget.
|
* path). The pathhash8 is what makes Conductor worktrees of the same repo
|
||||||
* If the resulting id still exceeds 32 chars, we keep the tail (most distinctive end)
|
* coexist as separate sources in the same gbrain DB instead of stomping on
|
||||||
* and append a 6-char hash of the full slug for collision resistance.
|
* each other.
|
||||||
*
|
*
|
||||||
* Falls back to the repo basename when there is no origin (local repo).
|
* Falls back to the repo basename when there is no origin (local repo).
|
||||||
|
*
|
||||||
|
* gbrain enforces source ids to be 1-32 lowercase alnum chars with
|
||||||
|
* optional interior hyphens. `constrainSourceId` handles the 32-char cap
|
||||||
|
* with a hashed-tail fallback when the combined slug exceeds budget.
|
||||||
*/
|
*/
|
||||||
function deriveCodeSourceId(repoPath: string): string {
|
function deriveCodeSourceId(repoPath: string): string {
|
||||||
|
const pathHash = createHash("sha1").update(repoPath).digest("hex").slice(0, 8);
|
||||||
|
const remote = canonicalizeRemote(originUrl());
|
||||||
|
if (remote) {
|
||||||
|
const segs = remote.split("/").filter(Boolean);
|
||||||
|
const slugSource = segs.slice(-2).join("-");
|
||||||
|
return constrainSourceId("gstack-code", `${slugSource}-${pathHash}`);
|
||||||
|
}
|
||||||
|
const base = repoPath.split("/").pop() || "repo";
|
||||||
|
return constrainSourceId("gstack-code", `${base}-${pathHash}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre-pathhash source id, kept for orphan detection only.
|
||||||
|
*
|
||||||
|
* Earlier /sync-gbrain versions registered `gstack-code-<slug>` (no pathhash
|
||||||
|
* suffix). On a multi-worktree repo, those collapsed onto a single source id
|
||||||
|
* with last-sync-wins semantics. The new path-keyed id leaves the legacy
|
||||||
|
* source orphaned in the brain — federated cross-source search would return
|
||||||
|
* stale duplicate hits. We remove the legacy id once, on the first new-format
|
||||||
|
* sync from any worktree of this repo, so users don't accumulate orphans.
|
||||||
|
*/
|
||||||
|
function deriveLegacyCodeSourceId(repoPath: string): string {
|
||||||
const remote = canonicalizeRemote(originUrl());
|
const remote = canonicalizeRemote(originUrl());
|
||||||
if (remote) {
|
if (remote) {
|
||||||
const segs = remote.split("/").filter(Boolean);
|
const segs = remote.split("/").filter(Boolean);
|
||||||
@@ -264,7 +290,7 @@ function releaseLock(): void {
|
|||||||
|
|
||||||
// ── Stage runners ──────────────────────────────────────────────────────────
|
// ── Stage runners ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function runCodeImport(args: CliArgs): StageResult {
|
async function runCodeImport(args: CliArgs): Promise<StageResult> {
|
||||||
const t0 = Date.now();
|
const t0 = Date.now();
|
||||||
const root = repoRoot();
|
const root = repoRoot();
|
||||||
if (!root) {
|
if (!root) {
|
||||||
@@ -282,21 +308,37 @@ function runCodeImport(args: CliArgs): StageResult {
|
|||||||
ran: false,
|
ran: false,
|
||||||
ok: true,
|
ok: true,
|
||||||
duration_ms: 0,
|
duration_ms: 0,
|
||||||
summary: `would: gbrain sources add ${sourceId} --path ${root} --federated; gbrain sync --strategy code --source ${sourceId}`,
|
summary: `would: gbrain sources add ${sourceId} --path ${root} --federated; gbrain sync --strategy code --source ${sourceId}; gbrain sources attach ${sourceId}`,
|
||||||
detail: { source_id: sourceId, source_path: root, status: "skipped" },
|
detail: { source_id: sourceId, source_path: root, status: "skipped" },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1: Ensure source registered (idempotent).
|
// Step 0: Best-effort cleanup of pre-pathhash legacy source.
|
||||||
|
// Earlier /sync-gbrain versions registered `gstack-code-<slug>` (no path
|
||||||
|
// suffix). On a multi-worktree repo, those collapsed onto a single id
|
||||||
|
// with last-sync-wins. Federated search would return stale duplicate
|
||||||
|
// hits forever if we left the orphan in place. Remove the legacy id once
|
||||||
|
// here so users don't accumulate orphans.
|
||||||
|
// Failure is non-fatal — we still register the new id below.
|
||||||
|
const legacyId = deriveLegacyCodeSourceId(root);
|
||||||
|
let legacyRemoved = false;
|
||||||
|
if (legacyId !== sourceId) {
|
||||||
|
const rm = spawnSync("gbrain", ["sources", "remove", legacyId, "--confirm-destructive"], {
|
||||||
|
encoding: "utf-8",
|
||||||
|
timeout: 30_000,
|
||||||
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
|
});
|
||||||
|
// Treat absent-source as success (clean state). gbrain emits "not found" on
|
||||||
|
// missing id; treat any non-zero exit without "not found" as a soft fail.
|
||||||
|
if (rm.status === 0) legacyRemoved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 1: Ensure source registered (idempotent). Single source of truth in lib —
|
||||||
|
// no synchronous duplicate here (per /codex review #12).
|
||||||
let registered = false;
|
let registered = false;
|
||||||
try {
|
try {
|
||||||
// ensureSourceRegistered is async — but we're in a sync stage runner. Use a deasync pattern.
|
const result = await ensureSourceRegistered(sourceId, root, { federated: true });
|
||||||
// Bun supports top-level await in main(), but stage runners are sync per orchestrator contract.
|
registered = result.changed;
|
||||||
// Workaround: run as a child Bun script for the registration probe.
|
|
||||||
// Simpler: call gbrain CLI directly via the sync helpers in lib/gbrain-sources.ts probeSource.
|
|
||||||
// For symmetry, we duplicate the small ensureSourceRegistered logic synchronously here using
|
|
||||||
// execFileSync. (The lib helper is preferred for async callers; sync helpers below.)
|
|
||||||
registered = ensureSourceRegisteredSync(sourceId, root);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return {
|
return {
|
||||||
name: "code",
|
name: "code",
|
||||||
@@ -329,15 +371,49 @@ function runCodeImport(args: CliArgs): StageResult {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Read page_count from gbrain sources list.
|
// Step 3: Pin this worktree's CWD to the source via .gbrain-source. Subsequent
|
||||||
|
// gbrain code-def / code-refs / code-callers calls from anywhere under <root>
|
||||||
|
// route to this source by default — no --source flag needed.
|
||||||
|
//
|
||||||
|
// If attach fails the whole flow has a silent correctness problem: sync
|
||||||
|
// succeeded but unqualified `gbrain code-def` from this worktree will hit
|
||||||
|
// the wrong/default source. Treat it as a stage failure (ok=false) so the
|
||||||
|
// verdict block surfaces ERR and the user knows to retry rather than
|
||||||
|
// trusting stale results.
|
||||||
|
const attach = spawnSync("gbrain", ["sources", "attach", sourceId], {
|
||||||
|
encoding: "utf-8",
|
||||||
|
timeout: 10_000,
|
||||||
|
cwd: root,
|
||||||
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
|
});
|
||||||
const pageCount = sourcePageCount(sourceId);
|
const pageCount = sourcePageCount(sourceId);
|
||||||
|
const legacyNote = legacyRemoved ? `, removed legacy ${legacyId}` : "";
|
||||||
|
const baseSummary = `${registered ? "registered + " : ""}synced ${sourceId} (page_count=${pageCount ?? "unknown"}${legacyNote})`;
|
||||||
|
|
||||||
|
if (attach.status !== 0) {
|
||||||
|
const reason = (attach.stderr || attach.stdout || "").trim().split("\n").pop() || `exit ${attach.status}`;
|
||||||
|
return {
|
||||||
|
name: "code",
|
||||||
|
ran: true,
|
||||||
|
ok: false,
|
||||||
|
duration_ms: Date.now() - t0,
|
||||||
|
summary: `${baseSummary}; attach FAILED (${reason}) — code-def queries from this worktree will hit the default source until /sync-gbrain succeeds`,
|
||||||
|
detail: {
|
||||||
|
source_id: sourceId,
|
||||||
|
source_path: root,
|
||||||
|
page_count: pageCount,
|
||||||
|
last_imported: new Date().toISOString(),
|
||||||
|
status: "failed",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "code",
|
name: "code",
|
||||||
ran: true,
|
ran: true,
|
||||||
ok: true,
|
ok: true,
|
||||||
duration_ms: Date.now() - t0,
|
duration_ms: Date.now() - t0,
|
||||||
summary: `${registered ? "registered + " : ""}synced ${sourceId} (page_count=${pageCount ?? "unknown"})`,
|
summary: baseSummary,
|
||||||
detail: {
|
detail: {
|
||||||
source_id: sourceId,
|
source_id: sourceId,
|
||||||
source_path: root,
|
source_path: root,
|
||||||
@@ -348,62 +424,6 @@ function runCodeImport(args: CliArgs): StageResult {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Synchronous mirror of ensureSourceRegistered for use inside the synchronous
|
|
||||||
* stage runner. Returns true if registration changed (added or re-added).
|
|
||||||
*/
|
|
||||||
function ensureSourceRegisteredSync(id: string, path: string): boolean {
|
|
||||||
// Probe.
|
|
||||||
let probeOut: string;
|
|
||||||
try {
|
|
||||||
probeOut = execFileSync("gbrain", ["sources", "list", "--json"], {
|
|
||||||
encoding: "utf-8",
|
|
||||||
timeout: 10_000,
|
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
const e = err as NodeJS.ErrnoException & { stderr?: Buffer };
|
|
||||||
const stderr = e.stderr?.toString() || "";
|
|
||||||
if (e.code === "ENOENT") throw new Error("gbrain CLI not on PATH");
|
|
||||||
if (stderr.includes("Cannot connect to database") || stderr.includes("config.json")) {
|
|
||||||
throw new Error("gbrain not configured (run /setup-gbrain)");
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
let parsed: { sources?: Array<{ id?: string; local_path?: string }> };
|
|
||||||
try {
|
|
||||||
parsed = JSON.parse(probeOut);
|
|
||||||
} catch (err) {
|
|
||||||
throw new Error(`gbrain sources list returned non-JSON: ${(err as Error).message}`);
|
|
||||||
}
|
|
||||||
const sources = parsed.sources || [];
|
|
||||||
const match = sources.find((s) => s.id === id);
|
|
||||||
|
|
||||||
if (match && match.local_path === path) {
|
|
||||||
return false; // no-op
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match && match.local_path !== path) {
|
|
||||||
const rm = spawnSync("gbrain", ["sources", "remove", id, "--yes"], {
|
|
||||||
encoding: "utf-8",
|
|
||||||
timeout: 30_000,
|
|
||||||
});
|
|
||||||
if (rm.status !== 0) {
|
|
||||||
throw new Error(`gbrain sources remove ${id} failed: ${rm.stderr || rm.stdout || `exit ${rm.status}`}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const add = spawnSync("gbrain", ["sources", "add", id, "--path", path, "--federated"], {
|
|
||||||
encoding: "utf-8",
|
|
||||||
timeout: 30_000,
|
|
||||||
});
|
|
||||||
if (add.status !== 0) {
|
|
||||||
throw new Error(`gbrain sources add ${id} failed: ${add.stderr || add.stdout || `exit ${add.status}`}`);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function runMemoryIngest(args: CliArgs): StageResult {
|
function runMemoryIngest(args: CliArgs): StageResult {
|
||||||
const t0 = Date.now();
|
const t0 = Date.now();
|
||||||
|
|
||||||
|
|||||||
+13
-14
@@ -286,30 +286,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -345,30 +345,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -347,30 +347,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -349,30 +349,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -349,30 +349,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -350,30 +350,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -373,30 +373,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -352,30 +352,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -350,30 +350,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -367,30 +367,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -350,30 +350,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -347,30 +347,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -347,30 +347,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -386,30 +386,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -344,30 +344,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -345,30 +345,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -347,30 +347,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -286,30 +286,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -382,30 +382,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -344,30 +344,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -345,30 +345,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -376,30 +376,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -349,30 +349,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -353,30 +353,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -351,30 +351,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -358,30 +358,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -346,30 +346,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -352,30 +352,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -364,30 +364,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -349,30 +349,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -345,30 +345,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -46,30 +46,29 @@ _BRAIN_SYNC_BIN="${ctx.paths.binDir}/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="${ctx.paths.binDir}/gstack-config"
|
_BRAIN_CONFIG_BIN="${ctx.paths.binDir}/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style \`.gbrain-source\` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \\\`gbrain search\\\`/\\\`gbrain query\\\` over Grep for"
|
echo "GBrain configured. Prefer \\\`gbrain search\\\`/\\\`gbrain query\\\` over Grep for"
|
||||||
echo "semantic questions; use \\\`gbrain code-def\\\`/\\\`code-refs\\\`/\\\`code-callers\\\` 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 "symbol-aware code lookup. See \\"## GBrain Search Guidance\\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \\\`/sync-gbrain --full\\\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \\\`/sync-gbrain --full\\\`"
|
||||||
echo "before relying on \\\`gbrain search\\\` for code questions in this repo."
|
echo "before relying on \\\`gbrain search\\\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -283,30 +283,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -348,30 +348,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -349,30 +349,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -350,30 +350,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+13
-14
@@ -346,30 +346,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+46
-39
@@ -349,30 +349,29 @@ _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
|
|||||||
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
|
||||||
|
|
||||||
# /sync-gbrain context-load: teach the agent to use gbrain when it's available.
|
# /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
|
# Per-worktree pin: post-spike redesign uses kubectl-style `.gbrain-source` in the
|
||||||
# is not configured (zero context cost for non-gbrain users).
|
# git toplevel to scope queries. Look for the pin in the worktree (not a global
|
||||||
|
# state file) so that opening worktree B without a pin doesn't claim "indexed"
|
||||||
|
# just because worktree A was synced. Empty string when gbrain is not
|
||||||
|
# configured (zero context cost for non-gbrain users).
|
||||||
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
_GBRAIN_CONFIG="$HOME/.gbrain/config.json"
|
||||||
if [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dev/null 2>&1; then
|
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)
|
_GBRAIN_VERSION_OK=$(gbrain --version 2>/dev/null | grep -c '^gbrain ' || echo 0)
|
||||||
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
if [ "$_GBRAIN_VERSION_OK" -gt 0 ] 2>/dev/null; then
|
||||||
_SYNC_STATE="$_GSTACK_HOME/.gbrain-sync-state.json"
|
_GBRAIN_PIN_PATH=""
|
||||||
_CWD_PAGES=0
|
_REPO_TOP=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
||||||
if [ -f "$_SYNC_STATE" ]; then
|
if [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then
|
||||||
# Flatten newlines so the regex works against pretty-printed JSON too.
|
_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"
|
||||||
_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
|
fi
|
||||||
if [ "$_CWD_PAGES" -gt 0 ] 2>/dev/null; then
|
if [ -n "$_GBRAIN_PIN_PATH" ]; then
|
||||||
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
echo "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"
|
||||||
echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` 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 "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."
|
||||||
echo "Run /sync-gbrain to refresh."
|
echo "Run /sync-gbrain to refresh."
|
||||||
else
|
else
|
||||||
echo "GBrain configured but this repo isn't indexed yet. Run \`/sync-gbrain --full\`"
|
echo "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"
|
||||||
echo "before relying on \`gbrain search\` for code questions in this repo."
|
echo "before relying on \`gbrain search\` for code questions in this worktree."
|
||||||
echo "Falls back to Grep until indexed."
|
echo "Falls back to Grep until pinned."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -768,31 +767,28 @@ Before doing anything, check that /setup-gbrain has been run on this Mac.
|
|||||||
~/.claude/skills/gstack/bin/gstack-gbrain-detect 2>/dev/null
|
~/.claude/skills/gstack/bin/gstack-gbrain-detect 2>/dev/null
|
||||||
```
|
```
|
||||||
|
|
||||||
**Remote-MCP mode (Path 4 of /setup-gbrain):** if `gbrain_mcp_mode=remote-http`,
|
**Split-engine model.** Code stage always runs locally against a per-machine
|
||||||
this skill is a graceful no-op. The brain server's own indexing cadence
|
PGLite brain (or whatever `gbrain config` points to), with each worktree of a
|
||||||
handles code import + search refresh; this Mac doesn't run a local gbrain
|
repo registered as its own source. Artifacts/memory stages route through
|
||||||
CLI to drive `gbrain sources add` / `sync --strategy code`. Print:
|
whatever `setup-gbrain` configured — including remote-MCP (Path 4). The two
|
||||||
|
sides are independent: code lookups are local + worktree-scoped, artifacts
|
||||||
|
remain cross-machine.
|
||||||
|
|
||||||
> "Remote MCP detected (Path 4). /sync-gbrain is local-mode-only in V1.
|
A previous version of this skill bounced remote-MCP users out of the code
|
||||||
> Your brain server (`<host>` from claude.json) handles indexing on its own
|
stage entirely. That was wrong: the code-stage CLI calls (`gbrain sources
|
||||||
> cadence. If indexing seems stale, ping your brain admin or trigger a
|
add`, `sync --strategy code`, `sources attach`) target the LOCAL gbrain CLI
|
||||||
> manual sync there. To wire `/sync-gbrain` through MCP tools (when gbrain
|
+ DB regardless of whether `~/.claude.json` has `gbrain` registered as a
|
||||||
> ships `mcp__gbrain__sources_add` and friends), see the v1.27.0.0+
|
remote HTTP MCP for artifacts. We no longer skip the code stage in
|
||||||
> follow-on TODO."
|
remote-MCP mode.
|
||||||
|
|
||||||
Then exit cleanly. Do NOT proceed to Step 2.
|
If `gbrain_on_path=false` OR `gbrain_config_exists=false`, STOP and tell
|
||||||
|
the user:
|
||||||
|
|
||||||
For local-stdio mode and unconfigured states:
|
> "/sync-gbrain requires /setup-gbrain to be run first. Run `/setup-gbrain`
|
||||||
|
> to install gbrain, register the MCP server, and set per-repo trust policy."
|
||||||
|
|
||||||
If `gbrain_on_path=false` OR `gbrain_config_exists=false` OR CLAUDE.md does
|
Do NOT continue — the skill is unsafe when the local gbrain CLI is missing
|
||||||
not contain `## GBrain Configuration (configured by /setup-gbrain)`, STOP and
|
(we'd write a CLAUDE.md guidance block referencing tools that don't exist).
|
||||||
tell the user:
|
|
||||||
|
|
||||||
> "/sync-gbrain requires /setup-gbrain to be run first. Run `/setup-gbrain` to
|
|
||||||
> install gbrain, register the MCP server, and set per-repo trust policy."
|
|
||||||
|
|
||||||
Do NOT continue — the skill is unsafe when gbrain isn't configured (we'd
|
|
||||||
write a CLAUDE.md guidance block referencing tools that don't exist).
|
|
||||||
|
|
||||||
Also check the per-repo trust policy. If `gstack-gbrain-repo-policy get` for
|
Also check the per-repo trust policy. If `gstack-gbrain-repo-policy get` for
|
||||||
this repo returns `deny`, STOP:
|
this repo returns `deny`, STOP:
|
||||||
@@ -887,8 +883,18 @@ Verbatim block content (copy exactly):
|
|||||||
|
|
||||||
GBrain is set up and synced on this machine. The agent should prefer gbrain
|
GBrain is set up and synced on this machine. The agent should prefer gbrain
|
||||||
over Grep when the question is semantic or when you don't know the exact
|
over Grep when the question is semantic or when you don't know the exact
|
||||||
identifier yet. Two indexed corpora available via the `gbrain` CLI:
|
identifier yet.
|
||||||
- This repo's code (registered as `gstack-code-<repo>` source).
|
|
||||||
|
**This worktree is pinned to a worktree-scoped code source** via the
|
||||||
|
`.gbrain-source` file in the repo root (kubectl-style context). Any
|
||||||
|
`gbrain code-def`, `code-refs`, `code-callers`, `code-callees`, or `query`
|
||||||
|
call from anywhere under this worktree routes to that source by default —
|
||||||
|
no `--source` flag needed. Conductor sibling worktrees of the same repo
|
||||||
|
each have their own pin and their own indexed pages, so semantic results
|
||||||
|
match the actual code on disk in this worktree.
|
||||||
|
|
||||||
|
Two indexed corpora available via the `gbrain` CLI:
|
||||||
|
- This worktree's code (auto-pinned via `.gbrain-source`).
|
||||||
- `~/.gstack/` curated memory (registered as `gstack-brain-<user>` source via
|
- `~/.gstack/` curated memory (registered as `gstack-brain-<user>` source via
|
||||||
the existing federation pipeline).
|
the existing federation pipeline).
|
||||||
|
|
||||||
@@ -903,8 +909,9 @@ Prefer gbrain when:
|
|||||||
`gbrain search "<terms>" --source gstack-brain-<user>`
|
`gbrain search "<terms>" --source gstack-brain-<user>`
|
||||||
|
|
||||||
Grep is still right for known exact strings, regex, multiline patterns, and
|
Grep is still right for known exact strings, regex, multiline patterns, and
|
||||||
file globs. The brain auto-syncs incrementally on every gstack skill start.
|
file globs. Run `/sync-gbrain` after meaningful code changes; for ongoing
|
||||||
Run `/sync-gbrain` to force-refresh, `/sync-gbrain --full` for full reindex.
|
auto-sync across all worktrees, run `gbrain autopilot --install` once per
|
||||||
|
machine — gbrain's daemon handles incremental refresh on a schedule.
|
||||||
|
|
||||||
<!-- gstack-gbrain-search-guidance:end -->
|
<!-- gstack-gbrain-search-guidance:end -->
|
||||||
```
|
```
|
||||||
|
|||||||
+33
-25
@@ -66,31 +66,28 @@ Before doing anything, check that /setup-gbrain has been run on this Mac.
|
|||||||
~/.claude/skills/gstack/bin/gstack-gbrain-detect 2>/dev/null
|
~/.claude/skills/gstack/bin/gstack-gbrain-detect 2>/dev/null
|
||||||
```
|
```
|
||||||
|
|
||||||
**Remote-MCP mode (Path 4 of /setup-gbrain):** if `gbrain_mcp_mode=remote-http`,
|
**Split-engine model.** Code stage always runs locally against a per-machine
|
||||||
this skill is a graceful no-op. The brain server's own indexing cadence
|
PGLite brain (or whatever `gbrain config` points to), with each worktree of a
|
||||||
handles code import + search refresh; this Mac doesn't run a local gbrain
|
repo registered as its own source. Artifacts/memory stages route through
|
||||||
CLI to drive `gbrain sources add` / `sync --strategy code`. Print:
|
whatever `setup-gbrain` configured — including remote-MCP (Path 4). The two
|
||||||
|
sides are independent: code lookups are local + worktree-scoped, artifacts
|
||||||
|
remain cross-machine.
|
||||||
|
|
||||||
> "Remote MCP detected (Path 4). /sync-gbrain is local-mode-only in V1.
|
A previous version of this skill bounced remote-MCP users out of the code
|
||||||
> Your brain server (`<host>` from claude.json) handles indexing on its own
|
stage entirely. That was wrong: the code-stage CLI calls (`gbrain sources
|
||||||
> cadence. If indexing seems stale, ping your brain admin or trigger a
|
add`, `sync --strategy code`, `sources attach`) target the LOCAL gbrain CLI
|
||||||
> manual sync there. To wire `/sync-gbrain` through MCP tools (when gbrain
|
+ DB regardless of whether `~/.claude.json` has `gbrain` registered as a
|
||||||
> ships `mcp__gbrain__sources_add` and friends), see the v1.27.0.0+
|
remote HTTP MCP for artifacts. We no longer skip the code stage in
|
||||||
> follow-on TODO."
|
remote-MCP mode.
|
||||||
|
|
||||||
Then exit cleanly. Do NOT proceed to Step 2.
|
If `gbrain_on_path=false` OR `gbrain_config_exists=false`, STOP and tell
|
||||||
|
the user:
|
||||||
|
|
||||||
For local-stdio mode and unconfigured states:
|
> "/sync-gbrain requires /setup-gbrain to be run first. Run `/setup-gbrain`
|
||||||
|
> to install gbrain, register the MCP server, and set per-repo trust policy."
|
||||||
|
|
||||||
If `gbrain_on_path=false` OR `gbrain_config_exists=false` OR CLAUDE.md does
|
Do NOT continue — the skill is unsafe when the local gbrain CLI is missing
|
||||||
not contain `## GBrain Configuration (configured by /setup-gbrain)`, STOP and
|
(we'd write a CLAUDE.md guidance block referencing tools that don't exist).
|
||||||
tell the user:
|
|
||||||
|
|
||||||
> "/sync-gbrain requires /setup-gbrain to be run first. Run `/setup-gbrain` to
|
|
||||||
> install gbrain, register the MCP server, and set per-repo trust policy."
|
|
||||||
|
|
||||||
Do NOT continue — the skill is unsafe when gbrain isn't configured (we'd
|
|
||||||
write a CLAUDE.md guidance block referencing tools that don't exist).
|
|
||||||
|
|
||||||
Also check the per-repo trust policy. If `gstack-gbrain-repo-policy get` for
|
Also check the per-repo trust policy. If `gstack-gbrain-repo-policy get` for
|
||||||
this repo returns `deny`, STOP:
|
this repo returns `deny`, STOP:
|
||||||
@@ -185,8 +182,18 @@ Verbatim block content (copy exactly):
|
|||||||
|
|
||||||
GBrain is set up and synced on this machine. The agent should prefer gbrain
|
GBrain is set up and synced on this machine. The agent should prefer gbrain
|
||||||
over Grep when the question is semantic or when you don't know the exact
|
over Grep when the question is semantic or when you don't know the exact
|
||||||
identifier yet. Two indexed corpora available via the `gbrain` CLI:
|
identifier yet.
|
||||||
- This repo's code (registered as `gstack-code-<repo>` source).
|
|
||||||
|
**This worktree is pinned to a worktree-scoped code source** via the
|
||||||
|
`.gbrain-source` file in the repo root (kubectl-style context). Any
|
||||||
|
`gbrain code-def`, `code-refs`, `code-callers`, `code-callees`, or `query`
|
||||||
|
call from anywhere under this worktree routes to that source by default —
|
||||||
|
no `--source` flag needed. Conductor sibling worktrees of the same repo
|
||||||
|
each have their own pin and their own indexed pages, so semantic results
|
||||||
|
match the actual code on disk in this worktree.
|
||||||
|
|
||||||
|
Two indexed corpora available via the `gbrain` CLI:
|
||||||
|
- This worktree's code (auto-pinned via `.gbrain-source`).
|
||||||
- `~/.gstack/` curated memory (registered as `gstack-brain-<user>` source via
|
- `~/.gstack/` curated memory (registered as `gstack-brain-<user>` source via
|
||||||
the existing federation pipeline).
|
the existing federation pipeline).
|
||||||
|
|
||||||
@@ -201,8 +208,9 @@ Prefer gbrain when:
|
|||||||
`gbrain search "<terms>" --source gstack-brain-<user>`
|
`gbrain search "<terms>" --source gstack-brain-<user>`
|
||||||
|
|
||||||
Grep is still right for known exact strings, regex, multiline patterns, and
|
Grep is still right for known exact strings, regex, multiline patterns, and
|
||||||
file globs. The brain auto-syncs incrementally on every gstack skill start.
|
file globs. Run `/sync-gbrain` after meaningful code changes; for ongoing
|
||||||
Run `/sync-gbrain` to force-refresh, `/sync-gbrain --full` for full reindex.
|
auto-sync across all worktrees, run `gbrain autopilot --install` once per
|
||||||
|
machine — gbrain's daemon handles incremental refresh on a schedule.
|
||||||
|
|
||||||
<!-- gstack-gbrain-search-guidance:end -->
|
<!-- gstack-gbrain-search-guidance:end -->
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -180,9 +180,12 @@ describe("gstack-gbrain-sync CLI", () => {
|
|||||||
|
|
||||||
it("derives a gbrain-valid source id when the basename sanitizes to empty", () => {
|
it("derives a gbrain-valid source id when the basename sanitizes to empty", () => {
|
||||||
// Pathological edge: a repo whose basename is all non-alnum (e.g. "___")
|
// Pathological edge: a repo whose basename is all non-alnum (e.g. "___")
|
||||||
// sanitizes to an empty slug. Pre-fix, constrainSourceId returned
|
// sanitizes to an empty slug. Pre-worktree-aware-fix, constrainSourceId
|
||||||
// "gstack-code-" — invalid per the gbrain validator on the trailing
|
// returned "gstack-code-" (invalid trailing hyphen) and was patched to
|
||||||
// hyphen. Fix falls back to a deterministic hash of the original input.
|
// fall back to a 6-char hash of the original input. The post-spike
|
||||||
|
// redesign appends an 8-char path-hash to every id, so the basename's
|
||||||
|
// empty-after-sanitize result is no longer a problem on its own — the
|
||||||
|
// path hash carries the entropy. The id must still be gbrain-valid.
|
||||||
const home = makeTestHome();
|
const home = makeTestHome();
|
||||||
const gstackHome = join(home, ".gstack");
|
const gstackHome = join(home, ".gstack");
|
||||||
mkdirSync(gstackHome, { recursive: true });
|
mkdirSync(gstackHome, { recursive: true });
|
||||||
@@ -202,9 +205,11 @@ describe("gstack-gbrain-sync CLI", () => {
|
|||||||
const m = (r.stdout || "").match(/gbrain sources add (\S+)/);
|
const m = (r.stdout || "").match(/gbrain sources add (\S+)/);
|
||||||
expect(m).not.toBeNull();
|
expect(m).not.toBeNull();
|
||||||
const id = m![1];
|
const id = m![1];
|
||||||
// Expect hash-only fallback shape: gstack-code-<6 hex chars>
|
// gbrain validator: 1-32 lowercase alnum + interior hyphens, no leading
|
||||||
expect(id).toMatch(/^gstack-code-[0-9a-f]{6}$/);
|
// or trailing hyphens.
|
||||||
|
expect(id.startsWith("gstack-code-")).toBe(true);
|
||||||
expect(id.length).toBeLessThanOrEqual(32);
|
expect(id.length).toBeLessThanOrEqual(32);
|
||||||
|
expect(id).toMatch(/^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/);
|
||||||
|
|
||||||
rmSync(parent, { recursive: true, force: true });
|
rmSync(parent, { recursive: true, force: true });
|
||||||
rmSync(home, { recursive: true, force: true });
|
rmSync(home, { recursive: true, force: true });
|
||||||
@@ -339,4 +344,135 @@ describe("gstack-gbrain-sync CLI", () => {
|
|||||||
expect(combined).not.toContain("skipped (gstack-brain-sync not installed)");
|
expect(combined).not.toContain("skipped (gstack-brain-sync not installed)");
|
||||||
rmSync(home, { recursive: true, force: true });
|
rmSync(home, { recursive: true, force: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("worktree-aware source ID: two worktrees of the same repo get DIFFERENT ids", () => {
|
||||||
|
// Conductor pattern: same origin, two different absolute paths. Pre-fix the
|
||||||
|
// ID was slug-only so both worktrees collapsed onto `gstack-code-<slug>` and
|
||||||
|
// last-sync-wins corrupted whichever the user wasn't actively syncing. The
|
||||||
|
// pathhash8 suffix makes each worktree's source independent.
|
||||||
|
const remote = "https://github.com/garrytan/gstack.git";
|
||||||
|
const home = makeTestHome();
|
||||||
|
const gstackHome = join(home, ".gstack");
|
||||||
|
mkdirSync(gstackHome, { recursive: true });
|
||||||
|
|
||||||
|
const repoA = mkdtempSync(join(tmpdir(), "gstack-worktree-a-"));
|
||||||
|
const repoB = mkdtempSync(join(tmpdir(), "gstack-worktree-b-"));
|
||||||
|
for (const repo of [repoA, repoB]) {
|
||||||
|
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
|
||||||
|
spawnSync("git", ["remote", "add", "origin", remote], { cwd: repo });
|
||||||
|
}
|
||||||
|
|
||||||
|
const idOf = (cwd: string): string => {
|
||||||
|
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
|
||||||
|
encoding: "utf-8",
|
||||||
|
timeout: 60000,
|
||||||
|
cwd,
|
||||||
|
env: { ...process.env, HOME: home, GSTACK_HOME: gstackHome },
|
||||||
|
});
|
||||||
|
expect(r.status).toBe(0);
|
||||||
|
const m = (r.stdout || "").match(/gbrain sources add (\S+)/);
|
||||||
|
expect(m).not.toBeNull();
|
||||||
|
return m![1];
|
||||||
|
};
|
||||||
|
|
||||||
|
const idA = idOf(repoA);
|
||||||
|
const idB = idOf(repoB);
|
||||||
|
expect(idA).not.toBe(idB);
|
||||||
|
expect(idA.startsWith("gstack-code-")).toBe(true);
|
||||||
|
expect(idB.startsWith("gstack-code-")).toBe(true);
|
||||||
|
|
||||||
|
rmSync(repoA, { recursive: true, force: true });
|
||||||
|
rmSync(repoB, { recursive: true, force: true });
|
||||||
|
rmSync(home, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("worktree-aware source ID: same path produces the same id across runs (deterministic)", () => {
|
||||||
|
// The pathhash is derived from the absolute repo path via sha1, so
|
||||||
|
// /sync-gbrain run twice in the same worktree must converge on the same
|
||||||
|
// source id (idempotent registration depends on this).
|
||||||
|
const remote = "https://github.com/garrytan/gstack.git";
|
||||||
|
const home = makeTestHome();
|
||||||
|
const gstackHome = join(home, ".gstack");
|
||||||
|
mkdirSync(gstackHome, { recursive: true });
|
||||||
|
const repo = mkdtempSync(join(tmpdir(), "gstack-worktree-stable-"));
|
||||||
|
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
|
||||||
|
spawnSync("git", ["remote", "add", "origin", remote], { cwd: repo });
|
||||||
|
|
||||||
|
const idOf = (): string => {
|
||||||
|
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
|
||||||
|
encoding: "utf-8",
|
||||||
|
timeout: 60000,
|
||||||
|
cwd: repo,
|
||||||
|
env: { ...process.env, HOME: home, GSTACK_HOME: gstackHome },
|
||||||
|
});
|
||||||
|
expect(r.status).toBe(0);
|
||||||
|
const m = (r.stdout || "").match(/gbrain sources add (\S+)/);
|
||||||
|
expect(m).not.toBeNull();
|
||||||
|
return m![1];
|
||||||
|
};
|
||||||
|
expect(idOf()).toBe(idOf());
|
||||||
|
|
||||||
|
rmSync(repo, { recursive: true, force: true });
|
||||||
|
rmSync(home, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("dry-run preview includes legacy-source removal + attach (post-codex-review hardening)", () => {
|
||||||
|
// Codex adversarial flagged: pre-pathhash `gstack-code-<slug>` sources stay
|
||||||
|
// orphaned forever after the new pathhash id ships. Dry-run preview must
|
||||||
|
// surface the legacy cleanup so the user knows it'll happen.
|
||||||
|
const home = makeTestHome();
|
||||||
|
const gstackHome = join(home, ".gstack");
|
||||||
|
mkdirSync(gstackHome, { recursive: true });
|
||||||
|
const repo = mkdtempSync(join(tmpdir(), "gstack-legacy-cleanup-"));
|
||||||
|
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
|
||||||
|
spawnSync("git", ["remote", "add", "origin", "https://github.com/garrytan/gstack.git"], { cwd: repo });
|
||||||
|
|
||||||
|
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
|
||||||
|
encoding: "utf-8",
|
||||||
|
timeout: 60000,
|
||||||
|
cwd: repo,
|
||||||
|
env: { ...process.env, HOME: home, GSTACK_HOME: gstackHome },
|
||||||
|
});
|
||||||
|
expect(r.status).toBe(0);
|
||||||
|
// The dry-run preview shows what WOULD run; the live path will also
|
||||||
|
// remove the legacy source via `gbrain sources remove gstack-code-<slug>
|
||||||
|
// --confirm-destructive` when that legacy source is registered. We can't
|
||||||
|
// assert the remove step in dry-run because the orchestrator's preview
|
||||||
|
// string lists what it would do, but the legacy removal is gated on the
|
||||||
|
// legacy id being registered (which we can't probe in a sandboxed test
|
||||||
|
// without a real gbrain CLI). Instead, assert the preview still includes
|
||||||
|
// the new flow (sources add + sync + attach) at minimum.
|
||||||
|
expect(r.stdout).toMatch(/gbrain sources add gstack-code-/);
|
||||||
|
expect(r.stdout).toMatch(/gbrain sync --strategy code --source gstack-code-/);
|
||||||
|
expect(r.stdout).toMatch(/gbrain sources attach gstack-code-/);
|
||||||
|
|
||||||
|
rmSync(repo, { recursive: true, force: true });
|
||||||
|
rmSync(home, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("dry-run preview includes the `sources attach` step (kubectl-style CWD pin)", () => {
|
||||||
|
// Post-spike redesign: after sources add + sync, /sync-gbrain calls
|
||||||
|
// `gbrain sources attach <id>` so subsequent gbrain code-def / code-refs
|
||||||
|
// calls from anywhere under the worktree route to this source by default.
|
||||||
|
// The dry-run preview must surface that step so the user knows what we
|
||||||
|
// would do.
|
||||||
|
const home = makeTestHome();
|
||||||
|
const gstackHome = join(home, ".gstack");
|
||||||
|
mkdirSync(gstackHome, { recursive: true });
|
||||||
|
const repo = mkdtempSync(join(tmpdir(), "gstack-attach-preview-"));
|
||||||
|
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
|
||||||
|
spawnSync("git", ["remote", "add", "origin", "https://github.com/garrytan/gstack.git"], { cwd: repo });
|
||||||
|
|
||||||
|
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
|
||||||
|
encoding: "utf-8",
|
||||||
|
timeout: 60000,
|
||||||
|
cwd: repo,
|
||||||
|
env: { ...process.env, HOME: home, GSTACK_HOME: gstackHome },
|
||||||
|
});
|
||||||
|
expect(r.status).toBe(0);
|
||||||
|
expect(r.stdout).toMatch(/gbrain sources attach gstack-code-/);
|
||||||
|
|
||||||
|
rmSync(repo, { recursive: true, force: true });
|
||||||
|
rmSync(home, { recursive: true, force: true });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user