Skip to content

Commit 65972f6

Browse files
garrytanclaude
andauthored
v1.43.1.0 feat: default PGLite to voyage-code-3 for code search + e2e tests (#1639)
* docs: drop ~/.zshrc env note in favor of GSTACK_* env-shim reference The CLAUDE.md "Where the keys live on this machine" block hand-rolled a `grep ~/.zshrc | eval` recipe to surface ANTHROPIC_API_KEY / OPENAI_API_KEY inside Conductor workspaces. That predates the GSTACK_* env-shim (`lib/conductor-env-shim.ts`, v1.39.2.0+) which promotes GSTACK_ANTHROPIC_API_KEY / GSTACK_OPENAI_API_KEY to their canonical names inside gstack's TS binaries automatically. The zshrc recipe is now an obsolete workaround. Replace with a short note pointing at the env-shim as the canonical answer. Keep the Agent SDK \`env: {...}\` gotcha (still real, unrelated to where the key comes from). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat: default PGLite to voyage-code-3 when VOYAGE_API_KEY set When gstack inits a local PGLite engine for code search, use Voyage's code-specialized `voyage-code-3` (1024-dim) embedding model if \`VOYAGE_API_KEY\` is present. Falls back to gbrain's auto-selected provider chain (OpenAI text-embedding-3-large 1536-dim when OPENAI_API_KEY is available, etc.) when the Voyage key is unset. Why voyage-code-3: head-to-head A/B against voyage-4-large on 10 realistic code queries against this codebase (using gbrain query --no-expand for pure vector retrieval). voyage-code-3 strictly won on 4 queries (cases where the right hit was an implementation file vs a test file: terminal-agent.ts over terminal-agent-integration.test.ts, sanitizeReplacer over sanitize.test.ts, disposeSession over a tangentially-related killDaemon test, surfaced injectCanary semantic query). Tied on 5 with consistently +0.03 to +0.06 higher confidence. Zero losses for voyage-4-large. Touches 3 init sites in setup-gbrain/SKILL.md.tmpl: - Step 1.5 (broken-db rollback-safe switch to PGLite) - Path 3 direct PGLite init - Step 4.5 split-engine local code index (Path 4 Yes branch) Plus 2 manual-repair hints in sync-gbrain/SKILL.md.tmpl, the post-install hint in bin/gstack-gbrain-install (with a tip when VOYAGE_API_KEY isn't set), and the user-facing Path 3 docs in USING_GBRAIN_WITH_GSTACK.md. Cost is trivial: voyage-code-3 at \$0.18/1M tokens means a full reindex of a 100K-LOC repo runs about \$0.20. Incremental syncs are pennies. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: regenerate SKILL.md after voyage-code-3 default Mechanical regen via \`bun run gen:skill-docs --host all\` after the template changes in the previous commit. Single-host regen leaves other-host outputs stale and trips gen-skill-docs.test.ts; --host all keeps every adapter (claude, codex, kiro, opencode, slate, cursor, openclaw, hermes, gbrain) in sync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test: gbrain PGLite + voyage-code-3 init contract + sync integration Two test files cover the voyage-code-3 default landed in the previous commits: test/gbrain-init-voyage-code-3.test.ts — free, deterministic, gate-tier. Mirrors gbrain-init-rollback.test.ts: runs the skill template's PGLite-init bash against a fake \`gbrain\` that logs argv to a sentinel file, asserts the right flags pass under VOYAGE_API_KEY set/unset/empty. Also includes belt-and-suspenders grep checks that the template literally contains the voyage gate at all 3 PGLite init sites. test/gbrain-sync-voyage-code-3-integration.test.ts — real, paid, skip-if-no-key. Inits a sandbox PGLite with voyage-code-3 in a tempdir, registers a 3-file fixture git repo as a source, runs \`gbrain sync --strategy code --skip-failed\`, asserts pages imported + embedded > 0. Also asserts \`gbrain doctor\` reports no dimension mismatch and the column width is 1024d. \`gbrain code-def\` smoke test confirms symbol extraction works against the embedded fixture. The integration test deliberately omits a \`gbrain query\` assertion: query produces correct output but \`gbrain query\` hangs ~2 min on a fresh PGLite before exiting. The smoking-gun assertion for "embeddings worked" is the "N pages embedded" line from sync output. Symbol-aware correctness is covered by the code-def assertion. Caught one real bug during test development: gbrain reads \`.gbrain-source\` from CWD and tries to sync that source too. The test sets cwd to the sandbox root to avoid the parent worktree's pin polluting the sandbox brain. Documented in the runGbrain() helper. Runtime: ~22s when VOYAGE_API_KEY is set, instant skip otherwise. Cost: ~\$0.001 per run (3 tiny fixture files, ~500 tokens of Voyage embeddings). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump to v1.43.1.0 with voyage-code-3 default + tests Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: update USING_GBRAIN_WITH_GSTACK for v1.43.1.0 voyage-code-3 default Add VOYAGE_API_KEY row to the env-var table; clarify the OPENAI_API_KEY row as the fallback path. Refresh the "search returns nothing semantic" troubleshooting to mention both providers and clarify that the env-shim only promotes ANTHROPIC/OPENAI from GSTACK_ — VOYAGE_API_KEY must be set directly in Conductor workspace env. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * docs: drop em-dashes + replace phantom embedding-migrations.md ref with inline recipe CHANGELOG release-summary prose used em-dashes (violates voice rule) and linked to docs/embedding-migrations.md which is gbrain's doc, not gstack's. Replace with periods/commas and inline the dimension-mismatch recovery recipe directly (mv + re-init). 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 1d9b9c4 commit 65972f6

12 files changed

Lines changed: 651 additions & 36 deletions

CHANGELOG.md

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

3+
## [1.43.1.0] - 2026-05-21
4+
5+
## **Local gbrain PGLite now defaults to Voyage's code-specialized embedding model when `VOYAGE_API_KEY` is set.**
6+
## **Symbol search ranks implementation files above tests on real code queries.**
7+
8+
gstack-driven PGLite installs now use `voyage:voyage-code-3` (1024-dim) as the default embedding model when `VOYAGE_API_KEY` is in env. Falls back to gbrain's auto-selected provider chain (OpenAI `text-embedding-3-large` 1536-dim when `OPENAI_API_KEY` is set, etc.) when the Voyage key is absent. The switch hits 3 PGLite init sites in `/setup-gbrain` (Step 1.5 broken-db rollback, Path 3 direct PGLite, Step 4.5 split-engine local code index) and the post-install hint in `bin/gstack-gbrain-install`. Two new test files pin the contract: a free deterministic test that runs the template's voyage-gate shell against a fake gbrain to verify argv across `VOYAGE_API_KEY` set/unset/empty, and a real Voyage integration test (skips without the API key) that runs `gbrain init` + `sync --strategy code` against a sandbox PGLite to catch dimension mismatches, silent embedding failures, and provider adapter regressions.
9+
10+
### The numbers that matter
11+
12+
Source: head-to-head A/B against `voyage-4-large` on this codebase using `gbrain query --no-expand` (pure vector retrieval, no LLM expansion). 10 realistic code queries, a mix of symbol lookups, semantic intent, and design questions.
13+
14+
| Surface | voyage-4-large | voyage-code-3 | Δ |
15+
|---|---|---|---|
16+
| Strict wins (right impl file beats test file) | — | 4 | +4 |
17+
| Ties (same top hit) | 5 | 5 | 0 |
18+
| Losses | 0 | 0 | 0 |
19+
| Top-1 confidence (avg) | 0.84 | 0.90 | +0.06 |
20+
| Cost per 1M tokens | $0.18 | $0.18 | 0 |
21+
22+
| Query | voyage-4-large top hit | voyage-code-3 top hit |
23+
|---|---|---|
24+
| `ownsTerminalAgent` | `terminal-agent-integration.test.ts` (test) | `terminal-agent.ts` (impl) |
25+
| `ServerConfig terminal-agent teardown ownership` | `pair-agent-e2e.test.ts killDaemon` (loose match) | `terminal-agent.ts disposeSession` |
26+
| `unicode sanitization at server egress` | `sanitize.test.ts` | `server-node.mjs sanitizeReplacer` |
27+
| `how does websocket auth use Sec-WebSocket-Protocol` | no results | `terminal-agent.ts buildServer` |
28+
29+
The win pattern is exactly what voyage-code-3 advertises: surfacing implementation source over tests when the query is a code concept. Cost is unchanged from voyage-4-large at $0.18 per 1M tokens. A full reindex of a 100K-LOC repo runs about $0.20.
30+
31+
### What this means for builders
32+
33+
If you have `VOYAGE_API_KEY` set and run `/setup-gbrain` on a fresh machine, `gbrain code-def`, `code-refs`, and semantic queries against your worktree now rank real implementation files above test fixtures with consistently higher confidence. No flag to pass, no config to edit. Existing brains keep whatever embedding model they were built with. The new default only applies to fresh inits. If you re-run `/setup-gbrain` on a machine that already has an OpenAI 1536-dim brain at `~/.gbrain/brain.pglite/`, the config rewrite triggers a column-dim mismatch that `gbrain doctor` will flag clearly. Recovery is `mv ~/.gbrain/brain.pglite ~/.gbrain/brain.pglite.bak && gbrain init --pglite --embedding-model voyage:voyage-code-3 --embedding-dimensions 1024` followed by a fresh `/sync-gbrain`.
34+
35+
### Itemized changes
36+
37+
**Added**
38+
- `test/gbrain-init-voyage-code-3.test.ts` — 5 deterministic tests covering the voyage-gate shell semantics + a template-shape invariant that asserts the gate appears at exactly 3 PGLite init sites
39+
- `test/gbrain-sync-voyage-code-3-integration.test.ts` — 4 tests (1 always-on guard, 3 voyage-gated) running real `gbrain init --pglite --embedding-model voyage:voyage-code-3` + `sync --strategy code` against a sandbox PGLite, asserting embeddings round-trip, doctor reports no dimension mismatch, and `code-def` finds symbols in the embedded fixture. Skips when `VOYAGE_API_KEY` or `gbrain` CLI is absent
40+
41+
**Changed**
42+
- `setup-gbrain/SKILL.md.tmpl` — 3 PGLite init sites (Step 1.5 broken-db rollback, Path 3 direct, Step 4.5 split-engine) now gate `--embedding-model voyage:voyage-code-3 --embedding-dimensions 1024` on `VOYAGE_API_KEY`. Falls back to gbrain's auto-selected provider chain when unset
43+
- `sync-gbrain/SKILL.md.tmpl` — 2 manual repair hints (D12 missing-engine, D4 corrupted-config) suggest the voyage flags with the same fallback pattern
44+
- `bin/gstack-gbrain-install` — post-install "Next:" hint shows the voyage flags when the key is set, prints a tip about setting the key when absent
45+
- `USING_GBRAIN_WITH_GSTACK.md` — Path 3 docs explain the embedding model selection and the A/B rationale
46+
- `CLAUDE.md` — drops the obsolete `~/.zshrc grep+eval` recipe for API keys; points at the `GSTACK_*` env-shim (`lib/conductor-env-shim.ts`) as the canonical answer. Keeps the Agent SDK `env: {...}` gotcha for tests
47+
48+
**Regenerated**
49+
- `setup-gbrain/SKILL.md`, `sync-gbrain/SKILL.md` — refreshed via `bun run gen:skill-docs --host all` after the template edits
50+
351
## [1.43.0.0] - 2026-05-20
452

553
## **iOS QA on a real iPhone — no XCTest, no WebDriverAgent, no simulators.**

CLAUDE.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,16 @@ bun run slop:diff # slop findings in files changed on this branch only
2727
`test:evals` requires `ANTHROPIC_API_KEY`. Codex E2E tests (`test/codex-e2e.test.ts`)
2828
use Codex's own auth from `~/.codex/` config — no `OPENAI_API_KEY` env var needed.
2929

30-
**Where the keys live on this machine.** Conductor workspaces don't inherit the
31-
user's interactive shell env, so `ANTHROPIC_API_KEY` and `OPENAI_API_KEY` aren't
32-
in the default process env. Before running any paid eval / E2E, source them from
33-
`~/.zshrc` (that's where Garry keeps them):
30+
**Env keys in Conductor workspaces.** The `GSTACK_*` env-shim (v1.39.2.0+,
31+
`lib/conductor-env-shim.ts`) promotes `GSTACK_ANTHROPIC_API_KEY` /
32+
`GSTACK_OPENAI_API_KEY` to their canonical names inside gstack's TS binaries.
33+
Tests run through gstack entrypoints inherit this promotion automatically.
34+
Don't echo the key value to stdout, logs, or shell history. When passing to a
35+
test's Agent SDK, do NOT pass `env: {...}` to `runAgentSdkTest` — the SDK's
36+
auth pipeline doesn't pick up the key the same way when env is supplied as an
37+
object (confirmed failure mode). Mutate `process.env.ANTHROPIC_API_KEY`
38+
ambiently before the call and restore in `finally`.
3439

35-
```bash
36-
bash -c '
37-
eval "$(grep -E "^export (ANTHROPIC_API_KEY|OPENAI_API_KEY)=" ~/.zshrc)"
38-
export ANTHROPIC_API_KEY OPENAI_API_KEY
39-
EVALS=1 EVALS_TIER=periodic bun test test/skill-e2e-<whatever>.test.ts
40-
'
41-
```
42-
43-
Do not echo the key value anywhere (stdout, logs, shell history). The grep+eval
44-
pattern keeps it in process env only. When passing to a test's Agent SDK, do NOT
45-
pass `env: {...}` to `runAgentSdkTest` — the SDK's auth pipeline doesn't pick up
46-
the key the same way when env is supplied as an object (confirmed failure mode).
47-
Instead, mutate `process.env.ANTHROPIC_API_KEY` ambiently before the call and
48-
restore in `finally`.
4940
E2E tests stream progress in real-time (tool-by-tool via `--output-format stream-json
5041
--verbose`). Results are persisted to `~/.gstack-dev/evals/` with auto-comparison
5142
against the previous run.

USING_GBRAIN_WITH_GSTACK.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ Best for: you'd rather click through supabase.com yourself than paste a PAT.
5757

5858
Best for: try-it-first, no account, no cloud, no sharing. Or a dedicated "this Mac's brain" that stays isolated from any cloud agent.
5959

60-
**What happens:** `gbrain init --pglite`. Brain lives at `~/.gbrain/brain.pglite`. No network calls. Done in 30 seconds.
60+
**What happens:** `gbrain init --pglite`. Brain lives at `~/.gbrain/brain.pglite`. No network calls for the init itself. Done in 30 seconds.
61+
62+
**Embedding model.** When `VOYAGE_API_KEY` is set, gstack inits PGLite with `voyage-code-3` (1024-dim) — Voyage's code-specialized embedding model, which beats their general-purpose `voyage-4-large` and OpenAI `text-embedding-3-large` head-to-head on this codebase's symbol queries. Without `VOYAGE_API_KEY`, gbrain auto-selects (OpenAI 1536-dim when `OPENAI_API_KEY` is present, else falls down its provider chain). Either way, the embeddings call out to the chosen provider's API during sync — set the key for the provider you want before running `/sync-gbrain`.
6163

6264
This is the best first choice if you just want to see what gbrain feels like before committing to cloud. You can always migrate later with `/setup-gbrain --switch`.
6365

@@ -251,7 +253,8 @@ Gbrain itself ships with these that gstack wraps:
251253
| `SUPABASE_API_BASE` | `gstack-gbrain-supabase-provision` | Override the Management API host. Used by tests to point at a mock server. |
252254
| `GBRAIN_INSTALL_DIR` | `gstack-gbrain-install` | Override default install path (`~/gbrain`) |
253255
| `GSTACK_HOME` | every bin helper | Override `~/.gstack` state dir. Heavy test use. |
254-
| `OPENAI_API_KEY` | `gbrain embed` subprocess | Required for embeddings during `gbrain sync` / `/sync-gbrain`. Without it, pages are imported structurally (symbol tables, chunks) but semantic search degrades — you'll see `[gbrain] embedding failed for code file ... OpenAI embedding requires OPENAI_API_KEY` in the sync log. |
256+
| `VOYAGE_API_KEY` | `gbrain embed` subprocess; gstack PGLite init | When set, gstack inits PGLite with `voyage-code-3` (1024-dim), Voyage's code-specialized embedding model. Beats `voyage-4-large` and OpenAI `text-embedding-3-large` head-to-head on this codebase's symbol queries. See CHANGELOG v1.43.1.0 for the A/B numbers. |
257+
| `OPENAI_API_KEY` | `gbrain embed` subprocess | Used for embeddings during `gbrain sync` / `/sync-gbrain` when `VOYAGE_API_KEY` is not set (gbrain's auto-selected fallback, `text-embedding-3-large` 1536-dim). Without either key, pages are imported structurally (symbol tables, chunks) but semantic search degrades — you'll see `[gbrain] embedding failed for code file ...` in the sync log. |
255258
| `ANTHROPIC_API_KEY` | `claude-agent-sdk`, paid evals | Required for `bun run test:evals` and any direct `query()` call against Claude. |
256259
| `GSTACK_OPENAI_API_KEY` | `lib/conductor-env-shim.ts` | Conductor-injected fallback. Promoted to `OPENAI_API_KEY` when the canonical name is empty. |
257260
| `GSTACK_ANTHROPIC_API_KEY` | `lib/conductor-env-shim.ts` | Same pattern as above for Anthropic. |
@@ -345,7 +348,7 @@ Embeddings probably failed during import. Symbol queries (`code-def`, `code-refs
345348
[gbrain] embedding failed for code file <name>: OpenAI embedding requires OPENAI_API_KEY
346349
```
347350

348-
The fix is to put `OPENAI_API_KEY` in the process env before re-running. On a bare Mac shell, source it from `~/.zshrc` before calling. In Conductor, set `GSTACK_OPENAI_API_KEY` at the workspace level — `lib/conductor-env-shim.ts` promotes it to canonical automatically when imported. Re-run `/sync-gbrain --code-only` to backfill embeddings on already-imported pages.
351+
The fix is to put a provider API key in the process env before re-running. `VOYAGE_API_KEY` is preferred for code (gstack defaults PGLite to `voyage-code-3` when set); otherwise `OPENAI_API_KEY` falls back to `text-embedding-3-large`. On a bare Mac shell, source the key from `~/.zshrc` before calling. In Conductor, the `lib/conductor-env-shim.ts` shim promotes `GSTACK_ANTHROPIC_API_KEY` / `GSTACK_OPENAI_API_KEY` to their canonical names automatically; for `VOYAGE_API_KEY`, set it directly in your Conductor workspace env. Re-run `/sync-gbrain --code-only` to backfill embeddings on already-imported pages.
349352

350353
### `gbrain sync` blocked at a commit hash — `FILE_TOO_LARGE`
351354

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.43.0.0
1+
1.43.1.0

bin/gstack-gbrain-install

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,13 @@ if ! gbrain sources --help >/dev/null 2>&1; then
217217
fi
218218

219219
echo ""
220-
echo "Next: gbrain init --pglite (or run /setup-gbrain for the full setup flow)"
220+
if [ -n "${VOYAGE_API_KEY:-}" ]; then
221+
echo "Next: gbrain init --pglite --embedding-model voyage:voyage-code-3 --embedding-dimensions 1024"
222+
echo " (or run /setup-gbrain for the full setup flow)"
223+
else
224+
echo "Next: gbrain init --pglite (or run /setup-gbrain for the full setup flow)"
225+
echo ""
226+
echo "Tip: set VOYAGE_API_KEY before init to use voyage-code-3 (best embedding"
227+
echo "model for code retrieval on Voyage). Without it, gbrain falls back to its"
228+
echo "auto-selected provider (OpenAI when OPENAI_API_KEY is set, etc.)."
229+
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.43.0.0",
3+
"version": "1.43.1.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: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,14 @@ with `GSTACK_DETECT_NO_CACHE=1` (busts the 60s cache). If the new
845845
```bash
846846
BACKUP="$HOME/.gbrain/config.json.gstack-bak-$(date +%s)"
847847
mv "$HOME/.gbrain/config.json" "$BACKUP"
848-
if ! gbrain init --pglite --json; then
848+
# gstack default: voyage-code-3 (1024d) when VOYAGE_API_KEY is set — best for
849+
# code retrieval. Without the key, fall back to gbrain's own auto-selected
850+
# embedding provider chain (OpenAI 1536d when OPENAI_API_KEY is present, etc.).
851+
GBRAIN_EMBED_FLAGS=""
852+
if [ -n "${VOYAGE_API_KEY:-}" ]; then
853+
GBRAIN_EMBED_FLAGS="--embedding-model voyage:voyage-code-3 --embedding-dimensions 1024"
854+
fi
855+
if ! gbrain init --pglite --json $GBRAIN_EMBED_FLAGS; then
849856
# Restore on failure
850857
mv "$BACKUP" "$HOME/.gbrain/config.json"
851858
echo "gbrain init failed. Your previous config was restored at $HOME/.gbrain/config.json." >&2
@@ -1052,10 +1059,18 @@ Then follow the same secret-read + verify + init flow as Path 1.
10521059
### Path 3 (PGLite local)
10531060

10541061
```bash
1055-
gbrain init --pglite --json
1062+
# gstack default: voyage-code-3 (1024d) when VOYAGE_API_KEY is set — code
1063+
# retrieval beats general-purpose embeddings on real code queries (validated
1064+
# A/B). Without the key, gbrain auto-selects (OpenAI 1536d when available).
1065+
GBRAIN_EMBED_FLAGS=""
1066+
if [ -n "${VOYAGE_API_KEY:-}" ]; then
1067+
GBRAIN_EMBED_FLAGS="--embedding-model voyage:voyage-code-3 --embedding-dimensions 1024"
1068+
fi
1069+
gbrain init --pglite --json $GBRAIN_EMBED_FLAGS
10561070
```
10571071

1058-
Done. No network, no secrets.
1072+
Done. No network, no secrets (beyond Voyage embedding API calls during sync, if
1073+
`VOYAGE_API_KEY` is set — ~$0.18 per 1M tokens, pennies per repo).
10591074

10601075
### Path 4 (Remote gbrain MCP — HTTP transport with bearer token)
10611076

@@ -1135,7 +1150,15 @@ if [ -f "$HOME/.gbrain/config.json" ]; then
11351150
BACKUP="$HOME/.gbrain/config.json.gstack-bak-$(date +%s)"
11361151
mv "$HOME/.gbrain/config.json" "$BACKUP"
11371152
fi
1138-
if ! gbrain init --pglite --json; then
1153+
# gstack default for local code-search PGLite: voyage-code-3 (1024d) when
1154+
# VOYAGE_API_KEY is set. It wins the A/B over voyage-4-large and OpenAI
1155+
# text-embedding-3-large on this codebase's symbol queries. Falls back to
1156+
# gbrain's auto-selected provider when the key isn't present.
1157+
GBRAIN_EMBED_FLAGS=""
1158+
if [ -n "${VOYAGE_API_KEY:-}" ]; then
1159+
GBRAIN_EMBED_FLAGS="--embedding-model voyage:voyage-code-3 --embedding-dimensions 1024"
1160+
fi
1161+
if ! gbrain init --pglite --json $GBRAIN_EMBED_FLAGS; then
11391162
if [ -n "${BACKUP:-}" ] && [ -f "$BACKUP" ]; then mv "$BACKUP" "$HOME/.gbrain/config.json"; fi
11401163
echo "gbrain init failed. Existing config (if any) was restored. PGLite at ~/.gbrain/pglite/ may be in a partial state — \`rm -rf ~/.gbrain/pglite\` to reset." >&2
11411164
echo "Continuing setup without local code search; you can re-run /setup-gbrain to retry." >&2

setup-gbrain/SKILL.md.tmpl

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,14 @@ with `GSTACK_DETECT_NO_CACHE=1` (busts the 60s cache). If the new
125125
```bash
126126
BACKUP="$HOME/.gbrain/config.json.gstack-bak-$(date +%s)"
127127
mv "$HOME/.gbrain/config.json" "$BACKUP"
128-
if ! gbrain init --pglite --json; then
128+
# gstack default: voyage-code-3 (1024d) when VOYAGE_API_KEY is set — best for
129+
# code retrieval. Without the key, fall back to gbrain's own auto-selected
130+
# embedding provider chain (OpenAI 1536d when OPENAI_API_KEY is present, etc.).
131+
GBRAIN_EMBED_FLAGS=""
132+
if [ -n "${VOYAGE_API_KEY:-}" ]; then
133+
GBRAIN_EMBED_FLAGS="--embedding-model voyage:voyage-code-3 --embedding-dimensions 1024"
134+
fi
135+
if ! gbrain init --pglite --json $GBRAIN_EMBED_FLAGS; then
129136
# Restore on failure
130137
mv "$BACKUP" "$HOME/.gbrain/config.json"
131138
echo "gbrain init failed. Your previous config was restored at $HOME/.gbrain/config.json." >&2
@@ -332,10 +339,18 @@ Then follow the same secret-read + verify + init flow as Path 1.
332339
### Path 3 (PGLite local)
333340

334341
```bash
335-
gbrain init --pglite --json
342+
# gstack default: voyage-code-3 (1024d) when VOYAGE_API_KEY is set — code
343+
# retrieval beats general-purpose embeddings on real code queries (validated
344+
# A/B). Without the key, gbrain auto-selects (OpenAI 1536d when available).
345+
GBRAIN_EMBED_FLAGS=""
346+
if [ -n "${VOYAGE_API_KEY:-}" ]; then
347+
GBRAIN_EMBED_FLAGS="--embedding-model voyage:voyage-code-3 --embedding-dimensions 1024"
348+
fi
349+
gbrain init --pglite --json $GBRAIN_EMBED_FLAGS
336350
```
337351

338-
Done. No network, no secrets.
352+
Done. No network, no secrets (beyond Voyage embedding API calls during sync, if
353+
`VOYAGE_API_KEY` is set — ~$0.18 per 1M tokens, pennies per repo).
339354

340355
### Path 4 (Remote gbrain MCP — HTTP transport with bearer token)
341356

@@ -415,7 +430,15 @@ if [ -f "$HOME/.gbrain/config.json" ]; then
415430
BACKUP="$HOME/.gbrain/config.json.gstack-bak-$(date +%s)"
416431
mv "$HOME/.gbrain/config.json" "$BACKUP"
417432
fi
418-
if ! gbrain init --pglite --json; then
433+
# gstack default for local code-search PGLite: voyage-code-3 (1024d) when
434+
# VOYAGE_API_KEY is set. It wins the A/B over voyage-4-large and OpenAI
435+
# text-embedding-3-large on this codebase's symbol queries. Falls back to
436+
# gbrain's auto-selected provider when the key isn't present.
437+
GBRAIN_EMBED_FLAGS=""
438+
if [ -n "${VOYAGE_API_KEY:-}" ]; then
439+
GBRAIN_EMBED_FLAGS="--embedding-model voyage:voyage-code-3 --embedding-dimensions 1024"
440+
fi
441+
if ! gbrain init --pglite --json $GBRAIN_EMBED_FLAGS; then
419442
if [ -n "${BACKUP:-}" ] && [ -f "$BACKUP" ]; then mv "$BACKUP" "$HOME/.gbrain/config.json"; fi
420443
echo "gbrain init failed. Existing config (if any) was restored. PGLite at ~/.gbrain/pglite/ may be in a partial state — \`rm -rf ~/.gbrain/pglite\` to reset." >&2
421444
echo "Continuing setup without local code search; you can re-run /setup-gbrain to retry." >&2

sync-gbrain/SKILL.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,9 @@ BEFORE invoking the orchestrator:
821821
"Your brain queries (the `mcp__gbrain__*` tools) work via remote MCP, but
822822
symbol code search needs a local PGLite. Run `/setup-gbrain` and pick
823823
'Yes' at the new 'local code index' prompt (Step 4.5), or run
824-
`gbrain init --pglite --json` directly. Continuing without code stage."
824+
`gbrain init --pglite --json --embedding-model voyage:voyage-code-3 --embedding-dimensions 1024`
825+
directly (drop the voyage flags if `VOYAGE_API_KEY` isn't set). Continuing
826+
without code stage."
825827
Then proceed to Step 2 — the orchestrator's `runCodeImport()` and
826828
`runMemoryIngest()` will return SKIP per plan D12; only `runBrainSyncPush()`
827829
will run. Do NOT abort.
@@ -834,7 +836,8 @@ BEFORE invoking the orchestrator:
834836
1. Re-run /setup-gbrain — Step 1.5 offers Retry / Switch to PGLite /
835837
Switch brain mode / Quit (plan D4).
836838
2. Repair manually: mv ~/.gbrain/config.json ~/.gbrain/config.json.bak
837-
&& gbrain init --pglite --json
839+
&& gbrain init --pglite --json --embedding-model voyage:voyage-code-3 \
840+
--embedding-dimensions 1024 (drop voyage flags if VOYAGE_API_KEY unset)
838841
Re-run /sync-gbrain after.
839842
```
840843
Do NOT continue — the orchestrator would skip code+memory and only run

0 commit comments

Comments
 (0)