Code Monkey home page Code Monkey logo

vscode-aider-extension's Introduction

VSCode-Aider-Extension

Example

Introduction

Aider's website describes the tool best:

Aider is a command line tool that allows you to pair program with GPT-3.5/GPT 4.0. You can start a new project or work with an existing repo. Aider makes sure edits from GPT are committed to git with sensible commit messages. Aider is unique in that it lets you ask for changes to pre-existing, larger codebases.

As a frequent user of Aider, I was looking for a way to accomplish three goals:

  1. With the aider tool, you have to tell it what files it should be considering in your current chat session. Much like the wonderful plugin for NeoVIM, I found it a mild chore to keep running /add filename and /drop filename and thought maybe I could make an extension that automates away those chores.
  2. Aider (like all ChatGPT tools) requires you to supply your OPENAI_API_KEY prior to calling API endpoints. Aider needs this as well. I wanted to be able to set this automatically.
  3. I wanted the tool to feel naturally like part of VSCode.

What Works, What Still Needs Some Iteration

I'm really new at writing VSCode plugins. Given that I like Aider, it might not surprise you that I ran:

Write a VSCode extension for running aider. The extension should keep track of open files, it should run \add and \drop to keep the commands inside of the tool synchronized with the open file list inside of VSCode.

This command created about 70% of version 0.0.1 of this plugin. Alas, there are some things are not quite right yet.

  1. When the plugin first opens, it should be automatically adding any currently open files to Aider. For whatever reason, the command I'm using vscode.workspace.textDocuments doesn't seem to return all the tabs I have open all of the time. I've also tried vscode.window.visibleTextEditors, it also refused to return all the open tabs all of the time. This mostly seems to happen when I've first starting up VSCode and it's using previously saved tabs.
  2. The Python plugin has a default setting that always activates the current python environment for every new terminal. This includes the terminal I create for aider. I wouldn't mind, except it pollutes the output of aider. The only solution I have so far is to turn off the property "Terminal: Activate Environment" in the Python settings. Keep in mind, you'll need to source your VENVs yourself if you turn this off.
  3. Aider won't enter "Pretty Mode" in the VSCode Terminal. Consequently, output isn't colored. I don't have context on why that doesn't work, but I know that it won't even obey the --pretty command line option at this point.

What Works

  1. Opening or closing tabs seems /add and /drop files correctly.
  2. I haven't had any problem using aider to make further modifications to the code.
  3. Configuration options seem to work, though I haven't really used the "ignore files" one very much.

Setting up the plugin

First and foremost, you need to have aider installed. If you don't have this done already, head over to the Aider website to get it installed.

After that's done, I would suggest doing three things:

  1. Open the Aider settings and set OPENAI_API_KEY.
  2. If you have trouble running Aider because it can't find the aider executable, you may need to set the full path to the executable in the "Command Line" setting for Aider. For example, you may need to set it to something like /opt/homebrew/bin/aider.
  3. If you want to use GPT 4.5 Turbo, you'll probably have to update the command line further, to something like aider --model gpt-4-1106-preview

If you have any trouble whatsoever with setting the working directory for aider, I encourage you to set the "working directory" setting. This will prevent the plugin from trying to figure out the working directory by itself.

Using the plugin

Run the "Aider Open" command from your Command Palette to start the plugin. This should always be the first step, as no other commands will work until it's open.

Aider relies on the user to specify the files that will need to change in order to accomplish the commands you give it. If you've used aider before, you'll be familiar with running /add filename and /drop filename to accomplish this. When using this plugin, whatever files you have open in your editor will automatically be in the aider chat.

If you're ready to have Aider make some changes to your site, go to Aider terminal window and do some pair programming with Aider. If you are new to Aider, I recommend checking out the Aider web site's examples page.

Who Wrote Aider?

The aider tool was written by Paul Gauthier. I am not a contributor on that project, but after using it extensively, I (Matt Flower) decided to write the Aider plugin for VSCode.

Reporting Bugs

Please report any bugs to the issues page on the GitHub site for this extension.

Pull Requests and the Future of this Plugin

I'm enjoying writing this plugin, and I'm enjoying using it. If you think you know the answer to any of the problems listed above (or other ones I haven't noticed yet!) I'm definitely open to Pull Requests.

vscode-aider-extension's People

Contributors

mattflower avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vscode-aider-extension's Issues

[Feature Request] Per-workspace Configs

Hello,

thanks for your work integrating aider with VSCode - you beat me to it! One thing I'd love to get working is per-workspace configs. I use aider for both personal and professional projects and I'd like to use my employer's OpenAI key when working on work-related code.

I'll try to circle back and get a PR for this, but wanted to put an issue up to see if other individuals would also find it useful.

thanks!

Hangs on Open

When I open Aider via the "Open Aider" command, Aider launches and a /add {open files} command displays in the aider prompt. But then it just hangs for ~30 seconds before finally returning control to the user.

Has anyone else experienced this?

"Open Aider" doesn't verify that Aider started correctly

... and sends the /add command to the shell irrespective of whether Aider's running or not.

$ aider
Aider v0.18.0
VSCode terminal detected, pretty output has been disabled.
No OpenAI API key provided. Use --openai-api-key or export OPENAI_API_KEY.
$ /add docs/contact.user.js
zsh: no such file or directory: /add

OSError: [Errno 30] Read-only file system: '.aider.chat.history.md'

When opening aider I get the following error message in the terminal:

Traceback (most recent call last):
  File "/opt/homebrew/anaconda3/envs/aider-chat/bin/aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/anaconda3/envs/aider-chat/lib/python3.12/site-packages/aider/main.py", line 434, in main
    io = InputOutput(
         ^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/aider-chat/lib/python3.12/site-packages/aider/io.py", line 142, in __init__
    self.append_chat_history(f"\n# aider chat started at {current_time}\n\n")
  File "/opt/homebrew/anaconda3/envs/aider-chat/lib/python3.12/site-packages/aider/io.py", line 361, in append_chat_history
    with self.chat_history_file.open("a", encoding=self.encoding) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/aider-chat/lib/python3.12/pathlib.py", line 1014, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '.aider.chat.history.md'

Starting aider outside VSC is working as expected.

GUI Mode Support.

Is there a way to support gui mode of aider in this extension. So open files can be auto synced while we are in browser .

The files opened in new tabs are not being added to the Aider session.

[beginner dev here]

Issue Summary:
I am experiencing an issue with the VSCode Aider extension where it fails to add files to the Aider session when I open them in new tabs in VSCode. Despite opening files, Aider does not seem to recognise or interact with these files as expected.

Expected Behavior:
When I open a file in a new tab, I expect the Aider extension to automatically add this file to the Aider session, making it visible and interactive in Aider.

Actual Behavior:
The files opened in new tabs are not being added to the Aider session. There is no interaction or recognition of these files by Aider.

I Have Azure OpenAi API key - To run Aider I had to have those settings in my .aider.cont.yml:
openai-api-type: azure
openai-api-key: ************
openai-api-base: https://bgg-recommender.openai.azure.com/
openai-api-version: 2023-03-15-preview
openai-api-deployment-id: gpt-35-20230623

Screenshot 2023-12-18 at 19 46 48

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.