Commit 331369d
committed
feat(agent-manager): add Gemini CLI agent adapter
Adds a GeminiCliAdapter alongside the existing Claude Code and Codex
adapters so `ai-devkit agent list` and `ai-devkit agent detail` can
discover and inspect running Gemini CLI sessions. The adapter follows
the canHandle / detectAgents / getConversation contract and registers
in every agent.ts entrypoint that composes an AgentManager.
Process detection reuses the shared `listAgentProcesses('gemini')`
helper. `isGeminiExecutable` falls back to `path.win32.basename` when
it sees a backslash separator so Windows-style command paths still
resolve to a gemini.exe basename on either platform.
Session discovery walks `~/.gemini/tmp/<shortId>/chats/session-*.json`
across every project short-id directory Gemini maintains. Each
session JSON carries its own `projectHash` — sha256 of the project
root that Gemini CLI resolved at write time via its `.git`-bounded
`findProjectRoot` walk. To stay consistent with that, the adapter
enumerates every ancestor of each running process' CWD, hashes each
candidate, and looks up any matching projectHash to populate
`resolvedCwd` on a SessionFile. The shared
`matchProcessesToSessions()` then performs the usual CWD + birthtime
1:1 greedy assignment, and processes without a matching session
fall back to the process-only AgentInfo shape.
`getConversation` parses the single-JSON-per-file layout Gemini uses
(not JSONL): `messages` is an array with `type` of 'user' or 'gemini'
for visible turns; 'thought' and 'tool' entries are hidden by default
and surface as `system` role when `--verbose` is set.
`displayContent` takes priority over `content` when both are present.
Test coverage mirrors the depth of CodexAdapter — 35 unit tests across
initialization, canHandle, detectAgents, discoverSessions (including
the parent-of-cwd git-root case), determineStatus, parseSession, and
getConversation. Also updates the jest mock in the CLI agent command
test so `agent detail` can route `gemini_cli` agents through the new
adapter for conversation rendering.1 parent 9419d3a commit 331369d
6 files changed
Lines changed: 1118 additions & 0 deletions
File tree
- packages
- agent-manager/src
- __tests__/adapters
- adapters
- cli/src
- __tests__/commands
- commands
0 commit comments