This commit is contained in:
2026-02-27 22:10:46 -05:00
parent fcd60c908b
commit a84ea40d16
11 changed files with 82 additions and 3 deletions

View File

@@ -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": [

Binary file not shown.

2
get_file_summary.bat Normal file
View File

@@ -0,0 +1,2 @@
@echo off
uv run python scripts/tool_call.py get_file_summary

View File

@@ -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

2
scripts/tool_call.bat Normal file
View File

@@ -0,0 +1,2 @@
@echo off
uv run python "%~dp0tool_call.py" %*

2
scripts/tool_call.cmd Normal file
View File

@@ -0,0 +1,2 @@
@echo off
uv run python scripts\tool_call.py %*

56
scripts/tool_call.cpp Normal file
View File

@@ -0,0 +1,56 @@
#include <iostream>
#include <string>
#include <vector>
#include <windows.h>
#include <process.h>
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 <tool_name>
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;
}

BIN
scripts/tool_call.exe Normal file

Binary file not shown.

3
scripts/tool_call.ps1 Normal file
View File

@@ -0,0 +1,3 @@
$toolName = $args[0]
$inputData = $input | Out-String
$inputData | uv run python "$PSScriptRoot/tool_call.py" $toolName

View File

@@ -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__), "..")))

View File

@@ -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))