@landienzla/claude-code-notify 1.0.3 → 1.0.5
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/README.md +4 -4
- package/bin/cli.js +30 -0
- package/hooks/scripts/notify.sh +8 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,10 +54,13 @@ Plugin mode requires no changes to your `settings.json` — the hook is loaded a
|
|
|
54
54
|
| Command | Description |
|
|
55
55
|
|---------|-------------|
|
|
56
56
|
| `claude-code-notify setup` | Install notification hook into `~/.claude/` |
|
|
57
|
+
| `claude-code-notify dry-run` | Preview what setup will change (no writes) |
|
|
57
58
|
| `claude-code-notify test` | Send a test notification |
|
|
58
59
|
| `claude-code-notify uninstall` | Remove notification hook and script |
|
|
59
60
|
| `claude-code-notify help` | Show usage info |
|
|
60
61
|
|
|
62
|
+
Run `dry-run` first to see exactly what files will be created/modified before committing.
|
|
63
|
+
|
|
61
64
|
## How It Works
|
|
62
65
|
|
|
63
66
|
Claude Code fires a [`Notification`](https://docs.anthropic.com/en/docs/claude-code/hooks) hook whenever it needs your attention. This package provides a handler that:
|
|
@@ -78,7 +81,7 @@ The hook fires on all notification types:
|
|
|
78
81
|
|
|
79
82
|
## Requirements
|
|
80
83
|
|
|
81
|
-
- **
|
|
84
|
+
- **Node.js** — already installed if you're using npm
|
|
82
85
|
- **Linux:** `libnotify-bin` for `notify-send`
|
|
83
86
|
```bash
|
|
84
87
|
# Debian/Ubuntu
|
|
@@ -116,9 +119,6 @@ npx @landienzla/claude-code-notify uninstall
|
|
|
116
119
|
- Install `libnotify-bin` (see Requirements)
|
|
117
120
|
- Ensure a notification daemon is running (e.g. `dunst`, `mako`, GNOME/KDE built-in)
|
|
118
121
|
|
|
119
|
-
**Generic "Needs your attention" message instead of context:**
|
|
120
|
-
- Ensure Python 3 is installed and on your PATH
|
|
121
|
-
|
|
122
122
|
## License
|
|
123
123
|
|
|
124
124
|
[MIT](LICENSE)
|
package/bin/cli.js
CHANGED
|
@@ -28,6 +28,30 @@ const HOOK_CONFIG = {
|
|
|
28
28
|
]
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
function dryRun() {
|
|
32
|
+
console.log('Dry run — no changes will be made.\n');
|
|
33
|
+
console.log('The following changes would be applied:\n');
|
|
34
|
+
console.log(` 1. Copy notification script to:`);
|
|
35
|
+
console.log(` ${NOTIFY_DEST}\n`);
|
|
36
|
+
console.log(` 2. Add Notification hook to:`);
|
|
37
|
+
console.log(` ${SETTINGS_PATH}\n`);
|
|
38
|
+
console.log(' Hook config:');
|
|
39
|
+
console.log(JSON.stringify(HOOK_CONFIG, null, 2).split('\n').map(l => ' ' + l).join('\n'));
|
|
40
|
+
|
|
41
|
+
if (fs.existsSync(SETTINGS_PATH)) {
|
|
42
|
+
try {
|
|
43
|
+
const settings = JSON.parse(fs.readFileSync(SETTINGS_PATH, 'utf8'));
|
|
44
|
+
if (settings.hooks && settings.hooks.Notification) {
|
|
45
|
+
console.log('\n Warning: Existing Notification hook will be replaced.');
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.log(`\n Warning: ${SETTINGS_PATH} is invalid JSON and will be backed up.`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.log('\nRun "claude-code-notify setup" to apply these changes.');
|
|
53
|
+
}
|
|
54
|
+
|
|
31
55
|
function setup() {
|
|
32
56
|
if (!fs.existsSync(CLAUDE_DIR)) {
|
|
33
57
|
console.error(`Error: ${CLAUDE_DIR} does not exist. Is Claude Code installed?`);
|
|
@@ -53,6 +77,10 @@ function setup() {
|
|
|
53
77
|
}
|
|
54
78
|
}
|
|
55
79
|
|
|
80
|
+
if (settings.hooks && settings.hooks.Notification) {
|
|
81
|
+
console.log(' Replacing existing Notification hook.');
|
|
82
|
+
}
|
|
83
|
+
|
|
56
84
|
if (!settings.hooks) settings.hooks = {};
|
|
57
85
|
settings.hooks.Notification = HOOK_CONFIG.Notification;
|
|
58
86
|
|
|
@@ -110,6 +138,7 @@ claude-code-notify - Desktop notifications for Claude Code
|
|
|
110
138
|
|
|
111
139
|
Usage:
|
|
112
140
|
claude-code-notify setup Install notification hook into ~/.claude/
|
|
141
|
+
claude-code-notify dry-run Preview what setup will change (no writes)
|
|
113
142
|
claude-code-notify uninstall Remove notification hook from ~/.claude/
|
|
114
143
|
claude-code-notify test Send a test notification
|
|
115
144
|
claude-code-notify help Show this help
|
|
@@ -123,6 +152,7 @@ const command = process.argv[2];
|
|
|
123
152
|
|
|
124
153
|
switch (command) {
|
|
125
154
|
case 'setup': setup(); break;
|
|
155
|
+
case 'dry-run': dryRun(); break;
|
|
126
156
|
case 'uninstall': uninstall(); break;
|
|
127
157
|
case 'test': test(); break;
|
|
128
158
|
case 'help': case '--help': case '-h': case undefined: help(); break;
|
package/hooks/scripts/notify.sh
CHANGED
|
@@ -7,13 +7,14 @@ INPUT=$(cat)
|
|
|
7
7
|
# Parse JSON and sanitize for safe shell usage
|
|
8
8
|
# - Strip characters that could break shell/PowerShell/XML/AppleScript interpolation
|
|
9
9
|
# - Truncate to 200 chars (OS notification display limit)
|
|
10
|
-
MESSAGE=$(printf '%s' "$INPUT" |
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
MESSAGE=$(printf '%s' "$INPUT" | node -e "
|
|
11
|
+
let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{
|
|
12
|
+
try{const o=JSON.parse(d);
|
|
13
|
+
let m=o.notification_message||o.message||'Needs your attention';
|
|
14
|
+
m=m.replace(/[^\w\s.,!?:;()\[\]{}\/\\@#%+=\-]/g,'').slice(0,200);
|
|
15
|
+
process.stdout.write(m);
|
|
16
|
+
}catch(e){process.stdout.write('Needs your attention')}
|
|
17
|
+
});
|
|
17
18
|
" 2>/dev/null)
|
|
18
19
|
|
|
19
20
|
# Fallback if python3 parsing fails
|
package/package.json
CHANGED