tzero-mcp 10.7.0 → 10.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/tzero-mcp.js +9 -16
- package/bin/tzero.js +9 -16
- package/index.js +7 -2
- package/package.json +2 -1
- package/src/addmcp.py +1194 -0
- package/src/main.py +60 -0
- package/src/siber_akademi_icon.py +77 -0
- package/src/tzero/jarvis/semantic_compressor.py +373 -0
- package/src/tzero.py +58 -0
- package/src/tzero_benchmark.py +475 -0
- package/src/tzero_bridge.py +362 -0
- package/src/tzero_ci.py +153 -0
- package/src/tzero_commit.py +192 -0
- package/src/tzero_cost.py +163 -0
- package/src/tzero_dashboard.py +1448 -0
- package/src/tzero_deps.py +287 -0
- package/src/tzero_drift.py +208 -0
- package/src/tzero_explain.py +240 -0
- package/src/tzero_features.py +3022 -0
- package/src/tzero_fix.py +228 -0
- package/src/tzero_fixer/__init__.py +63 -0
- package/src/tzero_fixer/amalgamation.py +334 -0
- package/src/tzero_fixer/ast_syntax_healer.py +464 -0
- package/src/tzero_fixer/ast_type_modernizer.py +288 -0
- package/src/tzero_fixer/async_io_modernizer.py +127 -0
- package/src/tzero_fixer/automated_regression_suite.py +600 -0
- package/src/tzero_fixer/benchmarks_and_diagnostics.py +174 -0
- package/src/tzero_fixer/ci_cd_self_healing_gate.py +246 -0
- package/src/tzero_fixer/code_duplicity_and_refactorer.py +151 -0
- package/src/tzero_fixer/code_smells_healer.py +260 -0
- package/src/tzero_fixer/cwe_remediator.py +171 -0
- package/src/tzero_fixer/dead_code_eliminator.py +150 -0
- package/src/tzero_fixer/dependency_vulnerability_auditor.py +309 -0
- package/src/tzero_fixer/git_advanced_surgeon.py +280 -0
- package/src/tzero_fixer/hardware_and_disk_doctor.py +325 -0
- package/src/tzero_fixer/import_graph_healer.py +412 -0
- package/src/tzero_fixer/interactive_tui.py +91 -0
- package/src/tzero_fixer/knowledge_base.py +295 -0
- package/src/tzero_fixer/knowledge_base_extended.py +940 -0
- package/src/tzero_fixer/linters_and_static_analyzer.py +307 -0
- package/src/tzero_fixer/mcp_server.py +447 -0
- package/src/tzero_fixer/models.py +385 -0
- package/src/tzero_fixer/orchestrator.py +375 -0
- package/src/tzero_fixer/os_doctor.py +502 -0
- package/src/tzero_fixer/packaging_abi_surgeon.py +323 -0
- package/src/tzero_fixer/pc_fixer_doctor.py +599 -0
- package/src/tzero_fixer/performance_and_memory_profiler.py +274 -0
- package/src/tzero_fixer/polyglot_ast_parsers.py +313 -0
- package/src/tzero_fixer/polyglot_build_healer.py +364 -0
- package/src/tzero_fixer/polyglot_config_healer.py +318 -0
- package/src/tzero_fixer/polyglot_doctor.py +372 -0
- package/src/tzero_fixer/polyglot_linters.py +619 -0
- package/src/tzero_fixer/polyglot_schema_validator.py +305 -0
- package/src/tzero_fixer/security_cwe_database.py +444 -0
- package/src/tzero_fixer/security_deep_rules.py +114 -0
- package/src/tzero_fixer/security_rules_catalog.py +110 -0
- package/src/tzero_fixer/security_zero_leak.py +326 -0
- package/src/tzero_fixer/smart_patch_recommender.py +223 -0
- package/src/tzero_fixer/synthetic_workspace_generator.py +220 -0
- package/src/tzero_fixer/system_diagnostics_extended.py +493 -0
- package/src/tzero_fixer/system_repair_recipes.py +447 -0
- package/src/tzero_fixer/venv_doctor.py +309 -0
- package/src/tzero_gateway.py +885 -0
- package/src/tzero_guard.py +243 -0
- package/src/tzero_infra.py +274 -0
- package/src/tzero_jarvis/__init__.py +124 -0
- package/src/tzero_jarvis/causal_graph.py +310 -0
- package/src/tzero_jarvis/graph_visualizer.py +395 -0
- package/src/tzero_jarvis/hybrid_search.py +214 -0
- package/src/tzero_jarvis/latent_press.py +137 -0
- package/src/tzero_jarvis/memory_consolidation.py +212 -0
- package/src/tzero_jarvis/minhash_lsh.py +184 -0
- package/src/tzero_jarvis/orchestrator.py +335 -0
- package/src/tzero_jarvis/self_healing.py +308 -0
- package/src/tzero_jarvis/semantic_compressor.py +887 -0
- package/src/tzero_jarvis/swarm.py +261 -0
- package/src/tzero_jarvis/swarm_bft.py +144 -0
- package/src/tzero_jarvis/workspace_orchestrator.py +1167 -0
- package/src/tzero_jarvis/zero_key_router.py +173 -0
- package/src/tzero_mcp.py +4858 -0
- package/src/tzero_neural_cortex.py +1425 -0
- package/src/tzero_packer.py +370 -0
- package/src/tzero_patch.py +624 -0
- package/src/tzero_pc_fixer.py +12657 -0
- package/src/tzero_pipe.py +95 -0
- package/src/tzero_polyglot.py +422 -0
- package/src/tzero_reachability.py +272 -0
- package/src/tzero_replay.py +141 -0
- package/src/tzero_security.py +570 -0
- package/src/tzero_snapshot.py +258 -0
- package/src/tzero_stubs.py +313 -0
- package/src/tzero_superdesign.py +774 -0
- package/src/tzero_sync.py +241 -0
- package/src/tzero_task_benchmark.py +363 -0
- package/src/tzero_tui.py +244 -0
- package/src/tzero_v3.py +9435 -0
|
@@ -0,0 +1,1167 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
T-ZERO JARVIS MASTER WORKSPACE ORCHESTRATOR & EXECUTIVE GOVERNANCE ENGINE
|
|
4
|
+
------------------------------------------------------------------------
|
|
5
|
+
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
6
|
+
Version: 5.0.0
|
|
7
|
+
|
|
8
|
+
Evrensel Çalışma Alanı Yöneticisi ve Otonom Orkestratör:
|
|
9
|
+
Herhangi bir yazılım projesini (Python, TypeScript, JavaScript, Rust, Go, C++,
|
|
10
|
+
Java, C#, Monorepo, Microservice vb.) derinlemesine analiz eder, teknoloji yığınını
|
|
11
|
+
ve mimari katmanlarını tespit eder; yapay zeka kodlama ajanları (Cursor, Antigravity,
|
|
12
|
+
Cline, Windsurf, Claude Code, GitHub Copilot) için en gelişmiş, projeye özel
|
|
13
|
+
kuralları (.cursorrules, AGENT.md, ARCHITECTURE.md, .clinerules vb.) otomatik
|
|
14
|
+
üretir ve çoklu-ajan PBFT konsensüsü ile yönetir.
|
|
15
|
+
|
|
16
|
+
Temel Yetenekler:
|
|
17
|
+
1. Derin Poliglot Çalışma Alanı Profilleme (WorkspaceProfiler)
|
|
18
|
+
2. Akıllı Mimari Katman ve İçe Aktarma Sınırı Tespiti (Layer Boundary Detection)
|
|
19
|
+
3. Özelleştirilmiş Yapay Zeka Kural ve Doküman Sentezi (WorkspaceGovernanceSynthesizer)
|
|
20
|
+
4. PBFT Sürü Güvenlik & Mimari Denetimi (Swarm Orchestration)
|
|
21
|
+
5. Çapraz Yığın Otonom Kendi Kendini Onarma ve Hata Teşhisi (Self-Healing Loop)
|
|
22
|
+
6. %100 Çevrimdışı, Sıfır Maliyetli ve Sıfır Sızıntı (%100 Zero-Leak)
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
import os
|
|
27
|
+
import sys
|
|
28
|
+
import re
|
|
29
|
+
import json
|
|
30
|
+
import time
|
|
31
|
+
import glob
|
|
32
|
+
import subprocess
|
|
33
|
+
from dataclasses import dataclass, field
|
|
34
|
+
from typing import Dict, List, Set, Optional, Tuple, Any
|
|
35
|
+
|
|
36
|
+
from tzero_jarvis.causal_graph import CausalTemporalGraph, CausalRelationType
|
|
37
|
+
from tzero_jarvis.self_healing import SelfHealingExecutionEngine, ExecutionResult
|
|
38
|
+
from tzero_jarvis.swarm import SwarmCoordinator
|
|
39
|
+
from tzero_jarvis.swarm_bft import ByzantineFaultTolerantSwarm, BFTConsensusCertificate
|
|
40
|
+
from tzero_jarvis.semantic_compressor import get_global_compressor
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass
|
|
44
|
+
class WorkspaceProfile:
|
|
45
|
+
"""Çalışma alanının çok boyutlu teknik ve mimari profili."""
|
|
46
|
+
workspace_root: str
|
|
47
|
+
project_name: str
|
|
48
|
+
primary_language: str
|
|
49
|
+
languages: Dict[str, int] = field(default_factory=dict)
|
|
50
|
+
frameworks: List[str] = field(default_factory=list)
|
|
51
|
+
package_managers: List[str] = field(default_factory=list)
|
|
52
|
+
build_systems: List[str] = field(default_factory=list)
|
|
53
|
+
test_frameworks: List[str] = field(default_factory=list)
|
|
54
|
+
default_test_command: str = "pytest"
|
|
55
|
+
default_lint_command: str = "ruff check ."
|
|
56
|
+
default_build_command: str = "python -m build"
|
|
57
|
+
architecture_pattern: str = "Modular Clean Architecture"
|
|
58
|
+
monorepo_packages: List[str] = field(default_factory=list)
|
|
59
|
+
container_configs: List[str] = field(default_factory=list)
|
|
60
|
+
ci_cd_configs: List[str] = field(default_factory=list)
|
|
61
|
+
total_files: int = 0
|
|
62
|
+
total_code_lines: int = 0
|
|
63
|
+
raw_tokens_est: int = 0
|
|
64
|
+
tzero_compressed_tokens_est: int = 0
|
|
65
|
+
token_savings_pct: float = 0.0
|
|
66
|
+
existing_rule_files: List[str] = field(default_factory=list)
|
|
67
|
+
missing_rule_files: List[str] = field(default_factory=list)
|
|
68
|
+
security_warnings: List[str] = field(default_factory=list)
|
|
69
|
+
architectural_layers: Dict[str, List[str]] = field(default_factory=dict)
|
|
70
|
+
forbidden_boundaries: List[Dict[str, Any]] = field(default_factory=list)
|
|
71
|
+
|
|
72
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
73
|
+
return {
|
|
74
|
+
"workspace_root": self.workspace_root,
|
|
75
|
+
"project_name": self.project_name,
|
|
76
|
+
"primary_language": self.primary_language,
|
|
77
|
+
"languages": self.languages,
|
|
78
|
+
"frameworks": self.frameworks,
|
|
79
|
+
"package_managers": self.package_managers,
|
|
80
|
+
"build_systems": self.build_systems,
|
|
81
|
+
"test_frameworks": self.test_frameworks,
|
|
82
|
+
"default_test_command": self.default_test_command,
|
|
83
|
+
"default_lint_command": self.default_lint_command,
|
|
84
|
+
"default_build_command": self.default_build_command,
|
|
85
|
+
"architecture_pattern": self.architecture_pattern,
|
|
86
|
+
"monorepo_packages": self.monorepo_packages,
|
|
87
|
+
"container_configs": self.container_configs,
|
|
88
|
+
"ci_cd_configs": self.ci_cd_configs,
|
|
89
|
+
"total_files": self.total_files,
|
|
90
|
+
"total_code_lines": self.total_code_lines,
|
|
91
|
+
"raw_tokens_est": self.raw_tokens_est,
|
|
92
|
+
"tzero_compressed_tokens_est": self.tzero_compressed_tokens_est,
|
|
93
|
+
"token_savings_pct": self.token_savings_pct,
|
|
94
|
+
"existing_rule_files": self.existing_rule_files,
|
|
95
|
+
"missing_rule_files": self.missing_rule_files,
|
|
96
|
+
"security_warnings": self.security_warnings,
|
|
97
|
+
"architectural_layers": self.architectural_layers,
|
|
98
|
+
"forbidden_boundaries": self.forbidden_boundaries
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class WorkspaceProfiler:
|
|
103
|
+
"""Evrensel çalışma alanı tarayıcısı ve teknoloji yığını çözümleyicisi."""
|
|
104
|
+
|
|
105
|
+
LANGUAGE_EXTENSIONS: Dict[str, str] = {
|
|
106
|
+
".py": "Python",
|
|
107
|
+
".ts": "TypeScript",
|
|
108
|
+
".tsx": "TypeScript (React)",
|
|
109
|
+
".js": "JavaScript",
|
|
110
|
+
".jsx": "JavaScript (React)",
|
|
111
|
+
".rs": "Rust",
|
|
112
|
+
".go": "Go",
|
|
113
|
+
".cpp": "C++",
|
|
114
|
+
".cc": "C++",
|
|
115
|
+
".cxx": "C++",
|
|
116
|
+
".c": "C",
|
|
117
|
+
".h": "C/C++ Header",
|
|
118
|
+
".hpp": "C++ Header",
|
|
119
|
+
".java": "Java",
|
|
120
|
+
".cs": "C#",
|
|
121
|
+
".php": "PHP",
|
|
122
|
+
".rb": "Ruby",
|
|
123
|
+
".sol": "Solidity",
|
|
124
|
+
".swift": "Swift",
|
|
125
|
+
".kt": "Kotlin",
|
|
126
|
+
".dart": "Dart",
|
|
127
|
+
".sh": "Shell",
|
|
128
|
+
".ps1": "PowerShell"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
IGNORE_DIRS: Set[str] = {
|
|
132
|
+
".git", ".svn", ".hg", "__pycache__", "node_modules", "dist", "build",
|
|
133
|
+
".venv", "venv", "env", "target", "vendor", ".idea", ".vscode",
|
|
134
|
+
".next", ".nuxt", "out", "bin", "obj", ".turbo", ".cache"
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
def __init__(self, workspace_root: str):
|
|
138
|
+
self.workspace_root = os.path.abspath(workspace_root)
|
|
139
|
+
self.project_name = os.path.basename(self.workspace_root) or "UniversalProject"
|
|
140
|
+
self._gitignore_cache: Optional[List[str]] = None
|
|
141
|
+
|
|
142
|
+
def _read_gitignore_patterns(self) -> List[str]:
|
|
143
|
+
if self._gitignore_cache is not None:
|
|
144
|
+
return self._gitignore_cache
|
|
145
|
+
patterns = []
|
|
146
|
+
gi = os.path.join(self.workspace_root, ".gitignore")
|
|
147
|
+
if os.path.isfile(gi):
|
|
148
|
+
try:
|
|
149
|
+
with open(gi, "r", encoding="utf-8", errors="ignore") as fp:
|
|
150
|
+
for line in fp:
|
|
151
|
+
s = line.strip()
|
|
152
|
+
if s and not s.startswith("#"):
|
|
153
|
+
patterns.append(s)
|
|
154
|
+
except Exception:
|
|
155
|
+
pass
|
|
156
|
+
self._gitignore_cache = patterns
|
|
157
|
+
return patterns
|
|
158
|
+
|
|
159
|
+
def profile(self) -> WorkspaceProfile:
|
|
160
|
+
"""Çalışma alanını baştan sona analiz ederek kapsamlı bir profil üretir."""
|
|
161
|
+
languages_count: Dict[str, int] = {}
|
|
162
|
+
total_files = 0
|
|
163
|
+
total_lines = 0
|
|
164
|
+
total_bytes = 0
|
|
165
|
+
security_warnings: List[str] = []
|
|
166
|
+
|
|
167
|
+
# 1. Dosya Sistemi Taraması
|
|
168
|
+
for root, dirs, files in os.walk(self.workspace_root):
|
|
169
|
+
# İstenmeyen dizinleri filtrele
|
|
170
|
+
dirs[:] = [d for d in dirs if d not in self.IGNORE_DIRS and not d.startswith(".git")]
|
|
171
|
+
rel_dir = os.path.relpath(root, self.workspace_root).replace("\\", "/")
|
|
172
|
+
|
|
173
|
+
for f in files:
|
|
174
|
+
ext = os.path.splitext(f)[1].lower()
|
|
175
|
+
full_path = os.path.join(root, f)
|
|
176
|
+
total_files += 1
|
|
177
|
+
|
|
178
|
+
try:
|
|
179
|
+
f_size = os.path.getsize(full_path)
|
|
180
|
+
total_bytes += f_size
|
|
181
|
+
except Exception:
|
|
182
|
+
f_size = 0
|
|
183
|
+
|
|
184
|
+
if ext in self.LANGUAGE_EXTENSIONS:
|
|
185
|
+
lang = self.LANGUAGE_EXTENSIONS[ext]
|
|
186
|
+
languages_count[lang] = languages_count.get(lang, 0) + 1
|
|
187
|
+
# Satır sayısı tahmini (hafif tarama)
|
|
188
|
+
if f_size < 500_000:
|
|
189
|
+
try:
|
|
190
|
+
with open(full_path, "r", encoding="utf-8", errors="ignore") as fp:
|
|
191
|
+
total_lines += sum(1 for _ in fp)
|
|
192
|
+
except Exception:
|
|
193
|
+
pass
|
|
194
|
+
|
|
195
|
+
# Hassas dosya kontrolü (%100 Zero-Leak)
|
|
196
|
+
if f in (".env", ".env.local", ".env.production", "id_rsa", "secrets.json"):
|
|
197
|
+
if not f.endswith(".example") and not f.endswith(".sample"):
|
|
198
|
+
# .gitignore içinde korunuyor mu kontrol et
|
|
199
|
+
is_ignored = False
|
|
200
|
+
gi_patterns = self._read_gitignore_patterns()
|
|
201
|
+
import fnmatch
|
|
202
|
+
for pat in gi_patterns:
|
|
203
|
+
clean_pat = pat.rstrip("/")
|
|
204
|
+
if fnmatch.fnmatch(f, clean_pat) or fnmatch.fnmatch(os.path.join(rel_dir, f).replace("\\", "/"), clean_pat):
|
|
205
|
+
is_ignored = True
|
|
206
|
+
break
|
|
207
|
+
if not is_ignored:
|
|
208
|
+
security_warnings.append(f"Hassas konfigürasyon dosyası VCS koruması altında değil: `{os.path.join(rel_dir, f)}`. %100 Zero-Leak için .gitignore'a ekleyin.")
|
|
209
|
+
|
|
210
|
+
# Birincil Dil Tespiti
|
|
211
|
+
primary_language = "Python"
|
|
212
|
+
if languages_count:
|
|
213
|
+
primary_language = max(languages_count.items(), key=lambda x: x[1])[0]
|
|
214
|
+
|
|
215
|
+
# 2. Paket Yöneticileri, Çatılar ve Araç Zinciri Tespiti
|
|
216
|
+
frameworks: List[str] = []
|
|
217
|
+
package_managers: List[str] = []
|
|
218
|
+
build_systems: List[str] = []
|
|
219
|
+
test_frameworks: List[str] = []
|
|
220
|
+
monorepo_packages: List[str] = []
|
|
221
|
+
container_configs: List[str] = []
|
|
222
|
+
ci_cd_configs: List[str] = []
|
|
223
|
+
|
|
224
|
+
test_cmd = "pytest -v" if primary_language == "Python" else "npm test"
|
|
225
|
+
lint_cmd = "ruff check ." if primary_language == "Python" else "eslint ."
|
|
226
|
+
build_cmd = "python -m build" if primary_language == "Python" else "npm run build"
|
|
227
|
+
|
|
228
|
+
# Python Yığını İncelemesi
|
|
229
|
+
pyproject_p = os.path.join(self.workspace_root, "pyproject.toml")
|
|
230
|
+
req_p = os.path.join(self.workspace_root, "requirements.txt")
|
|
231
|
+
setup_p = os.path.join(self.workspace_root, "setup.py")
|
|
232
|
+
|
|
233
|
+
if os.path.isfile(pyproject_p) or os.path.isfile(req_p) or os.path.isfile(setup_p) or "Python" in languages_count:
|
|
234
|
+
if os.path.isfile(pyproject_p):
|
|
235
|
+
package_managers.append("poetry/uv/flit")
|
|
236
|
+
build_systems.append("pyproject.toml")
|
|
237
|
+
try:
|
|
238
|
+
with open(pyproject_p, "r", encoding="utf-8", errors="ignore") as fp:
|
|
239
|
+
txt = fp.read().lower()
|
|
240
|
+
if "fastapi" in txt: frameworks.append("FastAPI")
|
|
241
|
+
if "django" in txt: frameworks.append("Django")
|
|
242
|
+
if "flask" in txt: frameworks.append("Flask")
|
|
243
|
+
if "pytest" in txt: test_frameworks.append("pytest")
|
|
244
|
+
if "ruff" in txt: lint_cmd = "ruff check ."
|
|
245
|
+
except Exception:
|
|
246
|
+
pass
|
|
247
|
+
if os.path.isfile(req_p):
|
|
248
|
+
package_managers.append("pip")
|
|
249
|
+
try:
|
|
250
|
+
with open(req_p, "r", encoding="utf-8", errors="ignore") as fp:
|
|
251
|
+
txt = fp.read().lower()
|
|
252
|
+
if "fastapi" in txt and "FastAPI" not in frameworks: frameworks.append("FastAPI")
|
|
253
|
+
if "django" in txt and "Django" not in frameworks: frameworks.append("Django")
|
|
254
|
+
if "flask" in txt and "Flask" not in frameworks: frameworks.append("Flask")
|
|
255
|
+
if "torch" in txt: frameworks.append("PyTorch")
|
|
256
|
+
if "tensorflow" in txt: frameworks.append("TensorFlow")
|
|
257
|
+
if "pytest" in txt and "pytest" not in test_frameworks: test_frameworks.append("pytest")
|
|
258
|
+
except Exception:
|
|
259
|
+
pass
|
|
260
|
+
if not test_frameworks:
|
|
261
|
+
test_frameworks.append("unittest/pytest")
|
|
262
|
+
test_cmd = "python -m unittest discover -s tests -p \"test_*.py\"" if os.path.isdir(os.path.join(self.workspace_root, "tests")) else "pytest"
|
|
263
|
+
lint_cmd = "ruff check ." if os.path.isfile(os.path.join(self.workspace_root, "ruff.toml")) else "flake8 ."
|
|
264
|
+
build_cmd = "python setup.py build" if os.path.isfile(setup_p) else "python -m build"
|
|
265
|
+
|
|
266
|
+
# Node / TypeScript / JavaScript İncelemesi
|
|
267
|
+
pkg_json_p = os.path.join(self.workspace_root, "package.json")
|
|
268
|
+
if os.path.isfile(pkg_json_p):
|
|
269
|
+
build_systems.append("npm/node")
|
|
270
|
+
package_managers.append("npm")
|
|
271
|
+
if os.path.isfile(os.path.join(self.workspace_root, "pnpm-lock.yaml")):
|
|
272
|
+
package_managers.append("pnpm")
|
|
273
|
+
elif os.path.isfile(os.path.join(self.workspace_root, "yarn.lock")):
|
|
274
|
+
package_managers.append("yarn")
|
|
275
|
+
elif os.path.isfile(os.path.join(self.workspace_root, "bun.lockb")):
|
|
276
|
+
package_managers.append("bun")
|
|
277
|
+
|
|
278
|
+
try:
|
|
279
|
+
with open(pkg_json_p, "r", encoding="utf-8", errors="ignore") as fp:
|
|
280
|
+
pkg_data = json.load(fp)
|
|
281
|
+
deps = {**pkg_data.get("dependencies", {}), **pkg_data.get("devDependencies", {})}
|
|
282
|
+
scripts = pkg_data.get("scripts", {})
|
|
283
|
+
|
|
284
|
+
if "next" in deps: frameworks.append("Next.js")
|
|
285
|
+
if "react" in deps and "Next.js" not in frameworks: frameworks.append("React")
|
|
286
|
+
if "vue" in deps: frameworks.append("Vue.js")
|
|
287
|
+
if "@nestjs/core" in deps: frameworks.append("NestJS")
|
|
288
|
+
if "express" in deps: frameworks.append("Express.js")
|
|
289
|
+
if "tailwindcss" in deps: frameworks.append("TailwindCSS")
|
|
290
|
+
if "three" in deps: frameworks.append("Three.js")
|
|
291
|
+
if "typescript" in deps: frameworks.append("TypeScript")
|
|
292
|
+
|
|
293
|
+
if "jest" in deps or "jest" in scripts.get("test", ""): test_frameworks.append("jest")
|
|
294
|
+
if "vitest" in deps or "vitest" in scripts.get("test", ""): test_frameworks.append("vitest")
|
|
295
|
+
if "mocha" in deps: test_frameworks.append("mocha")
|
|
296
|
+
|
|
297
|
+
if "test" in scripts:
|
|
298
|
+
test_cmd = "npm test"
|
|
299
|
+
if "lint" in scripts:
|
|
300
|
+
lint_cmd = "npm run lint"
|
|
301
|
+
if "build" in scripts:
|
|
302
|
+
build_cmd = "npm run build"
|
|
303
|
+
|
|
304
|
+
workspaces = pkg_data.get("workspaces", [])
|
|
305
|
+
if workspaces:
|
|
306
|
+
monorepo_packages.extend(workspaces if isinstance(workspaces, list) else workspaces.get("packages", []))
|
|
307
|
+
except Exception:
|
|
308
|
+
pass
|
|
309
|
+
|
|
310
|
+
# Rust İncelemesi
|
|
311
|
+
cargo_p = os.path.join(self.workspace_root, "Cargo.toml")
|
|
312
|
+
if os.path.isfile(cargo_p):
|
|
313
|
+
package_managers.append("cargo")
|
|
314
|
+
build_systems.append("cargo")
|
|
315
|
+
test_frameworks.append("cargo test")
|
|
316
|
+
test_cmd = "cargo test"
|
|
317
|
+
lint_cmd = "cargo clippy"
|
|
318
|
+
build_cmd = "cargo build --release"
|
|
319
|
+
try:
|
|
320
|
+
with open(cargo_p, "r", encoding="utf-8", errors="ignore") as fp:
|
|
321
|
+
c_txt = fp.read().lower()
|
|
322
|
+
if "actix" in c_txt: frameworks.append("Actix-Web")
|
|
323
|
+
if "axum" in c_txt: frameworks.append("Axum")
|
|
324
|
+
if "tokio" in c_txt: frameworks.append("Tokio")
|
|
325
|
+
if "workspace" in c_txt: monorepo_packages.append("Cargo Workspace")
|
|
326
|
+
except Exception:
|
|
327
|
+
pass
|
|
328
|
+
|
|
329
|
+
# Go İncelemesi
|
|
330
|
+
go_mod_p = os.path.join(self.workspace_root, "go.mod")
|
|
331
|
+
if os.path.isfile(go_mod_p):
|
|
332
|
+
package_managers.append("go modules")
|
|
333
|
+
build_systems.append("go build")
|
|
334
|
+
test_frameworks.append("go test")
|
|
335
|
+
test_cmd = "go test ./..."
|
|
336
|
+
lint_cmd = "golangci-lint run"
|
|
337
|
+
build_cmd = "go build ./..."
|
|
338
|
+
try:
|
|
339
|
+
with open(go_mod_p, "r", encoding="utf-8", errors="ignore") as fp:
|
|
340
|
+
g_txt = fp.read().lower()
|
|
341
|
+
if "gin-gonic" in g_txt: frameworks.append("Gin")
|
|
342
|
+
if "fiber" in g_txt: frameworks.append("Fiber")
|
|
343
|
+
if "echo" in g_txt: frameworks.append("Echo")
|
|
344
|
+
except Exception:
|
|
345
|
+
pass
|
|
346
|
+
|
|
347
|
+
# Container & CI/CD
|
|
348
|
+
if os.path.isfile(os.path.join(self.workspace_root, "Dockerfile")):
|
|
349
|
+
container_configs.append("Dockerfile")
|
|
350
|
+
if os.path.isfile(os.path.join(self.workspace_root, "docker-compose.yml")):
|
|
351
|
+
container_configs.append("docker-compose.yml")
|
|
352
|
+
if os.path.isdir(os.path.join(self.workspace_root, ".github", "workflows")):
|
|
353
|
+
ci_cd_configs.append("GitHub Actions")
|
|
354
|
+
if os.path.isfile(os.path.join(self.workspace_root, "vercel.json")):
|
|
355
|
+
ci_cd_configs.append("Vercel")
|
|
356
|
+
|
|
357
|
+
# 3. Mimari Katman Tespiti (Layer Boundary Detection)
|
|
358
|
+
layers: Dict[str, List[str]] = {}
|
|
359
|
+
for item in os.listdir(self.workspace_root):
|
|
360
|
+
item_path = os.path.join(self.workspace_root, item)
|
|
361
|
+
item_lower = item.lower()
|
|
362
|
+
if os.path.isdir(item_path) and item not in self.IGNORE_DIRS and not item.startswith("."):
|
|
363
|
+
if item_lower in ("api", "controllers", "routes", "endpoints", "server"):
|
|
364
|
+
layers["api"] = [f"{item}/**"]
|
|
365
|
+
elif item_lower in ("services", "usecases", "business", "logic"):
|
|
366
|
+
layers["services"] = [f"{item}/**"]
|
|
367
|
+
elif item_lower in ("models", "schemas", "entities", "db", "repositories", "data"):
|
|
368
|
+
layers["data"] = [f"{item}/**"]
|
|
369
|
+
elif item_lower in ("core", "domain", "tzero_jarvis", "kernel"):
|
|
370
|
+
layers["core"] = [f"{item}/**"]
|
|
371
|
+
elif item_lower in ("ui", "views", "components", "pages", "frontend", "public", "static"):
|
|
372
|
+
layers["presentation"] = [f"{item}/**"]
|
|
373
|
+
elif item_lower in ("tests", "test", "spec"):
|
|
374
|
+
layers["tests"] = [f"{item}/**"]
|
|
375
|
+
elif item_lower in ("cli", "commands", "cmd"):
|
|
376
|
+
layers["cli"] = [f"{item}/**"]
|
|
377
|
+
elif item_lower in ("utils", "common", "helpers", "shared"):
|
|
378
|
+
layers["shared"] = [f"{item}/**"]
|
|
379
|
+
|
|
380
|
+
# Kök dizindeki önemli modülleri tespit et
|
|
381
|
+
for root_file in os.listdir(self.workspace_root):
|
|
382
|
+
rf_path = os.path.join(self.workspace_root, root_file)
|
|
383
|
+
if os.path.isfile(rf_path):
|
|
384
|
+
rf_lower = root_file.lower()
|
|
385
|
+
if rf_lower in ("tzero_mcp.py", "server.py", "app.py", "api.py", "routes.py", "index.ts", "server.ts"):
|
|
386
|
+
layers.setdefault("api", []).append(root_file)
|
|
387
|
+
elif rf_lower in ("tzero_v3.py", "core.py", "engine.py", "main.py", "lib.rs", "main.go"):
|
|
388
|
+
layers.setdefault("core", []).append(root_file)
|
|
389
|
+
elif rf_lower in ("tzero_features.py", "features.py", "services.py"):
|
|
390
|
+
layers.setdefault("services", []).append(root_file)
|
|
391
|
+
elif rf_lower in ("tzero_dashboard.py", "addmcp.py", "cli.py"):
|
|
392
|
+
layers.setdefault("cli", []).append(root_file)
|
|
393
|
+
|
|
394
|
+
# Varsayılan katmanlar yoksa dosya desenlerine göre ata
|
|
395
|
+
if not layers:
|
|
396
|
+
layers["core"] = ["*.py", "src/**"]
|
|
397
|
+
layers["tests"] = ["tests/**", "test/**"]
|
|
398
|
+
|
|
399
|
+
forbidden_boundaries: List[Dict[str, Any]] = []
|
|
400
|
+
if "data" in layers and "api" in layers:
|
|
401
|
+
forbidden_boundaries.append({
|
|
402
|
+
"from_layer": "data",
|
|
403
|
+
"cannot_import": ["api", "presentation"],
|
|
404
|
+
"reason": "Veri katmanı (data/models) sunum veya API katmanına bağımlı olamaz (T-002 İhlali)."
|
|
405
|
+
})
|
|
406
|
+
if "core" in layers and "api" in layers:
|
|
407
|
+
forbidden_boundaries.append({
|
|
408
|
+
"from_layer": "core",
|
|
409
|
+
"cannot_import": ["api", "cli"],
|
|
410
|
+
"reason": "Çekirdek iş mantığı giriş/çıkış arayüzlerinden izole kalmalıdır."
|
|
411
|
+
})
|
|
412
|
+
if "shared" in layers and "core" in layers:
|
|
413
|
+
forbidden_boundaries.append({
|
|
414
|
+
"from_layer": "shared",
|
|
415
|
+
"cannot_import": ["core", "services", "api"],
|
|
416
|
+
"reason": "Ortak yardımcı modüller çekirdek iş servislerini içe aktaramaz (Döngüsel Bağımlılık Önleme)."
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
# Mimari Desen Tespiti
|
|
420
|
+
arch_pattern = "Modular Clean Architecture"
|
|
421
|
+
if monorepo_packages:
|
|
422
|
+
arch_pattern = "Monorepo Multi-Package Workspace"
|
|
423
|
+
elif "api" in layers and "services" in layers and "data" in layers:
|
|
424
|
+
arch_pattern = "Hexagonal / Ports-and-Adapters Architecture"
|
|
425
|
+
elif "presentation" in layers and "api" in layers:
|
|
426
|
+
arch_pattern = "Fullstack Client-Server Architecture"
|
|
427
|
+
elif "cli" in layers:
|
|
428
|
+
arch_pattern = "Autonomous CLI / Tool Architecture"
|
|
429
|
+
|
|
430
|
+
# 4. Mevcut ve Eksik AI Kural Dosyaları
|
|
431
|
+
candidate_rules = [
|
|
432
|
+
".cursorrules",
|
|
433
|
+
".clinerules",
|
|
434
|
+
".windsurfrules",
|
|
435
|
+
"AGENT.md",
|
|
436
|
+
"AGENTS.md",
|
|
437
|
+
"CLAUDE.md",
|
|
438
|
+
os.path.join(".github", "copilot-instructions.md"),
|
|
439
|
+
"ARCHITECTURE.md",
|
|
440
|
+
"tzero.rules.json",
|
|
441
|
+
os.path.join(".cursor", "rules", "architecture.mdc"),
|
|
442
|
+
os.path.join(".cursor", "rules", "security.mdc")
|
|
443
|
+
]
|
|
444
|
+
existing_rule_files = []
|
|
445
|
+
missing_rule_files = []
|
|
446
|
+
|
|
447
|
+
for cr in candidate_rules:
|
|
448
|
+
full_cr = os.path.join(self.workspace_root, cr)
|
|
449
|
+
if os.path.isfile(full_cr):
|
|
450
|
+
existing_rule_files.append(cr.replace("\\", "/"))
|
|
451
|
+
else:
|
|
452
|
+
missing_rule_files.append(cr.replace("\\", "/"))
|
|
453
|
+
|
|
454
|
+
# 5. Token Hacmi ve T-Zero Tasarruf Projeksiyonu
|
|
455
|
+
raw_tokens_est = max(10, total_bytes // 4)
|
|
456
|
+
tzero_compressed_tokens = int(raw_tokens_est * 0.12) # Ortalama %88 sıkıştırma
|
|
457
|
+
token_savings_pct = round((1.0 - (tzero_compressed_tokens / max(1, raw_tokens_est))) * 100.0, 1)
|
|
458
|
+
|
|
459
|
+
return WorkspaceProfile(
|
|
460
|
+
workspace_root=self.workspace_root,
|
|
461
|
+
project_name=self.project_name,
|
|
462
|
+
primary_language=primary_language,
|
|
463
|
+
languages=languages_count,
|
|
464
|
+
frameworks=frameworks,
|
|
465
|
+
package_managers=package_managers,
|
|
466
|
+
build_systems=build_systems,
|
|
467
|
+
test_frameworks=test_frameworks,
|
|
468
|
+
default_test_command=test_cmd,
|
|
469
|
+
default_lint_command=lint_cmd,
|
|
470
|
+
default_build_command=build_cmd,
|
|
471
|
+
architecture_pattern=arch_pattern,
|
|
472
|
+
monorepo_packages=monorepo_packages,
|
|
473
|
+
container_configs=container_configs,
|
|
474
|
+
ci_cd_configs=ci_cd_configs,
|
|
475
|
+
total_files=total_files,
|
|
476
|
+
total_code_lines=total_lines,
|
|
477
|
+
raw_tokens_est=raw_tokens_est,
|
|
478
|
+
tzero_compressed_tokens_est=tzero_compressed_tokens,
|
|
479
|
+
token_savings_pct=token_savings_pct,
|
|
480
|
+
existing_rule_files=existing_rule_files,
|
|
481
|
+
missing_rule_files=missing_rule_files,
|
|
482
|
+
security_warnings=security_warnings,
|
|
483
|
+
architectural_layers=layers,
|
|
484
|
+
forbidden_boundaries=forbidden_boundaries
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
class WorkspaceGovernanceSynthesizer:
|
|
489
|
+
"""Teknoloji yığınına özel, en gelişmiş yapay zeka ajan yönetişim dokümanları üreticisi."""
|
|
490
|
+
|
|
491
|
+
@staticmethod
|
|
492
|
+
def generate_cursorrules(profile: WorkspaceProfile) -> str:
|
|
493
|
+
"""Cursor IDE için projeye özel .cursorrules dosyası üretir."""
|
|
494
|
+
layers_str = "\n".join(f" - `{name}`: {', '.join(paths)}" for name, paths in profile.architectural_layers.items()) or " - Standard Modular Architecture"
|
|
495
|
+
forbidden_str = "\n".join(f" - `{b['from_layer']}` -> `{', '.join(b['cannot_import'])}`: {b['reason']}" for b in profile.forbidden_boundaries) or " - Enforce unidirectional inward dependency injection."
|
|
496
|
+
|
|
497
|
+
return f"""# ==============================================================================
|
|
498
|
+
# CURSOR AI RULES & BEHAVIORAL CONTRACT: {profile.project_name}
|
|
499
|
+
# Synthesized by T-Zero Jarvis Master Workspace Orchestrator (https://github.com/toprakahmetaydogmus/TZeroAlgorithm)
|
|
500
|
+
# ==============================================================================
|
|
501
|
+
|
|
502
|
+
[PROJECT CONTEXT & METADATA]
|
|
503
|
+
- Workspace Name: {profile.project_name}
|
|
504
|
+
- Primary Language: {profile.primary_language}
|
|
505
|
+
- Polyglot Languages: {', '.join(f'{k} ({v} files)' for k, v in profile.languages.items())}
|
|
506
|
+
- Frameworks & Engines: {', '.join(profile.frameworks) or 'Native / Standard Library'}
|
|
507
|
+
- Package & Dependency Managers: {', '.join(profile.package_managers) or 'Standard'}
|
|
508
|
+
- Architecture Paradigm: {profile.architecture_pattern}
|
|
509
|
+
|
|
510
|
+
[OFFICIAL COMMAND MATRIX]
|
|
511
|
+
- Primary Test Command: `{profile.default_test_command}`
|
|
512
|
+
- Linter & Code Style: `{profile.default_lint_command}`
|
|
513
|
+
- Production Build: `{profile.default_build_command}`
|
|
514
|
+
|
|
515
|
+
[ARCHITECTURAL LAYER ISOLATION]
|
|
516
|
+
{layers_str}
|
|
517
|
+
|
|
518
|
+
[FORBIDDEN IMPORT BOUNDARIES]
|
|
519
|
+
{forbidden_str}
|
|
520
|
+
|
|
521
|
+
[STRICT OPERATIONAL DIRECTIVES]
|
|
522
|
+
1. RULE T-001: 100% ZERO-LEAK SECURITY MANDATE
|
|
523
|
+
- NEVER output, hardcode, or log private credentials, API keys (OpenAI, Anthropic, Gemini, AWS), or tokens.
|
|
524
|
+
- Use environment variables or local secure keyrings. Never modify or commit sensitive `.env` files.
|
|
525
|
+
|
|
526
|
+
2. RULE T-002: ARCHITECTURAL BOUNDARY ENFORCEMENT
|
|
527
|
+
- Respect strictly defined layer hierarchy. Never create circular dependencies.
|
|
528
|
+
- Core domain logic must remain independent of CLI or presentation adapters.
|
|
529
|
+
|
|
530
|
+
3. RULE T-003: AST CONTRACT & COMMENT FIDELITY
|
|
531
|
+
- Preserve existing public API signatures, type annotations, and docstrings.
|
|
532
|
+
- Never delete explanatory code comments or existing documentation without explicit approval.
|
|
533
|
+
|
|
534
|
+
4. RULE T-004: VERIFICATION BEFORE TASK CONCLUSION
|
|
535
|
+
- Before reporting any task complete, ALWAYS execute the workspace test suite:
|
|
536
|
+
`{profile.default_test_command}`
|
|
537
|
+
- Ensure 0 regressions and 0 unhandled warnings.
|
|
538
|
+
"""
|
|
539
|
+
|
|
540
|
+
@staticmethod
|
|
541
|
+
def generate_agent_md(profile: WorkspaceProfile) -> str:
|
|
542
|
+
"""Antigravity, AutoGPT ve Otonom Ajanlar için AGENT.md / AGENTS.md yönergesi üretir."""
|
|
543
|
+
return f"""# 🤖 MASTER AGENT DIRECTIVE & ORCHESTRATION PROTOCOL
|
|
544
|
+
## Workspace: `{profile.project_name}`
|
|
545
|
+
*Engine: Siber Akademi T-Zero Jarvis Autonomous Multi-Agent Orchestrator*
|
|
546
|
+
*Version: 5.0.0 | Security Rating: 100% Zero-Leak Certified*
|
|
547
|
+
|
|
548
|
+
---
|
|
549
|
+
|
|
550
|
+
## 1. Executive Mission & Identity
|
|
551
|
+
You are operating as an **Elite Principal Software Engineer and Workspace Manager** on `{profile.project_name}`.
|
|
552
|
+
Your objective is to execute all coding, debugging, refactoring, and orchestration tasks with zero regressions, minimal blast radius, and 100% architectural fidelity.
|
|
553
|
+
|
|
554
|
+
## 2. Technical Stack & Environment Matrix
|
|
555
|
+
- **Primary Language:** `{profile.primary_language}`
|
|
556
|
+
- **Active Frameworks:** `{', '.join(profile.frameworks) or 'None / Core'}`
|
|
557
|
+
- **Build & Packaging:** `{', '.join(profile.package_managers)}`
|
|
558
|
+
- **Architectural Style:** `{profile.architecture_pattern}`
|
|
559
|
+
- **Estimated Code Volume:** `{profile.total_files} files` (~`{profile.total_code_lines} lines of code`)
|
|
560
|
+
- **T-Zero Context Budget:** `{profile.tzero_compressed_tokens_est} virtual tokens` (vs `{profile.raw_tokens_est}` raw tokens, **{profile.token_savings_pct}% context reduction**)
|
|
561
|
+
|
|
562
|
+
## 3. Operational Protocols & Verification Gates
|
|
563
|
+
Before marking any assignment, feature, or bugfix as complete, you MUST execute the following verification pipeline:
|
|
564
|
+
|
|
565
|
+
```bash
|
|
566
|
+
# 1. Run Workspace Static Quality & Lint Check
|
|
567
|
+
{profile.default_lint_command}
|
|
568
|
+
|
|
569
|
+
# 2. Run Comprehensive Automated Test Suite
|
|
570
|
+
{profile.default_test_command}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
If tests fail, activate the **T-Zero Self-Healing Execution Protocol**: diagnose the traceback, identify the exact failing AST node, apply surgical patches, and re-run until 100% green.
|
|
574
|
+
|
|
575
|
+
## 4. Architectural Boundaries & Structural Contracts
|
|
576
|
+
```mermaid
|
|
577
|
+
flowchart TD
|
|
578
|
+
subgraph Presentation ["Presentation & Interfaces"]
|
|
579
|
+
CLI["CLI / Terminal"]
|
|
580
|
+
API["API / HTTP / MCP"]
|
|
581
|
+
end
|
|
582
|
+
subgraph Business ["Core Domain & Services"]
|
|
583
|
+
ORCH["Jarvis Orchestrator"]
|
|
584
|
+
SERVICES["Business Services"]
|
|
585
|
+
end
|
|
586
|
+
subgraph Persistence ["Data & Shared Foundations"]
|
|
587
|
+
MODELS["Data Models / AST"]
|
|
588
|
+
UTILS["Shared Utilities / Codebook"]
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
CLI --> SERVICES
|
|
592
|
+
API --> SERVICES
|
|
593
|
+
SERVICES --> MODELS
|
|
594
|
+
SERVICES --> UTILS
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
- **Inward-Only Dependencies:** Outer layers depend on inner layers; inner layers MUST NOT depend on outer layers.
|
|
598
|
+
- **Zero Circular Imports:** Circular module imports are strictly prohibited.
|
|
599
|
+
|
|
600
|
+
## 5. 100% Zero-Leak Security Policy
|
|
601
|
+
- **No Hardcoded Secrets:** Any API key or confidential token encountered must immediately be flagged and moved to environment variables.
|
|
602
|
+
- **Local / Offline Safe:** Never transmit private repository source code to unverified external cloud endpoints without user consent.
|
|
603
|
+
|
|
604
|
+
## 6. T-Zero Grounding & MCP Intelligence Matrix (`tzero_grounding`)
|
|
605
|
+
- **System Prompt Reference:** Ground all multi-step reasoning using `tzero_grounding`.
|
|
606
|
+
- **AST Architecture Mapping:** Always consult `get_project_context_tree` (Tier 1-4) to minimize token consumption by up to 95%.
|
|
607
|
+
- **Zero-Leak Guard:** Use `verify_zero_leak_security` before concluding code modifications.
|
|
608
|
+
"""
|
|
609
|
+
|
|
610
|
+
@staticmethod
|
|
611
|
+
def generate_clinerules(profile: WorkspaceProfile) -> str:
|
|
612
|
+
"""Cline & Roo-Code için özel .clinerules üretir."""
|
|
613
|
+
return f"""# Cline & Roo-Code Executive Instructions for {profile.project_name}
|
|
614
|
+
# Enforced by T-Zero Jarvis Governance Engine
|
|
615
|
+
|
|
616
|
+
## Role & Standards
|
|
617
|
+
You are an autonomous engineering agent working on `{profile.project_name}` ({profile.primary_language}).
|
|
618
|
+
You have full terminal access and are expected to self-verify every change.
|
|
619
|
+
|
|
620
|
+
## Verification Workflow
|
|
621
|
+
1. Execute `{profile.default_test_command}` before making changes to baseline current health.
|
|
622
|
+
2. Apply minimal, clean modifications matching existing code formatting.
|
|
623
|
+
3. Execute `{profile.default_test_command}` and `{profile.default_lint_command}` after editing.
|
|
624
|
+
4. Only conclude your turn once all tests pass with exit code 0.
|
|
625
|
+
|
|
626
|
+
## Inviolable Rules
|
|
627
|
+
- **Rule T-001 (Zero-Leak):** Never commit secrets, credentials, or personal access tokens.
|
|
628
|
+
- **Rule T-002 (Architecture):** Maintain modular structure according to `{profile.architecture_pattern}`.
|
|
629
|
+
- **Rule T-003 (Contract Fidelity):** Retain all existing docstrings and comments.
|
|
630
|
+
"""
|
|
631
|
+
|
|
632
|
+
@staticmethod
|
|
633
|
+
def generate_windsurfrules(profile: WorkspaceProfile) -> str:
|
|
634
|
+
"""Windsurf Cascade için .windsurfrules üretir."""
|
|
635
|
+
return f"""# Windsurf Cascade Rules: {profile.project_name}
|
|
636
|
+
# Enforced by Siber Akademi T-Zero Context Engine
|
|
637
|
+
|
|
638
|
+
## Core Directives
|
|
639
|
+
1. **Zero-Leak Security:** Never output credentials or expose production tokens.
|
|
640
|
+
2. **Context-Aware Refactoring:** Respect `{profile.architecture_pattern}` layer boundaries.
|
|
641
|
+
3. **Preserve Documentation:** Do not delete existing comments or docstrings.
|
|
642
|
+
4. **Mandatory Test Verification:** Always verify changes using `{profile.default_test_command}`.
|
|
643
|
+
"""
|
|
644
|
+
|
|
645
|
+
@staticmethod
|
|
646
|
+
def generate_claude_instructions(profile: WorkspaceProfile) -> str:
|
|
647
|
+
"""Claude Code CLI için CLAUDE.md yönergeleri üretir."""
|
|
648
|
+
return f"""# Claude Code Guidelines: {profile.project_name}
|
|
649
|
+
|
|
650
|
+
## Project Overview
|
|
651
|
+
- **Name:** {profile.project_name}
|
|
652
|
+
- **Primary Language:** {profile.primary_language}
|
|
653
|
+
- **Frameworks:** {', '.join(profile.frameworks) or 'Standard Library'}
|
|
654
|
+
- **Pattern:** {profile.architecture_pattern}
|
|
655
|
+
|
|
656
|
+
## Key Commands
|
|
657
|
+
- **Test:** `{profile.default_test_command}`
|
|
658
|
+
- **Lint:** `{profile.default_lint_command}`
|
|
659
|
+
- **Build:** `{profile.default_build_command}`
|
|
660
|
+
|
|
661
|
+
## Engineering Principles
|
|
662
|
+
- Follow idiomatic conventions for {profile.primary_language}.
|
|
663
|
+
- Maintain 100% Zero-Leak security policy.
|
|
664
|
+
- Run tests and ensure zero regressions before reporting completion.
|
|
665
|
+
"""
|
|
666
|
+
|
|
667
|
+
@staticmethod
|
|
668
|
+
def generate_copilot_instructions(profile: WorkspaceProfile) -> str:
|
|
669
|
+
"""GitHub Copilot için .github/copilot-instructions.md üretir."""
|
|
670
|
+
return f"""# GitHub Copilot Repository Guidelines: {profile.project_name}
|
|
671
|
+
|
|
672
|
+
- **Stack:** {profile.primary_language} ({', '.join(profile.frameworks) or 'Modular'})
|
|
673
|
+
- **Testing:** Verify code against `{profile.default_test_command}`.
|
|
674
|
+
- **Security:** 100% Zero-Leak. Never suggest hardcoded secrets or API tokens.
|
|
675
|
+
- **Style:** Clean, typed, modular code adhering to {profile.architecture_pattern}.
|
|
676
|
+
"""
|
|
677
|
+
|
|
678
|
+
@staticmethod
|
|
679
|
+
def generate_cursor_mdc_rules(profile: WorkspaceProfile) -> Dict[str, str]:
|
|
680
|
+
"""Modern Cursor modular .cursor/rules/*.mdc formatı üretir."""
|
|
681
|
+
globs = "**/*.py" if profile.primary_language == "Python" else "**/*.ts,**/*.js"
|
|
682
|
+
|
|
683
|
+
arch_mdc = f"""---
|
|
684
|
+
description: Architectural Boundary & Layer Standards for {profile.project_name}
|
|
685
|
+
globs: {globs}
|
|
686
|
+
---
|
|
687
|
+
# Architecture Standards for {profile.project_name}
|
|
688
|
+
- **Pattern:** {profile.architecture_pattern}
|
|
689
|
+
- **Layers Enforced:**
|
|
690
|
+
{chr(10).join(f"- `{k}`: `{', '.join(v)}`" for k, v in profile.architectural_layers.items())}
|
|
691
|
+
|
|
692
|
+
## Import Restrictions:
|
|
693
|
+
{chr(10).join(f"- Layer `{b['from_layer']}` cannot import `{', '.join(b['cannot_import'])}`: {b['reason']}" for b in profile.forbidden_boundaries) or "- Prevent cyclic dependencies and respect inward layer flow."}
|
|
694
|
+
"""
|
|
695
|
+
|
|
696
|
+
sec_mdc = f"""---
|
|
697
|
+
description: 100% Zero-Leak Security & Secret Protection
|
|
698
|
+
globs: **/*
|
|
699
|
+
---
|
|
700
|
+
# Zero-Leak Security Mandate
|
|
701
|
+
- NEVER hardcode credentials, tokens, or API keys in code or configuration files.
|
|
702
|
+
- Use OS environment variables or secure vault integrations.
|
|
703
|
+
- Always verify `.gitignore` contains all sensitive `.env` files.
|
|
704
|
+
"""
|
|
705
|
+
|
|
706
|
+
test_mdc = f"""---
|
|
707
|
+
description: Testing and Quality Assurance Protocols
|
|
708
|
+
globs: **/*
|
|
709
|
+
---
|
|
710
|
+
# Testing Protocols for {profile.project_name}
|
|
711
|
+
- Always run `{profile.default_test_command}` before finishing tasks.
|
|
712
|
+
- Keep tests modular, self-contained, and fast.
|
|
713
|
+
- Never disable or bypass failing tests without explicit authorization.
|
|
714
|
+
"""
|
|
715
|
+
|
|
716
|
+
return {
|
|
717
|
+
"architecture.mdc": arch_mdc,
|
|
718
|
+
"security.mdc": sec_mdc,
|
|
719
|
+
"testing.mdc": test_mdc
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
@staticmethod
|
|
723
|
+
def generate_architecture_md(profile: WorkspaceProfile) -> str:
|
|
724
|
+
"""Mermaid topoloji diyagramlı kapsamlı ARCHITECTURE.md üretir."""
|
|
725
|
+
nodes = []
|
|
726
|
+
links = []
|
|
727
|
+
for l_name, paths in profile.architectural_layers.items():
|
|
728
|
+
safe_name = l_name.capitalize()
|
|
729
|
+
nodes.append(f' Node_{l_name}["{safe_name} Layer<br/>({", ".join(paths)})"]')
|
|
730
|
+
|
|
731
|
+
if "api" in profile.architectural_layers and "services" in profile.architectural_layers:
|
|
732
|
+
links.append(" Node_api --> Node_services")
|
|
733
|
+
if "services" in profile.architectural_layers and "core" in profile.architectural_layers:
|
|
734
|
+
links.append(" Node_services --> Node_core")
|
|
735
|
+
if "services" in profile.architectural_layers and "data" in profile.architectural_layers:
|
|
736
|
+
links.append(" Node_services --> Node_data")
|
|
737
|
+
if "cli" in profile.architectural_layers and "core" in profile.architectural_layers:
|
|
738
|
+
links.append(" Node_cli --> Node_core")
|
|
739
|
+
if "core" in profile.architectural_layers and "data" in profile.architectural_layers:
|
|
740
|
+
links.append(" Node_core --> Node_data")
|
|
741
|
+
if "core" in profile.architectural_layers and "tests" in profile.architectural_layers:
|
|
742
|
+
links.append(" Node_core --> Node_tests")
|
|
743
|
+
if not links:
|
|
744
|
+
links.append(" Node_core --> Node_tests")
|
|
745
|
+
|
|
746
|
+
mermaid_block = "```mermaid\nflowchart TD\n" + "\n".join(nodes) + "\n" + "\n".join(links) + "\n```"
|
|
747
|
+
|
|
748
|
+
return f"""# 🏛️ SYSTEM ARCHITECTURE SPECIFICATION: {profile.project_name}
|
|
749
|
+
*Generated by Siber Akademi T-Zero Jarvis Autonomous Engine V5.0*
|
|
750
|
+
|
|
751
|
+
## 1. Architectural Blueprint
|
|
752
|
+
- **Project Name:** `{profile.project_name}`
|
|
753
|
+
- **Primary Paradigm:** `{profile.architecture_pattern}`
|
|
754
|
+
- **Primary Language:** `{profile.primary_language}`
|
|
755
|
+
- **Active Frameworks:** `{', '.join(profile.frameworks) or 'Standard Library'}`
|
|
756
|
+
- **Total Codebase Volume:** `{profile.total_files} files` (~`{profile.total_code_lines} lines`)
|
|
757
|
+
|
|
758
|
+
## 2. Component Topology & Dependency Flow
|
|
759
|
+
{mermaid_block}
|
|
760
|
+
|
|
761
|
+
## 3. Layer Breakdown & Boundaries
|
|
762
|
+
| Layer | Scope / Patterns | Responsibility |
|
|
763
|
+
| :--- | :--- | :--- |
|
|
764
|
+
{chr(10).join(f"| **{k.capitalize()}** | `{', '.join(v)}` | Managed layer for {k} logic |" for k, v in profile.architectural_layers.items())}
|
|
765
|
+
|
|
766
|
+
## 4. Invariant Rules & Security Gate
|
|
767
|
+
- **100% Zero-Leak:** Zero secrets committed to VCS.
|
|
768
|
+
- **AST Fidelity:** All public functions maintain docstrings and typed contracts.
|
|
769
|
+
- **Verification Command:** `{profile.default_test_command}`
|
|
770
|
+
"""
|
|
771
|
+
|
|
772
|
+
@staticmethod
|
|
773
|
+
def generate_tzero_rules_json(profile: WorkspaceProfile) -> str:
|
|
774
|
+
"""tzero.rules.json mimari sınır doğrulama matrisini üretir."""
|
|
775
|
+
rules_data = {
|
|
776
|
+
"version": "5.0.0",
|
|
777
|
+
"project_name": profile.project_name,
|
|
778
|
+
"architecture_pattern": profile.architecture_pattern,
|
|
779
|
+
"layers": profile.architectural_layers,
|
|
780
|
+
"forbidden_imports": profile.forbidden_boundaries,
|
|
781
|
+
"security": {
|
|
782
|
+
"zero_leak_enforced": True,
|
|
783
|
+
"disallow_hardcoded_keys": True
|
|
784
|
+
},
|
|
785
|
+
"testing": {
|
|
786
|
+
"default_test_command": profile.default_test_command,
|
|
787
|
+
"default_lint_command": profile.default_lint_command
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return json.dumps(rules_data, indent=2, ensure_ascii=False)
|
|
791
|
+
|
|
792
|
+
@classmethod
|
|
793
|
+
def synthesize_all(cls, profile: WorkspaceProfile) -> Dict[str, str]:
|
|
794
|
+
"""Tüm yönetişim ve AI kural dosyalarını tek seferde üretir."""
|
|
795
|
+
files: Dict[str, str] = {
|
|
796
|
+
".cursorrules": cls.generate_cursorrules(profile),
|
|
797
|
+
"AGENT.md": cls.generate_agent_md(profile),
|
|
798
|
+
"AGENTS.md": cls.generate_agent_md(profile),
|
|
799
|
+
".clinerules": cls.generate_clinerules(profile),
|
|
800
|
+
".windsurfrules": cls.generate_windsurfrules(profile),
|
|
801
|
+
"CLAUDE.md": cls.generate_claude_instructions(profile),
|
|
802
|
+
os.path.join(".github", "copilot-instructions.md"): cls.generate_copilot_instructions(profile),
|
|
803
|
+
"ARCHITECTURE.md": cls.generate_architecture_md(profile),
|
|
804
|
+
"tzero.rules.json": cls.generate_tzero_rules_json(profile)
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
# Cursor MDC Rules
|
|
808
|
+
for mdc_name, content in cls.generate_cursor_mdc_rules(profile).items():
|
|
809
|
+
files[os.path.join(".cursor", "rules", mdc_name)] = content
|
|
810
|
+
|
|
811
|
+
return files
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
class WorkspaceOrchestrator:
|
|
815
|
+
"""
|
|
816
|
+
JARVIS MASTER WORKSPACE ORCHESTRATOR
|
|
817
|
+
------------------------------------
|
|
818
|
+
Çalışma alanını otonom bir yönetici gibi analiz eden, yapılandıran,
|
|
819
|
+
AI kural dosyalarını (.md) en gelişmiş şekilde üreten, PBFT konsensüsüyle
|
|
820
|
+
denetleyen ve kendi kendini iyileştiren ana sistem.
|
|
821
|
+
"""
|
|
822
|
+
|
|
823
|
+
def __init__(self, workspace_root: str = "."):
|
|
824
|
+
self.workspace_root = os.path.abspath(workspace_root)
|
|
825
|
+
self.profiler = WorkspaceProfiler(self.workspace_root)
|
|
826
|
+
self.compressor = get_global_compressor()
|
|
827
|
+
self.causal_graph = CausalTemporalGraph(self.compressor.codebook)
|
|
828
|
+
self.self_healing = SelfHealingExecutionEngine(self.causal_graph, work_dir=self.workspace_root)
|
|
829
|
+
|
|
830
|
+
def profile_workspace(self) -> WorkspaceProfile:
|
|
831
|
+
"""Çalışma alanının detaylı profilini çıkarır."""
|
|
832
|
+
return self.profiler.profile()
|
|
833
|
+
|
|
834
|
+
def synthesize_rules(self, profile: Optional[WorkspaceProfile] = None) -> Dict[str, str]:
|
|
835
|
+
"""Çalışma alanına özel tüm AI yönetişim dosyalarının içeriğini hazırlar."""
|
|
836
|
+
prof = profile or self.profile_workspace()
|
|
837
|
+
return WorkspaceGovernanceSynthesizer.synthesize_all(prof)
|
|
838
|
+
|
|
839
|
+
def apply_governance_rules(self, rules: Optional[Dict[str, str]] = None, overwrite: bool = True) -> List[str]:
|
|
840
|
+
"""
|
|
841
|
+
Üretilen .md ve konfigürasyon kurallarını diske yazar.
|
|
842
|
+
Mevcut dosyalar güvenli bir şekilde güncellenir.
|
|
843
|
+
"""
|
|
844
|
+
if rules is None:
|
|
845
|
+
rules = self.synthesize_rules()
|
|
846
|
+
|
|
847
|
+
written_files: List[str] = []
|
|
848
|
+
for rel_path, content in rules.items():
|
|
849
|
+
abs_path = os.path.join(self.workspace_root, rel_path)
|
|
850
|
+
os.makedirs(os.path.dirname(abs_path), exist_ok=True)
|
|
851
|
+
|
|
852
|
+
# Mevcut dosya varsa ve overwrite false ise atla
|
|
853
|
+
if os.path.isfile(abs_path) and not overwrite:
|
|
854
|
+
continue
|
|
855
|
+
|
|
856
|
+
with open(abs_path, "w", encoding="utf-8") as fp:
|
|
857
|
+
fp.write(content)
|
|
858
|
+
written_files.append(rel_path.replace("\\", "/"))
|
|
859
|
+
|
|
860
|
+
return written_files
|
|
861
|
+
|
|
862
|
+
def run_swarm_audit(self, profile: Optional[WorkspaceProfile] = None) -> Dict[str, Any]:
|
|
863
|
+
"""
|
|
864
|
+
5-Ajanlı PBFT Sürüsünü (Security, Hardware, AST Optimizer, DevOps, JARVIS Prime)
|
|
865
|
+
çalışma alanı denetimi için göreve çağırır.
|
|
866
|
+
"""
|
|
867
|
+
prof = profile or self.profile_workspace()
|
|
868
|
+
coordinator = SwarmCoordinator(self.compressor)
|
|
869
|
+
bft = ByzantineFaultTolerantSwarm(coordinator)
|
|
870
|
+
|
|
871
|
+
mission = (
|
|
872
|
+
f"Audit workspace '{prof.project_name}' ({prof.primary_language}). "
|
|
873
|
+
f"Pattern: {prof.architecture_pattern}, Files: {prof.total_files}. "
|
|
874
|
+
f"Verify 100% Zero-Leak security, layer separation, and test readiness."
|
|
875
|
+
)
|
|
876
|
+
context = f"Test Command: {prof.default_test_command}; Warnings: {len(prof.security_warnings)}"
|
|
877
|
+
|
|
878
|
+
cert = bft.reach_consensus(mission, context=context)
|
|
879
|
+
return cert.to_dict()
|
|
880
|
+
|
|
881
|
+
def run_workspace_diagnostics_and_heal(self, command: Optional[str] = None) -> Dict[str, Any]:
|
|
882
|
+
"""
|
|
883
|
+
Çalışma alanı test komutunu çalıştırır, hata oluşursa T-Zero otonom
|
|
884
|
+
cerrahi yama (self-healing) motoru ile analiz edip çözer.
|
|
885
|
+
"""
|
|
886
|
+
prof = self.profile_workspace()
|
|
887
|
+
target_cmd = command or prof.default_test_command
|
|
888
|
+
|
|
889
|
+
res: ExecutionResult = self.self_healing.execute_and_heal(target_cmd, max_retries=2)
|
|
890
|
+
return res.to_dict()
|
|
891
|
+
|
|
892
|
+
def orchestrate_workspace(
|
|
893
|
+
self,
|
|
894
|
+
auto_apply_rules: bool = True,
|
|
895
|
+
run_swarm: bool = True,
|
|
896
|
+
run_diagnostics: bool = False
|
|
897
|
+
) -> Dict[str, Any]:
|
|
898
|
+
"""
|
|
899
|
+
JARVIS ANA ORKESTRASYON AKIŞI:
|
|
900
|
+
1. Çalışma alanını poliglot olarak tara ve profille
|
|
901
|
+
2. Özel .md yönetişim kurallarını (.cursorrules, AGENT.md, ARCHITECTURE.md vb.) üret
|
|
902
|
+
3. Talep edilirse diske uygula (auto-apply)
|
|
903
|
+
4. 5-Ajanlı PBFT Sürüsü ile güvenlik ve mimari konsensüsü sağla
|
|
904
|
+
5. Talep edilirse testleri çalıştır ve kendi kendini iyileştir
|
|
905
|
+
6. Master Yönetişim Raporu (WORKSPACE_ORCHESTRATION.md) oluştur
|
|
906
|
+
"""
|
|
907
|
+
t0 = time.time()
|
|
908
|
+
profile = self.profile_workspace()
|
|
909
|
+
|
|
910
|
+
# 1. Kural Sentezi
|
|
911
|
+
rules = self.synthesize_rules(profile)
|
|
912
|
+
applied_files: List[str] = []
|
|
913
|
+
if auto_apply_rules:
|
|
914
|
+
applied_files = self.apply_governance_rules(rules, overwrite=True)
|
|
915
|
+
|
|
916
|
+
# 2. PBFT Sürü Denetimi
|
|
917
|
+
swarm_result: Optional[Dict[str, Any]] = None
|
|
918
|
+
if run_swarm:
|
|
919
|
+
try:
|
|
920
|
+
swarm_result = self.run_swarm_audit(profile)
|
|
921
|
+
except Exception as e:
|
|
922
|
+
swarm_result = {"consensus_verdict": "ERROR", "error": str(e)}
|
|
923
|
+
|
|
924
|
+
# 3. Kendi Kendini İyileştiren Teşhis (Opsiyonel)
|
|
925
|
+
diag_result: Optional[Dict[str, Any]] = None
|
|
926
|
+
if run_diagnostics:
|
|
927
|
+
try:
|
|
928
|
+
diag_result = self.run_workspace_diagnostics_and_heal()
|
|
929
|
+
except Exception as e:
|
|
930
|
+
diag_result = {"success": False, "error": str(e)}
|
|
931
|
+
|
|
932
|
+
# 4. Master Rapor Üretimi (WORKSPACE_ORCHESTRATION.md)
|
|
933
|
+
duration_ms = (time.time() - t0) * 1000.0
|
|
934
|
+
report_md = self._generate_master_report_md(profile, applied_files, swarm_result, diag_result, duration_ms)
|
|
935
|
+
|
|
936
|
+
if auto_apply_rules:
|
|
937
|
+
report_path = os.path.join(self.workspace_root, "WORKSPACE_ORCHESTRATION.md")
|
|
938
|
+
try:
|
|
939
|
+
with open(report_path, "w", encoding="utf-8") as fp:
|
|
940
|
+
fp.write(report_md)
|
|
941
|
+
applied_files.append("WORKSPACE_ORCHESTRATION.md")
|
|
942
|
+
except Exception:
|
|
943
|
+
pass
|
|
944
|
+
|
|
945
|
+
return {
|
|
946
|
+
"status": "SUCCESS",
|
|
947
|
+
"workspace_name": profile.project_name,
|
|
948
|
+
"workspace_root": profile.workspace_root,
|
|
949
|
+
"duration_ms": round(duration_ms, 2),
|
|
950
|
+
"profile": profile.to_dict(),
|
|
951
|
+
"applied_rule_files": applied_files,
|
|
952
|
+
"swarm_consensus": swarm_result,
|
|
953
|
+
"diagnostics": diag_result,
|
|
954
|
+
"executive_report_markdown": report_md
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
def _generate_master_report_md(
|
|
958
|
+
self,
|
|
959
|
+
profile: WorkspaceProfile,
|
|
960
|
+
applied_files: List[str],
|
|
961
|
+
swarm_result: Optional[Dict[str, Any]],
|
|
962
|
+
diag_result: Optional[Dict[str, Any]],
|
|
963
|
+
duration_ms: float
|
|
964
|
+
) -> str:
|
|
965
|
+
"""Kapsamlı WORKSPACE_ORCHESTRATION.md metnini biçimlendirir."""
|
|
966
|
+
swarm_verdict = swarm_result.get("consensus_verdict", "SKIPPED") if swarm_result else "SKIPPED"
|
|
967
|
+
verdict_emoji = "✅ APPROVED" if swarm_verdict == "APPROVED" else ("🛡️ VETO / WARNING" if "VETO" in swarm_verdict else swarm_verdict)
|
|
968
|
+
|
|
969
|
+
applied_list = "\n".join(f"- `{f}`" for f in applied_files) if applied_files else "- None (Dry-run mode)"
|
|
970
|
+
warnings_list = "\n".join(f"- ⚠️ {w}" for w in profile.security_warnings) or "- 🛡️ No hardcoded credentials or leak vulnerabilities detected."
|
|
971
|
+
|
|
972
|
+
diag_section = ""
|
|
973
|
+
if diag_result:
|
|
974
|
+
diag_status = "✅ PASSING" if diag_result.get("success") else "❌ FAILED"
|
|
975
|
+
diag_section = f"""
|
|
976
|
+
## 🩺 Diagnostics & Self-Healing Telemetry
|
|
977
|
+
- **Command:** `{diag_result.get('command')}`
|
|
978
|
+
- **Execution Status:** `{diag_status}`
|
|
979
|
+
- **Patches Applied:** `{len(diag_result.get('applied_patches', []))}`
|
|
980
|
+
- **Duration:** `{diag_result.get('duration_ms')} ms`
|
|
981
|
+
"""
|
|
982
|
+
|
|
983
|
+
return f"""# 🌐 T-ZERO JARVIS MASTER WORKSPACE ORCHESTRATION REPORT
|
|
984
|
+
*Executive Workspace Manager: Toprak Ahmet Aydoğmuş (Siber Akademi)*
|
|
985
|
+
*Generated on: {time.strftime('%Y-%m-%d %H:%M:%S')} | Orchestration Duration: {duration_ms:.2f} ms*
|
|
986
|
+
|
|
987
|
+
---
|
|
988
|
+
|
|
989
|
+
## 1. Executive Summary
|
|
990
|
+
- **Workspace Name:** `{profile.project_name}`
|
|
991
|
+
- **Primary Language:** **{profile.primary_language}**
|
|
992
|
+
- **Architecture Pattern:** **{profile.architecture_pattern}**
|
|
993
|
+
- **5-Agent Swarm PBFT Consensus:** **{verdict_emoji}**
|
|
994
|
+
- **Total Incurred Cost:** `$0.00` (100% Free / Zero Cloud API Key Required)
|
|
995
|
+
|
|
996
|
+
## 2. Workspace Profile & Telemetry
|
|
997
|
+
- **Detected Frameworks:** `{', '.join(profile.frameworks) or 'Standard Library'}`
|
|
998
|
+
- **Package Managers:** `{', '.join(profile.package_managers)}`
|
|
999
|
+
- **Total Tracked Files:** `{profile.total_files}`
|
|
1000
|
+
- **Estimated Code Lines:** `~{profile.total_code_lines}`
|
|
1001
|
+
- **T-Zero Token Optimization:**
|
|
1002
|
+
- Raw Context Volume: `{profile.raw_tokens_est:,} tokens`
|
|
1003
|
+
- T-Zero Compressed AST Context: `{profile.tzero_compressed_tokens_est:,} tokens`
|
|
1004
|
+
- **Net Context Budget Savings: {profile.token_savings_pct}%**
|
|
1005
|
+
|
|
1006
|
+
## 3. Active AI Governance & Rule Files Generated
|
|
1007
|
+
The following specialized `.md` and configuration governance contracts are active in this workspace:
|
|
1008
|
+
{applied_list}
|
|
1009
|
+
|
|
1010
|
+
## 4. 100% Zero-Leak Security Audit
|
|
1011
|
+
{warnings_list}
|
|
1012
|
+
{diag_section}
|
|
1013
|
+
|
|
1014
|
+
## 5. Architectural Boundaries & Standards
|
|
1015
|
+
```mermaid
|
|
1016
|
+
flowchart LR
|
|
1017
|
+
Dev["Developer / Agent"] --> Jarvis["Jarvis Orchestrator"]
|
|
1018
|
+
Jarvis --> Rules[".cursorrules / AGENT.md / CLAUDE.md"]
|
|
1019
|
+
Jarvis --> AST["T-Zero AST Compression Engine"]
|
|
1020
|
+
Jarvis --> Swarm["5-Agent PBFT Swarm"]
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
*T-Zero Jarvis Master Orchestrator guarantees zero regressions, minimal blast radius, and 100% boundary fidelity.*
|
|
1024
|
+
"""
|
|
1025
|
+
|
|
1026
|
+
def format_capabilities_catalog(self, profile: Optional[WorkspaceProfile] = None) -> str:
|
|
1027
|
+
"""Kullanıcıya veya yapay zeka asistanına Jarvis'in neler yapabileceğini sunan interaktif katalog."""
|
|
1028
|
+
prof = profile or self.profile_workspace()
|
|
1029
|
+
layers_desc = ", ".join(prof.architectural_layers.keys()) or "Standart Katmanlar"
|
|
1030
|
+
|
|
1031
|
+
return f"""# ⚡ T-ZERO JARVIS MASTER WORKSPACE ORCHESTRATOR
|
|
1032
|
+
*Executive AI Engineering Manager & Autonomous Multi-Agent Coordinator*
|
|
1033
|
+
*Version: 5.1.0 | 100% Offline | $0.00 Cost | 100% Zero-Leak Certified*
|
|
1034
|
+
|
|
1035
|
+
---
|
|
1036
|
+
|
|
1037
|
+
### 👑 Merhaba! Ben T-Zero Jarvis.
|
|
1038
|
+
Bu çalışma alanında (`{prof.project_name}`) bir **Yönetici (Executive Manager) ve Süper-Orkestratör** olarak görev yapıyorum.
|
|
1039
|
+
Geliştiriciye veya yapay zeka ajanlarına (Cursor, Claude, Antigravity, Windsurf) adım adım rehberlik edebilir,
|
|
1040
|
+
aşağıdaki otonom yetenekleri sunabilir ve projeyi uçtan uca planlayıp yönetebilirim:
|
|
1041
|
+
|
|
1042
|
+
#### 📊 Çalışma Alanı Durumu (Workspace Overview)
|
|
1043
|
+
- **Proje:** `{prof.project_name}`
|
|
1044
|
+
- **Ana Dil:** **{prof.primary_language}**
|
|
1045
|
+
- **Çatılar:** `{', '.join(prof.frameworks) or 'Standart Kütüphane'}`
|
|
1046
|
+
- **Paket Yöneticisi:** `{', '.join(prof.package_managers)}`
|
|
1047
|
+
- **Mimari Desen:** `{prof.architecture_pattern}`
|
|
1048
|
+
- **Tespit Edilen Katmanlar:** `{layers_desc}`
|
|
1049
|
+
- **Test Komutu:** `{prof.default_test_command}`
|
|
1050
|
+
- **Toplam Dosya:** `{prof.total_files}` (Tahmini Token: `{prof.raw_tokens_est:,}` -> Sıkıştırılmış: `{prof.tzero_compressed_tokens_est:,}`, **%{prof.token_savings_pct} Tasarruf**)
|
|
1051
|
+
|
|
1052
|
+
---
|
|
1053
|
+
|
|
1054
|
+
#### 🛠️ Neler Yapabilirim? (Executive Capabilities)
|
|
1055
|
+
|
|
1056
|
+
1. 📐 **Poliglot AI Yönetişim & Kural Dosyaları (.md) Oluşturma:**
|
|
1057
|
+
- Projenin dili ({prof.primary_language}) ve mimarisine ({prof.architecture_pattern}) özel `.cursorrules`, `.cursor/rules/*.mdc`, `AGENT.md`, `ARCHITECTURE.md`, `.clinerules`, `.windsurfrules`, `CLAUDE.md`, `tzero.rules.json` dosyalarını otomatik üretir ve senkronize ederim (`export_agent_rules`).
|
|
1058
|
+
|
|
1059
|
+
2. 🗜️ **T-Zero AST Token Sıkıştırma & Akıllı İskeletler (%85-%95 Tasarruf):**
|
|
1060
|
+
- Kod tabanındaki {prof.total_files} dosyayı AST seviyesinde analiz ederek bağlam penceresini %90'a varan oranda rahatlatır ve token maliyetini sıfıra indiririm (`get_project_context_tree`, `get_smart_skeleton_context`).
|
|
1061
|
+
|
|
1062
|
+
3. 🐝 **5-Ajanlı PBFT Bizans Sürü Konsensüsü (PBFT Swarm):**
|
|
1063
|
+
- Siber Güvenlik, Donanım, AST Optimizasyonu ve DevOps ajanları ile bağımsız 3-aşamalı Bizans konsensüsü sağlayıp kriptografik onay sertifikası üretirim (`jarvis_bft_swarm_consensus`).
|
|
1064
|
+
|
|
1065
|
+
4. 🩺 **Otonom Kendi Kendini İyileştirme (Self-Healing Loop):**
|
|
1066
|
+
- Test (`{prof.default_test_command}`) ve derleme komutlarını çalıştırır, hata anında traceback'i analiz edip AST yamaları uygularım (`jarvis_self_healing_execute`).
|
|
1067
|
+
|
|
1068
|
+
5. 🕰️ **4D Nedensellik & Zamansal Çizge (Causal Knowledge Graph):**
|
|
1069
|
+
- Olayların ve hataların kök nedenlerini (root causes) tespit eder, güvenli geri alma (rollback) planı hazırlarım (`jarvis_causal_chain_query`).
|
|
1070
|
+
|
|
1071
|
+
6. 🧬 **Shannon Entropili LatentPress Sıkıştırması:**
|
|
1072
|
+
- Uzun log ve bağlamları pre-prefill aşamasında sanal bellek tokenlarına (`<|tzero:mem:...|>`) sıkıştırırım (`jarvis_latent_press_compress`).
|
|
1073
|
+
|
|
1074
|
+
7. 🛡️ **%100 Zero-Leak Siber Güvenlik Denetimi:**
|
|
1075
|
+
- Kod tabanını ve `.env` yapılandırmalarını tarayarak hiçbir kimlik bilgisinin dışarıya sızmamasını garanti ederim (`verify_zero_leak_security`).
|
|
1076
|
+
|
|
1077
|
+
---
|
|
1078
|
+
|
|
1079
|
+
#### 💡 Nasıl Başlatırsınız?
|
|
1080
|
+
- Bir hedef veya görev belirtin (Örn: `"Projede kimlik doğrulama modülünü refactor et"`, `"Mimari kuralları ayarla"`, `"Güvenlik denetimi yap"`).
|
|
1081
|
+
- Jarvis hedefinize özel **Çok Fazlı Master Eylem Planı (Phased Execution Plan)** sunacaktır!
|
|
1082
|
+
"""
|
|
1083
|
+
|
|
1084
|
+
def generate_executive_plan(self, goal: str = "", context: str = "") -> Dict[str, Any]:
|
|
1085
|
+
"""Verilen hedefe veya genel çalışma alanına özel çok fazlı mühendislik eylem planı hazırlar."""
|
|
1086
|
+
prof = self.profile_workspace()
|
|
1087
|
+
effective_goal = goal.strip() if goal and goal.strip().lower() not in ("plan", "help", "ne yapabilirsin", "capabilities", "menu", "yetenekler") else f"{prof.project_name} mimarisini incele, kural dosyalarını (.md) ayarla ve sürü denetimi yap"
|
|
1088
|
+
|
|
1089
|
+
phases = [
|
|
1090
|
+
{
|
|
1091
|
+
"phase_id": 1,
|
|
1092
|
+
"name": "Keşif, AST Haritalama & Etki Analizi",
|
|
1093
|
+
"objectives": [
|
|
1094
|
+
f"Hedef kapsamın ({effective_goal[:60]}...) AST bağımlılıklarını çıkar",
|
|
1095
|
+
f"Olası değişikliklerin patlama yarıçapını (Blast Radius 0-100) hesapla",
|
|
1096
|
+
f"T-1'den T-4'e kadar akıllı iskelet bağlamını hazırla (%85+ token tasarrufu)"
|
|
1097
|
+
],
|
|
1098
|
+
"recommended_mcp_tools": ["get_project_context_tree", "query_module_dependencies", "analyze_change_impact"],
|
|
1099
|
+
"safety_gate": "Zero-Leak ve minimal blast radius doğrulaması"
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
"phase_id": 2,
|
|
1103
|
+
"name": "Yönetişim & Ajan Kural Sözleşmeleri Senkronizasyonu",
|
|
1104
|
+
"objectives": [
|
|
1105
|
+
f"Çalışma alanına özel `.cursorrules`, `AGENT.md` ve `ARCHITECTURE.md` dosyalarını güncelle",
|
|
1106
|
+
f"Mimari katman sınırlarını kilitle (`tzero.rules.json`)",
|
|
1107
|
+
f"Tüm IDE ajanları (Cursor, Claude, Antigravity, Windsurf) için ortak kuralları yay"
|
|
1108
|
+
],
|
|
1109
|
+
"recommended_mcp_tools": ["export_agent_rules", "enforce_architecture_boundaries", "generate_architecture_blueprint"],
|
|
1110
|
+
"safety_gate": "Katman izolasyonu ve döngüsel bağımlılık engelleme"
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
"phase_id": 3,
|
|
1114
|
+
"name": "Cerrahi Mühendislik & 5-Ajanlı PBFT Sürü Konsensüsü",
|
|
1115
|
+
"objectives": [
|
|
1116
|
+
f"Hedefe yönelik kod düzenlemelerini veya geliştirmeyi minimal etki yarıçapıyla uygula",
|
|
1117
|
+
f"5-Ajanlı Bizans Sürüsü (Security, Hardware, AST, DevOps, Prime) ile onay al",
|
|
1118
|
+
f"Semantik çıkarımı anlamsal bellek kod defterine (<|tzero:mem:...|>) kaydet"
|
|
1119
|
+
],
|
|
1120
|
+
"recommended_mcp_tools": ["jarvis_bft_swarm_consensus", "jarvis_compress_semantic_memory", "verify_zero_leak_security"],
|
|
1121
|
+
"safety_gate": "PBFT 2/3 ağırlıklı konsensüs ve Kriptografik Sertifika"
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
"phase_id": 4,
|
|
1125
|
+
"name": "Otonom Doğrulama & Kendi Kendini İyileştirme (Self-Healing)",
|
|
1126
|
+
"objectives": [
|
|
1127
|
+
f"Çalışma alanı test komutunu çalıştır: `{prof.default_test_command}`",
|
|
1128
|
+
f"Linter ve stil kontrolünü çalıştır: `{prof.default_lint_command}`",
|
|
1129
|
+
f"Olası hatalarda cerrahi AST yamalarıyla kendi kendini iyileştir (Self-Healing Loop)"
|
|
1130
|
+
],
|
|
1131
|
+
"recommended_mcp_tools": ["jarvis_self_healing_execute", "audit_codebase_quality"],
|
|
1132
|
+
"safety_gate": "Sıfır regresyon ve %100 yeşil test sonucu"
|
|
1133
|
+
}
|
|
1134
|
+
]
|
|
1135
|
+
|
|
1136
|
+
markdown = self._format_plan_markdown(effective_goal, prof, phases)
|
|
1137
|
+
return {
|
|
1138
|
+
"goal": effective_goal,
|
|
1139
|
+
"project_name": prof.project_name,
|
|
1140
|
+
"primary_language": prof.primary_language,
|
|
1141
|
+
"phases": phases,
|
|
1142
|
+
"markdown": markdown
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
def _format_plan_markdown(self, goal: str, prof: WorkspaceProfile, phases: List[Dict[str, Any]]) -> str:
|
|
1146
|
+
lines = [
|
|
1147
|
+
f"# 🗺️ T-ZERO JARVIS MASTER MÜHENDİSLİK EYLEM PLANI",
|
|
1148
|
+
f"- **Hedef:** **{goal}**",
|
|
1149
|
+
f"- **Çalışma Alanı:** `{prof.project_name}` ({prof.primary_language}) | **Desen:** `{prof.architecture_pattern}`",
|
|
1150
|
+
f"- **Doğrulama Komutu:** `{prof.default_test_command}` | **Maliyet:** `$0.00 (Zero-Key)`",
|
|
1151
|
+
"",
|
|
1152
|
+
"---",
|
|
1153
|
+
""
|
|
1154
|
+
]
|
|
1155
|
+
|
|
1156
|
+
for p in phases:
|
|
1157
|
+
lines.append(f"### 📌 Faz {p['phase_id']}: {p['name']}")
|
|
1158
|
+
lines.append("**Hedefler:**")
|
|
1159
|
+
for obj in p["objectives"]:
|
|
1160
|
+
lines.append(f"- [ ] {obj}")
|
|
1161
|
+
lines.append(f"**Önerilen T-Zero MCP Araçları:** `{', '.join(p['recommended_mcp_tools'])}`")
|
|
1162
|
+
lines.append(f"**Güvenlik / Doğrulama Kapısı:** *{p['safety_gate']}*\n")
|
|
1163
|
+
|
|
1164
|
+
lines.append("---")
|
|
1165
|
+
lines.append("#### 🚀 İcra Başlatma:")
|
|
1166
|
+
lines.append("Bu planı otonom olarak icra etmek için `jarvis_orchestrate_goal` aracını doğrudan bu hedefle çağırabilirsiniz.")
|
|
1167
|
+
return "\n".join(lines)
|