Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.

Commit 561b48c

Browse files
authored
Merge pull request #930 from ATheorell/fix#928
potential fix for some/dir/ bug #928
2 parents c6dd523 + 02fd2cf commit 561b48c

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

gpt_engineer/preprompts/improve

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Take requests for changes to the supplied code, and then you MUST
88

99
You MUST format EVERY code change with an *edit block* like this:
1010
```python
11-
some/dir/example.py
11+
example.py
1212
<<<<<<< HEAD
1313
# some comment
1414
# Func to multiply
@@ -29,7 +29,7 @@ Also, in the class `DB`, we need to update the "SOMETHING"
2929

3030
OUTPUT:
3131
```python
32-
some/dir/example_1.py
32+
example_1.py
3333
<<<<<<< HEAD
3434
def mul(a,b)
3535
=======
@@ -38,7 +38,7 @@ some/dir/example_1.py
3838
```
3939

4040
```python
41-
some/dir/example_1.py
41+
example_1.py
4242
<<<<<<< HEAD
4343
def add_one(a,b):
4444
a = a+2
@@ -49,7 +49,7 @@ some/dir/example_1.py
4949
```
5050

5151
```python
52-
some/dir/example_2.py
52+
example_1.py
5353
<<<<<<< HEAD
5454
class DBS:
5555
db = 'aaa'
@@ -65,6 +65,8 @@ So edit blocks must be precise and unambiguous!
6565

6666
Every *edit block* must be fenced with ```CONTENT OF EDIT BLOCK``` with the correct code language.
6767

68+
The file name at the top of the edit block (example_1.py in the examples) is the relative path to the file.
69+
6870
The `HEAD` section must be an *exact set of sequential lines* from the file! This is very important. Otherwise the parser won't work.
6971
NEVER SKIP LINES in the `HEAD` section!
7072
NEVER ELIDE LINES AND REPLACE THEM WITH A COMMENT!

tests/ai_cache.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/core/test_chat_to_files.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,19 @@ class DBS:
183183
assert parsed == expected
184184

185185

186+
def test_apply_overwrite_existing_file(log_capture):
187+
edits = [Edit("existing_file.py", "", "print('Hello, World!')")]
188+
code = {"existing_file.py": "some content"}
189+
apply_edits(edits, code)
190+
assert code == {"existing_file.py": "print('Hello, World!')"}
191+
assert "file will be overwritten" in log_capture.messages[0]
192+
193+
186194
def test_apply_edit_new_file(log_capture):
187195
edits = [Edit("new_file.py", "", "print('Hello, World!')")]
188-
code = {"new_file.py": "some content"}
196+
code = {}
189197
apply_edits(edits, code)
190198
assert code == {"new_file.py": "print('Hello, World!')"}
191-
assert "file will be overwritten" in log_capture.messages[0]
192199

193200

194201
def test_apply_edit_no_match(log_capture):

0 commit comments

Comments
 (0)