lycheedev 1.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.
- package/bin/lycheedev.js +257 -0
- package/package.json +42 -0
- package/src/addon.js +87 -0
- package/src/config.js +64 -0
- package/src/doctor.js +100 -0
- package/src/install.js +131 -0
- package/src/paths.js +93 -0
- package/src/python.js +107 -0
- package/src/skill.js +48 -0
- package/src/wow.js +110 -0
- package/vendor/addon/Core/Bootstrap.lua +131 -0
- package/vendor/addon/Core/Clients/Mainline.lua +9 -0
- package/vendor/addon/Core/Clients/Mists.lua +9 -0
- package/vendor/addon/Core/Clients/Titan.lua +9 -0
- package/vendor/addon/Core/Compatibility.lua +43 -0
- package/vendor/addon/Core/Database.lua +859 -0
- package/vendor/addon/Core/Inspector.lua +647 -0
- package/vendor/addon/Core/Locale.lua +307 -0
- package/vendor/addon/Core/Locale_enUS.lua +318 -0
- package/vendor/addon/Core/Safety.lua +42 -0
- package/vendor/addon/Core/Serializer.lua +324 -0
- package/vendor/addon/Libs/AutomationQR.lua +1176 -0
- package/vendor/addon/Lychee Dev_Mainline.toc +43 -0
- package/vendor/addon/Lychee Dev_Mists.toc +43 -0
- package/vendor/addon/Lychee Dev_Wrath.toc +43 -0
- package/vendor/addon/Media/GitHub.png +0 -0
- package/vendor/addon/Media/Logo.png +0 -0
- package/vendor/addon/Modules/Automation/Controller.lua +757 -0
- package/vendor/addon/Modules/Automation/Report.lua +409 -0
- package/vendor/addon/Modules/Automation/auto/auto.lua +12 -0
- package/vendor/addon/Modules/Diagnostics.lua +238 -0
- package/vendor/addon/Modules/Events/Catalog.lua +184 -0
- package/vendor/addon/Modules/Events/CatalogData_Mainline.lua +1788 -0
- package/vendor/addon/Modules/Events/CatalogData_Mists.lua +1489 -0
- package/vendor/addon/Modules/Events/CatalogData_Titan.lua +1492 -0
- package/vendor/addon/Modules/Events/Monitor.lua +181 -0
- package/vendor/addon/Modules/FunctionTrace.lua +85 -0
- package/vendor/addon/Modules/ObjectInspector.lua +329 -0
- package/vendor/addon/UI/AutomationOverlay.lua +183 -0
- package/vendor/addon/UI/Export.lua +140 -0
- package/vendor/addon/UI/Features.lua +890 -0
- package/vendor/addon/UI/MainWindow.lua +1145 -0
- package/vendor/addon/UI/Pages/About.lua +223 -0
- package/vendor/addon/UI/Pages/Automation.lua +417 -0
- package/vendor/addon/UI/Pages/Diagnostics.lua +289 -0
- package/vendor/addon/UI/Pages/ExportRecords.lua +387 -0
- package/vendor/addon/UI/Pages/Object.lua +573 -0
- package/vendor/addon/UI/Pages/Trace.lua +165 -0
- package/vendor/skill/SKILL.md +94 -0
- package/vendor/skill/agents/openai.yaml +4 -0
- package/vendor/skill/references/automation.md +327 -0
- package/vendor/skill/references/runtime-investigations.md +97 -0
- package/vendor/skill/scripts/automation/__init__.py +1 -0
- package/vendor/skill/scripts/automation/registry.py +516 -0
- package/vendor/skill/scripts/automation/saved_variables.py +438 -0
- package/vendor/skill/scripts/automation/session.py +207 -0
- package/vendor/skill/scripts/automation/windows.py +573 -0
- package/vendor/skill/scripts/automation.py +865 -0
- package/vendor/skill/scripts/requirements.txt +13 -0
- package/vendor/skill/scripts/selftest_offline.py +981 -0
package/src/paths.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Shared paths and small filesystem helpers. */
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
/** Package root (the directory that holds package.json). */
|
|
11
|
+
export const packageRoot = path.resolve(here, '..');
|
|
12
|
+
|
|
13
|
+
/** Vendored payload shipped inside the npm package. */
|
|
14
|
+
export const vendorRoot = path.join(packageRoot, 'vendor');
|
|
15
|
+
|
|
16
|
+
/** The addon folder name WoW expects. The TOC files reference it, so it keeps
|
|
17
|
+
* its display capitalization even though the npm package name is lowercase. */
|
|
18
|
+
export const addonFolderName = 'Lychee Dev';
|
|
19
|
+
|
|
20
|
+
export function homeDir() {
|
|
21
|
+
return process.env.LYCHEEDEV_HOME || os.homedir();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function dataDir() {
|
|
25
|
+
return path.join(homeDir(), '.lycheedev');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function configPath() {
|
|
29
|
+
return path.join(dataDir(), 'config.json');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** pip --target directory that holds the automation helper dependencies. */
|
|
33
|
+
export function pythonDepsDir() {
|
|
34
|
+
return path.join(dataDir(), 'python');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function skillsDir() {
|
|
38
|
+
return path.join(homeDir(), '.agents', 'skills');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function skillTargetDir() {
|
|
42
|
+
return path.join(skillsDir(), 'lycheedev');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function exists(target) {
|
|
46
|
+
try {
|
|
47
|
+
fs.statSync(target);
|
|
48
|
+
return true;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function isDir(target) {
|
|
55
|
+
try {
|
|
56
|
+
return fs.statSync(target).isDirectory();
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function readJson(target, fallback = null) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(fs.readFileSync(target, 'utf8'));
|
|
65
|
+
} catch {
|
|
66
|
+
return fallback;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function writeJson(target, value) {
|
|
71
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
72
|
+
fs.writeFileSync(target, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Copy a directory tree, skipping build noise. */
|
|
76
|
+
export function copyTree(from, to, { filter = null } = {}) {
|
|
77
|
+
fs.mkdirSync(to, { recursive: true });
|
|
78
|
+
for (const entry of fs.readdirSync(from, { withFileTypes: true })) {
|
|
79
|
+
const source = path.join(from, entry.name);
|
|
80
|
+
if (filter && !filter(source, entry)) continue;
|
|
81
|
+
const target = path.join(to, entry.name);
|
|
82
|
+
if (entry.isDirectory()) {
|
|
83
|
+
copyTree(source, target, { filter });
|
|
84
|
+
} else if (entry.isFile()) {
|
|
85
|
+
fs.copyFileSync(source, target);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Drop a directory tree if it is there. */
|
|
91
|
+
export function removeTree(target) {
|
|
92
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
93
|
+
}
|
package/src/python.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** Install and run the Python automation helper that the CLI delegates to. */
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
import { dataDir, exists, pythonDepsDir, vendorRoot } from './paths.js';
|
|
8
|
+
|
|
9
|
+
const REQUIREMENTS = path.join(vendorRoot, 'skill', 'scripts', 'requirements.txt');
|
|
10
|
+
export const automationScript = path.join(vendorRoot, 'skill', 'scripts', 'automation.py');
|
|
11
|
+
|
|
12
|
+
/** Candidate interpreters, in the order we prefer them. */
|
|
13
|
+
export function pythonCandidates(explicit = null) {
|
|
14
|
+
if (explicit) return [explicit];
|
|
15
|
+
const list = [];
|
|
16
|
+
if (process.env.LYCHEEDEV_PYTHON) list.push(process.env.LYCHEEDEV_PYTHON);
|
|
17
|
+
if (process.platform === 'win32') {
|
|
18
|
+
list.push('python', 'python3', 'py');
|
|
19
|
+
} else {
|
|
20
|
+
list.push('python3', 'python');
|
|
21
|
+
}
|
|
22
|
+
return list;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function run(command, args, options = {}) {
|
|
26
|
+
const result = spawnSync(command, args, {
|
|
27
|
+
encoding: 'utf8',
|
|
28
|
+
windowsHide: true,
|
|
29
|
+
...options,
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
ok: result.status === 0,
|
|
33
|
+
status: result.status,
|
|
34
|
+
stdout: (result.stdout || '').trim(),
|
|
35
|
+
stderr: (result.stderr || '').trim(),
|
|
36
|
+
error: result.error ? result.error.message : null,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Find a working Python 3 interpreter, or null. */
|
|
41
|
+
export function findPython(explicit = null) {
|
|
42
|
+
for (const candidate of pythonCandidates(explicit)) {
|
|
43
|
+
const probe = run(candidate, ['-c', 'import sys; print(sys.version_info[0])']);
|
|
44
|
+
if (probe.ok && probe.stdout.startsWith('3')) {
|
|
45
|
+
return { bin: candidate, version: run(candidate, ['--version']).stdout };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function depsInstalled() {
|
|
52
|
+
const marker = path.join(pythonDepsDir(), 'zxingcpp');
|
|
53
|
+
return exists(marker);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Environment that makes the vendored helper import the installed packages. */
|
|
57
|
+
export function pythonEnv() {
|
|
58
|
+
const deps = pythonDepsDir();
|
|
59
|
+
const existing = process.env.PYTHONPATH;
|
|
60
|
+
return {
|
|
61
|
+
...process.env,
|
|
62
|
+
PYTHONPATH: existing ? `${deps}${path.delimiter}${existing}` : deps,
|
|
63
|
+
PYTHONDONTWRITEBYTECODE: '1',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Install the pinned optional dependencies into ~/.lycheedev/python.
|
|
69
|
+
*
|
|
70
|
+
* They live outside the package so npm can stay dependency-free and a global
|
|
71
|
+
* install never needs write access to site-packages.
|
|
72
|
+
*/
|
|
73
|
+
export function installDeps({ pythonBin, quiet = false, onLine = null } = {}) {
|
|
74
|
+
const python = pythonBin || (findPython() || {}).bin;
|
|
75
|
+
if (!python) {
|
|
76
|
+
return { ok: false, error: 'no Python 3 interpreter found on PATH' };
|
|
77
|
+
}
|
|
78
|
+
if (!exists(REQUIREMENTS)) {
|
|
79
|
+
return { ok: false, error: `requirements file is missing: ${REQUIREMENTS}` };
|
|
80
|
+
}
|
|
81
|
+
fs.mkdirSync(dataDir(), { recursive: true });
|
|
82
|
+
const args = ['-m', 'pip', 'install', '--upgrade', '--no-input',
|
|
83
|
+
'--target', pythonDepsDir(), '-r', REQUIREMENTS];
|
|
84
|
+
const result = run(python, args, {
|
|
85
|
+
stdio: quiet ? 'pipe' : 'inherit',
|
|
86
|
+
env: process.env,
|
|
87
|
+
});
|
|
88
|
+
if (!result.ok && quiet && onLine) onLine(result.stderr);
|
|
89
|
+
if (result.ok && onLine) onLine('python dependencies installed');
|
|
90
|
+
return { ok: result.ok, status: result.status, error: result.error, dir: pythonDepsDir() };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Run the delegated automation CLI with the pinned dependency path. */
|
|
94
|
+
export function runAutomation(args, { pythonBin = null, inherit = true } = {}) {
|
|
95
|
+
const python = pythonBin || (findPython() || {}).bin;
|
|
96
|
+
if (!python) {
|
|
97
|
+
return { ok: false, status: 1, stderr: 'no Python 3 interpreter found on PATH' };
|
|
98
|
+
}
|
|
99
|
+
return run(python, ['-B', automationScript, ...args], {
|
|
100
|
+
stdio: inherit ? 'inherit' : 'pipe',
|
|
101
|
+
env: pythonEnv(),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function requirementsPath() {
|
|
106
|
+
return REQUIREMENTS;
|
|
107
|
+
}
|
package/src/skill.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Install the vendored skill into ~/.agents/skills/lycheedev. */
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { copyTree, exists, removeTree, skillTargetDir, vendorRoot } from './paths.js';
|
|
7
|
+
|
|
8
|
+
export function vendoredSkillRoot() {
|
|
9
|
+
return path.join(vendorRoot, 'skill');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function skillVersion() {
|
|
13
|
+
const skillFile = path.join(vendoredSkillRoot(), 'SKILL.md');
|
|
14
|
+
try {
|
|
15
|
+
const text = fs.readFileSync(skillFile, 'utf8');
|
|
16
|
+
const match = text.match(/^version:\s*(.+)$/m);
|
|
17
|
+
return match ? match[1].trim() : null;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function countFiles(dir) {
|
|
24
|
+
let total = 0;
|
|
25
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
26
|
+
if (entry.isDirectory()) total += countFiles(path.join(dir, entry.name));
|
|
27
|
+
else total += 1;
|
|
28
|
+
}
|
|
29
|
+
return total;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Replace the installed skill with the vendored copy.
|
|
34
|
+
*
|
|
35
|
+
* The skill is replaced rather than merged: a stale reference file that no
|
|
36
|
+
* longer ships would otherwise stay discoverable forever.
|
|
37
|
+
*/
|
|
38
|
+
export function installSkill() {
|
|
39
|
+
const source = vendoredSkillRoot();
|
|
40
|
+
if (!exists(source)) {
|
|
41
|
+
return { ok: false, error: 'vendored skill payload is missing; reinstall the package' };
|
|
42
|
+
}
|
|
43
|
+
const target = skillTargetDir();
|
|
44
|
+
removeTree(target);
|
|
45
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
46
|
+
copyTree(source, target);
|
|
47
|
+
return { ok: true, target, files: countFiles(target) };
|
|
48
|
+
}
|
package/src/wow.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Locate World of Warcraft installations and their client flavors. */
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { addonFolderName, exists, isDir } from './paths.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Flavor folders the addon supports. `id` is the stable key used by the CLI and
|
|
10
|
+
* by the Python automation profile; `folder` is what Blizzard names it.
|
|
11
|
+
*/
|
|
12
|
+
export const CLIENT_FLAVORS = [
|
|
13
|
+
{ id: 'retail', folder: '_retail_', label: 'Retail (Midnight)' },
|
|
14
|
+
{ id: 'classic', folder: '_classic_', label: 'Classic (Mists)' },
|
|
15
|
+
{ id: 'titan', folder: '_classic_arena', label: 'Classic Titan (Wrath)' },
|
|
16
|
+
{ id: 'classicEra', folder: '_classic_era_', label: 'Classic Era' },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const KNOWN_ROOTS = {
|
|
20
|
+
win32: [
|
|
21
|
+
'C:\\Program Files (x86)\\World of Warcraft',
|
|
22
|
+
'C:\\Program Files\\World of Warcraft',
|
|
23
|
+
'D:\\World of Warcraft',
|
|
24
|
+
'D:\\Game\\World of Warcraft',
|
|
25
|
+
'E:\\World of Warcraft',
|
|
26
|
+
'E:\\Game\\World of Warcraft',
|
|
27
|
+
],
|
|
28
|
+
darwin: ['/Applications/World of Warcraft'],
|
|
29
|
+
linux: [],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function looksLikeWowRoot(dir) {
|
|
33
|
+
if (!isDir(dir)) return false;
|
|
34
|
+
return CLIENT_FLAVORS.some((flavor) => isDir(path.join(dir, flavor.folder)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Directories that contain at least one known flavor folder. */
|
|
38
|
+
export function detectWowRoots() {
|
|
39
|
+
const candidates = [];
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
const push = (dir) => {
|
|
42
|
+
if (!dir || seen.has(dir)) return;
|
|
43
|
+
seen.add(dir);
|
|
44
|
+
if (looksLikeWowRoot(dir)) candidates.push(dir);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
for (const root of KNOWN_ROOTS[process.platform] || []) push(root);
|
|
48
|
+
for (const drive of ['C', 'D', 'E', 'F']) {
|
|
49
|
+
push(`${drive}:\\World of Warcraft`);
|
|
50
|
+
push(`${drive}:\\Game\\World of Warcraft`);
|
|
51
|
+
}
|
|
52
|
+
return candidates;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Describe the flavors present under a root. A given root may hold several
|
|
57
|
+
* (retail + classic), and each gets its own AddOns directory.
|
|
58
|
+
*/
|
|
59
|
+
export function scanClients(wowRoot) {
|
|
60
|
+
const found = [];
|
|
61
|
+
for (const flavor of CLIENT_FLAVORS) {
|
|
62
|
+
const flavorDir = path.join(wowRoot, flavor.folder);
|
|
63
|
+
const addonsDir = path.join(flavorDir, 'Interface', 'AddOns');
|
|
64
|
+
if (!isDir(flavorDir)) continue;
|
|
65
|
+
found.push({
|
|
66
|
+
...flavor,
|
|
67
|
+
flavorDir,
|
|
68
|
+
addonsDir,
|
|
69
|
+
addonsDirExists: isDir(addonsDir),
|
|
70
|
+
installed: exists(path.join(addonsDir, addonFolderName, `${addonFolderName}_Mainline.toc`))
|
|
71
|
+
|| exists(path.join(addonsDir, addonFolderName, `${addonFolderName}_Mists.toc`))
|
|
72
|
+
|| exists(path.join(addonsDir, addonFolderName, `${addonFolderName}_Wrath.toc`)),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return found;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Account-level SavedVariables candidates, newest first. */
|
|
79
|
+
export function findSavedVariablesCandidates(wowRoot, flavorFolder) {
|
|
80
|
+
const accountsDir = path.join(wowRoot, flavorFolder, 'WTF', 'Account');
|
|
81
|
+
if (!isDir(accountsDir)) return [];
|
|
82
|
+
const results = [];
|
|
83
|
+
for (const account of fs.readdirSync(accountsDir, { withFileTypes: true })) {
|
|
84
|
+
if (!account.isDirectory()) continue;
|
|
85
|
+
const file = path.join(accountsDir, account.name, 'SavedVariables', `${addonFolderName}.lua`);
|
|
86
|
+
if (!exists(file)) continue;
|
|
87
|
+
let mtime = 0;
|
|
88
|
+
try {
|
|
89
|
+
mtime = fs.statSync(file).mtimeMs;
|
|
90
|
+
} catch {
|
|
91
|
+
mtime = 0;
|
|
92
|
+
}
|
|
93
|
+
results.push({ account: account.name, path: file, mtime });
|
|
94
|
+
}
|
|
95
|
+
return results.sort((a, b) => b.mtime - a.mtime);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** `Lychee Dev_Mainline.toc` style file for a flavor. */
|
|
99
|
+
export function tocSuffixFor(flavorId) {
|
|
100
|
+
switch (flavorId) {
|
|
101
|
+
case 'retail':
|
|
102
|
+
return 'Mainline';
|
|
103
|
+
case 'classic':
|
|
104
|
+
return 'Mists';
|
|
105
|
+
case 'titan':
|
|
106
|
+
return 'Wrath';
|
|
107
|
+
default:
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
local ADDON_NAME, ns = ...
|
|
2
|
+
local L = ns.L
|
|
3
|
+
|
|
4
|
+
local MAX_CAPTURE_BYTES = 44000
|
|
5
|
+
|
|
6
|
+
local function AddOutput(output, text)
|
|
7
|
+
if output.truncated then
|
|
8
|
+
return
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
text = tostring(text or "")
|
|
12
|
+
local prefix = #output.parts > 0 and "\n" or ""
|
|
13
|
+
local remaining = MAX_CAPTURE_BYTES - output.length - #prefix
|
|
14
|
+
if #text > remaining then
|
|
15
|
+
output.parts[#output.parts + 1] = prefix
|
|
16
|
+
.. text:sub(1, math.max(0, remaining))
|
|
17
|
+
.. "\n... <output truncated>"
|
|
18
|
+
output.truncated = true
|
|
19
|
+
output.length = output.length + #output.parts[#output.parts]
|
|
20
|
+
return
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
output.parts[#output.parts + 1] = prefix .. text
|
|
24
|
+
output.length = output.length + #prefix + #text
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
local function NormalizeCode(code)
|
|
28
|
+
code = type(code) == "string" and code or ""
|
|
29
|
+
code = code:gsub("^%s+", ""):gsub("%s+$", "")
|
|
30
|
+
|
|
31
|
+
local prefixEnd = code:match("^/[Rr][Uu][Nn]%s+()")
|
|
32
|
+
or code:match("^/[Ss][Cc][Rr][Ii][Pp][Tt]%s+()")
|
|
33
|
+
if prefixEnd then
|
|
34
|
+
code = code:sub(prefixEnd)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
return code
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
local function BuildEnvironment(output)
|
|
41
|
+
local environment = {}
|
|
42
|
+
|
|
43
|
+
environment.print = function(...)
|
|
44
|
+
local values = { n = select("#", ...), ... }
|
|
45
|
+
local parts = {}
|
|
46
|
+
for index = 1, values.n do
|
|
47
|
+
if issecretvalue and issecretvalue(values[index]) then
|
|
48
|
+
parts[index] = "<secret>"
|
|
49
|
+
else
|
|
50
|
+
parts[index] = tostring(values[index])
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
AddOutput(output, table.concat(parts, " "))
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
environment.dump = function(value)
|
|
57
|
+
AddOutput(output, ns.Serialize(value))
|
|
58
|
+
return value
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
setmetatable(environment, { __index = _G, __newindex = _G })
|
|
62
|
+
return environment
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
local function Pack(...)
|
|
66
|
+
return { n = select("#", ...), ... }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
function ns.Execute(code)
|
|
70
|
+
if ns.IsCombatBlocked() then
|
|
71
|
+
return false, ns.L.COMBAT_BLOCKED, ""
|
|
72
|
+
end
|
|
73
|
+
code = NormalizeCode(code)
|
|
74
|
+
if code == "" then
|
|
75
|
+
return false, L.ENTER_LUA, code
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
local output = {
|
|
79
|
+
parts = {},
|
|
80
|
+
length = 0,
|
|
81
|
+
truncated = false,
|
|
82
|
+
}
|
|
83
|
+
local chunk, compileError = loadstring(code, "LycheeDevInput")
|
|
84
|
+
if not chunk then
|
|
85
|
+
return false, L.COMPILE_ERROR .. tostring(compileError), code
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
setfenv(chunk, BuildEnvironment(output))
|
|
89
|
+
|
|
90
|
+
local packed = Pack(pcall(chunk))
|
|
91
|
+
local succeeded = packed[1]
|
|
92
|
+
|
|
93
|
+
if not succeeded then
|
|
94
|
+
AddOutput(output, L.RUNTIME_ERROR .. tostring(packed[2]))
|
|
95
|
+
return false, table.concat(output.parts), code
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
local values = { n = packed.n - 1 }
|
|
99
|
+
for index = 2, packed.n do
|
|
100
|
+
values[index - 1] = packed[index]
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
if values.n > 0 then
|
|
104
|
+
AddOutput(output, ns.SerializeValues(values))
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
if #output.parts == 0 then
|
|
108
|
+
AddOutput(output, L.COMPLETED_NO_OUTPUT)
|
|
109
|
+
end
|
|
110
|
+
|
|
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()
|
|
131
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
local ADDON_NAME, ns = ...
|
|
2
|
+
|
|
3
|
+
local client = assert(ns.Client, "Lychee Dev client profile must load first")
|
|
4
|
+
|
|
5
|
+
function client.GetAddOnMetadata(addon, field)
|
|
6
|
+
return C_AddOns.GetAddOnMetadata(addon, field)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
function client.GetMouseFocus()
|
|
10
|
+
local foci = GetMouseFoci()
|
|
11
|
+
if issecretvalue(foci) or type(foci) ~= "table" or not foci[1]
|
|
12
|
+
or issecretvalue(foci[1]) then
|
|
13
|
+
return nil
|
|
14
|
+
end
|
|
15
|
+
return foci[1]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
-- UI units per physical screen pixel, for screen-space overlays such as the
|
|
19
|
+
-- automation status blocks and QR notice. GetPhysicalScreenSize was verified on
|
|
20
|
+
-- the Retail 12.1.0 baseline only; other clients use the legacy 768-height
|
|
21
|
+
-- approximation until verified.
|
|
22
|
+
function client.GetPhysicalPixelSize()
|
|
23
|
+
if GetPhysicalScreenSize then
|
|
24
|
+
local succeeded, width, height = pcall(GetPhysicalScreenSize)
|
|
25
|
+
if succeeded and not (issecretvalue and (issecretvalue(width) or issecretvalue(height)))
|
|
26
|
+
and width and width > 0 and GetScreenWidth then
|
|
27
|
+
local uiWidth = GetScreenWidth()
|
|
28
|
+
if uiWidth and uiWidth > 0 and not (issecretvalue and issecretvalue(uiWidth)) then
|
|
29
|
+
return uiWidth / width
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
-- Fallback for clients without a verified GetPhysicalScreenSize: the legacy
|
|
34
|
+
-- 768-height approximation treats the screen as 768 physical pixels tall,
|
|
35
|
+
-- so one physical pixel spans (uiHeight / 768) UI units. The inverse,
|
|
36
|
+
-- 768 / uiHeight, would shrink the 4x4 physical-pixel status blocks below
|
|
37
|
+
-- their specified minimum on tall UIs.
|
|
38
|
+
local uiHeight = GetScreenHeight and GetScreenHeight() or nil
|
|
39
|
+
if uiHeight and uiHeight > 0 and not (issecretvalue and issecretvalue(uiHeight)) then
|
|
40
|
+
return uiHeight / 768
|
|
41
|
+
end
|
|
42
|
+
return 1
|
|
43
|
+
end
|