@adhisang/minecraft-modding-mcp 3.0.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -420,7 +420,7 @@ function parseClientMappings(text) {
420
420
  }
421
421
  function normalizeTinyNamespace(namespace) {
422
422
  const normalized = namespace.trim().toLowerCase();
423
- if (normalized === "obfuscated") {
423
+ if (normalized === "obfuscated" || normalized === "official") {
424
424
  return "obfuscated";
425
425
  }
426
426
  if (normalized === "mojang") {
@@ -590,6 +590,12 @@ function mappingSourceOrder(priority) {
590
590
  }
591
591
  return ["loom-cache", "maven"];
592
592
  }
593
+ function requiresOnlyObfuscatedMojangGraph(sourceMapping, targetMapping) {
594
+ return sourceMapping !== "intermediary" &&
595
+ sourceMapping !== "yarn" &&
596
+ targetMapping !== "intermediary" &&
597
+ targetMapping !== "yarn";
598
+ }
593
599
  function namespacePath(graph, sourceMapping, targetMapping) {
594
600
  if (sourceMapping === targetMapping) {
595
601
  return [sourceMapping];
@@ -709,7 +715,7 @@ function normalizeMethodDescriptor(descriptor) {
709
715
  }
710
716
  return normalized;
711
717
  }
712
- function normalizeQuerySymbol(input, signatureMode) {
718
+ function normalizeQuerySymbol(input, signatureMode, options) {
713
719
  if (input.kind !== "class" && input.kind !== "field" && input.kind !== "method") {
714
720
  throw invalidInputError('kind must be one of "class", "field", or "method".', {
715
721
  kind: input.kind
@@ -735,7 +741,7 @@ function normalizeQuerySymbol(input, signatureMode) {
735
741
  });
736
742
  }
737
743
  const className = normalizeMappedSymbolOutput(normalizedName);
738
- if (!className.includes(".")) {
744
+ if (!className.includes(".") && !options?.allowShortClassName) {
739
745
  throw invalidInputError("name must be a fully qualified class name when kind=class.", {
740
746
  name: input.name
741
747
  });
@@ -905,7 +911,9 @@ export class MappingService {
905
911
  }
906
912
  });
907
913
  }
908
- const { record: queryRecord, querySymbol } = normalizeQuerySymbol(input, input.signatureMode);
914
+ const { record: queryRecord, querySymbol } = normalizeQuerySymbol(input, input.signatureMode, {
915
+ allowShortClassName: input.kind === "class" && input.sourceMapping === "obfuscated"
916
+ });
909
917
  const sourceMapping = input.sourceMapping;
910
918
  const targetMapping = input.targetMapping;
911
919
  if (!SUPPORTED_MAPPINGS.has(sourceMapping) || !SUPPORTED_MAPPINGS.has(targetMapping)) {
@@ -945,7 +953,7 @@ export class MappingService {
945
953
  warnings: []
946
954
  };
947
955
  }
948
- const graph = await this.loadGraph(version, priority);
956
+ const graph = await this.loadGraph(version, priority, requiresOnlyObfuscatedMojangGraph(sourceMapping, targetMapping) ? "obfuscated-mojang-only" : "full");
949
957
  const path = namespacePath(graph, sourceMapping, targetMapping);
950
958
  if (!path) {
951
959
  return {
@@ -1029,7 +1037,7 @@ export class MappingService {
1029
1037
  warnings: []
1030
1038
  };
1031
1039
  }
1032
- const graph = await this.loadGraph(version, priority);
1040
+ const graph = await this.loadGraph(version, priority, requiresOnlyObfuscatedMojangGraph(sourceMapping, targetMapping) ? "obfuscated-mojang-only" : "full");
1033
1041
  const path = namespacePath(graph, sourceMapping, targetMapping);
1034
1042
  if (!path) {
1035
1043
  throw createError({
@@ -1113,7 +1121,7 @@ export class MappingService {
1113
1121
  warnings: []
1114
1122
  };
1115
1123
  }
1116
- const graph = await this.loadGraph(version, priority);
1124
+ const graph = await this.loadGraph(version, priority, requiresOnlyObfuscatedMojangGraph(sourceMapping, targetMapping) ? "obfuscated-mojang-only" : "full");
1117
1125
  const path = namespacePath(graph, sourceMapping, targetMapping);
1118
1126
  if (!path) {
1119
1127
  return {
@@ -1214,7 +1222,7 @@ export class MappingService {
1214
1222
  });
1215
1223
  }
1216
1224
  const priority = mappingPriorityFromInput(this.config.mappingSourcePriority, input.sourcePriority);
1217
- const graph = await this.loadGraph(version, priority);
1225
+ const graph = await this.loadGraph(version, priority, "full");
1218
1226
  const warnings = [...graph.warnings];
1219
1227
  const includeKinds = normalizeIncludedKinds(input.includeKinds);
1220
1228
  const pathCache = new Map();
@@ -1246,7 +1254,7 @@ export class MappingService {
1246
1254
  classByMapping[mapping] = mapped[0];
1247
1255
  }
1248
1256
  }
1249
- const baseMapping = classByMapping.obfuscated ? "obfuscated" : classNameMapping;
1257
+ const baseMapping = classNameMapping;
1250
1258
  const baseClass = classByMapping[baseMapping];
1251
1259
  if (!baseClass) {
1252
1260
  return {
@@ -1435,7 +1443,7 @@ export class MappingService {
1435
1443
  querySymbol
1436
1444
  };
1437
1445
  })();
1438
- const graph = await this.loadGraph(version, priority);
1446
+ const graph = await this.loadGraph(version, priority, sourceMapping === "mojang" ? "obfuscated-mojang-only" : "full");
1439
1447
  const warnings = [...graph.warnings];
1440
1448
  const records = collectTargetRecords(graph, sourceMapping);
1441
1449
  if (records.length === 0) {
@@ -1640,7 +1648,7 @@ export class MappingService {
1640
1648
  const degradations = [];
1641
1649
  let graph;
1642
1650
  try {
1643
- graph = await this.loadGraph(input.version, priority);
1651
+ graph = await this.loadGraph(input.version, priority, "full");
1644
1652
  }
1645
1653
  catch {
1646
1654
  return {
@@ -1684,8 +1692,8 @@ export class MappingService {
1684
1692
  degradations
1685
1693
  };
1686
1694
  }
1687
- async loadGraph(version, priority) {
1688
- const cacheKey = `${version}|${priority}`;
1695
+ async loadGraph(version, priority, mode) {
1696
+ const cacheKey = `${version}|${priority}|${mode}`;
1689
1697
  const cached = this.graphCache.get(cacheKey);
1690
1698
  if (cached) {
1691
1699
  this.graphCache.delete(cacheKey);
@@ -1696,7 +1704,7 @@ export class MappingService {
1696
1704
  if (existingLock) {
1697
1705
  return existingLock;
1698
1706
  }
1699
- const buildPromise = this.buildGraph(version, priority);
1707
+ const buildPromise = this.buildGraph(version, priority, mode);
1700
1708
  this.buildLocks.set(cacheKey, buildPromise);
1701
1709
  try {
1702
1710
  const built = await buildPromise;
@@ -1708,11 +1716,12 @@ export class MappingService {
1708
1716
  this.buildLocks.delete(cacheKey);
1709
1717
  }
1710
1718
  }
1711
- async buildGraph(version, priority) {
1719
+ async buildGraph(version, priority, mode) {
1712
1720
  if (isUnobfuscatedVersion(version)) {
1713
1721
  return {
1714
1722
  version,
1715
1723
  priority,
1724
+ mode,
1716
1725
  pairs: new Map(),
1717
1726
  adjacency: new Map(),
1718
1727
  pathCache: new Map(),
@@ -1725,6 +1734,7 @@ export class MappingService {
1725
1734
  const graph = {
1726
1735
  version,
1727
1736
  priority,
1737
+ mode,
1728
1738
  pairs: new Map(),
1729
1739
  adjacency: new Map(),
1730
1740
  pathCache: new Map(),
@@ -1734,27 +1744,29 @@ export class MappingService {
1734
1744
  const mojangLoad = await this.loadMojangPairs(version);
1735
1745
  graph.warnings.push(...mojangLoad.warnings);
1736
1746
  this.mergePairs(graph.pairs, mojangLoad.pairs, "mojang-client-mappings", mojangLoad.mappingArtifact);
1737
- let tinyLoaded = false;
1738
- const deferredTinyWarnings = [];
1739
- for (const source of mappingSourceOrder(priority)) {
1740
- const tinyLoad = source === "loom-cache"
1741
- ? await this.loadTinyPairsFromLoom(version)
1742
- : await this.loadTinyPairsFromMaven(version);
1743
- if (tinyLoad.pairs.size === 0) {
1744
- deferredTinyWarnings.push(...tinyLoad.warnings);
1745
- continue;
1747
+ if (mode === "full") {
1748
+ let tinyLoaded = false;
1749
+ const deferredTinyWarnings = [];
1750
+ for (const source of mappingSourceOrder(priority)) {
1751
+ const tinyLoad = source === "loom-cache"
1752
+ ? await this.loadTinyPairsFromLoom(version)
1753
+ : await this.loadTinyPairsFromMaven(version);
1754
+ if (tinyLoad.pairs.size === 0) {
1755
+ deferredTinyWarnings.push(...tinyLoad.warnings);
1756
+ continue;
1757
+ }
1758
+ tinyLoaded = true;
1759
+ this.mergePairs(graph.pairs, tinyLoad.pairs, source, tinyLoad.mappingArtifact);
1760
+ graph.warnings.push(...tinyLoad.warnings);
1761
+ if (deferredTinyWarnings.length > 0) {
1762
+ graph.warnings.push(`Used ${source === "maven" ? "Maven" : "Loom cache"} tiny mappings for "${version}" after an earlier source lookup returned no data.`);
1763
+ }
1764
+ break;
1746
1765
  }
1747
- tinyLoaded = true;
1748
- this.mergePairs(graph.pairs, tinyLoad.pairs, source, tinyLoad.mappingArtifact);
1749
- graph.warnings.push(...tinyLoad.warnings);
1750
- if (deferredTinyWarnings.length > 0) {
1751
- graph.warnings.push(`Used ${source === "maven" ? "Maven" : "Loom cache"} tiny mappings for "${version}" after an earlier source lookup returned no data.`);
1766
+ if (!tinyLoaded) {
1767
+ graph.warnings.push(...deferredTinyWarnings);
1768
+ graph.warnings.push("No intermediary/yarn tiny mappings were found for this version.");
1752
1769
  }
1753
- break;
1754
- }
1755
- if (!tinyLoaded) {
1756
- graph.warnings.push(...deferredTinyWarnings);
1757
- graph.warnings.push("No intermediary/yarn tiny mappings were found for this version.");
1758
1770
  }
1759
1771
  graph.adjacency = buildAdjacency(graph.pairs);
1760
1772
  graph.recordsByTarget = buildTargetRecordIndex(graph.pairs);
@@ -1990,6 +2002,15 @@ export class MappingService {
1990
2002
  this.graphCache.delete(oldestKey);
1991
2003
  }
1992
2004
  }
2005
+ releaseGraphCacheEntry(version, sourcePriority) {
2006
+ const normalizedVersion = version.trim();
2007
+ if (!normalizedVersion) {
2008
+ return;
2009
+ }
2010
+ const priority = mappingPriorityFromInput(this.config.mappingSourcePriority, sourcePriority);
2011
+ this.graphCache.delete(`${normalizedVersion}|${priority}|full`);
2012
+ this.graphCache.delete(`${normalizedVersion}|${priority}|obfuscated-mojang-only`);
2013
+ }
1993
2014
  }
1994
2015
  // ---------------------------------------------------------------------------
1995
2016
  // Standalone: Tiny v2 mapping file resolution for remapping
@@ -3,12 +3,19 @@ export interface MetricTimingSnapshot {
3
3
  totalMs: number;
4
4
  avgMs: number;
5
5
  lastMs: number;
6
+ p95Ms: number;
7
+ p99Ms: number;
6
8
  }
7
9
  export interface CacheArtifactByteAccountingRow {
8
10
  artifact_id: string;
9
11
  content_bytes: number;
10
12
  updated_at: string;
11
13
  }
14
+ type CacheArtifactByteAccountingRefRow = {
15
+ artifactId: string;
16
+ totalContentBytes: number;
17
+ updatedAt: string;
18
+ };
12
19
  export interface RuntimeMetricSnapshot {
13
20
  resolve_duration_ms: MetricTimingSnapshot;
14
21
  search_duration_ms: MetricTimingSnapshot;
@@ -18,6 +25,10 @@ export interface RuntimeMetricSnapshot {
18
25
  search_intent_symbol_duration_ms: MetricTimingSnapshot;
19
26
  search_intent_text_duration_ms: MetricTimingSnapshot;
20
27
  search_intent_path_duration_ms: MetricTimingSnapshot;
28
+ search_query_mode_auto_count: number;
29
+ search_query_mode_token_count: number;
30
+ search_query_mode_literal_count: number;
31
+ search_literal_explicit_count: number;
21
32
  search_regex_fallback_count: number;
22
33
  search_token_bytes_returned: number;
23
34
  onehop_expand_count: number;
@@ -43,6 +54,10 @@ export declare class RuntimeMetrics {
43
54
  private cacheHits;
44
55
  private cacheMisses;
45
56
  private repoFailoverCount;
57
+ private searchQueryModeAutoCount;
58
+ private searchQueryModeTokenCount;
59
+ private searchQueryModeLiteralCount;
60
+ private searchLiteralExplicitCount;
46
61
  private searchRegexFallbackCount;
47
62
  private searchTokenBytesReturned;
48
63
  private oneHopExpandCount;
@@ -58,12 +73,13 @@ export declare class RuntimeMetrics {
58
73
  private cacheEvictions;
59
74
  private cacheEntries;
60
75
  private cacheTotalContentBytes;
61
- private cacheArtifactBytesLru;
76
+ private cacheArtifactBytesLruRef;
62
77
  constructor();
63
78
  recordDuration(name: DurationMetricName, durationMs: number): void;
64
79
  recordArtifactCacheHit(): void;
65
80
  recordArtifactCacheMiss(): void;
66
81
  recordRepoFailover(): void;
82
+ recordSearchQueryMode(mode: "auto" | "token" | "literal"): void;
67
83
  recordSearchIntentDuration(intent: "symbol" | "text" | "path", durationMs: number): void;
68
84
  recordSearchRegexFallback(): void;
69
85
  recordSearchTokenBytesReturned(tokenBytes: number): void;
@@ -80,7 +96,7 @@ export declare class RuntimeMetrics {
80
96
  recordCacheEviction(count?: number): void;
81
97
  setCacheEntries(entries: number): void;
82
98
  setCacheTotalContentBytes(totalBytes: number): void;
83
- setCacheArtifactByteAccounting(entries: CacheArtifactByteAccountingRow[]): void;
99
+ setCacheArtifactByteAccountingRef(entries: ReadonlyArray<CacheArtifactByteAccountingRefRow>): void;
84
100
  snapshot(): RuntimeMetricSnapshot;
85
101
  private toSnapshot;
86
102
  private resolveCacheHitRate;
@@ -1,8 +1,21 @@
1
+ const MAX_TIMING_SAMPLES = 512;
2
+ function percentile(samples, p) {
3
+ if (samples.length === 0) {
4
+ return 0;
5
+ }
6
+ const sorted = [...samples].sort((left, right) => left - right);
7
+ const index = Math.min(sorted.length - 1, Math.ceil((p / 100) * sorted.length) - 1);
8
+ return sorted[index] ?? 0;
9
+ }
1
10
  export class RuntimeMetrics {
2
11
  timings = new Map();
3
12
  cacheHits = 0;
4
13
  cacheMisses = 0;
5
14
  repoFailoverCount = 0;
15
+ searchQueryModeAutoCount = 0;
16
+ searchQueryModeTokenCount = 0;
17
+ searchQueryModeLiteralCount = 0;
18
+ searchLiteralExplicitCount = 0;
6
19
  searchRegexFallbackCount = 0;
7
20
  searchTokenBytesReturned = 0;
8
21
  oneHopExpandCount = 0;
@@ -18,7 +31,7 @@ export class RuntimeMetrics {
18
31
  cacheEvictions = 0;
19
32
  cacheEntries = 0;
20
33
  cacheTotalContentBytes = 0;
21
- cacheArtifactBytesLru = [];
34
+ cacheArtifactBytesLruRef = [];
22
35
  constructor() {
23
36
  const names = [
24
37
  "resolve_duration_ms",
@@ -31,7 +44,7 @@ export class RuntimeMetrics {
31
44
  "search_intent_path_duration_ms"
32
45
  ];
33
46
  for (const name of names) {
34
- this.timings.set(name, { count: 0, totalMs: 0, lastMs: 0 });
47
+ this.timings.set(name, { count: 0, totalMs: 0, lastMs: 0, samples: [] });
35
48
  }
36
49
  }
37
50
  recordDuration(name, durationMs) {
@@ -43,6 +56,10 @@ export class RuntimeMetrics {
43
56
  timing.count += 1;
44
57
  timing.totalMs += normalizedDuration;
45
58
  timing.lastMs = normalizedDuration;
59
+ timing.samples.push(normalizedDuration);
60
+ if (timing.samples.length > MAX_TIMING_SAMPLES) {
61
+ timing.samples.shift();
62
+ }
46
63
  }
47
64
  recordArtifactCacheHit() {
48
65
  this.cacheHits += 1;
@@ -53,6 +70,20 @@ export class RuntimeMetrics {
53
70
  recordRepoFailover() {
54
71
  this.repoFailoverCount += 1;
55
72
  }
73
+ recordSearchQueryMode(mode) {
74
+ switch (mode) {
75
+ case "auto":
76
+ this.searchQueryModeAutoCount += 1;
77
+ break;
78
+ case "token":
79
+ this.searchQueryModeTokenCount += 1;
80
+ break;
81
+ case "literal":
82
+ this.searchQueryModeLiteralCount += 1;
83
+ this.searchLiteralExplicitCount += 1;
84
+ break;
85
+ }
86
+ }
56
87
  recordSearchIntentDuration(intent, durationMs) {
57
88
  const metricName = intent === "symbol"
58
89
  ? "search_intent_symbol_duration_ms"
@@ -106,12 +137,8 @@ export class RuntimeMetrics {
106
137
  setCacheTotalContentBytes(totalBytes) {
107
138
  this.cacheTotalContentBytes = Math.max(0, Math.trunc(totalBytes));
108
139
  }
109
- setCacheArtifactByteAccounting(entries) {
110
- this.cacheArtifactBytesLru = entries.map((entry) => ({
111
- artifact_id: entry.artifact_id,
112
- content_bytes: Math.max(0, Math.trunc(entry.content_bytes)),
113
- updated_at: entry.updated_at
114
- }));
140
+ setCacheArtifactByteAccountingRef(entries) {
141
+ this.cacheArtifactBytesLruRef = entries;
115
142
  }
116
143
  snapshot() {
117
144
  return {
@@ -123,6 +150,10 @@ export class RuntimeMetrics {
123
150
  search_intent_symbol_duration_ms: this.toSnapshot("search_intent_symbol_duration_ms"),
124
151
  search_intent_text_duration_ms: this.toSnapshot("search_intent_text_duration_ms"),
125
152
  search_intent_path_duration_ms: this.toSnapshot("search_intent_path_duration_ms"),
153
+ search_query_mode_auto_count: this.searchQueryModeAutoCount,
154
+ search_query_mode_token_count: this.searchQueryModeTokenCount,
155
+ search_query_mode_literal_count: this.searchQueryModeLiteralCount,
156
+ search_literal_explicit_count: this.searchLiteralExplicitCount,
126
157
  search_regex_fallback_count: this.searchRegexFallbackCount,
127
158
  search_token_bytes_returned: this.searchTokenBytesReturned,
128
159
  onehop_expand_count: this.oneHopExpandCount,
@@ -138,7 +169,11 @@ export class RuntimeMetrics {
138
169
  cache_evictions: this.cacheEvictions,
139
170
  cache_entries: this.cacheEntries,
140
171
  cache_total_content_bytes: this.cacheTotalContentBytes,
141
- cache_artifact_bytes_lru: this.cacheArtifactBytesLru,
172
+ cache_artifact_bytes_lru: this.cacheArtifactBytesLruRef.map((entry) => ({
173
+ artifact_id: entry.artifactId,
174
+ content_bytes: Math.max(0, Math.trunc(entry.totalContentBytes)),
175
+ updated_at: entry.updatedAt
176
+ })),
142
177
  cache_hit_rate: this.resolveCacheHitRate(),
143
178
  repo_failover_count: this.repoFailoverCount
144
179
  };
@@ -151,7 +186,9 @@ export class RuntimeMetrics {
151
186
  count,
152
187
  totalMs,
153
188
  avgMs: count > 0 ? totalMs / count : 0,
154
- lastMs: timing?.lastMs ?? 0
189
+ lastMs: timing?.lastMs ?? 0,
190
+ p95Ms: percentile(timing?.samples ?? [], 95),
191
+ p99Ms: percentile(timing?.samples ?? [], 99)
155
192
  };
156
193
  }
157
194
  resolveCacheHitRate() {
@@ -488,7 +488,6 @@ export declare class SourceService {
488
488
  private searchTextIntent;
489
489
  private searchPathIntent;
490
490
  private findSymbolHits;
491
- private loadScopedFilePaths;
492
491
  private indexedCandidateLimit;
493
492
  private indexedCandidateLimitForMatch;
494
493
  private extractClassMetadata;
@@ -498,6 +497,8 @@ export declare class SourceService {
498
497
  private buildFallbackProvenance;
499
498
  private resolveClassNameForLookup;
500
499
  private buildClassSourceNotFoundError;
500
+ private rejectLifecycleClassLikeInput;
501
+ private releaseLifecycleMappingGraph;
501
502
  private resolveToObfuscatedClassName;
502
503
  private resolveToObfuscatedMemberName;
503
504
  private remapSignatureMembers;