tokensafe 3.1.4 → 3.1.5
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/package.json +1 -1
- package/plugin.json +1 -1
- package/server.json +3 -3
- package/src/benchmark_real.py +14 -3
- package/src/compactor.py +11 -3
- package/src/json_repair.py +45 -3
- package/src/mcp_server.py +1 -1
- package/src/telemetry_sync.py +1 -1
- package/src/version_checker.py +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"mcpName": "dev.tokensafe/tokensafe",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.5",
|
|
5
5
|
"description": "Reduce your AI bills by up to 99% locally. Your agents read only needed code, keep prompt caches intact across turns, and keep secrets out of git.",
|
|
6
6
|
"main": "bin/tokensafe.js",
|
|
7
7
|
"bin": {
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"displayName": "TokenSafe",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.5",
|
|
5
5
|
"description": "Reduce your AI bills by up to 99% locally. Your agents read only needed code, keep prompt caches intact across turns, and keep secrets out of git.",
|
|
6
6
|
"logo": "assets/logo.svg",
|
|
7
7
|
"author": {
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "dev.tokensafe/tokensafe",
|
|
4
4
|
"title": "TokenSafe",
|
|
5
5
|
"description": "Reduce your AI bills by up to 99% locally: focused code, warm prompt caches & zero secret leaks.",
|
|
6
|
-
"version": "3.1.
|
|
6
|
+
"version": "3.1.5",
|
|
7
7
|
"websiteUrl": "https://tokensafe.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/tokensafe-dev/tokensafe",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"registryType": "npm",
|
|
31
31
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
32
32
|
"identifier": "tokensafe",
|
|
33
|
-
"version": "3.1.
|
|
33
|
+
"version": "3.1.5",
|
|
34
34
|
"runtimeHint": "npx",
|
|
35
35
|
"transport": {
|
|
36
36
|
"type": "stdio"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"registryType": "pypi",
|
|
47
47
|
"registryBaseUrl": "https://pypi.org",
|
|
48
48
|
"identifier": "tokensafe",
|
|
49
|
-
"version": "3.1.
|
|
49
|
+
"version": "3.1.5",
|
|
50
50
|
"runtimeHint": "uvx",
|
|
51
51
|
"transport": {
|
|
52
52
|
"type": "stdio"
|
package/src/benchmark_real.py
CHANGED
|
@@ -86,10 +86,16 @@ def _gate_all_top_level_defs_present(full_text: str, skel_text: str, ext: str =
|
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
def _def_line_for(full_text: str, short: str) -> Optional[str]:
|
|
89
|
-
"""Language-agnostic: the first
|
|
89
|
+
"""Language-agnostic: the first line that DEFINES the symbol — the keyword
|
|
90
|
+
followed by the symbol name as a word. A bare `short in s` also matches
|
|
91
|
+
annotation usages ('def connect(self, node: "Node", ...)') and picked the
|
|
92
|
+
WRONG line, failing the signature gate on real repos (QA sweep:
|
|
93
|
+
diagrams/__init__.py)."""
|
|
94
|
+
pattern = re.compile(
|
|
95
|
+
rf"\b(?:{_DEF_KEYWORD_RE.pattern[2:-2]})\s+{re.escape(short)}\b")
|
|
90
96
|
for line in full_text.splitlines():
|
|
91
97
|
s = line.strip()
|
|
92
|
-
if
|
|
98
|
+
if pattern.search(s):
|
|
93
99
|
return s
|
|
94
100
|
return None
|
|
95
101
|
|
|
@@ -99,7 +105,12 @@ def _gate_signature_line_match(full_text: str, skel_text: str, symbol: str) -> b
|
|
|
99
105
|
(normalized) in the skeleton."""
|
|
100
106
|
short = symbol.rsplit(".", 1)[-1]
|
|
101
107
|
line = _def_line_for(full_text, short)
|
|
102
|
-
|
|
108
|
+
if not line:
|
|
109
|
+
return False
|
|
110
|
+
# The skeletonizer normalizes signature quotes to single style
|
|
111
|
+
# (model="large" -> model='large') — compare modulo quote style
|
|
112
|
+
# (QA sweep: face_recognition/api.py).
|
|
113
|
+
return line in skel_text or line.replace('"', "'") in skel_text.replace('"', "'")
|
|
103
114
|
|
|
104
115
|
|
|
105
116
|
def symbol_read_gates(full_text: str, skel_text: str, symbol: str, ext: str = ".py") -> Dict[str, bool]:
|
package/src/compactor.py
CHANGED
|
@@ -267,7 +267,7 @@ class PromptCompactor:
|
|
|
267
267
|
)
|
|
268
268
|
FILE_REGEX = re.compile(
|
|
269
269
|
r'(?:'
|
|
270
|
-
r'(?:[\w
|
|
270
|
+
r'(?:[\w\-\./\\@+()()][\w\-\./\\@+()() ]*[\/\\])?[\w\-\.+()()]+\.(?:' + "|".join(_FILE_EXTS) + r')\b'
|
|
271
271
|
r'|(?:\.env(?:\.[\w\-]+)?|\.gitignore|\.dockerignore|\.prettierrc[\w\.\-]*|\.eslintrc[\w\.\-]*|\.npmignore|\.npmrc|\.yarnrc)'
|
|
272
272
|
r'|\b(?:Dockerfile(?:\.[\w\-]+)?|Makefile|Procfile|Gemfile|Vagrantfile|Containerfile)\b'
|
|
273
273
|
r'|\b(?:README(?:\.md)?|LICENSE|CHANGELOG(?:\.md)?)\b'
|
|
@@ -473,8 +473,16 @@ class PromptCompactor:
|
|
|
473
473
|
# verbatim in the source prompt, prefer the original's
|
|
474
474
|
# own first file match (deterministic, no LLM trust).
|
|
475
475
|
orig_files = cls.FILE_REGEX.findall(raw_text)
|
|
476
|
-
if orig_files
|
|
477
|
-
|
|
476
|
+
if orig_files:
|
|
477
|
+
orig_first = cls._trim_path_noise(orig_files[0])
|
|
478
|
+
if not target_file:
|
|
479
|
+
target_file = orig_first
|
|
480
|
+
elif target_file != orig_first and orig_first.endswith(target_file):
|
|
481
|
+
# Partial path: the LLM dropped leading segments
|
|
482
|
+
# ('lib/x.py' for 'activesupport/lib/x.py') —
|
|
483
|
+
# upgrade to the full original path (QA sweep:
|
|
484
|
+
# rails/linkswift).
|
|
485
|
+
target_file = orig_first
|
|
478
486
|
|
|
479
487
|
# Extract symbol
|
|
480
488
|
symbol = cls.extract_symbol(raw_text, target_file)
|
package/src/json_repair.py
CHANGED
|
@@ -40,6 +40,45 @@ def parse_tool_arguments(raw: Any) -> Optional[dict]:
|
|
|
40
40
|
return None
|
|
41
41
|
|
|
42
42
|
|
|
43
|
+
def _py_literals_outside_strings(s: str) -> str:
|
|
44
|
+
"""Replaces Python literals (True/False/None) with JSON equivalents ONLY
|
|
45
|
+
outside string literals; string content is copied verbatim."""
|
|
46
|
+
out: List[str] = []
|
|
47
|
+
buf: List[str] = []
|
|
48
|
+
in_str = False
|
|
49
|
+
quote = ""
|
|
50
|
+
escaped = False
|
|
51
|
+
|
|
52
|
+
def _flush() -> None:
|
|
53
|
+
if buf:
|
|
54
|
+
seg = "".join(buf)
|
|
55
|
+
buf.clear()
|
|
56
|
+
seg = re.sub(r"\bTrue\b", "true", seg)
|
|
57
|
+
seg = re.sub(r"\bFalse\b", "false", seg)
|
|
58
|
+
seg = re.sub(r"\bNone\b", "null", seg)
|
|
59
|
+
out.append(seg)
|
|
60
|
+
|
|
61
|
+
for ch in s:
|
|
62
|
+
if in_str:
|
|
63
|
+
out.append(ch) # string content is data — copied verbatim
|
|
64
|
+
if escaped:
|
|
65
|
+
escaped = False
|
|
66
|
+
elif ch == "\\":
|
|
67
|
+
escaped = True
|
|
68
|
+
elif ch == quote:
|
|
69
|
+
in_str = False
|
|
70
|
+
continue
|
|
71
|
+
if ch in ('"', "'"):
|
|
72
|
+
_flush()
|
|
73
|
+
in_str = True
|
|
74
|
+
quote = ch
|
|
75
|
+
out.append(ch)
|
|
76
|
+
continue
|
|
77
|
+
buf.append(ch)
|
|
78
|
+
_flush()
|
|
79
|
+
return "".join(out)
|
|
80
|
+
|
|
81
|
+
|
|
43
82
|
def repair_json(s: str) -> Optional[str]:
|
|
44
83
|
"""Best-effort repair of a broken JSON string. Returns repaired text that
|
|
45
84
|
strict json.loads accepts, or None when nothing sensible can be produced."""
|
|
@@ -47,9 +86,12 @@ def repair_json(s: str) -> Optional[str]:
|
|
|
47
86
|
if not s:
|
|
48
87
|
return None
|
|
49
88
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
89
|
+
# Python-literal replacement is STRING-AWARE: blind re.sub rewrote
|
|
90
|
+
# 'None'/'True' INSIDE string values — a music-index fixture keyed by
|
|
91
|
+
# artist names turned "Sixpence None the Richer" into "Sixpence null the
|
|
92
|
+
# Richer" and fabricated keys (QA sweep). Only literals OUTSIDE strings
|
|
93
|
+
# are Python dialect.
|
|
94
|
+
py_fixed = _py_literals_outside_strings(s)
|
|
53
95
|
|
|
54
96
|
ctrl_fixed = _escape_control_chars_in_strings(py_fixed)
|
|
55
97
|
|
package/src/mcp_server.py
CHANGED
package/src/telemetry_sync.py
CHANGED
|
@@ -228,7 +228,7 @@ class TelemetrySync:
|
|
|
228
228
|
current_last_id = last_id
|
|
229
229
|
headers = {
|
|
230
230
|
"Content-Type": "application/json",
|
|
231
|
-
"User-Agent": "TokenSafe-Sync/3.1.
|
|
231
|
+
"User-Agent": "TokenSafe-Sync/3.1.5"
|
|
232
232
|
}
|
|
233
233
|
if active_key:
|
|
234
234
|
headers["Authorization"] = f"Bearer {active_key}"
|
package/src/version_checker.py
CHANGED
|
@@ -17,7 +17,7 @@ import urllib.request
|
|
|
17
17
|
import urllib.error
|
|
18
18
|
from typing import Dict, Any, Optional, Tuple
|
|
19
19
|
|
|
20
|
-
CURRENT_VERSION = "3.1.
|
|
20
|
+
CURRENT_VERSION = "3.1.5"
|
|
21
21
|
CACHE_TTL = 86400 # 24 hours
|
|
22
22
|
# When the cloud is unreachable we must NOT cache the synthesized "up to date"
|
|
23
23
|
# answer for a full day — otherwise an update released right after an outage
|