@alexgreensh/token-optimizer 0.0.0-stage → 5.13.50

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 (161) hide show
  1. package/.claude-plugin/marketplace.json +76 -0
  2. package/.claude-plugin/plugin.json +21 -0
  3. package/LICENSE +130 -0
  4. package/LICENSE-SMALL-BUSINESS.md +62 -0
  5. package/PRIVACY.md +200 -0
  6. package/README.md +13 -2
  7. package/hooks/codex-hooks.json +4 -0
  8. package/hooks/hooks.json +182 -0
  9. package/hooks/module_runner.py +149 -0
  10. package/hooks/posttooluse_runner.py +1110 -0
  11. package/hooks/python-launcher.sh +816 -0
  12. package/hooks/run.py +776 -0
  13. package/hooks/sessionstart_runner.py +629 -0
  14. package/hooks/stop_runner.py +408 -0
  15. package/hooks/userpromptsubmit_runner.py +722 -0
  16. package/hooks/windows-launcher.py +163 -0
  17. package/install-cloud.sh +23 -0
  18. package/package.json +29 -4
  19. package/skills/fleet-auditor/SKILL.md +150 -0
  20. package/skills/fleet-auditor/references/fleet-systems.md +167 -0
  21. package/skills/fleet-auditor/references/report-template.md +50 -0
  22. package/skills/fleet-auditor/references/waste-patterns.md +126 -0
  23. package/skills/fleet-auditor/scripts/fleet.py +3612 -0
  24. package/skills/fleet-auditor/scripts/shared.py +277 -0
  25. package/skills/resume-checkpoint/SKILL.md +52 -0
  26. package/skills/resume-checkpoint/scripts/pull_checkpoint.py +188 -0
  27. package/skills/token-coach/SKILL.md +129 -0
  28. package/skills/token-coach/assets/coach-dashboard-tab.html +45 -0
  29. package/skills/token-coach/examples/coaching-session-agentic.md +62 -0
  30. package/skills/token-coach/examples/coaching-session-heavy-setup.md +46 -0
  31. package/skills/token-coach/examples/coaching-session-new-project.md +38 -0
  32. package/skills/token-coach/references/agentic-systems.md +147 -0
  33. package/skills/token-coach/references/coach-patterns.md +120 -0
  34. package/skills/token-coach/references/coaching-scripts.md +146 -0
  35. package/skills/token-coach/references/deterministic-stages.md +102 -0
  36. package/skills/token-coach/references/keepwarm-consent.md +48 -0
  37. package/skills/token-coach/references/quick-reference.md +155 -0
  38. package/skills/token-dashboard/SKILL.md +72 -0
  39. package/skills/token-optimizer/SKILL.md +150 -0
  40. package/skills/token-optimizer/assets/dashboard.html +7251 -0
  41. package/skills/token-optimizer/examples/claude-md-optimized.md +40 -0
  42. package/skills/token-optimizer/examples/hooks-starter.json +179 -0
  43. package/skills/token-optimizer/examples/permissions-deny-template.json +24 -0
  44. package/skills/token-optimizer/pricing/prices.json +695 -0
  45. package/skills/token-optimizer/references/agent-prompts.md +687 -0
  46. package/skills/token-optimizer/references/cli-reference.md +92 -0
  47. package/skills/token-optimizer/references/codex-workflow.md +188 -0
  48. package/skills/token-optimizer/references/cursor-workflow.md +74 -0
  49. package/skills/token-optimizer/references/error-recovery.md +37 -0
  50. package/skills/token-optimizer/references/implementation-playbook.md +416 -0
  51. package/skills/token-optimizer/references/keepwarm-consent.md +48 -0
  52. package/skills/token-optimizer/references/opencode-workflow.md +72 -0
  53. package/skills/token-optimizer/references/optimization-checklist.md +714 -0
  54. package/skills/token-optimizer/references/phase0-setup.md +142 -0
  55. package/skills/token-optimizer/references/presentation-workflow.md +72 -0
  56. package/skills/token-optimizer/references/session-continuity.md +19 -0
  57. package/skills/token-optimizer/references/token-flow-architecture.md +629 -0
  58. package/skills/token-optimizer/scripts/activity_tracker.py +143 -0
  59. package/skills/token-optimizer/scripts/antigravity_doctor.py +548 -0
  60. package/skills/token-optimizer/scripts/antigravity_hook_bridge.py +511 -0
  61. package/skills/token-optimizer/scripts/antigravity_install.py +376 -0
  62. package/skills/token-optimizer/scripts/antigravity_proto.py +413 -0
  63. package/skills/token-optimizer/scripts/antigravity_session.py +346 -0
  64. package/skills/token-optimizer/scripts/antigravity_state.py +486 -0
  65. package/skills/token-optimizer/scripts/archive_result.py +1725 -0
  66. package/skills/token-optimizer/scripts/bash_compress.py +2490 -0
  67. package/skills/token-optimizer/scripts/bash_compress_hook.py +766 -0
  68. package/skills/token-optimizer/scripts/bash_hook.py +61 -0
  69. package/skills/token-optimizer/scripts/bash_whitelist.py +243 -0
  70. package/skills/token-optimizer/scripts/benchmark.py +1765 -0
  71. package/skills/token-optimizer/scripts/build_output_compress.py +776 -0
  72. package/skills/token-optimizer/scripts/cloud_kit.py +991 -0
  73. package/skills/token-optimizer/scripts/codex_command_compress.py +434 -0
  74. package/skills/token-optimizer/scripts/codex_compact_prompt.py +273 -0
  75. package/skills/token-optimizer/scripts/codex_doctor.py +454 -0
  76. package/skills/token-optimizer/scripts/codex_hook_bridge.py +311 -0
  77. package/skills/token-optimizer/scripts/codex_install.py +810 -0
  78. package/skills/token-optimizer/scripts/codex_io.py +119 -0
  79. package/skills/token-optimizer/scripts/codex_log_index.py +219 -0
  80. package/skills/token-optimizer/scripts/codex_models.py +34 -0
  81. package/skills/token-optimizer/scripts/codex_session.py +1186 -0
  82. package/skills/token-optimizer/scripts/codex_state.py +707 -0
  83. package/skills/token-optimizer/scripts/codex_statusline.py +303 -0
  84. package/skills/token-optimizer/scripts/command_filters.py +386 -0
  85. package/skills/token-optimizer/scripts/compression_backfill.py +600 -0
  86. package/skills/token-optimizer/scripts/compression_log.py +230 -0
  87. package/skills/token-optimizer/scripts/context_intel.py +331 -0
  88. package/skills/token-optimizer/scripts/context_pressure.py +115 -0
  89. package/skills/token-optimizer/scripts/copilot_doctor.py +406 -0
  90. package/skills/token-optimizer/scripts/copilot_hook_bridge.py +709 -0
  91. package/skills/token-optimizer/scripts/copilot_install.py +277 -0
  92. package/skills/token-optimizer/scripts/copilot_session.py +496 -0
  93. package/skills/token-optimizer/scripts/copilot_state.py +569 -0
  94. package/skills/token-optimizer/scripts/copilot_vscode.py +832 -0
  95. package/skills/token-optimizer/scripts/cowork_doctor.py +270 -0
  96. package/skills/token-optimizer/scripts/cowork_install.py +380 -0
  97. package/skills/token-optimizer/scripts/credential_patterns.py +1514 -0
  98. package/skills/token-optimizer/scripts/cursor_doctor.py +602 -0
  99. package/skills/token-optimizer/scripts/cursor_hook_bridge.py +843 -0
  100. package/skills/token-optimizer/scripts/cursor_install.py +423 -0
  101. package/skills/token-optimizer/scripts/cursor_session.py +303 -0
  102. package/skills/token-optimizer/scripts/cursor_state.py +348 -0
  103. package/skills/token-optimizer/scripts/delta_diff.py +110 -0
  104. package/skills/token-optimizer/scripts/detectors/__init__.py +2 -0
  105. package/skills/token-optimizer/scripts/detectors/bad_decomposition.py +78 -0
  106. package/skills/token-optimizer/scripts/detectors/cache_instability.py +504 -0
  107. package/skills/token-optimizer/scripts/detectors/looping.py +88 -0
  108. package/skills/token-optimizer/scripts/detectors/output_waste.py +143 -0
  109. package/skills/token-optimizer/scripts/detectors/overpowered.py +116 -0
  110. package/skills/token-optimizer/scripts/detectors/pdf_ingestion.py +52 -0
  111. package/skills/token-optimizer/scripts/detectors/registry.py +65 -0
  112. package/skills/token-optimizer/scripts/detectors/respond_to_bash.py +76 -0
  113. package/skills/token-optimizer/scripts/detectors/retry_churn.py +83 -0
  114. package/skills/token-optimizer/scripts/detectors/tool_cascade.py +62 -0
  115. package/skills/token-optimizer/scripts/detectors/wasteful_thinking.py +75 -0
  116. package/skills/token-optimizer/scripts/detectors/weak_model.py +55 -0
  117. package/skills/token-optimizer/scripts/detectors/websearch_routing.py +72 -0
  118. package/skills/token-optimizer/scripts/deterministic_candidates.py +1458 -0
  119. package/skills/token-optimizer/scripts/devin_compress.py +790 -0
  120. package/skills/token-optimizer/scripts/devin_doctor.py +403 -0
  121. package/skills/token-optimizer/scripts/devin_hooks.py +453 -0
  122. package/skills/token-optimizer/scripts/devin_install.py +1086 -0
  123. package/skills/token-optimizer/scripts/devin_source.py +119 -0
  124. package/skills/token-optimizer/scripts/devin_state.py +330 -0
  125. package/skills/token-optimizer/scripts/devin_verify.py +67 -0
  126. package/skills/token-optimizer/scripts/grok_doctor.py +560 -0
  127. package/skills/token-optimizer/scripts/grok_hook_bridge.py +699 -0
  128. package/skills/token-optimizer/scripts/grok_install.py +397 -0
  129. package/skills/token-optimizer/scripts/grok_session.py +317 -0
  130. package/skills/token-optimizer/scripts/grok_state.py +299 -0
  131. package/skills/token-optimizer/scripts/hermes_doctor.py +479 -0
  132. package/skills/token-optimizer/scripts/hermes_hook_bridge.py +285 -0
  133. package/skills/token-optimizer/scripts/hermes_install.py +668 -0
  134. package/skills/token-optimizer/scripts/hermes_session.py +691 -0
  135. package/skills/token-optimizer/scripts/hermes_state.py +448 -0
  136. package/skills/token-optimizer/scripts/hook_io.py +120 -0
  137. package/skills/token-optimizer/scripts/hook_runtime.py +713 -0
  138. package/skills/token-optimizer/scripts/injection.py +156 -0
  139. package/skills/token-optimizer/scripts/install_reconcile.py +952 -0
  140. package/skills/token-optimizer/scripts/measure.py +58739 -0
  141. package/skills/token-optimizer/scripts/outline.py +53 -0
  142. package/skills/token-optimizer/scripts/pipeline_analyzer.py +723 -0
  143. package/skills/token-optimizer/scripts/plugin_env.py +562 -0
  144. package/skills/token-optimizer/scripts/py_trust.py +80 -0
  145. package/skills/token-optimizer/scripts/quality_cache_gate.py +320 -0
  146. package/skills/token-optimizer/scripts/read_cache.py +2489 -0
  147. package/skills/token-optimizer/scripts/recovery_output.py +110 -0
  148. package/skills/token-optimizer/scripts/refetch_fingerprint.py +236 -0
  149. package/skills/token-optimizer/scripts/refetch_guard.py +244 -0
  150. package/skills/token-optimizer/scripts/routing_advisor.py +389 -0
  151. package/skills/token-optimizer/scripts/runtime_env.py +1893 -0
  152. package/skills/token-optimizer/scripts/session_store.py +979 -0
  153. package/skills/token-optimizer/scripts/spawn_utils.py +122 -0
  154. package/skills/token-optimizer/scripts/statusline.js +660 -0
  155. package/skills/token-optimizer/scripts/structure_map.py +2880 -0
  156. package/skills/token-optimizer/scripts/structure_map_ts.py +676 -0
  157. package/skills/token-optimizer/scripts/structure_replay.py +1556 -0
  158. package/skills/token-optimizer/scripts/thrash_guard.py +604 -0
  159. package/skills/token-optimizer/scripts/token_estimate.py +80 -0
  160. package/skills/token-optimizer/scripts/tool_search_diagnostic.py +61 -0
  161. package/skills/token-optimizer/scripts/utf8_io.py +219 -0
@@ -0,0 +1,285 @@
1
+ #!/usr/bin/env python3
2
+ """Hermes hook bridge for Token Optimizer.
3
+
4
+ Thin shim that locates measure.py and shells into its subcommands (rollup,
5
+ summary, dashboard) on behalf of the Hermes plugin hooks and slash command.
6
+
7
+ Design mirrors codex_hook_bridge.py:
8
+ - Resolves measure.py via __file__ → scripts/ sibling, not hardcoded paths.
9
+ - Captures errors quietly and returns safe empty strings instead of raising.
10
+ - Never imports Hermes modules.
11
+
12
+ Assumption: this file lives in the same directory as measure.py (the scripts/
13
+ directory inside the Token Optimizer repo, or the same directory as __init__.py
14
+ in the Hermes install tree). That directory is:
15
+ ~/.hermes/plugins/token-optimizer/ (installed)
16
+ skills/token-optimizer/scripts/ (repo checkout)
17
+
18
+ Either way, Path(__file__).parent / "measure.py" resolves correctly.
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ import logging
24
+ import os
25
+ import subprocess
26
+ import sys
27
+ from pathlib import Path
28
+
29
+ from runtime_env import runtime_home
30
+ from spawn_utils import spawn_detached
31
+
32
+ # Dashboard port constant — single source of truth.
33
+ try:
34
+ from hermes_doctor import DASHBOARD_PORT # noqa: PLC0415
35
+ except Exception:
36
+ DASHBOARD_PORT = 24844
37
+
38
+ logger = logging.getLogger(__name__)
39
+
40
+ # Windows: a console-subsystem child (python.exe, or an npm .cmd shim hosted by
41
+ # cmd.exe) allocates and flashes a console window unless the parent passes
42
+ # CREATE_NO_WINDOW. getattr -> 0 on POSIX, where creationflags=0 is an
43
+ # accepted no-op (CPython only rejects creationflags != 0 off-Windows).
44
+ # Fire-and-forget spawns go through spawn_utils.spawn_detached instead, whose
45
+ # DETACHED_PROCESS already suppresses console creation.
46
+ _NO_WINDOW = getattr(subprocess, "CREATE_NO_WINDOW", 0)
47
+
48
+ # ---------------------------------------------------------------------------
49
+ # measure.py location
50
+ # ---------------------------------------------------------------------------
51
+
52
+ _SCRIPTS_DIR = Path(__file__).parent.resolve()
53
+ _MEASURE_PY = _SCRIPTS_DIR / "measure.py"
54
+
55
+ # v5.X.Y: the installer does NOT copy measure.py into the plugin dir
56
+ # (version-drift risk). Instead it writes a one-line "measure-path" locator
57
+ # next to this bridge, naming the canonical measure.py in the checkout. We read
58
+ # it after the sibling check, before the hardcoded fallbacks.
59
+ _MEASURE_LOCATOR = _SCRIPTS_DIR / "measure-path"
60
+
61
+ # Fallback search paths if the primary location is missing (e.g. the bridge
62
+ # is bundled into the install tree but measure.py is in the repo checkout).
63
+ _FALLBACK_PATHS: list[Path] = [
64
+ runtime_home() / "skills" / "token-optimizer" / "scripts" / "measure.py",
65
+ Path.home() / ".hermes" / "plugins" / "token-optimizer" / "measure.py",
66
+ ]
67
+
68
+
69
+ _SENTINEL = object() # "not yet resolved" marker for the locate cache
70
+ _locate_measure_py_cache: Path | None | object = _SENTINEL
71
+
72
+ # v5.11.1: emit the "measure.py not found - rollups paused" warning at
73
+ # most once per process so a paused install doesn't spam the Hermes terminal.
74
+ _rollup_missing_warned = False
75
+
76
+
77
+ def _locate_measure_py() -> Path | None:
78
+ """Return the path to measure.py, or None if not found.
79
+
80
+ Result is cached ONLY on success. A None (measure.py not present at
81
+ probe time) is NOT cached so subsequent calls retry the filesystem stat —
82
+ important during install when the file may not yet exist.
83
+ """
84
+ global _locate_measure_py_cache
85
+ if isinstance(_locate_measure_py_cache, Path):
86
+ # v5.11.1: verify the cached path still exists before returning it.
87
+ # A measure.py that was moved/deleted after first resolution would
88
+ # otherwise have us shell to a dead path forever; one cheap stat per
89
+ # call re-resolves it instead.
90
+ if _locate_measure_py_cache.is_file():
91
+ return _locate_measure_py_cache
92
+ _locate_measure_py_cache = _SENTINEL
93
+ if _MEASURE_PY.is_file():
94
+ _locate_measure_py_cache = _MEASURE_PY
95
+ return _MEASURE_PY
96
+ # Locator file written by hermes_install.py. Tolerate any read/parse
97
+ # failure — a missing or garbage locator must never raise here.
98
+ try:
99
+ if _MEASURE_LOCATOR.is_file():
100
+ located = Path(_MEASURE_LOCATOR.read_text(encoding="utf-8").strip())
101
+ if located.is_file():
102
+ _locate_measure_py_cache = located
103
+ return located
104
+ except (OSError, ValueError):
105
+ pass
106
+ for candidate in _FALLBACK_PATHS:
107
+ if candidate.is_file():
108
+ _locate_measure_py_cache = candidate
109
+ return candidate
110
+ logger.warning(
111
+ "[hermes_hook_bridge] measure.py not found at %s or fallback paths. "
112
+ "Rollup/summary/dashboard will be skipped.",
113
+ _MEASURE_PY,
114
+ )
115
+ # Do NOT cache None — allow retry on next call.
116
+ return None
117
+
118
+
119
+ # ---------------------------------------------------------------------------
120
+ # Internal subprocess helper
121
+ # ---------------------------------------------------------------------------
122
+
123
+ def _run_measure(args: list[str], *, capture_output: bool = True, timeout: int = 30) -> str:
124
+ """Run `python3 measure.py <args>` and return stdout as a string.
125
+
126
+ On any error returns an empty string without raising.
127
+ """
128
+ measure_py = _locate_measure_py()
129
+ if measure_py is None:
130
+ return ""
131
+ cmd = [sys.executable, str(measure_py)] + args
132
+ try:
133
+ result = subprocess.run(
134
+ cmd,
135
+ capture_output=capture_output,
136
+ text=True,
137
+ encoding="utf-8",
138
+ errors="replace",
139
+ timeout=timeout,
140
+ env={**os.environ, "TOKEN_OPTIMIZER_RUNTIME": "hermes",
141
+ "PYTHONUTF8": "1", "PYTHONIOENCODING": "utf-8"},
142
+ creationflags=_NO_WINDOW,
143
+ )
144
+ if result.returncode != 0 and result.stderr:
145
+ logger.debug(
146
+ "[hermes_hook_bridge] measure.py %s exited %d: %s",
147
+ args[0] if args else "",
148
+ result.returncode,
149
+ result.stderr[:200],
150
+ )
151
+ return (result.stdout or "").strip() if capture_output else ""
152
+ except subprocess.TimeoutExpired:
153
+ logger.debug("[hermes_hook_bridge] measure.py %s timed out", args[0] if args else "")
154
+ return ""
155
+ except Exception as exc:
156
+ logger.debug("[hermes_hook_bridge] measure.py %s error: %s", args[0] if args else "", exc)
157
+ return ""
158
+
159
+
160
+ # ---------------------------------------------------------------------------
161
+ # Public API (called by hermes/__init__.py hooks and command handlers)
162
+ # ---------------------------------------------------------------------------
163
+
164
+ def run_rollup(
165
+ session_id: str = "", platform: str = "hermes", reason: str = "",
166
+ context_tokens: int | None = None,
167
+ ) -> None:
168
+ """Write a session rollup to TO's trends.db.
169
+
170
+ Shells to: python3 measure.py hermes-rollup --session <id> [--reason <r>]
171
+ Launched fire-and-forget (start_new_session=True) so it never blocks the
172
+ Hermes terminal. stdout/stderr are discarded (--quiet suppresses output).
173
+
174
+ Never raises; errors are logged at DEBUG level only.
175
+ """
176
+ if not session_id:
177
+ return
178
+ measure_py = _locate_measure_py()
179
+ if measure_py is None:
180
+ # v5.11.1: a missing measure.py silently pauses rollups, which is
181
+ # easy to miss. Surface it once to stderr with a remediation pointer.
182
+ global _rollup_missing_warned
183
+ if not _rollup_missing_warned:
184
+ _rollup_missing_warned = True
185
+ print(
186
+ "[Token Optimizer] measure.py not found - rollups paused. "
187
+ "Run hermes-doctor to diagnose.",
188
+ file=sys.stderr,
189
+ )
190
+ return
191
+ cmd = [sys.executable, str(measure_py), "hermes-rollup", "--quiet",
192
+ "--session", session_id]
193
+ if platform:
194
+ cmd += ["--platform", platform]
195
+ if reason:
196
+ cmd += ["--reason", reason]
197
+ if context_tokens is not None and context_tokens > 0:
198
+ cmd += ["--context-tokens", str(int(context_tokens))]
199
+ try:
200
+ _proc = spawn_detached(
201
+ cmd,
202
+ env={**os.environ, "TOKEN_OPTIMIZER_RUNTIME": "hermes",
203
+ "PYTHONUTF8": "1", "PYTHONIOENCODING": "utf-8"},
204
+ stdout=subprocess.DEVNULL,
205
+ stderr=subprocess.DEVNULL,
206
+ )
207
+ except Exception as exc:
208
+ logger.debug("[hermes_hook_bridge] run_rollup Popen error: %s", exc)
209
+ return
210
+ if _proc is None:
211
+ logger.warning("[hermes_hook_bridge] run_rollup spawn_detached returned None")
212
+ # Parity Gap 2: also refresh the dashboard on session-end so a Hermes user
213
+ # sees current data without a manual open. Detached + INTERACTIVE=1 so it runs
214
+ # UNBOUNDED off the hot path (never blocks, never truncates on the hook budget).
215
+ try:
216
+ spawn_detached(
217
+ [sys.executable, str(measure_py), "dashboard", "--quiet"],
218
+ env={**os.environ, "TOKEN_OPTIMIZER_RUNTIME": "hermes",
219
+ "TOKEN_OPTIMIZER_INTERACTIVE": "1",
220
+ "PYTHONUTF8": "1", "PYTHONIOENCODING": "utf-8"},
221
+ stdout=subprocess.DEVNULL,
222
+ stderr=subprocess.DEVNULL,
223
+ )
224
+ except Exception as exc:
225
+ logger.debug("[hermes_hook_bridge] run_rollup dashboard regen error: %s", exc)
226
+
227
+
228
+ def run_summary(session_id: str = "") -> str:
229
+ """Return a text summary for the current or specified session.
230
+
231
+ Shells to: python3 measure.py hermes-summary [--session <id>]
232
+
233
+ Returns the summary string or an empty string on error.
234
+ """
235
+ args = ["hermes-summary"]
236
+ if session_id:
237
+ args += ["--session", session_id]
238
+ return _run_measure(args, capture_output=True, timeout=15)
239
+
240
+
241
+ def run_dashboard(session_id: str = "", port: int = DASHBOARD_PORT) -> None:
242
+ """Open / serve the Token Optimizer dashboard on the given port.
243
+
244
+ Shells to: python3 measure.py dashboard [--port <port>]
245
+
246
+ This is a long-running command; we launch it without capturing output and
247
+ without waiting, so the CLI handler returns immediately.
248
+ """
249
+ measure_py = _locate_measure_py()
250
+ if measure_py is None:
251
+ print("[Token Optimizer] measure.py not found; cannot open dashboard.")
252
+ return
253
+ args = [sys.executable, str(measure_py), "dashboard", "--port", str(port)]
254
+ if session_id:
255
+ args += ["--session", session_id]
256
+ try:
257
+ _proc = spawn_detached(
258
+ args,
259
+ env={**os.environ, "TOKEN_OPTIMIZER_RUNTIME": "hermes",
260
+ "PYTHONUTF8": "1", "PYTHONIOENCODING": "utf-8"},
261
+ stdout=subprocess.DEVNULL,
262
+ stderr=subprocess.DEVNULL,
263
+ )
264
+ except Exception as exc:
265
+ logger.debug("[hermes_hook_bridge] dashboard launch error: %s", exc)
266
+ print(f"[Token Optimizer] Could not open dashboard: {exc}")
267
+ return
268
+ if _proc is None:
269
+ logger.warning("[hermes_hook_bridge] run_dashboard spawn_detached returned None")
270
+ print("[Token Optimizer] Could not open dashboard: spawn failed")
271
+
272
+
273
+ if __name__ == "__main__":
274
+ try:
275
+ from utf8_io import enforce_utf8_io
276
+ enforce_utf8_io()
277
+ except Exception:
278
+ pass
279
+ # Quick smoke test: locate measure.py and print status.
280
+ p = _locate_measure_py()
281
+ if p:
282
+ print(f"[OK] measure.py found at {p}")
283
+ else:
284
+ print("[WARN] measure.py not found")
285
+ sys.exit(1)