Files
cleveragents-core/robot/helper_skill_schema.py
aditya 6d7b759f25
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / lint (pull_request) Failing after 11s
CI / typecheck (pull_request) Successful in 28s
CI / security (pull_request) Successful in 25s
CI / quality (pull_request) Successful in 17s
CI / integration_tests (pull_request) Successful in 5m29s
CI / build (pull_request) Successful in 16s
CI / unit_tests (pull_request) Successful in 16m9s
style(skill): apply ruff auto-formatting to skill schema files
2026-02-17 10:13:19 +00:00

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())