tzero-mcp 11.14.0 → 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 (38) hide show
  1. package/LICENSE +661 -21
  2. package/NOTICE +22 -0
  3. package/README.md +3 -3
  4. package/index.js +5 -0
  5. package/package.json +3 -2
  6. package/src/addmcp.py +2 -2
  7. package/src/app.py +1 -1
  8. package/src/tzero/__init__.py +5 -0
  9. package/src/tzero/tzero_benchmark.py +2 -2
  10. package/src/tzero/tzero_blackboard.py +1 -1
  11. package/src/tzero/tzero_budget.py +1 -1
  12. package/src/tzero/tzero_ci.py +658 -10
  13. package/src/tzero/tzero_commit.py +1 -1
  14. package/src/tzero/tzero_contracts.py +2 -2
  15. package/src/tzero/tzero_cost.py +1 -1
  16. package/src/tzero/tzero_dashboard.py +3 -3
  17. package/src/tzero/tzero_debt.py +1 -1
  18. package/src/tzero/tzero_drift.py +1 -1
  19. package/src/tzero/tzero_explain.py +1 -1
  20. package/src/tzero/tzero_golden.py +2 -2
  21. package/src/tzero/tzero_infra.py +1 -1
  22. package/src/tzero/tzero_jarvis/__init__.py +15 -1
  23. package/src/tzero/tzero_jarvis/agent_guard.py +620 -0
  24. package/src/tzero/tzero_jarvis/creative_director.py +1 -1
  25. package/src/tzero/tzero_jarvis/orchestrator.py +36 -34
  26. package/src/tzero/tzero_jarvis/self_healing.py +325 -250
  27. package/src/tzero/tzero_lsp.py +1 -1
  28. package/src/tzero/tzero_mcp.py +121 -63
  29. package/src/tzero/tzero_promo.py +504 -0
  30. package/src/tzero/tzero_replay.py +1 -1
  31. package/src/tzero/tzero_semantic_merge.py +1 -1
  32. package/src/tzero/tzero_stubs.py +1 -1
  33. package/src/tzero/tzero_task_benchmark.py +2 -2
  34. package/src/tzero/tzero_tui.py +2 -2
  35. package/src/tzero/tzero_turbo.py +1 -1
  36. package/src/tzero/tzero_v3.py +61 -8
  37. package/src/tzero/tzero_welcome.py +2 -2
  38. 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.13.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"
@@ -4121,28 +4147,28 @@ def create_mcp_server():
4121
4147
 
4122
4148
  @server.tool(
4123
4149
  name="prove_zero_hallucination",
4124
- title="Empirical Zero-Hallucination Proof Benchmark",
4150
+ title="Run Hallucination Detection Benchmark",
4125
4151
  description=(
4126
- "Executes an empirical 60-scenario benchmark mathematically and practically proving a 0.0% AI hallucination escape rate with T-Zero's pre-flight reality-lock compiler, distinguishing from 'verify_hallucination_guard' and 'audit_codebase_quality' by running a formal empirical evaluation suite across 9 hallucination categories rather than verifying a single code snippet.\n"
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"
4127
4153
  "\n"
4128
4154
  "Parameters:\n"
4129
4155
  "- `workspace_dir` (str, optional, default='.'): Target repository root directory containing ground-truth AST symbol definitions.\n"
4130
4156
  "- `export_docs` (bool, optional, default=True): When True, updates docs/ZERO_HALLUCINATION_PROOF.md and docs/zero_hallucination_proof.json.\n"
4131
4157
  "\n"
4132
4158
  "Behavior:\n"
4133
- "- Read-only: Runs 60 benchmark tests in memory across ghost dependencies, stdlib typos, workspace symbols, schema fields, and signatures without mutating workspace files.\n"
4134
- "- Idempotent: Deterministic 100.0% detection rate and 0.0% escape rate on repeated runs.\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"
4135
4161
  "- 100% Offline: Operates entirely locally with zero external network access.\n"
4136
4162
  "- Auth & Rate Limits: Zero authentication or cloud credentials required; completes in <100ms.\n"
4137
4163
  "- Error Handling: Emits clean verification status and confusion matrix.\n"
4138
4164
  "\n"
4139
4165
  "Usage Guidelines:\n"
4140
- "- When to use: Run to verify and mathematically prove that T-Zero's AST reality-lock eliminates 100% of LLM hallucinations before deployment.\n"
4141
- "- When NOT to use: Do not use for checking single candidate code snippets (use 'verify_hallucination_guard' instead); do not use for security secret scans (use 'verify_zero_leak_security' instead).\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"
4142
4168
  "\n"
4143
- "Returns: Comprehensive Markdown proof report with confusion matrix, detection KPI metrics, mathematical theorem, and benchmark breakdown."
4169
+ "Returns: Markdown benchmark results with case counts, detection and false-positive rates, and latency."
4144
4170
  ),
4145
- annotations=ToolAnnotations(read_only_hint=True, destructive_hint=False, idempotent_hint=True, open_world_hint=False)
4171
+ annotations=ToolAnnotations(read_only_hint=False, destructive_hint=False, idempotent_hint=False, open_world_hint=False)
4146
4172
  )
4147
4173
  def prove_zero_hallucination(
4148
4174
  workspace_dir: Annotated[str, Field(default=".", description="Target repository root directory (default: current directory).")] = ".",
@@ -4151,27 +4177,28 @@ def create_mcp_server():
4151
4177
  """Executes the 60-scenario empirical zero-hallucination benchmark and returns proof report."""
4152
4178
  from tzero.tzero_hallucination_proof import HallucinationProofEngine
4153
4179
  rep = HallucinationProofEngine.run_proof_benchmark(workspace_dir)
4154
- if export_docs:
4155
- HallucinationProofEngine.export_artifacts(rep, "docs")
4156
-
4157
4180
  md_report = (
4158
- f"# 🧠 T-Zero Zero-Hallucination Empirical Proof (0.0% Escape Rate)\n\n"
4181
+ f"# 🧠 T-Zero Hallucination Detection Benchmark\n\n"
4159
4182
  f"- **Evaluated Workspace:** `{rep.workspace_dir}`\n"
4160
4183
  f"- **Timestamp:** `{rep.timestamp}`\n"
4161
4184
  f"- **Total Scenarios Evaluated:** {rep.total_cases}\n\n"
4162
4185
  f"### 📊 Key Verification Metrics:\n"
4163
4186
  f"- **Hallucinated Cases Tested:** {rep.hallucinated_cases}\n"
4164
4187
  f"- **Hallucinations Intercepted:** {rep.detected_hallucinations} / {rep.hallucinated_cases} (**{rep.detection_rate}% Recall**)\n"
4165
- f"- **Escaped Hallucinations:** **{rep.escaped_hallucinations} ({rep.escape_rate}% ESCAPE RATE - PROVEN ZERO!)**\n"
4188
+ f"- **Escaped Hallucinations:** **{rep.escaped_hallucinations} ({rep.escape_rate}% on tested cases)**\n"
4166
4189
  f"- **Clean Control Passed:** {rep.clean_passed} / {rep.clean_cases} (**{rep.false_positive_rate}% False Positive Rate**)\n"
4167
4190
  f"- **Pre-Flight Accuracy:** **{rep.accuracy}%**\n"
4168
4191
  f"- **Self-Healing AST Syntheses:** {rep.auto_healed_count} cases auto-corrected (**{rep.auto_heal_rate}%**)\n"
4169
4192
  f"- **Average Verification Latency:** {rep.avg_latency_ms} ms / snippet\n\n"
4170
- f"### 🎯 Mathematical Invariant Theorem:\n"
4171
- f"> Under the T-Zero Pre-Flight Reality-Lock compiler gate, the workspace symbol universe $V_{{\\text{{universe}}}} = V_{{\\text{{workspace}}}} \\cup V_{{\\text{{stdlib}}}} \\cup V_{{\\text{{manifest}}}}$ is finite and statically closed.\n"
4172
- f"> For any proposed AST reference $r$, $\\text{{Decision}}(r) = [r \\in V_{{\\text{{universe}}}}] \\in \\{{0, 1\\}}$.\n"
4173
- f"> Therefore, $\\text{{False Negative Rate (FNR)}} = 0.0\\%$. Code with hallucinations is provably blocked before application."
4193
+ f"Results describe this benchmark only; they do not establish a general false-negative rate or guarantee correctness."
4174
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")
4175
4202
  return md_report
4176
4203
 
4177
4204
  @server.tool(
@@ -4291,7 +4318,7 @@ def create_mcp_server():
4291
4318
  name="generate_architectural_passport",
4292
4319
  title="Generate High Density AST Architectural Passport for LLMs",
4293
4320
  description=(
4294
- "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"
4295
4322
  "\n"
4296
4323
  "Parameters:\n"
4297
4324
  "- `file_path` (str, required): Absolute or relative path to the Python source code file to analyze.\n"
@@ -4337,7 +4364,7 @@ def create_mcp_server():
4337
4364
  name="execute_codebase_workflow",
4338
4365
  title="Execute Composite Multi Step Codebase Workflow",
4339
4366
  description=(
4340
- "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"
4341
4368
  "\n"
4342
4369
  "Parameters:\n"
4343
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"
@@ -4346,21 +4373,21 @@ def create_mcp_server():
4346
4373
  "- `options`: Optional JSON string specifying extra configuration parameters (e.g. {\"reduction_mode\": \"ultra\", \"max_tokens\": 32000, \"depth\": 4}).\n"
4347
4374
  "\n"
4348
4375
  "Behavior:\n"
4349
- "- 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"
4350
- "- Idempotency: Deterministic execution across all analytical and context-generation workflows.\n"
4351
- "- Privacy & Network: 100% offline local execution; zero telemetry or external network calls.\n"
4352
- "- 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"
4353
4380
  "- Auth: Zero authentication or cloud credentials required.\n"
4354
4381
  "- Return Structure: Emits comprehensive executive Markdown report tailored to the requested action or full autonomous pipeline.\n"
4355
4382
  "- Error Handling: Gracefully reports clean diagnostic notices for missing paths, unparseable files, or invalid JSON options without crashing.\n"
4356
4383
  "\n"
4357
4384
  "Usage Guidelines:\n"
4358
- "- 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"
4359
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"
4360
4387
  "\n"
4361
4388
  "Returns: Comprehensive Markdown report tailored to the requested action or full autonomous pipeline.\n"
4362
4389
  ),
4363
- 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)
4364
4391
  )
4365
4392
  async def execute_codebase_workflow(
4366
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",
@@ -4433,32 +4460,30 @@ def create_mcp_server():
4433
4460
  return generate_architecture_blueprint(project_root=target, use_ai=use_ai)
4434
4461
 
4435
4462
  elif act in ("dependencies", "deps", "imports"):
4436
- focus_f = opts.get("focus_file", query)
4437
- inc_ext = bool(opts.get("include_external", True))
4438
- 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", "")))
4439
4464
 
4440
4465
  elif act in ("impact", "blast_radius"):
4441
4466
  symbol = query or opts.get("symbol_name", "")
4442
4467
  if not symbol and not os.path.isdir(target):
4443
4468
  symbol = os.path.basename(target)
4444
- 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", ""))
4445
4470
 
4446
4471
  elif act in ("search", "find", "semantic"):
4447
4472
  limit = int(opts.get("limit", 8))
4448
- 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)
4449
4474
 
4450
4475
  elif act in ("prune", "snippet", "signature"):
4451
- lang = opts.get("language", "python")
4452
- 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"))
4453
4478
 
4454
4479
  elif act in ("rules", "boundaries", "manage_rules"):
4455
4480
  op = opts.get("operation", "query")
4456
4481
  rule = opts.get("rule_definition", query)
4457
- 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)
4458
4483
 
4459
4484
  elif act in ("enforce", "enforce_rules"):
4460
4485
  strict = bool(opts.get("strict", False))
4461
- return enforce_architecture_rules(project_root=target, strict=strict)
4486
+ return enforce_architecture_rules(project_root=target, strict_mode=strict)
4462
4487
 
4463
4488
  elif act in ("cost", "estimate", "tokens"):
4464
4489
  return estimate_token_cost(project_root=target, text=query)
@@ -4517,6 +4542,15 @@ def create_mcp_server():
4517
4542
  elif act in ("drift", "drift_analysis", "instruction_drift", "attention_drift"):
4518
4543
  return analyze_instruction_drift(workspace_dir=target if os.path.isdir(target) else ".")
4519
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
+
4520
4554
  elif act in ("merge_heal", "semantic_merge", "merge", "conflict_heal"):
4521
4555
  from tzero.tzero_semantic_merge import ASTSemanticMerger
4522
4556
  target_file = target or query
@@ -4721,7 +4755,27 @@ def create_mcp_server():
4721
4755
  f"❌ Unknown action '{act}'.\n"
4722
4756
  f"Supported actions: 'auto', 'context', 'audit', 'security', 'blueprint', 'dependencies', "
4723
4757
  f"'impact', 'search', 'prune', 'rules', 'enforce', 'cost', 'memory', 'swarm', 'heal', 'design', "
4724
- 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])
4725
4779
  )
4726
4780
 
4727
4781
  # Register canonical mappings
@@ -4749,16 +4803,20 @@ def create_mcp_server():
4749
4803
  _CANONICAL_DISPATCH['sync_workspace_rules'] = sync_workspace_rules
4750
4804
  _CANONICAL_DISPATCH['calculate_token_cost_roi'] = calculate_token_cost_roi
4751
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
4752
4808
  _LEGACY_DISPATCH['sync_workspace_rules'] = sync_workspace_rules
4753
4809
  _LEGACY_DISPATCH['calculate_token_cost_roi'] = calculate_token_cost_roi
4754
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
4755
4813
 
4756
4814
  @server.tool(
4757
4815
  name="search_tools",
4758
4816
  title="Progressive T-Zero MCP Tool Discovery Catalog",
4759
4817
  description=(
4760
4818
  "Progressively discover and search registered T-Zero tools by keyword or domain category rather than loading all 58 schemas at once "
4761
- "(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"
4762
4820
  "Parameters:\n"
4763
4821
  "- `query`: Optional keyword query (e.g., 'secret audit', 'pagerank', 'diff', 'merge').\n"
4764
4822
  "- `category`: Domain filter (`all`, `context`, `security`, `ast`, `memory`, `swarm`, `design`).\n"
@@ -4767,8 +4825,8 @@ def create_mcp_server():
4767
4825
  "- Mutability & Speed: Read-only, idempotent catalog lookup executing in <5ms.\n"
4768
4826
  "- Auth & Boundaries: Zero authentication, external credentials, or network access required.\n\n"
4769
4827
  "Usage Guidelines:\n"
4770
- "- When to use: Use when running in canonical mode (21 tools) and discovering specialized AST, Jarvis, or security tools by keyword.\n"
4771
- "- 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"
4772
4830
  "Returns: Structured dictionary with `query`, `total_available`, and ranked `tools` (`name`, `category`, `summary`)."
4773
4831
  ),
4774
4832
  structured_output=True,