mirror of
https://github.com/lukaszraczylo/claude-adam.git
synced 2026-07-07 03:44:26 +00:00
feat(v0.6.3): release-update notifier (notify-only, SessionStart)
Adds a lightweight "new release available" notice without auto-installing — because re-running install.sh overwrites ADAM's own /reflect-applied skill edits, so the user must choose when to take an update. - install.sh writes ~/.claude/adam/.version (the installed release tag) on every install. Derived from $VERSION / piped REF / `git describe --tags`. - adam-nudge.mjs (SessionStart) compares .version against the latest GitHub release at most once/day. Cached in ~/.claude/adam/.update-check.json; the cache drives an instant nudge (no network on the hot path) and is refreshed best-effort with a 1.5s AbortController cap. fetch unavailable / offline / timeout / rate-limit / parse error all degrade to silent no-op. Opt out with ADAM_NO_UPDATE_CHECK=1. main() is now async; never blocks SessionStart. - README: "Staying up to date" section; pin example bumped to v0.6.3. Tests: 134 -> 138. Notifier verified fully offline (cache-driven): nudges when a newer release is cached, silent when current, suppressed by the opt-out env, and no-ops when the .version marker is absent.
This commit is contained in:
@@ -2058,6 +2058,57 @@ else
|
||||
fi
|
||||
rm -f "$ROOT/ab-tracking.jsonl"
|
||||
|
||||
# --- Test 114: update notifier nudges from cache when a newer release exists (no network) ---
|
||||
echo "Test 114: update notifier — cached newer release prints nudge"
|
||||
reset_state
|
||||
printf 'v0.6.2\n' > "$ROOT/.version"
|
||||
node -e "require('fs').writeFileSync('$ROOT/.update-check.json', JSON.stringify({last_check: Date.now(), latest: 'v9.9.9'}))"
|
||||
out=$(echo '{"hook_event_name":"SessionStart","session_id":"sUP"}' | NUDGE_RUN 2>/dev/null)
|
||||
if echo "$out" | grep -q "update available: v0.6.2 → v9.9.9"; then
|
||||
echo " PASS: update nudge printed from cache (offline)"; PASS=$((PASS+1))
|
||||
else
|
||||
echo " FAIL: expected update nudge (got: $out)"; FAIL=$((FAIL+1))
|
||||
fi
|
||||
rm -f "$ROOT/.version" "$ROOT/.update-check.json"
|
||||
|
||||
# --- Test 115: update notifier silent when installed is current ---
|
||||
echo "Test 115: update notifier — up-to-date is silent"
|
||||
reset_state
|
||||
printf 'v9.9.9\n' > "$ROOT/.version"
|
||||
node -e "require('fs').writeFileSync('$ROOT/.update-check.json', JSON.stringify({last_check: Date.now(), latest: 'v9.9.9'}))"
|
||||
out=$(echo '{"hook_event_name":"SessionStart","session_id":"sUP2"}' | NUDGE_RUN 2>/dev/null)
|
||||
if echo "$out" | grep -q "update available"; then
|
||||
echo " FAIL: nudged despite being current (got: $out)"; FAIL=$((FAIL+1))
|
||||
else
|
||||
echo " PASS: no nudge when up-to-date"; PASS=$((PASS+1))
|
||||
fi
|
||||
rm -f "$ROOT/.version" "$ROOT/.update-check.json"
|
||||
|
||||
# --- Test 116: ADAM_NO_UPDATE_CHECK disables the notifier ---
|
||||
echo "Test 116: ADAM_NO_UPDATE_CHECK opt-out"
|
||||
reset_state
|
||||
printf 'v0.6.2\n' > "$ROOT/.version"
|
||||
node -e "require('fs').writeFileSync('$ROOT/.update-check.json', JSON.stringify({last_check: Date.now(), latest: 'v9.9.9'}))"
|
||||
out=$(echo '{"hook_event_name":"SessionStart","session_id":"sUP3"}' | HOME="$TMP_HOME" ADAM_NO_UPDATE_CHECK=1 node "$NUDGE" 2>/dev/null)
|
||||
if echo "$out" | grep -q "update available"; then
|
||||
echo " FAIL: notifier ran despite opt-out (got: $out)"; FAIL=$((FAIL+1))
|
||||
else
|
||||
echo " PASS: ADAM_NO_UPDATE_CHECK suppressed the check"; PASS=$((PASS+1))
|
||||
fi
|
||||
rm -f "$ROOT/.version" "$ROOT/.update-check.json"
|
||||
|
||||
# --- Test 117: no .version marker → notifier no-op (no crash) ---
|
||||
echo "Test 117: missing .version marker → notifier silent, hook still runs"
|
||||
reset_state
|
||||
node -e "require('fs').writeFileSync('$ROOT/.update-check.json', JSON.stringify({last_check: Date.now(), latest: 'v9.9.9'}))"
|
||||
out=$(echo '{"hook_event_name":"SessionStart","session_id":"sUP4"}' | NUDGE_RUN 2>/dev/null)
|
||||
if echo "$out" | grep -q "update available"; then
|
||||
echo " FAIL: nudged without a .version marker (got: $out)"; FAIL=$((FAIL+1))
|
||||
else
|
||||
echo " PASS: no marker → no update nudge"; PASS=$((PASS+1))
|
||||
fi
|
||||
rm -f "$ROOT/.update-check.json"
|
||||
|
||||
echo
|
||||
echo "Results: $PASS passed, $FAIL failed"
|
||||
[ "$FAIL" = "0" ]
|
||||
|
||||
Reference in New Issue
Block a user