Files
temp/robot/helper_skill_schema.py

56 lines
1.5 KiB
Python

"""Robot Framework helper for skill YAML schema validation.
Provides a CLI-style interface for Robot to invoke schema validation
on skill YAML files. Exit code 0 = success, 1 = failure.
Usage:
python robot/helper_skill_schema.py validate <yaml_file>
python robot/helper_skill_schema.py validate-invalid <yaml_file>
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC = str(Path(__file__).resolve().parents[1] / "src")
if _SRC not in sys.path:
sys.path.insert(0, _SRC)
from cleveragents.skills.schema import SkillConfigSchema # noqa: E402
def main() -> int:
"""Entry point called by Robot Framework ``Run Process``."""
if len(sys.argv) < 3:
print("Usage: helper_skill_schema.py <validate|validate-invalid> <file>")
return 1
command = sys.argv[1]
yaml_path = sys.argv[2]
if command == "validate":
try:
config = SkillConfigSchema.from_yaml_file(yaml_path)
print(f"skill-schema-ok: {config.name}")
return 0
except Exception as exc:
print(f"skill-schema-fail: {exc}")
return 1
if command == "validate-invalid":
try:
SkillConfigSchema.from_yaml_file(yaml_path)
print("skill-schema-unexpected-success")
return 1
except Exception as exc:
print(f"skill-schema-expected-fail: {exc}")
return 0
print(f"Unknown command: {command}")
return 1
if __name__ == "__main__":
sys.exit(main())