mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
copy
This commit is contained in:
parent
f8b30e0703
commit
7bd8d26f95
5 changed files with 92 additions and 88 deletions
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
nav_order: 100
|
nav_order: 800
|
||||||
---
|
---
|
||||||
# Specifying coding conventions
|
# Specifying coding conventions
|
||||||
|
|
||||||
|
|
|
@ -58,91 +58,6 @@ pip install -r requirements.txt
|
||||||
python -m aider.main
|
python -m aider.main
|
||||||
```
|
```
|
||||||
|
|
||||||
## Can I script aider?
|
|
||||||
|
|
||||||
You can script aider via the command line or python.
|
|
||||||
|
|
||||||
## Command line
|
|
||||||
|
|
||||||
Aider takes a `--message` argument, where you can give it a natural language instruction.
|
|
||||||
It will do that one thing, apply the edits to the files and then exit.
|
|
||||||
So you could do:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
aider --message "make a script that prints hello" hello.js
|
|
||||||
```
|
|
||||||
|
|
||||||
Or you can write simple shell scripts to apply the same instruction to many files:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
for FILE in *.py ; do
|
|
||||||
aider --message "add descriptive docstrings to all the functions" $FILE
|
|
||||||
done
|
|
||||||
```
|
|
||||||
|
|
||||||
User `aider --help` to see all the command line options, but these are useful for scripting:
|
|
||||||
|
|
||||||
```
|
|
||||||
--stream, --no-stream
|
|
||||||
Enable/disable streaming responses (default: True) [env var:
|
|
||||||
AIDER_STREAM]
|
|
||||||
--message COMMAND, --msg COMMAND, -m COMMAND
|
|
||||||
Specify a single message to send GPT, process reply then exit
|
|
||||||
(disables chat mode) [env var: AIDER_MESSAGE]
|
|
||||||
--message-file MESSAGE_FILE, -f MESSAGE_FILE
|
|
||||||
Specify a file containing the message to send GPT, process reply,
|
|
||||||
then exit (disables chat mode) [env var: AIDER_MESSAGE_FILE]
|
|
||||||
--yes Always say yes to every confirmation [env var: AIDER_YES]
|
|
||||||
--auto-commits, --no-auto-commits
|
|
||||||
Enable/disable auto commit of GPT changes (default: True) [env var:
|
|
||||||
AIDER_AUTO_COMMITS]
|
|
||||||
--dirty-commits, --no-dirty-commits
|
|
||||||
Enable/disable commits when repo is found dirty (default: True) [env
|
|
||||||
var: AIDER_DIRTY_COMMITS]
|
|
||||||
--dry-run, --no-dry-run
|
|
||||||
Perform a dry run without modifying files (default: False) [env var:
|
|
||||||
AIDER_DRY_RUN]
|
|
||||||
--commit Commit all pending changes with a suitable commit message, then exit
|
|
||||||
[env var: AIDER_COMMIT]
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Python
|
|
||||||
|
|
||||||
You can also script aider from python:
|
|
||||||
|
|
||||||
```python
|
|
||||||
from aider.coders import Coder
|
|
||||||
from aider.models import Model
|
|
||||||
|
|
||||||
# This is a list of files to add to the chat
|
|
||||||
fnames = ["greeting.py"]
|
|
||||||
|
|
||||||
model = Model("gpt-4-turbo", weak_model="gpt-3.5-turbo")
|
|
||||||
|
|
||||||
# Create a coder object
|
|
||||||
coder = Coder.create(main_model=model, fnames=fnames)
|
|
||||||
|
|
||||||
# This will execute one instruction on those files and then return
|
|
||||||
coder.run("make a script that prints hello world")
|
|
||||||
|
|
||||||
# Send another instruction
|
|
||||||
coder.run("make it say goodbye")
|
|
||||||
```
|
|
||||||
|
|
||||||
See the
|
|
||||||
[Coder.create() and Coder.__init__() methods](https://github.com/paul-gauthier/aider/blob/main/aider/coders/base_coder.py)
|
|
||||||
for all the supported arguments.
|
|
||||||
|
|
||||||
It can also be helpful to set the equivalend of `--yes` by doing this:
|
|
||||||
|
|
||||||
```
|
|
||||||
from aider.io import InputOutput
|
|
||||||
io = InputOutput(yes=True)
|
|
||||||
# ...
|
|
||||||
coder = Coder.create(client=client, fnames=fnames, io=io)
|
|
||||||
```
|
|
||||||
|
|
||||||
## What code languages does aider support?
|
## What code languages does aider support?
|
||||||
|
|
||||||
Aider supports pretty much all the popular coding languages.
|
Aider supports pretty much all the popular coding languages.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
nav_order: 50
|
nav_order: 900
|
||||||
---
|
---
|
||||||
# Supported languages
|
# Supported languages
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
title: Repository map
|
title: Repository map
|
||||||
excerpt: Tree-sitter allows aider to build a repo map that better summarizes large code bases.
|
excerpt: Tree-sitter allows aider to build a repo map that better summarizes large code bases.
|
||||||
highlight_image: /assets/robot-ast.png
|
highlight_image: /assets/robot-ast.png
|
||||||
nav_order: 95
|
nav_order: 900
|
||||||
---
|
---
|
||||||
{% if page.date %}
|
{% if page.date %}
|
||||||
<p class="post-date">{{ page.date | date: "%B %d, %Y" }}</p>
|
<p class="post-date">{{ page.date | date: "%B %d, %Y" }}</p>
|
||||||
|
|
89
website/docs/scripting.md
Normal file
89
website/docs/scripting.md
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
---
|
||||||
|
nav_order: 900
|
||||||
|
---
|
||||||
|
|
||||||
|
# Scripting aider
|
||||||
|
|
||||||
|
You can script aider via the command line or python.
|
||||||
|
|
||||||
|
## Command line
|
||||||
|
|
||||||
|
Aider takes a `--message` argument, where you can give it a natural language instruction.
|
||||||
|
It will do that one thing, apply the edits to the files and then exit.
|
||||||
|
So you could do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
aider --message "make a script that prints hello" hello.js
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you can write simple shell scripts to apply the same instruction to many files:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
for FILE in *.py ; do
|
||||||
|
aider --message "add descriptive docstrings to all the functions" $FILE
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
User `aider --help` to see all the command line options, but these are useful for scripting:
|
||||||
|
|
||||||
|
```
|
||||||
|
--stream, --no-stream
|
||||||
|
Enable/disable streaming responses (default: True) [env var:
|
||||||
|
AIDER_STREAM]
|
||||||
|
--message COMMAND, --msg COMMAND, -m COMMAND
|
||||||
|
Specify a single message to send GPT, process reply then exit
|
||||||
|
(disables chat mode) [env var: AIDER_MESSAGE]
|
||||||
|
--message-file MESSAGE_FILE, -f MESSAGE_FILE
|
||||||
|
Specify a file containing the message to send GPT, process reply,
|
||||||
|
then exit (disables chat mode) [env var: AIDER_MESSAGE_FILE]
|
||||||
|
--yes Always say yes to every confirmation [env var: AIDER_YES]
|
||||||
|
--auto-commits, --no-auto-commits
|
||||||
|
Enable/disable auto commit of GPT changes (default: True) [env var:
|
||||||
|
AIDER_AUTO_COMMITS]
|
||||||
|
--dirty-commits, --no-dirty-commits
|
||||||
|
Enable/disable commits when repo is found dirty (default: True) [env
|
||||||
|
var: AIDER_DIRTY_COMMITS]
|
||||||
|
--dry-run, --no-dry-run
|
||||||
|
Perform a dry run without modifying files (default: False) [env var:
|
||||||
|
AIDER_DRY_RUN]
|
||||||
|
--commit Commit all pending changes with a suitable commit message, then exit
|
||||||
|
[env var: AIDER_COMMIT]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Python
|
||||||
|
|
||||||
|
You can also script aider from python:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from aider.coders import Coder
|
||||||
|
from aider.models import Model
|
||||||
|
|
||||||
|
# This is a list of files to add to the chat
|
||||||
|
fnames = ["greeting.py"]
|
||||||
|
|
||||||
|
model = Model("gpt-4-turbo", weak_model="gpt-3.5-turbo")
|
||||||
|
|
||||||
|
# Create a coder object
|
||||||
|
coder = Coder.create(main_model=model, fnames=fnames)
|
||||||
|
|
||||||
|
# This will execute one instruction on those files and then return
|
||||||
|
coder.run("make a script that prints hello world")
|
||||||
|
|
||||||
|
# Send another instruction
|
||||||
|
coder.run("make it say goodbye")
|
||||||
|
```
|
||||||
|
|
||||||
|
See the
|
||||||
|
[Coder.create() and Coder.__init__() methods](https://github.com/paul-gauthier/aider/blob/main/aider/coders/base_coder.py)
|
||||||
|
for all the supported arguments.
|
||||||
|
|
||||||
|
It can also be helpful to set the equivalend of `--yes` by doing this:
|
||||||
|
|
||||||
|
```
|
||||||
|
from aider.io import InputOutput
|
||||||
|
io = InputOutput(yes=True)
|
||||||
|
# ...
|
||||||
|
coder = Coder.create(client=client, fnames=fnames, io=io)
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue