🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
feat: + compatible with windows path
莘权 马51169d7a69f8
diff --git a/metagpt/actions/design_api.py b/metagpt/actions/design_api.pyindex 4060d211c..cb6013538 100644--- a/metagpt/actions/design_api.py+++ b/metagpt/actions/design_api.py@@ -46,7 +46,7 @@ class WriteDesign(Action):)async def run(self, with_messages: Message, schema: str = None):- # Use `git status` to identify which PRD documents have been modified in the `docs/prds` directory.+ # Use `git status` to identify which PRD documents have been modified in the `docs/prd` directory.changed_prds = self.repo.docs.prd.changed_files# Use `git status` to identify which design documents in the `docs/system_designs` directory have undergone# changes.diff --git a/metagpt/actions/prepare_documents.py b/metagpt/actions/prepare_documents.pyindex 84a4fc1d7..ab069dc11 100644--- a/metagpt/actions/prepare_documents.py+++ b/metagpt/actions/prepare_documents.py@@ -48,5 +48,5 @@ class PrepareDocuments(Action):# Write the newly added requirements from the main parameter idea to `docs/requirement.txt`.doc = await self.repo.docs.save(filename=REQUIREMENT_FILENAME, content=with_messages[0].content)# Send a Message notification to the WritePRD action, instructing it to process requirements using- # `docs/requirement.txt` and `docs/prds/`.+ # `docs/requirement.txt` and `docs/prd/`.return ActionOutput(content=doc.content, instruct_content=doc)diff --git a/metagpt/roles/engineer.py b/metagpt/roles/engineer.pyindex ee1a019bd..40ade2110 100644--- a/metagpt/roles/engineer.py+++ b/metagpt/roles/engineer.py@@ -178,7 +178,7 @@ class Engineer(Role):is_pass, reason = await self._is_pass(summary)if not is_pass:todo.i_context.reason = reason- tasks.append(todo.i_context.dict())+ tasks.append(todo.i_context.model_dump())await self.project_repo.docs.code_summary.save(filename=Path(todo.i_context.design_filename).name,diff --git a/metagpt/utils/dependency_file.py b/metagpt/utils/dependency_file.pyindex 7cf9a1d49..c8b3bc4a4 100644--- a/metagpt/utils/dependency_file.py+++ b/metagpt/utils/dependency_file.py@@ -9,6 +9,7 @@from __future__ import annotationsimport json+import refrom pathlib import Pathfrom typing import Set@@ -36,7 +37,9 @@ class DependencyFile:"""Load dependencies from the file asynchronously."""if not self._filename.exists():return- self._dependencies = json.loads(await aread(self._filename))+ json_data = await aread(self._filename)+ json_data = re.sub(r"\\+", "/", json_data) # Compatible with windows path+ self._dependencies = json.loads(json_data)@handle_exceptionasync def save(self):@@ -60,17 +63,20 @@ class DependencyFile:key = Path(filename).relative_to(root)except ValueError:key = filename-+ skey = re.sub(r"\\+", "/", str(key)) # Compatible with windows pathif dependencies:relative_paths = []for i in dependencies:try:- relative_paths.append(str(Path(i).relative_to(root)))+ s = str(Path(i).relative_to(root))except ValueError:- relative_paths.append(str(i))- self._dependencies[str(key)] = relative_paths- elif str(key) in self._dependencies:- del self._dependencies[str(key)]+ s = str(i)+ s = re.sub(r"\\+", "/", s) # Compatible with windows path+ relative_paths.append(s)++ self._dependencies[skey] = relative_paths+ elif skey in self._dependencies:+ del self._dependencies[skey]if persist:await self.save()diff --git a/metagpt/utils/file_repository.py b/metagpt/utils/file_repository.pyindex 94d6fe76d..d2a06963a 100644--- a/metagpt/utils/file_repository.py+++ b/metagpt/utils/file_repository.py@@ -101,21 +101,28 @@ class FileRepository:path_name = self.workdir / filenameif not path_name.exists():return None+ if not path_name.is_file():+ return Nonedoc.content = await aread(path_name)return doc- async def get_all(self) -> List[Document]:+ async def get_all(self, filter_ignored=True) -> List[Document]:"""Get the content of all files in the repository.:return: List of Document instances representing files."""docs = []- for root, dirs, files in os.walk(str(self.workdir)):- for file in files:- file_path = Path(root) / file- relative_path = file_path.relative_to(self.workdir)- doc = await self.get(relative_path)+ if filter_ignored:+ for f in self.all_files:+ doc = await self.get(f)docs.append(doc)+ else:+ for root, dirs, files in os.walk(str(self.workdir)):+ for file in files:+ file_path = Path(root) / file+ relative_path = file_path.relative_to(self.workdir)+ doc = await self.get(relative_path)+ docs.append(doc)return docs@property