Skip to content

Self-improving AI Employees for everyone

fix(clean): preserve .machina/packages/ -- stop re-downloading binaries

trohitg0beac87c9515
diff --git a/cli/commands/clean.py b/cli/commands/clean.py
index 087f8610..dd3117f9 100644
--- a/cli/commands/clean.py
+++ b/cli/commands/clean.py
@@ -48,10 +48,15 @@ _TARGETS = [
# holds ``machina deploy``'s Terraform working dirs + state files:
# deleting state for LIVE cloud resources orphans the VM/firewall
# (``machina deploy destroy`` could no longer find them) -- only
-# ``deploy destroy`` removes that tree. Anything else under
-# ``.machina/`` (claude state, workspaces, credentials.db, ...) is
-# transient runtime state and is fair game.
-_MACHINA_KEEP = frozenset({"workflows", "deploy"})
+# ``deploy destroy`` removes that tree. ``packages/`` holds the
+# MachinaOs-managed binaries (Temporal CLI ~114 MB, Stripe CLI, the
+# shared npm tree with claude/agent-browser/edgymeow): all of it is
+# re-fetchable but expensive -- wiping it forced a full Temporal
+# re-download on every clean+build cycle, which hard-fails ``machina
+# build`` on slow links. Anything else under ``.machina/`` (claude
+# state, workspaces, credentials.db, ...) is transient runtime state
+# and is fair game.
+_MACHINA_KEEP = frozenset({"workflows", "deploy", "packages"})
def _rmtree_with_retry(path: Path, *, attempts: int = 3, delay: float = 0.1) -> bool:
diff --git a/cli/tests/test_clean.py b/cli/tests/test_clean.py
index a14884bf..471234e0 100644
--- a/cli/tests/test_clean.py
+++ b/cli/tests/test_clean.py
@@ -20,13 +20,16 @@ def test_targets_list_is_stable():
]
-def test_machina_keep_preserves_workflows_and_deploy_state():
- """``workflows/`` (shipped example seeds) and ``deploy/`` (``machina
+def test_machina_keep_preserves_workflows_deploy_and_packages():
+ """``workflows/`` (shipped example seeds), ``deploy/`` (``machina
deploy``'s Terraform working dirs + state for LIVE cloud resources —
wiping it orphans the VM/firewall; only ``deploy destroy`` removes it)
- live under ``.machina/``; ``clean`` must never wipe either. Pin the
+ and ``packages/`` (MachinaOs-managed binaries: Temporal CLI ~114 MB,
+ Stripe CLI, shared npm tree — re-fetchable but expensive; wiping it
+ forced a full Temporal re-download on every clean+build cycle) live
+ under ``.machina/``; ``clean`` must never wipe any of them. Pin the
keep list so accidental additions/removals surface in review."""
- assert clean._MACHINA_KEEP == frozenset({"workflows", "deploy"})
+ assert clean._MACHINA_KEEP == frozenset({"workflows", "deploy", "packages"})
def test_rmtree_with_retry_handles_oserror(tmp_path: Path):