-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdivideWork.py
More file actions
75 lines (55 loc) · 2.32 KB
/
divideWork.py
File metadata and controls
75 lines (55 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from sendToAgent import callAgentAPI
def saveToFile(file_path, content):
import os
directory = os.path.dirname(file_path)
if not os.path.exists(directory):
os.makedirs(directory, exist_ok=True)
lines = content.splitlines()
if len(lines) > 1:
content = "\n".join(lines[1:-1]) # Keep only the middle lines
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
def code_strip(code):
lines = code.splitlines()
if len(lines) > 1:
return "\n".join(lines[1:-1]) # Keep only the middle lines
return code
def run_designer(response, _path):
designer_tasks = response['agent_tasks']['designer_agent']
frontend_structure = response['file_structure']['frontend']
paths = []
for idx, task in enumerate(designer_tasks):
# designer_tasks[idx]['frontend_general_structure'] = frontend_structure
print(f"Calling designer-agent on: {task['component_path']}")
# log_progress(f"Calling designer-agent on: {task['component_path']}", _path)
code = callAgentAPI('design-tech', task)['response']
path = task['component_path']
paths.append(path)
saveToFile(_path+path, code)
return paths
def run_developer(response, _path):
developer_tasks = response['agent_tasks']['developer_agent']
backend_structure = response['file_structure']['backend']
paths = []
for idx, task in enumerate(developer_tasks):
# developer_tasks[idx]['backend_general_structure'] = backend_structure
if "App.tsx" in task['file_path']:
continue
path = task['file_path']
paths.append(path)
# check if path (file) already exists
import os.path
if os.path.exists(_path+path):
with open(_path+path) as file:
task['existing_code'] = file.read()
print(f"Calling developer-agent on: {task['file_path']}")
# log_progress(f"Calling developer-agent on: {task['file_path']}", _path)
code = callAgentAPI('develop-tech', task)['response']
saveToFile(_path+path, code)
return paths
def get_App_js(response, _path):
code = callAgentAPI('app-tsx', response)['response']
path = '/src/App.tsx'
# log_progress(f"Calling app-tsx agent on: {path}", _path)
saveToFile(_path+path, code)
return [path]