@accelerationguy/accel 1.0.0 → 1.0.1
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/install.js +20 -8
- package/package.json +1 -1
package/bin/install.js
CHANGED
|
@@ -412,27 +412,38 @@ function registerHooks(installedModules) {
|
|
|
412
412
|
let registered = 0;
|
|
413
413
|
const hooksDir = path.join(CLAUDE_HOME, 'hooks');
|
|
414
414
|
|
|
415
|
+
// Collect all hooks per event type
|
|
416
|
+
const hooksByEvent = {};
|
|
415
417
|
for (const modId of installedModules) {
|
|
416
418
|
const hookDefs = HOOK_DEFINITIONS[modId];
|
|
417
419
|
if (!hookDefs) continue;
|
|
418
420
|
|
|
419
421
|
for (const def of hookDefs) {
|
|
422
|
+
if (!hooksByEvent[def.event]) hooksByEvent[def.event] = [];
|
|
420
423
|
const hookPath = path.join(hooksDir, def.script);
|
|
421
|
-
|
|
424
|
+
hooksByEvent[def.event].push({
|
|
422
425
|
type: 'command',
|
|
423
426
|
command: `python3 ${hookPath}`,
|
|
424
|
-
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
if (!Array.isArray(settings.hooks[def.event])) {
|
|
428
|
-
settings.hooks[def.event] = [];
|
|
429
|
-
}
|
|
430
|
-
settings.hooks[def.event].push(hookEntry);
|
|
427
|
+
});
|
|
431
428
|
registered++;
|
|
432
429
|
console.log(` ${c.green}\u2713${c.reset} Hook registered: ${def.script} (${def.event})`);
|
|
433
430
|
}
|
|
434
431
|
}
|
|
435
432
|
|
|
433
|
+
// Write hooks in the correct Claude Code format:
|
|
434
|
+
// { "hooks": { "EventName": [ { "matcher": "", "hooks": [...] } ] } }
|
|
435
|
+
for (const [eventName, hooks] of Object.entries(hooksByEvent)) {
|
|
436
|
+
if (!Array.isArray(settings.hooks[eventName])) {
|
|
437
|
+
settings.hooks[eventName] = [];
|
|
438
|
+
}
|
|
439
|
+
// Add one entry with all Accelerate hooks grouped together
|
|
440
|
+
settings.hooks[eventName].push({
|
|
441
|
+
matcher: '',
|
|
442
|
+
hooks: hooks,
|
|
443
|
+
[ACCEL_HOOK_MARKER]: true,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
436
447
|
if (registered > 0) {
|
|
437
448
|
fs.mkdirSync(path.dirname(SETTINGS_PATH), { recursive: true });
|
|
438
449
|
fs.writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2));
|
|
@@ -457,6 +468,7 @@ function deregisterHooks() {
|
|
|
457
468
|
for (const eventName of Object.keys(settings.hooks)) {
|
|
458
469
|
if (!Array.isArray(settings.hooks[eventName])) continue;
|
|
459
470
|
const before = settings.hooks[eventName].length;
|
|
471
|
+
// Remove entries that have our marker (both old flat format and new grouped format)
|
|
460
472
|
settings.hooks[eventName] = settings.hooks[eventName].filter(
|
|
461
473
|
(h) => !h[ACCEL_HOOK_MARKER]
|
|
462
474
|
);
|