Merge branch 'main' into chat-history

This commit is contained in:
Paul Gauthier 2023-07-21 07:44:09 -03:00
commit 6d044485f3
4 changed files with 19 additions and 10 deletions

View file

@ -2,6 +2,7 @@
### GitHub main branch ### GitHub main branch
- Updated keyboard interrupt logic so that 2 ^C in 2 seconds always forces aider to exit.
- Check pypi for newer versions and notify user. - Check pypi for newer versions and notify user.
- Provide GPT with detailed error if it makes a bad edit block, ask for a retry. - Provide GPT with detailed error if it makes a bad edit block, ask for a retry.
- Force `--no-pretty` if aider detects it is running inside a VSCode terminal. - Force `--no-pretty` if aider detects it is running inside a VSCode terminal.

View file

@ -155,6 +155,7 @@ For more information, see the [FAQ](https://aider.chat/docs/faq.html).
* *The best AI coding assistant so far.* -- [Matthew Berman](https://www.youtube.com/watch?v=df8afeb1FY8) * *The best AI coding assistant so far.* -- [Matthew Berman](https://www.youtube.com/watch?v=df8afeb1FY8)
* *Hands down, this is the best AI coding assistant tool so far.* -- [IndyDevDan](https://www.youtube.com/watch?v=MPYFPvxfGZs) * *Hands down, this is the best AI coding assistant tool so far.* -- [IndyDevDan](https://www.youtube.com/watch?v=MPYFPvxfGZs)
* *Aider ... has easily quadrupled my coding productivity.* -- [SOLAR_FIELDS](https://news.ycombinator.com/item?id=36212100) * *Aider ... has easily quadrupled my coding productivity.* -- [SOLAR_FIELDS](https://news.ycombinator.com/item?id=36212100)
* *It's really like having your senior developer live right in your Git repo - truly amazing!* -- [rappster](https://github.com/paul-gauthier/aider/issues/124)
* *What an amazing tool. It's incredible.* -- [valyagolev](https://github.com/paul-gauthier/aider/issues/6#issue-1722897858) * *What an amazing tool. It's incredible.* -- [valyagolev](https://github.com/paul-gauthier/aider/issues/6#issue-1722897858)
* *Aider is such an astounding thing!* -- [cgrothaus](https://github.com/paul-gauthier/aider/issues/82#issuecomment-1631876700) * *Aider is such an astounding thing!* -- [cgrothaus](https://github.com/paul-gauthier/aider/issues/82#issuecomment-1631876700)
* *It was WAY faster than I would be getting off the ground and making the first few working versions.* -- [Daniel Feldman](https://twitter.com/d_feldman/status/1662295077387923456) * *It was WAY faster than I would be getting off the ground and making the first few working versions.* -- [Daniel Feldman](https://twitter.com/d_feldman/status/1662295077387923456)

View file

@ -4,6 +4,7 @@ import hashlib
import json import json
import os import os
import sys import sys
import time
import traceback import traceback
from json.decoder import JSONDecodeError from json.decoder import JSONDecodeError
from pathlib import Path, PurePosixPath from pathlib import Path, PurePosixPath
@ -46,6 +47,7 @@ class Coder:
functions = None functions = None
total_cost = 0.0 total_cost = 0.0
num_exhausted_context_windows = 0 num_exhausted_context_windows = 0
last_keyboard_interrupt = None
@classmethod @classmethod
def create( def create(
@ -120,7 +122,6 @@ class Coder:
self.abs_fnames = set() self.abs_fnames = set()
self.cur_messages = [] self.cur_messages = []
self.done_messages = [] self.done_messages = []
self.num_control_c = 0
self.io = io self.io = io
self.stream = stream self.stream = stream
@ -395,13 +396,22 @@ class Coder:
return return
except KeyboardInterrupt: except KeyboardInterrupt:
self.num_control_c += 1 self.keyboard_interrupt()
if self.num_control_c >= 2:
break
self.io.tool_error("^C again or /exit to quit")
except EOFError: except EOFError:
return return
def keyboard_interrupt(self):
now = time.time()
thresh = 2 # seconds
if self.last_keyboard_interrupt and now - self.last_keyboard_interrupt < thresh:
self.io.tool_error("\n\n^C KeyboardInterrupt")
sys.exit()
self.io.tool_error("\n\n^C again to exit")
self.last_keyboard_interrupt = now
def should_dirty_commit(self, inp): def should_dirty_commit(self, inp):
cmds = self.commands.matching_commands(inp) cmds = self.commands.matching_commands(inp)
if cmds: if cmds:
@ -438,8 +448,6 @@ class Coder:
self.commands, self.commands,
) )
self.num_control_c = 0
if self.should_dirty_commit(inp): if self.should_dirty_commit(inp):
self.io.tool_output("Git repo has uncommitted changes, preparing commit...") self.io.tool_output("Git repo has uncommitted changes, preparing commit...")
self.commit(ask=True, which="repo_files") self.commit(ask=True, which="repo_files")
@ -521,8 +529,6 @@ class Coder:
content = "" content = ""
if interrupted: if interrupted:
self.io.tool_error("\n\n^C KeyboardInterrupt")
self.num_control_c += 1
content += "\n^C KeyboardInterrupt" content += "\n^C KeyboardInterrupt"
self.io.tool_output() self.io.tool_output()
@ -673,6 +679,7 @@ class Coder:
else: else:
self.show_send_output(completion, silent) self.show_send_output(completion, silent)
except KeyboardInterrupt: except KeyboardInterrupt:
self.keyboard_interrupt()
interrupted = True interrupted = True
if not silent: if not silent:

View file

@ -531,7 +531,7 @@ def run_test(
coder.run(with_message=instructions) coder.run(with_message=instructions)
dur += time.time() - start dur += time.time() - start
if coder.num_control_c: if coder.last_keyboard_interrupt:
raise KeyboardInterrupt raise KeyboardInterrupt
if no_unit_tests: if no_unit_tests: