lycheedev 1.0.3 → 1.0.5

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 CHANGED
@@ -6,12 +6,13 @@ import path from 'node:path';
6
6
 
7
7
  import { runDoctor } from '../src/doctor.js';
8
8
  import { runInstall } from '../src/install.js';
9
- import { loadConfig } from '../src/config.js';
9
+ import { loadConfig, updateConfig } from '../src/config.js';
10
10
  import { runAutomation } from '../src/python.js';
11
11
  import {
12
12
  findInstances,
13
13
  findSavedVariablesCandidates,
14
14
  formatInstance,
15
+ matchPinned,
15
16
  resolveInstance,
16
17
  scanClients,
17
18
  } from '../src/wow.js';
@@ -27,6 +28,8 @@ commands
27
28
  doctor report what is installed and what is missing
28
29
  clients list every detected build and its addon state
29
30
  instances list running game clients (build, pid, window)
31
+ use [index] pin one running client as the default target
32
+ use --clear drop the pin
30
33
  send <text> type one slash command into the running game
31
34
  capture poll the game window and decode the completion notice
32
35
  run --task <id> deliver, decode, reload once and read the result ticket
@@ -52,8 +55,10 @@ options
52
55
  -v, --version show the version
53
56
 
54
57
  Every non-retail client runs as WowClassic.exe, so a running client is matched
55
- by its install path, not its process name. When several clients are open, run
56
- "lycheedev instances" first and pass --instance <index> to choose one.
58
+ by its install path, not its process name. With several clients open, run
59
+ "lycheedev instances" then "lycheedev use <index>" to pin one as the target;
60
+ the pin stores the build, so it survives a restart even though the pid and
61
+ window handle change. Pass --instance <index> to override it for one command.
57
62
 
58
63
  The automation subcommands are thin wrappers over the bundled python helper, so
59
64
  the same arguments it accepts are forwarded unchanged.`;
@@ -146,21 +151,31 @@ function runClients(flags) {
146
151
 
147
152
  /** `lycheedev instances`: which game clients are running right now. */
148
153
  function runInstances(flags) {
154
+ const config = loadConfig();
149
155
  const instances = findInstances({ pythonBin: flags.python || null });
150
156
  if (instances.length === 0) {
151
157
  console.log('no World of Warcraft instance is running');
152
158
  return 0;
153
159
  }
160
+ const pinned = matchPinned(instances, config.pinnedInstance);
154
161
  console.log('running instances:');
155
- instances.forEach((instance, index) => console.log(formatInstance(instance, index)));
162
+ instances.forEach((instance, index) => {
163
+ console.log(formatInstance(instance, index));
164
+ });
156
165
  const supported = instances.filter((item) => item.supported);
157
- const sameBuild = supported.length > 1;
158
166
  console.log('');
167
+ if (pinned) {
168
+ const label = pinned.flavorLabel || pinned.flavorFolder;
169
+ console.log(`pinned: ${label} (pid ${pinned.pid}), pid ${pinned.pid} - commands target it`);
170
+ } else if (config.pinnedInstance) {
171
+ console.log('pinned client is not running; run `lycheedev use` to repin');
172
+ }
159
173
  if (supported.length === 0) {
160
174
  console.log('none of these builds are served by the addon');
161
- } else if (sameBuild) {
162
- console.log('several instances are running: target one with `--instance <index>`');
163
- } else {
175
+ } else if (!pinned && supported.length > 1) {
176
+ console.log('several clients are running: `lycheedev use <index>` pins one, '
177
+ + 'or pass --instance <index> per command');
178
+ } else if (!pinned) {
164
179
  console.log('commands target this instance automatically');
165
180
  }
166
181
  return 0;
@@ -169,28 +184,55 @@ function runInstances(flags) {
169
184
  /**
170
185
  * Resolve the live game window a command should type into.
171
186
  *
172
- * The executable name cannot identify a build, so the running instance list is
173
- * the source of truth: `--instance <index>` picks explicitly, `--client`
174
- * filters by build, and a single match needs no flag at all. `--hwnd`/`--pid`
175
- * still override for scripted use.
187
+ * Precedence: an explicit `--hwnd`/`--pid`, then `--instance <index>`, then the
188
+ * saved pin, then `--client`, and finally the only running instance when there
189
+ * is exactly one. `WowClassic.exe` looks identical for every classic build, so
190
+ * an ambiguous choice fails loudly instead of typing into the wrong game.
176
191
  */
177
192
  function resolveRuntime(flags) {
178
193
  if (flags.hwnd || flags.pid) {
179
194
  return { hwnd: flags.hwnd, pid: flags.pid };
180
195
  }
181
196
  const instances = findInstances({ pythonBin: flags.python || null });
182
- const resolved = resolveInstance(instances, {
183
- clientId: flags.client || null,
184
- index: flags.instance !== undefined ? flags.instance : null,
185
- });
197
+ const supported = instances.filter((item) => item.supported);
198
+
199
+ if (flags.instance !== undefined) {
200
+ const chosen = supported[Number(flags.instance)];
201
+ if (!chosen) {
202
+ console.error(`error: --instance ${flags.instance} is out of range (0..${supported.length - 1})`);
203
+ supported.forEach((item, index) => console.log(formatInstance(item, index)));
204
+ return { error: true };
205
+ }
206
+ return toTarget(chosen);
207
+ }
208
+
209
+ if (!flags.client) {
210
+ const config = loadConfig();
211
+ const pinned = matchPinned(instances, config.pinnedInstance);
212
+ if (pinned) {
213
+ return toTarget(pinned);
214
+ }
215
+ if (config.pinnedInstance) {
216
+ console.error('error: the pinned client is not running; run `lycheedev use` again '
217
+ + 'or pass --instance <index>');
218
+ }
219
+ }
220
+
221
+ const resolved = resolveInstance(instances, { clientId: flags.client || null, index: null });
186
222
  if (resolved.error) {
187
223
  console.error(`error: ${resolved.error}`);
188
224
  if (resolved.candidates) {
189
225
  resolved.candidates.forEach((item, index) => console.log(formatInstance(item, index)));
190
226
  }
227
+ if (supported.length === 0 && instances.length > 0) {
228
+ instances.forEach((item, index) => console.log(formatInstance(item, index)));
229
+ }
191
230
  return { error: true };
192
231
  }
193
- const instance = resolved.instance;
232
+ return toTarget(resolved.instance);
233
+ }
234
+
235
+ function toTarget(instance) {
194
236
  return {
195
237
  hwnd: instance.hwnd ? `0x${instance.hwnd.toString(16)}` : null,
196
238
  pid: instance.pid ? String(instance.pid) : null,
@@ -198,6 +240,60 @@ function resolveRuntime(flags) {
198
240
  };
199
241
  }
200
242
 
243
+ /**
244
+ * `lycheedev use [index]`: keep one running client as the default target.
245
+ *
246
+ * Stores only the build and the instance ordinal, so the pin survives a
247
+ * restart even though the pid and window handle do not.
248
+ */
249
+ function runUse(flags, rest) {
250
+ const instances = findInstances({ pythonBin: flags.python || null });
251
+ const supported = instances.filter((item) => item.supported);
252
+
253
+ if (flags.clear) {
254
+ updateConfig({ pinnedInstance: null });
255
+ console.log('cleared the pinned client');
256
+ return 0;
257
+ }
258
+ if (supported.length === 0) {
259
+ console.error('error: no supported World of Warcraft instance is running');
260
+ if (instances.length > 0) {
261
+ instances.forEach((item, index) => console.log(formatInstance(item, index)));
262
+ }
263
+ return 1;
264
+ }
265
+
266
+ const requested = rest.length > 0 ? Number(rest[0]) : (flags.instance !== undefined ? Number(flags.instance) : null);
267
+ let chosen;
268
+ let ordinal;
269
+ if (requested !== null) {
270
+ chosen = supported[requested];
271
+ if (!chosen) {
272
+ console.error(`error: instance ${requested} is out of range (0..${supported.length - 1})`);
273
+ supported.forEach((item, index) => console.log(formatInstance(item, index)));
274
+ return 1;
275
+ }
276
+ ordinal = supported
277
+ .slice(0, requested)
278
+ .filter((item) => item.flavorId === chosen.flavorId)
279
+ .length;
280
+ } else {
281
+ if (supported.length > 1) {
282
+ console.error('error: several clients are running; pass an index, e.g. `lycheedev use 0`');
283
+ supported.forEach((item, index) => console.log(formatInstance(item, index)));
284
+ return 1;
285
+ }
286
+ [chosen] = supported;
287
+ ordinal = 0;
288
+ }
289
+
290
+ updateConfig({ pinnedInstance: { flavor: chosen.flavorId, ordinal } });
291
+ const label = chosen.flavorLabel || chosen.flavorFolder;
292
+ console.log(`pinned ${label}${ordinal > 0 ? ` instance ${ordinal}` : ''} (pid ${chosen.pid})`);
293
+ console.log('commands now target it; pass --instance <index> to override');
294
+ return 0;
295
+ }
296
+
201
297
  function main(argv) {
202
298
  const { flags, rest } = parse(argv);
203
299
  const command = rest.shift();
@@ -231,6 +327,8 @@ function main(argv) {
231
327
  return runClients(flags);
232
328
  case 'instances':
233
329
  return runInstances(flags);
330
+ case 'use':
331
+ return runUse(flags, rest);
234
332
  case 'help':
235
333
  console.log(HELP);
236
334
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lycheedev",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "lycheedev: install the World of Warcraft inspection addon, its in-game automation tooling, and drive it from the command line.",
5
5
  "keywords": [
6
6
  "wow",
package/src/config.js CHANGED
@@ -8,6 +8,10 @@ const EMPTY = {
8
8
  pythonBin: null,
9
9
  installedAt: null,
10
10
  packageVersion: null,
11
+ // Which running client commands should target. `flavor` pins a build,
12
+ // `ordinal` picks among several instances of that same build. Window
13
+ // handles and pids change every launch, so only these stable fields persist.
14
+ pinnedInstance: null,
11
15
  };
12
16
 
13
17
  export function loadConfig() {
package/src/wow.js CHANGED
@@ -233,6 +233,21 @@ export function resolveInstance(instances, { clientId = null, index = null } = {
233
233
  };
234
234
  }
235
235
 
236
+ /**
237
+ * Find the instance a saved pin refers to.
238
+ *
239
+ * A pin stores the build plus which instance of that build, because window
240
+ * handles and pids change every launch. The number shown to the user counts
241
+ * among supported instances, so the same index works here.
242
+ */
243
+ export function matchPinned(instances, pin) {
244
+ if (!pin || !pin.flavor) return null;
245
+ const supported = instances.filter((item) => item.supported);
246
+ const ofFlavor = supported.filter((item) => item.flavorId === pin.flavor);
247
+ if (ofFlavor.length === 0) return null;
248
+ return ofFlavor[pin.ordinal || 0] || ofFlavor[0];
249
+ }
250
+
236
251
  export function formatInstance(instance, index) {
237
252
  const flavor = instance.flavorLabel || instance.flavorFolder || 'unknown';
238
253
  const suffix = instance.supported ? '' : ' (the addon does not serve this build)';
@@ -6,7 +6,7 @@
6
6
  ## Notes-zhCN: 运行 Lua,检查对象与事件,追踪函数并查看错误。
7
7
  ## Notes-zhTW: 執行 Lua,檢查物件與事件,追蹤函式並檢視錯誤。
8
8
  ## Author: Follen
9
- ## Version: 1.0.3
9
+ ## Version: 1.0.5
10
10
  ## Dependencies: !BugGrabber
11
11
  ## SavedVariables: LycheeDevDB, DumperDB
12
12
  ## IconTexture: Interface\AddOns\Lychee Dev\Media\Logo.png
@@ -6,7 +6,7 @@
6
6
  ## Notes-zhCN: 运行 Lua,检查对象与事件,追踪函数并查看错误。
7
7
  ## Notes-zhTW: 執行 Lua,檢查物件與事件,追蹤函式並檢視錯誤。
8
8
  ## Author: Follen
9
- ## Version: 1.0.3
9
+ ## Version: 1.0.5
10
10
  ## Dependencies: !BugGrabber
11
11
  ## SavedVariables: LycheeDevDB, DumperDB
12
12
  ## IconTexture: Interface\AddOns\Lychee Dev\Media\Logo.png
@@ -6,7 +6,7 @@
6
6
  ## Notes-zhCN: 运行 Lua,检查对象与事件,追踪函数并查看错误。
7
7
  ## Notes-zhTW: 執行 Lua,檢查物件與事件,追蹤函式並檢視錯誤。
8
8
  ## Author: Follen
9
- ## Version: 1.0.3
9
+ ## Version: 1.0.5
10
10
  ## Dependencies: !BugGrabber
11
11
  ## SavedVariables: LycheeDevDB, DumperDB
12
12
  ## IconTexture: Interface\AddOns\Lychee Dev\Media\Logo.png
@@ -7,6 +7,14 @@ description: Use when working with the Lychee Dev WoW addon to read persisted ru
7
7
 
8
8
  Use this skill as the operational guide for Lychee Dev, an in-game evidence workbench. The desired output is either (a) an evidence-backed diagnosis from SavedVariables or (b) a command/workflow the user can paste into WoW and report back.
9
9
 
10
+ Detail lives in `references/`. Read the one that matches the task instead of guessing:
11
+
12
+ | Reference | Read it when |
13
+ | --- | --- |
14
+ | [references/clients.md](references/clients.md) | Any command that types into the game, or the user has several builds or instances open |
15
+ | [references/automation.md](references/automation.md) | Authorized scripted task delivery: task blocks, run, notice, reload, receipt |
16
+ | [references/runtime-investigations.md](references/runtime-investigations.md) | Designing a memory/CPU probe |
17
+
10
18
  ## Choose the workflow
11
19
 
12
20
  - **Persisted evidence:** locate the WoW `WTF` SavedVariables file, find the exact Ticket, and read the complete payload.
@@ -18,6 +26,20 @@ Use this skill as the operational guide for Lychee Dev, an in-game evidence work
18
26
 
19
27
  The Performance page, automatic capture, health scan and function benchmark have been removed. Run, Objects, Events, Trace, Errors and Saved Records remain available. Do not route a new investigation to the removed UI. There are no separate `/object` or `/event` slash commands. Do not invent them; give the `/dev` UI steps instead.
20
28
 
29
+ ## Know which client you are driving
30
+
31
+ Three builds are supported: Retail `12.1.0` (`_retail_`), Classic `5.5.4` (`_classic_`) and Classic Titan `3.80.2` (`_classic_titan_`). Other folders may exist on disk but the addon does not serve them. Never infer the build from the window title, and never assume `WowClassic.exe` means Classic — every non-retail build uses that name.
32
+
33
+ Before a command that types into the game, confirm the target:
34
+
35
+ ```text
36
+ lycheedev clients # every build on disk, its version, and install state
37
+ lycheedev instances # what is running now, with pid and window handle
38
+ lycheedev use [index] # pin one as the default target
39
+ ```
40
+
41
+ With several clients open, `--instance <index>` overrides the pin for one command and `--client` filters by build. Same-build instances are ambiguous and the CLI refuses to guess. Full rules and the precedence order are in [references/clients.md](references/clients.md).
42
+
21
43
  ## Read SavedVariables
22
44
 
23
45
  1. Search the user's WoW installation for the global SavedVariables file, normally `WTF/Account/<account>/SavedVariables/Lychee Dev.lua`. The exact account/realm path is installation-specific. Use a filename search or `rg` for `LycheeDevDB`/the Ticket rather than assuming a path.
@@ -0,0 +1,119 @@
1
+ # Clients, builds and instances
2
+
3
+ How to tell which World of Warcraft client you are driving, and how to target
4
+ one when several are running. Read this before any command that types into the
5
+ game (`send`, `run`, `bugs`, `capture`, `ack`).
6
+
7
+ ## Supported builds
8
+
9
+ The addon ships one catalog per supported build. Nothing else loads it.
10
+
11
+ | Build | Version | Interface | Catalog | Install folder |
12
+ | --- | --- | --- | --- | --- |
13
+ | Retail | `12.1.0` | `120100` | `Lychee Dev_Mainline.toc` | `_retail_` |
14
+ | Classic | `5.5.4` | `50504` | `Lychee Dev_Mists.toc` | `_classic_` |
15
+ | Classic Titan | `3.80.2` | `38002` | `Lychee Dev_Wrath.toc` | `_classic_titan_` |
16
+
17
+ Other folders may exist on a machine (`_classic_era_`, `_anniversary_`,
18
+ `_beta_`). They are reported as **not served by the addon** and are deliberately
19
+ skipped. Do not install into them and do not tell the user they are supported.
20
+
21
+ The Titan folder is `_classic_titan_`. An earlier release used
22
+ `_classic_arena_`, which does not exist; that made an installed Titan client
23
+ invisible to both `install` and `doctor`. If a user reports "Titan was never
24
+ installed", check the folder name before anything else.
25
+
26
+ ## The executable name does not identify the build
27
+
28
+ Every non-retail client ships as `WowClassic.exe`. `Wow.exe` is retail,
29
+ `WowB.exe` is beta, and `WowVoiceProxy.exe` is a helper, not a client.
30
+
31
+ The **install path** does identify the build, because each one lives under a
32
+ `_build_` directory:
33
+
34
+ ```text
35
+ D:\Game\World of Warcraft\_retail_\Wow.exe -> retail
36
+ D:\Game\World of Warcraft\_classic_\WowClassic.exe -> classic
37
+ D:\Game\World of Warcraft\_classic_titan_\WowClassic.exe -> titan
38
+ ```
39
+
40
+ Never infer the build from the window title. Retail's title is localized (for
41
+ example `魔兽世界`) and gives no build information.
42
+
43
+ ## Commands
44
+
45
+ ### `lycheedev clients`
46
+
47
+ Every build on disk, with its real version read from the executable, and whether
48
+ the addon is installed:
49
+
50
+ ```text
51
+ retail _retail_ v12.1.0.69587 addon installed
52
+ classic _classic_ v5.5.4.69585 addon installed
53
+ titan _classic_titan_ v3.80.2.69496 addon installed
54
+ classicEra _classic_era_ v1.15.9.69547 not served by the addon
55
+ ```
56
+
57
+ ### `lycheedev instances`
58
+
59
+ Which clients are running right now, with the pid, window handle and build:
60
+
61
+ ```text
62
+ running instances:
63
+ [0] Retail pid=62460 hwnd=0x12410c7a "魔兽世界"
64
+
65
+ commands target this instance automatically
66
+ ```
67
+
68
+ The `[index]` is what you pass to `--instance` and to `use`.
69
+
70
+ ### `lycheedev use [index]`
71
+
72
+ Pin one running client as the default target, so later commands need no flag:
73
+
74
+ ```text
75
+ lycheedev use # the only running client
76
+ lycheedev use 1 # the instance at index 1
77
+ lycheedev use --clear
78
+ ```
79
+
80
+ Only the build and the instance ordinal are stored, because pids and window
81
+ handles change on every launch. The pin therefore survives a restart: it
82
+ re-resolves against whatever is running now. If the pinned build is not
83
+ running, commands fail with a clear message instead of typing into the wrong
84
+ game.
85
+
86
+ ## Choosing a target: precedence
87
+
88
+ 1. `--hwnd` / `--pid` — explicit, for scripted use
89
+ 2. `--instance <index>` — one command only, overrides the pin
90
+ 3. the saved pin from `use`
91
+ 4. `--client retail|classic|titan` — filter by build
92
+ 5. the single running instance, when there is exactly one
93
+
94
+ Several instances of **different** builds are separated by `--client`. Several
95
+ instances of the **same** build are genuinely ambiguous: the CLI prints the
96
+ table and fails instead of guessing, because a wrong guess types a slash command
97
+ into the wrong game.
98
+
99
+ ## Multiple installations
100
+
101
+ A machine can hold more than one WoW root. `--wow-root <path>` selects which one
102
+ to install into and is remembered in `~/.lycheedev/config.json`. `doctor`
103
+ reports the root it is using. Run `lycheedev clients --wow-root <other>` to
104
+ inspect a second root without changing the saved one.
105
+
106
+ ## What cannot be done from outside the game
107
+
108
+ - The **character** on a running client is not readable without a
109
+ build-specific memory reader. Nothing here guesses it. Two instances of the
110
+ same build can only be told apart by pid, window handle or index.
111
+ - The **account** behind a running client is likewise not exposed. SavedVariables
112
+ files are per account, and the newest file is not necessarily the live
113
+ session's account when several accounts are configured.
114
+ - WoW ignores posted window messages, so keyboard delivery needs the window in
115
+ the foreground. That is why targeting the right window matters.
116
+
117
+ If the user must be certain which client is which, ask them to run a trivial
118
+ in-game command (`/dev auto status <task>`) in the window they mean, or to close
119
+ the others.