From 18d09171754d12f439d4a19c94e7c87997f92812 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <christofer@coder.com>
Date: Tue, 5 Aug 2025 01:30:39 +0000
Subject: [PATCH 01/16] chore: cleanup gemini script and docs

- distinguished module usage in task mode and basic mode
- remove built in coder parameter, and add as variable instead
---
 registry/coder-labs/modules/gemini/README.md  | 114 ++++++++++++------
 .../coder-labs/modules/gemini/main.test.ts    |  12 ++
 registry/coder-labs/modules/gemini/main.tf    |  14 +--
 .../modules/gemini/scripts/install.sh         |  12 +-
 .../modules/gemini/scripts/start.sh           |   6 +-
 5 files changed, 105 insertions(+), 53 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/README.md b/registry/coder-labs/modules/gemini/README.md
index 65b9d9bc..c7ddd6bc 100644
--- a/registry/coder-labs/modules/gemini/README.md
+++ b/registry/coder-labs/modules/gemini/README.md
@@ -1,36 +1,40 @@
 ---
 display_name: Gemini CLI
+description: Run Gemini CLI in your workspace for AI pair programming
 icon: ../../../../.icons/gemini.svg
-description: Run Gemini CLI in your workspace with AgentAPI integration
 verified: true
 tags: [agent, gemini, ai, google, tasks]
 ---
 
 # Gemini CLI
 
-Run [Gemini CLI](https://ai.google.dev/gemini-api/docs/cli) in your workspace to access Google's Gemini AI models, and custom pre/post install scripts. This module integrates with [AgentAPI](https://github.com/coder/agentapi) for Coder Tasks compatibility.
+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.
 
 ```tf
 module "gemini" {
-  source           = "registry.coder.com/coder-labs/gemini/coder"
-  version          = "1.0.0"
-  agent_id         = coder_agent.example.id
-  gemini_api_key   = var.gemini_api_key
-  gemini_model     = "gemini-2.5-pro"
-  install_gemini   = true
-  gemini_version   = "latest"
-  agentapi_version = "latest"
+  source   = "registry.coder.com/coder-labs/gemini/coder"
+  version  = "1.0.0"
+  agent_id = coder_agent.example.id
 }
 ```
 
+## 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
 
-- You must add the [Coder Login](https://registry.coder.com/modules/coder-login/coder) module to your template
 - Node.js and npm will be installed automatically if not present
+- For automated task execution, you must add the [Coder Login](https://registry.coder.com/modules/coder/coder-login) module to your template
 
-## Usage Example
+## Examples
 
-- Example 1:
+### Basic setup
 
 ```tf
 variable "gemini_api_key" {
@@ -40,39 +44,77 @@ variable "gemini_api_key" {
 }
 
 module "gemini" {
-  count                     = data.coder_workspace.me.start_count
-  source                    = "registry.coder.com/coder-labs/gemini/coder"
-  version                   = "1.0.0"
-  agent_id                  = coder_agent.example.id
-  gemini_api_key            = var.gemini_api_key # we recommend providing this parameter inorder to have a smoother experience (i.e. no google sign-in)
-  gemini_model              = "gemini-2.5-flash"
-  install_gemini            = true
-  gemini_version            = "latest"
-  gemini_instruction_prompt = "Start every response with `Gemini says:`"
+  source         = "registry.coder.com/coder-labs/gemini/coder"
+  version        = "1.0.0"
+  agent_id       = coder_agent.example.id
+  gemini_api_key = var.gemini_api_key
 }
 ```
 
-## How it Works
+This basic setup will:
+
+- Install Gemini CLI in the workspace
+- Configure authentication with your API key
+- 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)
 
-- **Install**: The module installs Gemini CLI using npm (installs Node.js via NVM if needed)
-- **Instruction Prompt**: If `GEMINI_INSTRUCTION_PROMPT` and `GEMINI_START_DIRECTORY` are set, creates the directory (if needed) and writes the prompt to `GEMINI.md`
-- **Start**: Launches Gemini CLI in the specified directory, wrapped by AgentAPI
-- **Environment**: Sets `GEMINI_API_KEY`, `GOOGLE_GENAI_USE_VERTEXAI`, `GEMINI_MODEL` for the CLI (if variables provided)
+```tf
+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.example.id
+}
+
+data "coder_parameter" "ai_prompt" {
+  type        = "string"
+  name        = "AI Prompt"
+  default     = ""
+  description = "Task prompt for automated Gemini execution"
+  mutable     = true
+  ephemeral   = true
+}
+
+module "gemini" {
+  count              = data.coder_workspace.me.start_count
+  source             = "registry.coder.com/coder-labs/gemini/coder"
+  version            = "1.0.0"
+  agent_id           = coder_agent.example.id
+  gemini_api_key     = var.gemini_api_key
+  gemini_model       = "gemini-2.5-flash"
+  task_prompt        = data.coder_parameter.ai_prompt.value
+  gemini_system_prompt = <<-EOT
+    You are a helpful coding assistant. Always explain your code changes clearly.
+    YOU MUST REPORT ALL TASKS TO CODER.
+  EOT
+}
+```
 
 ## Troubleshooting
 
-- If Gemini CLI is not found, ensure `install_gemini = true` and your API key is valid
+- If Gemini CLI is not found, ensure your API key is valid (`install_gemini` defaults to `true`)
 - Node.js and npm are installed automatically if missing (using NVM)
-- Check logs in `/home/coder/.gemini-module/` for install/start output
-- We highly recommend using the `gemini_api_key` variable, this also ensures smooth tasks running without needing to sign in to Google.
+- Check logs in `~/.gemini-module/` for install/start output
+- Use the `gemini_api_key` variable to avoid requiring Google sign-in
 
-> [!IMPORTANT]
-> To use tasks with Gemini CLI, ensure you have the `gemini_api_key` variable set, and **you pass the `AI Prompt` Parameter**.
-> By default we inject the "theme": "Default" and "selectedAuthType": "gemini-api-key" to your ~/.gemini/settings.json along with the coder mcp server.
-> In `gemini_instruction_prompt` and `AI Prompt` text we recommend using (\`\`) backticks instead of quotes to avoid escaping issues. Eg: gemini_instruction_prompt = "Start every response with \`Gemini says:\` "
+The module creates log files in the workspace's `~/.gemini-module` directory for debugging purposes.
 
 ## References
 
-- [Gemini CLI Documentation](https://ai.google.dev/gemini-api/docs/cli)
+- [Gemini CLI Documentation](https://github.com/google-gemini/gemini-cli)
 - [AgentAPI Documentation](https://github.com/coder/agentapi)
-- [Coder AI Agents Guide](https://coder.com/docs/tutorials/ai-agents)
+- [Coder AI Agents Guide](https://coder.com/docs/ai-coder)
diff --git a/registry/coder-labs/modules/gemini/main.test.ts b/registry/coder-labs/modules/gemini/main.test.ts
index 181b6114..68e9409a 100644
--- a/registry/coder-labs/modules/gemini/main.test.ts
+++ b/registry/coder-labs/modules/gemini/main.test.ts
@@ -197,6 +197,18 @@ describe("gemini", async () => {
     expect(resp).toContain(prompt);
   });
 
+  test("task-prompt", async () => {
+    const taskPrompt = "Create a simple Hello World function";
+    const { id } = await setup({
+      moduleVariables: {
+        task_prompt: taskPrompt,
+      },
+    });
+    await execModuleScript(id);
+    const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log");
+    expect(resp).toContain("Running automated task:");
+  });
+
   test("start-without-prompt", async () => {
     const { id } = await setup();
     await execModuleScript(id);
diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf
index ab4fa945..aa5c4b82 100644
--- a/registry/coder-labs/modules/gemini/main.tf
+++ b/registry/coder-labs/modules/gemini/main.tf
@@ -74,7 +74,7 @@ variable "use_vertexai" {
 
 variable "install_agentapi" {
   type        = bool
-  description = "Whether to install AgentAPI."
+  description = "Whether to install AgentAPI for web UI and task automation."
   default     = true
 }
 
@@ -102,12 +102,10 @@ variable "post_install_script" {
   default     = null
 }
 
-data "coder_parameter" "ai_prompt" {
-  type        = "string"
-  name        = "AI Prompt"
+variable "task_prompt" {
+  type        = string
+  description = "Task prompt for automated Gemini execution"
   default     = ""
-  description = "Initial prompt for the Gemini CLI"
-  mutable     = true
 }
 
 variable "additional_extensions" {
@@ -192,7 +190,7 @@ module "agentapi" {
      GOOGLE_GENAI_USE_VERTEXAI='${var.use_vertexai}' \
      GEMINI_MODEL='${var.gemini_model}' \
      GEMINI_START_DIRECTORY='${var.folder}' \
-     GEMINI_TASK_PROMPT='${base64encode(data.coder_parameter.ai_prompt.value)}' \
+     GEMINI_TASK_PROMPT='${base64encode(var.task_prompt)}' \
      /tmp/start.sh
    EOT
 
@@ -209,7 +207,7 @@ module "agentapi" {
     BASE_EXTENSIONS='${base64encode(replace(local.base_extensions, "'", "'\\''"))}' \
     ADDITIONAL_EXTENSIONS='${base64encode(replace(var.additional_extensions != null ? var.additional_extensions : "", "'", "'\\''"))}' \
     GEMINI_START_DIRECTORY='${var.folder}' \
-    GEMINI_INSTRUCTION_PROMPT='${base64encode(var.gemini_system_prompt)}' \
+    GEMINI_SYSTEM_PROMPT='${base64encode(var.gemini_system_prompt)}' \
     /tmp/install.sh
   EOT
 }
\ No newline at end of file
diff --git a/registry/coder-labs/modules/gemini/scripts/install.sh b/registry/coder-labs/modules/gemini/scripts/install.sh
index a800dbd2..c6eb9e43 100644
--- a/registry/coder-labs/modules/gemini/scripts/install.sh
+++ b/registry/coder-labs/modules/gemini/scripts/install.sh
@@ -12,7 +12,7 @@ set -o nounset
 ARG_GEMINI_CONFIG=$(echo -n "$ARG_GEMINI_CONFIG" | base64 -d)
 BASE_EXTENSIONS=$(echo -n "$BASE_EXTENSIONS" | base64 -d)
 ADDITIONAL_EXTENSIONS=$(echo -n "$ADDITIONAL_EXTENSIONS" | base64 -d)
-GEMINI_INSTRUCTION_PROMPT=$(echo -n "$GEMINI_INSTRUCTION_PROMPT" | base64 -d)
+GEMINI_SYSTEM_PROMPT=$(echo -n "$GEMINI_SYSTEM_PROMPT" | base64 -d)
 
 echo "--------------------------------"
 printf "gemini_config: %s\n" "$ARG_GEMINI_CONFIG"
@@ -55,7 +55,7 @@ function install_gemini() {
     # we need node to install and run gemini-cli
     install_node
 
-  # If nvm does not exist, we will create a global npm directory (this os to prevent the possibility of EACCESS issues on npm -g)
+  # If nvm does not exist, we will create a global npm directory (this is to prevent the possibility of EACCESS issues on npm -g)
   if ! command_exists nvm; then
       printf "which node: %s\n" "$(which node)"
       printf "which npm: %s\n" "$(which npm)"
@@ -139,8 +139,8 @@ function append_extensions_to_settings_json() {
     printf "[append_extensions_to_settings_json] Merge complete.\n"
 }
 
-function add_instruction_prompt_if_exists() {
-    if [ -n "${GEMINI_INSTRUCTION_PROMPT:-}" ]; then
+function add_system_prompt_if_exists() {
+    if [ -n "${GEMINI_SYSTEM_PROMPT:-}" ]; then
         if [ -d "${GEMINI_START_DIRECTORY}" ]; then
             printf "Directory '%s' exists. Changing to it.\\n" "${GEMINI_START_DIRECTORY}"
             cd "${GEMINI_START_DIRECTORY}" || {
@@ -160,7 +160,7 @@ function add_instruction_prompt_if_exists() {
         fi
         touch GEMINI.md
         printf "Setting GEMINI.md\n"
-        echo "${GEMINI_INSTRUCTION_PROMPT}" > GEMINI.md
+        echo "${GEMINI_SYSTEM_PROMPT}" > GEMINI.md
     else
         printf "GEMINI.md is not set.\n"
     fi
@@ -171,5 +171,5 @@ function add_instruction_prompt_if_exists() {
 install_gemini
 gemini --version
 populate_settings_json
-add_instruction_prompt_if_exists
+add_system_prompt_if_exists
 
diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index 00e0b5ed..c62ca597 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -43,11 +43,11 @@ else
 fi
 
 if [ -n "$GEMINI_TASK_PROMPT" ]; then
-    printf "Running the task prompt %s\n" "$GEMINI_TASK_PROMPT"
+    printf "Running automated task: %s\n" "$GEMINI_TASK_PROMPT"
     PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT"
-    GEMINI_ARGS=(--prompt-interactive "$PROMPT")
+    GEMINI_ARGS=(--prompt "$PROMPT")
 else
-    printf "No task prompt given.\n"
+    printf "Starting Gemini CLI in interactive mode.\n"
     GEMINI_ARGS=()
 fi
 

From 40d4d3f885a7b2f3c4cfe6b2f419b4f4b9b8bda4 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 21:11:52 -0500
Subject: [PATCH 02/16] feat(gemini): add YOLO mode for auto-approving tool
 calls and update README

---
 registry/coder-labs/modules/gemini/README.md  | 19 ++++++++++++++++++-
 registry/coder-labs/modules/gemini/main.tf    | 14 ++++++++++++++
 .../modules/gemini/scripts/start.sh           | 17 ++++++++++++++---
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/README.md b/registry/coder-labs/modules/gemini/README.md
index c7ddd6bc..24caa21d 100644
--- a/registry/coder-labs/modules/gemini/README.md
+++ b/registry/coder-labs/modules/gemini/README.md
@@ -97,6 +97,7 @@ module "gemini" {
   gemini_api_key     = var.gemini_api_key
   gemini_model       = "gemini-2.5-flash"
   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.
@@ -104,10 +105,26 @@ module "gemini" {
 }
 ```
 
+> [!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:
+
+```tf
+module "gemini" {
+  source         = "registry.coder.com/coder-labs/gemini/coder"
+  version        = "1.0.0"
+  agent_id       = coder_agent.example.id
+  gemini_api_key = var.gemini_api_key
+  use_vertexai   = true
+}
+```
+
 ## Troubleshooting
 
 - If Gemini CLI is not found, ensure your API key is valid (`install_gemini` defaults to `true`)
-- Node.js and npm are installed automatically if missing (using NVM)
 - Check logs in `~/.gemini-module/` for install/start output
 - Use the `gemini_api_key` variable to avoid requiring Google sign-in
 
diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf
index aa5c4b82..fa49ff5e 100644
--- a/registry/coder-labs/modules/gemini/main.tf
+++ b/registry/coder-labs/modules/gemini/main.tf
@@ -120,12 +120,24 @@ variable "gemini_system_prompt" {
   default     = ""
 }
 
+variable "enable_yolo_mode" {
+  type        = bool
+  description = "Enable YOLO mode to automatically approve all tool calls without user confirmation. Use with caution."
+  default     = false
+}
+
 resource "coder_env" "gemini_api_key" {
   agent_id = var.agent_id
   name     = "GEMINI_API_KEY"
   value    = var.gemini_api_key
 }
 
+resource "coder_env" "google_api_key" {
+  agent_id = var.agent_id
+  name     = "GOOGLE_API_KEY"
+  value    = var.gemini_api_key
+}
+
 resource "coder_env" "gemini_use_vertex_ai" {
   agent_id = var.agent_id
   name     = "GOOGLE_GENAI_USE_VERTEXAI"
@@ -187,7 +199,9 @@ module "agentapi" {
      echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh
      chmod +x /tmp/start.sh
      GEMINI_API_KEY='${var.gemini_api_key}' \
+     GOOGLE_API_KEY='${var.gemini_api_key}' \
      GOOGLE_GENAI_USE_VERTEXAI='${var.use_vertexai}' \
+      GEMINI_YOLO_MODE='${var.enable_yolo_mode}' \
      GEMINI_MODEL='${var.gemini_model}' \
      GEMINI_START_DIRECTORY='${var.folder}' \
      GEMINI_TASK_PROMPT='${base64encode(var.task_prompt)}' \
diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index c62ca597..1b90936f 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -51,10 +51,21 @@ else
     GEMINI_ARGS=()
 fi
 
-if [ -n "$GEMINI_API_KEY" ]; then
-    printf "gemini_api_key provided !\n"
+# Enable YOLO mode if requested
+if [ -n "$GEMINI_YOLO_MODE" ] && [ "$GEMINI_YOLO_MODE" = "true" ]; then
+    printf "YOLO mode enabled - will auto-approve all tool calls\n"
+    GEMINI_ARGS+=(--yolo)
+fi
+
+# Check for API key in either environment variable
+if [ -n "$GEMINI_API_KEY" ] || [ -n "$GOOGLE_API_KEY" ]; then
+    if [ -n "$GOOGLE_GENAI_USE_VERTEXAI" ] && [ "$GOOGLE_GENAI_USE_VERTEXAI" = "true" ]; then
+        printf "Using Vertex AI with API key\n"
+    else
+        printf "Using direct Gemini API with API key\n"
+    fi
 else
-    printf "gemini_api_key not provided\n"
+    printf "No API key provided (neither GEMINI_API_KEY nor GOOGLE_API_KEY)\n"
 fi
 
 # use low width to fit in the tasks UI sidebar. height is adjusted so that width x height ~= 80x1000 characters

From ce41f0c9b140425a5aad4a2f822dd24a7b6b69ca Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 21:19:17 -0500
Subject: [PATCH 03/16] chore(gemini): clean up install and start scripts by
 removing unnecessary comments

---
 .../modules/gemini/scripts/install.sh           | 17 -----------------
 .../coder-labs/modules/gemini/scripts/start.sh  |  5 -----
 2 files changed, 22 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/scripts/install.sh b/registry/coder-labs/modules/gemini/scripts/install.sh
index c6eb9e43..b57dafd6 100644
--- a/registry/coder-labs/modules/gemini/scripts/install.sh
+++ b/registry/coder-labs/modules/gemini/scripts/install.sh
@@ -2,7 +2,6 @@
 
 BOLD='\033[0;1m'
 
-# Function to check if a command exists
 command_exists() {
     command -v "$1" >/dev/null 2>&1
 }
@@ -23,7 +22,6 @@ echo "--------------------------------"
 set +o nounset
 
 function install_node() {
-  # borrowed from claude-code module
     if ! command_exists npm; then
       printf "npm not found, checking for Node.js installation...\n"
       if ! command_exists node; then
@@ -52,24 +50,15 @@ function install_node() {
 
 function install_gemini() {
   if [ "${ARG_INSTALL}" = "true" ]; then
-    # we need node to install and run gemini-cli
     install_node
 
-  # If nvm does not exist, we will create a global npm directory (this is to prevent the possibility of EACCESS issues on npm -g)
   if ! command_exists nvm; then
       printf "which node: %s\n" "$(which node)"
       printf "which npm: %s\n" "$(which npm)"
 
-      # Create a directory for global packages
       mkdir -p "$HOME"/.npm-global
-
-      # Configure npm to use it
       npm config set prefix "$HOME/.npm-global"
-
-      # Add to PATH for current session
       export PATH="$HOME/.npm-global/bin:$PATH"
-
-      # Add to shell profile for future sessions
       if ! grep -q "export PATH=$HOME/.npm-global/bin:\$PATH" ~/.bashrc; then
           echo "export PATH=$HOME/.npm-global/bin:\$PATH" >> ~/.bashrc
       fi
@@ -108,7 +97,6 @@ function append_extensions_to_settings_json() {
     fi
     if [ ! -f "$SETTINGS_PATH" ]; then
       printf "%s does not exist. Creating with merged mcpServers structure.\n" "$SETTINGS_PATH"
-      # If ADDITIONAL_EXTENSIONS is not set or empty, use '{}'
       ADD_EXT_JSON='{}'
       if [ -n "${ADDITIONAL_EXTENSIONS:-}" ]; then
         ADD_EXT_JSON="$ADDITIONAL_EXTENSIONS"
@@ -116,10 +104,7 @@ function append_extensions_to_settings_json() {
       printf '{"mcpServers":%s}\n' "$(jq -s 'add' <(echo "$BASE_EXTENSIONS") <(echo "$ADD_EXT_JSON"))" > "$SETTINGS_PATH"
     fi
 
-    # Prepare temp files
     TMP_SETTINGS=$(mktemp)
-
-    # If ADDITIONAL_EXTENSIONS is not set or empty, use '{}'
     ADD_EXT_JSON='{}'
     if [ -n "${ADDITIONAL_EXTENSIONS:-}" ]; then
       printf "[append_extensions_to_settings_json] ADDITIONAL_EXTENSIONS is set.\n"
@@ -133,7 +118,6 @@ function append_extensions_to_settings_json() {
       '.mcpServers = (.mcpServers // {} + $base + $add)' \
       "$SETTINGS_PATH" > "$TMP_SETTINGS" && mv "$TMP_SETTINGS" "$SETTINGS_PATH"
 
-    # Add theme and selectedAuthType fields
     jq '.theme = "Default" | .selectedAuthType = "gemini-api-key"' "$SETTINGS_PATH" > "$TMP_SETTINGS" && mv "$TMP_SETTINGS" "$SETTINGS_PATH"
 
     printf "[append_extensions_to_settings_json] Merge complete.\n"
@@ -167,7 +151,6 @@ function add_system_prompt_if_exists() {
 }
 
 
-# Install Gemini
 install_gemini
 gemini --version
 populate_settings_json
diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index 1b90936f..2b464148 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -1,6 +1,5 @@
 #!/bin/bash
 
-# Load shell environment
 source "$HOME"/.bashrc
 
 command_exists() {
@@ -51,13 +50,11 @@ else
     GEMINI_ARGS=()
 fi
 
-# Enable YOLO mode if requested
 if [ -n "$GEMINI_YOLO_MODE" ] && [ "$GEMINI_YOLO_MODE" = "true" ]; then
     printf "YOLO mode enabled - will auto-approve all tool calls\n"
     GEMINI_ARGS+=(--yolo)
 fi
 
-# Check for API key in either environment variable
 if [ -n "$GEMINI_API_KEY" ] || [ -n "$GOOGLE_API_KEY" ]; then
     if [ -n "$GOOGLE_GENAI_USE_VERTEXAI" ] && [ "$GOOGLE_GENAI_USE_VERTEXAI" = "true" ]; then
         printf "Using Vertex AI with API key\n"
@@ -68,6 +65,4 @@ else
     printf "No API key provided (neither GEMINI_API_KEY nor GOOGLE_API_KEY)\n"
 fi
 
-# use low width to fit in the tasks UI sidebar. height is adjusted so that width x height ~= 80x1000 characters
-# are visible in the terminal screen by default.
 agentapi server --term-width 67 --term-height 1190 -- gemini "${GEMINI_ARGS[@]}"
\ No newline at end of file

From 4fcc003f9b6dfe980e3d9d9fb0ef1553196ce1f6 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 21:28:52 -0500
Subject: [PATCH 04/16] fix(gemini): update test expectation for API key usage
 message and bun fmt

---
 registry/coder-labs/modules/gemini/README.md    | 16 ++++++++--------
 registry/coder-labs/modules/gemini/main.test.ts |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/README.md b/registry/coder-labs/modules/gemini/README.md
index 24caa21d..3ec242b3 100644
--- a/registry/coder-labs/modules/gemini/README.md
+++ b/registry/coder-labs/modules/gemini/README.md
@@ -90,14 +90,14 @@ data "coder_parameter" "ai_prompt" {
 }
 
 module "gemini" {
-  count              = data.coder_workspace.me.start_count
-  source             = "registry.coder.com/coder-labs/gemini/coder"
-  version            = "1.0.0"
-  agent_id           = coder_agent.example.id
-  gemini_api_key     = var.gemini_api_key
-  gemini_model       = "gemini-2.5-flash"
-  task_prompt        = data.coder_parameter.ai_prompt.value
-  enable_yolo_mode   = true  # Auto-approve all tool calls for automation
+  count                = data.coder_workspace.me.start_count
+  source               = "registry.coder.com/coder-labs/gemini/coder"
+  version              = "1.0.0"
+  agent_id             = coder_agent.example.id
+  gemini_api_key       = var.gemini_api_key
+  gemini_model         = "gemini-2.5-flash"
+  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.
diff --git a/registry/coder-labs/modules/gemini/main.test.ts b/registry/coder-labs/modules/gemini/main.test.ts
index 68e9409a..7c656d93 100644
--- a/registry/coder-labs/modules/gemini/main.test.ts
+++ b/registry/coder-labs/modules/gemini/main.test.ts
@@ -117,7 +117,7 @@ describe("gemini", async () => {
     await execModuleScript(id);
 
     const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log");
-    expect(resp).toContain("gemini_api_key provided !");
+    expect(resp).toContain("Using direct Gemini API with API key");
   });
 
   test("use-vertexai", async () => {

From 370e73db8d9d7c23a043b3e53c3d32d1b8ef7a6c Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 21:57:08 -0500
Subject: [PATCH 05/16] refactor(gemini): improve parameter persistence and
 argument handling

---
 registry/coder-labs/modules/gemini/README.md        | 1 -
 registry/coder-labs/modules/gemini/scripts/start.sh | 3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/README.md b/registry/coder-labs/modules/gemini/README.md
index 3ec242b3..d249a951 100644
--- a/registry/coder-labs/modules/gemini/README.md
+++ b/registry/coder-labs/modules/gemini/README.md
@@ -86,7 +86,6 @@ data "coder_parameter" "ai_prompt" {
   default     = ""
   description = "Task prompt for automated Gemini execution"
   mutable     = true
-  ephemeral   = true
 }
 
 module "gemini" {
diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index 2b464148..e9392c66 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -44,7 +44,8 @@ fi
 if [ -n "$GEMINI_TASK_PROMPT" ]; then
     printf "Running automated task: %s\n" "$GEMINI_TASK_PROMPT"
     PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT"
-    GEMINI_ARGS=(--prompt "$PROMPT")
+    GEMINI_ARGS=(--prompt)
+    GEMINI_ARGS+=("$PROMPT")
 else
     printf "Starting Gemini CLI in interactive mode.\n"
     GEMINI_ARGS=()

From 9b442628a50ac12fcfa4c30033534dd921a294b9 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 22:10:42 -0500
Subject: [PATCH 06/16] refactor(gemini): reorganize agentapi module
 configuration and enhance start script

---
 registry/coder-labs/modules/gemini/main.tf    | 38 ++++++++++---------
 .../modules/gemini/scripts/start.sh           | 13 ++++++-
 2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf
index fa49ff5e..c82f149c 100644
--- a/registry/coder-labs/modules/gemini/main.tf
+++ b/registry/coder-labs/modules/gemini/main.tf
@@ -179,18 +179,39 @@ module "agentapi" {
   version = "1.0.0"
 
   agent_id             = var.agent_id
+  folder               = var.folder
   web_app_slug         = local.app_slug
   web_app_order        = var.order
   web_app_group        = var.group
   web_app_icon         = var.icon
   web_app_display_name = "Gemini"
+  cli_app              = true
   cli_app_slug         = "${local.app_slug}-cli"
   cli_app_display_name = "Gemini CLI"
+  cli_app_icon         = var.icon
+  cli_app_order        = var.order
+  cli_app_group        = var.group
   module_dir_name      = local.module_dir_name
   install_agentapi     = var.install_agentapi
   agentapi_version     = var.agentapi_version
   pre_install_script   = var.pre_install_script
   post_install_script  = var.post_install_script
+  install_script       = <<-EOT
+    #!/bin/bash
+    set -o errexit
+    set -o pipefail
+
+    echo -n '${base64encode(local.install_script)}' | base64 -d > /tmp/install.sh
+    chmod +x /tmp/install.sh
+    ARG_INSTALL='${var.install_gemini}' \
+    ARG_GEMINI_VERSION='${var.gemini_version}' \
+    ARG_GEMINI_CONFIG='${base64encode(var.gemini_settings_json)}' \
+    BASE_EXTENSIONS='${base64encode(replace(local.base_extensions, "'", "'\\''"))}' \
+    ADDITIONAL_EXTENSIONS='${base64encode(replace(var.additional_extensions != null ? var.additional_extensions : "", "'", "'\\''"))}' \
+    GEMINI_START_DIRECTORY='${var.folder}' \
+    GEMINI_SYSTEM_PROMPT='${base64encode(var.gemini_system_prompt)}' \
+    /tmp/install.sh
+  EOT
   start_script         = <<-EOT
      #!/bin/bash
      set -o errexit
@@ -207,21 +228,4 @@ module "agentapi" {
      GEMINI_TASK_PROMPT='${base64encode(var.task_prompt)}' \
      /tmp/start.sh
    EOT
-
-  install_script = <<-EOT
-    #!/bin/bash
-    set -o errexit
-    set -o pipefail
-
-    echo -n '${base64encode(local.install_script)}' | base64 -d > /tmp/install.sh
-    chmod +x /tmp/install.sh
-    ARG_INSTALL='${var.install_gemini}' \
-    ARG_GEMINI_VERSION='${var.gemini_version}' \
-    ARG_GEMINI_CONFIG='${base64encode(var.gemini_settings_json)}' \
-    BASE_EXTENSIONS='${base64encode(replace(local.base_extensions, "'", "'\\''"))}' \
-    ADDITIONAL_EXTENSIONS='${base64encode(replace(var.additional_extensions != null ? var.additional_extensions : "", "'", "'\\''"))}' \
-    GEMINI_START_DIRECTORY='${var.folder}' \
-    GEMINI_SYSTEM_PROMPT='${base64encode(var.gemini_system_prompt)}' \
-    /tmp/install.sh
-  EOT
 }
\ No newline at end of file
diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index e9392c66..25645c9f 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -1,4 +1,10 @@
 #!/bin/bash
+set -o errexit
+set -o pipefail
+
+# Handle parameters from agentapi module
+USE_PROMPT="$1"
+AGENTAPI_PORT="$2"
 
 source "$HOME"/.bashrc
 
@@ -41,7 +47,8 @@ else
     }
 fi
 
-if [ -n "$GEMINI_TASK_PROMPT" ]; then
+# Handle prompt logic based on parameters
+if [ -n "$USE_PROMPT" ] && [ "$USE_PROMPT" = "true" ] && [ -n "$GEMINI_TASK_PROMPT" ]; then
     printf "Running automated task: %s\n" "$GEMINI_TASK_PROMPT"
     PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT"
     GEMINI_ARGS=(--prompt)
@@ -66,4 +73,6 @@ else
     printf "No API key provided (neither GEMINI_API_KEY nor GOOGLE_API_KEY)\n"
 fi
 
-agentapi server --term-width 67 --term-height 1190 -- gemini "${GEMINI_ARGS[@]}"
\ No newline at end of file
+# Use the port parameter if provided, otherwise default to 3284
+PORT=${AGENTAPI_PORT:-3284}
+agentapi server --port "$PORT" --term-width 67 --term-height 1190 -- gemini "${GEMINI_ARGS[@]}"
\ No newline at end of file

From 00647fd738a61216d69c38a0988b201685216c6f Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 22:40:03 -0500
Subject: [PATCH 07/16] refactor(gemini): enhance task prompt handling and
 streamline start script execution

---
 .../coder-labs/modules/gemini/main.test.ts     |  4 +++-
 registry/coder-labs/modules/gemini/main.tf     |  6 +-----
 .../modules/gemini/scripts/install.sh          |  6 ++++++
 .../coder-labs/modules/gemini/scripts/start.sh | 18 +++++++++---------
 4 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/main.test.ts b/registry/coder-labs/modules/gemini/main.test.ts
index 7c656d93..8934b8e3 100644
--- a/registry/coder-labs/modules/gemini/main.test.ts
+++ b/registry/coder-labs/modules/gemini/main.test.ts
@@ -204,7 +204,9 @@ describe("gemini", async () => {
         task_prompt: taskPrompt,
       },
     });
-    await execModuleScript(id);
+    await execModuleScript(id, {
+      GEMINI_TASK_PROMPT: taskPrompt,
+    });
     const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log");
     expect(resp).toContain("Running automated task:");
   });
diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf
index c82f149c..b8bb6e2a 100644
--- a/registry/coder-labs/modules/gemini/main.tf
+++ b/registry/coder-labs/modules/gemini/main.tf
@@ -185,12 +185,8 @@ module "agentapi" {
   web_app_group        = var.group
   web_app_icon         = var.icon
   web_app_display_name = "Gemini"
-  cli_app              = true
   cli_app_slug         = "${local.app_slug}-cli"
   cli_app_display_name = "Gemini CLI"
-  cli_app_icon         = var.icon
-  cli_app_order        = var.order
-  cli_app_group        = var.group
   module_dir_name      = local.module_dir_name
   install_agentapi     = var.install_agentapi
   agentapi_version     = var.agentapi_version
@@ -225,7 +221,7 @@ module "agentapi" {
       GEMINI_YOLO_MODE='${var.enable_yolo_mode}' \
      GEMINI_MODEL='${var.gemini_model}' \
      GEMINI_START_DIRECTORY='${var.folder}' \
-     GEMINI_TASK_PROMPT='${base64encode(var.task_prompt)}' \
+     GEMINI_TASK_PROMPT='${var.task_prompt}' \
      /tmp/start.sh
    EOT
 }
\ No newline at end of file
diff --git a/registry/coder-labs/modules/gemini/scripts/install.sh b/registry/coder-labs/modules/gemini/scripts/install.sh
index b57dafd6..89ea07a0 100644
--- a/registry/coder-labs/modules/gemini/scripts/install.sh
+++ b/registry/coder-labs/modules/gemini/scripts/install.sh
@@ -150,9 +150,15 @@ function add_system_prompt_if_exists() {
     fi
 }
 
+function configure_mcp() {
+    export CODER_MCP_APP_STATUS_SLUG="gemini"
+    export CODER_MCP_AI_AGENTAPI_URL="http://localhost:3284"
+    coder exp mcp configure gemini "${GEMINI_START_DIRECTORY}"
+}
 
 install_gemini
 gemini --version
 populate_settings_json
 add_system_prompt_if_exists
+configure_mcp
 
diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index 25645c9f..70353931 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -2,8 +2,7 @@
 set -o errexit
 set -o pipefail
 
-# Handle parameters from agentapi module
-USE_PROMPT="$1"
+
 AGENTAPI_PORT="$2"
 
 source "$HOME"/.bashrc
@@ -20,7 +19,8 @@ fi
 
 printf "Version: %s\n" "$(gemini --version)"
 
-GEMINI_TASK_PROMPT=$(echo -n "$GEMINI_TASK_PROMPT" | base64 -d)
+MODULE_DIR="$HOME/.gemini-module"
+mkdir -p "$MODULE_DIR"
 
 if command_exists gemini; then
     printf "Gemini is installed\n"
@@ -47,12 +47,12 @@ else
     }
 fi
 
-# Handle prompt logic based on parameters
-if [ -n "$USE_PROMPT" ] && [ "$USE_PROMPT" = "true" ] && [ -n "$GEMINI_TASK_PROMPT" ]; then
+if [ -n "$GEMINI_TASK_PROMPT" ]; then
     printf "Running automated task: %s\n" "$GEMINI_TASK_PROMPT"
     PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT"
-    GEMINI_ARGS=(--prompt)
-    GEMINI_ARGS+=("$PROMPT")
+    PROMPT_FILE="$MODULE_DIR/prompt.txt"
+    echo -n "$PROMPT" >"$PROMPT_FILE"
+    GEMINI_ARGS=(--prompt "$PROMPT")
 else
     printf "Starting Gemini CLI in interactive mode.\n"
     GEMINI_ARGS=()
@@ -73,6 +73,6 @@ else
     printf "No API key provided (neither GEMINI_API_KEY nor GOOGLE_API_KEY)\n"
 fi
 
-# Use the port parameter if provided, otherwise default to 3284
 PORT=${AGENTAPI_PORT:-3284}
-agentapi server --port "$PORT" --term-width 67 --term-height 1190 -- gemini "${GEMINI_ARGS[@]}"
\ No newline at end of file
+agentapi server --port "$PORT" --term-width 67 --term-height 1190 -- \
+    bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")"
\ No newline at end of file

From 5dab7a545ae6ae7aa40c9ec12653df2693d102a5 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 23:02:02 -0500
Subject: [PATCH 08/16] refactor(gemini): remove hardcoded port configuration
 and simplify agentapi server startup

Remove AGENTAPI_PORT parameter handling and PORT variable assignment in start script,
allowing agentapi server to use its default port. Update test name from "happy-path"
to "agent-api" for better clarity of what is being tested.
---
 registry/coder-labs/modules/gemini/main.test.ts     | 2 +-
 registry/coder-labs/modules/gemini/scripts/start.sh | 6 +-----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/main.test.ts b/registry/coder-labs/modules/gemini/main.test.ts
index 8934b8e3..2ba58c2a 100644
--- a/registry/coder-labs/modules/gemini/main.test.ts
+++ b/registry/coder-labs/modules/gemini/main.test.ts
@@ -70,7 +70,7 @@ describe("gemini", async () => {
     await runTerraformInit(import.meta.dir);
   });
 
-  test("happy-path", async () => {
+  test("agent-api", async () => {
     const { id } = await setup();
     await execModuleScript(id);
     await expectAgentAPIStarted(id);
diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index 70353931..dc274875 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -2,9 +2,6 @@
 set -o errexit
 set -o pipefail
 
-
-AGENTAPI_PORT="$2"
-
 source "$HOME"/.bashrc
 
 command_exists() {
@@ -73,6 +70,5 @@ else
     printf "No API key provided (neither GEMINI_API_KEY nor GOOGLE_API_KEY)\n"
 fi
 
-PORT=${AGENTAPI_PORT:-3284}
-agentapi server --port "$PORT" --term-width 67 --term-height 1190 -- \
+agentapi server --term-width 67 --term-height 1190 -- \
     bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")"
\ No newline at end of file

From 0f91c177d1e4fedebb3868bfbfaa7cc4834ae51c Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 23:13:38 -0500
Subject: [PATCH 09/16] fix(gemini): fix agentapi versions

---
 registry/coder-labs/modules/gemini/main.tf | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf
index b8bb6e2a..9720dbf2 100644
--- a/registry/coder-labs/modules/gemini/main.tf
+++ b/registry/coder-labs/modules/gemini/main.tf
@@ -81,7 +81,7 @@ variable "install_agentapi" {
 variable "agentapi_version" {
   type        = string
   description = "The version of AgentAPI to install."
-  default     = "v0.3.0"
+  default     = "v0.2.3"
 }
 
 variable "gemini_model" {
@@ -176,10 +176,9 @@ EOT
 
 module "agentapi" {
   source  = "registry.coder.com/coder/agentapi/coder"
-  version = "1.0.0"
+  version = "1.0.2"
 
   agent_id             = var.agent_id
-  folder               = var.folder
   web_app_slug         = local.app_slug
   web_app_order        = var.order
   web_app_group        = var.group

From 6d8db8d408044af7d0a67a18288a51aa83e58f6d Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 23:21:03 -0500
Subject: [PATCH 10/16] refactor(gemini): enable interactive mode for Gemini
 CLI when a task prompt is provided

---
 registry/coder-labs/modules/gemini/scripts/start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index dc274875..fb1d7e2f 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -49,7 +49,7 @@ if [ -n "$GEMINI_TASK_PROMPT" ]; then
     PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT"
     PROMPT_FILE="$MODULE_DIR/prompt.txt"
     echo -n "$PROMPT" >"$PROMPT_FILE"
-    GEMINI_ARGS=(--prompt "$PROMPT")
+    GEMINI_ARGS=(--prompt "$PROMPT" --interactive)
 else
     printf "Starting Gemini CLI in interactive mode.\n"
     GEMINI_ARGS=()

From f1ecaacbe448461e1f62448ff52fd549ac846008 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Mon, 4 Aug 2025 23:26:15 -0500
Subject: [PATCH 11/16] refactor(gemini): update GEMINI_ARGS to use
 --prompt-interactive for task prompts

---
 registry/coder-labs/modules/gemini/scripts/start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh
index fb1d7e2f..aa09c165 100644
--- a/registry/coder-labs/modules/gemini/scripts/start.sh
+++ b/registry/coder-labs/modules/gemini/scripts/start.sh
@@ -49,7 +49,7 @@ if [ -n "$GEMINI_TASK_PROMPT" ]; then
     PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT"
     PROMPT_FILE="$MODULE_DIR/prompt.txt"
     echo -n "$PROMPT" >"$PROMPT_FILE"
-    GEMINI_ARGS=(--prompt "$PROMPT" --interactive)
+    GEMINI_ARGS=(--prompt-interactive "$PROMPT")
 else
     printf "Starting Gemini CLI in interactive mode.\n"
     GEMINI_ARGS=()

From 86f7b8a6566c409413adc6e26fa39091c8dfdbb2 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Tue, 5 Aug 2025 20:24:55 -0500
Subject: [PATCH 12/16] chore(gemini): replace gemini-mock.sh with inline mock
 content in setup function

---
 registry/coder-labs/modules/gemini/main.test.ts | 17 +++++++++++++++--
 .../modules/gemini/testdata/gemini-mock.sh      | 14 --------------
 2 files changed, 15 insertions(+), 16 deletions(-)
 delete mode 100644 registry/coder-labs/modules/gemini/testdata/gemini-mock.sh

diff --git a/registry/coder-labs/modules/gemini/main.test.ts b/registry/coder-labs/modules/gemini/main.test.ts
index 2ba58c2a..e0a36c49 100644
--- a/registry/coder-labs/modules/gemini/main.test.ts
+++ b/registry/coder-labs/modules/gemini/main.test.ts
@@ -8,7 +8,6 @@ import {
 } from "bun:test";
 import { execContainer, readFileContainer, runTerraformInit } from "~test";
 import {
-  loadTestFile,
   writeExecutable,
   setup as setupUtil,
   execModuleScript,
@@ -54,10 +53,24 @@ const setup = async (props?: SetupProps): Promise<{ id: string }> => {
     agentapiMockScript: props?.agentapiMockScript,
   });
   if (!props?.skipGeminiMock) {
+    const geminiMockContent = `#!/bin/bash
+
+if [[ "$1" == "--version" ]]; then
+  echo "HELLO: $(bash -c env)"
+  echo "gemini version v2.5.0"
+  exit 0
+fi
+
+set -e
+
+while true; do
+    echo "$(date) - gemini-mock"
+    sleep 15
+done`;
     await writeExecutable({
       containerId: id,
       filePath: "/usr/bin/gemini",
-      content: await loadTestFile(import.meta.dir, "gemini-mock.sh"),
+      content: geminiMockContent,
     });
   }
   return { id };
diff --git a/registry/coder-labs/modules/gemini/testdata/gemini-mock.sh b/registry/coder-labs/modules/gemini/testdata/gemini-mock.sh
deleted file mode 100644
index 53c9c41d..00000000
--- a/registry/coder-labs/modules/gemini/testdata/gemini-mock.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-if [[ "$1" == "--version" ]]; then
-  echo "HELLO: $(bash -c env)"
-  echo "gemini version v2.5.0"
-  exit 0
-fi
-
-set -e
-
-while true; do
-    echo "$(date) - gemini-mock"
-    sleep 15
-done
\ No newline at end of file

From c0d76052a1e6084e14b9e8a9a19dbf3405832716 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Tue, 5 Aug 2025 20:40:17 -0500
Subject: [PATCH 13/16] chore(gemini): update version to 1.1.0 in README.md for
 minor version bump

---
 registry/coder-labs/modules/gemini/README.md | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/registry/coder-labs/modules/gemini/README.md b/registry/coder-labs/modules/gemini/README.md
index d249a951..a5127aa4 100644
--- a/registry/coder-labs/modules/gemini/README.md
+++ b/registry/coder-labs/modules/gemini/README.md
@@ -13,7 +13,7 @@ Run [Gemini CLI](https://github.com/google-gemini/gemini-cli) in your workspace
 ```tf
 module "gemini" {
   source   = "registry.coder.com/coder-labs/gemini/coder"
-  version  = "1.0.0"
+  version  = "1.1.0"
   agent_id = coder_agent.example.id
 }
 ```
@@ -45,7 +45,7 @@ variable "gemini_api_key" {
 
 module "gemini" {
   source         = "registry.coder.com/coder-labs/gemini/coder"
-  version        = "1.0.0"
+  version        = "1.1.0"
   agent_id       = coder_agent.example.id
   gemini_api_key = var.gemini_api_key
 }
@@ -91,7 +91,7 @@ data "coder_parameter" "ai_prompt" {
 module "gemini" {
   count                = data.coder_workspace.me.start_count
   source               = "registry.coder.com/coder-labs/gemini/coder"
-  version              = "1.0.0"
+  version              = "1.1.0"
   agent_id             = coder_agent.example.id
   gemini_api_key       = var.gemini_api_key
   gemini_model         = "gemini-2.5-flash"
@@ -114,7 +114,7 @@ For enterprise users who prefer Google's Vertex AI platform:
 ```tf
 module "gemini" {
   source         = "registry.coder.com/coder-labs/gemini/coder"
-  version        = "1.0.0"
+  version        = "1.1.0"
   agent_id       = coder_agent.example.id
   gemini_api_key = var.gemini_api_key
   use_vertexai   = true

From f7c25f64ab669f91a05fb392ff424823dcfc401d Mon Sep 17 00:00:00 2001
From: DevelopmentCats <chris@dualriver.com>
Date: Tue, 5 Aug 2025 20:48:30 -0500
Subject: [PATCH 14/16] docs(gemini): update link to Gemini CLI documentation

---
 registry/coder-labs/modules/gemini/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/registry/coder-labs/modules/gemini/README.md b/registry/coder-labs/modules/gemini/README.md
index a5127aa4..8607e901 100644
--- a/registry/coder-labs/modules/gemini/README.md
+++ b/registry/coder-labs/modules/gemini/README.md
@@ -131,6 +131,6 @@ The module creates log files in the workspace's `~/.gemini-module` directory for
 
 ## References
 
-- [Gemini CLI Documentation](https://github.com/google-gemini/gemini-cli)
+- [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)

From 7d210095fcc79e2714761ffa513640091231a7ce Mon Sep 17 00:00:00 2001
From: DevCats <christofer@coder.com>
Date: Wed, 6 Aug 2025 08:17:49 -0500
Subject: [PATCH 15/16] chore: remove whitespace from env

Co-authored-by: Atif Ali <atif@coder.com>
---
 registry/coder-labs/modules/gemini/main.tf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf
index 9720dbf2..ad35d457 100644
--- a/registry/coder-labs/modules/gemini/main.tf
+++ b/registry/coder-labs/modules/gemini/main.tf
@@ -217,7 +217,7 @@ module "agentapi" {
      GEMINI_API_KEY='${var.gemini_api_key}' \
      GOOGLE_API_KEY='${var.gemini_api_key}' \
      GOOGLE_GENAI_USE_VERTEXAI='${var.use_vertexai}' \
-      GEMINI_YOLO_MODE='${var.enable_yolo_mode}' \
+     GEMINI_YOLO_MODE='${var.enable_yolo_mode}' \
      GEMINI_MODEL='${var.gemini_model}' \
      GEMINI_START_DIRECTORY='${var.folder}' \
      GEMINI_TASK_PROMPT='${var.task_prompt}' \

From 29c82c0459d0e1e54eee3d14508419c3029e5ce6 Mon Sep 17 00:00:00 2001
From: DevelopmentCats <christofer@coder.com>
Date: Wed, 6 Aug 2025 20:52:02 +0000
Subject: [PATCH 16/16] feat(gemini): add folder parameter to module
 configuration and change wording for coder-login req

---
 registry/coder-labs/modules/gemini/README.md | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/registry/coder-labs/modules/gemini/README.md b/registry/coder-labs/modules/gemini/README.md
index 8607e901..37fdca12 100644
--- a/registry/coder-labs/modules/gemini/README.md
+++ b/registry/coder-labs/modules/gemini/README.md
@@ -15,6 +15,7 @@ module "gemini" {
   source   = "registry.coder.com/coder-labs/gemini/coder"
   version  = "1.1.0"
   agent_id = coder_agent.example.id
+  folder   = "/home/coder/project"
 }
 ```
 
@@ -30,7 +31,7 @@ module "gemini" {
 ## Prerequisites
 
 - Node.js and npm will be installed automatically if not present
-- For automated task execution, you must add the [Coder Login](https://registry.coder.com/modules/coder/coder-login) module to your template
+- The [Coder Login](https://registry.coder.com/modules/coder/coder-login) module is required
 
 ## Examples
 
@@ -48,6 +49,7 @@ module "gemini" {
   version        = "1.1.0"
   agent_id       = coder_agent.example.id
   gemini_api_key = var.gemini_api_key
+  folder         = "/home/coder/project"
 }
 ```
 
@@ -55,6 +57,7 @@ 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
 
@@ -95,6 +98,7 @@ module "gemini" {
   agent_id             = coder_agent.example.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
@@ -117,6 +121,7 @@ module "gemini" {
   version        = "1.1.0"
   agent_id       = coder_agent.example.id
   gemini_api_key = var.gemini_api_key
+  folder         = "/home/coder/project"
   use_vertexai   = true
 }
 ```
