fix(convert): quote YAML frontmatter values (#778)

Signed-off-by: Mr-Neutr0n <harikp2002@gmail.com>
This commit is contained in:
hari
2026-08-26 08:49:51 -05:00
committed by GitHub
parent 3570801f74
commit 3464daa3c6
3 changed files with 68 additions and 19 deletions
+26 -19
View File
@@ -106,6 +106,13 @@ toml_escape_string() {
'
}
# Quote a single-line value for a YAML frontmatter scalar. Single-quoted YAML
# strings keep colons, hashes, backslashes, and Unicode literal, while doubling
# an apostrophe is the only escaping rule required here.
yaml_quote() {
printf "'%s'" "$(printf '%s' "$1" | sed "s/'/''/g")"
}
# --- Per-tool converters ---
convert_antigravity() {
@@ -127,8 +134,8 @@ convert_antigravity() {
# valid Agent-Skills skill for any host (and deterministic — no date stamp).
cat > "$outfile" <<HEREDOC
---
name: ${slug}
description: ${description}
name: $(yaml_quote "$slug")
description: $(yaml_quote "$description")
---
${body}
HEREDOC
@@ -154,8 +161,8 @@ convert_osaurus() {
# Kept to the standard fields so it stays compatible with any Agent-Skills host.
cat > "$outfile" <<HEREDOC
---
name: ${slug}
description: ${description}
name: $(yaml_quote "$slug")
description: $(yaml_quote "$description")
---
${body}
HEREDOC
@@ -199,8 +206,8 @@ convert_gemini_cli() {
cat > "$outfile" <<HEREDOC
---
name: ${slug}
description: ${description}
name: $(yaml_quote "$slug")
description: $(yaml_quote "$description")
---
${body}
HEREDOC
@@ -267,8 +274,8 @@ convert_opencode() {
# Named colors are resolved to hex via resolve_opencode_color().
cat > "$outfile" <<HEREDOC
---
name: ${name}
description: ${description}
name: $(yaml_quote "$name")
description: $(yaml_quote "$description")
mode: subagent
color: '${color}'
---
@@ -291,7 +298,7 @@ convert_cursor() {
# Cursor .mdc format: description + globs + alwaysApply frontmatter
cat > "$outfile" <<HEREDOC
---
description: ${description}
description: $(yaml_quote "$description")
globs: ""
alwaysApply: false
---
@@ -409,17 +416,17 @@ convert_qwen() {
if [[ -n "$tools" ]]; then
cat > "$outfile" <<HEREDOC
---
name: ${slug}
description: ${description}
tools: ${tools}
name: $(yaml_quote "$slug")
description: $(yaml_quote "$description")
tools: $(yaml_quote "$tools")
---
${body}
HEREDOC
else
cat > "$outfile" <<HEREDOC
---
name: ${slug}
description: ${description}
name: $(yaml_quote "$slug")
description: $(yaml_quote "$description")
---
${body}
HEREDOC
@@ -446,17 +453,17 @@ convert_zcode() {
if [[ -n "$tools" ]]; then
cat > "$outfile" <<HEREDOC
---
name: ${slug}
description: ${description}
tools: ${tools}
name: $(yaml_quote "$slug")
description: $(yaml_quote "$description")
tools: $(yaml_quote "$tools")
---
${body}
HEREDOC
else
cat > "$outfile" <<HEREDOC
---
name: ${slug}
description: ${description}
name: $(yaml_quote "$slug")
description: $(yaml_quote "$description")
---
${body}
HEREDOC