@alexgreensh/token-optimizer 5.13.67 → 5.13.69
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 +1 -1
- package/package.json +1 -1
- package/skills/fleet-auditor/references/fleet-systems.md +38 -0
- package/skills/fleet-auditor/scripts/fleet.py +63 -92
- package/skills/fleet-auditor/scripts/fleet_base.py +106 -0
- package/skills/fleet-auditor/scripts/fleet_cursor_adapter.py +376 -0
- package/skills/token-coach/SKILL.md +21 -23
- package/skills/token-dashboard/SKILL.md +5 -4
- package/skills/token-optimizer/SKILL.md +1 -1
- package/skills/token-optimizer/assets/dashboard.html +101 -50
- package/skills/token-optimizer/references/cli-reference.md +1 -1
- package/skills/token-optimizer/references/cursor-workflow.md +1 -1
- package/skills/token-optimizer/references/phase0-setup.md +1 -1
- package/skills/token-optimizer/references/presentation-workflow.md +1 -1
- package/skills/token-optimizer/scripts/_measure/__init__.py +1 -1
- package/skills/token-optimizer/scripts/_measure/_vendor/README.md +8 -2
- package/skills/token-optimizer/scripts/_measure/_vendor/__init__.py +46 -6
- package/skills/token-optimizer/scripts/_measure/_vendor/tomli/__init__.py +34 -3
- package/skills/token-optimizer/scripts/_measure/audit.py +5 -21
- package/skills/token-optimizer/scripts/_measure/cli.py +86 -0
- package/skills/token-optimizer/scripts/_measure/daemon.py +34 -76
- package/skills/token-optimizer/scripts/_measure/dashboard.py +63 -37
- package/skills/token-optimizer/scripts/_measure/dashboard_history.py +79 -0
- package/skills/token-optimizer/scripts/_measure/lifecycle.py +88 -528
- package/skills/token-optimizer/scripts/_measure/savings.py +20 -70
- package/skills/token-optimizer/scripts/_measure/sessions.py +58 -20
- package/skills/token-optimizer/scripts/_measure/weekly_activity.py +69 -0
- package/skills/token-optimizer/scripts/{_measure/_vendor/tomli/_parser.py → _tomli.py} +156 -10
- package/skills/token-optimizer/scripts/antigravity_install.py +7 -0
- package/skills/token-optimizer/scripts/bash_compress.py +8 -40
- package/skills/token-optimizer/scripts/bash_compress_hook.py +6 -0
- package/skills/token-optimizer/scripts/bash_search_results.py +43 -0
- package/skills/token-optimizer/scripts/cloud_kit.py +22 -22
- package/skills/token-optimizer/scripts/codex_doctor.py +34 -8
- package/skills/token-optimizer/scripts/codex_hook_provenance.py +268 -0
- package/skills/token-optimizer/scripts/codex_install.py +33 -69
- package/skills/token-optimizer/scripts/command_filters.py +39 -309
- package/skills/token-optimizer/scripts/copilot_install.py +9 -0
- package/skills/token-optimizer/scripts/credential_patterns.py +4 -19
- package/skills/token-optimizer/scripts/credential_url_patterns.py +42 -0
- package/skills/token-optimizer/scripts/cursor_audit.py +723 -0
- package/skills/token-optimizer/scripts/cursor_bridge_checkpoint.py +213 -0
- package/skills/token-optimizer/scripts/cursor_bridge_payload.py +170 -0
- package/skills/token-optimizer/scripts/cursor_bridge_rewrite.py +106 -0
- package/skills/token-optimizer/scripts/cursor_bridge_rollup.py +115 -0
- package/skills/token-optimizer/scripts/cursor_coach.py +485 -0
- package/skills/token-optimizer/scripts/cursor_doctor.py +89 -9
- package/skills/token-optimizer/scripts/cursor_hook_bridge.py +393 -276
- package/skills/token-optimizer/scripts/cursor_install.py +111 -19
- package/skills/token-optimizer/scripts/cursor_quality.py +505 -0
- package/skills/token-optimizer/scripts/cursor_read_cache.py +597 -0
- package/skills/token-optimizer/scripts/cursor_session.py +26 -5
- package/skills/token-optimizer/scripts/cursor_state.py +8 -0
- package/skills/token-optimizer/scripts/cursor_statusline.py +372 -0
- package/skills/token-optimizer/scripts/cursor_thrash.py +78 -0
- package/skills/token-optimizer/scripts/cursor_transcript.py +223 -0
- package/skills/token-optimizer/scripts/devin_install.py +6 -12
- package/skills/token-optimizer/scripts/devin_source.py +17 -6
- package/skills/token-optimizer/scripts/devin_verify.py +17 -0
- package/skills/token-optimizer/scripts/grok_install.py +9 -0
- package/skills/token-optimizer/scripts/heal_report.py +92 -0
- package/skills/token-optimizer/scripts/hermes_doctor.py +4 -1
- package/skills/token-optimizer/scripts/hermes_install.py +4 -1
- package/skills/token-optimizer/scripts/hook_heal.py +138 -0
- package/skills/token-optimizer/scripts/hook_provenance.py +878 -0
- package/skills/token-optimizer/scripts/measure.py +2 -2
- package/skills/token-optimizer/scripts/owned_hooks.py +420 -0
- package/skills/token-optimizer/scripts/shipped_codex_hook_templates.json +5815 -0
- package/skills/token-optimizer/scripts/shipped_hook_templates.py +252 -0
- package/skills/token-optimizer/scripts/shipped_starter_hooks.py +55 -0
- package/skills/token-optimizer/scripts/thrash_guard.py +10 -5
- package/skills/token-optimizer/scripts/_measure/_vendor/tomli/_re.py +0 -112
- package/skills/token-optimizer/scripts/_measure/_vendor/tomli/_types.py +0 -10
|
@@ -244,7 +244,7 @@ _NUMERIC_ERROR_LINE_RE = re.compile(
|
|
|
244
244
|
)
|
|
245
245
|
|
|
246
246
|
|
|
247
|
-
def _text_has_failure(text: str) -> bool:
|
|
247
|
+
def _text_has_failure(text: str, anchored: bool = False) -> bool:
|
|
248
248
|
"""True when any line of ``text`` matches a failure pattern.
|
|
249
249
|
|
|
250
250
|
Per line, so a pattern can match anywhere in the line (gcc/clang
|
|
@@ -255,6 +255,8 @@ def _text_has_failure(text: str) -> bool:
|
|
|
255
255
|
for line in text.splitlines():
|
|
256
256
|
if _NUMERIC_ERROR_LINE_RE.match(line):
|
|
257
257
|
continue
|
|
258
|
+
if anchored and not re.match(r"^\s*(?:(?:error|fatal|traceback|failed|panic|fehler|erreur|errore)\b|[^\n]+:\d+(?::\d+)?:\s*(?:fatal\s+)?error\b)", line, re.IGNORECASE):
|
|
259
|
+
continue
|
|
258
260
|
for pat in _ERROR_STDERR_PATTERNS:
|
|
259
261
|
if pat.search(line):
|
|
260
262
|
return True
|
|
@@ -329,6 +331,7 @@ def _looks_like_failure(
|
|
|
329
331
|
stderr: str,
|
|
330
332
|
exit_code: int | None = None,
|
|
331
333
|
redirected: bool = False,
|
|
334
|
+
combined_output: bool = False,
|
|
332
335
|
) -> bool:
|
|
333
336
|
"""Decide whether a Bash run failed.
|
|
334
337
|
|
|
@@ -340,8 +343,8 @@ def _looks_like_failure(
|
|
|
340
343
|
When no exit code is available, fall back to text: stderr is always
|
|
341
344
|
scanned; stdout is scanned only when the command redirected stderr into
|
|
342
345
|
stdout (``2>&1``), because otherwise an error-looking line on stdout is
|
|
343
|
-
just data. Redirected stdout is scanned line by line
|
|
344
|
-
|
|
346
|
+
just data. Redirected stdout is scanned line by line; combined Cursor
|
|
347
|
+
output uses anchored matching. Numeric error metrics are excluded.
|
|
345
348
|
"""
|
|
346
349
|
if exit_code is not None:
|
|
347
350
|
return exit_code != 0
|
|
@@ -367,7 +370,7 @@ def _looks_like_failure(
|
|
|
367
370
|
from bash_compress import _ERROR_STDERR_PATTERNS
|
|
368
371
|
if stderr and _text_has_failure(stderr):
|
|
369
372
|
return True
|
|
370
|
-
if stdout and redirected and _text_has_failure(stdout):
|
|
373
|
+
if stdout and redirected and _text_has_failure(stdout, anchored=combined_output):
|
|
371
374
|
return True
|
|
372
375
|
except Exception:
|
|
373
376
|
pass
|
|
@@ -381,6 +384,7 @@ def check(
|
|
|
381
384
|
stderr: str = "",
|
|
382
385
|
exit_code: int | None = None,
|
|
383
386
|
store_id: str | None = None,
|
|
387
|
+
combined_output: bool = False,
|
|
384
388
|
):
|
|
385
389
|
"""Record this Bash run and return a nudge line when the streak warrants it.
|
|
386
390
|
|
|
@@ -441,7 +445,8 @@ def check(
|
|
|
441
445
|
now = time.time() if now is None else now
|
|
442
446
|
is_fail = _looks_like_failure(
|
|
443
447
|
output, stderr, exit_code=exit_code,
|
|
444
|
-
redirected="2>&1" in command,
|
|
448
|
+
redirected=combined_output or "2>&1" in command,
|
|
449
|
+
combined_output=combined_output,
|
|
445
450
|
)
|
|
446
451
|
body = _heredoc_body(command)
|
|
447
452
|
has_inline_script = body is not None and len(body) >= INLINE_SCRIPT_MIN_CHARS
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: MIT
|
|
2
|
-
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
|
|
3
|
-
# Licensed to PSF under a Contributor Agreement.
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
from datetime import date, datetime, time, timedelta, timezone, tzinfo
|
|
8
|
-
from functools import lru_cache
|
|
9
|
-
import re
|
|
10
|
-
from typing import Any, Final
|
|
11
|
-
|
|
12
|
-
from ._types import ParseFloat
|
|
13
|
-
|
|
14
|
-
# E.g.
|
|
15
|
-
# - 00:32:00.999999
|
|
16
|
-
# - 00:32:00
|
|
17
|
-
_TIME_RE_STR: Final = (
|
|
18
|
-
r"([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(?:\.([0-9]{1,6})[0-9]*)?"
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
RE_NUMBER: Final = re.compile(
|
|
22
|
-
r"""
|
|
23
|
-
0
|
|
24
|
-
(?:
|
|
25
|
-
x[0-9A-Fa-f](?:_?[0-9A-Fa-f])* # hex
|
|
26
|
-
|
|
|
27
|
-
b[01](?:_?[01])* # bin
|
|
28
|
-
|
|
|
29
|
-
o[0-7](?:_?[0-7])* # oct
|
|
30
|
-
)
|
|
31
|
-
|
|
|
32
|
-
[+-]?(?:0|[1-9](?:_?[0-9])*) # dec, integer part
|
|
33
|
-
(?P<floatpart>
|
|
34
|
-
(?:\.[0-9](?:_?[0-9])*)? # optional fractional part
|
|
35
|
-
(?:[eE][+-]?[0-9](?:_?[0-9])*)? # optional exponent part
|
|
36
|
-
)
|
|
37
|
-
""",
|
|
38
|
-
flags=re.VERBOSE,
|
|
39
|
-
)
|
|
40
|
-
RE_LOCALTIME: Final = re.compile(_TIME_RE_STR)
|
|
41
|
-
RE_DATETIME: Final = re.compile(
|
|
42
|
-
rf"""
|
|
43
|
-
([0-9]{{4}})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) # date, e.g. 1988-10-27
|
|
44
|
-
(?:
|
|
45
|
-
[Tt ]
|
|
46
|
-
{_TIME_RE_STR}
|
|
47
|
-
(?:([Zz])|([+-])([01][0-9]|2[0-3]):([0-5][0-9]))? # optional time offset
|
|
48
|
-
)?
|
|
49
|
-
""",
|
|
50
|
-
flags=re.VERBOSE,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def match_to_datetime(match: re.Match) -> datetime | date:
|
|
55
|
-
"""Convert a `RE_DATETIME` match to `datetime.datetime` or `datetime.date`.
|
|
56
|
-
|
|
57
|
-
Raises ValueError if the match does not correspond to a valid date
|
|
58
|
-
or datetime.
|
|
59
|
-
"""
|
|
60
|
-
(
|
|
61
|
-
year_str,
|
|
62
|
-
month_str,
|
|
63
|
-
day_str,
|
|
64
|
-
hour_str,
|
|
65
|
-
minute_str,
|
|
66
|
-
sec_str,
|
|
67
|
-
micros_str,
|
|
68
|
-
zulu_time,
|
|
69
|
-
offset_sign_str,
|
|
70
|
-
offset_hour_str,
|
|
71
|
-
offset_minute_str,
|
|
72
|
-
) = match.groups()
|
|
73
|
-
year, month, day = int(year_str), int(month_str), int(day_str)
|
|
74
|
-
if hour_str is None:
|
|
75
|
-
return date(year, month, day)
|
|
76
|
-
hour, minute, sec = int(hour_str), int(minute_str), int(sec_str)
|
|
77
|
-
micros = int(micros_str.ljust(6, "0")) if micros_str else 0
|
|
78
|
-
if offset_sign_str:
|
|
79
|
-
tz: tzinfo | None = cached_tz(
|
|
80
|
-
offset_hour_str, offset_minute_str, offset_sign_str
|
|
81
|
-
)
|
|
82
|
-
elif zulu_time:
|
|
83
|
-
tz = timezone.utc
|
|
84
|
-
else: # local date-time
|
|
85
|
-
tz = None
|
|
86
|
-
return datetime(year, month, day, hour, minute, sec, micros, tzinfo=tz)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
# No need to limit cache size. This is only ever called on input
|
|
90
|
-
# that matched RE_DATETIME, so there is an implicit bound of
|
|
91
|
-
# 24 (hours) * 60 (minutes) * 2 (offset direction) = 2880.
|
|
92
|
-
@lru_cache(maxsize=None)
|
|
93
|
-
def cached_tz(hour_str: str, minute_str: str, sign_str: str) -> timezone:
|
|
94
|
-
sign = 1 if sign_str == "+" else -1
|
|
95
|
-
return timezone(
|
|
96
|
-
timedelta(
|
|
97
|
-
hours=sign * int(hour_str),
|
|
98
|
-
minutes=sign * int(minute_str),
|
|
99
|
-
)
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def match_to_localtime(match: re.Match) -> time:
|
|
104
|
-
hour_str, minute_str, sec_str, micros_str = match.groups()
|
|
105
|
-
micros = int(micros_str.ljust(6, "0")) if micros_str else 0
|
|
106
|
-
return time(int(hour_str), int(minute_str), int(sec_str), micros)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def match_to_number(match: re.Match, parse_float: ParseFloat) -> Any:
|
|
110
|
-
if match.group("floatpart"):
|
|
111
|
-
return parse_float(match.group())
|
|
112
|
-
return int(match.group(), 0)
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: MIT
|
|
2
|
-
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
|
|
3
|
-
# Licensed to PSF under a Contributor Agreement.
|
|
4
|
-
|
|
5
|
-
from typing import Any, Callable, Tuple
|
|
6
|
-
|
|
7
|
-
# Type annotations
|
|
8
|
-
ParseFloat = Callable[[str], Any]
|
|
9
|
-
Key = Tuple[str, ...]
|
|
10
|
-
Pos = int
|