transfer from monorepo
This commit is contained in:
52
worker/orca-agent/src/workflows/repoSummarizer/__main__.py
Normal file
52
worker/orca-agent/src/workflows/repoSummarizer/__main__.py
Normal file
@ -0,0 +1,52 @@
|
||||
"""Entry point for the todo creator workflow."""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from dotenv import load_dotenv
|
||||
from src.workflows.repoSummarizer.workflow import RepoSummarizerWorkflow
|
||||
from src.workflows.repoSummarizer.prompts import PROMPTS
|
||||
from prometheus_swarm.clients import setup_client
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the todo creator workflow."""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Create tasks from a feature specification for a GitHub repository"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--repo",
|
||||
type=str,
|
||||
required=True,
|
||||
help="GitHub repository URL (e.g., https://github.com/owner/repo)",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--model",
|
||||
type=str,
|
||||
default="anthropic",
|
||||
choices=["anthropic", "openai", "xai"],
|
||||
help="Model provider to use (default: anthropic)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Initialize client
|
||||
client = setup_client(args.model)
|
||||
|
||||
# Run the todo creator workflow
|
||||
workflow = RepoSummarizerWorkflow(
|
||||
client=client,
|
||||
prompts=PROMPTS,
|
||||
repo_url=args.repo,
|
||||
)
|
||||
|
||||
result = workflow.run()
|
||||
if not result or not result.get("success"):
|
||||
print("Todo creator workflow failed")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
67
worker/orca-agent/src/workflows/repoSummarizer/phases.py
Normal file
67
worker/orca-agent/src/workflows/repoSummarizer/phases.py
Normal file
@ -0,0 +1,67 @@
|
||||
"""Task decomposition workflow phases implementation."""
|
||||
|
||||
from prometheus_swarm.workflows.base import WorkflowPhase, Workflow
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BranchCreationPhase(WorkflowPhase):
|
||||
def __init__(self, workflow: Workflow, conversation_id: str = None):
|
||||
super().__init__(
|
||||
workflow=workflow,
|
||||
prompt_name="create_branch",
|
||||
available_tools=["create_branch"],
|
||||
conversation_id=conversation_id,
|
||||
name="Branch Creation",
|
||||
)
|
||||
|
||||
|
||||
class RepoClassificationPhase(WorkflowPhase):
|
||||
def __init__(self, workflow: Workflow, conversation_id: str = None):
|
||||
super().__init__(
|
||||
workflow=workflow,
|
||||
prompt_name="classify_repository",
|
||||
available_tools=["read_file", "list_files", "classify_repository"],
|
||||
conversation_id=conversation_id,
|
||||
name="Repository Classificati on",
|
||||
)
|
||||
|
||||
|
||||
class ReadmeGenerationPhase(WorkflowPhase):
|
||||
def __init__(
|
||||
self, workflow: Workflow, conversation_id: str = None, prompt_name: str = None
|
||||
):
|
||||
super().__init__(
|
||||
workflow=workflow,
|
||||
prompt_name=prompt_name,
|
||||
available_tools=[
|
||||
"read_file",
|
||||
"list_files",
|
||||
"write_file",
|
||||
],
|
||||
conversation_id=conversation_id,
|
||||
name="Readme Generation",
|
||||
)
|
||||
|
||||
|
||||
class ReadmeReviewPhase(WorkflowPhase):
|
||||
def __init__(self, workflow: Workflow, conversation_id: str = None):
|
||||
super().__init__(
|
||||
workflow=workflow,
|
||||
prompt_name="review_readme_file",
|
||||
available_tools=["read_file", "list_files", "review_readme_file"],
|
||||
conversation_id=conversation_id,
|
||||
name="Readme Review",
|
||||
)
|
||||
|
||||
|
||||
class CreatePullRequestPhase(WorkflowPhase):
|
||||
def __init__(self, workflow: Workflow, conversation_id: str = None):
|
||||
super().__init__(
|
||||
workflow=workflow,
|
||||
prompt_name="create_pr",
|
||||
available_tools=["read_file", "list_files", "create_pull_request_legacy"],
|
||||
conversation_id=conversation_id,
|
||||
name="Create Pull Request",
|
||||
)
|
593
worker/orca-agent/src/workflows/repoSummarizer/prompts.py
Normal file
593
worker/orca-agent/src/workflows/repoSummarizer/prompts.py
Normal file
@ -0,0 +1,593 @@
|
||||
"""Prompts for the repository summarization workflow."""
|
||||
|
||||
PROMPTS = {
|
||||
"system_prompt": (
|
||||
"You are an expert software architect and technical lead specializing in summarizing "
|
||||
"repositories into comprehensive documentation. You excel at analyzing codebases "
|
||||
"and creating clear, structured documentation."
|
||||
),
|
||||
"create_branch": (
|
||||
"You need to create a feature branch for the README generation.\n"
|
||||
"Create a new branch with a descriptive name related to creating a README file.\n"
|
||||
),
|
||||
"classify_repository": (
|
||||
"Analyze the repository structure and identify the type of repository this is.\n"
|
||||
"Use the `classify_repository` tool to report your choice.\n"
|
||||
"You must choose one of the following repository types:\n"
|
||||
"- Library/SDK: Code meant to be imported and used by other developers\n"
|
||||
"- Web App: Frontend or full-stack web application\n"
|
||||
"- API Service: Server-side application providing APIs\n"
|
||||
"- Mobile App: Native or cross-platform mobile app\n"
|
||||
"- Tutorial: Educational repository demonstrating techniques\n"
|
||||
"- Template: Starter code for new projects\n"
|
||||
"- CLI Tool: Command-line interface application\n"
|
||||
"- Framework: Foundational structure for building applications\n"
|
||||
"- Data Science: Machine learning or data analysis project\n"
|
||||
"- Plugin: Extension or module for a larger system (e.g., CMS, IDE, platform)\n"
|
||||
"- Chrome Extension: Browser extension targeting the Chrome platform\n"
|
||||
"- Jupyter Notebook: Interactive code notebooks, often for demos or research\n"
|
||||
"- Infrastructure: Configuration or automation code (e.g., Docker, Terraform)\n"
|
||||
"- Smart Contract: Blockchain smart contracts, typically written in Solidity, Rust, etc.\n"
|
||||
"- DApp: Decentralized application with both smart contract and frontend components\n"
|
||||
"- Game: Codebase for a game or game engine (2D, 3D, or browser-based)\n"
|
||||
"- Desktop App: GUI application for desktop environments (e.g., Electron, Qt, Tauri)\n"
|
||||
"- Dataset: Repository containing structured data for analysis or training\n"
|
||||
"- Other: If it doesn't fit into any of the above categories\n"
|
||||
),
|
||||
"create_pr": (
|
||||
"You are creating a pull request for the documentation you have generated:\n"
|
||||
"IMPORTANT: Always use relative paths (e.g., 'src/file.py' not '/src/file.py')\n\n"
|
||||
"Steps to create the pull request:\n"
|
||||
"1. First examine the available files to understand the implementation\n"
|
||||
"2. Create a clear and descriptive PR title\n"
|
||||
"3. Write a comprehensive PR description that includes:\n"
|
||||
" - Description of all changes made\n"
|
||||
" - The main features and value of the documentation\n"
|
||||
),
|
||||
"library": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a software library intended"
|
||||
" for use by developers.\n\n"
|
||||
"Your README should be formatted in Markdown and include clearly defined section headers.\n\n"
|
||||
"Please include the following sections:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - A concise description of what the library does\n"
|
||||
" - Its main purpose and the problems it solves\n"
|
||||
" - Key features and benefits\n\n"
|
||||
"2. **Installation**\n"
|
||||
" - Instructions for installing the library using relevant package managers (e.g., npm, pip, etc.)\n"
|
||||
" - Mention any prerequisites if applicable\n\n"
|
||||
"3. **API Reference**\n"
|
||||
" - Generate a complete list of all publicly exported functions, classes, and constants from the library\n"
|
||||
" - For each item, include:\n"
|
||||
" - Its name\n"
|
||||
" - Description of what it does\n"
|
||||
" - Function signature with types and descriptions of parameters and return values\n"
|
||||
" - Example usage\n"
|
||||
" - Do not omit any significant exports — include everything that would be relevant to a developer using "
|
||||
"this library\n"
|
||||
" - Group related items (e.g., utility functions, configuration, components) under subsections if helpful\n"
|
||||
"4. **Repository Structure**\n"
|
||||
" - Briefly explain the purpose of key directories and files\n\n"
|
||||
"5. **Contributing**\n"
|
||||
" - Include basic instructions for how others can contribute\n"
|
||||
" - Mention where to find or how to run tests (if available)\n\n"
|
||||
"6. **License**\n"
|
||||
" - State the type of license and include a link to the license file\n\n"
|
||||
"Additional notes:\n"
|
||||
"- Use bullet points and code blocks to improve readability\n"
|
||||
"- Keep language friendly but technical and precise\n"
|
||||
"- If configuration or extension points exist, explain them clearly\n\n"
|
||||
),
|
||||
"web_app": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a web application "
|
||||
"project.\n\n"
|
||||
"Format the output using Markdown with clear section headers and proper formatting.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - Describe the purpose and core functionality of the application\n"
|
||||
" - Highlight key features and typical use cases\n\n"
|
||||
"2. **Getting Started**\n"
|
||||
" - Provide setup instructions to run the app locally\n"
|
||||
" - Include steps for installing dependencies and starting the development server\n"
|
||||
" - Mention any required environment variables and how to configure them (e.g., `.env` file)\n\n"
|
||||
"3. **Deployment**\n"
|
||||
" - Describe how to build and deploy the application to production\n"
|
||||
" - Include relevant deployment commands and target platforms (e.g., Vercel, Netlify, Docker)\n\n"
|
||||
"4. **Project Structure**\n"
|
||||
" - Briefly explain the purpose of major folders and files (e.g., `src/`, `public/`, `components/`)\n\n"
|
||||
"5. **Technologies Used**\n"
|
||||
" - List the main frameworks, libraries, and tools (e.g., React, Vue, Vite, Tailwind)\n\n"
|
||||
"6. **Feature Highlights**\n"
|
||||
" - Describe core user-facing features or flows (e.g., authentication, dashboards, routing)\n\n"
|
||||
"7. **Configuration**\n"
|
||||
" - Mention any configurable options, build settings, or plugins used\n\n"
|
||||
"8. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Use bullet points, code blocks, and links where appropriate\n"
|
||||
"- Make sure commands are copy-pasteable\n"
|
||||
"- Keep language clear and helpful for developers new to the project"
|
||||
),
|
||||
"api_service": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a backend service that "
|
||||
"exposes an API (e.g., REST, GraphQL, or similar).\n\n"
|
||||
"Format the output using Markdown with clear section headers and developer-friendly formatting.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - Describe the purpose of the API and its core functionality\n"
|
||||
" - Highlight key features and typical use cases\n\n"
|
||||
"2. **Getting Started**\n"
|
||||
" - Provide setup instructions to run the service locally\n"
|
||||
" - Include dependency installation and environment variable setup\n"
|
||||
" - Describe how to start the server in development mode\n\n"
|
||||
"3. **API Documentation**\n"
|
||||
" - List the available endpoints or routes\n"
|
||||
" - For each endpoint, include:\n"
|
||||
" - Method (GET, POST, etc.)\n"
|
||||
" - Path and parameters\n"
|
||||
" - Example request and response\n"
|
||||
" - Authentication requirements (if any)\n"
|
||||
" - If an OpenAPI/Swagger spec or GraphQL schema exists, link to it\n\n"
|
||||
"4. **Authentication**\n"
|
||||
" - Describe how authentication works (e.g., API keys, OAuth, JWT)\n"
|
||||
" - Include example headers or auth flow steps if needed\n\n"
|
||||
"5. **Project Structure**\n"
|
||||
" - Explain key folders and files, such as `routes/`, `controllers/`, `models/`\n\n"
|
||||
"6. **Technologies Used**\n"
|
||||
" - List major frameworks, libraries, or tools (e.g., Express, FastAPI, Prisma)\n\n"
|
||||
"7. **Deployment**\n"
|
||||
" - Describe how to deploy the service (e.g., Docker, CI/CD, cloud platforms)\n"
|
||||
" - Include environment config or scaling considerations if relevant\n\n"
|
||||
"8. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Use bullet points, code blocks, and sample payloads for clarity\n"
|
||||
"- Focus on making the API easy to understand and consume\n"
|
||||
"- Keep the tone clear and helpful for developers using the API"
|
||||
),
|
||||
"mobile_app": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a mobile application "
|
||||
"project.\n\n"
|
||||
"Format the output using Markdown with clear section headers and mobile developer–friendly formatting.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - Describe the purpose and core functionality of the app\n"
|
||||
" - List key features and intended user experience\n\n"
|
||||
"2. **Supported Platforms**\n"
|
||||
" - Indicate whether the app runs on Android, iOS, or both\n"
|
||||
" - Mention any platform-specific dependencies or limitations\n\n"
|
||||
"3. **Getting Started**\n"
|
||||
" - Provide setup instructions for running the app locally\n"
|
||||
" - Include steps for installing dependencies and required SDKs (e.g., Android Studio, Xcode)\n"
|
||||
" - Describe how to configure environment variables or API keys\n\n"
|
||||
"4. **Running the App**\n"
|
||||
" - Show commands to run the app on a simulator/emulator or real device\n"
|
||||
" - Include platform-specific commands if needed (e.g., `npx react-native run-ios`, `flutter run`)\n\n"
|
||||
"5. **Project Structure**\n"
|
||||
" - Briefly explain the layout of important folders and files (e.g., `src/`, `ios/`, `android/`, `lib/`)\n\n"
|
||||
"6. **Technologies Used**\n"
|
||||
" - List the frameworks, SDKs, and libraries used (e.g., React Native, Flutter, Firebase)\n\n"
|
||||
"7. **Key Screens and Features**\n"
|
||||
" - Highlight core screens or flows within the app (e.g., login, profile, dashboard)\n"
|
||||
" - Optionally include screenshots or descriptions of user interactions\n\n"
|
||||
"8. **Build and Deployment**\n"
|
||||
" - Provide steps for creating production builds\n"
|
||||
" - Mention any tools or services used for distribution (e.g., TestFlight, Play Store, Expo)\n\n"
|
||||
"9. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Use bullet points, code blocks, and platform-specific sections where needed\n"
|
||||
"- Make sure setup steps work for both Android and iOS where applicable\n"
|
||||
"- Keep the tone clear and helpful for mobile developers"
|
||||
),
|
||||
"tutorial": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is designed as an educational "
|
||||
"tutorial or learning resource.\n\n"
|
||||
"Format the output using Markdown with clear section headers and a logical, beginner-friendly structure.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Summarize the goal of the tutorial and what users will learn\n"
|
||||
" - List key topics or technologies covered\n"
|
||||
" - Mention any prerequisites (e.g., knowledge of a language, tools to install)\n\n"
|
||||
"2. **Getting Started**\n"
|
||||
" - Provide step-by-step setup instructions\n"
|
||||
" - Include installation of dependencies, toolchain setup, and environment config\n"
|
||||
" - Ensure instructions work on major operating systems\n\n"
|
||||
"3. **Tutorial Structure**\n"
|
||||
" - Break down the tutorial into sections, stages, or lessons\n"
|
||||
" - Briefly describe what each section teaches or builds\n"
|
||||
" - Link to key files or folders associated with each part\n\n"
|
||||
"4. **Learning Outcomes**\n"
|
||||
" - Clearly list the skills or concepts users will have mastered by the end\n\n"
|
||||
"5. **Code Examples and Exercises**\n"
|
||||
" - Mention inline code snippets, checkpoints, or interactive examples\n"
|
||||
" - If exercises are included, describe how users should complete or test them\n\n"
|
||||
"6. **Project Structure**\n"
|
||||
" - Describe the layout of the repository and which files correspond to different tutorial stages\n\n"
|
||||
"7. **Next Steps / Further Reading**\n"
|
||||
" - Suggest where users can go after completing the tutorial\n"
|
||||
" - Include links to additional docs, libraries, or related tutorials\n\n"
|
||||
"8. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Use beginner-friendly language without dumbing things down\n"
|
||||
"- Include code blocks, links, and visual structure to aid readability\n"
|
||||
"- Help users stay oriented by reminding them what they've done and what's next"
|
||||
),
|
||||
"template": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which serves as a project starter or "
|
||||
"boilerplate template.\n\n"
|
||||
"Format the output using Markdown with clear section headers and developer-friendly formatting.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - Describe the purpose of this template and the type of projects it's meant for\n"
|
||||
" - List key features, tools, or configurations included by default\n\n"
|
||||
"2. **Getting Started**\n"
|
||||
" - Provide instructions for cloning or copying the template\n"
|
||||
" - Include setup steps: installing dependencies, environment config, and running locally\n\n"
|
||||
"3. **Customization Guide**\n"
|
||||
" - Explain which parts of the codebase are intended to be modified by users\n"
|
||||
" - Offer guidance on how to rename, rebrand, or restructure parts of the template\n\n"
|
||||
"4. **Project Structure**\n"
|
||||
" - Describe the layout of important directories and files\n"
|
||||
" - Highlight which files are meant for customization vs. boilerplate\n\n"
|
||||
"5. **Technologies Used**\n"
|
||||
" - List the frameworks, libraries, and tools integrated into the template (e.g., ESLint, Prettier, "
|
||||
"Tailwind, Express)\n\n"
|
||||
"6. **Use Cases**\n"
|
||||
" - Provide example scenarios where this template is useful (e.g., 'Use this for building a REST API with "
|
||||
"authentication')\n"
|
||||
" - Link to live demos or projects built from this template if available\n\n"
|
||||
"7. **Contributing**\n"
|
||||
" - If the template is open to contributions, provide basic instructions for submitting improvements\n\n"
|
||||
"8. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Focus on helping users get started quickly and confidently\n"
|
||||
"- Use code blocks and examples to show how things work\n"
|
||||
"- Encourage best practices and provide defaults users can trust or extend"
|
||||
),
|
||||
"cli_tool": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a command-line "
|
||||
"interface (CLI) tool.\n\n"
|
||||
"Format the output using Markdown with clear section headers and include clear command-line examples.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - Explain what the CLI tool does and why it's useful\n"
|
||||
" - Mention common use cases or problems it solves\n\n"
|
||||
"2. **Installation**\n"
|
||||
" - Provide steps to install the tool (e.g., npm, pip, Homebrew, binary download)\n"
|
||||
" - Mention any required dependencies or environment setup\n\n"
|
||||
"3. **Usage**\n"
|
||||
" - Show how to use the tool from the command line\n"
|
||||
" - Include at least 2–3 example commands with explanations of the output\n"
|
||||
" - Demonstrate the most common and useful flags or options\n"
|
||||
" - If the tool supports subcommands, show examples of each\n\n"
|
||||
"4. **Command Reference**\n"
|
||||
" - List all available commands, flags, and options in a table or list format\n"
|
||||
" - Explain each option clearly, including defaults and accepted values\n\n"
|
||||
"5. **Configuration (if applicable)**\n"
|
||||
" - Describe any optional or required configuration files (e.g., `.clirc`, `config.json`)\n"
|
||||
" - Show example configurations and where to place them\n\n"
|
||||
"6. **Project Structure**\n"
|
||||
" - Briefly describe key files or folders related to the CLI's source code\n\n"
|
||||
"7. **Contributing**\n"
|
||||
" - Outline how to contribute, test changes, or add new commands\n\n"
|
||||
"8. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Use code blocks for command examples and outputs\n"
|
||||
"- Keep tone practical and clear, suitable for developers or power users\n"
|
||||
"- Focus on usability and real-world examples of the tool in action"
|
||||
),
|
||||
"framework": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a software framework "
|
||||
"designed to be extended or used as a foundation for building applications.\n\n"
|
||||
"Format the output using Markdown with clear section headers and structured, developer-friendly formatting.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - Describe what the framework does and the type of projects it's built for\n"
|
||||
" - Highlight key concepts and design philosophy (e.g., convention over configuration, modularity)\n\n"
|
||||
"2. **Getting Started**\n"
|
||||
" - Include steps for installing and initializing a new project using the framework\n"
|
||||
" - Provide a minimal working example with code blocks\n\n"
|
||||
"3. **Core Concepts**\n"
|
||||
" - Explain the main components or building blocks (e.g., modules, services, lifecycle, routing, etc.)\n"
|
||||
" - Include diagrams or conceptual overviews if helpful\n\n"
|
||||
"4. **Extension Points**\n"
|
||||
" - Describe how developers can extend the framework (e.g., plugins, middleware, custom components)\n"
|
||||
" - Include examples of common extension use cases\n\n"
|
||||
"5. **Project Structure**\n"
|
||||
" - Explain the directory layout of a typical project using the framework\n"
|
||||
" - Highlight where user code should live and where internal framework logic resides\n\n"
|
||||
"6. **Technologies Used**\n"
|
||||
" - List core dependencies, supported environments, or language-level features leveraged\n\n"
|
||||
"7. **Best Practices**\n"
|
||||
" - Offer guidance for structuring large projects, writing maintainable code, or following framework "
|
||||
"conventions\n\n"
|
||||
"8. **Contributing**\n"
|
||||
" - Outline how contributors can report issues, add features, or build plugins for the framework\n\n"
|
||||
"9. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Use clear examples and code snippets to explain key abstractions\n"
|
||||
"- Keep the tone empowering and oriented toward other developers building on top of the framework\n"
|
||||
"- Emphasize extensibility and conceptual clarity"
|
||||
),
|
||||
"data_science": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a data science or "
|
||||
"machine learning project.\n\n"
|
||||
"Format the output using Markdown with clear section headers and helpful formatting for technical readers.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - Explain the goal of the project (e.g., prediction, classification, analysis)\n"
|
||||
" - Summarize key findings or outcomes (if applicable)\n\n"
|
||||
"2. **Dataset**\n"
|
||||
" - Describe the dataset used (source, size, structure)\n"
|
||||
" - Include schema information or link to external data sources\n"
|
||||
" - Mention whether the data is included in the repo or needs to be downloaded\n\n"
|
||||
"3. **Installation and Setup**\n"
|
||||
" - List dependencies and setup instructions (e.g., `requirements.txt`, `environment.yml`)\n"
|
||||
" - Mention any additional setup (e.g., downloading data, creating folders)\n\n"
|
||||
"4. **Project Structure**\n"
|
||||
" - Explain the layout of scripts, notebooks, data folders, and model outputs\n"
|
||||
" - Highlight the main entry points for running the pipeline\n\n"
|
||||
"5. **Model Architecture and Training**\n"
|
||||
" - Briefly describe the model(s) used and why they were chosen\n"
|
||||
" - Include training scripts and command-line instructions\n"
|
||||
" - Mention metrics used for evaluation\n\n"
|
||||
"6. **Evaluation and Results**\n"
|
||||
" - Summarize how the model was evaluated and key performance metrics\n"
|
||||
" - Optionally include plots, confusion matrices, or sample outputs\n\n"
|
||||
"7. **Inference / How to Use the Model**\n"
|
||||
" - Explain how to run inference or apply the model to new data\n"
|
||||
" - Include input/output formats and example commands or code\n\n"
|
||||
"8. **Technologies Used**\n"
|
||||
" - List key tools, libraries, and frameworks (e.g., scikit-learn, TensorFlow, pandas)\n\n"
|
||||
"9. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Use code blocks and examples where appropriate\n"
|
||||
"- Ensure reproducibility by including all necessary setup instructions\n"
|
||||
"- Keep the tone professional and geared toward data scientists or ML engineers"
|
||||
),
|
||||
"plugin": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a plugin or extension "
|
||||
"designed to integrate with a larger platform (such as a CMS, IDE, or framework).\n\n"
|
||||
"Format the output using Markdown with clear section headers.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Describe what this plugin does and the host system it's built for\n"
|
||||
" - List key features and benefits\n\n"
|
||||
"2. **Installation**\n"
|
||||
" - Provide installation instructions specific to the host platform\n"
|
||||
" - Mention compatible versions and any prerequisites\n\n"
|
||||
"3. **Usage**\n"
|
||||
" - Show how to enable and configure the plugin\n"
|
||||
" - Include code snippets or configuration steps\n\n"
|
||||
"4. **Integration Points**\n"
|
||||
" - Describe hooks, lifecycle methods, or extension APIs the plugin interacts with\n\n"
|
||||
"5. **Project Structure**\n"
|
||||
" - Briefly explain key files and folders\n\n"
|
||||
"6. **Technologies Used**\n"
|
||||
" - List frameworks, languages, or tooling\n\n"
|
||||
"7. **License**\n"
|
||||
" - State the license type and link to the license file"
|
||||
),
|
||||
"chrome_extension": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a Chrome extension "
|
||||
"project.\n\n"
|
||||
"Format the output using Markdown with clear section headers.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Describe the purpose and features of the extension\n\n"
|
||||
"2. **Installation**\n"
|
||||
" - Include instructions for loading the extension in Chrome (via the Extensions page or Chrome Web Store)\n"
|
||||
" - Mention required permissions and how to review the manifest\n\n"
|
||||
"3. **Usage**\n"
|
||||
" - Explain how users interact with the extension (e.g., popup UI, context menu, background scripts)\n"
|
||||
" - Include example scenarios or screenshots if applicable\n\n"
|
||||
"4. **Project Structure**\n"
|
||||
" - Briefly describe key files like `manifest.json`, `background.js`, and popup components\n\n"
|
||||
"5. **Technologies Used**\n"
|
||||
" - List libraries or frameworks (e.g., vanilla JS, React, Tailwind)\n\n"
|
||||
"6. **License**\n"
|
||||
" - State the license type and link to the license file"
|
||||
),
|
||||
"jupyter_notebook": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which consists of one or more "
|
||||
"Jupyter notebooks.\n\n"
|
||||
"Format the output using Markdown with clear section headers.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Describe the purpose of the notebooks and what they demonstrate or analyze\n\n"
|
||||
"2. **Getting Started**\n"
|
||||
" - Provide instructions for setting up the environment (e.g., installing Jupyter, dependencies, "
|
||||
"virtualenv)\n"
|
||||
" - Mention how to launch the notebooks (e.g., `jupyter notebook` or `jupyter lab`)\n\n"
|
||||
"3. **Notebook Summary**\n"
|
||||
" - List and briefly describe each notebook in the repo\n"
|
||||
" - Mention whether they build on each other or are standalone\n\n"
|
||||
"4. **Dataset (if applicable)**\n"
|
||||
" - Describe any datasets used and where they come from\n\n"
|
||||
"5. **Technologies Used**\n"
|
||||
" - List libraries (e.g., pandas, matplotlib, scikit-learn)\n\n"
|
||||
"6. **License**\n"
|
||||
" - State the license type and link to the license file"
|
||||
),
|
||||
"infrastructure": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which contains "
|
||||
"infrastructure-as-code or deployment configuration (e.g., Docker, Terraform, Ansible).\n\n"
|
||||
"Format the output using Markdown with clear section headers.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Explain what infrastructure is being managed and its intended use\n\n"
|
||||
"2. **Setup**\n"
|
||||
" - Describe any prerequisites (e.g., installing Docker, Terraform CLI, cloud access credentials)\n"
|
||||
" - Include instructions for initializing and applying the configuration\n\n"
|
||||
"3. **Configuration Files**\n"
|
||||
" - Explain the structure and purpose of major files (e.g., `main.tf`, `docker-compose.yml`, "
|
||||
"`playbooks/`)\n\n"
|
||||
"4. **Deployment Workflow**\n"
|
||||
" - Describe how deployments are triggered and verified\n"
|
||||
" - Mention any CI/CD pipelines, remote state management, or secrets handling\n\n"
|
||||
"5. **Environments**\n"
|
||||
" - Clarify how to deploy to multiple environments (dev, staging, prod)\n\n"
|
||||
"6. **License**\n"
|
||||
" - State the license type and link to the license file"
|
||||
),
|
||||
"smart_contract": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which contains smart contracts "
|
||||
"written for a blockchain platform (e.g., Ethereum, Solana).\n\n"
|
||||
"Format the output using Markdown with clear section headers.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Explain the purpose and functionality of the smart contracts\n"
|
||||
" - Mention the target blockchain platform\n\n"
|
||||
"2. **Installation and Setup**\n"
|
||||
" - List dependencies and setup instructions (e.g., hardhat, anchor, solana-cli)\n"
|
||||
" - Include local devnet instructions if applicable\n\n"
|
||||
"3. **Contracts**\n"
|
||||
" - Describe the main contract(s) and what each one does\n"
|
||||
" - Include deployment steps and how to interact with them\n\n"
|
||||
"4. **Testing**\n"
|
||||
" - Explain how to run tests and what framework is used\n\n"
|
||||
"5. **Project Structure**\n"
|
||||
" - Describe layout of contracts, migrations, and test files\n\n"
|
||||
"6. **License**\n"
|
||||
" - State the license type and link to the license file"
|
||||
),
|
||||
"dapp": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a decentralized application "
|
||||
"(dApp) that includes both smart contract(s) and a web-based frontend.\n\n"
|
||||
"Format the output using Markdown with clear section headers and examples for both on-chain and off-chain "
|
||||
"components.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Describe what the dApp does and the blockchain ecosystem it runs on\n"
|
||||
" - Mention the smart contract platform (e.g., Ethereum, Solana, NEAR) and wallet compatibility\n\n"
|
||||
"2. **Architecture**\n"
|
||||
" - Provide a high-level diagram or explanation of how the frontend interacts with smart contracts\n"
|
||||
" - Mention key technologies used on both sides (e.g., React, Ethers.js, Anchor, Web3.js)\n\n"
|
||||
"3. **Getting Started**\n"
|
||||
" - Provide setup instructions for both frontend and backend\n"
|
||||
" - Include how to install dependencies, configure environment variables, and run locally\n\n"
|
||||
"4. **Smart Contracts**\n"
|
||||
" - Describe the deployed contracts and how to interact with them\n"
|
||||
" - Include deployment instructions and test commands\n\n"
|
||||
"5. **Frontend**\n"
|
||||
" - Describe key UI components and user flows (e.g., connect wallet, mint token, submit vote)\n"
|
||||
" - Mention any integrations with IPFS, oracles, or off-chain data\n\n"
|
||||
"6. **License**\n"
|
||||
" - State the license type and link to the license file"
|
||||
),
|
||||
"game": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a game or game engine "
|
||||
"project.\n\n"
|
||||
"Format the output using Markdown with clear section headers and provide clear instructions for playing and "
|
||||
"modifying the game.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Describe the game concept, genre, and platform (e.g., browser, desktop, mobile)\n"
|
||||
" - Mention gameplay goals or mechanics\n\n"
|
||||
"2. **Installation and Setup**\n"
|
||||
" - Provide instructions for installing dependencies and running the game\n"
|
||||
" - Include setup for game engines or SDKs (e.g., Unity, Godot, Phaser, Unreal)\n\n"
|
||||
"3. **Controls and Gameplay**\n"
|
||||
" - Explain player controls and core mechanics\n"
|
||||
" - Optionally include screenshots, video, or demo links\n\n"
|
||||
"4. **Project Structure**\n"
|
||||
" - Describe key files and folders (e.g., assets, levels, scripts)\n\n"
|
||||
"5. **Technologies Used**\n"
|
||||
" - List engines, frameworks, or libraries used to build the game\n\n"
|
||||
"6. **License**\n"
|
||||
" - State the license type and link to the license file"
|
||||
),
|
||||
"desktop_app": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which is a desktop application "
|
||||
"project built with technologies like Electron, Tauri, Qt, or native frameworks.\n\n"
|
||||
"Format the output using Markdown with clear section headers and platform-aware instructions.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Describe what the desktop app does and who it's for\n"
|
||||
" - Mention platforms supported (e.g., Windows, macOS, Linux)\n\n"
|
||||
"2. **Installation and Setup**\n"
|
||||
" - Provide platform-specific install/build instructions\n"
|
||||
" - Include steps for running the app in development and building a production release\n\n"
|
||||
"3. **Usage**\n"
|
||||
" - Describe the app's main features and user workflows\n"
|
||||
" - Include screenshots if applicable\n\n"
|
||||
"4. **Project Structure**\n"
|
||||
" - Describe key files and folders (e.g., main process, renderer process, assets)\n\n"
|
||||
"5. **Technologies Used**\n"
|
||||
" - List major libraries, frameworks, and build tools\n\n"
|
||||
"6. **License**\n"
|
||||
" - State the license type and link to the license file"
|
||||
),
|
||||
"dataset": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository, which contains a dataset for "
|
||||
"analysis, training, or research purposes.\n\n"
|
||||
"Format the output using Markdown with clear section headers and data-focused structure.\n\n"
|
||||
"Include the following sections:\n"
|
||||
"1. **Overview**\n"
|
||||
" - Describe what the dataset contains and its intended purpose\n"
|
||||
" - Mention the source and whether it was collected, generated, or aggregated\n\n"
|
||||
"2. **Dataset Details**\n"
|
||||
" - Describe the structure and format (e.g., CSV, JSON, images, text)\n"
|
||||
" - Include column definitions, schema, or data dictionaries\n"
|
||||
" - Mention the number of records, size, and any notable characteristics\n\n"
|
||||
"3. **Usage Instructions**\n"
|
||||
" - Provide example code snippets for loading and using the dataset (e.g., pandas, SQL, etc.)\n"
|
||||
" - Mention any preprocessing steps if needed\n\n"
|
||||
"4. **Licensing and Terms of Use**\n"
|
||||
" - State the license and any restrictions on usage or distribution\n"
|
||||
" - Include citation or attribution instructions if required\n\n"
|
||||
"5. **Related Work / Source Links**\n"
|
||||
" - Link to original data sources, research papers, or related projects (if applicable)"
|
||||
),
|
||||
"other": (
|
||||
"Please scan the repository and generate or update a complete and professional readme_prometheus.md file for this repository.\n\n"
|
||||
"{previous_review_comments_section}\n\n"
|
||||
"Analyze the contents of the repository to infer its intent, and format the README using Markdown with "
|
||||
"clear section headers.\n\n"
|
||||
"Include the following general sections, customizing them as needed based on the repository type:\n"
|
||||
"1. **Project Overview**\n"
|
||||
" - Describe the purpose of the project and its main functionality\n"
|
||||
" - Summarize what the project does and who it's for\n\n"
|
||||
"2. **Getting Started**\n"
|
||||
" - Include setup or usage instructions based on the repo's structure\n"
|
||||
" - Mention installation steps, dependencies, and commands to run or use the project\n\n"
|
||||
"3. **Features / Capabilities**\n"
|
||||
" - List the core features or components of the project\n"
|
||||
" - Include relevant examples, demos, or configurations if applicable\n\n"
|
||||
"4. **Project Structure**\n"
|
||||
" - Describe the layout of files and folders, especially any key scripts, configs, or assets\n\n"
|
||||
"5. **Technologies Used**\n"
|
||||
" - List any major frameworks, libraries, or languages identified in the project\n\n"
|
||||
"6. **Usage Examples** (if applicable)\n"
|
||||
" - Include example commands or steps showing how to use the project\n\n"
|
||||
"7. **License**\n"
|
||||
" - State the license type and link to the license file\n\n"
|
||||
"Additional Notes:\n"
|
||||
"- Focus on making the README useful and descriptive, even if the project type is ambiguous\n"
|
||||
"- Use best judgment to tailor the content to the actual functionality and audience of the project\n"
|
||||
"- Avoid placeholder text and strive to extract real, useful information from the codebase"
|
||||
),
|
||||
"review_readme_file": (
|
||||
"Review the readme_prometheus.md file in the repository and evaluate its quality and relevance to the repository.\n\n"
|
||||
"Please analyze:\n"
|
||||
"1. Is the readme_prometheus.md file related to this specific repository? (Does it describe the actual code and purpose of this repo?)\n"
|
||||
"2. Does it correctly explain the repository's purpose, features, and functionality?\n"
|
||||
"3. Is it comprehensive enough to help users understand and use the repository?\n"
|
||||
"4. Does it follow best practices for README documentation?\n\n"
|
||||
"Use the validate_implementation tool to submit your findings.\n"
|
||||
"STOP after submitting the review report."
|
||||
),
|
||||
"previous_review_comments": (
|
||||
"Here are the comments from the previous review:\n"
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
277
worker/orca-agent/src/workflows/repoSummarizer/workflow.py
Normal file
277
worker/orca-agent/src/workflows/repoSummarizer/workflow.py
Normal file
@ -0,0 +1,277 @@
|
||||
"""Task decomposition workflow implementation."""
|
||||
|
||||
import os
|
||||
from github import Github
|
||||
from prometheus_swarm.workflows.base import Workflow
|
||||
from prometheus_swarm.utils.logging import log_section, log_key_value, log_error
|
||||
from src.workflows.repoSummarizer import phases
|
||||
from prometheus_swarm.workflows.utils import (
|
||||
check_required_env_vars,
|
||||
cleanup_repository,
|
||||
validate_github_auth,
|
||||
setup_repository
|
||||
)
|
||||
from src.workflows.repoSummarizer.prompts import PROMPTS
|
||||
|
||||
|
||||
class Task:
|
||||
def __init__(self, title: str, description: str, acceptance_criteria: list[str]):
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.acceptance_criteria = acceptance_criteria
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert task to dictionary format."""
|
||||
return {
|
||||
"title": self.title,
|
||||
"description": self.description,
|
||||
"acceptance_criteria": self.acceptance_criteria,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict) -> "Task":
|
||||
"""Create task from dictionary."""
|
||||
return cls(
|
||||
title=data["title"],
|
||||
description=data["description"],
|
||||
acceptance_criteria=data["acceptance_criteria"],
|
||||
)
|
||||
|
||||
|
||||
class RepoSummarizerWorkflow(Workflow):
|
||||
def __init__(
|
||||
self,
|
||||
client,
|
||||
prompts,
|
||||
repo_url,
|
||||
):
|
||||
# Extract owner and repo name from URL
|
||||
# URL format: https://github.com/owner/repo
|
||||
parts = repo_url.strip("/").split("/")
|
||||
repo_owner = parts[-2]
|
||||
repo_name = parts[-1]
|
||||
|
||||
super().__init__(
|
||||
client=client,
|
||||
prompts=prompts,
|
||||
repo_url=repo_url,
|
||||
repo_owner=repo_owner,
|
||||
repo_name=repo_name,
|
||||
)
|
||||
|
||||
def setup(self):
|
||||
"""Set up repository and workspace."""
|
||||
check_required_env_vars(["GITHUB_TOKEN", "GITHUB_USERNAME"])
|
||||
validate_github_auth(os.getenv("GITHUB_TOKEN"), os.getenv("GITHUB_USERNAME"))
|
||||
|
||||
# Get the default branch from GitHub
|
||||
try:
|
||||
gh = Github(os.getenv("GITHUB_TOKEN"))
|
||||
self.context["repo_full_name"] = (
|
||||
f"{self.context['repo_owner']}/{self.context['repo_name']}"
|
||||
)
|
||||
|
||||
repo = gh.get_repo(
|
||||
f"{self.context['repo_owner']}/{self.context['repo_name']}"
|
||||
)
|
||||
self.context["base"] = repo.default_branch
|
||||
log_key_value("Default branch", self.context["base"])
|
||||
except Exception as e:
|
||||
log_error(e, "Failed to get default branch, using 'main'")
|
||||
self.context["base"] = "main"
|
||||
|
||||
# Set up repository directory
|
||||
setup_result = setup_repository(self.context["repo_url"], github_token=os.getenv("GITHUB_TOKEN"), github_username=os.getenv("GITHUB_USERNAME"))
|
||||
if not setup_result["success"]:
|
||||
raise Exception(f"Failed to set up repository: {setup_result['message']}")
|
||||
self.context["github_token"] = os.getenv("GITHUB_TOKEN")
|
||||
self.context["repo_path"] = setup_result["data"]["clone_path"]
|
||||
self.original_dir = setup_result["data"]["original_dir"]
|
||||
self.context["fork_url"] = setup_result["data"]["fork_url"]
|
||||
self.context["fork_owner"] = setup_result["data"]["fork_owner"]
|
||||
self.context["fork_name"] = setup_result["data"]["fork_name"]
|
||||
|
||||
# Enter repo directory
|
||||
os.chdir(self.context["repo_path"])
|
||||
|
||||
# Configure Git user info
|
||||
# setup_git_user_config(self.context["repo_path"])
|
||||
|
||||
# Get current files for context
|
||||
|
||||
def cleanup(self):
|
||||
"""Cleanup workspace."""
|
||||
# Make sure we're not in the repo directory before cleaning up
|
||||
if os.getcwd() == self.context.get("repo_path", ""):
|
||||
os.chdir(self.original_dir)
|
||||
|
||||
# Clean up the repository directory
|
||||
cleanup_repository(self.original_dir, self.context.get("repo_path", ""))
|
||||
# Clean up the MongoDB
|
||||
|
||||
def run(self):
|
||||
self.setup()
|
||||
|
||||
# Create a feature branch
|
||||
log_section("CREATING FEATURE BRANCH")
|
||||
branch_phase = phases.BranchCreationPhase(workflow=self)
|
||||
branch_result = branch_phase.execute()
|
||||
|
||||
if not branch_result or not branch_result.get("success"):
|
||||
log_error(Exception("Branch creation failed"), "Branch creation failed")
|
||||
return {
|
||||
"success": False,
|
||||
"message": "Branch creation failed",
|
||||
"data": None,
|
||||
}
|
||||
|
||||
# Store branch name in context
|
||||
self.context["head"] = branch_result["data"]["branch_name"]
|
||||
log_key_value("Branch created", self.context["head"])
|
||||
|
||||
# Classify repository
|
||||
repo_classification_result = self.classify_repository()
|
||||
if not repo_classification_result or not repo_classification_result.get(
|
||||
"success"
|
||||
):
|
||||
log_error(
|
||||
Exception("Repository classification failed"),
|
||||
"Repository classification failed",
|
||||
)
|
||||
return {
|
||||
"success": False,
|
||||
"message": "Repository classification failed",
|
||||
"data": None,
|
||||
}
|
||||
|
||||
# Get prompt name for README generation
|
||||
prompt_name = repo_classification_result["data"].get("prompt_name")
|
||||
if not prompt_name:
|
||||
log_error(
|
||||
Exception("No prompt name returned from repository classification"),
|
||||
"Repository classification failed to provide prompt name",
|
||||
)
|
||||
return {
|
||||
"success": False,
|
||||
"message": "Repository classification failed to provide prompt name",
|
||||
"data": None,
|
||||
}
|
||||
|
||||
# Generate README file
|
||||
for i in range(3):
|
||||
if i > 0:
|
||||
prompt_name = "other"
|
||||
readme_result = self.generate_readme_file(prompt_name)
|
||||
if not readme_result or not readme_result.get("success"):
|
||||
log_error(Exception("README generation failed"), "README generation failed")
|
||||
return {
|
||||
"success": False,
|
||||
"message": "README generation failed",
|
||||
"data": None,
|
||||
}
|
||||
if readme_result.get("success"):
|
||||
review_result = self.review_readme_file(readme_result)
|
||||
if not review_result or not review_result.get("success"):
|
||||
log_error(Exception("README review failed"), "README review failed")
|
||||
return {
|
||||
"success": False,
|
||||
"message": "README review failed",
|
||||
"data": None,
|
||||
}
|
||||
log_key_value("README review result", review_result.get("data"))
|
||||
if review_result.get("success") and review_result.get("data").get("recommendation") == "APPROVE":
|
||||
result = self.create_pull_request()
|
||||
return result
|
||||
else:
|
||||
self.context["previous_review_comments_section"] = PROMPTS["previous_review_comments"] + review_result.get("data").get("comment")
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
"success": False,
|
||||
"message": "README Review Exceed Max Attempts",
|
||||
"data": None,
|
||||
}
|
||||
|
||||
def classify_repository(self):
|
||||
try:
|
||||
log_section("CLASSIFYING REPOSITORY TYPE")
|
||||
repo_classification_phase = phases.RepoClassificationPhase(workflow=self)
|
||||
return repo_classification_phase.execute()
|
||||
except Exception as e:
|
||||
log_error(e, "Repository classification workflow failed")
|
||||
return {
|
||||
"success": False,
|
||||
"message": f"Repository classification workflow failed: {str(e)}",
|
||||
"data": None,
|
||||
}
|
||||
def review_readme_file(self, readme_result):
|
||||
"""Execute the issue generation workflow."""
|
||||
try:
|
||||
log_section("REVIEWING README FILE")
|
||||
review_readme_file_phase = phases.ReadmeReviewPhase(workflow=self)
|
||||
return review_readme_file_phase.execute()
|
||||
except Exception as e:
|
||||
log_error(e, "Readme file review workflow failed")
|
||||
return {
|
||||
"success": False,
|
||||
"message": f"Readme file review workflow failed: {str(e)}",
|
||||
"data": None,
|
||||
}
|
||||
|
||||
def generate_readme_file(self, prompt_name):
|
||||
"""Execute the issue generation workflow."""
|
||||
try:
|
||||
|
||||
# ==================== Generate README file ====================
|
||||
log_section("GENERATING README FILE")
|
||||
generate_readme_file_phase = phases.ReadmeGenerationPhase(
|
||||
workflow=self, prompt_name=prompt_name
|
||||
)
|
||||
readme_result = generate_readme_file_phase.execute()
|
||||
|
||||
# Check README Generation Result
|
||||
if not readme_result or not readme_result.get("success"):
|
||||
log_error(
|
||||
Exception(readme_result.get("error", "No result")),
|
||||
"Readme file generation failed",
|
||||
)
|
||||
return None
|
||||
|
||||
return readme_result
|
||||
|
||||
except Exception as e:
|
||||
log_error(e, "Readme file generation workflow failed")
|
||||
return {
|
||||
"success": False,
|
||||
"message": f"Readme file generation workflow failed: {str(e)}",
|
||||
"data": None,
|
||||
}
|
||||
|
||||
def create_pull_request(self):
|
||||
"""Create a pull request for the README file."""
|
||||
try:
|
||||
log_section("CREATING PULL REQUEST")
|
||||
|
||||
# Add required PR title and description parameters to context
|
||||
self.context["title"] = f"Prometheus: Add README for {self.context['repo_name']}"
|
||||
self.context["description"] = (
|
||||
f"This PR adds a README file for the {self.context['repo_name']} repository."
|
||||
)
|
||||
|
||||
log_key_value(
|
||||
"Creating PR",
|
||||
f"from {self.context['head']} to {self.context['base']}",
|
||||
)
|
||||
|
||||
print("CONTEXT", self.context)
|
||||
create_pull_request_phase = phases.CreatePullRequestPhase(workflow=self)
|
||||
return create_pull_request_phase.execute()
|
||||
except Exception as e:
|
||||
log_error(e, "Pull request creation workflow failed")
|
||||
return {
|
||||
"success": False,
|
||||
"message": f"Pull request creation workflow failed: {str(e)}",
|
||||
"data": None,
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
"""Entry point for the todo creator workflow."""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from dotenv import load_dotenv
|
||||
from src.workflows.repoSummarizerAudit.workflow import repoSummarizerAuditWorkflow
|
||||
from src.workflows.repoSummarizerAudit.prompts import PROMPTS
|
||||
from prometheus_swarm.clients import setup_client
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the todo creator workflow."""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Create tasks from a feature specification for a GitHub repository"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--pr-url",
|
||||
type=str,
|
||||
required=True,
|
||||
help="GitHub pull request URL (e.g., https://github.com/owner/repo/pull/1)",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--model",
|
||||
type=str,
|
||||
default="anthropic",
|
||||
choices=["anthropic", "openai", "xai"],
|
||||
help="Model provider to use (default: anthropic)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Initialize client
|
||||
client = setup_client(args.model)
|
||||
|
||||
# Run the todo creator workflow
|
||||
workflow = repoSummarizerAuditWorkflow(
|
||||
client=client,
|
||||
prompts=PROMPTS,
|
||||
pr_url=args.pr_url,
|
||||
)
|
||||
|
||||
result = workflow.run()
|
||||
if not result or not result.get("success"):
|
||||
print("Todo creator workflow failed")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,15 @@
|
||||
"""Task decomposition workflow phases implementation."""
|
||||
|
||||
from prometheus_swarm.workflows.base import WorkflowPhase, Workflow
|
||||
|
||||
|
||||
class CheckReadmeFilePhase(WorkflowPhase):
|
||||
def __init__(self, workflow: Workflow, conversation_id: str = None):
|
||||
super().__init__(
|
||||
workflow=workflow,
|
||||
prompt_name="check_readme_file",
|
||||
available_tools=["read_file", "list_files", "review_pull_request_legacy"],
|
||||
conversation_id=conversation_id,
|
||||
name="Check Readme File",
|
||||
)
|
||||
|
@ -0,0 +1,29 @@
|
||||
"""Prompts for the repository summarization workflow."""
|
||||
|
||||
PROMPTS = {
|
||||
"system_prompt": (
|
||||
"You are an expert software architect and technical lead specializing in summarizing "
|
||||
"repositories into comprehensive documentation. You excel at analyzing codebases "
|
||||
"and creating clear, structured documentation."
|
||||
),
|
||||
|
||||
"check_readme_file": (
|
||||
"A pull request has been checked out for you. The repository is {repo_owner}/{repo_name} and "
|
||||
"the PR number is {pr_number}. The following files are available:\n"
|
||||
"{current_files}\n\n"
|
||||
"The criteria for the README file are:\n"
|
||||
"1. Project Overview\n"
|
||||
" - Purpose and main functionality\n"
|
||||
" - Key features\n"
|
||||
"2. Repository Structure\n"
|
||||
" - Detailed breakdown of directories and their purposes\n"
|
||||
" - Key files and their roles\n"
|
||||
"3. Technical Details\n"
|
||||
" - Technologies used\n"
|
||||
" - Architecture overview\n"
|
||||
"4. File Contents\n"
|
||||
" - Specific description of each significant file\n\n"
|
||||
"Please review the README file and give feedback.\n"
|
||||
),
|
||||
|
||||
}
|
163
worker/orca-agent/src/workflows/repoSummarizerAudit/workflow.py
Normal file
163
worker/orca-agent/src/workflows/repoSummarizerAudit/workflow.py
Normal file
@ -0,0 +1,163 @@
|
||||
"""Task decomposition workflow implementation."""
|
||||
|
||||
import os
|
||||
from github import Github
|
||||
from prometheus_swarm.workflows.base import Workflow
|
||||
from prometheus_swarm.utils.logging import log_section, log_key_value, log_error
|
||||
from src.workflows.repoSummarizerAudit import phases
|
||||
from prometheus_swarm.workflows.utils import (
|
||||
check_required_env_vars,
|
||||
validate_github_auth,
|
||||
setup_repository,
|
||||
cleanup_repository,
|
||||
get_current_files,
|
||||
)
|
||||
from git import Repo
|
||||
|
||||
|
||||
class Task:
|
||||
def __init__(self, title: str, description: str, acceptance_criteria: list[str]):
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.acceptance_criteria = acceptance_criteria
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert task to dictionary format."""
|
||||
return {
|
||||
"title": self.title,
|
||||
"description": self.description,
|
||||
"acceptance_criteria": self.acceptance_criteria,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict) -> "Task":
|
||||
"""Create task from dictionary."""
|
||||
return cls(
|
||||
title=data["title"],
|
||||
description=data["description"],
|
||||
acceptance_criteria=data["acceptance_criteria"],
|
||||
)
|
||||
|
||||
|
||||
class repoSummarizerAuditWorkflow(Workflow):
|
||||
def __init__(
|
||||
self,
|
||||
client,
|
||||
prompts,
|
||||
pr_url,
|
||||
):
|
||||
# Extract owner and repo name from URL
|
||||
# URL format: https://github.com/owner/repo
|
||||
parts = pr_url.strip("/").split("/")
|
||||
repo_owner = parts[-4]
|
||||
repo_name = parts[-3]
|
||||
pr_number = int(parts[-1]) # Convert to integer
|
||||
super().__init__(
|
||||
client=client,
|
||||
prompts=prompts,
|
||||
repo_owner=repo_owner,
|
||||
repo_name=repo_name,
|
||||
pr_number=pr_number,
|
||||
)
|
||||
self.context["pr_number"] = pr_number
|
||||
self.context["pr_url"] = pr_url
|
||||
self.context["repo_owner"] = repo_owner
|
||||
self.context["repo_name"] = repo_name
|
||||
self.context["repo_full_name"] = f"{repo_owner}/{repo_name}"
|
||||
|
||||
def setup(self):
|
||||
"""Set up repository and workspace."""
|
||||
# Check required environment variables and validate GitHub auth
|
||||
check_required_env_vars(["GITHUB_TOKEN", "GITHUB_USERNAME"])
|
||||
validate_github_auth(os.getenv("GITHUB_TOKEN"), os.getenv("GITHUB_USERNAME"))
|
||||
self.context["repo_url"] = f"https://github.com/{self.context['repo_owner']}/{self.context['repo_name']}"
|
||||
# Set up repository directory
|
||||
setup_result = setup_repository(self.context["repo_url"], github_token=os.getenv("GITHUB_TOKEN"), github_username=os.getenv("GITHUB_USERNAME"))
|
||||
if not setup_result["success"]:
|
||||
raise Exception(f"Failed to set up repository: {setup_result['message']}")
|
||||
|
||||
self.context["repo_path"] = setup_result["data"]["clone_path"]
|
||||
self.original_dir = setup_result["data"]["original_dir"]
|
||||
self.context["fork_url"] = setup_result["data"]["fork_url"]
|
||||
self.context["fork_owner"] = setup_result["data"]["fork_owner"]
|
||||
self.context["fork_name"] = setup_result["data"]["fork_name"]
|
||||
self.context["github_token"] = os.getenv("GITHUB_TOKEN")
|
||||
# Enter repo directory
|
||||
os.chdir(self.context["repo_path"])
|
||||
gh = Github(self.context["github_token"])
|
||||
repo = gh.get_repo(
|
||||
f"{self.context['repo_owner']}/{self.context['repo_name']}"
|
||||
)
|
||||
pr = repo.get_pull(self.context["pr_number"])
|
||||
self.context["pr"] = pr
|
||||
# Add remote for PR's repository and fetch the branch
|
||||
os.system(
|
||||
f"git remote add pr_source https://github.com/{pr.head.repo.full_name}"
|
||||
)
|
||||
os.system(f"git fetch pr_source {pr.head.ref}")
|
||||
os.system("git checkout FETCH_HEAD")
|
||||
|
||||
# Get current files for context
|
||||
self.context["current_files"] = get_current_files()
|
||||
|
||||
def cleanup(self):
|
||||
"""Cleanup workspace."""
|
||||
# Make sure we're not in the repo directory before cleaning up
|
||||
if os.getcwd() == self.context.get("repo_path", ""):
|
||||
os.chdir(self.original_dir)
|
||||
|
||||
# Clean up the repository directory
|
||||
cleanup_repository(self.original_dir, self.context.get("repo_path", ""))
|
||||
# Clean up the MongoDB
|
||||
|
||||
def run(self):
|
||||
check_readme_file_result = self.check_readme_file()
|
||||
|
||||
return check_readme_file_result
|
||||
|
||||
def check_readme_file(self):
|
||||
"""Execute the issue generation workflow."""
|
||||
try:
|
||||
self.setup()
|
||||
# ==================== Generate issues ====================
|
||||
check_readme_file_phase = phases.CheckReadmeFilePhase(workflow=self)
|
||||
check_readme_file_result = check_readme_file_phase.execute()
|
||||
# Check Issue Generation Result
|
||||
if not check_readme_file_result or not check_readme_file_result.get(
|
||||
"success"
|
||||
):
|
||||
log_error(
|
||||
Exception(check_readme_file_result.get("error", "No result")),
|
||||
"Readme file check failed",
|
||||
)
|
||||
return {
|
||||
"success": False,
|
||||
"message": "Readme file check failed",
|
||||
"data": {
|
||||
"recommendation": False,
|
||||
},
|
||||
}
|
||||
log_section("Readme file check completed")
|
||||
print(check_readme_file_result)
|
||||
recommendation = check_readme_file_result["data"]["recommendation"]
|
||||
log_key_value(
|
||||
"Readme file check completed", f"Recommendation: {recommendation}"
|
||||
)
|
||||
# Star the repository
|
||||
return {
|
||||
"success": True,
|
||||
"message": "Readme file check completed",
|
||||
"data": {
|
||||
"recommendation": recommendation == "APPROVE",
|
||||
},
|
||||
}
|
||||
except Exception as e:
|
||||
log_error(e, "Readme file check workflow failed")
|
||||
print(e)
|
||||
return {
|
||||
"success": False,
|
||||
"message": f"Readme file check workflow failed: {str(e)}",
|
||||
"data": {
|
||||
"recommendation": False,
|
||||
},
|
||||
}
|
57
worker/orca-agent/src/workflows/starRepo/__main__.py
Normal file
57
worker/orca-agent/src/workflows/starRepo/__main__.py
Normal file
@ -0,0 +1,57 @@
|
||||
"""Entry point for the todo creator workflow."""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
from dotenv import load_dotenv
|
||||
from src.workflows.starRepo.workflow import StarRepoWorkflow
|
||||
from src.workflows.starRepo.prompts import PROMPTS
|
||||
from prometheus_swarm.clients import setup_client
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the todo creator workflow."""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Create tasks from a feature specification for a GitHub repository"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--repo",
|
||||
type=str,
|
||||
required=True,
|
||||
help="GitHub repository URL (e.g., https://github.com/owner/repo)",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--model",
|
||||
type=str,
|
||||
default="anthropic",
|
||||
choices=["anthropic", "openai", "xai"],
|
||||
help="Model provider to use (default: anthropic)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Initialize client
|
||||
client = setup_client(args.model)
|
||||
|
||||
# Run the todo creator workflow
|
||||
workflow = StarRepoWorkflow(
|
||||
client=client,
|
||||
prompts=PROMPTS,
|
||||
repo_url=args.repo,
|
||||
)
|
||||
|
||||
|
||||
result = workflow.run()
|
||||
if not result or not result.get("success"):
|
||||
print("Todo creator workflow failed")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
15
worker/orca-agent/src/workflows/starRepo/phases.py
Normal file
15
worker/orca-agent/src/workflows/starRepo/phases.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""Task decomposition workflow phases implementation."""
|
||||
|
||||
from prometheus_swarm.workflows.base import WorkflowPhase, Workflow
|
||||
|
||||
|
||||
class ReadmeGenerationPhase(WorkflowPhase):
|
||||
def __init__(self, workflow: Workflow, conversation_id: str = None):
|
||||
super().__init__(
|
||||
workflow=workflow,
|
||||
prompt_name="generate_readme_file",
|
||||
available_tools=["read_file", "write_file", "list_files", "commit_and_push"],
|
||||
conversation_id=conversation_id,
|
||||
name="Readme Generation",
|
||||
)
|
||||
|
29
worker/orca-agent/src/workflows/starRepo/prompts.py
Normal file
29
worker/orca-agent/src/workflows/starRepo/prompts.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Prompts for the repository summarization workflow."""
|
||||
|
||||
PROMPTS = {
|
||||
"system_prompt": (
|
||||
"You are an expert software architect and technical lead specializing in summarizing "
|
||||
"repositories into comprehensive documentation. You excel at analyzing codebases "
|
||||
"and creating clear, structured documentation."
|
||||
),
|
||||
|
||||
"generate_readme_file": (
|
||||
"Generate a comprehensive README file for the following repository:\n"
|
||||
"Repository: {repo_url}\n\n"
|
||||
"Please include:\n"
|
||||
"1. Project Overview\n"
|
||||
" - Purpose and main functionality\n"
|
||||
" - Key features\n"
|
||||
"2. Repository Structure\n"
|
||||
" - Detailed breakdown of directories and their purposes\n"
|
||||
" - Key files and their roles\n"
|
||||
"3. Technical Details\n"
|
||||
" - Technologies used\n"
|
||||
" - Architecture overview\n"
|
||||
"4. File Contents\n"
|
||||
" - Specific description of each significant file\n\n"
|
||||
"Format the output in markdown, ensuring clear section headers and proper formatting."
|
||||
"Please commit and push the changes to the repository after generating the README file."
|
||||
),
|
||||
|
||||
}
|
141
worker/orca-agent/src/workflows/starRepo/workflow.py
Normal file
141
worker/orca-agent/src/workflows/starRepo/workflow.py
Normal file
@ -0,0 +1,141 @@
|
||||
"""Task decomposition workflow implementation."""
|
||||
|
||||
import os
|
||||
from github import Github
|
||||
from prometheus_swarm.workflows.base import Workflow
|
||||
from prometheus_swarm.tools.github_operations.implementations import star_repository
|
||||
from prometheus_swarm.utils.logging import log_section, log_key_value, log_error
|
||||
from src.workflows.repoSummarizer import phases
|
||||
from prometheus_swarm.workflows.utils import (
|
||||
check_required_env_vars,
|
||||
validate_github_auth,
|
||||
)
|
||||
|
||||
|
||||
class Task:
|
||||
def __init__(self, title: str, description: str, acceptance_criteria: list[str]):
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.acceptance_criteria = acceptance_criteria
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert task to dictionary format."""
|
||||
return {
|
||||
"title": self.title,
|
||||
"description": self.description,
|
||||
"acceptance_criteria": self.acceptance_criteria,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict) -> "Task":
|
||||
"""Create task from dictionary."""
|
||||
return cls(
|
||||
title=data["title"],
|
||||
description=data["description"],
|
||||
acceptance_criteria=data["acceptance_criteria"],
|
||||
)
|
||||
|
||||
|
||||
class StarRepoWorkflow(Workflow):
|
||||
def __init__(
|
||||
self,
|
||||
client,
|
||||
prompts,
|
||||
repo_url,
|
||||
):
|
||||
# Extract owner and repo name from URL
|
||||
# URL format: https://github.com/owner/repo
|
||||
parts = repo_url.strip("/").split("/")
|
||||
repo_owner = parts[-2]
|
||||
repo_name = parts[-1]
|
||||
|
||||
super().__init__(
|
||||
client=client,
|
||||
prompts=prompts,
|
||||
repo_url=repo_url,
|
||||
repo_owner=repo_owner,
|
||||
repo_name=repo_name,
|
||||
)
|
||||
self.context["repo_owner"] = repo_owner
|
||||
self.context["repo_name"] = repo_name
|
||||
self.context["github_token"] = os.getenv("GITHUB_TOKEN")
|
||||
|
||||
def setup(self):
|
||||
"""Set up repository and workspace."""
|
||||
check_required_env_vars(["GITHUB_TOKEN", "GITHUB_USERNAME"])
|
||||
validate_github_auth(os.getenv("GITHUB_TOKEN"), os.getenv("GITHUB_USERNAME"))
|
||||
|
||||
# # Get the default branch from GitHub
|
||||
# try:
|
||||
# gh = Github(os.getenv("GITHUB_TOKEN"))
|
||||
# repo = gh.get_repo(
|
||||
# f"{self.context['repo_owner']}/{self.context['repo_name']}"
|
||||
# )
|
||||
# self.context["base_branch"] = repo.default_branch
|
||||
# log_key_value("Default branch", self.context["base_branch"])
|
||||
# except Exception as e:
|
||||
# log_error(e, "Failed to get default branch, using 'main'")
|
||||
# self.context["base_branch"] = "main"
|
||||
|
||||
# Set up repository directory
|
||||
# repo_path, original_dir = setup_repo_directory()
|
||||
# self.context["repo_path"] = repo_path
|
||||
# self.original_dir = original_dir
|
||||
|
||||
# # Fork and clone repository
|
||||
# log_section("FORKING AND CLONING REPOSITORY")
|
||||
# fork_result = fork_repository(
|
||||
# f"{self.context['repo_owner']}/{self.context['repo_name']}",
|
||||
# self.context["repo_path"],
|
||||
# )
|
||||
# if not fork_result["success"]:
|
||||
# error = fork_result.get("error", "Unknown error")
|
||||
# log_error(Exception(error), "Fork failed")
|
||||
# raise Exception(error)
|
||||
|
||||
# # Enter repo directory
|
||||
# os.chdir(self.context["repo_path"])
|
||||
|
||||
# # Configure Git user info
|
||||
# setup_git_user_config(self.context["repo_path"])
|
||||
|
||||
# Get current files for context
|
||||
|
||||
def cleanup(self):
|
||||
"""Cleanup workspace."""
|
||||
# cleanup_repository(self.original_dir, self.context.get("repo_path", ""))
|
||||
# Make sure we're not in the repo directory before cleaning up
|
||||
# if os.getcwd() == self.context.get("repo_path", ""):
|
||||
# os.chdir(self.original_dir)
|
||||
|
||||
# # Clean up the repository directory
|
||||
# cleanup_repo_directory(self.original_dir, self.context.get("repo_path", ""))
|
||||
# Clean up the MongoDB
|
||||
|
||||
def run(self):
|
||||
star_repo_result = self.start_star_repo()
|
||||
return star_repo_result
|
||||
|
||||
def start_star_repo(self):
|
||||
"""Execute the issue generation workflow."""
|
||||
try:
|
||||
self.setup()
|
||||
# ==================== Generate issues ====================
|
||||
star_repo_result = star_repository(
|
||||
self.context["repo_owner"], self.context["repo_name"], self.context["github_token"]
|
||||
)
|
||||
if not star_repo_result or not star_repo_result.get("success"):
|
||||
log_error(
|
||||
Exception(star_repo_result.get("error", "No result")),
|
||||
"Repository star failed",
|
||||
)
|
||||
return None
|
||||
return star_repo_result
|
||||
except Exception as e:
|
||||
log_error(e, "Readme file generation workflow failed")
|
||||
print(e)
|
||||
return {
|
||||
"success": False,
|
||||
"message": f"Readme file generation workflow failed: {str(e)}",
|
||||
"data": None,
|
||||
}
|
58
worker/orca-agent/src/workflows/starRepoAudit/__main__.py
Normal file
58
worker/orca-agent/src/workflows/starRepoAudit/__main__.py
Normal file
@ -0,0 +1,58 @@
|
||||
"""Entry point for the todo creator workflow."""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
from dotenv import load_dotenv
|
||||
from src.workflows.starRepoAudit.workflow import StarRepoAuditWorkflow
|
||||
from src.workflows.starRepoAudit.prompts import PROMPTS
|
||||
from prometheus_swarm.clients import setup_client
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the todo creator workflow."""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Create tasks from a feature specification for a GitHub repository"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--repo",
|
||||
type=str,
|
||||
required=True,
|
||||
help="GitHub repository URL (e.g., https://github.com/owner/repo)",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--model",
|
||||
type=str,
|
||||
default="anthropic",
|
||||
choices=["anthropic", "openai", "xai"],
|
||||
help="Model provider to use (default: anthropic)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Initialize client
|
||||
client = setup_client(args.model)
|
||||
|
||||
# Run the todo creator workflow
|
||||
workflow = StarRepoAuditWorkflow(
|
||||
client=client,
|
||||
prompts=PROMPTS,
|
||||
repo_url=args.repo,
|
||||
github_username="HermanL02",
|
||||
)
|
||||
|
||||
|
||||
result = workflow.run()
|
||||
if not result or not result.get("success"):
|
||||
print("Todo creator workflow failed")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
15
worker/orca-agent/src/workflows/starRepoAudit/phases.py
Normal file
15
worker/orca-agent/src/workflows/starRepoAudit/phases.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""Task decomposition workflow phases implementation."""
|
||||
|
||||
from src.workflows.base import WorkflowPhase, Workflow
|
||||
|
||||
|
||||
class ReadmeGenerationPhase(WorkflowPhase):
|
||||
def __init__(self, workflow: Workflow, conversation_id: str = None):
|
||||
super().__init__(
|
||||
workflow=workflow,
|
||||
prompt_name="generate_readme_file",
|
||||
available_tools=["read_file", "write_file", "list_files", "commit_and_push"],
|
||||
conversation_id=conversation_id,
|
||||
name="Readme Generation",
|
||||
)
|
||||
|
29
worker/orca-agent/src/workflows/starRepoAudit/prompts.py
Normal file
29
worker/orca-agent/src/workflows/starRepoAudit/prompts.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Prompts for the repository summarization workflow."""
|
||||
|
||||
PROMPTS = {
|
||||
"system_prompt": (
|
||||
"You are an expert software architect and technical lead specializing in summarizing "
|
||||
"repositories into comprehensive documentation. You excel at analyzing codebases "
|
||||
"and creating clear, structured documentation."
|
||||
),
|
||||
|
||||
"generate_readme_file": (
|
||||
"Generate a comprehensive README file for the following repository:\n"
|
||||
"Repository: {repo_url}\n\n"
|
||||
"Please include:\n"
|
||||
"1. Project Overview\n"
|
||||
" - Purpose and main functionality\n"
|
||||
" - Key features\n"
|
||||
"2. Repository Structure\n"
|
||||
" - Detailed breakdown of directories and their purposes\n"
|
||||
" - Key files and their roles\n"
|
||||
"3. Technical Details\n"
|
||||
" - Technologies used\n"
|
||||
" - Architecture overview\n"
|
||||
"4. File Contents\n"
|
||||
" - Specific description of each significant file\n\n"
|
||||
"Format the output in markdown, ensuring clear section headers and proper formatting."
|
||||
"Please commit and push the changes to the repository after generating the README file."
|
||||
),
|
||||
|
||||
}
|
151
worker/orca-agent/src/workflows/starRepoAudit/workflow.py
Normal file
151
worker/orca-agent/src/workflows/starRepoAudit/workflow.py
Normal file
@ -0,0 +1,151 @@
|
||||
"""Task decomposition workflow implementation."""
|
||||
|
||||
import os
|
||||
from github import Github
|
||||
from prometheus_swarm.workflows.base import Workflow
|
||||
from prometheus_swarm.tools.github_operations.implementations import (
|
||||
get_user_starred_repos,
|
||||
)
|
||||
from prometheus_swarm.utils.logging import log_section, log_key_value, log_error
|
||||
from src.workflows.repoSummarizer import phases
|
||||
from prometheus_swarm.workflows.utils import (
|
||||
check_required_env_vars,
|
||||
validate_github_auth,
|
||||
)
|
||||
|
||||
|
||||
class Task:
|
||||
def __init__(self, title: str, description: str, acceptance_criteria: list[str]):
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.acceptance_criteria = acceptance_criteria
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert task to dictionary format."""
|
||||
return {
|
||||
"title": self.title,
|
||||
"description": self.description,
|
||||
"acceptance_criteria": self.acceptance_criteria,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict) -> "Task":
|
||||
"""Create task from dictionary."""
|
||||
return cls(
|
||||
title=data["title"],
|
||||
description=data["description"],
|
||||
acceptance_criteria=data["acceptance_criteria"],
|
||||
)
|
||||
|
||||
|
||||
class StarRepoAuditWorkflow(Workflow):
|
||||
def __init__(
|
||||
self,
|
||||
client,
|
||||
prompts,
|
||||
repo_url,
|
||||
github_username,
|
||||
):
|
||||
# Extract owner and repo name from URL
|
||||
# URL format: https://github.com/owner/repo
|
||||
parts = repo_url.strip("/").split("/")
|
||||
repo_owner = parts[-2]
|
||||
repo_name = parts[-1]
|
||||
|
||||
super().__init__(
|
||||
client=client,
|
||||
prompts=prompts,
|
||||
repo_url=repo_url,
|
||||
repo_owner=repo_owner,
|
||||
repo_name=repo_name,
|
||||
github_username=github_username,
|
||||
)
|
||||
self.context["repo_owner"] = repo_owner
|
||||
self.context["repo_name"] = repo_name
|
||||
self.context["github_username"] = github_username
|
||||
|
||||
def setup(self):
|
||||
"""Set up repository and workspace."""
|
||||
check_required_env_vars(["GITHUB_TOKEN", "GITHUB_USERNAME"])
|
||||
validate_github_auth(os.getenv("GITHUB_TOKEN"), os.getenv("GITHUB_USERNAME"))
|
||||
|
||||
# # Get the default branch from GitHub
|
||||
# try:
|
||||
# gh = Github(os.getenv("GITHUB_TOKEN"))
|
||||
# repo = gh.get_repo(
|
||||
# f"{self.context['repo_owner']}/{self.context['repo_name']}"
|
||||
# )
|
||||
# self.context["base_branch"] = repo.default_branch
|
||||
# log_key_value("Default branch", self.context["base_branch"])
|
||||
# except Exception as e:
|
||||
# log_error(e, "Failed to get default branch, using 'main'")
|
||||
# self.context["base_branch"] = "main"
|
||||
|
||||
# # Set up repository directory
|
||||
# repo_path, original_dir = setup_repo_directory()
|
||||
# self.context["repo_path"] = repo_path
|
||||
# self.original_dir = original_dir
|
||||
|
||||
# # Fork and clone repository
|
||||
# log_section("FORKING AND CLONING REPOSITORY")
|
||||
# fork_result = fork_repository(
|
||||
# f"{self.context['repo_owner']}/{self.context['repo_name']}",
|
||||
# self.context["repo_path"],
|
||||
# )
|
||||
# if not fork_result["success"]:
|
||||
# error = fork_result.get("error", "Unknown error")
|
||||
# log_error(Exception(error), "Fork failed")
|
||||
# raise Exception(error)
|
||||
|
||||
# # Enter repo directory
|
||||
# os.chdir(self.context["repo_path"])
|
||||
|
||||
# # Configure Git user info
|
||||
# setup_git_user_config(self.context["repo_path"])
|
||||
|
||||
# # Get current files for context
|
||||
|
||||
def cleanup(self):
|
||||
"""Cleanup workspace."""
|
||||
# # Make sure we're not in the repo directory before cleaning up
|
||||
# if os.getcwd() == self.context.get("repo_path", ""):
|
||||
# os.chdir(self.original_dir)
|
||||
|
||||
# # Clean up the repository directory
|
||||
# cleanup_repo_directory(self.original_dir, self.context.get("repo_path", ""))
|
||||
# Clean up the MongoDB
|
||||
|
||||
def run(self):
|
||||
star_repo_result = self.check_star_repo()
|
||||
if not star_repo_result:
|
||||
log_error(
|
||||
Exception("Repository is not starred"), "Repository is not starred"
|
||||
)
|
||||
return False
|
||||
return star_repo_result
|
||||
|
||||
def check_star_repo(self):
|
||||
"""Check if the repository is starred."""
|
||||
try:
|
||||
print(self.context["github_username"])
|
||||
|
||||
starred_repos = get_user_starred_repos(self.context["github_username"])
|
||||
print(starred_repos)
|
||||
if not starred_repos or not starred_repos.get("success"):
|
||||
log_error(
|
||||
Exception(starred_repos.get("error", "No result")),
|
||||
"Failed to get starred repositories",
|
||||
)
|
||||
return False
|
||||
# check if the repository is in the starred_repos
|
||||
if f"{self.context['repo_owner']}/{self.context['repo_name']}" in [
|
||||
repo["full_name"] for repo in starred_repos["data"]["starred_repos"]
|
||||
]:
|
||||
print("Repository is starred")
|
||||
return {"success": True, "result": "Repository is starred"}
|
||||
else:
|
||||
print("Repository is not starred")
|
||||
return {"success": False, "result": "Repository is not starred"}
|
||||
except Exception as e:
|
||||
log_error(e, "Failed to check if repository is starred")
|
||||
return False
|
Reference in New Issue
Block a user