@scheduler-systems/gal-run 0.0.406 → 0.0.407

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.
@@ -45,7 +45,7 @@ const os = require('os');
45
45
  * This function surgically removes only GAL-specific hook entries while
46
46
  * preserving the user's other hooks and settings. It handles:
47
47
  * - Filtering GAL hooks from UserPromptSubmit array
48
- * - Filtering GAL hooks from SessionStart array (v2.x)
48
+ * - Filtering GAL hooks from SessionStart and Stop arrays
49
49
  * - Removing empty hook arrays after filtering
50
50
  * - Preserving the settings.json file structure
51
51
  *
@@ -60,24 +60,31 @@ function removeGalHookEntries(settingsPath) {
60
60
 
61
61
  const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
62
62
 
63
- if (!settings.hooks?.UserPromptSubmit) {
63
+ if (!settings.hooks) {
64
64
  return false;
65
65
  }
66
66
 
67
- // Filter out GAL hooks while preserving user's other hooks
68
- const originalLength = settings.hooks.UserPromptSubmit.length;
69
- settings.hooks.UserPromptSubmit = settings.hooks.UserPromptSubmit.filter((entry) => {
70
- if (!entry.hooks) return true;
71
- // Keep entry only if it has non-GAL hooks
72
- entry.hooks = entry.hooks.filter((hook) =>
73
- !hook.command?.includes('gal-') && !hook.command?.includes('/gal/')
74
- );
75
- return entry.hooks.length > 0;
76
- });
77
-
78
- // Remove empty hooks array
79
- if (settings.hooks.UserPromptSubmit.length === 0) {
80
- delete settings.hooks.UserPromptSubmit;
67
+ let removedAny = false;
68
+
69
+ for (const event of ['UserPromptSubmit', 'SessionStart', 'Stop']) {
70
+ if (!settings.hooks[event]) continue;
71
+
72
+ const originalLength = settings.hooks[event].length;
73
+ settings.hooks[event] = settings.hooks[event].filter((entry) => {
74
+ if (!entry.hooks) return true;
75
+ entry.hooks = entry.hooks.filter((hook) =>
76
+ !hook.command?.includes('gal-') && !hook.command?.includes('/gal/')
77
+ );
78
+ return entry.hooks.length > 0;
79
+ });
80
+
81
+ if (settings.hooks[event].length === 0) {
82
+ delete settings.hooks[event];
83
+ }
84
+
85
+ if ((settings.hooks[event]?.length || 0) !== originalLength) {
86
+ removedAny = true;
87
+ }
81
88
  }
82
89
 
83
90
  // Remove empty hooks object
@@ -85,7 +92,7 @@ function removeGalHookEntries(settingsPath) {
85
92
  delete settings.hooks;
86
93
  }
87
94
 
88
- if (settings.hooks?.UserPromptSubmit?.length !== originalLength) {
95
+ if (removedAny) {
89
96
  fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
90
97
  return true;
91
98
  }