feat(gemini): gemini cleanup and refactor (#300)

Closes #260

## Description

Cleans up and fixes issues with Gemini module.

## Type of Change

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

## Module Information

<!-- Delete this section if not applicable -->

**Path:** `registry/coder-labs/modules/gemini`  
**New version:** `v1.1.0`  
**Breaking change:** [X] Yes [ ] No

## Testing & Validation

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

## Related Issues
 
#260 
<!-- Link related issues or write "None" if not applicable -->

---------

Co-authored-by: Atif Ali <atif@coder.com>
This commit is contained in:
DevCats 2025-08-12 11:37:45 -05:00 committed by GitHub
parent 61554aaa8c
commit 1749f9ca05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 200 additions and 112 deletions

View File

@ -1,36 +1,41 @@
--- ---
display_name: Gemini CLI display_name: Gemini CLI
description: Run Gemini CLI in your workspace for AI pair programming
icon: ../../../../.icons/gemini.svg icon: ../../../../.icons/gemini.svg
description: Run Gemini CLI in your workspace with AgentAPI integration
verified: true verified: true
tags: [agent, gemini, ai, google, tasks] tags: [agent, gemini, ai, google, tasks]
--- ---
# Gemini CLI # 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 ```tf
module "gemini" { module "gemini" {
source = "registry.coder.com/coder-labs/gemini/coder" source = "registry.coder.com/coder-labs/gemini/coder"
version = "1.0.1" version = "1.1.0"
agent_id = coder_agent.example.id agent_id = coder_agent.example.id
gemini_api_key = var.gemini_api_key folder = "/home/coder/project"
gemini_model = "gemini-2.5-pro"
install_gemini = true
gemini_version = "latest"
agentapi_version = "latest"
} }
``` ```
## 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 ## 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 - Node.js and npm will be installed automatically if not present
- The [Coder Login](https://registry.coder.com/modules/coder/coder-login) module is required
## Usage Example ## Examples
- Example 1: ### Basic setup
```tf ```tf
variable "gemini_api_key" { variable "gemini_api_key" {
@ -40,39 +45,97 @@ variable "gemini_api_key" {
} }
module "gemini" { module "gemini" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder-labs/gemini/coder" source = "registry.coder.com/coder-labs/gemini/coder"
version = "1.0.1" version = "1.1.0"
agent_id = coder_agent.example.id 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_api_key = var.gemini_api_key
gemini_model = "gemini-2.5-flash" folder = "/home/coder/project"
install_gemini = true
gemini_version = "latest"
gemini_instruction_prompt = "Start every response with `Gemini says:`"
} }
``` ```
## How it Works This basic setup will:
- **Install**: The module installs Gemini CLI using npm (installs Node.js via NVM if needed) - Install Gemini CLI in the workspace
- **Instruction Prompt**: If `GEMINI_INSTRUCTION_PROMPT` and `GEMINI_START_DIRECTORY` are set, creates the directory (if needed) and writes the prompt to `GEMINI.md` - Configure authentication with your API key
- **Start**: Launches Gemini CLI in the specified directory, wrapped by AgentAPI - Set Gemini to run in `/home/coder/project` directory
- **Environment**: Sets `GEMINI_API_KEY`, `GOOGLE_GENAI_USE_VERTEXAI`, `GEMINI_MODEL` for the CLI (if variables provided) - 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
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
}
module "gemini" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder-labs/gemini/coder"
version = "1.1.0"
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
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:
```tf
module "gemini" {
source = "registry.coder.com/coder-labs/gemini/coder"
version = "1.1.0"
agent_id = coder_agent.example.id
gemini_api_key = var.gemini_api_key
folder = "/home/coder/project"
use_vertexai = true
}
```
## Troubleshooting ## 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 `~/.gemini-module/` for install/start output
- Check logs in `/home/coder/.gemini-module/` for install/start output - Use the `gemini_api_key` variable to avoid requiring Google sign-in
- We highly recommend using the `gemini_api_key` variable, this also ensures smooth tasks running without needing to sign in to Google.
> [!IMPORTANT] The module creates log files in the workspace's `~/.gemini-module` directory for debugging purposes.
> 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:\` "
## References ## References
- [Gemini CLI Documentation](https://ai.google.dev/gemini-api/docs/cli) - [Gemini CLI Documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/index.md)
- [AgentAPI Documentation](https://github.com/coder/agentapi) - [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)

View File

@ -8,7 +8,6 @@ import {
} from "bun:test"; } from "bun:test";
import { execContainer, readFileContainer, runTerraformInit } from "~test"; import { execContainer, readFileContainer, runTerraformInit } from "~test";
import { import {
loadTestFile,
writeExecutable, writeExecutable,
setup as setupUtil, setup as setupUtil,
execModuleScript, execModuleScript,
@ -54,10 +53,24 @@ const setup = async (props?: SetupProps): Promise<{ id: string }> => {
agentapiMockScript: props?.agentapiMockScript, agentapiMockScript: props?.agentapiMockScript,
}); });
if (!props?.skipGeminiMock) { 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({ await writeExecutable({
containerId: id, containerId: id,
filePath: "/usr/bin/gemini", filePath: "/usr/bin/gemini",
content: await loadTestFile(import.meta.dir, "gemini-mock.sh"), content: geminiMockContent,
}); });
} }
return { id }; return { id };
@ -70,7 +83,7 @@ describe("gemini", async () => {
await runTerraformInit(import.meta.dir); await runTerraformInit(import.meta.dir);
}); });
test("happy-path", async () => { test("agent-api", async () => {
const { id } = await setup(); const { id } = await setup();
await execModuleScript(id); await execModuleScript(id);
await expectAgentAPIStarted(id); await expectAgentAPIStarted(id);
@ -117,7 +130,7 @@ describe("gemini", async () => {
await execModuleScript(id); await execModuleScript(id);
const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log"); 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 () => { test("use-vertexai", async () => {
@ -197,6 +210,20 @@ describe("gemini", async () => {
expect(resp).toContain(prompt); 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, {
GEMINI_TASK_PROMPT: taskPrompt,
});
const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log");
expect(resp).toContain("Running automated task:");
});
test("start-without-prompt", async () => { test("start-without-prompt", async () => {
const { id } = await setup(); const { id } = await setup();
await execModuleScript(id); await execModuleScript(id);

View File

@ -74,14 +74,14 @@ variable "use_vertexai" {
variable "install_agentapi" { variable "install_agentapi" {
type = bool type = bool
description = "Whether to install AgentAPI." description = "Whether to install AgentAPI for web UI and task automation."
default = true default = true
} }
variable "agentapi_version" { variable "agentapi_version" {
type = string type = string
description = "The version of AgentAPI to install." description = "The version of AgentAPI to install."
default = "v0.3.0" default = "v0.2.3"
} }
variable "gemini_model" { variable "gemini_model" {
@ -102,12 +102,10 @@ variable "post_install_script" {
default = null default = null
} }
data "coder_parameter" "ai_prompt" { variable "task_prompt" {
type = "string" type = string
name = "AI Prompt" description = "Task prompt for automated Gemini execution"
default = "" default = ""
description = "Initial prompt for the Gemini CLI"
mutable = true
} }
variable "additional_extensions" { variable "additional_extensions" {
@ -122,12 +120,24 @@ variable "gemini_system_prompt" {
default = "" 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" { resource "coder_env" "gemini_api_key" {
agent_id = var.agent_id agent_id = var.agent_id
name = "GEMINI_API_KEY" name = "GEMINI_API_KEY"
value = var.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" { resource "coder_env" "gemini_use_vertex_ai" {
agent_id = var.agent_id agent_id = var.agent_id
name = "GOOGLE_GENAI_USE_VERTEXAI" name = "GOOGLE_GENAI_USE_VERTEXAI"
@ -181,21 +191,6 @@ module "agentapi" {
agentapi_version = var.agentapi_version agentapi_version = var.agentapi_version
pre_install_script = var.pre_install_script pre_install_script = var.pre_install_script
post_install_script = var.post_install_script post_install_script = var.post_install_script
start_script = <<-EOT
#!/bin/bash
set -o errexit
set -o pipefail
echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh
chmod +x /tmp/start.sh
GEMINI_API_KEY='${var.gemini_api_key}' \
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)}' \
/tmp/start.sh
EOT
install_script = <<-EOT install_script = <<-EOT
#!/bin/bash #!/bin/bash
set -o errexit set -o errexit
@ -209,7 +204,23 @@ module "agentapi" {
BASE_EXTENSIONS='${base64encode(replace(local.base_extensions, "'", "'\\''"))}' \ BASE_EXTENSIONS='${base64encode(replace(local.base_extensions, "'", "'\\''"))}' \
ADDITIONAL_EXTENSIONS='${base64encode(replace(var.additional_extensions != null ? var.additional_extensions : "", "'", "'\\''"))}' \ ADDITIONAL_EXTENSIONS='${base64encode(replace(var.additional_extensions != null ? var.additional_extensions : "", "'", "'\\''"))}' \
GEMINI_START_DIRECTORY='${var.folder}' \ GEMINI_START_DIRECTORY='${var.folder}' \
GEMINI_INSTRUCTION_PROMPT='${base64encode(var.gemini_system_prompt)}' \ GEMINI_SYSTEM_PROMPT='${base64encode(var.gemini_system_prompt)}' \
/tmp/install.sh /tmp/install.sh
EOT EOT
start_script = <<-EOT
#!/bin/bash
set -o errexit
set -o pipefail
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='${var.task_prompt}' \
/tmp/start.sh
EOT
} }

View File

@ -2,7 +2,6 @@
BOLD='\033[0;1m' BOLD='\033[0;1m'
# Function to check if a command exists
command_exists() { command_exists() {
command -v "$1" >/dev/null 2>&1 command -v "$1" >/dev/null 2>&1
} }
@ -12,7 +11,7 @@ set -o nounset
ARG_GEMINI_CONFIG=$(echo -n "$ARG_GEMINI_CONFIG" | base64 -d) ARG_GEMINI_CONFIG=$(echo -n "$ARG_GEMINI_CONFIG" | base64 -d)
BASE_EXTENSIONS=$(echo -n "$BASE_EXTENSIONS" | base64 -d) BASE_EXTENSIONS=$(echo -n "$BASE_EXTENSIONS" | base64 -d)
ADDITIONAL_EXTENSIONS=$(echo -n "$ADDITIONAL_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 "--------------------------------" echo "--------------------------------"
printf "gemini_config: %s\n" "$ARG_GEMINI_CONFIG" printf "gemini_config: %s\n" "$ARG_GEMINI_CONFIG"
@ -23,7 +22,6 @@ echo "--------------------------------"
set +o nounset set +o nounset
function install_node() { function install_node() {
# borrowed from claude-code module
if ! command_exists npm; then if ! command_exists npm; then
printf "npm not found, checking for Node.js installation...\n" printf "npm not found, checking for Node.js installation...\n"
if ! command_exists node; then if ! command_exists node; then
@ -52,24 +50,15 @@ function install_node() {
function install_gemini() { function install_gemini() {
if [ "${ARG_INSTALL}" = "true" ]; then if [ "${ARG_INSTALL}" = "true" ]; then
# we need node to install and run gemini-cli
install_node 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 ! command_exists nvm; then if ! command_exists nvm; then
printf "which node: %s\n" "$(which node)" printf "which node: %s\n" "$(which node)"
printf "which npm: %s\n" "$(which npm)" printf "which npm: %s\n" "$(which npm)"
# Create a directory for global packages
mkdir -p "$HOME"/.npm-global mkdir -p "$HOME"/.npm-global
# Configure npm to use it
npm config set prefix "$HOME/.npm-global" npm config set prefix "$HOME/.npm-global"
# Add to PATH for current session
export PATH="$HOME/.npm-global/bin:$PATH" 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 if ! grep -q "export PATH=$HOME/.npm-global/bin:\$PATH" ~/.bashrc; then
echo "export PATH=$HOME/.npm-global/bin:\$PATH" >> ~/.bashrc echo "export PATH=$HOME/.npm-global/bin:\$PATH" >> ~/.bashrc
fi fi
@ -108,7 +97,6 @@ function append_extensions_to_settings_json() {
fi fi
if [ ! -f "$SETTINGS_PATH" ]; then if [ ! -f "$SETTINGS_PATH" ]; then
printf "%s does not exist. Creating with merged mcpServers structure.\n" "$SETTINGS_PATH" 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='{}' ADD_EXT_JSON='{}'
if [ -n "${ADDITIONAL_EXTENSIONS:-}" ]; then if [ -n "${ADDITIONAL_EXTENSIONS:-}" ]; then
ADD_EXT_JSON="$ADDITIONAL_EXTENSIONS" 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" printf '{"mcpServers":%s}\n' "$(jq -s 'add' <(echo "$BASE_EXTENSIONS") <(echo "$ADD_EXT_JSON"))" > "$SETTINGS_PATH"
fi fi
# Prepare temp files
TMP_SETTINGS=$(mktemp) TMP_SETTINGS=$(mktemp)
# If ADDITIONAL_EXTENSIONS is not set or empty, use '{}'
ADD_EXT_JSON='{}' ADD_EXT_JSON='{}'
if [ -n "${ADDITIONAL_EXTENSIONS:-}" ]; then if [ -n "${ADDITIONAL_EXTENSIONS:-}" ]; then
printf "[append_extensions_to_settings_json] ADDITIONAL_EXTENSIONS is set.\n" printf "[append_extensions_to_settings_json] ADDITIONAL_EXTENSIONS is set.\n"
@ -133,14 +118,13 @@ function append_extensions_to_settings_json() {
'.mcpServers = (.mcpServers // {} + $base + $add)' \ '.mcpServers = (.mcpServers // {} + $base + $add)' \
"$SETTINGS_PATH" > "$TMP_SETTINGS" && mv "$TMP_SETTINGS" "$SETTINGS_PATH" "$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" 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" printf "[append_extensions_to_settings_json] Merge complete.\n"
} }
function add_instruction_prompt_if_exists() { function add_system_prompt_if_exists() {
if [ -n "${GEMINI_INSTRUCTION_PROMPT:-}" ]; then if [ -n "${GEMINI_SYSTEM_PROMPT:-}" ]; then
if [ -d "${GEMINI_START_DIRECTORY}" ]; then if [ -d "${GEMINI_START_DIRECTORY}" ]; then
printf "Directory '%s' exists. Changing to it.\\n" "${GEMINI_START_DIRECTORY}" printf "Directory '%s' exists. Changing to it.\\n" "${GEMINI_START_DIRECTORY}"
cd "${GEMINI_START_DIRECTORY}" || { cd "${GEMINI_START_DIRECTORY}" || {
@ -160,16 +144,21 @@ function add_instruction_prompt_if_exists() {
fi fi
touch GEMINI.md touch GEMINI.md
printf "Setting GEMINI.md\n" printf "Setting GEMINI.md\n"
echo "${GEMINI_INSTRUCTION_PROMPT}" > GEMINI.md echo "${GEMINI_SYSTEM_PROMPT}" > GEMINI.md
else else
printf "GEMINI.md is not set.\n" printf "GEMINI.md is not set.\n"
fi 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
install_gemini install_gemini
gemini --version gemini --version
populate_settings_json populate_settings_json
add_instruction_prompt_if_exists add_system_prompt_if_exists
configure_mcp

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
set -o errexit
set -o pipefail
# Load shell environment
source "$HOME"/.bashrc source "$HOME"/.bashrc
command_exists() { command_exists() {
@ -15,7 +16,8 @@ fi
printf "Version: %s\n" "$(gemini --version)" 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 if command_exists gemini; then
printf "Gemini is installed\n" printf "Gemini is installed\n"
@ -43,20 +45,30 @@ else
fi fi
if [ -n "$GEMINI_TASK_PROMPT" ]; then 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" 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-interactive "$PROMPT") GEMINI_ARGS=(--prompt-interactive "$PROMPT")
else else
printf "No task prompt given.\n" printf "Starting Gemini CLI in interactive mode.\n"
GEMINI_ARGS=() GEMINI_ARGS=()
fi fi
if [ -n "$GEMINI_API_KEY" ]; then if [ -n "$GEMINI_YOLO_MODE" ] && [ "$GEMINI_YOLO_MODE" = "true" ]; then
printf "gemini_api_key provided !\n" printf "YOLO mode enabled - will auto-approve all tool calls\n"
else GEMINI_ARGS+=(--yolo)
printf "gemini_api_key not provided\n"
fi fi
# use low width to fit in the tasks UI sidebar. height is adjusted so that width x height ~= 80x1000 characters if [ -n "$GEMINI_API_KEY" ] || [ -n "$GOOGLE_API_KEY" ]; then
# are visible in the terminal screen by default. if [ -n "$GOOGLE_GENAI_USE_VERTEXAI" ] && [ "$GOOGLE_GENAI_USE_VERTEXAI" = "true" ]; then
agentapi server --term-width 67 --term-height 1190 -- gemini "${GEMINI_ARGS[@]}" printf "Using Vertex AI with API key\n"
else
printf "Using direct Gemini API with API key\n"
fi
else
printf "No API key provided (neither GEMINI_API_KEY nor GOOGLE_API_KEY)\n"
fi
agentapi server --term-width 67 --term-height 1190 -- \
bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")"

View File

@ -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