Agents kept configuring git with RAKAZO_GITHUB_BROKER_RUN_TOKEN as a password because the system prompt listed it among "managed credentials" to use in shell commands. GitHub rejects it, and the agent then asks the user for a personal access token. - List only the user's own agent secrets in that instruction; the broker variables stay in the environment for the git shim. - Make /usr/bin/git the shim as well, so git called by absolute path still goes through the broker; the real binary moves out of PATH. - Prompt no longer names the broker variable. Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ Co-authored-by: Claude <noreply@anthropic.com>
30 lines
935 B
Bash
Executable File
30 lines
935 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 rakazo-broker v1/git "$payload"
|
|
;;
|
|
esac
|
|
exec "$REAL_GIT" "$@"
|