Skip to content

micro-fix: shell config handling and add antigravity option#6844

Open
sundaram2021 wants to merge 4 commits intoaden-hive:mainfrom
sundaram2021:fix/quickstart-credentials-in-windows
Open

micro-fix: shell config handling and add antigravity option#6844
sundaram2021 wants to merge 4 commits intoaden-hive:mainfrom
sundaram2021:fix/quickstart-credentials-in-windows

Conversation

@sundaram2021
Copy link
Copy Markdown
Contributor

@sundaram2021 sundaram2021 commented Mar 28, 2026

Description

Restores Windows quickstart parity with the Bash flow.

This PR fixes two Windows-specific quickstart issues:

  1. Git Bash could save/read Hive credentials from the wrong shell startup file, which broke the Hive subscription flow with the queen model.
  2. quickstart.ps1 was missing the Antigravity subscription option even though the underlying support already existed.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

Changes Made

  • Align Git Bash shell config handling so quickstart and runtime both resolve the correct startup files on Windows (.bash_profile, .bashrc, .profile) for persisted credentials like HIVE_API_KEY
  • Add regression coverage for shell config fallback behavior in tools/tests/test_shell_config.py
  • Add the missing Antigravity subscription option to quickstart.ps1, including credential detection, previous-selection defaulting, menu entry, selection handling, config persistence, and success summary output

Testing

Describe the tests you ran to verify your changes:

  • Unit tests pass (cd core && pytest tests/)
  • Lint passes (cd core && ruff check .)
  • Manual testing performed

Manual / focused verification run:

  • cd tools && uv run pytest tests/test_shell_config.py
  • cd core && uv run pytest tests/test_credential_bootstrap.py
  • PowerShell parser check for quickstart.ps1
  • bash -n quickstart.sh

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Added Antigravity subscription option to the interactive provider setup with Direct OAuth and persistence of the selection.
  • Improvements

    • Updated provider menu ordering and selection handling to include Antigravity and reflect its status in final configuration output.
    • Enhanced shell detection and platform-aware shell config file fallback logic.
  • Tests

    • Added tests for shell config path selection and environment-variable extraction.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

📝 Walkthrough

Walkthrough

Adds Antigravity subscription option and Google OAuth flow to the interactive quickstart, plus platform- and login-shell-aware shell config detection and selection logic with associated tests.

Changes

Cohort / File(s) Summary
Antigravity Subscription Integration
quickstart.ps1
Insert Antigravity as provider option, detect ~/.hive/antigravity-accounts.json, launch core/antigravity_auth.py for Google OAuth, set SubscriptionMode="antigravity", persist config.llm.use_antigravity_subscription = $true, and update final status text and menu numbering.
Shell detection & config resolution
quickstart.sh, tools/src/aden_tools/credentials/shell_config.py
Improve shell detection and config-file candidate ordering (bash, zsh, unknown shells); prefer .bash_profile for Git Bash/MinGW on Windows; add _get_shell_config_candidates() and return first existing candidate or first candidate if none exist.
Tests for shell config logic
tools/tests/test_shell_config.py
New test suite that mocks home/platform/shell to validate candidate selection, environment-variable extraction, and fallback behavior across Windows (Git Bash) and non-Windows scenarios.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Quickstart as "quickstart.ps1"
    participant AuthScript as "core/antigravity_auth.py"
    participant Google as "Google OAuth"
    participant Config as "config.json / quickstart state"

    User->>Quickstart: select Antigravity option
    Quickstart->>AuthScript: execute antigravity_auth.py
    AuthScript->>Google: initiate OAuth flow
    Google-->>AuthScript: return token/credentials
    AuthScript->>Config: write credentials
    Quickstart->>Config: set SubscriptionMode="antigravity" and use_antigravity_subscription=true
    Quickstart->>User: display Antigravity subscription status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I found a key in Antigravity's nest,

I hopped through shells on a cross‑OS quest,
Bash and Zsh now sing in tune,
OAuth dawns like a silver moon,
Hoppy configs—everything works best!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: fixes shell config handling for Windows Git Bash and adds the Antigravity subscription option to quickstart, both of which are central to the PR's objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
tools/tests/test_shell_config.py (1)

83-90: Consider adding a test for fresh system scenario (no config files exist).

The current tests all create at least one config file. Adding a test for the case when no config files exist would verify the fallback behavior and catch any inconsistencies with quickstart.sh:

Suggested additional test
def test_get_shell_config_path_returns_first_candidate_when_none_exist(monkeypatch, tmp_path):
    """On Windows bash with no existing files, should return .bash_profile (first candidate)."""
    _mock_home(monkeypatch, tmp_path)
    monkeypatch.setenv("SHELL", "/usr/bin/bash")
    monkeypatch.setattr(shell_config.platform, "system", lambda: "Windows")

    # No config files created
    result = shell_config.get_shell_config_path()
    
    # Should return first candidate (.bash_profile) even though it doesn't exist
    assert result == tmp_path / ".bash_profile"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/tests/test_shell_config.py` around lines 83 - 90, Add a new unit test
(e.g., test_get_shell_config_path_returns_first_candidate_when_none_exist) that
uses _mock_home(monkeypatch, tmp_path), sets monkeypatch.setenv("SHELL",
"/usr/bin/bash") and monkeypatch.setattr(shell_config.platform, "system",
lambda: "Windows"), does NOT create any config files in tmp_path, calls
shell_config.get_shell_config_path(), and asserts the result equals tmp_path /
".bash_profile" to verify the function returns the first candidate when none
exist.
quickstart.sh (1)

676-693: Minor inconsistency in fallback behavior when no config files exist.

The shell script's fallback differs from the Python implementation:

  • Shell (line 685): Returns .profile when neither .bash_profile nor .bashrc exist
  • Python (shell_config.py): Returns .bash_profile (first candidate) when none exist

This could cause issues on a fresh Windows Git Bash system where no shell config files exist:

  1. quickstart.sh would write API keys to .profile
  2. A later call to add_env_var_to_shell_config() would create .bash_profile
  3. Different vars would end up in different files

For consistency, consider returning .bash_profile as the fallback on Windows:

Proposed fix to align fallback behavior
             if [ -n "$MSYSTEM" ] || [ -n "$MINGW_PREFIX" ]; then
                 if [ -f "$HOME/.bash_profile" ]; then
                     echo "$HOME/.bash_profile"
                 elif [ -f "$HOME/.bashrc" ]; then
                     echo "$HOME/.bashrc"
                 else
-                    echo "$HOME/.profile"
+                    echo "$HOME/.bash_profile"
                 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@quickstart.sh` around lines 676 - 693, The Windows/Git-Bash branch in
quickstart.sh currently falls back to echoing "$HOME/.profile" when neither
"$HOME/.bash_profile" nor "$HOME/.bashrc" exist, which mismatches
shell_config.py and can split environment variables between files; update the
MSYSTEM/MINGW_PREFIX conditional so that when no .bash_profile or .bashrc is
found it echoes "$HOME/.bash_profile" (not .profile) to align behavior with
shell_config.py and the add_env_var_to_shell_config() flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@quickstart.sh`:
- Around line 676-693: The Windows/Git-Bash branch in quickstart.sh currently
falls back to echoing "$HOME/.profile" when neither "$HOME/.bash_profile" nor
"$HOME/.bashrc" exist, which mismatches shell_config.py and can split
environment variables between files; update the MSYSTEM/MINGW_PREFIX conditional
so that when no .bash_profile or .bashrc is found it echoes
"$HOME/.bash_profile" (not .profile) to align behavior with shell_config.py and
the add_env_var_to_shell_config() flow.

In `@tools/tests/test_shell_config.py`:
- Around line 83-90: Add a new unit test (e.g.,
test_get_shell_config_path_returns_first_candidate_when_none_exist) that uses
_mock_home(monkeypatch, tmp_path), sets monkeypatch.setenv("SHELL",
"/usr/bin/bash") and monkeypatch.setattr(shell_config.platform, "system",
lambda: "Windows"), does NOT create any config files in tmp_path, calls
shell_config.get_shell_config_path(), and asserts the result equals tmp_path /
".bash_profile" to verify the function returns the first candidate when none
exist.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01939e57-e4fc-4380-81e3-cf8b42d08a7e

📥 Commits

Reviewing files that changed from the base of the PR and between c3c3075 and 9416057.

📒 Files selected for processing (4)
  • quickstart.ps1
  • quickstart.sh
  • tools/src/aden_tools/credentials/shell_config.py
  • tools/tests/test_shell_config.py

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
quickstart.ps1 (1)

1107-1114: Consider removing remaining hardcoded menu numbers to prevent future index drift.

Line 1107, Line 1179, Line 1377, and Line 1459 still repeat literal boundaries. Deriving these from shared variables would make future provider insertions safer.

Suggested refactor
+$SubscriptionChoiceCount = 7
+$ApiProviderStart = $SubscriptionChoiceCount + 1
+$ApiProviderEnd = $ApiProviderStart + $ProviderMenuEnvVars.Count - 1
+$OllamaChoice = $ApiProviderEnd + 1
+$SkipChoice = $OllamaChoice + 1
...
-    $num = $idx + 8
+    $num = $idx + $ApiProviderStart
...
-Write-Color -Text "14" -Color Cyan -NoNewline
+Write-Color -Text "$OllamaChoice" -Color Cyan -NoNewline
...
-{ $_ -ge 8 -and $_ -le 13 } {
-    $provIdx = $num - 8
+{ $_ -ge $ApiProviderStart -and $_ -le $ApiProviderEnd } {
+    $provIdx = $num - $ApiProviderStart
...
-14 {
+$OllamaChoice {

Also applies to: 1179-1200, 1377-1379, 1459-1459

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@quickstart.ps1` around lines 1107 - 1114, The switch cases set $DefaultChoice
using hardcoded numeric literals (e.g., "anthropic", "openai", "minimax"
assigning values to $DefaultChoice) which will break when providers are
inserted; instead derive $DefaultChoice programmatically from a single
authoritative providers list or mapping (e.g., compute index via an ordered
array of provider names or a Hashtable of provider=>menuIndex and assign
$DefaultChoice = ($providers.IndexOf('minimax') + <menu-offset>) or
$providerIndexMap['minimax']), and replace all remaining literal assignments
(the other similar switch blocks) to reference that shared source so menu
numbers stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@quickstart.ps1`:
- Around line 1107-1114: The switch cases set $DefaultChoice using hardcoded
numeric literals (e.g., "anthropic", "openai", "minimax" assigning values to
$DefaultChoice) which will break when providers are inserted; instead derive
$DefaultChoice programmatically from a single authoritative providers list or
mapping (e.g., compute index via an ordered array of provider names or a
Hashtable of provider=>menuIndex and assign $DefaultChoice =
($providers.IndexOf('minimax') + <menu-offset>) or
$providerIndexMap['minimax']), and replace all remaining literal assignments
(the other similar switch blocks) to reference that shared source so menu
numbers stay consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 71460812-66a7-4e72-8726-3de4ddedcb0e

📥 Commits

Reviewing files that changed from the base of the PR and between 9416057 and c564403.

📒 Files selected for processing (2)
  • quickstart.ps1
  • quickstart.sh
✅ Files skipped from review due to trivial changes (1)
  • quickstart.sh

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