v1.26.3.0 feat: /sync-gbrain skill + native code-surface orchestrator#1314
Merged
v1.26.3.0 feat: /sync-gbrain skill + native code-surface orchestrator#1314
Conversation
…d helper Replaces gbrain import (markdown only) with gbrain sources add + sync --strategy code (or reindex-code on --full). Adds lib/gbrain-sources.ts exporting ensureSourceRegistered/probeSource/sourcePageCount, plus lock file + tmp-rename atomicity + dry-run write skip in the orchestrator. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…e test Extends Step 8 to write a machine-agnostic guidance block that teaches the agent when to prefer gbrain CLI (search/query/code-def/code-refs/ code-callers/code-callees) over Grep. Gated on smoke test pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ance New top-level skill that wraps gstack-gbrain-sync with state probing, capability check (write+search round-trip, not gbrain doctor), CLAUDE.md guidance lifecycle (write iff healthy, remove iff broken), and a per-source verdict block. Re-runnable, idempotent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extends generate-brain-sync-block.ts to emit Variant A (steady-state, 4 lines) when cwd page_count > 0 or Variant B (empty-corpus emergency, 3 lines) when 0; empty string otherwise. Reads cached page_count from .gbrain-sync-state.json (handles pretty + compact JSON). Refreshes ship golden fixtures and bumps the plan-review preamble byte budget to 35K to absorb the new block. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mechanical regeneration after preamble + setup-gbrain template + new sync-gbrain skill. Run via: bun run gen:skill-docs --host all. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…k-sync-and-search # Conflicts: # test/gen-skill-docs.test.ts
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
E2E Evals: ✅ PASS61/61 tests passed | $9.14 total cost | 12 parallel runners
12x ubicloud-standard-2 (Docker: pre-baked toolchain + deps) | wall clock ≈ slowest suite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two functional gaps closed in one ship. The cwd repo wasn't actually being indexed by gbrain (the orchestrator called
gbrain importwhich only handles markdown directories, not code), and the coding agent had no idea gbrain existed in any session that didn't explicitly opt in./sync-gbrainskill (new top-level): wraps the orchestrator with state probing, capability check (write+search round-trip, NOTgbrain doctor), CLAUDE.md guidance lifecycle (write iff healthy, remove iff broken), per-source verdict block. Idempotent, re-runnable.bin/gstack-gbrain-sync.tsswitches fromgbrain import(markdown only) togbrain sources add+gbrain sync --strategy code(incremental) orgbrain reindex-code --yes(--full). Idempotent source registration via the newlib/gbrain-sources.tshelper. Lock file + tmp+atomic-rename for state file. Dry-run skips both writes.scripts/resolvers/preamble/generate-brain-sync-block.ts): every gstack skill start emits a 4-line "prefer gbrain over Grep" hint when capability is healthy and cwd page_count > 0; emits a 3-line emergency hint when corpus is empty; resolves to empty string when gbrain isn't configured (zero context tax for non-gbrain users).## GBrain Search GuidanceCLAUDE.md block written by/setup-gbrainStep 8 (gated on smoke test) and by/sync-gbrain(gated on capability check). Machine-agnostic content; HTML-comment delimited so removal regex never eats user content.7 commits, ~1.5K lines added. The previously-deferred V1.5 P0 watch daemon can wire through to gbrain v0.25.1's native
gbrain sync --watchrather than building gstack-side.Test Coverage
test/gbrain-sources.test.tscoveringensureSourceRegistered(4 cases: absent, no-op-match, drift recreate, no-reregister-on-drift),probeSource(2),sourcePageCount(3). Fakegbrainshell script on PATH via test-onlyenvparameter (Bun's execFileSync caches PATH at process start; explicit env is the only reliable redirect).test/gstack-gbrain-sync.test.ts(was 8) — adds source-id derivation, dry-run no-lock, stale-lock takeover, fresh-lock blocking, all using the post-codex native surface.gen-skill-docs+ manual 3-state smoke test (Variant A, Variant B, empty).test/skill-e2e-memory-pipeline.test.tsupdated to assertwould: gbrain sources addinstead ofwould: gbrain import.test/fixtures/golden/{claude,codex,factory}-ship-SKILL.md) refreshed.--fullagainst real gbrain DB — gbrain is mid-migration on this Mac (config points at unreachablelocalhost:5435), so live exercise is deferred to CI/post-merge.Tests: 720 → 729 free tests pass on merged code (
bun testexit 0).Pre-Landing Review
No findings. New TypeScript uses execFileSync with explicit timeouts and structured error handling. Bash in resolver uses strict quoting and
[ ]tests. Lock file useswxflag for atomic create. No SQL, no auth surfaces, no LLM trust violations.Plan Completion
/sync-gbrainskill (template + per-host SKILL.md generated)gbrain sources add+sync --strategy code)lib/gbrain-sources.tsDRY extraction (eng-review D3)gbrain doctor(codex M7).brainignore, double-indexing~/.gstack,gbrain doctoras gate8/8 accepted plan items DONE.
Verification Results
Skipped — no dev server running (gbrain DB on this Mac is unreachable due to config drift, unrelated to this PR). The dry-run smoke test on this repo confirms source-id derivation (
gstack-code-github.com-garrytan-gstack), three-stage preview, no writes. Live--fullexercise will run post-merge.TODOS
No items completed by this PR.
Documentation
Docs synced for v1.26.3.0:
/sync-gbrainto the Power tools table; added a "Keeping the brain current" paragraph in the GBrain section explaining thegbrain sources add+gbrain sync --strategy codeflow and the auto-removed## GBrain Search Guidanceblock; added/sync-gbrainto the CLAUDE.md available-skills snippet./sync-gbrain(already landed in 7414f45).Test plan
bun testexit 0)bun run gen:skill-docs --host allclean/sync-gbrain --dry-runsmoke test on this repo: source-id derived, three stages preview, no writes/sync-gbrain --fullagainst a healthy gbrain DB; confirmgbrain code-def detectEngineTierreturns the function fromlib/gstack-memory-helpers.ts🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmithwith what you need.