mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-02 14:45:17 +02:00
fixbug: source code path
This commit is contained in:
parent
dcdf643f1d
commit
f0ca7e6a8f
3 changed files with 20 additions and 13 deletions
|
|
@ -45,7 +45,12 @@ from metagpt.schema import (
|
|||
Documents,
|
||||
Message,
|
||||
)
|
||||
from metagpt.utils.common import any_to_name, any_to_str, any_to_str_set, aread
|
||||
from metagpt.utils.common import (
|
||||
any_to_name,
|
||||
any_to_str,
|
||||
any_to_str_set,
|
||||
get_project_srcs_path,
|
||||
)
|
||||
|
||||
IS_PASS_PROMPT = """
|
||||
{context}
|
||||
|
|
@ -239,8 +244,7 @@ class Engineer(Role):
|
|||
|
||||
async def _think(self) -> Action | None:
|
||||
if not self.src_workspace:
|
||||
name = await self._get_src_workspace_name()
|
||||
self.src_workspace = self.git_repo.workdir / name
|
||||
self.src_workspace = get_project_srcs_path(self.project_repo.workdir)
|
||||
write_plan_and_change_filters = any_to_str_set([WriteTasks, FixBug])
|
||||
write_code_filters = any_to_str_set([WriteTasks, WriteCodePlanAndChange, SummarizeCode])
|
||||
summarize_code_filters = any_to_str_set([WriteCode, WriteCodeReview])
|
||||
|
|
@ -384,10 +388,3 @@ class Engineer(Role):
|
|||
def action_description(self) -> str:
|
||||
"""AgentStore uses this attribute to display to the user what actions the current role should take."""
|
||||
return self.next_todo_action
|
||||
|
||||
async def _get_src_workspace_name(self):
|
||||
name = self.git_repo.workdir.name
|
||||
src_workspace_filename = self.git_repo.workdir / ".src_workspace"
|
||||
if src_workspace_filename.exists():
|
||||
name = await aread(filename=src_workspace_filename)
|
||||
return name
|
||||
|
|
|
|||
|
|
@ -879,3 +879,13 @@ def get_markdown_codeblock_type(filename: str = None, mime_type: str = None) ->
|
|||
"application/xml": "xml",
|
||||
}
|
||||
return mappings.get(mime_type, "text")
|
||||
|
||||
|
||||
def get_project_srcs_path(workdir: str | Path) -> Path:
|
||||
src_workdir_path = workdir / ".src_workspace"
|
||||
if src_workdir_path.exists():
|
||||
with open(src_workdir_path, "r") as file:
|
||||
src_name = file.read()
|
||||
else:
|
||||
src_name = Path(workdir).name
|
||||
return Path(workdir) / src_name
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ from metagpt.const import (
|
|||
TEST_OUTPUTS_FILE_REPO,
|
||||
VISUAL_GRAPH_REPO_FILE_REPO,
|
||||
)
|
||||
from metagpt.utils.common import get_project_srcs_path
|
||||
from metagpt.utils.file_repository import FileRepository
|
||||
from metagpt.utils.git_repository import GitRepository
|
||||
|
||||
|
|
@ -129,11 +130,10 @@ class ProjectRepo(FileRepository):
|
|||
return self._git_repo.new_file_repository(self._srcs_path)
|
||||
|
||||
def code_files_exists(self) -> bool:
|
||||
git_workdir = self.git_repo.workdir
|
||||
src_workdir = git_workdir / git_workdir.name
|
||||
src_workdir = get_project_srcs_path(self.git_repo.workdir)
|
||||
if not src_workdir.exists():
|
||||
return False
|
||||
code_files = self.with_src_path(path=git_workdir / git_workdir.name).srcs.all_files
|
||||
code_files = self.with_src_path(path=src_workdir).srcs.all_files
|
||||
if not code_files:
|
||||
return False
|
||||
return bool(code_files)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue