Task configuration:
{"task_id": "02", "task_name": "word_replace_in_file", "description": "\u5728vscode\u5de5\u4f5c\u533a\u6587\u4ef6\u4e2d\u6253\u5f00\u6587\u4ef6\u5e76\u4e14\u8fdb\u884c\u5185\u5bb9\u66ff\u6362", "application_info": {"name": "vscode", "executable_path": "/usr/share/code/code", "args": ["--no-sandbox", "--user-data-dir=/root/vscode_user_data_dir/"]}, "task_parameters": {"file_name": "bubble_sort.cpp", "origin_name": "swap_check", "expected_name": "swap_flag", "expected_path": "/root/C-Plus-Plus/sorting/bubble_sort.cpp"}, "instruction_template": "\u5728vscode\u5f53\u524d\u7684\u5de5\u4f5c\u533a\u4e2d\u627e\u5230\u5e76\u6253\u5f00\u540d\u4e3a ${file_name} \u7684\u6587\u4ef6, \u5c06\u6587\u4ef6\u4e2d\u540d\u4e3a ${origin_name} \u7684\u5185\u5bb9\u66ff\u6362\u4e3a ${expected_name}, \u8bf7\u6ce8\u610f\u6587\u4ef6\u7684\u4fdd\u5b58", "evaluation_setup": {"scripts": [{"role": "hook", "path": "hooker.js"}, {"role": "handler", "path": "handler.py"}], "timeout": 120, "evaluator_type": "IpcInjector", "evaluate_on_completion": true}, "total_key_steps": 2, "preconditions": {"vscode_running": true}, "events": {"open_file": {"description": "\u6253\u5f00\u6587\u4ef6", "is_key_step": true, "key_step_index": 1, "key_step_name": "\u5728vscode\u4e2d\u6253\u5f00\u6587\u4ef6"}, "evaluate_on_completion": {"description": "\u4efb\u52a1\u7ed3\u675f\u65f6\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9", "is_key_step": true, "key_step_index": 2, "key_step_name": "\u4efb\u52a1\u7ed3\u675f\u5224\u65ad\u6587\u4ef6\u5185\u5bb9\u662f\u5426\u6b63\u786e"}, "read_origin_content": {"description": "\u5728\u4efb\u52a1\u5f00\u59cb\u65f6\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9", "is_key_step": false}}, "mcp_servers": [{"command": "mcp-proxy", "args": ["http://127.0.0.1:6010/sse"]}], "context_data": [{"from": "tests/context_data/vscode/user_data", "to": "/root/vscode_user_data_dir"}, {"from": "tests/context_data/vscode/extensions", "to": "/root/.vscode/"}, {"from": "tests/context_data/vscode/C-Plus-Plus", "to": "/root/C-Plus-Plus"}]}

Hook script:
/**
 * Reads the content of a file at the specified path.
 * @param {string} path - The file path to read.
 * @returns {string|undefined} The file content or undefined if an error occurs.
 */
async function readFile(path) {
    try {
        // Check if the file exists
        if (!fs.existsSync(path)) {
            return undefined;
        }

        // Read the content of the file
        const fileContent = fs.readFileSync(path, 'utf8');
        return fileContent;
    } catch (error) {
        return undefined;
    }
}

readFile("/root/C-Plus-Plus/sorting/bubble_sort.cpp").then(origin_file_content => {
    socket.emit("send", {
        event_type: "read_origin_content",
        message: "初始文件内容",
        content: origin_file_content
    });
});

// Listen for 'evaluate' event
socket.on('evaluate', async () => {
    socket.emit("send", {
        event_type: "evaluate_on_completion",
        message: "任务结束时读取文件内容"
    });
});

// Register a listener for when a text document is opened
vscode.workspace.onDidOpenTextDocument(async (document) => {
    const filePath = document.uri.fsPath;
    socket.emit("send", {
        event_type: "open_file",
        message: "打开文件",
        path: filePath,
        scheme: document.uri.scheme
    });
});

Evaluation handler:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from typing import Dict, Any, Optional, Callable, List

file_path = None
origin_file_content = None

def message_handler(message: Dict[str, Any], logger, task_parameter: Dict[str, Any]) -> Optional[List[Dict[str, Any]]]:    
    global origin_file_content, file_path
    event_type = message.get('event_type')
    logger.info(message)
    expected_path = task_parameter.get("expected_path", "/root/C-Plus-Plus/sorting/bubble_sort.cpp")
    if event_type == "open_file":
        file_path = message.get("path")
        if message.get("scheme") == "git":
            file_path = file_path[:-4]
        if file_path == expected_path:
            return [
                {"status": "key_step", "index": 1}
            ]
    elif event_type == "read_origin_content":
        origin_file_content = message.get("content")
    elif event_type == "evaluate_on_completion":
        if origin_file_content:
            with open(expected_path, "r", encoding="UTF8") as f:
                changed_file_content = f.read()
            origin_name = task_parameter.get("origin_name", "swap_check")
            expected_name = task_parameter.get("expected_name", "swap_flag")
            expected_content = "".join(origin_file_content.replace(origin_name, expected_name).split())
            now_content = "".join(changed_file_content.split())
            logger.info(f"{expected_content}")
            logger.info(f"{now_content}")
            if expected_content == now_content:
                return [
                    {"status": "key_step", "index": 2},
                    {"status": "success", "reason": f"文件成功修改"}
                ]
            else:
                return [{"status": "error", "type": "evaluate_on_completion", "message": "任务没有完成"}]
        else:
            return [{"status": "error", "type": "evaluate_on_completion", "message": "任务没有完成"}]
    return None