-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
Part of the gh-gcs epic (#93).
When github-code-search is invoked as a gh extension (gh gcs), users have already authenticated via gh auth login. Requiring them to also export GITHUB_TOKEN is unnecessary friction.
Goal
In src/api.ts, before throwing on a missing token, attempt to retrieve it from the gh CLI:
// Fallback: delegate to gh CLI if GITHUB_TOKEN is not set
const ghToken = Bun.spawnSync(["gh", "auth", "token"]).stdout.toString().trim();
if (ghToken) return ghToken;The fallback must be silent if gh is not installed (no crash, no warning).
Behaviour
| Situation | Expected result |
|---|---|
GITHUB_TOKEN set |
Used as-is (no change) |
GITHUB_TOKEN unset, gh auth login done |
Token retrieved from gh auth token |
GITHUB_TOKEN unset, gh not installed |
Error: "No GitHub token found. Set GITHUB_TOKEN or run gh auth login." |
Implementation notes
- The change lives in
src/api.tsin the token resolution function Bun.spawnSyncexits with a non-zero code if not authenticated — handle this gracefully- No new dependency required
Acceptance criteria
- Running
gh gcs --org fulll "query"works withoutGITHUB_TOKENaftergh auth login -
GITHUB_TOKENcontinues to take precedence overgh auth token - Absence of
ghCLI does not crash the process — it falls through to the existing error -
bun test && bun run lintpass
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request