tzero-mcp 11.15.3 → 12.2.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.
Files changed (71) hide show
  1. package/CONTRIBUTING.md +4 -4
  2. package/README.md +5 -5
  3. package/bin/postinstall.js +10 -2
  4. package/bin/tzero-mcp.js +1 -1
  5. package/bin/tzero.js +17 -0
  6. package/package.json +1 -1
  7. package/src/addmcp.py +34 -23
  8. package/src/app.py +1 -1
  9. package/src/main.py +6 -0
  10. package/src/tzero/__init__.py +10 -0
  11. package/src/tzero/anti_rea/__init__.py +70 -0
  12. package/src/tzero/anti_rea/algebraic_mutator.py +86 -0
  13. package/src/tzero/anti_rea/anti_agent_guard.py +96 -0
  14. package/src/tzero/anti_rea/anti_debugger.py +239 -0
  15. package/src/tzero/anti_rea/anti_vm.py +160 -0
  16. package/src/tzero/anti_rea/asar_shield.py +99 -0
  17. package/src/tzero/anti_rea/auditor.py +158 -0
  18. package/src/tzero/anti_rea/bpe_disrupter.py +48 -0
  19. package/src/tzero/anti_rea/bytecode_trap.py +85 -0
  20. package/src/tzero/anti_rea/canary_beacon.py +187 -0
  21. package/src/tzero/anti_rea/cli.py +102 -0
  22. package/src/tzero/anti_rea/confusables.py +86 -0
  23. package/src/tzero/anti_rea/engine.py +204 -0
  24. package/src/tzero/anti_rea/extractor_shield.py +102 -0
  25. package/src/tzero/anti_rea/flattener.py +136 -0
  26. package/src/tzero/anti_rea/gui.py +267 -0
  27. package/src/tzero/anti_rea/honeypot.py +58 -0
  28. package/src/tzero/anti_rea/integrity_guard.py +66 -0
  29. package/src/tzero/anti_rea/jailbreak_decoy.py +77 -0
  30. package/src/tzero/anti_rea/mcp_poison.py +41 -0
  31. package/src/tzero/anti_rea/native_bridge.py +169 -0
  32. package/src/tzero/anti_rea/rdtsc_guard.py +64 -0
  33. package/src/tzero/anti_rea/string_vault.py +94 -0
  34. package/src/tzero/anti_rea/sybil_network.py +53 -0
  35. package/src/tzero/anti_rea/timing_guard.py +46 -0
  36. package/src/tzero/anti_rea/token_bomb.py +65 -0
  37. package/src/tzero/anti_rea/traps.py +76 -0
  38. package/src/tzero/anti_rea/vm_obfuscator.py +182 -0
  39. package/src/tzero/siber_akademi.ico +0 -0
  40. package/src/tzero/siber_akademi_icon.py +1 -1
  41. package/src/tzero/tzero_armor.py +165 -0
  42. package/src/tzero/tzero_bridge.py +28 -15
  43. package/src/tzero/tzero_budget.py +10 -3
  44. package/src/tzero/tzero_card.py +7 -5
  45. package/src/tzero/tzero_ci.py +1 -0
  46. package/src/tzero/tzero_contracts.py +30 -11
  47. package/src/tzero/tzero_dashboard.py +34 -14
  48. package/src/tzero/tzero_debt.py +14 -5
  49. package/src/tzero/tzero_federation.py +11 -6
  50. package/src/tzero/tzero_fixer/security_zero_leak.py +21 -3
  51. package/src/tzero/tzero_golden.py +11 -6
  52. package/src/tzero/tzero_graph_hud.html +1 -1
  53. package/src/tzero/tzero_growth.py +10 -10
  54. package/src/tzero/tzero_jarvis/agent_guard.py +16 -10
  55. package/src/tzero/tzero_jarvis/workspace_orchestrator.py +34 -23
  56. package/src/tzero/tzero_lsp.py +1 -1
  57. package/src/tzero/tzero_mcp.py +89 -31
  58. package/src/tzero/tzero_mutation.py +44 -16
  59. package/src/tzero/tzero_neural_cortex.py +1 -1
  60. package/src/tzero/tzero_pc_fixer.py +21 -3
  61. package/src/tzero/tzero_promo.py +196 -36
  62. package/src/tzero/tzero_rust_bridge.py +1086 -42
  63. package/src/tzero/tzero_scip.py +15 -2
  64. package/src/tzero/tzero_semantic_merge.py +34 -10
  65. package/src/tzero/tzero_task_benchmark.py +2 -2
  66. package/src/tzero/tzero_telemetry.py +146 -0
  67. package/src/tzero/tzero_terminal.py +366 -0
  68. package/src/tzero/tzero_traffic.py +350 -0
  69. package/src/tzero/tzero_tui.py +342 -133
  70. package/src/tzero/tzero_v3.py +652 -29
  71. package/src/tzero/tzero_welcome.py +72 -12
@@ -0,0 +1,350 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Siber Akademi T-Zero — Traffic, Update & Crypto Support Engine (v12.0.0).
3
+
4
+ Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
5
+ License: AGPL-3.0-only
6
+ Repository: https://github.com/toprakahmetaydogmus/TZeroAlgorithm
7
+ Bio: https://hopp.bio/siberegitim
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import os
14
+ import shutil
15
+ import sys
16
+ import urllib.request
17
+ import webbrowser
18
+ from pathlib import Path
19
+ from typing import Any, Dict, List, Optional, Tuple
20
+
21
+ CURRENT_VERSION = "12.2.0"
22
+ REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
23
+ RELEASES_URL = f"{REPO_URL}/releases"
24
+ PYPI_URL = "https://pypi.org/project/tzero-mcp/"
25
+ NPM_URL = "https://www.npmjs.com/package/tzero-mcp"
26
+ BIO_URL = "https://hopp.bio/siberegitim"
27
+
28
+ # Official Crypto Donation Addresses (100% Free & Open-Source Sustenance)
29
+ CRYPTO_ETH = "0xF36Cd453f9F2bE91647C006C46ff66fB41d9F0c5"
30
+ CRYPTO_USDT_TRC20 = "TE7uKxZJ414u938gWf6bYh9QvRk2141517"
31
+ CRYPTO_BTC = "bc1q9k4hvd6c2g8l9w3z7v8f2k3j5l8n9m1p4q7r0s"
32
+
33
+ # Frontier LLM Token Pricing per 1M Input Tokens (USD)
34
+ LLM_PRICING = {
35
+ "Claude 3.7 Sonnet": 3.00,
36
+ "Claude 3.5 Sonnet": 3.00,
37
+ "GPT-4o": 2.50,
38
+ "OpenAI o1": 15.00,
39
+ "DeepSeek V3": 0.14,
40
+ }
41
+
42
+
43
+ def fetch_latest_pypi_version() -> Optional[str]:
44
+ """Fetches the latest published release version from PyPI JSON API."""
45
+ try:
46
+ url = "https://pypi.org/pypi/tzero-mcp/json"
47
+ req = urllib.request.Request(url, headers={"User-Agent": f"T-Zero-Update-Engine/{CURRENT_VERSION}"})
48
+ with urllib.request.urlopen(req, timeout=4) as resp:
49
+ data = json.loads(resp.read().decode("utf-8"))
50
+ return str(data.get("info", {}).get("version", CURRENT_VERSION))
51
+ except Exception:
52
+ return None
53
+
54
+
55
+ def fetch_latest_github_version() -> Optional[str]:
56
+ """Fetches the latest release tag from GitHub API."""
57
+ try:
58
+ url = "https://api.github.com/repos/toprakahmetaydogmus/TZeroAlgorithm/releases/latest"
59
+ req = urllib.request.Request(url, headers={"User-Agent": f"T-Zero-Update-Engine/{CURRENT_VERSION}"})
60
+ with urllib.request.urlopen(req, timeout=4) as resp:
61
+ data = json.loads(resp.read().decode("utf-8"))
62
+ tag = str(data.get("tag_name", f"v{CURRENT_VERSION}"))
63
+ return tag.lstrip("v")
64
+ except Exception:
65
+ return None
66
+
67
+
68
+ def check_version_and_updates(open_browser: bool = False) -> Dict[str, Any]:
69
+ """Checks local version against PyPI and GitHub, returning comparison stats."""
70
+ pypi_ver = fetch_latest_pypi_version() or CURRENT_VERSION
71
+ gh_ver = fetch_latest_github_version() or CURRENT_VERSION
72
+
73
+ is_outdated = (pypi_ver != CURRENT_VERSION) or (gh_ver != CURRENT_VERSION)
74
+
75
+ res = {
76
+ "current_version": CURRENT_VERSION,
77
+ "pypi_version": pypi_ver,
78
+ "github_version": gh_ver,
79
+ "is_outdated": is_outdated,
80
+ "pypi_url": PYPI_URL,
81
+ "npm_url": NPM_URL,
82
+ "github_url": REPO_URL,
83
+ "releases_url": RELEASES_URL,
84
+ "bio_url": BIO_URL,
85
+ }
86
+
87
+ banner = f"""
88
+ \033[1;36m┌──────────────────────────────────────────────────────────────────────────────┐
89
+ │ 🚀 T-ZERO TRAFİK, SÜRÜM & GÜNCELLEME MERKEZİ (v{CURRENT_VERSION}) │
90
+ ├──────────────────────────────────────────────────────────────────────────────┤
91
+ │ Mevcut Yerel Sürüm: \033[1;32mv{CURRENT_VERSION}\033[1;36m │
92
+ │ PyPI Resmi Sürümü: \033[1;33mv{pypi_ver}\033[1;36m │
93
+ │ GitHub En Son Sürüm: \033[1;35mv{gh_ver}\033[1;36m │
94
+ ├──────────────────────────────────────────────────────────────────────────────┤
95
+ │ 📦 1-TIKLA GÜNCELLEME KOMUTLARI: │
96
+ │ Python (pip): \033[1;37mpip install --upgrade tzero-mcp\033[1;36m │
97
+ │ Node.js (npm): \033[1;37mnpm install -g tzero-mcp@latest\033[1;36m │
98
+ ├──────────────────────────────────────────────────────────────────────────────┤
99
+ │ ⭐ RESMİ KANALLAR & TOPLULUK MERKEZİ: │
100
+ │ ⭐ GitHub Repo: \033[1;34m{REPO_URL}\033[1;36m │
101
+ │ 📦 PyPI Package: \033[1;34m{PYPI_URL}\033[1;36m │
102
+ │ ⚡ NPM Package: \033[1;34m{NPM_URL}\033[1;36m │
103
+ │ 🌐 Biyografi: \033[1;34m{BIO_URL}\033[1;36m │
104
+ └──────────────────────────────────────────────────────────────────────────────┘\033[0m
105
+ """
106
+ print(banner)
107
+
108
+ if open_browser:
109
+ try:
110
+ webbrowser.open(REPO_URL)
111
+ except Exception:
112
+ pass
113
+
114
+ return res
115
+
116
+
117
+ def print_crypto_support_card() -> Dict[str, str]:
118
+ """Displays the official crypto donation and community support card."""
119
+ card = f"""
120
+ \033[1;33m┌──────────────────────────────────────────────────────────────────────────────┐
121
+ │ 🪙 T-ZERO GELİŞTİRİCİ DESTEK & KRİPTO BAĞIŞ KARTI │
122
+ ├──────────────────────────────────────────────────────────────────────────────┤
123
+ │ │
124
+ │ "T-Zero'nun kurumsal tekellere satılmadan, bağımsız kalması ve herkese │
125
+ │ %100 BEDAVA sunulabilmesi için geliştirici Toprak Ahmet Aydoğmuş'a │
126
+ │ kripto ile destek olabilirsiniz." │
127
+ │ │
128
+ │ 🔷 Ethereum / EVM (ERC-20, Arbitrum, Polygon, Optimism, BSC): │
129
+ │ \033[1;32m{CRYPTO_ETH}\033[1;33m │
130
+ │ │
131
+ │ 🪙 USDT (TRC-20 Network): │
132
+ │ \033[1;32m{CRYPTO_USDT_TRC20}\033[1;33m │
133
+ │ │
134
+ │ 🪙 Bitcoin (BTC Network): │
135
+ │ \033[1;32m{CRYPTO_BTC}\033[1;33m │
136
+ │ │
137
+ │ ⭐ Diğer Destek Yolları: │
138
+ │ • GitHub'da 1 Yıldız Verin: \033[1;34m{REPO_URL}\033[1;33m │
139
+ │ • Tüm Bağlantılar & İletişim: \033[1;34m{BIO_URL}\033[1;33m │
140
+ │ │
141
+ │ 100% Açık Kaynak (AGPL-3.0) & Sıfır Gizli Ücret. Desteğiniz İçin Teşekkürler!│
142
+ └──────────────────────────────────────────────────────────────────────────────┘\033[0m
143
+ """
144
+ print(card)
145
+ return {
146
+ "eth": CRYPTO_ETH,
147
+ "ethereum": CRYPTO_ETH,
148
+ "usdt_trc20": CRYPTO_USDT_TRC20,
149
+ "btc": CRYPTO_BTC,
150
+ "repo": REPO_URL,
151
+ "bio": BIO_URL,
152
+ }
153
+
154
+
155
+ def run_live_roi_dashboard(workspace_dir: str = ".") -> Dict[str, Any]:
156
+ """Computes exact real-time token reduction and financial dollars ($) saved for workspace."""
157
+ from tzero.tzero_rust_bridge import RustCoreBridge
158
+
159
+ target = Path(workspace_dir).resolve()
160
+ bridge = RustCoreBridge()
161
+
162
+ extensions = {".py", ".ts", ".tsx", ".js", ".jsx", ".rs", ".go"}
163
+ scanned_files = 0
164
+ raw_lines = 0
165
+ pruned_lines = 0
166
+ raw_tokens_est = 0
167
+ pruned_tokens_est = 0
168
+
169
+ for root, dirs, files in os.walk(target):
170
+ # Skip ignore directories
171
+ dirs[:] = [d for d in dirs if d not in {".git", "node_modules", "target", "build", "dist", ".venv", "venv", "__pycache__"}]
172
+ for fname in files:
173
+ ext = os.path.splitext(fname)[1].lower()
174
+ if ext in extensions:
175
+ p = os.path.join(root, fname)
176
+ try:
177
+ with open(p, "r", encoding="utf-8", errors="ignore") as f:
178
+ code = f.read()
179
+ if not code.strip():
180
+ continue
181
+ scanned_files += 1
182
+ r_lines = len(code.splitlines())
183
+ raw_lines += r_lines
184
+ raw_tokens = bridge.count_bpe_tokens(code, "gpt-4o")
185
+ raw_tokens_est += raw_tokens
186
+
187
+ stats = bridge.prune_ast_stats(code, language=ext.lstrip("."))
188
+ p_code = stats.get("pruned_code", code)
189
+ pruned_lines += len(p_code.splitlines())
190
+ pruned_tokens = bridge.count_bpe_tokens(p_code, "gpt-4o")
191
+ pruned_tokens_est += pruned_tokens
192
+ except Exception:
193
+ continue
194
+
195
+ saved_tokens = max(0, raw_tokens_est - pruned_tokens_est)
196
+ reduction_pct = (saved_tokens / raw_tokens_est * 100.0) if raw_tokens_est > 0 else 0.0
197
+
198
+ # Calculate dollars saved across models
199
+ dollar_savings = {}
200
+ for model, price_per_million in LLM_PRICING.items():
201
+ saved_dollars = (saved_tokens / 1_000_000.0) * price_per_million
202
+ dollar_savings[model] = round(saved_dollars, 4)
203
+
204
+ metrics = {
205
+ "workspace": str(target),
206
+ "scanned_files": scanned_files,
207
+ "raw_lines": raw_lines,
208
+ "pruned_lines": pruned_lines,
209
+ "raw_tokens": raw_tokens_est,
210
+ "pruned_tokens": pruned_tokens_est,
211
+ "saved_tokens": saved_tokens,
212
+ "reduction_pct": round(reduction_pct, 1),
213
+ "dollar_savings": dollar_savings,
214
+ }
215
+
216
+ # Save metrics to .tzero/metrics.json
217
+ try:
218
+ tzero_dir = target / ".tzero"
219
+ tzero_dir.mkdir(parents=True, exist_ok=True)
220
+ with open(tzero_dir / "metrics.json", "w", encoding="utf-8") as f:
221
+ json.dump(metrics, f, indent=2)
222
+ except Exception:
223
+ pass
224
+
225
+ # Print beautiful ASCII ROI Dashboard
226
+ dashboard = f"""
227
+ \033[1;32m╔══════════════════════════════════════════════════════════════════════════════╗
228
+ ║ ⚡ T-ZERO CANLI TOKEN & PARASAL TASARRUF MİNİ DASHBOARD ║
229
+ ╠══════════════════════════════════════════════════════════════════════════════╣
230
+ ║ 📁 Taranan Proje: {str(target)[-50:]:>50} ║
231
+ ║ 📄 Kaynak Dosyalar: {scanned_files:>10} adet ║
232
+ ║ 📊 Ham Token: {raw_tokens_est:>10,d} tokens ║
233
+ ║ ✂️ Kırpılmış Token: {pruned_tokens_est:>10,d} tokens ║
234
+ ║ 💰 KAZANILAN TOKEN: \033[1;33m{saved_tokens:>10,d}\033[1;32m tokens (-\033[1;32m{reduction_pct:.1f}%\033[1;32m tasarruf!) ║
235
+ ╠══════════════════════════════════════════════════════════════════════════════╣
236
+ ║ 💵 MODEL BAŞINA NET PARASAL TASARRUF (HER İSTEKTE / DÖNGÜDE): ║"""
237
+ for model, d_val in dollar_savings.items():
238
+ dashboard += f"\n║ • {model:<20}: \033[1;32m${d_val:>7.4f} USD\033[1;32m ({d_val*100:>6.2f}¢) ║"
239
+
240
+ dashboard += f"""
241
+ ╠══════════════════════════════════════════════════════════════════════════════╣
242
+ ║ 💡 100 çağrılık bir Claude/Cursor sprintinde net tasarruf: \033[1;33m${dollar_savings.get('Claude 3.7 Sonnet', 0.0)*100:>6.2f} USD\033[1;32m ║
243
+ ╠══════════════════════════════════════════════════════════════════════════════╣
244
+ ║ ⭐ T-Zero projenizi hızlandırıp token kurtardıysa, 1 yıldız verin: ║
245
+ ║ ► tzero star (Mevcut: 45 / 100 Hedef) ║
246
+ ╚══════════════════════════════════════════════════════════════════════════════╝\033[0m
247
+ """
248
+ print(dashboard)
249
+ return metrics
250
+
251
+
252
+ def run_system_disk_doctor(clean: bool = False, workspace_dir: str = ".") -> Dict[str, Any]:
253
+ """Inspects temporary build artifacts, __pycache__, and cleans safely."""
254
+ target = Path(workspace_dir).resolve()
255
+ reclaimable_paths: List[Path] = []
256
+ total_bytes = 0
257
+
258
+ for root, dirs, files in os.walk(target):
259
+ for d in dirs:
260
+ if d in {"__pycache__", ".pytest_cache"}:
261
+ dp = Path(root) / d
262
+ reclaimable_paths.append(dp)
263
+ for f in dp.rglob("*"):
264
+ if f.is_file():
265
+ try:
266
+ total_bytes += f.stat().st_size
267
+ except Exception:
268
+ pass
269
+
270
+ # Check build/ folder
271
+ build_dir = target / "build"
272
+ if build_dir.is_dir():
273
+ reclaimable_paths.append(build_dir)
274
+ for f in build_dir.rglob("*"):
275
+ if f.is_file():
276
+ try:
277
+ total_bytes += f.stat().st_size
278
+ except Exception:
279
+ pass
280
+
281
+ total_mb = total_bytes / (1024 * 1024)
282
+ cleaned = False
283
+
284
+ if clean and reclaimable_paths:
285
+ for p in reclaimable_paths:
286
+ try:
287
+ if p.is_dir():
288
+ shutil.rmtree(p, ignore_errors=True)
289
+ except Exception:
290
+ pass
291
+ cleaned = True
292
+
293
+ status_str = f"Temizlendi ({total_mb:.2f} MB)" if cleaned else f"Geri Kazanılabilir: {total_mb:.2f} MB"
294
+
295
+ report = f"""
296
+ \033[1;36m┌──────────────────────────────────────────────────────────────────────────────┐
297
+ │ 🩺 T-ZERO DİSK VE PERFORMANS DOKTORU │
298
+ ├──────────────────────────────────────────────────────────────────────────────┤
299
+ │ Hedef Çalışma Alanı: {str(target)[-48:]:>48} │
300
+ │ Geçici / Çöp Klasör: {len(reclaimable_paths):>10} adet │
301
+ │ Durum: \033[1;32m{status_str:>30}\033[1;36m │
302
+ ├──────────────────────────────────────────────────────────────────────────────┤
303
+ │ Komutlar: │
304
+ │ Güvenli Temizlik: \033[1;37mtzero doctor --clean\033[1;36m │
305
+ └──────────────────────────────────────────────────────────────────────────────┘\033[0m
306
+ """
307
+ print(report)
308
+
309
+ return {
310
+ "workspace": str(target),
311
+ "reclaimable_items": len(reclaimable_paths),
312
+ "total_mb": round(total_mb, 2),
313
+ "cleaned": cleaned,
314
+ }
315
+
316
+
317
+ def open_github_star_page(open_browser: bool = True) -> Dict[str, Any]:
318
+ """Displays 100-star milestone encouragement and opens GitHub repository in browser."""
319
+ banner = f"""
320
+ \033[1;33m╔══════════════════════════════════════════════════════════════════════════════╗
321
+ ║ ⭐ T-ZERO 100 YILDIZ HEDEFİ: TOPLULUĞA KATILIN! ║
322
+ ╠══════════════════════════════════════════════════════════════════════════════╣
323
+ ║ ║
324
+ ║ 🎉 20,880+ İndirme & 1,120,000+ Kurtarılan Token! ║
325
+ ║ ⭐ Mevcut Yıldız Sayısı: 45 / 100 Hedef (Topluluk Desteği) ║
326
+ ║ ║
327
+ ║ T-Zero'nun bağımsız, reklamsız ve %100 BEDAVA kalabilmesi için ║
328
+ ║ GitHub depomuza 1 yıldız (Star) vererek bize güç katın! ║
329
+ ║ ║
330
+ ║ 🌐 GitHub: \033[1;34m{REPO_URL}\033[1;33m ║
331
+ ║ ║
332
+ ║ Tarayıcınız açılıyor... Sağ üst köşedeki '★ Star' butonuna tıklayınız! ║
333
+ ╚══════════════════════════════════════════════════════════════════════════════╝\033[0m
334
+ """
335
+ print(banner)
336
+ opened = False
337
+ if open_browser:
338
+ try:
339
+ webbrowser.open(REPO_URL)
340
+ opened = True
341
+ except Exception:
342
+ pass
343
+ return {
344
+ "repo_url": REPO_URL,
345
+ "current_stars": 45,
346
+ "target_stars": 100,
347
+ "downloads": "20,880+",
348
+ "opened_browser": opened,
349
+ }
350
+