lycheedev 1.2.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +49 -0
- package/README.md +45 -0
- package/THIRD_PARTY_NOTICES +812 -0
- package/bin/lycheedev.mjs +56 -0
- package/native/windows-amd64/lycheedev.exe +0 -0
- package/package.json +12 -33
- package/payload/addon/Bridge/CaptureWriter.lua +154 -0
- package/payload/addon/Bridge/Definitions.lua +3 -0
- package/payload/addon/Bridge/Identity.lua +127 -0
- package/{vendor/addon/Libs/AutomationQR.lua → payload/addon/Bridge/MatrixSymbol.lua} +23 -30
- package/payload/addon/Bridge/ProbeQueue.lua +136 -0
- package/payload/addon/Bridge/ProbeRunner.lua +128 -0
- package/payload/addon/Bridge/ReceiptView.lua +160 -0
- package/payload/addon/Bridge/Reentry.lua +192 -0
- package/payload/addon/Bridge/ReportStore.lua +153 -0
- package/payload/addon/Bridge/Session.lua +163 -0
- package/payload/addon/Clients/Evergreen.lua +2 -0
- package/payload/addon/Clients/Live.lua +2 -0
- package/payload/addon/Clients/Pandaria.lua +2 -0
- package/payload/addon/Clients/Titan.lua +2 -0
- package/payload/addon/Core/Compat.lua +59 -0
- package/payload/addon/Core/Controls.lua +168 -0
- package/{vendor/addon/Core/Bootstrap.lua → payload/addon/Core/Execute.lua} +12 -23
- package/{vendor → payload}/addon/Core/Inspector.lua +19 -235
- package/{vendor → payload}/addon/Core/Locale.lua +128 -93
- package/{vendor → payload}/addon/Core/Locale_enUS.lua +128 -95
- package/payload/addon/Core/Persistence.lua +58 -0
- package/payload/addon/Core/Platform.lua +58 -0
- package/payload/addon/Core/Runtime.lua +25 -0
- package/payload/addon/Core/Safety.lua +56 -0
- package/{vendor → payload}/addon/Core/Serializer.lua +18 -6
- package/payload/addon/Core/Stores.lua +611 -0
- package/payload/addon/Lychee Dev_Forever.toc +52 -0
- package/payload/addon/Lychee Dev_Mainline.toc +52 -0
- package/payload/addon/Lychee Dev_Mists.toc +52 -0
- package/payload/addon/Lychee Dev_Wrath.toc +52 -0
- package/payload/addon/Modules/AutomationView.lua +393 -0
- package/{vendor → payload}/addon/Modules/Diagnostics.lua +92 -36
- package/{vendor → payload}/addon/Modules/Events/Catalog.lua +9 -0
- package/{vendor → payload}/addon/Modules/Events/Monitor.lua +45 -5
- package/payload/addon/Modules/FunctionTrace.lua +150 -0
- package/{vendor → payload}/addon/Modules/ObjectInspector.lua +105 -31
- package/{vendor → payload}/addon/UI/Export.lua +64 -34
- package/{vendor → payload}/addon/UI/Pages/About.lua +26 -14
- package/payload/addon/UI/Pages/Automation.lua +446 -0
- package/payload/addon/UI/Pages/Diagnostics.lua +402 -0
- package/{vendor/addon/UI/Features.lua → payload/addon/UI/Pages/Events.lua} +192 -302
- package/{vendor → payload}/addon/UI/Pages/ExportRecords.lua +213 -132
- package/{vendor → payload}/addon/UI/Pages/Object.lua +229 -121
- package/payload/addon/UI/Pages/Run.lua +423 -0
- package/payload/addon/UI/Pages/Trace.lua +314 -0
- package/payload/addon/UI/TreeView.lua +246 -0
- package/{vendor/addon/UI/MainWindow.lua → payload/addon/UI/Widgets.lua} +89 -529
- package/payload/addon/UI/Window.lua +425 -0
- package/payload/skill/SKILL.md +87 -0
- package/payload/skill/agents/openai.yaml +7 -0
- package/payload/skill/references/addon-validation.md +42 -0
- package/payload/skill/references/asset-export.md +109 -0
- package/payload/skill/references/commands.md +169 -0
- package/payload/skill/references/data-investigation.md +242 -0
- package/payload/skill/references/error-diagnosis.md +41 -0
- package/payload/skill/references/installation.md +18 -0
- package/payload/skill/references/live-investigation.md +129 -0
- package/payload/skill/references/source-research.md +82 -0
- package/payload/skill/scripts/lycheedev.mjs +59 -0
- package/release.json +346 -0
- package/bin/lycheedev.js +0 -746
- package/src/addon.js +0 -95
- package/src/config.js +0 -68
- package/src/doctor.js +0 -126
- package/src/install.js +0 -145
- package/src/paths.js +0 -93
- package/src/py/instances.py +0 -165
- package/src/python.js +0 -111
- package/src/skill.js +0 -48
- package/src/wow.js +0 -541
- package/vendor/addon/Core/Clients/Forever.lua +0 -9
- package/vendor/addon/Core/Clients/Mainline.lua +0 -9
- package/vendor/addon/Core/Clients/Mists.lua +0 -9
- package/vendor/addon/Core/Clients/Titan.lua +0 -9
- package/vendor/addon/Core/Compatibility.lua +0 -43
- package/vendor/addon/Core/Database.lua +0 -859
- package/vendor/addon/Core/Safety.lua +0 -42
- package/vendor/addon/Lychee Dev_Forever.toc +0 -44
- package/vendor/addon/Lychee Dev_Mainline.toc +0 -44
- package/vendor/addon/Lychee Dev_Mists.toc +0 -44
- package/vendor/addon/Lychee Dev_Wrath.toc +0 -44
- package/vendor/addon/Modules/Automation/Controller.lua +0 -896
- package/vendor/addon/Modules/Automation/Reload.lua +0 -101
- package/vendor/addon/Modules/Automation/Report.lua +0 -409
- package/vendor/addon/Modules/Automation/auto/auto.lua +0 -12
- package/vendor/addon/Modules/FunctionTrace.lua +0 -85
- package/vendor/addon/UI/AutomationOverlay.lua +0 -253
- package/vendor/addon/UI/Pages/Automation.lua +0 -417
- package/vendor/addon/UI/Pages/Diagnostics.lua +0 -289
- package/vendor/addon/UI/Pages/Trace.lua +0 -165
- package/vendor/skill/SKILL.md +0 -44
- package/vendor/skill/agents/openai.yaml +0 -4
- package/vendor/skill/references/automation.md +0 -130
- package/vendor/skill/references/clients.md +0 -51
- package/vendor/skill/references/runtime-investigations.md +0 -104
- package/vendor/skill/scripts/automation/__init__.py +0 -1
- package/vendor/skill/scripts/automation/registry.py +0 -516
- package/vendor/skill/scripts/automation/reload.py +0 -121
- package/vendor/skill/scripts/automation/saved_variables.py +0 -438
- package/vendor/skill/scripts/automation/session.py +0 -207
- package/vendor/skill/scripts/automation/windows.py +0 -792
- package/vendor/skill/scripts/automation.py +0 -1067
- package/vendor/skill/scripts/requirements.txt +0 -13
- package/vendor/skill/scripts/selftest_offline.py +0 -1061
- package/vendor/skill/scripts/test_input_safety.py +0 -132
- package/vendor/skill/scripts/test_reload.py +0 -120
- /package/{vendor → payload}/addon/Media/GitHub.png +0 -0
- /package/{vendor → payload}/addon/Media/Logo.png +0 -0
- /package/{vendor → payload}/addon/Modules/Events/CatalogData_Forever.lua +0 -0
- /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mainline.lua +0 -0
- /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mists.lua +0 -0
- /package/{vendor → payload}/addon/Modules/Events/CatalogData_Titan.lua +0 -0
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
-- One bootstrap listener is required to read a pending request after SV load.
|
|
4
|
-
-- Without a request it unregisters immediately; no overlay or timer is built.
|
|
5
|
-
local Reload = {}
|
|
6
|
-
ns.AutomationReload = Reload
|
|
7
|
-
local driver = CreateFrame("Frame")
|
|
8
|
-
local pending, expiry, markerShown
|
|
9
|
-
local entered, loadingDone = false, false
|
|
10
|
-
local requestedThisSession = false
|
|
11
|
-
local TTL = 120
|
|
12
|
-
|
|
13
|
-
local function ValidNonce(value)
|
|
14
|
-
return type(value) == "string" and #value > 0 and #value <= 64
|
|
15
|
-
and value:match("^[A-Za-z0-9%.%-]+$") ~= nil
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
local function PlainText(value)
|
|
19
|
-
return not (issecretvalue and issecretvalue(value)) and type(value) == "string" and value ~= ""
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
function Reload.Clear(nonce)
|
|
23
|
-
if nonce and (not pending or pending.nonce ~= nonce) then return false end
|
|
24
|
-
if expiry then expiry:Cancel(); expiry = nil end
|
|
25
|
-
driver:UnregisterAllEvents()
|
|
26
|
-
if markerShown then ns.AutomationOverlay.HideIdentity() end
|
|
27
|
-
markerShown, pending = nil, nil
|
|
28
|
-
return true
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
local function TryReady()
|
|
32
|
-
if not pending or not entered or not loadingDone or ns.IsCombatBlocked() then return end
|
|
33
|
-
if not SlashCmdList.LYCHEEDEV or not ns.Automation or not ns.AutomationOverlay then return end
|
|
34
|
-
local character, realm = UnitName("player"), GetRealmName()
|
|
35
|
-
if not PlainText(character) or not PlainText(realm)
|
|
36
|
-
or character ~= pending.character or realm ~= pending.realm then Reload.Clear(); return end
|
|
37
|
-
local version, build = GetBuildInfo()
|
|
38
|
-
local json = string.format(
|
|
39
|
-
'{"v":1,"kind":"reload","run":"%s","status":"ready","ts":%d,"client":"%s","build":"%s.%s"}',
|
|
40
|
-
pending.nonce, time(), ns.Client.id, version, build)
|
|
41
|
-
markerShown = ns.AutomationOverlay.ShowIdentity(json) and true or false
|
|
42
|
-
driver:UnregisterEvent("PLAYER_ENTERING_WORLD")
|
|
43
|
-
driver:UnregisterEvent("LOADING_SCREEN_DISABLED")
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
function Reload.Request(nonce)
|
|
47
|
-
if not ValidNonce(nonce) or ns.IsCombatBlocked() or requestedThisSession then return false end
|
|
48
|
-
ns.InitializeDatabase()
|
|
49
|
-
-- Do not overwrite an unknown/newer request format.
|
|
50
|
-
if LycheeDevDB.reloadHandshake ~= nil then return false end
|
|
51
|
-
local character, realm = UnitName("player"), GetRealmName()
|
|
52
|
-
if not PlainText(character) or not PlainText(realm) then return false end
|
|
53
|
-
Reload.Clear()
|
|
54
|
-
ns.EnsureSafety()
|
|
55
|
-
local request = {schema=1, nonce=nonce, requestedAt=time(),
|
|
56
|
-
character=character, realm=realm}
|
|
57
|
-
LycheeDevDB.reloadHandshake = request
|
|
58
|
-
requestedThisSession = true
|
|
59
|
-
local ok = pcall(ReloadUI)
|
|
60
|
-
if not ok then
|
|
61
|
-
if LycheeDevDB.reloadHandshake == request then LycheeDevDB.reloadHandshake = nil end
|
|
62
|
-
return false
|
|
63
|
-
end
|
|
64
|
-
-- Only the next Lua session can publish ready, never this call stack.
|
|
65
|
-
return true
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
driver:RegisterEvent("ADDON_LOADED")
|
|
69
|
-
driver:SetScript("OnEvent", function(_, event, name, isReloadingUi)
|
|
70
|
-
if event == "ADDON_LOADED" then
|
|
71
|
-
if name ~= ADDON_NAME then return end
|
|
72
|
-
driver:UnregisterEvent("ADDON_LOADED")
|
|
73
|
-
local request = type(LycheeDevDB) == "table" and LycheeDevDB.reloadHandshake
|
|
74
|
-
if type(request) ~= "table" or request.schema ~= 1 then return end
|
|
75
|
-
LycheeDevDB.reloadHandshake = nil
|
|
76
|
-
if not ValidNonce(request.nonce) or type(request.requestedAt) ~= "number"
|
|
77
|
-
or time() < request.requestedAt or time() - request.requestedAt > TTL
|
|
78
|
-
or not PlainText(request.character) or not PlainText(request.realm) then return end
|
|
79
|
-
pending = {nonce=request.nonce,character=request.character,realm=request.realm}
|
|
80
|
-
ns.EnsureSafety()
|
|
81
|
-
driver:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
82
|
-
driver:RegisterEvent("LOADING_SCREEN_DISABLED")
|
|
83
|
-
driver:RegisterEvent("LOADING_SCREEN_ENABLED")
|
|
84
|
-
driver:RegisterEvent("PLAYER_LEAVING_WORLD")
|
|
85
|
-
expiry = C_Timer.NewTimer(TTL, function() Reload.Clear() end)
|
|
86
|
-
elseif event == "PLAYER_ENTERING_WORLD" then
|
|
87
|
-
if not isReloadingUi then Reload.Clear(); return end
|
|
88
|
-
entered = true
|
|
89
|
-
TryReady()
|
|
90
|
-
elseif event == "LOADING_SCREEN_DISABLED" then
|
|
91
|
-
loadingDone = true
|
|
92
|
-
TryReady()
|
|
93
|
-
elseif event == "LOADING_SCREEN_ENABLED" then
|
|
94
|
-
loadingDone = false
|
|
95
|
-
if markerShown then Reload.Clear() end
|
|
96
|
-
elseif event == "PLAYER_LEAVING_WORLD" then
|
|
97
|
-
Reload.Clear()
|
|
98
|
-
end
|
|
99
|
-
end)
|
|
100
|
-
|
|
101
|
-
ns.RegisterCombatShutdown(function() Reload.Clear() end)
|
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
-- Automation report normalization and serialization.
|
|
4
|
-
-- This module owns the complete report body: strict JSON encoding, size
|
|
5
|
-
-- budgeting and the Adler-32 content checksum. It never touches QR transport.
|
|
6
|
-
|
|
7
|
-
local REPORT_SCHEMA = "lychee.automation.result.v1"
|
|
8
|
-
-- Keep in sync with MAX_AUTOMATION_REPORT_BYTES in Core/Database.lua.
|
|
9
|
-
local MAX_REPORT_CONTENT_BYTES = 1024 * 1024
|
|
10
|
-
local MAX_LIFECYCLE_LOG_ENTRIES = 128
|
|
11
|
-
local MAX_LIFECYCLE_LOG_BYTES = 16 * 1024
|
|
12
|
-
local MAX_ENCODE_DEPTH = 32
|
|
13
|
-
|
|
14
|
-
local BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
|
15
|
-
|
|
16
|
-
local CONTROL_ESCAPES = {
|
|
17
|
-
[0x08] = "\\b",
|
|
18
|
-
[0x09] = "\\t",
|
|
19
|
-
[0x0A] = "\\n",
|
|
20
|
-
[0x0C] = "\\f",
|
|
21
|
-
[0x0D] = "\\r",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
-- --- checksums and encodings -------------------------------------------------
|
|
25
|
-
|
|
26
|
-
function ns.AutomationAdler32(text)
|
|
27
|
-
local a, b = 1, 0
|
|
28
|
-
local length = #text
|
|
29
|
-
local index = 1
|
|
30
|
-
-- 5552 is the largest n so that 255*n*(n+1)/2 + (n+1)*(65520) stays below 2^32.
|
|
31
|
-
while index <= length do
|
|
32
|
-
local chunkEnd = math.min(index + 5551, length)
|
|
33
|
-
for position = index, chunkEnd do
|
|
34
|
-
a = a + string.byte(text, position)
|
|
35
|
-
b = b + a
|
|
36
|
-
end
|
|
37
|
-
a = a % 65521
|
|
38
|
-
b = b % 65521
|
|
39
|
-
index = chunkEnd + 1
|
|
40
|
-
end
|
|
41
|
-
return string.format("%08x", b * 65536 + a)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
local function EncodeBase64(text)
|
|
45
|
-
local parts = {}
|
|
46
|
-
local length = #text
|
|
47
|
-
local index = 1
|
|
48
|
-
while index <= length do
|
|
49
|
-
local b1 = string.byte(text, index)
|
|
50
|
-
local b2 = string.byte(text, index + 1)
|
|
51
|
-
local b3 = string.byte(text, index + 2)
|
|
52
|
-
local group = b1 * 65536 + (b2 or 0) * 256 + (b3 or 0)
|
|
53
|
-
local chars = {
|
|
54
|
-
BASE64_ALPHABET:sub(math.floor(group / 262144) % 64 + 1, math.floor(group / 262144) % 64 + 1),
|
|
55
|
-
BASE64_ALPHABET:sub(math.floor(group / 4096) % 64 + 1, math.floor(group / 4096) % 64 + 1),
|
|
56
|
-
b2 and BASE64_ALPHABET:sub(math.floor(group / 64) % 64 + 1, math.floor(group / 64) % 64 + 1) or "=",
|
|
57
|
-
b3 and BASE64_ALPHABET:sub(group % 64 + 1, group % 64 + 1) or "=",
|
|
58
|
-
}
|
|
59
|
-
parts[#parts + 1] = table.concat(chars)
|
|
60
|
-
index = index + 3
|
|
61
|
-
end
|
|
62
|
-
return table.concat(parts)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
local function IsUtf8Continuation(byte)
|
|
66
|
-
return byte ~= nil and byte >= 0x80 and byte <= 0xBF
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
-- Strict UTF-8: every sequence must carry exactly as many continuation bytes
|
|
70
|
-
-- as its leading byte announces. The leading byte ranges already exclude
|
|
71
|
-
-- C0/C1 (overlong) and F5..FF (out of range); the second byte must then rule
|
|
72
|
-
-- out overlong forms (E0 80..9F, F0 80..8F), surrogates (ED A0..BF) and code
|
|
73
|
-
-- points above U+10FFFF (F4 90..BF).
|
|
74
|
-
local function ValidateUtf8(text)
|
|
75
|
-
local index = 1
|
|
76
|
-
local length = #text
|
|
77
|
-
while index <= length do
|
|
78
|
-
local byte = string.byte(text, index)
|
|
79
|
-
local count
|
|
80
|
-
if byte < 0x80 then
|
|
81
|
-
count = 1
|
|
82
|
-
elseif byte >= 0xC2 and byte <= 0xDF then
|
|
83
|
-
count = 2
|
|
84
|
-
elseif byte >= 0xE0 and byte <= 0xEF then
|
|
85
|
-
count = 3
|
|
86
|
-
elseif byte >= 0xF0 and byte <= 0xF4 then
|
|
87
|
-
count = 4
|
|
88
|
-
else
|
|
89
|
-
return false
|
|
90
|
-
end
|
|
91
|
-
if index + count - 1 > length then
|
|
92
|
-
return false
|
|
93
|
-
end
|
|
94
|
-
local second, third, fourth = string.byte(text, index + 1, index + count - 1)
|
|
95
|
-
if count == 2 then
|
|
96
|
-
if not IsUtf8Continuation(second) then
|
|
97
|
-
return false
|
|
98
|
-
end
|
|
99
|
-
elseif count == 3 then
|
|
100
|
-
if not IsUtf8Continuation(second) or not IsUtf8Continuation(third) then
|
|
101
|
-
return false
|
|
102
|
-
end
|
|
103
|
-
if byte == 0xE0 and second < 0xA0 then return false end
|
|
104
|
-
if byte == 0xED and second > 0x9F then return false end
|
|
105
|
-
elseif count == 4 then
|
|
106
|
-
if not IsUtf8Continuation(second) or not IsUtf8Continuation(third)
|
|
107
|
-
or not IsUtf8Continuation(fourth) then
|
|
108
|
-
return false
|
|
109
|
-
end
|
|
110
|
-
if byte == 0xF0 and second < 0x90 then return false end
|
|
111
|
-
if byte == 0xF4 and second > 0x8F then return false end
|
|
112
|
-
end
|
|
113
|
-
index = index + count
|
|
114
|
-
end
|
|
115
|
-
return true
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
-- --- strict JSON encoding ----------------------------------------------------
|
|
119
|
-
|
|
120
|
-
local EncodeState = {}
|
|
121
|
-
EncodeState.__index = EncodeState
|
|
122
|
-
|
|
123
|
-
function EncodeState:new()
|
|
124
|
-
return setmetatable({
|
|
125
|
-
parts = {},
|
|
126
|
-
bytes = 0,
|
|
127
|
-
incomplete = false,
|
|
128
|
-
incompleteReasons = {},
|
|
129
|
-
overflow = false,
|
|
130
|
-
}, self)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
function EncodeState:MarkIncomplete(reason)
|
|
134
|
-
self.incomplete = true
|
|
135
|
-
if #self.incompleteReasons < 64 then
|
|
136
|
-
self.incompleteReasons[#self.incompleteReasons + 1] = reason
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
function EncodeState:Append(text)
|
|
141
|
-
if self.overflow then
|
|
142
|
-
return
|
|
143
|
-
end
|
|
144
|
-
if self.bytes + #text > MAX_REPORT_CONTENT_BYTES then
|
|
145
|
-
self.overflow = true
|
|
146
|
-
return
|
|
147
|
-
end
|
|
148
|
-
self.parts[#self.parts + 1] = text
|
|
149
|
-
self.bytes = self.bytes + #text
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
local function EncodeJSONString(state, text)
|
|
153
|
-
if not ValidateUtf8(text) then
|
|
154
|
-
-- Binary payloads travel as explicitly marked Base64, never transcoded.
|
|
155
|
-
state:Append('{"$base64":true,"data":"')
|
|
156
|
-
state:Append(EncodeBase64(text))
|
|
157
|
-
state:Append('"}')
|
|
158
|
-
state:MarkIncomplete("binary_string")
|
|
159
|
-
return
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
state:Append('"')
|
|
163
|
-
local index = 1
|
|
164
|
-
local length = #text
|
|
165
|
-
while index <= length do
|
|
166
|
-
local byte = string.byte(text, index)
|
|
167
|
-
local escape = CONTROL_ESCAPES[byte]
|
|
168
|
-
if escape then
|
|
169
|
-
state:Append(escape)
|
|
170
|
-
index = index + 1
|
|
171
|
-
elseif byte == 0x22 then
|
|
172
|
-
state:Append('\\"')
|
|
173
|
-
index = index + 1
|
|
174
|
-
elseif byte == 0x5C then
|
|
175
|
-
state:Append("\\\\")
|
|
176
|
-
index = index + 1
|
|
177
|
-
elseif byte < 0x20 then
|
|
178
|
-
state:Append(string.format("\\u%04x", byte))
|
|
179
|
-
index = index + 1
|
|
180
|
-
else
|
|
181
|
-
local start = index
|
|
182
|
-
repeat
|
|
183
|
-
index = index + 1
|
|
184
|
-
byte = index <= length and string.byte(text, index) or 0
|
|
185
|
-
until byte < 0x20 or byte == 0x22 or byte == 0x5C
|
|
186
|
-
state:Append(text:sub(start, index - 1))
|
|
187
|
-
end
|
|
188
|
-
if state.overflow then
|
|
189
|
-
return
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
state:Append('"')
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
local function EncodeJSONNumber(state, value)
|
|
196
|
-
if value ~= value or value == math.huge or value == -math.huge then
|
|
197
|
-
state:Append("null")
|
|
198
|
-
state:MarkIncomplete("non_finite_number")
|
|
199
|
-
return
|
|
200
|
-
end
|
|
201
|
-
state:Append(tostring(value))
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
local function IsPlainArray(value)
|
|
205
|
-
-- pairs() order is undefined, so array detection must not depend on it.
|
|
206
|
-
local maximum = 0
|
|
207
|
-
for key, _ in pairs(value) do
|
|
208
|
-
if type(key) ~= "number" or key % 1 ~= 0 or key < 1 then
|
|
209
|
-
return false
|
|
210
|
-
end
|
|
211
|
-
if key > maximum then
|
|
212
|
-
maximum = key
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
for index = 1, maximum do
|
|
216
|
-
if value[index] == nil then
|
|
217
|
-
return false
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
return true, maximum
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
local EncodeJSONValue
|
|
224
|
-
|
|
225
|
-
local function EncodeJSONTable(state, value, depth, seen)
|
|
226
|
-
if depth > MAX_ENCODE_DEPTH then
|
|
227
|
-
state:Append('"<max depth>"')
|
|
228
|
-
state:MarkIncomplete("max_depth")
|
|
229
|
-
return
|
|
230
|
-
end
|
|
231
|
-
if seen[value] then
|
|
232
|
-
state:Append('"<cycle>"')
|
|
233
|
-
state:MarkIncomplete("cycle")
|
|
234
|
-
return
|
|
235
|
-
end
|
|
236
|
-
seen[value] = true
|
|
237
|
-
|
|
238
|
-
local isArray, count = IsPlainArray(value)
|
|
239
|
-
if isArray and count > 0 then
|
|
240
|
-
state:Append("[")
|
|
241
|
-
for index = 1, count do
|
|
242
|
-
if index > 1 then
|
|
243
|
-
state:Append(",")
|
|
244
|
-
end
|
|
245
|
-
EncodeJSONValue(state, value[index], depth + 1, seen)
|
|
246
|
-
if state.overflow then
|
|
247
|
-
seen[value] = nil
|
|
248
|
-
return
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
state:Append("]")
|
|
252
|
-
else
|
|
253
|
-
state:Append("{")
|
|
254
|
-
local first = true
|
|
255
|
-
for key, child in pairs(value) do
|
|
256
|
-
if not first then
|
|
257
|
-
state:Append(",")
|
|
258
|
-
end
|
|
259
|
-
first = false
|
|
260
|
-
local keyType = type(key)
|
|
261
|
-
if keyType == "number" then
|
|
262
|
-
EncodeJSONString(state, tostring(key))
|
|
263
|
-
state:Append(":")
|
|
264
|
-
elseif keyType == "string" then
|
|
265
|
-
EncodeJSONString(state, key)
|
|
266
|
-
state:Append(":")
|
|
267
|
-
elseif keyType == "boolean" then
|
|
268
|
-
EncodeJSONString(state, tostring(key))
|
|
269
|
-
state:Append(":")
|
|
270
|
-
else
|
|
271
|
-
EncodeJSONString(state, "<unsupported key: " .. keyType .. ">")
|
|
272
|
-
state:Append(":")
|
|
273
|
-
state:MarkIncomplete("unsupported_key")
|
|
274
|
-
end
|
|
275
|
-
EncodeJSONValue(state, child, depth + 1, seen)
|
|
276
|
-
if state.overflow then
|
|
277
|
-
seen[value] = nil
|
|
278
|
-
return
|
|
279
|
-
end
|
|
280
|
-
end
|
|
281
|
-
state:Append("}")
|
|
282
|
-
end
|
|
283
|
-
seen[value] = nil
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
EncodeJSONValue = function(state, value, depth, seen)
|
|
287
|
-
local valueType = type(value)
|
|
288
|
-
if issecretvalue and issecretvalue(value) then
|
|
289
|
-
state:Append('"<secret>"')
|
|
290
|
-
state:MarkIncomplete("secret_value")
|
|
291
|
-
elseif valueType == "nil" then
|
|
292
|
-
state:Append("null")
|
|
293
|
-
elseif valueType == "boolean" then
|
|
294
|
-
state:Append(value and "true" or "false")
|
|
295
|
-
elseif valueType == "number" then
|
|
296
|
-
EncodeJSONNumber(state, value)
|
|
297
|
-
elseif valueType == "string" then
|
|
298
|
-
EncodeJSONString(state, value)
|
|
299
|
-
elseif valueType == "table" then
|
|
300
|
-
EncodeJSONTable(state, value, depth, seen)
|
|
301
|
-
else
|
|
302
|
-
state:Append('"' .. valueType .. '"')
|
|
303
|
-
state:MarkIncomplete("unsupported_type")
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
-- Encode one value as strict normalized JSON.
|
|
308
|
-
-- Returns json text (or nil on overflow), complete flag, reasons array.
|
|
309
|
-
local function EncodeJSON(value)
|
|
310
|
-
local state = EncodeState:new()
|
|
311
|
-
EncodeJSONValue(state, value, 0, {})
|
|
312
|
-
if state.overflow then
|
|
313
|
-
return nil, false, { "output_limit" }
|
|
314
|
-
end
|
|
315
|
-
return table.concat(state.parts), not state.incomplete, state.incompleteReasons
|
|
316
|
-
end
|
|
317
|
-
|
|
318
|
-
-- --- lifecycle log -----------------------------------------------------------
|
|
319
|
-
|
|
320
|
-
local function ClampLifecycleLog(log)
|
|
321
|
-
if type(log) ~= "table" then
|
|
322
|
-
return {}, false
|
|
323
|
-
end
|
|
324
|
-
local entries = {}
|
|
325
|
-
for index = 1, math.min(#log, MAX_LIFECYCLE_LOG_ENTRIES) do
|
|
326
|
-
entries[#entries + 1] = log[index]
|
|
327
|
-
end
|
|
328
|
-
local limited = #log > MAX_LIFECYCLE_LOG_ENTRIES
|
|
329
|
-
local bytes = 0
|
|
330
|
-
for index = 1, #entries do
|
|
331
|
-
local message = entries[index]
|
|
332
|
-
bytes = bytes + (type(message) == "table" and #(message.message or "") or #tostring(message)) + 24
|
|
333
|
-
end
|
|
334
|
-
while bytes > MAX_LIFECYCLE_LOG_BYTES and #entries > 1 do
|
|
335
|
-
local dropped = table.remove(entries, 1)
|
|
336
|
-
bytes = bytes - (#(type(dropped) == "table" and dropped.message or tostring(dropped)) + 24)
|
|
337
|
-
limited = true
|
|
338
|
-
end
|
|
339
|
-
return entries, limited
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
-- --- report building ---------------------------------------------------------
|
|
343
|
-
|
|
344
|
-
-- Build the complete automation report body.
|
|
345
|
-
-- Returns: content(string), metadata(table), errorCode(string|nil)
|
|
346
|
-
-- metadata: { complete = bool, contentChecksum = "xxxxxxxx" }
|
|
347
|
-
-- On overflow the caller receives nil and a stable errorCode.
|
|
348
|
-
function ns.AutomationReportBuild(spec)
|
|
349
|
-
spec = type(spec) == "table" and spec or {}
|
|
350
|
-
|
|
351
|
-
local log, logLimited = ClampLifecycleLog(spec.lifecycleLog)
|
|
352
|
-
local report = {
|
|
353
|
-
schema = REPORT_SCHEMA,
|
|
354
|
-
taskId = spec.taskId,
|
|
355
|
-
executionId = spec.executionId,
|
|
356
|
-
revision = spec.revision,
|
|
357
|
-
kind = spec.kind,
|
|
358
|
-
status = spec.status,
|
|
359
|
-
startedAt = spec.startedAt,
|
|
360
|
-
finishedAt = spec.finishedAt,
|
|
361
|
-
requestType = spec.requestType or "task",
|
|
362
|
-
source = spec.source,
|
|
363
|
-
params = spec.params,
|
|
364
|
-
stdout = spec.stdout,
|
|
365
|
-
outputTruncated = spec.outputTruncated and true or false,
|
|
366
|
-
returns = spec.returns,
|
|
367
|
-
error = spec.error,
|
|
368
|
-
lifecycleLog = log,
|
|
369
|
-
lifecycleLogLimited = logLimited,
|
|
370
|
-
bugSnapshot = spec.bugSnapshot,
|
|
371
|
-
environment = spec.environment,
|
|
372
|
-
complete = spec.complete and true or false,
|
|
373
|
-
incompleteReasons = spec.incompleteReasons,
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
local json, encodeComplete, reasons = EncodeJSON(report)
|
|
377
|
-
if not json then
|
|
378
|
-
return nil, nil, reasons and reasons[1] or "output_limit"
|
|
379
|
-
end
|
|
380
|
-
if spec.complete and not encodeComplete then
|
|
381
|
-
-- Encoding limits (cycles, secrets, unsupported types) make the report
|
|
382
|
-
-- incomplete; fold the encode reasons in and re-encode once.
|
|
383
|
-
local allReasons = {}
|
|
384
|
-
local specReasons = type(spec.incompleteReasons) == "table" and spec.incompleteReasons or {}
|
|
385
|
-
for index = 1, #specReasons do
|
|
386
|
-
allReasons[#allReasons + 1] = specReasons[index]
|
|
387
|
-
end
|
|
388
|
-
for index = 1, #reasons do
|
|
389
|
-
allReasons[#allReasons + 1] = "encode:" .. reasons[index]
|
|
390
|
-
end
|
|
391
|
-
report.incompleteReasons = allReasons
|
|
392
|
-
report.complete = false
|
|
393
|
-
json, encodeComplete, reasons = EncodeJSON(report)
|
|
394
|
-
if not json then
|
|
395
|
-
return nil, nil, "output_limit"
|
|
396
|
-
end
|
|
397
|
-
end
|
|
398
|
-
|
|
399
|
-
return json, {
|
|
400
|
-
complete = report.complete and true or false,
|
|
401
|
-
contentChecksum = ns.AutomationAdler32(json),
|
|
402
|
-
}, nil
|
|
403
|
-
end
|
|
404
|
-
|
|
405
|
-
ns.AutomationReport = {
|
|
406
|
-
Encode = EncodeJSON,
|
|
407
|
-
Adler32 = ns.AutomationAdler32,
|
|
408
|
-
MAX_REPORT_CONTENT_BYTES = MAX_REPORT_CONTENT_BYTES,
|
|
409
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
-- Automation task registry. This file contains generated data only; loading it
|
|
4
|
-
-- must never execute task source. Task blocks are written between the
|
|
5
|
-
-- BEGIN/END markers by the Lychee Dev skill tooling and are removed before
|
|
6
|
-
-- release packaging ships an empty registry.
|
|
7
|
-
|
|
8
|
-
ns.AutomationTaskDefinitions = ns.AutomationTaskDefinitions or {}
|
|
9
|
-
|
|
10
|
-
-- Task blocks use exactly this marker shape (task id may not contain the
|
|
11
|
-
-- marker text): "-- BEGIN LYCHEE DEV TASK <task-id>" ... "-- END LYCHEE DEV TASK <task-id>".
|
|
12
|
-
-- The skill tooling inserts and replaces them; releases ship this file empty.
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
local trace = {}
|
|
4
|
-
local MAX_RECORDS = 300
|
|
5
|
-
local MAX_ARGUMENTS = 16
|
|
6
|
-
local MAX_ARGUMENT_BYTES = 180
|
|
7
|
-
local hooks = {}
|
|
8
|
-
local records = {}
|
|
9
|
-
local head, count = 0, 0
|
|
10
|
-
local activePath
|
|
11
|
-
local enabled = false
|
|
12
|
-
local changedCallback
|
|
13
|
-
local startedAt = 0
|
|
14
|
-
|
|
15
|
-
local function IsSecret(value)
|
|
16
|
-
return issecretvalue and issecretvalue(value)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
local function FormatArgument(value)
|
|
20
|
-
if IsSecret(value) then return "<secret>" end
|
|
21
|
-
local valueType = type(value)
|
|
22
|
-
local text
|
|
23
|
-
if valueType == "string" then
|
|
24
|
-
text = string.format("%q", value)
|
|
25
|
-
elseif valueType == "number" or valueType == "boolean" or valueType == "nil" then
|
|
26
|
-
text = tostring(value)
|
|
27
|
-
elseif valueType == "table" then
|
|
28
|
-
text = "<table>"
|
|
29
|
-
else
|
|
30
|
-
text = "<" .. valueType .. ">"
|
|
31
|
-
end
|
|
32
|
-
return #text > MAX_ARGUMENT_BYTES and (text:sub(1, MAX_ARGUMENT_BYTES) .. "...") or text
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
local function OnCall(path, ...)
|
|
36
|
-
if not enabled or activePath ~= path or ns.IsCombatBlocked() then return end
|
|
37
|
-
local suppliedCount = select("#", ...)
|
|
38
|
-
local arguments = {}
|
|
39
|
-
for index = 1, math.min(suppliedCount, MAX_ARGUMENTS) do
|
|
40
|
-
arguments[index] = FormatArgument(select(index, ...))
|
|
41
|
-
end
|
|
42
|
-
if suppliedCount > MAX_ARGUMENTS then
|
|
43
|
-
arguments[#arguments + 1] = "<" .. (suppliedCount - MAX_ARGUMENTS) .. " more arguments>"
|
|
44
|
-
end
|
|
45
|
-
head = head % MAX_RECORDS + 1
|
|
46
|
-
records[head] = { elapsed = math.max(0, GetTime() - startedAt), path = path, arguments = arguments, summary = table.concat(arguments, ", ") }
|
|
47
|
-
count = math.min(count + 1, MAX_RECORDS)
|
|
48
|
-
if changedCallback then changedCallback(records[head]) end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
function trace.Start(path, callback)
|
|
52
|
-
if ns.IsCombatBlocked() then return false, ns.L.COMBAT_BLOCKED end
|
|
53
|
-
path = tostring(path or ""):match("^%s*(.-)%s*$")
|
|
54
|
-
local succeeded, owner, functionName, errorMessage = ns.ObjectInspector.ResolveFunctionTarget(path)
|
|
55
|
-
if not succeeded then return false, errorMessage end
|
|
56
|
-
local target = owner[functionName]
|
|
57
|
-
if IsSecret(target) or type(target) ~= "function" then return false, ns.L.FUNCTION_NOT_FOUND end
|
|
58
|
-
if not hooks[path] then
|
|
59
|
-
local hooked = pcall(hooksecurefunc, owner, functionName, function(...) OnCall(path, ...) end)
|
|
60
|
-
if not hooked then return false, ns.L.FUNCTION_HOOK_FAILED end
|
|
61
|
-
hooks[path] = true
|
|
62
|
-
end
|
|
63
|
-
activePath, enabled, changedCallback, startedAt = path, true, callback, GetTime()
|
|
64
|
-
return true
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
function trace.Stop()
|
|
68
|
-
enabled, activePath, changedCallback = false, nil, nil
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
function trace.Clear()
|
|
72
|
-
wipe(records)
|
|
73
|
-
head, count = 0, 0
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
function trace.GetCount() return count end
|
|
77
|
-
function trace.GetRecord(newestIndex)
|
|
78
|
-
if type(newestIndex) ~= "number" or newestIndex < 1 or newestIndex > count then return nil end
|
|
79
|
-
return records[(head - newestIndex) % MAX_RECORDS + 1]
|
|
80
|
-
end
|
|
81
|
-
function trace.IsRunning() return enabled end
|
|
82
|
-
function trace.GetActivePath() return activePath end
|
|
83
|
-
|
|
84
|
-
ns.RegisterCombatShutdown(trace.Stop)
|
|
85
|
-
ns.FunctionTrace = trace
|