github alexgreensh/token-optimizer v5.0.2
v5.0.2 — Smart auto-heal for plugin users

latest releases: v5.7.1, v5.7.0, v5.6.13...
one month ago

Fix: auto-heal respects install mode

If you installed Token Optimizer via install.sh and later switched to the marketplace plugin (or ran both side-by-side), every hook was firing twice per event — settings.json had a copy of what the plugin already provides. v5.0.2 fixes this.

What is new

  • ensure-health now branches on install mode. Plugin users get a cleanup pass that removes duplicate hooks from settings.json. Script-install users keep the existing add-missing-hooks behavior.
  • measure.py cleanup-duplicate-hooks — new manual command (with --dry-run) so you can trigger the cleanup yourself anytime.
  • Dedup preserves customizations. Only hook commands whose (event, matcher, identity) tuple exactly match an entry in plugin hooks.json are removed. Custom flags, wrapper scripts, and third-party hooks in the same group are left untouched.

Safety

  • Atomic writes via the existing _write_settings_atomic (file lock + tempfile + rename)
  • Refuses to run unless the marketplace plugin is actually installed
  • Refuses to write when settings.json appears corrupted
  • 24h throttle on the SessionStart path so auto-heal stays quiet
  • Isinstance guards on every walk — malformed hooks.json cannot crash the cleanup

Upgrade path

Plugin users get the fix automatically via /plugin update. The cleanup runs once on the next SessionStart after the throttle window and prints [Token Optimizer] Removed N duplicate hook(s) when it clears legacy state. Restart Claude Code once afterward to fully apply.

Version alignment

  • .claude-plugin/plugin.json → 5.0.2
  • .claude-plugin/marketplace.json → 5.0.2
  • Tag v5.0.2

Don't miss a new token-optimizer release

NewReleases is sending notifications on new releases.