mirror of
https://github.com/addyosmani/agent-skills.git
synced 2026-08-12 18:07:26 +02:00
fix: JSON-escape hook content in session-start hook
Fixes issue #89: session-start hook now properly escapes SKILL.md content when constructing JSON output, preventing parse errors when markdown contains quotes or control characters. Uses jq -cn with --arg flag to properly escape all special characters in the message field.
This commit is contained in:
@@ -8,13 +8,12 @@ META_SKILL="$SKILLS_DIR/using-agent-skills/SKILL.md"
|
||||
|
||||
if [ -f "$META_SKILL" ]; then
|
||||
CONTENT=$(cat "$META_SKILL")
|
||||
# Output as JSON for Claude Code hook consumption
|
||||
cat <<EOF
|
||||
{
|
||||
"priority": "IMPORTANT",
|
||||
"message": "agent-skills loaded. Use the skill discovery flowchart to find the right skill for your task.\n\n$CONTENT"
|
||||
}
|
||||
EOF
|
||||
# Use jq to properly escape and construct valid JSON
|
||||
jq -cn \
|
||||
--arg message "agent-skills loaded. Use the skill discovery flowchart to find the right skill for your task.
|
||||
|
||||
$CONTENT" \
|
||||
'{priority: "IMPORTANT", message: $message}'
|
||||
else
|
||||
echo '{"priority": "INFO", "message": "agent-skills: using-agent-skills meta-skill not found. Skills may still be available individually."}'
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user