lycheedev 1.1.1 → 2.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.
Files changed (115) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +45 -0
  3. package/THIRD_PARTY_NOTICES +812 -0
  4. package/bin/lycheedev.mjs +56 -0
  5. package/native/windows-amd64/lycheedev.exe +0 -0
  6. package/package.json +12 -33
  7. package/payload/addon/Bridge/CaptureWriter.lua +154 -0
  8. package/payload/addon/Bridge/Definitions.lua +3 -0
  9. package/payload/addon/Bridge/Identity.lua +127 -0
  10. package/{vendor/addon/Libs/AutomationQR.lua → payload/addon/Bridge/MatrixSymbol.lua} +23 -30
  11. package/payload/addon/Bridge/ProbeQueue.lua +136 -0
  12. package/payload/addon/Bridge/ProbeRunner.lua +128 -0
  13. package/payload/addon/Bridge/ReceiptView.lua +160 -0
  14. package/payload/addon/Bridge/Reentry.lua +192 -0
  15. package/payload/addon/Bridge/ReportStore.lua +153 -0
  16. package/payload/addon/Bridge/Session.lua +163 -0
  17. package/payload/addon/Clients/Evergreen.lua +2 -0
  18. package/payload/addon/Clients/Live.lua +2 -0
  19. package/payload/addon/Clients/Pandaria.lua +2 -0
  20. package/payload/addon/Clients/Titan.lua +2 -0
  21. package/payload/addon/Core/Compat.lua +59 -0
  22. package/payload/addon/Core/Controls.lua +168 -0
  23. package/{vendor/addon/Core/Bootstrap.lua → payload/addon/Core/Execute.lua} +12 -23
  24. package/{vendor → payload}/addon/Core/Inspector.lua +19 -235
  25. package/{vendor → payload}/addon/Core/Locale.lua +129 -94
  26. package/{vendor → payload}/addon/Core/Locale_enUS.lua +129 -96
  27. package/payload/addon/Core/Persistence.lua +58 -0
  28. package/payload/addon/Core/Platform.lua +58 -0
  29. package/payload/addon/Core/Runtime.lua +25 -0
  30. package/payload/addon/Core/Safety.lua +56 -0
  31. package/{vendor → payload}/addon/Core/Serializer.lua +18 -6
  32. package/payload/addon/Core/Stores.lua +611 -0
  33. package/payload/addon/Lychee Dev_Forever.toc +52 -0
  34. package/payload/addon/Lychee Dev_Mainline.toc +52 -0
  35. package/payload/addon/Lychee Dev_Mists.toc +52 -0
  36. package/payload/addon/Lychee Dev_Wrath.toc +52 -0
  37. package/payload/addon/Modules/AutomationView.lua +393 -0
  38. package/{vendor → payload}/addon/Modules/Diagnostics.lua +92 -36
  39. package/{vendor → payload}/addon/Modules/Events/Catalog.lua +9 -0
  40. package/{vendor → payload}/addon/Modules/Events/Monitor.lua +45 -5
  41. package/payload/addon/Modules/FunctionTrace.lua +150 -0
  42. package/{vendor → payload}/addon/Modules/ObjectInspector.lua +105 -31
  43. package/{vendor → payload}/addon/UI/Export.lua +64 -34
  44. package/{vendor → payload}/addon/UI/Pages/About.lua +26 -14
  45. package/payload/addon/UI/Pages/Automation.lua +446 -0
  46. package/payload/addon/UI/Pages/Diagnostics.lua +402 -0
  47. package/{vendor/addon/UI/Features.lua → payload/addon/UI/Pages/Events.lua} +192 -302
  48. package/{vendor → payload}/addon/UI/Pages/ExportRecords.lua +213 -132
  49. package/{vendor → payload}/addon/UI/Pages/Object.lua +229 -121
  50. package/payload/addon/UI/Pages/Run.lua +423 -0
  51. package/payload/addon/UI/Pages/Trace.lua +314 -0
  52. package/payload/addon/UI/TreeView.lua +246 -0
  53. package/{vendor/addon/UI/MainWindow.lua → payload/addon/UI/Widgets.lua} +89 -529
  54. package/payload/addon/UI/Window.lua +425 -0
  55. package/payload/skill/SKILL.md +87 -0
  56. package/payload/skill/agents/openai.yaml +7 -0
  57. package/payload/skill/references/addon-validation.md +42 -0
  58. package/payload/skill/references/asset-export.md +109 -0
  59. package/payload/skill/references/commands.md +169 -0
  60. package/payload/skill/references/data-investigation.md +242 -0
  61. package/payload/skill/references/error-diagnosis.md +41 -0
  62. package/payload/skill/references/installation.md +18 -0
  63. package/payload/skill/references/live-investigation.md +129 -0
  64. package/payload/skill/references/source-research.md +82 -0
  65. package/payload/skill/scripts/lycheedev.mjs +59 -0
  66. package/release.json +346 -0
  67. package/bin/lycheedev.js +0 -742
  68. package/src/addon.js +0 -95
  69. package/src/config.js +0 -68
  70. package/src/doctor.js +0 -126
  71. package/src/install.js +0 -145
  72. package/src/paths.js +0 -93
  73. package/src/py/instances.py +0 -165
  74. package/src/python.js +0 -111
  75. package/src/skill.js +0 -48
  76. package/src/wow.js +0 -541
  77. package/vendor/addon/Core/Clients/Forever.lua +0 -9
  78. package/vendor/addon/Core/Clients/Mainline.lua +0 -9
  79. package/vendor/addon/Core/Clients/Mists.lua +0 -9
  80. package/vendor/addon/Core/Clients/Titan.lua +0 -9
  81. package/vendor/addon/Core/Compatibility.lua +0 -43
  82. package/vendor/addon/Core/Database.lua +0 -859
  83. package/vendor/addon/Core/Safety.lua +0 -42
  84. package/vendor/addon/Lychee Dev_Forever.toc +0 -43
  85. package/vendor/addon/Lychee Dev_Mainline.toc +0 -43
  86. package/vendor/addon/Lychee Dev_Mists.toc +0 -43
  87. package/vendor/addon/Lychee Dev_Wrath.toc +0 -43
  88. package/vendor/addon/Modules/Automation/Controller.lua +0 -884
  89. package/vendor/addon/Modules/Automation/Report.lua +0 -409
  90. package/vendor/addon/Modules/Automation/auto/auto.lua +0 -12
  91. package/vendor/addon/Modules/FunctionTrace.lua +0 -85
  92. package/vendor/addon/UI/AutomationOverlay.lua +0 -253
  93. package/vendor/addon/UI/Pages/Automation.lua +0 -417
  94. package/vendor/addon/UI/Pages/Diagnostics.lua +0 -289
  95. package/vendor/addon/UI/Pages/Trace.lua +0 -165
  96. package/vendor/skill/SKILL.md +0 -42
  97. package/vendor/skill/agents/openai.yaml +0 -4
  98. package/vendor/skill/references/automation.md +0 -128
  99. package/vendor/skill/references/clients.md +0 -51
  100. package/vendor/skill/references/runtime-investigations.md +0 -104
  101. package/vendor/skill/scripts/automation/__init__.py +0 -1
  102. package/vendor/skill/scripts/automation/registry.py +0 -516
  103. package/vendor/skill/scripts/automation/saved_variables.py +0 -438
  104. package/vendor/skill/scripts/automation/session.py +0 -207
  105. package/vendor/skill/scripts/automation/windows.py +0 -792
  106. package/vendor/skill/scripts/automation.py +0 -1034
  107. package/vendor/skill/scripts/requirements.txt +0 -13
  108. package/vendor/skill/scripts/selftest_offline.py +0 -1061
  109. package/vendor/skill/scripts/test_input_safety.py +0 -132
  110. /package/{vendor → payload}/addon/Media/GitHub.png +0 -0
  111. /package/{vendor → payload}/addon/Media/Logo.png +0 -0
  112. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Forever.lua +0 -0
  113. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mainline.lua +0 -0
  114. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mists.lua +0 -0
  115. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Titan.lua +0 -0
package/src/addon.js DELETED
@@ -1,95 +0,0 @@
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 for one build's catalog. */
29
- export function installedVersion(addonsDir, toc = null) {
30
- const target = addonTargetDir(addonsDir);
31
- const catalogs = toc
32
- ? [toc]
33
- : [`${addonFolderName}_Mainline.toc`, `${addonFolderName}_Mists.toc`,
34
- `${addonFolderName}_Wrath.toc`, `${addonFolderName}_Forever.toc`];
35
- for (const name of catalogs) {
36
- const file = path.join(target, name);
37
- if (!exists(file)) continue;
38
- const match = fs.readFileSync(file, 'utf8').match(/^##\s*Version:\s*(.+)$/m);
39
- if (match) return match[1].trim();
40
- }
41
- return null;
42
- }
43
-
44
- export function countFiles(dir) {
45
- if (!exists(dir)) return 0;
46
- let total = 0;
47
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
48
- if (entry.isDirectory()) total += countFiles(path.join(dir, entry.name));
49
- else total += 1;
50
- }
51
- return total;
52
- }
53
-
54
- /**
55
- * Copy the vendored addon over the installed copy.
56
- *
57
- * The destination is replaced rather than merged so a file removed upstream
58
- * cannot linger. `auto.lua` is local task data, so it is preserved when the
59
- * caller asks for it: the empty shipped registry must not wipe pending work.
60
- */
61
- export function installAddon(addonsDir, { preserveRegistry = true, toc = null } = {}) {
62
- const source = vendoredAddonRoot();
63
- if (!exists(source)) {
64
- return { ok: false, error: 'vendored addon payload is missing; reinstall the package' };
65
- }
66
- // Refuse to write a build the addon has no catalog for: the game would load
67
- // nothing and report only a silent "out of date" addon.
68
- if (toc && !exists(path.join(source, toc))) {
69
- return { ok: false, error: `the payload has no ${toc}` };
70
- }
71
- const target = addonTargetDir(addonsDir);
72
-
73
- let savedRegistry = null;
74
- const registry = path.join(target, 'Modules', 'Automation', 'auto', 'auto.lua');
75
- if (preserveRegistry && exists(registry)) {
76
- const text = fs.readFileSync(registry, 'utf8');
77
- if (/^-- BEGIN LYCHEE DEV TASK /m.test(text)) savedRegistry = text;
78
- }
79
-
80
- removeTree(target);
81
- fs.mkdirSync(addonsDir, { recursive: true });
82
- copyTree(source, target);
83
-
84
- if (savedRegistry) {
85
- fs.writeFileSync(registry, savedRegistry, 'utf8');
86
- }
87
-
88
- return {
89
- ok: true,
90
- target,
91
- files: countFiles(target),
92
- version: payloadVersion(),
93
- keptRegistry: Boolean(savedRegistry),
94
- };
95
- }
package/src/config.js DELETED
@@ -1,68 +0,0 @@
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
- // 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,
15
- };
16
-
17
- export function loadConfig() {
18
- const stored = readJson(configPath(), null);
19
- if (!stored || typeof stored !== 'object') {
20
- return { ...EMPTY, clients: {} };
21
- }
22
- return {
23
- ...EMPTY,
24
- ...stored,
25
- clients: stored.clients && typeof stored.clients === 'object' ? stored.clients : {},
26
- };
27
- }
28
-
29
- export function saveConfig(config) {
30
- writeJson(configPath(), config);
31
- return config;
32
- }
33
-
34
- export function updateConfig(patch) {
35
- const config = loadConfig();
36
- const next = { ...config, ...patch };
37
- if (patch.clients) {
38
- next.clients = { ...config.clients, ...patch.clients };
39
- }
40
- return saveConfig(next);
41
- }
42
-
43
- export function setClient(config, clientId, value) {
44
- config.clients = { ...config.clients, [clientId]: value };
45
- return config;
46
- }
47
-
48
- /**
49
- * Resolve which WoW client to act on. An explicit id wins; otherwise the only
50
- * installed client is used, and an ambiguous set is reported instead of guessed.
51
- */
52
- export function resolveClient(config, requested) {
53
- const ids = Object.keys(config.clients).sort();
54
- if (requested) {
55
- const client = config.clients[requested];
56
- if (!client) {
57
- return { error: `unknown client '${requested}'; known: ${ids.join(', ') || 'none'}` };
58
- }
59
- return { id: requested, client };
60
- }
61
- if (ids.length === 0) {
62
- return { error: 'no World of Warcraft client is configured yet; run `lycheedev install`' };
63
- }
64
- if (ids.length > 1) {
65
- return { error: `several clients are configured (${ids.join(', ')}); pass --client <id>` };
66
- }
67
- return { id: ids[0], client: config.clients[ids[0]] };
68
- }
package/src/doctor.js DELETED
@@ -1,126 +0,0 @@
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 { configPath, dataDir, exists, pythonDepsDir, skillTargetDir } from './paths.js';
9
- import { automationScript, findPython, pythonEnv } from './python.js';
10
- import { findInstances, 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
- const clients = scanClients(roots[0]);
70
- for (const client of clients) {
71
- const version = client.version ? `v${client.version}` : 'unknown version';
72
- if (!client.toc) {
73
- // Present but intentionally not served: say so instead of hiding it.
74
- results.push(line(OK, `build (${client.id})`, `${client.folder} ${version} - not served by the addon`));
75
- continue;
76
- }
77
- const target = client.installedDir;
78
- if (!client.installed) {
79
- results.push(line(WARN, `addon (${client.id})`, `not installed in ${client.addonsDir}`));
80
- continue;
81
- }
82
- const current = installedVersion(client.addonsDir);
83
- const shipped = payloadVersion();
84
- const detail = `${client.folder} ${version} (installed ${current || '?'}, package ${shipped || '?'})`;
85
- results.push(current && shipped && current !== shipped
86
- ? line(WARN, `addon (${client.id})`, `${detail} - run \`lycheedev update\``)
87
- : line(OK, `addon (${client.id})`, detail));
88
-
89
- const candidates = findSavedVariablesCandidates(roots[0], client.folder);
90
- results.push(candidates.length
91
- ? line(OK, `savedvariables (${client.id})`, `${candidates.length} account(s), newest: ${candidates[0].account}`)
92
- : line(WARN, `savedvariables (${client.id})`, 'none yet; log into the game once'));
93
- }
94
- }
95
-
96
- // Which clients are running decides what `send`/`run` can target. Reuse the
97
- // interpreter already resolved above rather than probing for one again.
98
- const instances = findInstances({ pythonBin: python ? python.bin : null });
99
- const supportedRunning = instances.filter((item) => item.supported);
100
- if (instances.length === 0) {
101
- results.push(line(OK, 'running clients', 'none'));
102
- } else {
103
- for (const [index, instance] of instances.entries()) {
104
- const label = instance.flavorLabel || instance.flavorFolder || 'unknown';
105
- const detail = `${label} pid=${instance.pid}`
106
- + `${instance.hwnd ? ` hwnd=0x${instance.hwnd.toString(16)}` : ''}`
107
- + `${instance.supported ? '' : ' (not served by the addon)'}`;
108
- results.push(line(instance.supported ? OK : WARN, `running [${index}]`, detail));
109
- }
110
- if (supportedRunning.length > 1) {
111
- results.push(line(WARN, 'instance choice',
112
- 'several clients are running; pass `--instance <index>` to target one'));
113
- }
114
- }
115
-
116
- console.log(`\nconfig: ${configPath()}`);
117
- console.log(`data : ${dataDir()}`);
118
- if (python) {
119
- console.log(`python env PYTHONPATH=${pythonEnv().PYTHONPATH}`);
120
- }
121
-
122
- const failures = results.filter((entry) => entry === BAD).length;
123
- const warnings = results.filter((entry) => entry === WARN).length;
124
- console.log(`\n${failures} failure(s), ${warnings} warning(s)`);
125
- return failures > 0 ? 1 : 0;
126
- }
package/src/install.js DELETED
@@ -1,145 +0,0 @@
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 { exists } from './paths.js';
8
- import { depsInstalled, findPython, installDeps } from './python.js';
9
- import { installSkill } from './skill.js';
10
- import { detectWowRoots, findSavedVariablesCandidates, knownFolders, 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
- // 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',
38
- };
39
- }
40
- return { root: resolved, clients };
41
- }
42
- if (config.wowRoot && exists(config.wowRoot)) {
43
- const clients = scanClients(config.wowRoot);
44
- if (clients.length > 0) return { root: config.wowRoot, clients, fromConfig: true };
45
- }
46
- const detected = detectWowRoots();
47
- if (detected.length === 1) {
48
- return { root: detected[0], clients: scanClients(detected[0]), detected: true };
49
- }
50
- if (detected.length > 1) {
51
- return {
52
- error: `found several World of Warcraft folders:\n ${detected.join('\n ')}\n`
53
- + 'pass --wow-root to choose one',
54
- };
55
- }
56
- return { error: 'no World of Warcraft folder found; pass --wow-root <path>' };
57
- }
58
-
59
- export function runInstall({ flags }) {
60
- const config = loadConfig();
61
- const resolved = resolveWowRoot({ wowRoot: flags['wow-root'], config });
62
- if (resolved.error) {
63
- console.error(`error: ${resolved.error}`);
64
- return 1;
65
- }
66
-
67
- console.log(`world of warcraft: ${resolved.root}`
68
- + `${resolved.detected ? ' (auto-detected)' : ''}${resolved.fromConfig ? ' (from config)' : ''}`);
69
-
70
- const result = step('installing python dependencies', () => {
71
- const python = findPython(flags.python);
72
- if (!python) return { ok: false, error: 'no Python 3 interpreter found on PATH' };
73
- console.log(` python: ${python.bin} (${python.version})`);
74
- if (depsInstalled() && !flags.force) {
75
- console.log(' already installed (use --force to refresh)');
76
- return { ok: true, skipped: true };
77
- }
78
- return installDeps({ pythonBin: python.bin, quiet: true, onLine: (line) => console.log(` ${line}`) });
79
- });
80
-
81
- const skillResult = step('installing skill', () => installSkill());
82
-
83
- const nextConfig = { ...config, wowRoot: resolved.root, pythonBin: flags.python || config.pythonBin };
84
- const addonResults = [];
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;
91
-
92
- for (const client of resolved.clients) {
93
- // A build without a catalog is reported, not silently dropped: the folder
94
- // still exists and the user should know why nothing was installed there.
95
- if (!client.toc) {
96
- console.log(`\n${client.label} (${client.folder}): not served by the addon, skipped`);
97
- continue;
98
- }
99
- step(`${client.label}: installing addon into ${client.folder}`, () => {
100
- if (!exists(client.addonsDir)) {
101
- console.log(` skipped: ${client.addonsDir} does not exist yet`);
102
- return { ok: false, skipped: true };
103
- }
104
- const before = installedVersion(client.addonsDir);
105
- const installed = installAddon(client.addonsDir, {
106
- preserveRegistry: !flags['reset-registry'],
107
- toc: client.toc,
108
- });
109
- if (!installed.ok) {
110
- console.log(` error: ${installed.error}`);
111
- return installed;
112
- }
113
- console.log(` ${client.toc} -> ${installed.target}`);
114
- console.log(` files: ${installed.files}, version: ${before ? `${before} -> ` : ''}${installed.version}`);
115
- if (installed.keptRegistry) console.log(' kept the existing task registry (local task data)');
116
- addonResults.push({ client: client.id, ...installed });
117
- if (!defaultClient) defaultClient = client.id;
118
- return installed;
119
- });
120
- const candidates = findSavedVariablesCandidates(resolved.root, client.folder);
121
- setClient(nextConfig, client.id, {
122
- flavorFolder: client.folder,
123
- toc: client.toc,
124
- addonsDir: client.addonsDir,
125
- svPath: candidates[0] ? candidates[0].path : null,
126
- installedAt: new Date().toISOString(),
127
- });
128
- }
129
-
130
- updateConfig({ ...nextConfig, defaultClient });
131
-
132
- console.log('\nresult');
133
- console.log(` python deps : ${result.ok ? (result.skipped ? 'present' : 'installed') : `failed (${result.error})`}`);
134
- console.log(` skill : ${skillResult.ok ? `${skillResult.files} files -> ${skillResult.target}` : `failed (${skillResult.error})`}`);
135
- console.log(` addon : ${addonResults.length} client(s) updated`);
136
- console.log(` payload : version ${payloadVersion()}`);
137
-
138
- const failed = !result.ok || !skillResult.ok || addonResults.length === 0;
139
- if (failed) {
140
- console.log('\nnot fully installed; run `lycheedev doctor` for details');
141
- return 1;
142
- }
143
- console.log('\nrestart World of Warcraft (or /reload) to load the addon, then run `lycheedev doctor`');
144
- return 0;
145
- }
package/src/paths.js DELETED
@@ -1,93 +0,0 @@
1
- /** Shared paths and small filesystem helpers. */
2
-
3
- import fs from 'node:fs';
4
- import os from 'node:os';
5
- import path from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
-
8
- const here = path.dirname(fileURLToPath(import.meta.url));
9
-
10
- /** Package root (the directory that holds package.json). */
11
- export const packageRoot = path.resolve(here, '..');
12
-
13
- /** Vendored payload shipped inside the npm package. */
14
- export const vendorRoot = path.join(packageRoot, 'vendor');
15
-
16
- /** The addon folder name WoW expects. The TOC files reference it, so it keeps
17
- * its display capitalization even though the npm package name is lowercase. */
18
- export const addonFolderName = 'Lychee Dev';
19
-
20
- export function homeDir() {
21
- return process.env.LYCHEEDEV_HOME || os.homedir();
22
- }
23
-
24
- export function dataDir() {
25
- return path.join(homeDir(), '.lycheedev');
26
- }
27
-
28
- export function configPath() {
29
- return path.join(dataDir(), 'config.json');
30
- }
31
-
32
- /** pip --target directory that holds the automation helper dependencies. */
33
- export function pythonDepsDir() {
34
- return path.join(dataDir(), 'python');
35
- }
36
-
37
- export function skillsDir() {
38
- return path.join(homeDir(), '.agents', 'skills');
39
- }
40
-
41
- export function skillTargetDir() {
42
- return path.join(skillsDir(), 'lycheedev');
43
- }
44
-
45
- export function exists(target) {
46
- try {
47
- fs.statSync(target);
48
- return true;
49
- } catch {
50
- return false;
51
- }
52
- }
53
-
54
- export function isDir(target) {
55
- try {
56
- return fs.statSync(target).isDirectory();
57
- } catch {
58
- return false;
59
- }
60
- }
61
-
62
- export function readJson(target, fallback = null) {
63
- try {
64
- return JSON.parse(fs.readFileSync(target, 'utf8'));
65
- } catch {
66
- return fallback;
67
- }
68
- }
69
-
70
- export function writeJson(target, value) {
71
- fs.mkdirSync(path.dirname(target), { recursive: true });
72
- fs.writeFileSync(target, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
73
- }
74
-
75
- /** Copy a directory tree, skipping build noise. */
76
- export function copyTree(from, to, { filter = null } = {}) {
77
- fs.mkdirSync(to, { recursive: true });
78
- for (const entry of fs.readdirSync(from, { withFileTypes: true })) {
79
- const source = path.join(from, entry.name);
80
- if (filter && !filter(source, entry)) continue;
81
- const target = path.join(to, entry.name);
82
- if (entry.isDirectory()) {
83
- copyTree(source, target, { filter });
84
- } else if (entry.isFile()) {
85
- fs.copyFileSync(source, target);
86
- }
87
- }
88
- }
89
-
90
- /** Drop a directory tree if it is there. */
91
- export function removeTree(target) {
92
- fs.rmSync(target, { recursive: true, force: true });
93
- }
@@ -1,165 +0,0 @@
1
- """List running World of Warcraft instances as JSON.
2
-
3
- The executable name cannot identify a build: Blizzard ships every non-retail
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.
13
- """
14
-
15
- from __future__ import annotations
16
-
17
- import ctypes
18
- import json
19
- import os
20
- import re
21
- import sys
22
- from ctypes import wintypes
23
-
24
- user32 = ctypes.windll.user32
25
- kernel32 = ctypes.windll.kernel32
26
-
27
- PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
28
- ERROR_INSUFFICIENT_BUFFER = 122
29
-
30
- _FLAVOR_PRODUCT = re.compile(rb"\b(wow[a-z0-9_]*)\b", re.IGNORECASE)
31
-
32
- user32.EnumWindows.restype = wintypes.BOOL
33
- user32.EnumWindows.argtypes = [ctypes.c_void_p, wintypes.LPARAM]
34
- user32.IsWindowVisible.restype = wintypes.BOOL
35
- user32.GetWindowTextLengthW.restype = ctypes.c_int
36
- user32.GetWindowTextW.restype = ctypes.c_int
37
- user32.GetWindowThreadProcessId.restype = wintypes.DWORD
38
- user32.GetWindowThreadProcessId.argtypes = [wintypes.HWND, ctypes.POINTER(wintypes.DWORD)]
39
-
40
- kernel32.OpenProcess.restype = wintypes.HANDLE
41
- kernel32.OpenProcess.argtypes = [wintypes.DWORD, wintypes.BOOL, wintypes.DWORD]
42
- kernel32.QueryFullProcessImageNameW.restype = wintypes.BOOL
43
- kernel32.QueryFullProcessImageNameW.argtypes = [
44
- wintypes.HANDLE, wintypes.DWORD, wintypes.LPWSTR, ctypes.POINTER(wintypes.DWORD)]
45
- kernel32.CloseHandle.restype = wintypes.BOOL
46
- kernel32.CloseHandle.argtypes = [wintypes.HANDLE]
47
-
48
- EnumWindowsProc = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
49
-
50
- FLAVOR_LABELS = {
51
- "_retail_": ("retail", "Retail"),
52
- "_classic_": ("classic", "Classic"),
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"),
58
- "_classic_era_": ("classicEra", "Classic Era"),
59
- "_anniversary_": ("anniversary", "Anniversary"),
60
- "_beta_": ("beta", "Beta"),
61
- }
62
-
63
- SUPPORTED_EXE = {"wow.exe", "wowclassic.exe", "wowb.exe"}
64
-
65
-
66
- def process_image(pid: int) -> str | None:
67
- handle = kernel32.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, False, pid)
68
- if not handle:
69
- return None
70
- try:
71
- size = wintypes.DWORD(32768)
72
- buffer = ctypes.create_unicode_buffer(size.value)
73
- if not kernel32.QueryFullProcessImageNameW(handle, 0, buffer, ctypes.byref(size)):
74
- return None
75
- return buffer.value or None
76
- finally:
77
- kernel32.CloseHandle(handle)
78
-
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
-
105
- def visible_windows() -> dict[int, dict]:
106
- found: dict[int, dict] = {}
107
-
108
- def callback(hwnd, _lparam):
109
- if not user32.IsWindowVisible(hwnd):
110
- return True
111
- pid = wintypes.DWORD(0)
112
- user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
113
- length = user32.GetWindowTextLengthW(hwnd)
114
- if length <= 0:
115
- return True
116
- buffer = ctypes.create_unicode_buffer(length + 1)
117
- user32.GetWindowTextW(hwnd, buffer, length + 1)
118
- found.setdefault(pid.value, {"hwnd": int(hwnd), "title": buffer.value})
119
- return True
120
-
121
- user32.EnumWindows(EnumWindowsProc(callback), 0)
122
- return found
123
-
124
-
125
- def main() -> int:
126
- windows = visible_windows()
127
- instances = []
128
-
129
- for pid in windows:
130
- image = process_image(pid)
131
- if not image:
132
- continue
133
- base = os.path.basename(image).lower()
134
- if base not in SUPPORTED_EXE:
135
- continue
136
- parts = image.replace("/", os.sep).split(os.sep)
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.
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)
146
- instances.append({
147
- "pid": pid,
148
- "exe": os.path.basename(image),
149
- "exePath": image,
150
- "flavorFolder": folder,
151
- "flavorId": flavor_id,
152
- "flavorLabel": label,
153
- "product": product,
154
- "version": version,
155
- "hwnd": windows[pid]["hwnd"],
156
- "title": windows[pid]["title"],
157
- })
158
-
159
- instances.sort(key=lambda item: (item.get("flavorId") or "", item["pid"]))
160
- print(json.dumps(instances, ensure_ascii=False))
161
- return 0
162
-
163
-
164
- if __name__ == "__main__":
165
- sys.exit(main())