lycheedev 1.2.0 → 2.0.0

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.
Files changed (118) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +45 -0
  3. package/THIRD_PARTY_NOTICES +812 -0
  4. package/bin/lycheedev.mjs +56 -0
  5. package/native/windows-amd64/lycheedev.exe +0 -0
  6. package/package.json +12 -33
  7. package/payload/addon/Bridge/CaptureWriter.lua +154 -0
  8. package/payload/addon/Bridge/Definitions.lua +3 -0
  9. package/payload/addon/Bridge/Identity.lua +127 -0
  10. package/{vendor/addon/Libs/AutomationQR.lua → payload/addon/Bridge/MatrixSymbol.lua} +23 -30
  11. package/payload/addon/Bridge/ProbeQueue.lua +136 -0
  12. package/payload/addon/Bridge/ProbeRunner.lua +128 -0
  13. package/payload/addon/Bridge/ReceiptView.lua +160 -0
  14. package/payload/addon/Bridge/Reentry.lua +192 -0
  15. package/payload/addon/Bridge/ReportStore.lua +153 -0
  16. package/payload/addon/Bridge/Session.lua +163 -0
  17. package/payload/addon/Clients/Evergreen.lua +2 -0
  18. package/payload/addon/Clients/Live.lua +2 -0
  19. package/payload/addon/Clients/Pandaria.lua +2 -0
  20. package/payload/addon/Clients/Titan.lua +2 -0
  21. package/payload/addon/Core/Compat.lua +59 -0
  22. package/payload/addon/Core/Controls.lua +168 -0
  23. package/{vendor/addon/Core/Bootstrap.lua → payload/addon/Core/Execute.lua} +12 -23
  24. package/{vendor → payload}/addon/Core/Inspector.lua +19 -235
  25. package/{vendor → payload}/addon/Core/Locale.lua +128 -93
  26. package/{vendor → payload}/addon/Core/Locale_enUS.lua +128 -95
  27. package/payload/addon/Core/Persistence.lua +58 -0
  28. package/payload/addon/Core/Platform.lua +58 -0
  29. package/payload/addon/Core/Runtime.lua +25 -0
  30. package/payload/addon/Core/Safety.lua +56 -0
  31. package/{vendor → payload}/addon/Core/Serializer.lua +18 -6
  32. package/payload/addon/Core/Stores.lua +611 -0
  33. package/payload/addon/Lychee Dev_Forever.toc +52 -0
  34. package/payload/addon/Lychee Dev_Mainline.toc +52 -0
  35. package/payload/addon/Lychee Dev_Mists.toc +52 -0
  36. package/payload/addon/Lychee Dev_Wrath.toc +52 -0
  37. package/payload/addon/Modules/AutomationView.lua +393 -0
  38. package/{vendor → payload}/addon/Modules/Diagnostics.lua +92 -36
  39. package/{vendor → payload}/addon/Modules/Events/Catalog.lua +9 -0
  40. package/{vendor → payload}/addon/Modules/Events/Monitor.lua +45 -5
  41. package/payload/addon/Modules/FunctionTrace.lua +150 -0
  42. package/{vendor → payload}/addon/Modules/ObjectInspector.lua +105 -31
  43. package/{vendor → payload}/addon/UI/Export.lua +64 -34
  44. package/{vendor → payload}/addon/UI/Pages/About.lua +26 -14
  45. package/payload/addon/UI/Pages/Automation.lua +446 -0
  46. package/payload/addon/UI/Pages/Diagnostics.lua +402 -0
  47. package/{vendor/addon/UI/Features.lua → payload/addon/UI/Pages/Events.lua} +192 -302
  48. package/{vendor → payload}/addon/UI/Pages/ExportRecords.lua +213 -132
  49. package/{vendor → payload}/addon/UI/Pages/Object.lua +229 -121
  50. package/payload/addon/UI/Pages/Run.lua +423 -0
  51. package/payload/addon/UI/Pages/Trace.lua +314 -0
  52. package/payload/addon/UI/TreeView.lua +246 -0
  53. package/{vendor/addon/UI/MainWindow.lua → payload/addon/UI/Widgets.lua} +89 -529
  54. package/payload/addon/UI/Window.lua +425 -0
  55. package/payload/skill/SKILL.md +87 -0
  56. package/payload/skill/agents/openai.yaml +7 -0
  57. package/payload/skill/references/addon-validation.md +42 -0
  58. package/payload/skill/references/asset-export.md +109 -0
  59. package/payload/skill/references/commands.md +169 -0
  60. package/payload/skill/references/data-investigation.md +242 -0
  61. package/payload/skill/references/error-diagnosis.md +41 -0
  62. package/payload/skill/references/installation.md +18 -0
  63. package/payload/skill/references/live-investigation.md +129 -0
  64. package/payload/skill/references/source-research.md +82 -0
  65. package/payload/skill/scripts/lycheedev.mjs +59 -0
  66. package/release.json +346 -0
  67. package/bin/lycheedev.js +0 -746
  68. package/src/addon.js +0 -95
  69. package/src/config.js +0 -68
  70. package/src/doctor.js +0 -126
  71. package/src/install.js +0 -145
  72. package/src/paths.js +0 -93
  73. package/src/py/instances.py +0 -165
  74. package/src/python.js +0 -111
  75. package/src/skill.js +0 -48
  76. package/src/wow.js +0 -541
  77. package/vendor/addon/Core/Clients/Forever.lua +0 -9
  78. package/vendor/addon/Core/Clients/Mainline.lua +0 -9
  79. package/vendor/addon/Core/Clients/Mists.lua +0 -9
  80. package/vendor/addon/Core/Clients/Titan.lua +0 -9
  81. package/vendor/addon/Core/Compatibility.lua +0 -43
  82. package/vendor/addon/Core/Database.lua +0 -859
  83. package/vendor/addon/Core/Safety.lua +0 -42
  84. package/vendor/addon/Lychee Dev_Forever.toc +0 -44
  85. package/vendor/addon/Lychee Dev_Mainline.toc +0 -44
  86. package/vendor/addon/Lychee Dev_Mists.toc +0 -44
  87. package/vendor/addon/Lychee Dev_Wrath.toc +0 -44
  88. package/vendor/addon/Modules/Automation/Controller.lua +0 -896
  89. package/vendor/addon/Modules/Automation/Reload.lua +0 -101
  90. package/vendor/addon/Modules/Automation/Report.lua +0 -409
  91. package/vendor/addon/Modules/Automation/auto/auto.lua +0 -12
  92. package/vendor/addon/Modules/FunctionTrace.lua +0 -85
  93. package/vendor/addon/UI/AutomationOverlay.lua +0 -253
  94. package/vendor/addon/UI/Pages/Automation.lua +0 -417
  95. package/vendor/addon/UI/Pages/Diagnostics.lua +0 -289
  96. package/vendor/addon/UI/Pages/Trace.lua +0 -165
  97. package/vendor/skill/SKILL.md +0 -44
  98. package/vendor/skill/agents/openai.yaml +0 -4
  99. package/vendor/skill/references/automation.md +0 -130
  100. package/vendor/skill/references/clients.md +0 -51
  101. package/vendor/skill/references/runtime-investigations.md +0 -104
  102. package/vendor/skill/scripts/automation/__init__.py +0 -1
  103. package/vendor/skill/scripts/automation/registry.py +0 -516
  104. package/vendor/skill/scripts/automation/reload.py +0 -121
  105. package/vendor/skill/scripts/automation/saved_variables.py +0 -438
  106. package/vendor/skill/scripts/automation/session.py +0 -207
  107. package/vendor/skill/scripts/automation/windows.py +0 -792
  108. package/vendor/skill/scripts/automation.py +0 -1067
  109. package/vendor/skill/scripts/requirements.txt +0 -13
  110. package/vendor/skill/scripts/selftest_offline.py +0 -1061
  111. package/vendor/skill/scripts/test_input_safety.py +0 -132
  112. package/vendor/skill/scripts/test_reload.py +0 -120
  113. /package/{vendor → payload}/addon/Media/GitHub.png +0 -0
  114. /package/{vendor → payload}/addon/Media/Logo.png +0 -0
  115. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Forever.lua +0 -0
  116. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mainline.lua +0 -0
  117. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mists.lua +0 -0
  118. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Titan.lua +0 -0
@@ -0,0 +1,163 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ local binding
4
+ local boundRoot
5
+ local generation = 0
6
+ local runtimeEpoch, epochRoot
7
+ local pendingInput
8
+ local focusEvent = "ChatFrame.OnEditBoxFocusLost"
9
+ local function cancelInput()
10
+ local pending = pendingInput
11
+ pendingInput = nil
12
+ if pending then pending.registry:UnregisterCallback(focusEvent, pending) end
13
+ end
14
+ local function context()
15
+ local state, failure = ns.Persistence.Current()
16
+ if not state then return nil, failure end
17
+ if not ns.Startup.ready or not state.options or state.options.bridgeEnabled ~= true then
18
+ return nil, "bridge_disabled"
19
+ end
20
+ local actor, reason = ns.Platform.ObserveActor()
21
+ return actor, reason, state
22
+ end
23
+ local function copy(value)
24
+ return { sessionNonce = value.sessionNonce, character = value.character,
25
+ realm = value.realm, guid = value.guid, sequence = value.sequence, generation = value.generation,
26
+ runtimeEpoch = value.runtimeEpoch }
27
+ end
28
+ local function current()
29
+ local actor, failure, state = context()
30
+ if not actor then cancelInput(); binding, boundRoot = nil, nil; return nil, failure end
31
+ if not binding then return nil, "session_unbound" end
32
+ -- Retain only root identity for invalidation, never read settings through it.
33
+ if state ~= boundRoot then cancelInput(); binding, boundRoot = nil, nil; return nil, "session_state_changed" end
34
+ if (issecretvalue and issecretvalue(state.runtimeEpoch)) or state.runtimeEpoch ~= runtimeEpoch then
35
+ cancelInput(); binding, boundRoot = nil, nil; return nil, "session_epoch_changed"
36
+ end
37
+ if actor.character ~= binding.character or actor.realm ~= binding.realm or actor.guid ~= binding.guid then
38
+ cancelInput()
39
+ binding, boundRoot = nil, nil
40
+ return nil, "session_actor_changed"
41
+ end
42
+ return copy(binding)
43
+ end
44
+
45
+ ns.Session = {
46
+ Current = current,
47
+ CancelInputWait = cancelInput,
48
+ Connect = function()
49
+ local active = current()
50
+ if active then return active end
51
+ local actor, failure = context()
52
+ if not actor then return nil, failure end
53
+ if generation >= 9007199254740991 then return nil, "session_generation_exhausted" end
54
+ -- A visible correlation marker, not a password or input permission.
55
+ -- A counter prevents reuse in this runtime without reseeding WoW's RNG;
56
+ -- native process identity and actor checks distinguish other runtimes.
57
+ local nextGeneration = generation + 1
58
+ local nonce = string.format("%04x%04x%04x%04x%08x%08x",
59
+ math.random(0, 65535), math.random(0, 65535),
60
+ math.random(0, 65535), math.random(0, 65535),
61
+ math.floor(nextGeneration / 4294967296), nextGeneration % 4294967296)
62
+ return ns.Session.Bind(nonce)
63
+ end,
64
+ ReadyReceipt = function()
65
+ local active, failure = current()
66
+ if not active then return nil, failure end
67
+ local eligible = false
68
+ if type(ns.Platform.ObserveInputState) == "function" then
69
+ eligible = ns.Platform.ObserveInputState() == true
70
+ end
71
+ local identity, identityFailure = ns.Session.NextIdentity()
72
+ if not identity then return nil, identityFailure end
73
+ return ns.CaptureWriter.Encode({
74
+ schema = "lycheedev.signal.v1", release = ns.Release, kind = "ready",
75
+ sessionNonce = identity.sessionNonce, requestId = "",
76
+ character = identity.character, realm = identity.realm, guid = identity.guid,
77
+ product = ns.Startup.identity.product, build = ns.Startup.identity.build,
78
+ sequence = identity.sequence, inputReady = eligible,
79
+ runtimeEpoch = identity.runtimeEpoch,
80
+ }, 4096)
81
+ end,
82
+ -- One request-scoped callback, never a timer or permanent focus listener.
83
+ -- A focus event only prompts a fresh observation; it is not itself proof.
84
+ WhenInputReady = function(callback)
85
+ if type(callback) ~= "function" then return nil, "input_invalid_callback" end
86
+ local active, failure = current()
87
+ if not active then return nil, failure end
88
+ if pendingInput then return nil, "input_wait_busy" end
89
+ if type(ns.Platform.ObserveInputState) ~= "function" then return nil, "input_observation_unavailable" end
90
+ local ready, reason = ns.Platform.ObserveInputState()
91
+ if ready then callback(true); return true end
92
+ if reason ~= "input_keyboard_focus" then return nil, reason end
93
+ if type(EventRegistry) ~= "table" or type(EventRegistry.RegisterCallback) ~= "function"
94
+ or type(EventRegistry.UnregisterCallback) ~= "function" then
95
+ return nil, "input_events_unavailable"
96
+ end
97
+ local pending = { registry = EventRegistry, generation = active.generation }
98
+ pendingInput = pending
99
+ pending.registry:RegisterCallback(focusEvent, function()
100
+ if pendingInput ~= pending then return end
101
+ cancelInput()
102
+ local now, sessionFailure = current()
103
+ if not now or now.generation ~= pending.generation then
104
+ callback(false, sessionFailure or "input_session_changed")
105
+ return
106
+ end
107
+ local eligible, observeFailure = ns.Platform.ObserveInputState()
108
+ callback(eligible == true, observeFailure)
109
+ end, pending)
110
+ return true
111
+ end,
112
+ NextIdentity = function(afterSequence)
113
+ local active, failure = current()
114
+ if not active then return nil, failure end
115
+ if (issecretvalue and issecretvalue(afterSequence)) then return nil, "session_invalid_sequence" end
116
+ if afterSequence == nil then afterSequence = 0 end
117
+ if type(afterSequence) ~= "number" or afterSequence < 0 or afterSequence > 9007199254740991
118
+ or afterSequence % 1 ~= 0 then return nil, "session_invalid_sequence" end
119
+ local previous = math.max(binding.sequence, afterSequence)
120
+ if previous >= 9007199254740991 then return nil, "session_sequence_exhausted" end
121
+ binding.sequence = previous + 1
122
+ return copy(binding)
123
+ end,
124
+ Bind = function(nonce)
125
+ if (issecretvalue and issecretvalue(nonce)) or type(nonce) ~= "string"
126
+ or #nonce ~= 32 or not string.match(nonce, "^[0-9a-f]+$") then
127
+ return nil, "session_invalid_nonce"
128
+ end
129
+ local actor, failure, state = context()
130
+ if not actor then cancelInput(); binding, boundRoot = nil, nil; return nil, failure end
131
+ local previousEpoch = state.runtimeEpoch
132
+ if previousEpoch == nil then previousEpoch = 0 end
133
+ if (issecretvalue and issecretvalue(previousEpoch)) or type(previousEpoch) ~= "number"
134
+ or previousEpoch < 0 or previousEpoch % 1 ~= 0 or previousEpoch >= 9007199254740991 then
135
+ return nil, "session_invalid_epoch"
136
+ end
137
+ -- Allocate once per Lua runtime, only after opt-in and actor validation.
138
+ -- Persist a monotonic marker, never the binding nonce or input permission.
139
+ -- A profile re-root must not silently reuse another root's epoch.
140
+ if state == epochRoot and previousEpoch ~= runtimeEpoch then return nil, "session_epoch_changed" end
141
+ if binding and state == boundRoot and actor.character == binding.character and actor.realm == binding.realm and actor.guid == binding.guid then
142
+ if binding.sessionNonce ~= nonce then return nil, "session_busy" end
143
+ return copy(binding)
144
+ end
145
+ if generation >= 9007199254740991 then return nil, "session_generation_exhausted" end
146
+ if state ~= epochRoot then
147
+ local last = math.max(previousEpoch, runtimeEpoch or 0)
148
+ if last >= 9007199254740991 then return nil, "session_invalid_epoch" end
149
+ runtimeEpoch = last + 1
150
+ state.runtimeEpoch = runtimeEpoch
151
+ epochRoot = state
152
+ end
153
+ cancelInput()
154
+ generation = generation + 1
155
+ binding = { sessionNonce = nonce, character = actor.character, realm = actor.realm, guid = actor.guid, sequence = 0, generation = generation, runtimeEpoch = runtimeEpoch }
156
+ boundRoot = state
157
+ return copy(binding)
158
+ end,
159
+ Release = function()
160
+ cancelInput()
161
+ binding, boundRoot = nil, nil
162
+ end,
163
+ }
@@ -0,0 +1,2 @@
1
+ local ADDON_NAME, ns = ...
2
+ ns.PlatformProfile = { product = "forever", version = "1.60.1", interface = 16001 }
@@ -0,0 +1,2 @@
1
+ local ADDON_NAME, ns = ...
2
+ ns.PlatformProfile = { product = "retail", version = "12.1.0", interface = 120100 }
@@ -0,0 +1,2 @@
1
+ local ADDON_NAME, ns = ...
2
+ ns.PlatformProfile = { product = "classic", version = "5.5.4", interface = 50504 }
@@ -0,0 +1,2 @@
1
+ local ADDON_NAME, ns = ...
2
+ ns.PlatformProfile = { product = "titan", version = "3.80.2", interface = 38002 }
@@ -0,0 +1,59 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ -- One shared API surface for verified client differences needed by the
4
+ -- workbench. Every value that crosses a trust boundary is checked for secrecy
5
+ -- before it is compared, formatted, indexed or branched on; failures open to a
6
+ -- harmless visible state instead of throwing.
7
+ ns.Compat = {
8
+ GetAddOnMetadata = function(addonName, field)
9
+ if type(C_AddOns) ~= "table" or type(C_AddOns.GetAddOnMetadata) ~= "function" then
10
+ return nil
11
+ end
12
+ if (issecretvalue and (issecretvalue(addonName) or issecretvalue(field))) then
13
+ return nil
14
+ end
15
+ local succeeded, value = pcall(C_AddOns.GetAddOnMetadata, addonName, field)
16
+ if not succeeded or (issecretvalue and issecretvalue(value)) then
17
+ return nil
18
+ end
19
+ return value
20
+ end,
21
+
22
+ GetMouseFocus = function()
23
+ if type(GetMouseFoci) ~= "function" then
24
+ return nil
25
+ end
26
+ local succeeded, foci = pcall(GetMouseFoci)
27
+ if not succeeded or (issecretvalue and issecretvalue(foci))
28
+ or type(foci) ~= "table" or not foci[1]
29
+ or (issecretvalue and issecretvalue(foci[1])) then
30
+ return nil
31
+ end
32
+ return foci[1]
33
+ end,
34
+
35
+ -- UI units per physical screen pixel, for screen-space overlays such as
36
+ -- the automation status blocks and QR notice. GetPhysicalScreenSize was
37
+ -- verified on the Retail 12.1.0 baseline only; other clients use the
38
+ -- legacy 768-height approximation until verified.
39
+ GetPhysicalPixelSize = function()
40
+ if GetPhysicalScreenSize then
41
+ local succeeded, width, height = pcall(GetPhysicalScreenSize)
42
+ if succeeded and not (issecretvalue and (issecretvalue(width) or issecretvalue(height)))
43
+ and width and width > 0 and GetScreenWidth then
44
+ local uiWidth = GetScreenWidth()
45
+ if uiWidth and uiWidth > 0 and not (issecretvalue and issecretvalue(uiWidth)) then
46
+ return uiWidth / width
47
+ end
48
+ end
49
+ end
50
+ -- Fallback for clients without a verified GetPhysicalScreenSize: the
51
+ -- legacy 768-height approximation treats the screen as 768 physical
52
+ -- pixels tall, so one physical pixel spans (uiHeight / 768) UI units.
53
+ local uiHeight = GetScreenHeight and GetScreenHeight() or nil
54
+ if uiHeight and uiHeight > 0 and not (issecretvalue and issecretvalue(uiHeight)) then
55
+ return uiHeight / 768
56
+ end
57
+ return 1
58
+ end,
59
+ }
@@ -0,0 +1,168 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ local registered = false
4
+ local function restricted(value)
5
+ return issecretvalue and issecretvalue(value)
6
+ end
7
+
8
+ ns.Controls = {
9
+ Handle = function(message)
10
+ if restricted(message) or type(message) ~= "string" or #message > 256 then
11
+ return nil, "command_invalid_input"
12
+ end
13
+ local trimmed = string.match(message, "^%s*(.-)%s*$")
14
+ local command = string.lower(trimmed)
15
+ local nonce = string.match(command, "^bridge bind ([0-9a-f]+)$")
16
+ local identify = string.match(command, "^bridge identify ([0-9a-f]+)$")
17
+ local prefix, verb, requestId = string.match(trimmed, "^(%S+)%s+(%S+)%s+([%w_%-]+)$")
18
+ local action, reportSequence
19
+ local verifyPrefix, verifyVerb, verifyRequest, cleanupNonce = string.match(trimmed, "^(%S+)%s+(%S+)%s+([%w_%-]+)%s+([0-9a-f]+)$")
20
+ if verifyPrefix and string.lower(verifyPrefix) == "bridge" and string.lower(verifyVerb) == "verify"
21
+ and #verifyRequest <= 128 and #cleanupNonce == 32 then
22
+ action, requestId = "verify", verifyRequest
23
+ end
24
+ if verifyPrefix and string.lower(verifyPrefix) == "bridge" and string.lower(verifyVerb) == "clean"
25
+ and #verifyRequest <= 128 and #cleanupNonce == 32 then
26
+ action, requestId = "clean", verifyRequest
27
+ end
28
+ if verifyPrefix and string.lower(verifyPrefix) == "bridge" and string.lower(verifyVerb) == "prepare"
29
+ and #verifyRequest <= 128 and #cleanupNonce == 32 then
30
+ action, requestId = "prepare", verifyRequest
31
+ end
32
+ if verifyPrefix and string.lower(verifyPrefix) == "bridge" and string.lower(verifyVerb) == "ack"
33
+ and #verifyRequest <= 128 and #cleanupNonce <= 16 and string.match(cleanupNonce, "^[1-9]%d*$") then
34
+ action, requestId, reportSequence = "ack", verifyRequest, tonumber(cleanupNonce)
35
+ end
36
+ if command == "bridge ready" then action = "ready" end
37
+ if prefix and string.lower(prefix) == "bridge" and #requestId <= 128 then
38
+ verb = string.lower(verb)
39
+ if verb == "load" or verb == "run" or verb == "reload" then action = verb end
40
+ end
41
+ if command ~= "" and command ~= "status" and command ~= "connect" and command ~= "disconnect" and command ~= "bridge on" and command ~= "bridge off"
42
+ and command ~= "bridge unbind" and not nonce and not identify and not action then
43
+ return nil, "usage: /dev status | connect | disconnect"
44
+ end
45
+ if not ns.Startup.ready then return nil, ns.Startup.reason or "addon_not_ready" end
46
+ -- Bare /dev toggles the workbench. Everything below keeps the exact
47
+ -- status/connect/disconnect/bridge parsing contract.
48
+ if command == "" then
49
+ local shown, reason = ns.Workbench.Toggle()
50
+ if reason then
51
+ print("|cffd83b4eLychee Dev:|r " .. tostring(reason))
52
+ end
53
+ return true
54
+ end
55
+ local state, failure = ns.Persistence.Current()
56
+ if not state then return nil, failure end
57
+ if command == "connect" then
58
+ if not state.options then state.options = {} end
59
+ local previous = state.options.bridgeEnabled
60
+ state.options.bridgeEnabled = true
61
+ local connected, reason = ns.Session.Connect()
62
+ if not connected then state.options.bridgeEnabled = previous; return nil, reason end
63
+ action = "ready"
64
+ end
65
+ if identify then
66
+ -- Identity markers are session-free and never disturb another
67
+ -- operation's displayed receipt: Trigger fails closed when busy.
68
+ local receipt, reason = ns.Identity.Trigger(identify)
69
+ if not receipt then return nil, reason end
70
+ local shown, displayFailure = ns.ReceiptView.ShowIdentity(receipt)
71
+ if not shown then return nil, displayFailure end
72
+ ns.Identity.WhenInputReady(function(ready)
73
+ if not ready then return end
74
+ local refreshed, refreshFailure = ns.Identity.Refresh(identify)
75
+ if not refreshed then print("Lychee Dev: " .. refreshFailure); return end
76
+ local visible, showFailure = ns.ReceiptView.ShowIdentity(refreshed)
77
+ if not visible then ns.ReceiptView.Hide(); print("Lychee Dev: " .. showFailure) end
78
+ end)
79
+ return receipt
80
+ end
81
+ if action then
82
+ if action == "prepare" then return ns.Reentry.LoadQueue(requestId, cleanupNonce) end
83
+ if action == "clean" then return ns.Reentry.Reload(requestId, cleanupNonce) end
84
+ if action == "reload" then return ns.Reentry.Reload(requestId) end
85
+ -- Remove the old optical signal before loading or executing work.
86
+ -- Preserve request ID case; only command words are case-insensitive.
87
+ ns.Session.CancelInputWait()
88
+ ns.ReceiptView.Hide()
89
+ local receipt, reason
90
+ if action == "load" then receipt, reason = ns.ProbeQueue.Load(requestId)
91
+ elseif action == "ready" then receipt, reason = ns.Session.ReadyReceipt()
92
+ elseif action == "ack" then receipt, reason = ns.ProbeQueue.Acknowledge(requestId, reportSequence)
93
+ elseif action == "verify" then receipt, reason = ns.ProbeQueue.VerifyRetired(requestId, cleanupNonce)
94
+ else receipt, reason = ns.ProbeRunner.Dispatch(requestId) end
95
+ if not receipt then return nil, reason end
96
+ local shown, displayFailure = ns.ReceiptView.Show(receipt)
97
+ if not shown then return nil, displayFailure end
98
+ if action == "load" or action == "ready" or action == "run" or action == "ack" then
99
+ ns.Session.WhenInputReady(function(ready)
100
+ if not ready then return end
101
+ local refreshed, refreshFailure
102
+ if action == "ready" or action == "run" or action == "ack" then refreshed, refreshFailure = ns.Session.ReadyReceipt()
103
+ else refreshed, refreshFailure = ns.ProbeRunner.RefreshLoaded(requestId) end
104
+ if not refreshed then print("Lychee Dev: " .. refreshFailure); return end
105
+ local visible, reason
106
+ if action == "run" or action == "ack" then visible, reason = ns.ReceiptView.Show(receipt, refreshed)
107
+ else visible, reason = ns.ReceiptView.Show(refreshed) end
108
+ if not visible then ns.ReceiptView.Hide(); print("Lychee Dev: " .. reason); return end
109
+ if action ~= "run" and action ~= "ack" then receipt = refreshed end
110
+ end)
111
+ end
112
+ if command == "connect" then
113
+ local active = ns.Session.Current()
114
+ return { connected = true, character = active.character, realm = active.realm,
115
+ product = ns.Startup.identity.product, build = ns.Startup.identity.build }
116
+ end
117
+ return receipt
118
+ end
119
+ if command == "bridge on" or command == "bridge off" or command == "disconnect" then
120
+ if not state.options then state.options = {} end
121
+ -- Disabled is the default, not a persisted copy of that default.
122
+ -- Reports survive opt-out; disabling never acknowledges or deletes.
123
+ state.options.bridgeEnabled = command == "bridge on" and true or nil
124
+ if command ~= "bridge on" then
125
+ if ns.Reentry then ns.Reentry.Cancel(true) end
126
+ ns.Session.Release(); ns.ReceiptView.Hide()
127
+ end
128
+ end
129
+ if command == "bridge unbind" then
130
+ if ns.Reentry then ns.Reentry.Cancel(true) end
131
+ ns.Session.Release(); ns.ReceiptView.Hide()
132
+ end
133
+ if nonce then
134
+ local bound, reason = ns.Session.Bind(nonce)
135
+ if not bound then return nil, reason end
136
+ end
137
+ local enabled = state.options and state.options.bridgeEnabled == true or false
138
+ local session = ns.Session.Current()
139
+ return {
140
+ release = ns.Release, product = ns.Startup.identity.product,
141
+ build = ns.Startup.identity.build, enabled = enabled,
142
+ bound = session ~= nil, session = session,
143
+ -- Configuration is not input eligibility. Session binding and the
144
+ -- live transport must supply their own observed readiness later.
145
+ inputReady = false, reason = enabled and "transport_unavailable" or "bridge_disabled",
146
+ }
147
+ end,
148
+ Register = function()
149
+ if registered then return true end
150
+ if not ns.Startup.ready then return nil, "addon_not_ready" end
151
+ if restricted(SlashCmdList) or type(SlashCmdList) ~= "table"
152
+ or restricted(SlashCmdList.LYCHEETOOLKIT) or SlashCmdList.LYCHEETOOLKIT ~= nil
153
+ or restricted(SLASH_LYCHEETOOLKIT1) or SLASH_LYCHEETOOLKIT1 ~= nil then
154
+ return nil, "command_registration_conflict"
155
+ end
156
+ SLASH_LYCHEETOOLKIT1 = "/dev"
157
+ SlashCmdList.LYCHEETOOLKIT = function(message)
158
+ local result, failure = ns.Controls.Handle(message)
159
+ if not result then print("Lychee Dev: " .. failure); return end
160
+ if result == true then return end
161
+ if type(result) == "string" then print("Lychee Dev: " .. result); return end
162
+ local text, reason = ns.CaptureWriter.Encode(result, 4096)
163
+ print("Lychee Dev: " .. (text or reason))
164
+ end
165
+ registered = true
166
+ return true
167
+ end,
168
+ }
@@ -1,6 +1,10 @@
1
1
  local ADDON_NAME, ns = ...
2
2
  local L = ns.L
3
3
 
4
+ -- Explicit /run executor. Compile and runtime errors are returned as data, the
5
+ -- sandbox captures print/dump output under a hard byte cap, and the captured
6
+ -- globals never leak into _G. Global reads and writes pass through to _G so a
7
+ -- run behaves exactly like a chat /run.
4
8
  local MAX_CAPTURE_BYTES = 44000
5
9
 
6
10
  local function AddOutput(output, text)
@@ -54,7 +58,7 @@ local function BuildEnvironment(output)
54
58
  end
55
59
 
56
60
  environment.dump = function(value)
57
- AddOutput(output, ns.Serialize(value))
61
+ AddOutput(output, ns.Serializer.Serialize(value))
58
62
  return value
59
63
  end
60
64
 
@@ -66,8 +70,11 @@ local function Pack(...)
66
70
  return { n = select("#", ...), ... }
67
71
  end
68
72
 
73
+ -- Returns: succeeded, resultText, normalizedCode, liveTree, storedTree.
74
+ -- Failure paths return (false, resultText, normalizedCode); the trees are only
75
+ -- built for successful return values.
69
76
  function ns.Execute(code)
70
- if ns.IsCombatBlocked() then
77
+ if ns.Safety.IsCombatBlocked() then
71
78
  return false, ns.L.COMBAT_BLOCKED, ""
72
79
  end
73
80
  code = NormalizeCode(code)
@@ -101,31 +108,13 @@ function ns.Execute(code)
101
108
  end
102
109
 
103
110
  if values.n > 0 then
104
- AddOutput(output, ns.SerializeValues(values))
111
+ AddOutput(output, ns.Serializer.SerializeValues(values))
105
112
  end
106
113
 
107
114
  if #output.parts == 0 then
108
115
  AddOutput(output, L.COMPLETED_NO_OUTPUT)
109
116
  end
110
117
 
111
- return true, table.concat(output.parts), code, ns.CreateValueTree(values), ns.CreateStoredValueTree(values)
112
- end
113
-
114
- SLASH_LYCHEEDEV1 = "/dev"
115
- SlashCmdList.LYCHEEDEV = function(message)
116
- local text = tostring(message or "")
117
- local action = text:match("^(%S+)")
118
- if action and action:lower() == "auto" then
119
- if ns.Automation and ns.Automation.HandleCommand then
120
- ns.Automation.HandleCommand(text:match("^%S+%s*(.-)%s*$") or "")
121
- end
122
- return
123
- end
124
- if ns.IsCombatBlocked() then
125
- ns.PrintCombatBlocked()
126
- return
127
- end
128
- ns.EnsureSafety()
129
- ns.InitializeDatabase()
130
- ns.ToggleWindow()
118
+ return true, table.concat(output.parts), code,
119
+ ns.Inspector.CreateLiveTree(values), ns.Inspector.CreateStoredTree(values)
131
120
  end