tzero-mcp 12.2.2 → 12.3.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/README.md +6 -30
- package/bin/tzero-mcp.js +2 -2
- package/bin/tzero.js +11 -6
- package/package.json +1 -2
- package/src/addmcp.py +2 -2
- package/src/app.py +1 -1
- package/src/tzero/__init__.py +1 -1
- package/src/tzero/anti_rea/__init__.py +16 -2
- package/src/tzero/anti_rea/algebraic_mutator.py +65 -44
- package/src/tzero/anti_rea/anti_debugger.py +51 -18
- package/src/tzero/anti_rea/asar_shield.py +21 -0
- package/src/tzero/anti_rea/auditor.py +20 -0
- package/src/tzero/anti_rea/canary_beacon.py +33 -61
- package/src/tzero/anti_rea/cli.py +30 -4
- package/src/tzero/anti_rea/crypto_loader.py +132 -0
- package/src/tzero/anti_rea/engine.py +51 -20
- package/src/tzero/anti_rea/extractor_shield.py +60 -25
- package/src/tzero/anti_rea/tier_catalog.py +388 -0
- package/src/tzero/tzero_armor.py +3 -3
- package/src/tzero/tzero_benchmark.py +1 -1
- package/src/tzero/tzero_budget.py +1 -1
- package/src/tzero/tzero_ci.py +2 -2
- package/src/tzero/tzero_contracts.py +2 -2
- package/src/tzero/tzero_dashboard.py +3 -3
- package/src/tzero/tzero_debt.py +1 -1
- package/src/tzero/tzero_deps.py +109 -87
- package/src/tzero/tzero_explain.py +1 -1
- package/src/tzero/tzero_golden.py +2 -2
- package/src/tzero/tzero_growth.py +1 -1
- package/src/tzero/tzero_jarvis/workspace_orchestrator.py +1 -1
- package/src/tzero/tzero_jarvis/zero_key_router.py +10 -78
- package/src/tzero/tzero_lsp.py +1 -1
- package/src/tzero/tzero_mcp.py +8 -8
- package/src/tzero/tzero_mutation.py +6 -2
- package/src/tzero/tzero_promo.py +1 -1
- package/src/tzero/tzero_security.py +40 -11
- package/src/tzero/tzero_task_benchmark.py +2 -2
- package/src/tzero/tzero_traffic.py +1 -1
- package/src/tzero/tzero_tui.py +5 -5
- package/src/tzero/tzero_v3.py +44 -73
- package/src/tzero/tzero_welcome.py +1 -1
- package/bin/postinstall.js +0 -30
package/src/tzero/tzero_debt.py
CHANGED
|
@@ -13,7 +13,7 @@ Capabilities:
|
|
|
13
13
|
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).
|
|
14
14
|
|
|
15
15
|
Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
16
|
-
Part of T-Zero Context Architect v12.
|
|
16
|
+
Part of T-Zero Context Architect v12.3.2 Master Edition.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
import ast
|
package/src/tzero/tzero_deps.py
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
"""T-Zero dependency bootstrap and environment doctor (standard library only).
|
|
3
3
|
|
|
4
|
-
* ``ensure_dependencies()``
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* ``run_doctor()`` powers ``python main.py --doctor``: it checks Python, packages, tkinter, git
|
|
8
|
-
and the OS keyring and prints an easy-to-read report.
|
|
9
|
-
|
|
10
|
-
Set ``TZERO_NO_AUTO_INSTALL=1`` to disable automatic installation (the tool then only tells you
|
|
11
|
-
what is missing). Frozen builds (the .exe) never install anything.
|
|
4
|
+
* ``ensure_dependencies()`` checks installed package versions and prints a manual
|
|
5
|
+
installation command when something is missing.
|
|
6
|
+
* ``run_doctor()`` reports the state of Python, packages, tkinter, Git and keyring.
|
|
12
7
|
|
|
13
8
|
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
14
9
|
"""
|
|
@@ -17,9 +12,12 @@ import importlib
|
|
|
17
12
|
import importlib.util
|
|
18
13
|
import os
|
|
19
14
|
import re
|
|
15
|
+
import shlex
|
|
20
16
|
import shutil
|
|
21
17
|
import subprocess
|
|
22
18
|
import sys
|
|
19
|
+
import sysconfig
|
|
20
|
+
from pathlib import Path
|
|
23
21
|
from typing import List, NamedTuple, Optional, Tuple
|
|
24
22
|
|
|
25
23
|
OPT_OUT_ENV = "TZERO_NO_AUTO_INSTALL"
|
|
@@ -89,8 +87,8 @@ def _err(message: str) -> None:
|
|
|
89
87
|
pass
|
|
90
88
|
|
|
91
89
|
|
|
92
|
-
def ensure_dependencies(include_mcp: bool = False) -> bool:
|
|
93
|
-
"""
|
|
90
|
+
def ensure_dependencies(include_mcp: bool = False, *, install: bool = False) -> bool:
|
|
91
|
+
"""Check dependencies, with installation available to explicit callers.
|
|
94
92
|
|
|
95
93
|
Returns True when everything needed is available afterwards.
|
|
96
94
|
"""
|
|
@@ -101,7 +99,6 @@ def ensure_dependencies(include_mcp: bool = False) -> bool:
|
|
|
101
99
|
if getattr(sys, "frozen", False): # PyInstaller build: dependencies are bundled
|
|
102
100
|
return True
|
|
103
101
|
|
|
104
|
-
ensure_scripts_in_path(quiet=True)
|
|
105
102
|
deps = list(REQUIRED) + ([MCP_DEPENDENCY] if include_mcp else [])
|
|
106
103
|
problems = [d for d in deps if check_dependency(d)[0] != "ok"]
|
|
107
104
|
if not problems:
|
|
@@ -109,9 +106,9 @@ def ensure_dependencies(include_mcp: bool = False) -> bool:
|
|
|
109
106
|
|
|
110
107
|
specs = [d.spec for d in problems]
|
|
111
108
|
manual = f'"{sys.executable}" -m pip install ' + " ".join(f'"{s}"' for s in specs)
|
|
112
|
-
if os.environ.get(OPT_OUT_ENV) == "1":
|
|
109
|
+
if not install or os.environ.get(OPT_OUT_ENV) == "1":
|
|
113
110
|
_err("[T-Zero] Missing or outdated packages: " + ", ".join(specs))
|
|
114
|
-
_err(f"[T-Zero]
|
|
111
|
+
_err(f"[T-Zero] Install manually:\n {manual}")
|
|
115
112
|
return False
|
|
116
113
|
|
|
117
114
|
_err("[T-Zero] Installing missing or outdated packages: " + ", ".join(specs))
|
|
@@ -135,7 +132,6 @@ def ensure_dependencies(include_mcp: bool = False) -> bool:
|
|
|
135
132
|
_err(f" Install manually:\n {manual}")
|
|
136
133
|
return False
|
|
137
134
|
|
|
138
|
-
ensure_scripts_in_path(quiet=True)
|
|
139
135
|
still_bad = [d.spec for d in problems if check_dependency(d)[0] != "ok"]
|
|
140
136
|
if still_bad:
|
|
141
137
|
_err("[T-Zero] Still unavailable after install: " + ", ".join(still_bad))
|
|
@@ -144,77 +140,107 @@ def ensure_dependencies(include_mcp: bool = False) -> bool:
|
|
|
144
140
|
return True
|
|
145
141
|
|
|
146
142
|
|
|
147
|
-
def
|
|
148
|
-
""
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
"""
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
def _line(level: str, text: str) -> str:
|
|
144
|
+
return f" [{level:^4}] {text}"
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _tzero_scripts_directory() -> Path:
|
|
148
|
+
executable = "tzero.exe" if os.name == "nt" else "tzero"
|
|
149
|
+
for scheme in (sysconfig.get_default_scheme(), sysconfig.get_preferred_scheme("user")):
|
|
150
|
+
scripts = Path(sysconfig.get_path("scripts", scheme)).resolve()
|
|
151
|
+
if (scripts / executable).is_file():
|
|
152
|
+
return scripts
|
|
153
|
+
raise ValueError("No T-Zero executable was found for this Python installation.")
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _append_windows_user_path(scripts: Path) -> bool:
|
|
157
|
+
import ntpath
|
|
158
|
+
import winreg
|
|
159
|
+
|
|
160
|
+
directory = str(scripts)
|
|
161
|
+
|
|
162
|
+
def normalize(value: str) -> str:
|
|
163
|
+
return ntpath.normcase(ntpath.normpath(winreg.ExpandEnvironmentStrings(value)))
|
|
164
|
+
|
|
165
|
+
access = winreg.KEY_READ | winreg.KEY_SET_VALUE
|
|
166
|
+
with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, "Environment", 0, access) as key:
|
|
167
|
+
try:
|
|
168
|
+
current, kind = winreg.QueryValueEx(key, "Path")
|
|
169
|
+
except FileNotFoundError:
|
|
170
|
+
current, kind = "", winreg.REG_EXPAND_SZ
|
|
171
|
+
if kind not in (winreg.REG_SZ, winreg.REG_EXPAND_SZ):
|
|
172
|
+
raise ValueError("The Windows user PATH is not a string.")
|
|
173
|
+
if any(normalize(entry) == normalize(directory) for entry in current.split(";") if entry):
|
|
174
|
+
return False
|
|
175
|
+
separator = ";" if current and not current.endswith(";") else ""
|
|
176
|
+
winreg.SetValueEx(key, "Path", 0, kind, current + separator + directory)
|
|
177
|
+
return True
|
|
178
|
+
|
|
155
179
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
180
|
+
def _append_shell_path(scripts: Path, config: Path) -> bool:
|
|
181
|
+
import fcntl
|
|
182
|
+
|
|
183
|
+
directory = shlex.quote(str(scripts))
|
|
184
|
+
entry = f'case ":$PATH:" in *:{directory}:*) ;; *) export PATH="${{PATH:+$PATH:}}"{directory} ;; esac'
|
|
185
|
+
with config.open("a+", encoding="utf-8", errors="surrogateescape", newline="") as handle:
|
|
186
|
+
fcntl.flock(handle, fcntl.LOCK_EX)
|
|
187
|
+
handle.seek(0)
|
|
188
|
+
current = handle.read()
|
|
189
|
+
if entry in current.splitlines():
|
|
190
|
+
return False
|
|
191
|
+
if current and not current.endswith("\n"):
|
|
192
|
+
handle.write("\n")
|
|
193
|
+
handle.write(f"# Added by T-Zero\n{entry}\n")
|
|
194
|
+
return True
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def add_to_user_path(shell: Optional[str] = None) -> int:
|
|
198
|
+
"""Add an installed T-Zero launcher to the user's PATH on explicit request."""
|
|
199
|
+
try:
|
|
200
|
+
scripts = _tzero_scripts_directory()
|
|
201
|
+
separator = ";" if os.name == "nt" else ":"
|
|
202
|
+
if any(char in str(scripts) for char in (separator, "\r", "\n")):
|
|
203
|
+
raise ValueError("The T-Zero executable directory contains a PATH separator or newline.")
|
|
204
|
+
if os.name == "nt":
|
|
205
|
+
if shell:
|
|
206
|
+
raise ValueError("--shell applies to Bash and Zsh on Unix.")
|
|
207
|
+
changed = _append_windows_user_path(scripts)
|
|
208
|
+
target = "the Windows user PATH"
|
|
209
|
+
else:
|
|
210
|
+
shell = shell or Path(os.environ.get("SHELL", "")).name
|
|
211
|
+
if shell not in ("bash", "zsh"):
|
|
212
|
+
raise ValueError("Select Bash or Zsh with --shell bash or --shell zsh.")
|
|
213
|
+
config_dir = Path.home()
|
|
214
|
+
if shell == "zsh" and os.environ.get("ZDOTDIR"):
|
|
215
|
+
config_dir = Path(os.environ["ZDOTDIR"]).expanduser()
|
|
216
|
+
config = config_dir / f".{shell}rc"
|
|
217
|
+
changed = _append_shell_path(scripts, config)
|
|
218
|
+
target = str(config)
|
|
219
|
+
except (OSError, ValueError) as exc:
|
|
220
|
+
_err(f"[T-Zero] Could not update PATH: {exc}")
|
|
221
|
+
return 1
|
|
222
|
+
|
|
223
|
+
if changed:
|
|
224
|
+
print(f"Added {scripts} to {target}. Open a new shell to use the updated PATH.")
|
|
159
225
|
else:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
for p in [sys_scripts, user_scripts]:
|
|
164
|
-
if p and os.path.isdir(p) and p not in candidates:
|
|
165
|
-
candidates.append(p)
|
|
166
|
-
|
|
167
|
-
current_path_dirs = [os.path.normcase(os.path.abspath(x)) for x in os.environ.get("PATH", "").split(os.pathsep) if x]
|
|
168
|
-
|
|
169
|
-
added_any = False
|
|
170
|
-
for candidate in candidates:
|
|
171
|
-
norm_cand = os.path.normcase(os.path.abspath(candidate))
|
|
172
|
-
if norm_cand not in current_path_dirs:
|
|
173
|
-
# Update current process
|
|
174
|
-
os.environ["PATH"] = candidate + os.pathsep + os.environ.get("PATH", "")
|
|
175
|
-
current_path_dirs.insert(0, norm_cand)
|
|
176
|
-
added_any = True
|
|
177
|
-
|
|
178
|
-
# Permanently update user PATH
|
|
179
|
-
if os.name == "nt":
|
|
180
|
-
try:
|
|
181
|
-
import winreg
|
|
182
|
-
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Environment", 0, winreg.KEY_READ | winreg.KEY_WRITE) as key:
|
|
183
|
-
try:
|
|
184
|
-
user_path, _ = winreg.QueryValueEx(key, "Path")
|
|
185
|
-
except FileNotFoundError:
|
|
186
|
-
user_path = ""
|
|
187
|
-
parts = [x.strip() for x in user_path.split(";") if x.strip()]
|
|
188
|
-
if candidate not in parts:
|
|
189
|
-
parts.append(candidate)
|
|
190
|
-
new_path = ";".join(parts)
|
|
191
|
-
winreg.SetValueEx(key, "Path", 0, winreg.REG_EXPAND_SZ, new_path)
|
|
192
|
-
if not quiet:
|
|
193
|
-
sys.stderr.write(f"[T-Zero] Added {candidate} to User PATH in Windows Registry.\n")
|
|
194
|
-
except Exception:
|
|
195
|
-
pass
|
|
196
|
-
else:
|
|
197
|
-
try:
|
|
198
|
-
home = os.path.expanduser("~")
|
|
199
|
-
for rc_name in [".bashrc", ".zshrc"]:
|
|
200
|
-
rc_path = os.path.join(home, rc_name)
|
|
201
|
-
if os.path.exists(rc_path):
|
|
202
|
-
with open(rc_path, "r", encoding="utf-8", errors="ignore") as f:
|
|
203
|
-
rc_content = f.read()
|
|
204
|
-
export_line = f'export PATH="{candidate}:$PATH"'
|
|
205
|
-
if candidate not in rc_content:
|
|
206
|
-
with open(rc_path, "a", encoding="utf-8") as f:
|
|
207
|
-
f.write(f"\n# Added by T-Zero Context Architect\n{export_line}\n")
|
|
208
|
-
if not quiet:
|
|
209
|
-
sys.stderr.write(f"[T-Zero] Added {candidate} to {rc_name}\n")
|
|
210
|
-
except Exception:
|
|
211
|
-
pass
|
|
212
|
-
|
|
213
|
-
return added_any
|
|
226
|
+
print(f"{scripts} is already configured in {target}.")
|
|
227
|
+
return 0
|
|
214
228
|
|
|
215
229
|
|
|
216
|
-
def
|
|
217
|
-
|
|
230
|
+
def main() -> int:
|
|
231
|
+
import argparse
|
|
232
|
+
|
|
233
|
+
parser = argparse.ArgumentParser(description="Check Python dependencies and configure T-Zero's user PATH.")
|
|
234
|
+
parser.add_argument(
|
|
235
|
+
"--add-to-path", action="store_true", help="Persist T-Zero's executable directory in your user PATH."
|
|
236
|
+
)
|
|
237
|
+
parser.add_argument("--shell", choices=("bash", "zsh"), help="Select the shell configuration file to update on Unix.")
|
|
238
|
+
args = parser.parse_args()
|
|
239
|
+
if args.add_to_path:
|
|
240
|
+
return add_to_user_path(args.shell)
|
|
241
|
+
if args.shell:
|
|
242
|
+
parser.error("--shell requires --add-to-path")
|
|
243
|
+
return run_doctor()
|
|
218
244
|
|
|
219
245
|
|
|
220
246
|
def _run_deep_subsystem_check() -> int:
|
|
@@ -382,7 +408,7 @@ def _run_deep_subsystem_check() -> int:
|
|
|
382
408
|
|
|
383
409
|
|
|
384
410
|
def run_doctor(deep: bool = False) -> int:
|
|
385
|
-
"""Checks the environment
|
|
411
|
+
"""Checks the environment and returns a process exit code."""
|
|
386
412
|
print("T-Zero Doctor: environment check\n")
|
|
387
413
|
failures = 0
|
|
388
414
|
|
|
@@ -437,10 +463,6 @@ def run_doctor(deep: bool = False) -> int:
|
|
|
437
463
|
except Exception as exc:
|
|
438
464
|
print(_line("WARN", f"keyring could not be checked: {exc}"))
|
|
439
465
|
|
|
440
|
-
if not deep:
|
|
441
|
-
ensure_scripts_in_path(quiet=True)
|
|
442
|
-
print(_line("OK", "Python Scripts PATH verified (tzero, tzero-gui, tzero-mcp accessible)"))
|
|
443
|
-
|
|
444
466
|
if deep:
|
|
445
467
|
from tzero.tzero_polyglot import _ALLOW_BPE_DOWNLOAD
|
|
446
468
|
|
|
@@ -459,4 +481,4 @@ def run_doctor(deep: bool = False) -> int:
|
|
|
459
481
|
|
|
460
482
|
|
|
461
483
|
if __name__ == "__main__":
|
|
462
|
-
sys.exit(
|
|
484
|
+
sys.exit(main())
|
|
@@ -11,7 +11,7 @@ Capabilities:
|
|
|
11
11
|
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).
|
|
12
12
|
|
|
13
13
|
Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
14
|
-
Part of T-Zero Context Architect v12.
|
|
14
|
+
Part of T-Zero Context Architect v12.3.2 Master Edition.
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
17
|
import ast
|
|
@@ -208,7 +208,7 @@ class ASTGoldenRegressionEngine:
|
|
|
208
208
|
|
|
209
209
|
return GoldenBaseline(
|
|
210
210
|
workspace_root=abs_root,
|
|
211
|
-
version="12.
|
|
211
|
+
version="12.3.2",
|
|
212
212
|
created_at=time.time(),
|
|
213
213
|
symbols=all_sigs,
|
|
214
214
|
total_symbols=len(all_sigs),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
T-ZERO $0.00 BUDGET VIRAL MARKETING & COMMUNITY GROWTH ENGINE
|
|
4
4
|
-------------------------------------------------------------
|
|
5
5
|
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
6
|
-
License: MIT | Version: 12.
|
|
6
|
+
License: MIT | Version: 12.3.2
|
|
7
7
|
|
|
8
8
|
Strictly $0.00 budget: Zero paid ads, zero paid APIs, zero cloud tokens.
|
|
9
9
|
Pure organic developer-to-developer growth engine engineered to drive 100+ GitHub stars.
|
|
@@ -1041,7 +1041,7 @@ flowchart LR
|
|
|
1041
1041
|
|
|
1042
1042
|
return f"""# T-ZERO JARVIS MASTER WORKSPACE ORCHESTRATOR
|
|
1043
1043
|
*Executive AI Engineering Manager & Autonomous Multi-Agent Coordinator*
|
|
1044
|
-
*Version: 5.1.0 |
|
|
1044
|
+
*Version: 5.1.0 | Local AST Core | $0.00 Cost | 100% Zero-Leak Certified*
|
|
1045
1045
|
|
|
1046
1046
|
---
|
|
1047
1047
|
|
|
@@ -5,26 +5,13 @@ JARVIS ZERO-KEY INTELLIGENCE ROUTER
|
|
|
5
5
|
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
6
6
|
Version: 4.2.0
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
4 Katmanlı Akıllı Havuz:
|
|
12
|
-
1. Yerel Ollama (Eğer makinede yüklüyse, sıfır internet ve sıfır maliyetle çalışır)
|
|
13
|
-
2. Pollinations AI Ücretsiz Uç Noktası (Kayıt, kredi kartı veya API Key gerektirmez)
|
|
14
|
-
3. OpenRouter Free Whitelist (Sadece ':free' etiketli modeller)
|
|
15
|
-
4. Deterministik AST Tamircisi (Sözdizimi ve import hatalarını LLM olmadan doğrudan onarır)
|
|
8
|
+
Runs keyless inference through a local Ollama API and exposes a separate web
|
|
9
|
+
search helper.
|
|
16
10
|
"""
|
|
17
11
|
|
|
18
|
-
import os
|
|
19
|
-
import sys
|
|
20
12
|
import json
|
|
21
|
-
import logging
|
|
22
13
|
import urllib.request
|
|
23
|
-
import
|
|
24
|
-
import urllib.parse
|
|
25
|
-
from typing import Dict, List, Optional, Any
|
|
26
|
-
|
|
27
|
-
logger = logging.getLogger("TZeroJarvisRouter")
|
|
14
|
+
from typing import Any, Dict, Optional
|
|
28
15
|
|
|
29
16
|
|
|
30
17
|
class ZeroCostSecurityGuard:
|
|
@@ -49,8 +36,6 @@ class ZeroCostSecurityGuard:
|
|
|
49
36
|
class ZeroKeyAIRouter:
|
|
50
37
|
"""API Key gerektirmeyen, hatasız ve yedekli yapay zeka motoru."""
|
|
51
38
|
|
|
52
|
-
POLLINATIONS_URL = "https://text.pollinations.ai/"
|
|
53
|
-
|
|
54
39
|
@classmethod
|
|
55
40
|
def check_ollama_available(cls) -> bool:
|
|
56
41
|
"""Yerel makinede Ollama'nın çalışıp çalışmadığını yoklar."""
|
|
@@ -71,45 +56,6 @@ class ZeroKeyAIRouter:
|
|
|
71
56
|
data = json.loads(resp.read().decode("utf-8"))
|
|
72
57
|
return data.get("response", "")
|
|
73
58
|
|
|
74
|
-
@classmethod
|
|
75
|
-
def call_pollinations_free(cls, prompt: str, system_prompt: str = "Sen T-Zero Jarvis otonom kodlama asistanısın.") -> str:
|
|
76
|
-
"""
|
|
77
|
-
Pollinations AI ücretsiz REST uç noktasını çağırır.
|
|
78
|
-
HİÇBİR API KEY VEYA KAYIT GEREKTİRMEZ.
|
|
79
|
-
"""
|
|
80
|
-
payload = {
|
|
81
|
-
"messages": [
|
|
82
|
-
{"role": "system", "content": system_prompt},
|
|
83
|
-
{"role": "user", "content": prompt}
|
|
84
|
-
],
|
|
85
|
-
"model": "openai",
|
|
86
|
-
"seed": 42,
|
|
87
|
-
"jsonMode": False
|
|
88
|
-
}
|
|
89
|
-
data = json.dumps(payload).encode("utf-8")
|
|
90
|
-
req = urllib.request.Request(
|
|
91
|
-
cls.POLLINATIONS_URL,
|
|
92
|
-
data=data,
|
|
93
|
-
headers={
|
|
94
|
-
"Content-Type": "application/json",
|
|
95
|
-
"User-Agent": "T-Zero-Jarvis-Autonomous/4.2"
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
try:
|
|
99
|
-
with urllib.request.urlopen(req, timeout=45) as resp:
|
|
100
|
-
return resp.read().decode("utf-8", errors="replace").strip()
|
|
101
|
-
except urllib.error.HTTPError as e:
|
|
102
|
-
# Yedek GET parametreli ücretsiz çağrı
|
|
103
|
-
try:
|
|
104
|
-
encoded_prompt = urllib.parse.quote(prompt[:500])
|
|
105
|
-
fallback_url = f"{cls.POLLINATIONS_URL}{encoded_prompt}?system={urllib.parse.quote(system_prompt[:200])}"
|
|
106
|
-
fallback_req = urllib.request.Request(fallback_url, headers={"User-Agent": "T-Zero-Jarvis"})
|
|
107
|
-
with urllib.request.urlopen(fallback_req, timeout=30) as f_resp:
|
|
108
|
-
return f_resp.read().decode("utf-8", errors="replace").strip()
|
|
109
|
-
except Exception as e2:
|
|
110
|
-
logger.error(f"Pollinations fallback failed: {e2}")
|
|
111
|
-
raise RuntimeError(f"Ücretsiz genel çıkarım uç noktasına bağlanılamadı: {e}")
|
|
112
|
-
|
|
113
59
|
@classmethod
|
|
114
60
|
def search_duckduckgo_free(cls, query: str, max_results: int = 4) -> str:
|
|
115
61
|
"""API anahtarı olmadan canlı internet araması yapar."""
|
|
@@ -128,10 +74,7 @@ class ZeroKeyAIRouter:
|
|
|
128
74
|
|
|
129
75
|
@classmethod
|
|
130
76
|
def query_intelligence(cls, prompt: str, system_prompt: Optional[str] = None) -> Dict[str, Any]:
|
|
131
|
-
"""
|
|
132
|
-
Kullanıcıdan tek bir API key istemeden en uygun ücretsiz sağlayıcıyı
|
|
133
|
-
otomatik seçip yanıtı döndüren ana fonksiyon.
|
|
134
|
-
"""
|
|
77
|
+
"""Return an Ollama completion or report that local inference is unavailable."""
|
|
135
78
|
sys_p = system_prompt or "Sen Siber Akademi T-Zero Jarvis otonom yazılım mühendisisin."
|
|
136
79
|
|
|
137
80
|
# 1. Öncelik: Yerel Ollama (Maksimum Gizlilik & Sıfır İnternet)
|
|
@@ -148,23 +91,12 @@ class ZeroKeyAIRouter:
|
|
|
148
91
|
except Exception:
|
|
149
92
|
pass
|
|
150
93
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"cost": "0.00$",
|
|
158
|
-
"response": ans
|
|
159
|
-
}
|
|
160
|
-
except Exception as e:
|
|
161
|
-
# 3. Fallback: Deterministik yanıt
|
|
162
|
-
return {
|
|
163
|
-
"provider": "tzero_deterministic_engine",
|
|
164
|
-
"model": "ast-rule-engine",
|
|
165
|
-
"cost": "0.00$",
|
|
166
|
-
"response": f"[T-Zero Deterministik Zeka]: İstek AST motoru tarafından işlendi. Ağ bağlantısı veya yerel LLM olmadan deterministik çözüm uygulandı."
|
|
167
|
-
}
|
|
94
|
+
return {
|
|
95
|
+
"provider": "unavailable",
|
|
96
|
+
"model": "",
|
|
97
|
+
"cost": "0.00$",
|
|
98
|
+
"response": "Local Ollama is unavailable or returned no response.",
|
|
99
|
+
}
|
|
168
100
|
|
|
169
101
|
route_query = query_intelligence
|
|
170
102
|
|
package/src/tzero/tzero_lsp.py
CHANGED
package/src/tzero/tzero_mcp.py
CHANGED
|
@@ -33,7 +33,7 @@ import ast
|
|
|
33
33
|
import inspect
|
|
34
34
|
import logging
|
|
35
35
|
|
|
36
|
-
SERVER_VERSION = "12.
|
|
36
|
+
SERVER_VERSION = "12.3.2"
|
|
37
37
|
|
|
38
38
|
# Version checks must not initialize the MCP SDK or dependency bootstrap. Besides
|
|
39
39
|
# being needlessly expensive, that path may wait on package discovery/network
|
|
@@ -1890,9 +1890,9 @@ def create_mcp_server():
|
|
|
1890
1890
|
# -------------------------------------------------------------------------
|
|
1891
1891
|
@_maybe_tool(
|
|
1892
1892
|
name="jarvis_zero_key_query",
|
|
1893
|
-
title="Query
|
|
1893
|
+
title="Query Local Ollama Models via Zero Key Gateway",
|
|
1894
1894
|
description=(
|
|
1895
|
-
"Dispatches inference prompts to
|
|
1895
|
+
"Dispatches inference prompts strictly to a local Ollama daemon (127.0.0.1:11434) with zero external API keys, distinguishing from 'search_codebase_semantic' and 'get_project_context_tree' by generating natural language completions rather than static codebase context.\n"
|
|
1896
1896
|
"\n"
|
|
1897
1897
|
"Parameters:\n"
|
|
1898
1898
|
"- `prompt` (str, required): User prompt, code question, or instruction for the AI model.\n"
|
|
@@ -1901,15 +1901,15 @@ def create_mcp_server():
|
|
|
1901
1901
|
"Behavior:\n"
|
|
1902
1902
|
"- Read-only: Performs query inference without modifying workspace files or persisting conversational state.\n"
|
|
1903
1903
|
"- Non-idempotent: Model responses may vary across invocations.\n"
|
|
1904
|
-
"- Open-World Network Operation: Dispatches HTTP requests to local Ollama (127.0.0.1:11434)
|
|
1905
|
-
"- Auth & Rate Limits: Zero credentials required; no account or credit card needed.
|
|
1906
|
-
"- Error Handling:
|
|
1904
|
+
"- Open-World Network Operation: Dispatches local HTTP requests strictly to local Ollama (127.0.0.1:11434) with zero user API keys, zero billing, and zero external cloud fallbacks.\n"
|
|
1905
|
+
"- Auth & Rate Limits: Zero credentials required; no account or credit card needed. Local daemon check has a 1.5-second timeout and inference has a 60-second timeout.\n"
|
|
1906
|
+
"- Error Handling: Reports unavailability immediately if local Ollama is inactive without falling back to external cloud services.\n"
|
|
1907
1907
|
"\n"
|
|
1908
1908
|
"Usage Guidelines:\n"
|
|
1909
|
-
"- When to use: Query free
|
|
1909
|
+
"- When to use: Query free local Ollama inference for coding questions or reasoning without configuring API keys or paying commercial provider fees.\n"
|
|
1910
1910
|
"- When NOT to use: Do not use for local codebase search or AST parsing (use 'search_codebase_semantic' or 'get_project_context_tree' instead); do not use for structured file modifications (use 'generate_smart_micro_patch' instead).\n"
|
|
1911
1911
|
"\n"
|
|
1912
|
-
"Returns: Structured Markdown containing selected
|
|
1912
|
+
"Returns: Structured Markdown containing selected local provider name, model identifier, cost confirmation ($0.00), and response completion text."
|
|
1913
1913
|
),
|
|
1914
1914
|
annotations=ToolAnnotations(read_only_hint=True, destructive_hint=False, idempotent_hint=False, open_world_hint=True)
|
|
1915
1915
|
)
|
|
@@ -299,12 +299,16 @@ class ASTMutationEngine:
|
|
|
299
299
|
target_dir = os.path.dirname(abs_target)
|
|
300
300
|
expected_test_name = f"test_{os.path.splitext(os.path.basename(abs_target))[0]}.py"
|
|
301
301
|
|
|
302
|
-
# Discover untainted test files
|
|
302
|
+
# Discover untainted test files from workspace root, validated target_dir, and tzero_* temp dirs
|
|
303
303
|
discover_roots = [ws_root]
|
|
304
|
+
if base_root == tmp_root and target_dir not in discover_roots:
|
|
305
|
+
discover_roots.append(target_dir)
|
|
304
306
|
try:
|
|
305
307
|
for d_entry in os.scandir(tmp_root):
|
|
306
308
|
if d_entry.is_dir() and d_entry.name.startswith("tzero_"):
|
|
307
|
-
|
|
309
|
+
entry_real = os.path.realpath(d_entry.path)
|
|
310
|
+
if entry_real not in discover_roots:
|
|
311
|
+
discover_roots.append(entry_real)
|
|
308
312
|
except OSError:
|
|
309
313
|
pass
|
|
310
314
|
|
package/src/tzero/tzero_promo.py
CHANGED
|
@@ -209,7 +209,7 @@ SECRET_RULES: List[SecretRule] = [
|
|
|
209
209
|
rule_id="SEC-CRYPTO-001",
|
|
210
210
|
provider="PKI",
|
|
211
211
|
description="Private Key Block or Header (RSA, EC, OPENSSH, DSA, PGP)",
|
|
212
|
-
pattern=re.compile(r"-----BEGIN (?:[A-Z0-9 ]
|
|
212
|
+
pattern=re.compile(r"-----BEGIN (?:[A-Z0-9 ]{1,32} )?PRIVATE KEY-----"),
|
|
213
213
|
mask_tag="[ZERO_LEAK_MASKED_PRIVATE_KEY]"
|
|
214
214
|
),
|
|
215
215
|
SecretRule(
|
|
@@ -265,10 +265,38 @@ class ZeroLeakEngine:
|
|
|
265
265
|
|
|
266
266
|
MIN_ENTROPY_THRESHOLD: float = 4.75
|
|
267
267
|
MIN_ENTROPY_LENGTH: int = 28
|
|
268
|
-
_PEM_BEGIN_RE = re.compile(r"-----BEGIN (?:[A-Z0-9 ]
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
_PEM_BEGIN_RE = re.compile(r"-----BEGIN (?:[A-Z0-9 ]{1,32} )?PRIVATE KEY-----")
|
|
269
|
+
_PEM_END_RE = re.compile(r"-----END (?:[A-Z0-9 ]{1,32} )?PRIVATE KEY-----")
|
|
270
|
+
|
|
271
|
+
@classmethod
|
|
272
|
+
def _iter_pem_block_spans(cls, text: str) -> List[Tuple[int, int]]:
|
|
273
|
+
"""Linearly locates complete PEM BEGIN..END block byte spans without polynomial regex backtracking."""
|
|
274
|
+
spans: List[Tuple[int, int]] = []
|
|
275
|
+
pos = 0
|
|
276
|
+
for begin_match in cls._PEM_BEGIN_RE.finditer(text):
|
|
277
|
+
if begin_match.start() < pos:
|
|
278
|
+
continue
|
|
279
|
+
end_match = cls._PEM_END_RE.search(text, begin_match.end())
|
|
280
|
+
if not end_match:
|
|
281
|
+
break
|
|
282
|
+
spans.append((begin_match.start(), end_match.end()))
|
|
283
|
+
pos = end_match.end()
|
|
284
|
+
return spans
|
|
285
|
+
|
|
286
|
+
@classmethod
|
|
287
|
+
def _mask_pem_blocks(cls, text: str, replacement: str = "[ZERO_LEAK_MASKED_PRIVATE_KEY]") -> str:
|
|
288
|
+
"""Replaces complete PEM BEGIN..END blocks linearly cleanly."""
|
|
289
|
+
spans = cls._iter_pem_block_spans(text)
|
|
290
|
+
if not spans:
|
|
291
|
+
return text
|
|
292
|
+
chunks: List[str] = []
|
|
293
|
+
last = 0
|
|
294
|
+
for s, e in spans:
|
|
295
|
+
chunks.append(text[last:s])
|
|
296
|
+
chunks.append(replacement)
|
|
297
|
+
last = e
|
|
298
|
+
chunks.append(text[last:])
|
|
299
|
+
return "".join(chunks)
|
|
272
300
|
|
|
273
301
|
@classmethod
|
|
274
302
|
def is_placeholder(cls, s: str) -> bool:
|
|
@@ -304,9 +332,10 @@ class ZeroLeakEngine:
|
|
|
304
332
|
|
|
305
333
|
# Pre-compute line numbers covered by complete multi-line PEM blocks
|
|
306
334
|
pem_ranges: List[Tuple[int, int]] = []
|
|
307
|
-
for
|
|
308
|
-
|
|
309
|
-
|
|
335
|
+
for s_pos, e_pos in cls._iter_pem_block_spans(text):
|
|
336
|
+
block_txt = text[s_pos:e_pos]
|
|
337
|
+
start_line = text[:s_pos].count("\n") + 1
|
|
338
|
+
end_line = text[:e_pos].count("\n") + 1
|
|
310
339
|
pem_ranges.append((start_line, end_line))
|
|
311
340
|
findings.append(SecretFinding(
|
|
312
341
|
rule_id="SEC-CRYPTO-001",
|
|
@@ -315,9 +344,9 @@ class ZeroLeakEngine:
|
|
|
315
344
|
severity="CRITICAL",
|
|
316
345
|
line_no=start_line,
|
|
317
346
|
preview="[ZERO_LEAK_MASKED_PRIVATE_KEY]",
|
|
318
|
-
entropy=round(calculate_shannon_entropy(
|
|
347
|
+
entropy=round(calculate_shannon_entropy(block_txt), 2),
|
|
319
348
|
is_entropy_anomaly=False,
|
|
320
|
-
secret_value=
|
|
349
|
+
secret_value=block_txt,
|
|
321
350
|
))
|
|
322
351
|
|
|
323
352
|
def _in_pem_block(ln: int) -> bool:
|
|
@@ -426,7 +455,7 @@ class ZeroLeakEngine:
|
|
|
426
455
|
if not text:
|
|
427
456
|
return ""
|
|
428
457
|
|
|
429
|
-
sanitized = cls.
|
|
458
|
+
sanitized = cls._mask_pem_blocks(text, "[ZERO_LEAK_MASKED_PRIVATE_KEY]")
|
|
430
459
|
|
|
431
460
|
if cls._PEM_BEGIN_RE.search(sanitized):
|
|
432
461
|
if not allow_incomplete_pem:
|
|
@@ -75,7 +75,7 @@ class TaskEvaluationResult:
|
|
|
75
75
|
|
|
76
76
|
@dataclass
|
|
77
77
|
class TaskBenchmarkReport:
|
|
78
|
-
version: str = "12.
|
|
78
|
+
version: str = "12.3.2"
|
|
79
79
|
tokenizer: str = "tiktoken (cl100k_base)" if TIKTOKEN_AVAILABLE else "character-ratio fallback"
|
|
80
80
|
total_tasks: int = 0
|
|
81
81
|
passed_tasks: int = 0
|
|
@@ -465,7 +465,7 @@ def analyze_symbol_impact(symbol_path: str, table: SymbolTable, dag: CallGraphDA
|
|
|
465
465
|
"""Formats ANSI-styled benchmark summary table."""
|
|
466
466
|
lines = []
|
|
467
467
|
lines.append("=" * 78)
|
|
468
|
-
lines.append(" T-ZERO TASK-COMPLETION & BPE TOKENIZER BENCHMARK REPORT (v12.
|
|
468
|
+
lines.append(" T-ZERO TASK-COMPLETION & BPE TOKENIZER BENCHMARK REPORT (v12.3.2)")
|
|
469
469
|
lines.append(f" Tokenizer: {report.tokenizer} | Tasks Evaluated: {report.total_tasks}")
|
|
470
470
|
lines.append("=" * 78)
|
|
471
471
|
lines.append(f"{'Task ID':<10} | {'Raw BPE':<8} | {'T-Zero':<8} | {'Saved %':<8} | {'Contract %':<10} | {'Status'}")
|
|
@@ -18,7 +18,7 @@ import webbrowser
|
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from typing import Any, Dict, List, Optional, Tuple
|
|
20
20
|
|
|
21
|
-
CURRENT_VERSION = "12.
|
|
21
|
+
CURRENT_VERSION = "12.3.2"
|
|
22
22
|
REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
|
|
23
23
|
RELEASES_URL = f"{REPO_URL}/releases"
|
|
24
24
|
PYPI_URL = "https://pypi.org/project/tzero-mcp/"
|