cynarAI 1611fe5fa2
Let computers push from project folders through the GitHub broker (#217)
Two gaps kept agents from pushing on a containerized supervisor:

- The git and gh shims called rakazo-broker by name, and login shells in
  the computer reset PATH, so the broker was "not found". The shims now
  call it next to their own resolved path, and /usr/bin/gh is a shim too.
- A project folder outside the supervisor container's mounts is invisible
  to it, so broker git ran against an empty directory. Such calls now run
  in a one-off computer-image container that binds the folder.


Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-18 15:04:20 +02:00

30 lines
970 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
REAL_GIT=/usr/local/libexec/rakazo/git
if [[ "${RAKAZO_GITHUB_BROKER_URL:-}" == "" || "${RAKAZO_GITHUB_BROKER_RUN_TOKEN:-}" == "" ]]; then
exec "$REAL_GIT" "$@"
fi
# Skip global options so `git -c … clone` and `git -C dir fetch` still go through the broker.
# Config overrides are dropped: the broker supplies the credentials.
args=("$@")
i=0
cwd="$PWD"
while (( i < ${#args[@]} )); do
case "${args[i]}" in
-c) i=$((i + 2)) ;;
-C)
cwd="$(cd "$cwd" && cd "${args[i + 1]:-}" && pwd)" || exec "$REAL_GIT" "$@"
i=$((i + 2))
;;
--no-pager | -P) i=$((i + 1)) ;;
*) break ;;
esac
done
case "${args[i]:-}" in
push | fetch | pull | clone | ls-remote)
payload="$(python3 -c 'import json,sys; print(json.dumps({"argv":["git"]+sys.argv[2:],"cwd":sys.argv[1]}))' "$cwd" "${args[@]:i}")"
exec "$(dirname "$(readlink -f "$0")")/rakazo-broker" v1/git "$payload"
;;
esac
exec "$REAL_GIT" "$@"