From b84c57e29775d002e61d8902c30bee3e1a4d1083 Mon Sep 17 00:00:00 2001 From: zhongwei Date: Sat, 29 Nov 2025 09:37:45 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 15 ++++ README.md | 3 + commands/setup-notifications.md | 148 ++++++++++++++++++++++++++++++++ hooks/hooks.json | 49 +++++++++++ plugin.lock.json | 49 +++++++++++ 5 files changed, 264 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/setup-notifications.md create mode 100644 hooks/hooks.json create mode 100644 plugin.lock.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..35e69db --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "claude-notifications", + "description": "Smart notifications for Claude Code task statuses with desktop notifications, webhooks, and sound alerts", + "version": "1.0.3", + "author": { + "name": "777genius", + "email": "[email protected]" + }, + "commands": [ + "./commands/setup-notifications.md" + ], + "hooks": [ + "./hooks/hooks.json" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b77c9a2 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# claude-notifications + +Smart notifications for Claude Code task statuses with desktop notifications, webhooks, and sound alerts diff --git a/commands/setup-notifications.md b/commands/setup-notifications.md new file mode 100644 index 0000000..f7bc8af --- /dev/null +++ b/commands/setup-notifications.md @@ -0,0 +1,148 @@ +--- +description: Interactive setup wizard for claude-notifications plugin +allowed-tools: Bash, AskUserQuestion, Write, Read +--- + +# Setup Notifications Plugin + +You are helping the user configure the claude-notifications plugin interactively. Follow these steps carefully: + +## Step 1: Detect System Sounds + +First, detect the operating system and find available system sounds: + +**For macOS:** +- List sounds in `/System/Library/Sounds/` +- Common sounds: Glass.aiff, Ping.aiff, Pop.aiff, Purr.aiff, Funk.aiff, Hero.aiff, Sosumi.aiff, Basso.aiff, Blow.aiff, Frog.aiff, Submarine.aiff, Bottle.aiff, Morse.aiff, Tink.aiff + +**For Linux:** +- Check `/usr/share/sounds/` and subdirectories +- Look for .ogg, .wav files + +## Step 2: Present Available Sounds + +Show the user a formatted list of all available sounds with descriptions. For example: + +**Available System Sounds:** +- **Glass** - Crisp, clean chime +- **Ping** - Subtle ping sound +- **Hero** - Triumphant fanfare +- **Funk** - Distinctive funk sound +- **Pop** - Quick pop sound +- **Purr** - Gentle purr +- **Basso** - Deep bass sound +- **Sosumi** - Pleasant notification +- **Tink** - Light metallic sound +- **Frog** - Unique ribbit sound +- **Submarine** - Sonar-like ping +- (etc.) + +Tell the user: "You can ask me to play any sound before making your choice. For example, say 'play Glass' or 'прослушать Hero'. When you're ready, I'll ask you to select sounds for each notification type." + +## Step 3: Interactive Sound Selection + +For EACH notification type (Task Complete, Review Complete, Question, Plan Ready): + +1. **Announce the notification type** you're configuring +2. **Remind the user** they can request to play any sound (e.g., "play Funk", "прослушать Ping") +3. **Wait for user to explore sounds** - If user requests to play a sound: + - Play it using bash: `afplay /System/Library/Sounds/[SoundName].aiff` (macOS) or `paplay /usr/share/sounds/[file]` (Linux) + - Ask if they want to hear more sounds or are ready to choose +4. **When user is ready**, use AskUserQuestion to gather their final choice + +## Step 4: Ask Confirmation Questions + +After the user has explored sounds for each notification type, use AskUserQuestion to confirm their selections. Structure the questions as follows: + +**For each notification type (Task Complete, Review Complete, Question, Plan Ready):** +- **question**: "Which sound would you like for '[Type]' notifications?" +- **header**: "[Type]" +- **multiSelect**: false +- **options**: List all available system sounds with brief descriptions + +**Example options format:** +- Glass - "Crisp, clean chime" +- Ping - "Subtle ping sound" +- Hero - "Triumphant fanfare" +- Funk - "Distinctive funk sound" +- Pop - "Quick pop sound" +- Purr - "Gentle purr" +- Basso - "Deep bass sound" +- Sosumi - "Pleasant notification" +- (include all detected sounds) + +### Webhook Configuration +**question**: "Do you want to enable webhook notifications?" +**header**: "Webhook" +**multiSelect**: false +**options**: +- "No" - "Desktop notifications only" +- "Yes, JSON format" - "Send structured JSON to webhook" +- "Yes, text format" - "Send plain text to webhook" + +**If webhook is enabled**, inform the user: +"Please edit `config/config.json` manually to add your webhook URL and any custom headers." + +## Step 5: Create Configuration File + +Based on the user's answers, create the `config/config.json` file. Use the following template: + +```json +{ + "notifications": { + "desktop": { + "enabled": true, + "sound": true + }, + "webhook": { + "enabled": , + "url": "", + "format": "", + "headers": {} + } + }, + "statuses": { + "task_complete": { + "title": "✅ Task Completed", + "sound": "/System/Library/Sounds/", + "keywords": ["completed", "done", "finished", "успешно", "завершен"] + }, + "review_complete": { + "title": "🔍 Review Completed", + "sound": "/System/Library/Sounds/", + "keywords": ["review", "ревью", "analyzed", "проверка", "analysis"] + }, + "question": { + "title": "❓ Question", + "sound": "/System/Library/Sounds/", + "keywords": ["question", "вопрос", "clarify"] + }, + "plan_ready": { + "title": "📋 Plan Ready", + "sound": "/System/Library/Sounds/", + "keywords": ["plan", "план", "strategy"] + } + } +} +``` + +**IMPORTANT**: +- Get the plugin directory path using: `cd "$(dirname "$(readlink -f "$0" || echo "$0")")"` +- Write the config to `config/config.json` relative to the plugin root directory +- For Linux, adjust sound paths to use `/usr/share/sounds/` instead + +## Step 6: Confirm Success + +After creating the config file: +1. Show the user the generated configuration +2. Confirm setup is complete +3. Suggest they can re-run `/setup-notifications` anytime to reconfigure +4. If webhook was enabled, remind them to edit the URL in `config/config.json` + +## Step 7: Test Notification + +Offer to test the notification by playing the selected "task_complete" sound to confirm it works. + +--- + +**Remember**: Be friendly, clear, and help the user understand each step. Make this setup experience smooth and enjoyable! diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..9b04a36 --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,49 @@ +{ + "hooks": { + "PreToolUse": [ + { + "matcher": "ExitPlanMode|AskUserQuestion", + "hooks": [ + { + "type": "command", + "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/notification-handler.sh PreToolUse", + "timeout": 10 + } + ] + } + ], + "Notification": [ + { + "hooks": [ + { + "type": "command", + "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/notification-handler.sh Notification", + "timeout": 10 + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/notification-handler.sh Stop", + "timeout": 10 + } + ] + } + ], + "SubagentStop": [ + { + "hooks": [ + { + "type": "command", + "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/notification-handler.sh SubagentStop", + "timeout": 10 + } + ] + } + ] + } +} diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..2162a34 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,49 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:777genius/claude-notifications:", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "867d57cbbf9ffeae61afa3e820572d1ebfc2b1b5", + "treeHash": "b37f0558a939222e08bb3119f9bbacf147c97058418e2ec37973635490ab97b0", + "generatedAt": "2025-11-28T10:24:45.608236Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "claude-notifications", + "description": "Smart notifications for Claude Code task statuses with desktop notifications, webhooks, and sound alerts", + "version": "1.0.3" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "f539b5010b5eff268e0e8f67cad9de406947d2f5debf5fc78d83cbd2c71bfcbb" + }, + { + "path": "hooks/hooks.json", + "sha256": "936ad75d21eca5366f2a9386e87a297c5bb26b0a04457a424359a509d6f35043" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "bf860cead25c9b216082f2399898487173df9caace6b43e6148d2b6941fcdced" + }, + { + "path": "commands/setup-notifications.md", + "sha256": "f96eed405d578d7b7f1c789d09b5e44afeb47fea5bf16feb26925c769e69540b" + } + ], + "dirSha256": "b37f0558a939222e08bb3119f9bbacf147c97058418e2ec37973635490ab97b0" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file