diff --git a/.gemini/settings.json b/.gemini/settings.json index afd7f27..e505627 100644 --- a/.gemini/settings.json +++ b/.gemini/settings.json @@ -7,7 +7,7 @@ "*" ], "discoveryCommand": "powershell.exe -NoProfile -Command \"Get-Content .gemini/tools.json -Raw\"", - "callCommand": "python scripts/tool_call.py" + "callCommand": "scripts\\tool_call.exe" }, "hooks": { "BeforeTool": [ diff --git a/.gemini/tools.json b/.gemini/tools.json index ec68e20..0a1b709 100644 Binary files a/.gemini/tools.json and b/.gemini/tools.json differ diff --git a/get_file_summary.bat b/get_file_summary.bat new file mode 100644 index 0000000..d27226f --- /dev/null +++ b/get_file_summary.bat @@ -0,0 +1,2 @@ +@echo off +uv run python scripts/tool_call.py get_file_summary diff --git a/mcp_client.py b/mcp_client.py index 6ae74ad..c42356c 100644 --- a/mcp_client.py +++ b/mcp_client.py @@ -398,7 +398,7 @@ def fetch_url(url: str) -> str: if not url.startswith("http"): url = "https://" + url - req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'}) + req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'}) try: with urllib.request.urlopen(req, timeout=10) as resp: html = resp.read().decode('utf-8', errors='ignore') @@ -406,6 +406,10 @@ def fetch_url(url: str) -> str: parser.feed(html) full_text = " ".join(parser.text) full_text = _re.sub(r'\s+', ' ', full_text) + + if not full_text.strip(): + return f"FETCH OK: No readable text extracted from {url}. The page might be empty, JavaScript-heavy, or blocked." + # Limit to 40k chars to prevent context blowup if len(full_text) > 40000: return full_text[:40000] + "\n... (content truncated)" @@ -417,7 +421,7 @@ def fetch_url(url: str) -> str: def get_ui_performance() -> str: """Returns current UI performance metrics (FPS, Frame Time, CPU, Input Lag).""" if perf_monitor_callback is None: - return "ERROR: Performance monitor callback not registered." + return "INFO: UI Performance monitor is not available (headless/CLI mode). This tool is only functional when the Manual Slop GUI is running." try: metrics = perf_monitor_callback() # Clean up the dict string for the AI diff --git a/scripts/tool_call.bat b/scripts/tool_call.bat new file mode 100644 index 0000000..6b3c46f --- /dev/null +++ b/scripts/tool_call.bat @@ -0,0 +1,2 @@ +@echo off +uv run python "%~dp0tool_call.py" %* diff --git a/scripts/tool_call.cmd b/scripts/tool_call.cmd new file mode 100644 index 0000000..734cc8e --- /dev/null +++ b/scripts/tool_call.cmd @@ -0,0 +1,2 @@ +@echo off +uv run python scripts\tool_call.py %* diff --git a/scripts/tool_call.cpp b/scripts/tool_call.cpp new file mode 100644 index 0000000..36c1d02 --- /dev/null +++ b/scripts/tool_call.cpp @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) { + if (argc < 2) { + std::cerr << "No tool name provided" << std::endl; + return 1; + } + + std::string tool_name = argv[1]; + + // Construct the command: uv run python scripts/tool_call.py + std::string command = "uv run python scripts/tool_call.py " + tool_name; + + // Use CreateProcess to run the command and handle pipes + STARTUPINFOA si; + PROCESS_INFORMATION pi; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + si.dwFlags = STARTF_USESTDHANDLES; + si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); + si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); + si.hStdError = GetStdHandle(STD_ERROR_HANDLE); + ZeroMemory(&pi, sizeof(pi)); + + // Create the process + if (!CreateProcessA( + NULL, + (char*)command.c_str(), + NULL, + NULL, + TRUE, + 0, + NULL, + NULL, + &si, + &pi + )) { + std::cerr << "CreateProcess failed (" << GetLastError() << ")" << std::endl; + return 1; + } + + // Wait for the process to finish + WaitForSingleObject(pi.hProcess, INFINITE); + + DWORD exit_code; + GetExitCodeProcess(pi.hProcess, &exit_code); + + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + + return exit_code; +} diff --git a/scripts/tool_call.exe b/scripts/tool_call.exe new file mode 100644 index 0000000..c5cbbcb Binary files /dev/null and b/scripts/tool_call.exe differ diff --git a/scripts/tool_call.ps1 b/scripts/tool_call.ps1 new file mode 100644 index 0000000..77d464a --- /dev/null +++ b/scripts/tool_call.ps1 @@ -0,0 +1,3 @@ +$toolName = $args[0] +$inputData = $input | Out-String +$inputData | uv run python "$PSScriptRoot/tool_call.py" $toolName diff --git a/scripts/tool_call.py b/scripts/tool_call.py index 6f155bd..5263131 100644 --- a/scripts/tool_call.py +++ b/scripts/tool_call.py @@ -1,6 +1,11 @@ import sys import json import os +import io + +# Force UTF-8 for stdout/stderr to avoid encoding issues on Windows +sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') +sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8') # Add project root to sys.path sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) diff --git a/scripts/tool_discovery.py b/scripts/tool_discovery.py index 188d183..1d3c09f 100644 --- a/scripts/tool_discovery.py +++ b/scripts/tool_discovery.py @@ -37,6 +37,11 @@ def main(): } }) + # Rename 'parameters' to 'parametersJsonSchema' for Gemini CLI + for spec in specs: + if "parameters" in spec: + spec["parametersJsonSchema"] = spec.pop("parameters") + # Output as JSON array of FunctionDeclarations print(json.dumps(specs, indent=2))