|
691 | 691 | echo "✅ Legacy Claude hooks are repaired to the current code-notify config" |
692 | 692 | ) |
693 | 693 |
|
| 694 | + ( |
| 695 | + unset CLAUDE_HOME |
| 696 | + mkdir -p "$HOME/.config/.claude" "$HOME/.claude/notifications" |
| 697 | + rm -f "$HOME/.claude/settings.json" "$HOME/.claude/hooks.json" |
| 698 | + printf '{}\n' > "$HOME/.config/.claude/settings.json" |
| 699 | + |
| 700 | + source "$SCRIPT_DIR/../lib/code-notify/utils/colors.sh" |
| 701 | + source "$SCRIPT_DIR/../lib/code-notify/utils/detect.sh" |
| 702 | + source "$SCRIPT_DIR/../lib/code-notify/core/config.sh" |
| 703 | + source "$SCRIPT_DIR/../lib/code-notify/commands/global.sh" |
| 704 | + |
| 705 | + is_tool_installed() { return 0; } |
| 706 | + |
| 707 | + if [[ "$GLOBAL_SETTINGS_FILE" != "$HOME/.config/.claude/settings.json" ]]; then |
| 708 | + echo "❌ Alternate Claude settings path was not detected" |
| 709 | + echo "Resolved settings path: $GLOBAL_SETTINGS_FILE" |
| 710 | + exit 1 |
| 711 | + fi |
| 712 | + |
| 713 | + cat > "$GLOBAL_SETTINGS_FILE" << EOF |
| 714 | +{ |
| 715 | + "hooks": { |
| 716 | + "Notification": [ |
| 717 | + { |
| 718 | + "matcher": "", |
| 719 | + "hooks": [ |
| 720 | + { |
| 721 | + "type": "command", |
| 722 | + "command": "powershell -ExecutionPolicy Bypass -File \"$HOME/.claude/notifications/notify.ps1\" notification" |
| 723 | + } |
| 724 | + ] |
| 725 | + } |
| 726 | + ], |
| 727 | + "Stop": [ |
| 728 | + { |
| 729 | + "matcher": "", |
| 730 | + "hooks": [ |
| 731 | + { |
| 732 | + "type": "command", |
| 733 | + "command": "powershell -ExecutionPolicy Bypass -File \"$HOME/.claude/notifications/notify.ps1\" stop" |
| 734 | + } |
| 735 | + ] |
| 736 | + } |
| 737 | + ] |
| 738 | + } |
| 739 | +} |
| 740 | +EOF |
| 741 | + |
| 742 | + echo "" |
| 743 | + echo "=== Testing alternate Claude settings path repair ===" |
| 744 | + |
| 745 | + if ! claude_global_hooks_need_repair; then |
| 746 | + echo "❌ Alternate-path Claude hooks were not flagged for repair" |
| 747 | + cat "$GLOBAL_SETTINGS_FILE" |
| 748 | + exit 1 |
| 749 | + fi |
| 750 | + echo "✅ Alternate-path Claude hooks are detected as stale" |
| 751 | + |
| 752 | + local output |
| 753 | + output=$("$SCRIPT_DIR/../bin/code-notify" repair-hooks 2>&1) || { |
| 754 | + echo "❌ code-notify repair-hooks failed for alternate Claude settings path" |
| 755 | + echo "$output" |
| 756 | + exit 1 |
| 757 | + } |
| 758 | + |
| 759 | + grep -qF "\"matcher\": \"idle_prompt\"" "$GLOBAL_SETTINGS_FILE" || { |
| 760 | + echo "❌ Alternate-path Claude config did not restore idle_prompt matcher" |
| 761 | + cat "$GLOBAL_SETTINGS_FILE" |
| 762 | + exit 1 |
| 763 | + } |
| 764 | + |
| 765 | + if ! grep -qF "notification claude" "$GLOBAL_SETTINGS_FILE"; then |
| 766 | + echo "❌ Alternate-path Claude config did not add the claude notification argument" |
| 767 | + cat "$GLOBAL_SETTINGS_FILE" |
| 768 | + exit 1 |
| 769 | + fi |
| 770 | + |
| 771 | + if ! grep -qF "stop claude" "$GLOBAL_SETTINGS_FILE"; then |
| 772 | + echo "❌ Alternate-path Claude config did not add the claude stop argument" |
| 773 | + cat "$GLOBAL_SETTINGS_FILE" |
| 774 | + exit 1 |
| 775 | + fi |
| 776 | + |
| 777 | + echo "✅ Alternate Claude settings path is repaired to the current code-notify config" |
| 778 | + ) |
| 779 | + |
694 | 780 | return $? |
695 | 781 | } |
696 | 782 |
|
|
0 commit comments