Create a New Pull Request Function
Create a New Pull Request Function
@tool_spec(
spec={
'name': 'create_pull_request',
'description': """ Create a new pull request.
This function creates a new pull request in the specified
repository.
It requires the owner of the repository, the repository name, the
title for the pull request,
the head branch (the branch with the proposed changes), and the
base branch (the branch
into which the changes will be merged). Optional parameters
include the body of the
pull request, whether it should be a draft, and whether
maintainers can modify it.
The function returns details of the created pull request. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The account owner of the repository. The name is not
case sensitive.'
},
'repo': {
'type':
'string',
'description':
'The name of the repository without the .git
extension. The name is not case sensitive.'
},
'title': {
'type': 'string',
'description': 'The title of the new pull request.'
},
'head': {
'type':
'string',
'description':
'The name of the branch where your changes are
implemented.'
},
'base': {
'type':
'string',
'description':
'The name of the branch you want the changes pulled
into.'
},
'body': {
'type':
'string',
'description':
'The contents of the pull request. Defaults to None.'
},
'draft': {
'type':
'boolean',
'description':
'Indicates whether the pull request is a draft.
Defaults to False.'
},
'maintainer_can_modify': {
'type':
'boolean',
'description':
""" Indicates whether maintainers can modify the pull
request.
Defaults to False. """
}
},
'required': ['owner', 'repo', 'title', 'head', 'base']
}
})
def create_pull_request(owner: str,
repo: str,
title: str,
head: str,
base: str,
body: Optional[str] = None,
draft: bool = False,
maintainer_can_modify: bool = False) -> Dict[str,
Any]
It requires the owner of the repository, the repository name, the title for the pull request,
the head branch (the branch with the proposed changes), and the base branch (the branch
into which the changes will be merged). Optional parameters include the body of the
pull request, whether it should be a draft, and whether maintainers can modify it.
The function returns details of the created pull request.
Args:
owner (str): The account owner of the repository. The name is not case sensitive.
repo (str): The name of the repository without the .git extension. The name is not case
sensitive.
head (str): The name of the branch where your changes are implemented.
base (str): The name of the branch you want the changes pulled into.
draft (bool): Indicates whether the pull request is a draft. Defaults to False.
maintainer_can_modify (bool): Indicates whether maintainers can modify the pull request.
Defaults to False.
Returns:
Dict[str, Any]: A dictionary containing the details of the newly created pull request with the
following keys:
number (int): The pull request number, unique within the repository.
state (str): The current state of the pull request (e.g., 'open').
user (Dict[str, Any]): Details of the user who created the pull request.
head (Dict[str, Any]): Details of the head branch (the branch with the proposed changes).
label (str): The user-friendly label for the head branch (e.g., 'owner:feature-branch').
repo (Dict[str, Any]): Details of the repository containing the head branch.
base (Dict[str, Any]): Details of the base branch (the branch the changes will be merged
into).
label (str): The user-friendly label for the base branch (e.g., 'owner:main').
repo (Dict[str, Any]): Details of the repository containing the base branch.
updated_at (str): Timestamp indicating when the pull request was last updated (ISO 8601
format).
Raises:
NotFoundError: If the repository, head branch, or base branch does not exist.
create_pull_request_review
@tool_spec(
spec={
'name': 'create_pull_request_review',
'description': """ Creates a review on a specified pull request.
This function simulates the GitHub API endpoint for creating a
pull request review.
It allows for submitting reviews with different states (APPROVE,
REQUEST_CHANGES, COMMENT, PENDING),
an optional body text, and an array of inline draft review
comments.
The creation of a review with states other than PENDING typically
triggers notifications.
Pull request reviews created in the PENDING state (when the
`event` parameter is
left blank or not provided) are not considered "submitted" and
therefore do not
include the `submitted_at` property in the response until they
are explicitly submitted
via a separate action (not part of this function). """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The account owner of the repository. The name is not
case sensitive.'
},
'repo': {
'type':
'string',
'description':
'The name of the repository without the .git
extension. The name is not case sensitive.'
},
'pull_number': {
'type':
'integer',
'description':
'The number that identifies the pull request within
the repository.'
},
'commit_id': {
'type':
'string',
'description':
""" The SHA of the commit to which the review
applies. Defaults to None.
If not provided, the review applies to the latest
commit on the pull request's head branch.
Specifying an older commit SHA might result in
comments being outdated if subsequent
commits modify the commented lines. """
},
'body': {
'type':
'string',
'description':
""" The main body text of the pull request review.
Defaults to None.
This field is **required** if the `event` is
'REQUEST_CHANGES' or 'COMMENT'.
It can be an empty string. """
},
'event': {
'type':
'string',
'description':
""" The review action to perform. Defaults to None.
Valid values are:
- 'APPROVE': Submits an approving review.
- 'REQUEST_CHANGES': Submits a review requesting
changes. Requires `body`.
- 'COMMENT': Submits a general comment review.
Requires `body`.
If `event` is `None` or an empty string, the review
is created in a 'PENDING' state
and is not considered submitted. """
},
'comments': {
'type': 'array',
'description':
""" An array of draft review comment objects to be
included with this review. Defaults to None. Each
comment dictionary in the list should conform to the
following structure and validations (see
`PullRequestReviewCommentInput` model): """,
'items': {
'type': 'object',
'properties': {
'path': {
'type':
'string',
'description':
'Required. The relative path to the file
being commented on.'
},
'body': {
'type':
'string',
'description':
'Required. The text of the review
comment.'
},
'position': {
'type':
'integer',
'description':
""" The line index in the diff hunk to
which the comment applies.
This is mutually exclusive with `line`
for specifying a single-line comment location;
one of them must be provided if not a
multi-line comment on the file.
Must be >= 1. """
},
'line': {
'type':
'integer',
'description':
""" The line number in the file's diff
that the comment applies to.
For a multi-line comment, this is the
last line of the range.
This is mutually exclusive with
`position` for single-line comments. Must be >= 1. """
},
'side': {
'type':
'string',
'description':
""" The side of the diff to which the
comment applies.
Can be 'LEFT' or 'RIGHT'. Defaults to
'RIGHT' if `line` is provided. Only used for line-level
comments. """
},
'start_line': {
'type':
'integer',
'description':
""" For a multi-line comment, the first
line of the
comment's range. Requires `line` to
also be provided. Must be <= `line` and >= 1. """
},
'start_side': {
'type':
'string',
'description':
""" For a multi-line comment, the side of
the diff
for the `start_line`. Can be 'LEFT' or
'RIGHT'. Defaults to the value of `side`
if `start_line` is provided and
`start_side` is not. Requires `start_line`. """
}
},
'required': ['path', 'body']
}
}
},
'required': ['owner', 'repo', 'pull_number']
}
})
def create_pull_request_review(
owner: str,
repo: str,
pull_number: int,
commit_id: Optional[str] = None,
body: Optional[str] = None,
event: Optional[str] = None,
comments: Optional[List[Dict[str, Union[str,
int]]]] = None) -> Dict[str,
Any]
Creates a review on a specified pull request.
This function simulates the GitHub API endpoint for creating a pull request review.
The creation of a review with states other than PENDING typically triggers notifications.
Pull request reviews created in the PENDING state (when the `event` parameter is
left blank or not provided) are not considered "submitted" and therefore do not
include the `submitted_at` property in the response until they are explicitly submitted
Args:
owner (str): The account owner of the repository. The name is not case sensitive.
repo (str): The name of the repository without the .git extension. The name is not case
sensitive.
pull_number (int): The number that identifies the pull request within the repository.
commit_id (Optional[str]): The SHA of the commit to which the review applies. Defaults to
None.
If not provided, the review applies to the latest commit on the pull request's head branch.
Specifying an older commit SHA might result in comments being outdated if subsequent
body (Optional[str]): The main body text of the pull request review. Defaults to None.
event (Optional[str]): The review action to perform. Defaults to None. Valid values are:
included with this review. Defaults to None. Each comment dictionary in the list should
conform to the
• path (str): Required. The relative path to the file being commented on.
• position (Optional[int]): The line index in the diff hunk to which the
comment applies.
This is mutually exclusive with `line` for specifying a single-line comment location;
Must be >= 1.
• line (Optional[int]): The line number in the file's diff that the comment
applies to.
This is mutually exclusive with `position` for single-line comments. Must be >= 1.
• side (Optional[str]): The side of the diff to which the comment applies.
Can be 'LEFT' or 'RIGHT'. Defaults to 'RIGHT' if `line` is provided. Only used for line-level
comments.
comment's range. Requires `line` to also be provided. Must be <= `line` and >= 1.
for the `start_line`. Can be 'LEFT' or 'RIGHT'. Defaults to the value of `side`
Returns:
Dict[str, Any]: A dictionary representing the created pull request review, structured
according to the `PullRequestReview` Pydantic model. Key fields include:
containing:
• body (Optional[str]): The body text of the review. Will be present, even if
None.
"CHANGES_REQUESTED").
• commit_id (str): The SHA of the commit to which this review applies.
indicating when the review was submitted. This field is `None` if the review's
`state` is 'PENDING'.
Raises:
NotFoundError: If the specified repository, pull request, or (if provided) `commit_id`
ValidationError: If input parameters are invalid (e.g., unknown `event` type, missing
`body` for certain events, malformed `comments` array or objects within it,
on the pull request (e.g., lacks write access and is not the PR author).
list_repository_pull_requests
@tool_spec(
spec={
'name': 'list_repository_pull_requests',
'description': """ List and filter repository pull requests.
This function lists and filters pull requests for a specified
repository.
It allows querying for pull requests based on their state (open,
closed, or all).
Results can be sorted by various criteria such as creation date,
update date, popularity (number of comments), or by identifying
long-running
pull requests. The direction of sorting (ascending or descending)
can also be
specified. Pagination options are available to control the number
of results
per page and to fetch specific pages of results, facilitating the
handling of
large datasets. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The account owner of the repository. The name is not
case sensitive.'
},
'repo': {
'type':
'string',
'description':
'The name of the repository without the .git
extension. The name is not case sensitive.'
},
'state': {
'type':
'string',
'description':
"Filter by state. Possible values: 'open', 'closed',
'all'. Default: 'open'."
},
'sort': {
'type':
'string',
'description':
"What to sort results by. 'popularity' will sort by
the number of comments. 'long-running' will sort by date created and will
limit the results to pull requests that have been open for more than a
month and have had activity within the past month. Possible values:
'created', 'updated', 'popularity', 'long-running'. Default: 'created'."
},
'direction': {
'type':
'string',
'description':
"The direction of the sort. Possible values: 'asc',
'desc'. Default: 'desc' when 'sort' is 'created' or not specified,
otherwise 'asc'."
},
'per_page': {
'type':
'integer',
'description':
'The number of results per page (max 100). For more
information, see "Using pagination in the REST API." Default: 30.'
},
'page': {
'type':
'integer',
'description':
'The page number of the results to fetch. For more
information, see "Using pagination in the REST API." Default: 1.'
}
},
'required': ['owner', 'repo']
}
})
def list_repository_pull_requests(
owner: str,
repo: str,
state: Optional[str] = 'open',
sort: Optional[str] = 'created',
direction: Optional[str] = 'desc',
per_page: Optional[int] = 30,
page: Optional[int] = 1) -> List[Dict[str, Any]]
List and filter repository pull requests.
This function lists and filters pull requests for a specified repository.
It allows querying for pull requests based on their state (open, closed, or all).
per page and to fetch specific pages of results, facilitating the handling of
large datasets.
Args:
owner (str): The account owner of the repository. The name is not case sensitive.
repo (str): The name of the repository without the .git extension. The name is not case
sensitive.
state (Optional[str]): Filter by state. Possible values: 'open', 'closed', 'all'. Default: 'open'.
sort (Optional[str]): What to sort results by. 'popularity' will sort by the number of
comments. 'long-running' will sort by date created and will limit the results to pull requests
that have been open for more than a month and have had activity within the past month.
Possible values: 'created', 'updated', 'popularity', 'long-running'. Default: 'created'.
direction (Optional[str]): The direction of the sort. Possible values: 'asc', 'desc'. Default:
'desc' when 'sort' is 'created' or not specified, otherwise 'asc'.
per_page (Optional[int]): The number of results per page (max 100). For more information,
see "Using pagination in the REST API." Default: 30.
page (Optional[int]): The page number of the results to fetch. For more information, see
"Using pagination in the REST API." Default: 1.
Returns:
List[Dict[str, Any]]: A list of pull request dictionaries matching the filter criteria with the
following fields:
user (Dict[str, Any]): The user who created the pull request. Contains the following fields:
labels (List[Dict[str, Any]]): List of labels associated with the pull request. Each label
contains the following fields:
default (Optional[bool]): Whether the label is the default label for the repository.
assignee (Optional[Dict[str, Any]]): The user assigned to the pull request. Contains the
following fields:
assignees (List[Dict[str, Any]]): List of users assigned to the pull request, each containing the
following fields:
milestone: Optional[Dict[str, Any]]: The milestone associated with the pull request. Contains
the following fields:
id (int): Unique identifier for the milestone.
creator (Optional[Dict[str, Any]]): The user who created the milestone. Contains the
following fields:
open_issues (int): The number of open issues associated with the milestone.
closed_issues (int): The number of closed issues associated with the milestone.
created_at (datetime): The date and time the milestone was created.
updated_at (datetime): The date and time the milestone was last updated.
closed_at (Optional[datetime]): The date and time the milestone was closed.
created_at (datetime): The date and time the pull request was created.
updated_at (datetime): The date and time the pull request was last updated.
closed_at (Optional[datetime]): The date and time the pull request was closed.
merged_at (Optional[datetime]): The date and time the pull request was merged.
mergeable_state (Optional[str]): The mergeable state of the pull request. Could be "clean",
"dirty", or "unknown".
merged_by (Optional[Dict[str, Any]]): The user who merged the pull request. Contains the
following fields:
head (Dict[str, Any]): The head branch of the pull request. Contains the following fields:
user (Dict[str, Any]): The user who created the head branch. Contains the following fields:
repo (Dict[str, Any]): The repository of the head branch. Contains the following fields:
owner (Dict[str, Any]): The user or organization that owns the repository. Contains the
following fields:
updated_at (datetime): Timestamp for when the repository was last updated.
pushed_at (datetime): Timestamp for when the repository was last pushed to.
license (Optional[Dict[str, Any]]): The license of the repository. Contains the following fields:
fork_details (Optional[Dict[str, Any]]): Details about the fork lineage if the repository is a
fork, containig the following keys:
source_id (int): The ID of the ultimate source repository in the fork network.
base (Dict[str, Any]): The base branch of the pull request. Contains the following fields:
user (Dict[str, Any]): The user who created the head branch. Contains the following fields:
node_id (Optional[str]): Global node ID of the user.
repo (Dict[str, Any]): The repository of the head branch. Contains the following fields:
owner (Dict[str, Any]): The user or organization that owns the repository. Contains the
following fields:
updated_at (datetime): Timestamp for when the repository was last updated.
pushed_at (datetime): Timestamp for when the repository was last pushed to.
license (Optional[Dict[str, Any]]): The license of the repository. Contains the following fields:
fork_details (Optional[Dict[str, Any]]): Details about the fork lineage if the repository is a
fork, containig the following keys:
source_id (int): The ID of the ultimate source repository in the fork network.
update_pull_request
@tool_spec(
spec={
'name': 'update_pull_request',
'description':
""" Update an existing pull request in a GitHub repository.
Updates an existing pull request in a GitHub repository. This
function allows
for updating attributes of a pull request such as its title,
body, state
(e.g., 'open' or 'closed'), the base branch it targets, and
whether
maintainers are permitted to make modifications to it. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'pull_number': {
'type': 'integer',
'description': 'The number identifying the pull
request.'
},
'title': {
'type':
'string',
'description':
'The new title for the pull request. Defaults to
None.'
},
'body': {
'type':
'string',
'description':
'The new body content for the pull request. Defaults
to None.'
},
'state': {
'type':
'string',
'description':
""" The new state of the pull request (e.g., 'open'
or 'closed').
Defaults to None. """
},
'base': {
'type':
'string',
'description':
""" The name of the branch to which the changes are
proposed
(the base branch). Defaults to None. """
},
'maintainer_can_modify': {
'type':
'boolean',
'description':
""" Specifies whether maintainers can modify
the pull request. Defaults to False. """
}
},
'required': ['owner', 'repo', 'pull_number']
}
})
def update_pull_request(owner: str,
repo: str,
pull_number: int,
title: Optional[str] = None,
body: Optional[str] = None,
state: Optional[str] = None,
base: Optional[str] = None,
maintainer_can_modify: bool = False) -> Dict[str,
Any]
for updating attributes of a pull request such as its title, body, state
title (Optional[str]): The new title for the pull request. Defaults to None.
body (Optional[str]): The new body content for the pull request. Defaults to None.
state (Optional[str]): The new state of the pull request (e.g., 'open' or 'closed').
Defaults to None.
base (Optional[str]): The name of the branch to which the changes are proposed
Returns:
Dict[str, Any]: A dictionary containing the details of the updated pull request.
Key fields that can be directly updated via this method include title,
state (str): The state of the pull request (e.g., 'open', 'closed').
user (Dict[str, Any]): The user who created the pull request. Contains fields such as:
updated_at (str): ISO 8601 timestamp for when the pull request was last updated.
closed_at (Optional[str]): ISO 8601 timestamp for when the pull request was closed.
merged_at (Optional[str]): ISO 8601 timestamp for when the pull request was merged.
base (Dict[str, Any]): Details of the base branch. Contains fields such as:
sha (str): The SHA of the commit at the tip of the base branch.
repo (Dict[str, Any]): The repository of the base branch. Contains fields such as:
head (Dict[str, Any]): Details of the head branch. Contains fields such as:
sha (str): The SHA of the commit at the tip of the head branch.
repo (Dict[str, Any]): The repository of the head branch (may be null if fork was deleted).
Contains fields such as:
merged_by (Optional[Dict[str, Any]]): The user who merged the pull request. Contains fields
such as:
maintainer_can_modify (bool): Indicates whether maintainers can modify the pull request.
Raises:
NotFoundError: If the repository or pull request does not exist.
or 'closed').
the update).
ForbiddenError: If the user does not have permission to update the pull request.
update_pull_request_branch
@tool_spec(
spec={
'name': 'update_pull_request_branch',
'description':
""" Update a pull request branch with the latest changes from the
base branch.
This function updates a pull request branch by incorporating the
most recent changes
from its base branch. If an `expected_head_sha` is provided, the
update
will only proceed if this SHA matches the current head of the
pull request's
branch, ensuring the update is based on the expected state. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The account owner of the repository. The name is not
case sensitive.'
},
'repo': {
'type':
'string',
'description':
""" The name of the repository without the .git
extension. The name
is not case sensitive. """
},
'pull_number': {
'type': 'integer',
'description':
'The number that identifies the pull request.'
},
'expected_head_sha': {
'type':
'string',
'description':
""" The expected SHA of the pull request's HEAD
ref. This is the most recent commit on the pull
request's branch. If the
expected SHA does not match the pull request's HEAD,
you will receive a
422 Unprocessable Entity status. You can use the
"List commits" endpoint
to find the most recent commit SHA. Defaults to None.
"""
}
},
'required': ['owner', 'repo', 'pull_number']
}
})
def update_pull_request_branch(
owner: str,
repo: str,
pull_number: int,
expected_head_sha: Optional[str] = None) -> Dict[str, str]
Update a pull request branch with the latest changes from the base branch.
This function updates a pull request branch by incorporating the most recent changes
will only proceed if this SHA matches the current head of the pull request's
Args:
owner (str): The account owner of the repository. The name is not case sensitive.
repo (str): The name of the repository without the .git extension. The name
ref. This is the most recent commit on the pull request's branch. If the
expected SHA does not match the pull request's HEAD, you will receive a
422 Unprocessable Entity status. You can use the "List commits" endpoint
Returns:
Dict[str, str]: A dictionary confirming the branch update request. It contains
Raises:
NotFoundError: If the repository or pull request does not exist.
ForbiddenError: If the user does not have sufficient permissions to update the
add_pull_request_review_comment
@tool_spec(
spec={
'name': 'add_pull_request_review_comment',
'description':
""" Add a review comment to a pull request or reply to an
existing comment.
This function adds a review comment to a specified pull request
or replies to an
existing comment. Depending on whether it's a new comment or a
reply,
different parameters are required. For new comments, context like
commit SHA,
file path, and line number may be necessary. For replies, the ID
of the
parent comment is used to inherit context. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The account owner of the repository. The name is not
case sensitive.'
},
'repo': {
'type':
'string',
'description':
'The name of the repository. The name is not case
sensitive.'
},
'pull_number': {
'type': 'integer',
'description':
'The number that identifies the pull request.'
},
'body': {
'type': 'string',
'description': 'The text of the review comment.'
},
'commit_id': {
'type':
'string',
'description':
""" The SHA of the commit to comment on. Required if
`in_reply_to` is not provided and the comment is not
a reply. Defaults to None. """
},
'path': {
'type':
'string',
'description':
""" The relative path to the file that necessitates a
comment.
Required if `in_reply_to` is not provided and the
comment is not a reply. Defaults to None. """
},
'line': {
'type':
'integer',
'description':
""" The line of the blob in the pull request diff
that the
comment applies to. For a multi-line comment, this is
the last line
of the range. Required for new line-level comments
(when `subject_type`
is 'line' or inferred as such). Defaults to None. """
},
'side': {
'type':
'string',
'description':
""" The side of the diff to comment on. Valid values
are
'LEFT' (for the old version) or 'RIGHT' (for the new
version).
Defaults to 'RIGHT' if `line` is provided. Only used
for line-level
comments. Defaults to None. """
},
'start_line': {
'type':
'integer',
'description':
""" For a multi-line comment, the first line of the
range. `line` should be the end line. Only used for
line-level comments. Defaults to None. """
},
'start_side': {
'type':
'string',
'description':
""" The side of the diff for `start_line`. Valid
values
are 'LEFT' or 'RIGHT'. Defaults to the `side`
parameter if not
provided. Only used for multi-line comments. Defaults
to None. """
},
'subject_type': {
'type':
'string',
'description':
""" The type of subject for the comment. Valid values
are 'line' or 'file'. If 'file', line-specific
parameters (`line`,
`side`, `start_line`, `start_side`) are ignored. If
'line', they are
used. If not provided, the API may infer based on
other parameters
(e.g., presence of `line`). Defaults to None. """
},
'in_reply_to': {
'type':
'integer',
'description':
""" The ID of an existing comment to which this
comment is a reply. If provided, parameters like
`commit_id`, `path`,
`line`, `side`, `start_line`, `start_side`, and
`subject_type` are
typically ignored as the reply inherits context from
the parent comment. Defaults to None. """
}
},
'required': ['owner', 'repo', 'pull_number', 'body']
}
})
def add_pull_request_review_comment(
owner: str,
repo: str,
pull_number: int,
body: str,
commit_id: Optional[str] = None,
path: Optional[str] = None,
line: Optional[int] = None,
side: Optional[str] = None,
start_line: Optional[int] = None,
start_side: Optional[str] = None,
subject_type: Optional[str] = None,
in_reply_to: Optional[int] = None) -> Dict[str, Any]
different parameters are required. For new comments, context like commit SHA,
file path, and line number may be necessary. For replies, the ID of the
Args:
owner (str): The account owner of the repository. The name is not case sensitive.
repo (str): The name of the repository. The name is not case sensitive.
`in_reply_to` is not provided and the comment is not a reply. Defaults to None.
path (Optional[str]): The relative path to the file that necessitates a comment.
Required if `in_reply_to` is not provided and the comment is not a reply. Defaults to None.
line (Optional[int]): The line of the blob in the pull request diff that the
comment applies to. For a multi-line comment, this is the last line
side (Optional[str]): The side of the diff to comment on. Valid values are
'LEFT' (for the old version) or 'RIGHT' (for the new version).
start_side (Optional[str]): The side of the diff for `start_line`. Valid values
subject_type (Optional[str]): The type of subject for the comment. Valid values
used. If not provided, the API may infer based on other parameters
typically ignored as the reply inherits context from the parent comment. Defaults to None.
Returns:
Dict[str, Any]: A dictionary containing the details of the newly created review comment.
user (Dict[str, Any]): Object containing details about the commenter. This
position (Optional[int]): The line index in the diff to which the comment
created_at (str): The ISO 8601 timestamp for when the comment was created.
updated_at (str): The ISO 8601 timestamp for when the comment was last
updated.
Raises:
NotFoundError: If the specified `owner`/`repo`, `pull_number`, `commit_id`
range/format.
is not part of the diff, or the `path` is not part of the diff for
merge_pull_request
@tool_spec(
spec={
'name': 'merge_pull_request',
'description': 'Merge a pull request.',
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'pull_number': {
'type': 'integer',
'description': 'The number identifying the pull
request.'
},
'commit_title': {
'type':
'string',
'description':
'An optional title for the merge commit. Defaults to
None.'
},
'commit_message': {
'type':
'string',
'description':
'An optional message for the merge commit. Defaults
to None.'
},
'merge_method': {
'type':
'string',
'description':
'An optional merge method to use. Defaults to None.'
}
},
'required': ['owner', 'repo', 'pull_number']
}
})
def merge_pull_request(owner: str,
repo: str,
pull_number: int,
commit_title: Optional[str] = None,
commit_message: Optional[str] = None,
merge_method: Optional[str] = None) -> Dict[str,
Any]
Merge a pull request.
Args:
owner (str): The owner of the repository.
commit_title (Optional[str]): An optional title for the merge commit. Defaults to None.
Returns:
Dict[str, Any]: A dictionary confirming the merge status. It contains the following fields:
sha (str): The SHA (Secure Hash Algorithm) identifier of the merge commit.
merged (bool): Indicates if the merge was successfully completed (True) or not (False).
message (str): A human-readable message describing the outcome of the merge attempt
(e.g., 'Pull Request successfully merged', 'Merge conflict').
Raises:
NotFoundError: If the repository or pull request does not exist.
ConflictError: If the merge cannot be performed due to conflicts or if the head commit of the
pull request has changed since the merge was initiated.
ValidationError: If the merge method is invalid, or other input parameters are incorrect or
missing.
ForbiddenError: If the authenticated user does not have permission to merge the pull
request.
get_pull_request_files
@tool_spec(
spec={
'name': 'get_pull_request_files',
'description': """ Get the list of files changed in a pull
request.
This function retrieves the list of files changed in a specified
pull request.
The pull request is identified using the `owner` of the
repository,
the `repo` name, and the `pull_number`. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'pull_number': {
'type': 'integer',
'description': 'The number of the pull request.'
}
},
'required': ['owner', 'repo', 'pull_number']
}
})
def get_pull_request_files(owner: str, repo: str,
pull_number: int) -> List[Dict[str, Any]]
This function retrieves the list of files changed in a specified pull request.
Args:
owner (str): The owner of the repository.
Returns:
List[Dict[str, Any]]: A list of dictionaries, where each dictionary details a file
changed in the pull request. Each dictionary has the following keys:
sha (str): The SHA (Secure Hash Algorithm) identifier of the file blob.
filename (str): The relative path of the file within the repository.
status (str): The status of the file ('added', 'modified', 'removed', or 'renamed').
changes (int): The total number of lines changed in the file (sum of additions and deletions).
patch (Optional[str]): The patch data for the file. May be null for binary files or when not
available.
previous_filename (str): The previous filename (only present for renamed files).
Raises:
ValidationError: If the input parameters are invalid.
get_pull_request_status
@tool_spec(
spec={
'name': 'get_pull_request_status',
'description':
""" Get the combined status of all status checks for a pull
request.
This function retrieves the combined status of all status checks
for a specified pull request.
The pull request is identified by its owner, repository, and pull
number.
The returned status includes an overall state, commit SHA, total
check count,
and a detailed list of individual status checks. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'pull_number': {
'type': 'integer',
'description': 'The number identifying the pull
request.'
}
},
'required': ['owner', 'repo', 'pull_number']
}
})
def get_pull_request_status(owner: str, repo: str,
pull_number: int) -> Dict[str, Any]
Get the combined status of all status checks for a pull request.
This function retrieves the combined status of all status checks for a specified pull request.
The pull request is identified by its owner, repository, and pull number.
The returned status includes an overall state, commit SHA, total check count,
Args:
owner (str): The owner of the repository.
Returns:
Dict[str, Any]: A dictionary representing the combined status of a commit. It contains the
following keys:
state (str): The overall status (e.g., 'pending', 'success', 'failure', 'error').
sha (str): The SHA of the commit for which status is reported.
statuses (List[Dict[str, Any]]): A list of individual status check objects. Each dictionary
in this list details a specific status check and contains the following fields:
state (str): State of the specific check (e.g., 'pending', 'success', 'failure', 'error').
context (str): The name or identifier of the status check service (e.g., 'ci/travis-ci', 'lint').
Raises:
NotFoundError: If the repository or pull request (or its head commit) does not exist.
Lists all reviews for a specified pull request. The list of reviews returns in chronological
order.
Args:
owner (str): The account owner of the repository. The name is not case sensitive.
repo (str): The name of the repository without the .git extension. The name is not case
sensitive.
pull_number (int): The number that identifies the pull request. Must be a positive integer.
Returns:
List[Dict[str, Any]]: A list of dictionaries, where each dictionary represents a review
for the pull request. Each dictionary has the following keys:
user (Dict[str, Any]): A dictionary representing the user who submitted the review. This
dictionary contains:
commit_id (str): The SHA of the commit that the review pertains to.
submitted_at (Optional[str]): ISO 8601 timestamp of when the review was submitted.
Raises:
TypeError: If 'owner' or 'repo' is not a string, or if 'pull_number' is not an integer.
get_pull_request_review_comments
@tool_spec(
spec={
'name': 'get_pull_request_review_comments',
'description': """ Get the review comments on a pull request.
Retrieves all review comments associated with a specific pull
request.
The pull request is identified by the repository owner's
identifier,
the repository name, and the pull request number. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The login name or identifier of the repository
owner.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'pull_number': {
'type': 'integer',
'description': 'The number identifying the pull
request.'
}
},
'required': ['owner', 'repo', 'pull_number']
}
})
def get_pull_request_review_comments(owner: str, repo: str,
pull_number: int) -> List[Dict[str,
Any]]
Args:
owner (str): The login name or identifier of the repository owner.
Returns:
List[Dict[str, Any]]: A list of dictionaries, where each dictionary represents a review
comment
for the pull request. Each dictionary contains the following keys:
id (int): The unique ID of the comment.
pull_request_review_id (Optional[int]): The ID of the review this comment belongs to. Null if
the comment is not part of a review.
user (Dict[str, Any]): The user who created the comment. It includes the following keys:
position (Optional[int]): The line index in the diff to which the comment applies.
original_position (Optional[int]): The original line index in the diff. Null for file-level
comments.
diff_hunk (Optional[str]): The diff hunk where the comment appears. Null if not applicable
or available.
created_at (str): ISO 8601 timestamp of when the comment was created.
updated_at (str): ISO 8601 timestamp of when the comment was last updated.
start_line (Optional[int]): The first line of the range of the comment if it spans multiple lines.
Null for single-line comments.
original_start_line (Optional[int]): Original first line of a multi-line comment's range. Null for
single-line comments.
start_side (Optional[str]): The side of the diff to which the first line of a multi-line comment
line (Optional[int]): The line of the blob to which the comment applies. Null for file-level
comments.
original_line (Optional[int]): Original line of the blob. Null for file-level comments.
side (Optional[str]): The side of the diff to which the comment applies (e.g., 'LEFT' or
'RIGHT'). Null for file-level comments.
Raises:
NotFoundError: If the repository or pull request does not exist.
get_pull_request_details
@tool_spec(
spec={
'name': 'get_pull_request_details',
'description': """ Get details of a specific pull request.
This function gets details of a specific pull request. It uses
the provided
owner, repository name, and pull request number to identify and
retrieve
the comprehensive details of the pull request. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The account owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'pull_number': {
'type': 'integer',
'description':
'The number that identifies the pull request.'
}
},
'required': ['owner', 'repo', 'pull_number']
}
})
def get_pull_request_details(owner: str, repo: str,
pull_number: int) -> Dict[str, Any]
This function gets details of a specific pull request. It uses the provided
owner, repository name, and pull request number to identify and retrieve
Returns:
Dict[str, Any]: A dictionary containing the details of the pull request. Fields include:
user (Dict[str, Any]): The user who created the PR. Contains fields:
labels (List[Dict[str, Any]]): A list of labels associated with the PR. Each label object in the
list contains fields:
assignee (Optional[Dict[str, Any]]): The user assigned to the PR. If present, contains fields:
login (str): Username.
assignees (List[Dict[str, Any]]): A list of users assigned to the PR. Each user object in the list
contains fields:
milestone (Optional[Dict[str, Any]]): The milestone associated with the PR. If present,
contains fields:
creator (Dict[str, Any]): The user who created the milestone. Contains fields:
created_at (str): ISO 8601 timestamp of when the milestone was created.
updated_at (str): ISO 8601 timestamp of when the milestone was last updated.
closed_at (Optional[str]): ISO 8601 timestamp of when the milestone was closed.
updated_at (str): ISO 8601 timestamp of when the PR was last updated.
author_association (str): The relationship of the PR author to the repository (e.g., 'OWNER',
'MEMBER', 'COLLABORATOR', 'CONTRIBUTOR', 'FIRST_TIMER',
'FIRST_TIME_CONTRIBUTOR', 'MANNEQUIN', 'NONE').
mergeable_state (str): The state of mergeability (e.g., 'clean', 'dirty', 'unknown', 'blocked',
'behind', 'unstable').
merged_by (Optional[Dict[str, Any]]): The user who merged the PR. If present, contains
fields:
user (Dict[str, Any]): The user who owns the repository of the head branch. Contains fields:
repo (Dict[str, Any]): The repository of the head branch. Contains fields:
created_at (str): ISO 8601 timestamp of when the repository was created.
updated_at (str): ISO 8601 timestamp of when the repository was last updated.
user (Dict[str, Any]): The user who owns the repository of the base branch. Contains fields:
repo (Dict[str, Any]): The repository of the base branch. Contains fields:
created_at (str): ISO 8601 timestamp of when the repository was created.
updated_at (str): ISO 8601 timestamp of when the repository was last updated.
Raises:
ValueError: If any of the input parameters are invalid.
get_authenticated_user
@tool_spec(
spec={
'name': 'get_authenticated_user',
'description': """ Get details of the authenticated user.
Gets details of the authenticated user. """,
'parameters': {
'type': 'object',
'properties': {},
'required': []
}
})
def get_authenticated_user() -> Dict[str, Any]
Returns:
Dict[str, Any]: A dictionary containing the authenticated user's details with the following
keys:
created_at (str): ISO 8601 timestamp for when the account was created.
updated_at (str): ISO 8601 timestamp for when the account was last updated.
Raises:
AuthenticationError: If the request is not authenticated or if the authenticated user cannot
be found.
search_users
@tool_spec(
spec={
'name': 'search_users',
'description': """ Search for GitHub users.
Find users via various criteria. This method returns up to 100
results per page.
The query can contain any combination of search keywords and
qualifiers to narrow down the results.
When no sort is specified, results are sorted by best match. """,
'parameters': {
'type': 'object',
'properties': {
'q': {
'type':
'string',
'description':
""" The search query string. Can contain any
combination of search keywords and qualifiers.
For example: `q=tom+repos:>42+followers:>1000`.
Supported qualifiers:
- `in:login,name,email`: Restricts search to
specified fields.
- `repos:n`: Filters by repository count. Can use
`>`, `<`, `>=`, `<=`, and `..` ranges.
- `followers:n`: Filters by follower count. Can use
`>`, `<`, `>=`, `<=`, and `..` ranges.
- `created:YYYY-MM-DD`: Filters by creation date. Can
use `>`, `<`, `>=`, `<=`, and `..` ranges.
- `location:LOCATION`: Filters by location in the
user's profile.
- `type:user|org`: Restricts search to users or
organizations.
- `language:LANGUAGE`: Filters by the predominant
language in the user's repositories. """
},
'sort': {
'type':
'string',
'description':
""" The field to sort the search results by. Can be
one of 'followers', 'repositories', 'joined'.
Defaults to None (best match). """
},
'order': {
'type':
'string',
'description':
"The order of sorting ('asc' or 'desc'). Defaults to
'desc'."
},
'page': {
'type':
'integer',
'description':
'The page number for paginated results. Defaults to
1.'
},
'per_page': {
'type':
'integer',
'description':
'The number of results to return per page (max 100).
Defaults to 30.'
}
},
'required': ['q']
}
})
def search_users(q: str,
sort: Optional[str] = None,
order: Optional[str] = "desc",
page: Optional[int] = 1,
per_page: Optional[int] = 30) -> Dict[str, Any]
Find users via various criteria. This method returns up to 100 results per page.
The query can contain any combination of search keywords and qualifiers to narrow down
the results.
Args:
q (str): The search query string. Can contain any combination of search keywords and
qualifiers.
Supported qualifiers:
• `repos:n`: Filters by repository count. Can use `>`, `<`, `>=`, `<=`, and `..`
ranges.
• `followers:n`: Filters by follower count. Can use `>`, `<`, `>=`, `<=`, and `..`
ranges.
• `created:YYYY-MM-DD`: Filters by creation date. Can use `>`, `<`, `>=`, `<=`,
and `..` ranges.
sort (Optional[str]): The field to sort the search results by. Can be one of 'followers',
'repositories', 'joined'.
per_page (Optional[int]): The number of results to return per page (max 100). Defaults to
30.
Returns:
Dict[str, Any]: A dictionary containing user search results with the following keys:
incomplete_results (bool): Indicates if the search timed out before finding all results.
items (List[Dict[str, Any]]): A list of user objects matching the search criteria. Each user
object in the list has the following fields:
Raises:
InvalidInputError: If the search query 'q' is missing or invalid, or if pagination parameters
are incorrect.
search_repositories
@tool_spec(
spec={
'name': 'search_repositories',
'description': """ Search for GitHub repositories.
Find repositories via various criteria. This method returns up to
100 results per page.
The query can contain any combination of search keywords and
qualifiers to narrow down the results.
When no sort is specified, results are sorted by best match. """,
'parameters': {
'type': 'object',
'properties': {
'query': {
'type':
'string',
'description':
""" The search query string. Can contain any
combination of search keywords and qualifiers.
For example:
`q=tetris+language:assembly+fork:true+stars:>=100`.
Supported qualifiers:
- `in:name,description`
- `size:>=N`, `size:N..M`
- `forks:N`, `stars:N`, `watchers:N` (with ranges)
- `user:USERNAME`, `org:USERNAME`
- `language:LANGUAGE`
- `created:DATE`, `pushed:DATE`, `updated:DATE` (with
ranges)
- `is:public`, `is:private`, `is:archived`,
`is:template`
- `fork:true`, `fork:only` """
},
'sort': {
'type':
'string',
'description':
'The field to sort by. Can be `stars`, `forks`,
`updated`. Defaults to None.'
},
'order': {
'type':
'string',
'description':
'The direction to sort. Can be `asc` or `desc`.
Defaults to `desc`.'
},
'page': {
'type':
'integer',
'description':
'Page number of the results to fetch. Defaults to 1.'
},
'per_page': {
'type':
'integer',
'description':
'The number of results per page (max 100). Defaults
to 30.'
}
},
'required': ['query']
}
})
def search_repositories(query: str,
sort: Optional[str] = None,
order: Optional[str] = "desc",
page: Optional[int] = 1,
per_page: Optional[int] = 30) -> Dict[str, Any]
Search for GitHub repositories.
Find repositories via various criteria. This method returns up to 100 results per page.
The query can contain any combination of search keywords and qualifiers to narrow down
the results.
Args:
query (str): The search query string. Can contain any combination of search keywords and
qualifiers.
Supported qualifiers:
• `in:name,description`
• `size:>=N`, `size:N..M`
• `user:USERNAME`, `org:USERNAME`
• `language:LANGUAGE`
• `fork:true`, `fork:only`
sort (Optional[str]): The field to sort by. Can be `stars`, `forks`, `updated`. Defaults to None.
order (Optional[str]): The direction to sort. Can be `asc` or `desc`. Defaults to `desc`.
per_page (Optional[int]): The number of results per page (max 100). Defaults to 30.
Returns:
Dict[str, Any]: A dictionary containing a `search_results` object with the repository search
results.
• created_at (str): The timestamp (ISO 8601 format) for when the
repository was created.
• updated_at (str): The timestamp (ISO 8601 format) for when the
repository was last updated.
• pushed_at (str): The timestamp (ISO 8601 format) for when the
repository was last pushed to.
Raises:
InvalidInputError: If the query is invalid or pagination parameters are incorrect.
list_repository_commits
@tool_spec(
spec={
'name': 'list_repository_commits',
'description': """ Get a list of commits of a branch in a
repository.
This function gets a list of commits of a branch in a repository.
""",
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'sha': {
'type':
'string',
'description':
'The commit SHA or branch name to list commits from.
Defaults to None.'
},
'path': {
'type':
'string',
'description':
'Only commits containing this file path will be
returned. Defaults to None.'
},
'page': {
'type':
'integer',
'description':
'Page number of the results to fetch for pagination.
Defaults to 1.'
},
'per_page': {
'type':
'integer',
'description':
'The number of results per page for pagination.
Defaults to 30.'
}
},
'required': ['owner', 'repo']
}
})
def list_repository_commits(
owner: str,
repo: str,
sha: Optional[str] = None,
path: Optional[str] = None,
page: Optional[int] = 1,
per_page: Optional[int] = 30) -> List[Dict[str, Any]]
Args:
owner (str): The owner of the repository.
sha (Optional[str]): The commit SHA or branch name to list commits from. Defaults to None.
path (Optional[str]): Only commits containing this file path will be returned. Defaults to
None.
page (Optional[int]): Page number of the results to fetch for pagination. Defaults to 1.
per_page (Optional[int]): The number of results per page for pagination. Defaults to 30.
Returns:
List[Dict[str, Any]]: A list of commit objects. Each dictionary in this list
sha (str): The SHA (Secure Hash Algorithm) identifier of the commit.
node_id (str): The global node ID of the commit.
commit (Dict[str, Any]): Core commit information. Contains the following fields:
date (str): The timestamp (ISO 8601 format) when this commit
was authored.
date (str): The timestamp (ISO 8601 format) when this commit
was committed.
tree (Dict[str, Any]): Details of the tree object associated with this
author (Optional[Dict[str, Any]]): The GitHub user account that authored the
on GitHub.
on GitHub.
Raises:
ValidationError: If input parameters are invalid (empty strings, invalid formats,
get_repository_commit_details
@tool_spec(
spec={
'name': 'get_repository_commit_details',
'description': """ Get details for a commit from a repository.
This function gets details for a commit from a repository. The
`page` and
`per_page` parameters can be used to paginate the list of files
affected
by the commit, which is part of the returned details. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'sha': {
'type': 'string',
'description': 'The SHA of the commit to retrieve.'
},
'page': {
'type':
'integer',
'description':
'Page number for paginating the list of files
affected by the commit. Defaults to None.'
},
'per_page': {
'type':
'integer',
'description':
'The number of files to return per page when
paginating. Defaults to None.'
}
},
'required': ['owner', 'repo', 'sha']
}
})
def get_repository_commit_details(
owner: str,
repo: str,
sha: str,
page: Optional[int] = None,
per_page: Optional[int] = None) -> Dict[str, Any]
This function gets details for a commit from a repository. The `page` and
Args:
owner (str): The owner of the repository.
page (Optional[int]): Page number for paginating the list of files affected by the commit.
Defaults to None.
per_page (Optional[int]): The number of files to return per page when paginating. Defaults
to None.
Returns:
Dict[str, Any]: A dictionary containing details for a specific commit. It includes the following
keys:
date (str): Timestamp of when the commit was authored (ISO 8601 format).
committer (Dict[str, Any]): Details of the person who committed the changes:
date (str): Timestamp of when the commit was made (ISO 8601 format).
message (str): The commit message.
author (Optional[Dict[str, Any]]): The GitHub user who authored the commit (if linked to a
GitHub account).
If present, contains:
committer (Optional[Dict[str, Any]]): The GitHub user who committed the changes (if linked
to a GitHub account).
If present, contains:
parents (List[Dict[str, Any]]): A list of parent commit objects. Each object in the list contains:
files (Optional[List[Dict[str, Any]]]): A list of files affected by this commit. This list may be
paginated if 'page' and 'per_page' parameters are used in the request. Each file
status (str): Status of the file in this commit (e.g., 'added', 'modified', 'removed', 'renamed').
patch (Optional[str]): The patch data (diff) for the file, detailing the changes.
Raises:
ValidationError: If input parameters are invalid (invalid types, negative values for
page/per_page).
create_repository_branch
@tool_spec(
spec={
'name': 'create_repository_branch',
'description': """ Create a new branch.
This function establishes a new branch of development within the
repository. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The account owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'branch': {
'type': 'string',
'description': 'The name of the new branch to
create.'
},
'sha': {
'type':
'string',
'description':
'The SHA of the commit from which the new branch will
be created.'
}
},
'required': ['owner', 'repo', 'branch', 'sha']
}
})
def create_repository_branch(owner: str, repo: str, branch: str,
sha: str) -> Dict[str, Any]
Args:
owner (str): The account owner of the repository.
sha (str): The SHA of the commit from which the new branch will be created.
Returns:
Dict[str, Any]: A dictionary containing branch creation details with the following keys:
object (Dict[str, Any]): Details of the Git object this ref points to. This dictionary contains the
following keys:
sha (str): The SHA of the commit the new branch points to.
Raises:
NotFoundError: If the repository or the source 'sha' does not exist.
UnprocessableEntityError: If the branch already exists, if the 'sha' is not a valid commit SHA,
if the branch name is invalid, or if required fields (owner, repo, branch, sha)
create_or_update_repository_file
@tool_spec(
spec={
'name': 'create_or_update_repository_file',
'description': """ Create or update a single file in a
repository.
This function creates a new file or updates an existing file at a
specified
path within a given repository. It requires the repository
owner's identifier,
the repository name, the file's path, a commit message, and the
file's
content. Optional parameters include the branch name and, for
file updates,
the SHA of the existing file blob to ensure the correct file
version is modified. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The account owner of the repository (e.g., username
or organization name).'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'path': {
'type': 'string',
'description': 'The path to the file in the
repository.'
},
'message': {
'type': 'string',
'description': 'The commit message.'
},
'content': {
'type': 'string',
'description': 'The new file content, base64
encoded.'
},
'branch': {
'type':
'string',
'description':
""" The branch name. If not provided, the operation
typically targets the repository's default branch.
Defaults to None. """
},
'sha': {
'type':
'string',
'description':
""" The blob SHA of the file being replaced. This is
required if updating an existing file and is used to
prevent conflicts
by ensuring the file has not changed since the SHA
was obtained.
Defaults to None. """
}
},
'required': ['owner', 'repo', 'path', 'message', 'content']
}
})
def create_or_update_repository_file(
owner: str,
repo: str,
path: str,
message: str,
content: str,
branch: Optional[str] = None,
sha: Optional[str] = None) -> Dict[str, Any]
the repository name, the file's path, a commit message, and the file's
content. Optional parameters include the branch name and, for file updates,
the SHA of the existing file blob to ensure the correct file version is modified.
Args:
owner (str): The account owner of the repository (e.g., username or organization name).
sha (Optional[str]): The blob SHA of the file being replaced. This is
by ensuring the file has not changed since the SHA was obtained.
Defaults to None.
Returns:
Dict[str, Any]: A dictionary containing details about the commit and the file.
commit (Dict[str, Any]): Details of the commit that created/updated the file. This dictionary
contains:
author (Dict[str, Any]): The author of the commit. This dictionary contains:
date (str): The timestamp of the authorship, in ISO 8601 format (e.g.,
'YYYY-MM-DDTHH:MM:SSZ').
committer (Dict[str, Any]): The committer of the commit. This dictionary contains:
date (str): The timestamp of the commit, in ISO 8601 format (e.g.,
'YYYY-MM-DDTHH:MM:SSZ').
Raises:
NotFoundError: If the repository or branch (if specified) does not exist.
ConflictError: If updating a file and the provided 'sha' does not match
ForbiddenError: If the user does not have write access to the repository
Creates a new GitHub repository. The user specifies the name for the
Returns:
Dict[str, Any]: A dictionary containing the details of the newly created repository with the
following keys:
full_name (str): The full name of the repository, including the owner (e.g., 'owner/repo').
owner (Dict[str, Any]): Details of the repository owner. Key non-URL fields include:
fork (bool): Indicates if the repository is a fork. This will be false for newly created
repositories.
created_at (str): The ISO 8601 timestamp for when the repository was created.
updated_at (str): The ISO 8601 timestamp for when the repository was last updated.
pushed_at (str): The ISO 8601 timestamp for when the repository was last pushed to.
default_branch (str): The name of the default branch (e.g., 'main'). This is typically present if
'auto_init' was true during creation.
Raises:
ValidationError: If required inputs are missing (e.g., repository name) or if inputs are
malformed (e.g., invalid characters in the name).
UnprocessableEntityError: If the repository cannot be created due to semantic reasons, such
as the repository name already existing for the user/organization, or other server-side
validation failures not related to input format.
ForbiddenError: If the authenticated user does not have the necessary permissions to create
a repository (e.g., insufficient rights for an organization, or account restriction).
push_repository_files
@tool_spec(
spec={
'name': 'push_repository_files',
'description': """ Push multiple files in a single commit.
This function pushes multiple files in a single commit. It uses
the provided
repository owner's username, repository name, target branch name,
a list of
files (each defined by its path and content), and a commit
message to
perform the operation. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The username of the account that owns the
repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'branch': {
'type': 'string',
'description':
'The name of the branch to push the files to.'
},
'files': {
'type': 'array',
'description':
""" A list of dictionaries, where each dictionary
represents a file to be pushed. Each dictionary must
contain the
following keys: """,
'items': {
'type': 'object',
'properties': {
'path': {
'type':
'string',
'description':
'The full path of the file within the
repository.'
},
'content': {
'type': 'string',
'description': 'The content of the file.'
}
},
'required': ['path', 'content']
}
},
'message': {
'type': 'string',
'description': 'The commit message for the push
operation.'
},
'author_date': {
'type':
'string',
'description':
""" Custom author date in ISO 8601 format
(YYYY-MM-DDTHH:MM:SSZ).
If not provided, current date will be used. Defaults
to None. """
},
'committer_date': {
'type':
'string',
'description':
""" Custom committer date in ISO 8601 format
(YYYY-MM-DDTHH:MM:SSZ).
If not provided, current date will be used. Defaults
to None. """
}
},
'required': ['owner', 'repo', 'branch', 'files', 'message']
}
})
def push_repository_files(
owner: str,
repo: str,
branch: str,
files: List[Dict[str, str]],
message: str,
author_date: Optional[str] = None,
committer_date: Optional[str] = None) -> Dict[str, Any]
This function pushes multiple files in a single commit. It uses the provided
files (each defined by its path and content), and a commit message to
Args:
owner (str): The username of the account that owns the repository.
branch (str): The name of the branch to push the files to.
following keys:
path (str): The full path of the file within the repository.
Returns:
Dict[str, Any]: Details of the successful push operation, including commit
tree_sha (str): The SHA of the new tree object representing the repository state.
message (str): A confirmation message regarding the push.
Raises:
NotFoundError: If the repository or branch does not exist, or if the
or message is missing.
list_repository_branches
@tool_spec(
spec={
'name': 'list_repository_branches',
'description': """ List branches in a GitHub repository.
Lists branches in a GitHub repository, sorted by name. This
function allows for pagination
of the results. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The owner of the repository. Must not be empty.'
},
'repo': {
'type': 'string',
'description':
'The name of the repository. Must not be empty.'
},
'page': {
'type':
'integer',
'description':
""" The page number of the results to fetch. Defaults
to 1.
Must be a positive integer if provided. """
},
'per_page': {
'type':
'integer',
'description':
""" The number of results per page. Defaults to 30.
Must be a positive integer if provided. """
}
},
'required': ['owner', 'repo']
}
})
def list_repository_branches(
owner: str,
repo: str,
page: Optional[int] = 1,
per_page: Optional[int] = 30) -> List[Dict[str, Any]]
Lists branches in a GitHub repository, sorted by name. This function allows for pagination
of the results.
Args:
owner (str): The owner of the repository. Must not be empty.
Returns:
List[Dict[str, Any]]: A list of branch objects from the repository, sorted by name.
Each dictionary in the list represents a branch object and has the following fields:
fork_repository
@tool_spec(
spec={
'name': 'fork_repository',
'description': """ Fork a repository.
Creates a fork for the authenticated user. The user should have
`Administration` repository permissions (write) to set up and
configure the new repository (users fork) under the users account.
`Contents` repository permissions (read) to read the `Contents`
of the original repository to get all the data. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
""" The account owner of the repository. The name is
not case sensitive.
Must be a non-empty string without whitespace
characters. Maximum 39 characters. """
},
'repo': {
'type':
'string',
'description':
""" The name of the repository without the `.git`
extension. The name is not case sensitive.
Must be a non-empty string without whitespace
characters. Maximum 100 characters. """
},
'organization': {
'type':
'string',
'description':
""" Optional parameter to specify the organization
name if forking into an organization. Defaults to None.
If provided, must be a non-empty string without
whitespace characters. Maximum 39 characters. """
}
},
'required': ['owner', 'repo']
}
})
def fork_repository(owner: str,
repo: str,
organization: Optional[str] = None) -> Dict[str, Any]
Fork a repository.
Creates a fork for the authenticated user. The user should have
`Administration` repository permissions (write) to set up and configure the new repository
(users fork) under the users account.
`Contents` repository permissions (read) to read the `Contents` of the original repository to
get all the data.
Args:
owner (str): The account owner of the repository. The name is not case sensitive.
repo (str): The name of the repository without the `.git` extension. The name is not case
sensitive.
Returns:
Dict[str, Any]: A dictionary containing the details of the newly forked repository. The
structure includes the following fields:
owner (Dict[str, Any]): An object describing the owner of the forked repository. It includes
the following sub-fields:
Raises:
ValidationError: If input validation fails, including:
NotFoundError: If the source repository does not exist or target organization does not exist.
ForbiddenError: If the user does not have permission to read the source repository,
get_repository_file_contents
@tool_spec(
spec={
'name': 'get_repository_file_contents',
'description': """ Get contents of a file or directory.
This function retrieves the content of a specified file or
directory within a
repository. The nature of the returned data depends on whether
the specified
path points to a file or a directory. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'path': {
'type':
'string',
'description':
'The path to the file or directory within the
repository.'
},
'ref': {
'type':
'string',
'description':
""" An optional Git reference (e.g., a branch name,
tag, or commit SHA) specifying the version of the
content to retrieve.
Defaults to None. """
}
},
'required': ['owner', 'repo', 'path']
}
})
def get_repository_file_contents(
owner: str,
repo: str,
path: str,
ref: Optional[str] = None
) -> Union[Dict[str, Any], List[Dict[str, Any]]]
repository. The nature of the returned data depends on whether the specified
Args:
owner (str): The owner of the repository.
path (str): The path to the file or directory within the repository.
Defaults to None.
Returns:
Union[Dict[str, Any], List[Dict[str, Any]]]: The content of the specified path.
size (int): The size of the item in bytes. For directories, this may
path (str): The path of the file or directory within the repository.
sha (str): The Git blob SHA (for files) or tree SHA (for directories).
Raises:
ValidationError: If owner, repo, or path are empty.
search_repository_code
@tool_spec(
spec={
'name': 'search_repository_code',
'description': """ Search for code within repositories.
Searches for query terms inside of files. This method returns up
to 100 results per page.
The query can contain any combination of search keywords and
qualifiers.
Note: Due to the complexity of searching code, there are a few
restrictions:
- Only the default branch is considered. In most cases, this will
be the master branch.
- Only files smaller than 384 KB are searchable.
- You must always include at least one search term when searching
source code.
For example, searching for language:go is not valid, while
amazing language:go is. """,
'parameters': {
'type': 'object',
'properties': {
'query': {
'type':
'string',
'description':
""" The search query string. Can contain any
combination of search keywords and qualifiers.
Examples:
- `"addClass in:file language:js
repo:jquery/jquery"`: Find files containing 'addClass' in the
jquery/jquery repository
- `"repo:octocat/Spoon-Knife css"`: Find instances of
'css' in the octocat/Spoon-Knife repository
- `"shogun user:heroku language:ruby"`: Find 'shogun'
in Ruby files from heroku's repositories
- `"function size:>10000 language:python"`: Find
Python files containing 'function' larger than 10 KB
Supported qualifiers:
- `in:file,path`: Search in file contents and/or file
paths. If not specified, searches in both.
- `language:LANGUAGE`: Filter by programming language
(based on file extension).
Supported languages: javascript (js), python
(py), ruby (rb), go, java, c++ (cpp),
typescript (ts), php, c# (cs), html, css, shell
(sh), markdown (md).
- `repo:owner/repository`: Restrict search to a
specific repository.
- `user:USERNAME`, `org:USERNAME`: Search within a
user's or organization's repositories.
- `size:n`: Filter by file size (in bytes). Can use
`>`, `<`, `>=`, `<=`, and `..` ranges.
- `path:PATH`: Filter by file path.
- `extension:EXTENSION`: Filter by file extension.
- `is:public`, `is:private`: Filter by repository
visibility.
- `fork:true`, `fork:only`: Include forked
repositories in the search. """
},
'sort': {
'type':
'string',
'description':
""" The field to sort by. Can be 'indexed' or 'best
match'.
Defaults to 'best match'. """
},
'order': {
'type':
'string',
'description':
"The direction to sort. Can be 'asc' or 'desc'.
Defaults to 'desc'."
},
'page': {
'type':
'integer',
'description':
'Page number of the results to fetch. Defaults to 1.'
},
'per_page': {
'type':
'integer',
'description':
'The number of results per page (max 100). Defaults
to 30.'
}
},
'required': ['query']
}
})
def search_repository_code(query: str,
sort: Optional[str] = 'best match',
order: Optional[str] = 'desc',
page: Optional[int] = 1,
per_page: Optional[int] = 30) -> Dict[str,
Any]
Searches for query terms inside of files. This method returns up to 100 results per page.
The query can contain any combination of search keywords and qualifiers.
Note: Due to the complexity of searching code, there are a few restrictions:
• Only the default branch is considered. In most cases, this will be the master branch.
• You must always include at least one search term when searching source code.
For example, searching for language:go is not valid, while amazing language:go is.
Args:
query (str): The search query string. Can contain any combination of search keywords and
qualifiers.
Examples:
Supported qualifiers:
Supported languages: javascript (js), python (py), ruby (rb), go, java, c++ (cpp),
typescript (ts), php, c# (cs), html, css, shell (sh), markdown (md).
• `size:n`: Filter by file size (in bytes). Can use `>`, `<`, `>=`, `<=`, and `..`
ranges.
sort (Optional[str]): The field to sort by. Can be 'indexed' or 'best match'.
order (Optional[str]): The direction to sort. Can be 'asc' or 'desc'. Defaults to 'desc'.
per_page (Optional[int]): The number of results per page (max 100). Defaults to 30.
Returns:
Dict[str, Any]: A dictionary containing the search results with the following keys:
incomplete_results (bool): Indicates if the search timed out before finding all results.
items (List[Dict[str, Any]]): A list of code search result items. Each item contains:
repository (Dict[str, Any]): Details about the repository containing the file:
Raises:
InvalidInputError: If the search query is missing or invalid, or if pagination parameters are
malformed, not positive integers, or out of acceptable range.
RateLimitError: If the request exceeds the rate limit. Rate limits for search API:
search_issues_and_pull_requests
@tool_spec(
spec={
'name': 'search_issues_and_pull_requests',
'description': """ Search for issues and pull requests.
Finds issues and pull requests by searching against a query
string.
The query can contain any combination of search keywords and
qualifiers.
Supported qualifiers:
- `is:issue` or `is:pr`: Filters for either issues or pull
requests.
- `repo:owner/repository`: Restricts the search to a specific
repository.
- `author:username`: Finds items created by a specific user.
- `assignee:username`: Finds items assigned to a specific user.
- `label:"label name"`: Filters by a specific label. Use quotes
for labels with spaces.
- `state:open` or `state:closed`: Filters by the state.
- `in:title,body`: Searches for keywords in the title, body, or
both. """,
'parameters': {
'type': 'object',
'properties': {
'query': {
'type':
'string',
'description':
'The search query string, including any qualifiers.'
},
'sort': {
'type':
'string',
'description':
""" The field to sort by. Can be 'created',
'updated', or 'comments'.
Defaults to `None` (best-match). """
},
'order': {
'type':
'string',
'description':
"The direction to sort. Can be 'asc' or 'desc'.
Defaults to 'desc'."
},
'page': {
'type':
'integer',
'description':
'Page number of the results to fetch. Defaults to 1.'
},
'per_page': {
'type':
'integer',
'description':
'The number of results per page (max 100). Defaults
to 30.'
}
},
'required': ['query']
}
})
def search_issues_and_pull_requests(
query: str,
sort: Optional[str] = None,
order: Optional[str] = "desc",
page: Optional[int] = 1,
per_page: Optional[int] = 30) -> Dict[str, Any]
Supported qualifiers:
• `label:"label name"`: Filters by a specific label. Use quotes for labels with spaces.
Args:
query (str): The search query string, including any qualifiers.
sort (Optional[str]): The field to sort by. Can be 'created', 'updated', or 'comments'.
order (Optional[str]): The direction to sort. Can be 'asc' or 'desc'. Defaults to 'desc'.
per_page (Optional[int]): The number of results per page (max 100). Defaults to 30.
Returns:
Dict[str, Any]: A dictionary containing the search results, with the following keys:
• state (str): The current state of the issue (e.g., 'open', 'closed').
Raises:
custom_errors.InvalidInputError: If the search query is missing or invalid,
list_repository_issues
@tool_spec(
spec={
'name': 'list_repository_issues',
'description': """ List and filter repository issues.
Lists and filters issues for a specified repository. This
function allows
retrieval of issues based on criteria such as their state (e.g.,
open,
closed, all), associated labels, and a 'since' timestamp
indicating the
minimum update time. The results can be sorted by fields like
'created',
'updated', or 'comments', in either ascending ('asc') or
descending
('desc') order. Pagination is supported through 'page' and
'per_page'
parameters to manage the volume of returned data. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'state': {
'type':
'string',
'description':
""" The state of the issues to return (e.g., 'open',
'closed', 'all'). Defaults to None. """
},
'labels': {
'type': 'array',
'description':
'A list of label names to filter issues by. Defaults
to None.',
'items': {
'type': 'string'
}
},
'sort': {
'type':
'string',
'description':
""" The criteria for sorting the issues (e.g.,
'created',
'updated', 'comments'). Defaults to None. """
},
'direction': {
'type':
'string',
'description':
"The direction of sorting (e.g., 'asc', 'desc').
Defaults to None."
},
'since': {
'type':
'string',
'description':
""" An ISO 8601 timestamp to filter issues updated at
or after this time. Defaults to None. """
},
'page': {
'type':
'integer',
'description':
'The page number for paginated results. Defaults to
1.'
},
'per_page': {
'type':
'integer',
'description':
'The number of issues to return per page. Defaults to
30.'
}
},
'required': ['owner', 'repo']
}
})
def list_repository_issues(
owner: str,
repo: str,
state: Optional[str] = None,
labels: Optional[List[str]] = None,
sort: Optional[str] = None,
direction: Optional[str] = None,
since: Optional[str] = None,
page: Optional[int] = 1,
per_page: Optional[int] = 30) -> List[Dict[str, Any]]
Lists and filters issues for a specified repository. This function allows
minimum update time. The results can be sorted by fields like 'created',
labels (Optional[List[str]]): A list of label names to filter issues by. Defaults to None.
sort (Optional[str]): The criteria for sorting the issues (e.g., 'created',
direction (Optional[str]): The direction of sorting (e.g., 'asc', 'desc'). Defaults to None.
per_page (Optional[int]): The number of issues to return per page. Defaults to 30.
Returns:
List[Dict[str, Any]]: A list of dictionaries, where each dictionary
• user (Dict[str, Any]): The user who created the issue. This
issue, if applicable.
keys:
following keys:
following keys:
was created.
due date.
• created_at (str): ISO 8601 timestamp of when the issue was created.
• updated_at (str): ISO 8601 timestamp of when the issue was last
updated.
closed.
'MANNEQUIN', 'NONE').
Raises:
NotFoundError: If the repository does not exist.
update_issue
@tool_spec(
spec={
'name': 'update_issue',
'description': """ Update an existing issue in a GitHub
repository.
This function updates an existing issue within a specified GitHub
repository.
It allows modification of the issue's title, body, state (open or
closed),
associated labels, assigned users, and milestone. The title and
body can
be cleared by passing `None`. Labels and assignees are replaced
if new lists
are provided; an empty list clears them.
The `updated_at` timestamp is always modified on a successful
call. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
'The account owner of the repository.
Case-insensitive.'
},
'repo': {
'type': 'string',
'description':
'The name of the repository. Case-insensitive.'
},
'issue_number': {
'type':
'integer',
'description':
'The number that identifies the issue. Must be
positive.'
},
'title': {
'type':
'string',
'description':
""" The new title for the issue. If `None` (default
or explicit),
the title is cleared (set to `None`). """
},
'body': {
'type':
'string',
'description':
""" The new contents of the issue. If `None` (default
or explicit),
the body is cleared (set to `None`). """
},
'state': {
'type':
'string',
'description':
""" The new state ("open" or "closed"). If `None`
(default),
the state is not changed. """
},
'labels': {
'type': 'array',
'description':
""" List of label names to apply. Replaces existing
labels.
- If `None` (default): Labels are not changed.
- If `[]` (empty list): All labels are removed.
- If list of strings: These become the new labels.
Each name must exist.
Requires push access. """,
'items': {
'type': 'string'
}
},
'assignees': {
'type': 'array',
'description':
""" List of assignee logins. Replaces existing
assignees.
The first login becomes the primary assignee.
- If `None` (default): Assignees are not changed.
- If `[]` (empty list): All assignees are removed.
- If list of logins: These become the new assignees.
Each login must exist.
Requires push access. """,
'items': {
'type': 'string'
}
},
'milestone': {
'type':
'integer',
'description':
""" The number of the milestone to assign.
- If `None` (default or explicitly passed as `None`):
Removes the current milestone.
- If a positive integer: Assigns to this milestone.
Must exist in the repository.
- Note: Milestone number 0 is not valid and will
raise a ValidationError.
Requires push access for any change to the milestone
(setting or removing). """
}
},
'required': ['owner', 'repo', 'issue_number']
}
})
def update_issue(owner: str,
repo: str,
issue_number: int,
title: Optional[str] = None,
body: Optional[str] = None,
state: Optional[str] = None,
labels: Optional[List[str]] = None,
assignees: Optional[List[str]] = None,
milestone: Optional[int] = None) -> Dict[str, Any]
associated labels, assigned users, and milestone. The title and body can
be cleared by passing `None`. Labels and assignees are replaced if new lists
Args:
owner (str): The account owner of the repository. Case-insensitive.
issue_number (int): The number that identifies the issue. Must be positive.
title (Optional[str]): The new title for the issue. If `None` (default or explicit),
body (Optional[str]): The new contents of the issue. If `None` (default or explicit),
• If list of strings: These become the new labels. Each name must exist.
• If list of logins: These become the new assignees. Each login must exist.
Requires push access for any change to the milestone (setting or removing).
Returns:
Dict[str, Any]: Details of the updated issue. Contains:
Raises:
NotFoundError: If repository or issue is not found.
get_issue_comments
@tool_spec(
spec={
'name': 'get_issue_comments',
'description': """ Get comments for a GitHub issue.
This function gets comments for a GitHub issue. The issue is
identified using
the provided repository owner, repository name, and issue number.
""",
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'issue_number': {
'type': 'integer',
'description': 'The number of the issue.'
}
},
'required': ['owner', 'repo', 'issue_number']
}
})
def get_issue_comments(owner: str, repo: str,
issue_number: int) -> List[Dict[str, Any]]
This function gets comments for a GitHub issue. The issue is identified using
Args:
owner (str): The owner of the repository.
Returns:
List[Dict[str, Any]]: A list of comment objects for the issue. Each dictionary
user (Dict[str, Any]): Details of the user who created the comment. This
created_at (str): ISO 8601 timestamp indicating when the comment was
created.
updated_at (str): ISO 8601 timestamp indicating when the comment was
last updated.
Raises:
NotFoundError: If the repository or issue does not exist.
get_issue_content
@tool_spec(
spec={
'name': 'get_issue_content',
'description': """ Gets the contents of an issue within a
repository.
This function retrieves detailed information about a specific
issue identified
by its number, belonging to the specified repository and owner.
The returned
dictionary is a direct representation of the data for the found
issue. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type':
'string',
'description':
""" The username of the account that owns the
repository.
Must be a non-empty string. """
},
'repo': {
'type':
'string',
'description':
'The name of the repository. Must be a non-empty
string.'
},
'issue_number': {
'type':
'integer',
'description':
'The number that identifies the issue. Must be a
positive integer.'
}
},
'required': ['owner', 'repo', 'issue_number']
}
})
def get_issue_content(owner: str, repo: str,
issue_number: int) -> Dict[str, Any]
by its number, belonging to the specified repository and owner. The returned
Args:
owner (str): The username of the account that owns the repository.
issue_number (int): The number that identifies the issue. Must be a positive integer.
Returns:
Dict[str, Any]: A dictionary containing the details of the issue.
user (Dict[str, Any]): The user who created the issue. This dictionary
following fields:
assignee (Optional[Dict[str, Any]]): The user assigned to the issue (if any).
following fields:
milestone (Optional[Dict[str, Any]]): The milestone associated with the issue (if any).
created_at (str): ISO 8601 timestamp of when the milestone was created.
updated_at (str): ISO 8601 timestamp of when the milestone was last updated.
closed_at (Optional[str]): ISO 8601 timestamp of when the milestone was closed.
created_at (str): ISO 8601 timestamp of when the issue was created.
updated_at (str): ISO 8601 timestamp of when the issue was last updated.
closed_at (Optional[str]): ISO 8601 timestamp of when the issue was closed.
"NONE", "OWNER".
url (str): URL to the reactions API endpoint for this issue.
score (Optional[float]): Search score if the issue was retrieved from search results.
Raises:
TypeError: If any of the input arguments are of an incorrect type.
create_issue
@tool_spec(
spec={
'name': 'create_issue',
'description': """ Create a new issue in a GitHub repository.
This function facilitates the creation of a new issue within a
designated GitHub repository.
It accepts details such as the issue's title, an optional body,
optional assignees,
and optional labels to initialize the issue. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type':
'string',
'description':
'The name of the repository. Must be 1-100 characters
and can include alphanumeric characters, hyphens, underscores, or
periods.'
},
'title': {
'type': 'string',
'description': 'The title for the new issue.'
},
'body': {
'type': 'string',
'description':
'The contents of the issue. Default to None.'
},
'assignees': {
'type': 'array',
'description':
'A list of GitHub logins to assign to this issue.
Default to None.',
'items': {
'type': 'string'
}
},
'labels': {
'type': 'array',
'description':
'A list of label names to add to this issue. Default
to None.',
'items': {
'type': 'string'
}
}
},
'required': ['owner', 'repo', 'title']
}
})
def create_issue(owner: str,
repo: str,
title: str,
body: Optional[str] = None,
assignees: Optional[List[str]] = None,
labels: Optional[List[str]] = None) -> Dict[str, Any]
This function facilitates the creation of a new issue within a designated GitHub repository.
It accepts details such as the issue's title, an optional body, optional assignees,
Args:
owner (str): The owner of the repository.
repo (str): The name of the repository. Must be 1-100 characters and can include
alphanumeric characters, hyphens, underscores, or periods.
assignees (Optional[List[str]]): A list of GitHub logins to assign to this issue. Default to None.
labels (Optional[List[str]]): A list of label names to add to this issue. Default to None.
Returns:
Dict[str, Any]: A dictionary containing details of the created issue with the following keys:
user (Dict[str, Any]): The user who created the issue. The dictionary contains:
labels (List[Dict[str, Any]]): A list of labels associated with the issue. Each dictionary in the
list contains:
assignee (Optional[Dict[str, Any]]): The user assigned to the issue (if any). If present, the
dictionary contains:
assignees (List[Dict[str, Any]]): A list of users assigned to the issue. Each dictionary in the
list contains:
milestone (Optional[Dict[str, Any]]): The milestone associated with the issue. If present, the
dictionary contains:
creator (Dict[str, Any]): The user who created the milestone. The dictionary contains:
created_at (str): ISO 8601 timestamp of when the milestone was created.
updated_at (str): ISO 8601 timestamp of when the milestone was last updated.
closed_at (Optional[str]): ISO 8601 timestamp of when the milestone was closed.
created_at (str): ISO 8601 timestamp of when the issue was created.
updated_at (str): ISO 8601 timestamp of when the issue was last updated.
closed_at (Optional[str]): ISO 8601 timestamp of when the issue was closed (null if open).
author_association (str): The relationship of the issue author to the repository (e.g.,
'OWNER', 'MEMBER', 'CONTRIBUTOR', 'NONE').
Raises:
NotFoundError: If the repository does not exist.
ForbiddenError: If the user does not have permission to create issues in the repository.
InternalError: If the issue cannot be created due to an internal data validation error.
add_issue_comment
@tool_spec(
spec={
'name': 'add_issue_comment',
'description': """ Add a comment to an issue.
This function adds a comment to a specific issue. It takes the
repository's
owner, the repository name, the issue number, and the comment's
body content
as input. Upon successful execution, it provides a dictionary
containing
details of the newly created comment. """,
'parameters': {
'type': 'object',
'properties': {
'owner': {
'type': 'string',
'description': 'The owner of the repository.'
},
'repo': {
'type': 'string',
'description': 'The name of the repository.'
},
'issue_number': {
'type': 'integer',
'description': 'The number that identifies the
issue.'
},
'body': {
'type': 'string',
'description': 'The content of the comment.'
}
},
'required': ['owner', 'repo', 'issue_number', 'body']
}
})
def add_issue_comment(owner: str, repo: str, issue_number: int,
body: str) -> Dict[str, Any]
owner, the repository name, the issue number, and the comment's body content
Args:
owner (str): The owner of the repository.
Returns:
Dict[str, Any]: A dictionary containing the details of the newly created comment.
user (Dict[str, Any]): The user who created the comment. This dictionary
contains:
created_at (str): ISO 8601 timestamp of when the comment was created.
updated_at (str): ISO 8601 timestamp of when the comment was last
updated.
Raises:
NotFoundError: If the repository or issue does not exist.
ForbiddenError: If the user does not have permission to comment on the issue.