claude-code-tracker 1.2.1 → 1.2.3

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/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.3",
4
4
  "description": "Automatic token, cost, and prompt tracking for Claude Code sessions",
5
5
  "keywords": [
6
6
  "claude",
@@ -15,7 +15,7 @@ from datetime import date
15
15
  def find_git_root():
16
16
  root = os.getcwd()
17
17
  while root != "/":
18
- if os.path.isdir(os.path.join(root, ".git")):
18
+ if os.path.exists(os.path.join(root, ".git")):
19
19
  return root
20
20
  root = os.path.dirname(root)
21
21
  return root
package/src/stop-hook.sh CHANGED
@@ -10,7 +10,7 @@ if [[ "${1:-}" == "--backfill-only" ]]; then
10
10
  if [[ -z "$CWD" ]]; then exit 0; fi
11
11
  PROJECT_ROOT="$CWD"
12
12
  while [[ "$PROJECT_ROOT" != "/" ]]; do
13
- [[ -d "$PROJECT_ROOT/.git" ]] && break
13
+ [[ -e "$PROJECT_ROOT/.git" ]] && break
14
14
  PROJECT_ROOT="$(dirname "$PROJECT_ROOT")"
15
15
  done
16
16
  if [[ "$PROJECT_ROOT" == "/" ]]; then exit 0; fi
@@ -37,7 +37,7 @@ if [[ -z "$CWD" || -z "$TRANSCRIPT" || ! -f "$TRANSCRIPT" ]]; then exit 0; fi
37
37
  # Find project root (walk up to .git)
38
38
  PROJECT_ROOT="$CWD"
39
39
  while [[ "$PROJECT_ROOT" != "/" ]]; do
40
- [[ -d "$PROJECT_ROOT/.git" ]] && break
40
+ [[ -e "$PROJECT_ROOT/.git" ]] && break
41
41
  PROJECT_ROOT="$(dirname "$PROJECT_ROOT")"
42
42
  done
43
43
  if [[ "$PROJECT_ROOT" == "/" ]]; then exit 0; fi