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/bin/lycheedev.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** lycheedev command line entry. */
|
|
3
|
+
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
import { runDoctor } from '../src/doctor.js';
|
|
8
|
+
import { runInstall } from '../src/install.js';
|
|
9
|
+
import { loadConfig } from '../src/config.js';
|
|
10
|
+
import { runAutomation } from '../src/python.js';
|
|
11
|
+
import { scanClients } from '../src/wow.js';
|
|
12
|
+
import { addonFolderName, exists } from '../src/paths.js';
|
|
13
|
+
|
|
14
|
+
const HELP = `lycheedev - Lychee Dev installer and World of Warcraft automation driver
|
|
15
|
+
|
|
16
|
+
usage: lycheedev <command> [options]
|
|
17
|
+
|
|
18
|
+
commands
|
|
19
|
+
install install python dependencies, the skill and the addon
|
|
20
|
+
update refresh dependencies, skill and addon to this version
|
|
21
|
+
doctor report what is installed and what is missing
|
|
22
|
+
clients list detected clients and their addon directories
|
|
23
|
+
send <text> type one slash command into the running game
|
|
24
|
+
capture poll the game window and decode the completion notice
|
|
25
|
+
run --task <id> deliver, decode, reload once and read the result ticket
|
|
26
|
+
bugs --count <n> snapshot recent errors and read the result ticket
|
|
27
|
+
ack --ticket <t> report that a ticket was read (received|failed)
|
|
28
|
+
task <sub> manage the in-game task registry (upsert/list/remove)
|
|
29
|
+
sv <sub> discover SavedVariables and read a ticket (find/read)
|
|
30
|
+
profile <sub> bind a client install for direct automation.py use
|
|
31
|
+
status summarize the local session log
|
|
32
|
+
recover show reload intents that were never confirmed
|
|
33
|
+
|
|
34
|
+
options
|
|
35
|
+
--wow-root <path> folder that contains _retail_/_classic_/_classic_arena_
|
|
36
|
+
--client <id> retail | classic | titan (default: the only configured one)
|
|
37
|
+
--python <bin> python interpreter to use
|
|
38
|
+
--force redo work that is already present
|
|
39
|
+
--reset-registry install the addon with an empty task registry
|
|
40
|
+
--json machine-readable output where supported
|
|
41
|
+
-h, --help show this help
|
|
42
|
+
-v, --version show the version
|
|
43
|
+
|
|
44
|
+
The automation subcommands are thin wrappers over the bundled python helper, so
|
|
45
|
+
the same arguments it accepts are forwarded unchanged.`;
|
|
46
|
+
|
|
47
|
+
const SHORT_FLAGS = { '-h': 'help', '-v': 'version' };
|
|
48
|
+
|
|
49
|
+
function parse(argv) {
|
|
50
|
+
const flags = {};
|
|
51
|
+
const rest = [];
|
|
52
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
53
|
+
const token = argv[index];
|
|
54
|
+
if (token === '--') {
|
|
55
|
+
rest.push(...argv.slice(index + 1));
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
if (SHORT_FLAGS[token]) {
|
|
59
|
+
flags[SHORT_FLAGS[token]] = true;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (token.startsWith('--')) {
|
|
63
|
+
const [name, inline] = token.slice(2).split('=');
|
|
64
|
+
if (inline !== undefined) {
|
|
65
|
+
flags[name] = inline;
|
|
66
|
+
} else if (argv[index + 1] && !argv[index + 1].startsWith('-')) {
|
|
67
|
+
flags[name] = argv[index + 1];
|
|
68
|
+
index += 1;
|
|
69
|
+
} else {
|
|
70
|
+
flags[name] = true;
|
|
71
|
+
}
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
rest.push(token);
|
|
75
|
+
}
|
|
76
|
+
return { flags, rest };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** hwnd/pid/exe-path derived from config so the automation commands line up. */
|
|
80
|
+
function targetArgs(client) {
|
|
81
|
+
const args = [];
|
|
82
|
+
if (client && client.hwnd) args.push('--hwnd', String(client.hwnd));
|
|
83
|
+
if (client && client.pid) args.push('--pid', String(client.pid));
|
|
84
|
+
return args;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function requireClient(flags) {
|
|
88
|
+
const config = loadConfig();
|
|
89
|
+
const ids = Object.keys(config.clients);
|
|
90
|
+
const requested = flags.client;
|
|
91
|
+
if (requested) {
|
|
92
|
+
if (!config.clients[requested]) {
|
|
93
|
+
console.error(`error: unknown client '${requested}'; known: ${ids.join(', ') || 'none'}`);
|
|
94
|
+
return { error: true };
|
|
95
|
+
}
|
|
96
|
+
return { config, client: config.clients[requested], id: requested };
|
|
97
|
+
}
|
|
98
|
+
if (ids.length === 0) {
|
|
99
|
+
console.error('error: no client configured; run `lycheedev install --wow-root <path>`');
|
|
100
|
+
return { error: true };
|
|
101
|
+
}
|
|
102
|
+
if (ids.length === 1) {
|
|
103
|
+
return { config, client: config.clients[ids[0]], id: ids[0] };
|
|
104
|
+
}
|
|
105
|
+
// Several clients are installed; the one recorded at install time is the
|
|
106
|
+
// default so routine commands stay short, and --client overrides it.
|
|
107
|
+
const fallback = config.defaultClient;
|
|
108
|
+
if (fallback && config.clients[fallback]) {
|
|
109
|
+
return { config, client: config.clients[fallback], id: fallback };
|
|
110
|
+
}
|
|
111
|
+
console.error(`error: several clients configured (${ids.join(', ')}); pass --client <id>`);
|
|
112
|
+
return { error: true };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function runClients(flags) {
|
|
116
|
+
const config = loadConfig();
|
|
117
|
+
const root = flags['wow-root'] || config.wowRoot;
|
|
118
|
+
if (!root || !exists(root)) {
|
|
119
|
+
console.error('error: no World of Warcraft root; run `lycheedev install --wow-root <path>`');
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
console.log(root);
|
|
123
|
+
for (const client of scanClients(root)) {
|
|
124
|
+
const supported = ['retail', 'classic', 'titan'].includes(client.id);
|
|
125
|
+
const installed = exists(path.join(client.addonsDir, addonFolderName));
|
|
126
|
+
console.log(` ${client.id.padEnd(11)} ${client.folder.padEnd(16)} `
|
|
127
|
+
+ `${installed ? 'addon installed' : 'addon missing'}`.padEnd(18)
|
|
128
|
+
+ `${supported ? '' : '(not supported by the addon)'}`);
|
|
129
|
+
}
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function main(argv) {
|
|
134
|
+
const { flags, rest } = parse(argv);
|
|
135
|
+
const command = rest.shift();
|
|
136
|
+
|
|
137
|
+
// Help and version are answers, not errors: they must not depend on whether a
|
|
138
|
+
// command was supplied.
|
|
139
|
+
if (flags.help) {
|
|
140
|
+
console.log(HELP);
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
if (flags.version) {
|
|
144
|
+
const pkg = JSON.parse(
|
|
145
|
+
readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
|
|
146
|
+
);
|
|
147
|
+
console.log(pkg.version || 'unknown');
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
if (!command) {
|
|
151
|
+
console.log(HELP);
|
|
152
|
+
return 1;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
switch (command) {
|
|
156
|
+
case 'install':
|
|
157
|
+
return runInstall({ flags });
|
|
158
|
+
case 'update':
|
|
159
|
+
return runInstall({ flags: { ...flags, force: true } });
|
|
160
|
+
case 'doctor':
|
|
161
|
+
return runDoctor({ flags });
|
|
162
|
+
case 'clients':
|
|
163
|
+
return runClients(flags);
|
|
164
|
+
case 'help':
|
|
165
|
+
console.log(HELP);
|
|
166
|
+
return 0;
|
|
167
|
+
default:
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Everything else is forwarded to the bundled python helper.
|
|
172
|
+
const target = requireClient(flags);
|
|
173
|
+
if (target.error) return 1;
|
|
174
|
+
|
|
175
|
+
const forwarded = [];
|
|
176
|
+
const client = target.client || {};
|
|
177
|
+
if (client.addonsDir) forwarded.push('--install-dir', client.addonsDir);
|
|
178
|
+
|
|
179
|
+
switch (command) {
|
|
180
|
+
case 'send': {
|
|
181
|
+
const text = rest.join(' ');
|
|
182
|
+
if (!text) {
|
|
183
|
+
console.error('error: send needs the command text, e.g. `lycheedev send "/dev auto status x"`');
|
|
184
|
+
return 1;
|
|
185
|
+
}
|
|
186
|
+
return forward(['send', ...targetArgs(client), '--text', text, ...passthrough(flags)]);
|
|
187
|
+
}
|
|
188
|
+
case 'capture':
|
|
189
|
+
return forward(['capture', ...targetArgs(client), ...passthrough(flags)]);
|
|
190
|
+
case 'run':
|
|
191
|
+
if (!flags.task) {
|
|
192
|
+
console.error('error: run needs --task <id>');
|
|
193
|
+
return 1;
|
|
194
|
+
}
|
|
195
|
+
if (!client.svPath) {
|
|
196
|
+
console.error('error: no SavedVariables path recorded for this client; re-run `lycheedev install`');
|
|
197
|
+
return 1;
|
|
198
|
+
}
|
|
199
|
+
return forward(['run', ...targetArgs(client), '--task', flags.task, '--sv', client.svPath,
|
|
200
|
+
...passthrough(flags)]);
|
|
201
|
+
case 'bugs':
|
|
202
|
+
if (!flags.count) {
|
|
203
|
+
console.error('error: bugs needs --count <1-100>');
|
|
204
|
+
return 1;
|
|
205
|
+
}
|
|
206
|
+
if (!client.svPath) {
|
|
207
|
+
console.error('error: no SavedVariables path recorded for this client; re-run `lycheedev install`');
|
|
208
|
+
return 1;
|
|
209
|
+
}
|
|
210
|
+
return forward(['bugs', ...targetArgs(client), '--count', String(flags.count), '--sv', client.svPath,
|
|
211
|
+
...passthrough(flags)]);
|
|
212
|
+
case 'ack':
|
|
213
|
+
if (!flags.ticket || !flags.status) {
|
|
214
|
+
console.error('error: ack needs --ticket <t> --status received|failed');
|
|
215
|
+
return 1;
|
|
216
|
+
}
|
|
217
|
+
return forward(['ack', ...targetArgs(client), '--ticket', flags.ticket,
|
|
218
|
+
'--status', flags.status, ...passthrough(flags)]);
|
|
219
|
+
case 'task': {
|
|
220
|
+
const sub = rest.shift();
|
|
221
|
+
if (!sub) {
|
|
222
|
+
console.error('error: task needs a subcommand: upsert, list or remove');
|
|
223
|
+
return 1;
|
|
224
|
+
}
|
|
225
|
+
return forward(['task', sub, ...forwarded, ...passthrough(flags)]);
|
|
226
|
+
}
|
|
227
|
+
case 'sv':
|
|
228
|
+
case 'profile':
|
|
229
|
+
case 'status':
|
|
230
|
+
case 'recover':
|
|
231
|
+
return forward([command, ...rest, ...passthrough(flags)]);
|
|
232
|
+
default:
|
|
233
|
+
console.error(`error: unknown command '${command}'`);
|
|
234
|
+
console.log(HELP);
|
|
235
|
+
return 1;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function passthrough(all) {
|
|
239
|
+
const out = [];
|
|
240
|
+
for (const [name, value] of Object.entries(all)) {
|
|
241
|
+
if (['wow-root', 'client', 'python', 'force', 'reset-registry', 'task', 'count',
|
|
242
|
+
'ticket', 'status', 'json', 'help', 'version'].includes(name)) {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (value === true) out.push(`--${name}`);
|
|
246
|
+
else out.push(`--${name}`, String(value));
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function forward(args) {
|
|
252
|
+
const result = runAutomation(args, { pythonBin: flags.python || (target.config || {}).pythonBin });
|
|
253
|
+
return typeof result.status === 'number' ? result.status : 1;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
process.exitCode = main(process.argv.slice(2));
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lycheedev",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "lycheedev: install the World of Warcraft inspection addon, its in-game automation tooling, and drive it from the command line.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"wow",
|
|
7
|
+
"world-of-warcraft",
|
|
8
|
+
"addon",
|
|
9
|
+
"automation",
|
|
10
|
+
"cli"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Follen",
|
|
14
|
+
"homepage": "https://github.com/Follen/Lychee-Dev#readme",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/Follen/Lychee-Dev.git",
|
|
18
|
+
"directory": "packages/cli"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Follen/Lychee-Dev/issues"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"bin": {
|
|
25
|
+
"lycheedev": "bin/lycheedev.js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"bin/",
|
|
29
|
+
"src/",
|
|
30
|
+
"vendor/",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "node scripts/vendor.mjs",
|
|
38
|
+
"prepack": "node scripts/vendor.mjs",
|
|
39
|
+
"test": "node scripts/selftest.mjs"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {}
|
|
42
|
+
}
|
package/src/addon.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** Install the addon payload into a client's Interface/AddOns directory. */
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { addonFolderName, copyTree, exists, removeTree, vendorRoot } from './paths.js';
|
|
7
|
+
|
|
8
|
+
export function vendoredAddonRoot() {
|
|
9
|
+
return path.join(vendorRoot, 'addon');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function addonTargetDir(addonsDir) {
|
|
13
|
+
return path.join(addonsDir, addonFolderName);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Read the shipped version out of the vendored TOC. */
|
|
17
|
+
export function payloadVersion() {
|
|
18
|
+
const toc = path.join(vendoredAddonRoot(), `${addonFolderName}_Mainline.toc`);
|
|
19
|
+
try {
|
|
20
|
+
const text = fs.readFileSync(toc, 'utf8');
|
|
21
|
+
const match = text.match(/^##\s*Version:\s*(.+)$/m);
|
|
22
|
+
return match ? match[1].trim() : null;
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Version of whatever is currently installed, if any. */
|
|
29
|
+
export function installedVersion(addonsDir) {
|
|
30
|
+
const target = addonTargetDir(addonsDir);
|
|
31
|
+
for (const toc of [`${addonFolderName}_Mainline.toc`, `${addonFolderName}_Mists.toc`,
|
|
32
|
+
`${addonFolderName}_Wrath.toc`]) {
|
|
33
|
+
const file = path.join(target, toc);
|
|
34
|
+
if (!exists(file)) continue;
|
|
35
|
+
const match = fs.readFileSync(file, 'utf8').match(/^##\s*Version:\s*(.+)$/m);
|
|
36
|
+
if (match) return match[1].trim();
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function countFiles(dir) {
|
|
42
|
+
if (!exists(dir)) return 0;
|
|
43
|
+
let total = 0;
|
|
44
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
45
|
+
if (entry.isDirectory()) total += countFiles(path.join(dir, entry.name));
|
|
46
|
+
else total += 1;
|
|
47
|
+
}
|
|
48
|
+
return total;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Copy the vendored addon over the installed copy.
|
|
53
|
+
*
|
|
54
|
+
* The destination is replaced rather than merged so a file removed upstream
|
|
55
|
+
* cannot linger. `auto.lua` is local task data, so it is preserved when the
|
|
56
|
+
* caller asks for it: the empty shipped registry must not wipe pending work.
|
|
57
|
+
*/
|
|
58
|
+
export function installAddon(addonsDir, { preserveRegistry = true } = {}) {
|
|
59
|
+
const source = vendoredAddonRoot();
|
|
60
|
+
if (!exists(source)) {
|
|
61
|
+
return { ok: false, error: 'vendored addon payload is missing; reinstall the package' };
|
|
62
|
+
}
|
|
63
|
+
const target = addonTargetDir(addonsDir);
|
|
64
|
+
|
|
65
|
+
let savedRegistry = null;
|
|
66
|
+
const registry = path.join(target, 'Modules', 'Automation', 'auto', 'auto.lua');
|
|
67
|
+
if (preserveRegistry && exists(registry)) {
|
|
68
|
+
const text = fs.readFileSync(registry, 'utf8');
|
|
69
|
+
if (/^-- BEGIN LYCHEE DEV TASK /m.test(text)) savedRegistry = text;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
removeTree(target);
|
|
73
|
+
fs.mkdirSync(addonsDir, { recursive: true });
|
|
74
|
+
copyTree(source, target);
|
|
75
|
+
|
|
76
|
+
if (savedRegistry) {
|
|
77
|
+
fs.writeFileSync(registry, savedRegistry, 'utf8');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
ok: true,
|
|
82
|
+
target,
|
|
83
|
+
files: countFiles(target),
|
|
84
|
+
version: payloadVersion(),
|
|
85
|
+
keptRegistry: Boolean(savedRegistry),
|
|
86
|
+
};
|
|
87
|
+
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Persistent CLI configuration (~/.lycheedev/config.json). */
|
|
2
|
+
|
|
3
|
+
import { configPath, readJson, writeJson } from './paths.js';
|
|
4
|
+
|
|
5
|
+
const EMPTY = {
|
|
6
|
+
wowRoot: null,
|
|
7
|
+
clients: {},
|
|
8
|
+
pythonBin: null,
|
|
9
|
+
installedAt: null,
|
|
10
|
+
packageVersion: null,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function loadConfig() {
|
|
14
|
+
const stored = readJson(configPath(), null);
|
|
15
|
+
if (!stored || typeof stored !== 'object') {
|
|
16
|
+
return { ...EMPTY, clients: {} };
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...EMPTY,
|
|
20
|
+
...stored,
|
|
21
|
+
clients: stored.clients && typeof stored.clients === 'object' ? stored.clients : {},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function saveConfig(config) {
|
|
26
|
+
writeJson(configPath(), config);
|
|
27
|
+
return config;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function updateConfig(patch) {
|
|
31
|
+
const config = loadConfig();
|
|
32
|
+
const next = { ...config, ...patch };
|
|
33
|
+
if (patch.clients) {
|
|
34
|
+
next.clients = { ...config.clients, ...patch.clients };
|
|
35
|
+
}
|
|
36
|
+
return saveConfig(next);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function setClient(config, clientId, value) {
|
|
40
|
+
config.clients = { ...config.clients, [clientId]: value };
|
|
41
|
+
return config;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Resolve which WoW client to act on. An explicit id wins; otherwise the only
|
|
46
|
+
* installed client is used, and an ambiguous set is reported instead of guessed.
|
|
47
|
+
*/
|
|
48
|
+
export function resolveClient(config, requested) {
|
|
49
|
+
const ids = Object.keys(config.clients).sort();
|
|
50
|
+
if (requested) {
|
|
51
|
+
const client = config.clients[requested];
|
|
52
|
+
if (!client) {
|
|
53
|
+
return { error: `unknown client '${requested}'; known: ${ids.join(', ') || 'none'}` };
|
|
54
|
+
}
|
|
55
|
+
return { id: requested, client };
|
|
56
|
+
}
|
|
57
|
+
if (ids.length === 0) {
|
|
58
|
+
return { error: 'no World of Warcraft client is configured yet; run `lycheedev install`' };
|
|
59
|
+
}
|
|
60
|
+
if (ids.length > 1) {
|
|
61
|
+
return { error: `several clients are configured (${ids.join(', ')}); pass --client <id>` };
|
|
62
|
+
}
|
|
63
|
+
return { id: ids[0], client: config.clients[ids[0]] };
|
|
64
|
+
}
|
package/src/doctor.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/** `lycheedev doctor`: report what is installed and what is missing. */
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { installedVersion, payloadVersion } from './addon.js';
|
|
7
|
+
import { loadConfig } from './config.js';
|
|
8
|
+
import { addonFolderName, configPath, dataDir, exists, pythonDepsDir, skillTargetDir } from './paths.js';
|
|
9
|
+
import { automationScript, findPython, pythonEnv } from './python.js';
|
|
10
|
+
import { findSavedVariablesCandidates, scanClients } from './wow.js';
|
|
11
|
+
|
|
12
|
+
const OK = 'ok ';
|
|
13
|
+
const WARN = 'warn';
|
|
14
|
+
const BAD = 'fail';
|
|
15
|
+
|
|
16
|
+
function line(status, label, detail) {
|
|
17
|
+
const prefix = status === OK ? ' ok ' : status === WARN ? ' warn ' : ' fail ';
|
|
18
|
+
console.log(`${prefix} ${label.padEnd(28)} ${detail}`);
|
|
19
|
+
return status;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function runDoctor({ flags }) {
|
|
23
|
+
const config = loadConfig();
|
|
24
|
+
const results = [];
|
|
25
|
+
const python = findPython(flags.python || config.pythonBin);
|
|
26
|
+
|
|
27
|
+
console.log('lycheedev doctor\n');
|
|
28
|
+
|
|
29
|
+
results.push(line(OK, 'node', process.version));
|
|
30
|
+
|
|
31
|
+
results.push(python
|
|
32
|
+
? line(OK, 'python', `${python.bin} (${python.version})`)
|
|
33
|
+
: line(BAD, 'python', 'not found; install Python 3 and re-run'));
|
|
34
|
+
|
|
35
|
+
if (python) {
|
|
36
|
+
const missing = ['zxingcpp', 'windows_capture'].filter((name) => {
|
|
37
|
+
const target = path.join(pythonDepsDir(), name);
|
|
38
|
+
return !exists(target);
|
|
39
|
+
});
|
|
40
|
+
if (missing.length === 0) {
|
|
41
|
+
results.push(line(OK, 'python dependencies', pythonDepsDir()));
|
|
42
|
+
} else if (missing.length === 2) {
|
|
43
|
+
results.push(line(WARN, 'python dependencies',
|
|
44
|
+
'not installed (live capture/send unavailable); run `lycheedev install`'));
|
|
45
|
+
} else {
|
|
46
|
+
results.push(line(WARN, 'python dependencies',
|
|
47
|
+
`partial, missing: ${missing.join(', ')}; run ` + '`lycheedev install --force`'));
|
|
48
|
+
}
|
|
49
|
+
results.push(exists(automationScript)
|
|
50
|
+
? line(OK, 'automation helper', automationScript)
|
|
51
|
+
: line(BAD, 'automation helper', 'missing from the package; reinstall lycheedev'));
|
|
52
|
+
} else {
|
|
53
|
+
results.push(line(BAD, 'python dependencies', 'skipped (no python)'));
|
|
54
|
+
results.push(line(BAD, 'automation helper', 'skipped (no python)'));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (exists(skillTargetDir())) {
|
|
58
|
+
const files = fs.readdirSync(skillTargetDir());
|
|
59
|
+
results.push(line(OK, 'skill installed', `${skillTargetDir()} (${files.length} entries)`));
|
|
60
|
+
} else {
|
|
61
|
+
results.push(line(WARN, 'skill installed', `missing; run \`lycheedev install\``));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const roots = flags['wow-root'] ? [path.resolve(flags['wow-root'])] : (config.wowRoot ? [config.wowRoot] : []);
|
|
65
|
+
if (roots.length === 0 || !exists(roots[0])) {
|
|
66
|
+
results.push(line(WARN, 'wow root', 'not configured; run `lycheedev install --wow-root <path>`'));
|
|
67
|
+
} else {
|
|
68
|
+
results.push(line(OK, 'wow root', roots[0]));
|
|
69
|
+
for (const client of scanClients(roots[0])) {
|
|
70
|
+
if (!['retail', 'classic', 'titan'].includes(client.id)) continue;
|
|
71
|
+
const target = path.join(client.addonsDir, addonFolderName);
|
|
72
|
+
if (!exists(target)) {
|
|
73
|
+
results.push(line(WARN, `addon (${client.id})`, `not installed in ${client.addonsDir}`));
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const current = installedVersion(client.addonsDir);
|
|
77
|
+
const shipped = payloadVersion();
|
|
78
|
+
const detail = `${target} (installed ${current || '?'}, package ${shipped || '?'})`;
|
|
79
|
+
results.push(current && shipped && current !== shipped
|
|
80
|
+
? line(WARN, `addon (${client.id})`, `${detail} - run \`lycheedev update\``)
|
|
81
|
+
: line(OK, `addon (${client.id})`, detail));
|
|
82
|
+
|
|
83
|
+
const candidates = findSavedVariablesCandidates(roots[0], client.folder);
|
|
84
|
+
results.push(candidates.length
|
|
85
|
+
? line(OK, `savedvariables (${client.id})`, `${candidates.length} account(s), newest: ${candidates[0].account}`)
|
|
86
|
+
: line(WARN, `savedvariables (${client.id})`, 'none yet; log into the game once'));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log(`\nconfig: ${configPath()}`);
|
|
91
|
+
console.log(`data : ${dataDir()}`);
|
|
92
|
+
if (python) {
|
|
93
|
+
console.log(`python env PYTHONPATH=${pythonEnv().PYTHONPATH}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const failures = results.filter((entry) => entry === BAD).length;
|
|
97
|
+
const warnings = results.filter((entry) => entry === WARN).length;
|
|
98
|
+
console.log(`\n${failures} failure(s), ${warnings} warning(s)`);
|
|
99
|
+
return failures > 0 ? 1 : 0;
|
|
100
|
+
}
|
package/src/install.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/** `lycheedev install` / `update`: dependency, skill and addon installation. */
|
|
2
|
+
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { installAddon, installedVersion, payloadVersion } from './addon.js';
|
|
6
|
+
import { loadConfig, setClient, updateConfig } from './config.js';
|
|
7
|
+
import { addonFolderName, exists } from './paths.js';
|
|
8
|
+
import { depsInstalled, findPython, installDeps } from './python.js';
|
|
9
|
+
import { installSkill } from './skill.js';
|
|
10
|
+
import { detectWowRoots, findSavedVariablesCandidates, scanClients } from './wow.js';
|
|
11
|
+
|
|
12
|
+
function step(label, fn) {
|
|
13
|
+
process.stdout.write(`\n` + `${label}\n`);
|
|
14
|
+
return fn();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function flag(name, value) {
|
|
18
|
+
return value ? `[${name}] ${value}` : `[${name}] -`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the WoW root: an explicit flag wins, then a saved config value, then
|
|
23
|
+
* auto-detection. Ambiguity is reported instead of guessed so we never write
|
|
24
|
+
* into the wrong installation.
|
|
25
|
+
*/
|
|
26
|
+
export function resolveWowRoot({ wowRoot, config }) {
|
|
27
|
+
if (wowRoot) {
|
|
28
|
+
const resolved = path.resolve(wowRoot);
|
|
29
|
+
if (!exists(resolved)) return { error: `path does not exist: ${resolved}` };
|
|
30
|
+
const clients = scanClients(resolved);
|
|
31
|
+
if (clients.length === 0) {
|
|
32
|
+
return {
|
|
33
|
+
error: `${resolved} has no _retail_/_classic_/_classic_arena_ folder; `
|
|
34
|
+
+ 'point --wow-root at the folder that contains them',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return { root: resolved, clients };
|
|
38
|
+
}
|
|
39
|
+
if (config.wowRoot && exists(config.wowRoot)) {
|
|
40
|
+
const clients = scanClients(config.wowRoot);
|
|
41
|
+
if (clients.length > 0) return { root: config.wowRoot, clients, fromConfig: true };
|
|
42
|
+
}
|
|
43
|
+
const detected = detectWowRoots();
|
|
44
|
+
if (detected.length === 1) {
|
|
45
|
+
return { root: detected[0], clients: scanClients(detected[0]), detected: true };
|
|
46
|
+
}
|
|
47
|
+
if (detected.length > 1) {
|
|
48
|
+
return {
|
|
49
|
+
error: `found several World of Warcraft folders:\n ${detected.join('\n ')}\n`
|
|
50
|
+
+ 'pass --wow-root to choose one',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return { error: 'no World of Warcraft folder found; pass --wow-root <path>' };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function runInstall({ flags }) {
|
|
57
|
+
const config = loadConfig();
|
|
58
|
+
const resolved = resolveWowRoot({ wowRoot: flags['wow-root'], config });
|
|
59
|
+
if (resolved.error) {
|
|
60
|
+
console.error(`error: ${resolved.error}`);
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log(`world of warcraft: ${resolved.root}`
|
|
65
|
+
+ `${resolved.detected ? ' (auto-detected)' : ''}${resolved.fromConfig ? ' (from config)' : ''}`);
|
|
66
|
+
|
|
67
|
+
const result = step('installing python dependencies', () => {
|
|
68
|
+
const python = findPython(flags.python);
|
|
69
|
+
if (!python) return { ok: false, error: 'no Python 3 interpreter found on PATH' };
|
|
70
|
+
console.log(` python: ${python.bin} (${python.version})`);
|
|
71
|
+
if (depsInstalled() && !flags.force) {
|
|
72
|
+
console.log(' already installed (use --force to refresh)');
|
|
73
|
+
return { ok: true, skipped: true };
|
|
74
|
+
}
|
|
75
|
+
return installDeps({ pythonBin: python.bin, quiet: true, onLine: (line) => console.log(` ${line}`) });
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const skillResult = step('installing skill', () => installSkill());
|
|
79
|
+
|
|
80
|
+
const nextConfig = { ...config, wowRoot: resolved.root, pythonBin: flags.python || config.pythonBin };
|
|
81
|
+
const addonResults = [];
|
|
82
|
+
let defaultClient = config.defaultClient || null;
|
|
83
|
+
|
|
84
|
+
for (const client of resolved.clients) {
|
|
85
|
+
if (!['retail', 'classic', 'titan'].includes(client.id)) {
|
|
86
|
+
console.log(`\n${client.label}: skipped (unsupported by the addon)`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
step(`${client.label}: installing addon into ${client.folder}`, () => {
|
|
90
|
+
if (!exists(client.addonsDir)) {
|
|
91
|
+
console.log(` skipped: ${client.addonsDir} does not exist yet`);
|
|
92
|
+
return { ok: false, skipped: true };
|
|
93
|
+
}
|
|
94
|
+
const before = installedVersion(client.addonsDir);
|
|
95
|
+
const installed = installAddon(client.addonsDir, { preserveRegistry: !flags['reset-registry'] });
|
|
96
|
+
if (!installed.ok) {
|
|
97
|
+
console.log(` error: ${installed.error}`);
|
|
98
|
+
return installed;
|
|
99
|
+
}
|
|
100
|
+
console.log(` ${addonFolderName} -> ${installed.target}`);
|
|
101
|
+
console.log(` files: ${installed.files}, version: ${before ? `${before} -> ` : ''}${installed.version}`);
|
|
102
|
+
if (installed.keptRegistry) console.log(' kept the existing task registry (local task data)');
|
|
103
|
+
addonResults.push({ client: client.id, ...installed });
|
|
104
|
+
if (!defaultClient) defaultClient = client.id;
|
|
105
|
+
return installed;
|
|
106
|
+
});
|
|
107
|
+
const candidates = findSavedVariablesCandidates(resolved.root, client.folder);
|
|
108
|
+
setClient(nextConfig, client.id, {
|
|
109
|
+
flavorFolder: client.folder,
|
|
110
|
+
addonsDir: client.addonsDir,
|
|
111
|
+
svPath: candidates[0] ? candidates[0].path : null,
|
|
112
|
+
installedAt: new Date().toISOString(),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updateConfig({ ...nextConfig, defaultClient });
|
|
117
|
+
|
|
118
|
+
console.log('\nresult');
|
|
119
|
+
console.log(` python deps : ${result.ok ? (result.skipped ? 'present' : 'installed') : `failed (${result.error})`}`);
|
|
120
|
+
console.log(` skill : ${skillResult.ok ? `${skillResult.files} files -> ${skillResult.target}` : `failed (${skillResult.error})`}`);
|
|
121
|
+
console.log(` addon : ${addonResults.length} client(s) updated`);
|
|
122
|
+
console.log(` payload : version ${payloadVersion()}`);
|
|
123
|
+
|
|
124
|
+
const failed = !result.ok || !skillResult.ok || addonResults.length === 0;
|
|
125
|
+
if (failed) {
|
|
126
|
+
console.log('\nnot fully installed; run `lycheedev doctor` for details');
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
console.log('\nrestart World of Warcraft (or /reload) to load the addon, then run `lycheedev doctor`');
|
|
130
|
+
return 0;
|
|
131
|
+
}
|