diff --git a/.plugin/plugin.json b/.plugin/plugin.json new file mode 100644 index 0000000..a995517 --- /dev/null +++ b/.plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "gor", + "version": "1.0.0", + "description": "GitHub CLI — manage PRs, issues, repos, CI, releases, search, codespaces, and more via the GitHub API", + "author": { + "name": "kerryhatcher" + }, + "repository": "https://github.com/kerryhatcher/gor", + "homepage": "https://github.com/kerryhatcher/gor", + "license": "MIT OR Apache-2.0", + "keywords": ["github", "cli", "git", "pr", "issues", "ci", "devops"] +} diff --git a/AGENTS.md b/AGENTS.md index e7ba3c1..1f54579 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -310,3 +310,46 @@ Always create a story file before implementing a new command or subcommand. - `docs/research/research-architecture.md` — Crate ecosystem and architecture patterns - `docs/research/research-docs.md` — Documentation best practices - `docs/research/research-deployment.md` — Distribution and release automation + +--- + +## Open Plugins Integration + +gor bundles an [Open Plugins](https://open-plugins.com/) v1.0.0 plugin manifest +and command files, so CherryPi and other conformant agent tools can discover +gor as an installable plugin. + +### Plugin structure + +```text +.plugin/plugin.json # Manifest: name, version, metadata +commands/*.md # Command files teaching agents how to use gor +``` + +Each `.md` file in `commands/` is loaded as a namespaced command available +at `/gor:` (e.g. `/gor:pr`, `/gor:repo`). + +### Installing the plugin + +Any conformant agent tool that scans Open Plugins directories will discover +gor automatically when the repo root or a symlink is in the search path: + +```bash +ln -s /path/to/gor ~/.local/share/cherrypi/plugins/gor +``` + +Or install via cargo and copy the plugin directory: + +```bash +cargo install gor-cli +cp -r .plugin commands ~/.local/share/cherrypi/plugins/gor/ +``` + +### Key principles + +- The manifest (`name: "gor"`) namespaces all commands as `gor:`. +- Command files are documentation-first: they teach the AI how to invoke `gor` + with the right flags and `--json` output. +- Changes to the CLI surface (new subcommands, changed flags) should be + reflected in the corresponding command file. +- Adding a new command group? Create a matching `commands/.md`. diff --git a/commands/auth.md b/commands/auth.md new file mode 100644 index 0000000..ff101e1 --- /dev/null +++ b/commands/auth.md @@ -0,0 +1,81 @@ +--- +description: Authenticate with GitHub — login, logout, status, token, and git credential setup +--- + +# GitHub Authentication via gor + +Use the `gor` CLI to authenticate with GitHub. Supports fine-grained PATs, +classic PATs, and OAuth device flow. + +## Login + +Authenticate via OAuth device flow (opens a browser): + +```bash +gor auth login +``` + +Or provide a token directly from a file or pipe: + +```bash +gor auth login --with-token < ~/.gh-token +``` + +## Check status + +Verify you're authenticated and see which host and user: + +```bash +gor auth status +``` + +## Logout + +Remove stored credentials: + +```bash +gor auth logout +``` + +## View token + +Print the current token. Use `--secure` to mask the output (shows only first +and last few characters): + +```bash +gor auth token +gor auth token --secure +``` + +> **Warning:** Tokens grant full API access. Never expose them in logs, +> terminal history, screenshots, or agent output. Use `--secure` whenever +> possible to reduce accidental disclosure. + +## Configure git credential helper + +Set up git to use `gor` as a credential helper (so git commands authenticate +via your stored token): + +```bash +gor auth setup-git +gor auth setup-git --hostname github.mycompany.com +``` + +## Environment variables + +The following env vars are read automatically (no `auth login` needed): + +| Variable | Purpose | +|---|---| +| `GH_TOKEN` or `GITHUB_TOKEN` | Token for github.com | +| `GH_ENTERPRISE_TOKEN` or `GITHUB_ENTERPRISE_TOKEN` | Token for GHES | +| `GH_HOST` | Target hostname for GHES | + +## GitHub Enterprise Server + +Target a GHES instance on any command: + +```bash +gor --hostname github.mycompany.com auth status +gor --hostname github.mycompany.com repo view org/repo +``` diff --git a/commands/ci.md b/commands/ci.md new file mode 100644 index 0000000..b104244 --- /dev/null +++ b/commands/ci.md @@ -0,0 +1,43 @@ +--- +description: Manage GitHub Actions — workflows, runs, caches, and CI/CD operations +--- + +# CI/CD via gor + +Use the `gor` CLI to manage GitHub Actions workflows, runs, and caches. + +## Workflows + +```bash +gor workflow list -R owner/repo +gor workflow view .github/workflows/ci.yml -R owner/repo +gor workflow run .github/workflows/ci.yml -R owner/repo +gor workflow run .github/workflows/ci.yml -R owner/repo --ref main +gor workflow enable .github/workflows/ci.yml -R owner/repo +gor workflow disable .github/workflows/ci.yml -R owner/repo +``` + +## Workflow runs + +```bash +gor run list -R owner/repo +gor run list -R owner/repo --branch main --workflow ci.yml +gor run view 1234567890 -R owner/repo +gor run watch 1234567890 -R owner/repo +gor run cancel 1234567890 -R owner/repo +gor run rerun 1234567890 -R owner/repo --failed-jobs +gor run download 1234567890 -R owner/repo --dir ./artifacts +``` + +## Cache management + +```bash +gor cache list -R owner/repo +gor cache list -R owner/repo --json key,size_in_bytes,ref + +# Delete by exact key +gor cache delete --key "node-linux-pnpm-" -R owner/repo + +# Delete all caches +gor cache delete --all -R owner/repo +``` diff --git a/commands/codespace.md b/commands/codespace.md new file mode 100644 index 0000000..991f0c8 --- /dev/null +++ b/commands/codespace.md @@ -0,0 +1,26 @@ +--- +description: Manage GitHub Codespaces — list, create, stop, delete, and SSH +--- + +# Codespaces via gor + +Use the `gor` CLI to manage GitHub Codespaces. + +```bash +# List +gor codespace list +gor codespace list --json name,repository,state,branch + +# Create +gor codespace create owner/repo +gor codespace create owner/repo --branch feature-branch + +# SSH (positional: codespace name) +gor codespace ssh my-codespace-name + +# Stop (positional: codespace name) +gor codespace stop my-codespace-name + +# Delete (positional: codespace name, use --yes to skip prompt) +gor codespace delete my-codespace-name --yes +``` diff --git a/commands/gist.md b/commands/gist.md new file mode 100644 index 0000000..9dad216 --- /dev/null +++ b/commands/gist.md @@ -0,0 +1,23 @@ +--- +description: Manage Gists — list, view, create, edit, and delete +--- + +# Gists via gor + +Use the `gor` CLI to manage GitHub gists. + +```bash +gor gist list +gor gist list --limit 10 --json id,description,files + +gor gist view GIST_ID +gor gist view GIST_ID --json id,description,files,created_at + +gor gist create file.md --desc "A useful snippet" +gor gist create file1.rs file2.rs --desc "Rust examples" --public + +gor gist edit GIST_ID --desc "Updated description" +gor gist edit GIST_ID --add new_file.rs --filename old_name:new_name + +gor gist delete GIST_ID +``` diff --git a/commands/issue.md b/commands/issue.md new file mode 100644 index 0000000..3433982 --- /dev/null +++ b/commands/issue.md @@ -0,0 +1,53 @@ +--- +description: Manage GitHub Issues — list, view, create, comment, close, and edit +--- + +# Issues via gor + +Use the `gor` CLI to manage GitHub issues. + +## List issues + +```bash +gor issue list -R owner/repo +gor issue list -R owner/repo --state closed --label bug +gor issue list -R owner/repo --json number,title,labels,assignees +``` + +## View an issue + +```bash +gor issue view 123 -R owner/repo +gor issue view 123 -R owner/repo --json number,title,body,comments +``` + +## Create an issue + +```bash +gor issue create -R owner/repo --title "Bug found" --body "Steps to reproduce..." +gor issue create -R owner/repo --title "Feature request" --label enhancement +``` + +## Modify an issue + +```bash +gor issue comment 123 -R owner/repo --body "I can reproduce this" +gor issue close 123 -R owner/repo +gor issue reopen 123 -R owner/repo +gor issue edit 123 -R owner/repo --title "Updated title" +``` + +## Locking and pins + +```bash +gor issue lock 123 -R owner/repo --reason spam +gor issue unlock 123 -R owner/repo +gor issue pin 123 -R owner/repo +gor issue unpin 123 -R owner/repo +``` + +## Transfer to another repository + +```bash +gor issue transfer 123 -R owner/repo target-owner/target-repo +``` diff --git a/commands/label.md b/commands/label.md new file mode 100644 index 0000000..95f8ea5 --- /dev/null +++ b/commands/label.md @@ -0,0 +1,19 @@ +--- +description: Manage repository labels — list, create, edit, delete, and clone +--- + +# Labels via gor + +Use the `gor` CLI to manage repository labels. + +```bash +gor label list -R owner/repo +gor label list -R owner/repo --json name,color,description + +gor label create bug -R owner/repo --color d73a4a --description "Bug report" +gor label edit bug -R owner/repo --name bug --color d73a4a +gor label delete bug -R owner/repo + +# Clone labels: source is positional, target via -R +gor label clone source-owner/source-repo -R target-owner/target-repo +``` diff --git a/commands/other.md b/commands/other.md new file mode 100644 index 0000000..2a7b22a --- /dev/null +++ b/commands/other.md @@ -0,0 +1,50 @@ +--- +description: Additional commands — browse, API, config, orgs, projects, rulesets, extensions, attestations, copilot, classroom +--- + +# Additional Commands via gor + +```bash +# Browse — open in browser +gor browse # Open current repo +gor browse --issue 123 # Open issue +gor browse --pr 42 # Open PR +gor browse --settings # Open repo settings + +# API — arbitrary REST calls +gor api /repos/owner/repo +gor api /repos/owner/repo/issues --method POST --field title="Bug" +gor api graphql -f query="query { viewer { login } }" + +# Config +gor config list +gor config set --host github.com git_protocol ssh + +# Organizations +gor org list +gor org view my-org + +# Projects (GitHub Projects v2) +gor project list -R owner/repo +gor project view PROJECT_NUMBER -R owner/repo +gor project item-add PROJECT_NUMBER -R owner/repo --title "Task" + +# Rulesets +gor ruleset list -R owner/repo +gor ruleset view RULESET_ID -R owner/repo + +# Extensions +gor extension list +gor extension install owner/repo + +# Attestations +gor attestation verify path/to/artifact + +# Copilot +gor copilot status +gor copilot usage --org my-org + +# Classroom +gor classroom list +gor classroom view ASSIGNMENT_ID +``` diff --git a/commands/pr.md b/commands/pr.md new file mode 100644 index 0000000..a77527b --- /dev/null +++ b/commands/pr.md @@ -0,0 +1,64 @@ +--- +description: Manage GitHub Pull Requests — list, view, create, merge, review, checkout, and more +--- + +# Pull Requests via gor + +Use the `gor` CLI to manage pull requests. Always prefer `--json` for +programmatic consumption. + +## List pull requests + +```bash +gor pr list -R owner/repo +gor pr list -R owner/repo --state closed --limit 20 +gor pr list -R owner/repo --json number,title,author,state +``` + +## View a pull request + +```bash +gor pr view 42 -R owner/repo +gor pr view 42 -R owner/repo --json number,title,body,mergeable +``` + +## Create a pull request + +```bash +gor pr create -R owner/repo --title "Fix bug" --body "Description of fix" +gor pr create -R owner/repo --title "WIP: feature" --draft +``` + +## Merge a pull request + +```bash +gor pr merge 42 -R owner/repo +gor pr merge 42 -R owner/repo --squash +gor pr merge 42 -R owner/repo --merge --delete-branch +``` + +## Review a pull request + +```bash +gor pr review 42 -R owner/repo --approve --body "Looks good!" +gor pr review 42 -R owner/repo --request-changes --body "Needs tests" +gor pr review 42 -R owner/repo --comment --body "What about edge cases?" +``` + +## Checkout locally + +```bash +gor pr checkout 42 -R owner/repo +``` + +## Other operations + +```bash +gor pr comment 42 -R owner/repo --body "Fixed in latest commit" +gor pr close 42 -R owner/repo +gor pr reopen 42 -R owner/repo +gor pr ready 42 -R owner/repo +gor pr diff 42 -R owner/repo +gor pr checks 42 -R owner/repo +gor pr edit 42 -R owner/repo --title "New title" +``` diff --git a/commands/release.md b/commands/release.md new file mode 100644 index 0000000..380b9c3 --- /dev/null +++ b/commands/release.md @@ -0,0 +1,44 @@ +--- +description: Manage GitHub Releases — list, view, create, edit, upload, and download assets +--- + +# Releases via gor + +Use the `gor` CLI to manage GitHub releases. + +## List releases + +```bash +gor release list -R owner/repo +gor release list -R owner/repo --limit 5 --json tag_name,created_at +``` + +## View a release + +```bash +gor release view v1.0.0 -R owner/repo +gor release view v1.0.0 -R owner/repo --json tag_name,body,assets +``` + +## Create a release + +```bash +gor release create v1.0.0 -R owner/repo --title "v1.0.0" --body "Release notes..." +gor release create v1.0.0 -R owner/repo --notes-file CHANGELOG.md --prerelease +``` + +## Upload and download assets + +```bash +gor release upload v1.0.0 -R owner/repo ./binary.tar.gz +gor release upload v1.0.0 -R owner/repo ./binary.tar.gz --name "linux-amd64.tar.gz" + +gor release download v1.0.0 -R owner/repo --dir ./downloads +``` + +## Edit and delete + +```bash +gor release edit v1.0.0 -R owner/repo --title "New title" +gor release delete v1.0.0 -R owner/repo +``` diff --git a/commands/repo.md b/commands/repo.md new file mode 100644 index 0000000..e17837c --- /dev/null +++ b/commands/repo.md @@ -0,0 +1,58 @@ +--- +description: Manage GitHub repositories — view, list, create, fork, clone, and edit +--- + +# Repository Management via gor + +Use the `gor` CLI to manage GitHub repositories. + +## View a repository + +```bash +gor repo view owner/repo +gor repo view owner/repo --json name,description,stars,language +``` + +## List repositories + +```bash +gor repo list +gor repo list --org my-org +gor repo list --type fork --sort updated +``` + +## Create a repository + +Default visibility is public; use `--private` for private repos: + +```bash +gor repo create my-new-repo --description "A great project" +gor repo create private-repo --description "Internal tool" --private +``` + +## Fork a repository + +```bash +gor repo fork owner/repo +gor repo fork owner/repo --org my-org +``` + +## Clone a repository + +```bash +gor repo clone owner/repo +gor repo clone owner/repo --directory ./my-dir +``` + +## Other operations + +```bash +# Edit repo settings (use -R for target) +gor repo edit -R owner/repo --description "New description" --visibility private + +# Delete +gor repo delete owner/repo + +# Sync a fork with its upstream +gor repo sync +``` diff --git a/commands/search.md b/commands/search.md new file mode 100644 index 0000000..7a665a9 --- /dev/null +++ b/commands/search.md @@ -0,0 +1,42 @@ +--- +description: Search GitHub — repositories, issues, code, and commits +--- + +# Search via gor + +Use the `gor` CLI to search GitHub. + +## Search repositories + +```bash +gor search repos "rust cli" +gor search repos "rust cli" --limit 10 --json name,stars,description +``` + +## Search issues + +```bash +gor search issues "bug in login" -R owner/repo +gor search issues "state:open label:bug" --limit 20 +``` + +## Search code + +```bash +gor search code "fn main" --language rust +gor search code "TODO" --repo owner/repo +``` + +## Search commits + +```bash +gor search commits "fix clippy" --repo owner/repo +``` + +## Useful qualifiers + +```bash +gor search issues "label:bug is:open" +gor search issues "created:>2024-01-01" +gor search code "class Repository" --language python +``` diff --git a/commands/secrets.md b/commands/secrets.md new file mode 100644 index 0000000..5e74f75 --- /dev/null +++ b/commands/secrets.md @@ -0,0 +1,39 @@ +--- +description: Manage secrets, variables, SSH keys, and GPG keys +--- + +# Secrets, Variables & Keys via gor + +Use the `gor` CLI to manage secrets, variables, SSH keys, and GPG keys. + +## Secrets (org- or environment-scoped) + +```bash +gor secret list --org my-org +gor secret set MY_SECRET --body "value-here" --org my-org +gor secret delete MY_SECRET --org my-org +``` + +## Variables (org- or environment-scoped) + +```bash +gor variable list --org my-org +gor variable set MY_VAR --body "value-here" --org my-org +gor variable delete MY_VAR --org my-org +``` + +## SSH keys + +```bash +gor ssh-key list +gor ssh-key add ~/.ssh/id_ed25519.pub --title "My laptop" +gor ssh-key delete KEY_ID +``` + +## GPG keys + +```bash +gor gpg-key list +gor gpg-key add --file ~/.gnupg/pubkey.asc +gor gpg-key delete KEY_ID +```