-
Notifications
You must be signed in to change notification settings - Fork 59
Aider module support agentAPI #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+473
−677
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
6f2b128
Aider module support agentAPI
Harsh9485 3679fc0
Fix some small issues
Harsh9485 d95e715
Merge branch 'main' into aider-tasks-agentapi-support
Harsh9485 ef16196
Fix typos
Harsh9485 0ae492c
Merge branch 'aider-tasks-agentapi-support' of github.com:Harsh9485/r...
Harsh9485 9d74616
Add aider mock script
Harsh9485 8696a00
Fix README file style
Harsh9485 585723b
Fix main.test file
Harsh9485 9fd083d
Merge branch 'main' into aider-tasks-agentapi-support
Harsh9485 e9d3470
Fix README file
Harsh9485 2719a26
Merge branch 'aider-tasks-agentapi-support' of github.com:Harsh9485/r...
Harsh9485 b0826cc
Update start script
Harsh9485 1a8971a
Add MCP server configuration
Harsh9485 4428d8c
Merge branch 'main' into aider-tasks-agentapi-support
Harsh9485 2e40967
Update main.tf file
Harsh9485 2f1edb1
Merge branch 'main' into aider-tasks-agentapi-support
Harsh9485 478b4b6
Fix some typos
Harsh9485 78b9ebd
Fix Code style issues
Harsh9485 da3c310
Merge branch 'main' into aider-tasks-agentapi-support
Harsh9485 8dec903
Adapt all suggestions
Harsh9485 b464a71
Merge branch 'main' into aider-tasks-agentapi-support
Harsh9485 d2730cb
Adjust test suite according to update
Harsh9485 2cea9e8
Merge branch 'aider-tasks-agentapi-support' of github.com:Harsh9485/r...
Harsh9485 4ad30f7
Adapt Suggestions
Harsh9485 8985231
Fix Typos
Harsh9485 aafc932
prototype module
Harsh9485 fef659e
revert changes
Harsh9485 79e2fdd
Merge branch 'main' into aider-tasks-agentapi-support
Harsh9485 79ae316
Refactor Aider module
Harsh9485 ddef094
Merge branch 'main' into aider-tasks-agentapi-support
Harsh9485 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,76 +8,52 @@ tags: [agent, ai, aider] | |
|
||
# Aider | ||
|
||
Run [Aider](https://aider.chat) AI pair programming in your workspace. This module installs Aider and provides a persistent session using screen or tmux. | ||
Run [Aider](https://aider.chat) AI pair programming in your workspace. This module installs Aider with AgentAPI for seamless Coder Tasks Support. | ||
|
||
```tf | ||
module "aider" { | ||
source = "registry.coder.com/coder/aider/coder" | ||
version = "1.1.2" | ||
agent_id = coder_agent.example.id | ||
source = "registry.coder.com/coder/aider/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
credentials = var.api_key | ||
ai_provider = "google" | ||
model = "gemini" | ||
} | ||
``` | ||
|
||
## Features | ||
|
||
- **Interactive Parameter Selection**: Choose your AI provider, model, and configuration options when creating the workspace | ||
- **Multiple AI Providers**: Supports Anthropic (Claude), OpenAI, DeepSeek, GROQ, and OpenRouter | ||
- **Persistent Sessions**: Uses screen (default) or tmux to keep Aider running in the background | ||
- **Optional Dependencies**: Install Playwright for web page scraping and PortAudio for voice coding | ||
- **Project Integration**: Works with any project directory, including Git repositories | ||
- **Browser UI**: Use Aider in your browser with a modern web interface instead of the terminal | ||
- **Non-Interactive Mode**: Automatically processes tasks when provided via the `task_prompt` variable | ||
## Prerequisites | ||
|
||
## Module Parameters | ||
- pipx is automatically installed if not already available | ||
|
||
> [!NOTE] | ||
> 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`. | ||
|
||
## Usage Examples | ||
|
||
### Basic setup with API key | ||
## Usage Example | ||
|
||
```tf | ||
variable "anthropic_api_key" { | ||
type = string | ||
description = "Anthropic API key" | ||
sensitive = true | ||
} | ||
|
||
module "aider" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/aider/coder" | ||
version = "1.1.2" | ||
agent_id = coder_agent.example.id | ||
ai_api_key = var.anthropic_api_key | ||
data "coder_parameter" "ai_prompt" { | ||
name = "AI Prompt" | ||
description = "Write an initial prompt for Aider to work on." | ||
type = "string" | ||
default = "" | ||
mutable = true | ||
Comment on lines
+31
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L'et''s move this into the module source. |
||
} | ||
``` | ||
|
||
This basic setup will: | ||
|
||
- Install Aider in the workspace | ||
- Create a persistent screen session named "aider" | ||
- Configure Aider to use Anthropic Claude 3.7 Sonnet model | ||
- Enable task reporting (configures Aider to report tasks to Coder MCP) | ||
|
||
### Using OpenAI with tmux | ||
|
||
```tf | ||
variable "openai_api_key" { | ||
variable "gemini_api_key" { | ||
type = string | ||
description = "OpenAI API key" | ||
description = "Gemini API key" | ||
sensitive = true | ||
} | ||
|
||
module "aider" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/aider/coder" | ||
version = "1.1.2" | ||
agent_id = coder_agent.example.id | ||
use_tmux = true | ||
ai_provider = "openai" | ||
ai_model = "4o" # Uses Aider's built-in alias for gpt-4o | ||
ai_api_key = var.openai_api_key | ||
source = "registry.coder.com/coder/aider/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
credentials = var.gemini_api_key | ||
install_aider = true | ||
workdir = "/home/coder" | ||
ai_provider = "google" | ||
model = "gemini" | ||
install_agentapi = true | ||
ai_prompt = data.coder_parameter.ai_prompt.value | ||
system_prompt = "..." | ||
} | ||
``` | ||
|
||
|
@@ -93,174 +69,15 @@ variable "custom_api_key" { | |
module "aider" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/aider/coder" | ||
version = "1.1.2" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
ai_provider = "custom" | ||
custom_env_var_name = "MY_CUSTOM_API_KEY" | ||
ai_model = "custom-model" | ||
ai_api_key = var.custom_api_key | ||
} | ||
``` | ||
|
||
### Adding Custom Extensions (Experimental) | ||
|
||
You can extend Aider's capabilities by adding custom extensions: | ||
|
||
```tf | ||
module "aider" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/aider/coder" | ||
version = "1.1.2" | ||
agent_id = coder_agent.example.id | ||
ai_api_key = var.anthropic_api_key | ||
|
||
experiment_pre_install_script = <<-EOT | ||
pip install some-custom-dependency | ||
EOT | ||
|
||
experiment_additional_extensions = <<-EOT | ||
custom-extension: | ||
args: [] | ||
cmd: custom-extension-command | ||
description: A custom extension for Aider | ||
enabled: true | ||
envs: {} | ||
name: custom-extension | ||
timeout: 300 | ||
type: stdio | ||
EOT | ||
} | ||
``` | ||
|
||
Note: The indentation in the heredoc is preserved, so you can write the YAML naturally. | ||
|
||
## Task Reporting (Experimental) | ||
|
||
> This functionality is in early access as of Coder v2.21 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/tutorials/ai-agents) | ||
> | ||
> Join our [Discord channel](https://discord.gg/coder) or | ||
> [contact us](https://coder.com/contact) to get help or share feedback. | ||
|
||
Your workspace must have either `screen` or `tmux` installed to use this. | ||
|
||
Task reporting is **enabled by default** in this module, allowing you to: | ||
|
||
- Send an initial prompt to Aider during workspace creation | ||
- Monitor task progress in the Coder UI | ||
- Use the `coder_parameter` resource to collect prompts from users | ||
|
||
### Setting up Task Reporting | ||
|
||
To use task reporting effectively: | ||
|
||
1. Add the Coder Login module to your template | ||
2. Configure the necessary variables to pass the task prompt | ||
3. Optionally add a coder_parameter to collect prompts from users | ||
|
||
Here's a complete example: | ||
|
||
```tf | ||
module "coder-login" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/modules/coder-login/coder" | ||
version = "1.0.15" | ||
agent_id = coder_agent.example.id | ||
} | ||
|
||
variable "anthropic_api_key" { | ||
type = string | ||
description = "Anthropic API key" | ||
sensitive = true | ||
} | ||
|
||
data "coder_parameter" "ai_prompt" { | ||
type = "string" | ||
name = "AI Prompt" | ||
default = "" | ||
description = "Write a prompt for Aider" | ||
mutable = true | ||
ephemeral = true | ||
} | ||
|
||
module "aider" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/aider/coder" | ||
version = "1.1.2" | ||
agent_id = coder_agent.example.id | ||
ai_api_key = var.anthropic_api_key | ||
task_prompt = data.coder_parameter.ai_prompt.value | ||
|
||
# Optionally customize the system prompt | ||
system_prompt = <<-EOT | ||
You are a helpful Coding assistant. Aim to autonomously investigate | ||
and solve issues the user gives you and test your work, whenever possible. | ||
Avoid shortcuts like mocking tests. When you get stuck, you can ask the user | ||
but opt for autonomy. | ||
YOU MUST REPORT ALL TASKS TO CODER. | ||
When reporting tasks, you MUST follow these EXACT instructions: | ||
- IMMEDIATELY report status after receiving ANY user message. | ||
- Be granular. If you are investigating with multiple steps, report each step to coder. | ||
Task state MUST be one of the following: | ||
- Use "state": "working" when actively processing WITHOUT needing additional user input. | ||
- Use "state": "complete" only when finished with a task. | ||
- Use "state": "failure" when you need ANY user input, lack sufficient details, or encounter blockers. | ||
Task summaries MUST: | ||
- Include specifics about what you're doing. | ||
- Include clear and actionable steps for the user. | ||
- Be less than 160 characters in length. | ||
EOT | ||
model = "custom-model" | ||
credentials = var.custom_api_key | ||
} | ||
``` | ||
|
||
When a task prompt is provided via the `task_prompt` variable, the module automatically: | ||
|
||
1. Combines the system prompt with the task prompt into a single message in the format: | ||
|
||
``` | ||
SYSTEM PROMPT: | ||
[system_prompt content] | ||
|
||
This is your current task: [task_prompt] | ||
``` | ||
|
||
2. Executes the task during workspace creation using the `--message` and `--yes-always` flags | ||
3. Logs task output to `$HOME/.aider.log` for reference | ||
|
||
If you want to disable task reporting, set `experiment_report_tasks = false` in your module configuration. | ||
|
||
## Using Aider in Your Workspace | ||
|
||
After the workspace starts, Aider will be installed and configured according to your parameters. A persistent session will automatically be started during workspace creation. | ||
|
||
### Session Options | ||
|
||
You can run Aider in three different ways: | ||
|
||
1. **Direct Mode**: Aider starts directly in the specified folder when you click the app button | ||
|
||
- Simple setup without persistent context | ||
- Suitable for quick coding sessions | ||
|
||
2. **Screen Mode** (Default): Run Aider in a screen session that persists across connections | ||
|
||
- Session name: "aider" (or configured via `session_name`) | ||
|
||
3. **Tmux Mode**: Run Aider in a tmux session instead of screen | ||
|
||
- Set `use_tmux = true` to enable | ||
- Session name: "aider" (or configured via `session_name`) | ||
- Configures tmux with mouse support for shared sessions | ||
|
||
Persistent sessions (screen/tmux) allow you to: | ||
|
||
- Disconnect and reconnect without losing context | ||
- Run Aider in the background while doing other work | ||
- Switch between terminal and browser interfaces | ||
|
||
### Available AI Providers and Models | ||
|
||
Aider supports various providers and models, and this module integrates directly with Aider's built-in model aliases: | ||
|
@@ -280,10 +97,12 @@ For a complete and up-to-date list of supported aliases and models, please refer | |
|
||
## Troubleshooting | ||
|
||
If you encounter issues: | ||
- If `aider` is not found, ensure `install_aider = true` and your API key is valid | ||
- Logs are written under `/home/coder/.aider-module/` (`install.log`, `agentapi-start.log`) for debugging | ||
- If AgentAPI fails to start, verify that your container has network access and executable permissions for the scripts | ||
|
||
1. **Screen/Tmux issues**: If you can't reconnect to your session, check if the session exists with `screen -list` or `tmux list-sessions` | ||
2. **API key issues**: Ensure you've entered the correct API key for your selected provider | ||
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 | ||
## References | ||
|
||
For more information on using Aider, see the [Aider documentation](https://aider.chat/docs/). | ||
- [Aider Documentation](https://aider.chat/docs) | ||
- [AgentAPI Documentation](https://github.com/coder/agentapi) | ||
- [Coder AI Agents Guide](https://coder.com/docs/tutorials/ai-agents) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.