-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate to micro-step control management [WIP]
- Loading branch information
1 parent
7ec31a2
commit 52a7a9c
Showing
44 changed files
with
1,201 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from .fetch_web_page import fetch_web_page | ||
from .read_file import read_file | ||
from .read_file import ReadFileAction | ||
from .run_bash_command import run_bash_command | ||
from .run_rust_file import run_rust_file | ||
from .search_web import search_web | ||
from .search_web_types import WebSearchApiResponse | ||
from .write_file import write_file | ||
from .update_tasks import UpdateTasksAction | ||
from .write_file import WriteFileAction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Any, Dict, List, TypedDict | ||
|
||
|
||
class ActionDesciptionParametersDict(TypedDict): | ||
type: "object" | ||
properties: Dict[str, Any] | ||
required: List[str] | ||
|
||
|
||
class ActionDesciptionDict(TypedDict): | ||
name: str | ||
description: str | ||
parameters: ActionDesciptionParametersDict | ||
|
||
|
||
class BaseAction: | ||
_description: ActionDesciptionDict | ||
|
||
@classmethod | ||
def get_description(cls): | ||
return cls._description | ||
|
||
@staticmethod | ||
def run(*args, **kwargs): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,34 @@ | ||
import os | ||
|
||
from actions.base_action import BaseAction | ||
|
||
from constants import PROJECT_DIRECTORY_PATH | ||
|
||
|
||
def read_file(relative_path: str) -> str: | ||
""" | ||
Read content from a file and return it. | ||
""" | ||
full_path = os.path.join(PROJECT_DIRECTORY_PATH, relative_path) | ||
with open(full_path, "r") as file: | ||
return file.read() | ||
class ReadFileAction(BaseAction): | ||
_description = { | ||
"name": "read_file", | ||
"description": "Read and return a file content.", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"relative_path": { | ||
"type": "string", | ||
"description": "Relative path of the file. Path is relative to the project directory.", | ||
}, | ||
}, | ||
"required": ["relative_path"], | ||
}, | ||
} | ||
|
||
# pylint: disable=arguments-differ | ||
@staticmethod | ||
def read_file(relative_path: str) -> str: | ||
""" | ||
Read content from a file and return it. | ||
""" | ||
|
||
full_path = os.path.join(PROJECT_DIRECTORY_PATH, relative_path) | ||
|
||
with open(file=full_path, mode="r", encoding="utf-8") as file: | ||
return file.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import json | ||
from typing import List | ||
|
||
from actions.base_action import BaseAction | ||
from actions.write_file import WriteFileAction | ||
import typedefs | ||
|
||
|
||
class UpdateTasksAction(BaseAction): | ||
_description = { | ||
"name": "update_tasks", | ||
"description": "Update the entire task list file by replacing it with the new tasks.", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"file_name": { | ||
"type": "string", | ||
"description": "Tasks file name.", | ||
}, | ||
"tasks_as_strs": { | ||
"type": "array", | ||
"description": "List of tasks.", | ||
"items": { | ||
"type": "string", | ||
}, | ||
}, | ||
}, | ||
"required": ["updated_tasks"], | ||
}, | ||
} | ||
|
||
# pylint: disable=arguments-differ | ||
@staticmethod | ||
def run(file_name: str, tasks_as_strs: List[str]) -> str: | ||
""" | ||
Write content to a file. Create the file and/or directories if they don't exist. | ||
""" | ||
|
||
tasks = [ | ||
(index, UpdateTasksAction.get_task_from_task_as_str) | ||
for index, item in enumerate(tasks_as_strs) | ||
] | ||
tasks_as_json = json.dumps(tasks) | ||
|
||
return WriteFileAction.run(relative_path=file_name, file_source=tasks_as_json) | ||
|
||
@staticmethod | ||
def get_task_from_task_as_str(tasks_as_str: str, index: int) -> typedefs.TaskDict: | ||
return { | ||
"index": index, | ||
"description": tasks_as_str, | ||
"is_done": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
import os | ||
from actions.base_action import BaseAction | ||
|
||
from constants import PROJECT_DIRECTORY_PATH | ||
|
||
|
||
def write_file(relative_path: str, file_source: str) -> str: | ||
""" | ||
Write content to a file. Create the file and/or directories if they don't exist. | ||
""" | ||
full_path = os.path.join(PROJECT_DIRECTORY_PATH, relative_path) | ||
class WriteFileAction(BaseAction): | ||
_description = { | ||
"name": "write_file", | ||
"description": "Write content to a file, creating it if necessary.", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"relative_path": { | ||
"type": "string", | ||
"description": "Relative path of the file. Path is relative to the project directory.", | ||
}, | ||
"file_source": { | ||
"type": "string", | ||
"description": """Content to write.""", | ||
}, | ||
}, | ||
"required": ["relative_path", "file_source"], | ||
}, | ||
} | ||
|
||
try: | ||
os.makedirs(os.path.dirname(full_path), exist_ok=True) | ||
with open(full_path, "w") as file: | ||
file.write(file_source) | ||
# pylint: disable=arguments-differ | ||
@staticmethod | ||
def run(relative_path: str, file_source: str) -> str: | ||
""" | ||
Write content to a file. Create the file and/or directories if they don't exist. | ||
""" | ||
full_path = os.path.join(PROJECT_DIRECTORY_PATH, relative_path) | ||
|
||
return f"Done." | ||
except Exception as e: | ||
return f"Error: {str(e)}" | ||
try: | ||
os.makedirs(os.path.dirname(full_path), exist_ok=True) | ||
with open(file=full_path, mode="w", encoding="utf-8") as file: | ||
file.write(file_source) | ||
|
||
return f"File successfully written to `{relative_path}`." | ||
|
||
except Exception as e: | ||
return f"Error: {str(e)}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from .base_agent import BaseAgent | ||
from .ceo import CEO | ||
from .functionner import Functioneer | ||
from .planner import Planner | ||
from .product_owner import ProductOwner | ||
from .software_engineer import SoftwareEngineer | ||
from .user_experience_designer import UserExperienceDesigner |
Oops, something went wrong.