claude-notification-plugin 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Michael Makarov
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Michael Makarov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,116 +1,121 @@
1
- # claude-notification-plugin
2
-
3
- Notifications for Claude Code task completion. Sends alerts to Telegram and Windows when Claude finishes working.
4
-
5
- ## Features
6
-
7
- - Windows desktop notifications (toast)
8
- - Telegram bot messages
9
- - Sound alert
10
- - Voice announcement (TTS)
11
- - Skips short tasks (< 15s by default)
12
- - Granular per-channel enable/disable (globally and per-project)
13
-
14
- ## Install
15
-
16
- ```bash
17
- npm install -g claude-notification-plugin
18
- claude-notify-install
19
- ```
20
-
21
- The installer will:
22
- 1. Ask for Telegram bot credentials (optional)
23
- 2. Create config at `~/.claude/notifier.config.json`
24
- 3. Register hooks in `~/.claude/settings.json`
25
-
26
- ## Configuration
27
-
28
- Config file: `~/.claude/notifier.config.json`
29
-
30
- ```json
31
- {
32
- "telegram": {
33
- "enabled": true,
34
- "token": "YOUR_BOT_TOKEN",
35
- "chatId": "YOUR_CHAT_ID",
36
- "deleteAfterHours": 24
37
- },
38
- "windowsNotification": {
39
- "enabled": true
40
- },
41
- "sound": {
42
- "enabled": true,
43
- "file": "C:/Windows/Media/notify.wav"
44
- },
45
- "voice": {
46
- "enabled": true
47
- },
48
- "minSeconds": 15
49
- }
50
- ```
51
-
52
- Each channel has an `enabled` flag (`true`/`false`) for global control.
53
-
54
- `deleteAfterHours` auto-delete old Telegram messages after the specified number of hours (default: `24`, set `0` to disable).
55
-
56
- Environment variables `TELEGRAM_TOKEN` and `TELEGRAM_CHAT_ID` override config file values.
57
-
58
- ### Per-channel environment variables
59
-
60
- These env vars override the global config per channel (`"1"` = on, `"0"` = off):
61
-
62
- | Variable | Channel |
63
- |--------------------------|----------------------------|
64
- | `CLAUDE_NOTIFY_TELEGRAM` | Telegram messages |
65
- | `CLAUDE_NOTIFY_WINDOWS` | Windows toast notifications|
66
- | `CLAUDE_NOTIFY_SOUND` | Sound alert |
67
- | `CLAUDE_NOTIFY_VOICE` | Voice announcement (TTS) |
68
-
69
- ### Per-project configuration
70
-
71
- Add to `.claude/settings.local.json` in the project root to control channels per project:
72
-
73
- ```json
74
- {
75
- "env": {
76
- "DISABLE_CLAUDE_NOTIFIER": 0,
77
- "CLAUDE_NOTIFY_TELEGRAM": 1,
78
- "CLAUDE_NOTIFY_WINDOWS": 1,
79
- "CLAUDE_NOTIFY_SOUND": 1,
80
- "CLAUDE_NOTIFY_VOICE": 1
81
- }
82
- }
83
- ```
84
-
85
- To disable all notifications for a project:
86
-
87
- ```json
88
- {
89
- "env": {
90
- "DISABLE_CLAUDE_NOTIFIER": "1"
91
- }
92
- }
93
- ```
94
-
95
- ## Telegram Setup
96
-
97
- 1. Open Telegram, find **@BotFather**
98
- 2. Send `/newbot`, follow prompts, pick a name
99
- 3. Copy the bot token (format: `123456789:ABCdef...`)
100
- 4. **Send any message to your new bot**
101
- 5. Open `https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates`
102
- 6. Find `"chat":{"id":123456789}` in the response — that's your Chat ID
103
- 7. Run `claude-notify-install` and enter the token and chat ID
104
-
105
- Alternative for Chat ID: add **@userinfobot** to a chat and it will reply with the ID.
106
-
107
- ## Uninstall
108
-
109
- ```bash
110
- claude-notify-uninstall
111
- npm uninstall -g claude-notification-plugin
112
- ```
113
-
114
- ## License
115
-
116
- MIT
1
+ # claude-notification-plugin
2
+
3
+ Notifications for Claude Code task completion. Sends alerts to Telegram and Windows when Claude finishes working.
4
+
5
+ ## Features
6
+
7
+ - Windows desktop notifications (toast)
8
+ - Telegram bot messages
9
+ - Sound alert
10
+ - Voice announcement (TTS)
11
+ - Separate notifications for task completion and waiting-for-input events
12
+ - Skips short tasks (< 15s by default)
13
+ - Granular per-channel enable/disable (globally and per-project)
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install -g claude-notification-plugin
19
+ claude-notify-install
20
+ ```
21
+
22
+ The installer will:
23
+ 1. Ask for Telegram bot credentials (optional)
24
+ 2. Create config at `~/.claude/notifier.config.json`
25
+ 3. Register hooks in `~/.claude/settings.json`
26
+
27
+ ## Configuration
28
+
29
+ Config file: `~/.claude/notifier.config.json`
30
+
31
+ ```json
32
+ {
33
+ "telegram": {
34
+ "enabled": true,
35
+ "token": "YOUR_BOT_TOKEN",
36
+ "chatId": "YOUR_CHAT_ID",
37
+ "deleteAfterHours": 24
38
+ },
39
+ "windowsNotification": {
40
+ "enabled": true
41
+ },
42
+ "sound": {
43
+ "enabled": true,
44
+ "file": "C:/Windows/Media/notify.wav"
45
+ },
46
+ "voice": {
47
+ "enabled": true
48
+ },
49
+ "minSeconds": 15,
50
+ "notifyOnWaiting": true
51
+ }
52
+ ```
53
+
54
+ Each channel has an `enabled` flag (`true`/`false`) for global control.
55
+
56
+ `deleteAfterHours` auto-delete old Telegram messages after the specified number of hours (default: `24`, set `0` to disable).
57
+
58
+ `notifyOnWaiting` send notifications when Claude is waiting for user input, e.g. permission prompts (default: `true`, set `false` to disable).
59
+
60
+ Environment variables `TELEGRAM_TOKEN` and `TELEGRAM_CHAT_ID` override config file values.
61
+
62
+ ### Per-channel environment variables
63
+
64
+ These env vars override the global config per channel (`"1"` = on, `"0"` = off):
65
+
66
+ | Variable | Channel |
67
+ |--------------------------|----------------------------|
68
+ | `CLAUDE_NOTIFY_TELEGRAM` | Telegram messages |
69
+ | `CLAUDE_NOTIFY_WINDOWS` | Windows toast notifications|
70
+ | `CLAUDE_NOTIFY_SOUND` | Sound alert |
71
+ | `CLAUDE_NOTIFY_VOICE` | Voice announcement (TTS) |
72
+ | `CLAUDE_NOTIFY_WAITING` | Waiting-for-input events |
73
+
74
+ ### Per-project configuration
75
+
76
+ Add to `.claude/settings.local.json` in the project root to control channels per project:
77
+
78
+ ```json
79
+ {
80
+ "env": {
81
+ "DISABLE_CLAUDE_NOTIFIER": 0,
82
+ "CLAUDE_NOTIFY_TELEGRAM": 1,
83
+ "CLAUDE_NOTIFY_WINDOWS": 1,
84
+ "CLAUDE_NOTIFY_SOUND": 1,
85
+ "CLAUDE_NOTIFY_VOICE": 1
86
+ }
87
+ }
88
+ ```
89
+
90
+ To disable all notifications for a project:
91
+
92
+ ```json
93
+ {
94
+ "env": {
95
+ "DISABLE_CLAUDE_NOTIFIER": "1"
96
+ }
97
+ }
98
+ ```
99
+
100
+ ## Telegram Setup
101
+
102
+ 1. Open Telegram, find **@BotFather**
103
+ 2. Send `/newbot`, follow prompts, pick a name
104
+ 3. Copy the bot token (format: `123456789:ABCdef...`)
105
+ 4. **Send any message to your new bot**
106
+ 5. Open `https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates`
107
+ 6. Find `"chat":{"id":123456789}` in the response — that's your Chat ID
108
+ 7. Run `claude-notify-install` and enter the token and chat ID
109
+
110
+ Alternative for Chat ID: add **@userinfobot** to a chat and it will reply with the ID.
111
+
112
+ ## Uninstall
113
+
114
+ ```bash
115
+ claude-notify-uninstall
116
+ npm uninstall -g claude-notification-plugin
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
package/bin/install.js CHANGED
@@ -1,178 +1,178 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'fs';
4
- import os from 'os';
5
- import path from 'path';
6
- import readline from 'readline';
7
-
8
- const home = os.homedir();
9
- const claudeDir = path.join(home, '.claude');
10
- const configPath = path.join(claudeDir, 'notifier.config.json');
11
- const settingsPath = path.join(claudeDir, 'settings.json');
12
-
13
- const HOOK_COMMAND = 'claude-notifier';
14
-
15
- // ----------------------
16
- // HELPERS
17
- // ----------------------
18
-
19
- function ask (rl, question) {
20
- return new Promise((resolve) => {
21
- rl.question(question, (answer) => resolve(answer.trim()));
22
- });
23
- }
24
-
25
- async function fetchChatId (token) {
26
- const url = `https://api.telegram.org/bot${token}/getUpdates`;
27
-
28
- try {
29
- const res = await fetch(url);
30
- const data = await res.json();
31
-
32
- if (!data.ok || !data.result?.length) {
33
- return null;
34
- }
35
-
36
- const msg = data.result[data.result.length - 1].message;
37
- if (msg?.chat?.id) {
38
- return String(msg.chat.id);
39
- }
40
- } catch {
41
- // silent fail
42
- }
43
-
44
- return null;
45
- }
46
-
47
- function addHook (settings, event) {
48
- if (!settings.hooks[event]) {
49
- settings.hooks[event] = [];
50
- }
51
-
52
- const exists = settings.hooks[event].some((matcher) =>
53
- matcher.hooks?.some((h) => h.command?.includes(HOOK_COMMAND)),
54
- );
55
-
56
- if (!exists) {
57
- settings.hooks[event].push({
58
- hooks: [
59
- {
60
- type: 'command',
61
- command: HOOK_COMMAND,
62
- },
63
- ],
64
- });
65
- }
66
- }
67
-
68
- // ----------------------
69
- // MAIN
70
- // ----------------------
71
-
72
- async function main () {
73
- const rl = readline.createInterface({
74
- input: process.stdin,
75
- output: process.stdout,
76
- });
77
-
78
- console.log('');
79
- console.log('Claude Notification Plugin - Setup');
80
- console.log('==================================');
81
- console.log('');
82
-
83
- // Telegram setup
84
- let token = '';
85
- let chatId = '';
86
-
87
- const useTelegram = await ask(rl, 'Configure Telegram? (y/N): ');
88
-
89
- if (useTelegram.toLowerCase() === 'y') {
90
- token = await ask(rl, 'Bot Token: ');
91
-
92
- if (token) {
93
- console.log('');
94
- console.log('Send any message to your bot in Telegram, then press Enter.');
95
- await ask(rl, '');
96
-
97
- console.log('Fetching Chat ID...');
98
- chatId = await fetchChatId(token);
99
-
100
- if (chatId) {
101
- console.log('Chat ID detected: ' + chatId);
102
- } else {
103
- console.log('Could not detect Chat ID automatically.');
104
- chatId = await ask(rl, 'Enter Chat ID manually: ');
105
- }
106
- }
107
- }
108
-
109
- rl.close();
110
-
111
- // Create config
112
- fs.mkdirSync(claudeDir, { recursive: true });
113
-
114
- const config = {
115
- telegram: {
116
- enabled: true,
117
- token,
118
- chatId,
119
- deleteAfterHours: 24,
120
- },
121
- windowsNotification: {
122
- enabled: true,
123
- },
124
- sound: {
125
- enabled: true,
126
- file: 'C:/Windows/Media/notify.wav',
127
- },
128
- voice: {
129
- enabled: true,
130
- },
131
- minSeconds: 15,
132
- };
133
-
134
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
135
-
136
- // Patch settings.json
137
- let settings = {};
138
-
139
- if (fs.existsSync(settingsPath)) {
140
- try {
141
- settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
142
- } catch {
143
- settings = {};
144
- }
145
- }
146
-
147
- settings.hooks = settings.hooks || {};
148
-
149
- addHook(settings, 'UserPromptSubmit');
150
- addHook(settings, 'Stop');
151
- addHook(settings, 'Notification');
152
-
153
- fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
154
-
155
- // Output
156
- console.log('');
157
- console.log('Installed!');
158
- console.log('');
159
- console.log('Hooks registered:');
160
- console.log(' - UserPromptSubmit (start timer)');
161
- console.log(' - Stop (task finished)');
162
- console.log(' - Notification (waiting for input)');
163
- console.log('');
164
- console.log('Config: ' + configPath);
165
-
166
- if (token) {
167
- console.log('Telegram: configured');
168
- } else {
169
- console.log('Telegram: skipped (edit config later)');
170
- }
171
-
172
- console.log('');
173
- console.log('To disable per project, add to .claude/settings.local.json:');
174
- console.log(' { "env": { "DISABLE_CLAUDE_NOTIFIER": "1" } }');
175
- console.log('');
176
- }
177
-
178
- main().then(() => 0);
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs';
4
+ import os from 'os';
5
+ import path from 'path';
6
+ import readline from 'readline';
7
+
8
+ const home = os.homedir();
9
+ const claudeDir = path.join(home, '.claude');
10
+ const configPath = path.join(claudeDir, 'notifier.config.json');
11
+ const settingsPath = path.join(claudeDir, 'settings.json');
12
+
13
+ const HOOK_COMMAND = 'claude-notifier';
14
+
15
+ // ----------------------
16
+ // HELPERS
17
+ // ----------------------
18
+
19
+ function ask (rl, question) {
20
+ return new Promise((resolve) => {
21
+ rl.question(question, (answer) => resolve(answer.trim()));
22
+ });
23
+ }
24
+
25
+ async function fetchChatId (token) {
26
+ const url = `https://api.telegram.org/bot${token}/getUpdates`;
27
+
28
+ try {
29
+ const res = await fetch(url);
30
+ const data = await res.json();
31
+
32
+ if (!data.ok || !data.result?.length) {
33
+ return null;
34
+ }
35
+
36
+ const msg = data.result[data.result.length - 1].message;
37
+ if (msg?.chat?.id) {
38
+ return String(msg.chat.id);
39
+ }
40
+ } catch {
41
+ // silent fail
42
+ }
43
+
44
+ return null;
45
+ }
46
+
47
+ function addHook (settings, event) {
48
+ if (!settings.hooks[event]) {
49
+ settings.hooks[event] = [];
50
+ }
51
+
52
+ const exists = settings.hooks[event].some((matcher) =>
53
+ matcher.hooks?.some((h) => h.command?.includes(HOOK_COMMAND)),
54
+ );
55
+
56
+ if (!exists) {
57
+ settings.hooks[event].push({
58
+ hooks: [
59
+ {
60
+ type: 'command',
61
+ command: HOOK_COMMAND,
62
+ },
63
+ ],
64
+ });
65
+ }
66
+ }
67
+
68
+ // ----------------------
69
+ // MAIN
70
+ // ----------------------
71
+
72
+ async function main () {
73
+ const rl = readline.createInterface({
74
+ input: process.stdin,
75
+ output: process.stdout,
76
+ });
77
+
78
+ console.log('');
79
+ console.log('Claude Notification Plugin - Setup');
80
+ console.log('==================================');
81
+ console.log('');
82
+
83
+ // Telegram setup
84
+ let token = '';
85
+ let chatId = '';
86
+
87
+ const useTelegram = await ask(rl, 'Configure Telegram? (y/N): ');
88
+
89
+ if (useTelegram.toLowerCase() === 'y') {
90
+ token = await ask(rl, 'Bot Token: ');
91
+
92
+ if (token) {
93
+ console.log('');
94
+ console.log('Send any message to your bot in Telegram, then press Enter.');
95
+ await ask(rl, '');
96
+
97
+ console.log('Fetching Chat ID...');
98
+ chatId = await fetchChatId(token);
99
+
100
+ if (chatId) {
101
+ console.log('Chat ID detected: ' + chatId);
102
+ } else {
103
+ console.log('Could not detect Chat ID automatically.');
104
+ chatId = await ask(rl, 'Enter Chat ID manually: ');
105
+ }
106
+ }
107
+ }
108
+
109
+ rl.close();
110
+
111
+ // Create config
112
+ fs.mkdirSync(claudeDir, { recursive: true });
113
+
114
+ const config = {
115
+ telegram: {
116
+ enabled: true,
117
+ token,
118
+ chatId,
119
+ deleteAfterHours: 24,
120
+ },
121
+ windowsNotification: {
122
+ enabled: true,
123
+ },
124
+ sound: {
125
+ enabled: true,
126
+ file: 'C:/Windows/Media/notify.wav',
127
+ },
128
+ voice: {
129
+ enabled: true,
130
+ },
131
+ minSeconds: 15,
132
+ };
133
+
134
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
135
+
136
+ // Patch settings.json
137
+ let settings = {};
138
+
139
+ if (fs.existsSync(settingsPath)) {
140
+ try {
141
+ settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
142
+ } catch {
143
+ settings = {};
144
+ }
145
+ }
146
+
147
+ settings.hooks = settings.hooks || {};
148
+
149
+ addHook(settings, 'UserPromptSubmit');
150
+ addHook(settings, 'Stop');
151
+ addHook(settings, 'Notification');
152
+
153
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
154
+
155
+ // Output
156
+ console.log('');
157
+ console.log('Installed!');
158
+ console.log('');
159
+ console.log('Hooks registered:');
160
+ console.log(' - UserPromptSubmit (start timer)');
161
+ console.log(' - Stop (task finished)');
162
+ console.log(' - Notification (waiting for input)');
163
+ console.log('');
164
+ console.log('Config: ' + configPath);
165
+
166
+ if (token) {
167
+ console.log('Telegram: configured');
168
+ } else {
169
+ console.log('Telegram: skipped (edit config later)');
170
+ }
171
+
172
+ console.log('');
173
+ console.log('To disable per project, add to .claude/settings.local.json:');
174
+ console.log(' { "env": { "DISABLE_CLAUDE_NOTIFIER": "1" } }');
175
+ console.log('');
176
+ }
177
+
178
+ main().then(() => 0);