transfer from monorepo

This commit is contained in:
Laura Abro
2025-04-24 10:24:42 -03:00
parent a2175785d5
commit 1c6fc5540b
95 changed files with 7110 additions and 0 deletions

View File

@ -0,0 +1,16 @@
**/.env
**/.env.*
**/node_modules
**/dist
**/build
**/*.log
**/Dockerfile
**/docker-compose.yml
**/venv
**/.venv
**/*__pycache__
**/.pytest_cache
**/*.db
**/*.egg-info
**/*/repos/

View File

@ -0,0 +1,26 @@
ANTHROPIC_API_KEY=your_anthropic_api_key
# the token requires the repo scope
GITHUB_TOKEN=your_github_token
GITHUB_USERNAME=your_github_username
# for testing only
# these credentials must be different from the ones above
# they are used to create and delete test repositories
# the token requires the repo and delete_repo scopes
UPSTREAM_GITHUB_TOKEN=your_upstream_github_token
UPSTREAM_GITHUB_USERNAME=your_upstream_github_username
# for testing only
MIDDLE_SERVER_URL=http://localhost:3000
TASK_SYSTEM_PROMPT="You are an AI development assistant specializing in writing code and creating GitHub pull requests.
Follow these rules:
1. Create a new file in the /src directory.
2. Write a single Python function that accomplishes the assigned task.
3. Commit and push the changes to the remote repository.
4. Create a second new file in the /tests directory.
5. Write a series of tests that thoroughly test the function, including edge cases and error handling, using PyTest.
6. Commit and push the changes to the remote repository.
7. Run the tests to ensure they pass.
8. Continue to make commits and push them to the remote repository until the tests pass.
9. Validate code changes before submitting"

1
worker/orca-agent/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
venv

View File

@ -0,0 +1,48 @@
# Use the official Python image from the Docker Hub
FROM python:3.12-slim
# Set the working directory in the container
WORKDIR /app
# Copy the requirements.txt file into the container
COPY requirements.txt .
# Install Git and any other necessary packages
RUN apt-get update && apt-get install -y git sudo curl
# Install the dependencies
RUN pip install -r requirements.txt
# Configure Git to add the safe directory
RUN git config --global --add safe.directory /app
# Copy the rest of your application code into the container
COPY . .
ENV MIDDLE_SERVER_URL=https://builder247.api.koii.network
# Configure logging and output
ENV PYTHONUNBUFFERED=1
ENV TERM=xterm-256color
ENV FORCE_COLOR=1
# Add this environment variable after other ENV declarations
ENV DATABASE_PATH=/data/database.db
# Make port 8080 available to the world outside this container
EXPOSE 8080
# Set the command to run your application
CMD ["gunicorn", \
"--log-level=error", \
"--error-logfile=-", \
"--capture-output", \
"--enable-stdio-inheritance", \
"--logger-class=gunicorn.glogging.Logger", \
"--timeout", "600", \
"--graceful-timeout", "600", \
"--keep-alive", "5", \
"-w", "1", \
"-b", "0.0.0.0:8080", \
"main:app"]

View File

View File

@ -0,0 +1,6 @@
from src.server import create_app
app = create_app()
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080, debug=True)

View File

@ -0,0 +1,18 @@
anthropic>=0.8.1
python-dotenv>=1.0.0
pandas>=2.0.0
tiktoken>=0.5.2
pytest>=8.0.2
typing-extensions>=4.12.2
GitPython>=3.1.44
pygithub>=2.5.0
Flask>=3.0.0
requests>=2.32.0
cryptography>=42.0.0
gunicorn>=22.0.0
solders>=0.26.0
base58>=2.1.0
tenacity>=9.0.0
sqlmodel>=0.0.22
openai>=0.28.0
colorama>=0.4.6

118
worker/orca-agent/setup.md Normal file
View File

@ -0,0 +1,118 @@
# 247 Builder
## Developing locally
Navigate to the correct directory:
```sh
cd builder/container
```
Set up a virtual environment and activate it:
```sh
python3 -m venv .venv
source .venv/bin/activate
```
Install dependencies:
```sh
pip install -r requirements.txt
```
Run tests:
```sh
python3 -m pytest tests/
```
Run the agent:
```sh
python3 main.py
```
## Developing in Docker
### Running the Flask Server
Navigate to the correct directory:
```sh
cd builder/container
```
Build the image:
```sh
docker build -t builder247 .
```
Run the container:
```sh
docker run builder247
```
You can also run with a mounted volume if you'd like to change files without updating the container:
```sh
docker run -v $(pwd):/app builder247
```
### Running Interactively (using the shell)
Navigate to the correct directory:
```sh
cd builder/container
```
Change this line in the Dockerfile:
```sh
CMD ["python", "main.py"]
```
to
```sh
CMD ["/bin/bash"]
```
Build the image:
```sh
docker build -t builder247.
```
Run the container with a mounted volume:
```sh
docker run -it -v $(pwd)/builder:/app builder247
```
This will give you access to your files within the container and run the container in interactive mode with shell access. You can then run tests inside the container using:
```sh
python -m pytest tests/
```
or
```sh
python3 -m pytest tests/
```
You can also run the flask server in the container with:
```sh
python main.py
```
To exit the container's shell:
```sh
exit
```

View File

@ -0,0 +1,8 @@
from setuptools import setup, find_packages
setup(
name="task-flow",
version="0.1",
packages=find_packages(include=["src", "src.*"]),
python_requires=">=3.6",
)

View File

@ -0,0 +1,22 @@
"""Database models."""
from datetime import datetime
from typing import Optional, List
from sqlmodel import SQLModel, Field, Relationship
from sqlalchemy import JSON
from sqlalchemy import Column
from prometheus_swarm.database.models import Conversation, Message, Log
class Submission(SQLModel, table=True):
"""Task submission model."""
task_id: str
round_number: int = Field(primary_key=True)
status: str = "pending"
pr_url: Optional[str] = None
username: Optional[str] = None
repo_urls: Optional[dict] = Field(
default=None, sa_column=Column(JSON)
) # Store as JSON type
repo_url: Optional[str] = None

View File

@ -0,0 +1,70 @@
"""Flask application initialization."""
from flask import Flask, request
from .routes import repo_summary, star, audit, healthz, submission
from prometheus_swarm.utils.logging import configure_logging, log_section, log_key_value, log_value
from prometheus_swarm.database import initialize_database
from colorama import Fore, Style
import uuid
import os
def create_app():
"""Create and configure the Flask application."""
app = Flask(__name__)
# Add request ID middleware
@app.before_request
def before_request():
request.id = str(uuid.uuid4())
# Store request start time for duration calculation
request.start_time = request.environ.get("REQUEST_TIME", 0)
@app.after_request
def after_request(response):
# Calculate request duration
duration = (request.environ.get("REQUEST_TIME", 0) - request.start_time) * 1000
# Get error message if this is an error response
error_msg = ""
if response.status_code >= 400:
try:
json_data = response.get_json()
if isinstance(json_data, dict):
error_msg = json_data.get("error") or json_data.get("message", "")
except Exception:
# If we can't get JSON data, try to get the message from the response
error_msg = getattr(response, "description", "")
# Log the request with appropriate color
color = Fore.GREEN if response.status_code < 400 else Fore.RED
log_value(
f"[{color}REQ{Style.RESET_ALL}] {request.method} {request.path} "
f"{color}{response.status_code}{Style.RESET_ALL} {error_msg} {duration}ms"
)
return response
# Register blueprints
app.register_blueprint(healthz.bp)
app.register_blueprint(repo_summary.bp)
app.register_blueprint(star.bp)
app.register_blueprint(audit.bp)
app.register_blueprint(submission.bp)
# Configure logging within app context
with app.app_context():
# Set up logging (includes both console and database logging)
configure_logging()
# Initialize database
initialize_database()
# Disable Flask's default logging
app.logger.disabled = True
# Log startup information
log_section("SERVER STARTUP")
log_key_value("Workers", 1)
log_key_value("Host", "0.0.0.0:8080")
log_key_value("Database", os.getenv("DATABASE_PATH", "Not configured"))
return app

View File

@ -0,0 +1,65 @@
"""Database model for logging."""
from datetime import datetime
from prometheus_swarm.database import get_db
def init_logs_table():
"""Initialize the logs table if it doesn't exist."""
# Not needed - handled by SQLModel
pass
def save_log(
level: str,
message: str,
module: str = None,
function: str = None,
path: str = None,
line_no: int = None,
exception: str = None,
stack_trace: str = None,
request_id: str = None,
additional_data: str = None,
) -> bool:
"""
Save a log entry to the database.
Args:
level: Log level (ERROR, WARNING, INFO, etc)
message: Log message
module: Module name where log was generated
function: Function name where log was generated
path: File path where log was generated
line_no: Line number where log was generated
exception: Exception type if any
stack_trace: Stack trace if any
request_id: Request ID if available
additional_data: Any additional JSON-serializable data
Returns:
bool: True if log was saved successfully
"""
try:
db = get_db()
from prometheus_swarm.database import Log
log = Log(
timestamp=datetime.utcnow(),
level=level,
message=message,
module=module,
function=function,
path=path,
line_no=line_no,
exception=exception,
stack_trace=stack_trace,
request_id=request_id,
additional_data=additional_data,
)
db.add(log)
db.commit()
return True
except Exception as e:
print(f"Failed to save log to database: {e}") # Fallback logging
return False

View File

@ -0,0 +1,62 @@
from flask import Blueprint, jsonify, request
from src.server.services.github_service import verify_pr_ownership
from src.server.services.audit_service import audit_repo
import logging
logger = logging.getLogger(__name__)
bp = Blueprint("audit", __name__)
@bp.post("/audit/<round_number>")
def audit_submission(round_number: int):
logger.info("Auditing submission")
data = request.get_json()
submission = data.get("submission")
if not submission:
return jsonify({"error": "Missing submission"}), 400
# submission_round_number = submission.get("roundNumber")
task_id = submission.get("taskId")
pr_url = submission.get("prUrl")
github_username = submission.get("githubUsername")
# Extract repo owner and name from PR URL
try:
pr_url_parts = pr_url.split('github.com/')[1].split('/')
repo_owner = pr_url_parts[0]
repo_name = pr_url_parts[1]
except (IndexError, AttributeError):
return jsonify({"error": "Invalid PR URL format"}), 400
print(f"Repo owner: {repo_owner}, Repo name: {repo_name}")
# This is commented out because the round number might be different due to we put the audit logic in the distribution part
# if int(round_number) != submission_round_number:
# return jsonify({"error": "Round number mismatch"}), 400
if (
not task_id
or not pr_url
or not github_username
or not repo_owner
or not repo_name
):
return jsonify({"error": "Missing submission data"}), 400
is_valid = verify_pr_ownership(
pr_url=pr_url,
expected_username=github_username,
expected_owner=repo_owner,
expected_repo=repo_name,
)
if not is_valid:
return jsonify(False)
try:
is_approved = audit_repo(pr_url)
return jsonify(is_approved), 200
except Exception as e:
logger.error(f"Error auditing PR: {str(e)}")
return jsonify(True), 200

View File

@ -0,0 +1,14 @@
from flask import Blueprint, jsonify
from prometheus_swarm.database import get_db
import logging
logger = logging.getLogger(__name__)
bp = Blueprint("healthz", __name__)
@bp.post("/healthz")
def healthz():
# Test database connection
_ = get_db()
return jsonify({"status": "ok"})

View File

@ -0,0 +1,54 @@
from flask import Blueprint, jsonify, request
from src.server.services import repo_summary_service
bp = Blueprint("repo_summary", __name__)
@bp.post("/repo_summary/<round_number>")
def start_task(round_number):
logger = repo_summary_service.logger
logger.info(f"Task started for round: {round_number}")
data = request.get_json()
logger.info(f"Task data: {data}")
required_fields = [
"taskId",
"round_number",
"repo_url"
]
if any(data.get(field) is None for field in required_fields):
return jsonify({"error": "Missing data"}), 401
result = repo_summary_service.handle_task_creation(
task_id=data["taskId"],
round_number=int(round_number),
repo_url=data["repo_url"],
)
return result
if __name__ == "__main__":
from flask import Flask
# Create a Flask app instance
app = Flask(__name__)
app.register_blueprint(bp)
# Test data
test_data = {
"taskId": "fake",
"round_number": "1",
"repo_url": "https://github.com/koii-network/docs"
}
# Set up test context
with app.test_client() as client:
# Make a POST request to the endpoint
response = client.post(
"/repo_summary/1",
json=test_data
)
# Print the response
print(f"Status Code: {response.status_code}")
print(f"Response: {response.get_json()}")

View File

@ -0,0 +1,39 @@
from prometheus_swarm.utils.logging import log_key_value
from flask import Blueprint, jsonify, request
from src.server.services import star_service
bp = Blueprint("star", __name__)
@bp.post("/star/<round_number>")
def start_task(round_number):
logger = star_service.logger
logger.info(f"Task started for round: {round_number}")
data = request.get_json()
logger.info(f"Task data: {data}")
required_fields = [
"taskId",
"round_number",
"github_urls",
]
if any(data.get(field) is None for field in required_fields):
return jsonify({"error": "Missing data"}), 401
try:
# Log incoming data
print("Received data:", data)
print("Round number:", round_number)
result = star_service.handle_star_task(
task_id=data["taskId"],
round_number=int(round_number),
github_urls=data["github_urls"],
)
return result
except Exception as e:
print(f"Error in star endpoint: {str(e)}")
print(f"Error type: {type(e)}")
import traceback
print(f"Traceback: {traceback.format_exc()}")
return jsonify({'error': str(e)}), 500

View File

@ -0,0 +1,38 @@
from flask import Blueprint, jsonify
from prometheus_swarm.database import get_db
from src.dababase.models import Submission
import logging
import os
logger = logging.getLogger(__name__)
bp = Blueprint("submission", __name__)
@bp.get("/submission/<roundNumber>")
def fetch_submission(roundNumber):
logger.info(f"Fetching submission for round: {roundNumber}")
db = get_db()
submission = (
db.query(Submission)
.filter(
Submission.round_number == int(roundNumber),
)
.first()
)
logger.info(f"Submission: {submission}")
logger.info(f"Submission: {submission}")
if submission:
github_username = os.getenv("GITHUB_USERNAME")
return jsonify(
{
"taskId": submission.task_id,
"roundNumber": submission.round_number,
"status": submission.status,
"prUrl": submission.pr_url,
"githubUsername": github_username,
}
)
else:
return jsonify({"error": "Submission not found"}), 409

View File

@ -0,0 +1,47 @@
"""Audit service module."""
import logging
from prometheus_swarm.clients import setup_client
from src.workflows.repoSummarizerAudit.workflow import repoSummarizerAuditWorkflow
from src.workflows.repoSummarizerAudit.prompts import (
PROMPTS as REPO_SUMMARIZER_AUDIT_PROMPTS,
)
logger = logging.getLogger(__name__)
def audit_repo(pr_url):
# def review_pr(repo_urls, pr_url, github_username, star_only=True):
"""Review PR and decide if it should be accepted, revised, or rejected."""
try:
# Set up client and workflow
client = setup_client("anthropic")
# Below commented out because we won't need to distribute starring repo nodes
# star_repo_workflow = StarRepoAuditWorkflow(
# client=client,
# prompts=STAR_REPO_AUDIT_PROMPTS,
# repo_url=repo_urls[0],
# github_username=github_username,
# )
# star_repo_workflow.run()
repo_summerizer_audit_workflow = repoSummarizerAuditWorkflow(
client=client,
prompts=REPO_SUMMARIZER_AUDIT_PROMPTS,
pr_url=pr_url,
)
# Run workflow and get result
result = repo_summerizer_audit_workflow.run()
recommendation = result["data"]["recommendation"]
return recommendation
except Exception as e:
logger.error(f"PR review failed: {str(e)}")
raise Exception("PR review failed")
if __name__ == "__main__":
# review_pr(["https://github.com/alexander-morris/koii-dumper-reveal"], "https://github.com/koii-network/namespace-wrapper/pull/1", "HermanL02")
audit_repo("https://github.com/koii-network/namespace-wrapper/pull/1")

View File

@ -0,0 +1,44 @@
import re
import requests
from github import Github
import os
import logging
logger = logging.getLogger(__name__)
def verify_pr_ownership(
pr_url,
expected_username,
expected_owner,
expected_repo,
):
try:
gh = Github(os.environ.get("GITHUB_TOKEN"))
match = re.match(r"https://github.com/([^/]+)/([^/]+)/pull/(\d+)", pr_url)
if not match:
logger.error(f"Invalid PR URL: {pr_url}")
return False
owner, repo_name, pr_number = match.groups()
if owner != expected_owner or repo_name != expected_repo:
logger.error(
f"PR URL mismatch: {pr_url} != {expected_owner}/{expected_repo}"
)
return False
repo = gh.get_repo(f"{owner}/{repo_name}")
pr = repo.get_pull(int(pr_number))
if pr.user.login != expected_username:
logger.error(
f"PR username mismatch: {pr.user.login} != {expected_username}"
)
return False
return True
except Exception as e:
logger.error(f"Error verifying PR ownership: {str(e)}")
return True

View File

@ -0,0 +1,60 @@
"""Task service module."""
import requests
import os
from flask import jsonify
from prometheus_swarm.database import get_db
from prometheus_swarm.clients import setup_client
from src.workflows.repoSummarizer.workflow import RepoSummarizerWorkflow
from prometheus_swarm.utils.logging import logger, log_error
from dotenv import load_dotenv
from src.workflows.repoSummarizer.prompts import PROMPTS
from src.dababase.models import Submission
load_dotenv()
def handle_task_creation(task_id, round_number, repo_url):
"""Handle task creation request."""
try:
db = get_db()
client = setup_client("anthropic")
workflow = RepoSummarizerWorkflow(
client=client,
prompts=PROMPTS,
repo_url=repo_url,
)
result = workflow.run()
if result.get("success"):
submission = Submission(
task_id=task_id,
round_number=round_number,
status="summarized",
repo_url=repo_url,
pr_url=result["data"]["pr_url"],
)
db.add(submission)
db.commit()
return jsonify({"success": True, "result": result})
else:
return jsonify(
{"success": False, "result": result.get("error", "No result")}
)
except Exception as e:
logger.error(f"Repo summarizer failed: {str(e)}")
raise
if __name__ == "__main__":
from flask import Flask
app = Flask(__name__)
with app.app_context():
result = handle_task_creation(
task_id="1",
round_number=6,
repo_url="https://github.com/koii-network/builder-test",
)
print(result)

View File

@ -0,0 +1,50 @@
"""Task service module."""
import requests
import os
from flask import jsonify
from prometheus_swarm.database import get_db
from prometheus_swarm.clients import setup_client
from src.workflows.repoSummarizer.workflow import RepoSummarizerWorkflow
from prometheus_swarm.utils.logging import logger, log_error
from src.workflows.starRepo.workflow import StarRepoWorkflow
from dotenv import load_dotenv
from src.workflows.repoSummarizer.prompts import PROMPTS
load_dotenv()
def handle_star_task(task_id, round_number, github_urls):
"""Handle task creation request."""
try:
db = get_db()
client = setup_client("anthropic")
for url in github_urls:
star_workflow = StarRepoWorkflow(
client=client,
prompts=PROMPTS,
repo_url=url,
)
star_result = star_workflow.run()
if not star_result or not star_result.get("success"):
log_error(
Exception(star_result.get("error", "No result")),
"Repository star failed",
)
return jsonify({"success": True, "result": "Repository starred"})
except Exception as e:
logger.error(f"Repo summarizer failed: {str(e)}")
raise
if __name__ == "__main__":
from flask import Flask
app = Flask(__name__)
with app.app_context():
result = handle_star_task(
task_id="1",
round_number=6,
github_urls=["https://github.com/koii-network/builder-test"],
)
print(result)

View File

@ -0,0 +1,93 @@
from typing import Dict, Any, Optional, List, TypedDict, Union, Literal, Callable
class ToolDefinition(TypedDict):
"""Standard internal tool definition format."""
name: str
description: str
parameters: Dict[str, str] # JSON Schema object
required: List[str]
final_tool: bool
function: Callable
class ToolCall(TypedDict):
"""Format for a tool call made by the LLM."""
id: str # Unique identifier for this tool call
name: str # name of tool being called
arguments: Dict[str, Any]
class ToolOutput(TypedDict):
"""Standard output format for all tools.
All tools must return a response in this format.
The message field contains a human-readable description of what happened,
which will be an error message if success is False.
"""
success: bool # Whether the tool execution was successful
message: str # Human-readable message about what happened (error message if success is False)
data: Optional[Dict[str, Any]] # Optional structured data from the tool
class ToolResponse(TypedDict):
"""Format for a tool execution response.
Wraps a tool's output with its call ID for client handling.
"""
tool_call_id: str # ID of the tool call this is responding to
output: ToolOutput # The actual output from the tool
class PhaseResult(TypedDict):
"""Format for a phase result."""
success: bool
data: Dict[str, Any]
error: Optional[str]
class ToolChoice(TypedDict):
"""Configuration for tool usage."""
type: Literal["optional", "required", "required_any"]
tool: Optional[str] # Required only when type is "required"
class ToolConfig(TypedDict):
"""Configuration for tool usage."""
tool_definitions: List[ToolDefinition]
tool_choice: ToolChoice
class TextContent(TypedDict):
"""Format for plain text content."""
type: Literal["text"]
text: str
class ToolCallContent(TypedDict):
"""Format for tool call content."""
type: Literal["tool_call"]
tool_call: ToolCall
class ToolResponseContent(TypedDict):
"""Format for tool response content."""
type: Literal["tool_response"]
tool_response: ToolResponse
class MessageContent(TypedDict):
"""Standard internal message format."""
role: Literal["user", "assistant", "system", "tool"]
content: Union[str, List[Union[TextContent, ToolCall, ToolResponseContent]]]

View 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()

View 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",
)

View 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 developerfriendly 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 23 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"
),
}

View 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,
}

View File

@ -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()

View File

@ -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",
)

View 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"
),
}

View 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,
},
}

View 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()

View 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",
)

View 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."
),
}

View 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,
}

View 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()

View 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",
)

View 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."
),
}

View 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