Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 43 additions & 129 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,149 +7,60 @@ contribute.

## Bug Reports and Feature Requests

Please submit bug reports and feature requests as GitHub issues. This
helps us to keep track of them and discuss potential solutions or
enhancements.

## LLM Benchmark Results

Contributions of
[LLM benchmark results](https://aider.chat/docs/leaderboards/)
are welcome!
See the
[benchmark README](https://github.com/Aider-AI/aider/blob/main/benchmark/README.md)
for information on running aider's code editing benchmarks.
Submit results by opening a PR with edits to the
[benchmark results data files](https://github.com/Aider-AI/aider/blob/main/aider/website/_data/).
Please submit bug reports as GitHub issues. We would prefer feature requests
be brought directly to the [Discord Chat](https://discord.gg/AX9ZEA7nJn).
This should be faster for triaging feature requests and scoping hem out.


## Pull Requests

We appreciate your pull requests. For small changes, feel free to
submit a PR directly. If you are considering a large or significant
change, please discuss it in a GitHub issue before submitting the
change, please discuss it in the [Discord Chat](https://discord.gg/AX9ZEA7nJn) before submitting the
PR. This will save both you and the maintainers time, and it helps to
ensure that your contributions can be integrated smoothly.

## Licensing

Before contributing a PR, please review our
[Individual Contributor License Agreement](https://aider.chat/docs/legal/contributor-agreement.html).
All contributors will be asked to complete the agreement as part of the PR process.

## Setting up a Development Environment

### Clone the Repository

```
git clone https://github.com/Aider-AI/aider.git
cd aider
```

### Create a Virtual Environment

It is recommended to create a virtual environment outside of the repository to keep your development environment isolated.

#### Using `venv` (Python 3.9 and later)

```
python -m venv /path/to/venv
```

### Activate the Virtual Environment

#### On Windows

```
/path/to/venv/Scripts/activate
```

#### On Unix or macOS

```
source /path/to/venv/bin/activate
```

### Install the Project in Editable Mode

This step allows you to make changes to the source code and have them take effect immediately without reinstalling the package.

```
pip install -e .
```

### Install the Project Dependencies

```
pip install -r requirements.txt
```

For development, at least install the development dependencies:
## Setting up the Development Environment

```
pip install -r requirements/requirements-dev.txt
```

Consider installing other optional dependencies from the `requirements/` directory, if your development work needs them.
```bash
# Clone the repository
git clone https://github.com/dwash96/aider-ce.git
cd aider-ce

Note that these dependency files are generated by `./scripts/pip-compile.sh` and then committed. See [Managing Dependencies](#managing-dependencies).
# Make a venv
python3 -m venv venv
source venv/bin/activate

### Install Pre-commit Hooks (Optional)
# Install UV because it's superior
pip install uv

The project uses pre-commit hooks for code formatting and linting. If you want to install and use these hooks, run:
# Build Project
uv pip install -e .

```
# Add tool chain
uv install pre-commit
pre-commit install
```

This will automatically run the pre-commit hooks when you commit changes to the repository.

Now you should have a fully functional development environment for the Aider project. You can start making changes, running tests, and contributing to the project.
# Run Program
aider-ce

### Handy Opinionated Setup Commands for MacOS / Linux
# OR!

Here's an example of following the setup instructions above, for your copy/paste pleasure if your system works the same. Start in the project directory.
cecli

```
python3 -m venv ../aider_venv \
&& source ../aider_venv/bin/activate \
&& pip3 install -e . \
&& pip3 install -r requirements.txt \
&& pip3 install -r requirements/requirements-dev.txt
```

### Running Tests

Just run `pytest`.

### Building the Docker Image

The project includes a `Dockerfile` for building a Docker image. You can build the image by running:

```
docker build -t aider -f docker/Dockerfile .
```

### Building the Documentation

The project's documentation is built using Jekyll and hosted on GitHub Pages. To build the documentation locally, follow these steps:
docker build -t aider-ce -f docker/Dockerfile .

1. Install Ruby and Bundler (if not already installed).
2. Navigate to the `aider/website` directory.
3. Install the required gems:
```
bundle install
```
4. Build the documentation:
```
bundle exec jekyll build
```
5. Preview the website while editing (optional):
```
bundle exec jekyll serve
```
# OR!

The built documentation will be available in the `aider/website/_site` directory.
docker build -t cecli -f docker/Dockerfile .
```

## Coding Standards

Expand All @@ -161,10 +72,6 @@ Aider supports Python versions 3.9, 3.10, 3.11, and 3.12. When contributing code

The project follows the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide for Python code, with a maximum line length of 100 characters. Additionally, the project uses [isort](https://pycqa.github.io/isort/) and [Black](https://black.readthedocs.io/en/stable/) for sorting imports and code formatting, respectively. Please install the pre-commit hooks to automatically format your code before committing changes.

### No Type Hints

The project does not use type hints.

### Testing

The project uses [pytest](https://docs.pytest.org/en/latest/) for running unit tests. The test files are located in the `aider/tests` directory and follow the naming convention `test_*.py`.
Expand Down Expand Up @@ -226,16 +133,23 @@ You can also pass one argument to `pip-compile.sh`, which will flow through to `
./scripts/pip-compile.sh --upgrade
```

### Pre-commit Hooks

The project uses [pre-commit](https://pre-commit.com/) hooks to automatically format code, lint, and run other checks before committing changes. After cloning the repository, run the following command to set up the pre-commit hooks:
### Building the Documentation

```
pre-commit install
```
The project's documentation is built using Jekyll and hosted on GitHub Pages. To build the documentation locally, follow these steps:

pre-commit will then run automatically on each `git commit` command. You can use the following command line to run pre-commit manually:
1. Install Ruby and Bundler (if not already installed).
2. Navigate to the `aider/website` directory.
3. Install the required gems:
```
bundle install
```
4. Build the documentation:
```
bundle exec jekyll build
```
5. Preview the website while editing (optional):
```
bundle exec jekyll serve
```

```
pre-commit run --all-files
```
The built documentation will be available in the `aider/website/_site` directory.
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,23 @@ cache-prompts: true
check-update: true
debug: false
enable-context-compaction: true
context-compaction-max-tokens: 64000
env-file: .aider.env
multiline: true
preserve-todo-list: true
show-model-warnings: true
use-enhanced-map: true
watch-files: false
agent-config: |
{
"large_file_token_threshold": 12500,
"skip_cli_confirmations": false
}
mcp-servers: |
{
"mcpServers":
{
"context7":{
"transport":"http",
"url":"https://mcp.context7.com/mcp"
}
}
}

agent-config:
large_file_token_threshold: 12500
skip_cli_confirmations: false

mcp-servers:
mcpServers:
context7:
transport: http
url: https://mcp.context7.com/mcp
```

Use the adjacent .aider.env file to store model api keys as environment variables, e.g:
Expand Down
2 changes: 1 addition & 1 deletion aider/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from packaging import version

__version__ = "0.89.3.dev"
__version__ = "0.89.4.dev"
safe_version = __version__

try:
Expand Down
4 changes: 2 additions & 2 deletions aider/coders/base_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3001,8 +3001,8 @@ async def show_send_output_stream(self, completion):
await asyncio.sleep(0.1) # Yield control and wait briefly

if isinstance(chunk, str):
text = chunk
received_content = True
self.io.tool_error(chunk)
continue
else:
if len(chunk.choices) == 0:
continue
Expand Down
41 changes: 25 additions & 16 deletions aider/coders/chat_chunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,49 @@ def all_messages(self):
)

def add_cache_control_headers(self):
if self.examples:
self.add_cache_control(self.examples)
# Limit to 4 cacheable blocks to appease Anthropic's limits on chunk caching
if self.format_list("readonly_files"):
self.add_cache_control(self.format_list("readonly_files"))
elif self.format_list("static"):
self.add_cache_control(self.format_list("static"))
elif self.format_list("examples"):
self.add_cache_control(self.format_list("examples"))
else:
self.add_cache_control(self.system)
self.add_cache_control(self.format_list("system"))

# The files form a cacheable block.
# The block starts with readonly_files and ends with chat_files.
# So we mark the end of chat_files.
self.add_cache_control(self.chat_files)
# self.add_cache_control(self.add_cache_control(self.format_list("chat_files"))

# The repo map is its own cacheable block.
self.add_cache_control(self.repo)
if self.format_list("repo"):
self.add_cache_control(self.format_list("repo"))
elif self.format_list("chat_files"):
self.add_cache_control(self.format_list("chat_files"))

# The history is ephemeral on its own.
self.add_cache_control(self.done)
self.add_cache_control(self.add_cache_control(self.format_list("cur")), penultimate=True)

# Per this: https://github.com/BerriAI/litellm/issues/10226
# The first and second to last messages are cache optimal
# Since caches are also written to incrementally and you need
# the past and current states to properly append and gain
# efficiencies/savings in cache writing
def add_cache_control(self, messages):
if not messages or len(messages) < 2:
def add_cache_control(self, messages, penultimate=False):
if not messages:
return

content = messages[-2]["content"]
if type(content) is str:
content = dict(
type="text",
text=content,
)
content["cache_control"] = {"type": "ephemeral"}
if penultimate and len(messages) < 2:
content = messages[-2]["content"]
if type(content) is str:
content = dict(
type="text",
text=content,
)
content["cache_control"] = {"type": "ephemeral"}

messages[-2]["content"] = [content]
messages[-2]["content"] = [content]

content = messages[-1]["content"]
if type(content) is str:
Expand Down
Loading
Loading