Danielle Maywood 631bf027c6
refactor(coder-labs/gemini): support terraform provider coder v2.12.0 (#493)
## Description

Updates the module to use the new version of the agentapi module for
Coder 2.28

## Type of Change

- [ ] New module
- [ ] New template
- [ ] Bug fix
- [x] Feature/enhancement
- [ ] Documentation
- [ ] Other

## Module Information

**Path:** `registry/[namespace]/modules/[module-name]`  
**New version:** `v3.0.0`  
**Breaking change:** [x] Yes [ ] No

## Testing & Validation

- [x] Tests pass (`bun test`)
- [x] Code formatted (`bun fmt`)
- [ ] Changes tested locally

## Related Issues

- https://github.com/coder/internal/issues/1065

## Related PRs

- https://github.com/coder/registry/pull/485

---------

Co-authored-by: DevCats <christofer@coder.com>
2025-12-17 10:00:44 -06:00
..

display_name description icon verified tags
Gemini CLI Run Gemini CLI in your workspace for AI pair programming ../../../../.icons/gemini.svg true
agent
gemini
ai
google
tasks

Gemini CLI

Run Gemini CLI in your workspace to access Google's Gemini AI models for interactive coding assistance and automated task execution.

module "gemini" {
  source   = "registry.coder.com/coder-labs/gemini/coder"
  version  = "3.0.0"
  agent_id = coder_agent.main.id
  folder   = "/home/coder/project"
}

Features

  • Interactive AI Assistance: Run Gemini CLI directly in your terminal for coding help
  • Automated Task Execution: Execute coding tasks automatically via AgentAPI integration
  • Multiple AI Models: Support for Gemini 2.5 Pro, Flash, and other Google AI models
  • API Key Integration: Seamless authentication with Gemini API
  • MCP Server Integration: Built-in Coder MCP server for task reporting
  • Persistent Sessions: Maintain context across workspace sessions

Prerequisites

  • Node.js and npm must be sourced/available before the gemini module installs - ensure they are installed in your workspace image or via earlier provisioning steps
  • The Coder Login module is required

Examples

Basic setup

variable "gemini_api_key" {
  type        = string
  description = "Gemini API key"
  sensitive   = true
}

module "gemini" {
  source         = "registry.coder.com/coder-labs/gemini/coder"
  version        = "3.0.0"
  agent_id       = coder_agent.main.id
  gemini_api_key = var.gemini_api_key
  folder         = "/home/coder/project"
}

This basic setup will:

  • Install Gemini CLI in the workspace
  • Configure authentication with your API key
  • Set Gemini to run in /home/coder/project directory
  • Enable interactive use from the terminal
  • Set up MCP server integration for task reporting

Automated task execution (Experimental)

This functionality is in early access and is still evolving. For now, we recommend testing it in a demo or staging environment, rather than deploying to production

Learn more in the Coder documentation

variable "gemini_api_key" {
  type        = string
  description = "Gemini API key"
  sensitive   = true
}

module "coder-login" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/coder/coder-login/coder"
  version  = "~> 1.0"
  agent_id = coder_agent.main.id
}

data "coder_parameter" "ai_prompt" {
  type        = "string"
  name        = "AI Prompt"
  default     = ""
  description = "Task prompt for automated Gemini execution"
  mutable     = true
}

module "gemini" {
  count                = data.coder_workspace.me.start_count
  source               = "registry.coder.com/coder-labs/gemini/coder"
  version              = "3.0.0"
  agent_id             = coder_agent.main.id
  gemini_api_key       = var.gemini_api_key
  gemini_model         = "gemini-2.5-flash"
  folder               = "/home/coder/project"
  task_prompt          = data.coder_parameter.ai_prompt.value
  enable_yolo_mode     = true # Auto-approve all tool calls for automation
  gemini_system_prompt = <<-EOT
    You are a helpful coding assistant. Always explain your code changes clearly.
    YOU MUST REPORT ALL TASKS TO CODER.
  EOT
}

Warning

YOLO mode automatically approves all tool calls without user confirmation. The agent has access to your machine's file system and terminal. Only enable in trusted, isolated environments.

Using Vertex AI (Enterprise)

For enterprise users who prefer Google's Vertex AI platform:

module "gemini" {
  source         = "registry.coder.com/coder-labs/gemini/coder"
  version        = "3.0.0"
  agent_id       = coder_agent.main.id
  gemini_api_key = var.gemini_api_key
  folder         = "/home/coder/project"
  use_vertexai   = true
}

Troubleshooting

  • If Gemini CLI is not found, ensure your API key is valid (install_gemini defaults to true)
  • Check logs in ~/.gemini-module/ for install/start output
  • Use the gemini_api_key variable to avoid requiring Google sign-in

The module creates log files in the workspace's ~/.gemini-module directory for debugging purposes.

References