agent/codex/code/scripts/ensure-commit.sh
Snider 466fe9f5a6 feat(codex): mirror claude plugins and ethics modal
Summary:\n- added Codex marketplace registry plus awareness/ethics/guardrails sub-plugins\n- mirrored Claude plugin commands/scripts/hooks into codex api/ci/code/collect/coolify/core/issue/perf/qa/review/verify\n- embedded Axioms of Life ethics modal, guardrails, and kernel files under codex/ethics\n- added Codex parity report, improvements list, and MCP integration plan\n- extended Gemini MCP tools and docs for Codex awareness
2026-02-05 20:13:01 +00:00

44 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
# Ensure work ends with a commit during /core:yes mode
#
# Stop hook that blocks if uncommitted changes exist.
# Prevents Claude from stopping before work is committed.
read -r input
STOP_ACTIVE=$(echo "$input" | jq -r '.stop_hook_active // false')
# Prevent infinite loop - if we already blocked once, allow stop
if [ "$STOP_ACTIVE" = "true" ]; then
exit 0
fi
# Check for uncommitted changes
UNSTAGED=$(git diff --name-only 2>/dev/null | wc -l | tr -d ' ')
STAGED=$(git diff --cached --name-only 2>/dev/null | wc -l | tr -d ' ')
UNTRACKED=$(git ls-files --others --exclude-standard 2>/dev/null | grep -v '^\.idea/' | wc -l | tr -d ' ')
TOTAL=$((UNSTAGED + STAGED + UNTRACKED))
if [ "$TOTAL" -gt 0 ]; then
# Build file list for context
FILES=""
if [ "$UNSTAGED" -gt 0 ]; then
FILES="$FILES\nModified: $(git diff --name-only 2>/dev/null | head -3 | tr '\n' ' ')"
fi
if [ "$STAGED" -gt 0 ]; then
FILES="$FILES\nStaged: $(git diff --cached --name-only 2>/dev/null | head -3 | tr '\n' ' ')"
fi
if [ "$UNTRACKED" -gt 0 ]; then
FILES="$FILES\nUntracked: $(git ls-files --others --exclude-standard 2>/dev/null | grep -v '^\.idea/' | head -3 | tr '\n' ' ')"
fi
cat << EOF
{
"decision": "block",
"reason": "You have $TOTAL uncommitted changes. Please commit them before stopping.\n$FILES\n\nUse: git add <files> && git commit -m 'type(scope): description'"
}
EOF
else
# No changes, allow stop
exit 0
fi