Skip to content

Your lightweight open-source personal agent.

fix(cli): name roles through legacy launchers

Xubin Ren1e9d46fb36bc
diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py
index 051037183..4fcb7929e 100644
--- a/nanobot/cli/commands.py
+++ b/nanobot/cli/commands.py
@@ -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_runtime import _run_gateway # 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.runtime_config import ( # noqa: E402
_load_inspection_config,
@@ -99,12 +100,17 @@ def version_callback(value: bool):
@app.callback()
def main(
+ ctx: typer.Context,
version: bool = typer.Option(
None, "--version", "-v", callback=version_callback, is_eager=True
),
):
"""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:])
# ============================================================================
diff --git a/tests/cli/test_process_identity.py b/tests/cli/test_process_identity.py
index 72faf2cc9..114432929 100644
--- a/tests/cli/test_process_identity.py
+++ b/tests/cli/test_process_identity.py
@@ -4,7 +4,9 @@ import os
from pathlib import Path
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
@@ -44,6 +46,18 @@ def test_cli_process_identity_keeps_windows_launcher_name(
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(
tmp_path: Path,
) -> None: