@adhisang/minecraft-modding-mcp 4.0.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 (174) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +36 -23
  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 +50 -6
  7. package/dist/entry-tools/analyze-symbol-service.d.ts +16 -16
  8. package/dist/entry-tools/batch-class-members-service.d.ts +34 -0
  9. package/dist/entry-tools/batch-class-members-service.js +97 -0
  10. package/dist/entry-tools/batch-class-source-service.d.ts +37 -0
  11. package/dist/entry-tools/batch-class-source-service.js +100 -0
  12. package/dist/entry-tools/batch-mappings-service.d.ts +36 -0
  13. package/dist/entry-tools/batch-mappings-service.js +66 -0
  14. package/dist/entry-tools/batch-runner.d.ts +72 -0
  15. package/dist/entry-tools/batch-runner.js +90 -0
  16. package/dist/entry-tools/batch-symbol-exists-service.d.ts +46 -0
  17. package/dist/entry-tools/batch-symbol-exists-service.js +113 -0
  18. package/dist/entry-tools/compare-minecraft-service.d.ts +6 -6
  19. package/dist/entry-tools/inspect-minecraft/handlers/artifact.d.ts +5 -0
  20. package/dist/entry-tools/inspect-minecraft/handlers/artifact.js +83 -0
  21. package/dist/entry-tools/inspect-minecraft/handlers/class-members.d.ts +6 -0
  22. package/dist/entry-tools/inspect-minecraft/handlers/class-members.js +80 -0
  23. package/dist/entry-tools/inspect-minecraft/handlers/class-overview.d.ts +5 -0
  24. package/dist/entry-tools/inspect-minecraft/handlers/class-overview.js +248 -0
  25. package/dist/entry-tools/inspect-minecraft/handlers/class-source.d.ts +5 -0
  26. package/dist/entry-tools/inspect-minecraft/handlers/class-source.js +60 -0
  27. package/dist/entry-tools/inspect-minecraft/handlers/file.d.ts +5 -0
  28. package/dist/entry-tools/inspect-minecraft/handlers/file.js +54 -0
  29. package/dist/entry-tools/inspect-minecraft/handlers/list-files.d.ts +5 -0
  30. package/dist/entry-tools/inspect-minecraft/handlers/list-files.js +100 -0
  31. package/dist/entry-tools/inspect-minecraft/handlers/search.d.ts +5 -0
  32. package/dist/entry-tools/inspect-minecraft/handlers/search.js +155 -0
  33. package/dist/entry-tools/inspect-minecraft/handlers/versions.d.ts +6 -0
  34. package/dist/entry-tools/inspect-minecraft/handlers/versions.js +49 -0
  35. package/dist/entry-tools/inspect-minecraft/internal.d.ts +1042 -0
  36. package/dist/entry-tools/inspect-minecraft/internal.js +448 -0
  37. package/dist/entry-tools/inspect-minecraft-service.d.ts +193 -308
  38. package/dist/entry-tools/inspect-minecraft-service.js +20 -1244
  39. package/dist/entry-tools/manage-cache-service.d.ts +16 -16
  40. package/dist/entry-tools/validate-project/cases/access-transformer.d.ts +6 -0
  41. package/dist/entry-tools/validate-project/cases/access-transformer.js +106 -0
  42. package/dist/entry-tools/validate-project/cases/access-widener.d.ts +6 -0
  43. package/dist/entry-tools/validate-project/cases/access-widener.js +86 -0
  44. package/dist/entry-tools/validate-project/cases/mixin.d.ts +6 -0
  45. package/dist/entry-tools/validate-project/cases/mixin.js +90 -0
  46. package/dist/entry-tools/validate-project/cases/project-summary.d.ts +97 -0
  47. package/dist/entry-tools/validate-project/cases/project-summary.js +346 -0
  48. package/dist/entry-tools/validate-project/internal.d.ts +135 -0
  49. package/dist/entry-tools/validate-project/internal.js +287 -0
  50. package/dist/entry-tools/validate-project-service.d.ts +63 -47
  51. package/dist/entry-tools/validate-project-service.js +12 -562
  52. package/dist/entry-tools/verify-mixin-target-service.d.ts +133 -0
  53. package/dist/entry-tools/verify-mixin-target-service.js +323 -0
  54. package/dist/error-mapping.d.ts +40 -0
  55. package/dist/error-mapping.js +139 -0
  56. package/dist/errors.d.ts +6 -0
  57. package/dist/errors.js +6 -0
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.js +142 -1352
  60. package/dist/mapping/internal-types.d.ts +54 -0
  61. package/dist/mapping/internal-types.js +14 -0
  62. package/dist/mapping/loaders/mojang.d.ts +2 -0
  63. package/dist/mapping/loaders/mojang.js +64 -0
  64. package/dist/mapping/loaders/tiny-loom.d.ts +2 -0
  65. package/dist/mapping/loaders/tiny-loom.js +73 -0
  66. package/dist/mapping/loaders/tiny-maven.d.ts +2 -0
  67. package/dist/mapping/loaders/tiny-maven.js +104 -0
  68. package/dist/mapping/loaders/types.d.ts +14 -0
  69. package/dist/mapping/loaders/types.js +2 -0
  70. package/dist/mapping/lookup.d.ts +52 -0
  71. package/dist/mapping/lookup.js +496 -0
  72. package/dist/mapping/parsers/normalize.d.ts +10 -0
  73. package/dist/mapping/parsers/normalize.js +52 -0
  74. package/dist/mapping/parsers/proguard.d.ts +20 -0
  75. package/dist/mapping/parsers/proguard.js +138 -0
  76. package/dist/mapping/parsers/symbol-records.d.ts +27 -0
  77. package/dist/mapping/parsers/symbol-records.js +216 -0
  78. package/dist/mapping/parsers/tiny.d.ts +9 -0
  79. package/dist/mapping/parsers/tiny.js +96 -0
  80. package/dist/mapping/types.d.ts +147 -0
  81. package/dist/mapping/types.js +2 -0
  82. package/dist/mapping-pipeline-service.js +3 -2
  83. package/dist/mapping-service.d.ts +3 -144
  84. package/dist/mapping-service.js +19 -1201
  85. package/dist/mixin/access-validators.d.ts +9 -0
  86. package/dist/mixin/access-validators.js +257 -0
  87. package/dist/mixin/annotation-validators.d.ts +5 -0
  88. package/dist/mixin/annotation-validators.js +162 -0
  89. package/dist/mixin/helpers.d.ts +28 -0
  90. package/dist/mixin/helpers.js +315 -0
  91. package/dist/mixin/parsed-validator.d.ts +8 -0
  92. package/dist/mixin/parsed-validator.js +337 -0
  93. package/dist/mixin/types.d.ts +208 -0
  94. package/dist/mixin/types.js +28 -0
  95. package/dist/mixin-validator.d.ts +9 -201
  96. package/dist/mixin-validator.js +8 -1020
  97. package/dist/source/access-validate.d.ts +4 -0
  98. package/dist/source/access-validate.js +254 -0
  99. package/dist/source/artifact-resolver.d.ts +110 -0
  100. package/dist/source/artifact-resolver.js +1174 -0
  101. package/dist/source/cache-metrics.d.ts +26 -0
  102. package/dist/source/cache-metrics.js +172 -0
  103. package/dist/source/class-source/members-builder.d.ts +34 -0
  104. package/dist/source/class-source/members-builder.js +46 -0
  105. package/dist/source/class-source/snippet-builder.d.ts +19 -0
  106. package/dist/source/class-source/snippet-builder.js +46 -0
  107. package/dist/source/class-source-helpers.d.ts +34 -0
  108. package/dist/source/class-source-helpers.js +140 -0
  109. package/dist/source/class-source.d.ts +42 -0
  110. package/dist/source/class-source.js +883 -0
  111. package/dist/source/descriptor-utils.d.ts +6 -0
  112. package/dist/source/descriptor-utils.js +37 -0
  113. package/dist/source/file-access.d.ts +4 -0
  114. package/dist/source/file-access.js +102 -0
  115. package/dist/source/indexer.d.ts +82 -0
  116. package/dist/source/indexer.js +505 -0
  117. package/dist/source/lifecycle/diff-utils.d.ts +9 -0
  118. package/dist/source/lifecycle/diff-utils.js +107 -0
  119. package/dist/source/lifecycle/diff.d.ts +2 -0
  120. package/dist/source/lifecycle/diff.js +265 -0
  121. package/dist/source/lifecycle/mapping-helpers.d.ts +22 -0
  122. package/dist/source/lifecycle/mapping-helpers.js +327 -0
  123. package/dist/source/lifecycle/runtime-check.d.ts +2 -0
  124. package/dist/source/lifecycle/runtime-check.js +142 -0
  125. package/dist/source/lifecycle/trace.d.ts +2 -0
  126. package/dist/source/lifecycle/trace.js +231 -0
  127. package/dist/source/lifecycle.d.ts +4 -0
  128. package/dist/source/lifecycle.js +5 -0
  129. package/dist/source/search.d.ts +51 -0
  130. package/dist/source/search.js +676 -0
  131. package/dist/source/shared-utils.d.ts +6 -0
  132. package/dist/source/shared-utils.js +55 -0
  133. package/dist/source/state.d.ts +21 -0
  134. package/dist/source/state.js +19 -0
  135. package/dist/source/symbol-resolver.d.ts +3 -0
  136. package/dist/source/symbol-resolver.js +212 -0
  137. package/dist/source/validate-mixin/pipeline/mapping-health.d.ts +3 -0
  138. package/dist/source/validate-mixin/pipeline/mapping-health.js +41 -0
  139. package/dist/source/validate-mixin/pipeline/parse.d.ts +2 -0
  140. package/dist/source/validate-mixin/pipeline/parse.js +10 -0
  141. package/dist/source/validate-mixin/pipeline/resolve.d.ts +3 -0
  142. package/dist/source/validate-mixin/pipeline/resolve.js +78 -0
  143. package/dist/source/validate-mixin/pipeline/target-lookup.d.ts +6 -0
  144. package/dist/source/validate-mixin/pipeline/target-lookup.js +260 -0
  145. package/dist/source/validate-mixin/pipeline-context.d.ts +72 -0
  146. package/dist/source/validate-mixin/pipeline-context.js +93 -0
  147. package/dist/source/validate-mixin.d.ts +22 -0
  148. package/dist/source/validate-mixin.js +799 -0
  149. package/dist/source/workspace-target.d.ts +18 -0
  150. package/dist/source/workspace-target.js +305 -0
  151. package/dist/source-service.d.ts +147 -170
  152. package/dist/source-service.js +67 -6116
  153. package/dist/stage-emitter.d.ts +13 -0
  154. package/dist/stage-emitter.js +30 -0
  155. package/dist/stdio-supervisor.d.ts +61 -0
  156. package/dist/stdio-supervisor.js +326 -9
  157. package/dist/tool-contract-manifest.d.ts +1 -1
  158. package/dist/tool-contract-manifest.js +23 -6
  159. package/dist/tool-guidance.d.ts +82 -0
  160. package/dist/tool-guidance.js +734 -0
  161. package/dist/tool-schema-registry.d.ts +16 -0
  162. package/dist/tool-schema-registry.js +37 -0
  163. package/dist/tool-schemas.d.ts +3518 -0
  164. package/dist/tool-schemas.js +813 -0
  165. package/dist/types.d.ts +36 -0
  166. package/dist/version-service.js +7 -6
  167. package/dist/workspace-context-cache.d.ts +32 -0
  168. package/dist/workspace-context-cache.js +66 -0
  169. package/dist/workspace-mapping-service.d.ts +16 -0
  170. package/dist/workspace-mapping-service.js +173 -1
  171. package/docs/README-ja.md +414 -0
  172. package/docs/examples.md +483 -0
  173. package/docs/tool-reference.md +459 -0
  174. package/package.json +3 -2
@@ -0,0 +1,448 @@
1
+ import { z } from "zod";
2
+ import { buildSuggestedCall } from "../../build-suggested-call.js";
3
+ import { createError, ERROR_CODES, isAppError } from "../../errors.js";
4
+ export const TASKS = [
5
+ "auto",
6
+ "versions",
7
+ "artifact",
8
+ "class-overview",
9
+ "class-source",
10
+ "class-members",
11
+ "search",
12
+ "file",
13
+ "list-files"
14
+ ];
15
+ export const SUBJECT_KINDS = ["version", "artifact", "class", "file", "search", "workspace"];
16
+ const nonEmptyString = z.string().trim().min(1);
17
+ const resolveTargetSchema = z.object({
18
+ kind: z.enum(["version", "jar", "coordinate"]),
19
+ value: nonEmptyString
20
+ });
21
+ export const artifactRefSchema = z.discriminatedUnion("type", [
22
+ z.object({
23
+ type: z.literal("resolved-id"),
24
+ artifactId: nonEmptyString
25
+ }),
26
+ z.object({
27
+ type: z.literal("resolve-target"),
28
+ target: resolveTargetSchema
29
+ })
30
+ ]);
31
+ export const workspaceFocusSchema = z.discriminatedUnion("kind", [
32
+ z.object({
33
+ kind: z.literal("class"),
34
+ className: nonEmptyString,
35
+ artifact: artifactRefSchema.optional()
36
+ }),
37
+ z.object({
38
+ kind: z.literal("file"),
39
+ filePath: nonEmptyString,
40
+ artifact: artifactRefSchema.optional()
41
+ }),
42
+ z.object({
43
+ kind: z.literal("search"),
44
+ query: nonEmptyString,
45
+ artifact: artifactRefSchema.optional(),
46
+ intent: z.enum(["symbol", "text", "path"]).optional(),
47
+ match: z.enum(["exact", "prefix", "contains", "regex"]).optional(),
48
+ symbolKind: z.enum(["class", "interface", "enum", "record", "method", "field"]).optional(),
49
+ packagePrefix: nonEmptyString.optional(),
50
+ fileGlob: nonEmptyString.optional(),
51
+ queryMode: z.enum(["auto", "token", "literal"]).default("auto")
52
+ })
53
+ ]);
54
+ export const subjectSchema = z.discriminatedUnion("kind", [
55
+ z.object({
56
+ kind: z.literal("version"),
57
+ version: nonEmptyString,
58
+ mapping: z.enum(["obfuscated", "mojang", "intermediary", "yarn"]).optional(),
59
+ scope: z.enum(["vanilla", "merged", "loader"]).optional(),
60
+ projectPath: nonEmptyString.optional(),
61
+ preferProjectVersion: z.boolean().optional(),
62
+ strictVersion: z.boolean().optional()
63
+ }),
64
+ z.object({
65
+ kind: z.literal("artifact"),
66
+ artifact: artifactRefSchema,
67
+ mapping: z.enum(["obfuscated", "mojang", "intermediary", "yarn"]).optional(),
68
+ scope: z.enum(["vanilla", "merged", "loader"]).optional(),
69
+ projectPath: nonEmptyString.optional(),
70
+ preferProjectVersion: z.boolean().optional(),
71
+ strictVersion: z.boolean().optional()
72
+ }),
73
+ z.object({
74
+ kind: z.literal("class"),
75
+ className: nonEmptyString,
76
+ artifact: artifactRefSchema.optional(),
77
+ mapping: z.enum(["obfuscated", "mojang", "intermediary", "yarn"]).optional(),
78
+ scope: z.enum(["vanilla", "merged", "loader"]).optional(),
79
+ projectPath: nonEmptyString.optional(),
80
+ preferProjectVersion: z.boolean().optional(),
81
+ strictVersion: z.boolean().optional()
82
+ }),
83
+ z.object({
84
+ kind: z.literal("file"),
85
+ filePath: nonEmptyString,
86
+ artifact: artifactRefSchema.optional()
87
+ }),
88
+ z.object({
89
+ kind: z.literal("search"),
90
+ query: nonEmptyString,
91
+ artifact: artifactRefSchema.optional(),
92
+ intent: z.enum(["symbol", "text", "path"]).optional(),
93
+ match: z.enum(["exact", "prefix", "contains", "regex"]).optional(),
94
+ symbolKind: z.enum(["class", "interface", "enum", "record", "method", "field"]).optional(),
95
+ packagePrefix: nonEmptyString.optional(),
96
+ fileGlob: nonEmptyString.optional(),
97
+ queryMode: z.enum(["auto", "token", "literal"]).default("auto")
98
+ }),
99
+ z.object({
100
+ kind: z.literal("workspace"),
101
+ projectPath: nonEmptyString,
102
+ mapping: z.enum(["obfuscated", "mojang", "intermediary", "yarn"]).optional(),
103
+ scope: z.enum(["vanilla", "merged", "loader"]).optional(),
104
+ preferProjectVersion: z.boolean().optional(),
105
+ strictVersion: z.boolean().optional(),
106
+ focus: workspaceFocusSchema.optional()
107
+ })
108
+ ]);
109
+ export function hasPartialVanillaCoverage(artifact) {
110
+ return artifact?.qualityFlags.includes("partial-source-no-net-minecraft") === true
111
+ || artifact?.artifactContents.sourceCoverage === "partial";
112
+ }
113
+ export function looksLikeClassQuery(query) {
114
+ const trimmed = query.trim();
115
+ if (!/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(trimmed)) {
116
+ return false;
117
+ }
118
+ const simpleName = trimmed.split(".").at(-1) ?? trimmed;
119
+ return /^[A-Z_$]/.test(simpleName) || /^class_\d+(?:\$class_\d+)*$/.test(simpleName);
120
+ }
121
+ export function classNameToFilePath(className) {
122
+ const topLevelClassName = className.split("$")[0] ?? className;
123
+ return `${topLevelClassName.replace(/\./g, "/")}.java`;
124
+ }
125
+ function isVanillaNamespacePath(filePath) {
126
+ return filePath.startsWith("net/minecraft/") || filePath.startsWith("com/mojang/");
127
+ }
128
+ export function hitTargetsVanillaNamespace(hit) {
129
+ if (isVanillaNamespacePath(hit.filePath)) {
130
+ return true;
131
+ }
132
+ const qualifiedName = hit.symbol?.qualifiedName;
133
+ return qualifiedName?.startsWith("net.minecraft.") === true || qualifiedName?.startsWith("com.mojang.") === true;
134
+ }
135
+ // Helpers live as free functions so InspectMinecraftService keeps its baseline
136
+ // declaration surface (constructor + execute only).
137
+ export function requireWorkspaceClassFocus(subject) {
138
+ if (subject.kind !== "workspace" || subject.focus?.kind !== "class") {
139
+ throw createError({
140
+ code: ERROR_CODES.INVALID_INPUT,
141
+ message: "Workspace focus must be kind=class for this task."
142
+ });
143
+ }
144
+ return subject.focus;
145
+ }
146
+ export function requireWorkspaceSearchFocus(subject) {
147
+ if (subject.kind !== "workspace" || subject.focus?.kind !== "search") {
148
+ throw createError({
149
+ code: ERROR_CODES.INVALID_INPUT,
150
+ message: "Workspace focus must be kind=search for this task."
151
+ });
152
+ }
153
+ return subject.focus;
154
+ }
155
+ export function requireWorkspaceFileFocus(subject) {
156
+ if (subject.kind !== "workspace" || subject.focus?.kind !== "file") {
157
+ throw createError({
158
+ code: ERROR_CODES.INVALID_INPUT,
159
+ message: "Workspace focus must be kind=file for this task."
160
+ });
161
+ }
162
+ return subject.focus;
163
+ }
164
+ export function buildClassSubject(subject) {
165
+ if (subject.kind === "class") {
166
+ return subject;
167
+ }
168
+ const workspaceFocus = requireWorkspaceClassFocus(subject);
169
+ return {
170
+ kind: "class",
171
+ className: workspaceFocus.className,
172
+ artifact: workspaceFocus.artifact,
173
+ projectPath: subject.projectPath,
174
+ mapping: subject.mapping,
175
+ scope: subject.scope,
176
+ preferProjectVersion: subject.preferProjectVersion,
177
+ strictVersion: subject.strictVersion
178
+ };
179
+ }
180
+ export async function resolveClassArtifactReference(deps, subject, classSubject, task) {
181
+ if (subject.kind === "workspace") {
182
+ return resolveWorkspaceArtifactReference(deps, subject, classSubject.artifact);
183
+ }
184
+ return resolveArtifactReference(deps, classSubject, task);
185
+ }
186
+ export async function resolveWorkspaceArtifactReference(deps, subject, artifactRef) {
187
+ if (!artifactRef) {
188
+ return resolveArtifactReference(deps, subject);
189
+ }
190
+ if (artifactRef.type === "resolved-id") {
191
+ return {
192
+ artifactId: artifactRef.artifactId,
193
+ warnings: []
194
+ };
195
+ }
196
+ const artifact = await deps.resolveArtifact({
197
+ target: artifactRef.target,
198
+ mapping: subject.mapping,
199
+ scope: subject.scope,
200
+ projectPath: subject.projectPath,
201
+ preferProjectVersion: subject.preferProjectVersion,
202
+ strictVersion: subject.strictVersion
203
+ });
204
+ return {
205
+ artifactId: artifact.artifactId,
206
+ artifact,
207
+ warnings: [...artifact.warnings]
208
+ };
209
+ }
210
+ export function resolveTask(task, subject) {
211
+ if (task && task !== "auto") {
212
+ return task;
213
+ }
214
+ if (!subject) {
215
+ return "versions";
216
+ }
217
+ switch (subject.kind) {
218
+ case "version":
219
+ case "artifact":
220
+ return "artifact";
221
+ case "workspace":
222
+ switch (subject.focus?.kind) {
223
+ case "class":
224
+ return "class-overview";
225
+ case "search":
226
+ return "search";
227
+ case "file":
228
+ return "file";
229
+ default:
230
+ return "artifact";
231
+ }
232
+ case "class":
233
+ return "class-overview";
234
+ case "file":
235
+ return "file";
236
+ case "search":
237
+ return "search";
238
+ }
239
+ }
240
+ export function summarizeRequestedSubject(subject) {
241
+ if (subject.kind === "search") {
242
+ if (subject.queryMode !== "auto") {
243
+ return subject;
244
+ }
245
+ const { queryMode: _queryMode, ...requestedSubject } = subject;
246
+ return requestedSubject;
247
+ }
248
+ if (subject.kind === "workspace" && subject.focus?.kind === "search") {
249
+ if (subject.focus.queryMode !== "auto") {
250
+ return subject;
251
+ }
252
+ const { queryMode: _queryMode, ...requestedFocus } = subject.focus;
253
+ return {
254
+ ...subject,
255
+ focus: requestedFocus
256
+ };
257
+ }
258
+ return subject;
259
+ }
260
+ async function exampleVersionForSubject(deps, subject) {
261
+ if ("projectPath" in subject && typeof subject.projectPath === "string") {
262
+ const detectedVersion = await deps.detectProjectMinecraftVersion(subject.projectPath);
263
+ if (detectedVersion) {
264
+ return detectedVersion;
265
+ }
266
+ }
267
+ return "<version>";
268
+ }
269
+ async function buildArtifactContextSuggestedCall(deps, task, subject) {
270
+ return buildSuggestedCall({
271
+ tool: "inspect-minecraft",
272
+ params: {
273
+ task,
274
+ subject: {
275
+ ...subject,
276
+ artifact: {
277
+ type: "resolve-target",
278
+ target: {
279
+ kind: "version",
280
+ value: await exampleVersionForSubject(deps, subject)
281
+ }
282
+ }
283
+ }
284
+ }
285
+ });
286
+ }
287
+ export function taskForSubject(subject) {
288
+ return resolveTask(undefined, subject);
289
+ }
290
+ export function invalidTaskSubjectError(task, subject) {
291
+ if (task === "class-source" && subject.kind === "version") {
292
+ throw createError({
293
+ code: ERROR_CODES.INVALID_INPUT,
294
+ message: "class-source requires a class subject; version subjects resolve artifacts, not class names.",
295
+ details: {
296
+ nextAction: "Retry class-source with subject.kind=class and attach artifact context, or use task=artifact to inspect the version first.",
297
+ ...buildSuggestedCall({
298
+ tool: "inspect-minecraft",
299
+ params: {
300
+ task: "class-source",
301
+ subject: {
302
+ kind: "class",
303
+ className: "net.minecraft.world.item.Item",
304
+ artifact: {
305
+ type: "resolve-target",
306
+ target: {
307
+ kind: "version",
308
+ value: subject.version
309
+ }
310
+ }
311
+ }
312
+ }
313
+ })
314
+ }
315
+ });
316
+ }
317
+ const suggestedTask = taskForSubject(subject);
318
+ throw createError({
319
+ code: ERROR_CODES.INVALID_INPUT,
320
+ message: `${task} is not compatible with subject.kind="${subject.kind}".`,
321
+ details: {
322
+ nextAction: suggestedTask === "artifact"
323
+ ? `Retry with task=artifact for this ${subject.kind} subject, or reshape the subject so it supplies the input that ${task} needs.`
324
+ : `Retry with task=${suggestedTask} for this subject, or reshape the subject so it supplies the input that ${task} needs.`,
325
+ ...buildSuggestedCall({
326
+ tool: "inspect-minecraft",
327
+ params: {
328
+ task: suggestedTask,
329
+ subject
330
+ }
331
+ })
332
+ }
333
+ });
334
+ }
335
+ export async function resolveBinaryBackedClass(deps, className, input) {
336
+ if (!deps.checkSymbolExists || !input.version) {
337
+ return undefined;
338
+ }
339
+ let lookup;
340
+ try {
341
+ lookup = await deps.checkSymbolExists({
342
+ version: input.version,
343
+ kind: "class",
344
+ name: className,
345
+ sourceMapping: input.mapping ?? "obfuscated",
346
+ nameMode: className.includes(".") ? "fqcn" : "auto",
347
+ maxCandidates: 10
348
+ });
349
+ }
350
+ catch (caughtError) {
351
+ if (isAppError(caughtError)) {
352
+ return undefined;
353
+ }
354
+ throw caughtError;
355
+ }
356
+ const resolvedClassName = lookup.resolvedSymbol?.name;
357
+ if (!resolvedClassName) {
358
+ return undefined;
359
+ }
360
+ return {
361
+ className: resolvedClassName,
362
+ warnings: lookup.warnings
363
+ };
364
+ }
365
+ export async function resolveArtifactReference(deps, subject, task) {
366
+ if (subject.kind === "artifact") {
367
+ return resolveArtifactRef(deps, subject.artifact, subject);
368
+ }
369
+ if (subject.kind === "class" || subject.kind === "file" || subject.kind === "search") {
370
+ if (!subject.artifact) {
371
+ const suggestedTask = task
372
+ ?? (subject.kind === "class"
373
+ ? "class-overview"
374
+ : subject.kind === "search"
375
+ ? "search"
376
+ : "file");
377
+ throw createError({
378
+ code: ERROR_CODES.INVALID_INPUT,
379
+ message: `${subject.kind} subject requires artifact context.`,
380
+ details: {
381
+ nextAction: "Add subject.artifact or use subject.kind=workspace so inspect-minecraft can resolve the artifact first.",
382
+ ...(await buildArtifactContextSuggestedCall(deps, suggestedTask, subject))
383
+ }
384
+ });
385
+ }
386
+ return resolveArtifactRef(deps, subject.artifact, subject);
387
+ }
388
+ if (subject.kind === "version") {
389
+ const artifact = await deps.resolveArtifact({
390
+ target: { kind: "version", value: subject.version },
391
+ mapping: subject.mapping,
392
+ scope: subject.scope,
393
+ projectPath: subject.projectPath,
394
+ preferProjectVersion: subject.preferProjectVersion,
395
+ strictVersion: subject.strictVersion
396
+ });
397
+ return {
398
+ artifactId: artifact.artifactId,
399
+ artifact,
400
+ version: subject.version,
401
+ warnings: [...artifact.warnings]
402
+ };
403
+ }
404
+ const version = await deps.detectProjectMinecraftVersion(subject.projectPath);
405
+ if (!version) {
406
+ return {
407
+ artifactId: "",
408
+ version: undefined,
409
+ warnings: [`Could not infer Minecraft version from ${subject.projectPath}.`]
410
+ };
411
+ }
412
+ const artifact = await deps.resolveArtifact({
413
+ target: { kind: "version", value: version },
414
+ mapping: subject.mapping,
415
+ scope: subject.scope,
416
+ projectPath: subject.projectPath,
417
+ preferProjectVersion: subject.preferProjectVersion ?? true,
418
+ strictVersion: subject.strictVersion
419
+ });
420
+ return {
421
+ artifactId: artifact.artifactId,
422
+ artifact,
423
+ version,
424
+ warnings: [...artifact.warnings]
425
+ };
426
+ }
427
+ async function resolveArtifactRef(deps, ref, subject) {
428
+ if (ref.type === "resolved-id") {
429
+ return {
430
+ artifactId: ref.artifactId,
431
+ warnings: []
432
+ };
433
+ }
434
+ const artifact = await deps.resolveArtifact({
435
+ target: ref.target,
436
+ mapping: "mapping" in subject ? subject.mapping : undefined,
437
+ scope: "scope" in subject ? subject.scope : undefined,
438
+ projectPath: "projectPath" in subject ? subject.projectPath : undefined,
439
+ preferProjectVersion: "preferProjectVersion" in subject ? subject.preferProjectVersion : undefined,
440
+ strictVersion: "strictVersion" in subject ? subject.strictVersion : undefined
441
+ });
442
+ return {
443
+ artifactId: artifact.artifactId,
444
+ artifact,
445
+ warnings: [...artifact.warnings]
446
+ };
447
+ }
448
+ //# sourceMappingURL=internal.js.map