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
+2 -2
View File
@@ -12,8 +12,8 @@
- migrate async runtime from asyncio to anyio [#6](https://github.com/banteg/takopi/pull/6) - migrate async runtime from asyncio to anyio [#6](https://github.com/banteg/takopi/pull/6)
- stream runner events via async iterators (natural backpressure) - stream runner events via async iterators (natural backpressure)
- per-thread job queues with serialization for same-thread runs - per-thread job queues with serialization for same-thread runs
- emit `completed` as terminal event (carries resume + final answer) - render resume as `codex resume <token>` command lines
- render resume as `` `codex resume <token>` `` command lines - various rendering improvements including file edits
### breaking ### breaking
+1 -17
View File
@@ -1,7 +1,6 @@
from __future__ import annotations from __future__ import annotations
import os import os
from typing import Any
import anyio import anyio
import typer import typer
@@ -14,7 +13,6 @@ from .engines import (
get_backend, get_backend,
get_engine_config, get_engine_config,
list_backend_ids, list_backend_ids,
parse_engine_overrides,
) )
from .logging import setup_logging from .logging import setup_logging
from .onboarding import check_setup, render_setup_guide from .onboarding import check_setup, render_setup_guide
@@ -35,7 +33,6 @@ def _parse_bridge_config(
*, *,
final_notify: bool, final_notify: bool,
backend: EngineBackend, backend: EngineBackend,
engine_overrides: dict[str, Any],
) -> BridgeConfig: ) -> BridgeConfig:
startup_pwd = os.getcwd() startup_pwd = os.getcwd()
@@ -62,7 +59,7 @@ def _parse_bridge_config(
startup_msg = backend.startup_message(startup_pwd) startup_msg = backend.startup_message(startup_pwd)
bot = TelegramClient(token) bot = TelegramClient(token)
runner = backend.build_runner(engine_cfg, engine_overrides, config_path) runner = backend.build_runner(engine_cfg, config_path)
return BridgeConfig( return BridgeConfig(
bot=bot, bot=bot,
@@ -96,13 +93,6 @@ def run(
"--debug/--no-debug", "--debug/--no-debug",
help="Log engine JSONL, Telegram requests, and rendered messages.", 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: ) -> None:
setup_logging(debug=debug) setup_logging(debug=debug)
try: try:
@@ -110,11 +100,6 @@ def run(
except ConfigError as e: except ConfigError as e:
typer.echo(str(e), err=True) typer.echo(str(e), err=True)
raise typer.Exit(code=1) 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) setup = check_setup(backend)
if not setup.ok: if not setup.ok:
render_setup_guide(setup) render_setup_guide(setup)
@@ -123,7 +108,6 @@ def run(
cfg = _parse_bridge_config( cfg = _parse_bridge_config(
final_notify=final_notify, final_notify=final_notify,
backend=backend, backend=backend,
engine_overrides=overrides,
) )
except ConfigError as e: except ConfigError as e:
typer.echo(str(e), err=True) typer.echo(str(e), err=True)
+2 -23
View File
@@ -10,7 +10,6 @@ from .runner import Runner
from .runners.codex import CodexRunner from .runners.codex import CodexRunner
EngineConfig = dict[str, Any] EngineConfig = dict[str, Any]
EngineOverrides = dict[str, Any]
@dataclass(frozen=True, slots=True) @dataclass(frozen=True, slots=True)
@@ -24,7 +23,7 @@ class EngineBackend:
id: str id: str
display_name: str display_name: str
check_setup: Callable[[EngineConfig, Path], list[SetupIssue]] 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] startup_message: Callable[[str], str]
@@ -40,7 +39,7 @@ def _codex_check_setup(_config: EngineConfig, _config_path: Path) -> list[SetupI
def _codex_build_runner( def _codex_build_runner(
config: EngineConfig, overrides: EngineOverrides, config_path: Path config: EngineConfig, config_path: Path
) -> Runner: ) -> Runner:
codex_cmd = shutil.which("codex") codex_cmd = shutil.which("codex")
if not codex_cmd: if not codex_cmd:
@@ -73,13 +72,6 @@ def _codex_build_runner(
extra_args.extend(["--profile", profile_value]) extra_args.extend(["--profile", profile_value])
title = 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) 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) 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( def get_engine_config(
config: dict[str, Any], engine_id: str, config_path: Path config: dict[str, Any], engine_id: str, config_path: Path
) -> EngineConfig: ) -> EngineConfig:
-2
View File
@@ -34,7 +34,6 @@ def test_parse_bridge_config_rejects_empty_token(monkeypatch) -> None:
cli._parse_bridge_config( cli._parse_bridge_config(
final_notify=True, final_notify=True,
backend=engines.get_backend("codex"), backend=engines.get_backend("codex"),
engine_overrides={},
) )
@@ -47,7 +46,6 @@ def test_parse_bridge_config_rejects_string_chat_id(monkeypatch) -> None:
cli._parse_bridge_config( cli._parse_bridge_config(
final_notify=True, final_notify=True,
backend=engines.get_backend("codex"), backend=engines.get_backend("codex"),
engine_overrides={},
) )