feat: surface cross-user messages prominently on sync

sync.sh: after pull, scan changed session logs for "## Note for" /
"## Message for" sections and print them in a highlighted block
before the sync summary. Forces attention on inter-team messages.

CLAUDE.md: document mandatory behavior — cross-user notes displayed
at top of response with full content, action items addressed before
continuing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 19:03:52 -07:00
parent 14e7354ba5
commit 4d80bd96d1
2 changed files with 61 additions and 2 deletions

View File

@@ -156,12 +156,54 @@ else
echo -e "${GREEN}[OK]${NC} Nothing to push."
fi
# Phase 5: Summary
# Phase 5: Scan pulled session logs for cross-user messages
# Look for "## Note for" or "## Message for" sections in any session log
# touched by incoming commits. Print them prominently so they aren't missed.
if [ "$INCOMING_COUNT" -gt 0 ] && [ -n "$LOCAL_BEFORE" ]; then
CHANGED_LOGS=$(git diff --name-only "$LOCAL_BEFORE"..HEAD -- '**/session-logs/*.md' 'session-logs/*.md' 2>/dev/null || true)
if [ -n "$CHANGED_LOGS" ]; then
NOTES_FOUND=0
for LOG_FILE in $CHANGED_LOGS; do
if [ -f "$LOG_FILE" ]; then
# Extract author from "## User" block and any "## Note for" / "## Message for" sections
NOTE_CONTENT=$(awk '
/^## (Note|Message) for /{ in_note=1; header=$0; next }
in_note && /^## /{ in_note=0 }
in_note{ buf=buf"\n"$0 }
END{ if(buf) print header buf }
' "$LOG_FILE")
if [ -n "$NOTE_CONTENT" ]; then
if [ "$NOTES_FOUND" -eq 0 ]; then
echo ""
echo -e "${YELLOW}============================================================${NC}"
echo -e "${YELLOW} MESSAGES FROM OTHER TEAM MEMBERS${NC}"
echo -e "${YELLOW}============================================================${NC}"
NOTES_FOUND=1
fi
LOG_AUTHOR=$(awk '/^- \*\*User:\*\*/{print; exit}' "$LOG_FILE" | sed 's/.*\*\*User:\*\* //')
LOG_DATE=$(basename "$LOG_FILE" | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}' | head -1)
echo ""
echo -e "${YELLOW} From: ${LOG_AUTHOR:-unknown} | ${LOG_DATE:-unknown date} | ${LOG_FILE}${NC}"
echo -e "${YELLOW}------------------------------------------------------------${NC}"
echo "$NOTE_CONTENT"
fi
fi
done
if [ "$NOTES_FOUND" -gt 0 ]; then
echo ""
echo -e "${YELLOW}============================================================${NC}"
echo -e "${YELLOW} Address the above before continuing with other work.${NC}"
echo -e "${YELLOW}============================================================${NC}"
echo ""
fi
fi
fi
# Phase 6: Summary
echo ""
echo "=== Sync Summary ==="
if [ "$INCOMING_COUNT" -gt 0 ]; then
# Count commits by author
INCOMING_AUTHORS=$(git log --format='%an' $LOCAL_BEFORE..HEAD 2>/dev/null | sort | uniq -c | sort -rn | awk '{printf "%s (%s), ", substr($0, index($0,$2)), $1}' | sed 's/, $//')
echo -e "${CYAN}Pulled in:${NC} $INCOMING_COUNT commit(s) — authors: ${INCOMING_AUTHORS:-unknown}"
fi