feat: CLI consistency pass — unified args, verbs, and status

#1 Positional dest unified to `name` across info + dev verbs (was `project`).
#2 install/uninstall help now states the activate semantics (tool→PATH,
   service/job→systemd, frontend→served) rather than 'to PATH'.
#4 `service status` (a plural op) moved to `services status`; the singular
   `service` group is enable/disable only.
#5 `list --behavior` now filters the program *catalog* by its real behavior
   field. behavior (what a program is) and service/job (how it's deployed) are
   separate axes: `list` shows a Programs catalog plus Services/Jobs deployment
   views; a behavior filter scopes the catalog only.
#6 `list` uses lifecycle.is_active uniformly for the status dot (tool on PATH /
   service running / job timer / static frontend served) instead of registry
   presence.
#7 New `castle restart <name>` — restart a service (unit) or job (timer).
#8 New `castle status` — unified services + jobs + programs activation view.
#9 New `castle format [name]` dev verb (ruff format / pnpm format); wired into
   stacks DEV_ACTIONS + handlers.
#10 New `castle up` — deploy + start everything in one shot.

Docs: CLAUDE.md command reference refreshed. Tests updated to the two-axis
list model (+ a daemon-behavior program fixture). core 92 · cli 24 · api 52
green; ruff clean.
This commit is contained in:
2026-06-14 11:57:58 -07:00
parent 3f3b88f17b
commit a5dcb6b346
10 changed files with 245 additions and 156 deletions

View File

@@ -20,6 +20,10 @@ def castle_root(tmp_path: Path) -> Generator[Path, None, None]:
"description": "Test tool",
"behavior": "tool",
},
"test-daemon": {
"description": "Test daemon program",
"behavior": "daemon",
},
},
"services": {
"test-svc": {

View File

@@ -20,7 +20,7 @@ class TestInfoCommand:
from castle_cli.commands.info import run_info
result = run_info(Namespace(project="test-svc", json=False))
result = run_info(Namespace(name="test-svc", json=False))
assert result == 0
output = capsys.readouterr().out
@@ -37,7 +37,7 @@ class TestInfoCommand:
from castle_cli.commands.info import run_info
result = run_info(Namespace(project="test-tool", json=False))
result = run_info(Namespace(name="test-tool", json=False))
assert result == 0
output = capsys.readouterr().out
@@ -53,7 +53,7 @@ class TestInfoCommand:
from castle_cli.commands.info import run_info
result = run_info(Namespace(project="nope", json=False))
result = run_info(Namespace(name="nope", json=False))
assert result == 1
output = capsys.readouterr().out
@@ -68,7 +68,7 @@ class TestInfoCommand:
from castle_cli.commands.info import run_info
result = run_info(Namespace(project="test-svc", json=True))
result = run_info(Namespace(name="test-svc", json=True))
assert result == 0
output = capsys.readouterr().out
@@ -85,7 +85,7 @@ class TestInfoCommand:
from castle_cli.commands.info import run_info
result = run_info(Namespace(project="test-svc", json=False))
result = run_info(Namespace(name="test-svc", json=False))
assert result == 0
output = capsys.readouterr().out
@@ -100,7 +100,7 @@ class TestInfoCommand:
from castle_cli.commands.info import run_info
result = run_info(Namespace(project="test-svc", json=False))
result = run_info(Namespace(name="test-svc", json=False))
assert result == 0
output = capsys.readouterr().out

View File

@@ -28,7 +28,7 @@ class TestListCommand:
assert "test-tool" in captured.out
def test_list_filter_daemon(self, castle_root: Path, capsys: object) -> None:
"""List filtered to daemons."""
"""--behavior filters the program catalog by its real behavior field."""
with patch("castle_cli.commands.list_cmd.load_config") as mock_load:
from castle_cli.config import load_config
@@ -38,8 +38,10 @@ class TestListCommand:
assert result == 0
captured = capsys.readouterr() # type: ignore[attr-defined]
assert "test-svc" in captured.out
assert "test-daemon" in captured.out
assert "test-tool" not in captured.out
# Services/jobs are deployment views, not behaviors — hidden under a filter.
assert "test-svc" not in captured.out
def test_list_filter_tool(self, castle_root: Path, capsys: object) -> None:
"""List filtered to tools."""
@@ -55,22 +57,24 @@ class TestListCommand:
assert "test-tool" in captured.out
assert "test-svc" not in captured.out
def test_list_filter_job(self, castle_root: Path, capsys: object) -> None:
"""List filtered to jobs (shown under tool behavior)."""
def test_list_jobs_are_deployments(self, castle_root: Path, capsys: object) -> None:
"""Jobs are a deployment view: shown unfiltered, hidden under a behavior filter."""
with patch("castle_cli.commands.list_cmd.load_config") as mock_load:
from castle_cli.config import load_config
mock_load.return_value = load_config(castle_root)
args = Namespace(behavior="tool", stack=None, json=False)
result = run_list(args)
assert result == 0
captured = capsys.readouterr() # type: ignore[attr-defined]
assert "test-job" in captured.out
assert "test-svc" not in captured.out
# Unfiltered: the job appears.
run_list(Namespace(behavior=None, stack=None, json=False))
assert "test-job" in capsys.readouterr().out # type: ignore[attr-defined]
# Behavior filter targets the catalog, so jobs drop out.
run_list(Namespace(behavior="tool", stack=None, json=False))
out = capsys.readouterr().out # type: ignore[attr-defined]
assert "test-job" not in out
assert "test-svc" not in out
assert "test-tool" in out
def test_list_json(self, castle_root: Path, capsys: object) -> None:
"""List output as JSON."""
"""JSON output tags each entry with its kind; behavior lives on programs."""
with patch("castle_cli.commands.list_cmd.load_config") as mock_load:
from castle_cli.config import load_config
@@ -85,4 +89,7 @@ class TestListCommand:
assert "test-svc" in names
assert "test-tool" in names
svc = next(p for p in data if p["name"] == "test-svc")
assert svc["behavior"] == "daemon"
assert svc["kind"] == "service"
tool = next(p for p in data if p["name"] == "test-tool")
assert tool["kind"] == "program"
assert tool["behavior"] == "tool"