shenchucheng
commited on
Commit
•
5ce3b16
1
Parent(s):
a0d6fb3
change the uid when pack project
Browse files- software_company.py +25 -13
software_company.py
CHANGED
@@ -1,17 +1,14 @@
|
|
1 |
import asyncio
|
2 |
-
from functools import partial
|
3 |
-
import json
|
4 |
-
from pydantic import BaseModel, Field
|
5 |
import datetime
|
|
|
6 |
import os
|
|
|
7 |
from pathlib import Path
|
8 |
from typing import Any, Coroutine, Optional
|
9 |
|
10 |
import aiofiles
|
11 |
from aiobotocore.session import get_session
|
12 |
from mdutils.mdutils import MdUtils
|
13 |
-
from zipstream import AioZipStream
|
14 |
-
|
15 |
from metagpt.actions import Action
|
16 |
from metagpt.actions.action_output import ActionOutput
|
17 |
from metagpt.actions.design_api import WriteDesign
|
@@ -21,13 +18,19 @@ from metagpt.actions.summarize_code import SummarizeCode
|
|
21 |
from metagpt.actions.write_code import WriteCode
|
22 |
from metagpt.actions.write_prd import WritePRD
|
23 |
from metagpt.config import CONFIG
|
24 |
-
from metagpt.const import
|
|
|
|
|
|
|
|
|
|
|
25 |
from metagpt.roles import Architect, Engineer, ProductManager, ProjectManager, Role
|
26 |
from metagpt.schema import Message
|
27 |
from metagpt.team import Team
|
28 |
from metagpt.utils.common import any_to_str, read_json_file, write_json_file
|
29 |
from metagpt.utils.git_repository import GitRepository
|
30 |
-
|
|
|
31 |
|
32 |
_default_llm_stream_log = partial(print, end="")
|
33 |
|
@@ -59,7 +62,7 @@ class PackProject(Action):
|
|
59 |
workspace = CONFIG.git_repo.workdir
|
60 |
workspace = str(workspace)
|
61 |
for r, _, fs in os.walk(workspace):
|
62 |
-
_r = r[len(workspace):].lstrip("/")
|
63 |
for f in fs:
|
64 |
files.append({"file": os.path.join(r, f), "name": os.path.join(_r, f)})
|
65 |
# aiozipstream
|
@@ -71,6 +74,7 @@ class PackProject(Action):
|
|
71 |
|
72 |
class SoftwareCompany(Role):
|
73 |
"""封装软件公司成角色,以快速接入agent store。"""
|
|
|
74 |
finish: bool = False
|
75 |
company: Team = Field(default_factory=Team)
|
76 |
active_role: Optional[Role] = None
|
@@ -90,7 +94,7 @@ class SoftwareCompany(Role):
|
|
90 |
"""软件公司运行需要4轮
|
91 |
|
92 |
BOSS -> ProductManager -> Architect -> ProjectManager -> Engineer
|
93 |
-
BossRequirement -> WritePRD -> WriteDesign -> WriteTasks -> WriteCode ->
|
94 |
"""
|
95 |
if self.finish:
|
96 |
self._rc.todo = None
|
@@ -128,7 +132,7 @@ class SoftwareCompany(Role):
|
|
128 |
if isinstance(self._rc.todo, PackProject):
|
129 |
workdir = CONFIG.git_repo.workdir
|
130 |
name = workdir.name
|
131 |
-
uid = workdir.parent.
|
132 |
now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
133 |
key = f"{uid}/metagpt-{name}-{now}.zip"
|
134 |
output = await self._rc.todo.run(key)
|
@@ -201,7 +205,9 @@ class SoftwareCompany(Role):
|
|
201 |
|
202 |
title = "Competitive Quadrant Chart"
|
203 |
mdfile.new_header(2, title, add_table_of_contents=False)
|
204 |
-
competitive_analysis_path =
|
|
|
|
|
205 |
|
206 |
if competitive_analysis_path.exists():
|
207 |
key = str(competitive_analysis_path.relative_to(CONFIG.git_repo.workdir.parent.parent))
|
@@ -248,7 +254,11 @@ class SoftwareCompany(Role):
|
|
248 |
title = "Data structures and interfaces"
|
249 |
mdfile.new_header(2, title, add_table_of_contents=False)
|
250 |
|
251 |
-
data_api_design_path =
|
|
|
|
|
|
|
|
|
252 |
if data_api_design_path.exists():
|
253 |
key = str(data_api_design_path.relative_to(CONFIG.git_repo.workdir.parent.parent))
|
254 |
url = await upload_file_to_s3(data_api_design_path, key)
|
@@ -258,7 +268,9 @@ class SoftwareCompany(Role):
|
|
258 |
|
259 |
title = "Program call flow"
|
260 |
mdfile.new_header(2, title, add_table_of_contents=False)
|
261 |
-
seq_flow_path =
|
|
|
|
|
262 |
if seq_flow_path.exists():
|
263 |
key = str(seq_flow_path.relative_to(CONFIG.git_repo.workdir.parent.parent))
|
264 |
url = await upload_file_to_s3(seq_flow_path, key)
|
|
|
1 |
import asyncio
|
|
|
|
|
|
|
2 |
import datetime
|
3 |
+
import json
|
4 |
import os
|
5 |
+
from functools import partial
|
6 |
from pathlib import Path
|
7 |
from typing import Any, Coroutine, Optional
|
8 |
|
9 |
import aiofiles
|
10 |
from aiobotocore.session import get_session
|
11 |
from mdutils.mdutils import MdUtils
|
|
|
|
|
12 |
from metagpt.actions import Action
|
13 |
from metagpt.actions.action_output import ActionOutput
|
14 |
from metagpt.actions.design_api import WriteDesign
|
|
|
18 |
from metagpt.actions.write_code import WriteCode
|
19 |
from metagpt.actions.write_prd import WritePRD
|
20 |
from metagpt.config import CONFIG
|
21 |
+
from metagpt.const import (
|
22 |
+
COMPETITIVE_ANALYSIS_FILE_REPO,
|
23 |
+
DATA_API_DESIGN_FILE_REPO,
|
24 |
+
SEQ_FLOW_FILE_REPO,
|
25 |
+
SERDESER_PATH,
|
26 |
+
)
|
27 |
from metagpt.roles import Architect, Engineer, ProductManager, ProjectManager, Role
|
28 |
from metagpt.schema import Message
|
29 |
from metagpt.team import Team
|
30 |
from metagpt.utils.common import any_to_str, read_json_file, write_json_file
|
31 |
from metagpt.utils.git_repository import GitRepository
|
32 |
+
from pydantic import BaseModel, Field
|
33 |
+
from zipstream import AioZipStream
|
34 |
|
35 |
_default_llm_stream_log = partial(print, end="")
|
36 |
|
|
|
62 |
workspace = CONFIG.git_repo.workdir
|
63 |
workspace = str(workspace)
|
64 |
for r, _, fs in os.walk(workspace):
|
65 |
+
_r = r[len(workspace) :].lstrip("/")
|
66 |
for f in fs:
|
67 |
files.append({"file": os.path.join(r, f), "name": os.path.join(_r, f)})
|
68 |
# aiozipstream
|
|
|
74 |
|
75 |
class SoftwareCompany(Role):
|
76 |
"""封装软件公司成角色,以快速接入agent store。"""
|
77 |
+
|
78 |
finish: bool = False
|
79 |
company: Team = Field(default_factory=Team)
|
80 |
active_role: Optional[Role] = None
|
|
|
94 |
"""软件公司运行需要4轮
|
95 |
|
96 |
BOSS -> ProductManager -> Architect -> ProjectManager -> Engineer
|
97 |
+
BossRequirement -> WritePRD -> WriteDesign -> WriteTasks -> WriteCode ->
|
98 |
"""
|
99 |
if self.finish:
|
100 |
self._rc.todo = None
|
|
|
132 |
if isinstance(self._rc.todo, PackProject):
|
133 |
workdir = CONFIG.git_repo.workdir
|
134 |
name = workdir.name
|
135 |
+
uid = workdir.parent.name
|
136 |
now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
137 |
key = f"{uid}/metagpt-{name}-{now}.zip"
|
138 |
output = await self._rc.todo.run(key)
|
|
|
205 |
|
206 |
title = "Competitive Quadrant Chart"
|
207 |
mdfile.new_header(2, title, add_table_of_contents=False)
|
208 |
+
competitive_analysis_path = (
|
209 |
+
CONFIG.git_repo.workdir / Path(COMPETITIVE_ANALYSIS_FILE_REPO) / Path(prd_doc.filename).with_suffix(".png")
|
210 |
+
)
|
211 |
|
212 |
if competitive_analysis_path.exists():
|
213 |
key = str(competitive_analysis_path.relative_to(CONFIG.git_repo.workdir.parent.parent))
|
|
|
254 |
title = "Data structures and interfaces"
|
255 |
mdfile.new_header(2, title, add_table_of_contents=False)
|
256 |
|
257 |
+
data_api_design_path = (
|
258 |
+
CONFIG.git_repo.workdir
|
259 |
+
/ Path(DATA_API_DESIGN_FILE_REPO)
|
260 |
+
/ Path(system_design_doc.filename).with_suffix(".png")
|
261 |
+
)
|
262 |
if data_api_design_path.exists():
|
263 |
key = str(data_api_design_path.relative_to(CONFIG.git_repo.workdir.parent.parent))
|
264 |
url = await upload_file_to_s3(data_api_design_path, key)
|
|
|
268 |
|
269 |
title = "Program call flow"
|
270 |
mdfile.new_header(2, title, add_table_of_contents=False)
|
271 |
+
seq_flow_path = (
|
272 |
+
CONFIG.git_repo.workdir / SEQ_FLOW_FILE_REPO / Path(system_design_doc.filename).with_suffix(".png")
|
273 |
+
)
|
274 |
if seq_flow_path.exists():
|
275 |
key = str(seq_flow_path.relative_to(CONFIG.git_repo.workdir.parent.parent))
|
276 |
url = await upload_file_to_s3(seq_flow_path, key)
|