Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,20 @@ def append_file(filepath, content):

try:
os.makedirs(os.path.dirname(abs_path), exist_ok=True)

# Check if the file currently exists and ensure it ends with a newline
prefix = ""
if os.path.exists(abs_path):
with open(abs_path, encoding="utf-8") as f:
current_content = f.read()
if current_content and not current_content.endswith("\n"):
prefix = "\n"

# Append the prefix, the content, and a trailing newline
with open(abs_path, "a", encoding="utf-8") as f:
f.write(content)
return f"[SUCCESS: File appended to {filepath}]"
f.write(prefix + content + "\n")

return f"[SUCCESS: Data appended to {filepath}]"
except Exception as e:
return f"[ERROR: Failed to append to {filepath} - {e}]"

Expand Down
2 changes: 1 addition & 1 deletion tests/evals/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_actual_file_io(tmp_path, monkeypatch) -> None:
# Test read_directory_contents
dir_res = read_directory_contents(str(docs_dir))
# SHIFT-LEFT: Updated test to check for the new XML caching tags
assert "--- FILE: test.md ---" in dir_res
assert '<document path="test.md">' in dir_res


def test_get_active_artifacts(tmp_path, monkeypatch) -> None:
Expand Down
Loading