morpheus-rag / scripts /index_codebase_graph.py
nothex
Add hybrid graph substrate and deterministic code graph indexing
bf54e37
"""Index a local Python codebase into Morpheus' DB-backed graph."""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from backend.core.code_graph import index_python_codebase # noqa: E402
def main() -> int:
parser = argparse.ArgumentParser(description="Index a local Python codebase into Morpheus graph storage.")
parser.add_argument("--root", required=True, help="Root directory of the Python codebase.")
parser.add_argument("--label", default=None, help="Optional display label for the indexed codebase.")
parser.add_argument("--access-token", default=None, help="Tenant JWT for writing tenant-scoped graph data.")
parser.add_argument("--user-id", default=None, help="Explicit user UUID for local admin indexing.")
args = parser.parse_args()
result = index_python_codebase(
args.root,
access_token=args.access_token,
user_id=args.user_id,
label=args.label,
)
print(json.dumps(result, indent=2))
return 0
if __name__ == "__main__":
raise SystemExit(main())