160 lines
4.8 KiB
Python
160 lines
4.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Validate Android Dev agent pack references.
|
|
|
|
This script keeps the portable Android Dev pack from silently drifting away from
|
|
the reusable agent entry points. It checks that the pack owns the required files
|
|
and that common routing docs point to the pack instead of the legacy path.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
PACK = ROOT / "agent-packs" / "android-dev"
|
|
|
|
REQUIRED_PACK_FILES = [
|
|
"README.md",
|
|
"SKILL.md",
|
|
"AGENT.md",
|
|
"development_quality_gate.md",
|
|
"project_documentation_contract.md",
|
|
"mobile_architecture_guidelines.md",
|
|
"android_senior_engineering_standards.md",
|
|
"android_handoff_contract.md",
|
|
"agent_document_contract.md",
|
|
"shared-docs/figma_android_handoff.md",
|
|
"skills/p0-vertical-slice-architecture/SKILL.md",
|
|
"skills/compose-adaptive-layout/SKILL.md",
|
|
"skills/java-xml-adaptive-layout/SKILL.md",
|
|
"skills/design-fidelity-adaptation/SKILL.md",
|
|
]
|
|
|
|
REQUIRED_REFERENCES = {
|
|
"START_HERE.md": [
|
|
"agent-packs/android-dev/SKILL.md",
|
|
"agent-packs/android-dev/AGENT.md",
|
|
],
|
|
"pipeline/SKILL.md": [
|
|
"agent-packs/android-dev/SKILL.md",
|
|
"agent-packs/android-dev/AGENT.md",
|
|
],
|
|
"pipeline/agent_usage_guide.md": [
|
|
"agent-packs/android-dev/SKILL.md",
|
|
"agent-packs/android-dev/AGENT.md",
|
|
],
|
|
"pipeline/semantic_context_compaction.md": [
|
|
"agent-packs/android-dev/development_quality_gate.md",
|
|
"agent-packs/android-dev/mobile_architecture_guidelines.md",
|
|
],
|
|
"agents/code-quality/SKILL.md": [
|
|
"../../agent-packs/android-dev/development_quality_gate.md",
|
|
"../../agent-packs/android-dev/mobile_architecture_guidelines.md",
|
|
],
|
|
"agents/code-quality/AGENT.md": [
|
|
"../../agent-packs/android-dev/development_quality_gate.md",
|
|
"../../agent-packs/android-dev/mobile_architecture_guidelines.md",
|
|
],
|
|
}
|
|
|
|
PACK_INTERNAL_REFERENCES = {
|
|
"SKILL.md": [
|
|
"AGENT.md",
|
|
"android_senior_engineering_standards.md",
|
|
"mobile_architecture_guidelines.md",
|
|
"development_quality_gate.md",
|
|
"project_documentation_contract.md",
|
|
"android_handoff_contract.md",
|
|
"shared-docs/figma_android_handoff.md",
|
|
"skills/p0-vertical-slice-architecture/SKILL.md",
|
|
"skills/compose-adaptive-layout/SKILL.md",
|
|
"skills/java-xml-adaptive-layout/SKILL.md",
|
|
"skills/design-fidelity-adaptation/SKILL.md",
|
|
],
|
|
"AGENT.md": [
|
|
"shared-docs/figma_android_handoff.md",
|
|
],
|
|
"README.md": [
|
|
"SKILL.md",
|
|
"AGENT.md",
|
|
"project_documentation_contract.md",
|
|
"skills/p0-vertical-slice-architecture/SKILL.md",
|
|
"skills/compose-adaptive-layout/SKILL.md",
|
|
"skills/java-xml-adaptive-layout/SKILL.md",
|
|
"skills/design-fidelity-adaptation/SKILL.md",
|
|
],
|
|
}
|
|
|
|
LEGACY_ROUTING_FILES = [
|
|
"START_HERE.md",
|
|
"pipeline/SKILL.md",
|
|
"pipeline/agent_usage_guide.md",
|
|
"pipeline/semantic_context_compaction.md",
|
|
"agents/code-quality/SKILL.md",
|
|
"agents/code-quality/AGENT.md",
|
|
"agents/code-quality/使用说明.md",
|
|
"README.md",
|
|
]
|
|
|
|
|
|
def read(path: Path) -> str:
|
|
try:
|
|
return path.read_text(encoding="utf-8")
|
|
except FileNotFoundError:
|
|
return ""
|
|
|
|
|
|
def require_file(path: Path, errors: list[str]) -> None:
|
|
if not path.is_file():
|
|
errors.append(f"missing file: {path.relative_to(ROOT)}")
|
|
|
|
|
|
def require_text(path: Path, needles: list[str], errors: list[str]) -> None:
|
|
content = read(path)
|
|
if not content:
|
|
errors.append(f"missing readable file: {path.relative_to(ROOT)}")
|
|
return
|
|
for needle in needles:
|
|
if needle not in content:
|
|
errors.append(f"missing reference in {path.relative_to(ROOT)}: {needle}")
|
|
|
|
|
|
def reject_text(path: Path, needles: list[str], errors: list[str]) -> None:
|
|
content = read(path)
|
|
if not content:
|
|
return
|
|
for needle in needles:
|
|
if needle in content:
|
|
errors.append(f"legacy reference in {path.relative_to(ROOT)}: {needle}")
|
|
|
|
|
|
def main() -> int:
|
|
errors: list[str] = []
|
|
|
|
for relative in REQUIRED_PACK_FILES:
|
|
require_file(PACK / relative, errors)
|
|
|
|
for relative, needles in REQUIRED_REFERENCES.items():
|
|
require_text(ROOT / relative, needles, errors)
|
|
|
|
for relative, needles in PACK_INTERNAL_REFERENCES.items():
|
|
require_text(PACK / relative, needles, errors)
|
|
|
|
for relative in LEGACY_ROUTING_FILES:
|
|
reject_text(ROOT / relative, ["agents/android-dev/SKILL.md", "agents/android-dev/AGENT.md"], errors)
|
|
|
|
if errors:
|
|
print("Android Dev pack reference check failed:")
|
|
for error in errors:
|
|
print(f"- {error}")
|
|
return 1
|
|
|
|
print("Android Dev pack references OK")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|