mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 01:04:59 +00:00
refac
This commit is contained in:
parent
41f126cad7
commit
5c4b75909e
1 changed files with 25 additions and 6 deletions
31
aider/io.py
31
aider/io.py
|
@ -377,13 +377,11 @@ class InputOutput:
|
||||||
):
|
):
|
||||||
if changed:
|
if changed:
|
||||||
self.changed_files = changed
|
self.changed_files = changed
|
||||||
|
|
||||||
# ai move all this ...
|
|
||||||
self.changed_files = process_file_changes(changed)
|
|
||||||
self.interrupt_input()
|
self.interrupt_input()
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.tool_error(f"File watcher error: {e}")
|
self.tool_error(f"File watcher error: {e}")
|
||||||
|
raise e
|
||||||
|
|
||||||
# Start the watcher thread
|
# Start the watcher thread
|
||||||
watcher = threading.Thread(target=watch_files, daemon=True)
|
watcher = threading.Thread(target=watch_files, daemon=True)
|
||||||
|
@ -447,11 +445,10 @@ class InputOutput:
|
||||||
|
|
||||||
# Check if we were interrupted by a file change
|
# Check if we were interrupted by a file change
|
||||||
if self.changed_files:
|
if self.changed_files:
|
||||||
# ai ...down to here!
|
res = process_file_changes(self.changed_files)
|
||||||
changed = " ".join(self.changed_files)
|
|
||||||
self.changed_files = None
|
self.changed_files = None
|
||||||
|
return res
|
||||||
|
|
||||||
return f"/add {changed}" # Return an edit command for the changed file
|
|
||||||
except EOFError:
|
except EOFError:
|
||||||
return ""
|
return ""
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -770,3 +767,25 @@ def get_rel_fname(fname, root):
|
||||||
return os.path.relpath(fname, root)
|
return os.path.relpath(fname, root)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return fname
|
return fname
|
||||||
|
|
||||||
|
|
||||||
|
def process_file_changes(changed):
|
||||||
|
"""Process file changes and handle special ! comments"""
|
||||||
|
|
||||||
|
has_bangs = any(
|
||||||
|
"!" in comment for comments in changed.values() if comments for comment in comments
|
||||||
|
)
|
||||||
|
|
||||||
|
if not has_bangs:
|
||||||
|
return "/add " + " ".join(changed.keys())
|
||||||
|
|
||||||
|
res = "\n".join(comment for comments in changed.values() if comments for comment in comments)
|
||||||
|
res = """The "ai" comments below can be found in the code above.
|
||||||
|
They contain your instructions.
|
||||||
|
Make the requested changes.
|
||||||
|
Also remove all these comments from the code.
|
||||||
|
|
||||||
|
""" + res
|
||||||
|
|
||||||
|
dump(res)
|
||||||
|
return res
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue