mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-08-21 12:23:32 +02:00
Improve Claude optimization tooling
This commit is contained in:
@@ -1,34 +1,44 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
# Hourly rtk + headroom token-savings snapshot for the add-on log.
|
# Hourly RTK + Headroom + TokenSave token-savings snapshot for the add-on log.
|
||||||
# Invoked by cron (see /defaults/crontabs/root); its stdout is redirected to /proc/1/fd/1,
|
# Invoked by cron (see /defaults/crontabs/root); stdout is redirected to /proc/1/fd/1.
|
||||||
# so the report appears in the add-on log. Doubles as a heartbeat: if the numbers stop
|
# Each tool is reported independently so enabling Headroom cannot hide RTK or TokenSave data.
|
||||||
# growing, the corresponding tool has stopped working.
|
# with-contenv supplies the configured persistent HOME.
|
||||||
# with-contenv supplies HOME from the s6 envdir, so this honors a custom `data_location`
|
export NO_COLOR=1
|
||||||
# (see 20-folders.sh) instead of hardcoding /data/data; it also makes bashio::config
|
|
||||||
# available for the install_headroom gate below.
|
|
||||||
export NO_COLOR=1 # keep the add-on log free of ANSI color codes
|
|
||||||
export PATH="/lsiopy/bin:/usr/local/bin:/usr/bin:/bin:${PATH}"
|
export PATH="/lsiopy/bin:/usr/local/bin:/usr/bin:/bin:${PATH}"
|
||||||
|
|
||||||
have_rtk=false; command -v rtk >/dev/null 2>&1 && have_rtk=true
|
if ! bashio::config.true 'enable_tools_health_report'; then
|
||||||
have_headroom=false; command -v headroom >/dev/null 2>&1 && have_headroom=true
|
exit 0
|
||||||
|
|
||||||
# headroom is pip-installed unconditionally at build time, so its binary is on PATH even
|
|
||||||
# when install_headroom is off — gate on the same config svc-headroom checks, and only
|
|
||||||
# fall back to have_headroom as a secondary availability guard.
|
|
||||||
headroom_enabled=false
|
|
||||||
if bashio::config.true 'install_headroom' && $have_headroom; then
|
|
||||||
headroom_enabled=true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Nothing to report if neither tool is active — stay quiet.
|
rtk_enabled=false
|
||||||
if ! $have_rtk && ! $headroom_enabled; then exit 0; fi
|
headroom_enabled=false
|
||||||
|
tokensave_enabled=false
|
||||||
|
|
||||||
echo "===== claude gains report $(date '+%Y-%m-%d %H:%M:%S') ====="
|
if bashio::config.true 'install_rtk' && command -v rtk > /dev/null 2>&1; then
|
||||||
|
rtk_enabled=true
|
||||||
|
fi
|
||||||
|
if bashio::config.true 'install_headroom' && command -v headroom > /dev/null 2>&1; then
|
||||||
|
headroom_enabled=true
|
||||||
|
fi
|
||||||
|
if bashio::config.true 'install_tokensave' && command -v tokensave > /dev/null 2>&1; then
|
||||||
|
tokensave_enabled=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! $rtk_enabled && ! $headroom_enabled && ! $tokensave_enabled; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "===== claude tools report $(date '+%Y-%m-%d %H:%M:%S') ====="
|
||||||
if $headroom_enabled; then
|
if $headroom_enabled; then
|
||||||
echo "--- headroom savings ---"
|
echo "--- headroom savings ---"
|
||||||
headroom savings 2>&1 || echo "[warn] headroom savings failed"
|
headroom savings 2>&1 || echo "[warn] headroom savings failed"
|
||||||
elif $have_rtk; then
|
fi
|
||||||
|
if $rtk_enabled; then
|
||||||
echo "--- rtk gain ---"
|
echo "--- rtk gain ---"
|
||||||
rtk gain 2>&1 || echo "[warn] rtk gain failed"
|
rtk gain 2>&1 || echo "[warn] rtk gain failed"
|
||||||
fi
|
fi
|
||||||
echo "===== end gains report ====="
|
if $tokensave_enabled; then
|
||||||
|
echo "--- tokensave gain ---"
|
||||||
|
tokensave gain --all --range 30d 2>&1 || echo "[warn] tokensave gain failed"
|
||||||
|
fi
|
||||||
|
echo "===== end claude tools report ====="
|
||||||
|
|||||||
Reference in New Issue
Block a user