tokensafe 4.1.0 → 4.1.1
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/bin/tokensafe.js +9 -4
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/server.json +3 -3
- package/src/environment_auditor.py +26 -0
- package/src/mcp_server.py +1 -1
- package/src/telemetry_sync.py +1 -1
- package/src/treesitter_backend.py +37 -5
- package/src/version_checker.py +1 -1
package/bin/tokensafe.js
CHANGED
|
@@ -24,12 +24,17 @@ const CORE_DEPS = [
|
|
|
24
24
|
'tree-sitter-java',
|
|
25
25
|
'tree-sitter-php',
|
|
26
26
|
'tree-sitter-kotlin',
|
|
27
|
-
'tree-sitter-c-sharp'
|
|
27
|
+
'tree-sitter-c-sharp',
|
|
28
|
+
'tree-sitter-c',
|
|
29
|
+
'tree-sitter-cpp',
|
|
30
|
+
'tree-sitter-ruby',
|
|
31
|
+
'tree-sitter-swift',
|
|
32
|
+
'Pillow>=10.0.0'
|
|
28
33
|
];
|
|
29
34
|
|
|
30
|
-
function checkPython(cmd,
|
|
31
|
-
const probe =
|
|
32
|
-
? 'import sys, cryptography; assert sys.version_info >= (3, 10)'
|
|
35
|
+
function checkPython(cmd, requireDeps) {
|
|
36
|
+
const probe = requireDeps
|
|
37
|
+
? 'import sys, cryptography, tree_sitter; assert sys.version_info >= (3, 10)'
|
|
33
38
|
: 'import sys; assert sys.version_info >= (3, 10)';
|
|
34
39
|
try {
|
|
35
40
|
const res = spawnSync(cmd, ['-c', probe], { encoding: 'utf-8', stdio: 'pipe' });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"mcpName": "dev.tokensafe/tokensafe",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.1",
|
|
5
5
|
"description": "Make AI coding agents 3x faster without burning team quotas. Exact code context. Fewer tokens. Safer changes.",
|
|
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": "4.1.
|
|
4
|
+
"version": "4.1.1",
|
|
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": "4.1.
|
|
6
|
+
"version": "4.1.1",
|
|
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": "4.1.
|
|
33
|
+
"version": "4.1.1",
|
|
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": "4.1.
|
|
49
|
+
"version": "4.1.1",
|
|
50
50
|
"runtimeHint": "uvx",
|
|
51
51
|
"transport": {
|
|
52
52
|
"type": "stdio"
|
|
@@ -273,6 +273,23 @@ class EnvironmentAuditor:
|
|
|
273
273
|
|
|
274
274
|
bloated_servers = [s for s in servers.values() if s["is_bloat"]]
|
|
275
275
|
|
|
276
|
+
treesitter_info: Dict[str, Any] = {"available": False, "active": 0, "total": 0, "missing": []}
|
|
277
|
+
try:
|
|
278
|
+
from src.treesitter_backend import TreeSitterBackend
|
|
279
|
+
ts_status = TreeSitterBackend.check_all_languages()
|
|
280
|
+
ok_cnt = sum(1 for v in ts_status.values() if v)
|
|
281
|
+
tot_cnt = len(ts_status)
|
|
282
|
+
missing = [k for k, v in ts_status.items() if not v]
|
|
283
|
+
treesitter_info = {
|
|
284
|
+
"available": TreeSitterBackend.is_available(),
|
|
285
|
+
"active": ok_cnt,
|
|
286
|
+
"total": tot_cnt,
|
|
287
|
+
"all_ok": ok_cnt == tot_cnt and tot_cnt > 0,
|
|
288
|
+
"missing": missing,
|
|
289
|
+
}
|
|
290
|
+
except Exception:
|
|
291
|
+
pass
|
|
292
|
+
|
|
276
293
|
return {
|
|
277
294
|
"servers": servers,
|
|
278
295
|
"total_active_servers": len([s for s in servers.values() if s["active"]]),
|
|
@@ -285,6 +302,7 @@ class EnvironmentAuditor:
|
|
|
285
302
|
"has_critical_bloat": len(bloated_servers) > 0,
|
|
286
303
|
"rules": rules,
|
|
287
304
|
"ghost_tokens": ghost_tokens,
|
|
305
|
+
"treesitter": treesitter_info,
|
|
288
306
|
}
|
|
289
307
|
|
|
290
308
|
@classmethod
|
|
@@ -554,6 +572,14 @@ class EnvironmentAuditor:
|
|
|
554
572
|
for v in rules.get("violations", []):
|
|
555
573
|
lines.append(f" \033[31m✖ {v['path']}: {v['effective_bytes']:,} bytes > {RULE_FILE_LIMIT_BYTES:,} cap\033[0m")
|
|
556
574
|
|
|
575
|
+
ts = report.get("treesitter") or {}
|
|
576
|
+
if ts.get("total", 0) > 0:
|
|
577
|
+
if ts.get("all_ok"):
|
|
578
|
+
lines.append(f" \033[1mAST Engines (Tree-sitter):\033[0m \033[32m✔ {ts['active']}/{ts['total']} languages active\033[0m")
|
|
579
|
+
else:
|
|
580
|
+
missing_str = ", ".join(ts.get("missing", []))
|
|
581
|
+
lines.append(f" \033[1mAST Engines (Tree-sitter):\033[0m \033[33m⚠ {ts['active']}/{ts['total']} active (missing: {missing_str})\033[0m")
|
|
582
|
+
|
|
557
583
|
ghost = report.get("ghost_tokens") or {}
|
|
558
584
|
if ghost.get("has_ghost_tokens"):
|
|
559
585
|
lines.append(f"\n \033[33m\033[1m👻 Ghost Tokens Detected:\033[0m ~{ghost['ghost_tokens_per_turn']:,} wasted tokens per turn")
|
package/src/mcp_server.py
CHANGED
package/src/telemetry_sync.py
CHANGED
|
@@ -241,7 +241,7 @@ class TelemetrySync:
|
|
|
241
241
|
current_last_id = last_id
|
|
242
242
|
headers = {
|
|
243
243
|
"Content-Type": "application/json",
|
|
244
|
-
"User-Agent": "TokenSafe-Sync/4.1.
|
|
244
|
+
"User-Agent": "TokenSafe-Sync/4.1.1"
|
|
245
245
|
}
|
|
246
246
|
if active_key:
|
|
247
247
|
headers["Authorization"] = f"Bearer {active_key}"
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Core Tree-sitter Backend for TokenSafe GraphEngine and Skeletonizer.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
Provides high-performance, precise AST symbol extraction, call-graph tracking,
|
|
5
|
+
import resolution, and syntax-aware brace folding across 13 major programming
|
|
6
|
+
languages:
|
|
7
|
+
Python, JavaScript, TypeScript, Go, Rust, Java, C#, C, C++, PHP, Kotlin, Swift, Ruby.
|
|
8
|
+
|
|
9
|
+
All language grammars are standard mandatory dependencies with pre-compiled wheels.
|
|
10
|
+
Fail-safe fallback to stdlib ast / regex lexer is preserved if a grammar cannot load.
|
|
8
11
|
"""
|
|
9
12
|
|
|
10
13
|
import importlib
|
|
@@ -175,6 +178,35 @@ class TreeSitterBackend:
|
|
|
175
178
|
return set()
|
|
176
179
|
return {ext for ext in _LANGUAGE_SPECS if cls.get_parser(ext) is not None}
|
|
177
180
|
|
|
181
|
+
_CANONICAL_LANGUAGES: Dict[str, str] = {
|
|
182
|
+
"Python": ".py",
|
|
183
|
+
"JavaScript": ".js",
|
|
184
|
+
"TypeScript": ".ts",
|
|
185
|
+
"Go": ".go",
|
|
186
|
+
"Rust": ".rs",
|
|
187
|
+
"Java": ".java",
|
|
188
|
+
"C#": ".cs",
|
|
189
|
+
"C": ".c",
|
|
190
|
+
"C++": ".cpp",
|
|
191
|
+
"PHP": ".php",
|
|
192
|
+
"Kotlin": ".kt",
|
|
193
|
+
"Swift": ".swift",
|
|
194
|
+
"Ruby": ".rb",
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@classmethod
|
|
198
|
+
def check_all_languages(cls) -> Dict[str, bool]:
|
|
199
|
+
"""Verifies availability of all supported Tree-sitter language grammars."""
|
|
200
|
+
results: Dict[str, bool] = {}
|
|
201
|
+
for name, ext in cls._CANONICAL_LANGUAGES.items():
|
|
202
|
+
results[name] = cls.supports_ext(ext)
|
|
203
|
+
return results
|
|
204
|
+
|
|
205
|
+
@classmethod
|
|
206
|
+
def get_missing_languages(cls) -> List[str]:
|
|
207
|
+
"""Returns names of supported languages whose grammars are missing or failed to load."""
|
|
208
|
+
return [lang for lang, ok in cls.check_all_languages().items() if not ok]
|
|
209
|
+
|
|
178
210
|
@staticmethod
|
|
179
211
|
def _node_text(node: Any, code_bytes: bytes) -> str:
|
|
180
212
|
return code_bytes[node.start_byte:node.end_byte].decode("utf-8", errors="replace")
|
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 = "4.1.
|
|
20
|
+
CURRENT_VERSION = "4.1.1"
|
|
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
|