mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +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
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def wrap_fence(name):
|
||||||
|
return f"<{name}>", f"</{name}>"
|
||||||
|
|
||||||
|
|
||||||
class Coder:
|
class Coder:
|
||||||
abs_fnames = None
|
abs_fnames = None
|
||||||
repo = None
|
repo = None
|
||||||
|
@ -40,16 +44,6 @@ class Coder:
|
||||||
functions = None
|
functions = None
|
||||||
total_cost = 0.0
|
total_cost = 0.0
|
||||||
|
|
||||||
fences = [
|
|
||||||
("```", "```"),
|
|
||||||
("<source>", "</source>"),
|
|
||||||
("<code>", "</code>"),
|
|
||||||
("<pre>", "</pre>"),
|
|
||||||
("<codeblock>", "</codeblock>"),
|
|
||||||
("<sourcecode>", "</sourcecode>"),
|
|
||||||
]
|
|
||||||
fence = fences[0]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(
|
def create(
|
||||||
self,
|
self,
|
||||||
|
@ -249,6 +243,17 @@ class Coder:
|
||||||
|
|
||||||
self.repo = repo
|
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):
|
def choose_fence(self):
|
||||||
all_content = ""
|
all_content = ""
|
||||||
for fname in self.abs_fnames:
|
for fname in self.abs_fnames:
|
||||||
|
@ -256,13 +261,11 @@ class Coder:
|
||||||
|
|
||||||
all_content = all_content.splitlines()
|
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
|
good = False
|
||||||
break
|
for fence_open, fence_close in self.fences:
|
||||||
if good:
|
if fence_open in all_content or fence_close in all_content:
|
||||||
|
continue
|
||||||
|
good = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if good:
|
if good:
|
||||||
|
|
|
@ -47,8 +47,8 @@ def diff_partial_update(lines_orig, lines_updated, final=False, fname=None):
|
||||||
partially complete update.
|
partially complete update.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
dump(lines_orig)
|
# dump(lines_orig)
|
||||||
dump(lines_updated)
|
# dump(lines_updated)
|
||||||
|
|
||||||
assert_newlines(lines_orig)
|
assert_newlines(lines_orig)
|
||||||
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)
|
# print(diff)
|
||||||
|
|
||||||
dump(repr(show))
|
|
||||||
return show
|
return show
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue