@rulemetric/hooks 0.7.21 → 0.7.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulemetric/hooks",
3
- "version": "0.7.21",
3
+ "version": "0.7.22",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,7 +12,7 @@ _rulemetric_ensure_session() {
12
12
 
13
13
  # Check for existing temp file first
14
14
  if [ -f "$TEMP_DIR/$HOOK_SESSION_ID" ]; then
15
- RW_SESSION_ID=$(cat "$TEMP_DIR/$HOOK_SESSION_ID")
15
+ RW_SESSION_ID=$(head -n 1 "$TEMP_DIR/$HOOK_SESSION_ID")
16
16
  if [ -n "$RW_SESSION_ID" ]; then
17
17
  return 0
18
18
  fi
@@ -38,7 +38,7 @@ _rulemetric_ensure_session() {
38
38
 
39
39
  # Re-check after acquiring lock (another process may have created it)
40
40
  if [ -f "$TEMP_DIR/$HOOK_SESSION_ID" ]; then
41
- RW_SESSION_ID=$(cat "$TEMP_DIR/$HOOK_SESSION_ID")
41
+ RW_SESSION_ID=$(head -n 1 "$TEMP_DIR/$HOOK_SESSION_ID")
42
42
  if [ -n "$RW_SESSION_ID" ]; then
43
43
  rmdir "$lock_dir" 2>/dev/null
44
44
  return 0
@@ -190,7 +190,17 @@ _rulemetric_ensure_session() {
190
190
  return 1
191
191
  fi
192
192
 
193
- echo "$RW_SESSION_ID" > "$TEMP_DIR/$HOOK_SESSION_ID"
193
+ # Line 1 = DB session id, line 2 = tool. The proxy's session_linker reads the
194
+ # tool from line 2 (session_linker.py:109) to prefer a session whose harness
195
+ # matches the traffic it is attributing (_PROVIDER_TO_TOOLS). This file was
196
+ # written with the session id ALONE, so tool_type was always "" and that
197
+ # preference could never match for ANY provider — every snapshot fell through
198
+ # to "most recent session", i.e. whichever harness last wrote a file. On a dev
199
+ # machine that is the Claude Code session driving the terminal, so Antigravity
200
+ # / Cursor / Copilot generations were being recorded against Claude Code.
201
+ # Reading is already backward compatible (line 2 defaults to ""), so older
202
+ # single-line files keep working.
203
+ printf '%s\n%s\n' "$RW_SESSION_ID" "$HOOK_TOOL" > "$TEMP_DIR/$HOOK_SESSION_ID"
194
204
  echo "0" > "$TEMP_DIR/$HOOK_SESSION_ID.seq"
195
205
 
196
206
  _rulemetric_log "${1:-ensure-session}" "recovered" "lazy_create"
@@ -198,7 +208,7 @@ _rulemetric_ensure_session() {
198
208
 
199
209
  # Re-read the session ID written by the locked subshell
200
210
  if [ -f "$TEMP_DIR/$HOOK_SESSION_ID" ]; then
201
- RW_SESSION_ID=$(cat "$TEMP_DIR/$HOOK_SESSION_ID")
211
+ RW_SESSION_ID=$(head -n 1 "$TEMP_DIR/$HOOK_SESSION_ID")
202
212
  fi
203
213
  [ -n "$RW_SESSION_ID" ]
204
214
  }