tokensafe 3.1.3 → 3.1.4
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 +3 -3
- package/src/compactor.py +9 -1
- package/src/guard.py +1 -1
- 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.4",
|
|
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.4",
|
|
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.4",
|
|
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.4",
|
|
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.4",
|
|
50
50
|
"runtimeHint": "uvx",
|
|
51
51
|
"transport": {
|
|
52
52
|
"type": "stdio"
|
package/src/benchmark_real.py
CHANGED
|
@@ -442,7 +442,7 @@ class RealRepoBenchmark:
|
|
|
442
442
|
if not pattern:
|
|
443
443
|
return {"status": "skipped", "reason": "no pattern pre-registered"}
|
|
444
444
|
proc = subprocess.run(["git", "grep", "-n", pattern, "--", search_dir],
|
|
445
|
-
cwd=root, capture_output=True, text=True, timeout=120)
|
|
445
|
+
cwd=root, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=120)
|
|
446
446
|
raw_lines = [ln for ln in (proc.stdout or "").splitlines() if ln.strip()]
|
|
447
447
|
if not raw_lines:
|
|
448
448
|
return {"status": "skipped", "reason": f"no matches for '{pattern}'"}
|
|
@@ -474,7 +474,7 @@ class RealRepoBenchmark:
|
|
|
474
474
|
|
|
475
475
|
def measure_git_diff(self, root: str) -> Dict[str, Any]:
|
|
476
476
|
count = subprocess.run(["git", "rev-list", "--count", "HEAD"], cwd=root,
|
|
477
|
-
capture_output=True, text=True, timeout=60)
|
|
477
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=60)
|
|
478
478
|
try:
|
|
479
479
|
if int((count.stdout or "0").strip() or 0) < 2:
|
|
480
480
|
return {"status": "skipped", "reason": "insufficient history for git diff"}
|
|
@@ -707,7 +707,7 @@ class RealRepoBenchmark:
|
|
|
707
707
|
return {"status": "skipped", "reason": f"{junk} ({len(full_text.splitlines())} lines) is within the {cap_lines}-line cap — nothing to save"}
|
|
708
708
|
if rewritten:
|
|
709
709
|
capped = subprocess.run(rewritten, shell=True, cwd=root,
|
|
710
|
-
capture_output=True, text=True, timeout=60)
|
|
710
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=60)
|
|
711
711
|
capped_text = capped.stdout or ""
|
|
712
712
|
note = f"rewritten: {rewritten}"
|
|
713
713
|
else:
|
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'
|
|
@@ -467,6 +467,14 @@ class PromptCompactor:
|
|
|
467
467
|
# Extract file if present
|
|
468
468
|
files = cls.FILE_REGEX.findall(distilled)
|
|
469
469
|
target_file = cls._trim_path_noise(files[0]) if files else ""
|
|
470
|
+
# Path-fidelity anchor: the distiller LLM occasionally
|
|
471
|
+
# mangles or drops the file path; the ORIGINAL prompt is
|
|
472
|
+
# ground truth. If the distilled target does not appear
|
|
473
|
+
# verbatim in the source prompt, prefer the original's
|
|
474
|
+
# own first file match (deterministic, no LLM trust).
|
|
475
|
+
orig_files = cls.FILE_REGEX.findall(raw_text)
|
|
476
|
+
if orig_files and (not target_file or target_file not in raw_text):
|
|
477
|
+
target_file = cls._trim_path_noise(orig_files[0])
|
|
470
478
|
|
|
471
479
|
# Extract symbol
|
|
472
480
|
symbol = cls.extract_symbol(raw_text, target_file)
|
package/src/guard.py
CHANGED
|
@@ -583,7 +583,7 @@ class TokenSafeGuard:
|
|
|
583
583
|
try:
|
|
584
584
|
res = subprocess.run(
|
|
585
585
|
["git", "-C", target_dir, "status", "--porcelain", "-uall"],
|
|
586
|
-
capture_output=True, text=True, timeout=5
|
|
586
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=5
|
|
587
587
|
)
|
|
588
588
|
if res.returncode == 0:
|
|
589
589
|
for line in res.stdout.splitlines():
|
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.4"
|
|
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.4"
|
|
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
|