auto-update-daily-20260202
1#!/usr/bin/env bash
2# Wrapper script to translate Copilot hook JSON format to Claude Code format
3# Usage: copilot-to-claude.sh <claude-hooks-binary>
4#
5# Copilot format:
6# { "toolName": "bash", "toolArgs": "{\"command\":\"...\"}", "toolResult": {...} }
7#
8# Claude Code format:
9# { "tool_name": "Bash", "tool_input": {"command": "..."}, "tool_response": {...} }
10
11set -euo pipefail
12
13BINARY="${1:-}"
14if [[ -z "$BINARY" ]]; then
15 echo "Usage: $0 <claude-hooks-binary>" >&2
16 exit 1
17fi
18
19# Read stdin
20INPUT=$(cat)
21
22# Check if we have input
23if [[ -z "$INPUT" ]]; then
24 exit 0
25fi
26
27# Transform Copilot format to Claude Code format using jq
28# - toolName -> tool_name (capitalize first letter for Claude Code convention)
29# - toolArgs (string) -> tool_input (parsed object)
30# - toolResult -> tool_response
31TRANSFORMED=$(echo "$INPUT" | jq -c '
32{
33 tool_name: (.toolName | split("") | .[0:1] | map(ascii_upcase) | join("") + (.toolName | .[1:])),
34 tool_input: (if .toolArgs then (.toolArgs | fromjson) else {} end),
35 tool_response: (.toolResult // {}),
36 conversation_id: (.sessionId // "copilot")
37}
38' 2>/dev/null) || {
39 # If jq fails, just pass through empty and let binary handle it
40 exit 0
41}
42
43# Call the Claude hooks binary with transformed input
44echo "$TRANSFORMED" | "$BINARY"
45exit $?