added
This commit is contained in:
1 parent
614d235bbe
commit
1e52a733d1
29 files changed
+728
-66
No files matched your search
+4
-1
@@ -18,4 +18,7 @@ python scripts/validate_repository.py .
|
||||
python scripts/validate_repository.py . --json
|
||||
```
|
||||
|
||||
The validator checks required paths, JSON parsing, core manifest fields, author/publisher alignment, entrypoint paths, manifest contents paths, version alignment, license alignment, and relative Markdown links. It does not prove content accuracy or check external URLs.
|
||||
The validator checks required paths, JSON parsing, repository-variable and
|
||||
manifest alignment, author/publisher alignment, entrypoint paths, manifest
|
||||
contents paths, version alignment, license alignment, and relative Markdown
|
||||
links. It does not prove content accuracy or check external URLs.
|
||||
@@ -32,14 +32,17 @@ REQUIRED_PATHS = (
|
||||
"examples/README.md",
|
||||
"receipts/README.md",
|
||||
"repository.json",
|
||||
"repository-variables.json",
|
||||
"schemas/README.md",
|
||||
"schemas/repository.schema.json",
|
||||
"schemas/repository-variables.schema.json",
|
||||
"scripts/README.md",
|
||||
"skills.md",
|
||||
"skills/README.md",
|
||||
"skills/structure-ai-ready-repository/SKILL.md",
|
||||
"tasks/README.md",
|
||||
"templates/README.md",
|
||||
"templates/repository-variables.json.template",
|
||||
"tests/README.md",
|
||||
)
|
||||
|
||||
@@ -160,6 +163,77 @@ def validate_manifest(root: Path, findings: list[dict[str, str]]) -> dict | None
|
||||
return manifest
|
||||
|
||||
|
||||
def validate_variables(
|
||||
root: Path, manifest: dict | None, findings: list[dict[str, str]]
|
||||
) -> dict | None:
|
||||
path = root / "repository-variables.json"
|
||||
try:
|
||||
variables = json.loads(read_text(path))
|
||||
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
||||
add(findings, "error", f"repository-variables.json is invalid: {exc}")
|
||||
return None
|
||||
|
||||
required = (
|
||||
"schema_version",
|
||||
"purpose",
|
||||
"repository_profile",
|
||||
"identity",
|
||||
"repository",
|
||||
"rights",
|
||||
"skill_defaults",
|
||||
"verified_by",
|
||||
"verified_at",
|
||||
)
|
||||
for key in required:
|
||||
if key not in variables:
|
||||
add(findings, "error", f"repository-variables.json lacks required key: {key}")
|
||||
|
||||
if not manifest:
|
||||
return variables
|
||||
|
||||
identity = variables.get("identity", {})
|
||||
variable_authors = [
|
||||
item.get("name") for item in identity.get("authors", []) if isinstance(item, dict)
|
||||
]
|
||||
manifest_authors = [
|
||||
item.get("name")
|
||||
for item in manifest.get("authors", [])
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
if variable_authors != manifest_authors:
|
||||
add(findings, "error", "Authors differ between repository-variables.json and repository.json")
|
||||
|
||||
variable_publisher = identity.get("publisher", {}).get("name")
|
||||
manifest_publisher = manifest.get("publisher", {}).get("name")
|
||||
if variable_publisher != manifest_publisher:
|
||||
add(findings, "error", "Publisher differs between repository-variables.json and repository.json")
|
||||
|
||||
variable_maintainer = identity.get("maintainer", {}).get("name")
|
||||
manifest_maintainer = manifest.get("maintenance", {}).get("maintainer")
|
||||
if variable_maintainer != manifest_maintainer:
|
||||
add(findings, "error", "Maintainer differs between repository-variables.json and repository.json")
|
||||
|
||||
repository = variables.get("repository", {})
|
||||
for key in ("repository_id", "name", "title", "canonical_url", "organization"):
|
||||
if repository.get(key) != manifest.get(key):
|
||||
add(
|
||||
findings,
|
||||
"error",
|
||||
f"{key} differs between repository-variables.json and repository.json",
|
||||
)
|
||||
|
||||
variable_rights = variables.get("rights", {})
|
||||
manifest_rights = manifest.get("rights", {})
|
||||
for key in ("license", "license_file"):
|
||||
if variable_rights.get(key) != manifest_rights.get(key):
|
||||
add(
|
||||
findings,
|
||||
"error",
|
||||
f"{key} differs between repository-variables.json and repository.json",
|
||||
)
|
||||
return variables
|
||||
|
||||
|
||||
def validate_versions(root: Path, manifest: dict | None, findings: list[dict[str, str]]) -> None:
|
||||
version = read_text(root / "VERSION").strip()
|
||||
if not re.fullmatch(r"\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?", version):
|
||||
@@ -226,6 +300,8 @@ def validate(root: Path) -> dict:
|
||||
missing_core = False
|
||||
|
||||
manifest = None if not (root / "repository.json").is_file() else validate_manifest(root, findings)
|
||||
if (root / "repository-variables.json").is_file():
|
||||
validate_variables(root, manifest, findings)
|
||||
if not missing_core:
|
||||
validate_versions(root, manifest, findings)
|
||||
validate_markdown_links(root, findings)
|
||||
|
||||
Reference in new issue
Block a user