feat: add auto copy context feature with empty implementation

This commit is contained in:
Paul Gauthier 2024-12-05 20:35:02 -08:00 committed by Paul Gauthier (aider)
parent 87dbb56d7e
commit 75d8982b23

View file

@ -286,6 +286,7 @@ class Coder:
detect_urls=True, detect_urls=True,
ignore_mentions=None, ignore_mentions=None,
file_watcher=None, file_watcher=None,
auto_copy_context=False,
): ):
# Fill in a dummy Analytics if needed, but it is never .enable()'d # Fill in a dummy Analytics if needed, but it is never .enable()'d
self.analytics = analytics if analytics is not None else Analytics() self.analytics = analytics if analytics is not None else Analytics()
@ -297,6 +298,8 @@ class Coder:
self.rejected_urls = set() self.rejected_urls = set()
self.abs_root_path_cache = {} self.abs_root_path_cache = {}
self.auto_copy_context = auto_copy_context
self.ignore_mentions = ignore_mentions self.ignore_mentions = ignore_mentions
if not self.ignore_mentions: if not self.ignore_mentions:
self.ignore_mentions = set() self.ignore_mentions = set()
@ -792,9 +795,9 @@ class Coder:
self.io.user_input(with_message) self.io.user_input(with_message)
self.run_one(with_message, preproc) self.run_one(with_message, preproc)
return self.partial_response_content return self.partial_response_content
while True: while True:
try: try:
self.copy_context()
user_message = self.get_input() user_message = self.get_input()
self.run_one(user_message, preproc) self.run_one(user_message, preproc)
self.show_undo_hint() self.show_undo_hint()
@ -803,6 +806,10 @@ class Coder:
except EOFError: except EOFError:
return return
def copy_context(self):
# run cmd_copy_context if self.auto-copy-context ai!
pass
def get_input(self): def get_input(self):
inchat_files = self.get_inchat_relative_files() inchat_files = self.get_inchat_relative_files()
read_only_files = [self.get_rel_fname(fname) for fname in self.abs_read_only_fnames] read_only_files = [self.get_rel_fname(fname) for fname in self.abs_read_only_fnames]
@ -1114,7 +1121,10 @@ class Coder:
# add the reminder anyway # add the reminder anyway
total_tokens = 0 total_tokens = 0
if chunks.cur:
final = chunks.cur[-1] final = chunks.cur[-1]
else:
final = None
max_input_tokens = self.main_model.info.get("max_input_tokens") or 0 max_input_tokens = self.main_model.info.get("max_input_tokens") or 0
# Add the reminder prompt if we still have room to include it. # Add the reminder prompt if we still have room to include it.
@ -1125,7 +1135,7 @@ class Coder:
): ):
if self.main_model.reminder == "sys": if self.main_model.reminder == "sys":
chunks.reminder = reminder_message chunks.reminder = reminder_message
elif self.main_model.reminder == "user" and final["role"] == "user": elif self.main_model.reminder == "user" and final and final["role"] == "user":
# stuff it into the user message # stuff it into the user message
new_content = ( new_content = (
final["content"] final["content"]