54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
"""Phase 14: Cross-Repository Orchestration (CRO).
|
|
|
|
Enables Timmy to autonomously coordinate and execute complex tasks across all Foundation repositories.
|
|
"""
|
|
|
|
import logging
|
|
import json
|
|
from typing import List, Dict, Any
|
|
from agent.gemini_adapter import GeminiAdapter
|
|
from tools.gitea_client import GiteaClient
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class RepoOrchestrator:
|
|
def __init__(self):
|
|
self.adapter = GeminiAdapter()
|
|
self.gitea = GiteaClient()
|
|
|
|
def plan_global_task(self, task_description: str, repo_list: List[str]) -> Dict[str, Any]:
|
|
"""Plans a task that spans multiple repositories."""
|
|
logger.info(f"Planning global task across {len(repo_list)} repositories.")
|
|
|
|
prompt = f"""
|
|
Global Task: {task_description}
|
|
Repositories: {', '.join(repo_list)}
|
|
|
|
Please design a multi-repo workflow to execute this task.
|
|
Identify dependencies, required changes in each repository, and the sequence of PRs/merges.
|
|
Generate a 'Global Execution Plan'.
|
|
|
|
Format the output as JSON:
|
|
{{
|
|
"task": "{task_description}",
|
|
"execution_plan": [
|
|
{{
|
|
"repo": "...",
|
|
"action": "...",
|
|
"dependencies": [...],
|
|
"pr_description": "..."
|
|
}}
|
|
]
|
|
}}
|
|
"""
|
|
result = self.adapter.generate(
|
|
model="gemini-3.1-pro-preview",
|
|
prompt=prompt,
|
|
system_instruction="You are Timmy's Global Orchestrator. Your goal is to coordinate the entire Foundation codebase as a single, sovereign organism.",
|
|
thinking=True,
|
|
response_mime_type="application/json"
|
|
)
|
|
|
|
plan_data = json.loads(result["text"])
|
|
return plan_data
|