claude-code-notify-lite 1.0.2 → 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/README.md +36 -1
- package/package.json +2 -1
- package/src/installer.js +85 -3
package/README.md
CHANGED
|
@@ -120,12 +120,35 @@ Claude Code Notify Lite integrates with Claude Code's hook system:
|
|
|
120
120
|
|
|
121
121
|
## Troubleshooting
|
|
122
122
|
|
|
123
|
+
### Debug Logs
|
|
124
|
+
|
|
125
|
+
View debug logs to diagnose issues:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Show recent logs
|
|
129
|
+
ccnotify logs
|
|
130
|
+
|
|
131
|
+
# Show more lines
|
|
132
|
+
ccnotify logs -n 100
|
|
133
|
+
|
|
134
|
+
# Clear logs
|
|
135
|
+
ccnotify logs -c
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Log file locations:
|
|
139
|
+
- **Windows:** `%APPDATA%\claude-code-notify-lite\debug.log`
|
|
140
|
+
- **macOS:** `~/Library/Logs/claude-code-notify-lite/debug.log`
|
|
141
|
+
- **Linux:** `~/.local/state/claude-code-notify-lite/debug.log`
|
|
142
|
+
|
|
123
143
|
### Command 'ccnotify' not found
|
|
124
144
|
|
|
125
145
|
After npm global install, if `ccnotify` is not recognized:
|
|
126
146
|
|
|
127
147
|
```bash
|
|
128
|
-
# Use npx instead
|
|
148
|
+
# Use npx instead (short form)
|
|
149
|
+
npx ccnotify install
|
|
150
|
+
|
|
151
|
+
# Or use full package name
|
|
129
152
|
npx claude-code-notify-lite install
|
|
130
153
|
|
|
131
154
|
# Or find npm global bin location
|
|
@@ -133,6 +156,18 @@ npm root -g
|
|
|
133
156
|
# Then add the parent bin directory to PATH
|
|
134
157
|
```
|
|
135
158
|
|
|
159
|
+
### Hook error: "path not found"
|
|
160
|
+
|
|
161
|
+
If you see garbled text like "ϵͳ找不到指定的路径" in hook errors:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Reinstall to update hook command with absolute paths
|
|
165
|
+
npx ccnotify uninstall
|
|
166
|
+
npx ccnotify install
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The latest version uses absolute paths (node.exe + cli.js) instead of npx, which resolves PATH issues in hook execution environment.
|
|
170
|
+
|
|
136
171
|
### Notification not showing
|
|
137
172
|
|
|
138
173
|
**macOS:**
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-notify-lite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Task completion notifications for Claude Code - Cross-platform, lightweight, and easy to use",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
+
"claude-code-notify-lite": "./bin/cli.js",
|
|
7
8
|
"ccnotify": "./bin/cli.js"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
package/src/installer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
3
4
|
const { getClaudeConfigDir, getConfigDir, ensureConfigDir, saveConfig, getDefaultConfig } = require('./config');
|
|
4
5
|
const logger = require('./logger');
|
|
5
6
|
|
|
@@ -7,11 +8,92 @@ function getClaudeSettingsPath() {
|
|
|
7
8
|
return path.join(getClaudeConfigDir(), 'settings.json');
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
function isNpxCache(filePath) {
|
|
12
|
+
const normalizedPath = filePath.toLowerCase().replace(/\\/g, '/');
|
|
13
|
+
return normalizedPath.includes('npm-cache/_npx') ||
|
|
14
|
+
normalizedPath.includes('npm-cache\\_npx') ||
|
|
15
|
+
normalizedPath.includes('.npm/_npx');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function copyCliToConfigDir() {
|
|
19
|
+
const configDir = getConfigDir();
|
|
20
|
+
|
|
21
|
+
ensureConfigDir();
|
|
22
|
+
|
|
23
|
+
const srcDir = path.join(configDir, 'src');
|
|
24
|
+
if (!fs.existsSync(srcDir)) {
|
|
25
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const filesToCopy = [
|
|
29
|
+
{ src: path.resolve(__dirname, 'index.js'), dest: path.join(srcDir, 'index.js') },
|
|
30
|
+
{ src: path.resolve(__dirname, 'notifier.js'), dest: path.join(srcDir, 'notifier.js') },
|
|
31
|
+
{ src: path.resolve(__dirname, 'audio.js'), dest: path.join(srcDir, 'audio.js') },
|
|
32
|
+
{ src: path.resolve(__dirname, 'config.js'), dest: path.join(srcDir, 'config.js') },
|
|
33
|
+
{ src: path.resolve(__dirname, 'logger.js'), dest: path.join(srcDir, 'logger.js') }
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
for (const file of filesToCopy) {
|
|
37
|
+
if (fs.existsSync(file.src)) {
|
|
38
|
+
fs.copyFileSync(file.src, file.dest);
|
|
39
|
+
logger.debug('Copied file', { src: file.src, dest: file.dest });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const assetsDir = path.resolve(__dirname, '..', 'assets');
|
|
44
|
+
const targetAssetsDir = path.join(configDir, 'assets');
|
|
45
|
+
if (!fs.existsSync(targetAssetsDir)) {
|
|
46
|
+
fs.mkdirSync(targetAssetsDir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const soundsDir = path.join(assetsDir, 'sounds');
|
|
50
|
+
const targetSoundsDir = path.join(targetAssetsDir, 'sounds');
|
|
51
|
+
if (fs.existsSync(soundsDir)) {
|
|
52
|
+
if (!fs.existsSync(targetSoundsDir)) {
|
|
53
|
+
fs.mkdirSync(targetSoundsDir, { recursive: true });
|
|
54
|
+
}
|
|
55
|
+
const sounds = fs.readdirSync(soundsDir);
|
|
56
|
+
for (const sound of sounds) {
|
|
57
|
+
fs.copyFileSync(path.join(soundsDir, sound), path.join(targetSoundsDir, sound));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const runScript = `const path = require('path');
|
|
62
|
+
const srcDir = path.join(__dirname, 'src');
|
|
63
|
+
const { run } = require(path.join(srcDir, 'index.js'));
|
|
64
|
+
run().catch(err => {
|
|
65
|
+
console.error('Notification error:', err.message);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
|
68
|
+
`;
|
|
69
|
+
const runScriptPath = path.join(configDir, 'run.js');
|
|
70
|
+
fs.writeFileSync(runScriptPath, runScript, 'utf8');
|
|
71
|
+
|
|
72
|
+
logger.info('Copied CLI files to config directory', { configDir });
|
|
73
|
+
return runScriptPath;
|
|
74
|
+
}
|
|
75
|
+
|
|
10
76
|
function getHookCommand() {
|
|
11
77
|
logger.info('Generating hook command');
|
|
12
78
|
|
|
13
|
-
const
|
|
14
|
-
|
|
79
|
+
const nodePath = process.execPath;
|
|
80
|
+
const originalCliPath = path.resolve(__dirname, '..', 'bin', 'cli.js');
|
|
81
|
+
|
|
82
|
+
let cliPath = originalCliPath;
|
|
83
|
+
let useLocalCopy = false;
|
|
84
|
+
let command;
|
|
85
|
+
|
|
86
|
+
if (isNpxCache(originalCliPath)) {
|
|
87
|
+
logger.warn('Running from npx cache, copying files to config directory');
|
|
88
|
+
console.log(' [INFO] Detected npx execution, copying files for persistence...');
|
|
89
|
+
cliPath = copyCliToConfigDir();
|
|
90
|
+
useLocalCopy = true;
|
|
91
|
+
command = `"${nodePath}" "${cliPath}"`;
|
|
92
|
+
} else {
|
|
93
|
+
command = `"${nodePath}" "${cliPath}" run`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
logger.info('Using absolute path command', { command, nodePath, cliPath, useLocalCopy });
|
|
15
97
|
return command;
|
|
16
98
|
}
|
|
17
99
|
|
|
@@ -131,7 +213,7 @@ function install(options = {}) {
|
|
|
131
213
|
console.log(' [OK] Configured Claude Code hooks');
|
|
132
214
|
|
|
133
215
|
console.log('\nInstallation complete!');
|
|
134
|
-
console.log('Run "npx
|
|
216
|
+
console.log('Run "ccnotify test" or "npx ccnotify test" to verify.\n');
|
|
135
217
|
|
|
136
218
|
logger.info('Install completed successfully');
|
|
137
219
|
return { success: true };
|