Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

feat: add software team tool lib

莘权 马a994716eb2e9
diff --git a/metagpt/context.py b/metagpt/context.py
index 4596e7847..09e6ec2f9 100644
--- a/metagpt/context.py
+++ b/metagpt/context.py
@@ -82,8 +82,6 @@ class Context(BaseModel):
def set_repo_dir(self, path: str | Path):
repo_path = Path(path)
- if not repo_path.exists():
- return
self.git_repo = GitRepository(local_path=repo_path, auto_init=True)
self.repo = ProjectRepo(self.git_repo)
diff --git a/metagpt/tools/libs/software_development.py b/metagpt/tools/libs/software_development.py
index 15fc6ad28..0db899f49 100644
--- a/metagpt/tools/libs/software_development.py
+++ b/metagpt/tools/libs/software_development.py
@@ -12,7 +12,7 @@ from metagpt.utils.common import any_to_str
@register_tool(tags=["software company", "ProductManager"])
-async def write_prd(idea: str, project_path: Optional[str | Path]) -> Path:
+async def write_prd(idea: str, project_path: Optional[str | Path] = None) -> Path:
"""Writes a PRD based on user requirements.
Args:
diff --git a/tests/metagpt/tools/libs/test_software_development.py b/tests/metagpt/tools/libs/test_software_development.py
new file mode 100644
index 000000000..d51fc3dc1
--- /dev/null
+++ b/tests/metagpt/tools/libs/test_software_development.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import pytest
+
+from metagpt.tools.libs import (
+ fix_bug,
+ git_archive,
+ run_qa_test,
+ write_codes,
+ write_design,
+ write_prd,
+ write_project_plan,
+)
+
+
+async def test_software_team():
+ path = await write_prd("snake game")
+ assert path
+
+ path = await write_design(path)
+ assert path
+
+ path = await write_project_plan(path)
+ assert path
+
+ path = await write_codes(path)
+ assert path
+
+ path = await run_qa_test(path)
+ assert path
+
+ issue = """
+pygame 2.0.1 (SDL 2.0.14, Python 3.9.17)
+Hello from the pygame community. https://www.pygame.org/contribute.html
+Traceback (most recent call last):
+ File "/Users/ix/github/bak/MetaGPT/workspace/snake_game/snake_game/main.py", line 10, in <module>
+ main()
+ File "/Users/ix/github/bak/MetaGPT/workspace/snake_game/snake_game/main.py", line 7, in main
+ game.start_game()
+ File "/Users/ix/github/bak/MetaGPT/workspace/snake_game/snake_game/game.py", line 81, in start_game
+ x
+NameError: name 'x' is not defined
+ """
+ path = await fix_bug(path, issue)
+ assert path
+
+ new_path = await write_prd("snake game with moving enemy", path)
+ assert new_path == path
+
+ git_log = await git_archive(new_path)
+ assert git_log
+
+
+if __name__ == "__main__":
+ pytest.main([__file__, "-s"])