cc-hook-registry 3.0.0 → 3.1.0
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 +29 -1
- package/index.mjs +61 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,11 +19,39 @@ npx cc-hook-registry search database
|
|
|
19
19
|
```bash
|
|
20
20
|
npx cc-hook-registry search <keyword> # Find hooks by keyword
|
|
21
21
|
npx cc-hook-registry browse [category] # Browse by category
|
|
22
|
-
npx cc-hook-registry install <id> # Install a hook
|
|
22
|
+
npx cc-hook-registry install <id> # Install a hook (direct download)
|
|
23
|
+
npx cc-hook-registry recommend # Recommend hooks for your project
|
|
23
24
|
npx cc-hook-registry info <id> # Show hook details
|
|
24
25
|
npx cc-hook-registry stats # Registry statistics
|
|
25
26
|
```
|
|
26
27
|
|
|
28
|
+
### recommend
|
|
29
|
+
|
|
30
|
+
Scans your project for `package.json`, `requirements.txt`, `Dockerfile`, `.env`, `Gemfile`, `artisan` and recommends hooks based on your tech stack:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
npx cc-hook-registry recommend
|
|
34
|
+
|
|
35
|
+
✓ destructive-guard (installed)
|
|
36
|
+
Essential — prevents rm -rf disasters
|
|
37
|
+
|
|
38
|
+
○ auto-approve-build
|
|
39
|
+
Node.js project detected
|
|
40
|
+
Install: npx cc-hook-registry install auto-approve-build
|
|
41
|
+
|
|
42
|
+
○ block-database-wipe
|
|
43
|
+
Prisma detected — protect against migrate reset
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### install (direct download)
|
|
47
|
+
|
|
48
|
+
Hooks are downloaded directly from GitHub — no `cc-safe-setup` dependency needed:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx cc-hook-registry install block-database-wipe
|
|
52
|
+
# Downloads script, saves to ~/.claude/hooks/, registers in settings.json
|
|
53
|
+
```
|
|
54
|
+
|
|
27
55
|
## Categories
|
|
28
56
|
|
|
29
57
|
| Category | Hooks | What They Do |
|
package/index.mjs
CHANGED
|
@@ -113,6 +113,7 @@ if (!command || command === '--help' || command === '-h') {
|
|
|
113
113
|
install <id> Install a hook
|
|
114
114
|
info <id> Show hook details
|
|
115
115
|
recommend Recommend hooks for current project
|
|
116
|
+
outdated Check installed hooks for updates
|
|
116
117
|
stats Registry statistics
|
|
117
118
|
|
|
118
119
|
Examples:
|
|
@@ -367,6 +368,66 @@ else if (command === 'recommend') {
|
|
|
367
368
|
console.log();
|
|
368
369
|
}
|
|
369
370
|
|
|
371
|
+
else if (command === 'outdated') {
|
|
372
|
+
console.log();
|
|
373
|
+
console.log(c.bold + ' Checking installed hooks for updates...' + c.reset);
|
|
374
|
+
console.log();
|
|
375
|
+
|
|
376
|
+
if (!existsSync(HOOKS_DIR)) {
|
|
377
|
+
console.log(c.dim + ' No hooks installed.' + c.reset);
|
|
378
|
+
process.exit(0);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const { readdirSync } = await import('fs');
|
|
382
|
+
const installed = readdirSync(HOOKS_DIR).filter(f => f.endsWith('.sh'));
|
|
383
|
+
let outdated = 0;
|
|
384
|
+
let upToDate = 0;
|
|
385
|
+
let unknown = 0;
|
|
386
|
+
|
|
387
|
+
for (const file of installed) {
|
|
388
|
+
const name = file.replace('.sh', '');
|
|
389
|
+
const hook = REGISTRY.find(h => h.id === name);
|
|
390
|
+
const localContent = readFileSync(join(HOOKS_DIR, file), 'utf-8');
|
|
391
|
+
const localLines = localContent.split('\n').length;
|
|
392
|
+
|
|
393
|
+
if (!hook) {
|
|
394
|
+
// Custom hook, not in registry
|
|
395
|
+
console.log(' ' + c.dim + '?' + c.reset + ' ' + file + c.dim + ' (custom, not in registry)' + c.reset);
|
|
396
|
+
unknown++;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Check against GitHub for cc-safe-setup hooks
|
|
401
|
+
if (hook.source === 'cc-safe-setup' && hook.install.includes('--install-example')) {
|
|
402
|
+
try {
|
|
403
|
+
const rawUrl = `https://raw.githubusercontent.com/yurukusa/cc-safe-setup/main/examples/${name}.sh`;
|
|
404
|
+
const remote = execSync(`curl -sL "${rawUrl}" 2>/dev/null`, { encoding: 'utf-8', timeout: 5000 });
|
|
405
|
+
const remoteLines = remote.split('\n').length;
|
|
406
|
+
|
|
407
|
+
if (remote.trim() === localContent.trim()) {
|
|
408
|
+
console.log(' ' + c.green + '✓' + c.reset + ' ' + file + c.dim + ' (up to date)' + c.reset);
|
|
409
|
+
upToDate++;
|
|
410
|
+
} else {
|
|
411
|
+
const diff = remoteLines - localLines;
|
|
412
|
+
console.log(' ' + c.yellow + '↑' + c.reset + ' ' + file + c.yellow + ' (update available: ' + (diff > 0 ? '+' : '') + diff + ' lines)' + c.reset);
|
|
413
|
+
console.log(' ' + c.dim + 'Update: npx cc-hook-registry install ' + name + c.reset);
|
|
414
|
+
outdated++;
|
|
415
|
+
}
|
|
416
|
+
} catch {
|
|
417
|
+
console.log(' ' + c.dim + '?' + c.reset + ' ' + file + c.dim + ' (could not check)' + c.reset);
|
|
418
|
+
unknown++;
|
|
419
|
+
}
|
|
420
|
+
} else {
|
|
421
|
+
console.log(' ' + c.dim + '—' + c.reset + ' ' + file + c.dim + ' (external: ' + hook.source + ')' + c.reset);
|
|
422
|
+
unknown++;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
console.log();
|
|
427
|
+
console.log(' ' + c.green + upToDate + ' up to date' + c.reset + ' ' + c.yellow + outdated + ' outdated' + c.reset + ' ' + c.dim + unknown + ' unchecked' + c.reset);
|
|
428
|
+
console.log();
|
|
429
|
+
}
|
|
430
|
+
|
|
370
431
|
else if (command === 'stats') {
|
|
371
432
|
const categories = {};
|
|
372
433
|
const sources = {};
|