tokensafe 2.6.1 → 2.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tokensafe",
3
3
  "mcpName": "dev.tokensafe/tokensafe",
4
- "version": "2.6.1",
4
+ "version": "2.7.0",
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": "2.6.1",
4
+ "version": "2.7.0",
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": "2.6.1",
6
+ "version": "2.7.0",
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": "2.6.1",
33
+ "version": "2.7.0",
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": "2.6.1",
49
+ "version": "2.7.0",
50
50
  "runtimeHint": "uvx",
51
51
  "transport": {
52
52
  "type": "stdio"
package/src/cli.py CHANGED
@@ -292,8 +292,7 @@ def main():
292
292
  elif command in ("graph", "nodes"):
293
293
  from src.graph_engine import GraphEngine
294
294
  target_dir = args[1] if len(args) > 1 else os.getcwd()
295
- graph = GraphEngine(target_dir)
296
- graph.index_workspace()
295
+ graph = GraphEngine.get_instance(target_dir)
297
296
  print(f"\nšŸ” TokenSafe Graph Engine — Knowledge Graph & Centrality Analysis")
298
297
  print(f" Indexed: {len(graph.file_symbols)} code files, {len(graph.symbols)} symbols\n")
299
298
  god_nodes = graph.get_god_nodes(top_n=7)
@@ -306,9 +305,8 @@ def main():
306
305
  elif command in ("map", "surface"):
307
306
  from src.graph_engine import GraphEngine
308
307
  target_dir = args[1] if len(args) > 1 else os.getcwd()
309
- graph = GraphEngine(target_dir)
310
- graph.index_workspace()
311
- out_file = os.path.join(target_dir, "tokensafe-out", "API_SURFACE.md")
308
+ graph = GraphEngine.get_instance(target_dir)
309
+ out_file = os.path.join(os.path.abspath(target_dir), "tokensafe-out", "API_SURFACE.md")
312
310
  graph.generate_api_surface(out_file)
313
311
  print(f"\nāœ“ Generated API Surface Map: {out_file} ({os.path.getsize(out_file):,} bytes)")
314
312
  print(f" AI agents can read this file in ~1.5k tokens instead of reading the entire repo.\n")
@@ -318,10 +316,9 @@ def main():
318
316
  if len(args) < 2:
319
317
  print("Usage: tokensafe skeleton <file_path> [target_symbol]")
320
318
  sys.exit(1)
321
- file_path = args[1]
319
+ file_path = os.path.abspath(args[1])
322
320
  target_symbol = args[2] if len(args) > 2 else None
323
- target_dir = os.path.dirname(os.path.abspath(file_path)) or os.getcwd()
324
- graph = GraphEngine(target_dir)
321
+ graph, _ = GraphEngine.for_file(file_path)
325
322
  res = graph.graph_guided_skeletonize(file_path, target_symbol)
326
323
  print(res)
327
324
 
@@ -36,7 +36,7 @@ class DependencyPrefetcher:
36
36
 
37
37
  if ext == ".py":
38
38
  imported_symbols = cls._parse_python_imports(content, file_dir)
39
- elif ext in (".ts", ".js", ".tsx", ".jsx"):
39
+ elif ext in (".ts", ".js", ".tsx", ".jsx", ".mjs", ".cjs"):
40
40
  imported_symbols = cls._parse_ts_imports(content, file_dir)
41
41
 
42
42
  if not imported_symbols:
@@ -129,7 +129,7 @@ class DependencyPrefetcher:
129
129
  # Resolve target file path (check .ts, .tsx, .js, /index.ts)
130
130
  base_target = os.path.normpath(os.path.join(current_dir, rel_path))
131
131
  resolved = None
132
- for ext in (".ts", ".tsx", ".js", ".jsx", "/index.ts", "/index.js"):
132
+ for ext in (".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", "/index.ts", "/index.tsx", "/index.js", "/index.mjs"):
133
133
  candidate = f"{base_target}{ext}" if not ext.startswith("/") else f"{base_target}{ext}"
134
134
  if os.path.exists(candidate):
135
135
  resolved = candidate