aman/src/aman_maint.py
Thales Maciel 4d0081d1d0 Split aman.py into focused CLI and runtime modules
Break the old god module into flat siblings for CLI parsing, run lifecycle, daemon state, shared processing helpers, benchmark tooling, and maintainer-only model sync so changes stop sharing one giant import graph.

Keep aman as a thin shim over aman_cli, move sync-default-model behind the hidden aman-maint entrypoint plus Make wrappers, and update packaging metadata plus maintainer docs to reflect the new surface.

Retarget the tests to the new seams with dedicated runtime, run, benchmark, maintainer, and entrypoint suites, and verify with python3 -m unittest discover -s tests -p "test_*.py", python3 -m py_compile src/*.py tests/*.py, PYTHONPATH=src python3 -m aman --help, PYTHONPATH=src python3 -m aman version, and PYTHONPATH=src python3 -m aman_maint --help.
2026-03-14 14:54:57 -03:00

70 lines
2 KiB
Python

from __future__ import annotations
import argparse
import logging
import sys
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description="Maintainer commands for Aman release and packaging workflows."
)
subparsers = parser.add_subparsers(dest="command")
subparsers.required = True
sync_model_parser = subparsers.add_parser(
"sync-default-model",
help="sync managed editor model constants with benchmark winner report",
)
sync_model_parser.add_argument(
"--report",
default="benchmarks/results/latest.json",
help="path to winner report JSON",
)
sync_model_parser.add_argument(
"--artifacts",
default="benchmarks/model_artifacts.json",
help="path to model artifact registry JSON",
)
sync_model_parser.add_argument(
"--constants",
default="src/constants.py",
help="path to constants module to update/check",
)
sync_model_parser.add_argument(
"--check",
action="store_true",
help="check only; exit non-zero if constants do not match winner",
)
sync_model_parser.add_argument(
"--json",
action="store_true",
help="print JSON summary output",
)
return parser
def parse_args(argv: list[str]) -> argparse.Namespace:
return build_parser().parse_args(argv)
def _configure_logging() -> None:
logging.basicConfig(
stream=sys.stderr,
level=logging.INFO,
format="aman: %(asctime)s %(levelname)s %(message)s",
)
def main(argv: list[str] | None = None) -> int:
args = parse_args(list(argv) if argv is not None else sys.argv[1:])
_configure_logging()
if args.command == "sync-default-model":
from aman_model_sync import sync_default_model_command
return sync_default_model_command(args)
raise RuntimeError(f"unsupported maintainer command: {args.command}")
if __name__ == "__main__":
raise SystemExit(main())