claude-code-tracker 1.2.1 → 1.2.2

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.
Files changed (2) hide show
  1. package/install.sh +15 -18
  2. package/package.json +1 -1
package/install.sh CHANGED
@@ -55,31 +55,28 @@ hook_entry = {"type": "command", "command": hook_cmd, "timeout": 30, "async": Tr
55
55
  hooks = data.setdefault("hooks", {})
56
56
  stop_hooks = hooks.setdefault("Stop", [])
57
57
 
58
- already_stop = any(
59
- h.get("command") == hook_cmd
60
- for group in stop_hooks for h in group.get("hooks", [])
61
- )
62
- if already_stop:
63
- print("Hook already registered.")
64
- else:
65
- stop_hooks.append({"hooks": [hook_entry]})
58
+ # Remove any existing stop-hook.sh entries (from npm or brew) and replace with current path
59
+ stop_hooks[:] = [
60
+ g for g in stop_hooks
61
+ if not any("stop-hook.sh" in h.get("command", "") for h in g.get("hooks", []))
62
+ ]
63
+ stop_hooks.append({"hooks": [hook_entry]})
66
64
 
67
- # SessionStart hook
65
+ # SessionStart hook — same: remove old entries and replace
68
66
  backfill_cmd = hook_cmd + " --backfill-only"
69
67
  session_hooks = hooks.setdefault("SessionStart", [])
70
- already_session = any(
71
- h.get("command") == backfill_cmd
72
- for group in session_hooks for h in group.get("hooks", [])
73
- )
74
- if not already_session:
75
- session_hooks.append({"hooks": [{"type": "command", "command": backfill_cmd, "timeout": 60, "async": True}]})
68
+ session_hooks[:] = [
69
+ g for g in session_hooks
70
+ if not any("stop-hook.sh" in h.get("command", "") for h in g.get("hooks", []))
71
+ ]
72
+ session_hooks.append({"hooks": [{"type": "command", "command": backfill_cmd, "timeout": 60, "async": True}]})
76
73
 
77
- # permissions.allow
74
+ # permissions.allow — clean old entries and add current
78
75
  allow_entry = f"Bash({hook_cmd}*)"
79
76
  perms = data.setdefault("permissions", {})
80
77
  allow_list = perms.setdefault("allow", [])
81
- if allow_entry not in allow_list:
82
- allow_list.append(allow_entry)
78
+ allow_list[:] = [e for e in allow_list if "stop-hook.sh" not in e]
79
+ allow_list.append(allow_entry)
83
80
 
84
81
  os.makedirs(os.path.dirname(os.path.abspath(settings_file)), exist_ok=True)
85
82
  with open(settings_file, 'w') as f:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-tracker",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Automatic token, cost, and prompt tracking for Claude Code sessions",
5
5
  "keywords": [
6
6
  "claude",