Repository navigation
API Reference parrot_tools.gittoolkit
Git/GitHub toolkit inspired by :mod:parrot.tools.jiratoolkit.
This toolkit focuses on two complementary workflows that frequently appear in software review loops:
- producing a
git applycompatible patch from pieces of code supplied by an agent or user; and - turning those code snippets into an actionable GitHub pull request via the public REST API.
The implementation deliberately mirrors the structure of
JiraToolkit—async public methods automatically become tools thanks to the
AbstractToolkit base class—so that it can be dropped into existing agent
configurations with minimal friction.
Only standard library modules (plus :mod:requests, :mod:pydantic, which
are already dependencies of Parrot, and PyGithub>=2.1 for GitHub App
authentication) are required.
Input payload for add_pr_comment.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
Pull request number on the repository. | |
body |
str |
Comment body in Markdown. | |
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
Input payload for compare_pr_versions.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
Pull request number on the repository. | |
path |
str |
File path to compare between the PR base and head refs. | |
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
Return payload for compare_pr_versions.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
repository |
str |
Repository in 'owner/name' format. | |
pr_number |
int |
Pull request number. | |
path |
str |
File path that was compared. | |
base_sha |
str |
Full commit SHA of the PR base ref. | |
head_sha |
str |
Full commit SHA of the PR head ref. | |
base |
FileContentResult |
File content at the base ref (before the PR's changes). | |
head |
FileContentResult |
File content at the head ref (after the PR's changes). |
Aggregated stats for a single contributor across the repository's history.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
login |
Optional[str] |
GitHub login, or None when the commit email is not linked to an account. |
|
avatar_url |
Optional[str] |
None |
Avatar URL from the GitHub user object (None for anonymous). |
total_commits |
int |
All-time commit count for this contributor. | |
weeks |
List[ContributorWeek] |
Per-week breakdown — most recent last (GitHub ordering). |
One week's slice of a contributor's activity.
Mirrors the GitHub weeks[] entry from
GET /repos/{owner}/{repo}/stats/contributors.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
week_start |
datetime |
Sunday 00:00 UTC that begins this week (GitHub epoch converted to UTC). | |
additions |
int |
Lines added in the week. | |
deletions |
int |
Lines deleted in the week (non-negative). | |
commits |
int |
Commit count for the week. |
Input payload for create_pull_request.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
title |
str |
Pull request title | |
body |
Optional[str] |
None |
Pull request description |
base_branch |
Optional[str] |
None |
Branch into which the changes should merge. |
head_branch |
Optional[str] |
None |
Branch name to create and push changes onto. |
commit_message |
Optional[str] |
None |
Commit message used for the updates (defaults to title). |
files |
List[GitHubFileChange] |
List of file updates that compose the pull request. | |
draft |
bool |
False |
Create the pull request as a draft if true. |
labels |
Optional[List[str]] |
None |
Optional labels to apply after PR creation. |
Return payload for get_file_content_at_ref.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
exists |
bool |
True when the file was found at the given ref; False on 404. | |
path |
str |
File path as requested. | |
ref |
str |
Ref (branch, tag, or SHA) that was used to resolve the file. | |
repository |
str |
Repository in 'owner/name' format. | |
content |
Optional[str] |
None |
Decoded UTF-8 text content of the file, or None when exists=False or error is set. |
encoding |
Optional[str] |
None |
Content encoding: 'utf-8' for text files or 'base64' for binary blobs. |
size_bytes |
Optional[int] |
None |
Raw file size in bytes as reported by the GitHub Contents API. |
sha |
Optional[str] |
None |
Git blob SHA — used as the cache key for _FileBlobCache. |
commit_author |
Optional[str] |
None |
GitHub login of the author of the most recent commit that touched this file at ref. |
truncated |
bool |
False |
True when start_line/end_line slicing was applied to the content. |
error |
Optional[str] |
None |
Error indicator. 'file_too_large' when the blob exceeds GitHub's 1 MB limit; 'rate_limited' when the API quota is exhausted; None on success. |
Input payload for generate_git_apply_patch.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
files |
List[GitPatchFile] |
Collection of file changes that should be turned into a unified diff. | |
context_lines |
int |
3 |
How many context lines to include in the diff output. |
include_apply_snippet |
bool |
True |
If true, include a ready-to-run git-apply heredoc snippet. |
Input payload for get_code_frequency.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
Input payload for get_weekly_commit_activity.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
Input payload for get_contributor_stats.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
Input payload for get_file_content_at_ref.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
path |
str |
File path inside the repository, e.g. 'src/parrot/bots/agent.py'. | |
ref |
str |
Branch name, tag, or commit SHA at which to retrieve the file. | |
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
start_line |
Optional[int] |
None |
First line to return (1-indexed). When provided together with end_line, only that slice is returned and truncated=True is set on the result. |
end_line |
Optional[int] |
None |
Last line to return (1-indexed, inclusive). Must be >= start_line when both are set. |
Input payload for get_pull_request_diff.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
Pull request number on the repository. | |
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
max_bytes |
int |
50000 |
Truncate the diff to at most this many bytes (0 disables truncation). |
Input payload for get_pull_request.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
Pull request number on the repository. | |
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
Description of a file mutation when creating a pull request.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
path |
str |
File path inside the repository. | |
content |
Optional[str] |
None |
New file content. Leave None to delete a file. |
encoding |
Literal['utf-8', 'base64'] |
'utf-8' |
Encoding used for content. |
message |
Optional[str] |
None |
Optional commit message just for this file change. |
change_type |
Literal['modify', 'add', 'delete'] |
'modify' |
Type of change performed on the file. |
Represents a single file change for patch generation.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
path |
str |
Path to the file inside the repository. | |
change_type |
Literal['modify', 'add', 'delete'] |
'modify' |
Type of change represented by this patch fragment. |
original |
Optional[str] |
None |
Original file contents relevant to the change. |
updated |
Optional[str] |
None |
Updated file contents to apply. |
from_path |
Optional[str] |
None |
Override the 'from' path in the generated diff. |
to_path |
Optional[str] |
None |
Override the 'to' path in the generated diff. |
Toolkit dedicated to Git patch generation and GitHub pull requests.
| Parameter | Type | Default | Description |
|---|---|---|---|
default_repository |
Optional[str] |
None |
Default repo in owner/name format. |
default_branch |
str |
'main' |
Fallback branch for pull requests. |
github_token |
Optional[str] |
None |
PAT for GitHub API calls (required in pat mode). |
auth_type |
Literal['pat', 'github_app'] |
'pat' |
Authentication backend — 'pat' (default) or 'github_app'. |
app_id |
Optional[int] |
None |
GitHub App ID (required when auth_type='github_app'). |
installation_id |
Optional[int] |
None |
Installation ID for the org/account the App is installed in (required when auth_type='github_app'). |
private_key |
Optional[str] |
None |
PEM contents of the App's private key. Mutually exclusive with private_key_path. |
private_key_path |
Optional[str] |
None |
Filesystem path to the App's private key PEM. Mutually exclusive with private_key. |
repositories |
Optional[Dict[str, Union[RepositoryCredential, dict]]] |
None |
Optional named registry mapping an alias to that repository's credentials (RepositoryCredential or an equivalent dict). Tools may reference a repository by its alias or by its raw owner/name slug. Registry entries are explicit-config only — they do NOT inherit GITHUB_* env vars. Passing a "default" alias here while the legacy default_repository argument is also set raises, to avoid ambiguity. |
**kwargs |
Any |
{} |
Forwarded to the base class. |
Attributes:
| Attribute | Type | Description |
|---|---|---|
auth_type |
Literal['pat', 'github_app'] |
|
app_id |
Optional[int] |
|
installation_id |
Optional[int] |
Create a unified diff (and optional git apply snippet) from code blocks.
generate_git_apply_patch(files: List[GitPatchFile], context_lines: int = 3, include_apply_snippet: bool = True) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
files |
List[GitPatchFile] |
||
context_lines |
int |
3 |
|
include_apply_snippet |
bool |
True |
Returns: Dict[str, Any]
Create a GitHub pull request with the supplied file updates.
create_pull_request(repository: Optional[str], title: str, body: Optional[str], base_branch: Optional[str], head_branch: Optional[str], commit_message: Optional[str], files: List[GitHubFileChange], draft: bool = False, labels: Optional[List[str]] = None) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
||
title |
str |
||
body |
Optional[str] |
||
base_branch |
Optional[str] |
||
head_branch |
Optional[str] |
||
commit_message |
Optional[str] |
||
files |
List[GitHubFileChange] |
||
draft |
bool |
False |
|
labels |
Optional[List[str]] |
None |
Returns: Dict[str, Any]
Clone repository to dest_dir.
Uses the configured PAT / GitHub-App token (or the gh CLI when
present) for private repos. Idempotent: if dest_dir already holds a
git clone, delegates to :meth:pull_repo instead of re-cloning.
clone_repo(repository: str, dest_dir: str, branch: Optional[str] = None, *, private: bool = False, depth: Optional[int] = None, timeout: Optional[float] = None, prefer_gh: bool = True) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
repository |
str |
An alias from the configured registry, an owner/name slug, or a full clone URL. |
|
dest_dir |
str |
Destination directory for the clone. | |
branch |
Optional[str] |
None |
Optional branch to clone (--branch). |
private |
bool |
False |
When True, authenticate the clone (gh or token-in-URL). |
depth |
Optional[int] |
None |
Optional shallow-clone depth (--depth). |
timeout |
Optional[float] |
None |
Optional subprocess timeout in seconds. |
prefer_gh |
bool |
True |
Whether to prefer gh repo clone for private clones. |
Returns: Dict[str, Any] — {"path", "repository", "branch", "updated"}. Never contains a token.
Raises:
-
GitToolkitError— If the clone/pull fails (stderr is token-scrubbed).
Fast-forward an existing clone at repo_path to branch.
pull_repo(repo_path: str, branch: Optional[str] = None, *, timeout: Optional[float] = None, private: bool = False) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
repo_path |
str |
Path to an existing git clone. | |
branch |
Optional[str] |
None |
Optional branch to pull (origin <branch>); defaults to the clone's current upstream. |
timeout |
Optional[float] |
None |
Optional subprocess timeout in seconds. |
private |
bool |
False |
Authenticate through the subprocess environment (git >= 2.31) and first rewrite a credential-bearing origin URL (left by an earlier clone) to its clean form. |
Returns: Dict[str, Any] — {"path", "branch", "updated"}. Never contains a token.
Raises:
-
GitToolkitError— Ifrepo_pathis not a clone or the pull fails.
Fetch metadata for a GitHub pull request by number.
get_pull_request(pr_number: int, repository: Optional[str] = None) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
repository |
Optional[str] |
None |
Returns: Dict[str, Any]
List pull requests on a repository, defaulting to open ones.
list_pull_requests(repository: Optional[str] = None, state: Literal['open', 'closed', 'all'] = 'open', per_page: int = 100) -> List[Dict[str, Any]]
| Parameter | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
|
state |
Literal['open', 'closed', 'all'] |
'open' |
|
per_page |
int |
100 |
Returns: List[Dict[str, Any]]
Return the raw unified diff of a pull request, truncated to max_bytes.
get_pull_request_diff(pr_number: int, repository: Optional[str] = None, max_bytes: int = 50000) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
repository |
Optional[str] |
None |
|
max_bytes |
int |
50000 |
Returns: Dict[str, Any]
Add an issue-style comment to a pull request.
add_pr_comment(pr_number: int, body: str, repository: Optional[str] = None) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
body |
str |
||
repository |
Optional[str] |
None |
Returns: Dict[str, Any]
Submit a pull-request review (approve, request-changes or comment).
submit_pr_review(pr_number: int, event: Literal['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], body: str, repository: Optional[str] = None) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
event |
Literal['APPROVE', 'REQUEST_CHANGES', 'COMMENT'] |
||
body |
str |
||
repository |
Optional[str] |
None |
Returns: Dict[str, Any]
List changed files, including patch when supplied by GitHub.
list_pull_request_files(pr_number: int, repository: Optional[str] = None, max_items: int = 300) -> List[Dict[str, Any]]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
repository |
Optional[str] |
None |
|
max_items |
int |
300 |
Returns: List[Dict[str, Any]]
List issue-style comments with author identity and Bot/User type.
list_pull_request_comments(pr_number: int, repository: Optional[str] = None, max_items: int = 300) -> List[Dict[str, Any]]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
repository |
Optional[str] |
None |
|
max_items |
int |
300 |
Returns: List[Dict[str, Any]]
List PR review summaries with state and commit identity.
list_pull_request_reviews(pr_number: int, repository: Optional[str] = None, max_items: int = 300) -> List[Dict[str, Any]]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
repository |
Optional[str] |
None |
|
max_items |
int |
300 |
Returns: List[Dict[str, Any]]
List inline comments, locations and reply relationships.
list_pull_request_review_comments(pr_number: int, repository: Optional[str] = None, max_items: int = 300) -> List[Dict[str, Any]]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
repository |
Optional[str] |
None |
|
max_items |
int |
300 |
Returns: List[Dict[str, Any]]
Return the CI checks reported for a pull request's head commit.
Merges the Checks API (check-runs) with the legacy Commit Status
API, because a repository may use either or both, and normalizes every
entry to state in success|failure|pending alongside the raw
GitHub fields. head_sha skips the extra PR lookup when the caller
already knows it.
The two APIs sit behind independent token permissions, so a 403/404 on
one does not discard the other: the denial is listed in denied and
explained in reason, and available is False only when BOTH were
refused — "we do not know" must never read as "green".
get_pr_checks(pr_number: int, repository: Optional[str] = None, head_sha: Optional[str] = None) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
repository |
Optional[str] |
None |
|
head_sha |
Optional[str] |
None |
Returns: Dict[str, Any]
Convert an open pull request into a draft so it cannot be merged.
Returns status in converted|already_draft|not_open. Needs the
GraphQL mutation (REST has no writable draft field), so the token
must carry the same pull_requests: write permission used to submit
reviews.
convert_pr_to_draft(pr_number: int, repository: Optional[str] = None) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
||
repository |
Optional[str] |
None |
Returns: Dict[str, Any]
Ensure a GitHub webhook pointing at webhook_url exists on the repo.
Idempotent. Falls back gracefully when GitHub refuses the hooks
endpoint (status "no_permission") so callers can run in hybrid mode
(auto when allowed, manual otherwise). That refusal is not always a
missing scope: repository webhooks require the admin role on the
repo, and a fine-grained token can never exceed its owner's role, so
the result also carries status_code, api_message and
required_permission for the operator-facing log.
ensure_webhook(webhook_url: str, repository: Optional[str] = None, secret: Optional[str] = None, events: Optional[List[str]] = None) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
webhook_url |
str |
||
repository |
Optional[str] |
None |
|
secret |
Optional[str] |
None |
|
events |
Optional[List[str]] |
None |
Returns: Dict[str, Any]
Return the full or sliced contents of a file at a given git ref.
Fetches the file at the specified ref (branch name, tag, or full
commit SHA) from the GitHub Contents API. The blob is stored in an
in-process SHA-keyed cache so that repeated requests for the same ref
do not incur extra HTTP round-trips within a single review session.
Cache lookup order for blob content:
- Redis (checked here in the async wrapper before calling the sync helper)
- In-process LRU (checked inside the sync helper)
- Base64 decode from the GitHub Contents API response
The Contents API metadata call (which provides the blob SHA) is always made to resolve the SHA before the cache can be checked. This is unavoidable — the SHA is not known until the metadata is fetched.
Use this tool when the PR diff shows a change to a function or class
but the hunk is too small to judge correctness without seeing the full
file body. Prefer start_line / end_line on large files to stay
within the LLM context budget.
Example::
result = await toolkit.get_file_content_at_ref(
path="parrot/bots/agent.py",
ref="main",
start_line=100,
end_line=150,
)
if result.exists and result.content:
print(result.content)
get_file_content_at_ref(path: str, ref: str, repository: Optional[str] = None, start_line: Optional[int] = None, end_line: Optional[int] = None) -> 'FileContentResult'
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str |
File path inside the repository (e.g. "src/parrot/bots/agent.py"). |
|
ref |
str |
Branch name, tag, or commit SHA at which to retrieve the file. | |
repository |
Optional[str] |
None |
Repository in owner/name format. Uses the toolkit default when omitted. |
start_line |
Optional[int] |
None |
First line to return (1-indexed). When provided without end_line, returns from this line to end-of-file. |
end_line |
Optional[int] |
None |
Last line to return (1-indexed, inclusive). When provided without start_line, returns from line 1 to this line. |
Returns: 'FileContentResult' — class:FileContentResult with exists=True and content set on success; exists=False when the file is not found; error='file_too_large' when the blob exceeds GitHub's 1 MB limit.
List files and subdirectories at path for an explicit git ref.
list_repo_directory(path: str, ref: str, repository: Optional[str] = None) -> 'RepoDirectoryListing'
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str |
||
ref |
str |
||
repository |
Optional[str] |
None |
Returns: 'RepoDirectoryListing'
Return the base and head versions of a single file in a pull request.
Fetches the full content of path at both the PR's base commit SHA
and its head commit SHA. Both calls route through :meth:_FileBlobCache
so that multiple reviews of the same PR only hit GitHub once per
(repository, blob SHA) pair.
Use this tool when the PR diff hunk is too small to judge whether a refactored function or class is correct; viewing the full before/after bodies often reveals intent that a small hunk obscures.
Example::
diff = await toolkit.compare_pr_versions(pr_number=42, path="utils.py")
print("Before:", diff.base.content)
print("After:", diff.head.content)
compare_pr_versions(pr_number: int, path: str, repository: Optional[str] = None) -> 'CompareVersionsResult'
| Parameter | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
Pull request number (must be >= 1). | |
path |
str |
File path to compare (e.g. "src/utils.py"). |
|
repository |
Optional[str] |
None |
Repository in owner/name format. Uses the toolkit default when omitted. |
Returns: 'CompareVersionsResult' — class:CompareVersionsResult with base and head class:FileContentResult objects. When the file was added in the PR, base.exists is False. When deleted, head.exists is False.
Search code in the PR's repository via the GitHub Code Search API.
The repo:<owner>/<name> qualifier is automatically injected so the
search is scoped to the PR's own repository only — it never exposes
code from other repositories. Only the default branch is indexed by
GitHub's Code Search.
Use this tool when you suspect a changed function has callers or related code in other files that are not shown in the PR diff. For example: searching for usages of a renamed function, finding all implementations of an interface, or locating a constant that was moved.
Note: the Code Search API is rate-limited separately from the REST
API (30 requests/minute). When the quota is exceeded the tool returns
SearchCodeResult(error='rate_limited', items=[]) without raising.
Example::
results = await toolkit.search_repo_code("class PRReviewResult")
for item in results.items:
print(item["path"], item["html_url"])
search_repo_code(query: str, repository: Optional[str] = None, max_results: int = 20) -> 'SearchCodeResult'
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
str |
Code Search query (e.g. "def my_function" or "class MyModel language:python"). Do not include a repo: qualifier — it is added automatically. |
|
repository |
Optional[str] |
None |
Repository in owner/name format. Uses the toolkit default when omitted. |
max_results |
int |
20 |
Maximum number of results to return (1-100, default 20). |
Returns: 'SearchCodeResult' — class:SearchCodeResult with items containing raw GitHub Code Search item dicts (path, name, sha, html_url, score).
Return per-contributor weekly stats for the repository.
Calls GET /repos/{owner}/{repo}/stats/contributors. The endpoint is
asynchronous on GitHub's side: the first call after a cold cache returns
202 with an empty body. This method retries with exponential backoff until
it receives 200 (or gives up after max_retries), so callers always see
a populated list.
get_contributor_stats(repository: Optional[str] = None) -> List[ContributorStats]
| Parameter | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
Target repository in owner/name format. Uses default when omitted. |
Returns: List[ContributorStats] — List of :class:ContributorStats models with per-week breakdowns.
Return the last 52 weeks of repo-wide commits broken down by day-of-week.
Calls GET /repos/{owner}/{repo}/stats/commit_activity. Handles the
GitHub 202 async-compute pattern transparently.
get_weekly_commit_activity(repository: Optional[str] = None) -> List[Dict[str, Any]]
| Parameter | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
Target repository in owner/name format. Uses default when omitted. |
Returns: List[Dict[str, Any]] — List of dicts, each with week (Unix epoch Sunday), total, and days (list of 7 day counts, Sun-Sat).
Return per-week additions/deletions for the whole repository since inception.
Calls GET /repos/{owner}/{repo}/stats/code_frequency. Handles the GitHub
202 async-compute pattern transparently. Deletion counts are stored as
non-negative integers (GitHub returns them as negative in the raw payload).
get_code_frequency(repository: Optional[str] = None) -> List[WeeklyCodeFrequency]
| Parameter | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
Target repository in owner/name format. Uses default when omitted. |
Returns: List[WeeklyCodeFrequency] — List of :class:WeeklyCodeFrequency models, oldest first.
Raised when the toolkit cannot satisfy a request.
When the failure came from a GitHub API call the exception also carries the
HTTP context, so callers can branch on :attr:status_code instead of
sniffing the message, and can surface GitHub's own explanation to the
operator. str(exc) is unchanged, which keeps older callers working.
| Parameter | Type | Default | Description |
|---|---|---|---|
message |
str |
||
status_code |
Optional[int] |
None |
|
url |
Optional[str] |
None |
|
api_message |
Optional[str] |
None |
|
accepted_permissions |
Optional[str] |
None |
Attributes:
| Attribute | Type | Description |
|---|---|---|
status_code |
HTTP status returned by GitHub, or None for failures raised before/without a request (e.g. unresolved repository). |
|
url |
The API URL that failed. | |
api_message |
GitHub's own message field from the error body. |
|
accepted_permissions |
The x-accepted-github-permissions response header, which names the fine-grained permission the endpoint wants (e.g. repository_hooks=write). |
Default configuration shared by all tools in the toolkit.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
default_repository |
Optional[str] |
None |
Default GitHub repository in 'owner/name' format. |
default_branch |
str |
'main' |
Fallback branch used for pull requests. |
github_token |
Optional[str] |
None |
Personal access token with repo scope for GitHub calls. |
auth_type |
Literal['pat', 'github_app'] |
'pat' |
Authentication backend. 'pat' uses github_token; 'github_app' uses app_id + installation_id + private key. |
app_id |
Optional[int] |
None |
GitHub App ID (required when auth_type='github_app'). |
installation_id |
Optional[int] |
None |
Installation ID for the org/account the App is installed in (required when auth_type='github_app'). |
private_key |
Optional[str] |
None |
PEM contents of the App's private key. Mutually exclusive with private_key_path. |
private_key_path |
Optional[str] |
None |
Filesystem path to the App's private key PEM. Mutually exclusive with private_key. |
repositories |
Optional[Dict[str, RepositoryCredential]] |
None |
Named registry mapping an alias to that repository's credentials and defaults. All credentials are explicit-config only: the toolkit does NOT read GITHUB_* environment variables for auth (the default and ad-hoc connections also require explicitly passed credentials). |
Input payload for list_pull_requests.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
state |
Literal['open', 'closed', 'all'] |
'open' |
Filter pull requests by state. |
per_page |
int |
100 |
Number of pull requests per page (max 100). |
Input for a ref-specific repository directory listing.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
path |
str |
||
ref |
str |
||
repository |
Optional[str] |
None |
One file or directory in a repository directory listing.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
name |
str |
||
path |
str |
||
type |
Literal['file', 'dir'] |
Directory listing at an explicitly selected repository ref.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
exists |
bool |
||
path |
str |
||
ref |
str |
||
repository |
str |
||
entries |
List[RepoDirectoryEntry] |
Credentials + defaults for a single named repository in a registry.
Each entry in :attr:GitToolkit.repositories is one of these. The alias
(the dict key) is how tools reference the repository by name; the
repository field is the underlying owner/name slug used to build
GitHub API URLs.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
repository |
str |
GitHub repository in 'owner/name' format. | |
default_branch |
str |
'main' |
Fallback branch used for pull requests against this repo. |
auth_type |
Literal['pat', 'github_app'] |
'pat' |
Authentication backend. 'pat' uses github_token; 'github_app' uses app_id + installation_id + private key. |
github_token |
Optional[str] |
None |
Personal access token with repo scope (pat mode). |
app_id |
Optional[int] |
None |
GitHub App ID (required when auth_type='github_app'). |
installation_id |
Optional[int] |
None |
Installation ID (required when auth_type='github_app'). |
private_key |
Optional[str] |
None |
PEM contents of the App's private key. Mutually exclusive with private_key_path. |
private_key_path |
Optional[str] |
None |
Filesystem path to the App's private key PEM. Mutually exclusive with private_key. |
Return payload for search_repo_code.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
repository |
str |
Repository in 'owner/name' format that was searched. | |
query |
str |
The original query string (without the auto-injected repo: qualifier). | |
total_count |
int |
Total number of matching results as reported by GitHub Code Search. | |
items |
List[Dict[str, Any]] |
Raw GitHub Code Search item list. Each item contains at minimum: 'path', 'name', 'sha', 'html_url', and 'score'. | |
error |
Optional[str] |
None |
Error indicator. 'rate_limited' when the search API quota is exhausted; None on success. |
Input payload for search_repo_code.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
query |
str |
Code Search query text without the 'repo:' qualifier — that qualifier is injected automatically to scope the search to the PR's repository. | |
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
max_results |
int |
20 |
Maximum number of results to return (1-100). GitHub caps this at 100 per request. |
Raised when a /stats/* endpoint keeps answering 202.
GitHub computes repository statistics lazily: the first request for a cold
repo returns 202 Accepted and only starts the computation, which can
take minutes on a large repository. Exhausting the 202 retries therefore
means "not ready yet", not "broken" — a distinct outcome callers should be
able to defer on instead of treating as an error. It stays a
:class:GitToolkitError so existing except GitToolkitError handlers
keep working.
| Parameter | Type | Default | Description |
|---|---|---|---|
message |
str |
||
attempts |
Optional[int] |
None |
|
url |
Optional[str] |
None |
Attributes:
| Attribute | Type | Description |
|---|---|---|
attempts |
How many requests were made before giving up. |
Input payload for submit_pr_review.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
pr_number |
int |
Pull request number on the repository. | |
event |
Literal['APPROVE', 'REQUEST_CHANGES', 'COMMENT'] |
Review event to record on the pull request. | |
body |
str |
Review body in Markdown (required for REQUEST_CHANGES). | |
repository |
Optional[str] |
None |
Target repository: a registered alias from the toolkit's repositories registry, or a raw 'owner/name' slug. Uses the default repository when omitted. |
Repo-wide weekly additions/deletions totals.
Sourced from GET /repos/{owner}/{repo}/stats/code_frequency.
Fields:
| Field | Type | Default | Description |
|---|---|---|---|
week_start |
datetime |
Sunday 00:00 UTC that begins this week. | |
additions |
int |
Total lines added across the repository in the week. | |
deletions |
int |
Total lines deleted (stored as non-negative; GitHub returns negative). |
- 1. MCP Server — exposing tools as a service
- 2. A2A — exposing agents and orchestrators as services
- 3. Toolkits for third party services and Cloud Security composition
- 4. Interaction surface — WebSockets, audio, integrations
- 5. Hardening — anti prompt injection, PBAC and tool gating
- 6. Cross cutting concerns and reference deployment
- 7. AgentCrew — Sequential, Parallel, Flow and Loop execution
- 8. AgentsFlow — DAG first orchestration with per node FSM
- 9. Ontologic RAG — graph first retrieval, intent routing & multi tenant knowledge
- 10. Observability — OpenLIT + OpenTelemetry
- Class Catalog by Module
- Module level Functions Catalog
- AI Parrot — Exposure, Interoperability & Hardening Architecture
- Agent Mesh
- AgentService — Standalone Runtime for Autonomous Agents
- AbstractClient: The Provider Client Family
- Anthropic client
- Bedrock Mantle Client
- TypeSafe System One Client (
JevClient) - Meta Model API Client (Muse Spark)
- OpenAI Compatible Client Base (
OpenAIBaseClient) - Per Loop LLM Client Cache
- Question Token Budgets (Bedrock Converse, Nova text, Bedrock Mantle)
- Agent Configure Lifecycle
- AgentTalk Integration Guide
- Agent Configuration via
agents.yaml - AgentFactory HTTP API
- Agent Studio — API Reference
- Agent CLI Daemon (agentd)
- FirefliesInsightsAgent
- Follow up Suggestion Chips (FEAT 752)
- Agents and Chatbots: The Bot Class Hierarchy
- Agent Studio — database storage (host guide)
- Ephemeral User Agents — Frontend Integration Handoff
parrot agent— Agent Terminal Workspace- Crew Handler
- Database Agent
- Running the CVE Experts
- Domain Experts (FEAT 778)
- FEAT 437
- Technical Voice Guide (AgentTalk Voice) for Frontend
- AgentDashboard — A2UI v1.0 Technical Reference for
navigator frontend next - Semantic UI Model → Adaptive Cards (FEAT 303)
- Exposing an AI Parrot Agent as an MCP Server
- AgentCrew User Guide
- AgentsFlow User Guide
- Crew Definition Storage
- A2UI Agent Functions Runtime — the v1.0 RPC leg (FEAT 469)
- Capabilities of an AI Parrot Analytical Agent (PandasAgent)
- Agent Security Guardrails (FEAT 761)
- SpawnSubAgentTool
- Testagent
- Agentic End to End Testing (FEAT 581)
- Uiagent
- WebAgent — Browser Interaction via Chrome DevTools
- WebNavigatorAgent — Catalogued Web Navigation on Your Chrome Profile
- ExecutionMemory Integration Guide
- Agent Brain
- Agent Memory
- Conversation History Ownership
- Conversation Memory Subsystem Overview
- Dream Cycle — episodic → wiki brain consolidation
- Durable Conversation Memory
- Memory Dynamics
- Per Turn Conversation Compaction
- Recoverable Task Memory (FEAT 538)
- Task Memory — Phase 0 Integration Map (FEAT 538 / TASK 2970)
- User Memory
- Bookstore Agentic Retrieval
- Bookstore in Codex
- Bookstore Conceptual Relations — the book graph (FEAT 533)
- Bookstore notebooks
- Contracts catalog performance (FEAT 539, AC14)
- Contracts pilot acceptance — Bob's twelve cases (FEAT 539, AC15)
- Contracts Card & Ontology (FEAT 539)
- Luau parser resource policy (FEAT 532 TASK 2896)
- Glossary of Terms (FEAT 917)
- GraphIndex core seams (FEAT 540)
- GraphIndex — Structured Knowledge Graph Indexing
- Local Knowledge Base
- Procedure Graph — Assembly Manuals (FEAT 601)
- Ontology backend programme
- Ontology vocabulary store
- PageIndex Agentic Retrieval and Citations
- PageIndex Generation Publication
- PageIndex Layout Structure Builder
- PageIndex Local MCP Toolkit
- PageIndex Segment Store
- PageIndex Tree Optimizer
- PageIndex — Tree Based RAG for Document Retrieval
- ArxivTool for AI Parrot
- Accounting metrics layer
- Tool Result Compression Pipeline (FEAT 380)
- DatasetManager Implementation Walkthrough
- FredAPITool Documentation
- EmployeesTool Employee Hierarchy Tool for AI Parrot
- HoobaToolkit
- Jira text templates (JiraToolkit)
- Expose Toolkits as Local MCP (
parrot mcp local) - MultiStoreSearch Toolkit — Multi Origin Retrieval for Agents
- Supervised Obscura Browser Integration
- OdooHelpdeskToolkit — Softhealer helpdesk on Odoo 19
- OdooToolkit Capabilities
- QuerysourceToolkit
- ReadOnlyRepoToolkit (FEAT 484)
- PythonREPLTool Sandbox: Worker Process Execution Model
- Research Tools for Agents
- gVisor Installation Guide for AI Parrot Secure Sandbox
- SDD Sandbox — OS Setup
- Governed semantic layer
- Tool optimizations for Claude Code and Codex (FEAT 543)
- AbstractTool Clone Method
- Toolbar API Documentation
- AudioNoteCaptureToolkit
- ExecutionPlanToolkit — Reference
- Host toolkits for Agent Studio
- Infographic Authoring for Data Agents (FEAT 326)
- InfographicToolkit — Reference
- Tool System Internals: Tools, Toolkits and ToolManager
- AI Parrot Tools Documentation
- What If Scenario Analysis
- Workday worker history
- DecisionFlowNode Usage Guide
- Multi Agent Orchestration: AgentCrew and AgentsFlow
- Docker Tool Executor & Execution Policy
- Generic Gate Host
- HeartbeatManager — Per Agent Autonomous Heartbeat Loop
- JobManager
- Node Types Reference
- OrchestratorAgent — Multi Party Conferencing (
confer) - Planogram compliance cycle (perceive → identify → compare)
- Planogram compliance — migrating configurations to the new cycle (FEAT 574, FEAT 612)
- Planogram perception spike — FEAT 574
- Scheduler backends in multi worker deployments
- Thales User Guide
- Per tenant skills (FEAT 707)
- Skill routing and trigger caching
- Skills system: discovery, toolkits and mixin
- Contextual Embedding Headers
- DocumentDB Usage Patterns
- DocumentDB Interface Guide
- DynamoDB Local (docker compose)
- Fully offline local agent with LanceDB (FEAT 542)
- LanceDB vector, full text and hybrid store (FEAT 542)
- Loader Metadata Standard
- Document Loaders for RAG
- Matryoshka Embedding Truncation
- Parent Child Retrieval (Small to Big)
- Storage Backends Guide
- User stores (Redis by default)
- Vector Stores and Embeddings Reference
- Vector Store Handler — API Reference
- A2A Secure Communication Demo
- Agent as a Local MCP Server (parrot toolkits install agent)
- add repository:
- GitHub MCP Installation and Usage
- MCP integration: client, server and agent tools
- Create and configure agent
- Roost — local inter agent sub protocol
- Roost carriers
- Roost performatives, protocols and obligations
- Simple Mcp Server
- SimpleMCPServer Configuration
- API Endpoints Reference
- Admin UI (FEAT 468)
- Infographic Render Endpoint — Reference
- EventBus v2 Configuration Reference (
[bus]/[bus.alerts]) - EventBus v2 Migration Notes (FEAT 310)
- EventBus v2 — Unified Event Fabric (FEAT 310)
- Session file store
- A2UI Dashboard + Widget Renderer — Frontend Build Guide
- Avatar Technical Guide (LiveAvatar Phase A) for Frontend
- Frontend Guide for SvelteKit: LiveAvatar FULL Mode and VoiceBot (FEAT 248)
- DEPRECATED: Native Voice Avatar (LiveAvatar Phase C) Technical Guide for Frontend
- Technical Guide to Structured Artifacts for Frontend
- VoiceBot · VoiceChatHandler · FEAT 245 — Frontend Guide for Realtime Conversation with Agents
- Server Layer: BotManager and HTTP Handlers
- Infographic Handler — Frontend API Contract
- Interactive Artifacts — Frontend API Contract
- Google Drive file manager
- SharePoint & OneDrive file managers
- WhatsApp Integration Implementation Summary
- WhatsApp Integration for AI Parrot
- P3 — parrot admin ui inventory (canvases / A2UI / infographic / builders)
- WhatsApp + AutonomousOrchestrator Integration
- Audio Form Voice Modes — Developer Guide
- Who owns an OAuth2 (3LO) credential
- CommCenter — Bulk Notification Sender (FEAT 417)
- FormDesigner → MS Teams: Adaptive Card renderer and bot submit path (FEAT 551)
- GitHub reviewer
- Google OAuth 2.0 — AI Parrot Integration
- Fireflies Agent Examples
- HITL Tool Call Confirmation (FEAT 235)
- Teams HITL Channel Setup Guide (FEAT 205)
- JiraSpecialist Prompt Layer Stack
- JiraSpecialist — Daily Standup Lanes
- Jira Transition Actions — Activating
TRIGGER_AGENTDispatch - Jupyter Output Mode Documentation
- Knowledge upload from chat (FEAT 647)
- LiveAvatar over your own LiveKit (Cloud or self hosted)
- Matrix Bridges for the AI Parrot Swarm (FEAT 463)
- Matrix Clients for the AI Parrot Swarm (FEAT 463)
- Migration Guide: FEAT 202 — ai parrot integrations
- Connections on Microsoft Teams
- MS Teams Toolkit for AI Parrot
- Nova Sonic Voice Protocol Reference
- Office 365 OAuth 2.0 (Delegated) — AI Parrot Integration
- PR Review Command — Setup Guide
- Queued chat commands
- Runbook — the
issuesnamespace (Jira ticket corpus) - Dev loop kick off from Slack (FEAT 555)
- Telegram Auth Open Mode (webview | browser)
- Telegram connections
- Telegram Bot Integration Guide
- FEAT 536 — VoiceBot Nova Dual Output + LiveAvatar: Real Live Operational Acceptance
- FEAT 537 — Nova VoiceBot avatar broadcast: operational acceptance
- FEAT 537 — Nova PCM → LiveAvatar LITE → LiveKit multi subscriber live gate
- speech_report TTS backends
- Nova VoiceBot avatar broadcast for multiple browsers (FEAT 537)
- 🦜 AI Parrot Voice Chat
- WhisperX Setup Guide for AI Parrot
- A2UI Linked Surfaces (FEAT 598)
- A2UI v1.0 Wire (FEAT 470)
- === D3.js ===
- Backend HTML Design System (FEAT 493)
- FEAT 488
- FormDesigner Audio Renderer
- Form Designer — Autonomous FormSchema Persistence (Standalone Forms)
- Form Designer — Conditional Sections: Pre/Post Dependencies
- FormBuilder — LLM answer plausibility enforcement
- FormDesigner — orphan upload cleanup (FEAT 731)
- FormDesigner — public response controls
- Form Designer — Relational Fields
- Serving FormDesigner forms from a Teams agent
- Form Designer — Unknown Field Capture Policy for Form Submissions
- FormDesigner — validation audit trail
- Infographic Recipes (FEAT 324)
- Inline A2UI Component Routing (FEAT 755)
- Metric Definition Registry (FEAT 756)
- Smart OutputFormatter Documentation
- N4 — navigator api backend inventory (dashboards / widgets / templates / modules / programs)
- P1 — ai parrot HTTP/WS endpoint inventory (report builder lens)
- P2 — ai parrot (Python) UI components, models, renderers, persistence — inventory for a REPORT BUILDER
- P4 — ai parrot prior art for a Report Builder (SDD inventory)
- ai parrot server — Admin / Bots / Studio / misc endpoint inventory
- P1 — ai parrot HTTP/WS endpoint inventory (report builder lens) ( core)
- parrot formdesigner — HTTP/WS endpoint inventory
- Report Builder — ai parrot inventory and analysis
- WeasyPrint 69.0 CSS Support — Empirical Findings
- Identity Capability User Guide
- Layers Reference
- Output Language (FEAT 638)
- PromptBuilder — User Modifiable Variables
- PromptBuilder User Guide
- Delegated OAuth2 connections
- Delegated OAuth2 connections on the web channel — deployment recipe and live harness
- Deterministic Groundedness Scoring
- ONNX Backend for the Prompt Injection Guardrail (FEAT 439)
- PBAC Guardrails — Policy Driven Tool Call Denial (FEAT 406)
- SecurityAdvisor — SOC2 Oriented Read Only Advisory Agent
- User Profile Management
- AI Parrot MCP Server AWS Deployment Guide
- Bot Cleanup Lifecycle
- Business Automation — Operator Runbook
parrot loginand connections- CompanyInfoToolkit
- Per component and per agent LLM defaults (FEAT 796, FEAT 882)
- Answer Accuracy Metrics for the Evaluation Harness (FEAT 652)
- Infographic CSP and Signed URLs — Operations Guide
- Global install: the parrot managed runtime (reference)
- Runbook — the Fireflies Meeting Registry
- Wiki standup briefs — runbook
parrot.finance— the finance satellite- Migration — FEAT 201: ai parrot embeddings
- Migration — FEAT 203: ai parrot server
- FEAT 223 — Structured Artifact Contract: Migration Guide
- FEAT 273 — Legacy output mode deprecations → A2UI
- Migration — FEAT 315: Unified NovaClient for all Amazon Nova models
- Migration — FEAT 421: Client declared tenant in the forms URL
- Migration — FEAT 446: SaaS Auth Hardening (S0 of Parrot Research Cloud)
- Migration — FEAT 473: A2UI v1.0 for STRUCTURED_CHART / STRUCTURED_TABLE / STRUCTURED_MAP
- Migration — FEAT 523: PEP 420 LLM Client Extraction
- Gemini 2.5 retirement (FEAT 798)
- Migration — FEAT 564: Reliable video reels with Gemini Omni and Veo 3.1
- Native Claude sandbox for SDD sessions (FEAT 768)
- Complementary (collaborative) research partner (FEAT 482)
- Dev flow per seat LLM configuration (
DevFlowModelPlan) - Dev loop
novabackend (AWS Bedrock) - sdd worker as orchestrator of parallel sdd coder seats (FEAT 549)
- SDD compaction capability record
- SDD execution optimization — operation and rollout
- Proposals to Reduce SDD Execution Time
- Dev flow / dev loop telemetry accounting
- Language Agnostic Validation Runners (FEAT 709)
- Spec Driven Development in Google Gemini / Antigravity CLI
- Guide to using the SDD slash commands
- AI Parrot Spec Driven Development (SDD) Platform
- SDD on Google Antigravity (agy)
/sdd donecloseout hooks- Decision Audit (FEAT 784)
- SDD experience memory
- SDD Expert Consult
- Ledger outbox (FEAT 758)
- FEAT 580 LSP Pilot — Live Evaluation Results
- SDD LSP research pilot (FEAT 580)
- Necessity Ladder (FEAT 908)
- Procedure Graph
- Test selection in the SDD flow — the Validation Contract (FEAT 699)
- wikitoolkit Cheatsheet
- wikitoolkit inbox
- wikitoolkit lint
- LLM Wiki — an agent maintained knowledge repository
- Schema Plane — Operator Guide (FEAT 600)
- SQLite concurrency for wiki and ledger
- wikitoolkit standup
- WikiToolkit as Claude Code infrastructure
- Authentication uses Navigator Auth
- AbstractClient base changes require a decision
- Clients are memory less
- Configuration uses NavConfig
- Graph backends — retire ArangoDB for PostgreSQL + SurrealDB
- Conversation history has one writer
- HTTP stack uses aiohttp
- LangChain is not part of the stack
- Async code remains non blocking
- Concrete tools live in ai parrot tools