Skip to main content

Github Toolkit

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_toolkit_github


Swarmauri Toolkit · GitHub

A Swarmauri toolkit that wraps PyGithub behind Swarmauri’s agent/tool abstractions. Authenticate once and gain access to repository, issue, pull request, branch, and commit helpers—ready for scripted automation or conversational agents.

  • Creates a shared GitHub client so every tool call reuses the same token and rate-limit state.
  • Normalizes responses into dictionaries so downstream logic can inspect status messages or raw PyGithub payloads.
  • Covers common actions (create/list/update/delete) while staying extensible via the action parameter on each tool.

Requirements

  • Python 3.10 – 3.13.
  • GitHub personal access token (classic or fine-grained) with the scopes your workflow requires. Store it in an environment variable such as GITHUB_TOKEN.
  • Runtime dependencies (PyGithub, python-dotenv, and the Swarmauri base/standard packages) install automatically with the toolkit.

Installation

Choose any of the supported packaging flows; each command resolves transitive dependencies.

pip

pip install swarmauri_toolkit_github

Poetry

poetry add swarmauri_toolkit_github

uv

# Add to the current project and update uv.lock
uv add swarmauri_toolkit_github

# or install into the active environment without editing pyproject.toml
uv pip install swarmauri_toolkit_github

Tip: python-dotenv is imported automatically—drop your token into a local .env file (GITHUB_TOKEN=ghp_...) for quick experimentation.

Quick Start

import os
from swarmauri_toolkit_github import GithubToolkit

toolkit = GithubToolkit(api_token=os.environ["GITHUB_TOKEN"])

# List repositories for the authenticated user
repos = toolkit.github_repo_tool(action="list_repos")
print(repos["list_repos"])

# Open a tracking issue
issue = toolkit.github_issue_tool(
    action="create_issue",
    repo_name="owner/example",
    title="Investigate flaky tests",
    body="Logs: https://gist.github.com/..."
)
print(issue["create_issue"])

Each sub-tool accepts an action argument (see PyGithub docs for additional options) and returns a dictionary keyed by that action for ergonomic unpacking.

Usage Scenarios

Automate Release Housekeeping

from swarmauri_toolkit_github import GithubToolkit

toolkit = GithubToolkit(api_token=os.environ["GITHUB_TOKEN"])

# Create a release branch
toolkit.github_branch_tool(
    action="create_branch",
    repo_name="owner/service",
    new_branch="release/v1.4.0",
    source_branch="master"
)

# Cut a changelog commit
toolkit.github_commit_tool(
    action="create_file",
    repo_name="owner/service",
    path="CHANGELOG.md",
    message="Add release notes",
    content="### v1.4.0\n- New features...",
    branch="release/v1.4.0"
)

Drive GitHub From a Swarmauri Agent

from swarmauri_core.agent.Agent import Agent
from swarmauri_core.messages.HumanMessage import HumanMessage
from swarmauri_standard.tools.registry import ToolRegistry
from swarmauri_toolkit_github import GithubToolkit

toolkit = GithubToolkit(api_token=os.environ["GITHUB_TOKEN"])
registry = ToolRegistry()
registry.register(toolkit.github_issue_tool)
registry.register(toolkit.github_pr_tool)

agent = Agent(tool_registry=registry)
response = agent.run(HumanMessage(content="Open a PR from feature/auth to master"))
print(response)

Enable conversational workflows that translate natural-language requests into GitHub mutations.

Triage Issues Nightly

from datetime import datetime, timedelta
from swarmauri_toolkit_github import GithubToolkit

toolkit = GithubToolkit(api_token=os.environ["GITHUB_TOKEN"])
cutoff = datetime.utcnow() - timedelta(days=7)

issues = toolkit.github_issue_tool(
    action="list",
    repo_name="owner/product",
    state="open"
)["list"]

stale = [issue for issue in issues if issue.updated_at < cutoff]
for issue in stale:
    toolkit.github_issue_tool(
        action="create_comment",
        repo_name="owner/product",
        number=issue.number,
        body="Ping! Any update in the last week?"
    )

Keep a backlog tidy by automatically nudging stale tickets.

Troubleshooting

  • ValueError: Invalid Token or Missing api_token – Pass the token explicitly (GithubToolkit(api_token=...)) or export GITHUB_TOKEN before instantiating the toolkit.
  • PyGithub exception messages – Most actions bubble up PyGithub errors verbatim (permission issues, missing branches, etc.). Inspect the text in the returned string to resolve scope or naming problems.
  • GitHub rate limits – PyGithub tracks remaining requests; consider batching actions or sleeping when Github.get_rate_limit() indicates low headroom.

License

swarmauri_toolkit_github is released under the Apache 2.0 License. See LICENSE for full details.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_toolkit_github-0.8.3.dev3.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmauri_toolkit_github-0.8.3.dev3-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_toolkit_github-0.8.3.dev3.tar.gz.

File metadata

  • Download URL: swarmauri_toolkit_github-0.8.3.dev3.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_toolkit_github-0.8.3.dev3.tar.gz
Algorithm Hash digest
SHA256 54a38a5544597d53c7df37c2507f4dd1e465e83de03374666c9b2e9094a964e0
MD5 ef8adcf0be68cbdd3b5e73ac6b411e32
BLAKE2b-256 5cce52adbaa17cc78fb2a648b150f3ca61f2ee3384293e8d7e7f5c965d94eccc

See more details on using hashes here.

File details

Details for the file swarmauri_toolkit_github-0.8.3.dev3-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_toolkit_github-0.8.3.dev3-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_toolkit_github-0.8.3.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 4e75887d2d2de5550541e10b2688e2b3b5378882463d1c666c72f8d88ac377ee
MD5 db1eb643891f60969ed0df66f634681e
BLAKE2b-256 95fa0f1b904d77e8694d9b63433875a227d5370f663f0d3fd08eaef2b47506bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page