Datasets:
Download tests/quick_validate.py from LucioLiu/agent-phone-use: direct link, hf CLI and curl.
- Browser
- Download file 3.62 kB
-
https://huggingface.co/datasets/LucioLiu/agent-phone-use/resolve/main/tests/quick_validate.py
- Command line
-
hf download hf://datasets/LucioLiu/agent-phone-use/tests/quick_validate.py
-
curl -L -o quick_validate.py https://huggingface.co/datasets/LucioLiu/agent-phone-use/resolve/main/tests/quick_validate.py
3.62 kB
| #!/usr/bin/env python3 | |
| """Minimal public validator for an OpenAI-compatible skill folder.""" | |
| from __future__ import annotations | |
| import re | |
| import sys | |
| from pathlib import Path | |
| from urllib.parse import unquote | |
| import yaml | |
| def fail(message: str) -> None: | |
| print(f"ERROR: {message}", file=sys.stderr) | |
| raise SystemExit(1) | |
| def main() -> None: | |
| if len(sys.argv) != 2: | |
| fail("usage: quick_validate.py <skill-folder>") | |
| skill_dir = Path(sys.argv[1]) | |
| skill_file = skill_dir / "SKILL.md" | |
| if not skill_file.is_file(): | |
| fail("SKILL.md is missing") | |
| text = skill_file.read_text(encoding="utf-8") | |
| match = re.match(r"\A---\r?\n(.*?)\r?\n---\r?\n", text, re.DOTALL) | |
| if not match: | |
| fail("SKILL.md must begin with YAML frontmatter") | |
| data = yaml.safe_load(match.group(1)) | |
| if not isinstance(data, dict): | |
| fail("frontmatter must be a mapping") | |
| if set(data) != {"name", "description"}: | |
| fail("frontmatter must contain only name and description") | |
| name = data.get("name") | |
| if not isinstance(name, str) or not re.fullmatch(r"[a-z0-9-]{1,64}", name): | |
| fail("name must use lowercase letters, digits, and hyphens") | |
| if skill_dir.name != name: | |
| fail("folder name must match skill name") | |
| description = data.get("description") | |
| if not isinstance(description, str) or not description.strip(): | |
| fail("description must be a non-empty string") | |
| required = [ | |
| "agents/openai.yaml", | |
| "references/agent-runbook.md", | |
| "scripts/install-shortcut.ps1", | |
| "scripts/pair-android-wireless.ps1", | |
| "scripts/start-agent-phone-use.ps1", | |
| "scripts/start-hidden.vbs", | |
| ] | |
| missing = [relative for relative in required if not (skill_dir / relative).is_file()] | |
| if missing: | |
| fail("required files are missing: " + ", ".join(missing)) | |
| forbidden = [path.name for path in skill_dir.iterdir() if path.name.lower() == "readme.md"] | |
| if forbidden: | |
| fail("README.md belongs at the repository root, not inside the skill") | |
| interface_data = yaml.safe_load((skill_dir / "agents/openai.yaml").read_text(encoding="utf-8")) | |
| interface = interface_data.get("interface") if isinstance(interface_data, dict) else None | |
| if not isinstance(interface, dict): | |
| fail("agents/openai.yaml must contain an interface mapping") | |
| for key in ("display_name", "short_description", "default_prompt"): | |
| if not isinstance(interface.get(key), str) or not interface[key].strip(): | |
| fail(f"agents/openai.yaml is missing interface.{key}") | |
| markdown_link = re.compile(r"\[[^\]]+\]\(([^)]+)\)") | |
| for markdown_file in skill_dir.rglob("*.md"): | |
| markdown_text = markdown_file.read_text(encoding="utf-8") | |
| if "TODO" in markdown_text or "[TODO" in markdown_text: | |
| fail(f"unfinished TODO in {markdown_file.relative_to(skill_dir)}") | |
| for raw_target in markdown_link.findall(markdown_text): | |
| target = raw_target.strip("<>") | |
| if re.match(r"^(?:https?://|mailto:|#)", target): | |
| continue | |
| path_text = unquote(target.split("#", 1)[0]) | |
| if not path_text: | |
| continue | |
| resolved = (markdown_file.parent / path_text).resolve() | |
| if not resolved.exists(): | |
| fail( | |
| f"broken relative link in {markdown_file.relative_to(skill_dir)}: {target}" | |
| ) | |
| print("Skill is valid!") | |
| if __name__ == "__main__": | |
| main() | |