ISSUE DESCRIPTION gemini-cli: support Login with Google (oauth-personal), mirroring…
- User
ISSUE DESCRIPTION
gemini-cli: support Login with Google (oauth-personal), mirroring codex auth.json The
codexagent injects a cached OAuth credential (~/.codex/auth.json) so runs can use a login instead of an API key (CODEX_AUTH_JSON_PATH/CODEX_FORCE_AUTH_JSON), andclaude-codeacceptsCLAUDE_CODE_OAUTH_TOKEN(#173).gemini-clihas no equivalent — it only wiresGEMINI_API_KEY/ Vertex env, so users with a "Login with Google" session (~/.gemini/oauth_creds.json) must keep a separate API key for runs.Proposal: add the same opt-in OAuth-credential injection to the
gemini-cliagent, mirroring the codex pattern —GEMINI_OAUTH_CREDS_PATH/GEMINI_FORCE_OAUTH, default behavior unchanged (fully backward-compatible).I have a working implementation that mirrors the codex auth flow (
_resolve_oauth_creds_path→ upload → chown →~/.gemini) with tests ported 1:1 fromtest_codex_auth.py, verified end-to-end (gemini-cli --ae GEMINI_FORCE_OAUTH=truecompleted hello-world, reward 1.0). Happy to open the PR or hand it off — whichever you prefer.ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
Assistant
Let me start by understanding the repository structure. This seems to be a project that has multiple agents (codex, gemini-cli, claude-code). I need to find the relevant files for:
- The codex auth flow (as a reference)
- The gemini-cli agent (to add OAuth support)
Let me explore the repository structure first.
Assistant
Let me explore the adapters directory since that seems to be where the agents live.
Assistant
Let me look at the src directory and understand the project structure better.
Assistant
Let me look at the harbor source code.
Assistant
Let me look at the agents directory - this is likely where codex, gemini-cli, and claude-code live.
Assistant
Let me look at the installed directory and also look for gemini-related files.
Assistant
Now let me look at the codex agent to understand the OAuth flow, and then the gemini-cli agent
Assistant
Let me look at the full codex auth flow and the gemini-cli agent
Assistant
Let me see the rest of the codex run method and also look at the gemini-cli agent.
Assistant
Let me do one command at a time.
Assistant
Now let me look at the gemini-cli agent.
Assistant
Let me search for the run method and auth-related code in gemini_cli.
Assistant
Let me look at the gemini-cli run method and the auth variables section.
Assistant
Now let me look at the full codex auth implementation and tests for
Assistant
Let me look at the codex auth test file to understand the test pattern.
Assistant
Let me look at the class-level setup in codex.py to understand the remote paths.
Assistant
Let me look at the
BaseInstalledAgent's_get_envmethod and theparse_bool_env_valueutility.Assistant
Let me do one at a time.
Assistant
Let me check if there's already a test file for gemini-cli auth, and look at the existing gemini-cli test structure
Assistant
Let me look at the existing gemini test file and also look at the codex.py imports for completeness
Assistant
Let me now look at the codex imports to understand what's needed.
Assistant
Let me check
parse_bool_env_valueto understand it fully.Assistant
Let me look at the full gemini_cli class to understand its structure.
Assistant
Now let me look at the full run method in gemini_cli.py to plan my edits.
Assistant
Now I have a good understanding. Let me implement the changes. First, I'll add the import and the
_resolve_oauth_creds_pathmethod, then modify therunmethod.Assistant
First, let me add the import for
parse_bool_env_value.Assistant
Now add the import for
parse_bool_env_value.Assistant
Wait, that created duplicates. Let me fix the file by reverting and doing the edit properly.
Assistant
Let me be more careful. First, add
PurePosixPathto the existing import.Assistant
Now add the
parse_bool_env_valueimport after the trajectory import block.Assistant
I need to fix the blank line between the import and constants. Let me fix it.
Assistant
Good. Now let me find where to add the
_resolve_oauth_creds_pathmethod. Let me look at the area near the_build_settings_commandmethod.Assistant
Now let me add the
_resolve_oauth_creds_pathmethod right before therunmethodAssistant
I see there are duplicate lines (649-650 duplicate 647-648). Let me fix that.
Assistant
Now let me modify the
runmethod to integrate OAuth support. I need to replace the auth section.Assistant
Let me verify that
_has_envmethod exists in the base class.Assistant
Good,
_has_envexists. Now let me run the existing gemini-cli tests to make sure nothing is broken.Assistant
Let me check the environment setup.
Assistant
Let me activate the venv and install harbor in dev mode.
Assistant
Now let me run the existing gemini-cli tests.
Assistant
All existing tests pass. Now let me also run the codex tests to make sure they still pass.
Assistant
All tests pass. Now let me create the test file for gemini-cli OAuth support, mirroring the codex auth tests.
Assistant
Now let me write the test file.
Assistant
Now let me run the new tests.
Assistant
Almost there! 18 out of 19 pass. Let me fix the last test to handle
envbeingNonein some exec calls.Assistant
The issue is that some exec calls don't pass
env. Let me fix the test to handleNone.Assistant
Now let me run all the gemini-cli tests again.
Assistant
All 28 tests pass! Let me also run the full test suite to make sure nothing else is broken.
Assistant
Let me run all unit tests without the timeout flag.
Assistant
All 2522 tests pass. Let me now review the final diff to make sure everything is clean.
Assistant
Let me also verify the new test file is clean.
Assistant
Let me also confirm the new test file is properly there.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.