@rulemetric/hooks 0.3.0 → 0.4.0

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.3.0",
3
+ "version": "0.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -62,6 +62,23 @@ fi
62
62
 
63
63
  _rulemetric_log "session-end" "success"
64
64
 
65
+ # ── Emit a synthetic instruction snapshot (hooks-first, zero-proxy linking) ──
66
+ # The proxy classifies the rendered system prompt into context_items that
67
+ # link-instructions matches on. Hooks-only sessions have no proxy, so build an
68
+ # equivalent snapshot from on-disk CLAUDE.md files and POST it SYNCHRONOUSLY —
69
+ # it must land before the backgrounded link-instructions call below. Best-effort:
70
+ # a failure never breaks session-end (see the ERR trap guard). Claude Code only
71
+ # for now (the snapshot uses claude_md items).
72
+ if [ "$HOOK_TOOL" = "claude_code" ]; then
73
+ INSTR_SNAPSHOT=$(rulemetric hooks emit-instructions --project-dir "${HOOK_CWD:-$(pwd)}" 2>/dev/null || true)
74
+ if [ -n "$INSTR_SNAPSHOT" ]; then
75
+ curl -sf --noproxy '*' --max-time 5 -X POST "${RULEMETRIC_API_URL}/api/sessions/${RW_SESSION_ID}/context-snapshots" \
76
+ -H "$AUTH_HEADER" \
77
+ -H "Content-Type: application/json" \
78
+ -d "$INSTR_SNAPSHOT" > /dev/null 2>&1 || _rulemetric_log "session-end" "warn" "instruction_snapshot_failed"
79
+ fi
80
+ fi
81
+
65
82
  # ── Auto-link instructions from context snapshots ──
66
83
  # Fire-and-forget: link any captured context to instruction records
67
84
  (curl -sf --noproxy '*' --max-time 8 -X POST "${RULEMETRIC_API_URL}/api/sessions/link-instructions" \