Class GitHubTools
org.kohsuke:github-api client. Each returns
a Map with a "status" of "success", "error" or "dry_run".
Reads GITHUB_TOKEN from the environment; callers set dryRun to gate writes.
The tools cover the operations needed by the ADK GitHub automation samples: reading releases, diffs and file contents; searching code; listing and reading issues and their comments; listing repository collaborators; creating issues and pull requests; labelling/assigning issues; commenting on or closing issues; and reading, labelling and commenting on pull requests.
Defense in depth against prompt injection: the agents read untrusted GitHub content (diffs,
file contents, issue/PR titles) and could be steered into harmful writes. Independently of the
prompt, the write tools (a) only target writeRepoOwner/writeRepoName when set,
(b) restrict pull requests to Markdown files under docs/, and (c) cap how many issues and
pull requests a single run may create. The labelling/assignment/commenting tools are not
separately capped: unlike issue/PR creation they do not create new objects (so they carry no
unbounded-spam risk) and only mutate pre-existing issues or pull requests in the pinned target
repository from (a); the consuming triaging agents additionally bind them to a fixed label
allowlist and the specific issue/PR numbers the workflow authorized.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionaddCommentToIssue(String repoOwner, String repoName, int issueNumber, String body) addCommentToPullRequest(String repoOwner, String repoName, int prNumber, String comment) addLabelToIssue(String repoOwner, String repoName, int issueNumber, String label) addLabelToPullRequest(String repoOwner, String repoName, int prNumber, String label) assignIssue(String repoOwner, String repoName, int issueNumber, List<String> assignees) closeIssue(String repoOwner, String repoName, int issueNumber) createIssue(String repoOwner, String repoName, String title, String body) createPullRequest(String repoOwner, String repoName, String baseBranch, List<String> filePaths, List<String> newContents, String title, String body) findDocIssues(String repoOwner, String repoName, String codeRepo) findPullRequestsForIssue(String repoOwner, String repoName, int issueNumber) getChangedFiles(String repoOwner, String repoName, String startTag, String endTag, String pathFilter) getFileContent(String repoOwner, String repoName, String filePath) getIssueComments(String repoOwner, String repoName, int issueNumber) getPullRequest(String repoOwner, String repoName, int prNumber) listOpenIssues(String repoOwner, String repoName, Integer maxResults) listOpenIssuesUpdatedSince(String repoOwner, String repoName, String updatedSince, Integer maxResults) listReleases(String repoOwner, String repoName) listRepositoryCollaborators(String repoOwner, String repoName) removeLabelFromIssue(String repoOwner, String repoName, int issueNumber, String label) searchCode(String repoOwner, String repoName, String query)
-
Field Details
-
dryRun
public static boolean dryRunWhen true,create_issue/create_pull_requestreturn a preview instead of writing. -
writeRepoOwner
When both are set,create_issue/create_pull_requestrefuse to write to any other repository, regardless of the owner/repo the model passes. Set by the entry point to the docs repository so untrusted content cannot redirect writes elsewhere. -
writeRepoName
-
-
Method Details
-
listReleases
-
getChangedFiles
-
getFileDiff
-
searchCode
-
getFileContent
-
createIssue
-
findDocIssues
-
findPullRequestsForIssue
-
createPullRequest
-
listOpenIssues
-
listOpenIssuesUpdatedSince
-
getIssue
-
getIssueComments
-
listRepositoryCollaborators
-
addLabelToIssue
-
removeLabelFromIssue
-
assignIssue
-
getPullRequest
-
addLabelToPullRequest
-
addCommentToPullRequest
-
addCommentToIssue
-
closeIssue
-