#!/usr/bin/env python3 """Backend for /aircontext-pause [on|off].""" from __future__ import annotations import os import sys from pathlib import Path _HERE = Path(__file__).resolve().parent sys.path.insert(0, str(_HERE)) from core.state import StateFile # noqa: E402 def main() -> int: project = Path(os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd())) air = project / "AirContext" if not air.exists(): print("AirContext not initialised. Run /aircontext-init first.") return 1 state = StateFile(air / "state.json") arg = (sys.argv[1].lower() if len(sys.argv) > 1 else "").strip() cur = bool(state.read().get("paused")) if arg in ("on", "pause", "true", "1"): new = True elif arg in ("off", "resume", "false", "0"): new = False else: new = not cur # toggle state.update(paused=new) print(f"AirContext automatic compaction: {'PAUSED' if new else 'ACTIVE'}") return 0 if __name__ == "__main__": sys.exit(main())