Skip to main content

Module gh_shim

Module gh_shim 

Source
Expand description

gh as a program, for the callers the gh shell function never reaches.

An agent’s gh is a bash function (agentmux_common::github_broker_shim::GH_FUNCTION_BODY) that asks this wrapper for the token of the repository the command is about. A function exists only in the bash that imported it: timeout 60 gh pr create, xargs gh, env gh, make, a script with a #!/bin/sh line or a Python subprocess all start the real gh binary, which has no login in a container and says “gh auth login”.

In a container’s image this wrapper is also installed as /usr/local/bin/gh (a symlink, ahead of the real gh on PATH). Started under that name it does what the function does, with the function’s own text, and then runs the real gh. No token is stored: each call asks for one, as the function does.

Constants§

BROKER_ENV 🔒
Set by srv for an agent whose GitHub access goes through AgentMux.
DONE_ENV 🔒
Set by the function when it runs gh, so this program does not do the same work a second time.
REAL_GH_ENV 🔒
Where the function body finds the real gh (it says command gh in a shell, which would find this program).

Functions§

command_for 🔒
The command that runs gh with args: through the function’s steps when the agent’s GitHub access is brokered and the function has not run them already, else the real gh as it is.
invoked_as_gh 🔒
Whether the program was started as gh (or gh.exe).
launch 🔒
real_gh_in 🔒
The first gh on path that is not me (this program, which the symlink makes one of them).
run_if_invoked_as_gh 🔒
When this program was started as gh: run gh and give the exit code. None for any other name.
script 🔒
The shell text that is the function, calling the real gh by the path in REAL_GH_ENV, then running it.