function __ttStart(files,entry,prefix,initial,enabled)
    local hooks=__tt_hooks
    __tt_hooks=nil
    local function snapshot(v,depth,seen)
        local kind=type(v)
        if kind=="string" or kind=="number" or kind=="boolean" then return v end
        if kind~="table" then return kind end
        if depth>=4 or seen[v] then return "[…]" end
        local copy={};seen[v]=true;local count=0
        for k,value in next,v do
            if type(k)=="string" or type(k)=="number" then copy[tostring(k)]=snapshot(value,depth+1,seen) end
            count=count+1;if count>=100 then break end
        end
        seen[v]=nil;return copy
    end
    if enabled then
        __native("dbg.init",{prefix,initial})
        hooks.sethook(function(_,line)
            local first=hooks.getinfo(2,"S")
            if not first or not files[first.source:sub(2)] then return end
            local levels={}
            for i=2,256 do
                local info=hooks.getinfo(i,"Slnf")
                if not info then break end
                local id=info.source:sub(2)
                if files[id] then levels[#levels+1]={i=i,info=info,file=id} end
            end
            local reason=__native("dbg.tick",{levels[1].file,line,#levels})
            if reason=="" then return end
            local frames={}
            for _,frame in ipairs(levels) do
                local vars={}
                for j=1,200 do
                    local k,v=hooks.getupvalue(frame.info.func,j)
                    if not k then break end
                    if k~="_ENV" then vars[k]=snapshot(v,0,{}) end
                end
                for j=1,200 do
                    local k,v=hooks.getlocal(frame.i,j)
                    if not k then break end
                    if k:sub(1,1)~="(" then vars[k]=snapshot(v,0,{}) end
                end
                frames[#frames+1]={file=frame.file,line=frame.info.currentline,name=frame.info.name or "<模块>",vars=vars}
            end
            __native("dbg.stopped",{reason,frames})
        end,"l")
    end
    local cache={}
    function require(name)
        local id=name:gsub("^%./",""):gsub("%.lua$",""):gsub("%.","/")..".lua"
        if cache[id]~=nil then return cache[id] end
        local chunk=assert(load(assert(files[id],"找不到脚本模块 "..name),"@"..id,"t",_ENV))
        cache[id]=true;local v=chunk();if v~=nil then cache[id]=v end
        return cache[id]
    end
    local chunk=assert(load(files[entry],"@"..entry,"t",_ENV))
    chunk()
    if enabled then hooks.sethook() end
end