Files
AirPlan-V2/lib/air_runtime/modes/xdb_sdb_ndb_modes.py
AirPlan Team 2c4b3340bf AirPlan V2 initial release — unified scheduler with 12 sub-modes
Merges 8 V1 plugins into 1 unified plugin, adds 4 new components (dep, tst, sec, rvr).
12 sub-modes: arc, eng, do, dbg, xdb, sdb, ndb, ctx, dep, tst, sec, rvr.
L1 code-level guarantees: atomic writes, file locks, evidence gating, forced debug routing,
3-phase arc gate, evidence-first debug gate, Chinese language lock, scheduler boundary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 16:24:26 +08:00

98 lines
3.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""AirXDB mode — V2 GUI调试器AirSDB mode — V2 静态分析AirNDB mode — V2 网络调试。"""
# --- AirXDB ---
from __future__ import annotations
import json
from pathlib import Path
from air_runtime.io import atomic_json_write
from air_runtime.paths import airplan_root
from air_runtime.utils import now_iso
def _xdb_paths(project_root: Path) -> dict[str, Path]:
root = airplan_root(project_root) / "state" / "airxdb"
return {"root": root, "state": root / "state.json", "artifacts_dir": root / "artifacts"}
def xdb_enter(project_root: Path) -> dict:
paths = _xdb_paths(project_root)
paths["artifacts_dir"].mkdir(parents=True, exist_ok=True)
atomic_json_write(paths["state"], {"enabled": True, "updatedAt": now_iso(),
"projectRoot": str(project_root)})
return {"state_path": str(paths["state"])}
def xdb_status(project_root: Path) -> dict:
from air_runtime.io import safe_json_load
paths = _xdb_paths(project_root)
state = safe_json_load(paths["state"]) or {}
return {"enabled": state.get("enabled", False)}
def xdb_main(args) -> None:
project_root = Path(args.project).expanduser().resolve()
sub = args.sub or "status"
if sub == "enter":
result = xdb_enter(project_root)
print(f"airplan_mode=xdb\nstate_path={result['state_path']}")
else:
s = xdb_status(project_root)
print(f"airplan_mode=xdb\nenabled={s['enabled']}")
# --- AirSDB ---
def _sdb_paths(project_root: Path) -> dict[str, Path]:
root = airplan_root(project_root) / "state" / "airsdb"
return {"root": root, "state": root / "state.json", "reports_dir": root / "reports"}
def sdb_enter(project_root: Path) -> dict:
paths = _sdb_paths(project_root)
paths["reports_dir"].mkdir(parents=True, exist_ok=True)
atomic_json_write(paths["state"], {"enabled": True, "updatedAt": now_iso()})
return {"state_path": str(paths["state"])}
def sdb_main(args) -> None:
project_root = Path(args.project).expanduser().resolve()
sub = args.sub or "status"
from air_runtime.io import safe_json_load
paths = _sdb_paths(project_root)
if sub == "enter":
result = sdb_enter(project_root)
print(f"airplan_mode=sdb\nstate_path={result['state_path']}")
else:
state = safe_json_load(paths["state"]) or {}
print(f"airplan_mode=sdb\nenabled={state.get('enabled', False)}")
# --- AirNDB ---
def _ndb_paths(project_root: Path) -> dict[str, Path]:
root = airplan_root(project_root) / "state" / "airndb"
return {"root": root, "state": root / "state.json", "captures_dir": root / "captures"}
def ndb_enter(project_root: Path) -> dict:
paths = _ndb_paths(project_root)
paths["captures_dir"].mkdir(parents=True, exist_ok=True)
atomic_json_write(paths["state"], {"enabled": True, "updatedAt": now_iso()})
return {"state_path": str(paths["state"])}
def ndb_main(args) -> None:
project_root = Path(args.project).expanduser().resolve()
sub = args.sub or "status"
from air_runtime.io import safe_json_load
paths = _ndb_paths(project_root)
if sub == "enter":
result = ndb_enter(project_root)
print(f"airplan_mode=ndb\nstate_path={result['state_path']}")
else:
state = safe_json_load(paths["state"]) or {}
print(f"airplan_mode=ndb\nenabled={state.get('enabled', False)}")