agy-github
README.md
<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg" />
<source media="(prefers-color-scheme: light)" srcset="assets/logo-light.svg" />
<img src="assets/logo.svg" alt="agy-github logo" width="84" />
</picture>
# agy-github
**Manage GitHub Safely Inside Google Antigravity — Zero-Plaintext OAuth, Official GitHub MCP (48+ Tools) & 4-Tier `Turbo` Guardrails**
[](CHANGELOG.md)
[](https://github.com/Nodifferentiable/agy-github/actions/workflows/ci.yml)
[](https://github.com/Nodifferentiable/agy-github/stargazers)
[](#quick-start)
[](#architecture--comparison)
[](#quick-start)
[](LICENSE)
English · [简体中文](README.zh-CN.md) · [What You Can Manage](#what-you-can-manage-in-antigravity) · [Quick Start](#quick-start) · [Architecture](#architecture--comparison) · [4-Tier Guardrails](#4-tier-pretooluse-safety-model) · [Tool Reference](#tool--capability-catalog) · [Policy & CLI](#policy--cli-reference) · [FAQ](#faq--troubleshooting)
</div>
<br />
**`agy-github`** connects **Google Antigravity** (Desktop 2.0, CLI `agy`, and IDE) to your full GitHub account through **GitHub CLI (`gh`) OS-keyring OAuth**, a **zero-dependency local Node.js MCP bridge** to GitHub's official remote MCP (`https://api.githubcopilot.com/mcp/`), a **sandbox-safe REST/GraphQL client (`github_api`)**, and **deterministic 4-tier `PreToolUse` safety guardrails**.
| Plaintext Tokens on Disk | Windows Sandbox Proxy TLS | Official Remote MCP + REST/GraphQL | `Turbo` Mode Safety |
| :---: | :---: | :---: | :---: |
| **0**<br><sub>OAuth lives in OS Credential Manager / Keychain</sub> | **Node `fetch`**<br><sub>Natively trusts `NODE_EXTRA_CA_CERTS`</sub> | **46+ Official Tools + `github_api`**<br><sub>Hot-loads via `notifications/tools/list_changed`</sub> | **4-Tier `PreToolUse`**<br><sub>Forces `force_ask` on risky ops, `deny` on token leaks</sub> |
---
## What You Can Manage in Antigravity
If you use **Google Antigravity** (Desktop 2.0, CLI `agy`, or IDE) as your daily AI coding agent, **`agy-github`** gives Antigravity full control over your GitHub workflow without sacrificing credential hygiene or safety:
- **No plaintext PATs in `mcp_config.json`**: Avoids static tokens on disk and fixes `404` Dynamic Client Registration (DCR) failures against `https://api.githubcopilot.com/mcp/` by reusing your OS-keyring `gh` OAuth session and hot-loading 46+ official GitHub MCP tools.
- **Works cleanly inside Windows sandbox proxies**: Fixes `gh.exe` `x509: certificate signed by unknown authority` errors in sandboxed terminals via **`github_api`**, powered by Node `fetch` that natively trusts `NODE_EXTRA_CA_CERTS`.
- **Safe under `Turbo` auto-execution**: Deterministic 4-tier `PreToolUse` guardrails keep reads and feature-branch collaboration frictionless, enforce `force_ask` before irreversible actions, and hard-`deny` accidental token exfiltration.
### Everyday GitHub Management Workflows
| Workflow | What Antigravity Can Do for You |
| :--- | :--- |
| **Repositories & Account** | Audit public & private repos, inspect Stars/topics/API quotas, create repos, and manage visibility, archiving, or transfers (with `force_ask` confirmation) |
| **Branches, Commits & PRs** | Create feature branches, commit/push changes cleanly, open & update Pull Requests, inspect diffs, reply to code reviews, and merge PRs safely |
| **Issues & Code Search** | Search code, commits, and Issues across GitHub, triage Issues, add labels/comments, and organize sub-issues |
| **GitHub Actions CI/CD** | Inspect workflow runs and job status, troubleshoot failing builds/tests, check workflow permissions, and trigger `workflow_dispatch` |
| **Releases & Publishing** | Tag semver versions, draft bilingual changelogs, and publish official GitHub Releases with native `force_ask` sign-off |
| **`Turbo` Guardrails & Secrets** | Zero popups for reads & `feat/*` branches; strict confirmation on `main`/Secrets/Keys/Webhooks/visibility; hard `deny` on printing tokens or reading `hosts.yml` |
---
## Quick Start
**Prerequisites**: **Node.js >= 20** and **[GitHub CLI (`gh`)](https://cli.github.com/)**.
### 1. Install the Plugin
**Windows (PowerShell):**
```powershell
irm https://raw.githubusercontent.com/Nodifferentiable/agy-github/main/install.ps1 | iex
```
**macOS / Linux:**
```bash
curl -fsSL https://raw.githubusercontent.com/Nodifferentiable/agy-github/main/install.sh | sh
```
<details>
<summary>Alternative install options (local clone, per-project install, standalone MCP clients, <code>agy</code> CLI, or ask Antigravity)</summary>
#### Local clone (cross-platform)
```bash
git clone https://github.com/Nodifferentiable/agy-github.git
cd agy-github
node scripts/install.mjs install
```
#### Per-project install (repository-scoped `.agents/plugins/agy-github`)
```bash
node scripts/install.mjs install --project /path/to/your-repo
```
#### Standalone MCP clients (Claude Code, Codex, Cursor, etc.)
```bash
node scripts/install.mjs mcp-config
```
#### Antigravity CLI
```bash
agy plugin install /path/to/agy-github
agy plugin enable agy-github
```
#### Let Antigravity install it directly
```text
Clone https://github.com/Nodifferentiable/agy-github.git into ~/.gemini/config/plugins/agy-github, run `node ~/.gemini/config/plugins/agy-github/scripts/install.mjs install`, and verify with github_doctor.
```
</details>
### 2. One-Time Browser OAuth Login
Run the bundled login helper once in your terminal (this also configures `git` HTTPS credentials via `gh auth setup-git`):
**Windows (PowerShell):**
```powershell
& "$env:USERPROFILE\.gemini\config\plugins\agy-github\login.ps1"
```
**macOS / Linux:**
```bash
sh "$HOME/.gemini/config/plugins/agy-github/login.sh"
```
### 3. Verify Inside Antigravity
Ask Antigravity to run `github_doctor` (or invoke `/github`). Once authenticated, `agy-github` hot-loads all official remote GitHub MCP tools alongside `github_doctor` and `github_api` without restarting Antigravity.
---
## Architecture & Comparison
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/architecture-dark.svg" />
<source media="(prefers-color-scheme: light)" srcset="assets/architecture-light.svg" />
<img alt="agy-github zero-plaintext OAuth bridge and 4-tier guardrail architecture" src="assets/architecture-light.svg" width="100%" />
</picture>
</p>
| Dimension | Raw Remote `serverUrl` | Static PAT in `mcp_config.json` | Bare `gh.exe` in Windows Sandbox | **`agy-github` `v0.1.0`** |
| :--- | :--- | :--- | :--- | :--- |
| **OAuth Support** | Fails when remote MCP lacks DCR (`404`) | Manual copy-paste | Works outside sandbox only | **One-click `gh auth login --web` + auto hot-load** |
| **Secret Storage** | Token cache files | **Plaintext token on disk** | OS credential store | **OS Credential Manager / Keychain (0 plaintext on disk)** |
| **Windows Sandbox TLS** | N/A | N/A | Go `gh.exe` ignores `SSL_CERT_FILE` (`x509` error) | **Node `fetch` honors `NODE_EXTRA_CA_CERTS`** |
| **Repo Settings / Pagination** | Limited | Manual curl | Fails in Windows sandbox | **`github_api` REST (auto `Link` pagination) + GraphQL** |
| **`Turbo` Mode Safety** | None | None | None | **4-Tier `PreToolUse` + subshell unwrapping + SSRF guard** |
---
## 4-Tier `PreToolUse` Safety Model
Designed specifically for autonomous **`Turbo`** workflows (`rules/AGENTS.md` soft guidance + `hooks.json` hard enforcement across `run_command`, `mcp_agy-github_github_*`, `call_mcp_tool`, `mcp_agy-fast_fast_run_checks`, and `mcp_agy-fast_fast_apply_edits.verify`):
| Tier | Covered Operations | Hook Output | Effect |
| :--- | :--- | :---: | :--- |
| **Tier 0 · Read & Diagnostics** | Repo/PR/Issue/Actions reads, `git status/diff/log/clone/fetch`, `github_doctor`, `github_api` (`GET`/`HEAD` / GraphQL `query`) | `{"decision":"allow"}` | Zero prompt friction |
| **Tier 1 · Feature Branch Work** | Creating branches, pushing `feat/*` / `fix/*`, opening Issues/PRs, creating private repos (`private: true`) or draft releases | `{"decision":"allow"}` | Allowed smoothly; [AGENTS.md](rules/AGENTS.md) enforces clean commits |
| **Tier 2 · High-Risk / Irreversible** | Deleting/archiving/renaming/transferring repos, changing visibility, creating public repos, `git push -f` / `-uf` / `--all` / `+ref` / `:ref`, writing to `main`/`master`/`prod`/`production`/`release`, merging PRs, editing Secrets/Keys/Webhooks/Environments/Rulesets, publishing non-draft Releases | `force_ask` | **Ignores cached approvals & `Turbo` mode** — always shows native confirmation |
| **Tier 3 · Token Exfiltration** | Printing `gh auth token`, `gh auth status --show-token`, `git credential fill`, reading `hosts.yml` / `mcp_oauth_tokens.json`, reading `GH_TOKEN` / `GITHUB_TOKEN` / `AGY_GITHUB_TOKEN` | `deny` | **Hard-blocked** so tokens never enter chat or cloud context |
### Defense-in-Depth Runtime Protections
- **Subshell & wrapper unwrapping**: Recursively inspects `$(...)`, backtick substitutions, `cmd /c`, `sh -c` / `bash -c`, `powershell -Command`, and decodes UTF-16LE Base64 `-EncodedCommand` (or forces `force_ask` if opaque).
- **SSRF & cross-origin redirect protection**: `scripts/mcp-server.mjs` enforces a strict host allowlist (`api.github.com` for REST/GraphQL, `api.githubcopilot.com` for remote MCP) with `redirect: "manual"`, re-validating every redirect hop and paginated `Link rel="next"` URL before sending `Authorization: Bearer`.
- **Error redaction & UTF-8 safe bounding**: Scrubs any token patterns or `Bearer` headers from error output (`redactSecrets`) and bounds large responses safely on UTF-8 boundaries (`maxOutputBytes`, default `65536` bytes).
---
## Tool & Capability Catalog
### Built-in Eager Tools (`mcp_config.json`)
| Tool | Purpose | Key Parameters |
| :--- | :--- | :--- |
| **`github_doctor`** | Inspects `gh` CLI path/version, authenticated `login` & OAuth scopes, API quota, remote MCP connection/tool count, `git` credential helpers, and effective guardrail policy (token masked). | `refresh?: boolean` |
| **`github_api`** | Executes any GitHub REST v3 request or GraphQL v4 query/mutation via sandbox-safe Node `fetch`. | `method`, `endpoint`, `query`, `body`, `graphql`, `variables`, `paginate`, `maxPages` |
### Proxied Official GitHub Remote MCP Tools (46+ Lazy-Loaded Tools)
Once authenticated, `https://api.githubcopilot.com/mcp/` tools hot-load automatically covering repositories, branches, commits, files (`create_or_update_file`, `push_files`, `delete_file`), Issues, Pull Requests (`create_pull_request`, `merge_pull_request`, reviews), code search, users/teams, releases/tags, and Copilot/security scanning. Optional toolset filtering is supported via `AGY_GITHUB_TOOLSETS` or `toolsets` in `policy.json`.
---
## Policy & CLI Reference
### Daily Prompts Inside Antigravity
- *"Run `github_doctor` to verify my GitHub login, OAuth scopes, and remote MCP tools."*
- *"List my recent public and private repositories along with open PRs using `github_api`."*
- *"Create a `feat/ci-fix` branch, commit the changes without touching `.env`, push, and open a PR."*
### Terminal Management CLI (`scripts/install.mjs`)
```bash
# Inspect active guardrail policy
node ~/.gemini/config/plugins/agy-github/scripts/install.mjs policy --show
# Allow direct pushes to main on solo repos while keeping PR merge & delete prompts
node ~/.gemini/config/plugins/agy-github/scripts/install.mjs policy --confirm-main off --confirm-merge on
# Customize protected branches or UTF-8 output limit (4096..524288 bytes)
node ~/.gemini/config/plugins/agy-github/scripts/install.mjs policy --protected-branches main,master,release --max-bytes 65536
# Reset overrides back to strict defaults
node ~/.gemini/config/plugins/agy-github/scripts/install.mjs policy --reset
# Full plugin + LS + gh + git diagnostics
node ~/.gemini/config/plugins/agy-github/scripts/install.mjs doctor
```
### Policy File & Environment Variables
Settings file: `~/.gemini/config/agy-github-policy.json` (or `${PLUGIN_DATA}/policy.json`):
| Key | Default | Description |
| :--- | :---: | :--- |
| `protectedBranches` | `["main","master","prod","production","release"]` | Branches triggering `force_ask` on direct push/write |
| `confirmProtectedBranchWrite` | `true` | Require `force_ask` when pushing/writing to protected branches |
| `confirmPullRequestMerge` | `true` | Require `force_ask` on `merge_pull_request` / `gh pr merge` |
| `confirmRepoVisibilityChange` | `true` | Require `force_ask` on visibility changes & public repo creation |
| `confirmRepoDeleteOrTransfer` | `true` | Require `force_ask` on repo delete/archive/rename/transfer |
| `confirmForcePushAndRefDelete` | `true` | Require `force_ask` on `--force` / `-uf` / `+ref` / `:ref` |
| `confirmSecretsAndSecurity` | `true` | Require `force_ask` on Secrets/Keys/Webhooks/Environments/Rulesets |
| `confirmPublicRelease` | `true` | Require `force_ask` on non-draft Release creation or deletion |
| `blockTokenExfiltration` | `true` | Hard `deny` commands exposing GitHub tokens or `hosts.yml` |
| `maxOutputBytes` | `65536` | UTF-8 byte ceiling (`4096..524288`; override via `AGY_GITHUB_MAX_BYTES`) |
### Direct `--cli` Mode (Swarm & Automation)
Subagents without MCP access can invoke the bridge directly (still audited by `PreToolUse` when run via `run_command` or `agy-fast`):
```bash
node ~/.gemini/config/plugins/agy-github/scripts/mcp-server.mjs --cli doctor
node ~/.gemini/config/plugins/agy-github/scripts/mcp-server.mjs --cli api GET "/user/repos?sort=updated&per_page=10"
node ~/.gemini/config/plugins/agy-github/scripts/mcp-server.mjs --cli graphql "query { viewer { login } }"
```
---
## FAQ & Troubleshooting
<details>
<summary><strong>1. <code>gh</code> fails with x509 certificate errors in Antigravity's Windows sandbox</strong></summary>
This is expected when `gh.exe` runs inside a sandboxed local proxy whose CA is passed via `NODE_EXTRA_CA_CERTS` / `SSL_CERT_FILE`. Use **`github_api`** instead of shelling out to `gh api` — `github_api` uses Node's `fetch` which honors `NODE_EXTRA_CA_CERTS`.
</details>
<details>
<summary><strong>2. Only 2 tools appear at first before login</strong></summary>
When unauthenticated, `agy-github` intentionally degrades cleanly to `github_doctor` and `github_api`. Run `login.ps1` / `login.sh`, wait a few seconds (or call `github_doctor(refresh: true)`), and the bridge automatically sends `notifications/tools/list_changed` to hot-load all 46+ official remote MCP tools.
</details>
<details>
<summary><strong>3. How do I inspect the skill and agent rules shipped with the plugin?</strong></summary>
See [rules/AGENTS.md](rules/AGENTS.md) for the always-on routing & hygiene rules and [skills/github/SKILL.md](skills/github/SKILL.md) for the `/github` runbook.
</details>
---
## Related Antigravity Plugins
- **[agy-cua-desktop](https://github.com/Nodifferentiable/agy-cua-desktop)** — Script-first, background-first desktop GUI automation with `<150 ms` COM introspection, compact 2-tier MCP bridge, and `Turbo` guardrails.
## Contributing, Security & Star Support
If `agy-github` saves you from token headaches or risky `Turbo` mishaps, please consider giving the repo a ⭐ on [GitHub](https://github.com/Nodifferentiable/agy-github) — it helps more Antigravity developers discover it!
- [Contributing Guide](CONTRIBUTING.md)
- [Security Policy](SECURITY.md)
- [Changelog](CHANGELOG.md)
- [MIT License](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues