tzero-mcp 12.2.0 → 12.2.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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/addmcp.py +10 -5
- package/src/app.py +3 -9
- package/src/tzero/__init__.py +1 -1
- package/src/tzero/anti_rea/asar_shield.py +3 -1
- package/src/tzero/anti_rea/auditor.py +42 -12
- package/src/tzero/anti_rea/canary_beacon.py +27 -19
- package/src/tzero/anti_rea/cli.py +7 -1
- package/src/tzero/anti_rea/confusables.py +62 -18
- package/src/tzero/anti_rea/engine.py +79 -10
- package/src/tzero/anti_rea/extractor_shield.py +52 -9
- package/src/tzero/anti_rea/gui.py +1 -4
- package/src/tzero/anti_rea/integrity_guard.py +17 -5
- package/src/tzero/anti_rea/rdtsc_guard.py +21 -8
- package/src/tzero/anti_rea/string_vault.py +10 -7
- package/src/tzero/siber_akademi.ico +0 -0
- package/src/tzero/siber_akademi_icon.py +14 -8
- package/src/tzero/tzero_armor.py +27 -5
- package/src/tzero/tzero_benchmark.py +4 -2
- package/src/tzero/tzero_budget.py +14 -5
- package/src/tzero/tzero_ci.py +1 -1
- package/src/tzero/tzero_contracts.py +7 -5
- package/src/tzero/tzero_dashboard.py +28 -9
- package/src/tzero/tzero_debt.py +19 -4
- package/src/tzero/tzero_explain.py +1 -1
- package/src/tzero/tzero_features.py +43 -29
- package/src/tzero/tzero_federation.py +9 -2
- package/src/tzero/tzero_fixer/mcp_server.py +10 -0
- package/src/tzero/tzero_golden.py +37 -9
- package/src/tzero/tzero_growth.py +166 -8
- package/src/tzero/tzero_guard.py +147 -46
- package/src/tzero/tzero_lsp.py +1 -1
- package/src/tzero/tzero_mcp.py +64 -16
- package/src/tzero/tzero_mutation.py +88 -15
- package/src/tzero/tzero_promo.py +1 -1
- package/src/tzero/tzero_proxy.py +105 -12
- package/src/tzero/tzero_scip.py +12 -6
- package/src/tzero/tzero_security.py +375 -60
- package/src/tzero/tzero_task_benchmark.py +2 -2
- package/src/tzero/tzero_traffic.py +35 -10
- package/src/tzero/tzero_tui.py +17 -8
- package/src/tzero/tzero_v3.py +268 -88
- package/src/tzero/tzero_welcome.py +65 -30
package/src/tzero/tzero_v3.py
CHANGED
|
@@ -493,7 +493,7 @@ def calculate_token_cost(token_count: int, provider_name: str) -> float:
|
|
|
493
493
|
# i18n Translations
|
|
494
494
|
TRANSLATIONS: Dict[str, Dict[str, str]] = {
|
|
495
495
|
"en": {
|
|
496
|
-
"title": "T-Zero Developer Console & Context Architect v12.2.
|
|
496
|
+
"title": "T-Zero Developer Console & Context Architect v12.2.2",
|
|
497
497
|
"subtitle": f"Developer: {DEV_NAME} | {DEV_URL_MAIN} | {DEV_URL_BIO}",
|
|
498
498
|
"overview_tab": "🏠 Overview Dashboard",
|
|
499
499
|
"setup_tab": "⚡ Setup & AI Models",
|
|
@@ -530,7 +530,7 @@ TRANSLATIONS: Dict[str, Dict[str, str]] = {
|
|
|
530
530
|
"audit_btn": "🛡️ SECURITY AUDIT"
|
|
531
531
|
},
|
|
532
532
|
"tr": {
|
|
533
|
-
"title": "T-Zero Geliştirici Konsolu & Bağlam Mimarı v12.2.
|
|
533
|
+
"title": "T-Zero Geliştirici Konsolu & Bağlam Mimarı v12.2.2",
|
|
534
534
|
"subtitle": f"Geliştirici: {DEV_NAME} | {DEV_URL_MAIN} | {DEV_URL_BIO}",
|
|
535
535
|
"overview_tab": "🏠 Genel Bakış",
|
|
536
536
|
"setup_tab": "⚡ Kurulum & Model",
|
|
@@ -2050,7 +2050,56 @@ class KeyringSecretsBackupManager:
|
|
|
2050
2050
|
return False
|
|
2051
2051
|
|
|
2052
2052
|
@classmethod
|
|
2053
|
-
def
|
|
2053
|
+
def _validate_credential_map(cls, creds: Any) -> Optional[Dict[str, str]]:
|
|
2054
|
+
"""Validate backup credential schema strictly before touching OS keyring."""
|
|
2055
|
+
if not isinstance(creds, dict) or not creds:
|
|
2056
|
+
return None
|
|
2057
|
+
known_providers = set(globals().get("AI_PROVIDERS", {}).keys()) | {
|
|
2058
|
+
"OpenAI", "Anthropic", "NVIDIA NIM", "Google Gemini", "OpenRouter",
|
|
2059
|
+
"Groq", "DeepSeek", "HuggingFace", "GitHub", "Ollama",
|
|
2060
|
+
}
|
|
2061
|
+
validated: Dict[str, str] = {}
|
|
2062
|
+
for provider, secret in creds.items():
|
|
2063
|
+
if not isinstance(provider, str) or not isinstance(secret, str):
|
|
2064
|
+
return None
|
|
2065
|
+
p_clean = provider.strip()
|
|
2066
|
+
if not p_clean or len(p_clean) > 64 or any(ord(c) < 32 for c in p_clean):
|
|
2067
|
+
return None
|
|
2068
|
+
if p_clean not in known_providers and not re.fullmatch(r"[A-Za-z0-9 _.\-]{2,48}", p_clean):
|
|
2069
|
+
return None
|
|
2070
|
+
if not secret or len(secret) > 4096:
|
|
2071
|
+
return None
|
|
2072
|
+
validated[p_clean] = secret
|
|
2073
|
+
return validated
|
|
2074
|
+
|
|
2075
|
+
@classmethod
|
|
2076
|
+
def import_legacy_credentials(cls, filepath: str, cipher_key: str) -> bool:
|
|
2077
|
+
"""Import a legacy unauthenticated XOR backup after strict schema validation."""
|
|
2078
|
+
try:
|
|
2079
|
+
with open(filepath, "rb") as f:
|
|
2080
|
+
data = f.read()
|
|
2081
|
+
if not data or data.startswith(cls.MAGIC_HEADER):
|
|
2082
|
+
return False
|
|
2083
|
+
encrypted = bytearray(data)
|
|
2084
|
+
key_bytes = cipher_key.encode("utf-8")
|
|
2085
|
+
if key_bytes:
|
|
2086
|
+
for i in range(len(encrypted)):
|
|
2087
|
+
encrypted[i] ^= key_bytes[i % len(key_bytes)]
|
|
2088
|
+
raw_obj = json.loads(encrypted.decode("utf-8"))
|
|
2089
|
+
validated = cls._validate_credential_map(raw_obj)
|
|
2090
|
+
if not validated:
|
|
2091
|
+
logger.error("Legacy backup rejected: invalid provider/credential schema")
|
|
2092
|
+
return False
|
|
2093
|
+
logger.warning("Imported legacy unauthenticated backup; please re-export to modern HMAC TZB2 format.")
|
|
2094
|
+
for provider, secret in validated.items():
|
|
2095
|
+
keyring.set_password(SERVICE_NAME, provider, secret)
|
|
2096
|
+
return True
|
|
2097
|
+
except Exception as e:
|
|
2098
|
+
logger.error(f"Legacy backup import failed: {e}")
|
|
2099
|
+
return False
|
|
2100
|
+
|
|
2101
|
+
@classmethod
|
|
2102
|
+
def restore_credentials(cls, filepath: str, cipher_key: str, allow_legacy: bool = True) -> bool:
|
|
2054
2103
|
try:
|
|
2055
2104
|
import hashlib
|
|
2056
2105
|
import hmac
|
|
@@ -2068,19 +2117,18 @@ class KeyringSecretsBackupManager:
|
|
|
2068
2117
|
return False
|
|
2069
2118
|
kstream = cls._keystream(enc_key, len(cipher_bytes))
|
|
2070
2119
|
raw_data = bytes([b ^ k for b, k in zip(cipher_bytes, kstream)])
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
return True
|
|
2120
|
+
validated = cls._validate_credential_map(json.loads(raw_data.decode("utf-8")))
|
|
2121
|
+
if not validated:
|
|
2122
|
+
logger.error("Backup payload failed schema validation")
|
|
2123
|
+
return False
|
|
2124
|
+
for provider, secret in validated.items():
|
|
2125
|
+
keyring.set_password(SERVICE_NAME, provider, secret)
|
|
2126
|
+
return True
|
|
2127
|
+
|
|
2128
|
+
if allow_legacy:
|
|
2129
|
+
return cls.import_legacy_credentials(filepath, cipher_key)
|
|
2130
|
+
logger.error("Rejected unauthenticated legacy backup (allow_legacy=False)")
|
|
2131
|
+
return False
|
|
2084
2132
|
except Exception as e:
|
|
2085
2133
|
logger.error(f"Restore keyring credentials failed: {e}")
|
|
2086
2134
|
return False
|
|
@@ -3495,7 +3543,6 @@ class MonthlyStackedBarCard(LuxuryCard):
|
|
|
3495
3543
|
|
|
3496
3544
|
def _draw(self, event=None):
|
|
3497
3545
|
w = max(20, self.c.winfo_width())
|
|
3498
|
-
h = max(20, self.c.winfo_height())
|
|
3499
3546
|
self.c.delete("all")
|
|
3500
3547
|
months = ["EKI", "KAS", "ARA", "OCA"]
|
|
3501
3548
|
ratios = [0.75, 0.55, 0.85, 0.65]
|
|
@@ -4017,7 +4064,6 @@ class NodeGraphCanvas(tk.Canvas):
|
|
|
4017
4064
|
h = max(380, self.winfo_height())
|
|
4018
4065
|
|
|
4019
4066
|
card_bg = PALETTE.get("card_bg", "#0f172a")
|
|
4020
|
-
card_border = PALETTE.get("card_border", "#1e293b")
|
|
4021
4067
|
text_main = PALETTE.get("text_main", "#f8fafc")
|
|
4022
4068
|
text_muted = PALETTE.get("text_muted", "#64748b")
|
|
4023
4069
|
accent_cyan = PALETTE.get("accent_cyan", "#38bdf8")
|
|
@@ -4593,8 +4639,8 @@ class AutoReadmeGUI:
|
|
|
4593
4639
|
if siber_akademi_icon:
|
|
4594
4640
|
try:
|
|
4595
4641
|
siber_akademi_icon.apply_window_icon(self.root)
|
|
4596
|
-
self.logo_img = siber_akademi_icon.get_logo_photo_image((36, 36))
|
|
4597
|
-
self.logo_sm = siber_akademi_icon.get_logo_photo_image((
|
|
4642
|
+
self.logo_img = siber_akademi_icon.get_logo_photo_image((36, 36), circle=True)
|
|
4643
|
+
self.logo_sm = siber_akademi_icon.get_logo_photo_image((38, 38), circle=True)
|
|
4598
4644
|
except Exception:
|
|
4599
4645
|
pass
|
|
4600
4646
|
if not self.logo_img:
|
|
@@ -4606,6 +4652,21 @@ class AutoReadmeGUI:
|
|
|
4606
4652
|
except Exception:
|
|
4607
4653
|
pass
|
|
4608
4654
|
|
|
4655
|
+
try:
|
|
4656
|
+
from tzero.tzero_growth import get_cached_community_stats
|
|
4657
|
+
self.community_stats = get_cached_community_stats()
|
|
4658
|
+
except Exception:
|
|
4659
|
+
self.community_stats = {
|
|
4660
|
+
"stars": 111,
|
|
4661
|
+
"target_stars": 250,
|
|
4662
|
+
"progress_pct": 44.4,
|
|
4663
|
+
"downloads": 22900,
|
|
4664
|
+
"downloads_label": "22,900+",
|
|
4665
|
+
"saved_tokens_label": "1,120,000+",
|
|
4666
|
+
"source": "fallback",
|
|
4667
|
+
}
|
|
4668
|
+
self._star_dialog_widgets = {}
|
|
4669
|
+
|
|
4609
4670
|
saved_theme = _config_mgr.get_profile().get("theme", "Slate 950 (Linear Standard)")
|
|
4610
4671
|
if saved_theme in THEME_PALETTES:
|
|
4611
4672
|
update_colors(saved_theme)
|
|
@@ -4619,6 +4680,7 @@ class AutoReadmeGUI:
|
|
|
4619
4680
|
self.load_saved_credentials()
|
|
4620
4681
|
self.setup_keyboard_shortcuts()
|
|
4621
4682
|
self.start_system_telemetry()
|
|
4683
|
+
self.start_community_stats_refresh()
|
|
4622
4684
|
self.safe_after(1200, self.check_and_show_star_welcome_popup)
|
|
4623
4685
|
|
|
4624
4686
|
def safe_after(self, ms: int, func, *args):
|
|
@@ -4641,7 +4703,6 @@ class AutoReadmeGUI:
|
|
|
4641
4703
|
self.bg_canvas.pack(fill=tk.BOTH, expand=True)
|
|
4642
4704
|
|
|
4643
4705
|
sidebar_bg = PALETTE.get("sidebar_bg", "#3843a0")
|
|
4644
|
-
sidebar_fg = PALETTE.get("sidebar_fg", "#ffffff")
|
|
4645
4706
|
sidebar_muted = PALETTE.get("sidebar_muted", "#a5b4fc")
|
|
4646
4707
|
sidebar_hover = PALETTE.get("sidebar_hover", "#4a55ab")
|
|
4647
4708
|
sidebar_active = PALETTE.get("sidebar_active", "#2b3478")
|
|
@@ -4650,10 +4711,10 @@ class AutoReadmeGUI:
|
|
|
4650
4711
|
self.sidebar = GlassCard(self.bg_canvas, bg=sidebar_bg, highlightbackground=sidebar_bg)
|
|
4651
4712
|
self.sidebar.place(x=8, y=8, width=66, relheight=0.98)
|
|
4652
4713
|
|
|
4653
|
-
# Top
|
|
4714
|
+
# Top Siber Akademi Logo Badge
|
|
4654
4715
|
avatar_canvas = tk.Canvas(self.sidebar, width=44, height=44, bg=sidebar_bg, highlightthickness=0)
|
|
4655
4716
|
avatar_canvas.pack(pady=(12, 14))
|
|
4656
|
-
avatar_canvas.create_oval(2, 2, 42, 42, fill=PALETTE.get("
|
|
4717
|
+
avatar_canvas.create_oval(2, 2, 42, 42, fill="#181c24", outline=PALETTE.get("accent_cyan", "#38bdf8"), width=2)
|
|
4657
4718
|
if self.logo_sm:
|
|
4658
4719
|
avatar_canvas.create_image(22, 22, image=self.logo_sm)
|
|
4659
4720
|
else:
|
|
@@ -4804,14 +4865,14 @@ class AutoReadmeGUI:
|
|
|
4804
4865
|
|
|
4805
4866
|
self.star_header_btn = CanvasPillButton(
|
|
4806
4867
|
header_controls,
|
|
4807
|
-
text="★ STAR (
|
|
4868
|
+
text=f"★ STAR ({self.community_stats['stars']}★)",
|
|
4808
4869
|
command=self.open_star_action,
|
|
4809
4870
|
height=28,
|
|
4810
4871
|
radius=14,
|
|
4811
4872
|
bg_color=PALETTE.get("warning", "#eab308"),
|
|
4812
4873
|
text_color="#000000",
|
|
4813
4874
|
font=("Segoe UI", 7, "bold"),
|
|
4814
|
-
width=
|
|
4875
|
+
width=114
|
|
4815
4876
|
)
|
|
4816
4877
|
self.star_header_btn.pack(side=tk.LEFT, padx=3)
|
|
4817
4878
|
|
|
@@ -6138,7 +6199,6 @@ class AutoReadmeGUI:
|
|
|
6138
6199
|
self.sync_git_commits()
|
|
6139
6200
|
|
|
6140
6201
|
def load_saved_credentials(self):
|
|
6141
|
-
pname = self.provider_var.get()
|
|
6142
6202
|
self.on_provider_select()
|
|
6143
6203
|
executable_dir = os.path.dirname(sys.executable) if getattr(sys, "frozen", False) else None
|
|
6144
6204
|
if not self.dir_entry.get().strip():
|
|
@@ -6184,7 +6244,7 @@ class AutoReadmeGUI:
|
|
|
6184
6244
|
CRYPTO_BTC = "bc1q9k4hvd6c2g8l9w3z7v8f2k3j5l8n9m1p4q7r0s"
|
|
6185
6245
|
REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
|
|
6186
6246
|
BIO_URL = "https://hopp.bio/siberegitim"
|
|
6187
|
-
|
|
6247
|
+
from tzero import __version__ as CURRENT_VERSION
|
|
6188
6248
|
|
|
6189
6249
|
dialog = tk.Toplevel(self.root)
|
|
6190
6250
|
dialog.title(f"T-Zero v{CURRENT_VERSION} — Destek & Sürüm Merkezi")
|
|
@@ -6277,7 +6337,7 @@ class AutoReadmeGUI:
|
|
|
6277
6337
|
from tzero.tzero_traffic import REPO_URL, CURRENT_VERSION
|
|
6278
6338
|
except Exception:
|
|
6279
6339
|
REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
|
|
6280
|
-
|
|
6340
|
+
from tzero import __version__ as CURRENT_VERSION
|
|
6281
6341
|
|
|
6282
6342
|
# On first launch, automatically open the GitHub repo in browser and ask to star!
|
|
6283
6343
|
first_launch = not profile.get("first_launch_repo_opened_v12", False)
|
|
@@ -6289,8 +6349,21 @@ class AutoReadmeGUI:
|
|
|
6289
6349
|
except Exception:
|
|
6290
6350
|
pass
|
|
6291
6351
|
|
|
6352
|
+
stats = dict(getattr(self, "community_stats", {}) or {})
|
|
6353
|
+
stars = int(stats.get("stars", 111))
|
|
6354
|
+
target_stars = int(stats.get("target_stars", 250))
|
|
6355
|
+
pct_ratio = max(0.05, min(1.0, stars / max(1, target_stars)))
|
|
6356
|
+
pct_int = int(round(pct_ratio * 100))
|
|
6357
|
+
dl_label = str(stats.get("downloads_label", "22,900+"))
|
|
6358
|
+
saved_label = str(stats.get("saved_tokens_label", "1,120,000+"))
|
|
6359
|
+
|
|
6292
6360
|
dialog = tk.Toplevel(self.root)
|
|
6293
|
-
|
|
6361
|
+
if siber_akademi_icon:
|
|
6362
|
+
try:
|
|
6363
|
+
siber_akademi_icon.apply_window_icon(dialog)
|
|
6364
|
+
except Exception:
|
|
6365
|
+
pass
|
|
6366
|
+
dialog_title = f"⭐ T-Zero v{CURRENT_VERSION} — Lütfen Star Verin!" if first_launch else f"⭐ T-Zero v{CURRENT_VERSION} — {target_stars} Yıldız Hedefi!"
|
|
6294
6367
|
dialog.title(dialog_title)
|
|
6295
6368
|
dialog.geometry("560x430")
|
|
6296
6369
|
dialog.configure(bg=PALETTE["bg_start"])
|
|
@@ -6306,61 +6379,75 @@ class AutoReadmeGUI:
|
|
|
6306
6379
|
header_text = (
|
|
6307
6380
|
"🚀 TARAYICINIZDA GITHUB AÇILDI: LÜTFEN STAR VERİN! ⭐"
|
|
6308
6381
|
if first_launch
|
|
6309
|
-
else "⭐
|
|
6382
|
+
else f"⭐ {target_stars} YILDIZ HEDEFİ: TOPLULUĞA KATILIN!"
|
|
6310
6383
|
)
|
|
6311
|
-
tk.Label(
|
|
6384
|
+
hdr_lbl = tk.Label(
|
|
6312
6385
|
h_frame,
|
|
6313
6386
|
text=header_text,
|
|
6314
6387
|
font=("Segoe UI", 12, "bold"),
|
|
6315
6388
|
fg=PALETTE.get("warning", "#fbbf24"),
|
|
6316
6389
|
bg=PALETTE["bg_start"]
|
|
6317
|
-
)
|
|
6390
|
+
)
|
|
6391
|
+
hdr_lbl.pack(side=tk.LEFT)
|
|
6318
6392
|
|
|
6319
6393
|
# Stats Badge
|
|
6320
6394
|
stats_frame = tk.Frame(pad, bg=PALETTE["card_bg"], highlightthickness=1, highlightbackground=PALETTE["card_border"], padx=14, pady=10)
|
|
6321
6395
|
stats_frame.pack(fill=tk.X, pady=(0, 12))
|
|
6322
|
-
tk.Label(
|
|
6396
|
+
stats_lbl = tk.Label(
|
|
6323
6397
|
stats_frame,
|
|
6324
|
-
text="🚀
|
|
6398
|
+
text=f"🚀 {dl_label} İndirme (PyPI & npm) | ⚡ {saved_label} Kurtarılan Token\n⭐ Mevcut Yıldız: {stars} / {target_stars} Hedef (İlerleme: %{pct_int})",
|
|
6325
6399
|
font=("Segoe UI", 9, "bold"),
|
|
6326
6400
|
fg=PALETTE.get("accent_cyan", "#38bdf8"),
|
|
6327
6401
|
bg=PALETTE["card_bg"],
|
|
6328
6402
|
justify=tk.CENTER
|
|
6329
|
-
)
|
|
6403
|
+
)
|
|
6404
|
+
stats_lbl.pack()
|
|
6330
6405
|
|
|
6331
6406
|
# Visual Progress Bar
|
|
6332
6407
|
bar_container = tk.Frame(pad, bg=PALETTE["card_border"], height=14)
|
|
6333
6408
|
bar_container.pack(fill=tk.X, pady=(0, 14))
|
|
6334
6409
|
bar_container.pack_propagate(False)
|
|
6335
|
-
bar_fill = tk.Frame(bar_container, bg=PALETTE.get("warning", "#fbbf24"), width=int(508 *
|
|
6336
|
-
bar_fill.place(x=0, y=0, relheight=1.0, relwidth=
|
|
6410
|
+
bar_fill = tk.Frame(bar_container, bg=PALETTE.get("warning", "#fbbf24"), width=int(508 * pct_ratio), height=14)
|
|
6411
|
+
bar_fill.place(x=0, y=0, relheight=1.0, relwidth=pct_ratio)
|
|
6337
6412
|
|
|
6338
6413
|
# Message
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6414
|
+
def _build_star_msg(cur_s: int, tgt_s: int) -> str:
|
|
6415
|
+
if first_launch:
|
|
6416
|
+
return (
|
|
6417
|
+
"Merhaba! Ben Toprak Ahmet Aydoğmuş (Siber Akademi).\n"
|
|
6418
|
+
"T-Zero'yu başlattığınız için GitHub depomuz tarayıcınızda açıldı!\n\n"
|
|
6419
|
+
"Projemizin bağımsız kalabilmesi ve herkese %100 BEDAVA sunulabilmesi için\n"
|
|
6420
|
+
"lütfen açılan GitHub sayfasında sağ üstteki ★ STAR butonuna tıklayarak\n"
|
|
6421
|
+
f"projemize destek olun! ⭐ ({tgt_s} Yıldız Hedefi: {cur_s}/{tgt_s})\n\n"
|
|
6422
|
+
"Yıldızınız projemizin büyümesi ve daha fazla geliştiriciye ulaşması için çok değerli!"
|
|
6423
|
+
)
|
|
6424
|
+
return (
|
|
6350
6425
|
"Merhaba! Ben Toprak Ahmet Aydoğmuş (Siber Akademi).\n"
|
|
6351
6426
|
"T-Zero'yu yapay zeka araçlarındaki token maliyetini ve context israfını\n"
|
|
6352
6427
|
"önlemek için sıfırdan geliştirdim ve herkese %100 BEDAVA sunuyorum.\n\n"
|
|
6353
6428
|
"Projemizin bağımsız kalabilmesi ve daha fazla geliştiriciye ulaşabilmesi için\n"
|
|
6354
6429
|
"GitHub depomuza vereceğiniz TEK BİR YILDIZ çok büyük bir fark yaratıyor!"
|
|
6355
6430
|
)
|
|
6356
|
-
|
|
6431
|
+
|
|
6432
|
+
msg = _build_star_msg(stars, target_stars)
|
|
6433
|
+
msg_lbl = tk.Label(
|
|
6357
6434
|
pad,
|
|
6358
6435
|
text=msg,
|
|
6359
6436
|
font=("Segoe UI", 9),
|
|
6360
6437
|
fg=PALETTE["text_main"],
|
|
6361
6438
|
bg=PALETTE["bg_start"],
|
|
6362
6439
|
justify=tk.LEFT
|
|
6363
|
-
)
|
|
6440
|
+
)
|
|
6441
|
+
msg_lbl.pack(anchor=tk.W, pady=(0, 16))
|
|
6442
|
+
self._star_dialog_widgets = {
|
|
6443
|
+
"dialog": dialog,
|
|
6444
|
+
"hdr_lbl": hdr_lbl,
|
|
6445
|
+
"stats_lbl": stats_lbl,
|
|
6446
|
+
"bar_fill": bar_fill,
|
|
6447
|
+
"msg_lbl": msg_lbl,
|
|
6448
|
+
"first_launch": first_launch,
|
|
6449
|
+
"build_msg": _build_star_msg,
|
|
6450
|
+
}
|
|
6364
6451
|
|
|
6365
6452
|
# Star Action Button (Big Golden Button)
|
|
6366
6453
|
def on_star_click():
|
|
@@ -8273,7 +8360,7 @@ Custom Requirements:
|
|
|
8273
8360
|
else:
|
|
8274
8361
|
args = ", ".join(item["args"])
|
|
8275
8362
|
self.ast_tree.insert(file_node, "end", text=f"⚙ def {item['name']}({args})")
|
|
8276
|
-
except Exception
|
|
8363
|
+
except Exception:
|
|
8277
8364
|
# Fallback to simple label
|
|
8278
8365
|
file_node = self.ast_tree.insert("", "end", text=f"📄 {os.path.basename(filepath)} (AST Fail)")
|
|
8279
8366
|
|
|
@@ -8289,6 +8376,49 @@ Custom Requirements:
|
|
|
8289
8376
|
break
|
|
8290
8377
|
threading.Thread(target=telemetry, daemon=True).start()
|
|
8291
8378
|
|
|
8379
|
+
def _apply_live_community_stats(self, stats: Dict[str, Any]):
|
|
8380
|
+
"""Apply live GitHub star and registry download counts to header & open dialog."""
|
|
8381
|
+
if not stats:
|
|
8382
|
+
return
|
|
8383
|
+
self.community_stats = stats
|
|
8384
|
+
stars = int(stats.get("stars", 111))
|
|
8385
|
+
target_stars = int(stats.get("target_stars", 250))
|
|
8386
|
+
pct_ratio = max(0.05, min(1.0, stars / max(1, target_stars)))
|
|
8387
|
+
pct_int = int(round(pct_ratio * 100))
|
|
8388
|
+
dl_label = str(stats.get("downloads_label", "22,900+"))
|
|
8389
|
+
saved_label = str(stats.get("saved_tokens_label", "1,120,000+"))
|
|
8390
|
+
|
|
8391
|
+
try:
|
|
8392
|
+
if hasattr(self, "star_header_btn") and self.star_header_btn.winfo_exists():
|
|
8393
|
+
self.star_header_btn.set_text(f"★ STAR ({stars}★)")
|
|
8394
|
+
except Exception:
|
|
8395
|
+
pass
|
|
8396
|
+
|
|
8397
|
+
w = getattr(self, "_star_dialog_widgets", {}) or {}
|
|
8398
|
+
dlg = w.get("dialog")
|
|
8399
|
+
try:
|
|
8400
|
+
if dlg and dlg.winfo_exists():
|
|
8401
|
+
if not w.get("first_launch"):
|
|
8402
|
+
w["hdr_lbl"].config(text=f"⭐ {target_stars} YILDIZ HEDEFİ: TOPLULUĞA KATILIN!")
|
|
8403
|
+
w["stats_lbl"].config(
|
|
8404
|
+
text=f"🚀 {dl_label} İndirme (PyPI & npm) | ⚡ {saved_label} Kurtarılan Token\n⭐ Mevcut Yıldız: {stars} / {target_stars} Hedef (İlerleme: %{pct_int})"
|
|
8405
|
+
)
|
|
8406
|
+
w["bar_fill"].place_configure(relwidth=pct_ratio)
|
|
8407
|
+
w["msg_lbl"].config(text=w["build_msg"](stars, target_stars))
|
|
8408
|
+
except Exception:
|
|
8409
|
+
pass
|
|
8410
|
+
|
|
8411
|
+
def start_community_stats_refresh(self):
|
|
8412
|
+
"""Fetch live GitHub star count and download stats asynchronously without blocking UI."""
|
|
8413
|
+
def _worker():
|
|
8414
|
+
try:
|
|
8415
|
+
from tzero.tzero_growth import get_live_community_stats
|
|
8416
|
+
stats = get_live_community_stats(timeout=3.0, force_refresh=True, include_downloads=True)
|
|
8417
|
+
self.safe_after(0, lambda s=stats: self._apply_live_community_stats(s))
|
|
8418
|
+
except Exception:
|
|
8419
|
+
pass
|
|
8420
|
+
threading.Thread(target=_worker, daemon=True).start()
|
|
8421
|
+
|
|
8292
8422
|
|
|
8293
8423
|
# --- 14. STARTUP ORCHESTRATION & CLI WIZARD ---
|
|
8294
8424
|
|
|
@@ -8377,7 +8507,7 @@ def launch_gui():
|
|
|
8377
8507
|
except Exception:
|
|
8378
8508
|
pass
|
|
8379
8509
|
|
|
8380
|
-
|
|
8510
|
+
AutoReadmeGUI(root)
|
|
8381
8511
|
root.mainloop()
|
|
8382
8512
|
|
|
8383
8513
|
|
|
@@ -8549,8 +8679,12 @@ def run_pr_report_cli(target_dir: str, base_ref: str = "HEAD~1"):
|
|
|
8549
8679
|
analyzer = ChangeImpactAnalyzer(target_dir)
|
|
8550
8680
|
impact_items = []
|
|
8551
8681
|
for f in modified_files:
|
|
8682
|
+
if len(impact_items) >= 10:
|
|
8683
|
+
break
|
|
8552
8684
|
symbols = analyzer.extract_symbols_from_file(f)
|
|
8553
8685
|
for s in symbols[:3]:
|
|
8686
|
+
if len(impact_items) >= 10:
|
|
8687
|
+
break
|
|
8554
8688
|
imp = analyzer.analyze_symbol(s)
|
|
8555
8689
|
impact_items.append((s, imp["score"], imp["dependents_count"], imp["risk_level"]))
|
|
8556
8690
|
|
|
@@ -8650,7 +8784,6 @@ def run_review_cli(target_dir: str = ".", ref: str = "auto") -> bool:
|
|
|
8650
8784
|
added_code_lines.append(content)
|
|
8651
8785
|
|
|
8652
8786
|
full_added_text = "\n".join(added_lines)
|
|
8653
|
-
full_added_code = "\n".join(added_code_lines)
|
|
8654
8787
|
|
|
8655
8788
|
sec_findings = ZeroLeakEngine.scan_text(full_added_text)
|
|
8656
8789
|
|
|
@@ -9298,9 +9431,25 @@ def main():
|
|
|
9298
9431
|
|
|
9299
9432
|
# Fast path for Anti-REA armor / protection
|
|
9300
9433
|
if len(sys.argv) > 1 and sys.argv[1].lower() in ("armor", "anti-rea", "--armor", "--anti-rea"):
|
|
9434
|
+
extra_args = sys.argv[2:]
|
|
9435
|
+
if any(flag in ("-h", "--help") for flag in extra_args):
|
|
9436
|
+
print("Usage: tzero armor [TARGET_PATH] [--audit]")
|
|
9437
|
+
print(" Protect source files against AI reverse engineering (26-Tier TDQS-REA Armor).")
|
|
9438
|
+
print(" --audit, -a Audit AI decompilation resistance without modifying files.")
|
|
9439
|
+
sys.exit(0)
|
|
9440
|
+
target_path = next((a for a in extra_args if not a.startswith("-")), ".")
|
|
9441
|
+
out_path = None
|
|
9442
|
+
for idx_a, a in enumerate(extra_args):
|
|
9443
|
+
if a in ("-o", "--output", "--out") and idx_a + 1 < len(extra_args):
|
|
9444
|
+
out_path = extra_args[idx_a + 1]
|
|
9445
|
+
break
|
|
9446
|
+
if any(flag in ("--audit", "-a") for flag in extra_args):
|
|
9447
|
+
from tzero.tzero_armor import audit_path_rea_resistance
|
|
9448
|
+
audit = audit_path_rea_resistance(target_path)
|
|
9449
|
+
print(json.dumps(audit, indent=2))
|
|
9450
|
+
sys.exit(0 if "error" not in audit else 1)
|
|
9301
9451
|
from tzero.tzero_armor import protect_path_with_armor
|
|
9302
|
-
|
|
9303
|
-
res = protect_path_with_armor(target_path)
|
|
9452
|
+
res = protect_path_with_armor(target_path, output_path=out_path)
|
|
9304
9453
|
if res.get("success"):
|
|
9305
9454
|
print(f"[OK] Applied Anti-REA Armor to: {target_path}")
|
|
9306
9455
|
if "score_after" in res:
|
|
@@ -9316,16 +9465,22 @@ def main():
|
|
|
9316
9465
|
from tzero.tzero_armor import audit_path_rea_resistance
|
|
9317
9466
|
target_path = sys.argv[2] if len(sys.argv) > 2 and not sys.argv[2].startswith("-") else "."
|
|
9318
9467
|
audit = audit_path_rea_resistance(target_path)
|
|
9468
|
+
if audit.get("error"):
|
|
9469
|
+
print(f"[ERROR] {audit['error']}", file=sys.stderr)
|
|
9470
|
+
sys.exit(1)
|
|
9319
9471
|
print("================================================================================")
|
|
9320
9472
|
print(" SHIELD AUDIT REPORT: AI REVERSE-ENGINEERING RESISTANCE (TDQS-REA)")
|
|
9321
9473
|
print("================================================================================")
|
|
9322
9474
|
print(f"Target: {target_path}")
|
|
9323
|
-
print(f"AI Score: {audit.get('score', 0)} / 100 [{audit.get('rating', '
|
|
9475
|
+
print(f"AI Score: {audit.get('score', 0)} / 100 [{audit.get('rating', 'UNVERIFIED')}]")
|
|
9476
|
+
print(f"Score Basis: {audit.get('score_kind', 'static_textual_indicator')}")
|
|
9324
9477
|
print(f"Status: {audit.get('status', 'N/A')}")
|
|
9325
9478
|
if audit.get("defenses_active"):
|
|
9326
9479
|
print("\nActive Defenses:")
|
|
9327
9480
|
for k, v in audit["defenses_active"].items():
|
|
9328
9481
|
print(f" [{'✔' if v else ' '}] {k}")
|
|
9482
|
+
if audit.get("unverified_layers"):
|
|
9483
|
+
print(f"\nUnverified Layers (not measured statically): {', '.join(audit['unverified_layers'])}")
|
|
9329
9484
|
recs = audit.get("sample_findings") or audit.get("findings", [])
|
|
9330
9485
|
if recs:
|
|
9331
9486
|
print("\nRecommendations:")
|
|
@@ -9351,6 +9506,18 @@ def main():
|
|
|
9351
9506
|
|
|
9352
9507
|
# Fast path for Anti-REA radar / gui
|
|
9353
9508
|
if len(sys.argv) > 1 and sys.argv[1].lower() in ("radar", "--radar", "anti-rea-gui"):
|
|
9509
|
+
radar_args = sys.argv[2:]
|
|
9510
|
+
if any(a in ("-h", "--help") for a in radar_args):
|
|
9511
|
+
print("Usage: tzero radar [PATH | --audit PATH | --armor PATH]\n"
|
|
9512
|
+
"Launch Anti-REA Radar GUI or run headless Anti-REA audit/armor on a target path.")
|
|
9513
|
+
sys.exit(0)
|
|
9514
|
+
if radar_args:
|
|
9515
|
+
from tzero.tzero_armor import audit_path_rea_resistance, protect_path_with_armor
|
|
9516
|
+
mode_armor = "--armor" in radar_args
|
|
9517
|
+
target = next((a for a in radar_args if not a.startswith("-")), ".")
|
|
9518
|
+
res = protect_path_with_armor(target) if mode_armor else audit_path_rea_resistance(target)
|
|
9519
|
+
print(json.dumps(res, indent=2))
|
|
9520
|
+
sys.exit(0 if res.get("success", True) else 1)
|
|
9354
9521
|
try:
|
|
9355
9522
|
from tzero.anti_rea.gui import main as gui_main
|
|
9356
9523
|
gui_main()
|
|
@@ -9378,6 +9545,7 @@ def main():
|
|
|
9378
9545
|
parser.add_argument("--cli", "-c", action="store_true", help="Run interactive guided terminal wizard")
|
|
9379
9546
|
parser.add_argument("--install-ide", "--install-mcp", nargs="?", const="all", default=None, metavar="CLIENT", dest="install_ide", help="1-Click MCP installer for Cursor, Claude, Windsurf, Antigravity, VS Code, etc. (e.g. --install-ide cursor, --install-ide all)")
|
|
9380
9547
|
parser.add_argument("--scan", "-s", nargs="?", const=".", default=None, metavar="DIR", help="Scan codebase directory and print summary metrics")
|
|
9548
|
+
parser.add_argument("--tree", "--context", nargs="?", const=".", default=None, metavar="DIR", dest="tree", help="Generate complete AST skeleton context tree offline")
|
|
9381
9549
|
parser.add_argument("--watch", "-w", nargs="?", const=".", default=None, metavar="DIR", help="Continuous background AST context watcher (auto-reindexes on file save for Cursor/Claude)")
|
|
9382
9550
|
parser.add_argument("--audit", "-a", nargs="?", const=".", default=None, metavar="DIR", help="Run AST static code analysis & audit for code smells")
|
|
9383
9551
|
parser.add_argument("--dry-run", "-d", action="store_true", help="Generate complete context tree offline without API call (100%% free)")
|
|
@@ -9386,7 +9554,7 @@ def main():
|
|
|
9386
9554
|
parser.add_argument("--export-repomap", nargs="?", const="REPO_MAP.txt", default=None, metavar="FILE", help="Generate compact token repository map (REPO_MAP.txt)")
|
|
9387
9555
|
parser.add_argument("--export-html", nargs="?", const="README.html", default=None, metavar="FILE", help="Generate styled dark-mode HTML architecture preview")
|
|
9388
9556
|
parser.add_argument("--dir", default=".", help="Target project workspace directory (default: current dir)")
|
|
9389
|
-
parser.add_argument("--output", "-o", default="README.md", help="Output filepath for generated markdown (default: README.md)")
|
|
9557
|
+
parser.add_argument("--output", "--out", "-o", default="README.md", dest="output", help="Output filepath for generated markdown (default: README.md)")
|
|
9390
9558
|
parser.add_argument("--force", action="store_true", help="Allow the guided context wizard to overwrite an existing output file")
|
|
9391
9559
|
parser.add_argument("--provider", "-p", choices=list(PROVIDERS.keys()), help="AI Provider to use (default: active profile)")
|
|
9392
9560
|
parser.add_argument("--impact", metavar="SYMBOL", help="Analyze blast radius and change impact for a symbol")
|
|
@@ -9433,7 +9601,7 @@ def main():
|
|
|
9433
9601
|
parser.add_argument("--fuzzy", action="store_true", default=True, help="Enable fuzzy AST and whitespace matching for patch application (default: True)")
|
|
9434
9602
|
parser.add_argument("--armor", "--anti-rea", nargs="?", const=".", default=None, metavar="PATH", dest="armor", help="Apply military-grade Anti-REA armor against AI reverse engineering (morluto/rea)")
|
|
9435
9603
|
parser.add_argument("--audit-rea", nargs="?", const=".", default=None, metavar="PATH", dest="audit_rea", help="Audit code or binary for resistance against AI reverse engineering (0-100)")
|
|
9436
|
-
parser.add_argument("--telemetry",
|
|
9604
|
+
parser.add_argument("--telemetry", nargs="?", const=".", default=None, metavar="DIR", help="Show offline SQLite token savings & ROI telemetry report")
|
|
9437
9605
|
parser.add_argument("--no-fuzzy", dest="fuzzy", action="store_false", help="Disable fuzzy matching and enforce exact line matches only")
|
|
9438
9606
|
parser.add_argument("--dry-run-patch", action="store_true", help="Validate patch applicability without modifying files on disk")
|
|
9439
9607
|
parser.add_argument("--reverse-patch", action="store_true", help="Un-apply / revert patch changes")
|
|
@@ -9453,7 +9621,7 @@ def main():
|
|
|
9453
9621
|
default="o200k_base", help="BPE encoding for --symbol-context")
|
|
9454
9622
|
parser.add_argument("--cache-aligned", action="store_true", help="Order context for KV-cache prefix stability (immutable static prefix before dynamic query suffix)")
|
|
9455
9623
|
parser.add_argument("--commit-msg", action="store_true", help="Generate Conventional Commit message from local AST git diff ($0 local engine)")
|
|
9456
|
-
parser.add_argument("--changelog", nargs="?", const="v12.2.
|
|
9624
|
+
parser.add_argument("--changelog", nargs="?", const="v12.2.2", default=None, metavar="VERSION", help="Generate release CHANGELOG markdown from git history")
|
|
9457
9625
|
parser.add_argument("--ci", choices=["github", "gitlab", "pre-commit", "local", "all"], default=None, help="Install CI/CD workflow or run local verification suite")
|
|
9458
9626
|
parser.add_argument("--local-ci", action="store_true", help="Run comprehensive Local CI & Pre-Push verification battery ($0 quota burn)")
|
|
9459
9627
|
parser.add_argument("--quick-ci", action="store_true", help="Run fast Local CI smoke checks in seconds")
|
|
@@ -9517,7 +9685,7 @@ def main():
|
|
|
9517
9685
|
parser.add_argument("--card", "--badge", nargs="?", const="assets/tzero_badge_card.svg", default=None, metavar="FILE", help="Generate viral dark-mode SVG banner card and GitHub README badges")
|
|
9518
9686
|
parser.add_argument("--showcase", nargs="?", const="tzero_showcase.html", default=None, metavar="FILE", help="Generate interactive split-screen HTML5 comparison showcase slider")
|
|
9519
9687
|
parser.add_argument("--marketing", "--growth", action="store_true", help="Launch $0-budget viral growth engine and export campaign materials for Reddit, HN, X, and Product Hunt")
|
|
9520
|
-
parser.add_argument("--version", "-v", action="version", version="T-Zero Context Architect v12.2.
|
|
9688
|
+
parser.add_argument("--version", "-v", action="version", version="T-Zero Context Architect v12.2.2 Master Edition (engine v4.1.0)")
|
|
9521
9689
|
|
|
9522
9690
|
|
|
9523
9691
|
def print_master_tutorial():
|
|
@@ -9626,7 +9794,7 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
9626
9794
|
def print_quickstart_guide():
|
|
9627
9795
|
print("""
|
|
9628
9796
|
================================================================================
|
|
9629
|
-
⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & MCP v12.2.
|
|
9797
|
+
⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & MCP v12.2.2 MASTER (engine v4.1.0)
|
|
9630
9798
|
================================================================================
|
|
9631
9799
|
🎯 %95'e Varan Token Tasarrufu & Otonom Yapay Zeka Mimari Bağlam Motoru
|
|
9632
9800
|
|
|
@@ -9837,8 +10005,13 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
9837
10005
|
run_system_disk_doctor(clean=True, workspace_dir=args.dir)
|
|
9838
10006
|
return
|
|
9839
10007
|
elif getattr(args, "armor", None):
|
|
10008
|
+
if getattr(args, "audit", None) is not None:
|
|
10009
|
+
from tzero.tzero_armor import audit_path_rea_resistance
|
|
10010
|
+
audit = audit_path_rea_resistance(args.armor)
|
|
10011
|
+
print(json.dumps(audit, indent=2))
|
|
10012
|
+
return
|
|
9840
10013
|
from tzero.tzero_armor import protect_path_with_armor
|
|
9841
|
-
res = protect_path_with_armor(args.armor)
|
|
10014
|
+
res = protect_path_with_armor(args.armor, output_path=getattr(args, "output", None))
|
|
9842
10015
|
if res.get("success"):
|
|
9843
10016
|
print(f"[OK] Applied Anti-REA Armor to: {args.armor}")
|
|
9844
10017
|
if "score_after" in res:
|
|
@@ -9853,10 +10026,10 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
9853
10026
|
from tzero.tzero_armor import audit_path_rea_resistance
|
|
9854
10027
|
audit = audit_path_rea_resistance(args.audit_rea)
|
|
9855
10028
|
print(json.dumps(audit, indent=2))
|
|
9856
|
-
|
|
9857
|
-
elif getattr(args, "telemetry",
|
|
10029
|
+
sys.exit(1 if audit.get("error") else 0)
|
|
10030
|
+
elif getattr(args, "telemetry", None) is not None:
|
|
9858
10031
|
from tzero.tzero_telemetry import get_summary, render_report
|
|
9859
|
-
ws_dir = getattr(args, "dir", ".") or "."
|
|
10032
|
+
ws_dir = args.telemetry if args.telemetry != "." else (getattr(args, "dir", ".") or ".")
|
|
9860
10033
|
if getattr(args, "format", "text") == "json":
|
|
9861
10034
|
print(json.dumps(get_summary(workspace_dir=ws_dir), indent=2))
|
|
9862
10035
|
else:
|
|
@@ -10600,7 +10773,7 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
10600
10773
|
if not os.path.exists(app_path):
|
|
10601
10774
|
app_path = os.path.join(os.getcwd(), "huggingface-space", "app.py")
|
|
10602
10775
|
print("\033[36m" + "=" * 80)
|
|
10603
|
-
print("🤗 SİBER AKADEMİ — T-ZERO HUGGING FACE SPACE & GRADIO COCKPIT (v12.2.
|
|
10776
|
+
print("🤗 SİBER AKADEMİ — T-ZERO HUGGING FACE SPACE & GRADIO COCKPIT (v12.2.2)")
|
|
10604
10777
|
print("=" * 80 + "\033[0m")
|
|
10605
10778
|
print("🌐 Official Live Space : https://huggingface.co/spaces/toprakke4/tzero-token-reducer")
|
|
10606
10779
|
print(f"📁 Local Application : {app_path}")
|
|
@@ -10626,20 +10799,28 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
10626
10799
|
elif getattr(args, "vault", None) is not None:
|
|
10627
10800
|
from tzero.tzero_security import ZeroLeakEngine
|
|
10628
10801
|
target = args.vault or args.dir
|
|
10802
|
+
if not os.path.exists(target):
|
|
10803
|
+
print(f"[AUTO-VAULT ERROR] Target path not found: {target}", file=sys.stderr)
|
|
10804
|
+
sys.exit(1)
|
|
10805
|
+
proj_root = ZeroLeakEngine.resolve_project_root(target)
|
|
10806
|
+
env_path = os.path.join(proj_root, ".env")
|
|
10807
|
+
gi_path = os.path.join(proj_root, ".gitignore")
|
|
10629
10808
|
if os.path.isfile(target):
|
|
10630
10809
|
with open(target, "r", encoding="utf-8", errors="ignore") as f:
|
|
10631
10810
|
c = f.read()
|
|
10632
10811
|
migrated_code, env_file, count, report = ZeroLeakEngine.auto_migrate_to_env(
|
|
10633
|
-
c,
|
|
10634
|
-
env_file_path=".env" if args.migrate else None,
|
|
10635
|
-
gitignore_path=".gitignore" if args.migrate else None
|
|
10812
|
+
c, env_file_path=env_path, gitignore_path=gi_path, dry_run=True
|
|
10636
10813
|
)
|
|
10637
10814
|
if args.migrate:
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10815
|
+
res = ZeroLeakEngine.migrate_files_atomically([target], env_file_path=env_path, gitignore_path=gi_path)
|
|
10816
|
+
if not res.get("success"):
|
|
10817
|
+
print(f"[AUTO-VAULT ERROR] Migration aborted safely (files preserved): {res.get('error')}", file=sys.stderr)
|
|
10818
|
+
sys.exit(1)
|
|
10819
|
+
if res.get("warning"):
|
|
10820
|
+
print(f"[AUTO-VAULT WARNING] {res['warning']}", file=sys.stderr)
|
|
10821
|
+
print(f"[AUTO-VAULT] Successfully migrated {res.get('migrated_count', 0)} secret(s) into {env_path} and updated code.")
|
|
10641
10822
|
else:
|
|
10642
|
-
print(f"[AUTO-VAULT DRY-RUN] Detected {count} hardcoded credential(s) ready for
|
|
10823
|
+
print(f"[AUTO-VAULT DRY-RUN] Detected {count} hardcoded credential(s) ready for {env_path} migration. Re-run with --migrate to apply.")
|
|
10643
10824
|
else:
|
|
10644
10825
|
findings = ZeroLeakEngine.scan_workspace(target)
|
|
10645
10826
|
violations = findings.get("violations", [])
|
|
@@ -10651,21 +10832,18 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
10651
10832
|
for idx, _ in enumerate(violations, 1):
|
|
10652
10833
|
print(f" - [FINDING #{idx}] Credential pattern detected (redacted).")
|
|
10653
10834
|
if args.migrate:
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
f.write(mc)
|
|
10667
|
-
total_migrated += c_cnt
|
|
10668
|
-
print(f"[AUTO-VAULT] Successfully secured and migrated {total_migrated} secret(s) into {os.path.join(target, '.env')}.")
|
|
10835
|
+
violating_files = sorted({v.get("file", "") for v in violations if v.get("file") and os.path.isfile(v.get("file", ""))})
|
|
10836
|
+
res = ZeroLeakEngine.migrate_files_atomically(
|
|
10837
|
+
violating_files,
|
|
10838
|
+
env_file_path=os.path.join(target, ".env"),
|
|
10839
|
+
gitignore_path=os.path.join(target, ".gitignore"),
|
|
10840
|
+
)
|
|
10841
|
+
if not res.get("success"):
|
|
10842
|
+
print(f"[AUTO-VAULT ERROR] Migration aborted cleanly (all files preserved): {res.get('error')}", file=sys.stderr)
|
|
10843
|
+
sys.exit(1)
|
|
10844
|
+
if res.get("warning"):
|
|
10845
|
+
print(f"[AUTO-VAULT WARNING] {res['warning']}", file=sys.stderr)
|
|
10846
|
+
print(f"[AUTO-VAULT] Successfully secured and migrated {res.get('migrated_count', 0)} secret(s) into {os.path.join(target, '.env')}.")
|
|
10669
10847
|
else:
|
|
10670
10848
|
print("\n[TIP] Run with --migrate to automatically extract these secrets into .env and refactor source files.")
|
|
10671
10849
|
sys.exit(0)
|
|
@@ -10746,6 +10924,8 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
10746
10924
|
run_export_cli(args.dir, "repomap", args.export_repomap)
|
|
10747
10925
|
elif args.export_html is not None:
|
|
10748
10926
|
run_export_cli(args.dir, "html", args.export_html)
|
|
10927
|
+
elif getattr(args, "tree", None) is not None:
|
|
10928
|
+
run_dry_run_cli(args.tree or args.dir, args.output, args.force)
|
|
10749
10929
|
elif args.dry_run:
|
|
10750
10930
|
run_dry_run_cli(args.dir, args.output, args.force)
|
|
10751
10931
|
elif args.cli:
|