Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 39 additions & 62 deletions registry/coder-labs/modules/gemini/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ tags: [agent, gemini, ai, google, tasks]

# Gemini CLI

Run [Gemini CLI](https://github.com/google-gemini/gemini-cli) in your workspace to access Google's Gemini AI models for interactive coding assistance and automated task execution.
Install and configure the [Gemini CLI](https://github.com/google-gemini/gemini-cli) in your workspace to access Google's Gemini AI models for interactive coding assistance.

```tf
module "gemini" {
source = "registry.coder.com/coder-labs/gemini/coder"
version = "3.0.1"
version = "4.0.0"
agent_id = coder_agent.main.id
folder = "/home/coder/project"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 [DEREM-1] Quick-start example uses folder but the variable was renamed to workdir in this PR. Any user copying this snippet gets:

Error: Unsupported argument. An argument named "folder" is not expected here.

Fix: folderworkdir. (Netero)

🤖

}
```

> [!WARNING]
> If upgrading from v3.x.x of this module: v4 is a major refactor that drops support for [Coder Tasks](https://coder.com/docs/ai-coder/tasks). Keep using v3.x.x if you depend on them. See the [PR description](https://github.com/coder/registry/pull/879) for a full migration guide.

## 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
Expand All @@ -37,39 +39,16 @@ module "gemini" {

### Basic setup

```tf
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.1"
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](https://coder.com/docs/ai-coder)

```tf
locals {
gemini_workdir = "/home/coder/project"
}

variable "gemini_api_key" {
type = string
description = "Gemini API key"
Expand All @@ -83,29 +62,15 @@ module "coder-login" {
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.1"
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
pre_install_script = <<-EOT
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder-labs/gemini/coder"
version = "4.0.0"
agent_id = coder_agent.main.id
gemini_api_key = var.gemini_api_key
gemini_model = "gemini-2.5-flash"
workdir = locals.workdir
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 [DEREM-2] Two errors compound here:

  1. locals.workdir should be local. (singular) for Terraform local value access.
  2. The local is named gemini_workdir (defined on line 48 of this example), not workdir.

Correct reference: local.gemini_workdir. As written, terraform plan fails. (Netero)

🤖

pre_install_script = <<-EOT
#!/bin/bash
set -e

Expand All @@ -122,10 +87,21 @@ module "gemini" {
echo "Node install complete."
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.
resource "coder_app" "gemini" {
agent_id = coder_agent.main.id
slug = "gemini"
display_name = "Gemini"
icon = "/icon/openai.svg"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 [DEREM-3] icon = "/icon/openai.svg" in the Gemini coder_app example. The module itself defaults to /icon/gemini.svg. This is a copy-paste artifact that shows the wrong icon. (Netero)

🤖

open_in = "slim-window"
command = <<-EOT
#!/bin/bash
set -e
cd "${local.gemini_workdir}"
gemini
EOT
}
```

### Using Vertex AI (Enterprise)

Expand All @@ -134,24 +110,25 @@ For enterprise users who prefer Google's Vertex AI platform:
```tf
module "gemini" {
source = "registry.coder.com/coder-labs/gemini/coder"
version = "3.0.1"
version = "4.0.0"
agent_id = coder_agent.main.id
gemini_api_key = var.gemini_api_key
folder = "/home/coder/project"
workdir = "/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
Comment thread
DevelopmentCats marked this conversation as resolved.
Check the log files in `~/.coder-modules/coder-labs/gemini/logs/` for detailed information.

The module creates log files in the workspace's `~/.gemini-module` directory for debugging purposes.
```bash
cat ~/.coder-modules/coder-labs/gemini/logs/install.log
cat ~/.coder-modules/coder-labs/gemini/logs/pre_install.log
cat ~/.coder-modules/coder-labs/gemini/logs/post_install.log
```

## References

- [Gemini CLI Documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/index.md)
- [AgentAPI Documentation](https://github.com/coder/agentapi)
- [Coder AI Agents Guide](https://coder.com/docs/ai-coder)
Loading
Loading