Skip to content

Commit bc39c2e

Browse files
Aider module support agentAPI (#356)
Closes #239 /claim #239 ## Description video :- https://www.loom.com/share/d1d1d54d48bc45c4a48271ca9a387a88?sid=933e250d-78f8-4a7f-9745-0e908c0ee4d9 <!-- Briefly describe what this PR does and why --> ## Type of Change - [x] New module - [ ] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information <!-- Delete this section if not applicable --> **Path:** `registry/coder/modules/aider` **New version:** `v1.0.0` **Breaking change:** [ ] Yes [x] No ## Testing & Validation - [ ] Tests pass (`bun test`) - [ ] Code formatted (`bun run fmt`) - [ ] Changes tested locally ## Related Issues <!-- Link related issues or write "None" if not applicable --> --------- Co-authored-by: DevCats <christofer@coder.com>
1 parent e3ff43c commit bc39c2e

File tree

7 files changed

+575
-680
lines changed

7 files changed

+575
-680
lines changed

registry/coder/modules/aider/README.md

Lines changed: 44 additions & 218 deletions
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,58 @@ tags: [agent, ai, aider]
88

99
# Aider
1010

11-
Run [Aider](https://aider.chat) AI pair programming in your workspace. This module installs Aider and provides a persistent session using screen or tmux.
11+
Run [Aider](https://aider.chat) AI pair programming in your workspace. This module installs Aider with AgentAPI for seamless Coder Tasks Support.
1212

1313
```tf
14-
module "aider" {
15-
source = "registry.coder.com/coder/aider/coder"
16-
version = "1.1.2"
17-
agent_id = coder_agent.example.id
18-
}
19-
```
20-
21-
## Features
22-
23-
- **Interactive Parameter Selection**: Choose your AI provider, model, and configuration options when creating the workspace
24-
- **Multiple AI Providers**: Supports Anthropic (Claude), OpenAI, DeepSeek, GROQ, and OpenRouter
25-
- **Persistent Sessions**: Uses screen (default) or tmux to keep Aider running in the background
26-
- **Optional Dependencies**: Install Playwright for web page scraping and PortAudio for voice coding
27-
- **Project Integration**: Works with any project directory, including Git repositories
28-
- **Browser UI**: Use Aider in your browser with a modern web interface instead of the terminal
29-
- **Non-Interactive Mode**: Automatically processes tasks when provided via the `task_prompt` variable
30-
31-
## Module Parameters
32-
33-
> [!NOTE]
34-
> The `use_screen` and `use_tmux` parameters cannot both be enabled at the same time. By default, `use_screen` is set to `true` and `use_tmux` is set to `false`.
35-
36-
## Usage Examples
37-
38-
### Basic setup with API key
39-
40-
```tf
41-
variable "anthropic_api_key" {
14+
variable "api_key" {
4215
type = string
43-
description = "Anthropic API key"
16+
description = "API key"
4417
sensitive = true
4518
}
4619
4720
module "aider" {
48-
count = data.coder_workspace.me.start_count
49-
source = "registry.coder.com/coder/aider/coder"
50-
version = "1.1.2"
51-
agent_id = coder_agent.example.id
52-
ai_api_key = var.anthropic_api_key
21+
source = "registry.coder.com/coder/aider/coder"
22+
version = "2.0.0"
23+
agent_id = coder_agent.example.id
24+
api_key = var.api_key
25+
ai_provider = "google"
26+
model = "gemini"
5327
}
5428
```
5529

56-
This basic setup will:
30+
## Prerequisites
5731

58-
- Install Aider in the workspace
59-
- Create a persistent screen session named "aider"
60-
- Configure Aider to use Anthropic Claude 3.7 Sonnet model
61-
- Enable task reporting (configures Aider to report tasks to Coder MCP)
32+
- pipx is automatically installed if not already available
6233

63-
### Using OpenAI with tmux
34+
## Usage Example
6435

6536
```tf
66-
variable "openai_api_key" {
37+
data "coder_parameter" "ai_prompt" {
38+
name = "AI Prompt"
39+
description = "Write an initial prompt for Aider to work on."
40+
type = "string"
41+
default = ""
42+
mutable = true
43+
}
44+
45+
variable "gemini_api_key" {
6746
type = string
68-
description = "OpenAI API key"
47+
description = "Gemini API key"
6948
sensitive = true
7049
}
7150
7251
module "aider" {
73-
count = data.coder_workspace.me.start_count
74-
source = "registry.coder.com/coder/aider/coder"
75-
version = "1.1.2"
76-
agent_id = coder_agent.example.id
77-
use_tmux = true
78-
ai_provider = "openai"
79-
ai_model = "4o" # Uses Aider's built-in alias for gpt-4o
80-
ai_api_key = var.openai_api_key
52+
source = "registry.coder.com/coder/aider/coder"
53+
version = "2.0.0"
54+
agent_id = coder_agent.example.id
55+
api_key = var.gemini_api_key
56+
install_aider = true
57+
workdir = "/home/coder"
58+
ai_provider = "google"
59+
model = "gemini"
60+
install_agentapi = true
61+
ai_prompt = data.coder_parameter.ai_prompt.value
62+
system_prompt = "..."
8163
}
8264
```
8365

@@ -93,174 +75,16 @@ variable "custom_api_key" {
9375
module "aider" {
9476
count = data.coder_workspace.me.start_count
9577
source = "registry.coder.com/coder/aider/coder"
96-
version = "1.1.2"
78+
version = "2.0.0"
9779
agent_id = coder_agent.example.id
80+
workdir = "/home/coder"
9881
ai_provider = "custom"
9982
custom_env_var_name = "MY_CUSTOM_API_KEY"
100-
ai_model = "custom-model"
101-
ai_api_key = var.custom_api_key
102-
}
103-
```
104-
105-
### Adding Custom Extensions (Experimental)
106-
107-
You can extend Aider's capabilities by adding custom extensions:
108-
109-
```tf
110-
module "aider" {
111-
count = data.coder_workspace.me.start_count
112-
source = "registry.coder.com/coder/aider/coder"
113-
version = "1.1.2"
114-
agent_id = coder_agent.example.id
115-
ai_api_key = var.anthropic_api_key
116-
117-
experiment_pre_install_script = <<-EOT
118-
pip install some-custom-dependency
119-
EOT
120-
121-
experiment_additional_extensions = <<-EOT
122-
custom-extension:
123-
args: []
124-
cmd: custom-extension-command
125-
description: A custom extension for Aider
126-
enabled: true
127-
envs: {}
128-
name: custom-extension
129-
timeout: 300
130-
type: stdio
131-
EOT
132-
}
133-
```
134-
135-
Note: The indentation in the heredoc is preserved, so you can write the YAML naturally.
136-
137-
## Task Reporting (Experimental)
138-
139-
> This functionality is in early access as of Coder v2.21 and is still evolving.
140-
> For now, we recommend testing it in a demo or staging environment,
141-
> rather than deploying to production
142-
>
143-
> Learn more in [the Coder documentation](https://coder.com/docs/tutorials/ai-agents)
144-
>
145-
> Join our [Discord channel](https://discord.gg/coder) or
146-
> [contact us](https://coder.com/contact) to get help or share feedback.
147-
148-
Your workspace must have either `screen` or `tmux` installed to use this.
149-
150-
Task reporting is **enabled by default** in this module, allowing you to:
151-
152-
- Send an initial prompt to Aider during workspace creation
153-
- Monitor task progress in the Coder UI
154-
- Use the `coder_parameter` resource to collect prompts from users
155-
156-
### Setting up Task Reporting
157-
158-
To use task reporting effectively:
159-
160-
1. Add the Coder Login module to your template
161-
2. Configure the necessary variables to pass the task prompt
162-
3. Optionally add a coder_parameter to collect prompts from users
163-
164-
Here's a complete example:
165-
166-
```tf
167-
module "coder-login" {
168-
count = data.coder_workspace.me.start_count
169-
source = "registry.coder.com/modules/coder-login/coder"
170-
version = "1.0.15"
171-
agent_id = coder_agent.example.id
172-
}
173-
174-
variable "anthropic_api_key" {
175-
type = string
176-
description = "Anthropic API key"
177-
sensitive = true
178-
}
179-
180-
data "coder_parameter" "ai_prompt" {
181-
type = "string"
182-
name = "AI Prompt"
183-
default = ""
184-
description = "Write a prompt for Aider"
185-
mutable = true
186-
ephemeral = true
187-
}
188-
189-
module "aider" {
190-
count = data.coder_workspace.me.start_count
191-
source = "registry.coder.com/coder/aider/coder"
192-
version = "1.1.2"
193-
agent_id = coder_agent.example.id
194-
ai_api_key = var.anthropic_api_key
195-
task_prompt = data.coder_parameter.ai_prompt.value
196-
197-
# Optionally customize the system prompt
198-
system_prompt = <<-EOT
199-
You are a helpful Coding assistant. Aim to autonomously investigate
200-
and solve issues the user gives you and test your work, whenever possible.
201-
Avoid shortcuts like mocking tests. When you get stuck, you can ask the user
202-
but opt for autonomy.
203-
YOU MUST REPORT ALL TASKS TO CODER.
204-
When reporting tasks, you MUST follow these EXACT instructions:
205-
- IMMEDIATELY report status after receiving ANY user message.
206-
- Be granular. If you are investigating with multiple steps, report each step to coder.
207-
Task state MUST be one of the following:
208-
- Use "state": "working" when actively processing WITHOUT needing additional user input.
209-
- Use "state": "complete" only when finished with a task.
210-
- Use "state": "failure" when you need ANY user input, lack sufficient details, or encounter blockers.
211-
Task summaries MUST:
212-
- Include specifics about what you're doing.
213-
- Include clear and actionable steps for the user.
214-
- Be less than 160 characters in length.
215-
EOT
83+
model = "custom-model"
84+
api_key = var.custom_api_key
21685
}
21786
```
21887

219-
When a task prompt is provided via the `task_prompt` variable, the module automatically:
220-
221-
1. Combines the system prompt with the task prompt into a single message in the format:
222-
223-
```
224-
SYSTEM PROMPT:
225-
[system_prompt content]
226-
227-
This is your current task: [task_prompt]
228-
```
229-
230-
2. Executes the task during workspace creation using the `--message` and `--yes-always` flags
231-
3. Logs task output to `$HOME/.aider.log` for reference
232-
233-
If you want to disable task reporting, set `experiment_report_tasks = false` in your module configuration.
234-
235-
## Using Aider in Your Workspace
236-
237-
After the workspace starts, Aider will be installed and configured according to your parameters. A persistent session will automatically be started during workspace creation.
238-
239-
### Session Options
240-
241-
You can run Aider in three different ways:
242-
243-
1. **Direct Mode**: Aider starts directly in the specified folder when you click the app button
244-
245-
- Simple setup without persistent context
246-
- Suitable for quick coding sessions
247-
248-
2. **Screen Mode** (Default): Run Aider in a screen session that persists across connections
249-
250-
- Session name: "aider" (or configured via `session_name`)
251-
252-
3. **Tmux Mode**: Run Aider in a tmux session instead of screen
253-
254-
- Set `use_tmux = true` to enable
255-
- Session name: "aider" (or configured via `session_name`)
256-
- Configures tmux with mouse support for shared sessions
257-
258-
Persistent sessions (screen/tmux) allow you to:
259-
260-
- Disconnect and reconnect without losing context
261-
- Run Aider in the background while doing other work
262-
- Switch between terminal and browser interfaces
263-
26488
### Available AI Providers and Models
26589

26690
Aider supports various providers and models, and this module integrates directly with Aider's built-in model aliases:
@@ -280,10 +104,12 @@ For a complete and up-to-date list of supported aliases and models, please refer
280104

281105
## Troubleshooting
282106

283-
If you encounter issues:
107+
- If `aider` is not found, ensure `install_aider = true` and your API key is valid
108+
- Logs are written under `/home/coder/.aider-module/` (`install.log`, `agentapi-start.log`) for debugging
109+
- If AgentAPI fails to start, verify that your container has network access and executable permissions for the scripts
284110

285-
1. **Screen/Tmux issues**: If you can't reconnect to your session, check if the session exists with `screen -list` or `tmux list-sessions`
286-
2. **API key issues**: Ensure you've entered the correct API key for your selected provider
287-
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
111+
## References
288112

289-
For more information on using Aider, see the [Aider documentation](https://aider.chat/docs/).
113+
- [Aider Documentation](https://aider.chat/docs)
114+
- [AgentAPI Documentation](https://github.com/coder/agentapi)
115+
- [Coder AI Agents Guide](https://coder.com/docs/tutorials/ai-agents)

0 commit comments

Comments
 (0)