tzero-mcp 11.0.0 → 11.11.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +56 -56
  2. package/CONTRIBUTING.md +71 -71
  3. package/LICENSE +21 -21
  4. package/README.md +64 -64
  5. package/bin/tzero-mcp.js +62 -62
  6. package/bin/tzero.js +61 -61
  7. package/index.d.ts +25 -25
  8. package/index.js +15 -15
  9. package/package.json +89 -88
  10. package/src/addmcp.py +1203 -1197
  11. package/src/app.py +1810 -1810
  12. package/src/main.py +60 -60
  13. package/src/pc_fixer_mcp.py +25 -25
  14. package/src/tzero/__init__.py +54 -54
  15. package/src/tzero/__main__.py +6 -6
  16. package/src/tzero/siber_akademi_icon.py +77 -77
  17. package/src/tzero/tzero_arch_test.py +463 -463
  18. package/src/tzero/tzero_benchmark.py +475 -475
  19. package/src/tzero/tzero_blackboard.py +257 -257
  20. package/src/tzero/tzero_bridge.py +546 -546
  21. package/src/tzero/tzero_budget.py +195 -195
  22. package/src/tzero/tzero_card.py +431 -0
  23. package/src/tzero/tzero_ci.py +153 -153
  24. package/src/tzero/tzero_commit.py +192 -192
  25. package/src/tzero/tzero_contracts.py +1093 -1093
  26. package/src/tzero/tzero_cost.py +166 -166
  27. package/src/tzero/tzero_dashboard.py +1960 -1960
  28. package/src/tzero/tzero_debt.py +461 -461
  29. package/src/tzero/tzero_deps.py +462 -462
  30. package/src/tzero/tzero_drift.py +208 -208
  31. package/src/tzero/tzero_explain.py +306 -306
  32. package/src/tzero/tzero_features.py +3024 -3024
  33. package/src/tzero/tzero_federation.py +299 -299
  34. package/src/tzero/tzero_fix.py +557 -228
  35. package/src/tzero/tzero_fixer/__init__.py +63 -63
  36. package/src/tzero/tzero_fixer/amalgamation.py +334 -334
  37. package/src/tzero/tzero_fixer/ast_syntax_healer.py +464 -464
  38. package/src/tzero/tzero_fixer/ast_type_modernizer.py +288 -288
  39. package/src/tzero/tzero_fixer/async_io_modernizer.py +127 -127
  40. package/src/tzero/tzero_fixer/automated_regression_suite.py +600 -600
  41. package/src/tzero/tzero_fixer/benchmarks_and_diagnostics.py +174 -174
  42. package/src/tzero/tzero_fixer/ci_cd_self_healing_gate.py +246 -246
  43. package/src/tzero/tzero_fixer/code_duplicity_and_refactorer.py +151 -151
  44. package/src/tzero/tzero_fixer/code_smells_healer.py +260 -260
  45. package/src/tzero/tzero_fixer/cwe_remediator.py +171 -171
  46. package/src/tzero/tzero_fixer/dead_code_eliminator.py +150 -150
  47. package/src/tzero/tzero_fixer/dependency_vulnerability_auditor.py +309 -309
  48. package/src/tzero/tzero_fixer/git_advanced_surgeon.py +280 -280
  49. package/src/tzero/tzero_fixer/hardware_and_disk_doctor.py +325 -325
  50. package/src/tzero/tzero_fixer/import_graph_healer.py +412 -412
  51. package/src/tzero/tzero_fixer/interactive_tui.py +91 -91
  52. package/src/tzero/tzero_fixer/knowledge_base.py +295 -295
  53. package/src/tzero/tzero_fixer/knowledge_base_extended.py +940 -940
  54. package/src/tzero/tzero_fixer/linters_and_static_analyzer.py +307 -307
  55. package/src/tzero/tzero_fixer/mcp_server.py +489 -489
  56. package/src/tzero/tzero_fixer/models.py +385 -385
  57. package/src/tzero/tzero_fixer/orchestrator.py +375 -375
  58. package/src/tzero/tzero_fixer/os_doctor.py +502 -502
  59. package/src/tzero/tzero_fixer/packaging_abi_surgeon.py +323 -323
  60. package/src/tzero/tzero_fixer/pc_fixer_doctor.py +600 -600
  61. package/src/tzero/tzero_fixer/performance_and_memory_profiler.py +274 -274
  62. package/src/tzero/tzero_fixer/polyglot_ast_parsers.py +313 -313
  63. package/src/tzero/tzero_fixer/polyglot_build_healer.py +364 -364
  64. package/src/tzero/tzero_fixer/polyglot_config_healer.py +318 -318
  65. package/src/tzero/tzero_fixer/polyglot_doctor.py +372 -372
  66. package/src/tzero/tzero_fixer/polyglot_linters.py +619 -619
  67. package/src/tzero/tzero_fixer/polyglot_schema_validator.py +305 -305
  68. package/src/tzero/tzero_fixer/security_cwe_database.py +444 -444
  69. package/src/tzero/tzero_fixer/security_deep_rules.py +114 -114
  70. package/src/tzero/tzero_fixer/security_rules_catalog.py +110 -110
  71. package/src/tzero/tzero_fixer/security_zero_leak.py +326 -326
  72. package/src/tzero/tzero_fixer/smart_patch_recommender.py +223 -223
  73. package/src/tzero/tzero_fixer/synthetic_workspace_generator.py +220 -220
  74. package/src/tzero/tzero_fixer/system_diagnostics_extended.py +493 -493
  75. package/src/tzero/tzero_fixer/system_repair_recipes.py +447 -447
  76. package/src/tzero/tzero_fixer/venv_doctor.py +309 -309
  77. package/src/tzero/tzero_golden.py +319 -319
  78. package/src/tzero/tzero_graph_hud.html +338 -338
  79. package/src/tzero/tzero_graph_rag.py +263 -263
  80. package/src/tzero/tzero_growth.py +415 -0
  81. package/src/tzero/tzero_guard.py +251 -243
  82. package/src/tzero/tzero_hooks.py +565 -565
  83. package/src/tzero/tzero_infra.py +274 -274
  84. package/src/tzero/tzero_jarvis/__init__.py +134 -124
  85. package/src/tzero/tzero_jarvis/causal_graph.py +310 -310
  86. package/src/tzero/tzero_jarvis/creative_director.py +333 -0
  87. package/src/tzero/tzero_jarvis/graph_visualizer.py +395 -395
  88. package/src/tzero/tzero_jarvis/hybrid_search.py +214 -214
  89. package/src/tzero/tzero_jarvis/latent_press.py +137 -137
  90. package/src/tzero/tzero_jarvis/memory_consolidation.py +212 -212
  91. package/src/tzero/tzero_jarvis/minhash_lsh.py +184 -184
  92. package/src/tzero/tzero_jarvis/orchestrator.py +335 -335
  93. package/src/tzero/tzero_jarvis/self_healing.py +308 -308
  94. package/src/tzero/tzero_jarvis/semantic_compressor.py +887 -887
  95. package/src/tzero/tzero_jarvis/swarm.py +261 -261
  96. package/src/tzero/tzero_jarvis/swarm_bft.py +144 -144
  97. package/src/tzero/tzero_jarvis/workspace_orchestrator.py +1167 -1167
  98. package/src/tzero/tzero_jarvis/zero_key_router.py +173 -173
  99. package/src/tzero/tzero_lsp.py +634 -634
  100. package/src/tzero/tzero_mcp.py +5314 -5237
  101. package/src/tzero/tzero_mutation.py +358 -358
  102. package/src/tzero/tzero_neural_cortex.py +1425 -1425
  103. package/src/tzero/tzero_packer.py +577 -577
  104. package/src/tzero/tzero_patch.py +624 -624
  105. package/src/tzero/tzero_pc_fixer.py +12699 -12699
  106. package/src/tzero/tzero_pipe.py +95 -95
  107. package/src/tzero/tzero_polyglot.py +799 -799
  108. package/src/tzero/tzero_proxy.py +127 -127
  109. package/src/tzero/tzero_reachability.py +272 -272
  110. package/src/tzero/tzero_replay.py +141 -141
  111. package/src/tzero/tzero_rust_bridge.py +198 -198
  112. package/src/tzero/tzero_scip.py +368 -368
  113. package/src/tzero/tzero_security.py +573 -573
  114. package/src/tzero/tzero_semantic_merge.py +189 -189
  115. package/src/tzero/tzero_snapshot.py +471 -471
  116. package/src/tzero/tzero_stubs.py +313 -313
  117. package/src/tzero/tzero_subagent_engine.py +459 -459
  118. package/src/tzero/tzero_superdesign.py +774 -774
  119. package/src/tzero/tzero_sync.py +241 -241
  120. package/src/tzero/tzero_task_benchmark.py +506 -458
  121. package/src/tzero/tzero_tui.py +313 -313
  122. package/src/tzero/tzero_turbo.py +264 -264
  123. package/src/tzero/tzero_v3.py +9997 -9900
  124. package/src/tzero.py +6 -6
  125. package/src/tzero_mcp.py +25 -0
  126. package/test/package.test.js +55 -55
@@ -1,127 +1,127 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- T-Zero AsyncIO & Event Loop Blocking I/O Healer
4
- ==============================================
5
- Static AST analyzer that detects synchronous blocking calls (time.sleep, requests.get,
6
- blocking file operations) inside async coroutines (`async def`), preventing event loop starvation.
7
-
8
- Key Capabilities:
9
- - Detects `time.sleep()` inside `async def` and auto-heals to `await asyncio.sleep()`
10
- - Auto-injects `import asyncio` if missing when modernizing sleep calls
11
- - Detects blocking `requests.*` calls inside async coroutines
12
- - Detects blocking `subprocess.run()` calls without async executors
13
-
14
- Author: Siber Akademi T-Zero R&D Team
15
- Version: 10.5.0 | 100% Free & Local Offline | Zero-Leak Certified
16
- """
17
-
18
- from __future__ import annotations
19
-
20
- import ast
21
- import os
22
- import re
23
- from dataclasses import dataclass
24
- from pathlib import Path
25
- from typing import Any, Dict, List, Optional, Tuple
26
-
27
- from tzero.tzero_fixer.models import (
28
- DiagnosticCategory,
29
- DiagnosticIssue,
30
- HealAction,
31
- SeverityLevel,
32
- )
33
-
34
-
35
- class AsyncIoModernizer:
36
- """Specialist healer for async/await event loop hygiene and blocking I/O prevention."""
37
-
38
- @classmethod
39
- def diagnose_file(cls, file_path: str) -> List[DiagnosticIssue]:
40
- """Audit Python file for blocking calls inside async coroutines."""
41
- issues: List[DiagnosticIssue] = []
42
- try:
43
- content = Path(file_path).read_text(encoding="utf-8", errors="replace")
44
- tree = ast.parse(content, filename=file_path)
45
- except Exception:
46
- return issues
47
-
48
- for node in ast.walk(tree):
49
- if isinstance(node, ast.AsyncFunctionDef):
50
- # Traverse inside this async function only
51
- for sub in ast.walk(node):
52
- if isinstance(sub, ast.Call):
53
- # 1. Check time.sleep()
54
- if isinstance(sub.func, ast.Attribute) and sub.func.attr == "sleep":
55
- if isinstance(sub.func.value, ast.Name) and sub.func.value.id == "time":
56
- issues.append(DiagnosticIssue(
57
- category=DiagnosticCategory.PERFORMANCE,
58
- severity=SeverityLevel.WARNING,
59
- file_path=file_path,
60
- line_number=sub.lineno,
61
- error_code="TZ-ASYNC-BLOCKING-SLEEP",
62
- message=f"Event Loop Starvation: Synchronous 'time.sleep()' called inside async function '{node.name}'",
63
- suggested_fix="Replace with non-blocking 'await asyncio.sleep()'",
64
- auto_fixable=True,
65
- metadata={
66
- "issue_type": "async_time_sleep",
67
- "line_num": sub.lineno,
68
- "func_name": node.name,
69
- },
70
- ))
71
-
72
- # 2. Check requests.* inside async
73
- if isinstance(sub.func, ast.Attribute) and sub.func.attr in ("get", "post", "put", "delete"):
74
- if isinstance(sub.func.value, ast.Name) and sub.func.value.id == "requests":
75
- issues.append(DiagnosticIssue(
76
- category=DiagnosticCategory.PERFORMANCE,
77
- severity=SeverityLevel.WARNING,
78
- file_path=file_path,
79
- line_number=sub.lineno,
80
- error_code="TZ-ASYNC-BLOCKING-HTTP",
81
- message=f"Blocking HTTP Request: Synchronous 'requests.{sub.func.attr}()' called inside async function '{node.name}'",
82
- suggested_fix="Wrap with 'asyncio.to_thread()' or migrate to 'httpx.AsyncClient'",
83
- auto_fixable=False,
84
- metadata={"issue_type": "async_blocking_http", "line_num": sub.lineno},
85
- ))
86
-
87
- return issues
88
-
89
- @classmethod
90
- def heal_issue(cls, issue: DiagnosticIssue, dry_run: bool = False) -> HealAction:
91
- """Autonomously heal async event loop blocking issues."""
92
- itype = issue.metadata.get("issue_type")
93
- file_path = issue.file_path
94
- line_num = issue.metadata.get("line_num")
95
-
96
- if itype == "async_time_sleep" and file_path and line_num:
97
- p = Path(file_path)
98
- if not p.is_file():
99
- return HealAction(issue=issue, success=False, details="File not found")
100
-
101
- if dry_run:
102
- return HealAction(issue=issue, success=True, details="[Dry-Run] Would convert time.sleep() to await asyncio.sleep()")
103
-
104
- content = p.read_text(encoding="utf-8", errors="replace")
105
- lines = content.splitlines()
106
-
107
- if 1 <= line_num <= len(lines):
108
- orig_line = lines[line_num - 1]
109
- # Replace time.sleep(...) with await asyncio.sleep(...)
110
- repaired_line = re.sub(r"\btime\.sleep\(", "await asyncio.sleep(", orig_line)
111
- lines[line_num - 1] = repaired_line
112
-
113
- # Check if import asyncio is present
114
- has_asyncio = any(re.match(r"^import\s+asyncio\b", l) for l in lines)
115
- if not has_asyncio:
116
- # Insert after __future__ or top
117
- insert_idx = 0
118
- for idx, l in enumerate(lines):
119
- if l.startswith("from __future__"):
120
- insert_idx = idx + 1
121
- lines.insert(insert_idx, "import asyncio")
122
-
123
- p.write_text("\n".join(lines) + "\n", encoding="utf-8")
124
- return HealAction(issue=issue, success=True, details="Converted 'time.sleep()' to non-blocking 'await asyncio.sleep()' with auto-import")
125
-
126
- return HealAction(issue=issue, success=False, details=f"No automated heal for issue type '{itype}'")
127
-
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ T-Zero AsyncIO & Event Loop Blocking I/O Healer
4
+ ==============================================
5
+ Static AST analyzer that detects synchronous blocking calls (time.sleep, requests.get,
6
+ blocking file operations) inside async coroutines (`async def`), preventing event loop starvation.
7
+
8
+ Key Capabilities:
9
+ - Detects `time.sleep()` inside `async def` and auto-heals to `await asyncio.sleep()`
10
+ - Auto-injects `import asyncio` if missing when modernizing sleep calls
11
+ - Detects blocking `requests.*` calls inside async coroutines
12
+ - Detects blocking `subprocess.run()` calls without async executors
13
+
14
+ Author: Siber Akademi T-Zero R&D Team
15
+ Version: 10.5.0 | 100% Free & Local Offline | Zero-Leak Certified
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ import ast
21
+ import os
22
+ import re
23
+ from dataclasses import dataclass
24
+ from pathlib import Path
25
+ from typing import Any, Dict, List, Optional, Tuple
26
+
27
+ from tzero.tzero_fixer.models import (
28
+ DiagnosticCategory,
29
+ DiagnosticIssue,
30
+ HealAction,
31
+ SeverityLevel,
32
+ )
33
+
34
+
35
+ class AsyncIoModernizer:
36
+ """Specialist healer for async/await event loop hygiene and blocking I/O prevention."""
37
+
38
+ @classmethod
39
+ def diagnose_file(cls, file_path: str) -> List[DiagnosticIssue]:
40
+ """Audit Python file for blocking calls inside async coroutines."""
41
+ issues: List[DiagnosticIssue] = []
42
+ try:
43
+ content = Path(file_path).read_text(encoding="utf-8", errors="replace")
44
+ tree = ast.parse(content, filename=file_path)
45
+ except Exception:
46
+ return issues
47
+
48
+ for node in ast.walk(tree):
49
+ if isinstance(node, ast.AsyncFunctionDef):
50
+ # Traverse inside this async function only
51
+ for sub in ast.walk(node):
52
+ if isinstance(sub, ast.Call):
53
+ # 1. Check time.sleep()
54
+ if isinstance(sub.func, ast.Attribute) and sub.func.attr == "sleep":
55
+ if isinstance(sub.func.value, ast.Name) and sub.func.value.id == "time":
56
+ issues.append(DiagnosticIssue(
57
+ category=DiagnosticCategory.PERFORMANCE,
58
+ severity=SeverityLevel.WARNING,
59
+ file_path=file_path,
60
+ line_number=sub.lineno,
61
+ error_code="TZ-ASYNC-BLOCKING-SLEEP",
62
+ message=f"Event Loop Starvation: Synchronous 'time.sleep()' called inside async function '{node.name}'",
63
+ suggested_fix="Replace with non-blocking 'await asyncio.sleep()'",
64
+ auto_fixable=True,
65
+ metadata={
66
+ "issue_type": "async_time_sleep",
67
+ "line_num": sub.lineno,
68
+ "func_name": node.name,
69
+ },
70
+ ))
71
+
72
+ # 2. Check requests.* inside async
73
+ if isinstance(sub.func, ast.Attribute) and sub.func.attr in ("get", "post", "put", "delete"):
74
+ if isinstance(sub.func.value, ast.Name) and sub.func.value.id == "requests":
75
+ issues.append(DiagnosticIssue(
76
+ category=DiagnosticCategory.PERFORMANCE,
77
+ severity=SeverityLevel.WARNING,
78
+ file_path=file_path,
79
+ line_number=sub.lineno,
80
+ error_code="TZ-ASYNC-BLOCKING-HTTP",
81
+ message=f"Blocking HTTP Request: Synchronous 'requests.{sub.func.attr}()' called inside async function '{node.name}'",
82
+ suggested_fix="Wrap with 'asyncio.to_thread()' or migrate to 'httpx.AsyncClient'",
83
+ auto_fixable=False,
84
+ metadata={"issue_type": "async_blocking_http", "line_num": sub.lineno},
85
+ ))
86
+
87
+ return issues
88
+
89
+ @classmethod
90
+ def heal_issue(cls, issue: DiagnosticIssue, dry_run: bool = False) -> HealAction:
91
+ """Autonomously heal async event loop blocking issues."""
92
+ itype = issue.metadata.get("issue_type")
93
+ file_path = issue.file_path
94
+ line_num = issue.metadata.get("line_num")
95
+
96
+ if itype == "async_time_sleep" and file_path and line_num:
97
+ p = Path(file_path)
98
+ if not p.is_file():
99
+ return HealAction(issue=issue, success=False, details="File not found")
100
+
101
+ if dry_run:
102
+ return HealAction(issue=issue, success=True, details="[Dry-Run] Would convert time.sleep() to await asyncio.sleep()")
103
+
104
+ content = p.read_text(encoding="utf-8", errors="replace")
105
+ lines = content.splitlines()
106
+
107
+ if 1 <= line_num <= len(lines):
108
+ orig_line = lines[line_num - 1]
109
+ # Replace time.sleep(...) with await asyncio.sleep(...)
110
+ repaired_line = re.sub(r"\btime\.sleep\(", "await asyncio.sleep(", orig_line)
111
+ lines[line_num - 1] = repaired_line
112
+
113
+ # Check if import asyncio is present
114
+ has_asyncio = any(re.match(r"^import\s+asyncio\b", l) for l in lines)
115
+ if not has_asyncio:
116
+ # Insert after __future__ or top
117
+ insert_idx = 0
118
+ for idx, l in enumerate(lines):
119
+ if l.startswith("from __future__"):
120
+ insert_idx = idx + 1
121
+ lines.insert(insert_idx, "import asyncio")
122
+
123
+ p.write_text("\n".join(lines) + "\n", encoding="utf-8")
124
+ return HealAction(issue=issue, success=True, details="Converted 'time.sleep()' to non-blocking 'await asyncio.sleep()' with auto-import")
125
+
126
+ return HealAction(issue=issue, success=False, details=f"No automated heal for issue type '{itype}'")
127
+