feat: add agentgh github app token tool #29

Merged
benvin merged 2 commits from benvin/agentgh into main 2026-11-21 20:28:29 +11:00
Member

Agents need gh and git against GitHub as the iuclabs GitHub Apps without a long-lived token on disk. App creds already sit in Vault, so a short-lived installation token can be minted per process.

  • add agentgh with token, credential, whoami and gh subcommands
  • add --app coder|reviewer (env AGENTGH_APP) selecting kv/service/github/iuclabs/
  • sign the RS256 app JWT with the stdlib and mint installation tokens, cached per app
  • answer git credential requests only for https://github.com
  • run gh with GH_TOKEN and GH_HOST=github.com in the child env only, stripping other GitHub token/host vars
  • package agentgh with completions and document it

Requires terraform-vault policy for kv/service/github/iuclabs/{coder,reviewer}.

Agents need gh and git against GitHub as the iuclabs GitHub Apps without a long-lived token on disk. App creds already sit in Vault, so a short-lived installation token can be minted per process. - add agentgh with token, credential, whoami and gh subcommands - add --app coder|reviewer (env AGENTGH_APP) selecting kv/service/github/iuclabs/<app> - sign the RS256 app JWT with the stdlib and mint installation tokens, cached per app - answer git credential requests only for https://github.com - run gh with GH_TOKEN and GH_HOST=github.com in the child env only, stripping other GitHub token/host vars - package agentgh with completions and document it Requires terraform-vault policy for kv/service/github/iuclabs/{coder,reviewer}.
unkin-agent added 1 commit 2026-11-21 18:02:25 +11:00
feat: add agentgh github app token tool
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
79a269ebe0
Author
Member
  • cmd/agentgh/main.go:305 — credential get ignores protocol; protocol=http host=github.com gets the installation token in cleartext → require req["protocol"] == "https" too, add a test case.
  • cmd/agentgh/main.go:359 — child env only strips GH_TOKEN/GITHUB_TOKEN; an inherited GH_HOST/GH_ENTERPRISE_TOKEN can route the app token to a non-github.com host → strip GH_HOST, GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (or set GH_HOST=github.com) and test it.
  • Makefile:14 — new pre-commit target is unrelated to agentgh → drop from this PR (separate PR).
  • nit: cmd/agentgh/main.go:368 — ee.ExitCode() is -1 when gh is killed by a signal, so os.Exit(-1) yields 255 → map to 128+signal.
- cmd/agentgh/main.go:305 — credential get ignores `protocol`; `protocol=http host=github.com` gets the installation token in cleartext → require `req["protocol"] == "https"` too, add a test case. - cmd/agentgh/main.go:359 — child env only strips GH_TOKEN/GITHUB_TOKEN; an inherited `GH_HOST`/`GH_ENTERPRISE_TOKEN` can route the app token to a non-github.com host → strip GH_HOST, GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (or set GH_HOST=github.com) and test it. - Makefile:14 — new `pre-commit` target is unrelated to agentgh → drop from this PR (separate PR). - nit: cmd/agentgh/main.go:368 — `ee.ExitCode()` is -1 when gh is killed by a signal, so `os.Exit(-1)` yields 255 → map to 128+signal.
unkin-agent added 1 commit 2026-11-21 18:05:17 +11:00
fix(agentgh): require https for creds, pin gh to github.com, map signal exits
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
fa615d1733
Author
Member
  • nit: internal/agent/github.go:39 — AGENTGH_KV_PATH bypasses the coder|reviewer allowlist and lets any env-set path be read with the agent AppRole; not mentioned in the PR body → drop it, or restrict to the kv/service/github/iuclabs/ prefix.
- nit: internal/agent/github.go:39 — `AGENTGH_KV_PATH` bypasses the coder|reviewer allowlist and lets any env-set path be read with the agent AppRole; not mentioned in the PR body → drop it, or restrict to the `kv/service/github/iuclabs/` prefix.
benvin merged commit 15ea8b68e5 into main 2026-11-21 20:28:29 +11:00
benvin deleted branch benvin/agentgh 2026-11-21 20:28:29 +11:00
Sign in to join this conversation.