@adhisang/minecraft-modding-mcp 4.0.0 → 4.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.
- package/CHANGELOG.md +61 -0
- package/README.md +40 -23
- package/dist/build-suggested-call.d.ts +29 -0
- package/dist/build-suggested-call.js +58 -0
- package/dist/cache-registry.d.ts +3 -1
- package/dist/cache-registry.js +50 -6
- package/dist/entry-tools/analyze-symbol-service.d.ts +16 -16
- package/dist/entry-tools/batch-class-members-service.d.ts +34 -0
- package/dist/entry-tools/batch-class-members-service.js +97 -0
- package/dist/entry-tools/batch-class-source-service.d.ts +37 -0
- package/dist/entry-tools/batch-class-source-service.js +100 -0
- package/dist/entry-tools/batch-mappings-service.d.ts +36 -0
- package/dist/entry-tools/batch-mappings-service.js +66 -0
- package/dist/entry-tools/batch-runner.d.ts +72 -0
- package/dist/entry-tools/batch-runner.js +90 -0
- package/dist/entry-tools/batch-symbol-exists-service.d.ts +46 -0
- package/dist/entry-tools/batch-symbol-exists-service.js +113 -0
- package/dist/entry-tools/compare-minecraft-service.d.ts +6 -6
- package/dist/entry-tools/inspect-minecraft/handlers/artifact.d.ts +5 -0
- package/dist/entry-tools/inspect-minecraft/handlers/artifact.js +83 -0
- package/dist/entry-tools/inspect-minecraft/handlers/class-members.d.ts +6 -0
- package/dist/entry-tools/inspect-minecraft/handlers/class-members.js +80 -0
- package/dist/entry-tools/inspect-minecraft/handlers/class-overview.d.ts +5 -0
- package/dist/entry-tools/inspect-minecraft/handlers/class-overview.js +248 -0
- package/dist/entry-tools/inspect-minecraft/handlers/class-source.d.ts +5 -0
- package/dist/entry-tools/inspect-minecraft/handlers/class-source.js +60 -0
- package/dist/entry-tools/inspect-minecraft/handlers/file.d.ts +5 -0
- package/dist/entry-tools/inspect-minecraft/handlers/file.js +54 -0
- package/dist/entry-tools/inspect-minecraft/handlers/list-files.d.ts +5 -0
- package/dist/entry-tools/inspect-minecraft/handlers/list-files.js +100 -0
- package/dist/entry-tools/inspect-minecraft/handlers/search.d.ts +5 -0
- package/dist/entry-tools/inspect-minecraft/handlers/search.js +155 -0
- package/dist/entry-tools/inspect-minecraft/handlers/versions.d.ts +6 -0
- package/dist/entry-tools/inspect-minecraft/handlers/versions.js +49 -0
- package/dist/entry-tools/inspect-minecraft/internal.d.ts +1042 -0
- package/dist/entry-tools/inspect-minecraft/internal.js +448 -0
- package/dist/entry-tools/inspect-minecraft-service.d.ts +193 -308
- package/dist/entry-tools/inspect-minecraft-service.js +20 -1244
- package/dist/entry-tools/manage-cache-service.d.ts +16 -16
- package/dist/entry-tools/validate-project/cases/access-transformer.d.ts +6 -0
- package/dist/entry-tools/validate-project/cases/access-transformer.js +106 -0
- package/dist/entry-tools/validate-project/cases/access-widener.d.ts +6 -0
- package/dist/entry-tools/validate-project/cases/access-widener.js +86 -0
- package/dist/entry-tools/validate-project/cases/mixin.d.ts +6 -0
- package/dist/entry-tools/validate-project/cases/mixin.js +90 -0
- package/dist/entry-tools/validate-project/cases/project-summary.d.ts +102 -0
- package/dist/entry-tools/validate-project/cases/project-summary.js +415 -0
- package/dist/entry-tools/validate-project/internal.d.ts +142 -0
- package/dist/entry-tools/validate-project/internal.js +303 -0
- package/dist/entry-tools/validate-project-service.d.ts +67 -47
- package/dist/entry-tools/validate-project-service.js +13 -563
- package/dist/entry-tools/verify-mixin-target-service.d.ts +133 -0
- package/dist/entry-tools/verify-mixin-target-service.js +323 -0
- package/dist/error-mapping.d.ts +40 -0
- package/dist/error-mapping.js +139 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +147 -1354
- package/dist/mapping/internal-types.d.ts +54 -0
- package/dist/mapping/internal-types.js +14 -0
- package/dist/mapping/loaders/mojang.d.ts +2 -0
- package/dist/mapping/loaders/mojang.js +64 -0
- package/dist/mapping/loaders/tiny-loom.d.ts +2 -0
- package/dist/mapping/loaders/tiny-loom.js +73 -0
- package/dist/mapping/loaders/tiny-maven.d.ts +2 -0
- package/dist/mapping/loaders/tiny-maven.js +104 -0
- package/dist/mapping/loaders/types.d.ts +14 -0
- package/dist/mapping/loaders/types.js +2 -0
- package/dist/mapping/lookup.d.ts +52 -0
- package/dist/mapping/lookup.js +496 -0
- package/dist/mapping/parsers/normalize.d.ts +10 -0
- package/dist/mapping/parsers/normalize.js +52 -0
- package/dist/mapping/parsers/proguard.d.ts +20 -0
- package/dist/mapping/parsers/proguard.js +138 -0
- package/dist/mapping/parsers/symbol-records.d.ts +27 -0
- package/dist/mapping/parsers/symbol-records.js +216 -0
- package/dist/mapping/parsers/tiny.d.ts +9 -0
- package/dist/mapping/parsers/tiny.js +96 -0
- package/dist/mapping/types.d.ts +147 -0
- package/dist/mapping/types.js +2 -0
- package/dist/mapping-pipeline-service.js +3 -2
- package/dist/mapping-service.d.ts +8 -145
- package/dist/mapping-service.js +30 -1207
- package/dist/mixin/access-validators.d.ts +9 -0
- package/dist/mixin/access-validators.js +257 -0
- package/dist/mixin/annotation-validators.d.ts +5 -0
- package/dist/mixin/annotation-validators.js +162 -0
- package/dist/mixin/helpers.d.ts +28 -0
- package/dist/mixin/helpers.js +315 -0
- package/dist/mixin/parsed-validator.d.ts +8 -0
- package/dist/mixin/parsed-validator.js +337 -0
- package/dist/mixin/types.d.ts +208 -0
- package/dist/mixin/types.js +28 -0
- package/dist/mixin-validator.d.ts +9 -201
- package/dist/mixin-validator.js +8 -1020
- package/dist/source/access-validate.d.ts +4 -0
- package/dist/source/access-validate.js +254 -0
- package/dist/source/artifact-resolver.d.ts +111 -0
- package/dist/source/artifact-resolver.js +1271 -0
- package/dist/source/cache-metrics.d.ts +26 -0
- package/dist/source/cache-metrics.js +172 -0
- package/dist/source/class-source/members-builder.d.ts +34 -0
- package/dist/source/class-source/members-builder.js +46 -0
- package/dist/source/class-source/snippet-builder.d.ts +19 -0
- package/dist/source/class-source/snippet-builder.js +46 -0
- package/dist/source/class-source-helpers.d.ts +34 -0
- package/dist/source/class-source-helpers.js +140 -0
- package/dist/source/class-source.d.ts +42 -0
- package/dist/source/class-source.js +883 -0
- package/dist/source/descriptor-utils.d.ts +6 -0
- package/dist/source/descriptor-utils.js +37 -0
- package/dist/source/file-access.d.ts +4 -0
- package/dist/source/file-access.js +102 -0
- package/dist/source/indexer.d.ts +82 -0
- package/dist/source/indexer.js +522 -0
- package/dist/source/lifecycle/diff-utils.d.ts +9 -0
- package/dist/source/lifecycle/diff-utils.js +107 -0
- package/dist/source/lifecycle/diff.d.ts +2 -0
- package/dist/source/lifecycle/diff.js +265 -0
- package/dist/source/lifecycle/mapping-helpers.d.ts +22 -0
- package/dist/source/lifecycle/mapping-helpers.js +327 -0
- package/dist/source/lifecycle/runtime-check.d.ts +2 -0
- package/dist/source/lifecycle/runtime-check.js +142 -0
- package/dist/source/lifecycle/trace.d.ts +2 -0
- package/dist/source/lifecycle/trace.js +231 -0
- package/dist/source/lifecycle.d.ts +4 -0
- package/dist/source/lifecycle.js +5 -0
- package/dist/source/search.d.ts +51 -0
- package/dist/source/search.js +676 -0
- package/dist/source/shared-utils.d.ts +6 -0
- package/dist/source/shared-utils.js +55 -0
- package/dist/source/state.d.ts +26 -0
- package/dist/source/state.js +24 -0
- package/dist/source/symbol-resolver.d.ts +3 -0
- package/dist/source/symbol-resolver.js +212 -0
- package/dist/source/validate-mixin/pipeline/mapping-health.d.ts +3 -0
- package/dist/source/validate-mixin/pipeline/mapping-health.js +41 -0
- package/dist/source/validate-mixin/pipeline/parse.d.ts +2 -0
- package/dist/source/validate-mixin/pipeline/parse.js +10 -0
- package/dist/source/validate-mixin/pipeline/resolve.d.ts +3 -0
- package/dist/source/validate-mixin/pipeline/resolve.js +78 -0
- package/dist/source/validate-mixin/pipeline/target-lookup.d.ts +6 -0
- package/dist/source/validate-mixin/pipeline/target-lookup.js +260 -0
- package/dist/source/validate-mixin/pipeline-context.d.ts +72 -0
- package/dist/source/validate-mixin/pipeline-context.js +93 -0
- package/dist/source/validate-mixin.d.ts +22 -0
- package/dist/source/validate-mixin.js +799 -0
- package/dist/source/workspace-target.d.ts +18 -0
- package/dist/source/workspace-target.js +305 -0
- package/dist/source-resolver.d.ts +1 -0
- package/dist/source-resolver.js +1 -1
- package/dist/source-service.d.ts +164 -170
- package/dist/source-service.js +70 -6116
- package/dist/stage-emitter.d.ts +13 -0
- package/dist/stage-emitter.js +30 -0
- package/dist/stdio-supervisor.d.ts +61 -0
- package/dist/stdio-supervisor.js +326 -9
- package/dist/tool-contract-manifest.d.ts +1 -1
- package/dist/tool-contract-manifest.js +23 -6
- package/dist/tool-guidance.d.ts +82 -0
- package/dist/tool-guidance.js +734 -0
- package/dist/tool-schema-registry.d.ts +16 -0
- package/dist/tool-schema-registry.js +37 -0
- package/dist/tool-schemas.d.ts +3518 -0
- package/dist/tool-schemas.js +813 -0
- package/dist/types.d.ts +36 -0
- package/dist/version-service.js +7 -6
- package/dist/workspace-context-cache.d.ts +32 -0
- package/dist/workspace-context-cache.js +66 -0
- package/dist/workspace-mapping-service.d.ts +16 -0
- package/dist/workspace-mapping-service.js +173 -1
- package/docs/README-ja.md +416 -0
- package/docs/examples.md +483 -0
- package/docs/tool-reference.md +462 -0
- package/package.json +17 -4
|
@@ -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
|