addyosmani--agent-skills
501d2266dd
The fix in 43a0dde introduces jq as a hard runtime dependency for the
session-start hook. jq is not preinstalled on every macOS or Linux setup,
so users without it would hit a cryptic failure on every new session.
Add a `command -v jq` guard that emits a valid INFO-priority JSON message
explaining the dependency and pointing at install commands. Skills remain
available individually — only the meta-skill injection is skipped.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
25 行
1021 B
Bash
可执行文件
25 行
1021 B
Bash
可执行文件
#!/bin/bash
|
|
# agent-skills session start hook
|
|
# Injects the using-agent-skills meta-skill into every new session
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
SKILLS_DIR="$(dirname "$SCRIPT_DIR")/skills"
|
|
META_SKILL="$SKILLS_DIR/using-agent-skills/SKILL.md"
|
|
|
|
if ! command -v jq >/dev/null 2>&1; then
|
|
echo '{"priority": "INFO", "message": "agent-skills: jq is required for the session-start hook but was not found on PATH. Install jq (e.g. `brew install jq` or `apt-get install jq`) to enable meta-skill injection. Skills remain available individually."}'
|
|
exit 0
|
|
fi
|
|
|
|
if [ -f "$META_SKILL" ]; then
|
|
CONTENT=$(cat "$META_SKILL")
|
|
# 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
|