Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
refactor(cli): rename machina/ package dir to cli/
trohitg0cdfe1cefc6c
diff --git a/machina/README.md b/cli/README.mdsimilarity index 100%rename from machina/README.mdrename to cli/README.mddiff --git a/machina/__init__.py b/cli/__init__.pysimilarity index 100%rename from machina/__init__.pyrename to cli/__init__.pydiff --git a/machina/__main__.py b/cli/__main__.pysimilarity index 66%rename from machina/__main__.pyrename to cli/__main__.pyindex d9ba3472..c365b41d 100644--- a/machina/__main__.py+++ b/cli/__main__.py@@ -1,9 +1,13 @@-"""Entry point for ``python -m machina``.+"""Entry point for ``python -m cli``.-pnpm scripts call ``python -m machina ...`` from the system Python,+pnpm scripts call ``python -m cli ...`` from the system Python,which only has ``uv`` -- not typer / rich / anyio / psutil. On firstrun we detect the missing imports, pip-install the declared runtimedeps, and retry, so the user never has to ``pip install -e .`` by hand.++The public CLI command is still ``machina`` (the user-facing name);+``cli`` is just the Python import path after the+``<repo>/machina/ → <repo>/cli/`` source-dir rename."""import subprocess@@ -25,10 +29,10 @@ def _bootstrap_deps() -> None:try:- from machina.cli import app+ from cli.cli import appexcept ImportError:_bootstrap_deps()- from machina.cli import app+ from cli.cli import appif __name__ == "__main__":diff --git a/machina/buildenv.py b/cli/buildenv.pysimilarity index 97%rename from machina/buildenv.pyrename to cli/buildenv.pyindex 132acf96..52bf1e71 100644--- a/machina/buildenv.py+++ b/cli/buildenv.py@@ -11,7 +11,7 @@ from pathlib import Pathimport typer-from machina.colors import console+from cli.colors import consoledef venv_python(root: Path) -> Path | None:diff --git a/machina/cli.py b/cli/cli.pysimilarity index 70%rename from machina/cli.pyrename to cli/cli.pyindex 72321e81..e013f636 100644--- a/machina/cli.py+++ b/cli/cli.py@@ -1,6 +1,6 @@"""Typer CLI for ``machina``.-Each subcommand lives under ``machina.commands``; this module just+Each subcommand lives under ``cli.commands``; this module justmounts them and exposes ``app`` as the entry point."""@@ -8,14 +8,14 @@ from __future__ import annotationsimport typer-from machina.commands.build import build_command-from machina.commands.clean import clean_command-from machina.commands.daemon import app as daemon_app-from machina.commands.dev import dev_command-from machina.commands.docs import app as docs_app-from machina.commands.start import start_command-from machina.commands.stop import stop_command-from machina.commands.version import app as version_app+from cli.commands.build import build_command+from cli.commands.clean import clean_command+from cli.commands.daemon import app as daemon_app+from cli.commands.dev import dev_command+from cli.commands.docs import app as docs_app+from cli.commands.start import start_command+from cli.commands.stop import stop_command+from cli.commands.version import app as version_appapp = typer.Typer(diff --git a/machina/colors.py b/cli/colors.pysimilarity index 100%rename from machina/colors.pyrename to cli/colors.pydiff --git a/cli/commands/__init__.py b/cli/commands/__init__.pynew file mode 100644index 00000000..a0e282c6--- /dev/null+++ b/cli/commands/__init__.py@@ -0,0 +1 @@+"""``machina`` subcommand modules. Imported by ``cli.cli``."""diff --git a/machina/commands/_supervised_runtime.py b/cli/commands/_supervised_runtime.pysimilarity index 95%rename from machina/commands/_supervised_runtime.pyrename to cli/commands/_supervised_runtime.pyindex 65d3cd72..d5316f2c 100644--- a/machina/commands/_supervised_runtime.py+++ b/cli/commands/_supervised_runtime.py@@ -14,7 +14,7 @@ call it, ``await singleton.start()``, then block on a shutdown signal.Usage (inside ``ServiceSpec.argv``):[- "python", "-m", "machina.commands._supervised_runtime",+ "python", "-m", "cli.commands._supervised_runtime","services.temporal._runtime:get_postgres_runtime",]@@ -79,7 +79,7 @@ async def _run(factory_dotted: str) -> int:def main() -> int:if len(sys.argv) != 2:print(- "usage: python -m machina.commands._supervised_runtime "+ "usage: python -m cli.commands._supervised_runtime ""<module.path:factory>",file=sys.stderr,)diff --git a/machina/commands/_temporal_specs.py b/cli/commands/_temporal_specs.pysimilarity index 94%rename from machina/commands/_temporal_specs.pyrename to cli/commands/_temporal_specs.pyindex cc7894b8..c34e6164 100644--- a/machina/commands/_temporal_specs.py+++ b/cli/commands/_temporal_specs.py@@ -12,7 +12,7 @@ Returns the right Temporal ``ServiceSpec`` set based on the- ``postgres`` (prod) — two specs running the supervised runtimes:``temporal-postgres`` (pgserver) then ``temporal-server`` (Temporalbinary with YAML config). Both wrap ``BaseSupervisor`` singletons- via ``machina.commands._supervised_runtime``.+ via ``cli.commands._supervised_runtime``.The supervisor's TCP readiness probes (``ready_port``) order thepostgres → temporal startup automatically — Temporal won't start until@@ -23,7 +23,7 @@ from __future__ import annotationsimport osfrom pathlib import Path-from machina.supervisor import RestartPolicy, ServiceSpec+from cli.supervisor import RestartPolicy, ServiceSpec# Backend names — must match ``core.config.Settings.temporal_backend``# enum (``"sqlite" | "postgres"``). Read from ``TEMPORAL_BACKEND`` env@@ -58,7 +58,7 @@ def _runtime_argv(factory_path: str) -> list[str]:``module:attr`` accessor."""return ["uv", "run", "python", "-m",- "machina.commands._supervised_runtime",+ "cli.commands._supervised_runtime",factory_path,]@@ -66,7 +66,7 @@ def _runtime_argv(factory_path: str) -> list[str]:def temporal_specs(root: Path, cfg) -> list[ServiceSpec]:"""Return the Temporal ServiceSpec list for the current backend.- ``cfg`` is ``machina.config.Config``; ``cfg.temporal_port`` drives+ ``cfg`` is ``cli.config.Config``; ``cfg.temporal_port`` drivesthe gRPC readiness probe regardless of backend (same port forboth ``sqlite`` and ``postgres`` paths)."""diff --git a/machina/commands/build.py b/cli/commands/build.pysimilarity index 98%rename from machina/commands/build.pyrename to cli/commands/build.pyindex 0504068b..5050eaa1 100644--- a/machina/commands/build.py+++ b/cli/commands/build.py@@ -18,9 +18,9 @@ from pathlib import Pathimport typer-from machina.run import capture, run-from machina.colors import console-from machina.platform_ import project_root+from cli.run import capture, run+from cli.colors import console+from cli.platform_ import project_root# Source dirs / entry-point modules under ``server/`` that ``machina build``diff --git a/machina/commands/clean.py b/cli/commands/clean.pysimilarity index 92%rename from machina/commands/clean.pyrename to cli/commands/clean.pyindex 73339472..6170358f 100644--- a/machina/commands/clean.py+++ b/cli/commands/clean.py@@ -11,10 +11,10 @@ import shutilimport timefrom pathlib import Path-from machina.colors import console-from machina.config import load_config-from machina.platform_ import project_root-from machina.ports import kill_orphaned_machina_processes, kill_port+from cli.colors import console+from cli.config import load_config+from cli.platform_ import project_root+from cli.ports import kill_orphaned_machina_processes, kill_port# Removed each run -- order doesn't matter, ``shutil.rmtree`` is recursive.diff --git a/machina/commands/daemon.py b/cli/commands/daemon.pysimilarity index 96%rename from machina/commands/daemon.pyrename to cli/commands/daemon.pyindex be9a724e..281e7958 100644--- a/machina/commands/daemon.py+++ b/cli/commands/daemon.py@@ -21,9 +21,9 @@ from pathlib import Pathimport psutilimport typer-from machina.buildenv import venv_python-from machina.colors import console-from machina.platform_ import IS_WINDOWS, project_root+from cli.buildenv import venv_python+from cli.colors import console+from cli.platform_ import IS_WINDOWS, project_rootapp = typer.Typer(name="daemon",diff --git a/machina/commands/dev.py b/cli/commands/dev.pysimilarity index 90%rename from machina/commands/dev.pyrename to cli/commands/dev.pyindex e04e7379..255cc763 100644--- a/machina/commands/dev.py+++ b/cli/commands/dev.py@@ -19,13 +19,13 @@ from pathlib import Pathimport typer-from machina.colors import console-from machina.config import load_config-from machina.platform_ import platform_name, project_root-from machina.buildenv import validate_build-from machina.ports import kill_port-from machina.supervisor import Manager, ServiceSpec-from machina.commands._temporal_specs import temporal_specs+from cli.colors import console+from cli.config import load_config+from cli.platform_ import platform_name, project_root+from cli.buildenv import validate_build+from cli.ports import kill_port+from cli.supervisor import Manager, ServiceSpec+from cli.commands._temporal_specs import temporal_specsdef _has_vite(root: Path) -> bool:diff --git a/machina/commands/docs.py b/cli/commands/docs.pysimilarity index 98%rename from machina/commands/docs.pyrename to cli/commands/docs.pyindex 36e59b29..6749a782 100644--- a/machina/commands/docs.py+++ b/cli/commands/docs.py@@ -15,8 +15,8 @@ from pathlib import Pathimport typer-from machina.colors import console-from machina.platform_ import project_root+from cli.colors import console+from cli.platform_ import project_rootapp = typer.Typer(diff --git a/machina/commands/start.py b/cli/commands/start.pysimilarity index 92%rename from machina/commands/start.pyrename to cli/commands/start.pyindex 6afdf1ef..1f84bd65 100644--- a/machina/commands/start.py+++ b/cli/commands/start.py@@ -21,14 +21,14 @@ from pathlib import Pathimport typer-from machina.colors import console-from machina.config import load_config-from machina.platform_ import IS_WINDOWS, IS_WSL, platform_name, project_root-from machina.buildenv import validate_build, venv_python-from machina.ports import kill_port-from machina.run import which_argv-from machina.supervisor import Manager, RestartPolicy, ServiceSpec-from machina.commands._temporal_specs import temporal_specs+from cli.colors import console+from cli.config import load_config+from cli.platform_ import IS_WINDOWS, IS_WSL, platform_name, project_root+from cli.buildenv import validate_build, venv_python+from cli.ports import kill_port+from cli.run import which_argv+from cli.supervisor import Manager, RestartPolicy, ServiceSpec+from cli.commands._temporal_specs import temporal_specsdef _sqlalchemy_preflight(root: Path) -> None:diff --git a/machina/commands/stop.py b/cli/commands/stop.pysimilarity index 93%rename from machina/commands/stop.pyrename to cli/commands/stop.pyindex 8145ea34..19f5ed25 100644--- a/machina/commands/stop.py+++ b/cli/commands/stop.py@@ -11,10 +11,10 @@ import timeimport typer-from machina.colors import console-from machina.config import load_config-from machina.platform_ import platform_name, project_root-from machina.ports import (+from cli.colors import console+from cli.config import load_config+from cli.platform_ import platform_name, project_root+from cli.ports import (kill_by_pattern,kill_orphaned_machina_processes,kill_port,diff --git a/machina/commands/version.py b/cli/commands/version.pysimilarity index 96%rename from machina/commands/version.pyrename to cli/commands/version.pyindex 4e7fcd87..edcf0c2b 100644--- a/machina/commands/version.py+++ b/cli/commands/version.py@@ -13,9 +13,9 @@ from pathlib import Pathimport typer-from machina.colors import console-from machina.platform_ import project_root-from machina.run import capture+from cli.colors import console+from cli.platform_ import project_root+from cli.run import captureapp = typer.Typer(diff --git a/machina/config.py b/cli/config.pysimilarity index 98%rename from machina/config.pyrename to cli/config.pyindex 6cbd07c9..6506c78c 100644--- a/machina/config.py+++ b/cli/config.py@@ -13,7 +13,7 @@ from dataclasses import dataclassfrom functools import lru_cachefrom pathlib import Path-from machina.platform_ import project_root+from cli.platform_ import project_rootdef _load_env_file(path: Path) -> dict[str, str]:diff --git a/machina/platform_.py b/cli/platform_.pysimilarity index 100%rename from machina/platform_.pyrename to cli/platform_.pydiff --git a/machina/ports.py b/cli/ports.pysimilarity index 100%rename from machina/ports.pyrename to cli/ports.pydiff --git a/machina/pyproject.toml b/cli/pyproject.tomlsimilarity index 85%rename from machina/pyproject.tomlrename to cli/pyproject.tomlindex 007a3d7c..76971368 100644--- a/machina/pyproject.toml+++ b/cli/pyproject.toml@@ -9,7 +9,7 @@ dependencies = ["psutil>=6","anyio>=4","python-dotenv>=1",- # Required on Windows for the supervisor's Job Object (machina/tree.py).+ # Required on Windows for the supervisor's Job Object (cli/tree.py).# Without it, child processes survive abnormal supervisor exit (SIGKILL,# BSOD, console close) and accumulate as orphans across dev restarts.# Floor 308 is the first release shipping prebuilt wheels for Python 3.13.@@ -17,7 +17,7 @@ dependencies = [][project.scripts]-machina = "machina.cli:app"+machina = "cli.cli:app"[build-system]requires = ["setuptools>=68"]@@ -25,7 +25,7 @@ build-backend = "setuptools.build_meta"[tool.setuptools.packages.find]where = ["."]-include = ["machina*"]+include = ["cli*"]exclude = ["tests*"][tool.pytest.ini_options]diff --git a/machina/run.py b/cli/run.pysimilarity index 96%rename from machina/run.pyrename to cli/run.pyindex e322f1dd..f918429e 100644--- a/machina/run.py+++ b/cli/run.py@@ -1,4 +1,4 @@-"""Shared subprocess helpers used across ``machina.commands``.+"""Shared subprocess helpers used across ``cli.commands``.Two patterns covering ~95% of subprocess use in this CLI:@@ -23,7 +23,7 @@ from pathlib import Pathimport typer-from machina.colors import console+from cli.colors import consoledef which_argv(argv: list[str]) -> list[str]:diff --git a/machina/supervisor.py b/cli/supervisor.pysimilarity index 98%rename from machina/supervisor.pyrename to cli/supervisor.pyindex 291cb925..339e4c49 100644--- a/machina/supervisor.py+++ b/cli/supervisor.py@@ -30,10 +30,10 @@ from typing import Iterable, Optionalimport anyio-from machina.colors import emit, next_color-from machina.run import which_argv-from machina.tcp import wait_for_tcp_port-from machina.tree import add_to_job, kill_tree, new_session_kwargs+from cli.colors import emit, next_color+from cli.run import which_argv+from cli.tcp import wait_for_tcp_port+from cli.tree import add_to_job, kill_tree, new_session_kwargsclass RestartPolicy(enum.Enum):diff --git a/machina/tcp.py b/cli/tcp.pysimilarity index 100%rename from machina/tcp.pyrename to cli/tcp.pydiff --git a/machina/tests/__init__.py b/cli/tests/__init__.pysimilarity index 100%rename from machina/tests/__init__.pyrename to cli/tests/__init__.pydiff --git a/machina/tests/conftest.py b/cli/tests/conftest.pysimilarity index 88%rename from machina/tests/conftest.pyrename to cli/tests/conftest.pyindex 3be82659..ad169350 100644--- a/machina/tests/conftest.py+++ b/cli/tests/conftest.py@@ -17,7 +17,7 @@ working — pnpm resolves the new location.For files that don't live inside a workspace (``.github/workflows``,``scripts/install.js``), tests resolve via the ``root`` fixture which-points at ``machina.platform_.project_root()`` — the project's own+points at ``cli.platform_.project_root()`` — the project's owncanonical worktree-aware helper."""@@ -29,13 +29,13 @@ from pathlib import Pathimport pytest-from machina.platform_ import project_root-from machina.run import which_argv+from cli.platform_ import project_root+from cli.run import which_argv@pytest.fixture(scope="session")def root() -> Path:- """The project root, resolved via ``machina.platform_.project_root``."""+ """The project root, resolved via ``cli.platform_.project_root``."""return project_root()@@ -51,7 +51,7 @@ def workspace_members(root: Path) -> dict[str, Path]:Reference: https://pnpm.io/cli/list"""# which_argv resolves Windows .cmd / .bat shims via PATHEXT — the- # same helper machina.run uses everywhere else for the same reason.+ # same helper cli.run uses everywhere else for the same reason.argv = which_argv(["pnpm", "list", "--json", "--only-projects","--recursive", "--depth", "0"])try:diff --git a/machina/tests/test_build.py b/cli/tests/test_build.pysimilarity index 89%rename from machina/tests/test_build.pyrename to cli/tests/test_build.pyindex fc660d9b..cb89cfb9 100644--- a/machina/tests/test_build.py+++ b/cli/tests/test_build.py@@ -1,4 +1,4 @@-"""Smoke tests for ``machina.commands.build`` + ``machina.run`` shared helpers."""+"""Smoke tests for ``cli.commands.build`` + ``cli.run`` shared helpers."""from __future__ import annotations@@ -8,10 +8,10 @@ import pytestimport typerfrom machina import run as run_module-from machina.commands import build+from cli.commands import build-# --- shared helpers in machina.run -----------------------------------------+# --- shared helpers in cli.run -----------------------------------------def test_capture_returns_none_when_command_missing():with patch.object(run_module.subprocess, "run", side_effect=FileNotFoundError):diff --git a/machina/tests/test_build_compile_pipeline.py b/cli/tests/test_build_compile_pipeline.pysimilarity index 98%rename from machina/tests/test_build_compile_pipeline.pyrename to cli/tests/test_build_compile_pipeline.pyindex 9bb88cbf..27cdcd5a 100644--- a/machina/tests/test_build_compile_pipeline.py+++ b/cli/tests/test_build_compile_pipeline.py@@ -1,6 +1,6 @@"""Tests for the compile-pipeline additions to ``machina build``.-Covers the two new steps wired into ``machina.commands.build.build_command``:+Covers the two new steps wired into ``cli.commands.build.build_command``:- ``[3/6] Building Node.js sidecar`` -> ``pnpm --filter machinaos-nodejs-executor run build``- ``[5/6] Compiling Python bytecode`` -> ``uv run python -O -m compileall -q -j 0 ...``@@ -25,7 +25,7 @@ from pathlib import Pathfrom typing import Callablefrom unittest.mock import patch-from machina.commands import build+from cli.commands import build# ---------------------------------------------------------------------------@@ -47,7 +47,7 @@ def _run_build_capture_invocations(tmp_path: Path) -> list[dict]:"""Run ``build_command()`` with all external I/O mocked.Returns a list of dicts ``{"argv": [...], **kwargs}`` — one per call- to ``machina.run.run`` — in the order the orchestrator emitted them.+ to ``cli.run.run`` — in the order the orchestrator emitted them.Preserving kwargs lets tests assert ``check=False`` and ``cwd=...``."""_seed_edgymeow_binary(tmp_path)diff --git a/machina/tests/test_clean.py b/cli/tests/test_clean.pysimilarity index 92%rename from machina/tests/test_clean.pyrename to cli/tests/test_clean.pyindex 0b9fe467..ebb3814c 100644--- a/machina/tests/test_clean.py+++ b/cli/tests/test_clean.py@@ -1,11 +1,11 @@-"""Smoke tests for ``machina.commands.clean``."""+"""Smoke tests for ``cli.commands.clean``."""from __future__ import annotationsfrom pathlib import Pathfrom unittest.mock import patch-from machina.commands import clean+from cli.commands import cleandef test_targets_list_is_stable():diff --git a/machina/tests/test_cli.py b/cli/tests/test_cli.pysimilarity index 94%rename from machina/tests/test_cli.pyrename to cli/tests/test_cli.pyindex 6a4e58fb..13a7fd4f 100644--- a/machina/tests/test_cli.py+++ b/cli/tests/test_cli.py@@ -4,7 +4,7 @@ from __future__ import annotationsfrom typer.testing import CliRunner-from machina.cli import app+from cli.cli import apprunner = CliRunner()diff --git a/machina/tests/test_daemon.py b/cli/tests/test_daemon.pysimilarity index 92%rename from machina/tests/test_daemon.pyrename to cli/tests/test_daemon.pyindex b8e95f94..b20a5027 100644--- a/machina/tests/test_daemon.py+++ b/cli/tests/test_daemon.py@@ -1,4 +1,4 @@-"""Smoke tests for ``machina.commands.daemon``."""+"""Smoke tests for ``cli.commands.daemon``."""from __future__ import annotations@@ -9,10 +9,10 @@ from unittest.mock import MagicMock, patchimport psutilimport pytest-from machina.commands import daemon+from cli.commands import daemon-# venv-python discovery is now centralised in machina.buildenv; covered+# venv-python discovery is now centralised in cli.buildenv; covered# by tests/test_start.py (test_venv_python_finds_*).@@ -46,14 +46,14 @@ def test_read_pid_returns_none_when_file_missing(tmp_path: Path):def test_read_pid_returns_none_for_corrupt_pid_file(tmp_path: Path):- pid_file = tmp_path / "machina.pid"+ pid_file = tmp_path / "cli.pid"pid_file.write_text("not-a-number")with patch.object(daemon, "_PID_FILE", pid_file):assert daemon._read_pid() is Nonedef test_read_pid_returns_none_when_process_no_longer_exists(tmp_path: Path):- pid_file = tmp_path / "machina.pid"+ pid_file = tmp_path / "cli.pid"pid_file.write_text("999999")with patch.object(daemon, "_PID_FILE", pid_file), \patch.object(daemon.psutil, "pid_exists", return_value=False):@@ -61,7 +61,7 @@ def test_read_pid_returns_none_when_process_no_longer_exists(tmp_path: Path):def test_read_pid_returns_pid_when_alive(tmp_path: Path):- pid_file = tmp_path / "machina.pid"+ pid_file = tmp_path / "cli.pid"pid_file.write_text("1234\n")with patch.object(daemon, "_PID_FILE", pid_file), \patch.object(daemon.psutil, "pid_exists", return_value=True):@@ -97,7 +97,7 @@ def test_kill_tree_no_such_process_is_noop():def test_stop_command_clears_pid_file_when_not_running(tmp_path: Path):- pid_file = tmp_path / "machina.pid"+ pid_file = tmp_path / "cli.pid"pid_file.write_text("999999")with patch.object(daemon, "_PID_FILE", pid_file), \patch.object(daemon, "_read_pid", return_value=None):diff --git a/machina/tests/test_dev.py b/cli/tests/test_dev.pysimilarity index 95%rename from machina/tests/test_dev.pyrename to cli/tests/test_dev.pyindex 97b98071..c5390a10 100644--- a/machina/tests/test_dev.py+++ b/cli/tests/test_dev.py@@ -1,11 +1,11 @@-"""Smoke tests for ``machina.commands.dev``."""+"""Smoke tests for ``cli.commands.dev``."""from __future__ import annotationsfrom pathlib import Path-from machina.commands import dev-from machina.config import Config+from cli.commands import dev+from cli.config import Configdef _cfg() -> Config:diff --git a/machina/tests/test_docs.py b/cli/tests/test_docs.pysimilarity index 96%rename from machina/tests/test_docs.pyrename to cli/tests/test_docs.pyindex c7b7c4ef..68ca55d1 100644--- a/machina/tests/test_docs.py+++ b/cli/tests/test_docs.py@@ -1,10 +1,10 @@-"""Smoke tests for ``machina.commands.docs``."""+"""Smoke tests for ``cli.commands.docs``."""from __future__ import annotationsfrom pathlib import Path-from machina.commands import docs+from cli.commands import docsdef test_read_h1_extracts_first_h1(tmp_path: Path):diff --git a/machina/tests/test_ports.py b/cli/tests/test_ports.pysimilarity index 96%rename from machina/tests/test_ports.pyrename to cli/tests/test_ports.pyindex 9527581f..c6d7c7c3 100644--- a/machina/tests/test_ports.py+++ b/cli/tests/test_ports.py@@ -1,4 +1,4 @@-"""Unit tests for ``machina.ports``."""+"""Unit tests for ``cli.ports``."""from __future__ import annotationsdiff --git a/machina/tests/test_release_pipeline_config.py b/cli/tests/test_release_pipeline_config.pysimilarity index 99%rename from machina/tests/test_release_pipeline_config.pyrename to cli/tests/test_release_pipeline_config.pyindex 61aa6b81..21b28c93 100644--- a/machina/tests/test_release_pipeline_config.py+++ b/cli/tests/test_release_pipeline_config.py@@ -8,7 +8,7 @@ Reused infrastructure (no path strings duplicated across tests):``conftest.workspace_members`` → name → Path map from ``pnpm list````conftest.root`` → project_root() for top-level files- ``machina.commands.build.COMPILEALL_SOURCE_DIRS``+ ``cli.commands.build.COMPILEALL_SOURCE_DIRS``→ SSOT for the bytecode-compile pathlist shared with ``scripts/install.js````yaml`` (PyYAML, server dep) → structured workflow parsing@@ -32,7 +32,7 @@ from pathlib import Pathimport pytestimport yaml-from machina.commands import build+from cli.commands import build# ---------------------------------------------------------------------------diff --git a/machina/tests/test_start.py b/cli/tests/test_start.pysimilarity index 93%rename from machina/tests/test_start.pyrename to cli/tests/test_start.pyindex 90983cf3..b8e44584 100644--- a/machina/tests/test_start.py+++ b/cli/tests/test_start.py@@ -1,4 +1,4 @@-"""Smoke tests for ``machina.commands.start``."""+"""Smoke tests for ``cli.commands.start``."""from __future__ import annotations@@ -6,8 +6,8 @@ from pathlib import Pathfrom unittest.mock import patchfrom machina import buildenv-from machina.commands import start-from machina.config import Config+from cli.commands import start+from cli.config import Configdef _cfg() -> Config:diff --git a/machina/tests/test_supervisor.py b/cli/tests/test_supervisor.pysimilarity index 93%rename from machina/tests/test_supervisor.pyrename to cli/tests/test_supervisor.pyindex bb2a375b..fed95c28 100644--- a/machina/tests/test_supervisor.py+++ b/cli/tests/test_supervisor.py@@ -1,4 +1,4 @@-"""Unit tests for ``machina.supervisor``."""+"""Unit tests for ``cli.supervisor``."""from __future__ import annotations@@ -6,7 +6,7 @@ from collections import dequeimport pytest-from machina.supervisor import Manager, ServiceSpec, RestartPolicy, _full_env+from cli.supervisor import Manager, ServiceSpec, RestartPolicy, _full_envdef test_full_env_force_color_and_unbuffered():diff --git a/machina/tests/test_version.py b/cli/tests/test_version.pysimilarity index 93%rename from machina/tests/test_version.pyrename to cli/tests/test_version.pyindex f194dcf9..6eea0453 100644--- a/machina/tests/test_version.py+++ b/cli/tests/test_version.py@@ -1,4 +1,4 @@-"""Smoke tests for ``machina.commands.version``."""+"""Smoke tests for ``cli.commands.version``."""from __future__ import annotations@@ -9,7 +9,7 @@ from unittest.mock import patchimport pytestimport typer-from machina.commands import version+from cli.commands import versiondef test_tag_to_version_strips_v_prefix():diff --git a/machina/tree.py b/cli/tree.pysimilarity index 100%rename from machina/tree.pyrename to cli/tree.pydiff --git a/machina/commands/__init__.py b/machina/commands/__init__.pydeleted file mode 100644index 3d5571c8..00000000--- a/machina/commands/__init__.py+++ /dev/null@@ -1 +0,0 @@-"""``machina`` subcommand modules. Imported by ``machina.cli``."""diff --git a/package.json b/package.jsonindex 5d610ea2..cebe54d4 100644--- a/package.json+++ b/package.json@@ -36,9 +36,9 @@"bin/","scripts/","workflows/",- "machina/",- "!machina/tests/",- "!machina/**/__pycache__/",+ "cli/",+ "!cli/tests/",+ "!cli/**/__pycache__/","client/src/","client/public/","client/dist/",@@ -62,9 +62,9 @@"client"],"scripts": {- "start": "python -m machina start",- "dev": "python -m machina dev",- "start:temporal": "cross-env TEMPORAL_ENABLED=true python -m machina start",+ "start": "python -m cli start",+ "dev": "python -m cli dev",+ "start:temporal": "cross-env TEMPORAL_ENABLED=true python -m cli start","client:start": "cd client && npm run start","python:start": "cd server && uv run uvicorn main:app --host 127.0.0.1 --port 3010 --log-level warning","python:daemon": "cd server && uv run uvicorn main:app --host 0.0.0.0 --port 3010 --log-level warning",@@ -72,23 +72,23 @@"temporal:stop": "temporal stop","temporal:status": "temporal status","temporal:worker": "cd server && uv run python -m services.temporal.worker",- "build": "python -m machina build",- "clean": "python -m machina clean",- "stop": "python -m machina stop",+ "build": "python -m cli build",+ "clean": "python -m cli clean",+ "stop": "python -m cli stop","test": "npm run test:backend && npm run test:frontend","test:backend": "cd server && uv run pytest tests/ -v","test:frontend": "cd client && npm run test","test:nodes": "cd server && uv run pytest tests/nodes/ -v --cov=services.handlers --cov-report=term-missing",- "docs:nodes": "python -m machina docs nodes",- "docs:nodes:check": "python -m machina docs nodes --check",+ "docs:nodes": "python -m cli docs nodes",+ "docs:nodes:check": "python -m cli docs nodes --check","deploy": "bash deploy.sh","deploy:gcp": "bash deploy.sh",- "daemon:start": "python -m machina daemon start",- "daemon:stop": "python -m machina daemon stop",- "daemon:status": "python -m machina daemon status",- "daemon:restart": "python -m machina daemon restart",- "version:sync": "python -m machina version sync",- "prepublishOnly": "python -m machina version sync && node -e \"const p=require('./package.json'); if(!p.bin||!p.version){process.exit(1)}\"",+ "daemon:start": "python -m cli daemon start",+ "daemon:stop": "python -m cli daemon stop",+ "daemon:status": "python -m cli daemon status",+ "daemon:restart": "python -m cli daemon restart",+ "version:sync": "python -m cli version sync",+ "prepublishOnly": "python -m cli version sync && node -e \"const p=require('./package.json'); if(!p.bin||!p.version){process.exit(1)}\"","preinstall": "node scripts/preinstall.js","postinstall": "node scripts/postinstall.js","preuninstall": "node scripts/preinstall.js"diff --git a/pyproject.toml b/pyproject.tomlindex 58c5b72e..52632672 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -11,11 +11,11 @@ dependencies = [][project.scripts]-machina = "machina.cli:app"+machina = "cli.cli:app"[build-system]requires = ["hatchling"]build-backend = "hatchling.build"[tool.hatch.build.targets.wheel]-packages = ["machina"]+packages = ["cli"]diff --git a/scripts/postinstall.js b/scripts/postinstall.jsindex cf6e346d..a25df444 100755--- a/scripts/postinstall.js+++ b/scripts/postinstall.js@@ -82,28 +82,30 @@ async function main() {console.log('Installing dependencies...');await runScript(resolve(__dirname, 'install.js'));- // Note: we deliberately do NOT `pip install -e ./machina` here. An+ // Note: we deliberately do NOT `pip install -e ./cli` here. An// editable install creates a `Scripts/machina.exe` (or- // `bin/machina`) entry-point that imports `machina.cli` from the+ // `bin/machina`) entry-point that imports `cli.cli` from the// package's npm install directory. When npm later moves, prunes,// or upgrades that directory, the shim survives but its target// disappears -- the user runs `machina start` and gets- // `ModuleNotFoundError: No module named 'machina'`. The same+ // `ModuleNotFoundError: No module named 'cli'`. The same// shim also wins PATH precedence over the npm bin shim at// bin/cli.js, masking the real entry point.//- // Both call sites that need the Python CLI use `python -m machina+ // Both call sites that need the Python CLI use `python -m cli// <cmd>` (npm run start, .github/workflows/release.yml version// sync). `-m` resolves the package from the working directory's// sys.path entry, which `bin/cli.js` already pins to the npm// package root via `cwd: ROOT`. No pip install required.// Detect a stale `Scripts/machina.exe` (or `bin/machina`) left- // behind by a prior version's `pip install -e ./machina`. If pip- // shows the package installed but the current `machina` on PATH- // is NOT our Node shim, surface the cleanup command -- otherwise- // the user keeps hitting the dead Python entry-point even after- // upgrading.+ // behind by a prior version's `pip install -e ./machina` (the dir+ // was renamed from `machina/` to `cli/`; pip's metadata can lag).+ // The pip distribution name is still ``machina`` (the public CLI+ // name); the source dir is ``cli/``. If pip shows the package+ // installed but the current `machina` on PATH is NOT our Node+ // shim, surface the cleanup command -- otherwise the user keeps+ // hitting the dead Python entry-point even after upgrading.try {const pipShow = execSync('python -m pip show machina 2>nul || python3 -m pip show machina 2>/dev/null', {encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'], shell: true,diff --git a/server/services/temporal/_runtime.py b/server/services/temporal/_runtime.pyindex 824ea5b4..4f8129f1 100644--- a/server/services/temporal/_runtime.py+++ b/server/services/temporal/_runtime.py@@ -35,7 +35,7 @@ logger = get_logger(__name__)_PG_DEFAULT_PORT = 5432# How long each TCP-readiness probe waits per attempt. Mirrors-# ``machina.tcp.probe_tcp_port``'s semantics inside the server-side+# ``cli.tcp.probe_tcp_port``'s semantics inside the server-side# supervisor — sub-second so a stalled subprocess fails health fast._PROBE_TIMEOUT_SECONDS = 1.0@@ -44,8 +44,8 @@ async def _probe_tcp_port(port: int, host: str = "127.0.0.1") -> bool:"""Return ``True`` iff a TCP connection to ``host:port`` succeedswithin :data:`_PROBE_TIMEOUT_SECONDS`. Loopback-friendly readinesscheck used by both runtimes' ``health_check`` overrides. Mirrors- :func:`machina.tcp.probe_tcp_port` but keeps server-side modules- independent of the ``machina`` CLI package."""+ :func:`cli.tcp.probe_tcp_port` but keeps server-side modules+ independent of the ``cli`` CLI package."""try:_, writer = await asyncio.wait_for(asyncio.open_connection(host, port),diff --git a/server/tests/test_admin_handlers.py b/server/tests/test_admin_handlers.pyindex f3334847..bca72356 100644--- a/server/tests/test_admin_handlers.py+++ b/server/tests/test_admin_handlers.py@@ -24,12 +24,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp# ---------------------------------------------------------------------------diff --git a/server/tests/test_canary_registry.py b/server/tests/test_canary_registry.pyindex 950689b1..25df0a5a 100644--- a/server/tests/test_canary_registry.py+++ b/server/tests/test_canary_registry.py@@ -29,12 +29,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp@pytest.fixturediff --git a/server/tests/test_chat_trigger_canary_producer.py b/server/tests/test_chat_trigger_canary_producer.pyindex f2d81436..1a3da1da 100644--- a/server/tests/test_chat_trigger_canary_producer.py+++ b/server/tests/test_chat_trigger_canary_producer.py@@ -26,12 +26,12 @@ import pytest# Stub `machina` namespace.if "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp_EVENT_WAITER_DISPATCH_PATTERN = re.compile(r"event_waiter\.dispatch\s*\(")diff --git a/server/tests/test_cron_canary.py b/server/tests/test_cron_canary.pyindex f5efc61f..9ce78265 100644--- a/server/tests/test_cron_canary.py+++ b/server/tests/test_cron_canary.py@@ -33,12 +33,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp@pytest.fixturediff --git a/server/tests/test_deployment_canary_listener.py b/server/tests/test_deployment_canary_listener.pyindex 50105488..3014c7ca 100644--- a/server/tests/test_deployment_canary_listener.py+++ b/server/tests/test_deployment_canary_listener.py@@ -34,12 +34,12 @@ import pytest# Stub `machina` namespace — same pattern as other event-framework tests.if "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp@pytest.fixturediff --git a/server/tests/test_event_framework_phase_a.py b/server/tests/test_event_framework_phase_a.pyindex d6ee659b..01d9b5c5 100644--- a/server/tests/test_event_framework_phase_a.py+++ b/server/tests/test_event_framework_phase_a.py@@ -37,16 +37,16 @@ from unittest.mock import MagicMockimport pytest# Stub the `machina` package (lives at project root, outside server/) so-# `services.temporal.__init__` → `_runtime.py` → `from machina.tcp import+# `services.temporal.__init__` → `_runtime.py` → `from cli.tcp import# probe_tcp_port` doesn't crash collection. Conftest stubs core.* but# not machina.*.if "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcpfrom core.config import Settingsfrom services.events.envelope import WorkflowEventdiff --git a/server/tests/test_polling_trigger_workflow.py b/server/tests/test_polling_trigger_workflow.pyindex 7082baa6..58438210 100644--- a/server/tests/test_polling_trigger_workflow.py+++ b/server/tests/test_polling_trigger_workflow.py@@ -41,12 +41,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp@pytest.fixture(autouse=True)diff --git a/server/tests/test_retry_policies.py b/server/tests/test_retry_policies.pyindex 0c08f67b..51c87a90 100644--- a/server/tests/test_retry_policies.py+++ b/server/tests/test_retry_policies.py@@ -33,12 +33,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcpclass TestRetryPolicyConstants:diff --git a/server/tests/test_service_factories.py b/server/tests/test_service_factories.pyindex 92f55016..c4b78488 100644--- a/server/tests/test_service_factories.py+++ b/server/tests/test_service_factories.py@@ -27,12 +27,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp@pytest.fixturediff --git a/server/tests/test_shutdown_hooks.py b/server/tests/test_shutdown_hooks.pyindex a6821803..b8de77f8 100644--- a/server/tests/test_shutdown_hooks.py+++ b/server/tests/test_shutdown_hooks.py@@ -32,12 +32,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp@pytest.fixturediff --git a/server/tests/test_social_provider_registry.py b/server/tests/test_social_provider_registry.pyindex 77ad5354..d5ad1e97 100644--- a/server/tests/test_social_provider_registry.py+++ b/server/tests/test_social_provider_registry.py@@ -29,12 +29,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp@pytest.fixturediff --git a/server/tests/test_task_trigger_canary_producer.py b/server/tests/test_task_trigger_canary_producer.pyindex ba409dec..85fec1e1 100644--- a/server/tests/test_task_trigger_canary_producer.py+++ b/server/tests/test_task_trigger_canary_producer.py@@ -25,12 +25,12 @@ from unittest.mock import AsyncMock, MagicMockimport pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp_SEND_CUSTOM_EVENT_PATTERN = re.compile(r"send_custom_event\s*\(")diff --git a/server/tests/test_telegram_trigger_canary_producer.py b/server/tests/test_telegram_trigger_canary_producer.pyindex f0ad65ff..2d5bf133 100644--- a/server/tests/test_telegram_trigger_canary_producer.py+++ b/server/tests/test_telegram_trigger_canary_producer.py@@ -25,12 +25,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp_EVENT_WAITER_DISPATCH_PATTERN = re.compile(r"event_waiter\.dispatch\s*\(")diff --git a/server/tests/test_trigger_listener_workflow.py b/server/tests/test_trigger_listener_workflow.pyindex c134af54..8095fbdb 100644--- a/server/tests/test_trigger_listener_workflow.py+++ b/server/tests/test_trigger_listener_workflow.py@@ -31,15 +31,15 @@ from unittest.mock import AsyncMock, MagicMockimport pytest# Stub the `machina` package (lives at project root, outside server/) so-# services.temporal.__init__ → _runtime.py → from machina.tcp import+# services.temporal.__init__ → _runtime.py → from cli.tcp import# probe_tcp_port doesn't crash collection.if "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp@pytest.fixture(autouse=True)diff --git a/server/tests/test_whatsapp_trigger_canary_producer.py b/server/tests/test_whatsapp_trigger_canary_producer.pyindex 8c7d4106..2fdaeb1c 100644--- a/server/tests/test_whatsapp_trigger_canary_producer.py+++ b/server/tests/test_whatsapp_trigger_canary_producer.py@@ -26,12 +26,12 @@ import pytestif "machina" not in sys.modules:- _machina = types.ModuleType("machina")+ _machina = types.ModuleType("cli")_machina.__path__ = []- sys.modules["machina"] = _machina- _machina_tcp = types.ModuleType("machina.tcp")+ sys.modules["cli"] = _machina+ _machina_tcp = types.ModuleType("cli.tcp")_machina_tcp.probe_tcp_port = MagicMock(return_value=False)- sys.modules["machina.tcp"] = _machina_tcp+ sys.modules["cli.tcp"] = _machina_tcp_EVENTS_EMIT_PATTERN = re.compile(r"\bemit\s*\(")