@alexgreensh/token-optimizer 5.13.65 → 5.13.66
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/hooks/module_runner.py +62 -13
- package/hooks/userpromptsubmit_runner.py +13 -1
- package/package.json +1 -1
- package/skills/token-optimizer/scripts/_measure/__init__.py +16 -0
- package/skills/token-optimizer/scripts/_measure/_compat.py +200 -0
- package/skills/token-optimizer/scripts/_measure/audit.py +6949 -0
- package/skills/token-optimizer/scripts/_measure/cache_policy.py +6997 -0
- package/skills/token-optimizer/scripts/_measure/cli.py +2722 -0
- package/skills/token-optimizer/scripts/_measure/continuity.py +4630 -0
- package/skills/token-optimizer/scripts/_measure/daemon.py +6773 -0
- package/skills/token-optimizer/scripts/_measure/dashboard.py +4358 -0
- package/skills/token-optimizer/scripts/_measure/lifecycle.py +5952 -0
- package/skills/token-optimizer/scripts/_measure/pricing.py +2101 -0
- package/skills/token-optimizer/scripts/_measure/quality_archive.py +7138 -0
- package/skills/token-optimizer/scripts/_measure/runtime.py +1231 -0
- package/skills/token-optimizer/scripts/_measure/savings.py +7702 -0
- package/skills/token-optimizer/scripts/_measure/sessions.py +4784 -0
- package/skills/token-optimizer/scripts/_measure/trends.py +2432 -0
- package/skills/token-optimizer/scripts/cloud_kit.py +7 -8
- package/skills/token-optimizer/scripts/codex_doctor.py +14 -0
- package/skills/token-optimizer/scripts/devin_source.py +1 -0
- package/skills/token-optimizer/scripts/hermes_doctor.py +13 -0
- package/skills/token-optimizer/scripts/hermes_install.py +11 -0
- package/skills/token-optimizer/scripts/measure.py +2428 -60928
|
@@ -37,9 +37,7 @@ Rules this module keeps:
|
|
|
37
37
|
install-cloud.sh appends to install.log, and exit status 1), and the
|
|
38
38
|
shell wrapper always exits 0, so a cloud session's setup never fails.
|
|
39
39
|
"""
|
|
40
|
-
|
|
41
40
|
from __future__ import annotations
|
|
42
|
-
|
|
43
41
|
import base64
|
|
44
42
|
import compileall
|
|
45
43
|
import hashlib
|
|
@@ -53,7 +51,6 @@ import tempfile
|
|
|
53
51
|
import urllib.parse
|
|
54
52
|
import urllib.request
|
|
55
53
|
from pathlib import Path
|
|
56
|
-
|
|
57
54
|
PACKAGE = "@alexgreensh/token-optimizer"
|
|
58
55
|
REGISTRY = "https://registry.npmjs.org"
|
|
59
56
|
CACHE_DIRNAME = "token-optimizer-cloud"
|
|
@@ -61,15 +58,11 @@ RUNNER_NAME = "token-optimizer-cloud-run.sh"
|
|
|
61
58
|
# Every hook command we write contains this (whatever the cache dir is); it is
|
|
62
59
|
# how we, and measure.py's self-heal, recognize our entries and only ours.
|
|
63
60
|
MARKER = "/" + RUNNER_NAME
|
|
64
|
-
|
|
65
61
|
SCRIPTS_DIR = Path(__file__).resolve().parent
|
|
66
62
|
PLUGIN_ROOT = SCRIPTS_DIR.parents[2]
|
|
67
|
-
|
|
68
63
|
# Semver with an optional prerelease tag (5.13.50-rc.1). The charset stays
|
|
69
64
|
# shell-safe because the version is rendered into the setup script.
|
|
70
65
|
_VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?$")
|
|
71
|
-
|
|
72
|
-
|
|
73
66
|
def _version_key(v: str):
|
|
74
67
|
"""Sort key: releases after their prereleases, numeric parts numerically."""
|
|
75
68
|
core, _, pre = v.partition("-")
|
|
@@ -491,7 +484,13 @@ def render_run_sh(root: Path, pycache: Path, version: str) -> str:
|
|
|
491
484
|
# extracted tarball (package.json, README, LICENSE files) is copied too; this
|
|
492
485
|
# list is what must exist for a usable install.
|
|
493
486
|
_REQUIRED = ("hooks/hooks.json", "hooks/python-launcher.sh", "hooks/run.py",
|
|
494
|
-
"skills/token-optimizer/scripts/measure.py")
|
|
487
|
+
"skills/token-optimizer/scripts/measure.py") + tuple(
|
|
488
|
+
"skills/token-optimizer/scripts/_measure/" + name for name in (
|
|
489
|
+
'__init__.py', '_compat.py', 'runtime.py', 'pricing.py', 'audit.py',
|
|
490
|
+
'dashboard.py', 'lifecycle.py', 'sessions.py', 'trends.py', 'cache_policy.py',
|
|
491
|
+
'daemon.py', 'quality_archive.py', 'continuity.py', 'savings.py', 'cli.py',
|
|
492
|
+
)
|
|
493
|
+
)
|
|
495
494
|
|
|
496
495
|
|
|
497
496
|
# Written into the cache dir on install. Uninstall only removes the shared
|
|
@@ -57,6 +57,16 @@ SKILL_INSTALL_FILES = (
|
|
|
57
57
|
)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
# Completeness is separate from the legacy healthy-output counts.
|
|
61
|
+
_MEASURE_PACKAGE_FILES = (
|
|
62
|
+
"_measure/__init__.py", "_measure/_compat.py", "_measure/runtime.py",
|
|
63
|
+
"_measure/pricing.py", "_measure/audit.py", "_measure/dashboard.py",
|
|
64
|
+
"_measure/lifecycle.py", "_measure/sessions.py", "_measure/trends.py",
|
|
65
|
+
"_measure/cache_policy.py", "_measure/daemon.py", "_measure/quality_archive.py",
|
|
66
|
+
"_measure/continuity.py", "_measure/savings.py", "_measure/cli.py",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
60
70
|
def _repo_root() -> Path:
|
|
61
71
|
return Path(__file__).resolve().parents[3]
|
|
62
72
|
|
|
@@ -207,6 +217,8 @@ def _command_mentions_missing_path(root: Path, command: str) -> bool:
|
|
|
207
217
|
|
|
208
218
|
def _required_file_checks(root: Path) -> list[dict[str, str]]:
|
|
209
219
|
missing = [rel for rel in REQUIRED_FILES if not (root / rel).exists()]
|
|
220
|
+
missing += ['skills/token-optimizer/scripts/' + rel for rel in _MEASURE_PACKAGE_FILES
|
|
221
|
+
if not (root / 'skills/token-optimizer/scripts' / rel).is_file()]
|
|
210
222
|
if missing:
|
|
211
223
|
return [_check("FAIL", "Required files", ", ".join(missing))]
|
|
212
224
|
return [_check("OK", "Required files", f"{len(REQUIRED_FILES)} present")]
|
|
@@ -215,6 +227,8 @@ def _required_file_checks(root: Path) -> list[dict[str, str]]:
|
|
|
215
227
|
def _skill_install_checks() -> list[dict[str, str]]:
|
|
216
228
|
root = _skill_root()
|
|
217
229
|
missing = [rel for rel in SKILL_INSTALL_FILES if not (root / rel).exists()]
|
|
230
|
+
missing += ['scripts/' + rel for rel in _MEASURE_PACKAGE_FILES
|
|
231
|
+
if not (root / 'scripts' / rel).is_file()]
|
|
218
232
|
if missing:
|
|
219
233
|
return [_check("FAIL", "Installed skill files", ", ".join(missing))]
|
|
220
234
|
return [
|
|
@@ -16,6 +16,7 @@ ALLOWED_MODULES = frozenset(Path(name).stem for name in PAYLOAD)
|
|
|
16
16
|
|
|
17
17
|
# Repo names outside the installed closure must never fall back to sys.path.
|
|
18
18
|
REPO_MODULES = frozenset((
|
|
19
|
+
'_measure',
|
|
19
20
|
'activity_tracker', 'adapter_hook_command', 'antigravity_doctor', 'antigravity_hook_bridge', 'antigravity_install',
|
|
20
21
|
'antigravity_proto', 'antigravity_session', 'antigravity_state', 'archive_result',
|
|
21
22
|
'bash_compress', 'bash_compress_hook', 'bash_hook', 'bash_whitelist', 'benchmark', 'cloud_kit',
|
|
@@ -345,6 +345,16 @@ def _registration_checks() -> list[dict[str, str]]:
|
|
|
345
345
|
return checks
|
|
346
346
|
|
|
347
347
|
|
|
348
|
+
# Completeness is separate from the legacy healthy-output counts.
|
|
349
|
+
_MEASURE_PACKAGE_FILES = (
|
|
350
|
+
"_measure/__init__.py", "_measure/_compat.py", "_measure/runtime.py",
|
|
351
|
+
"_measure/pricing.py", "_measure/audit.py", "_measure/dashboard.py",
|
|
352
|
+
"_measure/lifecycle.py", "_measure/sessions.py", "_measure/trends.py",
|
|
353
|
+
"_measure/cache_policy.py", "_measure/daemon.py", "_measure/quality_archive.py",
|
|
354
|
+
"_measure/continuity.py", "_measure/savings.py", "_measure/cli.py",
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
|
|
348
358
|
def _engine_checks() -> list[dict[str, str]]:
|
|
349
359
|
"""The checkout the plugin points at must hold every engine script."""
|
|
350
360
|
plugin_dir = _plugin_install_dir(hermes_home())
|
|
@@ -355,6 +365,7 @@ def _engine_checks() -> list[dict[str, str]]:
|
|
|
355
365
|
return [_check("FAIL", "Engine scripts", f"cannot read {locator}; re-run: python3 hermes_install.py")]
|
|
356
366
|
sdir = measure_py.parent
|
|
357
367
|
missing = [name for name in REQUIRED_ENGINE_SCRIPTS if not (sdir / name).is_file()]
|
|
368
|
+
missing += [name for name in _MEASURE_PACKAGE_FILES if not (sdir / name).is_file()]
|
|
358
369
|
if missing:
|
|
359
370
|
return [_check("FAIL", "Engine scripts",
|
|
360
371
|
f"missing in {sdir}: {', '.join(missing)}; update the Token Optimizer checkout")]
|
|
@@ -645,6 +656,8 @@ def _dashboard_port_check() -> dict[str, str]:
|
|
|
645
656
|
def _skill_install_checks() -> list[dict[str, str]]:
|
|
646
657
|
root = _skill_root()
|
|
647
658
|
missing = [rel for rel in SKILL_INSTALL_FILES if not (root / rel).exists()]
|
|
659
|
+
missing += ['scripts/' + rel for rel in _MEASURE_PACKAGE_FILES
|
|
660
|
+
if not (root / 'scripts' / rel).is_file()]
|
|
648
661
|
if missing:
|
|
649
662
|
return [_check("FAIL", "Installed skill files", ", ".join(missing))]
|
|
650
663
|
return [
|
|
@@ -90,6 +90,16 @@ _CONFIG_FALLBACK = "config.yml"
|
|
|
90
90
|
_ENABLE_SNIPPET = "plugins:\n enabled:\n - token-optimizer\n"
|
|
91
91
|
|
|
92
92
|
|
|
93
|
+
# Completeness is separate from the legacy healthy-output counts.
|
|
94
|
+
_MEASURE_PACKAGE_FILES = (
|
|
95
|
+
"_measure/__init__.py", "_measure/_compat.py", "_measure/runtime.py",
|
|
96
|
+
"_measure/pricing.py", "_measure/audit.py", "_measure/dashboard.py",
|
|
97
|
+
"_measure/lifecycle.py", "_measure/sessions.py", "_measure/trends.py",
|
|
98
|
+
"_measure/cache_policy.py", "_measure/daemon.py", "_measure/quality_archive.py",
|
|
99
|
+
"_measure/continuity.py", "_measure/savings.py", "_measure/cli.py",
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
93
103
|
def _scripts_dir() -> Path:
|
|
94
104
|
"""Return the scripts/ dir that contains this installer and the runtime modules."""
|
|
95
105
|
return Path(__file__).resolve().parent
|
|
@@ -435,6 +445,7 @@ def install(
|
|
|
435
445
|
)
|
|
436
446
|
runtime_srcs.append(src)
|
|
437
447
|
missing_engines = [name for name in _ENGINE_SCRIPTS if not (scripts_dir / name).is_file()]
|
|
448
|
+
missing_engines += [name for name in _MEASURE_PACKAGE_FILES if not (scripts_dir / name).is_file()]
|
|
438
449
|
if missing_engines:
|
|
439
450
|
raise ValueError(
|
|
440
451
|
f"Token Optimizer engine scripts missing from {scripts_dir}: "
|