Initial release: airdo

This commit is contained in:
admin
2026-05-18 11:45:00 +08:00
commit 5e1684b73f
5 changed files with 210 additions and 0 deletions

80
scripts/airdo_mode.py Normal file
View File

@@ -0,0 +1,80 @@
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import sys
from pathlib import Path
def _add_lib_path() -> None:
root = Path(__file__).resolve().parents[3]
lib_path = root / "lib"
if str(lib_path) not in sys.path:
sys.path.insert(0, str(lib_path))
_add_lib_path()
from air_runtime.worker import enter_worker, finish_worker, handoff_worker, status_worker
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="AirDo public worker runtime")
parser.add_argument("--mode", choices=["enter", "status", "handoff", "finish"], default="status")
parser.add_argument("--project", default=".")
parser.add_argument("--task-id", default="")
parser.add_argument("--result", default="")
return parser.parse_args()
def main() -> None:
args = parse_args()
project_root = Path(args.project).expanduser().resolve()
if args.mode == "status":
status = status_worker(project_root)
print(f"airdo_mode={'enabled' if status['enabled'] else 'disabled'}")
print(f"project_root={project_root}")
print(f"active_task_id={status['activeTaskId']}")
print(f"known_tasks={','.join(status['taskIds'])}")
for key, value in status["artifactHealth"].items():
print(f"{key}={'ok' if value else 'missing'}")
return
if not args.task_id:
raise SystemExit("--task-id is required for enter, handoff, and finish modes")
if args.mode == "enter":
result = enter_worker(project_root, args.task_id)
print("airdo_mode=entered")
print(f"project_root={project_root}")
print(f"task_id={result['taskId']}")
print(f"brief_path={result['briefPath']}")
print(f"handoff_path={result['handoffPath']}")
print(f"result_path={result['resultPath']}")
print(f"worker_state_path={result['workerStatePath']}")
return
if args.mode == "handoff":
result = handoff_worker(project_root, args.task_id)
print("airdo_mode=handoff-ready")
print(f"project_root={project_root}")
print(f"task_id={result['taskId']}")
print(f"brief_path={result['briefPath']}")
print(f"handoff_path={result['handoffPath']}")
print(f"result_path={result['resultPath']}")
print(f"worker_state_path={result['workerStatePath']}")
return
result_path = Path(args.result).expanduser().resolve() if args.result else None
finalized = finish_worker(project_root, args.task_id, result_path)
print("airdo_mode=finished")
print(f"project_root={project_root}")
print(f"task_id={finalized['taskId']}")
print(f"task_status={finalized['status']}")
print(f"finalized_result_path={finalized['finalizedResultPath']}")
print(f"worker_state_path={finalized['workerStatePath']}")
if __name__ == "__main__":
main()