@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 +1 -1
- package/scripts/session-end.sh +17 -0
package/package.json
CHANGED
package/scripts/session-end.sh
CHANGED
|
@@ -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" \
|