tzero-mcp 11.12.1 → 11.15.2

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 (45) hide show
  1. package/LICENSE +661 -21
  2. package/NOTICE +22 -0
  3. package/README.md +3 -3
  4. package/bin/postinstall.js +22 -0
  5. package/bin/tzero-mcp.js +2 -1
  6. package/bin/tzero.js +8 -1
  7. package/index.js +5 -0
  8. package/package.json +4 -2
  9. package/src/addmcp.py +3 -3
  10. package/src/app.py +1 -1
  11. package/src/tzero/__init__.py +5 -0
  12. package/src/tzero/addmcp.py +18 -0
  13. package/src/tzero/tzero_benchmark.py +2 -2
  14. package/src/tzero/tzero_blackboard.py +1 -1
  15. package/src/tzero/tzero_budget.py +1 -1
  16. package/src/tzero/tzero_card.py +1 -1
  17. package/src/tzero/tzero_ci.py +658 -10
  18. package/src/tzero/tzero_commit.py +1 -1
  19. package/src/tzero/tzero_contracts.py +2 -2
  20. package/src/tzero/tzero_cost.py +1 -1
  21. package/src/tzero/tzero_dashboard.py +3 -3
  22. package/src/tzero/tzero_debt.py +1 -1
  23. package/src/tzero/tzero_drift.py +1 -1
  24. package/src/tzero/tzero_explain.py +1 -1
  25. package/src/tzero/tzero_features.py +268 -37
  26. package/src/tzero/tzero_golden.py +2 -2
  27. package/src/tzero/tzero_hallucination_proof.py +901 -0
  28. package/src/tzero/tzero_infra.py +1 -1
  29. package/src/tzero/tzero_jarvis/__init__.py +15 -1
  30. package/src/tzero/tzero_jarvis/agent_guard.py +620 -0
  31. package/src/tzero/tzero_jarvis/creative_director.py +1 -1
  32. package/src/tzero/tzero_jarvis/orchestrator.py +36 -34
  33. package/src/tzero/tzero_jarvis/self_healing.py +325 -250
  34. package/src/tzero/tzero_lsp.py +1 -1
  35. package/src/tzero/tzero_mcp.py +184 -53
  36. package/src/tzero/tzero_promo.py +504 -0
  37. package/src/tzero/tzero_replay.py +1 -1
  38. package/src/tzero/tzero_semantic_merge.py +1 -1
  39. package/src/tzero/tzero_stubs.py +1 -1
  40. package/src/tzero/tzero_task_benchmark.py +2 -2
  41. package/src/tzero/tzero_tui.py +2 -2
  42. package/src/tzero/tzero_turbo.py +1 -1
  43. package/src/tzero/tzero_v3.py +124 -13
  44. package/src/tzero/tzero_welcome.py +135 -0
  45. package/test/package.test.js +1 -1
@@ -33,7 +33,7 @@ import ast
33
33
  import inspect
34
34
  import logging
35
35
 
36
- SERVER_VERSION = "11.11.0"
36
+ SERVER_VERSION = "11.15.0"
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
@@ -258,12 +258,20 @@ def create_mcp_server():
258
258
 
259
259
  # mcp 2.x (MCPServer) accepts description/version; mcp 1.x (FastMCP) only knows
260
260
  # `instructions`. Pass whichever the installed SDK supports so both versions start.
261
- summary = "Enterprise-Grade Codebase Context Architect, AST Signatures Analyzer, & Token Reducer"
261
+ summary = (
262
+ "Local codebase analysis and context tools. Choose build_project_context for repository "
263
+ "context, generate_architectural_passport for one Python file, build_ast_snapshot to "
264
+ "write an index, and generate_architecture_blueprint for diagrams. Use audit_code_quality "
265
+ "for findings, heal_hallucinated_code for an in-memory candidate, and "
266
+ "diagnose_and_heal_system for workspace diagnosis or repair. "
267
+ "execute_codebase_workflow is a compatibility router; prefer the dedicated tools. "
268
+ "Some operations write files or call external services; inspect tool arguments first."
269
+ )
262
270
  supported = inspect.signature(ServerClass.__init__).parameters
263
271
  server_kwargs: Dict[str, Any] = {"name": "tzero-context-engine"}
264
272
  if "description" in supported:
265
273
  server_kwargs["description"] = summary
266
- elif "instructions" in supported:
274
+ if "instructions" in supported:
267
275
  server_kwargs["instructions"] = summary
268
276
  if "version" in supported:
269
277
  server_kwargs["version"] = SERVER_VERSION
@@ -2121,18 +2129,19 @@ def create_mcp_server():
2121
2129
  name="jarvis_self_healing_execute",
2122
2130
  title="Diagnose Test Failures and Apply AST Self-Healing Patches",
2123
2131
  description=(
2124
- "Executes commands in a guarded environment with automated error analysis and self-healing retry loops, distinguishing from 'jarvis_orchestrate_goal' and 'jarvis_bft_swarm_consensus' by focusing specifically on command execution recovery rather than full workspace orchestration or swarm consensus.\n"
2132
+ "Runs a trusted shell command and attempts a limited, verified Python syntax repair, distinguishing from 'jarvis_orchestrate_goal' and 'diagnose_and_heal_system' by executing focused single commands with AST rollback rather than multi-phase project workflows.\n"
2125
2133
  "\n"
2126
2134
  "Parameters:\n"
2127
2135
  "- `command` (str, required): Shell command or test script to execute.\n"
2128
- "- `max_retries` (int, optional, default=3): Maximum self-healing repair iterations if execution fails.\n"
2136
+ "- `max_retries` (int, optional, default=3): Set to zero to disable repairs; positive values permit one repair attempt.\n"
2129
2137
  "\n"
2130
2138
  "Behavior:\n"
2131
2139
  "- State-Modifying: Executes shell commands on local system and applies automated fixes on failure.\n"
2132
2140
  "- Non-idempotent: Command output and environmental state depend on local system execution.\n"
2133
- "- 100% Offline: Executes locally using native system shell; operates strictly offline.\n"
2134
- "- Auth & Rate Limits: Zero credentials required; execution bounded by command timeout (60s default).\n"
2135
- "- Error Handling: Intercepts non-zero exit codes, analyzes error stack traces, and synthesizes corrective micro-patches.\n"
2141
+ "- Network: The engine makes no network calls itself, but the supplied command can access the network or incur costs.\n"
2142
+ "- Auth & Credentials: Zero external credentials or API keys required by the engine; host commands operate under local user environment.\n"
2143
+ "- Execution: Commands run with a 30-second timeout and are gated by operator opt-in (TZERO_ALLOW_AGENT_SHELL=1).\n"
2144
+ "- Error Handling: Supports a single missing-colon syntax repair; retries the command and rolls back on failure when the file is unchanged.\n"
2136
2145
  "\n"
2137
2146
  "Usage Guidelines:\n"
2138
2147
  "- When to use: Run test suites, build scripts, or deployment commands that may require automated error diagnosis and self-healing fixes.\n"
@@ -2140,29 +2149,46 @@ def create_mcp_server():
2140
2149
  "\n"
2141
2150
  "Returns: Markdown execution log with process exit code, stdout/stderr output, diagnostic analysis, and applied self-healing remedies."
2142
2151
  ),
2143
- annotations=ToolAnnotations(read_only_hint=False, destructive_hint=False, idempotent_hint=False, open_world_hint=False)
2152
+ annotations=ToolAnnotations(read_only_hint=False, destructive_hint=True, idempotent_hint=False, open_world_hint=True)
2144
2153
  )
2145
2154
  def _legacy_jarvis_self_healing_execute(
2146
2155
  command: Annotated[str, Field(description="Shell command or test script to execute.")],
2147
- max_retries: Annotated[int, Field(default=3, description="Maximum self-healing repair iterations if execution fails (default: 3).")] = 3
2156
+ max_retries: Annotated[int, Field(default=3, description="Zero disables repair; a positive value permits one repair attempt.")] = 3
2148
2157
  ) -> str:
2149
2158
  """Runs command with autonomous AST error diagnosis and auto-repair."""
2159
+ from tzero.tzero_jarvis.self_healing import agent_command_execution_enabled
2160
+ if not agent_command_execution_enabled():
2161
+ return ("Self-healing command blocked: agent shell execution is disabled. "
2162
+ "Only the server operator can enable it with TZERO_ALLOW_AGENT_SHELL=1; "
2163
+ "enabled commands run without a sandbox.")
2150
2164
  from tzero.tzero_jarvis import SelfHealingExecutionEngine
2151
- engine = SelfHealingExecutionEngine()
2165
+ engine = SelfHealingExecutionEngine(enforce_agent_policy=True)
2152
2166
  res = engine.execute_and_heal(command, max_retries=max_retries)
2153
-
2167
+
2154
2168
  status_emoji = "✅" if res.success else "❌"
2155
- return (
2156
- f"### {status_emoji} Self-Healing Execution Result\n"
2157
- f"- **Command:** `{res.command}`\n"
2158
- f"- **Success:** `{res.success}` (Resolved: `{res.resolved}`)\n"
2159
- f"- **Exit Code:** `{res.exit_code}`\n"
2160
- f"- **Duration:** `{res.duration_ms} ms`\n"
2161
- f"- **Applied Patches:** `{len(res.applied_patches)}`\n"
2162
- + (f"- **Error Type:** `{res.error_type}` in `{res.error_file}:{res.error_line}`\n" if res.error_type else "")
2163
- + f"\n**Stdout:**\n```\n{res.stdout[:1500]}\n```\n"
2164
- + (f"**Stderr:**\n```\n{res.stderr[:1000]}\n```\n" if res.stderr else "")
2165
- )
2169
+ lines = [
2170
+ f"### {status_emoji} Self-Healing Execution Result",
2171
+ f"- **Command:** `{res.command}`",
2172
+ f"- **Success:** `{res.success}` (Resolved: `{res.resolved}`)",
2173
+ f"- **Exit Code:** `{res.exit_code}`",
2174
+ f"- **Duration:** `{res.duration_ms} ms`",
2175
+ f"- **Applied Patches:** `{len(res.applied_patches)}`"
2176
+ ]
2177
+ if res.risk_level:
2178
+ lines.append(f"- **Risk Level:** `{res.risk_level}`")
2179
+ if res.blocked_by_policy:
2180
+ lines.append("- **Security Notice:** 🛡️ Command execution blocked by safety policy.")
2181
+ if res.dry_run:
2182
+ lines.append("- **Execution Mode:** `[Dry-Run Preview]`")
2183
+ if res.error_type:
2184
+ lines.append(f"- **Error Type:** `{res.error_type}` in `{res.error_file}:{res.error_line}`")
2185
+ if res.diagnostics:
2186
+ lines.append("- **Diagnostics:** " + "; ".join(res.diagnostics))
2187
+ if res.stdout:
2188
+ lines.append(f"\n**Stdout:**\n```\n{res.stdout[:1500]}\n```")
2189
+ if res.stderr:
2190
+ lines.append(f"\n**Stderr:**\n```\n{res.stderr[:1000]}\n```")
2191
+ return "\n".join(lines)
2166
2192
 
2167
2193
  # -------------------------------------------------------------------------
2168
2194
  # TOOL 31: jarvis_consolidate_memory
@@ -2939,7 +2965,7 @@ def create_mcp_server():
2939
2965
  name="build_project_context",
2940
2966
  title="Build Hierarchical AST Codebase Context Tree",
2941
2967
  description=(
2942
- "Scans repository directories to construct a token-optimized hierarchical AST context tree (T-1 to T-4) for LLM prompts, distinguishing from 'prune_code_snippet' and 'search_codebase' by constructing multi-tier repository architecture outlines rather than pruning isolated in-memory snippets or executing keyword searches.\n"
2968
+ "Returns repository-wide context or a selected context view without persisting an index; distinguishing from 'build_ast_snapshot' which writes a cache and 'generate_architectural_passport' which analyzes one Python file.\n"
2943
2969
  "\n"
2944
2970
  "Parameters:\n"
2945
2971
  "- `project_root`: File system directory path; accepts relative or absolute paths, resolving symlinks and automatically skipping .git, node_modules, venv, and binary artifacts.\n"
@@ -4018,7 +4044,7 @@ def create_mcp_server():
4018
4044
  name="build_ast_snapshot",
4019
4045
  title="Build Persistent AST Context Snapshot Cache",
4020
4046
  description=(
4021
- "Pre-computes and caches high-speed AST symbols, module dependency graphs, and token metrics into a persistent '.tzero/snapshot.json' index, distinguishing from 'build_project_context' and 'search_codebase' by enabling sub-8ms instant context retrieval across multi-turn sessions rather than recalculating full AST representations on every invocation.\n"
4047
+ "Creates or reuses a persistent '.tzero/snapshot.json' AST index and returns cache status, distinguishing from 'build_project_context' which returns context without writing a snapshot and 'generate_architectural_passport' which inspects one file.\n"
4022
4048
  "\n"
4023
4049
  "Parameters:\n"
4024
4050
  "- `workspace_dir` (str, optional, default='.'): Target repository root directory containing source code to index.\n"
@@ -4119,6 +4145,62 @@ def create_mcp_server():
4119
4145
  lines.append("🌟 **Flawless Code:** Zero hallucinated symbols detected. All imports and methods verified against workspace AST.")
4120
4146
  return "\n".join(lines)
4121
4147
 
4148
+ @server.tool(
4149
+ name="prove_zero_hallucination",
4150
+ title="Run Hallucination Detection Benchmark",
4151
+ description=(
4152
+ "Runs a fixed 60-scenario hallucination detection benchmark, distinguishing from 'heal_hallucinated_code' for a single candidate snippet and 'audit_code_quality' for repository findings. Results apply only to the tested cases and do not prove absence of other hallucinations.\n"
4153
+ "\n"
4154
+ "Parameters:\n"
4155
+ "- `workspace_dir` (str, optional, default='.'): Target repository root directory containing ground-truth AST symbol definitions.\n"
4156
+ "- `export_docs` (bool, optional, default=True): When True, updates docs/ZERO_HALLUCINATION_PROOF.md and docs/zero_hallucination_proof.json.\n"
4157
+ "\n"
4158
+ "Behavior:\n"
4159
+ "- Mutability: export_docs=True writes benchmark artifacts in docs/ relative to the server working directory; False avoids those writes.\n"
4160
+ "- Idempotency: Report timestamps and measured latencies may differ between runs.\n"
4161
+ "- 100% Offline: Operates entirely locally with zero external network access.\n"
4162
+ "- Auth & Rate Limits: Zero authentication or cloud credentials required; completes in <100ms.\n"
4163
+ "- Error Handling: Emits clean verification status and confusion matrix.\n"
4164
+ "\n"
4165
+ "Usage Guidelines:\n"
4166
+ "- When to use: Measure detection and false-positive rates on the bundled scenarios before or after changes.\n"
4167
+ "- When NOT to use: Do not use for inspecting a single candidate snippet (use 'heal_hallucinated_code' instead); do not use for secret scans (use 'verify_security_guard' instead).\n"
4168
+ "\n"
4169
+ "Returns: Markdown benchmark results with case counts, detection and false-positive rates, and latency."
4170
+ ),
4171
+ annotations=ToolAnnotations(read_only_hint=False, destructive_hint=False, idempotent_hint=False, open_world_hint=False)
4172
+ )
4173
+ def prove_zero_hallucination(
4174
+ workspace_dir: Annotated[str, Field(default=".", description="Target repository root directory (default: current directory).")] = ".",
4175
+ export_docs: Annotated[bool, Field(default=True, description="Whether to write ZERO_HALLUCINATION_PROOF.md to docs/.")] = True
4176
+ ) -> str:
4177
+ """Executes the 60-scenario empirical zero-hallucination benchmark and returns proof report."""
4178
+ from tzero.tzero_hallucination_proof import HallucinationProofEngine
4179
+ rep = HallucinationProofEngine.run_proof_benchmark(workspace_dir)
4180
+ md_report = (
4181
+ f"# 🧠 T-Zero Hallucination Detection Benchmark\n\n"
4182
+ f"- **Evaluated Workspace:** `{rep.workspace_dir}`\n"
4183
+ f"- **Timestamp:** `{rep.timestamp}`\n"
4184
+ f"- **Total Scenarios Evaluated:** {rep.total_cases}\n\n"
4185
+ f"### 📊 Key Verification Metrics:\n"
4186
+ f"- **Hallucinated Cases Tested:** {rep.hallucinated_cases}\n"
4187
+ f"- **Hallucinations Intercepted:** {rep.detected_hallucinations} / {rep.hallucinated_cases} (**{rep.detection_rate}% Recall**)\n"
4188
+ f"- **Escaped Hallucinations:** **{rep.escaped_hallucinations} ({rep.escape_rate}% on tested cases)**\n"
4189
+ f"- **Clean Control Passed:** {rep.clean_passed} / {rep.clean_cases} (**{rep.false_positive_rate}% False Positive Rate**)\n"
4190
+ f"- **Pre-Flight Accuracy:** **{rep.accuracy}%**\n"
4191
+ f"- **Self-Healing AST Syntheses:** {rep.auto_healed_count} cases auto-corrected (**{rep.auto_heal_rate}%**)\n"
4192
+ f"- **Average Verification Latency:** {rep.avg_latency_ms} ms / snippet\n\n"
4193
+ f"Results describe this benchmark only; they do not establish a general false-negative rate or guarantee correctness."
4194
+ )
4195
+ if export_docs:
4196
+ from dataclasses import asdict
4197
+ os.makedirs("docs", exist_ok=True)
4198
+ with open(os.path.join("docs", "zero_hallucination_proof.json"), "w", encoding="utf-8") as fp:
4199
+ json.dump(asdict(rep), fp, indent=2)
4200
+ with open(os.path.join("docs", "ZERO_HALLUCINATION_PROOF.md"), "w", encoding="utf-8") as fp:
4201
+ fp.write(md_report + "\n")
4202
+ return md_report
4203
+
4122
4204
  @server.tool(
4123
4205
  name="transpile_model_bridge",
4124
4206
  title="Transpile Python Data Models to Polyglot Schemas",
@@ -4236,7 +4318,7 @@ def create_mcp_server():
4236
4318
  name="generate_architectural_passport",
4237
4319
  title="Generate High Density AST Architectural Passport for LLMs",
4238
4320
  description=(
4239
- "Generates an ultra-dense, prompt-ready AST architectural passport for a target source file, distinguishing from 'build_project_context' which outputs a multi-tier repository tree and 'generate_architecture_blueprint' which builds Mermaid diagrams by distilling module purpose, layer role, cyclomatic complexity, exported symbol contracts, and dependency topologies into a compact prompt block with up to 95% token savings.\n"
4321
+ "Returns a compact architectural passport for one Python file, distinguishing from 'build_project_context' for repository context, 'build_ast_snapshot' for a persisted index, and 'generate_architecture_blueprint' for repository diagrams.\n"
4240
4322
  "\n"
4241
4323
  "Parameters:\n"
4242
4324
  "- `file_path` (str, required): Absolute or relative path to the Python source code file to analyze.\n"
@@ -4282,7 +4364,7 @@ def create_mcp_server():
4282
4364
  name="execute_codebase_workflow",
4283
4365
  title="Execute Composite Multi Step Codebase Workflow",
4284
4366
  description=(
4285
- "Executes autonomous composite codebase analysis, context generation, and security pipelines in a single command, distinguishing from 'build_project_context', 'audit_code_quality', and 'verify_security_guard' by orchestrating end-to-end multi-step intelligence workflows rather than running isolated single-purpose context builds, quality audits, or secret scans.\n"
4367
+ "Compatibility router for combined reports, distinguishing from 'build_project_context' and 'audit_code_quality' by combining analyses when action='auto'; for individual tasks use the dedicated tools directly.\n"
4286
4368
  "\n"
4287
4369
  "Parameters:\n"
4288
4370
  "- `action`: Workflow operation: 'auto' runs comprehensive all-in-one audit & context pipeline; 'context' builds AST context tree; 'audit' checks code quality & smells; 'security' runs Zero-Leak secret scan; 'blueprint' generates Mermaid architecture; 'dependencies' maps import topology; 'impact' evaluates blast radius of modified symbols; 'search' performs hybrid BM25 code search; 'prune' strips in-memory AST bodies; 'heal' runs AST self-healing; 'memory' manages episodic memory; 'swarm' coordinates multi-agent consensus.\n"
@@ -4291,21 +4373,21 @@ def create_mcp_server():
4291
4373
  "- `options`: Optional JSON string specifying extra configuration parameters (e.g. {\"reduction_mode\": \"ultra\", \"max_tokens\": 32000, \"depth\": 4}).\n"
4292
4374
  "\n"
4293
4375
  "Behavior:\n"
4294
- "- Mutability: Read-only for analysis actions ('auto', 'context', 'audit', 'security', 'blueprint', 'dependencies', 'impact', 'search'); state-modifying only when executing explicit 'heal' patches or 'memory' resets.\n"
4295
- "- Idempotency: Deterministic execution across all analytical and context-generation workflows.\n"
4296
- "- Privacy & Network: 100% offline local execution; zero telemetry or external network calls.\n"
4297
- "- Performance & Resources: Executes composite pipeline in <500ms using <60MB RAM; thread-safe.\n"
4376
+ "- Mutability: Depends on action and options. Security may install hooks; rules, memory, sync, healing, merge, and generated tests can modify files.\n"
4377
+ "- Idempotency: Not guaranteed for state-changing operations.\n"
4378
+ "- Privacy & Network: Most analysis is local, but blueprint with use_ai can contact a configured provider and transmit context.\n"
4379
+ "- Performance & Resources: Runtime and memory depend on workspace size and selected operation.\n"
4298
4380
  "- Auth: Zero authentication or cloud credentials required.\n"
4299
4381
  "- Return Structure: Emits comprehensive executive Markdown report tailored to the requested action or full autonomous pipeline.\n"
4300
4382
  "- Error Handling: Gracefully reports clean diagnostic notices for missing paths, unparseable files, or invalid JSON options without crashing.\n"
4301
4383
  "\n"
4302
4384
  "Usage Guidelines:\n"
4303
- "- When to use: Use whenever you want an instant complete overview of a codebase, or want to perform any T-Zero operation through a single unified entrypoint without choosing between individual tools.\n"
4385
+ "- When to use: Use action='auto' for a combined report or retain this router for compatibility with existing clients.\n"
4304
4386
  "- When NOT to use: Do not use when an isolated single-purpose operation is sufficient, such as generating an AST context tree (use 'build_project_context' instead), auditing code smells (use 'audit_code_quality' instead), scanning secrets (use 'verify_security_guard' instead), or pruning an in-memory snippet (use 'prune_code_snippet' instead).\n"
4305
4387
  "\n"
4306
4388
  "Returns: Comprehensive Markdown report tailored to the requested action or full autonomous pipeline.\n"
4307
4389
  ),
4308
- annotations=ToolAnnotations(read_only_hint=False, destructive_hint=False, idempotent_hint=True, open_world_hint=False)
4390
+ annotations=ToolAnnotations(read_only_hint=False, destructive_hint=True, idempotent_hint=False, open_world_hint=True)
4309
4391
  )
4310
4392
  async def execute_codebase_workflow(
4311
4393
  action: Annotated[str, Field(default="auto", description="Workflow operation: 'auto' (comprehensive all-in-one pipeline), 'context', 'audit', 'security', 'blueprint', 'dependencies', 'impact', 'search', 'prune', 'heal', 'memory', 'swarm', 'design'.")] = "auto",
@@ -4378,32 +4460,30 @@ def create_mcp_server():
4378
4460
  return generate_architecture_blueprint(project_root=target, use_ai=use_ai)
4379
4461
 
4380
4462
  elif act in ("dependencies", "deps", "imports"):
4381
- focus_f = opts.get("focus_file", query)
4382
- inc_ext = bool(opts.get("include_external", True))
4383
- return analyze_code_dependencies(project_root=target, focus_file=focus_f, include_external=inc_ext)
4463
+ return analyze_code_dependencies(project_root=target, analysis_type=opts.get("analysis_type", "dependencies"), target_symbol=opts.get("target_symbol", query), file_path=opts.get("file_path", opts.get("focus_file", "")))
4384
4464
 
4385
4465
  elif act in ("impact", "blast_radius"):
4386
4466
  symbol = query or opts.get("symbol_name", "")
4387
4467
  if not symbol and not os.path.isdir(target):
4388
4468
  symbol = os.path.basename(target)
4389
- return analyze_change_impact(symbol_name=symbol, project_root=target if os.path.isdir(target) else ".")
4469
+ return analyze_change_impact(target_symbol=symbol, project_root=target if os.path.isdir(target) else ".", file_path=opts.get("file_path", ""))
4390
4470
 
4391
4471
  elif act in ("search", "find", "semantic"):
4392
4472
  limit = int(opts.get("limit", 8))
4393
- return search_codebase(query=query or target, project_root="." if os.path.isfile(target) else target, limit=limit)
4473
+ return search_codebase(query=query or target, project_root="." if os.path.isfile(target) else target, top_k=limit)
4394
4474
 
4395
4475
  elif act in ("prune", "snippet", "signature"):
4396
- lang = opts.get("language", "python")
4397
- return prune_code_snippet(code_snippet=query or target, language=lang)
4476
+ lang = opts.get("file_name_or_lang", opts.get("language", "snippet.py"))
4477
+ return prune_code_snippet(code=query or target, file_name_or_lang=lang, reduction_mode=opts.get("reduction_mode", "ultra"))
4398
4478
 
4399
4479
  elif act in ("rules", "boundaries", "manage_rules"):
4400
4480
  op = opts.get("operation", "query")
4401
4481
  rule = opts.get("rule_definition", query)
4402
- return manage_architecture_rules(project_root=target, operation=op, rule_definition=rule)
4482
+ return manage_architecture_rules(project_root=target, action=op, rule_name=opts.get("rule_name", ""), rule_definition=rule)
4403
4483
 
4404
4484
  elif act in ("enforce", "enforce_rules"):
4405
4485
  strict = bool(opts.get("strict", False))
4406
- return enforce_architecture_rules(project_root=target, strict=strict)
4486
+ return enforce_architecture_rules(project_root=target, strict_mode=strict)
4407
4487
 
4408
4488
  elif act in ("cost", "estimate", "tokens"):
4409
4489
  return estimate_token_cost(project_root=target, text=query)
@@ -4462,6 +4542,15 @@ def create_mcp_server():
4462
4542
  elif act in ("drift", "drift_analysis", "instruction_drift", "attention_drift"):
4463
4543
  return analyze_instruction_drift(workspace_dir=target if os.path.isdir(target) else ".")
4464
4544
 
4545
+ elif act in ("ci", "local_ci", "local-ci", "run_local_ci"):
4546
+ return run_local_ci(
4547
+ quick=bool(opts.get("quick", False)),
4548
+ auto_fix=bool(opts.get("auto_fix", False)),
4549
+ install_hook=bool(opts.get("install_hook", False)),
4550
+ uninstall_hook=bool(opts.get("uninstall_hook", False)),
4551
+ project_root=target if os.path.isdir(target) else "."
4552
+ )
4553
+
4465
4554
  elif act in ("merge_heal", "semantic_merge", "merge", "conflict_heal"):
4466
4555
  from tzero.tzero_semantic_merge import ASTSemanticMerger
4467
4556
  target_file = target or query
@@ -4666,7 +4755,27 @@ def create_mcp_server():
4666
4755
  f"❌ Unknown action '{act}'.\n"
4667
4756
  f"Supported actions: 'auto', 'context', 'audit', 'security', 'blueprint', 'dependencies', "
4668
4757
  f"'impact', 'search', 'prune', 'rules', 'enforce', 'cost', 'memory', 'swarm', 'heal', 'design', "
4669
- f"'patch', 'pagerank', 'dead_code', 'duplicity', 'call_chain', 'sync', 'roi', 'drift'."
4758
+ f"'patch', 'pagerank', 'dead_code', 'duplicity', 'call_chain', 'sync', 'roi', 'drift', 'ci', 'local_ci'."
4759
+ )
4760
+
4761
+ def run_local_ci(quick: bool = False, auto_fix: bool = False, install_hook: bool = False, uninstall_hook: bool = False, project_root: str = ".") -> str:
4762
+ """Executes T-Zero Local CI suite locally on the developer machine."""
4763
+ from tzero.tzero_ci import LocalCIRunner
4764
+ if install_hook:
4765
+ ok, msg = LocalCIRunner.install_git_pre_push_hook(project_root)
4766
+ return f"### T-Zero Pre-Push Git Hook Installation\n- Status: {'SUCCESS' if ok else 'FAILED'}\n- Message: {msg}\n"
4767
+ if uninstall_hook:
4768
+ ok, msg = LocalCIRunner.uninstall_git_pre_push_hook(project_root)
4769
+ return f"### T-Zero Pre-Push Git Hook Removal\n- Status: {'SUCCESS' if ok else 'FAILED'}\n- Message: {msg}\n"
4770
+
4771
+ runner = LocalCIRunner(repo_dir=project_root, quick=quick, auto_fix=auto_fix)
4772
+ report = runner.run()
4773
+ return (
4774
+ f"### T-Zero Local CI Verification Report\n"
4775
+ f"- **Status:** {'✅ ALL PASSED' if report.passed else '❌ FAILED'}\n"
4776
+ f"- **Duration:** {report.total_duration:.2f}s\n"
4777
+ f"- **Remote Actions Quota Saved:** ~{report.estimated_actions_minutes_saved:.1f} minutes\n\n"
4778
+ + "\n".join([f"- [{'PASS' if s.passed else 'FAIL'}] **{s.name}** ({s.duration:.2f}s): {s.output or s.error}" for s in report.steps])
4670
4779
  )
4671
4780
 
4672
4781
  # Register canonical mappings
@@ -4694,16 +4803,20 @@ def create_mcp_server():
4694
4803
  _CANONICAL_DISPATCH['sync_workspace_rules'] = sync_workspace_rules
4695
4804
  _CANONICAL_DISPATCH['calculate_token_cost_roi'] = calculate_token_cost_roi
4696
4805
  _CANONICAL_DISPATCH['analyze_instruction_drift'] = analyze_instruction_drift
4806
+ _CANONICAL_DISPATCH['run_local_ci'] = run_local_ci
4807
+ _CANONICAL_DISPATCH['execute_local_ci'] = run_local_ci
4697
4808
  _LEGACY_DISPATCH['sync_workspace_rules'] = sync_workspace_rules
4698
4809
  _LEGACY_DISPATCH['calculate_token_cost_roi'] = calculate_token_cost_roi
4699
4810
  _LEGACY_DISPATCH['analyze_instruction_drift'] = analyze_instruction_drift
4811
+ _LEGACY_DISPATCH['run_local_ci'] = run_local_ci
4812
+ _LEGACY_DISPATCH['execute_local_ci'] = run_local_ci
4700
4813
 
4701
4814
  @server.tool(
4702
4815
  name="search_tools",
4703
4816
  title="Progressive T-Zero MCP Tool Discovery Catalog",
4704
4817
  description=(
4705
4818
  "Progressively discover and search registered T-Zero tools by keyword or domain category rather than loading all 58 schemas at once "
4706
- "(unlike codebase searches; use 'search_codebase_semantic' for searching repository source files instead).\n\n"
4819
+ "(unlike codebase searches; use 'search_codebase' for searching repository source files instead).\n\n"
4707
4820
  "Parameters:\n"
4708
4821
  "- `query`: Optional keyword query (e.g., 'secret audit', 'pagerank', 'diff', 'merge').\n"
4709
4822
  "- `category`: Domain filter (`all`, `context`, `security`, `ast`, `memory`, `swarm`, `design`).\n"
@@ -4712,8 +4825,8 @@ def create_mcp_server():
4712
4825
  "- Mutability & Speed: Read-only, idempotent catalog lookup executing in <5ms.\n"
4713
4826
  "- Auth & Boundaries: Zero authentication, external credentials, or network access required.\n\n"
4714
4827
  "Usage Guidelines:\n"
4715
- "- When to use: Use when running in canonical mode (21 tools) and discovering specialized AST, Jarvis, or security tools by keyword.\n"
4716
- "- When NOT to use: Do not use when searching source files or symbols inside the workspace repository — use 'search_codebase_semantic' instead.\n\n"
4828
+ "- When to use: Discover specialized AST, Jarvis, or security tools by keyword; availability varies by tool mode.\n"
4829
+ "- When NOT to use: Do not use when searching source files or symbols inside the workspace repository — use 'search_codebase' instead.\n\n"
4717
4830
  "Returns: Structured dictionary with `query`, `total_available`, and ranked `tools` (`name`, `category`, `summary`)."
4718
4831
  ),
4719
4832
  structured_output=True,
@@ -5157,7 +5270,7 @@ def print_welcome_guide():
5157
5270
  ================================================================================
5158
5271
  ⚡ SIBER AKADEMI T-ZERO CONTEXT ARCHITECT & MCP ENGINE
5159
5272
  ================================================================================
5160
- Engineered by Toprak Ahmet Aydoğmuş (15-year-old developer) & Siber Akademi
5273
+ Engineered by Toprak Ahmet Aydoğmuş & Siber Akademi
5161
5274
  to eliminate token bloat, reduce prompt costs by up to 95%, and stop AI hallucinations.
5162
5275
  Search 'Toprak Ahmet Aydoğmuş' on Google to learn more!
5163
5276
  If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
@@ -5257,13 +5370,31 @@ def main():
5257
5370
  sys.stderr.write(f"[ERROR] Failed to launch T-Zero Dashboard: {e}\n")
5258
5371
  sys.exit(1)
5259
5372
 
5260
- if "--install" in sys.argv[1:] or "--add-mcp" in sys.argv[1:]:
5373
+ if any(arg in sys.argv[1:] for arg in ("--install", "--add-mcp", "install", "install-ide")):
5261
5374
  try:
5262
- import addmcp
5263
- sys.argv = [sys.argv[0]] + [a for a in sys.argv[1:] if a not in ("--install", "--add-mcp")]
5264
- addmcp.main()
5265
- return
5266
- except ImportError as e:
5375
+ try:
5376
+ from tzero.tzero_welcome import print_star_banner
5377
+ except ImportError:
5378
+ from tzero_welcome import print_star_banner
5379
+ print_star_banner()
5380
+ except Exception:
5381
+ pass
5382
+ try:
5383
+ try:
5384
+ import addmcp
5385
+ except ImportError:
5386
+ from tzero import addmcp
5387
+ raw_remaining = [a for a in sys.argv[1:] if a not in ("--install", "--add-mcp", "install", "install-ide")]
5388
+ # In CLI/npx mode without args or with '--all', run automatic 1-click installer across all detected IDEs
5389
+ if not raw_remaining or raw_remaining == ["--all"] or raw_remaining == ["all"]:
5390
+ sys.exit(addmcp.run_init([]))
5391
+ elif "--gui" in raw_remaining:
5392
+ sys.argv = [sys.argv[0]] + [a for a in raw_remaining if a != "--gui"]
5393
+ addmcp.main()
5394
+ return
5395
+ else:
5396
+ sys.exit(addmcp.run_init(raw_remaining))
5397
+ except Exception as e:
5267
5398
  sys.stderr.write(f"[ERROR] addmcp installer failed: {e}\n")
5268
5399
  sys.exit(1)
5269
5400