feat: Gemini CLI client adapter (D4a)#120
Merged
Merged
Conversation
Adds `gemini-cli` as a 6th first-class client targeting the user-global `~/.gemini/settings.json` (top-level `mcpServers` map) — a rootKey-only BaseAdapter subclass, a structural clone of the Claude Code adapter (D1). The detector auto-enumerates CLIENT_IDS, so every client-iterating command (install, remove, list, audit, doctor, sync --check, up, guard, …) picks it up with no further wiring. Writes preserve unrelated settings.json keys (theme, selectedAuthType, …) via the existing atomic read-modify-write + .bak. Scope: user-global only; per-project .gemini/settings.json is out of scope (same as D1). URL caveat: Gemini reads url=SSE / httpUrl=HTTP, mcpm writes url — the existing non-Cursor URL-transport caveat. Zero new deps. Verified end-to-end on the built CLI (doctor detects it; disable preserves sibling keys) + unit tests for clientId, read, sibling-preservation, and paths. Format confirmed against Google's gemini-cli docs.
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.
What
Adds Gemini CLI (Google's terminal agent) as a 6th first-class client, targeting the user-global
~/.gemini/settings.json(top-levelmcpServersmap). This is Wave-1 item D4a fromdocs/ROADMAP-ADOPTION.md— the next developer-reach adapter after D1 (Claude Code, shipped v0.18.0).It's a structural clone of the D1 pattern: a rootKey-only
BaseAdaptersubclass. The detector auto-enumeratesCLIENT_IDS, so every client-iterating command —install,remove,list,audit,doctor,sync --check,up,guard, … — picks it up with no further wiring.Changes
src/config/paths.ts—gemini-cliadded to theCLIENT_IDStuple +getConfigPathcase →~/.gemini/settings.json(home-relative on all platforms, like claude-code/cursor/windsurf)src/config/adapters/gemini-cli.ts— newGeminiCliAdapter(rootKeymcpServers)factory.ts/index.ts— wire + export the adaptercompletions.ts,doctor.ts,guard/cli.ts— the three hardcoded/label client lists (the exhaustiveness tripwire onRecord<ClientId, string>surfaced the last two at typecheck)Scope & caveats (honest)
.gemini/settings.jsonis deliberately out of scope — same reasoning as D1's per-project deferral (nested shape doesn't fit the single-rootKey model).urlas an SSE endpoint andhttpUrlas HTTP; mcpm writesurl. Same URL-transport caveat that already applies to every non-Cursor client.gemini-clidocs (top-levelmcpServers,~/.gemini/settings.json).Tests
gemini-cli.test.ts: clientId, readsmcpServers, and the key invariant — a write preserves unrelatedsettings.jsonkeys (theme,selectedAuthType, a server's extratrustfield)paths.test.ts: darwin/linux/win32 path resolutiondoctor.test.ts:ALL_CLIENTSupdated (the client-count invariant)FORCE_COLOR=0); typecheck + lint cleanEnd-to-end verification
Ran the built CLI in a throwaway
HOMEagainst a realistic~/.gemini/settings.json:doctor→✓ Gemini CLI — config found, 1 serverdisable existing --client gemini-cli→ preservedtheme/selectedAuthType/ the server'strustfield, addeddisabled: true, wrote.bakDocs
CHANGELOG
[Unreleased], README supported-clients table + diagram, CLAUDE.md (version line, architecture diagram, decisions log), ROADMAP-ADOPTION.md (D4a → ✅ SHIPPED).