@adhisang/minecraft-modding-mcp 2.1.0 → 3.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.
@@ -0,0 +1,304 @@
1
+ import { z } from "zod";
2
+ import { createError, ERROR_CODES } from "../errors.js";
3
+ import { buildIncludeSchema, detailSchema, positiveIntSchema } from "./entry-tool-schema.js";
4
+ import { buildEntryToolResult } from "./response-contract.js";
5
+ import { resolveDetail, resolveInclude } from "./request-normalizers.js";
6
+ const nonEmptyString = z.string().trim().min(1);
7
+ const INCLUDE_GROUPS = ["warnings", "candidates", "matrix", "workspace", "timings"];
8
+ const TASKS = ["exists", "map", "exact-map", "lifecycle", "workspace", "api-overview"];
9
+ export const analyzeSymbolShape = {
10
+ task: z.enum(TASKS),
11
+ subject: z.object({
12
+ kind: z.enum(["class", "method", "field", "symbol"]),
13
+ name: nonEmptyString,
14
+ owner: nonEmptyString.optional(),
15
+ descriptor: nonEmptyString.optional()
16
+ }),
17
+ version: nonEmptyString.optional(),
18
+ sourceMapping: z.enum(["obfuscated", "mojang", "intermediary", "yarn"]).optional(),
19
+ targetMapping: z.enum(["obfuscated", "mojang", "intermediary", "yarn"]).optional(),
20
+ classNameMapping: z.enum(["obfuscated", "mojang", "intermediary", "yarn"]).optional(),
21
+ projectPath: nonEmptyString.optional(),
22
+ signatureMode: z.enum(["exact", "name-only"]).optional(),
23
+ nameMode: z.enum(["fqcn", "auto"]).optional(),
24
+ includeKinds: z.array(z.enum(["class", "field", "method"])).optional(),
25
+ maxRows: positiveIntSchema.optional(),
26
+ maxCandidates: positiveIntSchema.optional(),
27
+ detail: detailSchema.optional(),
28
+ include: buildIncludeSchema(INCLUDE_GROUPS)
29
+ };
30
+ export const analyzeSymbolSchema = z.object(analyzeSymbolShape).superRefine((value, ctx) => {
31
+ if (value.task !== "workspace" && !value.version) {
32
+ ctx.addIssue({
33
+ code: z.ZodIssueCode.custom,
34
+ path: ["version"],
35
+ message: "version is required for non-workspace tasks."
36
+ });
37
+ }
38
+ if (value.task === "workspace" && !value.projectPath) {
39
+ ctx.addIssue({
40
+ code: z.ZodIssueCode.custom,
41
+ path: ["projectPath"],
42
+ message: "projectPath is required for task=workspace."
43
+ });
44
+ }
45
+ if (value.task === "api-overview" && value.subject.kind !== "class") {
46
+ ctx.addIssue({
47
+ code: z.ZodIssueCode.custom,
48
+ path: ["subject", "kind"],
49
+ message: "task=api-overview requires subject.kind=class."
50
+ });
51
+ }
52
+ if (value.task === "api-overview" && value.subject.owner) {
53
+ ctx.addIssue({
54
+ code: z.ZodIssueCode.custom,
55
+ path: ["subject", "owner"],
56
+ message: "task=api-overview does not accept owner or descriptor selectors."
57
+ });
58
+ }
59
+ if (value.task === "api-overview" && value.subject.descriptor) {
60
+ ctx.addIssue({
61
+ code: z.ZodIssueCode.custom,
62
+ path: ["subject", "descriptor"],
63
+ message: "task=api-overview does not accept owner or descriptor selectors."
64
+ });
65
+ }
66
+ });
67
+ function summaryStatusFromResolution(status) {
68
+ switch (status) {
69
+ case "resolved":
70
+ return "ok";
71
+ case "not_found":
72
+ return "not_found";
73
+ case "ambiguous":
74
+ return "ambiguous";
75
+ case "mapping_unavailable":
76
+ return "partial";
77
+ }
78
+ }
79
+ export class AnalyzeSymbolService {
80
+ deps;
81
+ constructor(deps) {
82
+ this.deps = deps;
83
+ }
84
+ async execute(input) {
85
+ const detail = resolveDetail(input.detail);
86
+ const include = resolveInclude(input.include);
87
+ const subjectKind = input.subject.kind === "symbol"
88
+ ? "class"
89
+ : input.subject.kind;
90
+ switch (input.task) {
91
+ case "exists": {
92
+ const output = await this.deps.checkSymbolExists({
93
+ version: input.version,
94
+ kind: subjectKind,
95
+ name: input.subject.name,
96
+ owner: input.subject.owner,
97
+ descriptor: input.subject.descriptor,
98
+ sourceMapping: input.sourceMapping ?? "obfuscated",
99
+ nameMode: input.nameMode,
100
+ signatureMode: input.signatureMode,
101
+ maxCandidates: input.maxCandidates
102
+ });
103
+ return {
104
+ ...buildEntryToolResult({
105
+ task: "exists",
106
+ detail,
107
+ include,
108
+ summary: {
109
+ status: summaryStatusFromResolution(output.status),
110
+ headline: output.resolved
111
+ ? `The symbol exists in ${output.mappingContext.version}.`
112
+ : `The symbol could not be resolved in ${output.mappingContext.version}.`,
113
+ counts: {
114
+ candidates: output.candidateCount
115
+ }
116
+ },
117
+ blocks: {
118
+ match: output.resolvedSymbol ?? output.querySymbol,
119
+ candidates: output.candidates,
120
+ ambiguity: output.ambiguityReasons ? { reasons: output.ambiguityReasons } : undefined
121
+ }
122
+ }),
123
+ warnings: output.warnings
124
+ };
125
+ }
126
+ case "map": {
127
+ const output = await this.deps.findMapping({
128
+ version: input.version,
129
+ kind: subjectKind,
130
+ name: input.subject.name,
131
+ owner: input.subject.owner,
132
+ descriptor: input.subject.descriptor,
133
+ sourceMapping: input.sourceMapping ?? "obfuscated",
134
+ targetMapping: input.targetMapping ?? "mojang",
135
+ signatureMode: input.signatureMode,
136
+ maxCandidates: input.maxCandidates
137
+ });
138
+ return {
139
+ ...buildEntryToolResult({
140
+ task: "map",
141
+ detail,
142
+ include,
143
+ summary: {
144
+ status: summaryStatusFromResolution(output.status),
145
+ headline: output.resolved
146
+ ? `Mapped the symbol into ${output.mappingContext.targetMapping}.`
147
+ : `Found ${output.candidateCount} candidate mappings.`,
148
+ counts: {
149
+ candidates: output.candidateCount
150
+ }
151
+ },
152
+ blocks: {
153
+ match: output.resolvedSymbol,
154
+ candidates: output.candidates,
155
+ ambiguity: output.ambiguityReasons ? { reasons: output.ambiguityReasons } : undefined
156
+ }
157
+ }),
158
+ warnings: output.warnings
159
+ };
160
+ }
161
+ case "exact-map": {
162
+ if (!input.subject.owner || !input.subject.descriptor) {
163
+ throw createError({
164
+ code: ERROR_CODES.INVALID_INPUT,
165
+ message: "task=exact-map requires owner and descriptor."
166
+ });
167
+ }
168
+ const output = await this.deps.resolveMethodMappingExact({
169
+ version: input.version,
170
+ owner: input.subject.owner,
171
+ name: input.subject.name,
172
+ descriptor: input.subject.descriptor,
173
+ sourceMapping: input.sourceMapping ?? "obfuscated",
174
+ targetMapping: input.targetMapping ?? "mojang",
175
+ maxCandidates: input.maxCandidates
176
+ });
177
+ return {
178
+ ...buildEntryToolResult({
179
+ task: "exact-map",
180
+ detail,
181
+ include,
182
+ summary: {
183
+ status: summaryStatusFromResolution(output.status),
184
+ headline: output.resolved
185
+ ? "Resolved the exact method mapping."
186
+ : "Could not resolve the exact method mapping.",
187
+ counts: {
188
+ candidates: output.candidateCount
189
+ }
190
+ },
191
+ blocks: {
192
+ match: output.resolvedSymbol,
193
+ candidates: output.candidates
194
+ }
195
+ }),
196
+ warnings: output.warnings
197
+ };
198
+ }
199
+ case "lifecycle": {
200
+ const output = await this.deps.traceSymbolLifecycle({
201
+ symbol: input.subject.owner
202
+ ? `${input.subject.owner}.${input.subject.name}`
203
+ : input.subject.name,
204
+ descriptor: input.subject.descriptor,
205
+ mapping: input.sourceMapping
206
+ });
207
+ return {
208
+ ...buildEntryToolResult({
209
+ task: "lifecycle",
210
+ detail,
211
+ include,
212
+ summary: {
213
+ status: output.presence.firstSeen ? "ok" : "not_found",
214
+ headline: output.presence.firstSeen
215
+ ? `Tracked the symbol from ${output.range.fromVersion} to ${output.range.toVersion}.`
216
+ : "The symbol was not found in the scanned version range.",
217
+ counts: {
218
+ scannedVersions: output.range.scannedCount
219
+ }
220
+ },
221
+ blocks: {
222
+ match: output.query,
223
+ timeline: output.timeline
224
+ }
225
+ }),
226
+ warnings: output.warnings
227
+ };
228
+ }
229
+ case "workspace": {
230
+ const output = await this.deps.resolveWorkspaceSymbol({
231
+ projectPath: input.projectPath,
232
+ version: input.version ?? "unknown",
233
+ kind: subjectKind,
234
+ name: input.subject.name,
235
+ owner: input.subject.owner,
236
+ descriptor: input.subject.descriptor,
237
+ sourceMapping: input.sourceMapping ?? "obfuscated",
238
+ maxCandidates: input.maxCandidates
239
+ });
240
+ return {
241
+ ...buildEntryToolResult({
242
+ task: "workspace",
243
+ detail,
244
+ include,
245
+ summary: {
246
+ status: summaryStatusFromResolution(output.status),
247
+ headline: output.workspaceDetection.resolved
248
+ ? `Resolved compile-visible symbol using ${output.workspaceDetection.mappingApplied} workspace mappings.`
249
+ : "Workspace compile mapping could not be detected confidently.",
250
+ counts: {
251
+ candidates: output.candidateCount
252
+ }
253
+ },
254
+ blocks: {
255
+ match: output.resolvedSymbol,
256
+ candidates: output.candidates,
257
+ workspace: output.workspaceDetection
258
+ }
259
+ }),
260
+ warnings: [...output.warnings, ...output.workspaceDetection.warnings]
261
+ };
262
+ }
263
+ case "api-overview": {
264
+ const output = await this.deps.getClassApiMatrix({
265
+ version: input.version,
266
+ className: input.subject.name,
267
+ classNameMapping: input.classNameMapping ?? "obfuscated",
268
+ includeKinds: input.includeKinds,
269
+ maxRows: input.maxRows
270
+ });
271
+ return {
272
+ ...buildEntryToolResult({
273
+ task: "api-overview",
274
+ detail,
275
+ include,
276
+ summary: {
277
+ status: "ok",
278
+ headline: `Built an API overview for ${output.className}.`,
279
+ counts: {
280
+ rows: output.rowCount,
281
+ ambiguousRows: output.ambiguousRowCount ?? 0
282
+ }
283
+ },
284
+ blocks: {
285
+ match: {
286
+ className: output.className,
287
+ classIdentity: output.classIdentity
288
+ },
289
+ matrix: include.includes("matrix") || detail !== "summary"
290
+ ? {
291
+ rowCount: output.rowCount,
292
+ rowsTruncated: output.rowsTruncated,
293
+ rows: output.rows.slice(0, 25)
294
+ }
295
+ : undefined
296
+ }
297
+ }),
298
+ warnings: output.warnings
299
+ };
300
+ }
301
+ }
302
+ }
303
+ }
304
+ //# sourceMappingURL=analyze-symbol-service.js.map
@@ -0,0 +1,210 @@
1
+ import { z } from "zod";
2
+ import type { DiffClassSignaturesOutput } from "../source-service.js";
3
+ import type { CompareVersionsOutput } from "../version-diff-service.js";
4
+ import type { GetRegistryDataOutput } from "../registry-service.js";
5
+ export declare const compareMinecraftShape: {
6
+ task: z.ZodOptional<z.ZodEnum<["auto", "versions", "class-diff", "registry-diff", "migration-overview"]>>;
7
+ subject: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
8
+ kind: z.ZodLiteral<"version-pair">;
9
+ fromVersion: z.ZodString;
10
+ toVersion: z.ZodString;
11
+ packageFilter: z.ZodOptional<z.ZodString>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ kind: "version-pair";
14
+ fromVersion: string;
15
+ toVersion: string;
16
+ packageFilter?: string | undefined;
17
+ }, {
18
+ kind: "version-pair";
19
+ fromVersion: string;
20
+ toVersion: string;
21
+ packageFilter?: string | undefined;
22
+ }>, z.ZodObject<{
23
+ kind: z.ZodLiteral<"class">;
24
+ className: z.ZodString;
25
+ fromVersion: z.ZodString;
26
+ toVersion: z.ZodString;
27
+ mapping: z.ZodOptional<z.ZodEnum<["obfuscated", "mojang", "intermediary", "yarn"]>>;
28
+ sourcePriority: z.ZodOptional<z.ZodEnum<["loom-first", "maven-first"]>>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ kind: "class";
31
+ className: string;
32
+ fromVersion: string;
33
+ toVersion: string;
34
+ mapping?: "intermediary" | "mojang" | "yarn" | "obfuscated" | undefined;
35
+ sourcePriority?: "loom-first" | "maven-first" | undefined;
36
+ }, {
37
+ kind: "class";
38
+ className: string;
39
+ fromVersion: string;
40
+ toVersion: string;
41
+ mapping?: "intermediary" | "mojang" | "yarn" | "obfuscated" | undefined;
42
+ sourcePriority?: "loom-first" | "maven-first" | undefined;
43
+ }>, z.ZodObject<{
44
+ kind: z.ZodLiteral<"registry">;
45
+ fromVersion: z.ZodString;
46
+ toVersion: z.ZodString;
47
+ registry: z.ZodOptional<z.ZodString>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ kind: "registry";
50
+ fromVersion: string;
51
+ toVersion: string;
52
+ registry?: string | undefined;
53
+ }, {
54
+ kind: "registry";
55
+ fromVersion: string;
56
+ toVersion: string;
57
+ registry?: string | undefined;
58
+ }>]>;
59
+ detail: z.ZodOptional<z.ZodEnum<["summary", "standard", "full"]>>;
60
+ include: z.ZodOptional<z.ZodArray<z.ZodEnum<[string, ...string[]]>, "many">>;
61
+ limit: z.ZodOptional<z.ZodNumber>;
62
+ maxClassResults: z.ZodOptional<z.ZodNumber>;
63
+ maxEntriesPerRegistry: z.ZodOptional<z.ZodNumber>;
64
+ includeFullDiff: z.ZodOptional<z.ZodBoolean>;
65
+ };
66
+ export declare const compareMinecraftSchema: z.ZodObject<{
67
+ task: z.ZodOptional<z.ZodEnum<["auto", "versions", "class-diff", "registry-diff", "migration-overview"]>>;
68
+ subject: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
69
+ kind: z.ZodLiteral<"version-pair">;
70
+ fromVersion: z.ZodString;
71
+ toVersion: z.ZodString;
72
+ packageFilter: z.ZodOptional<z.ZodString>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ kind: "version-pair";
75
+ fromVersion: string;
76
+ toVersion: string;
77
+ packageFilter?: string | undefined;
78
+ }, {
79
+ kind: "version-pair";
80
+ fromVersion: string;
81
+ toVersion: string;
82
+ packageFilter?: string | undefined;
83
+ }>, z.ZodObject<{
84
+ kind: z.ZodLiteral<"class">;
85
+ className: z.ZodString;
86
+ fromVersion: z.ZodString;
87
+ toVersion: z.ZodString;
88
+ mapping: z.ZodOptional<z.ZodEnum<["obfuscated", "mojang", "intermediary", "yarn"]>>;
89
+ sourcePriority: z.ZodOptional<z.ZodEnum<["loom-first", "maven-first"]>>;
90
+ }, "strip", z.ZodTypeAny, {
91
+ kind: "class";
92
+ className: string;
93
+ fromVersion: string;
94
+ toVersion: string;
95
+ mapping?: "intermediary" | "mojang" | "yarn" | "obfuscated" | undefined;
96
+ sourcePriority?: "loom-first" | "maven-first" | undefined;
97
+ }, {
98
+ kind: "class";
99
+ className: string;
100
+ fromVersion: string;
101
+ toVersion: string;
102
+ mapping?: "intermediary" | "mojang" | "yarn" | "obfuscated" | undefined;
103
+ sourcePriority?: "loom-first" | "maven-first" | undefined;
104
+ }>, z.ZodObject<{
105
+ kind: z.ZodLiteral<"registry">;
106
+ fromVersion: z.ZodString;
107
+ toVersion: z.ZodString;
108
+ registry: z.ZodOptional<z.ZodString>;
109
+ }, "strip", z.ZodTypeAny, {
110
+ kind: "registry";
111
+ fromVersion: string;
112
+ toVersion: string;
113
+ registry?: string | undefined;
114
+ }, {
115
+ kind: "registry";
116
+ fromVersion: string;
117
+ toVersion: string;
118
+ registry?: string | undefined;
119
+ }>]>;
120
+ detail: z.ZodOptional<z.ZodEnum<["summary", "standard", "full"]>>;
121
+ include: z.ZodOptional<z.ZodArray<z.ZodEnum<[string, ...string[]]>, "many">>;
122
+ limit: z.ZodOptional<z.ZodNumber>;
123
+ maxClassResults: z.ZodOptional<z.ZodNumber>;
124
+ maxEntriesPerRegistry: z.ZodOptional<z.ZodNumber>;
125
+ includeFullDiff: z.ZodOptional<z.ZodBoolean>;
126
+ }, "strip", z.ZodTypeAny, {
127
+ subject: {
128
+ kind: "version-pair";
129
+ fromVersion: string;
130
+ toVersion: string;
131
+ packageFilter?: string | undefined;
132
+ } | {
133
+ kind: "class";
134
+ className: string;
135
+ fromVersion: string;
136
+ toVersion: string;
137
+ mapping?: "intermediary" | "mojang" | "yarn" | "obfuscated" | undefined;
138
+ sourcePriority?: "loom-first" | "maven-first" | undefined;
139
+ } | {
140
+ kind: "registry";
141
+ fromVersion: string;
142
+ toVersion: string;
143
+ registry?: string | undefined;
144
+ };
145
+ limit?: number | undefined;
146
+ maxClassResults?: number | undefined;
147
+ task?: "auto" | "versions" | "class-diff" | "registry-diff" | "migration-overview" | undefined;
148
+ detail?: "full" | "summary" | "standard" | undefined;
149
+ include?: string[] | undefined;
150
+ maxEntriesPerRegistry?: number | undefined;
151
+ includeFullDiff?: boolean | undefined;
152
+ }, {
153
+ subject: {
154
+ kind: "version-pair";
155
+ fromVersion: string;
156
+ toVersion: string;
157
+ packageFilter?: string | undefined;
158
+ } | {
159
+ kind: "class";
160
+ className: string;
161
+ fromVersion: string;
162
+ toVersion: string;
163
+ mapping?: "intermediary" | "mojang" | "yarn" | "obfuscated" | undefined;
164
+ sourcePriority?: "loom-first" | "maven-first" | undefined;
165
+ } | {
166
+ kind: "registry";
167
+ fromVersion: string;
168
+ toVersion: string;
169
+ registry?: string | undefined;
170
+ };
171
+ limit?: number | undefined;
172
+ maxClassResults?: number | undefined;
173
+ task?: "auto" | "versions" | "class-diff" | "registry-diff" | "migration-overview" | undefined;
174
+ detail?: "full" | "summary" | "standard" | undefined;
175
+ include?: string[] | undefined;
176
+ maxEntriesPerRegistry?: number | undefined;
177
+ includeFullDiff?: boolean | undefined;
178
+ }>;
179
+ export type CompareMinecraftInput = z.infer<typeof compareMinecraftSchema>;
180
+ type CompareMinecraftDeps = {
181
+ compareVersions: (input: {
182
+ fromVersion: string;
183
+ toVersion: string;
184
+ category?: "classes" | "registry" | "all";
185
+ packageFilter?: string;
186
+ maxClassResults?: number;
187
+ }) => Promise<CompareVersionsOutput>;
188
+ diffClassSignatures: (input: {
189
+ className: string;
190
+ fromVersion: string;
191
+ toVersion: string;
192
+ mapping?: "obfuscated" | "mojang" | "intermediary" | "yarn";
193
+ sourcePriority?: "loom-first" | "maven-first";
194
+ includeFullDiff?: boolean;
195
+ }) => Promise<DiffClassSignaturesOutput>;
196
+ getRegistryData: (input: {
197
+ version: string;
198
+ registry?: string;
199
+ includeData?: boolean;
200
+ maxEntriesPerRegistry?: number;
201
+ }) => Promise<GetRegistryDataOutput>;
202
+ };
203
+ export declare class CompareMinecraftService {
204
+ private readonly deps;
205
+ constructor(deps: CompareMinecraftDeps);
206
+ execute(input: CompareMinecraftInput): Promise<Record<string, unknown> & {
207
+ warnings?: string[];
208
+ }>;
209
+ }
210
+ export {};