fix(skills): preserve version strings across markdown saves

This commit is contained in:
red person
2026-10-26 10:32:26 +03:00
parent 9d0d3720f4
commit fd27e9a429
2 changed files with 65 additions and 2 deletions
+6 -2
View File
@@ -84,10 +84,14 @@ _FM_KEY_RE = re.compile(r"^([a-z_][a-z0-9_]*):\s*(.*)$", re.IGNORECASE)
_FM_BLOCK_LIST_RE = re.compile(r"^\s*-\s*(.*)$")
def _parse_scalar(raw: str) -> Any:
def _parse_scalar(raw: str, *, string_only: bool = False) -> Any:
raw = raw.strip()
if raw == "":
return ""
# String fields keep their spelling; quoted values still use the decoder
# below so existing escapes round-trip as before.
if string_only and not (raw[0] == raw[-1] and raw[0] in ("'", '"')):
return raw
if raw.startswith("[") and raw.endswith("]"):
inner = raw[1:-1].strip()
if not inner:
@@ -171,7 +175,7 @@ def parse_frontmatter(text: str) -> tuple[Dict[str, Any], str]:
pending_key = key
fm[key] = []
else:
fm[key] = _parse_scalar(val)
fm[key] = _parse_scalar(val, string_only=(key == "version"))
pending_key = None
continue
m2 = _FM_BLOCK_LIST_RE.match(line)