tzero-mcp 12.2.2 → 12.3.3
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/README.md +6 -30
- package/bin/tzero-mcp.js +2 -2
- package/bin/tzero.js +11 -6
- package/package.json +1 -2
- package/src/addmcp.py +2 -2
- package/src/app.py +1 -1
- package/src/tzero/__init__.py +1 -1
- package/src/tzero/anti_rea/__init__.py +16 -2
- package/src/tzero/anti_rea/algebraic_mutator.py +65 -44
- package/src/tzero/anti_rea/anti_debugger.py +51 -18
- package/src/tzero/anti_rea/asar_shield.py +21 -0
- package/src/tzero/anti_rea/auditor.py +20 -0
- package/src/tzero/anti_rea/canary_beacon.py +33 -61
- package/src/tzero/anti_rea/cli.py +30 -4
- package/src/tzero/anti_rea/crypto_loader.py +132 -0
- package/src/tzero/anti_rea/engine.py +51 -20
- package/src/tzero/anti_rea/extractor_shield.py +60 -25
- package/src/tzero/anti_rea/tier_catalog.py +388 -0
- package/src/tzero/tzero_armor.py +3 -3
- package/src/tzero/tzero_benchmark.py +1 -1
- package/src/tzero/tzero_budget.py +1 -1
- package/src/tzero/tzero_ci.py +2 -2
- package/src/tzero/tzero_contracts.py +2 -2
- package/src/tzero/tzero_dashboard.py +3 -3
- package/src/tzero/tzero_debt.py +85 -7
- package/src/tzero/tzero_deps.py +109 -87
- package/src/tzero/tzero_explain.py +1 -1
- package/src/tzero/tzero_golden.py +2 -2
- package/src/tzero/tzero_graph_hud.html +4 -4
- package/src/tzero/tzero_growth.py +1 -1
- package/src/tzero/tzero_jarvis/swarm.py +23 -2
- package/src/tzero/tzero_jarvis/workspace_orchestrator.py +1 -1
- package/src/tzero/tzero_jarvis/zero_key_router.py +10 -78
- package/src/tzero/tzero_lsp.py +1 -1
- package/src/tzero/tzero_mcp.py +28 -10
- package/src/tzero/tzero_mutation.py +6 -2
- package/src/tzero/tzero_promo.py +1 -1
- package/src/tzero/tzero_security.py +40 -11
- package/src/tzero/tzero_task_benchmark.py +2 -2
- package/src/tzero/tzero_traffic.py +1 -1
- package/src/tzero/tzero_tui.py +5 -5
- package/src/tzero/tzero_v3.py +418 -275
- package/src/tzero/tzero_welcome.py +1 -1
- package/bin/postinstall.js +0 -30
package/src/tzero/tzero_mcp.py
CHANGED
|
@@ -33,7 +33,7 @@ import ast
|
|
|
33
33
|
import inspect
|
|
34
34
|
import logging
|
|
35
35
|
|
|
36
|
-
SERVER_VERSION = "12.
|
|
36
|
+
SERVER_VERSION = "12.3.3"
|
|
37
37
|
|
|
38
38
|
# Version checks must not initialize the MCP SDK or dependency bootstrap. Besides
|
|
39
39
|
# being needlessly expensive, that path may wait on package discovery/network
|
|
@@ -1890,9 +1890,9 @@ def create_mcp_server():
|
|
|
1890
1890
|
# -------------------------------------------------------------------------
|
|
1891
1891
|
@_maybe_tool(
|
|
1892
1892
|
name="jarvis_zero_key_query",
|
|
1893
|
-
title="Query
|
|
1893
|
+
title="Query Local Ollama Models via Zero Key Gateway",
|
|
1894
1894
|
description=(
|
|
1895
|
-
"Dispatches inference prompts to
|
|
1895
|
+
"Dispatches inference prompts strictly to a local Ollama daemon (127.0.0.1:11434) with zero external API keys, distinguishing from 'search_codebase_semantic' and 'get_project_context_tree' by generating natural language completions rather than static codebase context.\n"
|
|
1896
1896
|
"\n"
|
|
1897
1897
|
"Parameters:\n"
|
|
1898
1898
|
"- `prompt` (str, required): User prompt, code question, or instruction for the AI model.\n"
|
|
@@ -1901,15 +1901,15 @@ def create_mcp_server():
|
|
|
1901
1901
|
"Behavior:\n"
|
|
1902
1902
|
"- Read-only: Performs query inference without modifying workspace files or persisting conversational state.\n"
|
|
1903
1903
|
"- Non-idempotent: Model responses may vary across invocations.\n"
|
|
1904
|
-
"- Open-World Network Operation: Dispatches HTTP requests to local Ollama (127.0.0.1:11434)
|
|
1905
|
-
"- Auth & Rate Limits: Zero credentials required; no account or credit card needed.
|
|
1906
|
-
"- Error Handling:
|
|
1904
|
+
"- Open-World Network Operation: Dispatches local HTTP requests strictly to local Ollama (127.0.0.1:11434) with zero user API keys, zero billing, and zero external cloud fallbacks.\n"
|
|
1905
|
+
"- Auth & Rate Limits: Zero credentials required; no account or credit card needed. Local daemon check has a 1.5-second timeout and inference has a 60-second timeout.\n"
|
|
1906
|
+
"- Error Handling: Reports unavailability immediately if local Ollama is inactive without falling back to external cloud services.\n"
|
|
1907
1907
|
"\n"
|
|
1908
1908
|
"Usage Guidelines:\n"
|
|
1909
|
-
"- When to use: Query free
|
|
1909
|
+
"- When to use: Query free local Ollama inference for coding questions or reasoning without configuring API keys or paying commercial provider fees.\n"
|
|
1910
1910
|
"- When NOT to use: Do not use for local codebase search or AST parsing (use 'search_codebase_semantic' or 'get_project_context_tree' instead); do not use for structured file modifications (use 'generate_smart_micro_patch' instead).\n"
|
|
1911
1911
|
"\n"
|
|
1912
|
-
"Returns: Structured Markdown containing selected
|
|
1912
|
+
"Returns: Structured Markdown containing selected local provider name, model identifier, cost confirmation ($0.00), and response completion text."
|
|
1913
1913
|
),
|
|
1914
1914
|
annotations=ToolAnnotations(read_only_hint=True, destructive_hint=False, idempotent_hint=False, open_world_hint=True)
|
|
1915
1915
|
)
|
|
@@ -3433,16 +3433,34 @@ def create_mcp_server():
|
|
|
3433
3433
|
)
|
|
3434
3434
|
def audit_code_quality(
|
|
3435
3435
|
project_root: Annotated[str, Field(default=".", description="Root directory of the repository to audit (default: current directory).")] = ".",
|
|
3436
|
-
check_type: Annotated[str, Field(default="all", description="Audit scope: 'all' for complete check, 'smells' for code complexity/smells, 'duplicity' for copy-paste blocks, 'hallucinations' for invalid imports/signatures.")] = "all",
|
|
3436
|
+
check_type: Annotated[str, Field(default="all", description="Audit scope: 'all' for complete check, 'smells' for code complexity/smells, 'duplicity' for copy-paste blocks, 'hallucinations' for invalid imports/signatures, 'debt' for TODO/FIXME/HACK/XXX/TEMP markers grouped by scope with estimated remediation hours.")] = "all",
|
|
3437
3437
|
file_path: Annotated[str, Field(default="", description="Optional path to a single file to audit.")] = ""
|
|
3438
3438
|
) -> str:
|
|
3439
|
-
"""Audits AST code smells, cyclomatic complexity, copy-paste duplicity, and
|
|
3439
|
+
"""Audits AST code smells, cyclomatic complexity, copy-paste duplicity, hallucinations, and debt markers."""
|
|
3440
3440
|
c_type = (check_type or "all").lower().strip()
|
|
3441
3441
|
if c_type == "duplicity":
|
|
3442
3442
|
return _legacy_find_code_duplicity(project_root=project_root, min_lines=6)
|
|
3443
3443
|
elif c_type == "hallucinations":
|
|
3444
3444
|
target = file_path or project_root
|
|
3445
3445
|
return _legacy_verify_hallucination_guard(candidate_code=target, project_root=project_root)
|
|
3446
|
+
elif c_type == "debt":
|
|
3447
|
+
from tzero.tzero_debt import CodeHealthAnalyzer, WorkspaceHealthReport, format_debt_markers_markdown
|
|
3448
|
+
target = file_path or project_root
|
|
3449
|
+
if os.path.isfile(target):
|
|
3450
|
+
fr = CodeHealthAnalyzer.analyze_file(target)
|
|
3451
|
+
single = WorkspaceHealthReport(
|
|
3452
|
+
workspace_root=os.path.dirname(os.path.abspath(target)),
|
|
3453
|
+
total_files=1,
|
|
3454
|
+
total_lines_of_code=fr.lines_of_code,
|
|
3455
|
+
average_maintainability_index=fr.maintainability_index,
|
|
3456
|
+
overall_rating=fr.rating,
|
|
3457
|
+
total_debt_hours=fr.debt_hours,
|
|
3458
|
+
total_debt_cost_usd=fr.debt_cost_usd,
|
|
3459
|
+
total_todo_markers=fr.todo_count,
|
|
3460
|
+
file_reports=[fr],
|
|
3461
|
+
)
|
|
3462
|
+
return format_debt_markers_markdown(single)
|
|
3463
|
+
return format_debt_markers_markdown(CodeHealthAnalyzer.analyze_workspace(target))
|
|
3446
3464
|
else:
|
|
3447
3465
|
return _legacy_audit_codebase_quality(project_root=project_root, file_path=file_path)
|
|
3448
3466
|
|
|
@@ -299,12 +299,16 @@ class ASTMutationEngine:
|
|
|
299
299
|
target_dir = os.path.dirname(abs_target)
|
|
300
300
|
expected_test_name = f"test_{os.path.splitext(os.path.basename(abs_target))[0]}.py"
|
|
301
301
|
|
|
302
|
-
# Discover untainted test files
|
|
302
|
+
# Discover untainted test files from workspace root, validated target_dir, and tzero_* temp dirs
|
|
303
303
|
discover_roots = [ws_root]
|
|
304
|
+
if base_root == tmp_root and target_dir not in discover_roots:
|
|
305
|
+
discover_roots.append(target_dir)
|
|
304
306
|
try:
|
|
305
307
|
for d_entry in os.scandir(tmp_root):
|
|
306
308
|
if d_entry.is_dir() and d_entry.name.startswith("tzero_"):
|
|
307
|
-
|
|
309
|
+
entry_real = os.path.realpath(d_entry.path)
|
|
310
|
+
if entry_real not in discover_roots:
|
|
311
|
+
discover_roots.append(entry_real)
|
|
308
312
|
except OSError:
|
|
309
313
|
pass
|
|
310
314
|
|
package/src/tzero/tzero_promo.py
CHANGED
|
@@ -209,7 +209,7 @@ SECRET_RULES: List[SecretRule] = [
|
|
|
209
209
|
rule_id="SEC-CRYPTO-001",
|
|
210
210
|
provider="PKI",
|
|
211
211
|
description="Private Key Block or Header (RSA, EC, OPENSSH, DSA, PGP)",
|
|
212
|
-
pattern=re.compile(r"-----BEGIN (?:[A-Z0-9 ]
|
|
212
|
+
pattern=re.compile(r"-----BEGIN (?:[A-Z0-9 ]{1,32} )?PRIVATE KEY-----"),
|
|
213
213
|
mask_tag="[ZERO_LEAK_MASKED_PRIVATE_KEY]"
|
|
214
214
|
),
|
|
215
215
|
SecretRule(
|
|
@@ -265,10 +265,38 @@ class ZeroLeakEngine:
|
|
|
265
265
|
|
|
266
266
|
MIN_ENTROPY_THRESHOLD: float = 4.75
|
|
267
267
|
MIN_ENTROPY_LENGTH: int = 28
|
|
268
|
-
_PEM_BEGIN_RE = re.compile(r"-----BEGIN (?:[A-Z0-9 ]
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
_PEM_BEGIN_RE = re.compile(r"-----BEGIN (?:[A-Z0-9 ]{1,32} )?PRIVATE KEY-----")
|
|
269
|
+
_PEM_END_RE = re.compile(r"-----END (?:[A-Z0-9 ]{1,32} )?PRIVATE KEY-----")
|
|
270
|
+
|
|
271
|
+
@classmethod
|
|
272
|
+
def _iter_pem_block_spans(cls, text: str) -> List[Tuple[int, int]]:
|
|
273
|
+
"""Linearly locates complete PEM BEGIN..END block byte spans without polynomial regex backtracking."""
|
|
274
|
+
spans: List[Tuple[int, int]] = []
|
|
275
|
+
pos = 0
|
|
276
|
+
for begin_match in cls._PEM_BEGIN_RE.finditer(text):
|
|
277
|
+
if begin_match.start() < pos:
|
|
278
|
+
continue
|
|
279
|
+
end_match = cls._PEM_END_RE.search(text, begin_match.end())
|
|
280
|
+
if not end_match:
|
|
281
|
+
break
|
|
282
|
+
spans.append((begin_match.start(), end_match.end()))
|
|
283
|
+
pos = end_match.end()
|
|
284
|
+
return spans
|
|
285
|
+
|
|
286
|
+
@classmethod
|
|
287
|
+
def _mask_pem_blocks(cls, text: str, replacement: str = "[ZERO_LEAK_MASKED_PRIVATE_KEY]") -> str:
|
|
288
|
+
"""Replaces complete PEM BEGIN..END blocks linearly cleanly."""
|
|
289
|
+
spans = cls._iter_pem_block_spans(text)
|
|
290
|
+
if not spans:
|
|
291
|
+
return text
|
|
292
|
+
chunks: List[str] = []
|
|
293
|
+
last = 0
|
|
294
|
+
for s, e in spans:
|
|
295
|
+
chunks.append(text[last:s])
|
|
296
|
+
chunks.append(replacement)
|
|
297
|
+
last = e
|
|
298
|
+
chunks.append(text[last:])
|
|
299
|
+
return "".join(chunks)
|
|
272
300
|
|
|
273
301
|
@classmethod
|
|
274
302
|
def is_placeholder(cls, s: str) -> bool:
|
|
@@ -304,9 +332,10 @@ class ZeroLeakEngine:
|
|
|
304
332
|
|
|
305
333
|
# Pre-compute line numbers covered by complete multi-line PEM blocks
|
|
306
334
|
pem_ranges: List[Tuple[int, int]] = []
|
|
307
|
-
for
|
|
308
|
-
|
|
309
|
-
|
|
335
|
+
for s_pos, e_pos in cls._iter_pem_block_spans(text):
|
|
336
|
+
block_txt = text[s_pos:e_pos]
|
|
337
|
+
start_line = text[:s_pos].count("\n") + 1
|
|
338
|
+
end_line = text[:e_pos].count("\n") + 1
|
|
310
339
|
pem_ranges.append((start_line, end_line))
|
|
311
340
|
findings.append(SecretFinding(
|
|
312
341
|
rule_id="SEC-CRYPTO-001",
|
|
@@ -315,9 +344,9 @@ class ZeroLeakEngine:
|
|
|
315
344
|
severity="CRITICAL",
|
|
316
345
|
line_no=start_line,
|
|
317
346
|
preview="[ZERO_LEAK_MASKED_PRIVATE_KEY]",
|
|
318
|
-
entropy=round(calculate_shannon_entropy(
|
|
347
|
+
entropy=round(calculate_shannon_entropy(block_txt), 2),
|
|
319
348
|
is_entropy_anomaly=False,
|
|
320
|
-
secret_value=
|
|
349
|
+
secret_value=block_txt,
|
|
321
350
|
))
|
|
322
351
|
|
|
323
352
|
def _in_pem_block(ln: int) -> bool:
|
|
@@ -426,7 +455,7 @@ class ZeroLeakEngine:
|
|
|
426
455
|
if not text:
|
|
427
456
|
return ""
|
|
428
457
|
|
|
429
|
-
sanitized = cls.
|
|
458
|
+
sanitized = cls._mask_pem_blocks(text, "[ZERO_LEAK_MASKED_PRIVATE_KEY]")
|
|
430
459
|
|
|
431
460
|
if cls._PEM_BEGIN_RE.search(sanitized):
|
|
432
461
|
if not allow_incomplete_pem:
|
|
@@ -75,7 +75,7 @@ class TaskEvaluationResult:
|
|
|
75
75
|
|
|
76
76
|
@dataclass
|
|
77
77
|
class TaskBenchmarkReport:
|
|
78
|
-
version: str = "12.
|
|
78
|
+
version: str = "12.3.3"
|
|
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.
|
|
468
|
+
lines.append(" T-ZERO TASK-COMPLETION & BPE TOKENIZER BENCHMARK REPORT (v12.3.3)")
|
|
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.
|
|
21
|
+
CURRENT_VERSION = "12.3.3"
|
|
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/"
|
package/src/tzero/tzero_tui.py
CHANGED
|
@@ -135,7 +135,7 @@ 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
|
|
138
|
+
("12", "Anti-REA 180-Tier Armor & Audit", "🛡️ Anti-REA 180-Tier Armor & Audit (`tzero --audit-rea`)"),
|
|
139
139
|
("13", "Offline Telemetry & ROI Tracker", "📊 Offline Telemetry & ROI Tracker (`tzero --telemetry`)"),
|
|
140
140
|
("0", "Exit TUI", "🚪 Exit TUI"),
|
|
141
141
|
]
|
|
@@ -180,8 +180,8 @@ class TZeroTerminalCockpit:
|
|
|
180
180
|
box_bottom = f"{c.CYAN}╚{'═' * 78}╝{c.RESET}"
|
|
181
181
|
|
|
182
182
|
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.
|
|
184
|
-
lines.append(cls._box_line(f" {c.DIM}
|
|
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}"))
|
|
184
|
+
lines.append(cls._box_line(f" {c.DIM}Local AST Analysis | Optional Network Services{c.RESET}"))
|
|
185
185
|
lines.append(box_mid)
|
|
186
186
|
|
|
187
187
|
# Workspace summary line
|
|
@@ -325,7 +325,7 @@ class TZeroTerminalCockpit:
|
|
|
325
325
|
elif choice == "4":
|
|
326
326
|
from tzero.tzero_commit import LocalSemanticCommitSynthesizer
|
|
327
327
|
print(f"\n{cls.YELLOW}[Synthesizing Release CHANGELOG]...{cls.RESET}")
|
|
328
|
-
entry = LocalSemanticCommitSynthesizer.generate_changelog_entry(version="v12.
|
|
328
|
+
entry = LocalSemanticCommitSynthesizer.generate_changelog_entry(version="v12.3.3", repo_dir=workspace_dir)
|
|
329
329
|
print(f"\n{cls.BRIGHT_CYAN}{entry}{cls.RESET}\n")
|
|
330
330
|
input("Press Enter to return to cockpit...")
|
|
331
331
|
elif choice == "5":
|
|
@@ -402,7 +402,7 @@ class TZeroTerminalCockpit:
|
|
|
402
402
|
input("Press Enter to return to cockpit...")
|
|
403
403
|
elif choice == "12":
|
|
404
404
|
from tzero.tzero_armor import audit_path_rea_resistance, protect_path_with_armor
|
|
405
|
-
print(f"\n{cls.YELLOW}[Auditing
|
|
405
|
+
print(f"\n{cls.YELLOW}[Auditing 180-Tier Anti-REA Resistance for {workspace_dir}]...{cls.RESET}")
|
|
406
406
|
audit = audit_path_rea_resistance(workspace_dir)
|
|
407
407
|
print(f"{cls.BRIGHT_CYAN}AI Resistance Score: {audit.get('score', 0)}/100 ({audit.get('rating', 'UNKNOWN')}){cls.RESET}")
|
|
408
408
|
apply_ans = input("Apply Anti-REA armor to target file/dir now? [y/N]: ").strip().lower()
|