feat: core agent tools (fs, search, shell)
This commit is contained in:
69
src/components/ToolTester.tsx
Normal file
69
src/components/ToolTester.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
import { useState } from "react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
export function ToolTester() {
|
||||
const [output, setOutput] = useState<string>("Ready.");
|
||||
|
||||
const runCommand = async (name: string, args: Record<string, unknown>) => {
|
||||
setOutput(`Running ${name}...`);
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await invoke(name, args);
|
||||
setOutput(JSON.stringify(res, null, 2));
|
||||
} catch (e) {
|
||||
setOutput(`Error: ${e}`);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{ marginTop: "20px", border: "1px solid #ccc", padding: "10px" }}
|
||||
>
|
||||
<h3>Tool Tester</h3>
|
||||
<div style={{ display: "flex", gap: "10px", flexWrap: "wrap" }}>
|
||||
<button onClick={() => runCommand("list_directory", { path: "." })}>
|
||||
List Root
|
||||
</button>
|
||||
<button
|
||||
onClick={() =>
|
||||
runCommand("read_file", { path: ".living_spec/README.md" })
|
||||
}
|
||||
>
|
||||
Read Spec
|
||||
</button>
|
||||
<button onClick={() => runCommand("search_files", { query: "Story" })}>
|
||||
Search "Story"
|
||||
</button>
|
||||
<button
|
||||
onClick={() =>
|
||||
runCommand("exec_shell", { command: "ls", args: ["-F"] })
|
||||
}
|
||||
>
|
||||
Shell: ls -F
|
||||
</button>
|
||||
<button
|
||||
onClick={() =>
|
||||
runCommand("exec_shell", { command: "git", args: ["status"] })
|
||||
}
|
||||
>
|
||||
Shell: git status
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<pre
|
||||
style={{
|
||||
marginTop: "10px",
|
||||
background: "#333",
|
||||
color: "#fff",
|
||||
padding: "10px",
|
||||
borderRadius: "5px",
|
||||
overflowX: "auto",
|
||||
textAlign: "left",
|
||||
fontSize: "12px",
|
||||
}}
|
||||
>
|
||||
{output}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user