Skip to content

fix(shell): export GH_CONFIG_DIR and harden agent session detection#115

Merged
aguil merged 2 commits into
masterfrom
fix/shell-gh-subprocess-auth
Jul 11, 2026
Merged

fix(shell): export GH_CONFIG_DIR and harden agent session detection#115
aguil merged 2 commits into
masterfrom
fix/shell-gh-subprocess-auth

Conversation

@aguil

@aguil aguil commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Export profile-default GH_CONFIG_DIR from profile.d so subprocess gh callers (command gh, agents code-review, scripts) use the authenticated config instead of stale ~/.config/gh.
  • Refactor the gh() wrapper to always apply gh-routes.d / built-in path overrides (not only when GH_CONFIG_DIR is unset).
  • Harden agent-session detection for rehydrated shells: env-marker fallback for zoxide skip, _chez_agent_shell_active, and bash export -f parity with the gh route helper.
  • Add unit tests for gh default config and agent zoxide skip behavior.

Context

Regression surfaced when agents code-review --pr invoked bare gh (Jul 2026). Root cause: repo-scoped gh routing (Mar 2026) lived only in the shell gh() wrapper; June agent/rehydration work stressed subprocess env gaps. The gh gh api log line in agents was a misleading error prefix, not a double spawn (aguil/agents#59 closed).

Test plan

  • bats tests/shell/unit/gh_default_config.bats
  • bats tests/shell/unit/agent_shell_detection.bats
  • bash -lc and bash --rcfile ~/.bashrc -ic show GH_CONFIG_DIR=~/.config/gh-personal
  • GH_CONFIG_DIR=~/.config/gh-personal agents code-review --pr 112 fetches PR head SHA (no 401)

Made with Cursor

aguil added 2 commits July 11, 2026 13:25
Regression from repo-scoped gh routing (4361c73): auth lived only in the
shell gh() wrapper, so command gh and tools like agents code-review hit
stale ~/.config/gh and returned HTTP 401.

Export GH_CONFIG_DIR from profile.d for personal and work profiles, keep
gh-routes.d overrides in the wrapper, and add unit tests.
Agent shells that rehydrate from export -p can lose helper functions while
keeping CURSOR_AGENT/CLAUDECODE env markers. Fall back to env checks in
zoxide-init so smart-cd does not replace cd in agent sessions, and export
_chez_agent_shell_active for bash like the gh route helper.
@aguil aguil merged commit b148ba9 into master Jul 11, 2026
2 checks passed
@aguil aguil deleted the fix/shell-gh-subprocess-auth branch July 11, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant