← Files Computable Systems EngineeringARCHIVED FILE

skills/develop-conops/scripts/cse.py

2.06 KB · Dec 3, 2026 · 18:30 UTC

↓ Download file

#!/usr/bin/env python3
"""Run the shared CSE engine from the complete repository or plugin package."""

import argparse
import json
import os
from pathlib import Path
import subprocess
import sys

ROOT = Path(__file__).resolve().parents[3]
COMMANDS = {
    "check": "sysml.py",
    "testgen": "sysml_testgen.py",
    "view": "sysml_view.py",
    "sampled-trace": "sampled_trace.py",
    "diff": "sysml_diff.py",
    "concept-review": "concept_review.py",
    "configuration-review": "configuration.py",
    "question": "question.py",
    "terminology": "terminology.py",
    "prototype-review": "prototype_review.py",
    "prototype-demo": "prototype_demo.py",
    "analyze": "analyze.py",
    "finite": "verify.py",
    "install-parser": "install_sysml_parser.py",
}


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("command", choices=(*COMMANDS, "runtime"))
    parser.add_argument("arguments", nargs=argparse.REMAINDER)
    args = parser.parse_args()
    if not (ROOT / "verifier/sysml.py").is_file() or not (ROOT / "tools/sysml/SysmlBridge.java").is_file():
        print("The shared CSE runtime is missing. Use the complete repository or plugin package; "
              "copying a skill folder alone does not install "
              "the SysML checker.", file=sys.stderr)
        return 2
    if args.command == "runtime":
        print(json.dumps({"runtime_root": str(ROOT),
                          "profile": str(ROOT / "docs/sysml-v2-profile.md"),
                          "sysml_cache": str(Path(os.environ.get("CSE_SYSML_CACHE", ROOT / ".cache/sysml")).expanduser().resolve())}, sort_keys=True))
        return 0
    # Keep the caller's working directory: user model paths are not runtime paths.
    try:
        return subprocess.run([sys.executable, "-B", str(ROOT / "scripts" / COMMANDS[args.command]),
                               *args.arguments], check=False).returncode
    except OSError as exc:
        print(f"Cannot run the CSE engine: {exc}", file=sys.stderr)
        return 2


if __name__ == "__main__":
    raise SystemExit(main())

SHA-256: 35a89728eb0fd9b5557f161c03822bfe6a9467afe6dd38ce742dcca6e7edae4c