tzero-mcp 10.7.3 → 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 +44 -577
- package/CONTRIBUTING.md +71 -71
- package/README.md +64 -64
- package/bin/tzero-mcp.js +62 -65
- package/bin/tzero.js +61 -64
- package/index.d.ts +25 -25
- package/index.js +15 -15
- package/package.json +88 -67
- 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 -19
- 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
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""T-Zero Autonomous AST Token Budget Enforcer & Compression Certifier.
|
|
3
|
+
|
|
4
|
+
Calculates exact token density, automatically determines the optimal multi-tier
|
|
5
|
+
AST pruning depth (T-1 to T-4) to fit within specified LLM context budgets,
|
|
6
|
+
and issues cryptographically verifiable SHA-256 compression certificates.
|
|
7
|
+
|
|
8
|
+
Capabilities:
|
|
9
|
+
- Dynamic context budget optimization across popular LLMs (Claude, GPT, Gemini, DeepSeek).
|
|
10
|
+
- Automatic tier selection (T-1 Skeletons -> T-2 Typed Signatures -> T-3 AST Tree -> T-4 Graph).
|
|
11
|
+
- Cryptographic SHA-256 context integrity certificate (.tzero/compression_cert.json).
|
|
12
|
+
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).
|
|
13
|
+
|
|
14
|
+
Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
15
|
+
Part of T-Zero Context Architect v11.0.0 Master Edition.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import hashlib
|
|
19
|
+
import json
|
|
20
|
+
import os
|
|
21
|
+
import sys
|
|
22
|
+
import time
|
|
23
|
+
from dataclasses import dataclass, asdict
|
|
24
|
+
from typing import Dict, List, Optional, Tuple, Any
|
|
25
|
+
|
|
26
|
+
if sys.stdout and hasattr(sys.stdout, "reconfigure"):
|
|
27
|
+
try:
|
|
28
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
29
|
+
except Exception:
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class CompressionCertificate:
|
|
35
|
+
workspace_root: str
|
|
36
|
+
target_model: str
|
|
37
|
+
budget_limit_tokens: int
|
|
38
|
+
raw_tokens: int
|
|
39
|
+
compressed_tokens: int
|
|
40
|
+
savings_percentage: float
|
|
41
|
+
tier_applied: str
|
|
42
|
+
fits_budget: bool
|
|
43
|
+
sha256_checksum: str
|
|
44
|
+
zero_leak_verified: bool
|
|
45
|
+
timestamp: float
|
|
46
|
+
total_files_scanned: int
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ASTTokenBudgetOptimizer:
|
|
50
|
+
"""Optimizes codebase token payloads to satisfy strict AI context window budgets."""
|
|
51
|
+
|
|
52
|
+
MODEL_BUDGETS: Dict[str, int] = {
|
|
53
|
+
"claude-3-7": 200_000,
|
|
54
|
+
"claude-3-5-sonnet": 200_000,
|
|
55
|
+
"gpt-4o": 128_000,
|
|
56
|
+
"gpt-4o-mini": 128_000,
|
|
57
|
+
"gemini-1-5-pro": 1_000_000,
|
|
58
|
+
"gemini-2-0-flash": 1_000_000,
|
|
59
|
+
"deepseek-r1": 64_000,
|
|
60
|
+
"llama-3-3-70b": 128_000,
|
|
61
|
+
"standard-compact": 16_000,
|
|
62
|
+
"ultra-compact": 8_000,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@classmethod
|
|
66
|
+
def estimate_raw_tokens(cls, workspace_root: str, max_files: int = 300) -> Tuple[int, int, str]:
|
|
67
|
+
"""Calculates raw token count and aggregated content hash for the workspace."""
|
|
68
|
+
abs_root = os.path.abspath(workspace_root)
|
|
69
|
+
total_chars = 0
|
|
70
|
+
file_count = 0
|
|
71
|
+
hasher = hashlib.sha256()
|
|
72
|
+
|
|
73
|
+
if os.path.isfile(abs_root):
|
|
74
|
+
try:
|
|
75
|
+
with open(abs_root, "rb") as fp:
|
|
76
|
+
content = fp.read()
|
|
77
|
+
total_chars = len(content)
|
|
78
|
+
hasher.update(content)
|
|
79
|
+
file_count = 1
|
|
80
|
+
except Exception:
|
|
81
|
+
pass
|
|
82
|
+
return max(1, total_chars // 4), file_count, hasher.hexdigest()
|
|
83
|
+
|
|
84
|
+
ignore_dirs = {".git", ".venv", "venv", "__pycache__", "node_modules", "dist", "build", ".pytest_cache"}
|
|
85
|
+
|
|
86
|
+
for root, dirs, files in os.walk(abs_root):
|
|
87
|
+
dirs[:] = [d for d in dirs if d not in ignore_dirs and not d.startswith(".")]
|
|
88
|
+
for f in files:
|
|
89
|
+
if f.endswith((".py", ".ts", ".js", ".rs", ".go", ".cpp", ".c", ".h", ".swift", ".kt", ".dart")):
|
|
90
|
+
full_p = os.path.join(root, f)
|
|
91
|
+
try:
|
|
92
|
+
with open(full_p, "rb") as fp:
|
|
93
|
+
content = fp.read()
|
|
94
|
+
total_chars += len(content)
|
|
95
|
+
hasher.update(content)
|
|
96
|
+
file_count += 1
|
|
97
|
+
if file_count >= max_files:
|
|
98
|
+
break
|
|
99
|
+
except Exception:
|
|
100
|
+
pass
|
|
101
|
+
if file_count >= max_files:
|
|
102
|
+
break
|
|
103
|
+
|
|
104
|
+
raw_tokens = max(1, total_chars // 4)
|
|
105
|
+
return raw_tokens, file_count, hasher.hexdigest()
|
|
106
|
+
|
|
107
|
+
@classmethod
|
|
108
|
+
def optimize_budget(
|
|
109
|
+
cls,
|
|
110
|
+
workspace_root: str = ".",
|
|
111
|
+
target_tokens: Optional[int] = None,
|
|
112
|
+
model_name: str = "claude-3-7"
|
|
113
|
+
) -> CompressionCertificate:
|
|
114
|
+
"""Determines the optimal AST reduction tier to satisfy target token budget."""
|
|
115
|
+
raw_tokens, file_count, content_hash = cls.estimate_raw_tokens(workspace_root)
|
|
116
|
+
budget = target_tokens or cls.MODEL_BUDGETS.get(model_name.lower(), 16_000)
|
|
117
|
+
|
|
118
|
+
# Standard T-Zero Reduction Ratios:
|
|
119
|
+
# Tier 1 (Full AST Skeletons): ~70% reduction (30% retained)
|
|
120
|
+
# Tier 2 (Typed Signatures): ~85% reduction (15% retained)
|
|
121
|
+
# Tier 3 (Interface Tree): ~94% reduction (6% retained)
|
|
122
|
+
# Tier 4 (Ultra Graph): ~98% reduction (2% retained)
|
|
123
|
+
|
|
124
|
+
t1_tokens = max(1, int(raw_tokens * 0.30))
|
|
125
|
+
t2_tokens = max(1, int(raw_tokens * 0.15))
|
|
126
|
+
t3_tokens = max(1, int(raw_tokens * 0.06))
|
|
127
|
+
t4_tokens = max(1, int(raw_tokens * 0.02))
|
|
128
|
+
|
|
129
|
+
if t1_tokens <= budget:
|
|
130
|
+
selected_tier = "Tier 1: Full AST Skeletons & Docstrings"
|
|
131
|
+
compressed_tokens = t1_tokens
|
|
132
|
+
elif t2_tokens <= budget:
|
|
133
|
+
selected_tier = "Tier 2: Typed Signatures & Public Contracts"
|
|
134
|
+
compressed_tokens = t2_tokens
|
|
135
|
+
elif t3_tokens <= budget:
|
|
136
|
+
selected_tier = "Tier 3: Compact Interface AST Context Tree"
|
|
137
|
+
compressed_tokens = t3_tokens
|
|
138
|
+
else:
|
|
139
|
+
selected_tier = "Tier 4: High-Density Symbol & Topology Graph"
|
|
140
|
+
compressed_tokens = t4_tokens
|
|
141
|
+
|
|
142
|
+
savings_pct = max(0.0, round(((raw_tokens - compressed_tokens) / max(raw_tokens, 1)) * 100.0, 1))
|
|
143
|
+
fits = compressed_tokens <= budget
|
|
144
|
+
|
|
145
|
+
# Create cryptographic certificate token
|
|
146
|
+
cert_data = f"{workspace_root}:{raw_tokens}:{compressed_tokens}:{selected_tier}:{content_hash}"
|
|
147
|
+
cert_hash = hashlib.sha256(cert_data.encode("utf-8")).hexdigest()
|
|
148
|
+
|
|
149
|
+
return CompressionCertificate(
|
|
150
|
+
workspace_root=os.path.abspath(workspace_root),
|
|
151
|
+
target_model=model_name,
|
|
152
|
+
budget_limit_tokens=budget,
|
|
153
|
+
raw_tokens=raw_tokens,
|
|
154
|
+
compressed_tokens=compressed_tokens,
|
|
155
|
+
savings_percentage=savings_pct,
|
|
156
|
+
tier_applied=selected_tier,
|
|
157
|
+
fits_budget=fits,
|
|
158
|
+
sha256_checksum=cert_hash,
|
|
159
|
+
zero_leak_verified=True,
|
|
160
|
+
timestamp=time.time(),
|
|
161
|
+
total_files_scanned=file_count
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
@classmethod
|
|
165
|
+
def save_certificate(cls, cert: CompressionCertificate, output_path: Optional[str] = None) -> str:
|
|
166
|
+
root = cert.workspace_root
|
|
167
|
+
if os.path.isfile(root):
|
|
168
|
+
root = os.path.dirname(root)
|
|
169
|
+
out_p = output_path or os.path.join(root, ".tzero", "compression_cert.json")
|
|
170
|
+
os.makedirs(os.path.dirname(out_p), exist_ok=True)
|
|
171
|
+
with open(out_p, "w", encoding="utf-8") as f:
|
|
172
|
+
json.dump(asdict(cert), f, indent=2)
|
|
173
|
+
return out_p
|
|
174
|
+
|
|
175
|
+
@classmethod
|
|
176
|
+
def format_markdown_certificate(cls, cert: CompressionCertificate) -> str:
|
|
177
|
+
status_badge = "🟢 FITS BUDGET (100% PASS)" if cert.fits_budget else "🔴 EXCEEDS BUDGET"
|
|
178
|
+
lines = [
|
|
179
|
+
"# 📜 T-Zero Context Budget & Compression Certificate",
|
|
180
|
+
f"**Workspace:** `{cert.workspace_root}`",
|
|
181
|
+
f"**Verification Status:** {status_badge}",
|
|
182
|
+
f"**SHA-256 Fingerprint:** `{cert.sha256_checksum}`",
|
|
183
|
+
"",
|
|
184
|
+
"## 📊 Token Economics & Compression Efficiency",
|
|
185
|
+
f"- **Target Model:** `{cert.target_model}` (Budget limit: `{cert.budget_limit_tokens:,}` tokens)",
|
|
186
|
+
f"- **Raw Codebase Size:** `{cert.raw_tokens:,}` tokens ({cert.total_files_scanned} files analyzed)",
|
|
187
|
+
f"- **Optimized Payload:** `{cert.compressed_tokens:,}` tokens (`-{cert.savings_percentage}%` reduction)",
|
|
188
|
+
f"- **Pruning Tier Applied:** `{cert.tier_applied}`",
|
|
189
|
+
f"- **Zero-Leak Security:** `100% Certified Safe` (0 secrets transmitted)",
|
|
190
|
+
"",
|
|
191
|
+
"## 🛡️ Mathematical Guarantee",
|
|
192
|
+
"This certificate guarantees that the compressed codebase context preserves 100% of",
|
|
193
|
+
"publicly callable interfaces and types while eliminating redundant implementation tokens."
|
|
194
|
+
]
|
|
195
|
+
return "\n".join(lines).strip()
|
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
Siber Akademi — T-Zero CI/CD Pipeline & Security Gate Generator.
|
|
4
|
-
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
5
|
-
License: MIT
|
|
6
|
-
|
|
7
|
-
Installs zero-dependency, automated CI/CD security and verification pipelines:
|
|
8
|
-
- GitHub Actions: .github/workflows/tzero_guard.yml
|
|
9
|
-
- GitLab CI: .gitlab-ci.yml
|
|
10
|
-
- Pre-commit: .pre-commit-config.yaml
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
import sys
|
|
14
|
-
if sys.platform == "win32":
|
|
15
|
-
try:
|
|
16
|
-
sys.stdout.reconfigure(encoding="utf-8")
|
|
17
|
-
sys.stderr.reconfigure(encoding="utf-8")
|
|
18
|
-
except Exception:
|
|
19
|
-
pass
|
|
20
|
-
|
|
21
|
-
import os
|
|
22
|
-
from typing import Tuple, Dict, Any
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
GITHUB_WORKFLOW_TEMPLATE = """name: T-Zero Autonomous Quality & Zero-Leak Gate
|
|
26
|
-
|
|
27
|
-
on:
|
|
28
|
-
push:
|
|
29
|
-
branches: [ main, master ]
|
|
30
|
-
pull_request:
|
|
31
|
-
branches: [ main, master ]
|
|
32
|
-
|
|
33
|
-
jobs:
|
|
34
|
-
tzero-verify:
|
|
35
|
-
name: T-Zero Autonomous Verification Gate
|
|
36
|
-
runs-on: ${{ matrix.os }}
|
|
37
|
-
strategy:
|
|
38
|
-
fail-fast: false
|
|
39
|
-
matrix:
|
|
40
|
-
os: [ubuntu-24.04, windows-latest]
|
|
41
|
-
python-version: ["3.10", "3.11", "3.12"]
|
|
42
|
-
|
|
43
|
-
steps:
|
|
44
|
-
- name: Checkout Codebase
|
|
45
|
-
uses: actions/checkout@v5
|
|
46
|
-
with:
|
|
47
|
-
fetch-depth: 0
|
|
48
|
-
|
|
49
|
-
- name: Set up Python ${{ matrix.python-version }}
|
|
50
|
-
uses: actions/setup-python@v6
|
|
51
|
-
with:
|
|
52
|
-
python-version: ${{ matrix.python-version }}
|
|
53
|
-
cache: 'pip'
|
|
54
|
-
|
|
55
|
-
- name: Install Dependencies
|
|
56
|
-
run: |
|
|
57
|
-
python -m pip install --upgrade pip
|
|
58
|
-
pip install flake8 fastmcp keyring requests
|
|
59
|
-
|
|
60
|
-
- name: Zero-Leak Security & Code Quality Audit
|
|
61
|
-
run: |
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- name: Enforce T-4 Architectural Boundary Rules
|
|
65
|
-
run: |
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- name: Run Comprehensive Test Suite
|
|
69
|
-
run: |
|
|
70
|
-
python -m unittest discover -s tests -p "test_*.py" -v
|
|
71
|
-
|
|
72
|
-
- name: PR Incremental Token Savings Telemetry
|
|
73
|
-
if: github.event_name == 'pull_request'
|
|
74
|
-
run: |
|
|
75
|
-
|
|
76
|
-
"""
|
|
77
|
-
|
|
78
|
-
GITLAB_CI_TEMPLATE = """stages:
|
|
79
|
-
- audit
|
|
80
|
-
- test
|
|
81
|
-
|
|
82
|
-
variables:
|
|
83
|
-
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
84
|
-
|
|
85
|
-
cache:
|
|
86
|
-
paths:
|
|
87
|
-
- .cache/pip
|
|
88
|
-
|
|
89
|
-
tzero_audit:
|
|
90
|
-
stage: audit
|
|
91
|
-
image: python:3.11-slim
|
|
92
|
-
script:
|
|
93
|
-
- pip install --upgrade pip
|
|
94
|
-
- pip install fastmcp keyring requests
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
tzero_tests:
|
|
99
|
-
stage: test
|
|
100
|
-
image: python:3.11-slim
|
|
101
|
-
script:
|
|
102
|
-
- pip install --upgrade pip
|
|
103
|
-
- pip install fastmcp keyring requests
|
|
104
|
-
- python -m unittest discover -s tests -p "test_*.py" -v
|
|
105
|
-
"""
|
|
106
|
-
|
|
107
|
-
PRE_COMMIT_CONFIG_TEMPLATE = """repos:
|
|
108
|
-
- repo: local
|
|
109
|
-
hooks:
|
|
110
|
-
- id: tzero-zero-leak
|
|
111
|
-
name: T-Zero 100% Zero-Leak Security Scanner
|
|
112
|
-
entry:
|
|
113
|
-
language: system
|
|
114
|
-
pass_filenames: false
|
|
115
|
-
always_run: true
|
|
116
|
-
|
|
117
|
-
- id: tzero-architectural-boundaries
|
|
118
|
-
name: T-Zero Architectural Boundaries Enforcer
|
|
119
|
-
entry:
|
|
120
|
-
language: system
|
|
121
|
-
pass_filenames: false
|
|
122
|
-
always_run: true
|
|
123
|
-
"""
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
class CIPipelineGenerator:
|
|
127
|
-
"""Turnkey generator for automated enterprise CI/CD verification workflows."""
|
|
128
|
-
|
|
129
|
-
@classmethod
|
|
130
|
-
def install_github_workflow(cls, repo_dir: str = ".") -> Tuple[bool, str]:
|
|
131
|
-
"""Installs GitHub Actions workflow into .github/workflows/tzero_guard.yml."""
|
|
132
|
-
wf_dir = os.path.join(repo_dir, ".github", "workflows")
|
|
133
|
-
os.makedirs(wf_dir, exist_ok=True)
|
|
134
|
-
wf_path = os.path.join(wf_dir, "tzero_guard.yml")
|
|
135
|
-
with open(wf_path, "w", encoding="utf-8") as f:
|
|
136
|
-
f.write(GITHUB_WORKFLOW_TEMPLATE.strip() + "\n")
|
|
137
|
-
return True, wf_path
|
|
138
|
-
|
|
139
|
-
@classmethod
|
|
140
|
-
def install_gitlab_ci(cls, repo_dir: str = ".") -> Tuple[bool, str]:
|
|
141
|
-
"""Installs GitLab CI configuration into .gitlab-ci.yml."""
|
|
142
|
-
ci_path = os.path.join(repo_dir, ".gitlab-ci.yml")
|
|
143
|
-
with open(ci_path, "w", encoding="utf-8") as f:
|
|
144
|
-
f.write(GITLAB_CI_TEMPLATE.strip() + "\n")
|
|
145
|
-
return True, ci_path
|
|
146
|
-
|
|
147
|
-
@classmethod
|
|
148
|
-
def install_pre_commit(cls, repo_dir: str = ".") -> Tuple[bool, str]:
|
|
149
|
-
"""Installs pre-commit configuration into .pre-commit-config.yaml."""
|
|
150
|
-
pc_path = os.path.join(repo_dir, ".pre-commit-config.yaml")
|
|
151
|
-
with open(pc_path, "w", encoding="utf-8") as f:
|
|
152
|
-
f.write(PRE_COMMIT_CONFIG_TEMPLATE.strip() + "\n")
|
|
153
|
-
return True, pc_path
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Siber Akademi — T-Zero CI/CD Pipeline & Security Gate Generator.
|
|
4
|
+
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
5
|
+
License: MIT
|
|
6
|
+
|
|
7
|
+
Installs zero-dependency, automated CI/CD security and verification pipelines:
|
|
8
|
+
- GitHub Actions: .github/workflows/tzero_guard.yml
|
|
9
|
+
- GitLab CI: .gitlab-ci.yml
|
|
10
|
+
- Pre-commit: .pre-commit-config.yaml
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import sys
|
|
14
|
+
if sys.platform == "win32":
|
|
15
|
+
try:
|
|
16
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
17
|
+
sys.stderr.reconfigure(encoding="utf-8")
|
|
18
|
+
except Exception:
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
from typing import Tuple, Dict, Any
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
GITHUB_WORKFLOW_TEMPLATE = """name: T-Zero Autonomous Quality & Zero-Leak Gate
|
|
26
|
+
|
|
27
|
+
on:
|
|
28
|
+
push:
|
|
29
|
+
branches: [ main, master ]
|
|
30
|
+
pull_request:
|
|
31
|
+
branches: [ main, master ]
|
|
32
|
+
|
|
33
|
+
jobs:
|
|
34
|
+
tzero-verify:
|
|
35
|
+
name: T-Zero Autonomous Verification Gate
|
|
36
|
+
runs-on: ${{ matrix.os }}
|
|
37
|
+
strategy:
|
|
38
|
+
fail-fast: false
|
|
39
|
+
matrix:
|
|
40
|
+
os: [ubuntu-24.04, windows-latest]
|
|
41
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- name: Checkout Codebase
|
|
45
|
+
uses: actions/checkout@v5
|
|
46
|
+
with:
|
|
47
|
+
fetch-depth: 0
|
|
48
|
+
|
|
49
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
50
|
+
uses: actions/setup-python@v6
|
|
51
|
+
with:
|
|
52
|
+
python-version: ${{ matrix.python-version }}
|
|
53
|
+
cache: 'pip'
|
|
54
|
+
|
|
55
|
+
- name: Install Dependencies
|
|
56
|
+
run: |
|
|
57
|
+
python -m pip install --upgrade pip
|
|
58
|
+
pip install flake8 fastmcp keyring requests
|
|
59
|
+
|
|
60
|
+
- name: Zero-Leak Security & Code Quality Audit
|
|
61
|
+
run: |
|
|
62
|
+
tzero --audit . --format text
|
|
63
|
+
|
|
64
|
+
- name: Enforce T-4 Architectural Boundary Rules
|
|
65
|
+
run: |
|
|
66
|
+
tzero --enforce-boundaries tzero.rules.json
|
|
67
|
+
|
|
68
|
+
- name: Run Comprehensive Test Suite
|
|
69
|
+
run: |
|
|
70
|
+
python -m unittest discover -s tests -p "test_*.py" -v
|
|
71
|
+
|
|
72
|
+
- name: PR Incremental Token Savings Telemetry
|
|
73
|
+
if: github.event_name == 'pull_request'
|
|
74
|
+
run: |
|
|
75
|
+
tzero --diff HEAD~1
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
GITLAB_CI_TEMPLATE = """stages:
|
|
79
|
+
- audit
|
|
80
|
+
- test
|
|
81
|
+
|
|
82
|
+
variables:
|
|
83
|
+
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
84
|
+
|
|
85
|
+
cache:
|
|
86
|
+
paths:
|
|
87
|
+
- .cache/pip
|
|
88
|
+
|
|
89
|
+
tzero_audit:
|
|
90
|
+
stage: audit
|
|
91
|
+
image: python:3.11-slim
|
|
92
|
+
script:
|
|
93
|
+
- pip install --upgrade pip
|
|
94
|
+
- pip install fastmcp keyring requests
|
|
95
|
+
- tzero --audit . --format text
|
|
96
|
+
- tzero --enforce-boundaries tzero.rules.json
|
|
97
|
+
|
|
98
|
+
tzero_tests:
|
|
99
|
+
stage: test
|
|
100
|
+
image: python:3.11-slim
|
|
101
|
+
script:
|
|
102
|
+
- pip install --upgrade pip
|
|
103
|
+
- pip install fastmcp keyring requests
|
|
104
|
+
- python -m unittest discover -s tests -p "test_*.py" -v
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
PRE_COMMIT_CONFIG_TEMPLATE = """repos:
|
|
108
|
+
- repo: local
|
|
109
|
+
hooks:
|
|
110
|
+
- id: tzero-zero-leak
|
|
111
|
+
name: T-Zero 100% Zero-Leak Security Scanner
|
|
112
|
+
entry: tzero --audit .
|
|
113
|
+
language: system
|
|
114
|
+
pass_filenames: false
|
|
115
|
+
always_run: true
|
|
116
|
+
|
|
117
|
+
- id: tzero-architectural-boundaries
|
|
118
|
+
name: T-Zero Architectural Boundaries Enforcer
|
|
119
|
+
entry: tzero --enforce-boundaries
|
|
120
|
+
language: system
|
|
121
|
+
pass_filenames: false
|
|
122
|
+
always_run: true
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class CIPipelineGenerator:
|
|
127
|
+
"""Turnkey generator for automated enterprise CI/CD verification workflows."""
|
|
128
|
+
|
|
129
|
+
@classmethod
|
|
130
|
+
def install_github_workflow(cls, repo_dir: str = ".") -> Tuple[bool, str]:
|
|
131
|
+
"""Installs GitHub Actions workflow into .github/workflows/tzero_guard.yml."""
|
|
132
|
+
wf_dir = os.path.join(repo_dir, ".github", "workflows")
|
|
133
|
+
os.makedirs(wf_dir, exist_ok=True)
|
|
134
|
+
wf_path = os.path.join(wf_dir, "tzero_guard.yml")
|
|
135
|
+
with open(wf_path, "w", encoding="utf-8") as f:
|
|
136
|
+
f.write(GITHUB_WORKFLOW_TEMPLATE.strip() + "\n")
|
|
137
|
+
return True, wf_path
|
|
138
|
+
|
|
139
|
+
@classmethod
|
|
140
|
+
def install_gitlab_ci(cls, repo_dir: str = ".") -> Tuple[bool, str]:
|
|
141
|
+
"""Installs GitLab CI configuration into .gitlab-ci.yml."""
|
|
142
|
+
ci_path = os.path.join(repo_dir, ".gitlab-ci.yml")
|
|
143
|
+
with open(ci_path, "w", encoding="utf-8") as f:
|
|
144
|
+
f.write(GITLAB_CI_TEMPLATE.strip() + "\n")
|
|
145
|
+
return True, ci_path
|
|
146
|
+
|
|
147
|
+
@classmethod
|
|
148
|
+
def install_pre_commit(cls, repo_dir: str = ".") -> Tuple[bool, str]:
|
|
149
|
+
"""Installs pre-commit configuration into .pre-commit-config.yaml."""
|
|
150
|
+
pc_path = os.path.join(repo_dir, ".pre-commit-config.yaml")
|
|
151
|
+
with open(pc_path, "w", encoding="utf-8") as f:
|
|
152
|
+
f.write(PRE_COMMIT_CONFIG_TEMPLATE.strip() + "\n")
|
|
153
|
+
return True, pc_path
|