tzero-mcp 10.7.4 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +56 -29
  2. package/CONTRIBUTING.md +71 -71
  3. package/README.md +64 -64
  4. package/bin/tzero-mcp.js +62 -66
  5. package/bin/tzero.js +61 -65
  6. package/index.d.ts +25 -25
  7. package/index.js +15 -15
  8. package/package.json +88 -88
  9. package/src/addmcp.py +14 -11
  10. package/src/app.py +1810 -0
  11. package/src/main.py +1 -1
  12. package/src/pc_fixer_mcp.py +25 -0
  13. package/src/tzero/__init__.py +54 -0
  14. package/src/tzero/__main__.py +6 -0
  15. package/src/tzero/siber_akademi.ico +0 -0
  16. package/src/tzero/tzero_arch_test.py +463 -0
  17. package/src/{tzero_benchmark.py → tzero/tzero_benchmark.py} +475 -475
  18. package/src/tzero/tzero_blackboard.py +257 -0
  19. package/src/{tzero_bridge.py → tzero/tzero_bridge.py} +546 -362
  20. package/src/tzero/tzero_budget.py +195 -0
  21. package/src/{tzero_ci.py → tzero/tzero_ci.py} +153 -153
  22. package/src/{tzero_commit.py → tzero/tzero_commit.py} +192 -192
  23. package/src/tzero/tzero_contracts.py +1093 -0
  24. package/src/{tzero_cost.py → tzero/tzero_cost.py} +166 -163
  25. package/src/{tzero_dashboard.py → tzero/tzero_dashboard.py} +531 -19
  26. package/src/tzero/tzero_debt.py +461 -0
  27. package/src/{tzero_deps.py → tzero/tzero_deps.py} +179 -4
  28. package/src/{tzero_drift.py → tzero/tzero_drift.py} +208 -208
  29. package/src/{tzero_explain.py → tzero/tzero_explain.py} +73 -7
  30. package/src/{tzero_features.py → tzero/tzero_features.py} +19 -17
  31. package/src/tzero/tzero_federation.py +299 -0
  32. package/src/{tzero_fix.py → tzero/tzero_fix.py} +228 -228
  33. package/src/{tzero_fixer → tzero/tzero_fixer}/__init__.py +63 -63
  34. package/src/{tzero_fixer → tzero/tzero_fixer}/ast_syntax_healer.py +464 -464
  35. package/src/{tzero_fixer → tzero/tzero_fixer}/ast_type_modernizer.py +288 -288
  36. package/src/{tzero_fixer → tzero/tzero_fixer}/async_io_modernizer.py +127 -127
  37. package/src/{tzero_fixer → tzero/tzero_fixer}/automated_regression_suite.py +600 -600
  38. package/src/{tzero_fixer → tzero/tzero_fixer}/benchmarks_and_diagnostics.py +174 -174
  39. package/src/{tzero_fixer → tzero/tzero_fixer}/ci_cd_self_healing_gate.py +246 -246
  40. package/src/{tzero_fixer → tzero/tzero_fixer}/code_duplicity_and_refactorer.py +151 -151
  41. package/src/{tzero_fixer → tzero/tzero_fixer}/code_smells_healer.py +260 -260
  42. package/src/{tzero_fixer → tzero/tzero_fixer}/cwe_remediator.py +171 -171
  43. package/src/{tzero_fixer → tzero/tzero_fixer}/dead_code_eliminator.py +150 -150
  44. package/src/{tzero_fixer → tzero/tzero_fixer}/dependency_vulnerability_auditor.py +309 -309
  45. package/src/{tzero_fixer → tzero/tzero_fixer}/git_advanced_surgeon.py +1 -1
  46. package/src/{tzero_fixer → tzero/tzero_fixer}/hardware_and_disk_doctor.py +1 -1
  47. package/src/{tzero_fixer → tzero/tzero_fixer}/import_graph_healer.py +412 -412
  48. package/src/{tzero_fixer → tzero/tzero_fixer}/interactive_tui.py +91 -91
  49. package/src/{tzero_fixer → tzero/tzero_fixer}/knowledge_base.py +295 -295
  50. package/src/{tzero_fixer → tzero/tzero_fixer}/knowledge_base_extended.py +940 -940
  51. package/src/{tzero_fixer → tzero/tzero_fixer}/linters_and_static_analyzer.py +307 -307
  52. package/src/{tzero_fixer → tzero/tzero_fixer}/mcp_server.py +49 -7
  53. package/src/{tzero_fixer → tzero/tzero_fixer}/os_doctor.py +502 -502
  54. package/src/{tzero_fixer → tzero/tzero_fixer}/packaging_abi_surgeon.py +1 -1
  55. package/src/{tzero_fixer → tzero/tzero_fixer}/pc_fixer_doctor.py +600 -599
  56. package/src/{tzero_fixer → tzero/tzero_fixer}/performance_and_memory_profiler.py +274 -274
  57. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_ast_parsers.py +313 -313
  58. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_build_healer.py +1 -1
  59. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_config_healer.py +318 -318
  60. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_doctor.py +372 -372
  61. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_linters.py +1 -1
  62. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_schema_validator.py +305 -305
  63. package/src/{tzero_fixer → tzero/tzero_fixer}/security_cwe_database.py +444 -444
  64. package/src/{tzero_fixer → tzero/tzero_fixer}/security_deep_rules.py +114 -114
  65. package/src/{tzero_fixer → tzero/tzero_fixer}/security_rules_catalog.py +110 -110
  66. package/src/{tzero_fixer → tzero/tzero_fixer}/security_zero_leak.py +326 -326
  67. package/src/{tzero_fixer → tzero/tzero_fixer}/smart_patch_recommender.py +223 -223
  68. package/src/{tzero_fixer → tzero/tzero_fixer}/synthetic_workspace_generator.py +220 -220
  69. package/src/{tzero_fixer → tzero/tzero_fixer}/system_diagnostics_extended.py +1 -1
  70. package/src/{tzero_fixer → tzero/tzero_fixer}/system_repair_recipes.py +447 -447
  71. package/src/{tzero_fixer → tzero/tzero_fixer}/venv_doctor.py +309 -309
  72. package/src/tzero/tzero_golden.py +319 -0
  73. package/src/tzero/tzero_graph_hud.html +338 -0
  74. package/src/tzero/tzero_graph_rag.py +263 -0
  75. package/src/{tzero_guard.py → tzero/tzero_guard.py} +243 -243
  76. package/src/tzero/tzero_hooks.py +565 -0
  77. package/src/{tzero_infra.py → tzero/tzero_infra.py} +274 -274
  78. package/src/{tzero_jarvis → tzero/tzero_jarvis}/__init__.py +124 -124
  79. package/src/{tzero_jarvis → tzero/tzero_jarvis}/causal_graph.py +310 -310
  80. package/src/{tzero_jarvis → tzero/tzero_jarvis}/graph_visualizer.py +395 -395
  81. package/src/{tzero_jarvis → tzero/tzero_jarvis}/hybrid_search.py +214 -214
  82. package/src/{tzero_jarvis → tzero/tzero_jarvis}/latent_press.py +137 -137
  83. package/src/{tzero_jarvis → tzero/tzero_jarvis}/memory_consolidation.py +212 -212
  84. package/src/{tzero_jarvis → tzero/tzero_jarvis}/minhash_lsh.py +184 -184
  85. package/src/{tzero_jarvis → tzero/tzero_jarvis}/orchestrator.py +335 -335
  86. package/src/{tzero_jarvis → tzero/tzero_jarvis}/self_healing.py +308 -308
  87. package/src/{tzero_jarvis → tzero/tzero_jarvis}/semantic_compressor.py +887 -887
  88. package/src/{tzero_jarvis → tzero/tzero_jarvis}/swarm.py +261 -261
  89. package/src/{tzero_jarvis → tzero/tzero_jarvis}/swarm_bft.py +144 -144
  90. package/src/{tzero_jarvis → tzero/tzero_jarvis}/workspace_orchestrator.py +1167 -1167
  91. package/src/{tzero_jarvis → tzero/tzero_jarvis}/zero_key_router.py +173 -173
  92. package/src/tzero/tzero_lsp.py +634 -0
  93. package/src/{tzero_mcp.py → tzero/tzero_mcp.py} +479 -100
  94. package/src/tzero/tzero_mutation.py +358 -0
  95. package/src/tzero/tzero_packer.py +577 -0
  96. package/src/{tzero_patch.py → tzero/tzero_patch.py} +624 -624
  97. package/src/{tzero_pc_fixer.py → tzero/tzero_pc_fixer.py} +12699 -12657
  98. package/src/{tzero_pipe.py → tzero/tzero_pipe.py} +95 -95
  99. package/src/tzero/tzero_polyglot.py +799 -0
  100. package/src/tzero/tzero_proxy.py +127 -0
  101. package/src/{tzero_reachability.py → tzero/tzero_reachability.py} +272 -272
  102. package/src/{tzero_replay.py → tzero/tzero_replay.py} +141 -141
  103. package/src/tzero/tzero_rust_bridge.py +198 -0
  104. package/src/tzero/tzero_scip.py +368 -0
  105. package/src/{tzero_security.py → tzero/tzero_security.py} +5 -2
  106. package/src/tzero/tzero_semantic_merge.py +189 -0
  107. package/src/tzero/tzero_snapshot.py +471 -0
  108. package/src/{tzero_stubs.py → tzero/tzero_stubs.py} +313 -313
  109. package/src/tzero/tzero_subagent_engine.py +459 -0
  110. package/src/{tzero_superdesign.py → tzero/tzero_superdesign.py} +774 -774
  111. package/src/{tzero_sync.py → tzero/tzero_sync.py} +241 -241
  112. package/src/{tzero_task_benchmark.py → tzero/tzero_task_benchmark.py} +458 -363
  113. package/src/{tzero_tui.py → tzero/tzero_tui.py} +91 -22
  114. package/src/tzero/tzero_turbo.py +264 -0
  115. package/src/{tzero_v3.py → tzero/tzero_v3.py} +628 -163
  116. package/src/tzero.py +2 -54
  117. package/test/package.test.js +55 -43
  118. package/src/tzero/jarvis/semantic_compressor.py +0 -373
  119. package/src/tzero_gateway.py +0 -885
  120. package/src/tzero_packer.py +0 -370
  121. package/src/tzero_polyglot.py +0 -422
  122. package/src/tzero_snapshot.py +0 -258
  123. /package/src/{siber_akademi_icon.py → tzero/siber_akademi_icon.py} +0 -0
  124. /package/src/{tzero_fixer → tzero/tzero_fixer}/amalgamation.py +0 -0
  125. /package/src/{tzero_fixer → tzero/tzero_fixer}/models.py +0 -0
  126. /package/src/{tzero_fixer → tzero/tzero_fixer}/orchestrator.py +0 -0
  127. /package/src/{tzero_neural_cortex.py → tzero/tzero_neural_cortex.py} +0 -0
@@ -15,6 +15,7 @@ from __future__ import annotations
15
15
  import http.server
16
16
  import json
17
17
  import os
18
+ import re
18
19
  import sys
19
20
  import threading
20
21
  import time
@@ -22,8 +23,8 @@ import urllib.parse
22
23
  import webbrowser
23
24
  from typing import Dict, Any
24
25
 
25
- from tzero_polyglot import PolyglotTokenReducer
26
- from tzero_jarvis.causal_graph import CausalTemporalGraph
26
+ from tzero.tzero_polyglot import PolyglotTokenReducer
27
+ from tzero.tzero_jarvis.causal_graph import CausalTemporalGraph
27
28
 
28
29
  DASHBOARD_PORT = 8421
29
30
 
@@ -456,7 +457,7 @@ HTML_PAGE = """<!DOCTYPE html>
456
457
  <div class="brand-logo">T0</div>
457
458
  <div>
458
459
  <div class="brand-title">T-Zero Developer Console</div>
459
- <div class="brand-sub">Enterprise AST Context Architect &bull; v10.0.0</div>
460
+ <div class="brand-sub" id="headerBrandSub">Enterprise AST Context Architect &bull; v11.0.0</div>
460
461
  </div>
461
462
  </div>
462
463
  <div class="header-actions">
@@ -468,7 +469,7 @@ HTML_PAGE = """<!DOCTYPE html>
468
469
  </a>
469
470
  <div class="status-badge">
470
471
  <div class="status-pulse"></div>
471
- 48 MCP TOOLS OPERATIONAL
472
+ <span id="headerMcpBadge">57 MCP TOOLS OPERATIONAL</span>
472
473
  </div>
473
474
  </div>
474
475
  </header>
@@ -477,11 +478,11 @@ HTML_PAGE = """<!DOCTYPE html>
477
478
  <div class="kpi-grid">
478
479
  <div class="kpi-card">
479
480
  <div class="kpi-label">Active MCP Tools</div>
480
- <div class="kpi-val sky">49</div>
481
+ <div class="kpi-val sky" id="kpiTools">57</div>
481
482
  </div>
482
483
  <div class="kpi-card">
483
484
  <div class="kpi-label">Token Pruning Rate</div>
484
- <div class="kpi-val indigo">94.9%</div>
485
+ <div class="kpi-val indigo" id="kpiSavings">Live</div>
485
486
  </div>
486
487
  <div class="kpi-card">
487
488
  <div class="kpi-label">PBFT Swarm Quorum</div>
@@ -674,12 +675,12 @@ impl SwarmCluster {
674
675
  <div class="panel">
675
676
  <div class="panel-header">
676
677
  <div class="panel-title">MCP Tools Explorer &bull; Interactive Sandbox</div>
677
- <span class="panel-badge">49 Tools &bull; TDQS 5.0 Anchor Certified</span>
678
+ <span class="panel-badge" id="toolsBadge">57 Tools &bull; TDQS 5.0 Anchor Certified</span>
678
679
  </div>
679
680
  <div class="sandbox-container">
680
681
  <!-- Category Filter Pills -->
681
682
  <div style="display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px;">
682
- <button class="cat-pill active" onclick="filterCategory('all', this)">All (49)</button>
683
+ <button class="cat-pill active" onclick="filterCategory('all', this)">All (Tools)</button>
683
684
  <button class="cat-pill" onclick="filterCategory('context', this)">Context & Tree</button>
684
685
  <button class="cat-pill" onclick="filterCategory('polyglot', this)">Polyglot AST</button>
685
686
  <button class="cat-pill" onclick="filterCategory('security', this)">Zero-Leak Security</button>
@@ -748,10 +749,108 @@ impl SwarmCluster {
748
749
  </div>
749
750
  </div>
750
751
  </div>
752
+ <section class="panel" id="enterpriseSuitePanel">
753
+ <div class="panel-header">
754
+ <div>
755
+ <div class="panel-title">Enterprise Engineering Suite (Live API Workbench)</div>
756
+ <div class="panel-sub">Execute local AST diagnostics, budget certificates, SemVer contract diffs, mutation scoring, polyglot bridge, merge healing, blackboard, federation, hooks &amp; SCIP graph</div>
757
+ </div>
758
+ <span class="panel-badge">12 Live Endpoints</span>
759
+ </div>
760
+ <div style="padding: 20px;">
761
+ <div style="display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px;" id="suiteTabs">
762
+ <button class="btn-superdesign suite-tab-btn" style="border-color:var(--sky);color:var(--sky);" onclick="switchSuiteTab('debt', this)">Tech Debt</button>
763
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('budget', this)">Token Budget</button>
764
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('golden', this)">Golden Verify</button>
765
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('contracts', this)">API Contracts</button>
766
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('mutation', this)">Mutation Test</button>
767
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('bridge', this)">Polyglot Bridge</button>
768
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('merge', this)">Merge Healer</button>
769
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('blackboard', this)">Blackboard</button>
770
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('federation', this)">Federation</button>
771
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('hooks', this)">Hooks Guard</button>
772
+ <button class="btn-superdesign suite-tab-btn" onclick="switchSuiteTab('scip', this)">SCIP Graph</button>
773
+ </div>
774
+ <div id="tab-debt" class="suite-pane" style="display:block;">
775
+ <div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
776
+ <input id="debtPath" value="." style="flex:1; min-width:200px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
777
+ <button class="btn-run" onclick="runSuiteApi('/api/debt/analyze', 'POST', {path: document.getElementById('debtPath').value})">Analyze Technical Debt</button>
778
+ </div>
779
+ </div>
780
+ <div id="tab-budget" class="suite-pane" style="display:none;">
781
+ <div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
782
+ <input id="budgetPath" value="." style="flex:1; min-width:160px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
783
+ <input id="budgetTokens" type="number" value="8000" style="width:120px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
784
+ <select id="budgetModel" style="padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);"><option value="claude-3-7">claude-3-7</option><option value="gpt-4o">gpt-4o</option><option value="gemini-2.5-pro">gemini-2.5-pro</option></select>
785
+ <button class="btn-run" onclick="runSuiteApi('/api/budget/optimize', 'POST', {path: document.getElementById('budgetPath').value, target_tokens: parseInt(document.getElementById('budgetTokens').value, 10), model: document.getElementById('budgetModel').value})">Issue Budget Certificate</button>
786
+ </div>
787
+ </div>
788
+ <div id="tab-golden" class="suite-pane" style="display:none;">
789
+ <div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
790
+ <input id="goldenPath" value="." style="flex:1; min-width:200px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
791
+ <button class="btn-run" onclick="runSuiteApi('/api/golden/verify', 'POST', {path: document.getElementById('goldenPath').value})">Verify Golden Signatures</button>
792
+ </div>
793
+ </div>
794
+ <div id="tab-contracts" class="suite-pane" style="display:none;">
795
+ <div style="display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:10px;">
796
+ <textarea id="contractOld" rows="4" style="width:100%; padding:8px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);">def compute(x: int) -> int:
797
+ return x</textarea>
798
+ <textarea id="contractNew" rows="4" style="width:100%; padding:8px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);">def compute(x: int, y: int) -> int:
799
+ return x + y</textarea>
800
+ </div>
801
+ <button class="btn-run" onclick="runSuiteApi('/api/contracts/compare', 'POST', {old_code: document.getElementById('contractOld').value, new_code: document.getElementById('contractNew').value, file_path: 'module.py'})">Compare SemVer Contracts</button>
802
+ </div>
803
+ <div id="tab-mutation" class="suite-pane" style="display:none;">
804
+ <div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
805
+ <input id="mutFile" value="tzero_explain.py" style="flex:1; min-width:200px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
806
+ <input id="mutMax" type="number" value="3" style="width:90px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
807
+ <button class="btn-run" onclick="runSuiteApi('/api/mutation/test', 'POST', {file: document.getElementById('mutFile').value, max_mutants: parseInt(document.getElementById('mutMax').value, 10)})">Run AST Mutation Test</button>
808
+ </div>
809
+ </div>
810
+ <div id="tab-bridge" class="suite-pane" style="display:none;">
811
+ <textarea id="bridgeCode" rows="4" style="width:100%; padding:8px; margin-bottom:10px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);">export interface SessionToken { id: string; expiresAt: number; }</textarea>
812
+ <div style="display:flex; gap:10px; align-items:center;">
813
+ <select id="bridgeLang" style="padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px;"><option value="ts">TypeScript</option><option value="rust">Rust</option><option value="go">Go</option></select>
814
+ <button class="btn-run" onclick="runSuiteApi('/api/bridge/reverse', 'POST', {code: document.getElementById('bridgeCode').value, lang: document.getElementById('bridgeLang').value, flavor: 'dataclass'})">Reverse Transpile to Python</button>
815
+ </div>
816
+ </div>
817
+ <div id="tab-merge" class="suite-pane" style="display:none;">
818
+ <textarea id="mergeCode" rows="4" style="width:100%; padding:8px; margin-bottom:10px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);"><<<<<<< HEAD
819
+ x = 1
820
+ =======
821
+ x = 2
822
+ >>>>>>> branch</textarea>
823
+ <button class="btn-run" onclick="runSuiteApi('/api/merge/heal', 'POST', {code: document.getElementById('mergeCode').value})">Heal Semantic Conflict</button>
824
+ </div>
825
+ <div id="tab-blackboard" class="suite-pane" style="display:none;">
826
+ <button class="btn-run" onclick="runSuiteApi('/api/blackboard', 'GET')">Inspect Causal Blackboard Graph</button>
827
+ </div>
828
+ <div id="tab-federation" class="suite-pane" style="display:none;">
829
+ <div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:10px;">
830
+ <input id="fedSymbol" value="PolyglotTokenReducer" placeholder="Symbol name" style="flex:1; min-width:180px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
831
+ <input id="fedScipPath" value="" placeholder="Optional SCIP/LSIF index path" style="flex:1; min-width:180px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
832
+ </div>
833
+ <div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
834
+ <button class="btn-run" onclick="runSuiteApi('/api/federation/peers', 'GET')">List Federation Peers</button>
835
+ <button class="btn-run" onclick="runSuiteApi('/api/federation/impact', 'POST', {symbol: document.getElementById('fedSymbol').value, scip_path: document.getElementById('fedScipPath').value})">Analyze Cross-Repo Impact</button>
836
+ </div>
837
+ </div>
838
+ <div id="tab-hooks" class="suite-pane" style="display:none;">
839
+ <button class="btn-run" onclick="runSuiteApi('/api/hooks/preview', 'GET')">Preview PreToolUse / PostToolUse Hooks</button>
840
+ </div>
841
+ <div id="tab-scip" class="suite-pane" style="display:none;">
842
+ <div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
843
+ <input id="scipPath" value="index.scip" placeholder="Path to .scip / .lsif / .json index" style="flex:1; min-width:200px; padding:8px 12px; background:var(--bg-canvas); color:var(--text-main); border:1px solid var(--border); border-radius:6px; font-family:var(--font-code);" />
844
+ <button class="btn-run" onclick="runSuiteApi('/api/scip/summary', 'POST', {path: document.getElementById('scipPath').value})">Inspect SCIP / LSIF Summary</button>
845
+ </div>
846
+ </div>
847
+ <pre id="suiteResult" style="margin-top:14px; padding:14px; background:var(--bg-canvas); border:1px solid var(--border); border-radius:8px; font-family:var(--font-code); font-size:12px; color:var(--sky); max-height:260px; overflow:auto;">Select an Enterprise Suite tab and execute a local AST operation.</pre>
848
+ </div>
849
+ </section>
751
850
  </main>
752
851
 
753
852
  <footer>
754
- T-Zero Context Architect v10.0.0 &bull; Developer: Toprak Ahmet Aydoğmuş &bull; Siber Akademi
853
+ <span id="footerBrand">T-Zero Context Architect v11.0.0</span> &bull; Developer: Toprak Ahmet Aydoğmuş &bull; Siber Akademi
755
854
  </footer>
756
855
 
757
856
  <script>
@@ -1308,7 +1407,62 @@ contract TokenVault {
1308
1407
  document.getElementById('annualSavings').textContent = `$${annualSavings.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} / yr`;
1309
1408
  }
1310
1409
 
1410
+ async function loadLiveStats() {
1411
+ try {
1412
+ const res = await fetch('/api/stats');
1413
+ if (!res.ok) return;
1414
+ const stats = await res.json();
1415
+ const verEl = document.getElementById('headerBrandSub');
1416
+ if (verEl && stats.version) verEl.textContent = `Enterprise AST Context Architect • v${stats.version}`;
1417
+ const footEl = document.getElementById('footerBrand');
1418
+ if (footEl && stats.version) footEl.textContent = `T-Zero Context Architect v${stats.version}`;
1419
+ const badgeEl = document.getElementById('headerMcpBadge');
1420
+ if (badgeEl && stats.tools_count) badgeEl.textContent = `${stats.tools_count} MCP TOOLS OPERATIONAL`;
1421
+ const kpiTools = document.getElementById('kpiTools');
1422
+ if (kpiTools && stats.tools_count) kpiTools.textContent = String(stats.tools_count);
1423
+ const toolsBadge = document.getElementById('toolsBadge');
1424
+ if (toolsBadge && stats.tools_count) toolsBadge.textContent = `${stats.tools_count} Tools • TDQS 5.0 Anchor Certified`;
1425
+ const kpiSavings = document.getElementById('kpiSavings');
1426
+ if (kpiSavings && stats.token_savings) {
1427
+ kpiSavings.textContent = stats.token_savings;
1428
+ kpiSavings.title = `Raw: ${(stats.raw_tokens || 0).toLocaleString()} tok | Pruned: ${(stats.pruned_tokens || 0).toLocaleString()} tok (${stats.total_files || 0} files)`;
1429
+ }
1430
+ } catch (_) {}
1431
+ }
1432
+
1433
+ function switchSuiteTab(tabId, btn) {
1434
+ document.querySelectorAll('#suiteTabs .suite-tab-btn').forEach(b => {
1435
+ b.style.borderColor = '';
1436
+ b.style.color = '';
1437
+ });
1438
+ if (btn) {
1439
+ btn.style.borderColor = 'var(--sky)';
1440
+ btn.style.color = 'var(--sky)';
1441
+ }
1442
+ document.querySelectorAll('.suite-pane').forEach(p => { p.style.display = 'none'; });
1443
+ const pane = document.getElementById('tab-' + tabId);
1444
+ if (pane) pane.style.display = 'block';
1445
+ }
1446
+
1447
+ async function runSuiteApi(endpoint, method, payload) {
1448
+ const out = document.getElementById('suiteResult');
1449
+ out.textContent = `Running ${method} ${endpoint}...`;
1450
+ try {
1451
+ const opts = { method };
1452
+ if (method !== 'GET') {
1453
+ opts.headers = { 'Content-Type': 'application/json' };
1454
+ opts.body = JSON.stringify(payload || {});
1455
+ }
1456
+ const res = await fetch(endpoint, opts);
1457
+ const data = await res.json();
1458
+ out.textContent = JSON.stringify(data, null, 2);
1459
+ } catch (err) {
1460
+ out.textContent = `Request failed: ${err.message}`;
1461
+ }
1462
+ }
1463
+
1311
1464
  // Initialize on load
1465
+ loadLiveStats();
1312
1466
  filterCategory('all', document.querySelector('.cat-pill'));
1313
1467
  calculateROI();
1314
1468
  </script>
@@ -1317,6 +1471,97 @@ contract TokenVault {
1317
1471
  """
1318
1472
 
1319
1473
 
1474
+ _DASHBOARD_STATS_CACHE: Dict[str, Any] = {"ts": 0.0, "data": None}
1475
+
1476
+
1477
+ def compute_live_dashboard_stats(workspace_dir: str = ".") -> Dict[str, Any]:
1478
+ """Computes cached live workspace and MCP telemetry for /api/stats."""
1479
+ now = time.time()
1480
+ cached = _DASHBOARD_STATS_CACHE.get("data")
1481
+ if cached is not None and (now - _DASHBOARD_STATS_CACHE["ts"]) < 60.0:
1482
+ return cached
1483
+
1484
+ version = "11.0.0"
1485
+ tools_count = 57
1486
+ try:
1487
+ from tzero import tzero_mcp
1488
+ version = getattr(tzero_mcp, "SERVER_VERSION", version)
1489
+ except Exception:
1490
+ pass
1491
+ try:
1492
+ mcp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tzero_mcp.py")
1493
+ if os.path.isfile(mcp_path):
1494
+ with open(mcp_path, "r", encoding="utf-8", errors="ignore") as fp:
1495
+ mcp_src = fp.read()
1496
+ reg_count = len(re.findall(r"^\s*@(?:server\.tool|_maybe_tool)\b", mcp_src, re.M))
1497
+ if reg_count > 0:
1498
+ tools_count = reg_count
1499
+ except Exception:
1500
+ pass
1501
+
1502
+ total_files = 0
1503
+ raw_tokens = 0
1504
+ pruned_tokens = 0
1505
+ savings_pct = 0.0
1506
+ try:
1507
+ from tzero.tzero_snapshot import SnapshotEngine
1508
+ snap = SnapshotEngine.load_snapshot(workspace_dir)
1509
+ if snap and snap.total_raw_tokens > 0:
1510
+ total_files = snap.file_count
1511
+ raw_tokens = snap.total_raw_tokens
1512
+ pruned_tokens = snap.total_pruned_tokens
1513
+ savings_pct = snap.reduction_pct
1514
+ except Exception:
1515
+ pass
1516
+
1517
+ if raw_tokens == 0:
1518
+ try:
1519
+ from tzero.tzero_polyglot import PolyglotTokenReducer, count_bpe_tokens
1520
+ abs_ws = os.path.abspath(workspace_dir)
1521
+ sampled = 0
1522
+ for root, dirs, files in os.walk(abs_ws):
1523
+ dirs[:] = sorted(
1524
+ d for d in dirs
1525
+ if not d.startswith(".") and d not in (
1526
+ "__pycache__", "node_modules", "dist", "build", "venv", ".venv",
1527
+ "installers", "crates", "tzero-showcase", "huggingface-space", "docs",
1528
+ )
1529
+ )
1530
+ for fname in sorted(files):
1531
+ total_files += 1
1532
+ if sampled < 40 and PolyglotTokenReducer.detect_language(fname):
1533
+ fp = os.path.join(root, fname)
1534
+ try:
1535
+ with open(fp, "r", encoding="utf-8", errors="replace") as rf:
1536
+ raw_code = rf.read(24000)
1537
+ pruned_code = PolyglotTokenReducer.reduce_code(raw_code, filename=fname, mode="ultra")
1538
+ raw_tokens += count_bpe_tokens(raw_code)
1539
+ pruned_tokens += count_bpe_tokens(pruned_code)
1540
+ sampled += 1
1541
+ except OSError:
1542
+ pass
1543
+ if raw_tokens > 0:
1544
+ savings_pct = max(0.0, (1.0 - pruned_tokens / raw_tokens) * 100.0)
1545
+ except Exception:
1546
+ pass
1547
+
1548
+ stats = {
1549
+ "version": version,
1550
+ "tools_count": tools_count,
1551
+ "total_files": total_files,
1552
+ "raw_tokens": raw_tokens,
1553
+ "pruned_tokens": pruned_tokens,
1554
+ "savings_pct": round(savings_pct, 1),
1555
+ "token_savings": f"{round(savings_pct, 1)}%",
1556
+ "security": "100% Zero-Leak Guard",
1557
+ "superdesign": "Enabled (5 Orchestrator Tools)",
1558
+ "active_agents": 5,
1559
+ }
1560
+ _DASHBOARD_STATS_CACHE["ts"] = now
1561
+ _DASHBOARD_STATS_CACHE["data"] = stats
1562
+ return stats
1563
+
1564
+
1320
1565
  class DashboardRequestHandler(http.server.BaseHTTPRequestHandler):
1321
1566
  """Handles static UI and JSON-RPC API endpoints for T-Zero Dashboard."""
1322
1567
 
@@ -1324,6 +1569,22 @@ class DashboardRequestHandler(http.server.BaseHTTPRequestHandler):
1324
1569
  # Silence default HTTP server console logging to avoid noise
1325
1570
  pass
1326
1571
 
1572
+ def _read_json_body(self) -> Dict[str, Any]:
1573
+ """Reads and parses a JSON object request body safely."""
1574
+ content_length = int(self.headers.get("Content-Length", 0) or 0)
1575
+ body = self.rfile.read(content_length).decode("utf-8", errors="replace")
1576
+ if not body.strip():
1577
+ return {}
1578
+ parsed = json.loads(body)
1579
+ return parsed if isinstance(parsed, dict) else {}
1580
+
1581
+ def _send_json(self, payload: Dict[str, Any], status: int = 200) -> None:
1582
+ """Writes a UTF-8 JSON response with standard headers."""
1583
+ self.send_response(status)
1584
+ self.send_header("Content-Type", "application/json")
1585
+ self.end_headers()
1586
+ self.wfile.write(json.dumps(payload, ensure_ascii=False).encode("utf-8"))
1587
+
1327
1588
  def do_GET(self):
1328
1589
  parsed = urllib.parse.urlparse(self.path)
1329
1590
  if parsed.path in ("/", "/index.html"):
@@ -1335,14 +1596,7 @@ class DashboardRequestHandler(http.server.BaseHTTPRequestHandler):
1335
1596
  self.send_response(200)
1336
1597
  self.send_header("Content-Type", "application/json")
1337
1598
  self.end_headers()
1338
- stats = {
1339
- "version": "10.0.0",
1340
- "tools_count": 49,
1341
- "token_savings": "94.9%",
1342
- "security": "100% Zero-Leak Guard",
1343
- "superdesign": "Enabled (5 Orchestrator Tools)",
1344
- "active_agents": 5
1345
- }
1599
+ stats = compute_live_dashboard_stats(".")
1346
1600
  self.wfile.write(json.dumps(stats).encode("utf-8"))
1347
1601
  elif parsed.path == "/superdesign/gallery.html":
1348
1602
  # Serve Superdesign gallery if available
@@ -1350,7 +1604,7 @@ class DashboardRequestHandler(http.server.BaseHTTPRequestHandler):
1350
1604
  if not os.path.exists(gallery_path):
1351
1605
  # Auto-generate gallery if missing
1352
1606
  try:
1353
- import tzero_superdesign
1607
+ from tzero import tzero_superdesign
1354
1608
  tzero_superdesign.superdesign_gallery(".")
1355
1609
  except Exception:
1356
1610
  pass
@@ -1364,6 +1618,59 @@ class DashboardRequestHandler(http.server.BaseHTTPRequestHandler):
1364
1618
  else:
1365
1619
  self.send_response(404)
1366
1620
  self.end_headers()
1621
+ elif parsed.path == "/api/blackboard":
1622
+ try:
1623
+ from tzero.tzero_blackboard import get_shared_blackboard
1624
+ bb = get_shared_blackboard(".")
1625
+ resp = {"success": True, "markdown": bb.export_status_markdown()}
1626
+ except Exception as e:
1627
+ resp = {"success": False, "error": str(e)}
1628
+
1629
+ self.send_response(200)
1630
+ self.send_header("Content-Type", "application/json")
1631
+ self.end_headers()
1632
+ self.wfile.write(json.dumps(resp, ensure_ascii=False).encode("utf-8"))
1633
+ elif parsed.path == "/api/federation/peers":
1634
+ try:
1635
+ from tzero.tzero_federation import FederationSyncEngine
1636
+ resp = {"success": True, "peers": FederationSyncEngine.list_peers(".")}
1637
+ except Exception as e:
1638
+ resp = {"success": False, "error": str(e)}
1639
+ self._send_json(resp)
1640
+ elif parsed.path == "/api/hooks/preview":
1641
+ try:
1642
+ from tzero.tzero_hooks import build_claude_cursor_hook_config
1643
+ resp = {"success": True, "config": build_claude_cursor_hook_config()}
1644
+ except Exception as e:
1645
+ resp = {"success": False, "error": str(e)}
1646
+ self._send_json(resp)
1647
+ elif parsed.path == "/api/cost/cockpit":
1648
+ try:
1649
+ from tzero.tzero_cost import TokenCostCalculator
1650
+ report = TokenCostCalculator.calculate_cost(".")
1651
+ resp = {
1652
+ "success": True,
1653
+ "workspace_dir": report.workspace_dir,
1654
+ "total_files": report.total_files,
1655
+ "raw_tokens": report.raw_tokens,
1656
+ "tzero_pruned_tokens": report.tzero_pruned_tokens,
1657
+ "tokens_saved": report.tokens_saved,
1658
+ "reduction_pct": report.reduction_pct,
1659
+ "comparisons": [
1660
+ {
1661
+ "model": c.model_name,
1662
+ "rate_per_m": c.price_per_million,
1663
+ "raw_cost": round(c.raw_cost_per_query, 4),
1664
+ "tzero_cost": round(c.tzero_cost_per_query, 4),
1665
+ "savings_per_query": round(c.savings_per_query, 4),
1666
+ "monthly_team_savings": round(c.monthly_team_savings, 2),
1667
+ }
1668
+ for c in report.comparisons
1669
+ ],
1670
+ }
1671
+ except Exception as e:
1672
+ resp = {"success": False, "error": str(e)}
1673
+ self._send_json(resp)
1367
1674
  else:
1368
1675
  self.send_response(404)
1369
1676
  self.end_headers()
@@ -1404,7 +1711,7 @@ class DashboardRequestHandler(http.server.BaseHTTPRequestHandler):
1404
1711
  payload = json.loads(body)
1405
1712
  design_type = payload.get("design_type", "component")
1406
1713
  prompt = payload.get("prompt", "")
1407
- import tzero_superdesign
1714
+ from tzero import tzero_superdesign
1408
1715
  res = tzero_superdesign.superdesign_generate(prompt=prompt, design_type=design_type, workspace_path=".")
1409
1716
  resp = {"success": True, "data": res}
1410
1717
  except Exception as e:
@@ -1414,6 +1721,211 @@ class DashboardRequestHandler(http.server.BaseHTTPRequestHandler):
1414
1721
  self.send_header("Content-Type", "application/json")
1415
1722
  self.end_headers()
1416
1723
  self.wfile.write(json.dumps(resp, ensure_ascii=False).encode("utf-8"))
1724
+ elif parsed.path == "/api/bridge/reverse":
1725
+ content_length = int(self.headers.get("Content-Length", 0))
1726
+ body = self.rfile.read(content_length).decode("utf-8")
1727
+ try:
1728
+ payload = json.loads(body)
1729
+ src_code = payload.get("code", "")
1730
+ src_lang = payload.get("lang", "ts")
1731
+ flavor = payload.get("flavor", "dataclass")
1732
+ from tzero.tzero_bridge import PolyglotTypeBridge
1733
+ py_out = PolyglotTypeBridge.reverse_transpile(src_code, source_lang=src_lang, model_flavor=flavor)
1734
+ resp = {"success": True, "python_code": py_out}
1735
+ except Exception as e:
1736
+ resp = {"success": False, "error": str(e)}
1737
+
1738
+ self.send_response(200)
1739
+ self.send_header("Content-Type", "application/json")
1740
+ self.end_headers()
1741
+ self.wfile.write(json.dumps(resp, ensure_ascii=False).encode("utf-8"))
1742
+
1743
+ elif parsed.path == "/api/merge/heal":
1744
+ content_length = int(self.headers.get("Content-Length", 0))
1745
+ body = self.rfile.read(content_length).decode("utf-8")
1746
+ try:
1747
+ payload = json.loads(body)
1748
+ code = payload.get("code", "")
1749
+ from tzero.tzero_semantic_merge import ASTSemanticMerger
1750
+ res = ASTSemanticMerger.heal_conflict_file(code)
1751
+ resp = {
1752
+ "success": res.success,
1753
+ "merged_code": res.merged_code,
1754
+ "auto_resolved_conflicts": res.auto_resolved_conflicts,
1755
+ "unresolved_conflicts": res.unresolved_conflicts,
1756
+ "details": res.details
1757
+ }
1758
+ except Exception as e:
1759
+ resp = {"success": False, "error": str(e)}
1760
+
1761
+ self.send_response(200)
1762
+ self.send_header("Content-Type", "application/json")
1763
+ self.end_headers()
1764
+ self.wfile.write(json.dumps(resp, ensure_ascii=False).encode("utf-8"))
1765
+
1766
+ elif parsed.path == "/api/mutation/test":
1767
+ content_length = int(self.headers.get("Content-Length", 0))
1768
+ body = self.rfile.read(content_length).decode("utf-8")
1769
+ try:
1770
+ payload = json.loads(body)
1771
+ tgt_file = payload.get("file", "tzero_arch_test.py")
1772
+ max_m = int(payload.get("max_mutants", 5))
1773
+ from tzero.tzero_mutation import ASTMutationEngine
1774
+ rep = ASTMutationEngine.run_mutation_analysis(target_file=tgt_file, max_mutants=max_m)
1775
+ resp = {
1776
+ "success": True,
1777
+ "score": rep.mutation_score,
1778
+ "killed": rep.killed,
1779
+ "survived": rep.survived,
1780
+ "total": rep.total_mutants,
1781
+ "markdown": ASTMutationEngine.format_markdown_report(rep)
1782
+ }
1783
+ except Exception as e:
1784
+ resp = {"success": False, "error": str(e)}
1785
+
1786
+ self.send_response(200)
1787
+ self.send_header("Content-Type", "application/json")
1788
+ self.end_headers()
1789
+ self.wfile.write(json.dumps(resp, ensure_ascii=False).encode("utf-8"))
1790
+ elif parsed.path == "/api/contracts/compare":
1791
+ content_length = int(self.headers.get("Content-Length", 0))
1792
+ body = self.rfile.read(content_length).decode("utf-8")
1793
+ try:
1794
+ payload = json.loads(body)
1795
+ old_code = payload.get("old_code", "")
1796
+ new_code = payload.get("new_code", "")
1797
+ file_path = payload.get("file_path", "module.py")
1798
+ from tzero.tzero_contracts import ASTContractComparator
1799
+ rep = ASTContractComparator.compare_code(old_code, new_code, file_path=file_path)
1800
+ resp = {
1801
+ "success": True,
1802
+ "semver_bump": rep.semver_bump.value,
1803
+ "is_breaking": rep.is_breaking,
1804
+ "breaking_count": len(rep.breaking_changes),
1805
+ "additions_count": len(rep.non_breaking_additions),
1806
+ "modifications_count": len(rep.modifications),
1807
+ "markdown": ASTContractComparator.format_markdown_report([rep])
1808
+ }
1809
+ except Exception as e:
1810
+ resp = {"success": False, "error": str(e)}
1811
+
1812
+ self.send_response(200)
1813
+ self.send_header("Content-Type", "application/json")
1814
+ self.end_headers()
1815
+ self.wfile.write(json.dumps(resp, ensure_ascii=False).encode("utf-8"))
1816
+ elif parsed.path == "/api/debt/analyze":
1817
+ content_length = int(self.headers.get("Content-Length", 0))
1818
+ body = self.rfile.read(content_length).decode("utf-8")
1819
+ try:
1820
+ payload = json.loads(body) if body.strip() else {}
1821
+ target_p = payload.get("path", ".")
1822
+ from tzero.tzero_debt import CodeHealthAnalyzer
1823
+ if os.path.isfile(target_p):
1824
+ rep = CodeHealthAnalyzer.analyze_file(target_p)
1825
+ resp = {
1826
+ "success": True,
1827
+ "type": "file",
1828
+ "maintainability_index": rep.maintainability_index,
1829
+ "rating": rep.rating,
1830
+ "debt_hours": rep.debt_hours,
1831
+ "debt_cost_usd": rep.debt_cost_usd,
1832
+ "todo_count": rep.todo_count
1833
+ }
1834
+ else:
1835
+ rep = CodeHealthAnalyzer.analyze_workspace(target_p)
1836
+ resp = {
1837
+ "success": True,
1838
+ "type": "workspace",
1839
+ "average_maintainability_index": rep.average_maintainability_index,
1840
+ "rating": rep.overall_rating,
1841
+ "total_debt_hours": rep.total_debt_hours,
1842
+ "total_debt_cost_usd": rep.total_debt_cost_usd,
1843
+ "total_todo_markers": rep.total_todo_markers,
1844
+ "markdown": CodeHealthAnalyzer.format_markdown_report(rep)
1845
+ }
1846
+ except Exception as e:
1847
+ resp = {"success": False, "error": str(e)}
1848
+
1849
+ self.send_response(200)
1850
+ self.send_header("Content-Type", "application/json")
1851
+ self.end_headers()
1852
+ self.wfile.write(json.dumps(resp, ensure_ascii=False).encode("utf-8"))
1853
+ elif parsed.path == "/api/budget/optimize":
1854
+ content_length = int(self.headers.get("Content-Length", 0))
1855
+ body = self.rfile.read(content_length).decode("utf-8")
1856
+ try:
1857
+ payload = json.loads(body) if body.strip() else {}
1858
+ target_p = payload.get("path", ".")
1859
+ target_tokens = payload.get("target_tokens")
1860
+ model_name = payload.get("model", "claude-3-7")
1861
+ from tzero.tzero_budget import ASTTokenBudgetOptimizer
1862
+ cert = ASTTokenBudgetOptimizer.optimize_budget(target_p, target_tokens=target_tokens, model_name=model_name)
1863
+ resp = {
1864
+ "success": True,
1865
+ "target_model": cert.target_model,
1866
+ "budget_limit_tokens": cert.budget_limit_tokens,
1867
+ "raw_tokens": cert.raw_tokens,
1868
+ "compressed_tokens": cert.compressed_tokens,
1869
+ "savings_percentage": cert.savings_percentage,
1870
+ "tier_applied": cert.tier_applied,
1871
+ "fits_budget": cert.fits_budget,
1872
+ "sha256_checksum": cert.sha256_checksum,
1873
+ "markdown": ASTTokenBudgetOptimizer.format_markdown_certificate(cert)
1874
+ }
1875
+ except Exception as e:
1876
+ resp = {"success": False, "error": str(e)}
1877
+
1878
+ self.send_response(200)
1879
+ self.send_header("Content-Type", "application/json")
1880
+ self.end_headers()
1881
+ self.wfile.write(json.dumps(resp, ensure_ascii=False).encode("utf-8"))
1882
+ elif parsed.path == "/api/golden/verify":
1883
+ content_length = int(self.headers.get("Content-Length", 0))
1884
+ body = self.rfile.read(content_length).decode("utf-8")
1885
+ try:
1886
+ payload = json.loads(body) if body.strip() else {}
1887
+ target_p = payload.get("path", ".")
1888
+ from tzero.tzero_golden import ASTGoldenRegressionEngine
1889
+ rep = ASTGoldenRegressionEngine.verify_against_golden(target_p)
1890
+ resp = {
1891
+ "success": rep.get("success", False),
1892
+ "clean": rep.get("clean", False),
1893
+ "removed_count": len(rep.get("removed_symbols", [])),
1894
+ "modified_count": len(rep.get("modified_signatures", [])),
1895
+ "added_count": len(rep.get("added_symbols", [])),
1896
+ "markdown": ASTGoldenRegressionEngine.format_markdown_report(rep)
1897
+ }
1898
+ except Exception as e:
1899
+ resp = {"success": False, "error": str(e)}
1900
+
1901
+ self._send_json(resp)
1902
+ elif parsed.path == "/api/federation/impact":
1903
+ try:
1904
+ payload = self._read_json_body()
1905
+ symbol = str(payload.get("symbol") or "").strip()
1906
+ scip_path = str(payload.get("scip_path") or "").strip() or None
1907
+ if not symbol:
1908
+ resp = {"success": False, "error": "symbol required"}
1909
+ else:
1910
+ from tzero.tzero_federation import FederationSyncEngine
1911
+ res = FederationSyncEngine.analyze_cross_repo_impact(".", symbol, scip_path=scip_path)
1912
+ resp = {"success": True, **res}
1913
+ except Exception as e:
1914
+ resp = {"success": False, "error": str(e)}
1915
+ self._send_json(resp)
1916
+ elif parsed.path == "/api/scip/summary":
1917
+ try:
1918
+ payload = self._read_json_body()
1919
+ scip_path = str(payload.get("path") or "").strip()
1920
+ if not scip_path or not os.path.isfile(scip_path):
1921
+ resp = {"success": False, "error": f"SCIP/LSIF index file not found: {scip_path or '(empty)'}"}
1922
+ else:
1923
+ from tzero.tzero_scip import ScipIndexImporter
1924
+ graph = ScipIndexImporter.load(scip_path)
1925
+ resp = {"success": True, **graph.export_tzero_graph()}
1926
+ except Exception as e:
1927
+ resp = {"success": False, "error": str(e)}
1928
+ self._send_json(resp)
1417
1929
  else:
1418
1930
  self.send_response(404)
1419
1931
  self.end_headers()