@alexgreensh/token-optimizer 5.13.54 → 5.13.55
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.
|
|
16
|
+
"version": "5.13.55",
|
|
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.
|
|
58
|
+
"version": "5.13.55",
|
|
59
59
|
"author": {
|
|
60
60
|
"name": "Alex Greenshpun",
|
|
61
61
|
"url": "https://linkedin.com/in/alexgreensh"
|
package/hooks/module_runner.py
CHANGED
|
@@ -106,6 +106,23 @@ _COLD_COMPILE_WAIT_S = {
|
|
|
106
106
|
"measure": 4.0,
|
|
107
107
|
"codex_hook_bridge": 1.5,
|
|
108
108
|
}
|
|
109
|
+
# The PreCompact save (measure.py compact-capture --trigger auto) is the one
|
|
110
|
+
# measure.py hook whose skip loses data: no save means the restore after the
|
|
111
|
+
# compaction falls back to an older checkpoint. Its host timeout is 30 s and it
|
|
112
|
+
# runs async, so it can wait far longer than the 4 s the tightest measure.py
|
|
113
|
+
# hook allows. 12 s + its own 15 s budget (hook_runtime.BUDGET_PRECOMPACT_CAPTURE)
|
|
114
|
+
# + start-up stays under the 30 s.
|
|
115
|
+
_COLD_COMPILE_WAIT_PRECOMPACT_SAVE_S = 12.0
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _is_precompact_save(module_name: str, script_args) -> bool:
|
|
119
|
+
args = list(script_args or ())
|
|
120
|
+
if module_name != "measure" or not args or args[0] != "compact-capture":
|
|
121
|
+
return False
|
|
122
|
+
try:
|
|
123
|
+
return args[args.index("--trigger") + 1] == "auto"
|
|
124
|
+
except (ValueError, IndexError):
|
|
125
|
+
return False
|
|
109
126
|
# Seconds; overrides every wait above. A negative value turns the gate off
|
|
110
127
|
# (compile inline, the pre-5.13.51 behaviour).
|
|
111
128
|
_COLD_COMPILE_WAIT_ENV = "TOKEN_OPTIMIZER_COLD_COMPILE_WAIT_S"
|
|
@@ -332,10 +349,12 @@ def _measure_bytecode_ready(plugin_scripts: str, wait_s: float) -> bool:
|
|
|
332
349
|
time.sleep(0.05)
|
|
333
350
|
|
|
334
351
|
|
|
335
|
-
def _cold_compile_wait(module_name: str):
|
|
352
|
+
def _cold_compile_wait(module_name: str, script_args=()):
|
|
336
353
|
"""Seconds this entry may wait for a background compile, or None when the
|
|
337
354
|
entry is not gated (it does not import measure.py up front)."""
|
|
338
355
|
wait = _COLD_COMPILE_WAIT_S.get(module_name)
|
|
356
|
+
if _is_precompact_save(module_name, script_args):
|
|
357
|
+
wait = _COLD_COMPILE_WAIT_PRECOMPACT_SAVE_S
|
|
339
358
|
if wait is None:
|
|
340
359
|
return None
|
|
341
360
|
raw = os.environ.get(_COLD_COMPILE_WAIT_ENV, "").strip()
|
|
@@ -386,7 +405,7 @@ def main() -> int:
|
|
|
386
405
|
|
|
387
406
|
# Before anything imports measure.py: never compile it on the hook's
|
|
388
407
|
# deadline (#264). See _measure_bytecode_ready.
|
|
389
|
-
_wait = _cold_compile_wait(module_name)
|
|
408
|
+
_wait = _cold_compile_wait(module_name, script_args)
|
|
390
409
|
if _wait is not None:
|
|
391
410
|
try:
|
|
392
411
|
if not _measure_bytecode_ready(_plugin_scripts, _wait):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexgreensh/token-optimizer",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.55",
|
|
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)",
|