@amitkot/pi-safe-github
Typed GitHub wrapper tools for Pi: PRs, CI runs, issues, releases, and workflows.
Package details
Install @amitkot/pi-safe-github from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@amitkot/pi-safe-github- Package
@amitkot/pi-safe-github- Version
0.2.0- Published
- Jun 17, 2026
- Downloads
- 158/mo · 158/wk
- Author
- amitkot
- License
- MIT
- Types
- extension
- Size
- 77.3 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
safe-github extension
A narrow, typed GitHub operation surface for Pi.
Purpose
Provides safe, host-side GitHub operations via the gh CLI, bypassing macOS sandbox TLS issues in the sandboxed bash tool.
Threat Model
- Risk: accidental mutation, operations on the wrong repo, shell injection, token exposure.
- Mitigations:
- Uses
child_process.execFilewith argument arrays; no shell strings. - Adds execution timeouts and output limits.
- Validates and normalizes parameters.
- Infers owner/repo from the active Pi session cwd unless
cwdis provided. - High-risk mutations preview unless
confirm: true. - Mutation previews redact long bodies/notes.
- Does not expose
gh auth tokenor a genericgh/gh apitool. - Does not pass the full process environment to subprocesses.
- Uses
Installation
pi install npm:@amitkot/pi-safe-github
For local development from a checkout:
pi -e ./packages/safe-github/src/index.ts
If you are working inside this repository, Pi can also auto-load the project-local shim at .pi/extensions/safe-github/index.ts after the project is trusted.
Requirements
- GitHub CLI (
gh) installed on the host machine - Host
ghauthenticated (gh auth status) - Run Pi from inside a GitHub-backed git repository for repo/PR tools
Tools
Read-oriented
github_auth_status— verify gh CLI auth and logged-in usergithub_repo_info— repo identity, branches, visibility, viewer permissiongithub_branch_info— branch existence, protection, ahead/behindgithub_pr_list— list PRs with filtersgithub_pr_view— view a PR or current-branch PRgithub_pr_checks— detailed PR checks with linksgithub_pr_files— changed files for a PRgithub_pr_diff— truncated PR diff/patchgithub_run_list— list workflow runsgithub_run_view— view run jobs and failed stepsgithub_commit_status— commit status and check runs for SHA/HEADgithub_issue_list— list issuesgithub_issue_view— view issuegithub_workflow_list— list workflowsgithub_workflow_view— view workflow summary/YAMLgithub_release_list— list releasesgithub_release_view— view release details/assets
Sensitive read
github_run_logs— fetch/tail workflow logs. Recommended permission:ask.
Mutating
github_pr_create— preview/create PRgithub_pr_edit— edit PR title/bodygithub_pr_comment— comment on PRgithub_pr_review— approve/comment/request changesgithub_pr_ready— mark draft PR readygithub_pr_close/github_pr_reopengithub_pr_merge— preview/merge with safeguardsgithub_issue_creategithub_issue_commentgithub_issue_editgithub_issue_close/github_issue_reopengithub_workflow_dispatch— preview/dispatch workflowgithub_run_rerun— preview/rerun workflow run/jobgithub_run_cancel— preview/cancel workflow rungithub_release_create— preview/create releasegithub_release_upload_asset— preview/upload one release asset
Approval Model
Configure mutating tool names as ask in @gotgenes/pi-permission-system.
High-risk tools also require confirm: true internally:
github_pr_creategithub_pr_mergegithub_workflow_dispatchgithub_run_rerungithub_run_cancelgithub_release_creategithub_release_upload_asset
Calling these without confirm: true returns a preview only.
Recommended permission examples are in docs/plans/safe-github-expanded-tools.md.
Prompt Guidelines
- Use these typed tools instead of raw
ghcommands. - Use
github_auth_statusbefore GitHub operations when auth is uncertain. - Use
github_repo_infobefore mutating operations to confirm the repo/branch. - Never use raw
gh api,gh auth token, or shell for GitHub operations when these tools are available.
Testing
npm run check
npm test
Manual smoke tests after /reload:
- Call
github_auth_status. - Call
github_repo_info. - Call
github_pr_list/github_pr_view. - Use
github_pr_checks,github_run_list, andgithub_run_viewon a repo with Actions. - Call a high-risk mutation without
confirm; expected: preview only. - Call the same mutation with
confirm: trueonly in a test repo/branch and approve the Pi permission prompt.