@autosk/gh-review
v0.1.0
Published
gh-review — review a GitHub issue or PR (URL in the task title) with a pi agent in a per-task dockerSandbox and a READ-ONLY gh; review → accept (human) → cleanup → done.
Maintainers
Readme
@autosk/gh-review
Review a GitHub issue or pull request from a task: enroll a task whose title
carries a GitHub issue/PR URL (https://github.com/<owner>/<repo>/issues/9
or …/pull/12), and a pi agent reviews it inside a per-task
docker run -i --rm container with a READ-ONLY gh — the verdict lands
as a structured comment on the autosk task. Nothing is ever written to GitHub
(the token's scopes reject every write with 403, and the prompt never tries).
It registers ONE workflow, gh-review:
review ──▶ accept (human) ──▶ cleanup ──▶ donereview—piAgent(xhigh) in a per-taskdockerSandboxcontainer (ghcr.io/wierdbytes/pi-runtime, which shipsgh); it reads the issue/PR withgh(+ a clone when the diff is not enough), reviews it, posts the review as one task comment, and transits toaccept.accept—statusStep("human"); the task parks for you to read the review.cleanup—sandboxCleanupStep: removes the per-task worktree/container, then transits todone(autosk resume <id> --to cleanup).
The enroll is validated before any agent runs (onTransit): a task with no
parsable GitHub URL — or a daemon with no gh config — is rejected with an
explanatory comment and stays new.
Setup: read-only gh
On GitHub, create a fine-grained personal access token:
- Repository access: only the repositories you want reviewed.
- Permissions (all Read-only):
Contents,Issues,Pull requests,Metadata. (Contents: Readis what allowsgh repo clonefor a deeper PR review; drop it for a diff-only token.)
Store it in
~/.autosk/github/ro-token.json(override the dir withAUTOSK_GH_DIR):{ "token": "github_pat_…" }chmod 600 ~/.autosk/github/ro-token.jsonDone. The extension reads the file at container-start and passes the token as the
GH_TOKENenv — gh's native token mechanism: no gh config file exists in the container, so gh never tries to rewrite one (gh ≥2.40 rewriteshosts.ymlon most invocations — a read-only config mount does not work), andGH_NO_UPDATE_NOTIFIER=1/CHECKPOINT_DISABLE=1keep gh from writing anything else. The token is visible indocker inspectwhile the per-task container lives (minutes); read-only access is enforced by the token's scopes on GitHub's side (a write → 403). Rotating the token in the file takes effect on the next run — no daemon restart.
Use it
# 1. build (or pull) the pi-runtime image (ships gh)
daemon/extensions/pi-agent/docker/build.sh
# 2. install this extension (hot-applies to open projects, no restart)
autosk ext add npm:@autosk/gh-review # or: autosk ext add /path/to/gh-review
# 3. enroll a task whose title carries the URL
id=$(autosk create "https://github.com/wierdbytes/autosk/pull/12" --workflow gh-review --json | jq -r .id)
# the daemon runs the review and parks the task at `accept`;
# read the review comment, then route it through cleanup:
autosk resume "$id" --to cleanup # → done (worktree/container removed)The host project must be a git repo (the sandbox is a per-task worktree, same
as feature-dev). If the URL points at a different repository, the agent
clones it inside the container (gone when the container exits).
Env knobs (all optional):
| var | default | what |
|-----|---------|------|
| AUTOSK_GH_REVIEW_IMAGE | ghcr.io/wierdbytes/pi-runtime:latest | image to run (must ship gh) |
| AUTOSK_GH_DIR | ~/.autosk/github | dir holding ro-token.json (read fresh per run) |
| AUTOSK_PI_DIR | ~/.pi | host pi config (auth + models) bind-mounted into the container |
Exports
- default — the extension factory (registers
gh-review). ghReviewWorkflow(opts)/ghReviewSandbox()— compose your own workflow over the same docker sandbox.ghReviewGuard— theonTransitenroll validator (URL + gh token).parseGhTarget(text)— the title/description URL parser.defaultDockerImage()/ghConfigDir()/ghTokenFile()/readGhToken()/checkGhToken().
