State the frontmatter line-break rule exactly
Check instruction packages / check (push) Successful in 5s
Check instruction packages / check (pull_request) Successful in 5s

Name the separators the checker rejects and the end-of-file closing
delimiter it accepts, and show that the rule stops at the frontmatter: a
CRLF body and a frontmatter-only file still pass. Split frontmatter lines
once and assert the exact rejection reason.

Refs #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-11-25 19:04:47 -05:00
1 parent 45eff20ecb
commit da34e1c1bf
3 files changed
+25 -10

No files matched your search

@@ -82,9 +82,11 @@ metadata:
makes the package manual-only. Every key other than `metadata` is written 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, `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 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 blank or comment lines. The block and its delimiters contain no line-break
LF alone: CR, CRLF, and Unicode line separators fail the check. Any other key, character other than LF (such as CR, vertical tab, form feed, or a Unicode
such as `tools` or `allowed-tools`, fails the check. 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 ## Identity and archive
+13 -1
View File
@@ -252,7 +252,19 @@ class RoleStepRejectionTests(unittest.TestCase):
for label, mutate in cases: for label, mutate in cases:
with self.subTest(name=name, case=label), FixtureCopy(name) as copy: with self.subTest(name=name, case=label), FixtureCopy(name) as copy:
mutate(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): def test_rejects_unsafe_or_undeclared_content(self):
cases = ( cases = (
+7 -6
View File
@@ -131,13 +131,14 @@ def check_package(path):
if not match: if not match:
_fail(f"{path}: invalid SKILL.md frontmatter") _fail(f"{path}: invalid SKILL.md frontmatter")
frontmatter = match.group(1) frontmatter = match.group(1)
# Lines end in LF only: CR, CRLF, or Unicode separators would split differently. lines = frontmatter.split("\n")
if frontmatter.splitlines() != 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") _fail(f"{path}: invalid SKILL.md frontmatter")
top_keys = [] top_keys = []
nested_keys = [] nested_keys = []
in_metadata = False in_metadata = False
for line in frontmatter.splitlines(): for line in lines:
if line.startswith(" "): if line.startswith(" "):
if not in_metadata or not re.fullmatch(r" [a-z-]+: .+", line): if not in_metadata or not re.fullmatch(r" [a-z-]+: .+", line):
_fail(f"{path}: unsupported skill metadata") _fail(f"{path}: unsupported skill metadata")
@@ -147,14 +148,14 @@ def check_package(path):
top_keys.append(key) top_keys.append(key)
in_metadata = key == "metadata" in_metadata = key == "metadata"
# metadata stands alone; every other key carries an inline value. # 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: if not valid_line:
_fail(f"{path}: unsupported skill metadata") _fail(f"{path}: unsupported skill metadata")
else: else:
_fail(f"{path}: unsupported skill metadata") _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"}: 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") _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"): 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") _fail(f"{path}: disable-model-invocation must be a boolean")
expected_name = path.name expected_name = path.name
@@ -162,7 +163,7 @@ def check_package(path):
_fail(f"{path}: missing or incompatible skill metadata") _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: 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") _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: if len(display_name) > 128:
_fail(f"{path}: display name exceeds owner bounds") _fail(f"{path}: display name exceeds owner bounds")
digest = hashlib.sha256(b"relayview-instruction-package-v1\0" + _frame(raw_manifest)) digest = hashlib.sha256(b"relayview-instruction-package-v1\0" + _frame(raw_manifest))