Skip to content

Commit 104ec87

Browse files
skills: parse SKILL.md frontmatter with yaml.safe_load
Replaces the hand-rolled block-scalar walker (added one commit ago) with PyYAML's safe_load. PyYAML's default SafeLoader is pure-Python — no C extension required — and handles every YAML edge case for free instead of reimplementing them. Side-benefit: also fixes a second latent bug. The regex parser stripped the outer YAML quotes but left inner `\"` escapes intact as literal backslash-quote characters, so descriptions like `"... mentions \"switch workspace\"..."` ended up in manifest.json with the backslashes preserved. yaml.safe_load resolves these correctly. Regenerated manifest reflects the fix for databricks-config. Co-authored-by: Isaac
1 parent e3a3dc1 commit 104ec87

2 files changed

Lines changed: 8 additions & 30 deletions

File tree

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": "2",
3-
"updated_at": "2026-05-12T21:53:00Z",
3+
"updated_at": "2026-05-12T21:58:09Z",
44
"skills": {
55
"databricks-apps": {
66
"version": "0.1.1",
@@ -253,7 +253,7 @@
253253
},
254254
"databricks-config": {
255255
"version": "0.0.1",
256-
"description": "Manage Databricks workspace connections: check current workspace, switch profiles, list available workspaces, or authenticate to a new workspace. Use when the user mentions \\\"switch workspace\\\", \\\"which workspace\\\", \\\"current profile\\\", \\\"databrickscfg\\\", \\\"connect to workspace\\\", or \\\"databricks auth\\\".",
256+
"description": "Manage Databricks workspace connections: check current workspace, switch profiles, list available workspaces, or authenticate to a new workspace. Use when the user mentions \"switch workspace\", \"which workspace\", \"current profile\", \"databrickscfg\", \"connect to workspace\", or \"databricks auth\".",
257257
"experimental": true,
258258
"updated_at": "2026-05-12T21:15:40Z",
259259
"files": [

scripts/skills.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from datetime import datetime, timezone
1010
from pathlib import Path
1111

12+
import yaml
13+
1214

1315
SHARED_ASSETS = [
1416
"assets/databricks.svg",
@@ -194,17 +196,8 @@ def check_assets_synced(repo_root: Path) -> list[str]:
194196
# Manifest generation
195197
# ---------------------------------------------------------------------------
196198

197-
_BLOCK_SCALAR_INDICATORS = {"|", "|-", "|+", ">", ">-", ">+"}
198-
199-
200199
def extract_description_from_skill(skill_path: Path) -> str:
201-
"""Best-effort extraction of `description:` from SKILL.md frontmatter.
202-
203-
Handles plain (`description: foo`), quoted (`description: "foo"`), and
204-
block-scalar (`description: >-` followed by indented lines) values. The
205-
regex-only version captured the block-scalar indicator verbatim, which
206-
corrupted manifest entries and Codex marketplace metadata.
207-
"""
200+
"""Best-effort extraction of `description:` from SKILL.md frontmatter."""
208201
skill_md = skill_path / "SKILL.md"
209202
if not skill_md.exists():
210203
return ""
@@ -214,24 +207,9 @@ def extract_description_from_skill(skill_path: Path) -> str:
214207
end_idx = content.find("---", 3)
215208
if end_idx == -1:
216209
return ""
217-
lines = content[3:end_idx].splitlines()
218-
for i, line in enumerate(lines):
219-
m = re.match(r'^description:\s*(.*?)\s*$', line)
220-
if not m:
221-
continue
222-
value = m.group(1)
223-
if value in _BLOCK_SCALAR_INDICATORS:
224-
collected = []
225-
for cont in lines[i + 1:]:
226-
if cont and not cont[0].isspace():
227-
break
228-
stripped = cont.strip()
229-
if stripped:
230-
collected.append(stripped)
231-
joiner = " " if value.startswith(">") else "\n"
232-
return joiner.join(collected)
233-
return value.strip().strip('"').strip("'")
234-
return ""
210+
parsed = yaml.safe_load(content[3:end_idx]) or {}
211+
description = parsed.get("description", "")
212+
return description.strip() if isinstance(description, str) else ""
235213

236214

237215
# Markers that separate the "what this skill does" lead-in from the

0 commit comments

Comments
 (0)