4 Commits
Author SHA1 Message Date
gitea-actions ca6b917b17 ci: bin.json v0.1.3 2026-11-03 22:47:35 +00:00
johannes 042f1ed3b5 Merge branch 'fix/lenient-skill-frontmatter'
build / version (push) Successful in 9s
build / build (aarch64-apple-darwin) (push) Successful in 5m29s
build / build (x86_64-unknown-linux-musl) (push) Successful in 4m54s
build / release (push) Successful in 21s
2026-11-03 23:36:29 +01:00
johannesandClaude Sonnet 5.5 9843e5305c skills: fall back to line-based frontmatter when YAML is invalid
Descriptions with an unquoted ': ' (e.g. floorplan) failed strict YAML and
the skill was silently dropped. Read single-line known keys instead; skills
with no recognised key are still skipped and reported in /skills.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 23:36:18 +01:00
gitea-actions 047e781ca4 ci: bin.json v0.1.2 2026-11-03 21:32:24 +00:00
2 changed files with 41 additions and 7 deletions

No files matched your search

+3 -3
View File
@@ -1,7 +1,7 @@
{
"version": "0.1.1",
"version": "0.1.3",
"sha256": {
"aarch64-apple-darwin": "d1684b780a1f988babccb24ec4de341fb04e2f0eccc43d82487287337b83216a",
"x86_64-unknown-linux-musl": "6ab0530d4c97839da685462bf3acac9db28173ed443c89f3e0037cccc693a92c"
"aarch64-apple-darwin": "0fa455f5cc4c63df942224602ecad0b83ee91847cef6fde8f0e4704bf0913810",
"x86_64-unknown-linux-musl": "8bc56e52a403088229e25470ccd12b2b7fe9e1195062206827beff9be630f3f7"
}
}
+38 -4
View File
@@ -97,6 +97,34 @@ struct Front {
argument_hint: Option<String>,
}
/// Fallback for frontmatter that is not valid YAML: `key: value` on one line, value taken verbatim
/// (surrounding quotes stripped). None when no known key is found.
fn lenient_front(fm: &str) -> Option<Front> {
let mut f = Front::default();
let mut found = false;
for line in fm.lines() {
let Some((k, v)) = line.split_once(':') else {
continue;
};
let v = v.trim();
let v = v
.strip_prefix('"')
.and_then(|x| x.strip_suffix('"'))
.unwrap_or(v)
.to_string();
match k {
"name" => f.name = Some(v),
"description" => f.description = Some(v),
"load" => f.load = Some(v),
"disable-model-invocation" => f.disable_model_invocation = Some(v == "true"),
"argument-hint" => f.argument_hint = Some(v),
_ => continue,
}
found = true;
}
found.then_some(f)
}
/// Skill dirs, lowest priority first: `~/.claude/skills`, `~/.agents/skills` (shared with other agents),
/// `<hx home>/skills`, `<project>/.agents/skills`, `<project>/.claude/skills`, `<project>/.hx/skills`.
pub fn skill_dirs(home: &Path, cwd: &Path) -> Vec<PathBuf> {
@@ -133,7 +161,11 @@ pub fn parse_skill(p: &Path, s: &str) -> Result<Skill, String> {
let f: Front = if fm.trim().is_empty() {
Front::default()
} else {
serde_norway::from_str(fm).map_err(|e| e.to_string())?
match serde_norway::from_str(fm) {
Ok(f) => f,
// strict YAML failed (e.g. unquoted `: ` in a description): read single-line top-level keys
Err(e) => lenient_front(fm).ok_or_else(|| e.to_string())?,
}
};
let load = match f.load.as_deref() {
Some("always") => Load::Always,
@@ -307,7 +339,7 @@ mod tests {
assert!(!k.model_invocable && k.load == Load::Auto);
let k = parse_skill(p, "---\nname: n\ndescription: |\n a\n b\n---\n").unwrap();
assert_eq!(k.description, "a b");
assert!(parse_skill(p, "---\ndescription: [oops\n---\nB").is_err());
assert!(parse_skill(p, "---\noops: [oops\n---\nB").is_err());
let k = parse_skill(p, "no frontmatter").unwrap();
assert_eq!((k.name.as_str(), k.body.as_str()), ("n", "no frontmatter"));
assert!(
@@ -329,7 +361,8 @@ load: manual
for (n, fm) in [
("ok", "description: fine"),
("hid", "description: secret\ndisable-model-invocation: true"),
("bad", "description: [oops"),
("bad", "oops: [oops"),
("colon", "description: before code exists: when asked"),
] {
let d = t.path().join("s").join(n);
std::fs::create_dir_all(&d).unwrap();
@@ -337,7 +370,8 @@ load: manual
}
let (sk, warn) = scan_skills(&[t.path().join("s")]);
let names: Vec<_> = sk.iter().map(|k| k.name.as_str()).collect();
assert_eq!(names, ["hid", "ok"]);
assert_eq!(names, ["colon", "hid", "ok"]);
assert_eq!(sk[0].description, "before code exists: when asked");
assert!(
warn.len() == 1 && warn[0].contains("bad/SKILL.md"),
"{warn:?}"