ai-lens 0.8.22 → 0.8.23

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/.commithash CHANGED
@@ -1 +1 @@
1
- 23120cb
1
+ 9446d54
package/cli/hooks.js CHANGED
@@ -106,15 +106,17 @@ export function captureCommand() {
106
106
  const capturePath = CAPTURE_PATH.replace(/\\/g, '/');
107
107
  const escaped = shellEscape(capturePath);
108
108
  // /usr/bin/env doesn't need shell-escaping, but named paths do
109
- const base = nodePath === '/usr/bin/env node'
109
+ return nodePath === '/usr/bin/env node'
110
110
  ? `/usr/bin/env node ${escaped}`
111
111
  : `${shellEscape(nodePath.replace(/\\/g, '/'))} ${escaped}`;
112
- // On Windows, prefix with "& " so the command works in both PowerShell and cmd.exe.
113
- // PowerShell treats a quoted path like "node.exe" as a string expression, not a command;
114
- // the & (call) operator is required. In cmd.exe, & is a command separator — the empty
115
- // first part is a no-op, and the real command runs as the second part.
116
- if (process.platform === 'win32') return `& ${base}`;
117
- return base;
112
+ }
113
+
114
+ // Cursor on Windows executes hooks via PowerShell, which treats a quoted path like
115
+ // "node.exe" as a string expression, not a command invocation. The & (call) operator
116
+ // is required. Claude Code uses bash or cmd.exe where & is not needed (and breaks bash).
117
+ export function cursorCaptureCommand() {
118
+ const cmd = captureCommand();
119
+ return process.platform === 'win32' ? `& ${cmd}` : cmd;
118
120
  }
119
121
 
120
122
  // ---------------------------------------------------------------------------
@@ -169,20 +171,20 @@ const CLAUDE_CODE_HOOKS = {
169
171
  };
170
172
 
171
173
  const CURSOR_HOOKS = {
172
- sessionStart: () => ({ command: captureCommand() }),
173
- beforeSubmitPrompt: () => ({ command: captureCommand() }),
174
- postToolUse: () => ({ command: captureCommand() }),
175
- postToolUseFailure: () => ({ command: captureCommand() }),
176
- afterFileEdit: () => ({ command: captureCommand() }),
177
- afterShellExecution: () => ({ command: captureCommand() }),
178
- afterMCPExecution: () => ({ command: captureCommand() }),
179
- subagentStart: () => ({ command: captureCommand() }),
180
- subagentStop: () => ({ command: captureCommand() }),
181
- preCompact: () => ({ command: captureCommand() }),
182
- afterAgentResponse: () => ({ command: captureCommand() }),
183
- afterAgentThought: () => ({ command: captureCommand() }),
184
- stop: () => ({ command: captureCommand() }),
185
- sessionEnd: () => ({ command: captureCommand() }),
174
+ sessionStart: () => ({ command: cursorCaptureCommand() }),
175
+ beforeSubmitPrompt: () => ({ command: cursorCaptureCommand() }),
176
+ postToolUse: () => ({ command: cursorCaptureCommand() }),
177
+ postToolUseFailure: () => ({ command: cursorCaptureCommand() }),
178
+ afterFileEdit: () => ({ command: cursorCaptureCommand() }),
179
+ afterShellExecution: () => ({ command: cursorCaptureCommand() }),
180
+ afterMCPExecution: () => ({ command: cursorCaptureCommand() }),
181
+ subagentStart: () => ({ command: cursorCaptureCommand() }),
182
+ subagentStop: () => ({ command: cursorCaptureCommand() }),
183
+ preCompact: () => ({ command: cursorCaptureCommand() }),
184
+ afterAgentResponse: () => ({ command: cursorCaptureCommand() }),
185
+ afterAgentThought: () => ({ command: cursorCaptureCommand() }),
186
+ stop: () => ({ command: cursorCaptureCommand() }),
187
+ sessionEnd: () => ({ command: cursorCaptureCommand() }),
186
188
  };
187
189
 
188
190
  export const TOOL_CONFIGS = [
@@ -224,7 +226,11 @@ export function isAiLensHook(entry) {
224
226
  }
225
227
 
226
228
  function isCurrentAiLensHook(entry, expected) {
227
- const expected_cmd = captureCommand();
229
+ // Extract expected command from the hook definition (supports per-tool commands,
230
+ // e.g. Cursor uses & prefix on Windows for PowerShell, Claude Code does not).
231
+ const expected_cmd = expected?.command
232
+ || expected?.hooks?.[0]?.command
233
+ || captureCommand(); // fallback
228
234
  // Normalize separators so hooks installed before path-normalization fix still match
229
235
  const norm = s => (s || '').replace(/\\/g, '/');
230
236
  // Flat format (Cursor)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-lens",
3
- "version": "0.8.22",
3
+ "version": "0.8.23",
4
4
  "type": "module",
5
5
  "description": "Centralized session analytics for AI coding tools",
6
6
  "bin": {