Command Line#
The my-own-accelerator package exposes:
review-prto fetch information about a GitHub pull request and print a Markdown summary.review-localto review one or multiple local files and print a Markdown summary.
Both commands support --copilot-review to append AI-generated
feedback produced by GitHub Copilot.
Installation#
Install the package (preferably in a virtual environment) to make the command available:
pip install my-own-accelerator
After installation the review-pr and review-local commands are
available on the path.
review-local#
Synopsis:
review-local [--token TOKEN] [--save] [--copilot-review] [--model MODEL] file [file ...]
Examples:
review-local README.md
review-local --copilot-review --token "$GITHUB_TOKEN" moa/commands/review_pr.py
python -m moa review-local README.md
The command prints a # Local Files Review markdown report containing
the provided files and, if requested, a ## Copilot Review section.
It reuses the same token cache file as review-pr
(~/.config/moa/review_pr.json) and supports --save to persist
the resolved token.
Synopsis#
review-pr [--token TOKEN] [--api-url URL] [--user USERNAME] [--save] [--copilot-review] [--model MODEL] owner repo pull_request
Positional Arguments#
ownerGitHub user or organisation that owns the repository (e.g.
xadupre).repoName of the GitHub repository (e.g.
my-own-accelerator).pull_requestInteger number of the pull request to review (e.g.
42).
Optional Arguments#
--token TOKENGitHub personal access token used to authenticate API requests. Resolution order: explicit flag value →
GITHUB_TOKENenvironment variable (automatically set in GitHub Actions workflows) → value cached with--save→ unauthenticated. For private repositories or to avoid rate limiting, a token with at leastrepo:readscope is required.See Obtaining a GitHub Personal Access Token for instructions on how to obtain a token.
Example:
review-pr --token ghp_xxxxxxxxxxxx owner repo 42
--api-url URLBase URL of the GitHub API. Resolution order: explicit flag value →
GITHUB_API_URLenvironment variable (automatically set in GitHub Actions workflows) → value cached with--save→https://api.github.com. Override this when working against a GitHub Enterprise instance:review-pr --api-url https://github.example.com/api/v3 owner repo 42
--user USERNAMEYour GitHub username. Resolution order: explicit flag value →
GITHUB_USERenvironment variable → value cached with--save. When set andowneris omitted from the command line, the username is used as the repository owner automatically.Example – save your username once, then omit
ownerin future calls:review-pr --user myname --token "$GITHUB_TOKEN" --save myname my-repo 1 review-pr my-repo 2
--savePersist the resolved
--token,--api-url, and--uservalues to~/.config/moa/review_pr.jsonso they are used automatically in future invocations (without needing to pass the flags again). The file is created with owner-read-only permissions (0600).Warning
This stores your token in plain text. Only use
--saveon a personal workstation that you control. In CI environments, rely onGITHUB_TOKENinstead.Example – authenticate once and save:
review-pr --token "$GITHUB_TOKEN" --save xadupre my-own-accelerator 1
Subsequent invocations on the same machine no longer need
--token:review-pr xadupre my-own-accelerator 2
--copilot-reviewAfter fetching the pull request data, send the summary to the GitHub Models API (powered by GitHub Copilot) to obtain an AI-generated code review. The review is appended to the Markdown output as a
## Copilot Reviewsection. A valid GitHub token is required (see--token):review-pr --copilot-review xadupre my-own-accelerator 1
--model MODELAI model to use when
--copilot-reviewis set. Accepts any model identifier available on the GitHub Models API. Defaults toopenai/gpt-4o-mini:review-pr --copilot-review --model openai/gpt-4o xadupre my-own-accelerator 1
-h,--helpPrint a short help message and exit.
Examples#
Review a public pull request without authentication:
review-pr xadupre my-own-accelerator 1
Review a pull request and save the output to a file:
review-pr xadupre my-own-accelerator 1 > review.md
Authenticate with a personal access token (recommended for private repositories or to increase the API rate limit):
review-pr --token "$GITHUB_TOKEN" xadupre my-own-accelerator 1
Include an AI-powered Copilot review:
review-pr --copilot-review --token "$GITHUB_TOKEN" xadupre my-own-accelerator 1
Review a pull request on a GitHub Enterprise server:
review-pr \
--api-url https://github.example.com/api/v3 \
--token "$GHE_TOKEN" \
myorg myrepo 7
Output Format#
The command prints a Markdown document to standard output. The document
contains three sections (plus an optional Copilot Review section when
--copilot-review is used):
Summary – title, state, author, URL, number of changed files, and total additions/deletions.
Description – the body text of the pull request.
Changed Files – list of every file touched by the pull request together with the number of added and deleted lines.
Copilot Review (optional) – AI-generated review produced by the GitHub Models API when
--copilot-reviewis passed.
Example output (values are illustrative):
# Pull Request Review
## Summary
- **Title:** Fix typo in README
- **State:** open
- **Author:** octocat
- **URL:** https://github.com/owner/repo/pull/42
- **Files changed:** 2
- **Additions/Deletions:** +10 / -3
## Description
Fixes a typo in the README introduction paragraph.
## Changed Files
- `README.md` (+10/-3)
- `docs/index.rst` (+1/-0)
## Copilot Review
The change looks straightforward. Consider adding a test to ensure
the README renders correctly in CI.
Exit Codes#
0The pull request was retrieved and the Markdown summary was printed successfully.
1An error occurred (network failure, invalid PR number, or authentication problem). A human-readable message is printed to standard error.
Python API#
The command can also be invoked programmatically:
from moa.commands.review_pr import review_pull_request
# Basic summary
markdown = review_pull_request(
owner="xadupre",
repo="my-own-accelerator",
pull_request=1,
token="ghp_xxxxxxxxxxxx", # optional
api_url="https://api.github.com", # optional
)
print(markdown)
# With Copilot review
markdown = review_pull_request(
owner="xadupre",
repo="my-own-accelerator",
pull_request=1,
token="ghp_xxxxxxxxxxxx",
copilot_review=True,
model="openai/gpt-4o-mini", # optional, this is the default
)
print(markdown)
See the moa.commands.review_pr API reference for full details.