Skip to content

Commit 24ccbab

Browse files
authored
Merge pull request #138 from dwash96/v0.88.16
V0.88.16
2 parents c7bd262 + 42adc49 commit 24ccbab

5 files changed

Lines changed: 107 additions & 74 deletions

File tree

aider/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from packaging import version
22

3-
__version__ = "0.88.15.dev"
3+
__version__ = "0.88.16.dev"
44
safe_version = __version__
55

66
try:

aider/coders/base_coder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,7 @@ async def process_tool_calls(self, tool_call_response):
22272227
self._print_tool_call_info(server_tool_calls)
22282228

22292229
if await self.io.confirm_ask("Run tools?", group_response="Run MCP Tools"):
2230+
await self.io.recreate_input()
22302231
tool_responses = await self._execute_tool_calls(server_tool_calls)
22312232

22322233
# Add all tool responses
@@ -2512,7 +2513,7 @@ async def get_server_tools(server):
25122513
)
25132514
return (server.name, server_tools)
25142515
except Exception as e:
2515-
if server.name != "unnamed-server":
2516+
if server.name != "unnamed-server" and server.name != "local_tools":
25162517
self.io.tool_warning(f"Error initializing MCP server {server.name}: {e}")
25172518
return None
25182519

aider/commands.py

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,66 +1051,87 @@ def _handle_read_only_files(self, expanded_word, file_set, description=""):
10511051
file_set.remove(matched_file)
10521052
self.io.tool_output(f"Removed {description} file {matched_file} from the chat")
10531053

1054-
def cmd_drop(self, args=""):
1054+
async def cmd_drop(self, args=""):
10551055
"Remove files from the chat session to free up context space"
10561056

1057-
if not args.strip():
1058-
if self.original_read_only_fnames:
1059-
self.io.tool_output(
1060-
"Dropping all files from the chat session except originally read-only files."
1061-
)
1062-
else:
1063-
self.io.tool_output("Dropping all files from the chat session.")
1064-
self._drop_all_files()
1057+
try:
1058+
if not args.strip():
1059+
if self.original_read_only_fnames:
1060+
self.io.tool_output(
1061+
"Dropping all files from the chat session except originally read-only"
1062+
" files."
1063+
)
1064+
else:
1065+
self.io.tool_output("Dropping all files from the chat session.")
1066+
self._drop_all_files()
10651067

1066-
# Recalculate context block tokens after dropping all files
1067-
if hasattr(self.coder, "use_enhanced_context") and self.coder.use_enhanced_context:
1068-
if hasattr(self.coder, "_calculate_context_block_tokens"):
1069-
self.coder._calculate_context_block_tokens()
1070-
return
1068+
# Recalculate context block tokens after dropping all files
1069+
if hasattr(self.coder, "use_enhanced_context") and self.coder.use_enhanced_context:
1070+
if hasattr(self.coder, "_calculate_context_block_tokens"):
1071+
self.coder._calculate_context_block_tokens()
10711072

1072-
filenames = parse_quoted_filenames(args)
1073-
files_changed = False
1073+
return
10741074

1075-
for word in filenames:
1076-
# Expand tilde in the path
1077-
expanded_word = os.path.expanduser(word)
1075+
filenames = parse_quoted_filenames(args)
1076+
files_changed = False
10781077

1079-
# Handle read-only files
1080-
self._handle_read_only_files(
1081-
expanded_word, self.coder.abs_read_only_fnames, "read-only"
1082-
)
1083-
self._handle_read_only_files(
1084-
expanded_word, self.coder.abs_read_only_stubs_fnames, "read-only (stub)"
1085-
)
1078+
for word in filenames:
1079+
# Expand tilde in the path
1080+
expanded_word = os.path.expanduser(word)
10861081

1087-
# For editable files, use glob if word contains glob chars, otherwise use substring
1088-
if any(c in expanded_word for c in "*?[]"):
1089-
matched_files = self.glob_filtered_to_repo(expanded_word)
1090-
else:
1091-
# Use substring matching like we do for read-only files
1092-
matched_files = [
1093-
self.coder.get_rel_fname(f) for f in self.coder.abs_fnames if expanded_word in f
1094-
]
1082+
# Handle read-only files
1083+
self._handle_read_only_files(
1084+
expanded_word, self.coder.abs_read_only_fnames, "read-only"
1085+
)
1086+
self._handle_read_only_files(
1087+
expanded_word, self.coder.abs_read_only_stubs_fnames, "read-only (stub)"
1088+
)
10951089

1096-
if not matched_files:
1097-
matched_files.append(expanded_word)
1098-
1099-
for matched_file in matched_files:
1100-
abs_fname = self.coder.abs_root_path(matched_file)
1101-
if abs_fname in self.coder.abs_fnames:
1102-
self.coder.abs_fnames.remove(abs_fname)
1103-
self.io.tool_output(f"Removed {matched_file} from the chat")
1104-
files_changed = True
1105-
1106-
# Recalculate context block tokens if any files were changed and using agent mode
1107-
if (
1108-
files_changed
1109-
and hasattr(self.coder, "use_enhanced_context")
1110-
and self.coder.use_enhanced_context
1111-
):
1112-
if hasattr(self.coder, "_calculate_context_block_tokens"):
1113-
self.coder._calculate_context_block_tokens()
1090+
# For editable files, use glob if word contains glob chars, otherwise use substring
1091+
if any(c in expanded_word for c in "*?[]"):
1092+
matched_files = self.glob_filtered_to_repo(expanded_word)
1093+
else:
1094+
# Use substring matching like we do for read-only files
1095+
matched_files = [
1096+
self.coder.get_rel_fname(f)
1097+
for f in self.coder.abs_fnames
1098+
if expanded_word in f
1099+
]
1100+
1101+
if not matched_files:
1102+
matched_files.append(expanded_word)
1103+
1104+
for matched_file in matched_files:
1105+
abs_fname = self.coder.abs_root_path(matched_file)
1106+
if abs_fname in self.coder.abs_fnames:
1107+
self.coder.abs_fnames.remove(abs_fname)
1108+
self.io.tool_output(f"Removed {matched_file} from the chat")
1109+
files_changed = True
1110+
1111+
# Recalculate context block tokens if any files were changed and using agent mode
1112+
if (
1113+
files_changed
1114+
and hasattr(self.coder, "use_enhanced_context")
1115+
and self.coder.use_enhanced_context
1116+
):
1117+
if hasattr(self.coder, "_calculate_context_block_tokens"):
1118+
self.coder._calculate_context_block_tokens()
1119+
finally:
1120+
if self.coder.repo_map:
1121+
map_tokens = self.coder.repo_map.max_map_tokens
1122+
map_mul_no_files = self.coder.repo_map.map_mul_no_files
1123+
else:
1124+
map_tokens = 0
1125+
map_mul_no_files = 1
1126+
1127+
raise SwitchCoder(
1128+
edit_format=self.coder.edit_format,
1129+
summarize_from_coder=False,
1130+
from_coder=self.coder,
1131+
map_tokens=map_tokens,
1132+
map_mul_no_files=map_mul_no_files,
1133+
show_announcements=False,
1134+
)
11141135

11151136
def cmd_git(self, args):
11161137
"Run a git command (output excluded from chat)"

aider/io.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def without_input_history(func):
9494
"""Decorator to temporarily disable history saving for the prompt session buffer."""
9595

9696
@functools.wraps(func)
97-
def wrapper(self, *args, **kwargs):
97+
async def wrapper(self, *args, **kwargs):
9898
orig_buf_append = None
9999
try:
100100
orig_buf_append = self.prompt_session.default_buffer.append_to_history
@@ -105,7 +105,7 @@ def wrapper(self, *args, **kwargs):
105105
pass
106106

107107
try:
108-
return func(self, *args, **kwargs)
108+
return await func(self, *args, **kwargs)
109109
except Exception:
110110
raise
111111
finally:
@@ -340,6 +340,17 @@ def __init__(
340340
self.notifications = notifications
341341
self.verbose = verbose
342342

343+
# Variables used to interface with base_coder
344+
self.coder = None
345+
self.input_task = None
346+
self.processing_task = None
347+
348+
# State tracking for confirmation input
349+
self.confirmation_in_progress = False
350+
self.confirmation_acknowledgement = False
351+
self.confirmation_input_active = False
352+
self.saved_input_text = ""
353+
343354
if notifications and notifications_command is None:
344355
self.notifications_command = self.get_default_notification_command()
345356
else:
@@ -413,7 +424,6 @@ def __init__(
413424
self.dry_run = dry_run
414425

415426
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
416-
self.append_chat_history(f"\n# aider chat started at {current_time}\n\n")
417427

418428
self.is_dumb_terminal = is_dumb_terminal()
419429
self.is_tty = sys.stdout.isatty()
@@ -465,19 +475,9 @@ def __init__(
465475
self.file_watcher = file_watcher
466476
self.root = root
467477

468-
# Variables used to interface with base_coder
469-
self.coder = None
470-
self.input_task = None
471-
self.processing_task = None
472-
self.confirmation_in_progress = False
473-
self.confirmation_acknowledgement = False
474-
475-
# State tracking for confirmation input
476-
self.confirmation_input_active = False
477-
self.saved_input_text = ""
478-
479478
# Validate color settings after console is initialized
480479
self._validate_color_settings()
480+
self.append_chat_history(f"\n# aider chat started at {current_time}\n\n")
481481

482482
def _spinner_supports_unicode(self) -> bool:
483483
if not self.is_tty:
@@ -908,6 +908,8 @@ def get_continuation(width, line_number, is_soft_wrap):
908908
if self.clipboard_watcher:
909909
self.clipboard_watcher.stop()
910910

911+
line = line or ""
912+
911913
if line.strip("\r\n") and not multiline_input:
912914
stripped = line.strip("\r\n")
913915
if stripped == "{":
@@ -1012,6 +1014,13 @@ def user_input(self, inp, log_only=True):
10121014
if not log_only:
10131015
self.display_user_input(inp)
10141016

1017+
if (
1018+
len(inp) <= 1
1019+
or self.confirmation_in_progress
1020+
or self.get_confirmation_acknowledgement()
1021+
):
1022+
return
1023+
10151024
prefix = "####"
10161025
if inp:
10171026
hist = inp.splitlines()
@@ -1055,6 +1064,7 @@ def acknowledge_confirmation(self):
10551064
return outstanding_confirmation
10561065

10571066
@restore_multiline_async
1067+
@without_input_history
10581068
async def confirm_ask(
10591069
self,
10601070
*args,
@@ -1324,12 +1334,7 @@ def assistant_output(self, message, pretty=None):
13241334
if pretty is None:
13251335
pretty = self.pretty
13261336

1327-
if pretty:
1328-
show_resp = Markdown(
1329-
message, style=self.assistant_output_color, code_theme=self.code_theme
1330-
)
1331-
else:
1332-
show_resp = Text(message or "(empty response)")
1337+
show_resp = Text(message or "(empty response)")
13331338

13341339
self.stream_print(show_resp)
13351340

@@ -1487,6 +1492,9 @@ def toggle_multiline_mode(self):
14871492
)
14881493

14891494
def append_chat_history(self, text, linebreak=False, blockquote=False, strip=True):
1495+
if self.confirmation_in_progress or self.get_confirmation_acknowledgement():
1496+
return
1497+
14901498
if blockquote:
14911499
if strip:
14921500
text = text.strip()

aider/tools/grep.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ def _execute_grep(
116116
cmd_args.append("-n") # Line numbers for rg and grep
117117
# ag includes line numbers by default
118118

119+
if tool_name in ["rg"]:
120+
cmd_args.append("--heading") # Filename above output for ripgrep
121+
119122
# Context lines (Before and After)
120123
if context_before > 0:
121124
# All tools use -B for lines before

0 commit comments

Comments
 (0)