claude-code-notify-lite 1.0.6 → 1.0.7
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 +66 -0
- package/package.json +1 -1
- package/src/installer.js +11 -0
package/bin/cli.js
CHANGED
|
@@ -310,4 +310,70 @@ program
|
|
|
310
310
|
console.log('');
|
|
311
311
|
});
|
|
312
312
|
|
|
313
|
+
program
|
|
314
|
+
.command('doctor')
|
|
315
|
+
.description('Diagnose hook configuration and show current settings')
|
|
316
|
+
.action(() => {
|
|
317
|
+
console.log(chalk.blue('Diagnosing claude-code-notify-lite...\n'));
|
|
318
|
+
|
|
319
|
+
const { getClaudeConfigDir } = safeRequire('../src/config', 'config');
|
|
320
|
+
const settingsPath = path.join(getClaudeConfigDir(), 'settings.json');
|
|
321
|
+
|
|
322
|
+
console.log(` Settings file: ${chalk.gray(settingsPath)}`);
|
|
323
|
+
|
|
324
|
+
if (!fs.existsSync(settingsPath)) {
|
|
325
|
+
console.log(chalk.yellow(' [!] Settings file not found'));
|
|
326
|
+
console.log(chalk.yellow(' Run "ccnotify install" to create hooks\n'));
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
try {
|
|
331
|
+
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
332
|
+
|
|
333
|
+
if (!settings.hooks || !settings.hooks.Stop) {
|
|
334
|
+
console.log(chalk.yellow(' [!] No Stop hooks configured'));
|
|
335
|
+
console.log(chalk.yellow(' Run "ccnotify install" to create hooks\n'));
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
console.log(chalk.green(' [OK] Stop hooks found\n'));
|
|
340
|
+
console.log(chalk.blue(' Current Stop hooks:'));
|
|
341
|
+
|
|
342
|
+
let hookCount = 0;
|
|
343
|
+
let hasValidHook = false;
|
|
344
|
+
|
|
345
|
+
settings.hooks.Stop.forEach((hookGroup, i) => {
|
|
346
|
+
if (hookGroup.hooks) {
|
|
347
|
+
hookGroup.hooks.forEach((hook, j) => {
|
|
348
|
+
hookCount++;
|
|
349
|
+
const cmd = hook.command || '(no command)';
|
|
350
|
+
const isValid = cmd.includes('cli.js') || cmd.includes('run.js') || cmd.includes('ccnotify');
|
|
351
|
+
|
|
352
|
+
if (isValid) {
|
|
353
|
+
hasValidHook = true;
|
|
354
|
+
console.log(chalk.green(` ${hookCount}. [VALID] ${cmd}`));
|
|
355
|
+
} else {
|
|
356
|
+
console.log(chalk.red(` ${hookCount}. [INVALID] ${cmd}`));
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
console.log('');
|
|
363
|
+
|
|
364
|
+
if (!hasValidHook) {
|
|
365
|
+
console.log(chalk.red(' [ERROR] No valid notification hooks found'));
|
|
366
|
+
console.log(chalk.yellow(' The hook command appears incomplete or corrupted'));
|
|
367
|
+
console.log(chalk.yellow(' Run "ccnotify repair" to fix\n'));
|
|
368
|
+
} else if (hookCount > 1) {
|
|
369
|
+
console.log(chalk.yellow(` [WARN] Multiple hooks detected (${hookCount})`));
|
|
370
|
+
console.log(chalk.yellow(' Run "ccnotify repair" to clean up\n'));
|
|
371
|
+
} else {
|
|
372
|
+
console.log(chalk.green(' [OK] Configuration looks good\n'));
|
|
373
|
+
}
|
|
374
|
+
} catch (err) {
|
|
375
|
+
console.log(chalk.red(` [ERROR] Failed to parse settings: ${err.message}\n`));
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
313
379
|
program.parse();
|
package/package.json
CHANGED
package/src/installer.js
CHANGED
|
@@ -79,6 +79,11 @@ function getHookCommand() {
|
|
|
79
79
|
const nodePath = process.execPath;
|
|
80
80
|
const originalCliPath = path.resolve(__dirname, '..', 'bin', 'cli.js');
|
|
81
81
|
|
|
82
|
+
if (!fs.existsSync(originalCliPath)) {
|
|
83
|
+
logger.error('CLI script not found', { originalCliPath });
|
|
84
|
+
throw new Error(`CLI script not found: ${originalCliPath}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
let cliPath = originalCliPath;
|
|
83
88
|
let useLocalCopy = false;
|
|
84
89
|
let command;
|
|
@@ -93,6 +98,11 @@ function getHookCommand() {
|
|
|
93
98
|
command = `"${nodePath}" "${cliPath}" run`;
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
if (!command.includes('cli.js') && !command.includes('run.js')) {
|
|
102
|
+
logger.error('Invalid hook command generated', { command, nodePath, cliPath });
|
|
103
|
+
throw new Error(`Invalid hook command: ${command}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
96
106
|
logger.info('Using absolute path command', { command, nodePath, cliPath, useLocalCopy });
|
|
97
107
|
return command;
|
|
98
108
|
}
|
|
@@ -240,6 +250,7 @@ function install(options = {}) {
|
|
|
240
250
|
|
|
241
251
|
writeClaudeSettings(settings);
|
|
242
252
|
console.log(' [OK] Configured Claude Code hooks');
|
|
253
|
+
console.log(` [OK] Hook command: ${hookCommand}`);
|
|
243
254
|
|
|
244
255
|
console.log('\nInstallation complete!');
|
|
245
256
|
console.log('Run "ccnotify test" or "npx ccnotify test" to verify.\n');
|