headroom/tests/test_cli
Rod Boev 701e4616d9
fix(kimi): route managed Kimi Code through the proxy (#3223)
## Description

Managed Kimi Code reads KIMI_CODE_BASE_URL while headroom wrap kimi
previously supplied only KIMI_BASE_URL. The managed client can therefore
keep its direct endpoint while the wrapper appears healthy. Emit both
provider-owned keys and recompute them through the existing launch
callback at the proxy's actual port. Preserve the legacy route and
unrelated wrappers. Closes #3207

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (feature that would cause existing behavior to
change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- Set KIMI_CODE_BASE_URL and KIMI_BASE_URL from one project-aware proxy
URL.
- Recompute both values and their display lines through the Kimi
configure_launch callback after port fallback.
- Remove the generic display rewrite from _launch_tool so other wrappers
retain their base behavior.
- Add production-boundary child, fallback-port, legacy-preservation, and
non-Kimi negative-space tests.

## Testing

- [x] Unit tests pass (`uv run pytest tests/test_cli/test_wrap_kimi.py
-q`)
- [x] Linting passes (`uv run ruff check .`)
- [ ] Type checking passes (`uv run mypy headroom`)
- [x] New tests added for the regression
- [x] Manual testing performed through the production subprocess
boundary

### Test Output

```text
uv run pytest tests/test_cli/test_wrap_kimi.py -q
10 passed in 0.40s
uv run pytest tests/test_cli/test_wrap_grok.py -q
2 passed
uv run ruff check .
All checks passed!
uv run ruff format . --check
1534 files already formatted
git diff --check
```

## Real Behavior Proof

- Environment: Windows, isolated Kimi wrapper subprocess harness.
- Exact command / steps: launch a contract-compatible child through the
Kimi wrapper; exercise requested and fallback ports, project prefixes,
legacy selection, and a non-Kimi wrapper.
- Observed result: the child receives the effective project-aware proxy
URL in both Kimi keys; the displayed URL matches it after fallback;
legacy and non-Kimi behavior remain unchanged.
- Not tested: live authenticated Kimi Code managed request

## Runtime Rollout Safety

- Rollout-managed feature(s): None; managed Kimi Code routing is
selected by the existing wrapper mode.
- Minimum rollout channel: Stable; no staged rollout mechanism exists
for this wrapper path.
- Stable/default behavior changed: Yes, managed Kimi Code launches now
receive the effective proxy URL in both provider-owned keys.
- Kill switch / disable path: Stop using the managed Kimi wrapper path
or revert the release commit.
- Unsafe override required: No.
- Qualification impact: None.
- Rollback path: Revert the release 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] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective
- [x] New and existing unit tests pass locally with my changes
- [x] I have updated the CHANGELOG.md if applicable

## Additional Notes

Kimi Code owns OAuth credentials and the /login flow. Headroom does not
read or modify Kimi config or credential files. The changelog is
generated by the release pipeline.
2026-08-23 19:55:14 -07:00
..
conftest.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_copilot_auth.py fix(auth): support GitHub Enterprise Copilot OAuth domain (#2192) 2026-07-14 16:07:17 -04:00
test_init_cli.py fix(cli/init): fail clearly on a target settings file with invalid JSON (#2227) 2026-07-15 18:15:45 +00:00
test_init_enable_tool_search.py fix(vscode): persist compatible Claude modes and route Copilot CAPI (#2986) 2026-08-13 15:06:41 -05:00
test_install_cli.py fix(install): honor HEADROOM_PORT in install apply and deploy (#3085) 2026-08-17 20:20:38 -07:00
test_main_help_version.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_mcp.py feat(mcp): add streamable HTTP MCP transport (#1773) 2026-07-14 13:25:45 -04:00
test_mcp_reconcile.py fix(mcp): add explicit Serena reconciliation (#3222) 2026-08-23 11:52:50 -07:00
test_mcp_status.py fix(mcp): mcp status checks ~/.claude.json, not only ~/.claude/mcp.json (#990) 2026-07-15 09:25:52 -05:00
test_recover_codex.py test(recover-codex): bind AF_UNIX socket via short relative path (#2396) 2026-08-02 13:14:31 -07:00
test_serena_disable.py fix(serena): stop the Serena dashboard popup and make --no-serena actually disable Serena (#1003) 2026-06-14 23:32:46 -07:00
test_serena_migrate.py fix(wrap/serena): stop creating serena_config.yml, unbricking Serena on fresh installs (#2676) 2026-07-30 20:55:47 -07:00
test_serena_reconcile.py fix(mcp): add explicit Serena reconciliation (#3222) 2026-08-23 11:52:50 -07:00
test_subprocess_utf8_encoding.py fix(windows): pin UTF-8 encoding on text-mode subprocess calls (#1311) 2026-06-23 12:52:49 -05:00
test_unwrap_claude.py fix(install): consolidate Windows fallback and cleanup safety (#2980) 2026-08-13 15:05:45 -05:00
test_wrap_aider.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_bridge.py fix(wrap): set xAI upstream for grok-build proxy (#2772) 2026-08-16 15:04:59 -07:00
test_wrap_claude.py fix(claude): stop forcing tool search on Foundry (#2477) 2026-08-12 00:15:07 -05:00
test_wrap_claude_base_url.py fix(vscode): persist compatible Claude modes and route Copilot CAPI (#2986) 2026-08-13 15:06:41 -05:00
test_wrap_claude_finally_unbound.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_claude_vertex_proxy_env.py fix(claude): reject conflicting auth before proxy startup (#2993) 2026-08-13 23:01:59 -05:00
test_wrap_codex.py fix(wrap): verify proxy deps before mutating Codex config (#1628) 2026-08-13 11:52:22 -05:00
test_wrap_copilot.py fix(wrap): honor Copilot OAuth wire-api override and model default (#2387) 2026-08-12 00:04:42 -05:00
test_wrap_dead_marker_selfheal.py fix(wrap): self-heal a stale ANTHROPIC_BASE_URL left by a dead proxy (#2223) 2026-07-15 19:58:10 +00:00
test_wrap_encoding.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_goose.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_grok.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_helpers.py feat(wrap/claude): make the --1m fallback model configurable via HEADROOM_1M_MODEL (#2983) 2026-08-16 15:09:46 -07:00
test_wrap_kimi.py fix(kimi): route managed Kimi Code through the proxy (#3223) 2026-08-23 19:55:14 -07:00
test_wrap_omp.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_openclaude.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_openclaw.py fix(wrap): use canonical headroom-openclaw npm package for wrap openclaw (#1969) (#2120) 2026-07-13 16:33:44 -04:00
test_wrap_opencode.py fix(wrap): verify proxy deps before mutating Codex config (#1628) 2026-08-13 11:52:22 -05:00
test_wrap_openhands.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_persistent.py feat(opencode): support Copilot subscription backend for headroom models (#2441) (#2445) 2026-07-20 11:02:14 -07:00
test_wrap_proxy_detach.py fix(wrap): detach the shared proxy on Windows so it survives an ungraceful agent close (#1464) 2026-06-30 13:49:28 -05:00
test_wrap_serena_boost.py fix(wrap): make the Serena pre-index stall budget configurable (#3183) 2026-08-21 14:59:53 -07:00
test_wrap_stale_marker.py fix: detect and clear stale ANTHROPIC_BASE_URL from crashed wrap sessions (#1768) (#1837) 2026-07-06 08:35:40 -07:00
test_wrap_vibe.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
test_wrap_vscode.py fix(copilot): send VS Code inline completions to the host that serves them (#3112) 2026-08-18 15:21:22 -07:00
test_wrap_vscode_claude.py fix(vscode): persist compatible Claude modes and route Copilot CAPI (#2986) 2026-08-13 15:06:41 -05:00
test_wrap_zcode.py fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00