@alexgreensh/token-optimizer 5.13.55 → 5.13.56

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.
@@ -13,7 +13,7 @@
13
13
  "name": "token-optimizer",
14
14
  "source": "./",
15
15
  "description": "Audit, fix, and monitor Claude Code context window usage. Find the ghost tokens.",
16
- "version": "5.13.55",
16
+ "version": "5.13.56",
17
17
  "author": {
18
18
  "name": "Alex Greenshpun",
19
19
  "url": "https://linkedin.com/in/alexgreensh"
@@ -55,7 +55,7 @@
55
55
  "name": "token-optimizer-cowork",
56
56
  "source": "./cowork/token-optimizer",
57
57
  "description": "Token Optimizer for Claude Cowork \u2014 full skills + Cowork-native hooks (beta). Install THIS in Cowork; the standard token-optimizer entry is for desktop Claude Code.",
58
- "version": "5.13.55",
58
+ "version": "5.13.56",
59
59
  "author": {
60
60
  "name": "Alex Greenshpun",
61
61
  "url": "https://linkedin.com/in/alexgreensh"
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "homepage": "https://github.com/alexgreensh/token-optimizer",
9
9
  "repository": "https://github.com/alexgreensh/token-optimizer",
10
- "version": "5.13.55",
10
+ "version": "5.13.56",
11
11
  "license": "PolyForm-Noncommercial-1.0.0",
12
12
  "keywords": [
13
13
  "token",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgreensh/token-optimizer",
3
- "version": "5.13.55",
3
+ "version": "5.13.56",
4
4
  "description": "Token Optimizer for Claude Code cloud sessions: the real plugin, installed by your cloud environment's setup script.",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "author": "Alex Greenshpun (https://linkedin.com/in/alexgreensh)",
@@ -35046,7 +35046,7 @@ def _remove_our_settings_entries(settings: dict) -> list[str]:
35046
35046
  sl = settings.get("statusLine")
35047
35047
  if isinstance(sl, dict):
35048
35048
  cmd = sl.get("command", "")
35049
- if isinstance(cmd, str) and "statusline.js" in cmd and "token-optimizer" in cmd:
35049
+ if _statusline_cmd_is_ours(cmd):
35050
35050
  del settings["statusLine"]
35051
35051
  removed.append("statusLine (token-optimizer)")
35052
35052
  # Hook entries we own, across every event.
@@ -46833,6 +46833,28 @@ def _statusline_js_in_command(cmd):
46833
46833
  return m.start(3), m.end(3), m.group(3)
46834
46834
 
46835
46835
 
46836
+ def _statusline_cmd_is_ours(cmd):
46837
+ """True when a statusLine command runs Token Optimizer's statusline.js.
46838
+
46839
+ Judged by the folder the script sits in (``token-optimizer/`` or
46840
+ ``token-optimizer/scripts/``), not by "token-optimizer" appearing anywhere
46841
+ in the command: another tool's statusline.js under a home or project folder
46842
+ that happens to contain that name is not ours. A command whose script path
46843
+ cannot be parsed falls back to the plain substring test.
46844
+ """
46845
+ if not isinstance(cmd, str) or "statusline.js" not in cmd or "token-optimizer" not in cmd:
46846
+ return False
46847
+ found = _statusline_js_in_command(cmd)
46848
+ if not found:
46849
+ return True
46850
+ parts = [p for p in re.split(r"[\\/]", found[2].lower()) if p]
46851
+ if len(parts) < 2 or parts[-1] != "statusline.js":
46852
+ return False
46853
+ if parts[-2] == "token-optimizer":
46854
+ return True
46855
+ return len(parts) >= 3 and parts[-2] == "scripts" and parts[-3] == "token-optimizer"
46856
+
46857
+
46836
46858
  def _path_is_under(path, base):
46837
46859
  try:
46838
46860
  Path(path).expanduser().resolve(strict=False).relative_to(Path(base).resolve(strict=False))
@@ -46870,7 +46892,7 @@ def _heal_dangling_statusline():
46870
46892
  if not isinstance(sl, dict):
46871
46893
  return False
46872
46894
  cmd = sl.get("command") or ""
46873
- if not isinstance(cmd, str) or "statusline.js" not in cmd or "token-optimizer" not in cmd:
46895
+ if not _statusline_cmd_is_ours(cmd):
46874
46896
  return False
46875
46897
  found = _statusline_js_in_command(cmd)
46876
46898
  if not found:
@@ -47162,7 +47184,7 @@ def _is_quality_bar_installed(settings=None):
47162
47184
  # Check statusline
47163
47185
  sl = (settings.get("statusLine") or {})
47164
47186
  cmd = sl.get("command", "")
47165
- if "statusline.js" in cmd and "token-optimizer" in cmd:
47187
+ if _statusline_cmd_is_ours(cmd):
47166
47188
  result["statusline"] = True
47167
47189
 
47168
47190
  # Check UserPromptSubmit hook (settings.json). Recognizes both the legacy
@@ -47971,7 +47993,7 @@ def setup_quality_bar(dry_run=False, uninstall=False, status_only=False, force=F
47971
47993
 
47972
47994
  # Remove statusLine if it's ours
47973
47995
  sl = settings.get("statusLine", {})
47974
- if "statusline.js" in sl.get("command", "") and "token-optimizer" in sl.get("command", ""):
47996
+ if _statusline_cmd_is_ours(sl.get("command", "")):
47975
47997
  del settings["statusLine"]
47976
47998
  removed += 1
47977
47999
 
@@ -56436,7 +56458,7 @@ def run_ensure_health():
56436
56458
  # make setup_quality_bar skip silently; never claim an
56437
56459
  # install we didn't deliver.
56438
56460
  _eh_sl = (_read_settings_json()[0].get("statusLine") or {}).get("command", "") or ""
56439
- if "statusline.js" in _eh_sl and "token-optimizer" in _eh_sl:
56461
+ if _statusline_cmd_is_ours(_eh_sl):
56440
56462
  print(
56441
56463
  " [Token Optimizer] Quality statusline enabled "
56442
56464
  "(context % + quality score). "
@@ -56445,7 +56467,7 @@ def run_ensure_health():
56445
56467
  )
56446
56468
  else:
56447
56469
  statusline_cmd = (settings.get("statusLine") or {}).get("command", "") or ""
56448
- statusline_is_ours = "statusline.js" in statusline_cmd and "token-optimizer" in statusline_cmd
56470
+ statusline_is_ours = _statusline_cmd_is_ours(statusline_cmd)
56449
56471
  hooks = settings.get("hooks", {}).get("UserPromptSubmit", [])
56450
56472
  # Recognize the consolidated dispatcher as well as
56451
56473
  # the legacy standalone hook, else this re-adds the