The world's first agentic reverse engineer.
feat: update banner for CUSTOM-safe lookups
Amruth774397d9e5d7
diff --git a/kong/banner.py b/kong/banner.pyindex 9fd7794..9ff238c 100644--- a/kong/banner.py+++ b/kong/banner.py@@ -56,8 +56,8 @@ _KEY_URLS: dict[LLMProvider, str] = {}-def _env_var_for(provider: LLMProvider) -> str:- return _ENV_VARS[provider]+def _env_var_for(provider: LLMProvider) -> str | None:+ return _ENV_VARS.get(provider)def _load_dotenv(provider: LLMProvider) -> None:@@ -66,6 +66,8 @@ def _load_dotenv(provider: LLMProvider) -> None:Checks cwd first, then the package root (two levels up from this file)."""env_var = _env_var_for(provider)+ if env_var is None:+ returnif os.environ.get(env_var):returnpackage_root = Path(__file__).resolve().parent.parent@@ -84,20 +86,28 @@ def _load_dotenv(provider: LLMProvider) -> None:def check_api_key(provider: LLMProvider) -> bool:+ env_var = _env_var_for(provider)+ if env_var is None:+ return True_load_dotenv(provider)- return bool(os.environ.get(_env_var_for(provider)))+ return bool(os.environ.get(env_var))def print_setup_needed(console: Console, provider: LLMProvider = LLMProvider.ANTHROPIC) -> None:env_var = _env_var_for(provider)+ if env_var is None:+ console.print()+ console.print("[bold red]Custom provider not configured.[/bold red]")+ console.print("Run [bold cyan]kong setup[/bold cyan] to configure a custom endpoint.")+ returnconsole.print()console.print(f"[bold red]{env_var} is not set.[/bold red]")console.print()console.print(f"Kong requires a {provider.display_name} API key to analyze binaries.")console.print("Run [bold cyan]kong setup[/bold cyan] for guided configuration.")console.print()- console.print("Or set it directly:")- console.print(f" [bold]export {env_var}={_KEY_EXAMPLES[provider]}[/bold]")+ key_example = _KEY_EXAMPLES.get(provider, "your-key-here")+ console.print(f" [bold]export {env_var}={key_example}[/bold]")def print_analyze_header(diff --git a/tests/test_cli.py b/tests/test_cli.pyindex 9fcb2c2..9267231 100644--- a/tests/test_cli.py+++ b/tests/test_cli.py@@ -81,6 +81,18 @@ def test_eval_with_test_data(tmp_path):assert "Symbol Accuracy" in result.output+class TestBannerCustomProvider:+ def test_env_vars_does_not_have_custom(self):+ from kong.banner import _ENV_VARS++ assert LLMProvider.CUSTOM not in _ENV_VARS++ def test_check_api_key_returns_true_for_custom(self):+ from kong.banner import check_api_key++ assert check_api_key(LLMProvider.CUSTOM) is True++class TestCreateLLMClient:@patch("kong.llm.openai_client.openai.OpenAI")def test_custom_returns_openai_client_with_base_url(self, mock_openai_cls):