@rulemetric/hooks 0.7.39 → 0.7.41
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
package/scripts/_config.sh
CHANGED
|
@@ -99,6 +99,16 @@ _rulemetric_load_config() {
|
|
|
99
99
|
# below. `auth login` against prod doesn't persist RULEMETRIC_API_URL, so
|
|
100
100
|
# requiring it here made every fresh npm install skip capture with
|
|
101
101
|
# "no_config" unless auth.json happened to survive.
|
|
102
|
+
if [ "${RULEMETRIC_STRICT_LOCAL:-0}" = "1" ] && [ -z "${RULEMETRIC_API_URL:-}" ]; then
|
|
103
|
+
# L1.2: strict-local refuses the cloud default — leave the URL unset so
|
|
104
|
+
# every downstream no-URL skip path disables capture, loudly. return 0,
|
|
105
|
+
# not 1: hooks run under `set -e` and must never break the agent.
|
|
106
|
+
# The hooks source this file with 2>/dev/null, so the notice is
|
|
107
|
+
# handed back via a variable and printed by each hook itself.
|
|
108
|
+
export RULEMETRIC_CAPTURE_DISABLED_REASON="RULEMETRIC_STRICT_LOCAL: no RULEMETRIC_API_URL configured — capture disabled."
|
|
109
|
+
_rulemetric_load_active_org
|
|
110
|
+
return 0
|
|
111
|
+
fi
|
|
102
112
|
export RULEMETRIC_API_URL="${RULEMETRIC_API_URL:-https://rulemetric.com}"
|
|
103
113
|
_rulemetric_load_active_org
|
|
104
114
|
return 0
|
|
@@ -112,6 +122,16 @@ _rulemetric_load_config() {
|
|
|
112
122
|
if [ -n "$token" ]; then
|
|
113
123
|
export RULEMETRIC_ACCESS_TOKEN="$token"
|
|
114
124
|
# Default API URL if not set
|
|
125
|
+
if [ "${RULEMETRIC_STRICT_LOCAL:-0}" = "1" ] && [ -z "${RULEMETRIC_API_URL:-}" ]; then
|
|
126
|
+
# L1.2: strict-local refuses the cloud default — leave the URL unset so
|
|
127
|
+
# every downstream no-URL skip path disables capture, loudly. return 0,
|
|
128
|
+
# not 1: hooks run under `set -e` and must never break the agent.
|
|
129
|
+
# The hooks source this file with 2>/dev/null, so the notice is
|
|
130
|
+
# handed back via a variable and printed by each hook itself.
|
|
131
|
+
export RULEMETRIC_CAPTURE_DISABLED_REASON="RULEMETRIC_STRICT_LOCAL: no RULEMETRIC_API_URL configured — capture disabled."
|
|
132
|
+
_rulemetric_load_active_org
|
|
133
|
+
return 0
|
|
134
|
+
fi
|
|
115
135
|
export RULEMETRIC_API_URL="${RULEMETRIC_API_URL:-https://rulemetric.com}"
|
|
116
136
|
_rulemetric_load_active_org
|
|
117
137
|
return 0
|
package/scripts/_post.sh
CHANGED
|
@@ -49,6 +49,11 @@ _rulemetric_beacon() {
|
|
|
49
49
|
local code_int proxied
|
|
50
50
|
code_int=$((10#$code)) 2>/dev/null || code_int=0
|
|
51
51
|
proxied=$([ -n "${HTTPS_PROXY:-}" ] && echo true || echo false)
|
|
52
|
+
# L1.2: the beacon is UNAUTHENTICATED cloud telemetry by default — under
|
|
53
|
+
# strict-local with no configured URL it must not fire at all.
|
|
54
|
+
if [ "${RULEMETRIC_STRICT_LOCAL:-0}" = "1" ] && [ -z "${RULEMETRIC_API_URL:-}" ]; then
|
|
55
|
+
return 0
|
|
56
|
+
fi
|
|
52
57
|
( curl -s --noproxy '*' --max-time 2 -X POST \
|
|
53
58
|
"${RULEMETRIC_API_URL:-https://rulemetric.com}/api/telemetry/cli-error" \
|
|
54
59
|
-H 'Content-Type: application/json' \
|
|
@@ -15,6 +15,9 @@ trap 'echo "rulemetric assistant-response failed at line $LINENO: $BASH_COMMAND"
|
|
|
15
15
|
|
|
16
16
|
# Load config (env vars, ~/.config/rulemetric/env, or .env.local)
|
|
17
17
|
source "$SCRIPT_DIR/_config.sh" 2>/dev/null || true
|
|
18
|
+
if [ -n "${RULEMETRIC_CAPTURE_DISABLED_REASON:-}" ]; then
|
|
19
|
+
echo "[rulemetric] $RULEMETRIC_CAPTURE_DISABLED_REASON" >&2
|
|
20
|
+
fi
|
|
18
21
|
|
|
19
22
|
INPUT=$(cat)
|
|
20
23
|
source "$SCRIPT_DIR/_normalize.sh"
|
package/scripts/post-tool-use.sh
CHANGED
|
@@ -8,6 +8,9 @@ trap 'echo "rulemetric post-tool-use failed at line $LINENO: $BASH_COMMAND" >&2;
|
|
|
8
8
|
|
|
9
9
|
# Load config (env vars, ~/.config/rulemetric/env, or .env.local)
|
|
10
10
|
source "$SCRIPT_DIR/_config.sh" 2>/dev/null || true
|
|
11
|
+
if [ -n "${RULEMETRIC_CAPTURE_DISABLED_REASON:-}" ]; then
|
|
12
|
+
echo "[rulemetric] $RULEMETRIC_CAPTURE_DISABLED_REASON" >&2
|
|
13
|
+
fi
|
|
11
14
|
|
|
12
15
|
# Read hook input from stdin and normalize across tools
|
|
13
16
|
INPUT=$(cat)
|
package/scripts/session-end.sh
CHANGED
|
@@ -13,6 +13,9 @@ trap 'echo "rulemetric session-end failed at line $LINENO: $BASH_COMMAND" >&2; _
|
|
|
13
13
|
|
|
14
14
|
# Load config (env vars, ~/.config/rulemetric/env, or .env.local)
|
|
15
15
|
source "$SCRIPT_DIR/_config.sh" 2>/dev/null || true
|
|
16
|
+
if [ -n "${RULEMETRIC_CAPTURE_DISABLED_REASON:-}" ]; then
|
|
17
|
+
echo "[rulemetric] $RULEMETRIC_CAPTURE_DISABLED_REASON" >&2
|
|
18
|
+
fi
|
|
16
19
|
|
|
17
20
|
# Read hook input from stdin and normalize across tools. Bound the read so a
|
|
18
21
|
# hook runner that leaves stdin open cannot wedge the agent.
|
package/scripts/session-start.sh
CHANGED
|
@@ -9,6 +9,9 @@ trap 'echo "rulemetric session-start failed at line $LINENO: $BASH_COMMAND" >&2;
|
|
|
9
9
|
|
|
10
10
|
# Load config (env vars, ~/.config/rulemetric/env, or .env.local)
|
|
11
11
|
source "$SCRIPT_DIR/_config.sh" 2>/dev/null || true
|
|
12
|
+
if [ -n "${RULEMETRIC_CAPTURE_DISABLED_REASON:-}" ]; then
|
|
13
|
+
echo "[rulemetric] $RULEMETRIC_CAPTURE_DISABLED_REASON" >&2
|
|
14
|
+
fi
|
|
12
15
|
|
|
13
16
|
# Read hook input from stdin and normalize across tools. Bound the read so a
|
|
14
17
|
# hook runner that leaves stdin open cannot wedge the agent.
|
package/scripts/user-prompt.sh
CHANGED
|
@@ -8,6 +8,9 @@ trap 'echo "rulemetric user-prompt failed at line $LINENO: $BASH_COMMAND" >&2; _
|
|
|
8
8
|
|
|
9
9
|
# Load config (env vars, ~/.config/rulemetric/env, or .env.local)
|
|
10
10
|
source "$SCRIPT_DIR/_config.sh" 2>/dev/null || true
|
|
11
|
+
if [ -n "${RULEMETRIC_CAPTURE_DISABLED_REASON:-}" ]; then
|
|
12
|
+
echo "[rulemetric] $RULEMETRIC_CAPTURE_DISABLED_REASON" >&2
|
|
13
|
+
fi
|
|
11
14
|
|
|
12
15
|
# Read hook input from stdin and normalize across tools
|
|
13
16
|
INPUT=$(cat)
|