From 07e398b487bb57be3406a034452f47cd0fb59475 Mon Sep 17 00:00:00 2001 From: Mike Gehard Date: Sat, 18 Jan 2025 15:50:08 -0500 Subject: [PATCH] feat: Add devcontainer configuration This will allow folks to easily use devcontainers to develop aider. --- .devcontainer/devcontainer.json | 31 ++++++++++++++++++ .env.example | 5 +++ .gitignore | 3 +- CONTRIBUTING.md | 56 ++++++++++++++++++++++++++++++++- 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .env.example diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..8ba551855e7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,31 @@ +{ + "name": "Aider Development", + "image": "paulgauthier/aider-full:latest", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.flake8" + ], + "settings": { + "python.defaultInterpreterPath": "/home/appuser/venv/bin/python", + "python.linting.enabled": true, + "python.linting.flake8Enabled": true, + "python.formatting.provider": "none", + "editor.formatOnSave": true, + "editor.rulers": [ + 100 + ] + } + } + }, + "postCreateCommand": "pip install -e . && pip install -r requirements/requirements-dev.txt && pre-commit install", + "postAttachCommand": "aider", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/appuser/app,type=bind", + "workspaceFolder": "/home/appuser/app", + "remoteEnv": { + "OPENAI_API_KEY": "${localEnv:OPENAI_API_KEY}", + "ANTHROPIC_API_KEY": "${localEnv:ANTHROPIC_API_KEY}" + } +} \ No newline at end of file diff --git a/.env.example b/.env.example new file mode 100644 index 00000000000..92a60615efa --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# Copy this file to .env and adjust values as needed +# The values will be loaded into the devcontainer +# and can be used to configure Aider. +OPENAI_API_KEY=your_api_key_here +ANTHROPIC_API_KEY=your_api_key_here \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8ad33fd3cef..7efe4808c30 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ aider/_version.py .venv/ .#* .gitattributes -tmp.benchmarks/ \ No newline at end of file +tmp.benchmarks/ +.env \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index abe35a1c0ee..75af48ab90b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,7 +90,7 @@ For development, at least install the development dependencies: pip install -r requirements/requirements-dev.txt ``` -Consider installing other optional dependencies from the `requirements/` directory, if your development work needs them. +Consider installing other optional dependencies from the `requirements/` directory, if your development work needs them. Note that these dependency files are generated by `./scripts/pip-compile.sh` and then committed. See [Managing Dependencies](#managing-dependencies). @@ -151,6 +151,60 @@ The project's documentation is built using Jekyll and hosted on GitHub Pages. To The built documentation will be available in the `aider/website/_site` directory. +### Devcontainers as a development environment + +The project includes a `.devcontainer` configuration that provides a fully configured development environment. You can use this either through VS Code or the devcontainer CLI. + +#### Using VS Code + +1. Install the "Remote - Containers" extension in VS Code +2. Open the project folder in VS Code +3. When prompted to "Reopen in Container", click yes + - Or use the Command Palette (F1) and select "Remote-Containers: Reopen in Container" +4. VS Code will build and start the development container +5. The container includes all dependencies and tools needed for development + +#### Using Devcontainer CLI + +1. Install the devcontainer CLI: +```bash +npm install -g @devcontainers/cli +``` + +2. Build and start the development container: +```bash +devcontainer up --workspace-folder . +``` + +The development container provides: +- All Python dependencies pre-installed +- Pre-commit hooks configured +- Development tools like git, pytest, etc. +- Proper Python version and environment + +### Using GitHub Codespaces + +You can use GitHub Codespaces as a development environment: + +1. Click the "Code" button on the repository page +2. Select the "Codespaces" tab +3. Click "Create codespace on main" + +The codespace will automatically: +- Set up the development container +- Install all dependencies +- Configure pre-commit hooks +- Set up the Python environment + +#### Environment Variables + +You'll need to set up environment variables in your codespace: + +1. Go to [codespace Settings](https://github.com/settings/codespaces) +2. Add the following Secrets from your `.env` file: + - OPENAI_API_KEY + - ANTHROPIC_API_KEY + ## Coding Standards ### Python Compatibility