@adhisang/minecraft-modding-mcp 3.2.0 → 4.1.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 (194) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +52 -32
  3. package/dist/build-suggested-call.d.ts +29 -0
  4. package/dist/build-suggested-call.js +58 -0
  5. package/dist/cache-registry.d.ts +3 -1
  6. package/dist/cache-registry.js +59 -7
  7. package/dist/config.d.ts +10 -1
  8. package/dist/config.js +52 -1
  9. package/dist/entry-tools/analyze-symbol-service.d.ts +18 -18
  10. package/dist/entry-tools/analyze-symbol-service.js +13 -2
  11. package/dist/entry-tools/batch-class-members-service.d.ts +34 -0
  12. package/dist/entry-tools/batch-class-members-service.js +97 -0
  13. package/dist/entry-tools/batch-class-source-service.d.ts +37 -0
  14. package/dist/entry-tools/batch-class-source-service.js +100 -0
  15. package/dist/entry-tools/batch-mappings-service.d.ts +36 -0
  16. package/dist/entry-tools/batch-mappings-service.js +66 -0
  17. package/dist/entry-tools/batch-runner.d.ts +72 -0
  18. package/dist/entry-tools/batch-runner.js +90 -0
  19. package/dist/entry-tools/batch-symbol-exists-service.d.ts +46 -0
  20. package/dist/entry-tools/batch-symbol-exists-service.js +113 -0
  21. package/dist/entry-tools/compare-minecraft-service.d.ts +6 -6
  22. package/dist/entry-tools/inspect-minecraft/handlers/artifact.d.ts +5 -0
  23. package/dist/entry-tools/inspect-minecraft/handlers/artifact.js +83 -0
  24. package/dist/entry-tools/inspect-minecraft/handlers/class-members.d.ts +6 -0
  25. package/dist/entry-tools/inspect-minecraft/handlers/class-members.js +80 -0
  26. package/dist/entry-tools/inspect-minecraft/handlers/class-overview.d.ts +5 -0
  27. package/dist/entry-tools/inspect-minecraft/handlers/class-overview.js +248 -0
  28. package/dist/entry-tools/inspect-minecraft/handlers/class-source.d.ts +5 -0
  29. package/dist/entry-tools/inspect-minecraft/handlers/class-source.js +60 -0
  30. package/dist/entry-tools/inspect-minecraft/handlers/file.d.ts +5 -0
  31. package/dist/entry-tools/inspect-minecraft/handlers/file.js +54 -0
  32. package/dist/entry-tools/inspect-minecraft/handlers/list-files.d.ts +5 -0
  33. package/dist/entry-tools/inspect-minecraft/handlers/list-files.js +100 -0
  34. package/dist/entry-tools/inspect-minecraft/handlers/search.d.ts +5 -0
  35. package/dist/entry-tools/inspect-minecraft/handlers/search.js +155 -0
  36. package/dist/entry-tools/inspect-minecraft/handlers/versions.d.ts +6 -0
  37. package/dist/entry-tools/inspect-minecraft/handlers/versions.js +49 -0
  38. package/dist/entry-tools/inspect-minecraft/internal.d.ts +1042 -0
  39. package/dist/entry-tools/inspect-minecraft/internal.js +448 -0
  40. package/dist/entry-tools/inspect-minecraft-service.d.ts +213 -328
  41. package/dist/entry-tools/inspect-minecraft-service.js +20 -1238
  42. package/dist/entry-tools/manage-cache-service.d.ts +16 -16
  43. package/dist/entry-tools/validate-project/cases/access-transformer.d.ts +6 -0
  44. package/dist/entry-tools/validate-project/cases/access-transformer.js +106 -0
  45. package/dist/entry-tools/validate-project/cases/access-widener.d.ts +6 -0
  46. package/dist/entry-tools/validate-project/cases/access-widener.js +86 -0
  47. package/dist/entry-tools/validate-project/cases/mixin.d.ts +6 -0
  48. package/dist/entry-tools/validate-project/cases/mixin.js +90 -0
  49. package/dist/entry-tools/validate-project/cases/project-summary.d.ts +97 -0
  50. package/dist/entry-tools/validate-project/cases/project-summary.js +346 -0
  51. package/dist/entry-tools/validate-project/internal.d.ts +135 -0
  52. package/dist/entry-tools/validate-project/internal.js +287 -0
  53. package/dist/entry-tools/validate-project-service.d.ts +63 -47
  54. package/dist/entry-tools/validate-project-service.js +12 -482
  55. package/dist/entry-tools/verify-mixin-target-service.d.ts +133 -0
  56. package/dist/entry-tools/verify-mixin-target-service.js +323 -0
  57. package/dist/error-mapping.d.ts +40 -0
  58. package/dist/error-mapping.js +139 -0
  59. package/dist/errors.d.ts +6 -0
  60. package/dist/errors.js +6 -0
  61. package/dist/index.d.ts +2 -0
  62. package/dist/index.js +170 -1314
  63. package/dist/lru-list.d.ts +31 -0
  64. package/dist/lru-list.js +102 -0
  65. package/dist/mapping/internal-types.d.ts +54 -0
  66. package/dist/mapping/internal-types.js +14 -0
  67. package/dist/mapping/loaders/mojang.d.ts +2 -0
  68. package/dist/mapping/loaders/mojang.js +64 -0
  69. package/dist/mapping/loaders/tiny-loom.d.ts +2 -0
  70. package/dist/mapping/loaders/tiny-loom.js +73 -0
  71. package/dist/mapping/loaders/tiny-maven.d.ts +2 -0
  72. package/dist/mapping/loaders/tiny-maven.js +104 -0
  73. package/dist/mapping/loaders/types.d.ts +14 -0
  74. package/dist/mapping/loaders/types.js +2 -0
  75. package/dist/mapping/lookup.d.ts +52 -0
  76. package/dist/mapping/lookup.js +496 -0
  77. package/dist/mapping/parsers/normalize.d.ts +10 -0
  78. package/dist/mapping/parsers/normalize.js +52 -0
  79. package/dist/mapping/parsers/proguard.d.ts +20 -0
  80. package/dist/mapping/parsers/proguard.js +138 -0
  81. package/dist/mapping/parsers/symbol-records.d.ts +27 -0
  82. package/dist/mapping/parsers/symbol-records.js +216 -0
  83. package/dist/mapping/parsers/tiny.d.ts +9 -0
  84. package/dist/mapping/parsers/tiny.js +96 -0
  85. package/dist/mapping/types.d.ts +147 -0
  86. package/dist/mapping/types.js +2 -0
  87. package/dist/mapping-pipeline-service.d.ts +10 -1
  88. package/dist/mapping-pipeline-service.js +16 -3
  89. package/dist/mapping-service.d.ts +15 -144
  90. package/dist/mapping-service.js +179 -1119
  91. package/dist/mixin/access-validators.d.ts +9 -0
  92. package/dist/mixin/access-validators.js +257 -0
  93. package/dist/mixin/annotation-validators.d.ts +5 -0
  94. package/dist/mixin/annotation-validators.js +162 -0
  95. package/dist/mixin/helpers.d.ts +28 -0
  96. package/dist/mixin/helpers.js +315 -0
  97. package/dist/mixin/parsed-validator.d.ts +8 -0
  98. package/dist/mixin/parsed-validator.js +337 -0
  99. package/dist/mixin/types.d.ts +208 -0
  100. package/dist/mixin/types.js +28 -0
  101. package/dist/mixin-validator.d.ts +9 -201
  102. package/dist/mixin-validator.js +8 -1005
  103. package/dist/observability.d.ts +18 -1
  104. package/dist/observability.js +44 -1
  105. package/dist/response-utils.d.ts +44 -10
  106. package/dist/response-utils.js +131 -17
  107. package/dist/source/access-validate.d.ts +4 -0
  108. package/dist/source/access-validate.js +254 -0
  109. package/dist/source/artifact-resolver.d.ts +110 -0
  110. package/dist/source/artifact-resolver.js +1174 -0
  111. package/dist/source/cache-metrics.d.ts +26 -0
  112. package/dist/source/cache-metrics.js +172 -0
  113. package/dist/source/class-source/members-builder.d.ts +34 -0
  114. package/dist/source/class-source/members-builder.js +46 -0
  115. package/dist/source/class-source/snippet-builder.d.ts +19 -0
  116. package/dist/source/class-source/snippet-builder.js +46 -0
  117. package/dist/source/class-source-helpers.d.ts +34 -0
  118. package/dist/source/class-source-helpers.js +140 -0
  119. package/dist/source/class-source.d.ts +42 -0
  120. package/dist/source/class-source.js +883 -0
  121. package/dist/source/descriptor-utils.d.ts +6 -0
  122. package/dist/source/descriptor-utils.js +37 -0
  123. package/dist/source/file-access.d.ts +4 -0
  124. package/dist/source/file-access.js +102 -0
  125. package/dist/source/indexer.d.ts +82 -0
  126. package/dist/source/indexer.js +505 -0
  127. package/dist/source/lifecycle/diff-utils.d.ts +9 -0
  128. package/dist/source/lifecycle/diff-utils.js +107 -0
  129. package/dist/source/lifecycle/diff.d.ts +2 -0
  130. package/dist/source/lifecycle/diff.js +265 -0
  131. package/dist/source/lifecycle/mapping-helpers.d.ts +22 -0
  132. package/dist/source/lifecycle/mapping-helpers.js +327 -0
  133. package/dist/source/lifecycle/runtime-check.d.ts +2 -0
  134. package/dist/source/lifecycle/runtime-check.js +142 -0
  135. package/dist/source/lifecycle/trace.d.ts +2 -0
  136. package/dist/source/lifecycle/trace.js +231 -0
  137. package/dist/source/lifecycle.d.ts +4 -0
  138. package/dist/source/lifecycle.js +5 -0
  139. package/dist/source/search.d.ts +51 -0
  140. package/dist/source/search.js +676 -0
  141. package/dist/source/shared-utils.d.ts +6 -0
  142. package/dist/source/shared-utils.js +55 -0
  143. package/dist/source/state.d.ts +21 -0
  144. package/dist/source/state.js +19 -0
  145. package/dist/source/symbol-resolver.d.ts +3 -0
  146. package/dist/source/symbol-resolver.js +212 -0
  147. package/dist/source/validate-mixin/pipeline/mapping-health.d.ts +3 -0
  148. package/dist/source/validate-mixin/pipeline/mapping-health.js +41 -0
  149. package/dist/source/validate-mixin/pipeline/parse.d.ts +2 -0
  150. package/dist/source/validate-mixin/pipeline/parse.js +10 -0
  151. package/dist/source/validate-mixin/pipeline/resolve.d.ts +3 -0
  152. package/dist/source/validate-mixin/pipeline/resolve.js +78 -0
  153. package/dist/source/validate-mixin/pipeline/target-lookup.d.ts +6 -0
  154. package/dist/source/validate-mixin/pipeline/target-lookup.js +260 -0
  155. package/dist/source/validate-mixin/pipeline-context.d.ts +72 -0
  156. package/dist/source/validate-mixin/pipeline-context.js +93 -0
  157. package/dist/source/validate-mixin.d.ts +22 -0
  158. package/dist/source/validate-mixin.js +799 -0
  159. package/dist/source/workspace-target.d.ts +18 -0
  160. package/dist/source/workspace-target.js +305 -0
  161. package/dist/source-resolver.d.ts +9 -1
  162. package/dist/source-resolver.js +14 -6
  163. package/dist/source-service.d.ts +178 -105
  164. package/dist/source-service.js +72 -5312
  165. package/dist/stage-emitter.d.ts +13 -0
  166. package/dist/stage-emitter.js +30 -0
  167. package/dist/stdio-supervisor.d.ts +61 -0
  168. package/dist/stdio-supervisor.js +326 -9
  169. package/dist/storage/artifacts-repo.d.ts +4 -1
  170. package/dist/storage/artifacts-repo.js +33 -5
  171. package/dist/storage/files-repo.d.ts +0 -2
  172. package/dist/storage/files-repo.js +0 -11
  173. package/dist/storage/migrations.d.ts +1 -1
  174. package/dist/storage/migrations.js +10 -2
  175. package/dist/storage/schema.d.ts +2 -0
  176. package/dist/storage/schema.js +25 -0
  177. package/dist/tool-contract-manifest.d.ts +1 -1
  178. package/dist/tool-contract-manifest.js +23 -6
  179. package/dist/tool-guidance.d.ts +82 -0
  180. package/dist/tool-guidance.js +734 -0
  181. package/dist/tool-schema-registry.d.ts +16 -0
  182. package/dist/tool-schema-registry.js +37 -0
  183. package/dist/tool-schemas.d.ts +3518 -0
  184. package/dist/tool-schemas.js +813 -0
  185. package/dist/types.d.ts +39 -0
  186. package/dist/version-service.js +7 -6
  187. package/dist/workspace-context-cache.d.ts +32 -0
  188. package/dist/workspace-context-cache.js +66 -0
  189. package/dist/workspace-mapping-service.d.ts +16 -0
  190. package/dist/workspace-mapping-service.js +173 -1
  191. package/docs/README-ja.md +414 -0
  192. package/docs/examples.md +483 -0
  193. package/docs/tool-reference.md +459 -0
  194. package/package.json +5 -2
@@ -0,0 +1,31 @@
1
+ /**
2
+ * O(1) doubly-linked list + Map LRU.
3
+ * head = oldest, tail = newest.
4
+ */
5
+ export declare class LruList<T> {
6
+ private map;
7
+ private head;
8
+ private tail;
9
+ get size(): number;
10
+ /** O(1) — move to tail (most recent), return value reference. */
11
+ touch(key: string): T | undefined;
12
+ /** O(1) — insert or update + move to tail. Returns previous value if existed. */
13
+ upsert(key: string, value: T): T | undefined;
14
+ /** O(1) — remove by key, return removed value. */
15
+ remove(key: string): T | undefined;
16
+ /** O(1) — peek at oldest (head) without removing. */
17
+ peekOldest(): {
18
+ key: string;
19
+ value: T;
20
+ } | undefined;
21
+ /** O(1) — clear all entries. */
22
+ clear(): void;
23
+ /** O(n) — iterate oldest → newest. */
24
+ toArray(): Array<{
25
+ key: string;
26
+ value: T;
27
+ }>;
28
+ private unlink;
29
+ private appendToTail;
30
+ private moveToTail;
31
+ }
@@ -0,0 +1,102 @@
1
+ /**
2
+ * O(1) doubly-linked list + Map LRU.
3
+ * head = oldest, tail = newest.
4
+ */
5
+ export class LruList {
6
+ map = new Map();
7
+ head = null;
8
+ tail = null;
9
+ get size() {
10
+ return this.map.size;
11
+ }
12
+ /** O(1) — move to tail (most recent), return value reference. */
13
+ touch(key) {
14
+ const node = this.map.get(key);
15
+ if (!node) {
16
+ return undefined;
17
+ }
18
+ this.moveToTail(node);
19
+ return node.value;
20
+ }
21
+ /** O(1) — insert or update + move to tail. Returns previous value if existed. */
22
+ upsert(key, value) {
23
+ const existing = this.map.get(key);
24
+ if (existing) {
25
+ const prev = existing.value;
26
+ existing.value = value;
27
+ this.moveToTail(existing);
28
+ return prev;
29
+ }
30
+ const node = { key, value, prev: null, next: null };
31
+ this.map.set(key, node);
32
+ this.appendToTail(node);
33
+ return undefined;
34
+ }
35
+ /** O(1) — remove by key, return removed value. */
36
+ remove(key) {
37
+ const node = this.map.get(key);
38
+ if (!node) {
39
+ return undefined;
40
+ }
41
+ this.unlink(node);
42
+ this.map.delete(key);
43
+ return node.value;
44
+ }
45
+ /** O(1) — peek at oldest (head) without removing. */
46
+ peekOldest() {
47
+ if (!this.head) {
48
+ return undefined;
49
+ }
50
+ return { key: this.head.key, value: this.head.value };
51
+ }
52
+ /** O(1) — clear all entries. */
53
+ clear() {
54
+ this.map.clear();
55
+ this.head = null;
56
+ this.tail = null;
57
+ }
58
+ /** O(n) — iterate oldest → newest. */
59
+ toArray() {
60
+ const result = [];
61
+ let current = this.head;
62
+ while (current) {
63
+ result.push({ key: current.key, value: current.value });
64
+ current = current.next;
65
+ }
66
+ return result;
67
+ }
68
+ unlink(node) {
69
+ if (node.prev) {
70
+ node.prev.next = node.next;
71
+ }
72
+ else {
73
+ this.head = node.next;
74
+ }
75
+ if (node.next) {
76
+ node.next.prev = node.prev;
77
+ }
78
+ else {
79
+ this.tail = node.prev;
80
+ }
81
+ node.prev = null;
82
+ node.next = null;
83
+ }
84
+ appendToTail(node) {
85
+ if (!this.tail) {
86
+ this.head = node;
87
+ this.tail = node;
88
+ return;
89
+ }
90
+ node.prev = this.tail;
91
+ this.tail.next = node;
92
+ this.tail = node;
93
+ }
94
+ moveToTail(node) {
95
+ if (node === this.tail) {
96
+ return;
97
+ }
98
+ this.unlink(node);
99
+ this.appendToTail(node);
100
+ }
101
+ }
102
+ //# sourceMappingURL=lru-list.js.map
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Internal types shared between the MappingService class and the parser
3
+ * modules under `src/mapping/parsers/`. Public mapping API types live in
4
+ * `src/mapping-service.ts`; this file is intentionally limited to types
5
+ * the parsers need to operate on indexes.
6
+ */
7
+ import type { SourceMapping } from "../types.js";
8
+ export type PairKey = `${SourceMapping}->${SourceMapping}`;
9
+ export type MappingSymbolKind = "class" | "field" | "method";
10
+ export type MappingSymbolRecord = {
11
+ kind: MappingSymbolKind;
12
+ symbol: string;
13
+ owner?: string;
14
+ name: string;
15
+ descriptor?: string;
16
+ };
17
+ export type DirectionIndex = {
18
+ exact: Map<string, Set<string>>;
19
+ normalized: Map<string, Set<string>>;
20
+ simple: Map<string, Set<string>>;
21
+ records: Map<string, MappingSymbolRecord>;
22
+ };
23
+ export type MappingLookupSource = "loom-cache" | "maven" | "mojang-client-mappings";
24
+ export type PairRecord = {
25
+ index: DirectionIndex;
26
+ source: MappingLookupSource;
27
+ mappingArtifact: string;
28
+ };
29
+ export declare const MATCH_RANK: {
30
+ readonly exact: 3;
31
+ readonly normalized: 2;
32
+ readonly "simple-name": 1;
33
+ };
34
+ export declare const DESCRIPTOR_FALLBACK_CONFIDENCE = 0.85;
35
+ export declare const MAX_CANDIDATES = 200;
36
+ export type MatchRankKey = keyof typeof MATCH_RANK;
37
+ export type GraphLoadMode = "full" | "obfuscated-mojang-only";
38
+ export type CandidateAccumulator = {
39
+ key: string;
40
+ record: MappingSymbolRecord;
41
+ matchKind: import("./types.js").MappingMatchKind;
42
+ confidence: number;
43
+ rank: number;
44
+ };
45
+ export type LoadedGraph = {
46
+ version: string;
47
+ priority: import("../types.js").MappingSourcePriority;
48
+ mode: GraphLoadMode;
49
+ pairs: Map<PairKey, PairRecord>;
50
+ adjacency: Map<import("../types.js").SourceMapping, import("../types.js").SourceMapping[]>;
51
+ pathCache: Map<PairKey, import("../types.js").SourceMapping[] | undefined>;
52
+ recordsByTarget: Map<import("../types.js").SourceMapping, MappingSymbolRecord[]>;
53
+ warnings: string[];
54
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Internal types shared between the MappingService class and the parser
3
+ * modules under `src/mapping/parsers/`. Public mapping API types live in
4
+ * `src/mapping-service.ts`; this file is intentionally limited to types
5
+ * the parsers need to operate on indexes.
6
+ */
7
+ export const MATCH_RANK = {
8
+ exact: 3,
9
+ normalized: 2,
10
+ "simple-name": 1
11
+ };
12
+ export const DESCRIPTOR_FALLBACK_CONFIDENCE = 0.85;
13
+ export const MAX_CANDIDATES = 200;
14
+ //# sourceMappingURL=internal-types.js.map
@@ -0,0 +1,2 @@
1
+ import type { MappingLoaderDeps, MappingLoaderResult } from "./types.js";
2
+ export declare function loadMojangPairs(deps: MappingLoaderDeps, version: string): Promise<MappingLoaderResult>;
@@ -0,0 +1,64 @@
1
+ import { existsSync } from "node:fs";
2
+ import { mkdir, readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { downloadToCache } from "../../repo-downloader.js";
5
+ import { parseClientMappings } from "../parsers/proguard.js";
6
+ export async function loadMojangPairs(deps, version) {
7
+ const warnings = [];
8
+ let metadata;
9
+ try {
10
+ metadata = await deps.versionService.resolveVersionMappings(version);
11
+ }
12
+ catch (caughtError) {
13
+ return {
14
+ pairs: new Map(),
15
+ warnings: [
16
+ `Failed to resolve version metadata for "${version}": ${caughtError instanceof Error ? caughtError.message : String(caughtError)}`
17
+ ],
18
+ mappingArtifact: `version:${version}`
19
+ };
20
+ }
21
+ const clientMappingsUrl = metadata.clientMappingsUrl ?? metadata.mappingsUrl;
22
+ if (!clientMappingsUrl) {
23
+ warnings.push(`Minecraft version "${version}" does not expose client mappings URL.`);
24
+ return {
25
+ pairs: new Map(),
26
+ warnings,
27
+ mappingArtifact: metadata.versionDetailUrl
28
+ };
29
+ }
30
+ const mappingsPath = join(deps.config.cacheDir, "mappings", version, "client_mappings.txt");
31
+ if (!existsSync(mappingsPath)) {
32
+ await mkdir(dirname(mappingsPath), { recursive: true });
33
+ const downloaded = await downloadToCache(clientMappingsUrl, mappingsPath, {
34
+ fetchFn: deps.fetchFn,
35
+ retries: deps.config.fetchRetries,
36
+ timeoutMs: deps.config.fetchTimeoutMs
37
+ });
38
+ if (!downloaded.ok || !downloaded.path) {
39
+ warnings.push(`Failed to download client mappings from "${clientMappingsUrl}" (status: ${downloaded.statusCode ?? "unknown"}).`);
40
+ return {
41
+ pairs: new Map(),
42
+ warnings,
43
+ mappingArtifact: clientMappingsUrl
44
+ };
45
+ }
46
+ }
47
+ try {
48
+ const content = await readFile(mappingsPath, "utf8");
49
+ return {
50
+ pairs: parseClientMappings(content),
51
+ warnings,
52
+ mappingArtifact: clientMappingsUrl
53
+ };
54
+ }
55
+ catch (caughtError) {
56
+ warnings.push(`Failed to parse client mappings for "${version}": ${caughtError instanceof Error ? caughtError.message : String(caughtError)}`);
57
+ return {
58
+ pairs: new Map(),
59
+ warnings,
60
+ mappingArtifact: clientMappingsUrl
61
+ };
62
+ }
63
+ }
64
+ //# sourceMappingURL=mojang.js.map
@@ -0,0 +1,2 @@
1
+ import type { MappingLoaderResult } from "./types.js";
2
+ export declare function loadTinyPairsFromLoom(version: string, projectPath?: string): Promise<MappingLoaderResult>;
@@ -0,0 +1,73 @@
1
+ import { existsSync } from "node:fs";
2
+ import { readFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import fastGlob from "fast-glob";
5
+ import { buildVersionSourceSearchRoots } from "../../gradle-paths.js";
6
+ import { effectiveLoomSearchProjectPath } from "../lookup.js";
7
+ import { mergeDirectionIndexes } from "../parsers/symbol-records.js";
8
+ import { parseTinyMappings } from "../parsers/tiny.js";
9
+ const GLOB_SPECIAL_CHARS = /[\\!*+?()[\]{}@|]/g;
10
+ export async function loadTinyPairsFromLoom(version, projectPath) {
11
+ const searchRoots = buildVersionSourceSearchRoots(effectiveLoomSearchProjectPath(projectPath));
12
+ const merged = new Map();
13
+ const discoveredPaths = new Set();
14
+ for (const root of searchRoots) {
15
+ let discovered = [];
16
+ const versionRoot = join(root, version);
17
+ try {
18
+ discovered = existsSync(versionRoot)
19
+ ? await fastGlob.glob(["**/*.tiny", "**/*.tinyv2"], {
20
+ cwd: versionRoot,
21
+ absolute: true,
22
+ onlyFiles: true
23
+ })
24
+ : await fastGlob.glob([`${version.replace(GLOB_SPECIAL_CHARS, "\\$&")}/**/*.tiny`, `${version.replace(GLOB_SPECIAL_CHARS, "\\$&")}/**/*.tinyv2`], {
25
+ cwd: root,
26
+ absolute: true,
27
+ onlyFiles: true
28
+ });
29
+ }
30
+ catch {
31
+ continue;
32
+ }
33
+ const byVersion = discovered
34
+ .filter((path) => path.replaceAll("\\", "/").includes(`/${version}/`))
35
+ .sort((left, right) => left.localeCompare(right));
36
+ if (byVersion.length === 0) {
37
+ continue;
38
+ }
39
+ for (const path of byVersion) {
40
+ discoveredPaths.add(path);
41
+ try {
42
+ const content = await readFile(path, "utf8");
43
+ const parsed = parseTinyMappings(content);
44
+ for (const [key, index] of parsed.entries()) {
45
+ const existing = merged.get(key);
46
+ if (!existing) {
47
+ merged.set(key, index);
48
+ }
49
+ else {
50
+ mergeDirectionIndexes(existing, index);
51
+ }
52
+ }
53
+ }
54
+ catch {
55
+ // best effort: skip unreadable or invalid files
56
+ }
57
+ }
58
+ }
59
+ const orderedPaths = [...discoveredPaths].sort((left, right) => left.localeCompare(right));
60
+ if (orderedPaths.length > 0) {
61
+ return {
62
+ pairs: merged,
63
+ warnings: [],
64
+ mappingArtifact: orderedPaths[0]
65
+ };
66
+ }
67
+ return {
68
+ pairs: new Map(),
69
+ warnings: [`No Loom tiny mapping files matched version "${version}".`],
70
+ mappingArtifact: "loom-cache:none"
71
+ };
72
+ }
73
+ //# sourceMappingURL=tiny-loom.js.map
@@ -0,0 +1,2 @@
1
+ import type { MappingLoaderDeps, MappingLoaderResult } from "./types.js";
2
+ export declare function loadTinyPairsFromMaven(deps: MappingLoaderDeps, version: string): Promise<MappingLoaderResult>;
@@ -0,0 +1,104 @@
1
+ import { defaultDownloadPath, downloadToCache } from "../../repo-downloader.js";
2
+ import { collectMatchedJarEntriesAsUtf8 } from "../../source-jar-reader.js";
3
+ import { mergeDirectionIndexes } from "../parsers/symbol-records.js";
4
+ import { parseTinyMappings } from "../parsers/tiny.js";
5
+ async function fetchYarnCoordinates(fetchFn, repoBase, version) {
6
+ const metadataUrl = `${repoBase}/net/fabricmc/yarn/maven-metadata.xml`;
7
+ try {
8
+ const response = await fetchFn(metadataUrl);
9
+ if (!response.ok) {
10
+ return [];
11
+ }
12
+ const xml = await response.text();
13
+ const versions = [...xml.matchAll(/<version>([^<]+)<\/version>/g)]
14
+ .map((match) => match[1]?.trim() ?? "")
15
+ .filter((value) => value.startsWith(`${version}+build.`));
16
+ const sorted = versions.sort((left, right) => {
17
+ const leftBuild = Number.parseInt(left.split("+build.")[1] ?? "0", 10);
18
+ const rightBuild = Number.parseInt(right.split("+build.")[1] ?? "0", 10);
19
+ return rightBuild - leftBuild;
20
+ });
21
+ if (sorted.length > 0) {
22
+ return sorted.slice(0, 3);
23
+ }
24
+ return [version];
25
+ }
26
+ catch {
27
+ return [version];
28
+ }
29
+ }
30
+ async function parseTinyFromJar(jarPath) {
31
+ const tinyEntries = (await collectMatchedJarEntriesAsUtf8(jarPath, (entry) => entry.toLowerCase().endsWith(".tiny") || entry.toLowerCase().endsWith(".tinyv2"), { continueOnError: true })).sort((left, right) => left.filePath.localeCompare(right.filePath));
32
+ const merged = new Map();
33
+ for (const entry of tinyEntries) {
34
+ try {
35
+ const parsed = parseTinyMappings(entry.content);
36
+ for (const [key, index] of parsed.entries()) {
37
+ const existing = merged.get(key);
38
+ if (!existing) {
39
+ merged.set(key, index);
40
+ }
41
+ else {
42
+ mergeDirectionIndexes(existing, index);
43
+ }
44
+ }
45
+ }
46
+ catch {
47
+ // skip malformed tiny entries
48
+ }
49
+ }
50
+ return merged;
51
+ }
52
+ export async function loadTinyPairsFromMaven(deps, version) {
53
+ const warnings = [];
54
+ const merged = new Map();
55
+ const repos = deps.config.sourceRepos;
56
+ const intermediaryUrls = [];
57
+ const yarnUrls = [];
58
+ const repoBases = repos.map((repo) => repo.replace(/\/+$/, ""));
59
+ const yarnCoordinatesByRepo = await Promise.all(repoBases.map(async (base) => ({
60
+ base,
61
+ yarnCoordinates: await fetchYarnCoordinates(deps.fetchFn, base, version)
62
+ })));
63
+ for (const { base, yarnCoordinates } of yarnCoordinatesByRepo) {
64
+ intermediaryUrls.push(`${base}/net/fabricmc/intermediary/${version}/intermediary-${version}-v2.jar`, `${base}/net/fabricmc/intermediary/${version}/intermediary-${version}.jar`);
65
+ for (const coordinate of yarnCoordinates) {
66
+ yarnUrls.push(`${base}/net/fabricmc/yarn/${coordinate}/yarn-${coordinate}-v2.jar`, `${base}/net/fabricmc/yarn/${coordinate}/yarn-${coordinate}.jar`);
67
+ }
68
+ }
69
+ const allUrls = [...intermediaryUrls, ...yarnUrls];
70
+ const parsedResults = await Promise.allSettled(allUrls.map(async (url) => {
71
+ const downloaded = await downloadToCache(url, defaultDownloadPath(deps.config.cacheDir, url), {
72
+ fetchFn: deps.fetchFn,
73
+ retries: deps.config.fetchRetries,
74
+ timeoutMs: deps.config.fetchTimeoutMs
75
+ });
76
+ if (!downloaded.ok || !downloaded.path) {
77
+ return undefined;
78
+ }
79
+ return parseTinyFromJar(downloaded.path);
80
+ }));
81
+ for (const result of parsedResults) {
82
+ if (result.status !== "fulfilled" || !result.value) {
83
+ continue;
84
+ }
85
+ for (const [key, index] of result.value.entries()) {
86
+ const existing = merged.get(key);
87
+ if (!existing) {
88
+ merged.set(key, index);
89
+ }
90
+ else {
91
+ mergeDirectionIndexes(existing, index);
92
+ }
93
+ }
94
+ }
95
+ if (merged.size === 0) {
96
+ warnings.push(`No Maven tiny mappings could be loaded for "${version}".`);
97
+ }
98
+ return {
99
+ pairs: merged,
100
+ warnings,
101
+ mappingArtifact: allUrls[0] ?? "maven:none"
102
+ };
103
+ }
104
+ //# sourceMappingURL=tiny-maven.js.map
@@ -0,0 +1,14 @@
1
+ import type { Config } from "../../types.js";
2
+ import type { VersionService } from "../../version-service.js";
3
+ import type { DirectionIndex, PairKey } from "../internal-types.js";
4
+ export type VersionMappingsResolver = Pick<VersionService, "resolveVersionMappings">;
5
+ export type MappingLoaderDeps = {
6
+ config: Config;
7
+ fetchFn: typeof fetch;
8
+ versionService: VersionMappingsResolver;
9
+ };
10
+ export type MappingLoaderResult = {
11
+ pairs: Map<PairKey, DirectionIndex>;
12
+ warnings: string[];
13
+ mappingArtifact: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,52 @@
1
+ import type { MappingSourcePriority, SourceMapping } from "../types.js";
2
+ import type { CandidateAccumulator, DirectionIndex, LoadedGraph, MappingLookupSource, MappingSymbolRecord, MatchRankKey, PairKey, PairRecord } from "./internal-types.js";
3
+ import { MAX_CANDIDATES } from "./internal-types.js";
4
+ import type { ClassApiMatrixKind, DescriptorProjection, MappingLookupCandidate, ResolutionCandidate, SymbolQueryInput, SymbolReference } from "./types.js";
5
+ export type { DescriptorProjection };
6
+ export { MAX_CANDIDATES };
7
+ export declare function addCandidates(target: Map<string, CandidateAccumulator>, index: DirectionIndex, symbols: Set<string> | undefined, kind: MatchRankKey, confidence: number): void;
8
+ export declare function lookupCandidates(index: DirectionIndex, query: MappingSymbolRecord): MappingLookupCandidate[];
9
+ export declare function mappingPriorityFromInput(configPriority: MappingSourcePriority, override: MappingSourcePriority | undefined): MappingSourcePriority;
10
+ export declare function mappingSourceOrder(priority: MappingSourcePriority): Array<"loom-cache" | "maven">;
11
+ export declare function requiresOnlyObfuscatedMojangGraph(sourceMapping: SourceMapping, targetMapping?: SourceMapping): boolean;
12
+ export declare function namespacePath(graph: LoadedGraph, sourceMapping: SourceMapping, targetMapping: SourceMapping): SourceMapping[] | undefined;
13
+ export declare function pathUsesSource(pairs: Map<PairKey, PairRecord>, path: SourceMapping[], source: MappingLookupSource): boolean;
14
+ export declare function pathToTransformChain(path: SourceMapping[]): string[];
15
+ export declare function toLookupCandidate(record: MappingSymbolRecord): MappingLookupCandidate;
16
+ export declare function toSymbolReference(record: MappingSymbolRecord): SymbolReference;
17
+ export declare function toResolutionCandidate(candidate: MappingLookupCandidate): SymbolReference & Pick<MappingLookupCandidate, "matchKind" | "confidence">;
18
+ export declare function invalidInputError(message: string, details: Record<string, unknown>): import("../errors.js").AppError;
19
+ export declare function normalizeMemberName(name: string): string;
20
+ /**
21
+ * Validate a JVM method descriptor such as `(I)V`, `()Lfoo/Bar;`, `(Lfoo/Bar;[I)V`.
22
+ * Rejects empty strings, missing/mis-positioned parens, empty return type, and invalid base
23
+ * type tokens so "(" or "()" style half-descriptors surface as ERR_INVALID_INPUT instead of
24
+ * being silently accepted.
25
+ */
26
+ export declare function normalizeMethodDescriptor(descriptor: string | undefined): string;
27
+ export declare function isValidMethodDescriptor(descriptor: string): boolean;
28
+ export declare function consumeFieldType(descriptor: string, position: number, allowVoid: boolean): number;
29
+ export declare function normalizeQuerySymbol(input: SymbolQueryInput, signatureMode?: "exact" | "name-only", options?: {
30
+ allowShortClassName?: boolean;
31
+ }): {
32
+ record: MappingSymbolRecord;
33
+ querySymbol: SymbolReference;
34
+ };
35
+ export declare function normalizeOwnerHint(ownerHint: string | undefined): string | undefined;
36
+ export declare function normalizeDescriptorHint(descriptorHint: string | undefined): string | undefined;
37
+ export declare function applyDisambiguationHints(candidates: MappingLookupCandidate[], disambiguation: {
38
+ ownerHint?: string;
39
+ descriptorHint?: string;
40
+ } | undefined): MappingLookupCandidate[];
41
+ export declare function projectLookupCandidateDescriptor(candidate: MappingLookupCandidate, sourceDescriptor: string, targetDescriptor: string | undefined): MappingLookupCandidate;
42
+ export declare function effectiveLoomSearchProjectPath(projectPath: string | undefined): string | undefined;
43
+ export declare function collectTargetRecords(graph: LoadedGraph, targetMapping: SourceMapping): MappingSymbolRecord[];
44
+ export declare function normalizeIncludedKinds(inputKinds: ClassApiMatrixKind[] | undefined): Set<ClassApiMatrixKind>;
45
+ export declare function inferAmbiguityReasons(candidates: ResolutionCandidate[], usedMojangClientMappings: boolean): string[];
46
+ export declare function clampCandidateLimit(limit: number | undefined): number;
47
+ export declare function limitResolutionCandidates(candidates: ResolutionCandidate[], requestedLimit: number | undefined): {
48
+ candidates: ResolutionCandidate[];
49
+ candidateCount: number;
50
+ candidatesTruncated?: boolean;
51
+ };
52
+ export declare function clampRowLimit(limit: number | undefined): number | undefined;