Includes AirPlan design documents, AircOding-alpha1-plan, AirPlanV2, AirPlan-ParaV2, AirPlan-Para V1 reference docs, and all working code changes across packages. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
58 lines
1.9 KiB
Python
Executable File
58 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Backend for /aircontext-status."""
|
|
from __future__ import annotations
|
|
import json
|
|
import os
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
_HERE = Path(__file__).resolve().parent
|
|
sys.path.insert(0, str(_HERE))
|
|
|
|
from core.config_loader import load_config, validate_config # noqa: E402
|
|
from core.state import StateFile # noqa: E402
|
|
|
|
|
|
def main() -> int:
|
|
project = Path(os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd()))
|
|
air = project / "AirContext"
|
|
cfg_path = air / "config.yaml"
|
|
print(f"Project root: {project}")
|
|
print(f"AirContext dir: {air} {'(present)' if air.exists() else '(MISSING)'}")
|
|
if not cfg_path.exists():
|
|
print("Status: not initialised. Run /aircontext-init.")
|
|
return 0
|
|
err = validate_config(cfg_path)
|
|
if err:
|
|
print(f"Config: invalid — {err}")
|
|
else:
|
|
cfg = load_config(cfg_path)
|
|
b = cfg.get("backend", {})
|
|
t = cfg.get("trigger", {})
|
|
print(f"Backend: {b.get('endpoint')} (model={b.get('model')})")
|
|
print(
|
|
f"Trigger: strategy={t.get('strategy')} "
|
|
f"threshold={t.get('threshold')} window={t.get('model_context_window')}"
|
|
)
|
|
|
|
state = StateFile(air / "state.json").read()
|
|
print(f"Paused: {state.get('paused')}")
|
|
print(f"Compacting now: {state.get('compaction_in_progress')}")
|
|
print(f"Ready to apply: {state.get('compaction_ready')}")
|
|
last = state.get("last_compaction_unix") or 0
|
|
if last:
|
|
ago = int(time.time() - last)
|
|
print(f"Last compaction: {ago}s ago")
|
|
else:
|
|
print("Last compaction: never")
|
|
snapshots = air / "snapshots"
|
|
if snapshots.exists():
|
|
files = [p for p in snapshots.iterdir() if p.suffix == ".jsonl"]
|
|
print(f"Snapshots: {len(files)} stored under {snapshots}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|