Skip to content

Commit 353d144

Browse files
committed
copy
1 parent 9930057 commit 353d144

File tree

2 files changed

+73
-4
lines changed

2 files changed

+73
-4
lines changed

aider/watch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ def process_changes(self):
171171

172172
self.io.tool_output("Processing your request...")
173173

174-
res = """The "ai" comments below can be found in the code files I've shared with you.
174+
res = """The "AI" comments below can be found in the code files I've shared with you.
175175
They contain your instructions.
176176
Make the requested changes.
177-
Be sure to remove all these "ai" comments from the code!
177+
Be sure to remove all these "AI" comments from the code!
178178
179179
"""
180180

aider/website/docs/usage/watch.md

+71-2
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ and look for any AI coding instructions you add using your favorite IDE or text
3939

4040
Specifically, aider looks for one-liner comments (# ... or // ...) that either start or end with `AI` or `AI!`, like these:
4141

42-
```
42+
```python
4343
# Implement a snake game. AI!
44+
```
4445

46+
Or in `//` comment languages...
47+
48+
```js
4549
// Write a self-learning protein folding prediction engine. AI!
4650
```
4751

48-
Aider will take note of all the comments you add that start or end with `AI`, but
52+
Aider will take note of all the comments that start or end with `AI`, but
4953
a comment that includes `AI!` with an exclamation point is special.
5054
That triggers aider to take action to collect *all* the AI comments and use them as instructions to make code changes.
5155

@@ -142,3 +146,68 @@ simply put an `#AI` comment in it and save the file.
142146
You can undo/remove the comment immediately if you like, the file
143147
will still be added to the aider chat.
144148

149+
150+
### You can be lazy
151+
152+
The comments in the examples above all show AI
153+
comments with full sentences, proper capitalization, punctuation, etc.
154+
This was done for clarity, but is not needed in practice.
155+
156+
Most LLMs are perfectly capable of dealing with ambiguity and
157+
inferring implied intent.
158+
This often allows you to be quite lazy with your AI comments.
159+
In particular, you can start and end comments with lowercase `ai` and `ai!`,
160+
but you can also be much more terse with the request itself.
161+
Below are simpler versions of some of the examples given above.
162+
163+
When the context clearly implies the needed action, `ai!` might be all you
164+
need. For example, to implement a factorial function
165+
in a program full of other math functions either of these
166+
approaches would probably work:
167+
168+
```js
169+
function factorial(n) // ai!
170+
```
171+
172+
Or...
173+
174+
```js
175+
// add factorial() ai!
176+
```
177+
178+
Rather than a long, explicit comment like "Add error handling for NaN and less than zero,"
179+
you can let aider infer more about the request.
180+
This simpler comment may be sufficient:
181+
182+
```javascript
183+
app.get('/sqrt/:n', (req, res) => {
184+
const n = parseFloat(req.params.n);
185+
186+
// add error handling ai!
187+
188+
const result = math.sqrt(n);
189+
res.json({ result: result });
190+
});
191+
```
192+
193+
Similarly, this refactor probably could have been requested with fewer words, like this:
194+
195+
```python
196+
@app.route('/factorial/<int:n>')
197+
def factorial(n):
198+
if n < 0:
199+
return jsonify(error="Factorial is not defined for negative numbers"), 400
200+
201+
# ai refactor...
202+
203+
result = 1
204+
for i in range(1, n + 1):
205+
result *= i
206+
207+
# ... to compute_factorial() ai!
208+
209+
return jsonify(result=result)
210+
```
211+
212+
As you use aider with your chosen LLM, you can develop a sense for how
213+
explicit you need to make your AI comments.

0 commit comments

Comments
 (0)