lycheedev 1.0.6 → 1.1.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/bin/lycheedev.js +257 -38
- package/package.json +1 -1
- package/src/addon.js +1 -1
- package/src/doctor.js +2 -1
- package/src/install.js +12 -4
- package/src/py/instances.py +50 -5
- package/src/wow.js +278 -24
- package/vendor/addon/Core/Clients/Forever.lua +9 -0
- package/vendor/addon/Core/Locale.lua +6 -2
- package/vendor/addon/Core/Locale_enUS.lua +6 -2
- package/vendor/addon/Lychee Dev_Forever.toc +43 -0
- package/vendor/addon/Lychee Dev_Mainline.toc +1 -1
- package/vendor/addon/Lychee Dev_Mists.toc +1 -1
- package/vendor/addon/Lychee Dev_Wrath.toc +1 -1
- package/vendor/addon/Modules/Automation/Controller.lua +130 -3
- package/vendor/addon/Modules/Events/CatalogData_Forever.lua +1809 -0
- package/vendor/addon/UI/AutomationOverlay.lua +83 -13
- package/vendor/addon/UI/Pages/About.lua +4 -1
- package/vendor/skill/SKILL.md +23 -97
- package/vendor/skill/agents/openai.yaml +3 -3
- package/vendor/skill/references/automation.md +85 -284
- package/vendor/skill/references/clients.md +28 -112
- package/vendor/skill/references/runtime-investigations.md +7 -0
- package/vendor/skill/scripts/automation/windows.py +269 -50
- package/vendor/skill/scripts/automation.py +194 -25
- package/vendor/skill/scripts/selftest_offline.py +153 -73
- package/vendor/skill/scripts/test_input_safety.py +132 -0
package/bin/lycheedev.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
/** lycheedev command line entry. */
|
|
3
3
|
|
|
4
4
|
import { readFileSync } from 'node:fs';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import os from 'node:os';
|
|
5
7
|
import path from 'node:path';
|
|
8
|
+
import { randomBytes } from 'node:crypto';
|
|
6
9
|
|
|
7
10
|
import { runDoctor } from '../src/doctor.js';
|
|
8
11
|
import { runInstall } from '../src/install.js';
|
|
@@ -13,6 +16,9 @@ import {
|
|
|
13
16
|
findInstances,
|
|
14
17
|
findSavedVariablesCandidates,
|
|
15
18
|
formatInstance,
|
|
19
|
+
identityKey,
|
|
20
|
+
identityLabel,
|
|
21
|
+
matchIdentity,
|
|
16
22
|
matchPinned,
|
|
17
23
|
resolveInstance,
|
|
18
24
|
scanClients,
|
|
@@ -29,7 +35,9 @@ commands
|
|
|
29
35
|
doctor report what is installed and what is missing
|
|
30
36
|
clients list every detected build and its addon state
|
|
31
37
|
instances list running game clients (build, pid, window)
|
|
38
|
+
instances --identify also read each window's character and build marker
|
|
32
39
|
use [index] pin one running client as the default target
|
|
40
|
+
use --character <n> pin the window that reports character <n>
|
|
33
41
|
use --clear drop the pin
|
|
34
42
|
send <text> type one slash command into the running game
|
|
35
43
|
capture poll the game window and decode the completion notice
|
|
@@ -44,8 +52,10 @@ commands
|
|
|
44
52
|
|
|
45
53
|
options
|
|
46
54
|
--wow-root <path> folder that contains _retail_/_classic_/_classic_titan_
|
|
47
|
-
--client <id> retail | classic | titan (default: the
|
|
55
|
+
--client <id> retail | classic | titan | forever (default: the configured one)
|
|
48
56
|
--instance <index> which running client to target when several are open
|
|
57
|
+
--character <name> target the window reporting that character (Name or Name-Realm)
|
|
58
|
+
--identify also read each window's character marker (instances, use)
|
|
49
59
|
--hwnd <handle> target one window directly, skipping instance lookup
|
|
50
60
|
--pid <pid> expected process id for the target window
|
|
51
61
|
--python <bin> python interpreter to use
|
|
@@ -56,10 +66,20 @@ options
|
|
|
56
66
|
-v, --version show the version
|
|
57
67
|
|
|
58
68
|
Every non-retail client runs as WowClassic.exe, so a running client is matched
|
|
59
|
-
by its install path, not its process name.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
by its install path, not its process name. A folder is only a location: the CLI
|
|
70
|
+
also reads each client's own .flavor.info product code and version.txt build, so
|
|
71
|
+
a reused test folder (such as _classic_beta_ carrying WoW: Forever) is still
|
|
72
|
+
identified correctly. With several clients open, run "lycheedev instances" then
|
|
73
|
+
"lycheedev use <index>" to pin one as the target; the pin stores the build, so it
|
|
74
|
+
survives a restart even though the pid and window handle change. Pass
|
|
75
|
+
--instance <index> to override it for one command.
|
|
76
|
+
|
|
77
|
+
When several windows share one build, they are told apart by the character each
|
|
78
|
+
window reports: run "/dev auto identify" in each game window, then
|
|
79
|
+
"lycheedev instances --identify" to read them, and pin by name with
|
|
80
|
+
"lycheedev use --character <name>". Windows that report the same character, or
|
|
81
|
+
that show no marker, remain ambiguous and the CLI asks for one window to be
|
|
82
|
+
closed rather than risking a command in the wrong game.
|
|
63
83
|
|
|
64
84
|
The automation subcommands are thin wrappers over the bundled python helper, so
|
|
65
85
|
the same arguments it accepts are forwarded unchanged.`;
|
|
@@ -101,6 +121,8 @@ function targetArgs(client) {
|
|
|
101
121
|
const args = [];
|
|
102
122
|
if (client && client.hwnd) args.push('--hwnd', String(client.hwnd));
|
|
103
123
|
if (client && client.pid) args.push('--pid', String(client.pid));
|
|
124
|
+
const exePath = client?.exePath || client?.instance?.exePath;
|
|
125
|
+
if (exePath) args.push('--exe-path', exePath);
|
|
104
126
|
return args;
|
|
105
127
|
}
|
|
106
128
|
|
|
@@ -142,10 +164,16 @@ function runClients(flags) {
|
|
|
142
164
|
console.log(root);
|
|
143
165
|
for (const client of scanClients(root)) {
|
|
144
166
|
const version = client.version ? `v${client.version}` : 'unknown version';
|
|
167
|
+
// The product is the client's own identity; the folder is only where it
|
|
168
|
+
// lives, and one folder can serve different products over time.
|
|
169
|
+
const product = client.folderProduct && client.folderProduct !== client.product
|
|
170
|
+
? `[${client.folderProduct}] `
|
|
171
|
+
: '';
|
|
145
172
|
const state = !client.toc
|
|
146
173
|
? 'not served by the addon'
|
|
147
174
|
: (client.installed ? 'addon installed' : 'addon missing');
|
|
148
|
-
console.log(` ${client.id.padEnd(12)} ${client.folder.padEnd(18)}
|
|
175
|
+
console.log(` ${client.id.padEnd(12)} ${client.folder.padEnd(18)} `
|
|
176
|
+
+ `${(product + version).padEnd(18)} ${state}`);
|
|
149
177
|
}
|
|
150
178
|
return 0;
|
|
151
179
|
}
|
|
@@ -153,11 +181,40 @@ function runClients(flags) {
|
|
|
153
181
|
/** `lycheedev instances`: which game clients are running right now. */
|
|
154
182
|
function runInstances(flags) {
|
|
155
183
|
const config = loadConfig();
|
|
156
|
-
|
|
184
|
+
let instances = findInstances({ pythonBin: flags.python || null });
|
|
157
185
|
if (instances.length === 0) {
|
|
158
186
|
console.log('no World of Warcraft instance is running');
|
|
159
187
|
return 0;
|
|
160
188
|
}
|
|
189
|
+
|
|
190
|
+
// `--identify` asks each window to report the character and build it holds.
|
|
191
|
+
// Capture reads the window surface directly, so no window needs the
|
|
192
|
+
// foreground and nothing is typed into the game.
|
|
193
|
+
let identifyNote = null;
|
|
194
|
+
if (flags.identify) {
|
|
195
|
+
const supported = instances.filter((item) => item.supported);
|
|
196
|
+
if (supported.length === 0) {
|
|
197
|
+
identifyNote = 'no served build is running, so there is nothing to identify';
|
|
198
|
+
} else {
|
|
199
|
+
const probed = probeIdentities(supported, flags);
|
|
200
|
+
if (probed.error) {
|
|
201
|
+
identifyNote = probed.error;
|
|
202
|
+
} else {
|
|
203
|
+
const byHwnd = new Map(probed.list.map((entry) => [String(entry.hwnd), entry]));
|
|
204
|
+
instances = instances.map((instance) => {
|
|
205
|
+
const entry = byHwnd.get(String(instance.hwnd));
|
|
206
|
+
if (!entry || !entry.identity) return instance;
|
|
207
|
+
return { ...instance, identity: entry.identity };
|
|
208
|
+
});
|
|
209
|
+
const unidentified = probed.list.filter((entry) => !entry.identity);
|
|
210
|
+
if (unidentified.length) {
|
|
211
|
+
identifyNote = `${unidentified.length} window(s) show no identity marker; `
|
|
212
|
+
+ 'run `/dev auto identify` in each game window you care about, then retry';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
161
218
|
const pinned = matchPinned(instances, config.pinnedInstance);
|
|
162
219
|
console.log('running instances:');
|
|
163
220
|
instances.forEach((instance, index) => {
|
|
@@ -174,21 +231,69 @@ function runInstances(flags) {
|
|
|
174
231
|
if (supported.length === 0) {
|
|
175
232
|
console.log('none of these builds are served by the addon');
|
|
176
233
|
} else if (!pinned && supported.length > 1) {
|
|
177
|
-
|
|
178
|
-
|
|
234
|
+
const shape = describeAmbiguity(instances);
|
|
235
|
+
if (shape.sameBuildCollision) {
|
|
236
|
+
// Do not suggest `use <index>` here: pinning is refused for windows that
|
|
237
|
+
// cannot be told apart, so pointing at it would send the user in a circle.
|
|
238
|
+
console.log('several clients are running and cannot be told apart: run '
|
|
239
|
+
+ '`/dev auto identify` in each game window, then `lycheedev use --character <name>`');
|
|
240
|
+
} else {
|
|
241
|
+
console.log('several clients are running: `lycheedev use <index>` pins one, '
|
|
242
|
+
+ 'or pass --instance <index> per command');
|
|
243
|
+
}
|
|
179
244
|
} else if (!pinned) {
|
|
180
245
|
console.log('commands target this instance automatically');
|
|
181
246
|
}
|
|
247
|
+
if (identifyNote) console.log(identifyNote);
|
|
182
248
|
return 0;
|
|
183
249
|
}
|
|
184
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Ask the Python helper to read the identity marker from each window.
|
|
253
|
+
*
|
|
254
|
+
* The instance list is handed over as a file rather than arguments, because
|
|
255
|
+
* every field has to survive the trip and a command line is a fragile place to
|
|
256
|
+
* put it. The name is unpredictable and the file is created exclusively, so a
|
|
257
|
+
* pre-existing file at that path cannot be followed or silently overwritten.
|
|
258
|
+
*/
|
|
259
|
+
function probeIdentities(supported, flags) {
|
|
260
|
+
const windowsFile = path.join(os.tmpdir(),
|
|
261
|
+
`lycheedev-windows-${process.pid}-${randomBytes(8).toString('hex')}.json`);
|
|
262
|
+
try {
|
|
263
|
+
fs.writeFileSync(windowsFile, JSON.stringify(supported), { encoding: 'utf8', flag: 'wx' });
|
|
264
|
+
const args = ['identify', '--windows-json', windowsFile];
|
|
265
|
+
if (flags.timeout) args.push('--timeout', String(flags.timeout));
|
|
266
|
+
const result = runAutomation(args, {
|
|
267
|
+
pythonBin: flags.python || null,
|
|
268
|
+
inherit: false,
|
|
269
|
+
});
|
|
270
|
+
if (!result.ok) {
|
|
271
|
+
return { error: `could not read identity markers: ${result.stderr || 'helper failed'}` };
|
|
272
|
+
}
|
|
273
|
+
return { list: JSON.parse(result.stdout || '[]') };
|
|
274
|
+
} catch (error) {
|
|
275
|
+
return { error: `could not read identity markers: ${error.message}` };
|
|
276
|
+
} finally {
|
|
277
|
+
try {
|
|
278
|
+
fs.unlinkSync(windowsFile);
|
|
279
|
+
} catch {
|
|
280
|
+
// A leftover temp file is harmless.
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
185
285
|
/**
|
|
186
286
|
* Resolve the live game window a command should type into.
|
|
187
287
|
*
|
|
188
|
-
* Precedence: an explicit `--hwnd`/`--pid`, then `--instance <index>`, then
|
|
189
|
-
* saved pin, then `--client`, and finally the only
|
|
190
|
-
* is exactly one. `WowClassic.exe` looks identical
|
|
191
|
-
* an ambiguous choice fails loudly instead of typing
|
|
288
|
+
* Precedence: an explicit `--hwnd`/`--pid`, then `--instance <index>`, then
|
|
289
|
+
* `--character <name>`, then the saved pin, then `--client`, and finally the only
|
|
290
|
+
* running instance when there is exactly one. `WowClassic.exe` looks identical
|
|
291
|
+
* for every classic build, so an ambiguous choice fails loudly instead of typing
|
|
292
|
+
* into the wrong game.
|
|
293
|
+
*
|
|
294
|
+
* Windows of one build are distinguishable when each reports a different
|
|
295
|
+
* character; only windows that report the same character (or no marker at all)
|
|
296
|
+
* are genuinely ambiguous, and those still fail loudly.
|
|
192
297
|
*/
|
|
193
298
|
function resolveRuntime(flags) {
|
|
194
299
|
if (flags.hwnd || flags.pid) {
|
|
@@ -207,6 +312,14 @@ function resolveRuntime(flags) {
|
|
|
207
312
|
return toTarget(chosen);
|
|
208
313
|
}
|
|
209
314
|
|
|
315
|
+
if (flags.character) {
|
|
316
|
+
// A named character is only findable if the window showed its marker, so
|
|
317
|
+
// probe first; this is read-only capture and types nothing.
|
|
318
|
+
const named = resolveByCharacter(instances, flags.character, flags);
|
|
319
|
+
if (named.error) return { error: true };
|
|
320
|
+
return toTarget(named.instance);
|
|
321
|
+
}
|
|
322
|
+
|
|
210
323
|
if (!flags.client) {
|
|
211
324
|
const config = loadConfig();
|
|
212
325
|
const pinned = matchPinned(instances, config.pinnedInstance);
|
|
@@ -222,14 +335,29 @@ function resolveRuntime(flags) {
|
|
|
222
335
|
const resolved = resolveInstance(instances, { clientId: flags.client || null, index: null });
|
|
223
336
|
if (resolved.error) {
|
|
224
337
|
const shape = describeAmbiguity(instances);
|
|
225
|
-
// Several windows of one build: no flag can pick the right one reliably, so
|
|
226
|
-
// ask for a single window rather than inviting a wrong guess.
|
|
227
338
|
if (shape.sameBuildCollision) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
339
|
+
// Same build and no way to separate the windows: no flag can pick the right
|
|
340
|
+
// one reliably, so ask for a single window rather than inviting a wrong guess.
|
|
341
|
+
for (const entry of shape.collisions) {
|
|
342
|
+
for (const group of entry.sameCharacter) {
|
|
343
|
+
const label = group[0].flavorLabel || entry.flavorId;
|
|
344
|
+
console.error(`error: ${group.length} ${label} clients report the same character `
|
|
345
|
+
+ `and cannot be told apart`);
|
|
346
|
+
console.error(` close all but one, or close these pids: `
|
|
347
|
+
+ group.map((i) => i.pid).join(', '));
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (!shape.sameBuildNamed) {
|
|
351
|
+
console.error(' run `/dev auto identify` in each game window, then retry '
|
|
352
|
+
+ 'with --identify');
|
|
232
353
|
}
|
|
354
|
+
} else if (supported.length > 1) {
|
|
355
|
+
// Several windows of one build, and the caller filtered to that build. They
|
|
356
|
+
// may well be separable by character, so say how rather than just failing.
|
|
357
|
+
console.error(`error: ${resolved.error}`);
|
|
358
|
+
console.error(' if each window shows a different character, run '
|
|
359
|
+
+ '`/dev auto identify` in each, then pass --character <name>; '
|
|
360
|
+
+ 'otherwise pass --instance <index>');
|
|
233
361
|
} else {
|
|
234
362
|
console.error(`error: ${resolved.error}`);
|
|
235
363
|
}
|
|
@@ -244,6 +372,43 @@ function resolveRuntime(flags) {
|
|
|
244
372
|
return toTarget(resolved.instance);
|
|
245
373
|
}
|
|
246
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Find the window reporting a named character, probing the markers first.
|
|
377
|
+
*
|
|
378
|
+
* Names only exist inside the marker, so read it when the caller has not already
|
|
379
|
+
* supplied it. Returns `{ instance }` or `{ error: true }` after explaining why.
|
|
380
|
+
*/
|
|
381
|
+
function resolveByCharacter(instances, query, flags) {
|
|
382
|
+
const supported = instances.filter((item) => item.supported);
|
|
383
|
+
if (supported.length === 0) {
|
|
384
|
+
console.error('error: no served build is running');
|
|
385
|
+
return { error: true };
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
let probed = supported;
|
|
389
|
+
if (!supported.some((item) => item.identity)) {
|
|
390
|
+
const result = probeIdentities(supported, flags);
|
|
391
|
+
if (result.error) {
|
|
392
|
+
console.error('error: could not read identity markers; run '
|
|
393
|
+
+ '`lycheedev instances --identify` after `/dev auto identify` in each game window');
|
|
394
|
+
return { error: true };
|
|
395
|
+
}
|
|
396
|
+
const byHwnd = new Map(result.list.map((entry) => [String(entry.hwnd), entry]));
|
|
397
|
+
probed = supported.map((instance) => {
|
|
398
|
+
const entry = byHwnd.get(String(instance.hwnd));
|
|
399
|
+
return entry && entry.identity ? { ...instance, identity: entry.identity } : instance;
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const matched = matchIdentity(probed, query);
|
|
404
|
+
if (matched.error) {
|
|
405
|
+
console.error(`error: ${matched.error}`);
|
|
406
|
+
(matched.candidates || probed).forEach((item, index) => console.log(formatInstance(item, index)));
|
|
407
|
+
return { error: true };
|
|
408
|
+
}
|
|
409
|
+
return { instance: matched.instance };
|
|
410
|
+
}
|
|
411
|
+
|
|
247
412
|
function toTarget(instance) {
|
|
248
413
|
return {
|
|
249
414
|
hwnd: instance.hwnd ? `0x${instance.hwnd.toString(16)}` : null,
|
|
@@ -253,15 +418,18 @@ function toTarget(instance) {
|
|
|
253
418
|
}
|
|
254
419
|
|
|
255
420
|
/**
|
|
256
|
-
* `lycheedev use [index]`: keep one running client as the
|
|
421
|
+
* `lycheedev use [index|--character <name>]`: keep one running client as the
|
|
422
|
+
* default target.
|
|
257
423
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
424
|
+
* The pin stores the build, the instance ordinal and — when the window showed
|
|
425
|
+
* its identity marker — the character. The character is the durable half: pids
|
|
426
|
+
* and window handles change every launch, and an ordinal shifts as soon as the
|
|
427
|
+
* windows are opened in a different order.
|
|
260
428
|
*/
|
|
261
429
|
function runUse(flags, rest) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
430
|
+
let instances = findInstances({ pythonBin: flags.python || null });
|
|
431
|
+
let shape = describeAmbiguity(instances);
|
|
432
|
+
let supported = shape.supported;
|
|
265
433
|
|
|
266
434
|
if (flags.clear) {
|
|
267
435
|
updateConfig({ pinnedInstance: null });
|
|
@@ -276,16 +444,55 @@ function runUse(flags, rest) {
|
|
|
276
444
|
return 1;
|
|
277
445
|
}
|
|
278
446
|
|
|
279
|
-
//
|
|
280
|
-
//
|
|
447
|
+
// Probing is read-only capture that types nothing, so do it whenever it could
|
|
448
|
+
// resolve an ambiguity. An explicit index or character already is the decision,
|
|
449
|
+
// so probing then would only add seconds of waiting for no new information.
|
|
450
|
+
const decided = Boolean(flags.character) || rest.length > 0 || flags.instance !== undefined;
|
|
451
|
+
const wantsIdentity = Boolean(flags.character) || Boolean(flags.identify)
|
|
452
|
+
|| (shape.sameBuildCollision && !decided);
|
|
453
|
+
if (wantsIdentity) {
|
|
454
|
+
const probed = probeIdentities(supported, flags);
|
|
455
|
+
if (probed.error) {
|
|
456
|
+
if (flags.character) {
|
|
457
|
+
console.error(`error: ${probed.error}`);
|
|
458
|
+
return 1;
|
|
459
|
+
}
|
|
460
|
+
// Without an explicit name request the pin can still be taken by ordinal.
|
|
461
|
+
} else {
|
|
462
|
+
const byHwnd = new Map(probed.list.map((entry) => [String(entry.hwnd), entry]));
|
|
463
|
+
instances = instances.map((instance) => {
|
|
464
|
+
const entry = byHwnd.get(String(instance.hwnd));
|
|
465
|
+
return entry && entry.identity ? { ...instance, identity: entry.identity } : instance;
|
|
466
|
+
});
|
|
467
|
+
supported = instances.filter((item) => item.supported);
|
|
468
|
+
shape = describeAmbiguity(instances);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// Pinning by name is the recommended path when several windows share a build.
|
|
473
|
+
if (flags.character) {
|
|
474
|
+
const matched = matchIdentity(supported, flags.character);
|
|
475
|
+
if (matched.error) {
|
|
476
|
+
console.error(`error: ${matched.error}`);
|
|
477
|
+
(matched.candidates || supported).forEach((item, index) => console.log(formatInstance(item, index)));
|
|
478
|
+
return 1;
|
|
479
|
+
}
|
|
480
|
+
return savePin(matched.instance);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Only windows that report the same character (or no marker at all) are
|
|
484
|
+
// genuinely indistinguishable; those still get asked for a single window.
|
|
281
485
|
if (shape.sameBuildCollision) {
|
|
282
|
-
for (const
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
486
|
+
for (const entry of shape.collisions) {
|
|
487
|
+
for (const group of entry.sameCharacter) {
|
|
488
|
+
const label = group[0].flavorLabel || entry.flavorId;
|
|
489
|
+
console.error(`error: ${group.length} ${label} clients cannot be told apart`);
|
|
490
|
+
console.error(` close all but one, or close these pids: `
|
|
491
|
+
+ group.map((i) => i.pid).join(', '));
|
|
492
|
+
}
|
|
286
493
|
}
|
|
287
|
-
console.error('
|
|
288
|
-
|
|
494
|
+
console.error(' or run `/dev auto identify` in each game window and then '
|
|
495
|
+
+ '`lycheedev use --character <name>`');
|
|
289
496
|
supported.forEach((item, index) => console.log(formatInstance(item, index)));
|
|
290
497
|
return 1;
|
|
291
498
|
}
|
|
@@ -316,10 +523,22 @@ function runUse(flags, rest) {
|
|
|
316
523
|
ordinal = 0;
|
|
317
524
|
}
|
|
318
525
|
|
|
319
|
-
|
|
526
|
+
return savePin(chosen, ordinal);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** Persist a pin, preferring the character when the window reported one. */
|
|
530
|
+
function savePin(chosen, ordinal = 0) {
|
|
531
|
+
const pin = { flavor: chosen.flavorId, ordinal };
|
|
532
|
+
// The character is the durable half of the pin; the ordinal stays as a
|
|
533
|
+
// fallback for a build whose windows never showed a marker.
|
|
534
|
+
const character = identityKey(chosen);
|
|
535
|
+
if (character) pin.character = character;
|
|
536
|
+
|
|
537
|
+
updateConfig({ pinnedInstance: pin });
|
|
320
538
|
const label = chosen.flavorLabel || chosen.flavorFolder;
|
|
321
|
-
|
|
322
|
-
console.log(
|
|
539
|
+
const name = identityLabel(chosen);
|
|
540
|
+
console.log(`pinned ${label}${name ? ` (${name})` : ''} (pid ${chosen.pid})`);
|
|
541
|
+
console.log('commands now target it; pass --instance <index> or --character <name> to override');
|
|
323
542
|
return 0;
|
|
324
543
|
}
|
|
325
544
|
|
|
@@ -383,7 +602,7 @@ function main(argv) {
|
|
|
383
602
|
: null;
|
|
384
603
|
if (runtime && runtime.error) return 1;
|
|
385
604
|
const live = runtime && runtime.hwnd
|
|
386
|
-
?
|
|
605
|
+
? runtime
|
|
387
606
|
: null;
|
|
388
607
|
|
|
389
608
|
switch (command) {
|
|
@@ -409,7 +628,7 @@ function main(argv) {
|
|
|
409
628
|
console.error('error: no SavedVariables path recorded for this client; re-run `lycheedev install`');
|
|
410
629
|
return 1;
|
|
411
630
|
}
|
|
412
|
-
return forward(['run', ...targetArgs(live), '--task', flags.task, '--sv', client.svPath,
|
|
631
|
+
return forward(['run', ...forwarded, ...targetArgs(live), '--task', flags.task, '--sv', client.svPath,
|
|
413
632
|
...passthrough(flags)]);
|
|
414
633
|
case 'bugs':
|
|
415
634
|
if (!flags.count) {
|
package/package.json
CHANGED
package/src/addon.js
CHANGED
|
@@ -31,7 +31,7 @@ export function installedVersion(addonsDir, toc = null) {
|
|
|
31
31
|
const catalogs = toc
|
|
32
32
|
? [toc]
|
|
33
33
|
: [`${addonFolderName}_Mainline.toc`, `${addonFolderName}_Mists.toc`,
|
|
34
|
-
`${addonFolderName}_Wrath.toc`];
|
|
34
|
+
`${addonFolderName}_Wrath.toc`, `${addonFolderName}_Forever.toc`];
|
|
35
35
|
for (const name of catalogs) {
|
|
36
36
|
const file = path.join(target, name);
|
|
37
37
|
if (!exists(file)) continue;
|
package/src/doctor.js
CHANGED
|
@@ -93,7 +93,8 @@ export function runDoctor({ flags }) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
// Which clients are running decides what `send`/`run` can target.
|
|
96
|
+
// Which clients are running decides what `send`/`run` can target. Reuse the
|
|
97
|
+
// interpreter already resolved above rather than probing for one again.
|
|
97
98
|
const instances = findInstances({ pythonBin: python ? python.bin : null });
|
|
98
99
|
const supportedRunning = instances.filter((item) => item.supported);
|
|
99
100
|
if (instances.length === 0) {
|
package/src/install.js
CHANGED
|
@@ -7,7 +7,7 @@ import { loadConfig, setClient, updateConfig } from './config.js';
|
|
|
7
7
|
import { exists } from './paths.js';
|
|
8
8
|
import { depsInstalled, findPython, installDeps } from './python.js';
|
|
9
9
|
import { installSkill } from './skill.js';
|
|
10
|
-
import { detectWowRoots, findSavedVariablesCandidates, scanClients } from './wow.js';
|
|
10
|
+
import { detectWowRoots, findSavedVariablesCandidates, knownFolders, scanClients } from './wow.js';
|
|
11
11
|
|
|
12
12
|
function step(label, fn) {
|
|
13
13
|
process.stdout.write(`\n` + `${label}\n`);
|
|
@@ -30,8 +30,11 @@ export function resolveWowRoot({ wowRoot, config }) {
|
|
|
30
30
|
const clients = scanClients(resolved);
|
|
31
31
|
if (clients.length === 0) {
|
|
32
32
|
return {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// List what detection actually accepts, generated from the same table,
|
|
34
|
+
// so the message cannot drift from the behavior it describes.
|
|
35
|
+
error: `${resolved} has no known client folder:\n `
|
|
36
|
+
+ knownFolders().join('\n ')
|
|
37
|
+
+ '\npoint --wow-root at the folder that contains them',
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
return { root: resolved, clients };
|
|
@@ -79,7 +82,12 @@ export function runInstall({ flags }) {
|
|
|
79
82
|
|
|
80
83
|
const nextConfig = { ...config, wowRoot: resolved.root, pythonBin: flags.python || config.pythonBin };
|
|
81
84
|
const addonResults = [];
|
|
82
|
-
|
|
85
|
+
// Prefer retail as the default target so a routine command stays predictable;
|
|
86
|
+
// otherwise take the first supported client that was actually updated.
|
|
87
|
+
const preferredDefault = resolved.clients.some((client) => client.toc && client.id === 'retail')
|
|
88
|
+
? 'retail'
|
|
89
|
+
: null;
|
|
90
|
+
let defaultClient = config.defaultClient || preferredDefault || null;
|
|
83
91
|
|
|
84
92
|
for (const client of resolved.clients) {
|
|
85
93
|
// A build without a catalog is reported, not silently dropped: the folder
|
package/src/py/instances.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"""List running World of Warcraft instances as JSON.
|
|
2
2
|
|
|
3
3
|
The executable name cannot identify a build: Blizzard ships every non-retail
|
|
4
|
-
client as ``WowClassic.exe``. The install path
|
|
5
|
-
a
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
client as ``WowClassic.exe``. The install path narrows it to a ``_flavor_``
|
|
5
|
+
folder, but a folder is a location rather than an identity - the game reuses a
|
|
6
|
+
test folder for whatever is on the test track, so ``_classic_beta_`` currently
|
|
7
|
+
carries WoW: Forever (1.60.x) on that track. The folder's own ``.flavor.info``
|
|
8
|
+
product code and ``version.txt`` build are reported alongside the window handle
|
|
9
|
+
so the caller can identify the client from the client itself.
|
|
10
|
+
|
|
11
|
+
Read-only: this opens no process, only enumerates windows and reads process
|
|
12
|
+
metadata plus two small per-folder files.
|
|
9
13
|
"""
|
|
10
14
|
|
|
11
15
|
from __future__ import annotations
|
|
@@ -13,6 +17,7 @@ from __future__ import annotations
|
|
|
13
17
|
import ctypes
|
|
14
18
|
import json
|
|
15
19
|
import os
|
|
20
|
+
import re
|
|
16
21
|
import sys
|
|
17
22
|
from ctypes import wintypes
|
|
18
23
|
|
|
@@ -22,6 +27,8 @@ kernel32 = ctypes.windll.kernel32
|
|
|
22
27
|
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
|
|
23
28
|
ERROR_INSUFFICIENT_BUFFER = 122
|
|
24
29
|
|
|
30
|
+
_FLAVOR_PRODUCT = re.compile(rb"\b(wow[a-z0-9_]*)\b", re.IGNORECASE)
|
|
31
|
+
|
|
25
32
|
user32.EnumWindows.restype = wintypes.BOOL
|
|
26
33
|
user32.EnumWindows.argtypes = [ctypes.c_void_p, wintypes.LPARAM]
|
|
27
34
|
user32.IsWindowVisible.restype = wintypes.BOOL
|
|
@@ -44,6 +51,10 @@ FLAVOR_LABELS = {
|
|
|
44
51
|
"_retail_": ("retail", "Retail"),
|
|
45
52
|
"_classic_": ("classic", "Classic"),
|
|
46
53
|
"_classic_titan_": ("titan", "Classic Titan"),
|
|
54
|
+
# Folder default only: this folder also carries WoW: Forever on the test
|
|
55
|
+
# track, which the caller resolves from the folder's own product code.
|
|
56
|
+
"_classic_beta_": ("classicBeta", "Classic Beta"),
|
|
57
|
+
"_forever_": ("forever", "Forever"),
|
|
47
58
|
"_classic_era_": ("classicEra", "Classic Era"),
|
|
48
59
|
"_anniversary_": ("anniversary", "Anniversary"),
|
|
49
60
|
"_beta_": ("beta", "Beta"),
|
|
@@ -66,6 +77,31 @@ def process_image(pid: int) -> str | None:
|
|
|
66
77
|
kernel32.CloseHandle(handle)
|
|
67
78
|
|
|
68
79
|
|
|
80
|
+
def _read_small_text(path: str, limit: int = 512) -> str | None:
|
|
81
|
+
try:
|
|
82
|
+
with open(path, "rb") as handle:
|
|
83
|
+
return handle.read(limit).decode("utf-8", "replace").strip() or None
|
|
84
|
+
except OSError:
|
|
85
|
+
return None
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def folder_product(version_dir: str) -> str | None:
|
|
89
|
+
"""The folder's declared product code, e.g. ``wow_classic_titan``."""
|
|
90
|
+
for name in (".flavor.info", "flavor.info"):
|
|
91
|
+
text = _read_small_text(os.path.join(version_dir, name))
|
|
92
|
+
if not text:
|
|
93
|
+
continue
|
|
94
|
+
match = _FLAVOR_PRODUCT.search(text.encode("utf-8", "replace"))
|
|
95
|
+
if match:
|
|
96
|
+
return match.group(1).decode("ascii", "replace").lower()
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def folder_version(version_dir: str) -> str | None:
|
|
101
|
+
"""The folder's build, e.g. ``1.60.1.69893`` from ``version.txt``."""
|
|
102
|
+
return _read_small_text(os.path.join(version_dir, "version.txt"))
|
|
103
|
+
|
|
104
|
+
|
|
69
105
|
def visible_windows() -> dict[int, dict]:
|
|
70
106
|
found: dict[int, dict] = {}
|
|
71
107
|
|
|
@@ -99,7 +135,14 @@ def main() -> int:
|
|
|
99
135
|
continue
|
|
100
136
|
parts = image.replace("/", os.sep).split(os.sep)
|
|
101
137
|
folder = next((part for part in parts if part.startswith("_") and part.endswith("_")), None)
|
|
138
|
+
# Folder defaults only. The caller re-resolves the flavor from `product`
|
|
139
|
+
# and `version`, because a folder name is a location rather than an
|
|
140
|
+
# identity; keeping the product rule in one place avoids two mappings
|
|
141
|
+
# that can disagree about a reused test folder.
|
|
102
142
|
flavor_id, label = FLAVOR_LABELS.get(folder, (None, None))
|
|
143
|
+
version_dir = os.path.dirname(image)
|
|
144
|
+
product = folder_product(version_dir)
|
|
145
|
+
version = folder_version(version_dir)
|
|
103
146
|
instances.append({
|
|
104
147
|
"pid": pid,
|
|
105
148
|
"exe": os.path.basename(image),
|
|
@@ -107,6 +150,8 @@ def main() -> int:
|
|
|
107
150
|
"flavorFolder": folder,
|
|
108
151
|
"flavorId": flavor_id,
|
|
109
152
|
"flavorLabel": label,
|
|
153
|
+
"product": product,
|
|
154
|
+
"version": version,
|
|
110
155
|
"hwnd": windows[pid]["hwnd"],
|
|
111
156
|
"title": windows[pid]["title"],
|
|
112
157
|
})
|