Validate Tester and Coordinator role/step pairs #30
No files matched your search
@@ -82,9 +82,11 @@ metadata:
|
||||
makes the package manual-only. Every key other than `metadata` is written
|
||||
`key: value` with a non-empty value. `metadata:` stands alone on its line,
|
||||
followed by exactly those two keys, each indented two spaces. The block has no
|
||||
blank or comment lines. The block and its `---` delimiters end each line with
|
||||
LF alone: CR, CRLF, and Unicode line separators fail the check. Any other key,
|
||||
such as `tools` or `allowed-tools`, fails the check.
|
||||
blank or comment lines. The block and its delimiters contain no line-break
|
||||
character other than LF (such as CR, vertical tab, form feed, or a Unicode
|
||||
line or paragraph separator), and the closing `---` ends with LF or the end of
|
||||
the file. This line-break rule does not apply to the Markdown body. Any other
|
||||
key, such as `tools` or `allowed-tools`, fails the check.
|
||||
|
||||
## Identity and archive
|
||||
|
||||
|
||||
@@ -252,7 +252,19 @@ class RoleStepRejectionTests(unittest.TestCase):
|
||||
for label, mutate in cases:
|
||||
with self.subTest(name=name, case=label), FixtureCopy(name) as copy:
|
||||
mutate(copy)
|
||||
self.assertRejected(copy, "frontmatter|skill metadata")
|
||||
self.assertRejected(copy, "invalid SKILL.md frontmatter")
|
||||
|
||||
def test_line_break_rule_stops_at_the_frontmatter(self):
|
||||
for name in NEW_PAIR_FIXTURES:
|
||||
with self.subTest(name=name, case="CRLF body"), FixtureCopy(name) as copy:
|
||||
text = (copy.path / "SKILL.md").read_text()
|
||||
head, body = text.split("\n---\n", 1)
|
||||
copy.write_file("SKILL.md", head + "\n---\n" + body.replace("\n", "\r\n") + "\u2028\n")
|
||||
check_package(copy.path)
|
||||
with self.subTest(name=name, case="frontmatter only, no final newline"), FixtureCopy(name) as copy:
|
||||
text = (copy.path / "SKILL.md").read_text()
|
||||
copy.write_file("SKILL.md", text.split("\n---\n", 1)[0] + "\n---")
|
||||
check_package(copy.path)
|
||||
|
||||
def test_rejects_unsafe_or_undeclared_content(self):
|
||||
cases = (
|
||||
|
||||
+7
-6
@@ -131,13 +131,14 @@ def check_package(path):
|
||||
if not match:
|
||||
_fail(f"{path}: invalid SKILL.md frontmatter")
|
||||
frontmatter = match.group(1)
|
||||
# Lines end in LF only: CR, CRLF, or Unicode separators would split differently.
|
||||
if frontmatter.splitlines() != frontmatter.split("\n"):
|
||||
lines = frontmatter.split("\n")
|
||||
# LF is the only line break: CR, CRLF, and other separators split differently.
|
||||
if frontmatter.splitlines() != lines:
|
||||
_fail(f"{path}: invalid SKILL.md frontmatter")
|
||||
top_keys = []
|
||||
nested_keys = []
|
||||
in_metadata = False
|
||||
for line in frontmatter.splitlines():
|
||||
for line in lines:
|
||||
if line.startswith(" "):
|
||||
if not in_metadata or not re.fullmatch(r" [a-z-]+: .+", line):
|
||||
_fail(f"{path}: unsupported skill metadata")
|
||||
@@ -147,14 +148,14 @@ def check_package(path):
|
||||
top_keys.append(key)
|
||||
in_metadata = key == "metadata"
|
||||
# metadata stands alone; every other key carries an inline value.
|
||||
valid_line = line == "metadata:" if in_metadata else re.fullmatch(r"[a-z-]+: .+", line)
|
||||
valid_line = line == "metadata:" if in_metadata else bool(re.fullmatch(r"[a-z-]+: .+", line))
|
||||
if not valid_line:
|
||||
_fail(f"{path}: unsupported skill metadata")
|
||||
else:
|
||||
_fail(f"{path}: unsupported skill metadata")
|
||||
if len(top_keys) != len(set(top_keys)) or set(top_keys) - {"name", "description", "metadata", "disable-model-invocation"} or len(nested_keys) != len(set(nested_keys)) or set(nested_keys) != {"relayview-display-name", "relayview-version"}:
|
||||
_fail(f"{path}: unsupported skill metadata")
|
||||
values = dict(line.split(": ", 1) for line in frontmatter.splitlines() if not line.startswith(" ") and ": " in line)
|
||||
values = dict(line.split(": ", 1) for line in lines if not line.startswith(" ") and ": " in line)
|
||||
if "disable-model-invocation" in values and values["disable-model-invocation"] not in ("true", "false"):
|
||||
_fail(f"{path}: disable-model-invocation must be a boolean")
|
||||
expected_name = path.name
|
||||
@@ -162,7 +163,7 @@ def check_package(path):
|
||||
_fail(f"{path}: missing or incompatible skill metadata")
|
||||
if not re.fullmatch(r"[a-z0-9]+(?:-[a-z0-9]+)*", expected_name) or len(expected_name) > 64 or len(values["description"]) > 1024:
|
||||
_fail(f"{path}: skill name or description exceeds owner bounds")
|
||||
display_name = next(line.split(": ", 1)[1] for line in frontmatter.splitlines() if line.startswith(" relayview-display-name: "))
|
||||
display_name = next(line.split(": ", 1)[1] for line in lines if line.startswith(" relayview-display-name: "))
|
||||
if len(display_name) > 128:
|
||||
_fail(f"{path}: display name exceeds owner bounds")
|
||||
digest = hashlib.sha256(b"relayview-instruction-package-v1\0" + _frame(raw_manifest))
|
||||
|
||||
Reference in new issue
Block a user