Skip to content

Commit 9523feb

Browse files
garrytanclaude
andauthored
v1.12.2.0 fix: /setup-gbrain day-two fixes (MCP scope, version parse, gh repo create order, smoke test) (garrytan#1187)
* fix: parse gbrain --version without "gbrain" prefix Installer's D19 PATH-shadow check compared `expected_version` from package.json against `actual_version` from `gbrain --version`. The output is "gbrain 0.18.2" with a literal prefix; `tr -d '[:space:]'` left "gbrain0.18.2" which never matched "0.18.2", causing every fresh install to exit 3 with a false-positive shadowing error. Use `awk '{print $NF}'` to grab just the last whitespace-separated token before stripping whitespace. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(brain-init): drop --source flag before git init gstack-brain-init used `gh repo create --source $GSTACK_HOME` before running `git init` on that directory. gh requires --source to point at an existing git repo, so the call fails with "not a git repository" on first run. The fallback path (gh repo view) could only recover if the repo was somehow pre-created — which it wasn't. Fix: omit --source from `gh repo create`. The script's later steps (git init, remote add, push) wire up the remote explicitly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(setup-gbrain): smoke test command + MCP user scope with absolute path Three Step 5a/9 defects found running /setup-gbrain end-to-end: 1. Step 9 smoke test used `gbrain put_page --title ... --tags ...`, which doesn't exist. The real command is `gbrain put <slug>` with body piped on stdin. Updated to match. 2. Step 5a registered MCP with `claude mcp add gbrain -- gbrain serve`. Default scope is local (per-workspace), so other projects never saw gbrain. Cross-session memory is the whole point — user scope is correct. 3. Step 5a passed `gbrain` by bare name, relying on PATH being resolved when Claude Code spawns the subprocess. Fragile across shell configs. Use absolute path from `command -v gbrain` with ~/.bun/bin/gbrain fallback. Also: remove any stale local-scope registration before re-adding, and tell the user that open Claude Code sessions need a restart to see the new mcp__gbrain__* tools (loaded at session start, not mid-session). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump version and changelog (v1.12.1.0) Also updates test/gstack-brain-init-gh-mock.test.ts to match the fixed behavior of bin/gstack-brain-init (the assertion previously required `--source`, which was the bug being fixed in 04185d8). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: tighten CHANGELOG entry for v1.12.1.0 Shorter, matter-of-fact list of the fixes. No preamble. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0f00403 commit 9523feb

8 files changed

Lines changed: 70 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## [1.12.2.0] - 2026-04-24
4+
5+
## **`/setup-gbrain` polish: PATH parsing, repo init order, MCP user scope.**
6+
7+
Small refinements to the /setup-gbrain onboarding path.
8+
9+
### Fixed
10+
- `bin/gstack-gbrain-install`: parse `gbrain --version` output with `awk '{print $NF}'` so the D19 PATH-shadow check compares just the version number.
11+
- `bin/gstack-brain-init`: omit `--source` from `gh repo create`. Later steps handle `git init` + remote setup explicitly.
12+
- `setup-gbrain` Step 9: smoke test uses `gbrain put <slug>` with body piped on stdin.
13+
- `setup-gbrain` Step 5a: MCP registers with `--scope user` and an absolute path to the gbrain binary, so `mcp__gbrain__*` tools are available in every Claude Code session on the machine.
14+
15+
### Changed
16+
- `test/gstack-brain-init-gh-mock.test.ts`: asserts `--source` is absent from the `gh repo create` call.
17+
318
## [1.12.1.0] - 2026-04-24
419

520
## **Plan-mode review skills run the review directly, no more "exit and rerun" prompt.**

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.12.1.0
1+
1.12.2.0

bin/gstack-brain-init

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ if [ -z "$REMOTE_URL" ]; then
8686
read -r REPLY || REPLY=""
8787
if [ -z "$REPLY" ]; then
8888
echo "Creating GitHub repo: $DEFAULT_NAME ..."
89-
if ! gh repo create "$DEFAULT_NAME" --private --description "gstack session memory" --source "$GSTACK_HOME" 2>/dev/null; then
89+
# Note: --source omitted intentionally. gh requires --source to point at
90+
# an existing git repo, but we don't init $GSTACK_HOME until after the
91+
# remote is chosen. Create bare, then fetch URL.
92+
if ! gh repo create "$DEFAULT_NAME" --private --description "gstack session memory" 2>/dev/null; then
9093
# Maybe the repo already exists; try to fetch its URL.
9194
REMOTE_URL=$(gh repo view "$DEFAULT_NAME" --json sshUrl -q .sshUrl 2>/dev/null || echo "")
9295
if [ -z "$REMOTE_URL" ]; then

bin/gstack-gbrain-install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ if ! command -v gbrain >/dev/null 2>&1; then
151151
fail "bun link completed but 'gbrain' is not on PATH. Ensure ~/.bun/bin is in your PATH."
152152
fi
153153

154-
actual_version=$(gbrain --version 2>/dev/null | head -1 | tr -d '[:space:]' || true)
154+
actual_version=$(gbrain --version 2>/dev/null | head -1 | awk '{print $NF}' | tr -d '[:space:]' || true)
155155
if [ -z "$actual_version" ]; then
156156
fail "gbrain is on PATH but 'gbrain --version' produced no output — the binary may be broken."
157157
fi

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gstack",
3-
"version": "1.12.1.0",
3+
"version": "1.12.2.0",
44
"description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.",
55
"license": "MIT",
66
"type": "module",

setup-gbrain/SKILL.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,17 +1283,33 @@ doctor output and STOP.
12831283
Only if `which claude` resolves. Ask: "Give Claude Code a typed tool surface
12841284
for gbrain? (recommended yes)"
12851285

1286-
If yes:
1286+
If yes, register at **user scope** with an **absolute path** to the gbrain
1287+
binary. User scope makes the MCP available in every Claude Code session on
1288+
this machine, not just the current workspace. Absolute path avoids PATH
1289+
resolution issues when Claude Code spawns `gbrain serve` as a subprocess.
12871290

12881291
```bash
1289-
claude mcp add gbrain -- gbrain serve
1290-
claude mcp list | grep gbrain # verify
1292+
GBRAIN_BIN=$(command -v gbrain)
1293+
[ -z "$GBRAIN_BIN" ] && GBRAIN_BIN="$HOME/.bun/bin/gbrain"
1294+
claude mcp add --scope user gbrain -- "$GBRAIN_BIN" serve
1295+
claude mcp list | grep gbrain # verify: should show "✓ Connected"
1296+
```
1297+
1298+
If the user already had a local-scope registration from an earlier run,
1299+
remove it first so both scopes don't conflict:
1300+
```bash
1301+
claude mcp remove gbrain 2>/dev/null || true
12911302
```
12921303

12931304
If `claude` is not on PATH: emit "MCP registration skipped — this skill is
12941305
Claude-Code-targeted; register `gbrain serve` in your agent's MCP config
12951306
manually." Continue to step 6.
12961307

1308+
**Heads-up for the user:** an already-open Claude Code session will not
1309+
pick up the new MCP tools until restart. Tell them: "Restart any open
1310+
Claude Code sessions to see `mcp__gbrain__*` tools — they're loaded at
1311+
session start, not mid-session."
1312+
12971313
---
12981314

12991315
## Step 6: Per-remote policy (D3 triad, gated repo-import)
@@ -1368,9 +1384,9 @@ Find-and-replace (or append) this section in CLAUDE.md:
13681384
## Step 9: Smoke test
13691385

13701386
```bash
1371-
gbrain put_page --title "setup-gbrain smoke test" --tags "meta" \
1372-
<<<"Set up on $(date)"
1373-
gbrain search "smoke test" | grep -i "setup-gbrain smoke test"
1387+
SLUG="setup-gbrain-smoke-test-$(date +%s)"
1388+
echo "Set up on $(date). Smoke test for /setup-gbrain." | gbrain put "$SLUG"
1389+
gbrain search "smoke test" | grep -i "$SLUG"
13741390
```
13751391

13761392
Confirms the round trip. On failure, surface `gbrain doctor --json` output

setup-gbrain/SKILL.md.tmpl

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,33 @@ doctor output and STOP.
285285
Only if `which claude` resolves. Ask: "Give Claude Code a typed tool surface
286286
for gbrain? (recommended yes)"
287287

288-
If yes:
288+
If yes, register at **user scope** with an **absolute path** to the gbrain
289+
binary. User scope makes the MCP available in every Claude Code session on
290+
this machine, not just the current workspace. Absolute path avoids PATH
291+
resolution issues when Claude Code spawns `gbrain serve` as a subprocess.
289292

290293
```bash
291-
claude mcp add gbrain -- gbrain serve
292-
claude mcp list | grep gbrain # verify
294+
GBRAIN_BIN=$(command -v gbrain)
295+
[ -z "$GBRAIN_BIN" ] && GBRAIN_BIN="$HOME/.bun/bin/gbrain"
296+
claude mcp add --scope user gbrain -- "$GBRAIN_BIN" serve
297+
claude mcp list | grep gbrain # verify: should show "✓ Connected"
298+
```
299+
300+
If the user already had a local-scope registration from an earlier run,
301+
remove it first so both scopes don't conflict:
302+
```bash
303+
claude mcp remove gbrain 2>/dev/null || true
293304
```
294305

295306
If `claude` is not on PATH: emit "MCP registration skipped — this skill is
296307
Claude-Code-targeted; register `gbrain serve` in your agent's MCP config
297308
manually." Continue to step 6.
298309

310+
**Heads-up for the user:** an already-open Claude Code session will not
311+
pick up the new MCP tools until restart. Tell them: "Restart any open
312+
Claude Code sessions to see `mcp__gbrain__*` tools — they're loaded at
313+
session start, not mid-session."
314+
299315
---
300316

301317
## Step 6: Per-remote policy (D3 triad, gated repo-import)
@@ -370,9 +386,9 @@ Find-and-replace (or append) this section in CLAUDE.md:
370386
## Step 9: Smoke test
371387

372388
```bash
373-
gbrain put_page --title "setup-gbrain smoke test" --tags "meta" \
374-
<<<"Set up on $(date)"
375-
gbrain search "smoke test" | grep -i "setup-gbrain smoke test"
389+
SLUG="setup-gbrain-smoke-test-$(date +%s)"
390+
echo "Set up on $(date). Smoke test for /setup-gbrain." | gbrain put "$SLUG"
391+
gbrain search "smoke test" | grep -i "$SLUG"
376392
```
377393

378394
Confirms the round trip. On failure, surface `gbrain doctor --json` output

test/gstack-brain-init-gh-mock.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ describe('gstack-brain-init uses gh CLI when present + authed', () => {
134134
expect(createCall).toContain('gstack-brain-testuser');
135135
expect(createCall).toContain('--private');
136136
expect(createCall).toContain('--description');
137-
expect(createCall).toContain('--source');
138-
expect(createCall).toContain(tmpHome);
137+
// --source is intentionally omitted: gh requires the source dir to already
138+
// be a git repo, but brain-init doesn't `git init $GSTACK_HOME` until later.
139+
// Creating bare and wiring up the remote explicitly avoids that ordering bug.
140+
expect(createCall).not.toContain('--source');
139141
});
140142

141143
test('falls back to gh repo view when create reports already-exists', () => {

0 commit comments

Comments
 (0)