blob: cf93e771d2d6ac24536de88407fc7a8e1de34534 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/bash
# agent-skills session start hook
# Injects the using-agent-skills meta-skill into a new session.
#
# Not wired by the plugin: hosts that already route skills from their
# descriptions (Claude Code, Codex CLI) would run a second router on top of
# the native one — see docs/getting-started.md. Wire this script into a
# SessionStart hook only on hosts without native skill routing.
#
# Every output path must emit the standard SessionStart envelope
# {"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "..."}}
# Hosts that validate hook output (Codex CLI, Claude Code) reject other shapes.
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 '{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "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 context "agent-skills loaded. Use the skill discovery flowchart to find the right skill for your task.
$CONTENT" \
'{hookSpecificOutput: {hookEventName: "SessionStart", additionalContext: $context}}'
else
echo '{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "agent-skills: using-agent-skills meta-skill not found. Skills may still be available individually."}}'
fi
|