@landienzla/claude-code-notify 1.0.1 → 1.0.3
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/bin/cli.js +7 -1
- package/hooks/scripts/notify.sh +8 -7
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -90,7 +90,13 @@ function uninstall() {
|
|
|
90
90
|
function test() {
|
|
91
91
|
const input = JSON.stringify({ notification_message: 'Test notification from claude-code-notify' });
|
|
92
92
|
try {
|
|
93
|
-
|
|
93
|
+
const { spawnSync } = require('child_process');
|
|
94
|
+
const result = spawnSync('bash', [NOTIFY_SRC], {
|
|
95
|
+
input,
|
|
96
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
97
|
+
timeout: 15000
|
|
98
|
+
});
|
|
99
|
+
if (result.status !== 0) throw new Error(`exit code ${result.status}`);
|
|
94
100
|
console.log('Test notification sent!');
|
|
95
101
|
} catch (e) {
|
|
96
102
|
console.error('Test failed:', e.message);
|
package/hooks/scripts/notify.sh
CHANGED
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
INPUT=$(cat)
|
|
6
6
|
|
|
7
|
-
# Parse JSON
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
# Parse JSON and sanitize for safe shell usage
|
|
8
|
+
# - Strip characters that could break shell/PowerShell/XML/AppleScript interpolation
|
|
9
|
+
# - Truncate to 200 chars (OS notification display limit)
|
|
10
|
+
MESSAGE=$(printf '%s' "$INPUT" | python3 -c "
|
|
11
|
+
import sys, json, re
|
|
10
12
|
data = json.load(sys.stdin)
|
|
11
13
|
message = data.get('notification_message', data.get('message', 'Needs your attention'))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
message = re.sub(r'[^\w\s.,!?:;()\[\]{}/\\@#%+=\-]', '', message)
|
|
15
|
+
message = message[:200]
|
|
14
16
|
print(message)
|
|
15
17
|
" 2>/dev/null)
|
|
16
18
|
|
|
@@ -37,8 +39,7 @@ case "$(uname -s)" in
|
|
|
37
39
|
;;
|
|
38
40
|
Darwin*)
|
|
39
41
|
# macOS
|
|
40
|
-
|
|
41
|
-
osascript -e "display notification \"$ESCAPED\" with title \"Claude Code\"" 2>/dev/null || true
|
|
42
|
+
osascript -e "display notification \"$MESSAGE\" with title \"Claude Code\"" 2>/dev/null || true
|
|
42
43
|
;;
|
|
43
44
|
CYGWIN*|MINGW*|MSYS*)
|
|
44
45
|
# Native Windows (Git Bash / MSYS2)
|
package/package.json
CHANGED