mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-31 08:13:11 +03:00
fix(cli): name roles through legacy launchers
This commit is contained in:
@@ -56,6 +56,7 @@ from nanobot.cli.agent import agent # noqa: E402
|
|||||||
from nanobot.cli.gateway import create_gateway_app # noqa: E402
|
from nanobot.cli.gateway import create_gateway_app # noqa: E402
|
||||||
from nanobot.cli.gateway_runtime import _run_gateway # noqa: E402
|
from nanobot.cli.gateway_runtime import _run_gateway # noqa: E402
|
||||||
from nanobot.cli.log_control import _set_nanobot_logs # noqa: E402
|
from nanobot.cli.log_control import _set_nanobot_logs # noqa: E402
|
||||||
|
from nanobot.cli.process_identity import set_cli_process_identity # noqa: E402
|
||||||
from nanobot.cli.provider import provider_app # noqa: E402
|
from nanobot.cli.provider import provider_app # noqa: E402
|
||||||
from nanobot.cli.runtime_config import ( # noqa: E402
|
from nanobot.cli.runtime_config import ( # noqa: E402
|
||||||
_load_inspection_config,
|
_load_inspection_config,
|
||||||
@@ -99,12 +100,17 @@ def version_callback(value: bool):
|
|||||||
|
|
||||||
@app.callback()
|
@app.callback()
|
||||||
def main(
|
def main(
|
||||||
|
ctx: typer.Context,
|
||||||
version: bool = typer.Option(
|
version: bool = typer.Option(
|
||||||
None, "--version", "-v", callback=version_callback, is_eager=True
|
None, "--version", "-v", callback=version_callback, is_eager=True
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
"""nanobot - Personal AI Assistant."""
|
"""nanobot - Personal AI Assistant."""
|
||||||
pass
|
# Editable/source installs can retain an older generated console script that
|
||||||
|
# imports this Typer app directly instead of ``nanobot.cli.entry``. Keep the
|
||||||
|
# role identity correct until that launcher is regenerated.
|
||||||
|
command = ctx.invoked_subcommand
|
||||||
|
set_cli_process_identity([command] if command else sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
|
from nanobot.cli.commands import app
|
||||||
from nanobot.cli.process_identity import named_executable, set_cli_process_identity
|
from nanobot.cli.process_identity import named_executable, set_cli_process_identity
|
||||||
|
|
||||||
|
|
||||||
@@ -44,6 +46,18 @@ def test_cli_process_identity_keeps_windows_launcher_name(
|
|||||||
assert titles == []
|
assert titles == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_legacy_console_entrypoint_still_sets_subcommand_identity(
|
||||||
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
) -> None:
|
||||||
|
commands: list[list[str]] = []
|
||||||
|
monkeypatch.setattr("nanobot.cli.commands.set_cli_process_identity", commands.append)
|
||||||
|
|
||||||
|
result = CliRunner().invoke(app, ["webui", "--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert commands == [["webui"]]
|
||||||
|
|
||||||
|
|
||||||
def test_named_executable_creates_stable_role_symlink(
|
def test_named_executable_creates_stable_role_symlink(
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user