fix(shell): export GH_CONFIG_DIR and harden agent session detection#115
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GH_CONFIG_DIRfromprofile.dso subprocessghcallers (command gh,agents code-review, scripts) use the authenticated config instead of stale~/.config/gh.gh()wrapper to always applygh-routes.d/ built-in path overrides (not only whenGH_CONFIG_DIRis unset)._chez_agent_shell_active, and bashexport -fparity with the gh route helper.Context
Regression surfaced when
agents code-review --prinvoked baregh(Jul 2026). Root cause: repo-scoped gh routing (Mar 2026) lived only in the shellgh()wrapper; June agent/rehydration work stressed subprocess env gaps. Thegh gh apilog 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.batsbats tests/shell/unit/agent_shell_detection.batsbash -lcandbash --rcfile ~/.bashrc -icshowGH_CONFIG_DIR=~/.config/gh-personalGH_CONFIG_DIR=~/.config/gh-personal agents code-review --pr 112fetches PR head SHA (no 401)Made with Cursor