fix(opencode): add color name-to-hex mapping for agent files
OpenCode only accepts hex color codes (e.g. #00FFFF), not named colors (e.g. cyan). Add resolve_opencode_color() with a 14-entry lookup table and wire it into convert_opencode(). Colors already in hex pass through.
This commit is contained in:
@@ -127,21 +127,44 @@ ${body}
|
|||||||
HEREDOC
|
HEREDOC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Map named colors to hex codes for OpenCode (which only accepts hex values).
|
||||||
|
# Colors already starting with '#' pass through unchanged.
|
||||||
|
resolve_opencode_color() {
|
||||||
|
local c="$1"
|
||||||
|
case "$c" in
|
||||||
|
cyan) echo "#00FFFF" ;;
|
||||||
|
blue) echo "#3498DB" ;;
|
||||||
|
green) echo "#2ECC71" ;;
|
||||||
|
red) echo "#E74C3C" ;;
|
||||||
|
purple) echo "#9B59B6" ;;
|
||||||
|
orange) echo "#F39C12" ;;
|
||||||
|
teal) echo "#008080" ;;
|
||||||
|
indigo) echo "#6366F1" ;;
|
||||||
|
pink) echo "#E84393" ;;
|
||||||
|
gold) echo "#EAB308" ;;
|
||||||
|
amber) echo "#F59E0B" ;;
|
||||||
|
neon-green) echo "#10B981" ;;
|
||||||
|
neon-cyan) echo "#06B6D4" ;;
|
||||||
|
metallic-blue) echo "#3B82F6" ;;
|
||||||
|
*) echo "$c" ;; # already hex or unknown — pass through
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
convert_opencode() {
|
convert_opencode() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local name description color slug outfile body
|
local name description color slug outfile body
|
||||||
|
|
||||||
name="$(get_field "name" "$file")"
|
name="$(get_field "name" "$file")"
|
||||||
description="$(get_field "description" "$file")"
|
description="$(get_field "description" "$file")"
|
||||||
color="$(get_field "color" "$file")"
|
color="$(resolve_opencode_color "$(get_field "color" "$file")")"
|
||||||
slug="$(slugify "$name")"
|
slug="$(slugify "$name")"
|
||||||
body="$(get_body "$file")"
|
body="$(get_body "$file")"
|
||||||
|
|
||||||
outfile="$OUT_DIR/opencode/agents/${slug}.md"
|
outfile="$OUT_DIR/opencode/agents/${slug}.md"
|
||||||
mkdir -p "$OUT_DIR/opencode/agents"
|
mkdir -p "$OUT_DIR/opencode/agents"
|
||||||
|
|
||||||
# OpenCode agent format: same as the source format (.md with frontmatter).
|
# OpenCode agent format: .md with YAML frontmatter in .opencode/agents/.
|
||||||
# color field is supported. No conversion needed beyond directory placement.
|
# Named colors are resolved to hex via resolve_opencode_color().
|
||||||
cat > "$outfile" <<HEREDOC
|
cat > "$outfile" <<HEREDOC
|
||||||
---
|
---
|
||||||
name: ${name}
|
name: ${name}
|
||||||
|
|||||||
Reference in New Issue
Block a user