feat: advance repository records and provenance
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
parent
329af60753
commit
35e86d7b85
24 changed files with 1618 additions and 51 deletions
78
.githooks/prepare-commit-msg
Executable file
78
.githooks/prepare-commit-msg
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
#!/bin/sh
|
||||
# Repo Manager coding-assistant provenance hook. This hook must never block Git.
|
||||
|
||||
message_file=${1:-}
|
||||
[ -n "$message_file" ] && [ -f "$message_file" ] || exit 0
|
||||
|
||||
assistant=${ASSISTANT_NAME:-}
|
||||
model=${ASSISTANT_MODEL:-}
|
||||
process=${ASSISTANT_PROCESS:-}
|
||||
session=${ASSISTANT_SESSION:-}
|
||||
|
||||
if [ -z "$assistant" ] && { [ "${CLAUDECODE:-}" = "1" ] || [ -n "${CLAUDE_CODE_SESSION_ID:-}" ]; }; then
|
||||
assistant=claude-code
|
||||
session=${session:-${CLAUDE_CODE_SESSION_ID:-}}
|
||||
process=${process:-${CLAUDE_PID:-}}
|
||||
fi
|
||||
|
||||
if [ -z "$assistant" ] && { [ -n "${CODEX_SESSION_ID:-}" ] || [ -n "${CODEX_THREAD_ID:-}" ]; }; then
|
||||
assistant=codex
|
||||
session=${session:-${CODEX_SESSION_ID:-${CODEX_THREAD_ID:-}}}
|
||||
process=${process:-${CODEX_PID:-}}
|
||||
fi
|
||||
|
||||
if [ -z "$assistant" ] && { [ -n "${GROK_SESSION_ID:-}" ] || [ "${GROKCODE:-}" = "1" ] || [ "${GROK_CODE:-}" = "1" ]; }; then
|
||||
assistant=grok
|
||||
session=${session:-${GROK_SESSION_ID:-}}
|
||||
process=${process:-${GROK_PID:-}}
|
||||
fi
|
||||
|
||||
[ -n "$assistant" ] || exit 0
|
||||
|
||||
if [ -z "$model" ] && [ "$assistant" = "claude-code" ]; then
|
||||
claude_settings=${CLAUDE_SETTINGS_PATH:-${HOME:-}/.claude/settings.json}
|
||||
if [ -f "$claude_settings" ]; then
|
||||
model=$(sed -n 's/^[[:space:]]*"model"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$claude_settings" 2>/dev/null | head -1)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$model" ] && [ "$assistant" = "codex" ]; then
|
||||
codex_config=${CODEX_HOME:-${HOME:-}/.codex}/config.toml
|
||||
if [ -f "$codex_config" ]; then
|
||||
model=$(sed -n 's/^[[:space:]]*model[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' "$codex_config" 2>/dev/null | head -1)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$model" ] && [ "$assistant" = "grok" ]; then
|
||||
model=${GROK_DEFAULT_MODEL:-}
|
||||
fi
|
||||
|
||||
if [ -n "$process" ]; then
|
||||
case "$process" in
|
||||
*@*) : ;;
|
||||
*) process="$process@$(hostname 2>/dev/null || printf unknown-host)" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
have_assistant_trailer=0
|
||||
if grep -Eiq '^Assistant(-Model|-Process|-Session)?:[[:space:]]*' "$message_file" 2>/dev/null; then
|
||||
have_assistant_trailer=1
|
||||
fi
|
||||
|
||||
add_trailer() {
|
||||
token=$1
|
||||
value=$2
|
||||
[ -n "$value" ] || return 0
|
||||
grep -Eiq "^${token}:[[:space:]]*" "$message_file" 2>/dev/null && return 0
|
||||
if [ "$have_assistant_trailer" -eq 0 ]; then
|
||||
printf '\n' >>"$message_file" 2>/dev/null || return 0
|
||||
have_assistant_trailer=1
|
||||
fi
|
||||
printf '%s: %s\n' "$token" "$value" >>"$message_file" 2>/dev/null || true
|
||||
}
|
||||
|
||||
add_trailer Assistant "$assistant"
|
||||
add_trailer Assistant-Model "$model"
|
||||
add_trailer Assistant-Process "$process"
|
||||
add_trailer Assistant-Session "$session"
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue