Implementation Guide — GitHub Agent Project

This directory originally contained Python source files that were removed from this archive.
An AI assistant can recreate them by following the instructions below.
See README.md and requirements.txt for project context and dependencies.


agent.py

Purpose: An AI agent that can interact with the GitHub API to automate common tasks.

What to implement:

  1. Use the Anthropic SDK with tool-use.
  2. Define GitHub tools (wrap PyGithub or direct REST calls with the requests library):
    • list_issues(repo: str, state: str = "open") → list[dict] — list issues.
    • get_issue(repo: str, issue_number: int) → dict — get issue details.
    • create_issue(repo: str, title: str, body: str, labels: list[str]) → dict — create an issue.
    • list_pull_requests(repo: str, state: str = "open") → list[dict] — list PRs.
    • get_pr_diff(repo: str, pr_number: int) → str — fetch the unified diff of a PR.
    • post_comment(repo: str, issue_number: int, body: str) → dict — comment on issue/PR.
  3. Implement an agent loop that processes a natural-language task string, calls tools as needed, and returns a final summary.
  4. Read GitHub token from GITHUB_TOKEN environment variable.
  5. Demo tasks:
    • “List all open bugs in owner/repo and summarize them.”
    • “Review PR #42 in owner/repo and post a one-line review comment.”

CLI usage: GITHUB_TOKEN=xxx python agent.py "List open issues in owner/repo"
Dependencies: see requirements.txt (anthropic, PyGithub or requests)