fix: doctor resolves skills/ from install path when run outside repo#128
Open
TheAndersMadsen wants to merge 1 commit intogarrytan:masterfrom
Open
fix: doctor resolves skills/ from install path when run outside repo#128TheAndersMadsen wants to merge 1 commit intogarrytan:masterfrom
TheAndersMadsen wants to merge 1 commit intogarrytan:masterfrom
Conversation
Before this patch, `gbrain doctor` required the user to be inside (or
below) a directory containing `skills/RESOLVER.md`. That matches the
"clone and hack on the brain" flow, but breaks the hosted/CLI-only flow
where the user installs via `bun install github:garrytan/gbrain` and
runs `gbrain` from `~` — the bundled skills live under
`node_modules/gbrain/skills/` and are invisible to a cwd-only walk.
The resolver_health check then reports "Could not find skills directory"
and drops the health score by 5 for every user of the hosted path.
Resolution now falls back through three sources (first hit wins):
1. `GBRAIN_SKILLS_DIR` env var — explicit override for non-standard
layouts (Docker mounts, CI, monorepo subdirs).
2. Walk up from cwd — original behavior, still preferred when you
are inside a brain repo.
3. Walk up from this module's install path via `import.meta.url` —
catches the `node_modules/gbrain/` case without requiring any
user configuration.
Two new tests cover the hosted-CLI case (run from tmpdir, expect no
"Could not find" warning) and the env override path.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
gbrain doctorreportsresolver_health: warn — "Could not find skills directory"for every user who installed viabun install github:garrytan/gbrainand runsgbrainfrom~or any other directory that has noskills/RESOLVER.mdup the tree. The bundledskills/directory lives undernode_modules/gbrain/skills/but the cwd-only walk infindRepoRoot()never looks there.Impact: every hosted-CLI install takes a permanent
-5on the health score, plus the scary-sounding warning noise, even though everything is actually wired correctly.Fix
Three-tier resolution in
findRepoRoot()(first hit wins):GBRAIN_SKILLS_DIRenv var — explicit override for Docker mounts, CI, monorepo subdirs, or anyone who wants a deterministic path.fileURLToPath(import.meta.url), catchesnode_modules/gbrain/automatically without user config.Also refactors the walk into a
walkUpFor(start, relPath)helper so cwd and install-path both share a single, tested implementation.Test plan
bun test test/doctor.test.ts— 7 pass, 0 fail (2 new tests added)bun test(full suite) — 823 pass, 126 skip, 0 failcd ~ && gbrain doctor --fast --jsonno longer shows "Could not find skills directory" —resolver_healthnow reports the actual resolver state (found 10 upstream DRY_VIOLATION warnings in bundled skill content, which is a separate issue).GBRAIN_SKILLS_DIR=/tmp/my-skills gbrain doctor --fastuses the override path.New tests
resolver_health finds bundled skills when run outside repo— spawnsgbrain doctor --fast --jsonfrom a fresh tmpdir and asserts the message does not contain "Could not find".resolver_health honors GBRAIN_SKILLS_DIR env override— creates a tmpdir skills layout, points the env var at it, asserts the resolver finds it.🤖 Generated with Claude Code