tzero-mcp 10.7.4 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -29
- package/CONTRIBUTING.md +71 -71
- package/README.md +64 -64
- package/bin/tzero-mcp.js +62 -66
- package/bin/tzero.js +61 -65
- package/index.d.ts +25 -25
- package/index.js +15 -15
- package/package.json +88 -88
- package/src/addmcp.py +14 -11
- package/src/app.py +1810 -0
- package/src/main.py +1 -1
- package/src/pc_fixer_mcp.py +25 -0
- package/src/tzero/__init__.py +54 -0
- package/src/tzero/__main__.py +6 -0
- package/src/tzero/siber_akademi.ico +0 -0
- package/src/tzero/tzero_arch_test.py +463 -0
- package/src/{tzero_benchmark.py → tzero/tzero_benchmark.py} +475 -475
- package/src/tzero/tzero_blackboard.py +257 -0
- package/src/{tzero_bridge.py → tzero/tzero_bridge.py} +546 -362
- package/src/tzero/tzero_budget.py +195 -0
- package/src/{tzero_ci.py → tzero/tzero_ci.py} +153 -153
- package/src/{tzero_commit.py → tzero/tzero_commit.py} +192 -192
- package/src/tzero/tzero_contracts.py +1093 -0
- package/src/{tzero_cost.py → tzero/tzero_cost.py} +166 -163
- package/src/{tzero_dashboard.py → tzero/tzero_dashboard.py} +531 -19
- package/src/tzero/tzero_debt.py +461 -0
- package/src/{tzero_deps.py → tzero/tzero_deps.py} +179 -4
- package/src/{tzero_drift.py → tzero/tzero_drift.py} +208 -208
- package/src/{tzero_explain.py → tzero/tzero_explain.py} +73 -7
- package/src/{tzero_features.py → tzero/tzero_features.py} +19 -17
- package/src/tzero/tzero_federation.py +299 -0
- package/src/{tzero_fix.py → tzero/tzero_fix.py} +228 -228
- package/src/{tzero_fixer → tzero/tzero_fixer}/__init__.py +63 -63
- package/src/{tzero_fixer → tzero/tzero_fixer}/ast_syntax_healer.py +464 -464
- package/src/{tzero_fixer → tzero/tzero_fixer}/ast_type_modernizer.py +288 -288
- package/src/{tzero_fixer → tzero/tzero_fixer}/async_io_modernizer.py +127 -127
- package/src/{tzero_fixer → tzero/tzero_fixer}/automated_regression_suite.py +600 -600
- package/src/{tzero_fixer → tzero/tzero_fixer}/benchmarks_and_diagnostics.py +174 -174
- package/src/{tzero_fixer → tzero/tzero_fixer}/ci_cd_self_healing_gate.py +246 -246
- package/src/{tzero_fixer → tzero/tzero_fixer}/code_duplicity_and_refactorer.py +151 -151
- package/src/{tzero_fixer → tzero/tzero_fixer}/code_smells_healer.py +260 -260
- package/src/{tzero_fixer → tzero/tzero_fixer}/cwe_remediator.py +171 -171
- package/src/{tzero_fixer → tzero/tzero_fixer}/dead_code_eliminator.py +150 -150
- package/src/{tzero_fixer → tzero/tzero_fixer}/dependency_vulnerability_auditor.py +309 -309
- package/src/{tzero_fixer → tzero/tzero_fixer}/git_advanced_surgeon.py +1 -1
- package/src/{tzero_fixer → tzero/tzero_fixer}/hardware_and_disk_doctor.py +1 -1
- package/src/{tzero_fixer → tzero/tzero_fixer}/import_graph_healer.py +412 -412
- package/src/{tzero_fixer → tzero/tzero_fixer}/interactive_tui.py +91 -91
- package/src/{tzero_fixer → tzero/tzero_fixer}/knowledge_base.py +295 -295
- package/src/{tzero_fixer → tzero/tzero_fixer}/knowledge_base_extended.py +940 -940
- package/src/{tzero_fixer → tzero/tzero_fixer}/linters_and_static_analyzer.py +307 -307
- package/src/{tzero_fixer → tzero/tzero_fixer}/mcp_server.py +49 -7
- package/src/{tzero_fixer → tzero/tzero_fixer}/os_doctor.py +502 -502
- package/src/{tzero_fixer → tzero/tzero_fixer}/packaging_abi_surgeon.py +1 -1
- package/src/{tzero_fixer → tzero/tzero_fixer}/pc_fixer_doctor.py +600 -599
- package/src/{tzero_fixer → tzero/tzero_fixer}/performance_and_memory_profiler.py +274 -274
- package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_ast_parsers.py +313 -313
- package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_build_healer.py +1 -1
- package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_config_healer.py +318 -318
- package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_doctor.py +372 -372
- package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_linters.py +1 -1
- package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_schema_validator.py +305 -305
- package/src/{tzero_fixer → tzero/tzero_fixer}/security_cwe_database.py +444 -444
- package/src/{tzero_fixer → tzero/tzero_fixer}/security_deep_rules.py +114 -114
- package/src/{tzero_fixer → tzero/tzero_fixer}/security_rules_catalog.py +110 -110
- package/src/{tzero_fixer → tzero/tzero_fixer}/security_zero_leak.py +326 -326
- package/src/{tzero_fixer → tzero/tzero_fixer}/smart_patch_recommender.py +223 -223
- package/src/{tzero_fixer → tzero/tzero_fixer}/synthetic_workspace_generator.py +220 -220
- package/src/{tzero_fixer → tzero/tzero_fixer}/system_diagnostics_extended.py +1 -1
- package/src/{tzero_fixer → tzero/tzero_fixer}/system_repair_recipes.py +447 -447
- package/src/{tzero_fixer → tzero/tzero_fixer}/venv_doctor.py +309 -309
- package/src/tzero/tzero_golden.py +319 -0
- package/src/tzero/tzero_graph_hud.html +338 -0
- package/src/tzero/tzero_graph_rag.py +263 -0
- package/src/{tzero_guard.py → tzero/tzero_guard.py} +243 -243
- package/src/tzero/tzero_hooks.py +565 -0
- package/src/{tzero_infra.py → tzero/tzero_infra.py} +274 -274
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/__init__.py +124 -124
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/causal_graph.py +310 -310
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/graph_visualizer.py +395 -395
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/hybrid_search.py +214 -214
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/latent_press.py +137 -137
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/memory_consolidation.py +212 -212
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/minhash_lsh.py +184 -184
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/orchestrator.py +335 -335
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/self_healing.py +308 -308
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/semantic_compressor.py +887 -887
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/swarm.py +261 -261
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/swarm_bft.py +144 -144
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/workspace_orchestrator.py +1167 -1167
- package/src/{tzero_jarvis → tzero/tzero_jarvis}/zero_key_router.py +173 -173
- package/src/tzero/tzero_lsp.py +634 -0
- package/src/{tzero_mcp.py → tzero/tzero_mcp.py} +479 -100
- package/src/tzero/tzero_mutation.py +358 -0
- package/src/tzero/tzero_packer.py +577 -0
- package/src/{tzero_patch.py → tzero/tzero_patch.py} +624 -624
- package/src/{tzero_pc_fixer.py → tzero/tzero_pc_fixer.py} +12699 -12657
- package/src/{tzero_pipe.py → tzero/tzero_pipe.py} +95 -95
- package/src/tzero/tzero_polyglot.py +799 -0
- package/src/tzero/tzero_proxy.py +127 -0
- package/src/{tzero_reachability.py → tzero/tzero_reachability.py} +272 -272
- package/src/{tzero_replay.py → tzero/tzero_replay.py} +141 -141
- package/src/tzero/tzero_rust_bridge.py +198 -0
- package/src/tzero/tzero_scip.py +368 -0
- package/src/{tzero_security.py → tzero/tzero_security.py} +5 -2
- package/src/tzero/tzero_semantic_merge.py +189 -0
- package/src/tzero/tzero_snapshot.py +471 -0
- package/src/{tzero_stubs.py → tzero/tzero_stubs.py} +313 -313
- package/src/tzero/tzero_subagent_engine.py +459 -0
- package/src/{tzero_superdesign.py → tzero/tzero_superdesign.py} +774 -774
- package/src/{tzero_sync.py → tzero/tzero_sync.py} +241 -241
- package/src/{tzero_task_benchmark.py → tzero/tzero_task_benchmark.py} +458 -363
- package/src/{tzero_tui.py → tzero/tzero_tui.py} +91 -22
- package/src/tzero/tzero_turbo.py +264 -0
- package/src/{tzero_v3.py → tzero/tzero_v3.py} +628 -163
- package/src/tzero.py +2 -54
- package/test/package.test.js +55 -43
- package/src/tzero/jarvis/semantic_compressor.py +0 -373
- package/src/tzero_gateway.py +0 -885
- package/src/tzero_packer.py +0 -370
- package/src/tzero_polyglot.py +0 -422
- package/src/tzero_snapshot.py +0 -258
- /package/src/{siber_akademi_icon.py → tzero/siber_akademi_icon.py} +0 -0
- /package/src/{tzero_fixer → tzero/tzero_fixer}/amalgamation.py +0 -0
- /package/src/{tzero_fixer → tzero/tzero_fixer}/models.py +0 -0
- /package/src/{tzero_fixer → tzero/tzero_fixer}/orchestrator.py +0 -0
- /package/src/{tzero_neural_cortex.py → tzero/tzero_neural_cortex.py} +0 -0
|
@@ -18,6 +18,13 @@ Bio & Socials: https://hopp.bio/siberegitim
|
|
|
18
18
|
GitHub: https://github.com/toprakahmetaydogmus/TZeroAlgorithm
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
|
+
# Support direct execution by MCP clients and bundled launchers.
|
|
22
|
+
if __name__ == "__main__" and not __package__:
|
|
23
|
+
import os
|
|
24
|
+
import sys
|
|
25
|
+
|
|
26
|
+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
27
|
+
|
|
21
28
|
import os
|
|
22
29
|
import sys
|
|
23
30
|
import re
|
|
@@ -75,9 +82,16 @@ if sys.stderr and hasattr(sys.stderr, "reconfigure"):
|
|
|
75
82
|
|
|
76
83
|
# Install missing third-party packages before they are imported (see tzero_deps.py).
|
|
77
84
|
try:
|
|
78
|
-
import tzero_deps
|
|
85
|
+
from tzero import tzero_deps
|
|
79
86
|
except ImportError: # tzero_v3.py copied on its own without the helper module
|
|
80
87
|
tzero_deps = None
|
|
88
|
+
# The deep doctor reports missing dependencies without attempting to install them.
|
|
89
|
+
if tzero_deps is not None and sys.argv[1:] in (
|
|
90
|
+
["--doctor", "--deep"], ["--deep", "--doctor"],
|
|
91
|
+
["doctor", "--deep"], ["--deep", "doctor"],
|
|
92
|
+
):
|
|
93
|
+
sys.exit(tzero_deps.run_doctor(deep=True))
|
|
94
|
+
|
|
81
95
|
if tzero_deps is not None and not tzero_deps.ensure_dependencies():
|
|
82
96
|
sys.exit(1)
|
|
83
97
|
|
|
@@ -89,7 +103,7 @@ import webbrowser
|
|
|
89
103
|
from typing import Dict, List, Any, Tuple, Optional, Set, Callable
|
|
90
104
|
|
|
91
105
|
try:
|
|
92
|
-
from tzero_features import ArchitectureRuleEngine
|
|
106
|
+
from tzero.tzero_features import ArchitectureRuleEngine
|
|
93
107
|
except Exception:
|
|
94
108
|
ArchitectureRuleEngine = None
|
|
95
109
|
|
|
@@ -122,7 +136,7 @@ except ImportError: # pragma: no cover - depends on the host Python build
|
|
|
122
136
|
from concurrent.futures import ThreadPoolExecutor
|
|
123
137
|
|
|
124
138
|
try:
|
|
125
|
-
import siber_akademi_icon
|
|
139
|
+
from tzero import siber_akademi_icon
|
|
126
140
|
except ImportError:
|
|
127
141
|
siber_akademi_icon = None
|
|
128
142
|
|
|
@@ -468,7 +482,7 @@ def calculate_token_cost(token_count: int, provider_name: str) -> float:
|
|
|
468
482
|
# i18n Translations
|
|
469
483
|
TRANSLATIONS: Dict[str, Dict[str, str]] = {
|
|
470
484
|
"en": {
|
|
471
|
-
"title": "T-Zero Developer Console & Context Architect
|
|
485
|
+
"title": "T-Zero Developer Console & Context Architect v11.0.0",
|
|
472
486
|
"subtitle": f"Developer: {DEV_NAME} | {DEV_URL_MAIN} | {DEV_URL_BIO}",
|
|
473
487
|
"overview_tab": "🏠 Overview Dashboard",
|
|
474
488
|
"setup_tab": "⚡ Setup & AI Models",
|
|
@@ -505,7 +519,7 @@ TRANSLATIONS: Dict[str, Dict[str, str]] = {
|
|
|
505
519
|
"audit_btn": "🛡️ SECURITY AUDIT"
|
|
506
520
|
},
|
|
507
521
|
"tr": {
|
|
508
|
-
"title": "T-Zero Geliştirici Konsolu & Bağlam Mimarı
|
|
522
|
+
"title": "T-Zero Geliştirici Konsolu & Bağlam Mimarı v11.0.0",
|
|
509
523
|
"subtitle": f"Geliştirici: {DEV_NAME} | {DEV_URL_MAIN} | {DEV_URL_BIO}",
|
|
510
524
|
"overview_tab": "🏠 Genel Bakış",
|
|
511
525
|
"setup_tab": "⚡ Kurulum & Model",
|
|
@@ -1104,39 +1118,10 @@ class PolyglotSignatureExtractor:
|
|
|
1104
1118
|
|
|
1105
1119
|
@classmethod
|
|
1106
1120
|
def extract(cls, file_path: str, code: str, mode: str = "ultra") -> str:
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
return cls.reduce_go(code, mode)
|
|
1112
|
-
elif ext == ".rs":
|
|
1113
|
-
return cls.reduce_rust(code, mode)
|
|
1114
|
-
elif ext in (".java", ".cs"):
|
|
1115
|
-
return cls.reduce_java_csharp(code, mode)
|
|
1116
|
-
elif ext in (".cpp", ".c", ".h", ".hpp", ".cc", ".cxx"):
|
|
1117
|
-
return cls.reduce_c_cpp(code, mode)
|
|
1118
|
-
elif ext in (".kt", ".kts"):
|
|
1119
|
-
return cls.reduce_kotlin(code, mode)
|
|
1120
|
-
elif ext == ".swift":
|
|
1121
|
-
return cls.reduce_swift(code, mode)
|
|
1122
|
-
elif ext in (".rb", ".rake", ".gemspec"):
|
|
1123
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1124
|
-
return PolyglotTokenReducer.reduce_ruby(code, mode)
|
|
1125
|
-
elif ext in (".php", ".phtml"):
|
|
1126
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1127
|
-
return PolyglotTokenReducer.reduce_php(code, mode)
|
|
1128
|
-
elif ext in (".dart",):
|
|
1129
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1130
|
-
return PolyglotTokenReducer.reduce_dart(code, mode)
|
|
1131
|
-
elif ext in (".sol",):
|
|
1132
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1133
|
-
return PolyglotTokenReducer.reduce_solidity(code, mode)
|
|
1134
|
-
elif ext in (".scala", ".sc"):
|
|
1135
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1136
|
-
return PolyglotTokenReducer.reduce_scala(code, mode)
|
|
1137
|
-
elif ext in (".ex", ".exs"):
|
|
1138
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1139
|
-
return PolyglotTokenReducer.reduce_elixir(code, mode)
|
|
1121
|
+
from tzero.tzero_polyglot import PolyglotTokenReducer
|
|
1122
|
+
norm_mode = "light" if str(mode).lower() in ("light", "balanced") else mode
|
|
1123
|
+
if PolyglotTokenReducer.detect_language(file_path):
|
|
1124
|
+
return PolyglotTokenReducer.reduce_code(code, filename=file_path, mode=norm_mode)
|
|
1140
1125
|
return code
|
|
1141
1126
|
|
|
1142
1127
|
@staticmethod
|
|
@@ -1598,22 +1583,22 @@ class TokenReducer:
|
|
|
1598
1583
|
elif ext == ".swift":
|
|
1599
1584
|
return PolyglotSignatureExtractor.reduce_swift(code, mode)
|
|
1600
1585
|
elif ext == ".sol":
|
|
1601
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1586
|
+
from tzero.tzero_polyglot import PolyglotTokenReducer
|
|
1602
1587
|
return PolyglotTokenReducer.reduce_solidity(code, mode)
|
|
1603
1588
|
elif ext in (".rb", ".rake", ".gemspec"):
|
|
1604
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1589
|
+
from tzero.tzero_polyglot import PolyglotTokenReducer
|
|
1605
1590
|
return PolyglotTokenReducer.reduce_ruby(code, mode)
|
|
1606
1591
|
elif ext in (".php", ".phtml"):
|
|
1607
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1592
|
+
from tzero.tzero_polyglot import PolyglotTokenReducer
|
|
1608
1593
|
return PolyglotTokenReducer.reduce_php(code, mode)
|
|
1609
1594
|
elif ext in (".dart",):
|
|
1610
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1595
|
+
from tzero.tzero_polyglot import PolyglotTokenReducer
|
|
1611
1596
|
return PolyglotTokenReducer.reduce_dart(code, mode)
|
|
1612
1597
|
elif ext in (".scala", ".sc"):
|
|
1613
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1598
|
+
from tzero.tzero_polyglot import PolyglotTokenReducer
|
|
1614
1599
|
return PolyglotTokenReducer.reduce_scala(code, mode)
|
|
1615
1600
|
elif ext in (".ex", ".exs"):
|
|
1616
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
1601
|
+
from tzero.tzero_polyglot import PolyglotTokenReducer
|
|
1617
1602
|
return PolyglotTokenReducer.reduce_elixir(code, mode)
|
|
1618
1603
|
|
|
1619
1604
|
return TokenReducer._default_trim(code)
|
|
@@ -1623,13 +1608,13 @@ class TokenReducer:
|
|
|
1623
1608
|
f_lower = file_path.lower()
|
|
1624
1609
|
if f_lower.endswith((".sql", ".yaml", ".yml", ".tf", ".hcl")) or "dockerfile" in f_lower:
|
|
1625
1610
|
try:
|
|
1626
|
-
from tzero_infra import SchemaInfraReducer
|
|
1611
|
+
from tzero.tzero_infra import SchemaInfraReducer
|
|
1627
1612
|
return SchemaInfraReducer.reduce(file_path, code, mode=mode)
|
|
1628
1613
|
except Exception:
|
|
1629
1614
|
pass
|
|
1630
1615
|
if f_lower.endswith((".diff", ".patch")):
|
|
1631
1616
|
try:
|
|
1632
|
-
from tzero_patch import SmartMicroPatcher
|
|
1617
|
+
from tzero.tzero_patch import SmartMicroPatcher
|
|
1633
1618
|
return SmartMicroPatcher.compress_diff(code)
|
|
1634
1619
|
except Exception:
|
|
1635
1620
|
pass
|
|
@@ -1777,7 +1762,8 @@ def resolve_default_workspace(current_dir: Optional[str] = None, executable_dir:
|
|
|
1777
1762
|
root = os.path.dirname(candidate)
|
|
1778
1763
|
while root != os.path.dirname(root):
|
|
1779
1764
|
if (
|
|
1780
|
-
os.path.isfile(os.path.join(root, "tzero_v3.py"))
|
|
1765
|
+
(os.path.isfile(os.path.join(root, "tzero", "tzero_v3.py"))
|
|
1766
|
+
or os.path.isfile(os.path.join(root, "tzero_v3.py")))
|
|
1781
1767
|
and os.path.isfile(os.path.join(root, "pyproject.toml"))
|
|
1782
1768
|
):
|
|
1783
1769
|
return root
|
|
@@ -1814,22 +1800,37 @@ class CodebaseScanner:
|
|
|
1814
1800
|
files_list.append(rel_path)
|
|
1815
1801
|
sizes[rel_path] = os.path.getsize(full_path)
|
|
1816
1802
|
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
results = executor.map(process_file, files_list)
|
|
1830
|
-
for rel, snip in results:
|
|
1803
|
+
try:
|
|
1804
|
+
from tzero.tzero_turbo import get_turbo_accelerator
|
|
1805
|
+
turbo = get_turbo_accelerator()
|
|
1806
|
+
reduction_mode = profile.get("reduction", "Ultra")
|
|
1807
|
+
full_paths = [os.path.join(root_dir, rel_p) for rel_p in files_list]
|
|
1808
|
+
reduced_map = turbo.parallel_reduce_batch(
|
|
1809
|
+
full_paths,
|
|
1810
|
+
lambda code, p, m: TokenReducer.reduce(code, p, mode=m),
|
|
1811
|
+
mode=reduction_mode
|
|
1812
|
+
)
|
|
1813
|
+
for rel_p, full_p in zip(files_list, full_paths):
|
|
1814
|
+
snip = reduced_map.get(full_p, "")
|
|
1831
1815
|
if snip:
|
|
1832
|
-
snippets[
|
|
1816
|
+
snippets[rel_p] = snip
|
|
1817
|
+
except Exception:
|
|
1818
|
+
def process_file(rel_path: str):
|
|
1819
|
+
full_path = os.path.join(root_dir, rel_path)
|
|
1820
|
+
try:
|
|
1821
|
+
with open(full_path, "r", encoding="utf-8", errors="ignore") as file_io:
|
|
1822
|
+
raw_code = file_io.read(15000)
|
|
1823
|
+
reduction_mode = profile.get("reduction", "Ultra")
|
|
1824
|
+
return rel_path, TokenReducer.reduce(raw_code, full_path, reduction_mode)
|
|
1825
|
+
except Exception as e:
|
|
1826
|
+
logger.warning(f"Unable to read signature file {rel_path}: {e}")
|
|
1827
|
+
return rel_path, ""
|
|
1828
|
+
|
|
1829
|
+
with ThreadPoolExecutor(max_workers=thread_size) as executor:
|
|
1830
|
+
results = executor.map(process_file, files_list)
|
|
1831
|
+
for rel, snip in results:
|
|
1832
|
+
if snip:
|
|
1833
|
+
snippets[rel] = snip
|
|
1833
1834
|
|
|
1834
1835
|
return sorted(files_list), sizes, snippets
|
|
1835
1836
|
|
|
@@ -2671,8 +2672,12 @@ Dependencies and inter-module relationships.
|
|
|
2671
2672
|
return rendered
|
|
2672
2673
|
|
|
2673
2674
|
|
|
2675
|
+
from tzero.tzero_polyglot import _BPE_ENCODING_CACHE, count_bpe_tokens
|
|
2676
|
+
|
|
2677
|
+
|
|
2674
2678
|
def count_tokens_precise(text: str, model_name: str = "gpt-4o") -> int:
|
|
2675
|
-
|
|
2679
|
+
"""Count exact tokens using cached local tiktoken BPE encodings with char//4 fallback."""
|
|
2680
|
+
return count_bpe_tokens(text, model_name=model_name, fallback_divisor=4.0)
|
|
2676
2681
|
|
|
2677
2682
|
|
|
2678
2683
|
def get_budgeted_snippets(selected_files: List[str], file_snippets: Dict[str, str]) -> Dict[str, str]:
|
|
@@ -2777,7 +2782,12 @@ class ContextGenerator:
|
|
|
2777
2782
|
raise e
|
|
2778
2783
|
|
|
2779
2784
|
|
|
2780
|
-
def generate_offline_context(
|
|
2785
|
+
def generate_offline_context(
|
|
2786
|
+
project_dir: str,
|
|
2787
|
+
selected_files: List[str],
|
|
2788
|
+
file_snippets: Dict[str, str],
|
|
2789
|
+
cache_aligned: bool = False,
|
|
2790
|
+
) -> str:
|
|
2781
2791
|
"""Generates an enterprise-grade hierarchical T-Zero context tree offline without API call.
|
|
2782
2792
|
|
|
2783
2793
|
Adheres strictly to the T-Zero 4-Tier Context Architecture (T-1 to T-4)
|
|
@@ -2842,6 +2852,64 @@ def generate_offline_context(project_dir: str, selected_files: List[str], file_s
|
|
|
2842
2852
|
tree_lines = [f"├── {f}" for f in sorted(selected_files)]
|
|
2843
2853
|
tree_ascii = "\n".join(tree_lines)
|
|
2844
2854
|
|
|
2855
|
+
if cache_aligned:
|
|
2856
|
+
static_prefix = f"""# T-Zero Context Tree (KV-Cache Aligned)
|
|
2857
|
+
|
|
2858
|
+
> **Engine:** Siber Akademi T-Zero Context Architect V3 (AST Pruning & Zero-Leak Engine)
|
|
2859
|
+
> **Security:** 100% Zero-Leak (No secrets, no API keys, client-side offline execution)
|
|
2860
|
+
|
|
2861
|
+
---
|
|
2862
|
+
|
|
2863
|
+
## 🛡️ Tier T-4: T-Zero Algorithm Rules & Guardrails
|
|
2864
|
+
|
|
2865
|
+
The following four canonical T-Zero Algorithm Rules govern this codebase:
|
|
2866
|
+
|
|
2867
|
+
### 🔒 Rule T-001: Zero-Leak Isolation
|
|
2868
|
+
- **Directive:** NEVER commit, embed, or transmit secrets, passwords, auth tokens, or private API keys.
|
|
2869
|
+
- **Enforcement:** Client-side regex & Shannon entropy inspection (`H(S) > 4.5`). Sensitive tokens are masked as `[REDACTED_BY_TZERO_SECURITY_GUARD]`.
|
|
2870
|
+
|
|
2871
|
+
### 🏛️ Rule T-002: Architectural Boundary Enforcement
|
|
2872
|
+
- **Directive:** Strict architectural layering defined in `tzero.rules.json`. Core domain logic must never import visual UI; data models must decouple from presentation/controllers.
|
|
2873
|
+
- **Enforcement:** Enforced via AST import graph analysis and CI boundary gates (`ArchitectureRuleEngine`).
|
|
2874
|
+
|
|
2875
|
+
### 📝 Rule T-003: AST Interface Contract Fidelity
|
|
2876
|
+
- **Directive:** Class declarations, method signatures, return type annotations, parameter schemas, and docstrings must remain 100% syntactically valid and structurally complete.
|
|
2877
|
+
- **Enforcement:** AST compiler preservation ensures AI coding agents understand exact interface boundaries with zero hallucination.
|
|
2878
|
+
|
|
2879
|
+
### ⚡ Rule T-004: Anti-Pattern & Maintainability Guard
|
|
2880
|
+
- **Directive:** Guard against high cyclomatic complexity, code bloat, and maintainability erosion.
|
|
2881
|
+
- **Enforcement:** Flags functions with >30 lines, parameter lists with >6 arguments, missing docstrings, global keyword abuse, and copy-pasted duplicate code blocks (6+ lines).
|
|
2882
|
+
|
|
2883
|
+
---
|
|
2884
|
+
|
|
2885
|
+
## 🗺️ Tier T-1: Architecture Overview & Physical Topology
|
|
2886
|
+
|
|
2887
|
+
```
|
|
2888
|
+
{tree_ascii}
|
|
2889
|
+
```
|
|
2890
|
+
|
|
2891
|
+
---
|
|
2892
|
+
|
|
2893
|
+
## 🔗 Tier T-2: Module Dependencies & Import Hierarchy
|
|
2894
|
+
|
|
2895
|
+
- **Detected Dependencies / Imports:** {deps_str}
|
|
2896
|
+
- **Component Count:** {len(selected_files)} active modules mapped
|
|
2897
|
+
|
|
2898
|
+
---
|
|
2899
|
+
|
|
2900
|
+
## 📑 Tier T-3: Module Reference & Signatures (AST Contracts)
|
|
2901
|
+
|
|
2902
|
+
All internal function and method implementation bodies are pruned using semantic ellipses (`...`),
|
|
2903
|
+
preserving 100% syntactically valid type annotations, arguments, classes, and docstrings:
|
|
2904
|
+
|
|
2905
|
+
{modules_str}"""
|
|
2906
|
+
dynamic_suffix = f"""\n<!-- TZERO_DYNAMIC_SUFFIX -->
|
|
2907
|
+
- **Project:** `{project_name}`
|
|
2908
|
+
- **Workspace:** `{project_dir}`
|
|
2909
|
+
- **Analyzed Modules:** {len(selected_files)} files | ~{total_lines} lines of code
|
|
2910
|
+
"""
|
|
2911
|
+
return static_prefix + dynamic_suffix
|
|
2912
|
+
|
|
2845
2913
|
return f"""# {project_name} — T-Zero Context Tree
|
|
2846
2914
|
|
|
2847
2915
|
> **Engine:** Siber Akademi T-Zero Context Architect V3 (AST Pruning & Zero-Leak Engine)
|
|
@@ -4512,8 +4580,8 @@ class AutoReadmeGUI:
|
|
|
4512
4580
|
except Exception:
|
|
4513
4581
|
pass
|
|
4514
4582
|
if not self.logo_img:
|
|
4515
|
-
resource_dir = getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__)))
|
|
4516
|
-
icon_path = os.path.join(resource_dir, "siber_akademi.ico")
|
|
4583
|
+
resource_dir = getattr(sys, "_MEIPASS", os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
4584
|
+
icon_path = os.path.join(resource_dir, "tzero", "siber_akademi.ico")
|
|
4517
4585
|
if os.path.isfile(icon_path):
|
|
4518
4586
|
try:
|
|
4519
4587
|
self.root.iconbitmap(icon_path)
|
|
@@ -4830,7 +4898,7 @@ class AutoReadmeGUI:
|
|
|
4830
4898
|
def open_web_console(self):
|
|
4831
4899
|
play_sfx("click")
|
|
4832
4900
|
try:
|
|
4833
|
-
from tzero_dashboard import start_dashboard_server, DASHBOARD_PORT
|
|
4901
|
+
from tzero.tzero_dashboard import start_dashboard_server, DASHBOARD_PORT
|
|
4834
4902
|
if not getattr(self, "_web_server_started", False):
|
|
4835
4903
|
try:
|
|
4836
4904
|
threading.Thread(target=lambda: start_dashboard_server(DASHBOARD_PORT, open_browser=False), daemon=True).start()
|
|
@@ -7523,8 +7591,9 @@ Custom Requirements:
|
|
|
7523
7591
|
with open(out_path, "w", encoding="utf-8") as f:
|
|
7524
7592
|
f.write(content)
|
|
7525
7593
|
self.safe_after(0, lambda: self._on_arch_export_done(out_path, use_ai))
|
|
7526
|
-
except Exception as
|
|
7527
|
-
|
|
7594
|
+
except Exception as exc:
|
|
7595
|
+
err_msg = str(exc)
|
|
7596
|
+
self.safe_after(0, lambda: self._on_arch_export_error(err_msg))
|
|
7528
7597
|
|
|
7529
7598
|
threading.Thread(target=worker, daemon=True).start()
|
|
7530
7599
|
|
|
@@ -8010,15 +8079,54 @@ def launch_gui():
|
|
|
8010
8079
|
root.mainloop()
|
|
8011
8080
|
|
|
8012
8081
|
|
|
8013
|
-
def run_scan_cli(target_dir: str):
|
|
8082
|
+
def run_scan_cli(target_dir: str, output_format: str = "text"):
|
|
8014
8083
|
target_dir = os.path.abspath(target_dir)
|
|
8015
|
-
print(f"\n\033[1m\033[36m=== T-ZERO CODEBASE SCANNER ===\033[0m")
|
|
8016
|
-
print(f"Directory: {target_dir}\n")
|
|
8017
8084
|
if not os.path.exists(target_dir):
|
|
8018
|
-
|
|
8085
|
+
if output_format == "json":
|
|
8086
|
+
print(json.dumps({"error": f"Directory not found: {target_dir}", "workspace_dir": target_dir}))
|
|
8087
|
+
else:
|
|
8088
|
+
print(f"\n\033[1m\033[36m=== T-ZERO CODEBASE SCANNER ===\033[0m")
|
|
8089
|
+
print(f"Directory: {target_dir}\n")
|
|
8090
|
+
print(f"\033[31m[ERROR] Directory not found: {target_dir}\033[0m")
|
|
8019
8091
|
sys.exit(1)
|
|
8092
|
+
|
|
8020
8093
|
scanner = CodebaseScanner()
|
|
8021
8094
|
files, sizes, snippets = scanner.scan_directory(target_dir)
|
|
8095
|
+
|
|
8096
|
+
if output_format == "json":
|
|
8097
|
+
file_entries = []
|
|
8098
|
+
raw_tokens_total = 0
|
|
8099
|
+
pruned_tokens_total = 0
|
|
8100
|
+
for f in files:
|
|
8101
|
+
sz = sizes.get(f, 0)
|
|
8102
|
+
raw_tok = max(1, sz // 4) if sz > 0 else 0
|
|
8103
|
+
snip = snippets.get(f, "")
|
|
8104
|
+
pruned_tok = max(1, len(snip) // 4) if snip else 0
|
|
8105
|
+
raw_tokens_total += raw_tok
|
|
8106
|
+
pruned_tokens_total += pruned_tok
|
|
8107
|
+
file_entries.append({
|
|
8108
|
+
"file": f,
|
|
8109
|
+
"size_bytes": sz,
|
|
8110
|
+
"raw_tokens": raw_tok,
|
|
8111
|
+
"pruned_tokens": pruned_tok,
|
|
8112
|
+
})
|
|
8113
|
+
savings_pct = (
|
|
8114
|
+
round(max(0.0, (1.0 - (pruned_tokens_total / raw_tokens_total)) * 100.0), 1)
|
|
8115
|
+
if raw_tokens_total > 0
|
|
8116
|
+
else 0.0
|
|
8117
|
+
)
|
|
8118
|
+
print(json.dumps({
|
|
8119
|
+
"workspace_dir": target_dir,
|
|
8120
|
+
"total_files": len(files),
|
|
8121
|
+
"raw_tokens": raw_tokens_total,
|
|
8122
|
+
"pruned_tokens": pruned_tokens_total,
|
|
8123
|
+
"savings_pct": savings_pct,
|
|
8124
|
+
"files": file_entries,
|
|
8125
|
+
}, indent=2))
|
|
8126
|
+
return
|
|
8127
|
+
|
|
8128
|
+
print(f"\n\033[1m\033[36m=== T-ZERO CODEBASE SCANNER ===\033[0m")
|
|
8129
|
+
print(f"Directory: {target_dir}\n")
|
|
8022
8130
|
print(f"{'File':<55} | {'Size':<10} | {'Tokens':<8}")
|
|
8023
8131
|
print("-" * 78)
|
|
8024
8132
|
total_size = 0
|
|
@@ -8038,7 +8146,7 @@ def run_audit_cli(target_dir: str, output_format: str = "text"):
|
|
|
8038
8146
|
target_dir = os.path.abspath(target_dir)
|
|
8039
8147
|
all_issues = []
|
|
8040
8148
|
py_files = 0
|
|
8041
|
-
from tzero_features import should_skip_dir
|
|
8149
|
+
from tzero.tzero_features import should_skip_dir
|
|
8042
8150
|
for root, dirs, filenames in os.walk(target_dir):
|
|
8043
8151
|
dirs[:] = [d for d in dirs if not should_skip_dir(os.path.join(root, d), target_dir)]
|
|
8044
8152
|
for f in filenames:
|
|
@@ -8126,7 +8234,7 @@ def run_audit_cli(target_dir: str, output_format: str = "text"):
|
|
|
8126
8234
|
|
|
8127
8235
|
def run_pr_report_cli(target_dir: str, base_ref: str = "HEAD~1"):
|
|
8128
8236
|
target_dir = os.path.abspath(target_dir)
|
|
8129
|
-
from tzero_features import GitDiffContextBuilder, ChangeImpactAnalyzer
|
|
8237
|
+
from tzero.tzero_features import GitDiffContextBuilder, ChangeImpactAnalyzer
|
|
8130
8238
|
diff_builder = GitDiffContextBuilder(target_dir)
|
|
8131
8239
|
diff_res = diff_builder.build_diff_context(base_ref)
|
|
8132
8240
|
|
|
@@ -8188,8 +8296,8 @@ def run_review_cli(target_dir: str = ".", ref: str = "auto") -> bool:
|
|
|
8188
8296
|
"""
|
|
8189
8297
|
target_dir = os.path.abspath(target_dir)
|
|
8190
8298
|
import subprocess
|
|
8191
|
-
from tzero_security import ZeroLeakEngine
|
|
8192
|
-
from tzero_features import ZeroHallucinationGuard, ChangeImpactAnalyzer
|
|
8299
|
+
from tzero.tzero_security import ZeroLeakEngine
|
|
8300
|
+
from tzero.tzero_features import ZeroHallucinationGuard, ChangeImpactAnalyzer
|
|
8193
8301
|
|
|
8194
8302
|
print("\033[36m" + "=" * 80)
|
|
8195
8303
|
print("🔍 [T-ZERO AUTONOMOUS CODE REVIEW & REALITY-LOCK GATE]")
|
|
@@ -8232,7 +8340,9 @@ def run_review_cli(target_dir: str = ".", ref: str = "auto") -> bool:
|
|
|
8232
8340
|
content = line[1:]
|
|
8233
8341
|
added_lines.append(content)
|
|
8234
8342
|
if current_file and current_file.endswith(".py"):
|
|
8235
|
-
|
|
8343
|
+
norm = current_file.replace("\\", "/").lower()
|
|
8344
|
+
if not any(ign in norm for ign in ["installers/", "dist/", "build/", "site-packages/", "node_modules/", "vscode-extension/"]):
|
|
8345
|
+
added_code_lines.append(content)
|
|
8236
8346
|
|
|
8237
8347
|
full_added_text = "\n".join(added_lines)
|
|
8238
8348
|
full_added_code = "\n".join(added_code_lines)
|
|
@@ -8241,7 +8351,7 @@ def run_review_cli(target_dir: str = ".", ref: str = "auto") -> bool:
|
|
|
8241
8351
|
|
|
8242
8352
|
guard = ZeroHallucinationGuard(target_dir)
|
|
8243
8353
|
hallucination_violations = []
|
|
8244
|
-
for line in
|
|
8354
|
+
for line in added_code_lines:
|
|
8245
8355
|
line_s = line.strip()
|
|
8246
8356
|
if line_s.startswith("import ") or line_s.startswith("from "):
|
|
8247
8357
|
try:
|
|
@@ -8332,9 +8442,9 @@ def run_review_cli(target_dir: str = ".", ref: str = "auto") -> bool:
|
|
|
8332
8442
|
def run_demo_cli():
|
|
8333
8443
|
"""Runs a 100ms instant live interactive demonstration of T-Zero core engines."""
|
|
8334
8444
|
import time
|
|
8335
|
-
from tzero_features import ZeroHallucinationGuard
|
|
8336
|
-
from tzero_security import ZeroLeakEngine
|
|
8337
|
-
from tzero_polyglot import PolyglotTokenReducer
|
|
8445
|
+
from tzero.tzero_features import ZeroHallucinationGuard
|
|
8446
|
+
from tzero.tzero_security import ZeroLeakEngine
|
|
8447
|
+
from tzero.tzero_polyglot import PolyglotTokenReducer
|
|
8338
8448
|
|
|
8339
8449
|
sample_code = '''import os
|
|
8340
8450
|
import sys
|
|
@@ -8532,6 +8642,10 @@ def run_export_cli(project_dir: str, export_type: str, out_file: str):
|
|
|
8532
8642
|
else:
|
|
8533
8643
|
return
|
|
8534
8644
|
|
|
8645
|
+
if out_file == "-":
|
|
8646
|
+
print(content)
|
|
8647
|
+
return
|
|
8648
|
+
|
|
8535
8649
|
out_path = os.path.join(project_dir, out_file) if not os.path.isabs(out_file) else out_file
|
|
8536
8650
|
with open(out_path, "w", encoding="utf-8") as f:
|
|
8537
8651
|
f.write(content)
|
|
@@ -8575,18 +8689,21 @@ def run_watch_mode(target_dir: str = ".", interval: float = 1.0, once_test: bool
|
|
|
8575
8689
|
pass
|
|
8576
8690
|
return mtimes
|
|
8577
8691
|
|
|
8578
|
-
def reindex():
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8692
|
+
def reindex(changed_paths: Optional[List[str]] = None):
|
|
8693
|
+
from tzero.tzero_snapshot import SnapshotEngine
|
|
8694
|
+
snap, _ = SnapshotEngine.update_incremental(target_dir, changed_files=changed_paths)
|
|
8695
|
+
reduced_text = "\n\n".join(
|
|
8696
|
+
f"# --- {rel} ---\n{fs.skeleton}"
|
|
8697
|
+
for rel, fs in sorted(snap.files.items())
|
|
8698
|
+
if fs.skeleton
|
|
8699
|
+
)
|
|
8700
|
+
raw_tokens = max(1, snap.total_raw_tokens)
|
|
8701
|
+
reduced_tokens = max(1, snap.total_pruned_tokens)
|
|
8585
8702
|
sav = ((raw_tokens - reduced_tokens) / raw_tokens) * 100.0 if raw_tokens > 0 else 0.0
|
|
8586
8703
|
with open(out_file, "w", encoding="utf-8") as out_f:
|
|
8587
8704
|
out_f.write(reduced_text)
|
|
8588
8705
|
now = datetime.now().strftime("%H:%M:%S")
|
|
8589
|
-
print(f"\033[32m[{now}] ⚡ Re-indexed {
|
|
8706
|
+
print(f"\033[32m[{now}] ⚡ Re-indexed {snap.file_count} AST modules (~{reduced_tokens:,} tokens vs {raw_tokens:,} raw, -{sav:.1f}% savings)\033[0m")
|
|
8590
8707
|
|
|
8591
8708
|
reindex()
|
|
8592
8709
|
if once_test:
|
|
@@ -8600,16 +8717,17 @@ def run_watch_mode(target_dir: str = ".", interval: float = 1.0, once_test: bool
|
|
|
8600
8717
|
changes = []
|
|
8601
8718
|
for fp, mt in current_mtimes.items():
|
|
8602
8719
|
if fp not in last_mtimes or mt > last_mtimes[fp]:
|
|
8603
|
-
changes.append(os.path.relpath(fp, target_dir))
|
|
8720
|
+
changes.append(os.path.relpath(fp, target_dir).replace("\\", "/"))
|
|
8604
8721
|
for fp in last_mtimes:
|
|
8605
8722
|
if fp not in current_mtimes:
|
|
8606
|
-
|
|
8723
|
+
rel_path = os.path.relpath(fp, target_dir).replace("\\", "/")
|
|
8724
|
+
changes.append(f"deleted:{rel_path}")
|
|
8607
8725
|
|
|
8608
8726
|
if changes:
|
|
8609
8727
|
now = datetime.now().strftime("%H:%M:%S")
|
|
8610
8728
|
rel_disp = ", ".join(changes[:3]) + (f" (+{len(changes)-3} more)" if len(changes) > 3 else "")
|
|
8611
8729
|
print(f"\033[33m[{now}] 🔄 File change detected: {rel_disp}\033[0m")
|
|
8612
|
-
reindex()
|
|
8730
|
+
reindex([c.replace("deleted:", "") for c in changes])
|
|
8613
8731
|
last_mtimes = current_mtimes
|
|
8614
8732
|
except KeyboardInterrupt:
|
|
8615
8733
|
print("\n\033[36m[🛑 T-ZERO WATCHER STOPPED] Goodbye!\033[0m")
|
|
@@ -8654,6 +8772,7 @@ def main():
|
|
|
8654
8772
|
parser.add_argument("--info", "--quickstart", action="store_true", help="Show quickstart guide and simplest installation/usage steps")
|
|
8655
8773
|
parser.add_argument("--gui", "-g", action="store_true", help="Launch the GUI Dashboard")
|
|
8656
8774
|
parser.add_argument("--doctor", action="store_true", help="Check Python, dependencies, tkinter, git and keyring (installs missing packages)")
|
|
8775
|
+
parser.add_argument("--deep", action="store_true", help="Run deep offline subsystem self-check with all 9 v11 subsystems (use with --doctor)")
|
|
8657
8776
|
parser.add_argument("--pipe", nargs="?", const="", default=None, metavar="FILENAME_HINT", help="Read code/diff/schema from stdin, compress tokens, and output to stdout")
|
|
8658
8777
|
parser.add_argument("--clip", "--copy", nargs="?", const="", default=None, metavar="FILE", help="Prune file AST signatures and copy directly to system clipboard")
|
|
8659
8778
|
parser.add_argument("--sync", nargs="?", const=".", default=None, metavar="DIR", help="Synchronize active codebase rules across Cursor, Claude Code, Windsurf & Git hooks")
|
|
@@ -8672,15 +8791,27 @@ def main():
|
|
|
8672
8791
|
parser.add_argument("--pack", nargs="?", const=16000, type=int, default=None, metavar="BUDGET", help="Pack codebase into an exact token budget (default: 16000 tokens)")
|
|
8673
8792
|
parser.add_argument("--focus", default="", metavar="TARGET", help="Focus file or semantic search query for context budget packing")
|
|
8674
8793
|
parser.add_argument("--pack-out", default=None, metavar="FILE", help="Output file for packed context bundle (default: stdout)")
|
|
8794
|
+
context_delta = parser.add_mutually_exclusive_group()
|
|
8795
|
+
context_delta.add_argument("--context-delta", nargs=3, metavar=("BASE", "CURRENT", "OUTPUT"),
|
|
8796
|
+
help="Write a lossless context delta to a new file")
|
|
8797
|
+
context_delta.add_argument("--restore-context", nargs=3, metavar=("BASE", "DELTA", "OUTPUT"),
|
|
8798
|
+
help="Restore context bytes from a base and delta to a new file")
|
|
8799
|
+
context_delta.add_argument("--symbol-context", nargs="+", metavar="FILE_OR_SYMBOL",
|
|
8800
|
+
help="Emit complete Python definitions: FILE SYMBOL [SYMBOL ...]")
|
|
8801
|
+
parser.add_argument("--min-token-reduction", type=int, default=95, metavar="PERCENT",
|
|
8802
|
+
help="Minimum exact reduction for --symbol-context (default: 95)")
|
|
8803
|
+
parser.add_argument("--context-encoding", choices=("o200k_base", "cl100k_base"),
|
|
8804
|
+
default="o200k_base", help="BPE encoding for --symbol-context")
|
|
8805
|
+
parser.add_argument("--cache-aligned", action="store_true", help="Order context for KV-cache prefix stability (immutable static prefix before dynamic query suffix)")
|
|
8675
8806
|
parser.add_argument("--commit-msg", action="store_true", help="Generate Conventional Commit message from local AST git diff ($0 local engine)")
|
|
8676
|
-
parser.add_argument("--changelog", nargs="?", const="
|
|
8807
|
+
parser.add_argument("--changelog", nargs="?", const="v11.0.0", default=None, metavar="VERSION", help="Generate release CHANGELOG markdown from git history")
|
|
8677
8808
|
parser.add_argument("--ci", choices=["github", "gitlab", "pre-commit", "all"], default=None, help="Install turnkey CI/CD security and verification workflow")
|
|
8678
8809
|
parser.add_argument("--stubs", nargs="?", const=".", default=None, metavar="PATH", help="Generate PEP-484 AST type stubs (.pyi) for target file or workspace")
|
|
8679
8810
|
parser.add_argument("--stubs-out", default=None, metavar="DIR", help="Output directory for generated type stubs (default: alongside .py files)")
|
|
8680
8811
|
parser.add_argument("--guard-install", action="store_true", help="Install local git pre-commit zero-leak and token security hook")
|
|
8681
8812
|
parser.add_argument("--tui", "--monitor", "--cockpit", action="store_true", help="Launch live ANSI terminal cockpit and interactive executive dashboard")
|
|
8682
8813
|
parser.add_argument("--neural", "--cortex", action="store_true", help="Launch T-Zero Neural Cortex & Autonomous Multi-Agent OS")
|
|
8683
|
-
parser.add_argument("--swarm", nargs="?", const=".", default=None, metavar="MISSION", help="
|
|
8814
|
+
parser.add_argument("--swarm", "--subagent", "--subagents", nargs="?", const=".", default=None, metavar="MISSION", help="Autonomous dynamic subagent decomposition & multi-agent swarm execution")
|
|
8684
8815
|
parser.add_argument("--forge", nargs=2, metavar=("ROLE", "TASK"), help="Synthesize domain-specific subagent persona (e.g. --forge SecurityAuditor 'Audit API routes')")
|
|
8685
8816
|
parser.add_argument("--matrix", action="store_true", help="Display full 105 T-Zero Enterprise AI Capability Matrix")
|
|
8686
8817
|
parser.add_argument("--pillar", type=int, choices=range(1, 8), default=None, help="Filter --matrix by Pillar number (1 to 7)")
|
|
@@ -8689,15 +8820,47 @@ def main():
|
|
|
8689
8820
|
parser.add_argument("--benchmark", nargs="?", const=".", default=None, metavar="PATH", help="Run multi-model token reduction, latency & ROI benchmark (Claude, GPT-4o, Gemini, DeepSeek)")
|
|
8690
8821
|
parser.add_argument("--benchmark-svg", action="store_true", help="Generate animated macOS terminal SVG recording of benchmark for README")
|
|
8691
8822
|
parser.add_argument("--task-benchmark", action="store_true", help="Run empirical task-completion & BPE tokenizer benchmark (tiktoken)")
|
|
8823
|
+
parser.add_argument("--benchmark-suite", choices=["core", "adversarial"], default="core", help="Task benchmark suite selection (core or 8-task adversarial)")
|
|
8824
|
+
parser.add_argument("--ollama-model", default=None, metavar="MODEL", help="Optional local Ollama model tag for live prompt/completion accuracy benchmark")
|
|
8825
|
+
parser.add_argument("--scip-import", default=None, metavar="FILE", help="Import SCIP JSON or LSIF NDJSON cross-language index")
|
|
8826
|
+
parser.add_argument("--scip-symbol", default=None, metavar="SYMBOL", help="Optional symbol filter when querying --scip-import")
|
|
8827
|
+
parser.add_argument("--federation", nargs="?", const="list", default=None, metavar="ACTION", help="Cryptographic multi-repo AST federation (export, import, verify, list, impact)")
|
|
8828
|
+
parser.add_argument("--federation-out", default=None, metavar="FILE", help="Target manifest file for --federation export/import/verify")
|
|
8829
|
+
parser.add_argument("--federation-name", default=None, metavar="NAME", help="Repository identifier for --federation export")
|
|
8830
|
+
parser.add_argument("--federation-symbol", default=None, metavar="SYMBOL", help="Target symbol name for --federation impact cross-repo analysis")
|
|
8831
|
+
parser.add_argument("--federation-scip", default=None, metavar="FILE", help="Optional SCIP/LSIF index to augment --federation impact trace")
|
|
8692
8832
|
parser.add_argument("--huggingface", "--hf", action="store_true", help="Launch local Hugging Face Space Gradio app or display deployment guide")
|
|
8693
8833
|
parser.add_argument("--snapshot", nargs="?", const=".", default=None, metavar="DIR", help="Pre-compute sub-8ms AST context snapshot cache (.tzero/snapshot.json)")
|
|
8834
|
+
parser.add_argument("--hook", action="store_true", help="Run lifecycle hook guard for Claude Code, Gemini CLI, or Cursor (stdin JSON)")
|
|
8835
|
+
parser.add_argument("--hook-install", "--install", nargs="?", const="all", choices=["all", "claude", "cursor", "gemini"], default=None, dest="hook_install", help="Install T-Zero PreToolUse/PostToolUse hooks for Claude Code, Cursor, or Gemini CLI")
|
|
8836
|
+
parser.add_argument("--event", default="PreToolUse", help="Lifecycle hook event (PreToolUse or PostToolUse)")
|
|
8837
|
+
parser.add_argument("--lsp", action="store_true", help="Run T-Zero stdio JSON-RPC Language Server (Zero-Leak, boundaries, CodeLens)")
|
|
8838
|
+
parser.add_argument("--agent-kernel", action="store_true", help="Validate Agent Kernel WASM/FFI capability sandbox and Rust bridge status")
|
|
8694
8839
|
parser.add_argument("--fix", metavar="FILE_OR_CODE", default=None, help="Self-healing AST auto-corrector for hallucinated AI methods and phantom imports")
|
|
8695
8840
|
parser.add_argument("--bridge", metavar="FILE", default=None, help="Polyglot type & schema transpiler: convert Python models to TS, Rust, or Go")
|
|
8696
8841
|
parser.add_argument("--bridge-lang", choices=["ts", "rust", "go", "kt", "swift", "all"], default="ts", help="Target language for --bridge (ts, rust, go, kt, swift, all)")
|
|
8842
|
+
parser.add_argument("--bridge-reverse", metavar="FILE_OR_CODE", default=None, help="Reverse polyglot transpiler: convert TypeScript/Rust/Go schemas to Python dataclasses")
|
|
8843
|
+
parser.add_argument("--from-lang", choices=["ts", "rust", "go"], default="ts", help="Source language for --bridge-reverse (ts, rust, go)")
|
|
8844
|
+
parser.add_argument("--model-flavor", choices=["dataclass", "pydantic"], default="dataclass", help="Output model flavor for --bridge-reverse (dataclass, pydantic)")
|
|
8697
8845
|
parser.add_argument("--replay", nargs="?", const=15, type=int, default=None, metavar="COMMITS", help="Historical git token and financial ROI replay (default: 15 commits)")
|
|
8698
8846
|
parser.add_argument("--pc-fixer", "--fixer", nargs="?", const=".", default=None, metavar="DIR", help="Autonomous self-healing PC & codebase doctor (heal syntax, imports, venv, caches)")
|
|
8699
8847
|
parser.add_argument("--explain", metavar="FILE", default=None, help="Generate high-density AST architectural passport for file or LLM prompt")
|
|
8700
|
-
parser.add_argument("--
|
|
8848
|
+
parser.add_argument("--turbo", "--overdrive", "--kamcilama", nargs="?", const="status", default=None, metavar="CMD", help="Turbo Overdrive Burst Accelerator (Kamçılama): adaptive latency sensing & multi-core fast-path cache")
|
|
8849
|
+
parser.add_argument("--merge-heal", metavar="FILE", default=None, help="Autonomous AST semantic 3-way merge conflict healer")
|
|
8850
|
+
parser.add_argument("--generate-arch-tests", nargs="?", const="tests/test_architecture_guard.py", default=None, metavar="OUT_PATH", help="Generate zero-dependency standalone unittest architecture guard test suite from tzero.rules.json")
|
|
8851
|
+
parser.add_argument("--check-arch", "--arch-audit", action="store_true", help="Run live in-memory validation of layer boundaries, circular imports, and zero-leak security")
|
|
8852
|
+
parser.add_argument("--mutate", "--mutation-test", metavar="FILE", default=None, help="Autonomous AST mutation testing & test suite quality score (0-100%%)")
|
|
8853
|
+
parser.add_argument("--test-cmd", metavar="CMD", default=None, help="Target test command for --mutate (default: auto-detected unittest)")
|
|
8854
|
+
parser.add_argument("--max-mutants", type=int, default=10, metavar="N", help="Maximum AST mutants to generate and evaluate (default: 10)")
|
|
8855
|
+
parser.add_argument("--contracts", "--check-contracts", nargs="?", const="HEAD~1", default=None, metavar="BASE_REF", help="Audit public AST API contracts and SemVer compatibility against git base ref")
|
|
8856
|
+
parser.add_argument("--breaking-changes", nargs="?", const="HEAD~1", default=None, metavar="BASE_REF", help="Enforce zero-breaking-changes gate against git base ref (fails if breaking changes detected)")
|
|
8857
|
+
parser.add_argument("--contracts-sarif", nargs="?", const="-", default=None, metavar="OUT_PATH", help="Emit SARIF 2.1.0 contract report JSON to file or '-' for stdout")
|
|
8858
|
+
parser.add_argument("--debt", "--code-health", nargs="?", const=".", default=None, metavar="DIR", help="Autonomous AST technical debt, cognitive complexity & maintainability index")
|
|
8859
|
+
parser.add_argument("--budget", "--token-budget", nargs="?", const=".", default=None, metavar="DIR", help="Optimize codebase context payload to fit AI model token budget and issue SHA-256 certificate")
|
|
8860
|
+
parser.add_argument("--target-tokens", type=int, default=None, metavar="N", help="Target token budget for --budget (e.g. 16000, 64000)")
|
|
8861
|
+
parser.add_argument("--target-model", default="claude-3-7", metavar="MODEL", help="Target LLM model for --budget context sizing")
|
|
8862
|
+
parser.add_argument("--golden", "--goldens", nargs="?", const="generate", default=None, metavar="ACTION", help="Generate or verify golden AST public signature baseline (generate, verify, update)")
|
|
8863
|
+
parser.add_argument("--version", "-v", action="version", version="T-Zero Context Architect v11.0.0 Master Edition (engine v4.1.0)")
|
|
8701
8864
|
|
|
8702
8865
|
|
|
8703
8866
|
def print_master_tutorial():
|
|
@@ -8792,20 +8955,20 @@ Generate tailored subagent manifests (.tzero/agents/ + SKILL.md) in 1 second:
|
|
|
8792
8955
|
• 3D Synaptic Web Lab: $ python benchmark-site/serve.py (Opens on http://localhost:8080)
|
|
8793
8956
|
|
|
8794
8957
|
================================================================================
|
|
8795
|
-
|
|
8958
|
+
⚡ SIBER AKADEMI T-ZERO CONTEXT ARCHITECT & MCP ENGINE
|
|
8796
8959
|
================================================================================
|
|
8797
|
-
|
|
8798
|
-
|
|
8960
|
+
Engineered by Toprak Ahmet Aydoğmuş & Siber Akademi to eliminate token bloat,
|
|
8961
|
+
reduce prompt costs by up to 95%, and stop AI hallucinations worldwide.
|
|
8799
8962
|
If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
8800
8963
|
👉 https://github.com/toprakahmetaydogmus/TZeroAlgorithm
|
|
8801
|
-
|
|
8964
|
+
100% Free & Open-Source under MIT License. Thank you! 🚀
|
|
8802
8965
|
================================================================================
|
|
8803
8966
|
""")
|
|
8804
8967
|
|
|
8805
8968
|
def print_quickstart_guide():
|
|
8806
8969
|
print("""
|
|
8807
8970
|
================================================================================
|
|
8808
|
-
⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & MCP
|
|
8971
|
+
⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & MCP v11.0.0 MASTER (engine v4.1.0)
|
|
8809
8972
|
================================================================================
|
|
8810
8973
|
🎯 %95'e Varan Token Tasarrufu & Otonom Yapay Zeka Mimari Bağlam Motoru
|
|
8811
8974
|
|
|
@@ -8848,11 +9011,19 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
8848
9011
|
9️⃣ Hugging Face Space & Canlı Web Paneli:
|
|
8849
9012
|
$ tzero hf
|
|
8850
9013
|
|
|
8851
|
-
|
|
8852
|
-
|
|
9014
|
+
🔬 v11 FRONTIER CAPABILITIES:
|
|
9015
|
+
$ tzero --lsp # Zero-Leak Language Server (stdio JSON-RPC)
|
|
9016
|
+
$ tzero --hook-install all # Install AI lifecycle hook guardrails
|
|
9017
|
+
$ tzero --federation impact --federation-symbol SYMBOL # Cross-repo SCIP impact federation
|
|
9018
|
+
$ tzero --scip-import <FILE> # Binary SCIP protobuf graph import
|
|
9019
|
+
$ tzero --contracts-sarif report.sarif # Export contract changes as SARIF 2.1.0
|
|
9020
|
+
$ tzero --doctor --deep # Deep offline 9-subsystem self-check
|
|
9021
|
+
|
|
9022
|
+
⭐ PROJEYE BİR YILDIZLA DESTEK OLUN:
|
|
9023
|
+
Merhaba! Ben Toprak Ahmet Aydoğmuş. T-Zero'yu sıfırdan geliştirdim.
|
|
8853
9024
|
İşinize yaradıysa lütfen GitHub'da yıldız vermeyi unutmayın:
|
|
8854
9025
|
👉 https://github.com/toprakahmetaydogmus/TZeroAlgorithm
|
|
8855
|
-
|
|
9026
|
+
%100 Ücretsiz ve Açık Kaynak (MIT Lisansı). Teşekkürler! 🚀
|
|
8856
9027
|
================================================================================
|
|
8857
9028
|
""")
|
|
8858
9029
|
|
|
@@ -8896,6 +9067,8 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
8896
9067
|
"neural": "--neural",
|
|
8897
9068
|
"cortex": "--neural",
|
|
8898
9069
|
"swarm": "--swarm",
|
|
9070
|
+
"subagent": "--swarm",
|
|
9071
|
+
"subagents": "--swarm",
|
|
8899
9072
|
"forge": "--forge",
|
|
8900
9073
|
"matrix": "--matrix",
|
|
8901
9074
|
"tutorial": "--tutorial",
|
|
@@ -8917,6 +9090,30 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
8917
9090
|
"review": "--review",
|
|
8918
9091
|
"watch": "--watch",
|
|
8919
9092
|
"demo": "--demo",
|
|
9093
|
+
"turbo": "--turbo",
|
|
9094
|
+
"overdrive": "--turbo",
|
|
9095
|
+
"kamcilama": "--turbo",
|
|
9096
|
+
"generate-arch-tests": "--generate-arch-tests",
|
|
9097
|
+
"check-arch": "--check-arch",
|
|
9098
|
+
"arch-audit": "--check-arch",
|
|
9099
|
+
"mutate": "--mutate",
|
|
9100
|
+
"mutation-test": "--mutate",
|
|
9101
|
+
"contracts": "--contracts",
|
|
9102
|
+
"check-contracts": "--contracts",
|
|
9103
|
+
"breaking-changes": "--breaking-changes",
|
|
9104
|
+
"debt": "--debt",
|
|
9105
|
+
"health": "--debt",
|
|
9106
|
+
"code-health": "--debt",
|
|
9107
|
+
"budget": "--budget",
|
|
9108
|
+
"cert": "--budget",
|
|
9109
|
+
"certificate": "--budget",
|
|
9110
|
+
"golden": "--golden",
|
|
9111
|
+
"goldens": "--golden",
|
|
9112
|
+
"hook": "--hook",
|
|
9113
|
+
"lsp": "--lsp",
|
|
9114
|
+
"agent-kernel": "--agent-kernel",
|
|
9115
|
+
"scip": "--scip-import",
|
|
9116
|
+
"federation": "--federation",
|
|
8920
9117
|
}
|
|
8921
9118
|
if sub in sub_map:
|
|
8922
9119
|
sys.argv[1] = sub_map[sub]
|
|
@@ -8946,7 +9143,30 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
8946
9143
|
if tzero_deps is None:
|
|
8947
9144
|
print("[ERROR] tzero_deps.py is missing; reinstall T-Zero to use --doctor.")
|
|
8948
9145
|
sys.exit(1)
|
|
8949
|
-
sys.exit(tzero_deps.run_doctor())
|
|
9146
|
+
sys.exit(tzero_deps.run_doctor(deep=getattr(args, "deep", False)))
|
|
9147
|
+
elif getattr(args, "hook", False) or getattr(args, "hook_install", None) is not None:
|
|
9148
|
+
from tzero import tzero_hooks
|
|
9149
|
+
sys.exit(tzero_hooks.run_hook_cli(
|
|
9150
|
+
event=getattr(args, "event", "PreToolUse"),
|
|
9151
|
+
workspace_dir=args.dir,
|
|
9152
|
+
install_client=getattr(args, "hook_install", None),
|
|
9153
|
+
))
|
|
9154
|
+
elif getattr(args, "lsp", False):
|
|
9155
|
+
from tzero import tzero_lsp
|
|
9156
|
+
sys.exit(tzero_lsp.main(workspace_dir=args.dir))
|
|
9157
|
+
elif getattr(args, "agent_kernel", False):
|
|
9158
|
+
from tzero import tzero_rust_bridge
|
|
9159
|
+
sys.exit(tzero_rust_bridge.run_agent_kernel_cli(workspace_dir=args.dir))
|
|
9160
|
+
elif getattr(args, "federation", None) is not None:
|
|
9161
|
+
from tzero import tzero_federation
|
|
9162
|
+
sys.exit(tzero_federation.run_federation_cli(
|
|
9163
|
+
action=args.federation,
|
|
9164
|
+
workspace_dir=args.dir,
|
|
9165
|
+
target_file=getattr(args, "federation_out", None),
|
|
9166
|
+
repo_name=getattr(args, "federation_name", None),
|
|
9167
|
+
symbol_name=getattr(args, "federation_symbol", None) or getattr(args, "scip_symbol", None),
|
|
9168
|
+
scip_path=getattr(args, "federation_scip", None),
|
|
9169
|
+
))
|
|
8950
9170
|
elif args.init is not None:
|
|
8951
9171
|
import addmcp
|
|
8952
9172
|
target_arg = [] if args.init == "auto" else [args.init]
|
|
@@ -8955,14 +9175,14 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
8955
9175
|
import addmcp
|
|
8956
9176
|
sys.exit(addmcp.run_cli())
|
|
8957
9177
|
elif args.mcp:
|
|
8958
|
-
import tzero_mcp
|
|
9178
|
+
from tzero import tzero_mcp
|
|
8959
9179
|
tzero_mcp.main()
|
|
8960
9180
|
elif args.pipe is not None:
|
|
8961
|
-
from tzero_pipe import PipeCompressor
|
|
9181
|
+
from tzero.tzero_pipe import PipeCompressor
|
|
8962
9182
|
PipeCompressor.run_cli_pipe(filename_hint=args.pipe, copy_to_clipboard=bool(getattr(args, "clip", False)))
|
|
8963
9183
|
sys.exit(0)
|
|
8964
9184
|
elif args.clip is not None:
|
|
8965
|
-
from tzero_pipe import PipeCompressor
|
|
9185
|
+
from tzero.tzero_pipe import PipeCompressor
|
|
8966
9186
|
clip_target = args.clip if args.clip and args.clip != "" else args.dir
|
|
8967
9187
|
if os.path.isfile(clip_target):
|
|
8968
9188
|
with open(clip_target, "r", encoding="utf-8", errors="replace") as cf:
|
|
@@ -8981,13 +9201,13 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
8981
9201
|
print(f"\033[31m[ERROR] File not found: {clip_target}\033[0m")
|
|
8982
9202
|
sys.exit(1)
|
|
8983
9203
|
elif args.sync is not None:
|
|
8984
|
-
from tzero_sync import WorkspaceSyncManager
|
|
9204
|
+
from tzero.tzero_sync import WorkspaceSyncManager
|
|
8985
9205
|
target = args.sync or args.dir
|
|
8986
9206
|
res = WorkspaceSyncManager.sync(target)
|
|
8987
9207
|
WorkspaceSyncManager.render_cli(res)
|
|
8988
9208
|
sys.exit(0)
|
|
8989
9209
|
elif args.cost is not None:
|
|
8990
|
-
from tzero_cost import TokenCostCalculator
|
|
9210
|
+
from tzero.tzero_cost import TokenCostCalculator
|
|
8991
9211
|
target = args.cost or args.dir
|
|
8992
9212
|
rep = TokenCostCalculator.calculate_cost(target)
|
|
8993
9213
|
if getattr(args, "format", "text") == "json":
|
|
@@ -8996,7 +9216,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
8996
9216
|
TokenCostCalculator.render_cli(rep)
|
|
8997
9217
|
sys.exit(0)
|
|
8998
9218
|
elif args.drift is not None:
|
|
8999
|
-
from tzero_drift import DriftAnalyzer
|
|
9219
|
+
from tzero.tzero_drift import DriftAnalyzer
|
|
9000
9220
|
target = args.drift or args.dir
|
|
9001
9221
|
rep = DriftAnalyzer.analyze_workspace(target)
|
|
9002
9222
|
if getattr(args, "format", "text") == "json":
|
|
@@ -9005,7 +9225,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9005
9225
|
DriftAnalyzer.render_cli(rep)
|
|
9006
9226
|
sys.exit(0)
|
|
9007
9227
|
elif getattr(args, "snapshot", None) is not None:
|
|
9008
|
-
from tzero_snapshot import SnapshotEngine
|
|
9228
|
+
from tzero.tzero_snapshot import SnapshotEngine
|
|
9009
9229
|
target = args.snapshot or args.dir
|
|
9010
9230
|
snap, was_cached = SnapshotEngine.get_or_create(target)
|
|
9011
9231
|
if getattr(args, "format", "text") == "json":
|
|
@@ -9014,7 +9234,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9014
9234
|
SnapshotEngine.render_cli(snap, was_cached)
|
|
9015
9235
|
sys.exit(0)
|
|
9016
9236
|
elif getattr(args, "fix", None) is not None:
|
|
9017
|
-
from tzero_fix import ASTHallucinationAutoCorrector
|
|
9237
|
+
from tzero.tzero_fix import ASTHallucinationAutoCorrector
|
|
9018
9238
|
target = args.fix
|
|
9019
9239
|
if os.path.exists(target):
|
|
9020
9240
|
rep = ASTHallucinationAutoCorrector.heal_file(target, workspace_dir=args.dir, apply_write=True)
|
|
@@ -9024,19 +9244,151 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9024
9244
|
ASTHallucinationAutoCorrector.render_cli(rep, target_hint="inline_code")
|
|
9025
9245
|
sys.exit(0)
|
|
9026
9246
|
elif getattr(args, "bridge", None) is not None:
|
|
9027
|
-
from tzero_bridge import PolyglotTypeBridge
|
|
9247
|
+
from tzero.tzero_bridge import PolyglotTypeBridge
|
|
9028
9248
|
target = args.bridge
|
|
9029
9249
|
blang = getattr(args, "bridge_lang", "ts")
|
|
9030
9250
|
PolyglotTypeBridge.render_cli(target, blang)
|
|
9031
9251
|
sys.exit(0)
|
|
9252
|
+
elif getattr(args, "bridge_reverse", None) is not None:
|
|
9253
|
+
from tzero.tzero_bridge import PolyglotTypeBridge
|
|
9254
|
+
target = args.bridge_reverse
|
|
9255
|
+
flang = getattr(args, "from_lang", "ts")
|
|
9256
|
+
flavor = getattr(args, "model_flavor", "dataclass")
|
|
9257
|
+
if os.path.isfile(target):
|
|
9258
|
+
with open(target, "r", encoding="utf-8", errors="replace") as f:
|
|
9259
|
+
content = f.read()
|
|
9260
|
+
else:
|
|
9261
|
+
content = target
|
|
9262
|
+
out = PolyglotTypeBridge.reverse_transpile(content, source_lang=flang, model_flavor=flavor)
|
|
9263
|
+
print(f"\n🌉 \033[1mT-ZERO REVERSE POLYGLOT SCHEMA TRANSPILER ({flang.upper()} -> Python {flavor.capitalize()})\033[0m")
|
|
9264
|
+
print("=" * 70)
|
|
9265
|
+
print(out)
|
|
9266
|
+
print("=" * 70)
|
|
9267
|
+
sys.exit(0)
|
|
9268
|
+
elif getattr(args, "merge_heal", None) is not None:
|
|
9269
|
+
from tzero.tzero_semantic_merge import ASTSemanticMerger
|
|
9270
|
+
target = args.merge_heal
|
|
9271
|
+
res = ASTSemanticMerger.heal_file_on_disk(target, write_in_place=not getattr(args, "dry_run", False))
|
|
9272
|
+
ASTSemanticMerger.render_cli(res, file_hint=target)
|
|
9273
|
+
sys.exit(0 if res.success else 1)
|
|
9274
|
+
elif getattr(args, "generate_arch_tests", None) is not None:
|
|
9275
|
+
from tzero.tzero_arch_test import ArchitectureTestSuiteGenerator
|
|
9276
|
+
gen = ArchitectureTestSuiteGenerator(args.dir)
|
|
9277
|
+
target_p = os.path.join(args.dir, args.generate_arch_tests) if not os.path.isabs(args.generate_arch_tests) else args.generate_arch_tests
|
|
9278
|
+
out_p = gen.write_test_file(target_p)
|
|
9279
|
+
print(f"\n[⚡ T-ZERO ARCH-GUARD] Generated standalone architecture test suite at: {out_p}")
|
|
9280
|
+
print("[⚡ T-ZERO ARCH-GUARD] Run in CI/CD with: python -m unittest " + os.path.relpath(out_p, args.dir).replace("\\", "/"))
|
|
9281
|
+
sys.exit(0)
|
|
9282
|
+
elif getattr(args, "check_arch", False):
|
|
9283
|
+
from tzero.tzero_arch_test import ArchitectureTestSuiteGenerator
|
|
9284
|
+
gen = ArchitectureTestSuiteGenerator(args.dir)
|
|
9285
|
+
report = gen.run_live_audit()
|
|
9286
|
+
if report["success"]:
|
|
9287
|
+
print(f"\n✅ [T-ZERO ARCH-AUDIT PASS] All {report['scanned_files']} modules satisfy declared layer boundaries.")
|
|
9288
|
+
print(f" - Layers Configured : {report['layers_count']}")
|
|
9289
|
+
print(" - Circular Imports : 0 cycles detected")
|
|
9290
|
+
print(" - Zero-Leak Guard : 100% clean (0 secret leaks)\n")
|
|
9291
|
+
sys.exit(0)
|
|
9292
|
+
else:
|
|
9293
|
+
print("\n❌ [T-ZERO ARCH-AUDIT FAILED] Detected architectural infractions:")
|
|
9294
|
+
for v in report["layer_violations"]:
|
|
9295
|
+
print(f" [LAYER VIOLATION] {v['file']}:{v['line']} (layer: {v['layer']}) imports forbidden '{v['imported']}' - {v['reason']}")
|
|
9296
|
+
for c in report["circular_cycles"]:
|
|
9297
|
+
print(f" [CIRCULAR IMPORT] Cycle detected: {c}")
|
|
9298
|
+
for s in report["secret_leaks"]:
|
|
9299
|
+
print(f" [SECRET LEAK] {s['file']}: {s['pattern']}")
|
|
9300
|
+
print()
|
|
9301
|
+
sys.exit(1)
|
|
9302
|
+
elif getattr(args, "mutate", None) is not None:
|
|
9303
|
+
from tzero.tzero_mutation import ASTMutationEngine
|
|
9304
|
+
target = args.mutate
|
|
9305
|
+
print(f"\n🧬 [T-ZERO MUTATION ENGINE] Analyzing test robustness for '{target}'...")
|
|
9306
|
+
report = ASTMutationEngine.run_mutation_analysis(
|
|
9307
|
+
target_file=target,
|
|
9308
|
+
test_command=getattr(args, "test_cmd", None),
|
|
9309
|
+
max_mutants=getattr(args, "max_mutants", 10)
|
|
9310
|
+
)
|
|
9311
|
+
print(ASTMutationEngine.format_markdown_report(report))
|
|
9312
|
+
sys.exit(0 if report.mutation_score >= 70.0 else 1)
|
|
9313
|
+
elif (
|
|
9314
|
+
getattr(args, "contracts", None) is not None
|
|
9315
|
+
or getattr(args, "breaking_changes", None) is not None
|
|
9316
|
+
or getattr(args, "contracts_sarif", None) is not None
|
|
9317
|
+
):
|
|
9318
|
+
from tzero.tzero_contracts import ASTContractComparator
|
|
9319
|
+
base_ref = getattr(args, "contracts", None) or getattr(args, "breaking_changes", None) or "HEAD~1"
|
|
9320
|
+
is_gate = getattr(args, "breaking_changes", None) is not None
|
|
9321
|
+
sarif_out = getattr(args, "contracts_sarif", None)
|
|
9322
|
+
target_dir = getattr(args, "dir", ".") or "."
|
|
9323
|
+
|
|
9324
|
+
if sarif_out != "-":
|
|
9325
|
+
print(f"\n🛡️ [T-ZERO CONTRACT GUARDIAN] Evaluating AST public API changes against '{base_ref}'...")
|
|
9326
|
+
|
|
9327
|
+
reports = ASTContractComparator.compare_git_revision(repo_dir=target_dir, base_ref=base_ref)
|
|
9328
|
+
has_breaking = any(r.is_breaking for r in reports)
|
|
9329
|
+
|
|
9330
|
+
if sarif_out is not None:
|
|
9331
|
+
sarif = ASTContractComparator.format_sarif_report(reports)
|
|
9332
|
+
if sarif_out == "-":
|
|
9333
|
+
print(json.dumps(sarif, indent=2))
|
|
9334
|
+
else:
|
|
9335
|
+
with open(sarif_out, "w", encoding="utf-8") as f:
|
|
9336
|
+
json.dump(sarif, f, indent=2)
|
|
9337
|
+
md = ASTContractComparator.format_markdown_report(reports)
|
|
9338
|
+
print("\n" + md + "\n")
|
|
9339
|
+
print(f"✅ SARIF 2.1.0 contract report written to: {sarif_out}\n")
|
|
9340
|
+
else:
|
|
9341
|
+
md = ASTContractComparator.format_markdown_report(reports)
|
|
9342
|
+
print("\n" + md + "\n")
|
|
9343
|
+
|
|
9344
|
+
if is_gate and has_breaking:
|
|
9345
|
+
if sarif_out != "-":
|
|
9346
|
+
print("❌ [T-ZERO CONTRACT GATE FAILED] Incompatible breaking changes detected in public API.\n")
|
|
9347
|
+
sys.exit(1)
|
|
9348
|
+
sys.exit(0)
|
|
9349
|
+
elif getattr(args, "debt", None) is not None:
|
|
9350
|
+
from tzero.tzero_debt import CodeHealthAnalyzer
|
|
9351
|
+
target = args.debt or args.dir
|
|
9352
|
+
print(f"\n🏥 [T-ZERO HEALTH] Computing AST technical debt & maintainability index for '{target}'...")
|
|
9353
|
+
rep = CodeHealthAnalyzer.analyze_workspace(target)
|
|
9354
|
+
md = CodeHealthAnalyzer.format_markdown_report(rep)
|
|
9355
|
+
print("\n" + md + "\n")
|
|
9356
|
+
sys.exit(0)
|
|
9357
|
+
elif getattr(args, "budget", None) is not None:
|
|
9358
|
+
from tzero.tzero_budget import ASTTokenBudgetOptimizer
|
|
9359
|
+
target = args.budget or args.dir
|
|
9360
|
+
m_name = getattr(args, "target_model", "claude-3-7")
|
|
9361
|
+
b_tok = getattr(args, "target_tokens", None)
|
|
9362
|
+
print(f"\n📜 [T-ZERO BUDGET] Sizing context payload for '{target}' ({m_name})...")
|
|
9363
|
+
cert = ASTTokenBudgetOptimizer.optimize_budget(target, target_tokens=b_tok, model_name=m_name)
|
|
9364
|
+
saved_path = ASTTokenBudgetOptimizer.save_certificate(cert)
|
|
9365
|
+
md = ASTTokenBudgetOptimizer.format_markdown_certificate(cert)
|
|
9366
|
+
print("\n" + md + "\n")
|
|
9367
|
+
print(f"✅ Certificate issued & cryptographically signed at: {saved_path}\n")
|
|
9368
|
+
sys.exit(0)
|
|
9369
|
+
elif getattr(args, "golden", None) is not None:
|
|
9370
|
+
from tzero.tzero_golden import ASTGoldenRegressionEngine
|
|
9371
|
+
act = (args.golden or "generate").lower()
|
|
9372
|
+
if act in ("verify", "check", "audit"):
|
|
9373
|
+
print(f"\n🔍 [T-ZERO GOLDEN GUARD] Verifying AST signatures against baseline for '{args.dir}'...")
|
|
9374
|
+
rep = ASTGoldenRegressionEngine.verify_against_golden(args.dir)
|
|
9375
|
+
print("\n" + ASTGoldenRegressionEngine.format_markdown_report(rep) + "\n")
|
|
9376
|
+
sys.exit(0 if rep.get("clean", False) else 1)
|
|
9377
|
+
else:
|
|
9378
|
+
print(f"\n🏆 [T-ZERO GOLDEN ENGINE] Capturing golden AST signature baseline for '{args.dir}'...")
|
|
9379
|
+
baseline = ASTGoldenRegressionEngine.generate_baseline(args.dir)
|
|
9380
|
+
out_path = ASTGoldenRegressionEngine.save_baseline(baseline)
|
|
9381
|
+
print(f"✅ Captured {baseline.total_symbols} golden public AST signatures.")
|
|
9382
|
+
print(f"📁 Baseline stored & cryptographically signed at: {out_path}\n")
|
|
9383
|
+
sys.exit(0)
|
|
9032
9384
|
elif getattr(args, "replay", None) is not None:
|
|
9033
|
-
from tzero_replay import HistoricalTokenReplay
|
|
9385
|
+
from tzero.tzero_replay import HistoricalTokenReplay
|
|
9034
9386
|
max_c = args.replay if isinstance(args.replay, int) else 15
|
|
9035
9387
|
rep = HistoricalTokenReplay.replay_history(args.dir, max_commits=max_c)
|
|
9036
9388
|
HistoricalTokenReplay.render_cli(rep)
|
|
9037
9389
|
sys.exit(0)
|
|
9038
9390
|
elif getattr(args, "pc_fixer", None) is not None:
|
|
9039
|
-
from tzero_pc_fixer import PCFixerDoctor
|
|
9391
|
+
from tzero.tzero_pc_fixer import PCFixerDoctor
|
|
9040
9392
|
from dataclasses import asdict
|
|
9041
9393
|
target = args.pc_fixer or args.dir
|
|
9042
9394
|
res_heal = PCFixerDoctor.auto_heal(target, dry_run=getattr(args, "dry_run", False))
|
|
@@ -9047,7 +9399,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9047
9399
|
PCFixerDoctor.render_cli(diag, res_heal)
|
|
9048
9400
|
sys.exit(0)
|
|
9049
9401
|
elif getattr(args, "explain", None) is not None:
|
|
9050
|
-
from tzero_explain import ArchitecturalPassportGenerator
|
|
9402
|
+
from tzero.tzero_explain import ArchitecturalPassportGenerator
|
|
9051
9403
|
from dataclasses import asdict
|
|
9052
9404
|
target = args.explain
|
|
9053
9405
|
passport = ArchitecturalPassportGenerator.explain_file(target)
|
|
@@ -9056,12 +9408,84 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9056
9408
|
else:
|
|
9057
9409
|
ArchitecturalPassportGenerator.render_cli(passport)
|
|
9058
9410
|
sys.exit(0)
|
|
9411
|
+
elif getattr(args, "turbo", None) is not None:
|
|
9412
|
+
from tzero.tzero_turbo import get_turbo_accelerator
|
|
9413
|
+
turbo = get_turbo_accelerator()
|
|
9414
|
+
cmd = str(args.turbo).strip().lower()
|
|
9415
|
+
if cmd in ("bench", "benchmark", "test"):
|
|
9416
|
+
print("\033[36m================================================================================")
|
|
9417
|
+
print("🚀 T-ZERO TURBO OVERDRIVE: KAMÇILAMA BENCHMARK SUITE")
|
|
9418
|
+
print("================================================================================\033[0m")
|
|
9419
|
+
target_dir = getattr(args, "dir", ".") or "."
|
|
9420
|
+
test_files = []
|
|
9421
|
+
for root, _, files in os.walk(target_dir):
|
|
9422
|
+
if any(ignored in root for ignored in [".git", "node_modules", ".venv", "__pycache__", "dist", "build"]):
|
|
9423
|
+
continue
|
|
9424
|
+
for f in files:
|
|
9425
|
+
if f.endswith((".py", ".js", ".ts", ".go", ".rs", ".java")) and not f.startswith("."):
|
|
9426
|
+
test_files.append(os.path.join(root, f))
|
|
9427
|
+
if len(test_files) >= 30:
|
|
9428
|
+
break
|
|
9429
|
+
if len(test_files) >= 30:
|
|
9430
|
+
break
|
|
9431
|
+
|
|
9432
|
+
if not test_files:
|
|
9433
|
+
print("⚠️ No source files found in target directory to benchmark.")
|
|
9434
|
+
sys.exit(0)
|
|
9435
|
+
|
|
9436
|
+
print(f"📦 Benchmarking across {len(test_files)} source files...")
|
|
9437
|
+
turbo.clear_cache()
|
|
9438
|
+
|
|
9439
|
+
# Pass 1: Cold Sequential
|
|
9440
|
+
t0 = time.perf_counter()
|
|
9441
|
+
for fp in test_files:
|
|
9442
|
+
try:
|
|
9443
|
+
with open(fp, "r", encoding="utf-8", errors="ignore") as f:
|
|
9444
|
+
code = f.read(50000)
|
|
9445
|
+
TokenReducer.reduce(code, fp, mode="Ultra")
|
|
9446
|
+
except Exception:
|
|
9447
|
+
pass
|
|
9448
|
+
cold_seq_time = max(0.0001, time.perf_counter() - t0)
|
|
9449
|
+
|
|
9450
|
+
# Pass 2: Turbo Overdrive Parallel (Burst Mode / Kamçılama)
|
|
9451
|
+
turbo.clear_cache()
|
|
9452
|
+
turbo.set_force_overdrive(True)
|
|
9453
|
+
t1 = time.perf_counter()
|
|
9454
|
+
turbo.parallel_reduce_batch(
|
|
9455
|
+
test_files,
|
|
9456
|
+
lambda code, p, m: TokenReducer.reduce(code, p, mode=m),
|
|
9457
|
+
mode="Ultra"
|
|
9458
|
+
)
|
|
9459
|
+
turbo_cold_time = max(0.0001, time.perf_counter() - t1)
|
|
9460
|
+
|
|
9461
|
+
# Pass 3: Turbo Overdrive In-Memory Fast-Path Cache (Hot)
|
|
9462
|
+
t2 = time.perf_counter()
|
|
9463
|
+
turbo.parallel_reduce_batch(
|
|
9464
|
+
test_files,
|
|
9465
|
+
lambda code, p, m: TokenReducer.reduce(code, p, mode=m),
|
|
9466
|
+
mode="Ultra"
|
|
9467
|
+
)
|
|
9468
|
+
turbo_hot_time = max(0.0001, time.perf_counter() - t2)
|
|
9469
|
+
|
|
9470
|
+
speedup_cold = cold_seq_time / turbo_cold_time
|
|
9471
|
+
speedup_hot = cold_seq_time / turbo_hot_time
|
|
9472
|
+
|
|
9473
|
+
print(f"⏱️ Standard Sequential Run : {cold_seq_time * 1000.0:.2f} ms")
|
|
9474
|
+
print(f"⚡ Turbo Cold Parallel Burst : {turbo_cold_time * 1000.0:.2f} ms ({speedup_cold:.2f}x faster)")
|
|
9475
|
+
print(f"🔥 Turbo Hot In-Memory Cache : {turbo_hot_time * 1000.0:.2f} ms ({speedup_hot:.2f}x faster)")
|
|
9476
|
+
print("\n\033[32m✅ Kamçılama Modu Başarıyla Doğrulandı (Zero-Leak & Zero-Regression)!\033[0m\n")
|
|
9477
|
+
print(turbo.format_status_report())
|
|
9478
|
+
elif cmd in ("clear", "reset"):
|
|
9479
|
+
turbo.clear_cache()
|
|
9480
|
+
print("\033[32m⚡ [TURBO OVERDRIVE] Accelerator in-memory fast-path cache cleared.\033[0m")
|
|
9481
|
+
else:
|
|
9482
|
+
print(turbo.format_status_report())
|
|
9059
9483
|
sys.exit(0)
|
|
9060
9484
|
elif getattr(args, "tutorial", False) or getattr(args, "guide", False):
|
|
9061
9485
|
print_master_tutorial()
|
|
9062
9486
|
sys.exit(0)
|
|
9063
9487
|
elif getattr(args, "neural", False):
|
|
9064
|
-
from tzero_neural_cortex import CapabilityRegistry, TZeroAgentFleet
|
|
9488
|
+
from tzero.tzero_neural_cortex import CapabilityRegistry, TZeroAgentFleet
|
|
9065
9489
|
reg = CapabilityRegistry()
|
|
9066
9490
|
fleet = TZeroAgentFleet()
|
|
9067
9491
|
print("\033[36m================================================================================")
|
|
@@ -9072,7 +9496,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9072
9496
|
print("🌐 Neural Web Studio: Run 'python benchmark-site/serve.py' for 3D Neural Canvas (port 8080)")
|
|
9073
9497
|
sys.exit(0)
|
|
9074
9498
|
elif getattr(args, "matrix", False):
|
|
9075
|
-
from tzero_neural_cortex import CapabilityRegistry
|
|
9499
|
+
from tzero.tzero_neural_cortex import CapabilityRegistry
|
|
9076
9500
|
reg = CapabilityRegistry()
|
|
9077
9501
|
p_filter = getattr(args, "pillar", None)
|
|
9078
9502
|
all_caps = reg.search(pillar_num=p_filter) if p_filter else reg.list_all()
|
|
@@ -9090,23 +9514,23 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9090
9514
|
print(f" \033[32m[{cap.id}]\033[0m \033[1m{cap.name}\033[0m ({cap.tier}) - {cap.description}")
|
|
9091
9515
|
sys.exit(0)
|
|
9092
9516
|
elif getattr(args, "swarm", None) is not None:
|
|
9093
|
-
from
|
|
9094
|
-
coordinator = NeuralSwarmCoordinator()
|
|
9517
|
+
from tzero.tzero_subagent_engine import get_autonomous_swarm_coordinator
|
|
9095
9518
|
mission_text = args.swarm if args.swarm != "." else "Full Workspace AST & Security Audit"
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
print(f"
|
|
9102
|
-
print(f"Conflict-Free Isolation: {'✅ Active' if report['conflict_free'] else '⚠️ Overlapping'}")
|
|
9519
|
+
coordinator = get_autonomous_swarm_coordinator(workspace_root=args.dir)
|
|
9520
|
+
dossier = coordinator.execute_mission(mission_goal=mission_text)
|
|
9521
|
+
print(f"\n\033[36m🐝 T-ZERO DYNAMIC SUBAGENT SWARM: {mission_text}\033[0m")
|
|
9522
|
+
status_color = "\033[32m" if dossier.consensus == "APPROVED" else "\033[33m"
|
|
9523
|
+
print(f"Executive Consensus: {status_color}{dossier.consensus} ({dossier.consensus_score:.1f}%)\033[0m")
|
|
9524
|
+
print(f"Subagents Dispatched: {dossier.subagents_engaged} ({dossier.dynamic_subagents_created} dynamic on-the-fly) in {dossier.total_execution_ms:.1f}ms")
|
|
9103
9525
|
print("================================================================================")
|
|
9104
|
-
for res in
|
|
9105
|
-
|
|
9106
|
-
|
|
9526
|
+
for res in dossier.subagent_reports:
|
|
9527
|
+
r_color = "\033[32m" if res.verdict in ("APPROVED", "COMPLETED") else "\033[33m"
|
|
9528
|
+
dyn_tag = " \033[35m[DYNAMIC SYNTHESIS]\033[0m" if res.is_dynamic else ""
|
|
9529
|
+
finding_text = res.findings[0] if res.findings else ""
|
|
9530
|
+
print(f" {r_color}[{res.verdict}]\033[0m \033[1m{res.agent_name}\033[0m{dyn_tag}: {finding_text}")
|
|
9107
9531
|
sys.exit(0)
|
|
9108
9532
|
elif getattr(args, "forge", None) is not None:
|
|
9109
|
-
from tzero_neural_cortex import AgentForge
|
|
9533
|
+
from tzero.tzero_neural_cortex import AgentForge
|
|
9110
9534
|
role, task = args.forge
|
|
9111
9535
|
forge = AgentForge()
|
|
9112
9536
|
res = forge.synthesize_subagent(role=role, task=task, workspace_dir=args.dir)
|
|
@@ -9115,7 +9539,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9115
9539
|
print(f" - Skill: {res['generated_files']['SKILL.md']}")
|
|
9116
9540
|
sys.exit(0)
|
|
9117
9541
|
elif getattr(args, "hallucination_check", None) is not None:
|
|
9118
|
-
from tzero_neural_cortex import HallucinationGuard
|
|
9542
|
+
from tzero.tzero_neural_cortex import HallucinationGuard
|
|
9119
9543
|
target = args.hallucination_check
|
|
9120
9544
|
code_str = target
|
|
9121
9545
|
if os.path.isfile(target):
|
|
@@ -9132,7 +9556,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9132
9556
|
print(f" - Line {h.line_number}: {h.diagnosis}")
|
|
9133
9557
|
sys.exit(1)
|
|
9134
9558
|
elif args.init_hooks is not None:
|
|
9135
|
-
from tzero_guard import GitSecurityGuard
|
|
9559
|
+
from tzero.tzero_guard import GitSecurityGuard
|
|
9136
9560
|
res = GitSecurityGuard.install_hook(args.init_hooks)
|
|
9137
9561
|
if res.get("success"):
|
|
9138
9562
|
print(f"\033[32m[SUCCESS] {res['message']}\033[0m")
|
|
@@ -9142,7 +9566,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9142
9566
|
sys.exit(1)
|
|
9143
9567
|
elif args.web is not None:
|
|
9144
9568
|
try:
|
|
9145
|
-
from tzero_dashboard import start_dashboard_server
|
|
9569
|
+
from tzero.tzero_dashboard import start_dashboard_server
|
|
9146
9570
|
server = start_dashboard_server(port=args.web, open_browser=True)
|
|
9147
9571
|
try:
|
|
9148
9572
|
server.serve_forever()
|
|
@@ -9150,15 +9574,15 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9150
9574
|
print("\n[⚡ T-ZERO JARVIS DASHBOARD] Shutting down.")
|
|
9151
9575
|
server.server_close()
|
|
9152
9576
|
except Exception:
|
|
9153
|
-
from tzero_features import launch_web_dashboard
|
|
9577
|
+
from tzero.tzero_features import launch_web_dashboard
|
|
9154
9578
|
launch_web_dashboard(args.dir, port=args.web)
|
|
9155
9579
|
elif args.impact:
|
|
9156
|
-
from tzero_features import ChangeImpactAnalyzer
|
|
9580
|
+
from tzero.tzero_features import ChangeImpactAnalyzer
|
|
9157
9581
|
analyzer = ChangeImpactAnalyzer(args.dir)
|
|
9158
9582
|
analysis = analyzer.analyze_symbol(args.impact)
|
|
9159
9583
|
print(analyzer.format_report(analysis))
|
|
9160
9584
|
elif args.enforce_boundaries is not None:
|
|
9161
|
-
from tzero_features import ArchitectureRuleEngine
|
|
9585
|
+
from tzero.tzero_features import ArchitectureRuleEngine
|
|
9162
9586
|
config_p = os.path.join(args.dir, args.enforce_boundaries) if not os.path.isabs(args.enforce_boundaries) else args.enforce_boundaries
|
|
9163
9587
|
engine = ArchitectureRuleEngine(args.dir, config_p)
|
|
9164
9588
|
res = engine.enforce_boundaries()
|
|
@@ -9168,17 +9592,17 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9168
9592
|
else:
|
|
9169
9593
|
sys.exit(0)
|
|
9170
9594
|
elif args.search:
|
|
9171
|
-
from tzero_features import LocalSemanticCodeSearch
|
|
9595
|
+
from tzero.tzero_features import LocalSemanticCodeSearch
|
|
9172
9596
|
searcher = LocalSemanticCodeSearch(args.dir)
|
|
9173
9597
|
matches = searcher.search(args.search, top_k=6)
|
|
9174
9598
|
print(searcher.format_search_results(args.search, matches))
|
|
9175
9599
|
elif args.helpers:
|
|
9176
|
-
from tzero_features import ReusableHelperSuggester
|
|
9600
|
+
from tzero.tzero_features import ReusableHelperSuggester
|
|
9177
9601
|
suggester = ReusableHelperSuggester(args.dir)
|
|
9178
9602
|
matches = suggester.suggest_helpers(args.helpers, top_k=6)
|
|
9179
9603
|
print(suggester.format_helpers_report(matches, query=args.helpers))
|
|
9180
9604
|
elif args.guard:
|
|
9181
|
-
from tzero_features import ZeroHallucinationGuard
|
|
9605
|
+
from tzero.tzero_features import ZeroHallucinationGuard
|
|
9182
9606
|
code_input = args.guard
|
|
9183
9607
|
if os.path.exists(code_input) and os.path.isfile(code_input):
|
|
9184
9608
|
with open(code_input, "r", encoding="utf-8", errors="ignore") as f:
|
|
@@ -9193,24 +9617,24 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9193
9617
|
else:
|
|
9194
9618
|
sys.exit(0)
|
|
9195
9619
|
elif args.grounding_contract:
|
|
9196
|
-
from tzero_features import ZeroHallucinationGuard
|
|
9620
|
+
from tzero.tzero_features import ZeroHallucinationGuard
|
|
9197
9621
|
guard = ZeroHallucinationGuard(args.dir)
|
|
9198
9622
|
print(guard.generate_grounding_contract())
|
|
9199
9623
|
elif args.export_agent_rules:
|
|
9200
|
-
from tzero_features import AgentRulesGenerator
|
|
9624
|
+
from tzero.tzero_features import AgentRulesGenerator
|
|
9201
9625
|
created = AgentRulesGenerator.export_all(args.dir)
|
|
9202
9626
|
print(f"\n\033[32m[SUCCESS] Exported {len(created)} AI Agent rule files:")
|
|
9203
9627
|
for p in created:
|
|
9204
9628
|
print(f" - {os.path.relpath(p, args.dir)}")
|
|
9205
9629
|
print("\033[0m")
|
|
9206
9630
|
elif args.orchestrate_workspace is not None:
|
|
9207
|
-
from tzero_jarvis.workspace_orchestrator import WorkspaceOrchestrator
|
|
9631
|
+
from tzero.tzero_jarvis.workspace_orchestrator import WorkspaceOrchestrator
|
|
9208
9632
|
target_dir = args.orchestrate_workspace or args.dir
|
|
9209
9633
|
orch = WorkspaceOrchestrator(workspace_root=target_dir)
|
|
9210
9634
|
res = orch.orchestrate_workspace(auto_apply_rules=True, run_swarm=True)
|
|
9211
9635
|
print(res["executive_report_markdown"])
|
|
9212
9636
|
elif args.savings:
|
|
9213
|
-
from tzero_features import TokenROICalculator
|
|
9637
|
+
from tzero.tzero_features import TokenROICalculator
|
|
9214
9638
|
scanner = CodebaseScanner()
|
|
9215
9639
|
files, sizes, snippets = scanner.scan_directory(args.dir)
|
|
9216
9640
|
raw_chars = sum(sizes.values())
|
|
@@ -9220,7 +9644,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9220
9644
|
metrics = TokenROICalculator.calculate(raw_tokens, reduced_tokens)
|
|
9221
9645
|
print(TokenROICalculator.format_report(metrics))
|
|
9222
9646
|
elif args.diff is not None:
|
|
9223
|
-
from tzero_features import GitDiffContextBuilder
|
|
9647
|
+
from tzero.tzero_features import GitDiffContextBuilder
|
|
9224
9648
|
builder = GitDiffContextBuilder(args.dir)
|
|
9225
9649
|
res = builder.build_diff_context(args.diff)
|
|
9226
9650
|
print(res["markdown"])
|
|
@@ -9234,7 +9658,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9234
9658
|
run_demo_cli()
|
|
9235
9659
|
return
|
|
9236
9660
|
elif args.apply_patch is not None:
|
|
9237
|
-
from tzero_patch import ASTFuzzyPatcher, patch_file
|
|
9661
|
+
from tzero.tzero_patch import ASTFuzzyPatcher, patch_file
|
|
9238
9662
|
patch_arg = args.apply_patch
|
|
9239
9663
|
target = args.target
|
|
9240
9664
|
|
|
@@ -9269,26 +9693,61 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9269
9693
|
else:
|
|
9270
9694
|
print(f"\033[31m[FAILED] Could not apply patch to {target_path}: {res.get('error', 'Hunk match failed')}\033[0m")
|
|
9271
9695
|
sys.exit(1)
|
|
9696
|
+
elif args.symbol_context:
|
|
9697
|
+
import tokenize
|
|
9698
|
+
from tzero.tzero_packer import pack_python_symbols
|
|
9699
|
+
|
|
9700
|
+
source_path, *symbols = args.symbol_context
|
|
9701
|
+
try:
|
|
9702
|
+
with open(os.path.join(args.dir, source_path), "rb") as source_file:
|
|
9703
|
+
encoding, _ = tokenize.detect_encoding(source_file.readline)
|
|
9704
|
+
source_file.seek(0)
|
|
9705
|
+
source = source_file.read().decode(encoding)
|
|
9706
|
+
context = pack_python_symbols(
|
|
9707
|
+
source, symbols, args.min_token_reduction, args.context_encoding,
|
|
9708
|
+
)
|
|
9709
|
+
except (OSError, SyntaxError, ValueError) as exc:
|
|
9710
|
+
parser.exit(1, f"T-Zero symbol context: {exc}\n")
|
|
9711
|
+
sys.stdout.buffer.write(context.text.encode("utf-8"))
|
|
9712
|
+
print(
|
|
9713
|
+
f"{context.source_tokens:,} -> {context.context_tokens:,} tokens "
|
|
9714
|
+
f"({context.reduction_pct:.2f}% reduction, {context.encoding})",
|
|
9715
|
+
file=sys.stderr,
|
|
9716
|
+
)
|
|
9717
|
+
elif args.context_delta or args.restore_context:
|
|
9718
|
+
from tzero.tzero_packer import encode_context_delta, restore_context_delta
|
|
9719
|
+
|
|
9720
|
+
encode = args.context_delta is not None
|
|
9721
|
+
base_path, input_path, output_path = args.context_delta if encode else args.restore_context
|
|
9722
|
+
operation = encode_context_delta if encode else restore_context_delta
|
|
9723
|
+
try:
|
|
9724
|
+
with open(base_path, "rb") as base_file, open(input_path, "rb") as input_file:
|
|
9725
|
+
output = operation(base_file.read(), input_file.read())
|
|
9726
|
+
with open(output_path, "xb") as output_file:
|
|
9727
|
+
output_file.write(output)
|
|
9728
|
+
except (OSError, ValueError) as exc:
|
|
9729
|
+
parser.exit(1, f"T-Zero context delta: {exc}\n")
|
|
9272
9730
|
elif args.pack is not None:
|
|
9273
|
-
from tzero_packer import pack_workspace
|
|
9731
|
+
from tzero.tzero_packer import pack_workspace
|
|
9274
9732
|
budget = args.pack
|
|
9275
9733
|
focus = getattr(args, "focus", "")
|
|
9276
9734
|
out_f = getattr(args, "pack_out", None)
|
|
9277
|
-
|
|
9735
|
+
cache_aligned = getattr(args, "cache_aligned", False)
|
|
9736
|
+
res = pack_workspace(workspace_dir=args.dir, budget_tokens=budget, focus=focus, out_file=out_f, cache_aligned=cache_aligned)
|
|
9278
9737
|
if out_f:
|
|
9279
9738
|
print(f"\033[32m[SUCCESS] Packed context bundle ({res.total_tokens:,} tokens, {res.utilization_pct}% capacity) saved to: {out_f}\033[0m")
|
|
9280
9739
|
else:
|
|
9281
9740
|
print(res.bundle_text)
|
|
9282
9741
|
elif args.commit_msg:
|
|
9283
|
-
from tzero_commit import LocalSemanticCommitSynthesizer
|
|
9742
|
+
from tzero.tzero_commit import LocalSemanticCommitSynthesizer
|
|
9284
9743
|
msg = LocalSemanticCommitSynthesizer.generate_commit_message(repo_dir=args.dir, staged=True)
|
|
9285
9744
|
print(msg)
|
|
9286
9745
|
elif args.changelog is not None:
|
|
9287
|
-
from tzero_commit import LocalSemanticCommitSynthesizer
|
|
9746
|
+
from tzero.tzero_commit import LocalSemanticCommitSynthesizer
|
|
9288
9747
|
entry = LocalSemanticCommitSynthesizer.generate_changelog_entry(version=args.changelog, repo_dir=args.dir)
|
|
9289
9748
|
print(entry)
|
|
9290
9749
|
elif args.ci is not None:
|
|
9291
|
-
from tzero_ci import CIPipelineGenerator
|
|
9750
|
+
from tzero.tzero_ci import CIPipelineGenerator
|
|
9292
9751
|
target = args.ci
|
|
9293
9752
|
installed = []
|
|
9294
9753
|
if target in ("github", "all"):
|
|
@@ -9304,7 +9763,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9304
9763
|
for p in installed:
|
|
9305
9764
|
print(f" - {os.path.relpath(p, args.dir)}")
|
|
9306
9765
|
elif args.stubs is not None:
|
|
9307
|
-
from tzero_stubs import TypeStubGenerator
|
|
9766
|
+
from tzero.tzero_stubs import TypeStubGenerator
|
|
9308
9767
|
target = args.stubs
|
|
9309
9768
|
out_dir = getattr(args, "stubs_out", None)
|
|
9310
9769
|
if os.path.isfile(target):
|
|
@@ -9314,7 +9773,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9314
9773
|
res = TypeStubGenerator.generate_workspace_stubs(workspace_dir=target, output_dir=out_dir)
|
|
9315
9774
|
print(f"\033[32m[SUCCESS] Generated {res['total_files']} type stubs in {res['output_dir']} (~{res['stub_tokens']:,} tokens vs {res['raw_tokens']:,} raw tokens - {res['overall_savings_pct']}% reduction)\033[0m")
|
|
9316
9775
|
elif getattr(args, "guard_install", False):
|
|
9317
|
-
from tzero_guard import GitSecurityGuard
|
|
9776
|
+
from tzero.tzero_guard import GitSecurityGuard
|
|
9318
9777
|
res = GitSecurityGuard.install_hook(args.dir)
|
|
9319
9778
|
if res.get("success"):
|
|
9320
9779
|
print(f"\033[32m[SUCCESS] {res.get('message', 'Pre-commit zero-leak guard installed.')}\033[0m")
|
|
@@ -9322,7 +9781,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9322
9781
|
print(f"\033[31m[FAILED] {res.get('message')}\033[0m")
|
|
9323
9782
|
sys.exit(1)
|
|
9324
9783
|
elif getattr(args, "benchmark", None) is not None or getattr(args, "benchmark_svg", False):
|
|
9325
|
-
from tzero_benchmark import TZeroBenchmarkEngine
|
|
9784
|
+
from tzero.tzero_benchmark import TZeroBenchmarkEngine
|
|
9326
9785
|
target = args.benchmark if (args.benchmark and args.benchmark != ".") else args.dir
|
|
9327
9786
|
rep = TZeroBenchmarkEngine.run_benchmark(target)
|
|
9328
9787
|
if getattr(args, "benchmark_svg", False):
|
|
@@ -9332,16 +9791,21 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9332
9791
|
TZeroBenchmarkEngine.render_cli(rep)
|
|
9333
9792
|
out_p = TZeroBenchmarkEngine.generate_animated_svg(rep)
|
|
9334
9793
|
print(f"\033[32m[SUCCESS] Vector-animated macOS terminal recording saved to: {out_p}\033[0m")
|
|
9794
|
+
elif getattr(args, "scip_import", None) is not None:
|
|
9795
|
+
from tzero.tzero_scip import run_scip_import_cli
|
|
9796
|
+
sys.exit(run_scip_import_cli(args.scip_import, symbol=getattr(args, "scip_symbol", None)))
|
|
9335
9797
|
elif getattr(args, "task_benchmark", False):
|
|
9336
|
-
from tzero_task_benchmark import TaskCompletionBenchmark
|
|
9337
|
-
|
|
9798
|
+
from tzero.tzero_task_benchmark import TaskCompletionBenchmark
|
|
9799
|
+
suite_name = getattr(args, "benchmark_suite", "core")
|
|
9800
|
+
ollama_m = getattr(args, "ollama_model", None)
|
|
9801
|
+
rep = TaskCompletionBenchmark.evaluate_suite(suite=suite_name, ollama_model=ollama_m)
|
|
9338
9802
|
print(TaskCompletionBenchmark.format_terminal_summary(rep))
|
|
9339
9803
|
elif getattr(args, "huggingface", False):
|
|
9340
|
-
app_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "huggingface-space", "app.py")
|
|
9804
|
+
app_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "huggingface-space", "app.py")
|
|
9341
9805
|
if not os.path.exists(app_path):
|
|
9342
9806
|
app_path = os.path.join(os.getcwd(), "huggingface-space", "app.py")
|
|
9343
9807
|
print("\033[36m" + "=" * 80)
|
|
9344
|
-
print("🤗 SİBER AKADEMİ — T-ZERO HUGGING FACE SPACE & GRADIO COCKPIT (
|
|
9808
|
+
print("🤗 SİBER AKADEMİ — T-ZERO HUGGING FACE SPACE & GRADIO COCKPIT (v11.0.0)")
|
|
9345
9809
|
print("=" * 80 + "\033[0m")
|
|
9346
9810
|
print("🌐 Official Live Space : https://huggingface.co/spaces/toprakke4/tzero-token-reducer")
|
|
9347
9811
|
print(f"📁 Local Application : {app_path}")
|
|
@@ -9355,7 +9819,7 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9355
9819
|
else:
|
|
9356
9820
|
print("[INFO] Directory 'huggingface-space/' not found in current folder.")
|
|
9357
9821
|
elif getattr(args, "tui", False):
|
|
9358
|
-
from tzero_tui import TZeroTerminalCockpit
|
|
9822
|
+
from tzero.tzero_tui import TZeroTerminalCockpit
|
|
9359
9823
|
TZeroTerminalCockpit.run_interactive(args.dir)
|
|
9360
9824
|
elif args.gui:
|
|
9361
9825
|
launch_gui()
|
|
@@ -9363,9 +9827,9 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9363
9827
|
target = args.watch or args.dir
|
|
9364
9828
|
run_watch_mode(target)
|
|
9365
9829
|
elif args.scan is not None:
|
|
9366
|
-
run_scan_cli(args.scan or args.dir)
|
|
9830
|
+
run_scan_cli(args.scan or args.dir, output_format=getattr(args, "format", "text"))
|
|
9367
9831
|
elif getattr(args, "vault", None) is not None:
|
|
9368
|
-
from tzero_security import ZeroLeakEngine
|
|
9832
|
+
from tzero.tzero_security import ZeroLeakEngine
|
|
9369
9833
|
target = args.vault or args.dir
|
|
9370
9834
|
if os.path.isfile(target):
|
|
9371
9835
|
with open(target, "r", encoding="utf-8", errors="ignore") as f:
|
|
@@ -9397,7 +9861,8 @@ Every star means the world to a young open-source developer! 🚀
|
|
|
9397
9861
|
print(f" - [{v['provider']}] {v['file']}:{v['line']} -> {v['preview']}")
|
|
9398
9862
|
if args.migrate:
|
|
9399
9863
|
total_migrated = 0
|
|
9400
|
-
for
|
|
9864
|
+
violating_files = sorted({v.get("file", "") for v in violations if v.get("file")})
|
|
9865
|
+
for vf in violating_files:
|
|
9401
9866
|
if os.path.isfile(vf):
|
|
9402
9867
|
with open(vf, "r", encoding="utf-8", errors="ignore") as f:
|
|
9403
9868
|
sc = f.read()
|