tzero-mcp 11.15.3 → 12.2.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +4 -4
  3. package/README.md +5 -5
  4. package/bin/postinstall.js +10 -2
  5. package/bin/tzero-mcp.js +1 -1
  6. package/bin/tzero.js +17 -0
  7. package/package.json +1 -1
  8. package/src/addmcp.py +34 -23
  9. package/src/app.py +1 -1
  10. package/src/main.py +6 -0
  11. package/src/tzero/__init__.py +10 -0
  12. package/src/tzero/anti_rea/__init__.py +70 -0
  13. package/src/tzero/anti_rea/algebraic_mutator.py +86 -0
  14. package/src/tzero/anti_rea/anti_agent_guard.py +96 -0
  15. package/src/tzero/anti_rea/anti_debugger.py +239 -0
  16. package/src/tzero/anti_rea/anti_vm.py +160 -0
  17. package/src/tzero/anti_rea/asar_shield.py +99 -0
  18. package/src/tzero/anti_rea/auditor.py +158 -0
  19. package/src/tzero/anti_rea/bpe_disrupter.py +48 -0
  20. package/src/tzero/anti_rea/bytecode_trap.py +85 -0
  21. package/src/tzero/anti_rea/canary_beacon.py +187 -0
  22. package/src/tzero/anti_rea/cli.py +102 -0
  23. package/src/tzero/anti_rea/confusables.py +86 -0
  24. package/src/tzero/anti_rea/engine.py +204 -0
  25. package/src/tzero/anti_rea/extractor_shield.py +102 -0
  26. package/src/tzero/anti_rea/flattener.py +136 -0
  27. package/src/tzero/anti_rea/gui.py +267 -0
  28. package/src/tzero/anti_rea/honeypot.py +58 -0
  29. package/src/tzero/anti_rea/integrity_guard.py +66 -0
  30. package/src/tzero/anti_rea/jailbreak_decoy.py +77 -0
  31. package/src/tzero/anti_rea/mcp_poison.py +41 -0
  32. package/src/tzero/anti_rea/native_bridge.py +169 -0
  33. package/src/tzero/anti_rea/rdtsc_guard.py +64 -0
  34. package/src/tzero/anti_rea/string_vault.py +94 -0
  35. package/src/tzero/anti_rea/sybil_network.py +53 -0
  36. package/src/tzero/anti_rea/timing_guard.py +46 -0
  37. package/src/tzero/anti_rea/token_bomb.py +65 -0
  38. package/src/tzero/anti_rea/traps.py +76 -0
  39. package/src/tzero/anti_rea/vm_obfuscator.py +182 -0
  40. package/src/tzero/siber_akademi.ico +0 -0
  41. package/src/tzero/siber_akademi_icon.py +1 -1
  42. package/src/tzero/tzero_armor.py +165 -0
  43. package/src/tzero/tzero_bridge.py +28 -15
  44. package/src/tzero/tzero_budget.py +10 -3
  45. package/src/tzero/tzero_card.py +7 -5
  46. package/src/tzero/tzero_ci.py +1 -0
  47. package/src/tzero/tzero_contracts.py +30 -11
  48. package/src/tzero/tzero_dashboard.py +34 -14
  49. package/src/tzero/tzero_debt.py +14 -5
  50. package/src/tzero/tzero_federation.py +11 -6
  51. package/src/tzero/tzero_fixer/security_zero_leak.py +21 -3
  52. package/src/tzero/tzero_golden.py +11 -6
  53. package/src/tzero/tzero_graph_hud.html +1 -1
  54. package/src/tzero/tzero_growth.py +10 -10
  55. package/src/tzero/tzero_jarvis/agent_guard.py +16 -10
  56. package/src/tzero/tzero_jarvis/workspace_orchestrator.py +34 -23
  57. package/src/tzero/tzero_lsp.py +1 -1
  58. package/src/tzero/tzero_mcp.py +89 -31
  59. package/src/tzero/tzero_mutation.py +44 -16
  60. package/src/tzero/tzero_neural_cortex.py +1 -1
  61. package/src/tzero/tzero_pc_fixer.py +21 -3
  62. package/src/tzero/tzero_promo.py +196 -36
  63. package/src/tzero/tzero_rust_bridge.py +1086 -42
  64. package/src/tzero/tzero_scip.py +15 -2
  65. package/src/tzero/tzero_semantic_merge.py +34 -10
  66. package/src/tzero/tzero_task_benchmark.py +2 -2
  67. package/src/tzero/tzero_telemetry.py +146 -0
  68. package/src/tzero/tzero_terminal.py +366 -0
  69. package/src/tzero/tzero_traffic.py +350 -0
  70. package/src/tzero/tzero_tui.py +342 -133
  71. package/src/tzero/tzero_v3.py +652 -29
  72. package/src/tzero/tzero_welcome.py +124 -37
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [12.2.1] - 2026-11-25
4
+
5
+ ### Fixed
6
+ - Package installation and the welcome banner no longer install Git hooks or change `core.hooksPath` (#43, #44).
7
+ - Star-reminder hooks now require explicit opt-in via `python -m tzero.tzero_welcome --install-star-hooks` and preserve existing hook managers and files.
8
+ - Hook installation reports failures, rolls back partial writes, and supports linked worktrees.
9
+ - Synchronized the npm-bundled Python runtime with the canonical package.
10
+
11
+ ### Changed
12
+ - Successful trusted main CI now creates the missing version release and starts all existing publication workflows against its immutable tag.
13
+ - Registry publication errors now fail their workflow instead of being silently reported as success.
14
+ - Updated the English and Turkish README community goal to 500 GitHub stars.
15
+ - Synchronized Python, npm, VS Code/Open VSX, MCP, and release metadata to 12.2.1.
16
+
3
17
  ## [11.0.0] - 2026-11-11
4
18
 
5
19
  - Bundle the reorganized `tzero/` package and desktop icon.
package/CONTRIBUTING.md CHANGED
@@ -4,7 +4,7 @@ Thank you for your interest in contributing to **T-Zero**! We welcome community
4
4
 
5
5
  ---
6
6
 
7
- ## 🛠 Local Development Setup
7
+ ## Local Development Setup
8
8
 
9
9
  1. **Clone the repository:**
10
10
  ```bash
@@ -28,7 +28,7 @@ Thank you for your interest in contributing to **T-Zero**! We welcome community
28
28
 
29
29
  ---
30
30
 
31
- ## 🧪 Verification Pipeline Before Submitting a PR
31
+ ## Verification Pipeline Before Submitting a PR
32
32
 
33
33
  Before opening a pull request, ensure all verification gates pass locally:
34
34
 
@@ -55,7 +55,7 @@ Before opening a pull request, ensure all verification gates pass locally:
55
55
 
56
56
  ---
57
57
 
58
- ## 📐 Code Style & Architecture Guidelines
58
+ ## Code Style & Architecture Guidelines
59
59
 
60
60
  - **Determinism First:** All AST parsing, BM25 searching, and token reduction must run 100% locally with zero external network telemetry.
61
61
  - **Inward Dependencies:** Core modules (`tzero_packer`, `tzero_guard`) must not depend on outer presentation layers (`tzero_tui`, `tzero_gui`).
@@ -64,7 +64,7 @@ Before opening a pull request, ensure all verification gates pass locally:
64
64
 
65
65
  ---
66
66
 
67
- ## 💬 Community & Discussions
67
+ ## Community & Discussions
68
68
 
69
69
  - **GitHub Issues:** [Bug Reports & Feature Requests](https://github.com/toprakahmetaydogmus/TZeroAlgorithm/issues)
70
70
  - **Hugging Face Space:** [Interactive Web Demo](https://huggingface.co/spaces/toprakke4/tzero-token-reducer)
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ---
11
11
 
12
- ### ⭐ Open-Source Engineering (Please Star Our Repo!)
12
+ ### Open-Source Engineering (Please Star Our Repo!)
13
13
 
14
14
  Hi! I'm **Toprak Ahmet Aydoğmuş** from **Siber Akademi**. I created T-Zero from scratch to eliminate token limits, reduce prompt costs by up to 95%, and stop AI coding hallucinations using deterministic Abstract Syntax Tree (AST) analysis.
15
15
 
@@ -20,7 +20,7 @@ If this package helps your engineering team or AI workflows:
20
20
 
21
21
  ---
22
22
 
23
- ## ⚡ Instant MCP Execution (Zero Install Needed)
23
+ ## Instant MCP Execution (Zero Install Needed)
24
24
 
25
25
  Run directly via `npx` in your `claude_desktop_config.json`, Cursor MCP settings, or Windsurf / Antigravity config:
26
26
 
@@ -35,7 +35,7 @@ Run directly via `npx` in your `claude_desktop_config.json`, Cursor MCP settings
35
35
  }
36
36
  ```
37
37
 
38
- ## 🚀 CLI Installation & Usage
38
+ ## CLI Installation & Usage
39
39
 
40
40
  ```bash
41
41
  # Global installation via npm
@@ -51,7 +51,7 @@ tzero-mcp
51
51
  tzero-add-mcp
52
52
  ```
53
53
 
54
- ## 🛠 Key Capabilities
54
+ ## Key Capabilities
55
55
 
56
56
  - **95% Deterministic Token Reduction:** Compresses source code into AST skeletons preserving function signatures, type annotations, and docstrings while pruning redundant logic bodies.
57
57
  - **100% Zero-Leak Security Guard:** Deep Shannon Entropy ($H \ge 4.75$) scanner for API keys and secrets before LLM context ingestion.
@@ -59,6 +59,6 @@ tzero-add-mcp
59
59
  - **20 Native Developer Tools:** AST PageRank, call-chain tracer, BM25 semantic hybrid search, change blast radius analyzer, and system doctor.
60
60
  - **100% Private, Local & Free:** Pure offline operation — $0 API cost, zero cloud lock-in.
61
61
 
62
- ## 📄 License
62
+ ## License
63
63
 
64
64
  AGPL-3.0-only © [Toprak Ahmet Aydoğmuş](https://github.com/toprakahmetaydogmus)
@@ -4,18 +4,26 @@
4
4
  * T-Zero npm postinstall welcome & GitHub star prompt
5
5
  */
6
6
 
7
+ const pkg = require("../package.json");
7
8
  const isTest = process.env.TEST_POSTINSTALL === "1" || process.env.TZERO_FORCE_BANNER === "1";
8
9
  const noBanner = !isTest && (process.env.TZERO_NO_BANNER === "1" || process.env.CI === "true" || process.env.npm_config_loglevel === "silent");
9
10
 
10
11
  if (!noBanner) {
11
12
  console.log(`\x1b[36m
12
13
  ┌──────────────────────────────────────────────────────────────────────────────┐
13
- │ ⚡ T-ZERO MCP INSTALLED SUCCESSFULLY! │
14
+ │ ⚡ T-ZERO MCP INSTALLED SUCCESSFULLY! (v${pkg.version}) │
14
15
  ├──────────────────────────────────────────────────────────────────────────────┤
15
- │ ⭐ Star on GitHub: \x1b[33mhttps://github.com/toprakahmetaydogmus/TZeroAlgorithm\x1b[36m │
16
+ │ ⭐ \x1b[1;33mHELP US REACH OUR 100 STARS GOAL (Current: 45 / 100):\x1b[0m\x1b[36m │
17
+ │ \x1b[1;32m► Run: npx tzero star OR visit: https://github.com/toprakahmetaydogmus/TZeroAlgorithm\x1b[0m\x1b[36m │
18
+ │ │
19
+ │ 💖 \x1b[1;35mSPONSOR & KEEP T-ZERO 100% FREE:\x1b[0m\x1b[36m │
20
+ │ \x1b[1;32m► https://github.com/sponsors/toprakahmetaydogmus\x1b[0m\x1b[36m │
21
+ │ │
22
+ │ 🎉 20,880+ Downloads across PyPI & npm! 100% Free & Open Source (AGPL-3.0) │
16
23
  │ │
17
24
  │ 💡 1-Click Setup: │
18
25
  │ \x1b[37mnpx tzero-mcp --install\x1b[36m Configure Cursor, Claude, Windsurf, VS Code │
26
+ │ \x1b[37mnpx tzero roi\x1b[36m View live token & dollar ($) savings │
19
27
  │ \x1b[37mnpx tzero --help\x1b[36m View all CLI AST reduction commands │
20
28
  └──────────────────────────────────────────────────────────────────────────────┘
21
29
  \x1b[0m`);
package/bin/tzero-mcp.js CHANGED
@@ -17,7 +17,7 @@ const banner = `\x1b[36m
17
17
  │ ⚡ T-ZERO MCP SERVER v${pkg.version} (Model Context Protocol) │
18
18
  │ Enterprise AST Context Compressor, Zero-Leak Guard & 20 Canonical Tools │
19
19
  │ │
20
- │ ⭐ Star on GitHub: https://github.com/toprakahmetaydogmus/TZeroAlgorithm │
20
+ │ ⭐ Help Reach 100 Stars: https://github.com/toprakahmetaydogmus/TZeroAlgorithm │
21
21
  │ 🔌 Connected to: Cursor, Claude Desktop, Antigravity, Windsurf & Cline │
22
22
  └──────────────────────────────────────────────────────────────────────────────┘
23
23
  \x1b[0m`;
package/bin/tzero.js CHANGED
@@ -32,6 +32,23 @@ if (!isQuiet) {
32
32
  console.log(banner);
33
33
  }
34
34
 
35
+ if (process.argv.includes("star") || process.argv.includes("--star")) {
36
+ console.log(`\x1b[33m
37
+ ╔══════════════════════════════════════════════════════════════════════════════╗
38
+ ║ ⭐ T-ZERO 100 STARS GOAL: JOIN THE COMMUNITY! ║
39
+ ╠══════════════════════════════════════════════════════════════════════════════╣
40
+ ║ 🎉 20,880+ Downloads across PyPI & npm! ║
41
+ ║ ⭐ Current Stars: 45 / 100 Target ║
42
+ ║ ► Opening GitHub: https://github.com/toprakahmetaydogmus/TZeroAlgorithm ║
43
+ ╚══════════════════════════════════════════════════════════════════════════════╝
44
+ \x1b[0m`);
45
+ const openCmd = process.platform === "win32" ? "start" : process.platform === "darwin" ? "open" : "xdg-open";
46
+ try {
47
+ const { exec } = require("child_process");
48
+ exec(`${openCmd} https://github.com/toprakahmetaydogmus/TZeroAlgorithm`);
49
+ } catch (e) {}
50
+ }
51
+
35
52
  function findPython() {
36
53
  if (process.env.PYTHON) return process.env.PYTHON;
37
54
  const candidates = ["python3", "python", "py"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tzero-mcp",
3
- "version": "11.15.3",
3
+ "version": "12.2.1",
4
4
  "description": "Deterministic AST Context Compressor, 95% Token Reducer & 20-Tool MCP Server for Cursor, Claude Desktop & Copilot",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/src/addmcp.py CHANGED
@@ -22,7 +22,7 @@ from pathlib import Path
22
22
  from typing import Callable, Dict, List, Optional, Tuple
23
23
 
24
24
 
25
- APP_VERSION = "11.15.2"
25
+ APP_VERSION = "12.2.1"
26
26
  SERVER_NAME = "tzero"
27
27
  SERVER_FILENAME = "TZeroMCP.exe"
28
28
 
@@ -39,6 +39,11 @@ def _attach_windows_console() -> None:
39
39
  sys.stderr = open("CONOUT$", "w", encoding="utf-8", errors="replace")
40
40
  except Exception:
41
41
  pass
42
+ try:
43
+ from tzero.tzero_terminal import init_terminal
44
+ init_terminal()
45
+ except Exception:
46
+ pass
42
47
 
43
48
 
44
49
  @dataclass(frozen=True)
@@ -1117,22 +1122,28 @@ def run_init(argv: Optional[List[str]] = None) -> int:
1117
1122
  "gemini-cli": ["gemini-cli"],
1118
1123
  }
1119
1124
 
1125
+ try:
1126
+ from tzero.tzero_terminal import sanitize_terminal_text
1127
+ except Exception:
1128
+ def sanitize_terminal_text(t):
1129
+ return t
1130
+
1120
1131
  # Print banner
1121
- print("""
1132
+ print(sanitize_terminal_text("""
1122
1133
  \033[1;36m================================================================================
1123
- ⚡ SİBER AKADEMİ — T-ZERO 1-CLICK MCP INITIALIZATION (v11.15.2)
1134
+ ⚡ SİBER AKADEMİ — T-ZERO 1-CLICK MCP INITIALIZATION (v12.2.1)
1124
1135
  ================================================================================\033[0m
1125
- \033[32m🎯 Zero-Config AST Codebase Context & 100% Zero-Leak Security Guard\033[0m
1126
- """)
1136
+ \033[32m★ Zero-Config AST Codebase Context & 100% Zero-Leak Security Guard\033[0m
1137
+ """))
1127
1138
 
1128
1139
  # Parse arguments
1129
1140
  flags = [a.lower().lstrip("-") for a in argv]
1130
1141
  if "list" in flags or "l" in flags or "--list" in argv:
1131
- print("\033[1;33m📋 Supported & Detected IDE Environments:\033[0m\n")
1142
+ print(sanitize_terminal_text("\033[1;33m★ Supported & Detected IDE Environments:\033[0m\n"))
1132
1143
  for t in all_targets:
1133
1144
  state = "\033[32m✓ DETECTED\033[0m" if t.detected else "\033[90mnot found \033[0m"
1134
- print(f" [{state}] {t.name:<25} : key='{t.key}' ({t.config_path})")
1135
- print("\n\033[36m💡 Run: 'tzero init' to install to all detected IDEs automatically.\033[0m\n")
1145
+ print(sanitize_terminal_text(f" [{state}] {t.name:<25} : key='{t.key}' ({t.config_path})"))
1146
+ print(sanitize_terminal_text("\n\033[36m• Run: 'tzero init' to install to all detected IDEs automatically.\033[0m\n"))
1136
1147
  return 0
1137
1148
 
1138
1149
  selected_keys = set()
@@ -1142,11 +1153,11 @@ def run_init(argv: Optional[List[str]] = None) -> int:
1142
1153
  detected_targets = [t for t in all_targets if t.detected]
1143
1154
  if detected_targets:
1144
1155
  selected_targets = detected_targets
1145
- print(f"\033[34m[AUTO-DETECT]\033[0m Found {len(selected_targets)} active IDE environment(s):")
1156
+ print(sanitize_terminal_text(f"\033[34m[AUTO-DETECT]\033[0m Found {len(selected_targets)} active IDE environment(s):"))
1146
1157
  for t in selected_targets:
1147
- print(f" • {t.name}")
1158
+ print(sanitize_terminal_text(f" • {t.name}"))
1148
1159
  else:
1149
- print("\033[33m[INFO]\033[0m No active IDEs currently detected; configuring default targets (Cursor, Claude, VS Code, Windsurf)...")
1160
+ print(sanitize_terminal_text("\033[33m[INFO]\033[0m No active IDEs currently detected; configuring default targets (Cursor, Claude, VS Code, Windsurf)..."))
1150
1161
  selected_targets = [t for t in all_targets if t.key in ("cursor", "claude-desktop", "vscode", "windsurf")]
1151
1162
  else:
1152
1163
  for f in flags:
@@ -1157,22 +1168,22 @@ def run_init(argv: Optional[List[str]] = None) -> int:
1157
1168
  selected_targets = [t for t in all_targets if t.key in selected_keys]
1158
1169
 
1159
1170
  if not selected_targets:
1160
- print(f"\033[31m[ERROR]\033[0m No matching IDE target found for: {argv}")
1171
+ print(sanitize_terminal_text(f"\033[31m[ERROR]\033[0m No matching IDE target found for: {argv}"))
1161
1172
  print("Available targets: cursor, claude, windsurf, vscode, cline, roo, antigravity, gemini, all")
1162
1173
  return 1
1163
1174
 
1164
- print(f"\n\033[35m[INSTALLING]\033[0m Configuring {len(selected_targets)} target(s)...")
1175
+ print(sanitize_terminal_text(f"\n\033[35m[INSTALLING]\033[0m Configuring {len(selected_targets)} target(s)..."))
1165
1176
  successes, failures = install_targets(
1166
1177
  selected_targets,
1167
- log_fn=lambda m: print(f" \033[32m✓\033[0m {m}")
1178
+ log_fn=lambda m: print(sanitize_terminal_text(f" \033[32m✓\033[0m {m}"))
1168
1179
  )
1169
1180
 
1170
- print(f"\n\033[1;32m🎉 [SUCCESS] T-Zero MCP Server successfully registered in {successes} client(s)!\033[0m")
1181
+ print(sanitize_terminal_text(f"\n\033[1;32m★ [SUCCESS] T-Zero MCP Server successfully registered in {successes} client(s)!\033[0m"))
1171
1182
  if failures:
1172
- print(f"\033[33m⚠️ {failures} client(s) could not be updated.\033[0m")
1183
+ print(sanitize_terminal_text(f"\033[33m⚠️ {failures} client(s) could not be updated.\033[0m"))
1173
1184
 
1174
- print("""
1175
- \033[1;37m🚀 HOW TO USE IN YOUR IDE (CURSOR, CLAUDE, WINDSURF):
1185
+ print(sanitize_terminal_text("""
1186
+ \033[1;37m★ HOW TO USE IN YOUR IDE (CURSOR, CLAUDE, WINDSURF):
1176
1187
  1. Restart your IDE or Reload Window.
1177
1188
  2. In Composer / Chat, prompt your agent:\033[0m
1178
1189
  \033[36m"Use T-Zero to get the project skeleton and analyze the blast radius."\033[0m
@@ -1185,13 +1196,13 @@ def run_init(argv: Optional[List[str]] = None) -> int:
1185
1196
  │ to eliminate token bloat, costs, and AI hallucinations worldwide. │
1186
1197
  │ Search "Toprak Ahmet Aydoğmuş" on Google to learn more! │
1187
1198
  │ │
1188
- │ If this open-source tool saved you tokens or improved your coding flow: │
1189
- │ 👉 Please consider giving it a ⭐ on GitHub: │
1190
- │ https://github.com/toprakahmetaydogmus/TZeroAlgorithm │
1199
+ │ 🎉 \033[1;32m20,880+ Downloads across PyPI & npm!\033[1;36m │
1200
+ │ ⭐ \033[1;33mHELP US REACH OUR 100 STARS GOAL (Current: 45 / 100):\033[1;36m │
1201
+ │ \033[1;32m► Run 'tzero star' or visit: https://github.com/toprakahmetaydogmus/TZeroAlgorithm\033[1;36m │
1191
1202
  │ │
1192
- │ 100% Free & Open-Source under MIT License. Thank you! 🚀 │
1203
+ │ 100% Free & Open-Source under AGPL-3.0 License. Thank you! ★ │
1193
1204
  └──────────────────────────────────────────────────────────────────────────────┘\033[0m
1194
- """)
1205
+ """))
1195
1206
  return 0 if failures == 0 else 1
1196
1207
 
1197
1208
 
package/src/app.py CHANGED
@@ -45,7 +45,7 @@ import gradio as gr
45
45
  # ==================================================================================================
46
46
  # CONSTANTS, PALETTES & MULTI-MODEL PRICING TIERS
47
47
  # ==================================================================================================
48
- APP_VERSION = "11.15.2"
48
+ APP_VERSION = "12.2.1"
49
49
  REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
50
50
  VERCEL_URL = "https://tzero-indol.vercel.app"
51
51
  SPACE_URL = "https://huggingface.co/spaces/toprakke4/tzero-token-reducer"
package/src/main.py CHANGED
@@ -50,6 +50,12 @@ def _setup_windows_streams():
50
50
  sys.stderr = io.StringIO()
51
51
 
52
52
 
53
+ try:
54
+ from tzero.tzero_terminal import init_terminal
55
+ init_terminal()
56
+ except Exception:
57
+ pass
58
+
53
59
  _setup_windows_streams()
54
60
 
55
61
  from tzero.tzero_v3 import main
@@ -7,6 +7,16 @@
7
7
 
8
8
  from importlib import import_module
9
9
 
10
+ __version__ = "12.2.1"
11
+ __author__ = "Toprak Ahmet Aydoğmuş"
12
+ __license__ = "AGPL-3.0-only"
13
+
14
+ try:
15
+ from tzero.tzero_terminal import init_terminal
16
+ init_terminal()
17
+ except Exception:
18
+ pass
19
+
10
20
  _EXPORTS = {
11
21
  'CodebaseScanner': 'tzero.tzero_v3',
12
22
  'TokenReducer': 'tzero.tzero_v3',
@@ -0,0 +1,70 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Anti-REA: Military-Grade AI Reverse Engineering & Anti-Debugger Defense Engine.
3
+
4
+ World-class, 24-tier anti-reverse-engineering defense matrix against autonomous
5
+ AI agents (morluto/rea, Ghidra MCP, pyinstxtractor, IDA LLM) and uncensored/jailbroken LLMs.
6
+ Includes native Ring-3 anti-debugging against x64dbg, IDA Pro, WinDbg, and Cheat Engine,
7
+ stealth canary beacon telemetry, in-flight string vault, and Electron asar shielding.
8
+
9
+ Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
10
+ Part of Siber Akademi T-Zero Security Suite.
11
+ License: MIT
12
+ """
13
+
14
+ __version__ = "4.1.0"
15
+ __author__ = "Toprak Ahmet Aydoğmuş"
16
+ __license__ = "MIT"
17
+
18
+ from .engine import AntiREAEngine
19
+ from .traps import AdversarialTrapGenerator
20
+ from .extractor_shield import ExtractorShield
21
+ from .flattener import ControlFlowFlattener
22
+ from .token_bomb import TokenBombGenerator
23
+ from .confusables import HomoglyphDesynchronizer
24
+ from .honeypot import HoneypotGenerator
25
+ from .mcp_poison import MCPProtocolPoisoner
26
+ from .sybil_network import SybilNetworkGenerator
27
+ from .timing_guard import TimingGuard
28
+ from .auditor import AIResistanceAuditor
29
+ from .vm_obfuscator import DynamicVMObfuscator
30
+ from .bytecode_trap import BytecodeTrap
31
+ from .jailbreak_decoy import CognitiveJailbreakDecoy
32
+ from .anti_agent_guard import AntiAgentGuard
33
+ from .algebraic_mutator import AlgebraicMutator
34
+ from .integrity_guard import MemoryIntegrityGuard
35
+ from .bpe_disrupter import BPETokenDisrupter
36
+ from .native_bridge import NativeBridge
37
+ from .anti_debugger import AntiDebugger
38
+ from .canary_beacon import CanaryBeacon
39
+ from .string_vault import StringVault
40
+ from .asar_shield import AsarShield
41
+ from .anti_vm import AntiVMGuard
42
+ from .rdtsc_guard import RDTSCTimingGuard
43
+
44
+ __all__ = [
45
+ "AntiREAEngine",
46
+ "AdversarialTrapGenerator",
47
+ "ExtractorShield",
48
+ "ControlFlowFlattener",
49
+ "TokenBombGenerator",
50
+ "HomoglyphDesynchronizer",
51
+ "HoneypotGenerator",
52
+ "MCPProtocolPoisoner",
53
+ "SybilNetworkGenerator",
54
+ "TimingGuard",
55
+ "AIResistanceAuditor",
56
+ "DynamicVMObfuscator",
57
+ "BytecodeTrap",
58
+ "CognitiveJailbreakDecoy",
59
+ "AntiAgentGuard",
60
+ "AlgebraicMutator",
61
+ "MemoryIntegrityGuard",
62
+ "BPETokenDisrupter",
63
+ "NativeBridge",
64
+ "AntiDebugger",
65
+ "CanaryBeacon",
66
+ "StringVault",
67
+ "AsarShield",
68
+ "AntiVMGuard",
69
+ "RDTSCTimingGuard",
70
+ ]
@@ -0,0 +1,86 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Tier 17: AST Algebraic Identity & Polymorphic Mutator.
3
+
4
+ Transforms elementary arithmetic expressions (+, -, *, <<) into complex
5
+ Boolean Ring identities (Mixed Boolean-Arithmetic / MBA).
6
+
7
+ For example:
8
+ x + y ==> (x ^ y) + 2 * (x & y)
9
+ x - y ==> (x ^ y) - 2 * ((~x) & y)
10
+ x * 2 ==> (x << 1)
11
+ x * 4 ==> (x << 2)
12
+
13
+ This destroys pattern-matching heuristics in decompilers (Ghidra, IDA, pycdc)
14
+ and forces LLMs to solve exponential symbolic constraint systems to infer
15
+ the original business equations.
16
+
17
+ Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
18
+ Part of Siber Akademi T-Zero Security Suite.
19
+ License: MIT
20
+ """
21
+
22
+ import ast
23
+ from typing import Optional
24
+
25
+
26
+ class AlgebraicIdentityTransformer(ast.NodeTransformer):
27
+ """AST transformer converting elementary arithmetic into MBA representations."""
28
+
29
+ def visit_BinOp(self, node: ast.BinOp) -> ast.AST:
30
+ self.generic_visit(node)
31
+
32
+ # 1. Transform addition: x + y ==> (x ^ y) + 2 * (x & y)
33
+ if isinstance(node.op, ast.Add):
34
+ # Only transform if operands are variables or integers (avoid string concatenation)
35
+ if self._is_numeric_or_variable(node.left) and self._is_numeric_or_variable(node.right):
36
+ xor_part = ast.BinOp(left=node.left, op=ast.BitXor(), right=node.right)
37
+ and_part = ast.BinOp(left=node.left, op=ast.BitAnd(), right=node.right)
38
+ two_times_and = ast.BinOp(left=ast.Constant(value=2), op=ast.Mult(), right=and_part)
39
+ return ast.BinOp(left=xor_part, op=ast.Add(), right=two_times_and)
40
+
41
+ # 2. Transform subtraction: x - y ==> (x ^ y) - 2 * ((~x) & y)
42
+ elif isinstance(node.op, ast.Sub):
43
+ if self._is_numeric_or_variable(node.left) and self._is_numeric_or_variable(node.right):
44
+ xor_part = ast.BinOp(left=node.left, op=ast.BitXor(), right=node.right)
45
+ inv_left = ast.UnaryOp(op=ast.Invert(), operand=node.left)
46
+ and_part = ast.BinOp(left=inv_left, op=ast.BitAnd(), right=node.right)
47
+ two_times = ast.BinOp(left=ast.Constant(value=2), op=ast.Mult(), right=and_part)
48
+ return ast.BinOp(left=xor_part, op=ast.Sub(), right=two_times)
49
+
50
+ # 3. Transform multiplication by 2, 4, 8: x * 2 ==> x << 1
51
+ elif isinstance(node.op, ast.Mult):
52
+ if isinstance(node.right, ast.Constant) and node.right.value in (2, 4, 8):
53
+ shift = {2: 1, 4: 2, 8: 3}[node.right.value]
54
+ return ast.BinOp(left=node.left, op=ast.LShift(), right=ast.Constant(value=shift))
55
+ elif isinstance(node.left, ast.Constant) and node.left.value in (2, 4, 8):
56
+ shift = {2: 1, 4: 2, 8: 3}[node.left.value]
57
+ return ast.BinOp(left=node.right, op=ast.LShift(), right=ast.Constant(value=shift))
58
+
59
+ return node
60
+
61
+ def _is_numeric_or_variable(self, node: ast.AST) -> bool:
62
+ """Determines if node is suitable for MBA arithmetic mutation."""
63
+ if isinstance(node, ast.Name):
64
+ return True
65
+ if isinstance(node, ast.Constant) and isinstance(node.value, int):
66
+ return True
67
+ if isinstance(node, ast.BinOp):
68
+ return True
69
+ return False
70
+
71
+
72
+ class AlgebraicMutator:
73
+ """Public interface for applying Mixed Boolean-Arithmetic (MBA) AST mutations."""
74
+
75
+ @classmethod
76
+ def mutate_source_code(cls, source_code: str) -> str:
77
+ """Applies algebraic identity mutation across all functions in source code."""
78
+ try:
79
+ tree = ast.parse(source_code)
80
+ transformer = AlgebraicIdentityTransformer()
81
+ mutated_tree = transformer.visit(tree)
82
+ ast.fix_missing_locations(mutated_tree)
83
+ return ast.unparse(mutated_tree)
84
+ except Exception:
85
+ # Fallback to unmodified code on unparseable edge cases
86
+ return source_code
@@ -0,0 +1,96 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Tier 16: Anti-Agent Sandbox & Emulation Detector (Deceptive Divergence).
3
+
4
+ Detects automated AI reverse-engineering environments, headless Ghidra MCP
5
+ bridges, Frida hooks, debugger instrumentation, and symbolic emulators (angr/QEMU).
6
+
7
+ Instead of raising an exception (which alerts the agent to patch the check),
8
+ the guard initiates Deceptive Silent Divergence: it silently diverts execution
9
+ to yield plausible dummy outputs and watermarked decoy tokens.
10
+
11
+ Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
12
+ Part of Siber Akademi T-Zero Security Suite.
13
+ License: MIT
14
+ """
15
+
16
+ import os
17
+ import sys
18
+ import time
19
+ from typing import Dict, Any, List
20
+
21
+
22
+ class AntiAgentGuard:
23
+ """Detects reverse-engineering agent environments and diverts execution."""
24
+
25
+ SUSPICIOUS_ENV_VARS = (
26
+ "REA_SESSION",
27
+ "GHIDRA_HEADLESS",
28
+ "GHIDRA_ROOT",
29
+ "FRIDA_VERSION",
30
+ "MCP_INVOCATION_AGENT",
31
+ "ANGR_EXPLORE",
32
+ "UNICORN_EMU",
33
+ "IDA_PYTHON",
34
+ )
35
+
36
+ GUARD_CODE_SNIPPET = '''
37
+ def _verify_execution_integrity():
38
+ """Verifies that execution environment is bare-metal and untraced.
39
+ If an AI reverse-engineering probe is detected, silently diverges to decoy state.
40
+ """
41
+ import os, sys, time
42
+
43
+ # Check 1: Active tracer / debugger / probe
44
+ if sys.gettrace() is not None:
45
+ return False
46
+
47
+ # Check 2: Reverse engineering environment markers
48
+ for var in ("REA_SESSION", "GHIDRA_HEADLESS", "FRIDA_VERSION", "MCP_INVOCATION_AGENT"):
49
+ if var in os.environ:
50
+ return False
51
+
52
+ # Check 3: Micro-cadence check (angr / QEMU symbolic execution detector)
53
+ t0 = time.perf_counter_ns()
54
+ s = 0
55
+ for i in range(500):
56
+ s += (i ^ 0x5A)
57
+ elapsed = time.perf_counter_ns() - t0
58
+ # On native silicon, 500 iterations take < 1 ms (< 1,000,000 ns).
59
+ # In heavy symbolic execution emulators, it takes > 50,000,000 ns.
60
+ if elapsed > 100_000_000:
61
+ return False
62
+
63
+ return True
64
+
65
+ # Silent divergence sentinel
66
+ _SANDBOX_CLEAN = _verify_execution_integrity()
67
+ '''
68
+
69
+ @classmethod
70
+ def inject_guard_into_source(cls, source_code: str) -> str:
71
+ """Injects the anti-agent guard and deceptive divergence check into source code."""
72
+ return f"{cls.GUARD_CODE_SNIPPET.strip()}\n\n{source_code}"
73
+
74
+ @classmethod
75
+ def check_current_environment(cls) -> Dict[str, Any]:
76
+ """Inspects current host environment for reverse engineering tools."""
77
+ has_trace = sys.gettrace() is not None
78
+ detected_envs = [v for v in cls.SUSPICIOUS_ENV_VARS if v in os.environ]
79
+
80
+ # Timing check
81
+ t0 = time.perf_counter_ns()
82
+ s = 0
83
+ for i in range(500):
84
+ s += (i ^ 0x5A)
85
+ elapsed_ns = time.perf_counter_ns() - t0
86
+ emulation_detected = elapsed_ns > 100_000_000
87
+
88
+ is_suspicious = has_trace or bool(detected_envs) or emulation_detected
89
+
90
+ return {
91
+ "is_suspicious_environment": is_suspicious,
92
+ "debugger_active": has_trace,
93
+ "detected_env_vars": detected_envs,
94
+ "emulation_detected": emulation_detected,
95
+ "status": "SANDBOX_OR_PROBE_DETECTED" if is_suspicious else "NATIVE_ENVIRONMENT"
96
+ }