Forked from soumyajit7038/python-tools
Project Files
src / utils / toolRegistry.ts
export interface ToolDefinition {
name: string;
description: string;
}
export const TOOL_DEFINITIONS: ToolDefinition[] = [
{
name: "run_python",
description: "Runs short Python code locally and returns stdout, stderr, exit code, timeout status, and selected interpreter. This is not a secure sandbox and is intended only for trusted local use.",
},
{
name: "run_python_file",
description: "Runs an existing Python .py file in the background and returns stdout, stderr, exit code, timeout status, and selected interpreter. This is not a secure sandbox and is intended only for trusted local use.",
},
{
name: "run_python_interactive",
description: "Saves provided Python code to a temporary .py file, opens a visible terminal window, runs it with the selected Python interpreter, keeps the terminal open, and returns immediately. This is not a secure sandbox and is intended only for trusted local use.",
},
{
name: "run_python_file_interactive",
description: "Opens a visible terminal window, runs an existing workspace Python .py file with the selected Python interpreter and optional args, keeps the terminal open, and returns immediately. This is not a secure sandbox and is intended only for trusted local use.",
},
{
name: "install_module",
description: "Installs Python packages into the selected Python interpreter using pip install.",
},
{
name: "uninstall_module",
description: "Uninstalls Python packages from the selected Python interpreter using non-interactive pip uninstall -y.",
},
{
name: "switch_python_version",
description: "Lists or switches the Python interpreter used by Python execution and package tools.",
},
{
name: "save_python_file",
description: "Creates or overwrites a Python .py file inside the configured workspace root.",
},
{
name: "read_python_file",
description: "Reads a Python .py file from the configured workspace root, optionally with line ranges and line numbers.",
},
{
name: "list_directory",
description: "Lists files and folders inside the configured workspace root with optional recursion and filtering.",
},
{
name: "edit_python_file",
description: "Edits a Python .py file by exact string replacement with optional backup creation.",
},
{
name: "edit_python_file_by_line",
description: "Edits a Python .py file by line number using replace, insert, or delete operations with optional backup creation.",
},
{
name: "check_for_bugs",
description: "Checks provided Python source for syntax and basic compile issues using py_compile without running the code normally.",
},
{
name: "check_for_bugs_in_file",
description: "Checks an existing Python .py file for syntax and basic compile issues using py_compile without running the file normally.",
},
{
name: "list_tools",
description: "Lists the plugin's available tools and descriptions.",
},
];
export function getToolDefinition(toolName: string): ToolDefinition {
const definition = TOOL_DEFINITIONS.find((tool) => tool.name === toolName);
if (definition === undefined) {
throw new Error(`Tool definition not found: ${toolName}`);
}
return definition;
}
export function getToolList(includeDetails: boolean): string[] | ToolDefinition[] {
if (!includeDetails) {
return TOOL_DEFINITIONS.map((tool) => tool.name);
}
return TOOL_DEFINITIONS.map((tool) => ({ ...tool }));
}