Commit graph

79 commits

Author SHA1 Message Date
Paul Gauthier (aider)
4537e1a9f5 feat: Add shell command to input history before execution 2024-08-21 05:17:18 -07:00
Paul Gauthier (aider)
0006d70a7c style: Fix import order and formatting in editblock_coder.py 2024-08-20 19:25:13 -07:00
Paul Gauthier (aider)
4917054518 fix: Implement portable way to run interactive subprocesses 2024-08-20 19:25:09 -07:00
Paul Gauthier (aider)
15ebdcc45c fix: run subprocess with no stdin 2024-08-20 19:21:07 -07:00
Paul Gauthier
fd5eb164b5 bold the command 2024-08-20 18:52:38 -07:00
Paul Gauthier
fa7be35ec9 fix: Handle errors in EditBlockCoder more gracefully 2024-08-20 17:33:23 -07:00
Paul Gauthier (aider)
b229661d0a style: Format code with linter 2024-08-20 17:31:40 -07:00
Paul Gauthier (aider)
359e4129c6 fix: Combine stdout and stderr, output directly without additional messages 2024-08-20 17:31:36 -07:00
Paul Gauthier
8d0c2b1667 fix: Remove unnecessary debug statements and improve shell command confirmation prompt 2024-08-20 17:31:34 -07:00
Paul Gauthier (aider)
7bcd6d4ebb style: format code with linter 2024-08-20 17:28:08 -07:00
Paul Gauthier (aider)
6f0d9a09df feat: Implement shell command execution in EditBlockCoder 2024-08-20 17:28:04 -07:00
Paul Gauthier
682294118d fix: Dump edits in EditBlockCoder 2024-08-20 17:28:03 -07:00
Paul Gauthier (aider)
9f3cdf1a94 fix: Remove unused variable shell_type 2024-08-20 17:04:34 -07:00
Paul Gauthier
347f3fe140 fix: Handle case where edit path is None 2024-08-20 17:04:27 -07:00
Paul Gauthier (aider)
72bc851ac0 fix: Implement line-by-line processing for SEARCH/REPLACE and shell code blocks 2024-08-20 16:23:07 -07:00
Paul Gauthier
f198c4a691 fix: Add debug logging to EditBlockCoder 2024-08-20 16:23:06 -07:00
Paul Gauthier (aider)
574efcd35d fix: Handle shell commands in apply_edits method 2024-08-20 13:40:28 -07:00
Paul Gauthier (aider)
5f4d6bc4a5 feat: Add support for executing shell commands in apply_edits 2024-08-20 13:31:14 -07:00
Paul Gauthier
c4855c84da fix: Remove unnecessary metadata from EditBlockCoder 2024-08-20 13:31:13 -07:00
Paul Gauthier (aider)
a0f9989f1c style: format shell code block starts 2024-08-20 13:28:48 -07:00
Paul Gauthier (aider)
64b92c8d89 feat: Expand support for commonly used shells 2024-08-20 13:28:44 -07:00
Paul Gauthier (aider)
7ebbb3d4f4 fix: Expand code block detection to support various Windows shells 2024-08-20 13:28:10 -07:00
Paul Gauthier (aider)
3984716608 style: Apply linter formatting changes 2024-08-20 13:26:31 -07:00
Paul Gauthier (aider)
9dea3f48cb feat: Add support for scanning and yielding ```bash blocks in find_original_update_blocks 2024-08-20 13:26:27 -07:00
Your Name (aider)
45af678026 Update class docstrings to refer to "search/replace blocks" instead of "edit blocks" 2024-07-28 20:20:13 -03:00
Your Name (aider)
0ff1c36668 Add concise docstrings to each xxxCoder class describing their purpose. 2024-07-28 20:19:22 -03:00
Your Name (aider)
5fcf454968 Remove __init__ from all coders and set edit_format and gpt_prompts like ChatCoder 2024-07-28 18:43:14 -03:00
Paul Gauthier
b678e26281 Don't ask LLM are you sure about S/R blocks with null R section #835 2024-07-12 17:18:59 +01:00
Paul Gauthier
7be08c782c Tell Sonnet to make concise SEARCH/REPLACE blocks #705 2024-06-23 17:24:14 -07:00
Paul Gauthier
4fd61f1112 More flexible filename search for deepseek coder v2 2024-06-21 08:51:53 -07:00
Paul Gauthier
819fccc7a4 added temp param, prompt strong that files message is truth 2024-05-16 08:52:30 -07:00
Paul Gauthier
6638efbee4 better prompting for LLM to suggest files 2024-05-14 06:02:16 -07:00
Paul Gauthier
eea8e50c60 ask llm are you sure? when REPLACE exists 2024-05-11 16:56:14 -07:00
Paul Gauthier
90c0a5b9a4 reflect multiple messages; do not strip edit error messages 2024-05-11 16:40:37 -07:00
Paul Gauthier
cd78080fa5 on search/replace error ask the LLM did you mean? 2024-05-11 15:02:22 -07:00
Paul Gauthier
6c45b58698 aider: Implemented find_similar_lines to fuzzy search content and return closest matching contiguous chunk of lines.
# Aider chat conversation:

USER: implement `find_similar_lines` which will fuzzy search the content for the original lines and return the contiguous chunk of lines from content which are the closest match

ASSISTANT: Here is the implementation of `find_similar_lines` to fuzzy search the content and return the closest matching contiguous chunk of lines:

aider/coders/editblock_coder.py
<source>python
<<<<<<< SEARCH
    #did_you_mean = find_similar_lines(original, content)
=======
    did_you_mean = find_similar_lines(original, content)
>>>>>>> REPLACE
</source>

aider/coders/editblock_coder.py
<source>python
<<<<<<< SEARCH
=======
def find_similar_lines(search_lines, content_lines, threshold=0.8):
    search_lines = search_lines.splitlines()
    content_lines = content_lines.splitlines()

    best_ratio = 0
    best_match = None

    for i in range(len(content_lines) - len(search_lines) + 1):
        chunk = content_lines[i:i+len(search_lines)]
        ratio = SequenceMatcher(None, search_lines, chunk).ratio()
        if ratio > best_ratio:
            best_ratio = ratio
            best_match = chunk

    if best_ratio >= threshold:
        return "\n".join(best_match)
    else:
        return ""
>>>>>>> REPLACE
</source>

This adds the `find_similar_lines` function which:

1. Splits the search lines and content lines on newlines
2. Iterates through the content lines, considering each contiguous chunk the same length as the search lines
3. Calculates the SequenceMatcher ratio between the search lines and each chunk
4. Keeps track of the chunk with the highest ratio
5. If the best ratio is above the threshold (default 0.8), it returns the best matching chunk joined back into a string
6. Otherwise it returns an empty string to indicate no close enough match was found

It also uncomments the line to call `find_similar_lines` and store the result in `did_you_mean`.

Let me know if you have any other questions!
2024-05-11 10:49:34 -07:00
Paul Gauthier
056dae6530 Removed unused find_similar_lines function call from EditBlockCoder class. 2024-05-11 10:49:33 -07:00
Paul Gauthier
fd6f31f972 Replaced find_similar_text with find_similar_lines in editblock_coder.py. 2024-05-11 10:48:45 -07:00
Paul Gauthier
d02506db16 aider: Implemented find_similar_text function to fuzzy search the content for the closest match to the original text.
# Aider chat conversation:

USER: I did `git reset --hard HEAD~1` to discard the last edits. Please wait for further instructions before attempting that change again. Feel free to ask relevant questions about why the changes were reverted.

ASSISTANT: I understand you reverted the previous changes. Before I attempt to implement the `find_similar_lines` function again, I have a few questions to ensure I follow your guidelines correctly:

1. When proposing changes, should I only modify the `aider/coders/editblock_coder.py` file since that is the only one you have explicitly added to the chat
^C KeyboardInterrupt

USER: implement `find_similar_text` which will fuzzy search the content for the original text and return the part of content which is the closest match

ASSISTANT: Here is the implementation of `find_similar_text` to fuzzy search the content for the closest match to the original text:

aider/coders/editblock_coder.py
<source>python
<<<<<<< SEARCH
=======
from difflib import SequenceMatcher

def find_similar_text(original, content):
    content_len = len(content)
    original_len = len(original)

    best_ratio = 0
    best_match = None

    for i in range(content_len - original_len + 1):
        chunk = content[i:i+original_len]
        ratio = SequenceMatcher(None, original, chunk).ratio()

        if ratio > best_ratio:
            best_ratio = ratio
            best_match = chunk

    return best_match
>>>>>>> REPLACE
</source>

This function:

1. Iterates through the content, considering each chunk of text the same length as the original
2. Calculates the SequenceMatcher ratio between the original text and each chunk
3. Keeps track of the chunk with the highest ratio
4. Returns the chunk of content that best matches the original text

It will return the portion of `content` that is the closest fuzzy match to `original`.

Let me know if you have any other questions!
2024-05-11 10:43:40 -07:00
Paul Gauthier
6d39e2c857 Replaced find_similar_lines with find_similar_text in the EditBlockCoder class. 2024-05-11 10:43:38 -07:00
Paul Gauthier
587ba4d676 Added functionality to suggest similar lines when a search block fails to match in EditBlockCoder. 2024-05-11 10:38:44 -07:00
Paul Gauthier
785259b59c try patching any of the other files in the chat 2024-05-11 10:33:46 -07:00
Paul Gauthier
5ec441dd2c More clear feedback when SEARCH/REPLACE blocks fail to match 2024-05-11 10:25:16 -07:00
Paul Gauthier
f4b1797998 put filename back outside fences 2024-05-01 11:59:23 -07:00
Paul Gauthier
cd838901d1 Added improved editing support for command-r-plus 2024-04-20 16:53:27 -07:00
Paul Gauthier
360846320f announce the edit format 2023-12-17 12:58:48 -08:00
Paul Gauthier
2609ec1b06 find_original_update_blocks now accepts fence param, raises on mangled <source>filename.ext #317 2023-11-02 12:05:39 -07:00
Paul Gauthier
15d3a5d581 Switch from "edit block" to "search/replace block"
Succeeded in tricky task in the grep-ast codebase:
- checkout ed714ffe58734 / tricky-search-and-replace-state
- "read and parse .gitignore once, not each time we recurse `enumerate_files`"
- was having a lot of trouble creating a head/updated block that matched the actual source code
- new search/replace block does much better

Benchmark had *best* try 1 result and *lowest* num_error_outputs ever seen on gpt-4-0613.
Low num_error_outputs means it's less likely to elide/... code in the before block (original/search).

──────────── tmp.benchmarks/2023-10-25-22-03-19--search-and-replace-and-think ─────────────
test-cases: 133
model: gpt-4
edit_format: diff
commit_hash: c9c2ddb
num_error_outputs: 6
num_user_asks: 0
num_exhausted_context_windows 0
test_timeouts: 2

50.4% correct after try 0
66.2% correct after try 1
2023-10-25 15:24:03 -07:00
Paul Gauthier
3299d90317 Handle successive editblocks from same file w/o filename #267 2023-10-22 11:28:22 -07:00
Paul Gauthier
e608a351f0 standardize on abs_root_path(), simplify get/apply_edit 2023-08-18 07:20:15 -07:00