feat: Add autocomplete support for /read-only command

This commit is contained in:
Paul Gauthier 2024-09-28 15:14:35 -07:00 committed by Paul Gauthier (aider)
parent d1ee3644ec
commit 97ddcb2ae6
3 changed files with 21 additions and 9 deletions

View file

@ -14,6 +14,7 @@
- ModelSettings takes `extra_params` dict to specify any extras to pass to `litellm.completion()`. - ModelSettings takes `extra_params` dict to specify any extras to pass to `litellm.completion()`.
- Renamed `/clipboard` to `/paste`. - Renamed `/clipboard` to `/paste`.
- New `/copy` command to copy the last LLM response to the clipboard. - New `/copy` command to copy the last LLM response to the clipboard.
- Autocomplete for `/read-only` supports the entire filesystem.
- Support for litellm's `extra_body` parameter. - Support for litellm's `extra_body` parameter.
- Support for cursor shapes when in vim mode. - Support for cursor shapes when in vim mode.
- Numerous bug fixes. - Numerous bug fixes.

View file

@ -789,7 +789,9 @@ class Coder:
group = ConfirmGroup(urls) group = ConfirmGroup(urls)
for url in urls: for url in urls:
if url not in self.rejected_urls: if url not in self.rejected_urls:
if self.io.confirm_ask("Add URL to the chat?", subject=url, group=group): if self.io.confirm_ask(
"Add URL to the chat?", subject=url, group=group, allow_never=True
):
inp += "\n\n" inp += "\n\n"
inp += self.commands.cmd_web(url) inp += self.commands.cmd_web(url)
added_urls.append(url) added_urls.append(url)
@ -1380,7 +1382,7 @@ class Coder:
added_fnames = [] added_fnames = []
group = ConfirmGroup(new_mentions) group = ConfirmGroup(new_mentions)
for rel_fname in sorted(new_mentions): for rel_fname in sorted(new_mentions):
if self.io.confirm_ask(f"Add {rel_fname} to the chat?", group=group): if self.io.confirm_ask(f"Add {rel_fname} to the chat?", group=group, allow_never=True):
self.add_rel_fname(rel_fname) self.add_rel_fname(rel_fname)
added_fnames.append(rel_fname) added_fnames.append(rel_fname)
else: else:
@ -1957,7 +1959,11 @@ class Coder:
) )
prompt = "Run shell command?" if command_count == 1 else "Run shell commands?" prompt = "Run shell command?" if command_count == 1 else "Run shell commands?"
if not self.io.confirm_ask( if not self.io.confirm_ask(
prompt, subject="\n".join(commands), explicit_yes_required=True, group=group prompt,
subject="\n".join(commands),
explicit_yes_required=True,
group=group,
allow_never=True,
): ):
return return
@ -1976,7 +1982,7 @@ class Coder:
accumulated_output += f"Output from {command}\n{output}\n" accumulated_output += f"Output from {command}\n{output}\n"
if accumulated_output.strip() and not self.io.confirm_ask( if accumulated_output.strip() and not self.io.confirm_ask(
"Add command output to the chat?" "Add command output to the chat?", allow_never=True
): ):
accumulated_output = "" accumulated_output = ""

View file

@ -488,11 +488,15 @@ class InputOutput:
): ):
self.num_user_asks += 1 self.num_user_asks += 1
if question in self.never_prompts: question_id = (question, subject)
if question_id in self.never_prompts:
return False return False
if group and not group.show_group: if group and not group.show_group:
group = None group = None
if group:
allow_never = True
valid_responses = ["yes", "no"] valid_responses = ["yes", "no"]
options = " (Y)es/(N)o" options = " (Y)es/(N)o"
@ -503,8 +507,9 @@ class InputOutput:
options += "/(S)kip all" options += "/(S)kip all"
valid_responses.append("skip") valid_responses.append("skip")
if allow_never: if allow_never:
options += "/(X)Never" options += "/(D)on't ask again"
valid_responses.append("never") valid_responses.append("don't")
question += options + " [Yes]: " question += options + " [Yes]: "
if subject: if subject:
@ -555,8 +560,8 @@ class InputOutput:
res = res.lower()[0] res = res.lower()[0]
if res == "x" and allow_never: if res == "d" and allow_never:
self.never_prompts.add(question) self.never_prompts.add(question_id)
hist = f"{question.strip()} {res}" hist = f"{question.strip()} {res}"
self.append_chat_history(hist, linebreak=True, blockquote=True) self.append_chat_history(hist, linebreak=True, blockquote=True)
return False return False