Phillnet-2 / Tools /wrench_runtime_validator.py
ayjays132's picture
Upload 478 files
101858b verified
import os
import subprocess
import json
from pathlib import Path
def validate_wrench_suite():
print("=== GLOBAL WRENCH RUNTIME VALIDATOR ===")
# Dynamic path detection for project root
tools_dir = Path(__file__).resolve().parent
wrench_dir = tools_dir / "Wrench"
if not wrench_dir.exists():
print(f"Error: Wrench directory not found at {wrench_dir}")
return
tools = [f for f in os.listdir(wrench_dir) if f.endswith(".ts") and not f.endswith(".test.ts") and f not in ["tools.ts", "tool-registry.ts", "tool-names.ts", "tool-error.ts", "constants.ts", "modifiable-tool.ts", "mcp-tool.ts"]]
results = {}
for tool_file in tools:
tool_name = tool_file.replace(".ts", "")
print(f"Checking {tool_name}...", end=" ", flush=True)
# Test bootstrap by trying to import it in a small TS harness
# cmd = f"npx tsx -e \"import './Wrench/{tool_file}'; console.log('LOAD_OK')\"" # Cross-platform tweak
cmd = f"npx tsx -e \"import './Wrench/{tool_file}'; console.log('LOAD_OK')\""
try:
res = subprocess.run(cmd, cwd=str(tools_dir), capture_output=True, text=True, timeout=20, shell=True)
if "LOAD_OK" in res.stdout:
print("PASSED")
results[tool_name] = "PASSED"
else:
print("FAILED")
# print(res.stderr)
results[tool_name] = "FAILED: " + res.stderr.split("\n")[0]
except Exception as e:
print(f"ERROR: {str(e)}")
results[tool_name] = "ERROR"
print("\n" + "="*40)
print("SUMMARY")
print("="*40)
for t, r in results.items():
print(f"{t:20}: {r}")
if __name__ == "__main__":
validate_wrench_suite()