lycheedev 1.0.5 → 1.0.6

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
@@ -9,6 +9,7 @@ import { runInstall } from '../src/install.js';
9
9
  import { loadConfig, updateConfig } from '../src/config.js';
10
10
  import { runAutomation } from '../src/python.js';
11
11
  import {
12
+ describeAmbiguity,
12
13
  findInstances,
13
14
  findSavedVariablesCandidates,
14
15
  formatInstance,
@@ -220,7 +221,18 @@ function resolveRuntime(flags) {
220
221
 
221
222
  const resolved = resolveInstance(instances, { clientId: flags.client || null, index: null });
222
223
  if (resolved.error) {
223
- console.error(`error: ${resolved.error}`);
224
+ 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
+ if (shape.sameBuildCollision) {
228
+ for (const [flavorId, list] of shape.duplicates) {
229
+ const label = list[0].flavorLabel || flavorId;
230
+ console.error(`error: ${list.length} ${label} clients are running and cannot be told apart`);
231
+ console.error(` close all but one, or close these pids: ${list.map((i) => i.pid).join(', ')}`);
232
+ }
233
+ } else {
234
+ console.error(`error: ${resolved.error}`);
235
+ }
224
236
  if (resolved.candidates) {
225
237
  resolved.candidates.forEach((item, index) => console.log(formatInstance(item, index)));
226
238
  }
@@ -248,7 +260,8 @@ function toTarget(instance) {
248
260
  */
249
261
  function runUse(flags, rest) {
250
262
  const instances = findInstances({ pythonBin: flags.python || null });
251
- const supported = instances.filter((item) => item.supported);
263
+ const shape = describeAmbiguity(instances);
264
+ const supported = shape.supported;
252
265
 
253
266
  if (flags.clear) {
254
267
  updateConfig({ pinnedInstance: null });
@@ -263,7 +276,23 @@ function runUse(flags, rest) {
263
276
  return 1;
264
277
  }
265
278
 
266
- const requested = rest.length > 0 ? Number(rest[0]) : (flags.instance !== undefined ? Number(flags.instance) : null);
279
+ // Several windows of one build cannot be told apart from outside the game, so
280
+ // pinning one of them would only look precise. Ask for a single window instead.
281
+ if (shape.sameBuildCollision) {
282
+ for (const [flavorId, list] of shape.duplicates) {
283
+ const label = list[0].flavorLabel || flavorId;
284
+ console.error(`error: ${list.length} ${label} clients are running and cannot be told apart`);
285
+ console.error(` close all but one, or close these pids: ${list.map((i) => i.pid).join(', ')}`);
286
+ }
287
+ console.error(' nothing observable from outside the game identifies which character');
288
+ console.error(' is behind which window, so pinning one would risk typing into the wrong game');
289
+ supported.forEach((item, index) => console.log(formatInstance(item, index)));
290
+ return 1;
291
+ }
292
+
293
+ const requested = rest.length > 0
294
+ ? Number(rest[0])
295
+ : (flags.instance !== undefined ? Number(flags.instance) : null);
267
296
  let chosen;
268
297
  let ordinal;
269
298
  if (requested !== null) {
@@ -289,7 +318,7 @@ function runUse(flags, rest) {
289
318
 
290
319
  updateConfig({ pinnedInstance: { flavor: chosen.flavorId, ordinal } });
291
320
  const label = chosen.flavorLabel || chosen.flavorFolder;
292
- console.log(`pinned ${label}${ordinal > 0 ? ` instance ${ordinal}` : ''} (pid ${chosen.pid})`);
321
+ console.log(`pinned ${label} (pid ${chosen.pid})`);
293
322
  console.log('commands now target it; pass --instance <index> to override');
294
323
  return 0;
295
324
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lycheedev",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
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/wow.js CHANGED
@@ -256,3 +256,32 @@ export function formatInstance(instance, index) {
256
256
  return ` [${index}] ${flavor.padEnd(14)} pid=${String(instance.pid).padEnd(8)} `
257
257
  + `hwnd=${hwnd.padEnd(12)}${title}${suffix}`;
258
258
  }
259
+
260
+ /**
261
+ * Decide whether several running instances can be told apart.
262
+ *
263
+ * Different builds are safe: the install path identifies them, so `--client`
264
+ * picks one. Several instances of the *same* build are not, because nothing
265
+ * observable from outside the game says which character is behind which pid —
266
+ * only a build-specific memory reader could, and none ships here. Rather than
267
+ * let the user pin an ordinal that may point at the wrong window, the caller is
268
+ * told to close the extras.
269
+ */
270
+ export function describeAmbiguity(instances) {
271
+ const supported = instances.filter((item) => item.supported);
272
+ const byBuild = new Map();
273
+ for (const instance of supported) {
274
+ if (!byBuild.has(instance.flavorId)) byBuild.set(instance.flavorId, []);
275
+ byBuild.get(instance.flavorId).push(instance);
276
+ }
277
+ const duplicates = [...byBuild.entries()].filter(([, list]) => list.length > 1);
278
+ const distinct = byBuild.size;
279
+ return {
280
+ supported,
281
+ duplicates,
282
+ // Several builds open: picking one is unambiguous.
283
+ multipleBuilds: distinct > 1,
284
+ // Several windows of one build: nothing can tell them apart.
285
+ sameBuildCollision: duplicates.length > 0,
286
+ };
287
+ }
@@ -6,7 +6,7 @@
6
6
  ## Notes-zhCN: 运行 Lua,检查对象与事件,追踪函数并查看错误。
7
7
  ## Notes-zhTW: 執行 Lua,檢查物件與事件,追蹤函式並檢視錯誤。
8
8
  ## Author: Follen
9
- ## Version: 1.0.5
9
+ ## Version: 1.0.6
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.5
9
+ ## Version: 1.0.6
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.5
9
+ ## Version: 1.0.6
10
10
  ## Dependencies: !BugGrabber
11
11
  ## SavedVariables: LycheeDevDB, DumperDB
12
12
  ## IconTexture: Interface\AddOns\Lychee Dev\Media\Logo.png
@@ -38,7 +38,7 @@ lycheedev instances # what is running now, with pid and window handle
38
38
  lycheedev use [index] # pin one as the default target
39
39
  ```
40
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).
41
+ With several clients open, `--instance <index>` overrides the pin for one command and `--client` filters by build. Different builds can stay open together because the install path separates them. Two windows of the **same** build cannot be told apart from outside the game, so the CLI refuses and names the pids to close — ask the user to close all but one instead of picking for them. Full rules and the precedence order are in [references/clients.md](references/clients.md).
42
42
 
43
43
  ## Read SavedVariables
44
44
 
@@ -73,7 +73,7 @@ Pin one running client as the default target, so later commands need no flag:
73
73
 
74
74
  ```text
75
75
  lycheedev use # the only running client
76
- lycheedev use 1 # the instance at index 1
76
+ lycheedev use 1 # the instance at index 1, when the builds differ
77
77
  lycheedev use --clear
78
78
  ```
79
79
 
@@ -83,6 +83,10 @@ re-resolves against whatever is running now. If the pinned build is not
83
83
  running, commands fail with a clear message instead of typing into the wrong
84
84
  game.
85
85
 
86
+ Pinning is for choosing **between builds**. If two windows of the same build are
87
+ open, `use` refuses and asks for one window to be closed — see the ambiguity rule
88
+ below.
89
+
86
90
  ## Choosing a target: precedence
87
91
 
88
92
  1. `--hwnd` / `--pid` — explicit, for scripted use
@@ -91,10 +95,22 @@ game.
91
95
  4. `--client retail|classic|titan` — filter by build
92
96
  5. the single running instance, when there is exactly one
93
97
 
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
+ Several instances of **different** builds are safe to keep open: the install path
99
+ separates them, so `--client` picks one.
100
+
101
+ Several instances of the **same** build cannot be told apart. Nothing observable
102
+ from outside the game says which character is behind which window — only a
103
+ build-specific memory reader could, and none ships here. Pinning an ordinal would
104
+ only look precise while risking a slash command in the wrong game. The CLI
105
+ therefore refuses and tells the user to close the extras:
106
+
107
+ ```text
108
+ error: 2 Retail clients are running and cannot be told apart
109
+ close all but one, or close these pids: 62460, 71824
110
+ ```
111
+
112
+ **Ask the user to close all but one window of that build.** Do not invent a way
113
+ to pick between them, and do not offer to pin one.
98
114
 
99
115
  ## Multiple installations
100
116