Files
headroom/tests/test_cli/test_wrap_antigravity.py
AP 4c7acba593 docs: correct Antigravity IDE setup instructions (no third-party model providers) (#4258)
## Description

Follow-up to the merged #3817. As flagged in the post-merge thread, the
Antigravity IDE doesn’t expose third-party model-provider settings, so
the setup text was telling users to add a custom model provider in a
panel that doesn’t exist. The instructions now describe what the
integration actually covers (MCP registration and the
`/v1internal:streamGenerateContent` endpoint for `google-antigravity`
clients) and distinguish the IDE from the Antigravity CLI (`agy`), which
is the surface that accepts a custom endpoint via
`GOOGLE_GEMINI_BASE_URL`.

Follow-up fix (Devin review on this PR): the `agy` note mentioned
`GOOGLE_GEMINI_BASE_URL` but only printed the OpenAI-compatible URL. It
now prints the Gemini-compatible base URL (scheme://host, the Gemini API
convention) as an explicit `GOOGLE_GEMINI_BASE_URL=...` assignment, and
the OpenAI block is labeled for OpenAI-speaking clients.

## 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 change)
- [x] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- `headroom wrap antigravity` help text and printed setup instructions
no longer reference IDE model-provider settings; they point at MCP
registration and the native endpoint, and name the CLI separately.
- The `agy` note now shows the Gemini-compatible base URL explicitly
(`GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:<port>`), with the project
prefix (`/p/<name>`) applied like the other URLs.
- `docs/content/docs/proxy.mdx` Antigravity section corrected the same
way.
- Tests updated to assert the corrected wording.

## Testing

- [x] Unit tests pass (`pytest`)

### Test Output

```text
$ pytest tests/test_provider_antigravity.py -q
12 passed, 1 warning in 2.07s

$ pytest tests/test_mcp_registry/test_antigravity_registrar.py -q
25 passed, 1 warning in 0.82s
```

(`test_cli/test_wrap_antigravity.py` was not run locally — `typer` is
not installed in this environment; CI covers it.)

## Real Behavior Proof

- Environment: docs/string-only change; no runtime behavior affected.
- What was checked: the removed claim ("add a custom OpenAI-compatible
model provider in Antigravity’s model-provider settings") was verified
false three ways — the reporter’s own `~/.gemini/settings.json` has no
model-provider keys; Antigravity IDE 2.5.5 exposes no third-party
model-provider settings panel (upstream report plus current docs); and
the `google-antigravity` clients the new text names really do speak
Cloud Code Assist (`POST /v1internal:streamGenerateContent` is served by
the proxy — see `CLOUDCODE_HANDLER_ROUTES` in `route_specs.py`).
- Observed result: `render_setup_lines(8787)` now prints the corrected
IDE/MCP/native-traffic text,
`GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:8787` for `agy`, and the OpenAI
block labeled for OpenAI-speaking clients; the 37 tests above pass.
- Not tested: a live Antigravity IDE run — no Mac with the IDE installed
in this environment, and nothing in this change touches a runtime path,
so there is no behavior to smoke-test.

## Runtime Rollout Safety

- Rollout-managed feature(s): none — documentation/strings only.
- Minimum rollout channel: n/a.
- Stable/default behavior changed: no; rendered CLI text only.
- Kill switch / disable path: n/a.
- Unsafe override required: n/a.
- Qualification impact: none.
- Rollback path: revert the commit.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project’s style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md` — it is generated by
release-please from my Conventional Commit PR title (a CI guard enforces
this)

## Additional Notes

Docs-only PR; the remaining `wrap` CLI test module is covered by CI.

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/4258"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
2026-10-20 21:48:29 -05:00

99 lines
3.5 KiB
Python

"""Tests for the `headroom wrap antigravity` command."""
from __future__ import annotations
from typing import Any
from unittest.mock import patch
from click.testing import CliRunner
from headroom.cli import wrap as wrap_mod
from headroom.cli.main import main
def test_wrap_help_lists_antigravity() -> None:
result = CliRunner().invoke(main, ["wrap", "--help"])
assert result.exit_code == 0, result.output
assert "antigravity" in result.output
def test_wrap_antigravity_help_says_ide_has_no_third_party_providers() -> None:
result = CliRunner().invoke(main, ["wrap", "antigravity", "--help"])
assert result.exit_code == 0, result.output
assert "Antigravity" in result.output
assert "does not support third-party model providers" in result.output
assert "custom OpenAI-compatible model provider" not in result.output
def test_wrap_antigravity_prepare_only_exits_cleanly() -> None:
result = CliRunner().invoke(main, ["wrap", "antigravity", "--prepare-only"])
assert result.exit_code == 0, result.output
def test_wrap_antigravity_uses_proxy_only_watcher_with_antigravity_type() -> None:
captured: dict[str, Any] = {}
def fake_watcher(**kwargs: Any) -> None:
captured.update(kwargs)
with patch.object(wrap_mod, "_run_proxy_only_watcher", side_effect=fake_watcher):
result = CliRunner().invoke(main, ["wrap", "antigravity", "--port", "8787"])
assert result.exit_code == 0, result.output
assert captured["agent_label"] == "antigravity"
assert captured["agent_type"] == "antigravity"
assert captured["port"] == 8787
def test_wrap_antigravity_setup_lines_render_actual_port(monkeypatch) -> None:
monkeypatch.setattr(wrap_mod, "_project_name_from_cwd", lambda: None)
captured: dict[str, Any] = {}
def fake_watcher(**kwargs: Any) -> None:
captured.update(kwargs)
with patch.object(wrap_mod, "_run_proxy_only_watcher", side_effect=fake_watcher):
result = CliRunner().invoke(main, ["wrap", "antigravity"])
assert result.exit_code == 0, result.output
print_setup_lines = captured["print_setup_lines"]
with patch("click.echo") as echo_mock:
print_setup_lines(9999)
rendered = "\n".join(call.args[0] for call in echo_mock.call_args_list)
assert "http://127.0.0.1:9999/v1" in rendered
assert "Antigravity" in rendered
def test_wrap_antigravity_honors_headroom_port_env(monkeypatch) -> None:
"""HEADROOM_PORT configures the proxy port like every other wrap command."""
monkeypatch.setenv("HEADROOM_PORT", "9999")
monkeypatch.delenv("HEADROOM_PORT_DISCOVERY", raising=False)
captured: dict[str, Any] = {}
def fake_watcher(**kwargs: Any) -> None:
captured.update(kwargs)
with patch.object(wrap_mod, "_run_proxy_only_watcher", side_effect=fake_watcher):
result = CliRunner().invoke(main, ["wrap", "antigravity"])
assert result.exit_code == 0, result.output
assert captured["port"] == 9999
def test_wrap_antigravity_explicit_port_overrides_env(monkeypatch) -> None:
"""An explicit --port always wins over HEADROOM_PORT."""
monkeypatch.setenv("HEADROOM_PORT", "9999")
monkeypatch.delenv("HEADROOM_PORT_DISCOVERY", raising=False)
captured: dict[str, Any] = {}
def fake_watcher(**kwargs: Any) -> None:
captured.update(kwargs)
with patch.object(wrap_mod, "_run_proxy_only_watcher", side_effect=fake_watcher):
result = CliRunner().invoke(main, ["wrap", "antigravity", "--port", "7777"])
assert result.exit_code == 0, result.output
assert captured["port"] == 7777