From 7c543beffe8c2a4091c84b7c2ebc2600f66ad6e7 Mon Sep 17 00:00:00 2001 From: Felix Martin Date: Wed, 10 Jun 2026 21:12:23 -0400 Subject: [PATCH] Add tool registry for tool windows Co-Authored-By: Claude Opus 4.8 --- src/hqt/tools.py | 28 ++++++++++++++++++++++++++++ tests/test_tools.py | 24 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/hqt/tools.py create mode 100644 tests/test_tools.py diff --git a/src/hqt/tools.py b/src/hqt/tools.py new file mode 100644 index 0000000..109ecae --- /dev/null +++ b/src/hqt/tools.py @@ -0,0 +1,28 @@ +"""Tools that can be opened in their own tmux window for a session's project. + +A tool window is NOT an hqt session: hqt spawns and styles it, then forgets it. +It lives purely as a tmux window until the tool exits. (``clone`` is handled +separately in the service — it creates a real session, not an aux window.) +""" + +from dataclasses import dataclass + + +@dataclass(frozen=True) +class Tool: + """How to open a tool in its own window. + + ``label`` is the base ``@hqt_label`` text (the project name is appended per + spawn). ``command`` is the argv to run; an empty list means "use tmux's + default shell" (a plain interactive shell). + """ + + label: str + command: list[str] + + +TOOLS: dict[str, Tool] = { + "nvim": Tool(label="nvim", command=["nvim"]), + "lazygit": Tool(label="lazygit", command=["lazygit"]), + "shell": Tool(label="shell", command=[]), +} diff --git a/tests/test_tools.py b/tests/test_tools.py new file mode 100644 index 0000000..51fcea8 --- /dev/null +++ b/tests/test_tools.py @@ -0,0 +1,24 @@ +from hqt.tools import TOOLS, Tool + + +def test_registry_has_the_three_tools(): + assert set(TOOLS) == {"nvim", "lazygit", "shell"} + + +def test_each_entry_is_a_tool(): + assert all(isinstance(t, Tool) for t in TOOLS.values()) + + +def test_nvim_and_lazygit_have_commands(): + assert TOOLS["nvim"].command == ["nvim"] + assert TOOLS["lazygit"].command == ["lazygit"] + + +def test_shell_has_empty_command_meaning_default_shell(): + assert TOOLS["shell"].command == [] + + +def test_labels_are_the_bare_tool_names(): + assert TOOLS["nvim"].label == "nvim" + assert TOOLS["lazygit"].label == "lazygit" + assert TOOLS["shell"].label == "shell"