Merge pull request #2798 from schpet/improve-watch-description

This commit is contained in:
paul-gauthier 2025-01-07 15:02:52 -08:00 committed by GitHub
commit 155f397d0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,7 +3,7 @@ title: Aider in your IDE
#highlight_image: /assets/browser.jpg #highlight_image: /assets/browser.jpg
parent: Usage parent: Usage
nav_order: 750 nav_order: 750
description: Aider can run in your browser, not just on the command line. description: Aider can watch your files and respond to AI comments you add in your favorite IDE or text editor.
--- ---
# Aider in your IDE # Aider in your IDE
@ -34,7 +34,7 @@ description: Aider can run in your browser, not just on the command line.
## AI comments ## AI comments
If you run aider with `--watch-files`, it will watch all files in your repo If you run aider with `--watch-files`, it will watch all files in your repo
and look for any AI coding instructions you add using your favorite IDE or text editor. and look for any AI coding instructions you add using your favorite IDE or text editor.
Specifically, aider looks for one-liner comments (# ... or // ...) that either start or end with `AI`, `AI!` or `AI?` like these: Specifically, aider looks for one-liner comments (# ... or // ...) that either start or end with `AI`, `AI!` or `AI?` like these:
@ -52,14 +52,14 @@ Or in `//` comment languages...
Aider will take note of all the comments that start or end with `AI`. Aider will take note of all the comments that start or end with `AI`.
Comments that include `AI!` with an exclamation point or `AI?` with a question Comments that include `AI!` with an exclamation point or `AI?` with a question
mark are special. mark are special.
They triggers aider to take action to collect *all* the AI comments and use them They triggers aider to take action to collect *all* the AI comments and use them
as your instructions. as your instructions.
- `AI!` triggers aider to make changes to your code. - `AI!` triggers aider to make changes to your code.
- `AI?` triggers aider to answer your question. - `AI?` triggers aider to answer your question.
See the demo video above that shows aider working with AI comments in VSCode. See the demo video above that shows aider working with AI comments in VSCode.
## Example ## Example
@ -88,8 +88,8 @@ Aider only watches for these types of **one-liner** comments:
``` ```
# Python and bash style # Python and bash style
// Javascript style // Javascript style
-- SQL style -- SQL style
``` ```
Aider will look for those comment types in all files. Aider will look for those comment types in all files.
@ -102,7 +102,7 @@ This capability is quite flexible and powerful, and can be used in many ways.
### In-context instructions ### In-context instructions
You can add an AI comment in the function you want changed, You can add an AI comment in the function you want changed,
explaining the change request in-context right where you want the changes. explaining the change request in-context right where you want the changes.
```javascript ```javascript
@ -129,15 +129,15 @@ Just use `AI!` last, to trigger aider.
def factorial(n): def factorial(n):
if n < 0: if n < 0:
return jsonify(error="Factorial is not defined for negative numbers"), 400 return jsonify(error="Factorial is not defined for negative numbers"), 400
# AI: Refactor this code... # AI: Refactor this code...
result = 1 result = 1
for i in range(1, n + 1): for i in range(1, n + 1):
result *= i result *= i
# ... into to a compute_factorial() function. AI! # ... into to a compute_factorial() function. AI!
return jsonify(result=result) return jsonify(result=result)
``` ```
@ -180,7 +180,7 @@ many of aider's more advanced features:
- Use `/undo` to revert changes you don't like. Although you may also be able to use your IDE's undo function to step back in the file history. - Use `/undo` to revert changes you don't like. Although you may also be able to use your IDE's undo function to step back in the file history.
- Use [chat modes](https://aider.chat/docs/usage/modes.html) to ask questions or get help. - Use [chat modes](https://aider.chat/docs/usage/modes.html) to ask questions or get help.
- Manage the chat context with `/tokens`, `/clear`, `/drop`, `/reset`. - Manage the chat context with `/tokens`, `/clear`, `/drop`, `/reset`.
Adding an AI comment will add the file to the chat. Adding an AI comment will add the file to the chat.
Periodically, you may want remove extra context that is no longer needed. Periodically, you may want remove extra context that is no longer needed.
- [Fix lint and test errors](https://aider.chat/docs/usage/lint-test.html). - [Fix lint and test errors](https://aider.chat/docs/usage/lint-test.html).
- Run shell commands. - Run shell commands.
@ -194,14 +194,14 @@ comments with full sentences, proper capitalization, punctuation, etc.
This was done to help explain how AI comments work, but is not needed in practice. This was done to help explain how AI comments work, but is not needed in practice.
Most LLMs are perfectly capable of dealing with ambiguity and Most LLMs are perfectly capable of dealing with ambiguity and
inferring implied intent. inferring implied intent.
This often allows you to be quite lazy with your AI comments. This often allows you to be quite lazy with your AI comments.
In particular, you can start and end comments with lowercase `ai` and `ai!`, In particular, you can start and end comments with lowercase `ai` and `ai!`,
but you can also be much more terse with the request itself. but you can also be much more terse with the request itself.
Below are simpler versions of some of the examples given above. Below are simpler versions of some of the examples given above.
When the context clearly implies the needed action, `ai!` might be all you When the context clearly implies the needed action, `ai!` might be all you
need. For example, to implement a factorial function need. For example, to implement a factorial function
in a program full of other math functions either of these in a program full of other math functions either of these
approaches would probably work: approaches would probably work:
@ -237,15 +237,15 @@ Similarly, this refactor probably could have been requested with fewer words, li
def factorial(n): def factorial(n):
if n < 0: if n < 0:
return jsonify(error="Factorial is not defined for negative numbers"), 400 return jsonify(error="Factorial is not defined for negative numbers"), 400
# ai refactor... # ai refactor...
result = 1 result = 1
for i in range(1, n + 1): for i in range(1, n + 1):
result *= i result *= i
# ... to compute_factorial() ai! # ... to compute_factorial() ai!
return jsonify(result=result) return jsonify(result=result)
``` ```
@ -289,7 +289,6 @@ todo_app.py:
#### Credits #### Credits
*This feature was inspired by *This feature was inspired by
the way [Override](https://github.com/oi-overide) watches for file changes the way [Override](https://github.com/oi-overide) watches for file changes
to find prompts embedded within `//> a specific set of delimiters <//`.* to find prompts embedded within `//> a specific set of delimiters <//`.*