Files

17 lines
681 B
Bash
Raw Permalink Normal View History

#!/bin/sh
# Print the OpenCode Go API key on stdout.
#
# Codex uses this as its command-backed provider auth
# ([model_providers.opencode-go.auth].command). That keeps ~/.codex/auth.json
# untouched in ChatGPT mode, so the ChatGPT desktop app and the OpenCode Go
# subscription coexist in the same Codex install. The key is never committed; it
# is read live from the opencode auth store (the same source oc2 and Hermes use).
set -eu
auth="${XDG_DATA_HOME:-$HOME/.local/share}/opencode/auth.json"
py="$(command -v python3 || true)"
if [ -z "$py" ]; then
py=/usr/bin/python3
fi
exec "$py" -c 'import json, sys; print(json.load(open(sys.argv[1]))["opencode-go"]["key"])' "$auth"