feat(cli): keep lite autoroute up and down as hidden deprecated aliases

This commit is contained in:
mateo-berri 2026-09-17 15:25:12 -07:00
parent a440d6d452
commit 4371ddb620
3 changed files with 65 additions and 9 deletions

View file

@ -668,6 +668,8 @@ lite autoroute start
lite autoroute stop # only needed if `start` was killed uncleanly instead of Ctrl-C'd
```
The previous names, `lite autoroute up` and `lite autoroute down`, still work as hidden aliases of `start` and `stop`: each prints a deprecation notice on stderr and will be removed in a future release
#### Caveats
Adaptive mode's learned state does not persist across `lite autoroute start` sessions -- there is no local database, so every session starts adaptive selection cold. A Claude Code session already running before `start` ran, or still running when it stops, keeps whatever settings it loaded at its own startup; like `lite up`, this is a one-time file patch and restore, not a live traffic interceptor. Only Claude Code is supported, for the same reason as `lite up`: no other supported agent (for example Cursor) has an equivalent hot-patchable config file.

View file

@ -88,14 +88,17 @@ def configure(ctx: click.Context) -> None:
run_configure_wizard(ctx)
@autoroute_group.command("start")
@click.option(
_PORT_OPTION: Final = click.option(
"--port",
type=click.IntRange(1, 65535),
default=DEFAULT_AUTOROUTE_PORT,
show_default=True,
help="Loopback port for the ephemeral proxy; stable across runs so configured clients keep working.",
)
@autoroute_group.command("start")
@_PORT_OPTION
def start(port: int) -> None:
"""Launch the ephemeral auto-router proxy and route Claude Code through it"""
if not CONFIG_PATH.exists():
@ -241,4 +244,31 @@ def stop() -> None:
click.echo(f"Removed {CLAUDE_SETTINGS_PATH} (it did not exist before `lite autoroute start`).")
AUTOROUTE_ALIAS_DEPRECATION_NOTICE: Final = (
"`lite autoroute {retired}` is deprecated and will be removed in a future release; "
"run `lite autoroute {current}` instead, it takes the same options."
)
def _warn_deprecated_alias(retired: str, current: str) -> None:
click.secho(AUTOROUTE_ALIAS_DEPRECATION_NOTICE.format(retired=retired, current=current), err=True, fg="yellow")
@autoroute_group.command("up", hidden=True)
@_PORT_OPTION
@click.pass_context
def up(ctx: click.Context, port: int) -> None:
"""Deprecated alias of `lite autoroute start`"""
_warn_deprecated_alias("up", "start")
ctx.invoke(start, port=port)
@autoroute_group.command("down", hidden=True)
@click.pass_context
def down(ctx: click.Context) -> None:
"""Deprecated alias of `lite autoroute stop`"""
_warn_deprecated_alias("down", "stop")
ctx.invoke(stop)
__all__ = ["autoroute_group"]

View file

@ -547,17 +547,41 @@ class TestStopCommand:
class TestSubcommandNames:
def test_start_and_stop_replace_up_and_down(self):
def test_start_and_stop_are_the_listed_commands(self):
"""`lite up` already routes an existing proxy into Claude Code, so the ephemeral proxy's
launcher and its recovery path are `start` and `stop`, with no `up`/`down` alias left."""
launcher and its recovery path are listed as `start` and `stop`; the old names stay callable
but are hidden from the listing."""
runner = CliRunner()
for retired in ("up", "down"):
result = runner.invoke(autoroute_group, [retired, "--help"])
assert result.exit_code == 2, result.output
assert f"No such command '{retired}'" in result.output
listing = runner.invoke(autoroute_group, ["--help"])
assert listing.exit_code == 0, listing.output
listed = {line.split()[0] for line in listing.output.splitlines() if line.startswith(" ")}
assert {"configure", "start", "stop"} <= listed
assert listed.isdisjoint({"up", "down"})
for name in ("start", "stop"):
for name in ("start", "stop", "up", "down"):
result = runner.invoke(autoroute_group, [name, "--help"])
assert result.exit_code == 0, result.output
assert "Show this message and exit" in result.output
def test_up_warns_then_behaves_like_start(self, monkeypatch, tmp_path):
_patch_paths(monkeypatch, tmp_path)
runner = CliRunner()
result = runner.invoke(autoroute_group, ["up", "--port", "5555"])
assert result.exit_code == 1, result.output
assert "`lite autoroute up` is deprecated" in result.stderr
assert "run `lite autoroute start` instead" in result.stderr
assert "No config found. Run `lite autoroute configure` first." in result.output
def test_down_warns_then_behaves_like_stop(self, monkeypatch, tmp_path):
_patch_paths(monkeypatch, tmp_path)
runner = CliRunner()
result = runner.invoke(autoroute_group, ["down"])
assert result.exit_code == 0, result.output
assert "`lite autoroute down` is deprecated" in result.stderr
assert "run `lite autoroute stop` instead" in result.stderr
assert "Nothing to restore." in result.output