Skip to content

Commit 7c0538a

Browse files
committed
fix: switch aider module to use coder_env instead of inline environment variables
- Replace inline 'export API_KEY=' statements with coder_env resource - Add coder_env resource to set AI provider API keys as environment variables - Update README to document the new environment variable handling - Update tests to reflect the new behavior - Resolves issue #128 The aider module now properly uses the coder_env resource to set environment variables instead of exporting them inline in shell commands. This reduces cognitive load for users and follows Terraform best practices.
1 parent cc40d6c commit 7c0538a

File tree

6 files changed

+933
-83
lines changed

6 files changed

+933
-83
lines changed

registry/coder/modules/aider/README.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
display_name: Aider
32
description: Run Aider AI pair programming in your workspace
43
icon: ../../../../.icons/aider.svg
@@ -14,7 +13,7 @@ Run [Aider](https://aider.chat) AI pair programming in your workspace. This modu
1413
```tf
1514
module "aider" {
1615
source = "registry.coder.com/coder/aider/coder"
17-
version = "1.1.0"
16+
version = "1.0.1"
1817
agent_id = coder_agent.example.id
1918
}
2019
```
@@ -69,7 +68,7 @@ variable "anthropic_api_key" {
6968
module "aider" {
7069
count = data.coder_workspace.me.start_count
7170
source = "registry.coder.com/coder/aider/coder"
72-
version = "1.1.0"
71+
version = "1.0.1"
7372
agent_id = coder_agent.example.id
7473
ai_api_key = var.anthropic_api_key
7574
}
@@ -81,6 +80,7 @@ This basic setup will:
8180
- Create a persistent screen session named "aider"
8281
- Configure Aider to use Anthropic Claude 3.7 Sonnet model
8382
- Enable task reporting (configures Aider to report tasks to Coder MCP)
83+
- Set the API key as an environment variable using the `coder_env` resource
8484

8585
### Using OpenAI with tmux
8686

@@ -94,9 +94,10 @@ variable "openai_api_key" {
9494
module "aider" {
9595
count = data.coder_workspace.me.start_count
9696
source = "registry.coder.com/coder/aider/coder"
97-
version = "1.1.0"
97+
version = "1.0.1"
9898
agent_id = coder_agent.example.id
9999
use_tmux = true
100+
use_screen = false
100101
ai_provider = "openai"
101102
ai_model = "4o" # Uses Aider's built-in alias for gpt-4o
102103
ai_api_key = var.openai_api_key
@@ -115,7 +116,7 @@ variable "custom_api_key" {
115116
module "aider" {
116117
count = data.coder_workspace.me.start_count
117118
source = "registry.coder.com/coder/aider/coder"
118-
version = "1.1.0"
119+
version = "1.0.1"
119120
agent_id = coder_agent.example.id
120121
ai_provider = "custom"
121122
custom_env_var_name = "MY_CUSTOM_API_KEY"
@@ -132,7 +133,7 @@ You can extend Aider's capabilities by adding custom extensions:
132133
module "aider" {
133134
count = data.coder_workspace.me.start_count
134135
source = "registry.coder.com/coder/aider/coder"
135-
version = "1.1.0"
136+
version = "1.0.1"
136137
agent_id = coder_agent.example.id
137138
ai_api_key = var.anthropic_api_key
138139
@@ -211,7 +212,7 @@ data "coder_parameter" "ai_prompt" {
211212
module "aider" {
212213
count = data.coder_workspace.me.start_count
213214
source = "registry.coder.com/coder/aider/coder"
214-
version = "1.1.0"
215+
version = "1.0.1"
215216
agent_id = coder_agent.example.id
216217
ai_api_key = var.anthropic_api_key
217218
task_prompt = data.coder_parameter.ai_prompt.value
@@ -254,6 +255,23 @@ This is your current task: [task_prompt]
254255

255256
If you want to disable task reporting, set `experiment_report_tasks = false` in your module configuration.
256257

258+
## Environment Variables
259+
260+
The module automatically sets the appropriate environment variable for your selected AI provider using the `coder_env` resource:
261+
262+
| Provider | Environment Variable |
263+
| ------------- | ----------------------- |
264+
| **anthropic** | `ANTHROPIC_API_KEY` |
265+
| **openai** | `OPENAI_API_KEY` |
266+
| **azure** | `AZURE_OPENAI_API_KEY` |
267+
| **google** | `GOOGLE_API_KEY` |
268+
| **cohere** | `COHERE_API_KEY` |
269+
| **mistral** | `MISTRAL_API_KEY` |
270+
| **ollama** | `OLLAMA_HOST` |
271+
| **custom** | Your custom variable |
272+
273+
The API key is securely set as an environment variable and will be available to Aider when it runs.
274+
257275
## Using Aider in Your Workspace
258276

259277
After the workspace starts, Aider will be installed and configured according to your parameters. A persistent session will automatically be started during workspace creation.
@@ -309,7 +327,3 @@ If you encounter issues:
309327
3. **Browser mode issues**: If the browser interface doesn't open, check that you're accessing it from a machine that can reach your Coder workspace
310328

311329
For more information on using Aider, see the [Aider documentation](https://aider.chat/docs/).
312-
313-
```
314-
315-
```

0 commit comments

Comments
 (0)