tzero-mcp 12.3.3 → 12.3.5

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 (62) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +4 -0
  3. package/package.json +3 -4
  4. package/src/addmcp.py +2 -2
  5. package/src/app.py +1 -1
  6. package/src/main.py +4 -0
  7. package/src/tzero/__init__.py +1 -1
  8. package/src/tzero/desktop_updater.py +6 -0
  9. package/src/tzero/tzero_benchmark.py +1 -1
  10. package/src/tzero/tzero_budget.py +1 -1
  11. package/src/tzero/tzero_ci.py +1 -1
  12. package/src/tzero/tzero_contracts.py +2 -2
  13. package/src/tzero/tzero_dashboard.py +3 -3
  14. package/src/tzero/tzero_debt.py +1 -1
  15. package/src/tzero/tzero_deps.py +1 -0
  16. package/src/tzero/tzero_explain.py +1 -1
  17. package/src/tzero/tzero_features.py +31 -74
  18. package/src/tzero/tzero_golden.py +2 -2
  19. package/src/tzero/tzero_growth.py +1 -1
  20. package/src/tzero/tzero_jarvis/orchestrator.py +1 -1
  21. package/src/tzero/tzero_jarvis/workspace_orchestrator.py +10 -21
  22. package/src/tzero/tzero_lsp.py +1 -1
  23. package/src/tzero/tzero_mcp.py +19 -120
  24. package/src/tzero/tzero_promo.py +1 -1
  25. package/src/tzero/tzero_security.py +3 -3
  26. package/src/tzero/tzero_sync.py +73 -148
  27. package/src/tzero/tzero_task_benchmark.py +2 -2
  28. package/src/tzero/tzero_traffic.py +1 -1
  29. package/src/tzero/tzero_tui.py +2 -13
  30. package/src/tzero/tzero_v3.py +56 -187
  31. package/src/tzero/tzero_welcome.py +1 -1
  32. package/src/tzero/anti_rea/__init__.py +0 -84
  33. package/src/tzero/anti_rea/algebraic_mutator.py +0 -107
  34. package/src/tzero/anti_rea/anti_agent_guard.py +0 -96
  35. package/src/tzero/anti_rea/anti_debugger.py +0 -272
  36. package/src/tzero/anti_rea/anti_vm.py +0 -160
  37. package/src/tzero/anti_rea/asar_shield.py +0 -122
  38. package/src/tzero/anti_rea/auditor.py +0 -208
  39. package/src/tzero/anti_rea/bpe_disrupter.py +0 -48
  40. package/src/tzero/anti_rea/bytecode_trap.py +0 -85
  41. package/src/tzero/anti_rea/canary_beacon.py +0 -167
  42. package/src/tzero/anti_rea/cli.py +0 -134
  43. package/src/tzero/anti_rea/confusables.py +0 -130
  44. package/src/tzero/anti_rea/crypto_loader.py +0 -132
  45. package/src/tzero/anti_rea/engine.py +0 -304
  46. package/src/tzero/anti_rea/extractor_shield.py +0 -180
  47. package/src/tzero/anti_rea/flattener.py +0 -136
  48. package/src/tzero/anti_rea/gui.py +0 -264
  49. package/src/tzero/anti_rea/honeypot.py +0 -58
  50. package/src/tzero/anti_rea/integrity_guard.py +0 -78
  51. package/src/tzero/anti_rea/jailbreak_decoy.py +0 -77
  52. package/src/tzero/anti_rea/mcp_poison.py +0 -41
  53. package/src/tzero/anti_rea/native_bridge.py +0 -169
  54. package/src/tzero/anti_rea/rdtsc_guard.py +0 -77
  55. package/src/tzero/anti_rea/string_vault.py +0 -97
  56. package/src/tzero/anti_rea/sybil_network.py +0 -53
  57. package/src/tzero/anti_rea/tier_catalog.py +0 -388
  58. package/src/tzero/anti_rea/timing_guard.py +0 -46
  59. package/src/tzero/anti_rea/token_bomb.py +0 -65
  60. package/src/tzero/anti_rea/traps.py +0 -76
  61. package/src/tzero/anti_rea/vm_obfuscator.py +0 -182
  62. package/src/tzero/tzero_armor.py +0 -187
@@ -37,7 +37,7 @@ AUTHOR = "Toprak Ahmet Aydoğmuş"
37
37
  ORGANIZATION = "Siber Akademi"
38
38
  PYPI_PKG = "tzero-mcp"
39
39
  NPM_PKG = "tzero-mcp"
40
- CANONICAL_VERSION = "v12.3.3"
40
+ CANONICAL_VERSION = "v12.3.5"
41
41
 
42
42
 
43
43
  def get_current_version() -> str:
@@ -55,7 +55,7 @@ PLACEHOLDER_SUBSTRINGS = (
55
55
  "YOUR_API_KEY", "YOUR-API-KEY", "YOUR_SECRET", "YOUR_TOKEN",
56
56
  "YOUR-", "YOUR_", "ENTER_YOUR", "PLACEHOLDER", "CHANGEME", "INSERT_HERE",
57
57
  "000000000000", "EXAMPLE_KEY", "EXAMPLEKEY", "EXAMPLE_SECRET",
58
- "MOCK_KEY_PLACEHOLDER", "MOCK", "DEMO"
58
+ "MOCK_KEY_PLACEHOLDER"
59
59
  )
60
60
 
61
61
 
@@ -302,7 +302,7 @@ class ZeroLeakEngine:
302
302
  def is_placeholder(cls, s: str) -> bool:
303
303
  """Determines if a candidate string is an intentional placeholder/mock."""
304
304
  up = s.upper()
305
- return any(ph in up for ph in PLACEHOLDER_SUBSTRINGS)
305
+ return up in {"MOCK", "DEMO"} or any(ph in up for ph in PLACEHOLDER_SUBSTRINGS)
306
306
 
307
307
  @classmethod
308
308
  def is_natural_or_identifier(cls, s: str) -> bool:
@@ -387,7 +387,7 @@ class ZeroLeakEngine:
387
387
  val = match.group(1)
388
388
  else:
389
389
  val = match.group(0)
390
- if cls.is_placeholder(val) or cls.is_placeholder(match.group(0)):
390
+ if cls.is_placeholder(val):
391
391
  continue
392
392
 
393
393
  ent = calculate_shannon_entropy(val)
@@ -1,27 +1,32 @@
1
1
  # -*- coding: utf-8 -*-
2
- """
3
- Siber Akademi — T-Zero Autonomous Multi-IDE Rules & Context Synchronizer.
4
- Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
5
- License: MIT
6
-
7
- Synchronizes current codebase AST topologies, helper catalogs, architecture layers,
8
- and Zero-Leak security rules into:
9
- 1. .cursorrules & .cursor/rules/*.mdc (Cursor IDE)
10
- 2. CLAUDE.md (Claude Code & Claude Desktop)
11
- 3. .windsurfrules (Windsurf Cascade)
12
- 4. .agents/rules/tzero-context.md (Antigravity IDE & Autonomous Agents)
13
- 5. .git/hooks/pre-commit (Git Zero-Leak Security Guard)
14
- """
2
+ """Preview and create local editor context files."""
15
3
 
16
- import os
17
- import sys
4
+ import argparse
18
5
  import ast
19
6
  import json
7
+ import os
20
8
  from dataclasses import dataclass, field
21
- from typing import Dict, List, Set, Any, Optional
22
-
23
- from tzero.tzero_security import ZeroLeakEngine
24
- from tzero.tzero_guard import GitSecurityGuard
9
+ from pathlib import Path
10
+ from typing import Any, Dict, List
11
+
12
+
13
+ def create_workspace_file(root: str, relative_path: str, content: str) -> bool:
14
+ """Create a new file and skip existing paths and redirected subdirectories."""
15
+ relative = Path(relative_path)
16
+ if relative.anchor or ".." in relative.parts:
17
+ return False
18
+ parent = Path(root).resolve()
19
+ for part in relative.parts[:-1]:
20
+ parent /= part
21
+ if parent.resolve() != parent or parent.is_symlink():
22
+ return False
23
+ parent.mkdir(exist_ok=True)
24
+ try:
25
+ with (parent / relative.name).open("x", encoding="utf-8") as output:
26
+ output.write(content)
27
+ except FileExistsError:
28
+ return False
29
+ return True
25
30
 
26
31
 
27
32
  @dataclass
@@ -81,137 +86,53 @@ class WorkspaceSyncManager:
81
86
  "function_count": len(functions)
82
87
  }
83
88
 
84
- @classmethod
85
- def generate_cursorrules(cls, workspace_name: str, symbols: Dict[str, Any]) -> str:
86
- """Generates tailored .cursorrules file."""
87
- return f"""# T-Zero Autonomous Context & Rules for Cursor (Generated by tzero sync)
88
- # Workspace: {workspace_name}
89
- # Engine: Siber Akademi T-Zero Context Architect
90
-
91
- # Core Directives
92
- 1. Zero-Leak Security: Never hardcode secrets, tokens, or credentials. Use os.environ.get.
93
- 2. Architecture Fidelity: Respect layer boundaries. Outer presentation layers must not introduce circular dependencies.
94
- 3. Anti-Reinvention: Always reuse existing helper functions before writing new utilities.
95
- 4. AST Compression: When ingesting code, prioritize interface signatures and contracts over raw method bodies.
96
-
97
- # Key Workspace Classes ({symbols['class_count']} total)
98
- {chr(10).join(f"- {c}" for c in symbols['classes'][:20])}
99
-
100
- # Key Exported Helpers ({symbols['function_count']} total)
101
- {chr(10).join(f"- {f}" for f in symbols['functions'][:25])}
102
-
103
- # Verification Command
104
- Run verification before completing any task:
105
- $ python -m unittest discover tests -v
106
- """
89
+ @staticmethod
90
+ def render_context(workspace_name: str, symbols: Dict[str, Any]) -> str:
91
+ """Describe scanned workspace contents without issuing agent directives."""
92
+ lines = [
93
+ "# Workspace context generated by tzero sync",
94
+ "",
95
+ "This report lists symbols discovered by static analysis.",
96
+ "",
97
+ f"- Workspace: {json.dumps(workspace_name)}",
98
+ f"- Python modules: {symbols['module_count']}",
99
+ f"- Top-level classes: {symbols['class_count']}",
100
+ f"- Public top-level functions: {symbols['function_count']}",
101
+ "",
102
+ "## Selected symbols",
103
+ ]
104
+ lines.extend(f"- {json.dumps(symbol)}" for symbol in symbols["classes"][:20])
105
+ lines.extend(f"- {json.dumps(symbol)}" for symbol in symbols["functions"][:25])
106
+ return "\n".join(lines) + "\n"
107
107
 
108
108
  @classmethod
109
- def generate_claudemd(cls, workspace_name: str, symbols: Dict[str, Any]) -> str:
110
- """Generates tailored CLAUDE.md file for Claude Code."""
111
- return f"""# CLAUDE.md — Architecture & Operational Directives (Generated by tzero sync)
112
- > Workspace: `{workspace_name}` | Engine: T-Zero Context Architect | Security: 100% Zero-Leak Certified
113
-
114
- ## Executive Mission
115
- Execute all coding, refactoring, and debugging tasks with minimal blast radius, zero regressions, and maximum token efficiency.
116
-
117
- ## Quickstart & Verification Pipeline
118
- ```bash
119
- # 1. Run Complete Test Suite
120
- python -m unittest discover tests -v
121
-
122
- # 2. Run T-Zero Security & AST Audit
123
- tzero audit .
124
-
125
- # 3. Synchronize AI Context
126
- tzero sync
127
- ```
128
-
129
- ## Ground-Truth Architecture Symbols
130
- - **Active Modules:** {symbols['module_count']} core files
131
- - **Primary Classes:**
132
- {chr(10).join(f" * `{c}`" for c in symbols['classes'][:15])}
133
- - **Primary Public Functions:**
134
- {chr(10).join(f" * `{f}`" for f in symbols['functions'][:20])}
135
-
136
- ## Security & Zero-Leak Policy
137
- - All secrets, API keys, and sensitive database credentials must be kept out of commits.
138
- - Hardcoded secrets will be intercepted and blocked by the T-Zero Git Pre-Commit Guard.
139
- """
140
-
141
- @classmethod
142
- def generate_windsurfrules(cls, workspace_name: str, symbols: Dict[str, Any]) -> str:
143
- """Generates tailored .windsurfrules file for Windsurf Cascade."""
144
- return f"""# Windsurf Cascade Rules for {workspace_name} (Generated by tzero sync)
145
- - Maintain 100% Zero-Leak security standards.
146
- - Prefer existing helper functions in the repository AST before generating new ones.
147
- - Run tests (`python -m unittest discover tests -v`) before asserting task completion.
148
- - Key modules in this workspace: {', '.join(symbols['modules'][:10])}.
149
- """
150
-
151
- @classmethod
152
- def sync(cls, workspace_dir: str = ".") -> SyncResult:
153
- """Executes full autonomous synchronization across IDEs and Git hooks."""
109
+ def sync(cls, workspace_dir: str = ".", *, apply: bool = False) -> SyncResult:
110
+ """Preview rule generation by default; never overwrite files or install hooks."""
154
111
  abs_root = os.path.abspath(workspace_dir)
155
112
  workspace_name = os.path.basename(abs_root) or "TZeroAlgorithm"
156
-
157
- synced_files: List[str] = []
158
-
159
- # 1. Extract AST symbols
160
113
  symbols = cls.scan_symbols(abs_root)
161
114
  total_symbols = symbols["class_count"] + symbols["function_count"]
162
-
163
- # 2. Update .cursorrules
164
- cursor_path = os.path.join(abs_root, ".cursorrules")
165
- try:
166
- with open(cursor_path, "w", encoding="utf-8") as f:
167
- f.write(cls.generate_cursorrules(workspace_name, symbols))
168
- synced_files.append(".cursorrules")
169
- except Exception:
170
- pass
171
-
172
- # 3. Update CLAUDE.md
173
- claude_path = os.path.join(abs_root, "CLAUDE.md")
174
- try:
175
- with open(claude_path, "w", encoding="utf-8") as f:
176
- f.write(cls.generate_claudemd(workspace_name, symbols))
177
- synced_files.append("CLAUDE.md")
178
- except Exception:
179
- pass
180
-
181
- # 4. Update .windsurfrules
182
- windsurf_path = os.path.join(abs_root, ".windsurfrules")
183
- try:
184
- with open(windsurf_path, "w", encoding="utf-8") as f:
185
- f.write(cls.generate_windsurfrules(workspace_name, symbols))
186
- synced_files.append(".windsurfrules")
187
- except Exception:
188
- pass
189
-
190
- # 5. Ensure .agents rules directory is synchronized if present
191
- agents_rules_dir = os.path.join(abs_root, ".agents", "rules")
192
- if os.path.isdir(os.path.join(abs_root, ".agents")):
193
- os.makedirs(agents_rules_dir, exist_ok=True)
194
- agent_rule_path = os.path.join(agents_rules_dir, "tzero-context.md")
195
- try:
196
- with open(agent_rule_path, "w", encoding="utf-8") as f:
197
- f.write(cls.generate_claudemd(workspace_name, symbols))
198
- synced_files.append(".agents/rules/tzero-context.md")
199
- except Exception:
200
- pass
201
-
202
- # 6. Verify / install Git Pre-Commit Security Hook
203
- hook_res = GitSecurityGuard.install_hook(abs_root)
204
- if hook_res.get("success"):
205
- synced_files.append(".git/hooks/pre-commit")
206
-
115
+ candidates = (".cursorrules", "CLAUDE.md", ".windsurfrules")
116
+ created = []
117
+ skipped = []
118
+ if apply:
119
+ content = cls.render_context(workspace_name, symbols)
120
+ for name in candidates:
121
+ try:
122
+ if create_workspace_file(abs_root, name, content):
123
+ created.append(name)
124
+ else:
125
+ skipped.append(name)
126
+ except OSError as exc:
127
+ skipped.append(f"{name} ({exc})")
207
128
  return SyncResult(
208
- success=True,
209
- workspace_dir=abs_root,
210
- synced_files=synced_files,
211
- symbols_indexed=total_symbols,
212
- modules_scanned=symbols["module_count"],
213
- zero_leak_status="100% ZERO-LEAK VERIFIED",
214
- summary_message=f"Synchronized {len(synced_files)} AI rules & hooks across {workspace_name} ({total_symbols} AST symbols indexed)."
129
+ success=not skipped, workspace_dir=abs_root, synced_files=created,
130
+ symbols_indexed=total_symbols, modules_scanned=symbols["module_count"],
131
+ zero_leak_status="Not assessed",
132
+ summary_message=(
133
+ f"Created {len(created)} files. Skipped: {', '.join(skipped) or 'none'}."
134
+ if apply else f"Preview only; no files changed. Candidate files: {', '.join(candidates)}."
135
+ )
215
136
  )
216
137
 
217
138
  @classmethod
@@ -227,15 +148,19 @@ tzero sync
227
148
  for sf in result.synced_files:
228
149
  print(f" ✔ \033[32m{sf}\033[0m")
229
150
  print("-" * 75)
230
- print("🚀 \033[32mCursor, Claude Code, Windsurf, and Git hooks are now 100% aligned with active codebase.\033[0m")
151
+ print(result.summary_message)
231
152
  print("=" * 75 + "\n")
232
153
 
233
154
 
234
155
  def main():
235
- target = sys.argv[1] if len(sys.argv) > 1 and not sys.argv[1].startswith("-") else "."
236
- res = WorkspaceSyncManager.sync(target)
237
- WorkspaceSyncManager.render_cli(res)
156
+ parser = argparse.ArgumentParser(description="Preview or create missing workspace rule files.")
157
+ parser.add_argument("workspace", nargs="?", default=".")
158
+ parser.add_argument("--apply", action="store_true", help="Create files that do not already exist")
159
+ args = parser.parse_args()
160
+ result = WorkspaceSyncManager.sync(args.workspace, apply=args.apply)
161
+ WorkspaceSyncManager.render_cli(result)
162
+ return 0 if result.success else 1
238
163
 
239
164
 
240
165
  if __name__ == "__main__":
241
- main()
166
+ raise SystemExit(main())
@@ -75,7 +75,7 @@ class TaskEvaluationResult:
75
75
 
76
76
  @dataclass
77
77
  class TaskBenchmarkReport:
78
- version: str = "12.3.3"
78
+ version: str = "12.3.5"
79
79
  tokenizer: str = "tiktoken (cl100k_base)" if TIKTOKEN_AVAILABLE else "character-ratio fallback"
80
80
  total_tasks: int = 0
81
81
  passed_tasks: int = 0
@@ -465,7 +465,7 @@ def analyze_symbol_impact(symbol_path: str, table: SymbolTable, dag: CallGraphDA
465
465
  """Formats ANSI-styled benchmark summary table."""
466
466
  lines = []
467
467
  lines.append("=" * 78)
468
- lines.append(" T-ZERO TASK-COMPLETION & BPE TOKENIZER BENCHMARK REPORT (v12.3.3)")
468
+ lines.append(" T-ZERO TASK-COMPLETION & BPE TOKENIZER BENCHMARK REPORT (v12.3.5)")
469
469
  lines.append(f" Tokenizer: {report.tokenizer} | Tasks Evaluated: {report.total_tasks}")
470
470
  lines.append("=" * 78)
471
471
  lines.append(f"{'Task ID':<10} | {'Raw BPE':<8} | {'T-Zero':<8} | {'Saved %':<8} | {'Contract %':<10} | {'Status'}")
@@ -18,7 +18,7 @@ import webbrowser
18
18
  from pathlib import Path
19
19
  from typing import Any, Dict, List, Optional, Tuple
20
20
 
21
- CURRENT_VERSION = "12.3.3"
21
+ CURRENT_VERSION = "12.3.5"
22
22
  REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
23
23
  RELEASES_URL = f"{REPO_URL}/releases"
24
24
  PYPI_URL = "https://pypi.org/project/tzero-mcp/"
@@ -135,7 +135,6 @@ class TZeroTerminalCockpit:
135
135
  ("9", "Run AST Mutation Test Suite", "🧬 Run AST Mutation Test Suite (`tzero --mutate <file>`)"),
136
136
  ("10", "Code Health & Technical Debt Index", "🏥 Code Health & Technical Debt Index (`tzero --debt`)"),
137
137
  ("11", "Context Budget Optimizer & Certificate", "📜 Context Budget Optimizer & Certificate (`tzero --budget`)"),
138
- ("12", "Anti-REA 180-Tier Armor & Audit", "🛡️ Anti-REA 180-Tier Armor & Audit (`tzero --audit-rea`)"),
139
138
  ("13", "Offline Telemetry & ROI Tracker", "📊 Offline Telemetry & ROI Tracker (`tzero --telemetry`)"),
140
139
  ("0", "Exit TUI", "🚪 Exit TUI"),
141
140
  ]
@@ -180,7 +179,7 @@ class TZeroTerminalCockpit:
180
179
  box_bottom = f"{c.CYAN}╚{'═' * 78}╝{c.RESET}"
181
180
 
182
181
  lines.append(box_top)
183
- lines.append(cls._box_line(f" {c.BOLD}{c.BRIGHT_CYAN}⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & LIVE COCKPIT v12.3.3{c.RESET}"))
182
+ lines.append(cls._box_line(f" {c.BOLD}{c.BRIGHT_CYAN}⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & LIVE COCKPIT v12.3.5{c.RESET}"))
184
183
  lines.append(cls._box_line(f" {c.DIM}Local AST Analysis | Optional Network Services{c.RESET}"))
185
184
  lines.append(box_mid)
186
185
 
@@ -325,7 +324,7 @@ class TZeroTerminalCockpit:
325
324
  elif choice == "4":
326
325
  from tzero.tzero_commit import LocalSemanticCommitSynthesizer
327
326
  print(f"\n{cls.YELLOW}[Synthesizing Release CHANGELOG]...{cls.RESET}")
328
- entry = LocalSemanticCommitSynthesizer.generate_changelog_entry(version="v12.3.3", repo_dir=workspace_dir)
327
+ entry = LocalSemanticCommitSynthesizer.generate_changelog_entry(version="v12.3.5", repo_dir=workspace_dir)
329
328
  print(f"\n{cls.BRIGHT_CYAN}{entry}{cls.RESET}\n")
330
329
  input("Press Enter to return to cockpit...")
331
330
  elif choice == "5":
@@ -400,16 +399,6 @@ class TZeroTerminalCockpit:
400
399
  print(f"\n{cls.BRIGHT_CYAN}{ASTTokenBudgetOptimizer.format_markdown_certificate(cert)}{cls.RESET}\n")
401
400
  print(f"{cls.GREEN}[SUCCESS] Certificate saved to: {saved_p}{cls.RESET}")
402
401
  input("Press Enter to return to cockpit...")
403
- elif choice == "12":
404
- from tzero.tzero_armor import audit_path_rea_resistance, protect_path_with_armor
405
- print(f"\n{cls.YELLOW}[Auditing 180-Tier Anti-REA Resistance for {workspace_dir}]...{cls.RESET}")
406
- audit = audit_path_rea_resistance(workspace_dir)
407
- print(f"{cls.BRIGHT_CYAN}AI Resistance Score: {audit.get('score', 0)}/100 ({audit.get('rating', 'UNKNOWN')}){cls.RESET}")
408
- apply_ans = input("Apply Anti-REA armor to target file/dir now? [y/N]: ").strip().lower()
409
- if apply_ans == "y":
410
- res = protect_path_with_armor(workspace_dir)
411
- print(f"{cls.GREEN}[OK] Protected: {res}{cls.RESET}")
412
- input("Press Enter to return to cockpit...")
413
402
  elif choice == "13":
414
403
  from tzero.tzero_telemetry import render_report
415
404
  print(f"\n{cls.BRIGHT_CYAN}{render_report(workspace_dir)}{cls.RESET}\n")