refactor(cli): remove engine overrides

This commit is contained in:
banteg
2026-01-01 02:30:09 +04:00
parent d7e6076040
commit 6cdd4e9177
4 changed files with 5 additions and 44 deletions
+1 -17
View File
@@ -1,7 +1,6 @@
from __future__ import annotations
import os
from typing import Any
import anyio
import typer
@@ -14,7 +13,6 @@ from .engines import (
get_backend,
get_engine_config,
list_backend_ids,
parse_engine_overrides,
)
from .logging import setup_logging
from .onboarding import check_setup, render_setup_guide
@@ -35,7 +33,6 @@ def _parse_bridge_config(
*,
final_notify: bool,
backend: EngineBackend,
engine_overrides: dict[str, Any],
) -> BridgeConfig:
startup_pwd = os.getcwd()
@@ -62,7 +59,7 @@ def _parse_bridge_config(
startup_msg = backend.startup_message(startup_pwd)
bot = TelegramClient(token)
runner = backend.build_runner(engine_cfg, engine_overrides, config_path)
runner = backend.build_runner(engine_cfg, config_path)
return BridgeConfig(
bot=bot,
@@ -96,13 +93,6 @@ def run(
"--debug/--no-debug",
help="Log engine JSONL, Telegram requests, and rendered messages.",
),
engine_option: list[str] = typer.Option(
[],
"--engine-option",
"-E",
help="Engine-specific override in KEY=VALUE form (repeatable).",
hidden=True,
),
) -> None:
setup_logging(debug=debug)
try:
@@ -110,11 +100,6 @@ def run(
except ConfigError as e:
typer.echo(str(e), err=True)
raise typer.Exit(code=1)
try:
overrides = parse_engine_overrides(engine_option)
except ConfigError as e:
typer.echo(str(e), err=True)
raise typer.Exit(code=1)
setup = check_setup(backend)
if not setup.ok:
render_setup_guide(setup)
@@ -123,7 +108,6 @@ def run(
cfg = _parse_bridge_config(
final_notify=final_notify,
backend=backend,
engine_overrides=overrides,
)
except ConfigError as e:
typer.echo(str(e), err=True)
+2 -23
View File
@@ -10,7 +10,6 @@ from .runner import Runner
from .runners.codex import CodexRunner
EngineConfig = dict[str, Any]
EngineOverrides = dict[str, Any]
@dataclass(frozen=True, slots=True)
@@ -24,7 +23,7 @@ class EngineBackend:
id: str
display_name: str
check_setup: Callable[[EngineConfig, Path], list[SetupIssue]]
build_runner: Callable[[EngineConfig, EngineOverrides, Path], Runner]
build_runner: Callable[[EngineConfig, Path], Runner]
startup_message: Callable[[str], str]
@@ -40,7 +39,7 @@ def _codex_check_setup(_config: EngineConfig, _config_path: Path) -> list[SetupI
def _codex_build_runner(
config: EngineConfig, overrides: EngineOverrides, config_path: Path
config: EngineConfig, config_path: Path
) -> Runner:
codex_cmd = shutil.which("codex")
if not codex_cmd:
@@ -73,13 +72,6 @@ def _codex_build_runner(
extra_args.extend(["--profile", profile_value])
title = profile_value
if overrides:
unknown = ", ".join(sorted(overrides))
raise ConfigError(
"Codex does not support --engine-option overrides yet. "
f"Remove: {unknown}"
)
return CodexRunner(codex_cmd=codex_cmd, extra_args=extra_args, title=title)
@@ -116,19 +108,6 @@ def list_backend_ids() -> list[str]:
return sorted(_ENGINE_BACKENDS)
def parse_engine_overrides(options: list[str]) -> EngineOverrides:
overrides: EngineOverrides = {}
for raw in options:
key, sep, value = raw.partition("=")
if not sep:
raise ConfigError(f"Invalid --engine-option {raw!r}; expected KEY=VALUE.")
key = key.strip()
if not key:
raise ConfigError(f"Invalid --engine-option {raw!r}; expected KEY=VALUE.")
overrides[key] = value
return overrides
def get_engine_config(
config: dict[str, Any], engine_id: str, config_path: Path
) -> EngineConfig: