BurningTimesAi/scripts/hold_watch.sh

52 lines
1.9 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# UserPromptSubmit hook용 — HOLD·긴급 파일 변경 감지 경고
# 기획팀 Phase 3 HOLD 인지 실패 사례(2026-04-15)의 근본 방지
# C10-3 HOLD 충돌 처리 자동화
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
[ -z "$REPO_ROOT" ] && exit 0
THROTTLE_DIR="$HOME/.claude/.burningtimes_throttle"
mkdir -p "$THROTTLE_DIR" 2>/dev/null
HOLD_HASH_FILE="$THROTTLE_DIR/hold_files_hash"
# 현재 HOLD·긴급 파일 목록 수집 (자기 부서 + 소통 허브 inbox)
HOLD_FILES=$(find "$REPO_ROOT" -maxdepth 2 \( -name '🛑_*' -o -name '⚠_*' -o -name '🚨_*' \) 2>/dev/null | sort)
# 소통 허브 inbox의 HOLD·긴급 파일도 스캔 (타 부서 HOLD 양방향 전파)
CURRENT_DIR=$(pwd)
INBOX_DIRS=""
case "$CURRENT_DIR" in
*개발팀*) INBOX_DIRS="$REPO_ROOT/공유/소통/PM→개발팀 $REPO_ROOT/공유/소통/기획팀→개발팀" ;;
*기획팀*) INBOX_DIRS="$REPO_ROOT/공유/소통/PM→기획팀 $REPO_ROOT/공유/소통/개발팀→기획팀" ;;
*) INBOX_DIRS="$REPO_ROOT/공유/소통/개발팀→PM $REPO_ROOT/공유/소통/기획팀→PM" ;;
esac
for DIR in $INBOX_DIRS; do
if [ -d "$DIR" ]; then
INBOX_HOLD=$(find "$DIR" -maxdepth 1 \( -name '*HOLD*' -o -name '*긴급*' -o -name '*차단*' -o -name '*블로커*' \) 2>/dev/null | sort)
if [ -n "$INBOX_HOLD" ]; then
HOLD_FILES="$HOLD_FILES
$INBOX_HOLD"
fi
fi
done
HOLD_FILES=$(echo "$HOLD_FILES" | grep -v '^$' | sort)
if [ -z "$HOLD_FILES" ]; then
# HOLD 파일 없음 — 해시 초기화
echo "" > "$HOLD_HASH_FILE"
exit 0
fi
CURRENT_HASH=$(echo "$HOLD_FILES" | sha1sum 2>/dev/null | cut -d' ' -f1)
PREV_HASH=$(cat "$HOLD_HASH_FILE" 2>/dev/null)
if [ "$CURRENT_HASH" != "$PREV_HASH" ]; then
echo "🚨 [HOLD 감지] HOLD·긴급 파일 변경 발견:"
echo "$HOLD_FILES" | while read -r f; do
echo "$(basename "$f")"
done
echo "$CURRENT_HASH" > "$HOLD_HASH_FILE"
fi
exit 0