Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add aider module #456

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

Closed
wants to merge 69 commits into from
Closed

feat: add aider module #456

wants to merge 69 commits into from

Conversation

DevelopmentCats
Copy link
Contributor

This pull request introduces the aider module, enabling seamless integration of Aider AI pair programming into Coder workspaces. The module provides a robust and configurable setup for developers to leverage AI assistance in their coding workflows.

Key Features:

  • Persistent Sessions: Supports screen (default) or tmux for maintaining Aider sessions across workspace connections.
  • Task Reporting: Experimental support for task reporting via Coder MCP, allowing users to send initial prompts and monitor task progress.
  • Pre- and Post-Install Scripts: Customizable scripts for pre- and post-installation tasks to suit specific workspace requirements.
  • AI Provider Flexibility: Supports multiple AI providers, including Anthropic, OpenAI, DeepSeek, GROQ, and OpenRouter, with configurable API keys and models.
  • Comprehensive Documentation: Includes detailed usage examples, configuration options, and troubleshooting steps in the README.md.

Changes:

  1. Added main.tf to define the Aider module with Terraform resources for installation, configuration, and session management.
  2. Updated README.md with detailed instructions, examples, and feature descriptions.
  3. Added main.test.ts to validate module functionality with comprehensive test cases.

Testing:

  • All tests pass successfully using bun test.
  • Verified module functionality in a local Coder workspace with various configurations (e.g., screen, tmux, task reporting).

Notes:

  • Task reporting is experimental and requires Coder v2.21 or later.
  • Feedback and suggestions are welcome to further refine this module..

@DevelopmentCats DevelopmentCats changed the title Add Aider Module for AI Pair Programming with Persistent Sessions and Task Reporting feat(aider): Add Aider Module May 2, 2025
@DevelopmentCats DevelopmentCats changed the title feat(aider): Add Aider Module feat(aider): add aider module May 2, 2025
@DevelopmentCats DevelopmentCats requested a review from matifali May 2, 2025 03:50
Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested some changes.

DevelopmentCats and others added 5 commits May 2, 2025 10:09
…oder_env's. removed deafult references in examples. Combine API Key info and add link to aider docs. Removed defaults
…g macOS installation logic for initial commit. Change icon to refer to new aider icon. Made folder variable required. Screen and Task Reporting are defaulted to true now.
@matifali matifali requested a review from stirby May 5, 2025 18:48
…g multi-user settings in .screenrc and enhancing log file creation
…ts to include user bin directories for improved command accessibility
… reporting instructions into Aider execution
…ed readability of task reporting instructions
@DevelopmentCats DevelopmentCats changed the title docs: add aider module feat: add aider module May 7, 2025
…r consistent status reporting in Aider sessions, and remove tee since it might have been interfering with the app_status
@DevelopmentCats
Copy link
Contributor Author

DevelopmentCats commented May 7, 2025

Aider does not currently have the functionality to make external MCP Calls, so task reporting is not possible until this PR gets merged for Aider: Aider-AI/aider#3937

At this point the module:
Installs Aider
Runs Aider in a Screen Session, by default with optional tmux support.
Passes a prompt variable to the Persistent Aider Session.
Groundwork is done for mcp support when it comes to aider. ( Some cleanup may need to be done based on the aider configuration for mcp servers )

I'm going to request that someone review this so we can merge it, and then I can prepare this for a module release to then push it to the registry.

@matifali matifali requested a review from hugodutka May 7, 2025 15:24
Copy link
Contributor

@stirby stirby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, down the road we will need a list of allowed commands for aider as well, but this can wait.

const instance = findResourceInstance(state, "coder_script");

// Check for the correct tmux condition with the interpolated value
expect(instance.script.includes('if [ "true" = "true" ]')).toBe(true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be possible for this string to be present with other variable combinations too?

Comment on lines 131 to 153
// Verify all required flags are present in the aider command
expect(
instance.script.includes(
"aider --architect --yes-always --read CONVENTIONS.md --message",
),
).toBe(true);

// Verify the expected message format is correct
expect(
instance.script.includes(
'--message \\"Report each step to Coder. Your task: $CODER_MCP_AIDER_TASK_PROMPT\\"',
),
).toBe(true);

// Verify the script creates a flag file to prevent duplicate execution
expect(instance.script.includes('touch "$HOME/.aider_task_executed"')).toBe(
true,
);

// Verify the app status slug is properly set in the screen session
expect(
instance.script.includes('export CODER_MCP_APP_STATUS_SLUG=\\"aider\\"'),
).toBe(true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we checking that the script contains these strings? Is it to prevent typos when it's edited in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go through and remove this functionality.

I was going down a rabbit-hole when I was trying to figure out why app_status was not generating, but then later realized its because I actually need to have aider utilize the coder mcp server.

I will most likely change this to be a variable, so people can choose to pass specific options in the template rather than it being hard-coded one specific way in the module

…suring tmux and screen are only installed if not present, and move checks for Python dependencies into Aider installation section
Comment on lines +26 to +35
await execContainer(id, [
"sh",
"-c",
`
apk add --no-cache bash
mkdir -p /home/coder/bin
touch /home/coder/.aider.log
${extraCommands}
`,
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why the first two elements of the array are individual command segments, and then the last one is a multi-line template literal encompassing multiple commands? Is that guaranteed to be safe?

agent_id: "foo",
});

// Install bash and run the script
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete comments like this? I don't know if they're artifacts from AI coding, but they add a lot of extra noise when someone is reading through the code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add them in when I'm writing everything, and I have rules in my cursor IDE to insert these comments for when I am reading through everything again. I realize this might be confusing and noisy for anyone else, so I will make sure to remove any unnecessary comments in the future.

Comment on lines 89 to 92
// Verify task reporting is mentioned
expect(output.stdout).toContain(
"Configuring Aider to report tasks via Coder MCP...",
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to improve the test/module to make it more clear that the reporting actually exists? "Configuring" implies an incomplete action, as opposed to "configured"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im standardizing the command flags, and re-writing the tests right now so I will make sure that they are more meaningful rather than looking for the echo command. I was ultimately just making sure that the task reporting aspect of the script was triggered properly when the variable was set.

Comment on lines 113 to 118
// Verify all required flags are present in the aider command
expect(
instance.script.includes(
"aider --architect --yes-always --read CONVENTIONS.md --message",
),
).toBe(true);
Copy link
Member

@Parkreiner Parkreiner May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be refactored to

expect(instance.script).toInclude(
  "aider --architect --yes-always --read CONVENTIONS.md --message",
);

@matifali
Copy link
Member

matifali commented May 9, 2025

We are moving to https://github.com/coder/regitsry. Please move your PR there. Thanks
More context in #469

@matifali matifali closed this May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants