Task configuration:
{"task_id": "25", "task_name": "\u63d2\u4ef6:Enhanced Cloze", "description": "\u4f7f\u7528\u63d2\u4ef6enhanced cloze\u6765\u521b\u5efa\u5361\u7247", "application_info": {"name": "anki", "executable_path": "/home/agent/anki/out/pyenv/bin/python", "args": ["/home/agent/anki/tools/run.py"], "cwd": "/home/agent/anki"}, "task_parameters": {}, "instruction_template": "\u4f7f\u7528enhanced cloze\u63d2\u4ef6\u63d0\u4f9b\u7684\u6a21\u677f\u521b\u5efa\u4e00\u4e2a\u5361\u7247\uff08https://ankiweb.net/shared/info/1990296174\uff09\u3002\u6211\u5df2\u7ecf\u66ff\u4f60\u5b89\u88c5\u597d\u4e86\u3002\u4f60\u9700\u8981\u914d\u7f6e\u4e00\u4e0b\u63d2\u4ef6,\u8bbe\u7f6eshow Hints For Pseudo Clozes\u4e3aFalse\uff0c\u7136\u540e\u6dfb\u52a0\u4e00\u4e2a\u7528\u8fd9\u4e2a\u6a21\u677f\u7684\u5361\u7247\uff0c\u6b63\u9762\u5185\u5bb9\u4e3a\"The quick brown fox jumps over the lazy dog.\",\u5206\u522b\u5bf9brown(c1),fox(c2)\u548cdog(c3)\u6316\u7a7a\u3002\u5bf9lazy\u6316\u7a7a\uff0c\u4f46\u662flazy\u8bbe\u7f6e\u4e3a\u59cb\u7ec8\u663e\u793a\u6a21\u5f0f\u3002\u4e0b\u9762\u6709\u4e00\u6bb5\u8bf4\u660e\uff1aImproved Mechanism of Displaying Clozes.\nTake card1 for example.All c1 clozes (called \"genuine clozes\") will be red.All other clozes (called \"pseudo clozes\" for this card), eg. c2, c3 will be blue.On the front of the card, all clozes (genuine or pseudo) will be shown as their hint (if one exists) or empty.You can show the answer of every cloze (genuine or pseudo) by clicking it.This means you can think about a genuize cloze and check the answer one by one without getting hints from pseudo-clozes and genuine clozes after it.Handy Keyboard And Touchscreen Shortcut You can...uncover genuine clozes one by one using the keyboard shortcut [J] (conifgurable) or by touching the left border of the card.uncover pseudo clozes one by one using the keyboard shortcut [N] (conifgurable) or by touching the right border of the cardtoggle all genuine clozes using the keyboard shortcut [Shift+J] (conifgurable) border.toggle all pseudo clozes using the keyboard shortcut [Shift+N] (conifgurable) border.This makes uncovering clozes super convenient, no matter whether it's on a computer using the keyboard or on a mobile phone.You can edit the shortcut keys in the config (Tools -> Enhanced Cloze -> Config)Auto Scroll To The Relevant ClozeThe card will scroll to the first genuine cloze at the very beginning.When you use shortcut to uncover clozes one by one, if the next cloze is out of view (common situation on mobile phones with small screen), the card will automatically scroll to it. This makes for a super fluent experience of answering cards. The behaviour can be turned off (Tools -> Enhanced Cloze -> Config).Can Be Used In No-Cloze Basic ModeIt is also Ok to go without clozes using this note type. (Note: Creating such notes only works on Anki Desktop, not on mobile!) Just type the question in the Content field and the answer in the Note field. The Note field will be hidden on the front of the card and shown on the back of the card, just like with the Basic note type.Anki won't warn you that no clozes are found.\"Normal\" clozesIf you want a cloze to alway be displayed when it's a pseudo cloze, prepend the answer with a #-sign like this: {{c1::#some text}}.", "evaluation_setup": {"scripts": [{"role": "hook", "path": "hooker.js", "dependency": ["../common/hooker_common.js"]}, {"role": "handler", "path": "handler.py"}], "timeout": 60}, "events": {"add_card": {"description": "\u6dfb\u52a0\u5361\u7247", "is_key_step": true, "key_step_index": 1, "key_step_name": "\u6dfb\u52a0\u5361\u7247"}, "card_info_correct": {"description": "\u5361\u7247\u4fe1\u606f\u6b63\u786e", "is_key_step": false}, "card_format_correct": {"description": "\u5361\u7247\u6570\u636e\u6b63\u786e", "is_key_step": true, "key_step_index": 2, "key_step_name": "\u5361\u7247\u6570\u636e\u6b63\u786e"}, "setting_correct": {"description": "\u63d2\u4ef6\u8bbe\u7f6e\u6b63\u786e", "is_key_step": false}}, "sql_path": "/home/agent/.local/share/Anki2/sam/collection.anki2", "total_key_steps": 2, "mcp_servers": [{"command": "/home/agent/anki-mcp-server/.venv/bin/python", "args": ["/home/agent/anki-mcp-server/run_server.py"]}]}

Hook script:
const TRACE_FUNCTION = [
    "storage_add_note"
]
function initHooks() {
    // iterate function name and addr, init it.
    for (const function_name of TRACE_FUNCTION){
        initHook(function_name, TRACE_MAPS[function_name]);
    }
}
initHooks();
sendLog("info", "add hooks done");

Evaluation handler:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
sys.path.append(os.path.dirname(__file__))
from common import *
import json
import re

def handle_storage_add_note(context: Context,message) -> Status:
    status = Status()
    context.update_database()

    if not context.monitor.is_event_triggered(EventSettingCorrect()) and os.path.exists("/home/agent/.local/share/Anki2/addons21/1990296174/meta.json"):
        print("checking")
        with open("/home/agent/.local/share/Anki2/addons21/1990296174/meta.json") as f:
            config = json.load(f)
            if config["config"]["showHintsForPseudoClozes"] == False:
                status.emit(EventSettingCorrect())
    
    latest : Note = sorted(context.notes,key=lambda x: x.mod,reverse=True)[0]
    if latest.mid == context._ntid:
        status.emit(EventAddCard())

        content = latest.fields[0]
        pattern = r"\{\{c\d+::(.*?)\}\}"

        result = re.sub(pattern, r"\1", content).replace("#","")
        if result == "The quick brown fox jumps over the lazy dog.":
            status.emit(EventCardInfoCorrect())
        
        
        pattern = r"\{\{c\d+::(.*?)\}\}"
        result = re.findall(pattern, content)
        if len(result) == 4 and result[0] == "brown" and result[1] == "fox" and result[2] == "#lazy" and result[3] == "dog":
            status.emit(EventCardFormatCorrect())
    return status
def init(context : Context):
    context.update_database()
    for nt in context.notetypes:
        if "Enhanced Cloze" in nt.name:
            context._ntid = nt.id
    if not hasattr(context,"_ntid"):
        raise "no Enhanced Cloze notetype found. Try install Enhanced Cloze plugin with code(1990296174)."
    context.log("info",f"Enhanced Cloze notetype found with id {context._ntid}")
       

TRACE_HANDLERS = {
    "storage_add_note" : handle_storage_add_note,
}   

dependency_graph = {
    add_card_ : [],
    card_info_correct_ : [add_card_],
    card_format_correct_ : [add_card_],
    setting_correct_ : []
}
finished_list = [
    setting_correct_,card_format_correct_,card_info_correct_
]

bind_handlers(TRACE_HANDLERS,dependency_graph,finished_list,init=init)