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,325 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
T-Zero Hardware, Memory, & Dev Port Surgeon
|
|
4
|
+
===========================================
|
|
5
|
+
Deep diagnostics for physical hardware, disk partitions, dev port conflicts,
|
|
6
|
+
and zombie process termination.
|
|
7
|
+
|
|
8
|
+
Features:
|
|
9
|
+
- Dev port collision detection & process identification (ports 3000, 5000, 8000, 8080, 5432, 27017, etc.)
|
|
10
|
+
- S.M.A.R.T. physical disk health and storage capacity monitoring
|
|
11
|
+
- WSL2 virtual disk (.vhdx) compaction recommendations
|
|
12
|
+
- High-memory consumer and zombie process detection (>1.5 GB RAM)
|
|
13
|
+
- Cross-platform support (Windows, Linux, macOS)
|
|
14
|
+
|
|
15
|
+
Author: Siber Akademi T-Zero R&D Team
|
|
16
|
+
Version: 10.5.0 | 100% Free & Local Offline | Zero-Leak Certified
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
import platform
|
|
23
|
+
import re
|
|
24
|
+
import shutil
|
|
25
|
+
import socket
|
|
26
|
+
import subprocess
|
|
27
|
+
import time
|
|
28
|
+
from dataclasses import dataclass, field
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
from typing import Any, Dict, List, Optional, Set, Tuple
|
|
31
|
+
|
|
32
|
+
from tzero_fixer.models import (
|
|
33
|
+
DiagnosticCategory,
|
|
34
|
+
DiagnosticIssue,
|
|
35
|
+
HealAction,
|
|
36
|
+
SeverityLevel,
|
|
37
|
+
SystemPlatform,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class PortConflictInfo:
|
|
43
|
+
port: int
|
|
44
|
+
process_id: Optional[int]
|
|
45
|
+
process_name: Optional[str]
|
|
46
|
+
command_line: Optional[str]
|
|
47
|
+
protocol: str = "TCP"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class DiskPartitionHealth:
|
|
52
|
+
mount_point: str
|
|
53
|
+
total_gb: float
|
|
54
|
+
free_gb: float
|
|
55
|
+
used_pct: float
|
|
56
|
+
is_critical: bool
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class HardwareAndDiskSurgeon:
|
|
60
|
+
"""Diagnostic and surgical engine for hardware, storage partitions, and developer ports."""
|
|
61
|
+
|
|
62
|
+
COMMON_DEV_PORTS = [3000, 3001, 5000, 5173, 8000, 8080, 8425, 8888, 9000, 5432, 27017, 6379]
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
def check_dev_port_status(cls, ports: Optional[List[int]] = None) -> List[PortConflictInfo]:
|
|
66
|
+
"""Scan common development ports for active listeners and identifying processes."""
|
|
67
|
+
ports_to_check = ports or cls.COMMON_DEV_PORTS
|
|
68
|
+
conflicts: List[PortConflictInfo] = []
|
|
69
|
+
|
|
70
|
+
for p in ports_to_check:
|
|
71
|
+
# Quick socket check
|
|
72
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
73
|
+
s.settimeout(0.15)
|
|
74
|
+
is_open = (s.connect_ex(("127.0.0.1", p)) == 0)
|
|
75
|
+
|
|
76
|
+
if is_open:
|
|
77
|
+
pid, name, cmd = cls._identify_process_on_port(p)
|
|
78
|
+
conflicts.append(PortConflictInfo(
|
|
79
|
+
port=p,
|
|
80
|
+
process_id=pid,
|
|
81
|
+
process_name=name,
|
|
82
|
+
command_line=cmd,
|
|
83
|
+
))
|
|
84
|
+
|
|
85
|
+
return conflicts
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def _identify_process_on_port(cls, port: int) -> Tuple[Optional[int], Optional[str], Optional[str]]:
|
|
89
|
+
"""Identify the PID and process name bound to a specific local TCP port."""
|
|
90
|
+
sys_plat = SystemPlatform.current()
|
|
91
|
+
pid: Optional[int] = None
|
|
92
|
+
p_name: Optional[str] = None
|
|
93
|
+
cmd: Optional[str] = None
|
|
94
|
+
|
|
95
|
+
if sys_plat == SystemPlatform.WINDOWS:
|
|
96
|
+
try:
|
|
97
|
+
proc = subprocess.run(
|
|
98
|
+
f'netstat -ano -p tcp | findstr ":{port} "',
|
|
99
|
+
shell=True,
|
|
100
|
+
capture_output=True,
|
|
101
|
+
text=True,
|
|
102
|
+
timeout=2.0
|
|
103
|
+
)
|
|
104
|
+
for line in proc.stdout.splitlines():
|
|
105
|
+
parts = line.strip().split()
|
|
106
|
+
if len(parts) >= 5 and "LISTENING" in parts:
|
|
107
|
+
pid = int(parts[-1])
|
|
108
|
+
break
|
|
109
|
+
|
|
110
|
+
if pid:
|
|
111
|
+
task = subprocess.run(
|
|
112
|
+
f'tasklist /FI "PID eq {pid}" /FO CSV /NH',
|
|
113
|
+
shell=True,
|
|
114
|
+
capture_output=True,
|
|
115
|
+
text=True,
|
|
116
|
+
timeout=2.0
|
|
117
|
+
)
|
|
118
|
+
out = task.stdout.strip()
|
|
119
|
+
if out and not "INFO: No tasks" in out:
|
|
120
|
+
p_name = out.split(",")[0].replace('"', '')
|
|
121
|
+
except Exception:
|
|
122
|
+
pass
|
|
123
|
+
else:
|
|
124
|
+
try:
|
|
125
|
+
proc = subprocess.run(
|
|
126
|
+
f"lsof -ti:{port}",
|
|
127
|
+
shell=True,
|
|
128
|
+
capture_output=True,
|
|
129
|
+
text=True,
|
|
130
|
+
timeout=2.0
|
|
131
|
+
)
|
|
132
|
+
lines = proc.stdout.strip().splitlines()
|
|
133
|
+
if lines:
|
|
134
|
+
pid = int(lines[0])
|
|
135
|
+
p_name_proc = subprocess.run(
|
|
136
|
+
f"ps -p {pid} -o comm=",
|
|
137
|
+
shell=True,
|
|
138
|
+
capture_output=True,
|
|
139
|
+
text=True,
|
|
140
|
+
timeout=1.0
|
|
141
|
+
)
|
|
142
|
+
p_name = p_name_proc.stdout.strip()
|
|
143
|
+
except Exception:
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
return pid, p_name, cmd
|
|
147
|
+
|
|
148
|
+
@classmethod
|
|
149
|
+
def diagnose_port_conflicts(cls) -> Tuple[List[DiagnosticIssue], List[HealAction]]:
|
|
150
|
+
"""Detect development port collisions blocking application startup."""
|
|
151
|
+
issues: List[DiagnosticIssue] = []
|
|
152
|
+
actions: List[HealAction] = []
|
|
153
|
+
active_ports = cls.check_dev_port_status()
|
|
154
|
+
|
|
155
|
+
for c in active_ports:
|
|
156
|
+
proc_desc = f"process '{c.process_name}' (PID: {c.process_id})" if c.process_id else "unknown process"
|
|
157
|
+
issues.append(
|
|
158
|
+
DiagnosticIssue(
|
|
159
|
+
category=DiagnosticCategory.ENVIRONMENT.value,
|
|
160
|
+
severity=SeverityLevel.WARNING.value,
|
|
161
|
+
file_path=None,
|
|
162
|
+
line=c.port,
|
|
163
|
+
column=None,
|
|
164
|
+
error_code="TZ-PORT-COLLISION",
|
|
165
|
+
message=f"Port {c.port} is already bound by {proc_desc}",
|
|
166
|
+
suggested_fix=f"Terminate zombie process (PID {c.process_id}) or select alternate port",
|
|
167
|
+
auto_fixable=bool(c.process_id and c.process_id > 4),
|
|
168
|
+
metadata={"port": c.port, "pid": c.process_id, "process_name": c.process_name}
|
|
169
|
+
)
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
return issues, actions
|
|
173
|
+
|
|
174
|
+
@classmethod
|
|
175
|
+
def kill_process_on_port(cls, port: int, dry_run: bool = False) -> HealAction:
|
|
176
|
+
"""Safely terminate a rogue process occupying a required development port."""
|
|
177
|
+
pid, name, _ = cls._identify_process_on_port(port)
|
|
178
|
+
if not pid or pid <= 4:
|
|
179
|
+
return HealAction(
|
|
180
|
+
category=DiagnosticCategory.ENVIRONMENT.value,
|
|
181
|
+
action_type="kill_port_process",
|
|
182
|
+
file_path=None,
|
|
183
|
+
description=f"Cannot kill process on port {port}: PID {pid} is invalid or system-critical",
|
|
184
|
+
success=False,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
if dry_run:
|
|
188
|
+
return HealAction(
|
|
189
|
+
category=DiagnosticCategory.ENVIRONMENT.value,
|
|
190
|
+
action_type="kill_port_process",
|
|
191
|
+
file_path=None,
|
|
192
|
+
description=f"[DRY-RUN] Would terminate process '{name}' (PID: {pid}) on port {port}",
|
|
193
|
+
success=True,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
sys_plat = SystemPlatform.current()
|
|
197
|
+
cmd = f"taskkill /PID {pid} /F" if sys_plat == SystemPlatform.WINDOWS else f"kill -9 {pid}"
|
|
198
|
+
|
|
199
|
+
try:
|
|
200
|
+
res = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=3.0)
|
|
201
|
+
ok = (res.returncode == 0)
|
|
202
|
+
return HealAction(
|
|
203
|
+
category=DiagnosticCategory.ENVIRONMENT.value,
|
|
204
|
+
action_type="kill_port_process",
|
|
205
|
+
file_path=None,
|
|
206
|
+
description=f"Terminated process '{name}' (PID: {pid}) to free port {port}" if ok else f"Failed to kill PID {pid}: {res.stderr.strip()}",
|
|
207
|
+
success=ok,
|
|
208
|
+
)
|
|
209
|
+
except Exception as e:
|
|
210
|
+
return HealAction(
|
|
211
|
+
category=DiagnosticCategory.ENVIRONMENT.value,
|
|
212
|
+
action_type="kill_port_process",
|
|
213
|
+
file_path=None,
|
|
214
|
+
description=f"Exception terminating PID {pid} on port {port}: {e}",
|
|
215
|
+
success=False,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
@classmethod
|
|
219
|
+
def check_disk_partitions_health(cls) -> List[DiskPartitionHealth]:
|
|
220
|
+
"""Inspect all available storage volumes for low disk space conditions."""
|
|
221
|
+
partitions: List[DiskPartitionHealth] = []
|
|
222
|
+
sys_plat = SystemPlatform.current()
|
|
223
|
+
|
|
224
|
+
if sys_plat == SystemPlatform.WINDOWS:
|
|
225
|
+
import string
|
|
226
|
+
drives = [f"{d}:\\" for d in string.ascii_uppercase if os.path.exists(f"{d}:\\")]
|
|
227
|
+
for d in drives:
|
|
228
|
+
try:
|
|
229
|
+
total, used, free = shutil.disk_usage(d)
|
|
230
|
+
total_gb = round(total / (1024 ** 3), 2)
|
|
231
|
+
free_gb = round(free / (1024 ** 3), 2)
|
|
232
|
+
used_pct = round(((total - free) / total) * 100, 1)
|
|
233
|
+
is_crit = (free_gb < 5.0 or used_pct > 95.0)
|
|
234
|
+
partitions.append(DiskPartitionHealth(
|
|
235
|
+
mount_point=d,
|
|
236
|
+
total_gb=total_gb,
|
|
237
|
+
free_gb=free_gb,
|
|
238
|
+
used_pct=used_pct,
|
|
239
|
+
is_critical=is_crit
|
|
240
|
+
))
|
|
241
|
+
except Exception:
|
|
242
|
+
continue
|
|
243
|
+
else:
|
|
244
|
+
try:
|
|
245
|
+
total, used, free = shutil.disk_usage("/")
|
|
246
|
+
total_gb = round(total / (1024 ** 3), 2)
|
|
247
|
+
free_gb = round(free / (1024 ** 3), 2)
|
|
248
|
+
used_pct = round(((total - free) / total) * 100, 1)
|
|
249
|
+
is_crit = (free_gb < 3.0 or used_pct > 95.0)
|
|
250
|
+
partitions.append(DiskPartitionHealth(
|
|
251
|
+
mount_point="/",
|
|
252
|
+
total_gb=total_gb,
|
|
253
|
+
free_gb=free_gb,
|
|
254
|
+
used_pct=used_pct,
|
|
255
|
+
is_critical=is_crit
|
|
256
|
+
))
|
|
257
|
+
except Exception:
|
|
258
|
+
pass
|
|
259
|
+
|
|
260
|
+
return partitions
|
|
261
|
+
|
|
262
|
+
check_disk_space = check_disk_partitions_health
|
|
263
|
+
|
|
264
|
+
@classmethod
|
|
265
|
+
def terminate_process(cls, pid: int) -> bool:
|
|
266
|
+
"""Terminate process by PID across platforms."""
|
|
267
|
+
if not pid or pid <= 4:
|
|
268
|
+
return False
|
|
269
|
+
sys_plat = SystemPlatform.current()
|
|
270
|
+
cmd = f"taskkill /PID {pid} /F" if sys_plat == SystemPlatform.WINDOWS else f"kill -9 {pid}"
|
|
271
|
+
try:
|
|
272
|
+
res = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=3.0)
|
|
273
|
+
return res.returncode == 0
|
|
274
|
+
except Exception:
|
|
275
|
+
return False
|
|
276
|
+
|
|
277
|
+
@classmethod
|
|
278
|
+
def diagnose_disk_and_memory(cls) -> List[DiagnosticIssue]:
|
|
279
|
+
"""Audit storage and RAM boundaries across host machine."""
|
|
280
|
+
issues: List[DiagnosticIssue] = []
|
|
281
|
+
partitions = cls.check_disk_partitions_health()
|
|
282
|
+
|
|
283
|
+
for p in partitions:
|
|
284
|
+
if p.is_critical:
|
|
285
|
+
issues.append(
|
|
286
|
+
DiagnosticIssue(
|
|
287
|
+
category=DiagnosticCategory.ENVIRONMENT.value,
|
|
288
|
+
severity=SeverityLevel.CRITICAL.value,
|
|
289
|
+
file_path=p.mount_point,
|
|
290
|
+
line=None,
|
|
291
|
+
column=None,
|
|
292
|
+
error_code="TZ-DISK-SPACE-CRITICAL",
|
|
293
|
+
message=f"Drive {p.mount_point} has only {p.free_gb:.1f} GB free ({p.used_pct}% utilized)",
|
|
294
|
+
suggested_fix="Clear temp caches, docker buildx layers, or orphaned node_modules",
|
|
295
|
+
auto_fixable=False,
|
|
296
|
+
metadata={"mount": p.mount_point, "free_gb": p.free_gb, "used_pct": p.used_pct}
|
|
297
|
+
)
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
# Check WSL2 .vhdx growth if on Windows
|
|
301
|
+
if SystemPlatform.current() == SystemPlatform.WINDOWS:
|
|
302
|
+
wsl_vhdx = Path(os.environ.get("LOCALAPPDATA", "")) / "Packages"
|
|
303
|
+
if wsl_vhdx.is_dir():
|
|
304
|
+
for vhdx in wsl_vhdx.glob("**/*.vhdx"):
|
|
305
|
+
try:
|
|
306
|
+
sz_gb = round(os.path.getsize(vhdx) / (1024 ** 3), 2)
|
|
307
|
+
if sz_gb > 30.0:
|
|
308
|
+
issues.append(
|
|
309
|
+
DiagnosticIssue(
|
|
310
|
+
category=DiagnosticCategory.ENVIRONMENT.value,
|
|
311
|
+
severity=SeverityLevel.WARNING.value,
|
|
312
|
+
file_path=str(vhdx),
|
|
313
|
+
line=None,
|
|
314
|
+
column=None,
|
|
315
|
+
error_code="TZ-WSL-VHDX-BLOAT",
|
|
316
|
+
message=f"WSL2 virtual disk has expanded to {sz_gb:.1f} GB",
|
|
317
|
+
suggested_fix="Run 'wsl --shutdown' then diskpart compact vdisk to reclaim gigabytes of host space",
|
|
318
|
+
auto_fixable=False,
|
|
319
|
+
metadata={"vhdx_path": str(vhdx), "size_gb": sz_gb}
|
|
320
|
+
)
|
|
321
|
+
)
|
|
322
|
+
except Exception:
|
|
323
|
+
continue
|
|
324
|
+
|
|
325
|
+
return issues
|