Skip to content

feat: add Gemini CLI as a provider #24

@williamwarlick

Description

@williamwarlick

Summary

Add Google Gemini CLI (@google/gemini-cli) as a third provider alongside Claude and Codex. This lets nightshift utilize unused Gemini token budgets for overnight task execution.

Motivation

Gemini CLI supports headless execution (gemini -p <prompt> -y --output-format json), model selection (-m), and stores session data with token usage locally at ~/.gemini/tmp/. This maps cleanly onto nightshift's two-layer provider architecture (provider for budget tracking, agent for task execution).

Proposed Changes

Provider layer (internal/providers/gemini.go):

  • Parse Gemini CLI session files to calculate daily/weekly token usage
  • Implement GetUsedPercent, GetTodayUsage, GetWeeklyUsage following the existing provider pattern

Agent layer (internal/agents/gemini.go):

  • Spawn gemini -p <prompt> -m <model> -y --output-format json for headless task execution
  • Support configurable model (e.g., gemini-3-pro-preview)
  • Auto-approve flag support via -y

Config (internal/config/config.go):

  • Add gemini to ProvidersConfig with enabled, data_path, and model fields

Budget (internal/budget/budget.go):

  • Integrate GeminiUsageProvider into the budget manager

Commands:

  • Wire gemini into run, daemon, budget, preview, doctor, task, and snapshot subcommands
  • Add "gemini" to provider preference and candidate selection

Testing

  • 10 provider tests (session parsing, token summing, usage percent, edge cases)
  • 8 agent tests (defaults, options, execution, timeout, file context, errors)

Notes

  • Snapshot collector integration left as follow-up
  • Requires gemini CLI binary in PATH (installable via npm i -g @google/gemini-cli or homebrew)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions