Skip to content

Commit 88ea2d3

Browse files
author
Ramraj Bishnoie
committed
chore: update marketplace and SKILL version to 1.2.0 and add version validation for SKILL.md
1 parent 2f42a7f commit 88ea2d3

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"name": "codeguard-security",
1414
"source": "./",
1515
"description": "Comprehensive security rules for AI coding agents",
16-
"version": "1.1.0",
16+
"version": "1.2.0",
1717
"repository": "https://github.com/project-codeguard/rules.git",
1818
"tags": [
1919
"security",

src/validate_versions.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414

1515
import json
16+
import re
1617
import sys
1718
import tomllib
1819
from pathlib import Path
@@ -21,6 +22,7 @@
2122

2223
class VersionCheck(NamedTuple):
2324
"""Result of a version check."""
25+
2426
file: str
2527
expected: str
2628
found: str
@@ -74,6 +76,29 @@ def set_marketplace_version(version: str, root: Path) -> None:
7476
f.write("\n")
7577

7678

79+
def _read_front_matter_value(path: Path, key: str) -> str:
80+
"""Read a YAML front-matter value from a markdown file."""
81+
content = path.read_text(encoding="utf-8")
82+
front_matter_match = re.match(r"^---\s*\n(.*?)\n---\s*\n", content, re.DOTALL)
83+
if not front_matter_match:
84+
raise ValueError(f"Missing front matter in {path}")
85+
front_matter = front_matter_match.group(1)
86+
value_match = re.search(
87+
rf'^{re.escape(key)}:\s*"([^"]+)"\s*$',
88+
front_matter,
89+
re.MULTILINE,
90+
)
91+
if not value_match:
92+
raise ValueError(f"Missing {key} in front matter for {path}")
93+
return value_match.group(1)
94+
95+
96+
def get_skill_codeguard_version(root: Path) -> str:
97+
"""Get codeguard-version from skills/software-security/SKILL.md."""
98+
skill_path = root / "skills" / "software-security" / "SKILL.md"
99+
return _read_front_matter_value(skill_path, "codeguard-version")
100+
101+
77102
def validate_versions(expected_version: str, root: Path = None) -> list[VersionCheck]:
78103
"""
79104
Validate all versions match the expected version.
@@ -89,15 +114,24 @@ def validate_versions(expected_version: str, root: Path = None) -> list[VersionC
89114
root = Path(__file__).parent.parent
90115

91116
checks = [
92-
VersionCheck("pyproject.toml", expected_version, get_pyproject_version(root), False),
117+
VersionCheck(
118+
"pyproject.toml", expected_version, get_pyproject_version(root), False
119+
),
93120
VersionCheck("plugin.json", expected_version, get_plugin_version(root), False),
94-
VersionCheck("marketplace.json", expected_version, get_marketplace_version(root), False),
121+
VersionCheck(
122+
"marketplace.json", expected_version, get_marketplace_version(root), False
123+
),
124+
VersionCheck(
125+
"SKILL.md",
126+
expected_version,
127+
get_skill_codeguard_version(root),
128+
False,
129+
),
95130
]
96131

97132
# Update matches field
98133
return [
99-
VersionCheck(c.file, c.expected, c.found, c.expected == c.found)
100-
for c in checks
134+
VersionCheck(c.file, c.expected, c.found, c.expected == c.found) for c in checks
101135
]
102136

103137

0 commit comments

Comments
 (0)