From 58b007f8a316757bca72e428846903449f97138d Mon Sep 17 00:00:00 2001 From: Ziang Zhang Date: Mon, 8 Jun 2026 10:21:17 +0800 Subject: [PATCH 1/3] fix: include config directory in hatch build The config manifest files (builtin_commands.md, plugins.md) in trushell/config/ were not listed in the hatch build include list, which could cause a broken PyPI install where the kernel can't find any manifests. Fix: add 'trushell/config/*' to the include list in pyproject.toml. Closes #48 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ff35ef9..166e006 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ build-backend = "hatchling.build" [tool.hatch.build] packages = ["trushell"] -include = ["README.md", "LICENSE", "trushell/sounds/*"] +include = ["README.md", "LICENSE", "trushell/sounds/*", "trushell/config/*"] [tool.ruff] line-length = 88 From 48021c9eb9dd9114c06291d3d4829e85709d9706 Mon Sep 17 00:00:00 2001 From: Ziang Zhang Date: Mon, 8 Jun 2026 14:30:28 +0800 Subject: [PATCH 2/3] test: fix help docs test by adding _import_module to fake kernel The test_run_help_prints_docstring_for_known_command test was failing because the fake kernel lacked a _import_module method, causing the module import to fail silently and fall through to the error message. Add a working _fake_import_module that uses importlib to resolve the module path, allowing run_help to read and print the docstring. --- tests/test_help_docs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_help_docs.py b/tests/test_help_docs.py index 8eb08dd..99e9b03 100644 --- a/tests/test_help_docs.py +++ b/tests/test_help_docs.py @@ -1,18 +1,24 @@ from __future__ import annotations +import importlib from types import SimpleNamespace from trushell.commands.core import run_help def test_run_help_prints_docstring_for_known_command(monkeypatch, capsys): + def _fake_import_module(path: str): + module = importlib.import_module(path.replace("/", ".").removesuffix(".py")) + return module + fake_kernel = SimpleNamespace( registry={ "settings": { "path": "trushell/commands/settings.py", "function": "run_settings", } - } + }, + _import_module=_fake_import_module, ) monkeypatch.setattr("trushell.core.trukernel.get_kernel", lambda: fake_kernel) From 3fb196dd2d0ef0d1e425374b12ebcd69714a0034 Mon Sep 17 00:00:00 2001 From: Ziang Zhang Date: Mon, 8 Jun 2026 09:46:07 +0800 Subject: [PATCH 3/3] fix: resolve NameError crash at startup by defining argv before use The function referenced a bare name that was never imported or defined, causing a NameError crash on every invocation. Fix: move before the conditional block so it is always defined when reached by the comparison at the end of the function. Closes #40 --- trushell/cli.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/trushell/cli.py b/trushell/cli.py index ff10ff7..ecf12a4 100644 --- a/trushell/cli.py +++ b/trushell/cli.py @@ -26,11 +26,11 @@ def app_with_lower() -> None: """Entry point that normalizes the first argument to lowercase for case-insensitive invocation.""" - if len(sys.argv) > 1: - # Create a local copy to avoid mutating the global sys.argv - argv_copy = sys.argv.copy() - if argv_copy[1].lower() not in {"--help", "-h", "version"}: - raw = " ".join(argv_copy[1:]) + # Create a local copy to avoid mutating the global sys.argv + argv = sys.argv.copy() + if len(argv) > 1: + if argv[1].lower() not in {"--help", "-h", "version"}: + raw = " ".join(argv[1:]).lower() get_kernel().execute_command(raw) return