mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
fences are obfuscated so aider can modify itself
This commit is contained in:
parent
d4d327e6d9
commit
58690da8b4
2 changed files with 21 additions and 19 deletions
|
@ -31,6 +31,10 @@ class ExhaustedContextWindow(Exception):
|
|||
pass
|
||||
|
||||
|
||||
def wrap_fence(name):
|
||||
return f"<{name}>", f"</{name}>"
|
||||
|
||||
|
||||
class Coder:
|
||||
abs_fnames = None
|
||||
repo = None
|
||||
|
@ -40,16 +44,6 @@ class Coder:
|
|||
functions = None
|
||||
total_cost = 0.0
|
||||
|
||||
fences = [
|
||||
("```", "```"),
|
||||
("<source>", "</source>"),
|
||||
("<code>", "</code>"),
|
||||
("<pre>", "</pre>"),
|
||||
("<codeblock>", "</codeblock>"),
|
||||
("<sourcecode>", "</sourcecode>"),
|
||||
]
|
||||
fence = fences[0]
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
self,
|
||||
|
@ -249,6 +243,17 @@ class Coder:
|
|||
|
||||
self.repo = repo
|
||||
|
||||
# fences are obfuscated so aider can modify this file!
|
||||
fences = [
|
||||
("``" + "`", "``" + "`"),
|
||||
wrap_fence("source"),
|
||||
wrap_fence("code"),
|
||||
wrap_fence("pre"),
|
||||
wrap_fence("codeblock"),
|
||||
wrap_fence("sourcecode"),
|
||||
]
|
||||
fence = fences[0]
|
||||
|
||||
def choose_fence(self):
|
||||
all_content = ""
|
||||
for fname in self.abs_fnames:
|
||||
|
@ -256,13 +261,11 @@ class Coder:
|
|||
|
||||
all_content = all_content.splitlines()
|
||||
|
||||
for fence_open, fence_close in self.fences:
|
||||
good = True
|
||||
for line in all_content:
|
||||
if line.startswith(fence_open) or line.startswith(fence_close):
|
||||
good = False
|
||||
break
|
||||
if good:
|
||||
for fence_open, fence_close in self.fences:
|
||||
if fence_open in all_content or fence_close in all_content:
|
||||
continue
|
||||
good = True
|
||||
break
|
||||
|
||||
if good:
|
||||
|
|
|
@ -47,8 +47,8 @@ def diff_partial_update(lines_orig, lines_updated, final=False, fname=None):
|
|||
partially complete update.
|
||||
"""
|
||||
|
||||
dump(lines_orig)
|
||||
dump(lines_updated)
|
||||
# dump(lines_orig)
|
||||
# dump(lines_updated)
|
||||
|
||||
assert_newlines(lines_orig)
|
||||
assert_newlines(lines_orig)
|
||||
|
@ -100,7 +100,6 @@ def diff_partial_update(lines_orig, lines_updated, final=False, fname=None):
|
|||
|
||||
# print(diff)
|
||||
|
||||
dump(repr(show))
|
||||
return show
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue