tokensafe 4.1.0 → 4.1.2

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 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, requireCrypto) {
31
- const probe = requireCrypto
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.0",
4
+ "version": "4.1.2",
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.0",
4
+ "version": "4.1.2",
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.0",
6
+ "version": "4.1.2",
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.0",
33
+ "version": "4.1.2",
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.0",
49
+ "version": "4.1.2",
50
50
  "runtimeHint": "uvx",
51
51
  "transport": {
52
52
  "type": "stdio"
@@ -121,7 +121,10 @@ class EnvironmentAuditor:
121
121
  with open(plugin_cfg, "r", encoding="utf-8") as f:
122
122
  loaded = json.load(f)
123
123
  if isinstance(loaded, dict) and isinstance(loaded.get("mcpServers"), dict):
124
- configured.update(loaded["mcpServers"])
124
+ for s_name, s_cfg in loaded["mcpServers"].items():
125
+ configured[s_name] = s_cfg
126
+ # Antigravity namespaces plugin MCP servers as <plugin_name>_<server_name>
127
+ configured[f"{entry}_{s_name}"] = s_cfg
125
128
  except Exception:
126
129
  continue
127
130
  return configured
@@ -229,8 +232,14 @@ class EnvironmentAuditor:
229
232
  }
230
233
 
231
234
  # Include configured servers that might not have a schema dir cached yet
235
+ # Skip un-namespaced aliases if their namespaced counterpart already matched a schema
236
+ seen_plugin_suffixes = {
237
+ s_name.split("_", 1)[1] for s_name in servers.keys() if "_" in s_name
238
+ }
232
239
  for srv_name in configured:
233
240
  if srv_name not in servers:
241
+ if srv_name in seen_plugin_suffixes:
242
+ continue
234
243
  servers[srv_name] = {
235
244
  "name": srv_name,
236
245
  "active": True,
@@ -273,6 +282,23 @@ class EnvironmentAuditor:
273
282
 
274
283
  bloated_servers = [s for s in servers.values() if s["is_bloat"]]
275
284
 
285
+ treesitter_info: Dict[str, Any] = {"available": False, "active": 0, "total": 0, "missing": []}
286
+ try:
287
+ from src.treesitter_backend import TreeSitterBackend
288
+ ts_status = TreeSitterBackend.check_all_languages()
289
+ ok_cnt = sum(1 for v in ts_status.values() if v)
290
+ tot_cnt = len(ts_status)
291
+ missing = [k for k, v in ts_status.items() if not v]
292
+ treesitter_info = {
293
+ "available": TreeSitterBackend.is_available(),
294
+ "active": ok_cnt,
295
+ "total": tot_cnt,
296
+ "all_ok": ok_cnt == tot_cnt and tot_cnt > 0,
297
+ "missing": missing,
298
+ }
299
+ except Exception:
300
+ pass
301
+
276
302
  return {
277
303
  "servers": servers,
278
304
  "total_active_servers": len([s for s in servers.values() if s["active"]]),
@@ -285,6 +311,7 @@ class EnvironmentAuditor:
285
311
  "has_critical_bloat": len(bloated_servers) > 0,
286
312
  "rules": rules,
287
313
  "ghost_tokens": ghost_tokens,
314
+ "treesitter": treesitter_info,
288
315
  }
289
316
 
290
317
  @classmethod
@@ -554,6 +581,14 @@ class EnvironmentAuditor:
554
581
  for v in rules.get("violations", []):
555
582
  lines.append(f" \033[31m✖ {v['path']}: {v['effective_bytes']:,} bytes > {RULE_FILE_LIMIT_BYTES:,} cap\033[0m")
556
583
 
584
+ ts = report.get("treesitter") or {}
585
+ if ts.get("total", 0) > 0:
586
+ if ts.get("all_ok"):
587
+ lines.append(f" \033[1mAST Engines (Tree-sitter):\033[0m \033[32m✔ {ts['active']}/{ts['total']} languages active\033[0m")
588
+ else:
589
+ missing_str = ", ".join(ts.get("missing", []))
590
+ lines.append(f" \033[1mAST Engines (Tree-sitter):\033[0m \033[33m⚠ {ts['active']}/{ts['total']} active (missing: {missing_str})\033[0m")
591
+
557
592
  ghost = report.get("ghost_tokens") or {}
558
593
  if ghost.get("has_ghost_tokens"):
559
594
  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
@@ -42,7 +42,7 @@ from src.paths import get_active_workspace, is_plugin_or_system_dir
42
42
 
43
43
  SERVER_INFO = {
44
44
  "name": "tokensafe-mcp",
45
- "version": "4.1.0"
45
+ "version": "4.1.2"
46
46
  }
47
47
 
48
48
  # MCP client attribution: the initialize handshake carries clientInfo, which
@@ -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.0"
244
+ "User-Agent": "TokenSafe-Sync/4.1.2"
245
245
  }
246
246
  if active_key:
247
247
  headers["Authorization"] = f"Bearer {active_key}"
@@ -1,10 +1,13 @@
1
1
  """
2
- Optional Tree-sitter Backend for TokenSafe GraphEngine and Skeletonizer.
2
+ Core Tree-sitter Backend for TokenSafe GraphEngine and Skeletonizer.
3
3
 
4
- Strictly optional: all imports of `tree_sitter` and `tree_sitter_*` grammars are
5
- lazy and fail-safe. When unavailable (or disabled via TOKENSAFE_TREESITTER=0),
6
- callers fall back seamlessly to TokenSafe's zero-dependency stdlib AST/BraceLexer
7
- engines.
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")
@@ -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.0"
20
+ CURRENT_VERSION = "4.1.2"
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