@ghl-ai/aw 0.1.42-beta.35 → 0.1.42-beta.37

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/startup.mjs +39 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghl-ai/aw",
3
- "version": "0.1.42-beta.35",
3
+ "version": "0.1.42-beta.37",
4
4
  "description": "Agentic Workspace CLI — pull, push & manage agents, skills and commands from the registry",
5
5
  "type": "module",
6
6
  "bin": {
package/startup.mjs CHANGED
@@ -19,27 +19,27 @@ const CLAUDE_TELEMETRY_HOOKS = [
19
19
  {
20
20
  phase: 'SessionStart',
21
21
  matcher: undefined,
22
- command: 'node "$HOME/.aw-ecc/scripts/hooks/aw-usage-session-start.js"',
22
+ command: 'test -f "$HOME/.aw-ecc/scripts/hooks/aw-usage-session-start.js" && node "$HOME/.aw-ecc/scripts/hooks/aw-usage-session-start.js" || true',
23
23
  },
24
24
  {
25
25
  phase: 'PostToolUse',
26
26
  matcher: 'Skill|Agent|Shell|Bash',
27
- command: 'node "$HOME/.aw-ecc/scripts/hooks/aw-usage-post-tool-use.js"',
27
+ command: 'test -f "$HOME/.aw-ecc/scripts/hooks/aw-usage-post-tool-use.js" && node "$HOME/.aw-ecc/scripts/hooks/aw-usage-post-tool-use.js" || true',
28
28
  },
29
29
  {
30
30
  phase: 'Stop',
31
31
  matcher: undefined,
32
- command: 'node "$HOME/.aw-ecc/scripts/hooks/aw-usage-stop.js"',
32
+ command: 'test -f "$HOME/.aw-ecc/scripts/hooks/aw-usage-stop.js" && node "$HOME/.aw-ecc/scripts/hooks/aw-usage-stop.js" || true',
33
33
  },
34
34
  {
35
35
  phase: 'PostToolUseFailure',
36
36
  matcher: undefined,
37
- command: 'node "$HOME/.aw-ecc/scripts/hooks/aw-usage-post-tool-use-failure.js"',
37
+ command: 'test -f "$HOME/.aw-ecc/scripts/hooks/aw-usage-post-tool-use-failure.js" && node "$HOME/.aw-ecc/scripts/hooks/aw-usage-post-tool-use-failure.js" || true',
38
38
  },
39
39
  {
40
40
  phase: 'UserPromptSubmit',
41
41
  matcher: undefined,
42
- command: 'node "$HOME/.aw-ecc/scripts/hooks/aw-usage-prompt-submit.js"',
42
+ command: 'test -f "$HOME/.aw-ecc/scripts/hooks/aw-usage-prompt-submit.js" && node "$HOME/.aw-ecc/scripts/hooks/aw-usage-prompt-submit.js" || true',
43
43
  },
44
44
  ];
45
45
  const CURSOR_SESSION_START_COMMAND = 'node .cursor/hooks/session-start.js';
@@ -195,6 +195,18 @@ function buildClaudeTelemetryEntry(hookDef) {
195
195
  return entry;
196
196
  }
197
197
 
198
+ /**
199
+ * Resolve the filesystem path from a telemetry hook command.
200
+ * Commands look like: node "$HOME/.aw-ecc/scripts/hooks/aw-usage-stop.js"
201
+ */
202
+ function resolveHookScriptPath(command, homeDir) {
203
+ const match = command.match(/"\$HOME\/([^"]+)"/);
204
+ if (match) return join(homeDir, match[1]);
205
+ const matchBare = command.match(/\$HOME\/(\S+)/);
206
+ if (matchBare) return join(homeDir, matchBare[1]);
207
+ return null;
208
+ }
209
+
198
210
  function enableClaudeTelemetryHooks(homeDir = homedir()) {
199
211
  const settingsPath = join(homeDir, '.claude', 'settings.json');
200
212
  const config = readJson(settingsPath, {});
@@ -206,6 +218,24 @@ function enableClaudeTelemetryHooks(homeDir = homedir()) {
206
218
  const current = Array.isArray(config.hooks[hookDef.phase]) ? config.hooks[hookDef.phase] : [];
207
219
  const managed = current.filter(isManagedClaudeTelemetryEntry);
208
220
 
221
+ // Only register hooks whose script files actually exist on disk.
222
+ // On version downgrade the aw-ecc clone may not have them — registering
223
+ // hooks for missing scripts causes MODULE_NOT_FOUND crashes.
224
+ const scriptPath = resolveHookScriptPath(hookDef.command, homeDir);
225
+ if (scriptPath && !existsSync(scriptPath)) {
226
+ // Script missing — remove any stale telemetry entries for this phase
227
+ if (managed.length > 0) {
228
+ const cleaned = current.filter(e => !isManagedClaudeTelemetryEntry(e));
229
+ if (cleaned.length > 0) {
230
+ config.hooks[hookDef.phase] = cleaned;
231
+ } else {
232
+ delete config.hooks[hookDef.phase];
233
+ }
234
+ changed = true;
235
+ }
236
+ continue;
237
+ }
238
+
209
239
  // If exactly one properly described entry exists, nothing to do
210
240
  if (managed.length === 1 && managed[0].description === CLAUDE_TELEMETRY_DESCRIPTION) continue;
211
241
 
@@ -217,6 +247,10 @@ function enableClaudeTelemetryHooks(homeDir = homedir()) {
217
247
 
218
248
  if (!changed) return [];
219
249
 
250
+ if (isEmptyObject(config.hooks)) {
251
+ delete config.hooks;
252
+ }
253
+
220
254
  writeJson(settingsPath, config);
221
255
  return [settingsPath];
222
256
  }