Skip to content

Devika is the first open-source implementation of an Agentic Software Engineer. Initially started as an open-source alternative to Devin.

Python

Update patcher.py (#364)

Ahmet0691e0d974867efe
diff --git a/src/agents/feature/feature.py b/src/agents/feature/feature.py
index 811e31f..eecef06 100644
--- a/src/agents/feature/feature.py
+++ b/src/agents/feature/feature.py
@@ -66,13 +66,13 @@ class Feature:
project_name = project_name.lower().replace(" ", "-")
for file in response:
- file_path = f"{self.project_dir}/{project_name}/{file['file']}"
- file_path_dir = file_path[:file_path.rfind("/")]
+ file_path = os.path.join(self.project_dir, project_name, file['file'])
+ file_path_dir = os.path.dirname(file_path)
os.makedirs(file_path_dir, exist_ok=True)
-
- with open(file_path, "w") as f:
- f.write(file["code"])
+ with open(file_path, "w", encoding="utf-8") as f:
+ f.write(file["code"])
+
return file_path_dir
def get_project_path(self, project_name: str):
diff --git a/src/agents/patcher/patcher.py b/src/agents/patcher/patcher.py
index 47fe6c8..0c019e0 100644
--- a/src/agents/patcher/patcher.py
+++ b/src/agents/patcher/patcher.py
@@ -69,15 +69,14 @@ class Patcher:
project_name = project_name.lower().replace(" ", "-")
for file in response:
- file_path = f"{self.project_dir}/{project_name}/{file['file']}"
- file_path_dir = file_path[:file_path.rfind("/")]
+ file_path = os.path.join(self.project_dir, project_name, file['file'])
+ file_path_dir = os.path.dirname(file_path)
os.makedirs(file_path_dir, exist_ok=True)
-
- with open(file_path, "w") as f:
+
+ with open(file_path, "w", encoding="utf-8") as f:
f.write(file["code"])
return file_path_dir
-
def get_project_path(self, project_name: str):
project_name = project_name.lower().replace(" ", "-")
return f"{self.project_dir}/{project_name}"