mirror of
https://github.com/johndoe6345789/AutoMetabuilder.git
synced 2026-04-26 06:45:00 +00:00
Introduce AutoMetabuilder core components and workflow packages:
- Implement core components: CLI argument parsing, environment loading, GitHub service creation, and logging configuration. - Add support for OpenAI client setup and model resolution. - Develop SDLC context loader from GitHub and repository files. - Implement workflow context and engine builders. - Introduce major workflow packages: `game_tick_loop` and `contextual_iterative_loop`. - Update localization files with new package descriptions and labels. - Streamline web navigation by loading items from a dedicated JSON file.
This commit is contained in:
62
backend/autometabuilder/web/routes/context.py
Normal file
62
backend/autometabuilder/web/routes/context.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""Context routes for dashboard state and logs."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from flask import Blueprint
|
||||
|
||||
from ..data import (
|
||||
get_env_vars,
|
||||
get_navigation_items,
|
||||
get_prompt_content,
|
||||
get_recent_logs,
|
||||
get_ui_messages,
|
||||
get_workflow_content,
|
||||
list_translations,
|
||||
load_metadata,
|
||||
load_workflow_packages,
|
||||
summarize_workflow_packages,
|
||||
)
|
||||
from ..run_state import bot_process, current_run_config, mock_running
|
||||
from ..roadmap_utils import is_mvp_reached
|
||||
|
||||
context_bp = Blueprint("context", __name__)
|
||||
|
||||
|
||||
def build_context() -> dict[str, object]:
|
||||
lang = os.environ.get("APP_LANG", "en")
|
||||
metadata = load_metadata()
|
||||
packages = load_workflow_packages()
|
||||
return {
|
||||
"logs": get_recent_logs(),
|
||||
"env_vars": get_env_vars(),
|
||||
"translations": list_translations(),
|
||||
"metadata": metadata,
|
||||
"navigation": get_navigation_items(),
|
||||
"prompt_content": get_prompt_content(),
|
||||
"workflow_content": get_workflow_content(),
|
||||
"workflow_packages": summarize_workflow_packages(packages),
|
||||
"workflow_packages_raw": packages,
|
||||
"messages": get_ui_messages(lang),
|
||||
"lang": lang,
|
||||
"status": {
|
||||
"is_running": bot_process is not None or mock_running,
|
||||
"mvp_reached": is_mvp_reached(),
|
||||
"config": current_run_config,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@context_bp.route("/api/context")
|
||||
def api_context() -> tuple[dict[str, object], int]:
|
||||
return build_context(), 200
|
||||
|
||||
|
||||
@context_bp.route("/api/status")
|
||||
def api_status() -> tuple[dict[str, object], int]:
|
||||
return build_context()["status"], 200
|
||||
|
||||
|
||||
@context_bp.route("/api/logs")
|
||||
def api_logs() -> tuple[dict[str, str], int]:
|
||||
return {"logs": get_recent_logs()}, 200
|
||||
64
backend/autometabuilder/web/run_state.py
Normal file
64
backend/autometabuilder/web/run_state.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""Run state helpers for long-lived bot executions."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from typing import Dict
|
||||
|
||||
from ..roadmap_utils import is_mvp_reached
|
||||
|
||||
bot_process = None
|
||||
mock_running = False
|
||||
current_run_config: Dict[str, object] = {}
|
||||
|
||||
|
||||
def _reset_run_state() -> None:
|
||||
global bot_process, current_run_config
|
||||
bot_process = None
|
||||
current_run_config = {}
|
||||
|
||||
|
||||
def run_bot_task(mode: str, iterations: int, yolo: bool, stop_at_mvp: bool) -> None:
|
||||
global bot_process, mock_running, current_run_config
|
||||
current_run_config = {
|
||||
"mode": mode,
|
||||
"iterations": iterations,
|
||||
"yolo": yolo,
|
||||
"stop_at_mvp": stop_at_mvp,
|
||||
}
|
||||
|
||||
if os.environ.get("MOCK_WEB_UI") == "true":
|
||||
mock_running = True
|
||||
time.sleep(5)
|
||||
mock_running = False
|
||||
_reset_run_state()
|
||||
return
|
||||
|
||||
try:
|
||||
cmd = [sys.executable, "-m", "autometabuilder.main"]
|
||||
if yolo:
|
||||
cmd.append("--yolo")
|
||||
if mode == "once":
|
||||
cmd.append("--once")
|
||||
if mode == "iterations" and iterations > 1:
|
||||
for _ in range(iterations):
|
||||
if stop_at_mvp and is_mvp_reached():
|
||||
break
|
||||
bot_process = subprocess.Popen(cmd + ["--once"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
bot_process.wait()
|
||||
else:
|
||||
bot_process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
bot_process.wait()
|
||||
finally:
|
||||
_reset_run_state()
|
||||
|
||||
|
||||
def start_bot(mode: str = "once", iterations: int = 1, yolo: bool = True, stop_at_mvp: bool = False) -> bool:
|
||||
if bot_process is not None or mock_running:
|
||||
return False
|
||||
thread = threading.Thread(target=run_bot_task, args=(mode, iterations, yolo, stop_at_mvp), daemon=True)
|
||||
thread.start()
|
||||
return True
|
||||
Reference in New Issue
Block a user