diff --git a/gate.py b/gate.py index 6a25135..2636493 100644 --- a/gate.py +++ b/gate.py @@ -333,3 +333,24 @@ async def health(): index_ready=retriever is not None, graph_ready=compiled_graph is not None ) + + +def main() -> None: + """Console entry point for ``cyclaw-server`` (see pyproject [project.scripts]). + + Serves the FastAPI app on the loopback host/port from config.yaml. Without + this, the declared ``cyclaw-server = "gate:main"`` script raised + AttributeError because no ``main`` symbol existed in this module. + """ + import uvicorn + + api_cfg = cfg.get("api", {}) + uvicorn.run( + app, + host=api_cfg.get("host", "127.0.0.1"), # DevSkim: ignore DS162092 - loopback-only binding by design + port=api_cfg.get("port", 8787), + ) + + +if __name__ == "__main__": + main() diff --git a/metrics.py b/metrics.py index fc97f10..565c2cf 100644 --- a/metrics.py +++ b/metrics.py @@ -45,5 +45,15 @@ def print_metrics(config_path: str = "config.yaml"): for mode, count in mode_counts.most_common(): print(f" {mode}: {count}") -if __name__ == "__main__": +def main() -> None: + """Console entry point for ``cyclaw-metrics`` (see pyproject [project.scripts]). + + Thin wrapper over :func:`print_metrics`. The declared + ``cyclaw-metrics = "metrics:main"`` script previously raised AttributeError + because this module only defined ``print_metrics``, not ``main``. + """ print_metrics() + + +if __name__ == "__main__": + main() diff --git a/retrieval/indexer.py b/retrieval/indexer.py index b537d30..a0c0f20 100644 --- a/retrieval/indexer.py +++ b/retrieval/indexer.py @@ -132,5 +132,15 @@ def build_index(config_path: str = "config.yaml") -> None: print(f"[Indexer] Done. ChromaDB: {chroma_path}, BM25: {bm25_path}") -if __name__ == "__main__": +def main() -> None: + """Console entry point for ``cyclaw-index`` (see pyproject [project.scripts]). + + Thin wrapper over :func:`build_index`. The declared + ``cyclaw-index = "retrieval.indexer:main"`` script previously raised + AttributeError because this module only defined ``build_index``. + """ build_index() + + +if __name__ == "__main__": + main()