@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.
- package/CHANGELOG.md +72 -0
- package/README.md +52 -32
- 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 +59 -7
- package/dist/config.d.ts +10 -1
- package/dist/config.js +52 -1
- package/dist/entry-tools/analyze-symbol-service.d.ts +18 -18
- package/dist/entry-tools/analyze-symbol-service.js +13 -2
- 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 +213 -328
- package/dist/entry-tools/inspect-minecraft-service.js +20 -1238
- 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 +97 -0
- package/dist/entry-tools/validate-project/cases/project-summary.js +346 -0
- package/dist/entry-tools/validate-project/internal.d.ts +135 -0
- package/dist/entry-tools/validate-project/internal.js +287 -0
- package/dist/entry-tools/validate-project-service.d.ts +63 -47
- package/dist/entry-tools/validate-project-service.js +12 -482
- 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 +170 -1314
- package/dist/lru-list.d.ts +31 -0
- package/dist/lru-list.js +102 -0
- 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.d.ts +10 -1
- package/dist/mapping-pipeline-service.js +16 -3
- package/dist/mapping-service.d.ts +15 -144
- package/dist/mapping-service.js +179 -1119
- 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 -1005
- package/dist/observability.d.ts +18 -1
- package/dist/observability.js +44 -1
- package/dist/response-utils.d.ts +44 -10
- package/dist/response-utils.js +131 -17
- package/dist/source/access-validate.d.ts +4 -0
- package/dist/source/access-validate.js +254 -0
- package/dist/source/artifact-resolver.d.ts +110 -0
- package/dist/source/artifact-resolver.js +1174 -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 +505 -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 +21 -0
- package/dist/source/state.js +19 -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 +9 -1
- package/dist/source-resolver.js +14 -6
- package/dist/source-service.d.ts +178 -105
- package/dist/source-service.js +72 -5312
- 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/storage/artifacts-repo.d.ts +4 -1
- package/dist/storage/artifacts-repo.js +33 -5
- package/dist/storage/files-repo.d.ts +0 -2
- package/dist/storage/files-repo.js +0 -11
- package/dist/storage/migrations.d.ts +1 -1
- package/dist/storage/migrations.js +10 -2
- package/dist/storage/schema.d.ts +2 -0
- package/dist/storage/schema.js +25 -0
- 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 +39 -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 +414 -0
- package/docs/examples.md +483 -0
- package/docs/tool-reference.md +459 -0
- package/package.json +5 -2
|
@@ -0,0 +1,813 @@
|
|
|
1
|
+
import { isAbsolute as pathIsAbsolute, resolve as pathResolve } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const SOURCE_MAPPINGS = ["obfuscated", "mojang", "intermediary", "yarn"];
|
|
4
|
+
export const SOURCE_PRIORITIES = ["loom-first", "maven-first"];
|
|
5
|
+
export const TARGET_KINDS = ["version", "jar", "coordinate"];
|
|
6
|
+
export const SEARCH_INTENTS = ["symbol", "text", "path"];
|
|
7
|
+
export const SEARCH_MATCHES = ["exact", "prefix", "contains", "regex"];
|
|
8
|
+
export const SEARCH_SYMBOL_KINDS = ["class", "interface", "enum", "record", "method", "field"];
|
|
9
|
+
export const MEMBER_ACCESS = ["public", "all"];
|
|
10
|
+
export const WORKSPACE_SYMBOL_KINDS = ["class", "field", "method"];
|
|
11
|
+
export const CLASS_NAME_MODES = ["fqcn", "auto"];
|
|
12
|
+
export const SOURCE_MODES = ["metadata", "snippet", "full"];
|
|
13
|
+
export const ARTIFACT_SCOPES = ["vanilla", "merged", "loader"];
|
|
14
|
+
export const DECODE_COMPRESSIONS = ["none", "gzip", "auto"];
|
|
15
|
+
export const ENCODE_COMPRESSIONS = ["none", "gzip"];
|
|
16
|
+
export const nonEmptyString = z.string().trim().min(1);
|
|
17
|
+
export const optionalNonEmptyString = z.string().trim().min(1).optional();
|
|
18
|
+
export const optionalPositiveInt = z.number().int().positive().optional();
|
|
19
|
+
// Optional descriptor: "" and whitespace-only strings are normalized to undefined so that
|
|
20
|
+
// tools with signatureMode="name-only" can accept "caller omitted descriptor" inputs whether
|
|
21
|
+
// the caller passed an empty string or omitted the field entirely. Malformed descriptors are
|
|
22
|
+
// still rejected downstream by normalizeMethodDescriptor in mapping-service.
|
|
23
|
+
export const optionalDescriptorString = z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.transform((value) => {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
const trimmed = value.trim();
|
|
30
|
+
return trimmed.length === 0 ? undefined : trimmed;
|
|
31
|
+
});
|
|
32
|
+
export const sourceMappingSchema = z.enum(SOURCE_MAPPINGS);
|
|
33
|
+
export const mappingSourcePrioritySchema = z.enum(SOURCE_PRIORITIES);
|
|
34
|
+
export const targetKindSchema = z.enum(TARGET_KINDS);
|
|
35
|
+
export const searchIntentSchema = z.enum(SEARCH_INTENTS);
|
|
36
|
+
export const searchMatchSchema = z.enum(SEARCH_MATCHES);
|
|
37
|
+
export const searchSymbolKindSchema = z.enum(SEARCH_SYMBOL_KINDS);
|
|
38
|
+
export const memberAccessSchema = z.enum(MEMBER_ACCESS);
|
|
39
|
+
export const workspaceSymbolKindSchema = z.enum(WORKSPACE_SYMBOL_KINDS);
|
|
40
|
+
export const classNameModeSchema = z.enum(CLASS_NAME_MODES);
|
|
41
|
+
export const sourceModeSchema = z.enum(SOURCE_MODES);
|
|
42
|
+
export const artifactScopeSchema = z.enum(ARTIFACT_SCOPES);
|
|
43
|
+
export const decodeCompressionSchema = z.enum(DECODE_COMPRESSIONS);
|
|
44
|
+
export const encodeCompressionSchema = z.enum(ENCODE_COMPRESSIONS);
|
|
45
|
+
export const workspaceTargetSchema = z.object({
|
|
46
|
+
kind: z.literal("workspace"),
|
|
47
|
+
scope: artifactScopeSchema.optional(),
|
|
48
|
+
strict: z.boolean().optional()
|
|
49
|
+
});
|
|
50
|
+
export const dependencyTargetSchema = z.object({
|
|
51
|
+
kind: z.literal("dependency"),
|
|
52
|
+
group: nonEmptyString,
|
|
53
|
+
name: nonEmptyString,
|
|
54
|
+
version: z.string().trim().min(1).optional(),
|
|
55
|
+
versionFromProject: z.boolean().optional()
|
|
56
|
+
});
|
|
57
|
+
export const resolveArtifactTargetSchema = z.discriminatedUnion("kind", [
|
|
58
|
+
z.object({ kind: z.literal("version"), value: nonEmptyString }),
|
|
59
|
+
z.object({ kind: z.literal("jar"), value: nonEmptyString }),
|
|
60
|
+
z.object({ kind: z.literal("coordinate"), value: nonEmptyString }),
|
|
61
|
+
workspaceTargetSchema,
|
|
62
|
+
dependencyTargetSchema
|
|
63
|
+
]);
|
|
64
|
+
export const sourceLookupTargetSchema = z.union([
|
|
65
|
+
z.object({
|
|
66
|
+
type: z.literal("artifact"),
|
|
67
|
+
artifactId: nonEmptyString
|
|
68
|
+
}),
|
|
69
|
+
z.object({ type: z.literal("resolve"), kind: z.literal("version"), value: nonEmptyString }),
|
|
70
|
+
z.object({ type: z.literal("resolve"), kind: z.literal("jar"), value: nonEmptyString }),
|
|
71
|
+
z.object({ type: z.literal("resolve"), kind: z.literal("coordinate"), value: nonEmptyString }),
|
|
72
|
+
z.object({
|
|
73
|
+
type: z.literal("resolve"),
|
|
74
|
+
kind: z.literal("workspace"),
|
|
75
|
+
scope: artifactScopeSchema.optional(),
|
|
76
|
+
strict: z.boolean().optional()
|
|
77
|
+
}),
|
|
78
|
+
z.object({
|
|
79
|
+
type: z.literal("resolve"),
|
|
80
|
+
kind: z.literal("dependency"),
|
|
81
|
+
group: nonEmptyString,
|
|
82
|
+
name: nonEmptyString,
|
|
83
|
+
version: z.string().trim().min(1).optional(),
|
|
84
|
+
versionFromProject: z.boolean().optional()
|
|
85
|
+
})
|
|
86
|
+
]);
|
|
87
|
+
export const RESOLVE_ARTIFACT_TARGET_DESCRIPTION = 'Object with kind. Examples: {"kind":"version","value":"1.21.10"}, {"kind":"workspace"} (uses projectPath), or {"kind":"dependency","group":"dev.architectury","name":"architectury"}. Must be an object, not a string.';
|
|
88
|
+
export const SOURCE_LOOKUP_TARGET_DESCRIPTION = 'Object: {"type":"resolve","kind":"version","value":"1.21.10"} or {"type":"resolve","kind":"workspace"} or {"type":"resolve","kind":"dependency","group":"...","name":"..."} or {"type":"artifact","artifactId":"..."}. Must be an object, not a string.';
|
|
89
|
+
export const SOURCE_SCOPE_DESCRIPTION = "vanilla = Mojang client jar only; merged = source-oriented merged runtime discovery; loader = loader/runtime artifact discovery when the workspace exposes transformed runtime jars.";
|
|
90
|
+
export const listVersionsShape = {
|
|
91
|
+
includeSnapshots: z.boolean().default(false),
|
|
92
|
+
limit: optionalPositiveInt.default(20).describe("max 200")
|
|
93
|
+
};
|
|
94
|
+
export const listVersionsSchema = z.object(listVersionsShape);
|
|
95
|
+
export const resolveArtifactShape = {
|
|
96
|
+
target: resolveArtifactTargetSchema.describe(RESOLVE_ARTIFACT_TARGET_DESCRIPTION),
|
|
97
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn"),
|
|
98
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
99
|
+
allowDecompile: z.boolean().default(true),
|
|
100
|
+
projectPath: optionalNonEmptyString.describe("Optional workspace root path for Loom cache-assisted source resolution"),
|
|
101
|
+
scope: artifactScopeSchema.optional().describe(SOURCE_SCOPE_DESCRIPTION),
|
|
102
|
+
preferProjectVersion: z.boolean().optional().describe("When true, detect MC version from gradle.properties and override target.value"),
|
|
103
|
+
strictVersion: z.boolean().optional().describe("When true, reject version-approximated results instead of returning them. Default false."),
|
|
104
|
+
compact: z.boolean().default(true).describe("Return minimal fields (artifactId, origin, isDecompiled, version, requestedMapping, mappingApplied, qualityFlags). "
|
|
105
|
+
+ "Omit provenance, artifactContents, sampleEntries, adjacentSourceCandidates, binaryJarPath, coordinate, repoUrl, resolvedSourceJarPath. "
|
|
106
|
+
+ "Enabled by default; set to false for full output.")
|
|
107
|
+
};
|
|
108
|
+
export const resolveArtifactSchema = z.object(resolveArtifactShape);
|
|
109
|
+
export const getClassSourceShape = {
|
|
110
|
+
className: nonEmptyString,
|
|
111
|
+
mode: sourceModeSchema.default("metadata").describe("metadata = symbol outline only; snippet = source with default maxLines=200; full = entire source"),
|
|
112
|
+
target: sourceLookupTargetSchema.describe(SOURCE_LOOKUP_TARGET_DESCRIPTION),
|
|
113
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn"),
|
|
114
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
115
|
+
allowDecompile: z.boolean().default(true),
|
|
116
|
+
projectPath: optionalNonEmptyString.describe("Optional workspace root path for Loom cache-assisted source resolution"),
|
|
117
|
+
scope: artifactScopeSchema.optional().describe(SOURCE_SCOPE_DESCRIPTION),
|
|
118
|
+
preferProjectVersion: z.boolean().optional().describe("When true, detect MC version from gradle.properties and override target.value"),
|
|
119
|
+
strictVersion: z.boolean().optional().describe("When true, reject version-approximated results instead of returning them. Default false."),
|
|
120
|
+
startLine: optionalPositiveInt,
|
|
121
|
+
endLine: optionalPositiveInt,
|
|
122
|
+
maxLines: optionalPositiveInt,
|
|
123
|
+
maxChars: optionalPositiveInt.describe("Hard character limit on sourceText; truncates if exceeded"),
|
|
124
|
+
outputFile: optionalNonEmptyString.describe("Write source to this file path and return metadata-only response"),
|
|
125
|
+
compact: z.boolean().default(false).describe("When true, strip debug metadata (provenance, artifactContents, qualityFlags) and empty fields from the response. Default false.")
|
|
126
|
+
};
|
|
127
|
+
export const getClassSourceSchema = z
|
|
128
|
+
.object(getClassSourceShape)
|
|
129
|
+
.superRefine((value, ctx) => {
|
|
130
|
+
if (value.startLine !== undefined &&
|
|
131
|
+
value.endLine !== undefined &&
|
|
132
|
+
value.startLine > value.endLine) {
|
|
133
|
+
ctx.addIssue({
|
|
134
|
+
code: z.ZodIssueCode.custom,
|
|
135
|
+
message: "startLine must be less than or equal to endLine.",
|
|
136
|
+
path: ["startLine"]
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
export const getClassMembersShape = {
|
|
141
|
+
className: nonEmptyString,
|
|
142
|
+
target: sourceLookupTargetSchema.describe(SOURCE_LOOKUP_TARGET_DESCRIPTION),
|
|
143
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn (default obfuscated)"),
|
|
144
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
145
|
+
allowDecompile: z.boolean().default(true),
|
|
146
|
+
access: memberAccessSchema.default("public").describe("public | all"),
|
|
147
|
+
includeSynthetic: z.boolean().default(false),
|
|
148
|
+
includeInherited: z.boolean().default(false),
|
|
149
|
+
memberPattern: optionalNonEmptyString,
|
|
150
|
+
maxMembers: optionalPositiveInt.describe("default 500, max 5000"),
|
|
151
|
+
projectPath: optionalNonEmptyString,
|
|
152
|
+
scope: artifactScopeSchema.optional().describe(SOURCE_SCOPE_DESCRIPTION),
|
|
153
|
+
preferProjectVersion: z.boolean().optional().describe("When true, detect MC version from gradle.properties and override version"),
|
|
154
|
+
strictVersion: z.boolean().optional().describe("When true, reject version-approximated results instead of returning them. Default false."),
|
|
155
|
+
compact: z.boolean().default(false).describe("When true, strip debug metadata (provenance, artifactContents, qualityFlags, context) and empty fields from the response. Default false.")
|
|
156
|
+
};
|
|
157
|
+
export const getClassMembersSchema = z.object(getClassMembersShape);
|
|
158
|
+
export const verifyMixinTargetMemberSchema = z.discriminatedUnion("kind", [
|
|
159
|
+
z.object({
|
|
160
|
+
kind: z.literal("method"),
|
|
161
|
+
name: nonEmptyString,
|
|
162
|
+
descriptor: z.string().trim().min(1).optional()
|
|
163
|
+
}),
|
|
164
|
+
z.object({
|
|
165
|
+
kind: z.literal("field"),
|
|
166
|
+
name: nonEmptyString,
|
|
167
|
+
descriptor: z.string().trim().min(1).optional()
|
|
168
|
+
})
|
|
169
|
+
]);
|
|
170
|
+
export const verifyMixinTargetShape = {
|
|
171
|
+
owner: nonEmptyString.describe("Fully-qualified class name of the target owner (e.g. net.minecraft.world.entity.LivingEntity)."),
|
|
172
|
+
member: verifyMixinTargetMemberSchema.describe('Member to verify. Object with kind. Examples: {"kind":"method","name":"tick","descriptor":"()V"} or {"kind":"field","name":"airSupply"}.'),
|
|
173
|
+
mixinMemberName: optionalNonEmptyString.describe("Optional caller-authored mixin field/method name. Drives @Accessor (getXxx/setXxx) and @Invoker (invokeXxx/callXxx) advice when the target is private."),
|
|
174
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn"),
|
|
175
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
176
|
+
projectPath: optionalNonEmptyString.describe("Workspace root path for target.kind=workspace and Loom cache assistance."),
|
|
177
|
+
target: resolveArtifactTargetSchema.describe(RESOLVE_ARTIFACT_TARGET_DESCRIPTION),
|
|
178
|
+
scope: artifactScopeSchema.optional().describe(SOURCE_SCOPE_DESCRIPTION),
|
|
179
|
+
preferProjectVersion: z.boolean().optional().describe("When true, detect MC version from gradle.properties and override target.value"),
|
|
180
|
+
strictVersion: z.boolean().optional().describe("When true, reject version-approximated results instead of returning them. Default false.")
|
|
181
|
+
};
|
|
182
|
+
export const verifyMixinTargetSchema = z.object(verifyMixinTargetShape);
|
|
183
|
+
export const batchSymbolKindSchema = z.enum(["class", "field", "method"]);
|
|
184
|
+
export const batchClassSourceEntrySchema = z.object({
|
|
185
|
+
className: nonEmptyString,
|
|
186
|
+
mode: sourceModeSchema.optional(),
|
|
187
|
+
startLine: optionalPositiveInt,
|
|
188
|
+
endLine: optionalPositiveInt,
|
|
189
|
+
maxLines: optionalPositiveInt,
|
|
190
|
+
maxChars: optionalPositiveInt,
|
|
191
|
+
outputFile: optionalNonEmptyString
|
|
192
|
+
});
|
|
193
|
+
export const batchClassSourceShape = {
|
|
194
|
+
target: resolveArtifactTargetSchema.describe(RESOLVE_ARTIFACT_TARGET_DESCRIPTION),
|
|
195
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn"),
|
|
196
|
+
sourcePriority: mappingSourcePrioritySchema.optional(),
|
|
197
|
+
allowDecompile: z.boolean().optional(),
|
|
198
|
+
projectPath: optionalNonEmptyString,
|
|
199
|
+
scope: artifactScopeSchema.optional(),
|
|
200
|
+
preferProjectVersion: z.boolean().optional(),
|
|
201
|
+
strictVersion: z.boolean().optional(),
|
|
202
|
+
concurrency: z.number().int().min(1).max(8).optional().describe("1..8, default 4"),
|
|
203
|
+
failFast: z.boolean().optional().describe("default false"),
|
|
204
|
+
compact: z.boolean().optional().describe("default true"),
|
|
205
|
+
entries: z
|
|
206
|
+
.array(batchClassSourceEntrySchema)
|
|
207
|
+
.min(1)
|
|
208
|
+
.max(50)
|
|
209
|
+
.describe("1..50 entries; each shares the resolved target artifact.")
|
|
210
|
+
};
|
|
211
|
+
export const batchClassSourceSchema = z.object(batchClassSourceShape).superRefine((value, ctx) => {
|
|
212
|
+
// Per-entry `outputFile` is forwarded into the concurrently-dispatched
|
|
213
|
+
// `getClassSource` calls; two entries resolving to the same physical file
|
|
214
|
+
// would race on `writeFile`. Normalize via `path.resolve` so aliases like
|
|
215
|
+
// `out.java` / `./out.java` / `dir/../out.java` collide as expected,
|
|
216
|
+
// matching the writer's `isAbsolute(p) ? p : resolvePath(p)` rule.
|
|
217
|
+
const seen = new Map();
|
|
218
|
+
for (let i = 0; i < value.entries.length; i += 1) {
|
|
219
|
+
const entry = value.entries[i];
|
|
220
|
+
if (!entry || entry.outputFile === undefined)
|
|
221
|
+
continue;
|
|
222
|
+
const trimmed = entry.outputFile.trim();
|
|
223
|
+
if (trimmed.length === 0)
|
|
224
|
+
continue;
|
|
225
|
+
const canonical = pathIsAbsolute(trimmed) ? trimmed : pathResolve(trimmed);
|
|
226
|
+
const previous = seen.get(canonical);
|
|
227
|
+
if (previous !== undefined) {
|
|
228
|
+
ctx.addIssue({
|
|
229
|
+
code: z.ZodIssueCode.custom,
|
|
230
|
+
path: ["entries", i, "outputFile"],
|
|
231
|
+
message: `Duplicate outputFile (resolves to "${canonical}") with entry ${previous.index} (raw "${previous.raw}"); concurrent batch writes to the same file would race. Each entry's outputFile must resolve to a unique path.`
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
seen.set(canonical, { index: i, raw: trimmed });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
export const batchClassMembersEntrySchema = z.object({
|
|
240
|
+
className: nonEmptyString,
|
|
241
|
+
access: memberAccessSchema.optional(),
|
|
242
|
+
includeSynthetic: z.boolean().optional(),
|
|
243
|
+
includeInherited: z.boolean().optional(),
|
|
244
|
+
memberPattern: optionalNonEmptyString,
|
|
245
|
+
maxMembers: optionalPositiveInt
|
|
246
|
+
});
|
|
247
|
+
export const batchClassMembersShape = {
|
|
248
|
+
target: resolveArtifactTargetSchema.describe(RESOLVE_ARTIFACT_TARGET_DESCRIPTION),
|
|
249
|
+
mapping: sourceMappingSchema.optional(),
|
|
250
|
+
sourcePriority: mappingSourcePrioritySchema.optional(),
|
|
251
|
+
allowDecompile: z.boolean().optional(),
|
|
252
|
+
projectPath: optionalNonEmptyString,
|
|
253
|
+
scope: artifactScopeSchema.optional(),
|
|
254
|
+
preferProjectVersion: z.boolean().optional(),
|
|
255
|
+
strictVersion: z.boolean().optional(),
|
|
256
|
+
concurrency: z.number().int().min(1).max(8).optional(),
|
|
257
|
+
failFast: z.boolean().optional(),
|
|
258
|
+
compact: z.boolean().optional(),
|
|
259
|
+
entries: z.array(batchClassMembersEntrySchema).min(1).max(50)
|
|
260
|
+
};
|
|
261
|
+
export const batchClassMembersSchema = z.object(batchClassMembersShape);
|
|
262
|
+
export const batchSymbolExistsTargetSchema = z.discriminatedUnion("kind", [
|
|
263
|
+
z.object({ kind: z.literal("version"), value: nonEmptyString }),
|
|
264
|
+
workspaceTargetSchema
|
|
265
|
+
]).describe('Object with kind. Only kind="version" or kind="workspace" is accepted; dependency/jar/coordinate targets carry library versions, not Minecraft versions, and would corrupt the mapping query.');
|
|
266
|
+
export const batchSymbolExistsEntrySchema = z.object({
|
|
267
|
+
kind: batchSymbolKindSchema,
|
|
268
|
+
name: nonEmptyString,
|
|
269
|
+
owner: optionalNonEmptyString,
|
|
270
|
+
descriptor: optionalDescriptorString,
|
|
271
|
+
nameMode: classNameModeSchema.optional(),
|
|
272
|
+
signatureMode: z.enum(["exact", "name-only"]).optional(),
|
|
273
|
+
maxCandidates: optionalPositiveInt
|
|
274
|
+
});
|
|
275
|
+
export const batchSymbolExistsShape = {
|
|
276
|
+
target: batchSymbolExistsTargetSchema,
|
|
277
|
+
mapping: sourceMappingSchema.optional(),
|
|
278
|
+
sourcePriority: mappingSourcePrioritySchema.optional(),
|
|
279
|
+
allowDecompile: z.boolean().optional(),
|
|
280
|
+
projectPath: optionalNonEmptyString,
|
|
281
|
+
scope: artifactScopeSchema.optional(),
|
|
282
|
+
preferProjectVersion: z.boolean().optional(),
|
|
283
|
+
strictVersion: z.boolean().optional(),
|
|
284
|
+
concurrency: z.number().int().min(1).max(8).optional(),
|
|
285
|
+
failFast: z.boolean().optional(),
|
|
286
|
+
compact: z.boolean().optional(),
|
|
287
|
+
entries: z.array(batchSymbolExistsEntrySchema).min(1).max(50)
|
|
288
|
+
};
|
|
289
|
+
export const batchSymbolExistsSchema = z.object(batchSymbolExistsShape);
|
|
290
|
+
export const batchMappingsEntrySchema = z
|
|
291
|
+
.object({
|
|
292
|
+
kind: batchSymbolKindSchema,
|
|
293
|
+
name: nonEmptyString,
|
|
294
|
+
owner: optionalNonEmptyString,
|
|
295
|
+
descriptor: optionalDescriptorString,
|
|
296
|
+
sourceMapping: sourceMappingSchema,
|
|
297
|
+
targetMapping: sourceMappingSchema,
|
|
298
|
+
signatureMode: z.enum(["exact", "name-only"]).optional(),
|
|
299
|
+
disambiguation: z
|
|
300
|
+
.object({
|
|
301
|
+
ownerHint: optionalNonEmptyString,
|
|
302
|
+
descriptorHint: optionalNonEmptyString
|
|
303
|
+
})
|
|
304
|
+
.partial()
|
|
305
|
+
.optional(),
|
|
306
|
+
maxCandidates: optionalPositiveInt
|
|
307
|
+
})
|
|
308
|
+
.strict();
|
|
309
|
+
export const batchMappingsShape = {
|
|
310
|
+
version: nonEmptyString.describe("Minecraft version shared by every entry. Per-entry version is rejected; this batch shape is intentionally single-version."),
|
|
311
|
+
sourcePriority: mappingSourcePrioritySchema.optional(),
|
|
312
|
+
projectPath: optionalNonEmptyString,
|
|
313
|
+
concurrency: z.number().int().min(1).max(8).optional(),
|
|
314
|
+
failFast: z.boolean().optional(),
|
|
315
|
+
compact: z.boolean().optional(),
|
|
316
|
+
entries: z.array(batchMappingsEntrySchema).min(1).max(50)
|
|
317
|
+
};
|
|
318
|
+
export const batchMappingsSchema = z.object(batchMappingsShape);
|
|
319
|
+
export const searchClassSourceShape = {
|
|
320
|
+
artifactId: nonEmptyString,
|
|
321
|
+
query: nonEmptyString,
|
|
322
|
+
intent: searchIntentSchema.optional().describe("symbol | text | path"),
|
|
323
|
+
match: searchMatchSchema.optional().describe("exact | prefix | contains | regex"),
|
|
324
|
+
packagePrefix: optionalNonEmptyString,
|
|
325
|
+
fileGlob: optionalNonEmptyString,
|
|
326
|
+
symbolKind: searchSymbolKindSchema.optional().describe("class | interface | enum | record | method | field"),
|
|
327
|
+
queryMode: z.enum(["auto", "token", "literal"]).default("auto").describe("auto: indexed search, including separator queries like foo.bar; token: indexed-only; literal: explicit substring scan only"),
|
|
328
|
+
limit: optionalPositiveInt.default(20),
|
|
329
|
+
cursor: optionalNonEmptyString,
|
|
330
|
+
queryNamespace: sourceMappingSchema.optional().describe("Namespace of the query. When set and intent='symbol' with a fully-qualified class name, the query is translated through find-mapping before searching the artifact namespace. Ignored for text/path intents (warning surfaced)."),
|
|
331
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first. Used only when queryNamespace triggers translation."),
|
|
332
|
+
compact: z.boolean().default(false).describe("When true, strip the artifactContents summary and empty fields from the response. Default false.")
|
|
333
|
+
};
|
|
334
|
+
export const searchClassSourceSchema = z.object(searchClassSourceShape).superRefine((value, ctx) => {
|
|
335
|
+
if (value.symbolKind && value.intent && value.intent !== "symbol") {
|
|
336
|
+
ctx.addIssue({
|
|
337
|
+
code: z.ZodIssueCode.custom,
|
|
338
|
+
path: ["symbolKind"],
|
|
339
|
+
message: 'symbolKind filter is only supported when intent="symbol".'
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
export const getArtifactFileShape = {
|
|
344
|
+
artifactId: nonEmptyString,
|
|
345
|
+
filePath: nonEmptyString,
|
|
346
|
+
maxBytes: optionalPositiveInt
|
|
347
|
+
};
|
|
348
|
+
export const getArtifactFileSchema = z.object(getArtifactFileShape);
|
|
349
|
+
export const listArtifactFilesShape = {
|
|
350
|
+
artifactId: nonEmptyString,
|
|
351
|
+
prefix: optionalNonEmptyString,
|
|
352
|
+
limit: optionalPositiveInt,
|
|
353
|
+
cursor: optionalNonEmptyString,
|
|
354
|
+
compact: z.boolean().default(false).describe("When true, strip the artifactContents summary and empty fields from the response. Default false.")
|
|
355
|
+
};
|
|
356
|
+
export const listArtifactFilesSchema = z.object(listArtifactFilesShape);
|
|
357
|
+
export const traceSymbolLifecycleShape = {
|
|
358
|
+
symbol: nonEmptyString.describe("fully.qualified.Class.method"),
|
|
359
|
+
descriptor: optionalDescriptorString.describe('optional JVM descriptor, e.g. "(I)V". Empty strings are treated as omitted.'),
|
|
360
|
+
fromVersion: optionalNonEmptyString,
|
|
361
|
+
toVersion: optionalNonEmptyString,
|
|
362
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn (default obfuscated)"),
|
|
363
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
364
|
+
includeSnapshots: z.boolean().default(false),
|
|
365
|
+
maxVersions: optionalPositiveInt.default(120).describe("max 400"),
|
|
366
|
+
includeTimeline: z.boolean().default(false)
|
|
367
|
+
};
|
|
368
|
+
export const traceSymbolLifecycleSchema = z.object(traceSymbolLifecycleShape);
|
|
369
|
+
export const diffClassSignaturesShape = {
|
|
370
|
+
className: nonEmptyString,
|
|
371
|
+
fromVersion: nonEmptyString,
|
|
372
|
+
toVersion: nonEmptyString,
|
|
373
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn (default obfuscated)"),
|
|
374
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
375
|
+
includeFullDiff: z.boolean().default(true).describe("When false, omit from/to snapshots from modified entries and keep only key+changed")
|
|
376
|
+
};
|
|
377
|
+
export const diffClassSignaturesSchema = z.object(diffClassSignaturesShape);
|
|
378
|
+
export const findMappingShape = {
|
|
379
|
+
version: nonEmptyString,
|
|
380
|
+
kind: workspaceSymbolKindSchema.describe("class | field | method"),
|
|
381
|
+
name: nonEmptyString,
|
|
382
|
+
owner: optionalNonEmptyString,
|
|
383
|
+
descriptor: optionalDescriptorString.describe("JVM descriptor. Optional when signatureMode='name-only' (default). Empty strings are treated as omitted."),
|
|
384
|
+
sourceMapping: sourceMappingSchema.describe("obfuscated | mojang | intermediary | yarn"),
|
|
385
|
+
targetMapping: sourceMappingSchema.describe("obfuscated | mojang | intermediary | yarn"),
|
|
386
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
387
|
+
signatureMode: z.enum(["exact", "name-only"]).default("name-only")
|
|
388
|
+
.describe("exact: descriptor required for kind=method; name-only (default): match by owner+name only"),
|
|
389
|
+
disambiguation: z
|
|
390
|
+
.object({
|
|
391
|
+
ownerHint: optionalNonEmptyString,
|
|
392
|
+
descriptorHint: optionalNonEmptyString
|
|
393
|
+
})
|
|
394
|
+
.partial()
|
|
395
|
+
.optional(),
|
|
396
|
+
maxCandidates: optionalPositiveInt.default(5).describe("Limit returned candidates (default 5, max 200). Raise when you need the full candidate list."),
|
|
397
|
+
compact: z.boolean().default(true).describe("Omit top-level empty arrays, null/undefined values, and empty objects from the response. "
|
|
398
|
+
+ "Also omit redundant candidates array for single full-confidence exact-match resolutions. "
|
|
399
|
+
+ "Enabled by default; set to false for full output.")
|
|
400
|
+
};
|
|
401
|
+
export const findMappingSchema = z.object(findMappingShape).superRefine((value, ctx) => {
|
|
402
|
+
if (value.kind === "class") {
|
|
403
|
+
if (value.owner) {
|
|
404
|
+
ctx.addIssue({
|
|
405
|
+
code: z.ZodIssueCode.custom,
|
|
406
|
+
message: "owner is not allowed when kind=class.",
|
|
407
|
+
path: ["owner"]
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
if (value.descriptor) {
|
|
411
|
+
ctx.addIssue({
|
|
412
|
+
code: z.ZodIssueCode.custom,
|
|
413
|
+
message: "descriptor is not allowed when kind=class.",
|
|
414
|
+
path: ["descriptor"]
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
if (value.sourceMapping !== "obfuscated" && !value.name.includes(".")) {
|
|
418
|
+
ctx.addIssue({
|
|
419
|
+
code: z.ZodIssueCode.custom,
|
|
420
|
+
message: "name must be fully-qualified class name when kind=class.",
|
|
421
|
+
path: ["name"]
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (!value.owner) {
|
|
427
|
+
ctx.addIssue({
|
|
428
|
+
code: z.ZodIssueCode.custom,
|
|
429
|
+
message: "owner is required when kind is field or method.",
|
|
430
|
+
path: ["owner"]
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
if (/[\s./()]/.test(value.name)) {
|
|
434
|
+
ctx.addIssue({
|
|
435
|
+
code: z.ZodIssueCode.custom,
|
|
436
|
+
message: "name must be a simple member name when kind is field or method.",
|
|
437
|
+
path: ["name"]
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
if (value.kind === "field") {
|
|
441
|
+
if (value.descriptor) {
|
|
442
|
+
ctx.addIssue({
|
|
443
|
+
code: z.ZodIssueCode.custom,
|
|
444
|
+
message: "descriptor is not allowed when kind=field.",
|
|
445
|
+
path: ["descriptor"]
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (!value.descriptor && value.signatureMode !== "name-only") {
|
|
451
|
+
ctx.addIssue({
|
|
452
|
+
code: z.ZodIssueCode.custom,
|
|
453
|
+
message: "descriptor is required when kind=method (use signatureMode='name-only' to match by name only).",
|
|
454
|
+
path: ["descriptor"]
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
export const resolveMethodMappingExactShape = {
|
|
459
|
+
version: nonEmptyString,
|
|
460
|
+
name: nonEmptyString,
|
|
461
|
+
owner: nonEmptyString,
|
|
462
|
+
descriptor: nonEmptyString.describe("required JVM descriptor"),
|
|
463
|
+
sourceMapping: sourceMappingSchema.describe("obfuscated | mojang | intermediary | yarn"),
|
|
464
|
+
targetMapping: sourceMappingSchema.describe("obfuscated | mojang | intermediary | yarn"),
|
|
465
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
466
|
+
maxCandidates: optionalPositiveInt.default(5).describe("Limit returned candidates (default 5, max 200). Raise when you need the full candidate list."),
|
|
467
|
+
compact: z.boolean().default(true).describe("Omit top-level empty arrays, null/undefined values, and empty objects from the response. "
|
|
468
|
+
+ "Also omit redundant candidates array for single full-confidence exact-match resolutions. "
|
|
469
|
+
+ "Enabled by default; set to false for full output.")
|
|
470
|
+
};
|
|
471
|
+
export const resolveMethodMappingExactSchema = z
|
|
472
|
+
.object(resolveMethodMappingExactShape)
|
|
473
|
+
.superRefine((value, ctx) => {
|
|
474
|
+
if (/[\s./()]/.test(value.name)) {
|
|
475
|
+
ctx.addIssue({
|
|
476
|
+
code: z.ZodIssueCode.custom,
|
|
477
|
+
message: "name must be a simple method name.",
|
|
478
|
+
path: ["name"]
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
export const classApiKindsSchema = z.string().superRefine((value, ctx) => {
|
|
483
|
+
const tokens = value
|
|
484
|
+
.split(",")
|
|
485
|
+
.map((entry) => entry.trim().toLowerCase())
|
|
486
|
+
.filter((entry) => entry.length > 0);
|
|
487
|
+
if (tokens.length === 0) {
|
|
488
|
+
ctx.addIssue({
|
|
489
|
+
code: z.ZodIssueCode.custom,
|
|
490
|
+
message: "includeKinds must include at least one of class, field, method."
|
|
491
|
+
});
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
const invalidTokens = tokens.filter((entry) => entry !== "class" && entry !== "field" && entry !== "method");
|
|
495
|
+
if (invalidTokens.length > 0) {
|
|
496
|
+
ctx.addIssue({
|
|
497
|
+
code: z.ZodIssueCode.custom,
|
|
498
|
+
message: `includeKinds contains invalid values: ${invalidTokens.join(", ")}. Allowed values are class, field, method.`
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
export const getClassApiMatrixShape = {
|
|
503
|
+
version: nonEmptyString,
|
|
504
|
+
className: nonEmptyString,
|
|
505
|
+
classNameMapping: sourceMappingSchema.describe("obfuscated | mojang | intermediary | yarn"),
|
|
506
|
+
includeKinds: classApiKindsSchema.optional().describe("comma-separated: class,field,method"),
|
|
507
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
508
|
+
maxRows: optionalPositiveInt.describe("Limit returned rows (max 5000)")
|
|
509
|
+
};
|
|
510
|
+
export const getClassApiMatrixSchema = z.object(getClassApiMatrixShape);
|
|
511
|
+
export const resolveWorkspaceSymbolShape = {
|
|
512
|
+
projectPath: nonEmptyString,
|
|
513
|
+
version: nonEmptyString,
|
|
514
|
+
kind: workspaceSymbolKindSchema.describe("class | field | method"),
|
|
515
|
+
name: nonEmptyString,
|
|
516
|
+
owner: optionalNonEmptyString,
|
|
517
|
+
descriptor: optionalDescriptorString.describe("JVM descriptor. Empty strings are treated as omitted."),
|
|
518
|
+
sourceMapping: sourceMappingSchema.describe("obfuscated | mojang | intermediary | yarn"),
|
|
519
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
520
|
+
maxCandidates: optionalPositiveInt.default(5).describe("Limit returned candidates for field/method lookups (default 5, max 200). Raise when you need the full candidate list."),
|
|
521
|
+
compact: z.boolean().default(true).describe("Omit top-level empty arrays, null/undefined values, and empty objects from the response. "
|
|
522
|
+
+ "Also omit redundant candidates array for single full-confidence exact-match resolutions. "
|
|
523
|
+
+ "Enabled by default; set to false for full output.")
|
|
524
|
+
};
|
|
525
|
+
export const resolveWorkspaceSymbolSchema = z
|
|
526
|
+
.object(resolveWorkspaceSymbolShape)
|
|
527
|
+
.superRefine((value, ctx) => {
|
|
528
|
+
if (value.kind === "class") {
|
|
529
|
+
if (value.owner) {
|
|
530
|
+
ctx.addIssue({
|
|
531
|
+
code: z.ZodIssueCode.custom,
|
|
532
|
+
message: "owner is not allowed when kind=class.",
|
|
533
|
+
path: ["owner"]
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
if (value.descriptor) {
|
|
537
|
+
ctx.addIssue({
|
|
538
|
+
code: z.ZodIssueCode.custom,
|
|
539
|
+
message: "descriptor is not allowed when kind=class.",
|
|
540
|
+
path: ["descriptor"]
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
if (!value.name.includes(".")) {
|
|
544
|
+
ctx.addIssue({
|
|
545
|
+
code: z.ZodIssueCode.custom,
|
|
546
|
+
message: "name must be fully-qualified class name when kind=class.",
|
|
547
|
+
path: ["name"]
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (!value.owner) {
|
|
553
|
+
ctx.addIssue({
|
|
554
|
+
code: z.ZodIssueCode.custom,
|
|
555
|
+
message: "owner is required when kind is field or method.",
|
|
556
|
+
path: ["owner"]
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if (/[\s./()]/.test(value.name)) {
|
|
560
|
+
ctx.addIssue({
|
|
561
|
+
code: z.ZodIssueCode.custom,
|
|
562
|
+
message: "name must be a simple member name when kind is field or method.",
|
|
563
|
+
path: ["name"]
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
if (value.kind === "field") {
|
|
567
|
+
if (value.descriptor) {
|
|
568
|
+
ctx.addIssue({
|
|
569
|
+
code: z.ZodIssueCode.custom,
|
|
570
|
+
message: "descriptor is not allowed when kind=field.",
|
|
571
|
+
path: ["descriptor"]
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (!value.descriptor) {
|
|
577
|
+
ctx.addIssue({
|
|
578
|
+
code: z.ZodIssueCode.custom,
|
|
579
|
+
message: "descriptor is required when kind=method.",
|
|
580
|
+
path: ["descriptor"]
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
export const checkSymbolExistsShape = {
|
|
585
|
+
version: nonEmptyString,
|
|
586
|
+
kind: workspaceSymbolKindSchema.describe("class | field | method"),
|
|
587
|
+
owner: optionalNonEmptyString,
|
|
588
|
+
name: nonEmptyString,
|
|
589
|
+
descriptor: optionalDescriptorString.describe("required for kind=method unless signatureMode=name-only. Empty strings are treated as omitted."),
|
|
590
|
+
sourceMapping: sourceMappingSchema.describe("obfuscated | mojang | intermediary | yarn"),
|
|
591
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
592
|
+
nameMode: classNameModeSchema.default("fqcn").describe("fqcn | auto"),
|
|
593
|
+
signatureMode: z.enum(["exact", "name-only"]).default("exact")
|
|
594
|
+
.describe("exact: require descriptor for methods; name-only: match by owner+name only"),
|
|
595
|
+
maxCandidates: optionalPositiveInt.default(5).describe("Limit returned candidates (default 5, max 200). Raise when you need the full candidate list."),
|
|
596
|
+
compact: z.boolean().default(true).describe("Omit top-level empty arrays, null/undefined values, and empty objects from the response. "
|
|
597
|
+
+ "Also omit redundant candidates array for single full-confidence exact-match resolutions. "
|
|
598
|
+
+ "Enabled by default; set to false for full output.")
|
|
599
|
+
};
|
|
600
|
+
export const checkSymbolExistsSchema = z.object(checkSymbolExistsShape).superRefine((value, ctx) => {
|
|
601
|
+
if (value.kind === "class") {
|
|
602
|
+
if (value.owner) {
|
|
603
|
+
ctx.addIssue({
|
|
604
|
+
code: z.ZodIssueCode.custom,
|
|
605
|
+
message: "owner is not allowed when kind=class.",
|
|
606
|
+
path: ["owner"]
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
if (value.descriptor) {
|
|
610
|
+
ctx.addIssue({
|
|
611
|
+
code: z.ZodIssueCode.custom,
|
|
612
|
+
message: "descriptor is not allowed when kind=class.",
|
|
613
|
+
path: ["descriptor"]
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
if (value.nameMode !== "auto" && !value.name.includes(".")) {
|
|
617
|
+
ctx.addIssue({
|
|
618
|
+
code: z.ZodIssueCode.custom,
|
|
619
|
+
message: "name must be fully-qualified class name when kind=class.",
|
|
620
|
+
path: ["name"]
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
if (!value.owner) {
|
|
626
|
+
ctx.addIssue({
|
|
627
|
+
code: z.ZodIssueCode.custom,
|
|
628
|
+
message: "owner is required when kind is field or method.",
|
|
629
|
+
path: ["owner"]
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
if (/[\s./()]/.test(value.name)) {
|
|
633
|
+
ctx.addIssue({
|
|
634
|
+
code: z.ZodIssueCode.custom,
|
|
635
|
+
message: "name must be a simple member name when kind is field or method.",
|
|
636
|
+
path: ["name"]
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
if (value.kind === "field") {
|
|
640
|
+
if (value.descriptor) {
|
|
641
|
+
ctx.addIssue({
|
|
642
|
+
code: z.ZodIssueCode.custom,
|
|
643
|
+
message: "descriptor is not allowed when kind=field.",
|
|
644
|
+
path: ["descriptor"]
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
if (!value.descriptor && value.signatureMode !== "name-only") {
|
|
650
|
+
ctx.addIssue({
|
|
651
|
+
code: z.ZodIssueCode.custom,
|
|
652
|
+
message: "descriptor is required when kind=method (use signatureMode='name-only' to match by name only).",
|
|
653
|
+
path: ["descriptor"]
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
export const nbtToJsonShape = {
|
|
658
|
+
nbtBase64: nonEmptyString,
|
|
659
|
+
compression: decodeCompressionSchema.default("auto").describe("none | gzip | auto")
|
|
660
|
+
};
|
|
661
|
+
export const nbtToJsonSchema = z.object(nbtToJsonShape);
|
|
662
|
+
const nbtPatchOperationSchema = z
|
|
663
|
+
.object({
|
|
664
|
+
op: z.enum(["add", "remove", "replace", "test"]),
|
|
665
|
+
path: nonEmptyString,
|
|
666
|
+
value: z.unknown().optional()
|
|
667
|
+
})
|
|
668
|
+
.passthrough();
|
|
669
|
+
export const nbtApplyJsonPatchShape = {
|
|
670
|
+
typedJson: z.unknown(),
|
|
671
|
+
patch: z.array(nbtPatchOperationSchema).describe("RFC6902 operation array (add/remove/replace/test)")
|
|
672
|
+
};
|
|
673
|
+
export const nbtApplyJsonPatchSchema = z.object(nbtApplyJsonPatchShape);
|
|
674
|
+
export const jsonToNbtShape = {
|
|
675
|
+
typedJson: z.unknown(),
|
|
676
|
+
compression: encodeCompressionSchema.default("none").describe("none | gzip")
|
|
677
|
+
};
|
|
678
|
+
export const jsonToNbtSchema = z.object(jsonToNbtShape);
|
|
679
|
+
export const indexArtifactShape = {
|
|
680
|
+
artifactId: nonEmptyString,
|
|
681
|
+
force: z.boolean().default(false)
|
|
682
|
+
};
|
|
683
|
+
export const indexArtifactSchema = z.object(indexArtifactShape);
|
|
684
|
+
export const validateMixinShape = {
|
|
685
|
+
input: z.discriminatedUnion("mode", [
|
|
686
|
+
z.object({
|
|
687
|
+
mode: z.literal("inline"),
|
|
688
|
+
source: nonEmptyString.describe("Mixin Java source text")
|
|
689
|
+
}),
|
|
690
|
+
z.object({
|
|
691
|
+
mode: z.literal("path"),
|
|
692
|
+
path: nonEmptyString.describe("Path to a Mixin .java file")
|
|
693
|
+
}),
|
|
694
|
+
z.object({
|
|
695
|
+
mode: z.literal("paths"),
|
|
696
|
+
paths: z.array(nonEmptyString).min(1).describe("Array of Mixin .java file paths for batch validation")
|
|
697
|
+
}),
|
|
698
|
+
z.object({
|
|
699
|
+
mode: z.literal("config"),
|
|
700
|
+
configPaths: z.array(nonEmptyString).min(1).describe("Path array to mixin config JSON files (e.g. modid.mixins.json)")
|
|
701
|
+
}),
|
|
702
|
+
z.object({
|
|
703
|
+
mode: z.literal("project"),
|
|
704
|
+
path: nonEmptyString.describe("Workspace root path used to discover *.mixins.json files automatically")
|
|
705
|
+
})
|
|
706
|
+
]).describe("One of { mode: 'inline', source }, { mode: 'path', path }, { mode: 'paths', paths[] }, { mode: 'config', configPaths[] }, or { mode: 'project', path }."),
|
|
707
|
+
sourceRoots: z.array(z.string().min(1)).optional()
|
|
708
|
+
.describe("Array of source roots for multi-module projects (e.g. ['common/src/main/java', 'neoforge/src/main/java'])"),
|
|
709
|
+
version: nonEmptyString.describe("Minecraft version"),
|
|
710
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn"),
|
|
711
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
712
|
+
scope: artifactScopeSchema.optional().describe(SOURCE_SCOPE_DESCRIPTION),
|
|
713
|
+
projectPath: optionalNonEmptyString.describe("Optional workspace root path for Loom cache-assisted source resolution"),
|
|
714
|
+
preferProjectVersion: z.boolean().optional().describe("When true, detect MC version from gradle.properties and override version"),
|
|
715
|
+
minSeverity: z.enum(["error", "warning", "all"]).default("all")
|
|
716
|
+
.describe("'error'=errors only, 'warning'=errors+warnings, 'all'=everything"),
|
|
717
|
+
hideUncertain: z.boolean().default(false)
|
|
718
|
+
.describe("Omit issues with confidence='uncertain'"),
|
|
719
|
+
explain: z.boolean().default(false)
|
|
720
|
+
.describe("When true, enrich each issue with explanation and suggestedCall for agent recovery"),
|
|
721
|
+
warningMode: z.enum(["full", "aggregated"]).optional()
|
|
722
|
+
.describe("'full'=all warnings; 'aggregated'=group warnings by category with counts and samples. Single validation uses the provided value as-is; batch validation defaults to 'aggregated'"),
|
|
723
|
+
preferProjectMapping: z.boolean().default(false)
|
|
724
|
+
.describe("When true, auto-detect mapping from project config even if mapping is explicitly provided"),
|
|
725
|
+
reportMode: z.enum(["compact", "full", "summary-first"]).default("full")
|
|
726
|
+
.describe("'compact' omits heavy per-result detail, 'summary-first' hoists shared provenance/warnings/incomplete reasons, 'full'=everything"),
|
|
727
|
+
warningCategoryFilter: z.array(z.enum(["mapping", "configuration", "validation", "resolution", "parse"])).optional()
|
|
728
|
+
.describe("Only include warnings/issues matching these categories (default: all)"),
|
|
729
|
+
treatInfoAsWarning: z.boolean().default(true)
|
|
730
|
+
.describe("When false, suppress info-severity structured warnings from output"),
|
|
731
|
+
includeIssues: z.boolean().default(true)
|
|
732
|
+
.describe("When false, keep summary fields but omit per-result issues[] payloads")
|
|
733
|
+
};
|
|
734
|
+
export const validateMixinSchema = z.object(validateMixinShape);
|
|
735
|
+
export const validateAccessWidenerShape = {
|
|
736
|
+
content: nonEmptyString.describe("Access Widener file content"),
|
|
737
|
+
version: nonEmptyString.describe("Minecraft version"),
|
|
738
|
+
mapping: sourceMappingSchema.optional().describe("obfuscated | mojang | intermediary | yarn"),
|
|
739
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
740
|
+
projectPath: optionalNonEmptyString.describe("Optional workspace root path for Loom cache-assisted runtime validation"),
|
|
741
|
+
scope: artifactScopeSchema.optional().describe(SOURCE_SCOPE_DESCRIPTION),
|
|
742
|
+
preferProjectVersion: z.boolean().default(false)
|
|
743
|
+
.describe("When true, detect MC version from gradle.properties and override version")
|
|
744
|
+
};
|
|
745
|
+
export const validateAccessWidenerSchema = z.object(validateAccessWidenerShape);
|
|
746
|
+
export const validateAccessTransformerShape = {
|
|
747
|
+
content: nonEmptyString.describe("Access Transformer file content"),
|
|
748
|
+
version: nonEmptyString.describe("Minecraft version"),
|
|
749
|
+
atNamespace: z.enum(["srg", "mojang", "obfuscated"]).optional().describe("srg | mojang | obfuscated"),
|
|
750
|
+
sourcePriority: mappingSourcePrioritySchema.optional().describe("loom-first | maven-first"),
|
|
751
|
+
projectPath: optionalNonEmptyString.describe("Optional workspace root path for Forge/NeoForge runtime validation"),
|
|
752
|
+
scope: artifactScopeSchema.optional().describe(SOURCE_SCOPE_DESCRIPTION),
|
|
753
|
+
preferProjectVersion: z.boolean().default(false)
|
|
754
|
+
.describe("When true, detect MC version from gradle.properties and override version")
|
|
755
|
+
};
|
|
756
|
+
export const validateAccessTransformerSchema = z.object(validateAccessTransformerShape);
|
|
757
|
+
export const analyzeModJarShape = {
|
|
758
|
+
jarPath: nonEmptyString.describe("Local path to the mod JAR file"),
|
|
759
|
+
includeClasses: z.boolean().default(false).describe("Include full class listing")
|
|
760
|
+
};
|
|
761
|
+
export const analyzeModJarSchema = z.object(analyzeModJarShape);
|
|
762
|
+
export const getRegistryDataShape = {
|
|
763
|
+
version: nonEmptyString.describe("Minecraft version (e.g. 1.21)"),
|
|
764
|
+
registry: optionalNonEmptyString.describe('Optional registry name (e.g. "block", "item", "minecraft:biome"). Omit to list all registries.'),
|
|
765
|
+
includeData: z.boolean().default(true).describe("When false, return registry names/counts without full entry bodies"),
|
|
766
|
+
maxEntriesPerRegistry: optionalPositiveInt.describe("Limit returned entries per registry body")
|
|
767
|
+
};
|
|
768
|
+
export const getRegistryDataSchema = z.object(getRegistryDataShape);
|
|
769
|
+
export const COMPARE_VERSIONS_CATEGORIES = ["classes", "registry", "all"];
|
|
770
|
+
export const compareVersionsCategorySchema = z.enum(COMPARE_VERSIONS_CATEGORIES);
|
|
771
|
+
export const compareVersionsShape = {
|
|
772
|
+
fromVersion: nonEmptyString.describe("Older Minecraft version (e.g. 1.20.4)"),
|
|
773
|
+
toVersion: nonEmptyString.describe("Newer Minecraft version (e.g. 1.21)"),
|
|
774
|
+
category: compareVersionsCategorySchema.default("all").describe("classes | registry | all"),
|
|
775
|
+
packageFilter: optionalNonEmptyString.describe("Filter classes to a package prefix (e.g. net.minecraft.world.item)"),
|
|
776
|
+
maxClassResults: optionalPositiveInt.default(500).describe("Max class results per direction (max 5000)")
|
|
777
|
+
};
|
|
778
|
+
export const compareVersionsSchema = z.object(compareVersionsShape);
|
|
779
|
+
export const decompileModJarShape = {
|
|
780
|
+
jarPath: nonEmptyString.describe("Local path to the mod JAR file"),
|
|
781
|
+
className: optionalNonEmptyString.describe("Optional fully-qualified class name to view source. Omit to list all classes."),
|
|
782
|
+
includeFiles: z.boolean().default(true).describe("When false, omit the full class list and return counts only"),
|
|
783
|
+
maxFiles: optionalPositiveInt.describe("Limit returned class names when files are included")
|
|
784
|
+
};
|
|
785
|
+
export const decompileModJarSchema = z.object(decompileModJarShape);
|
|
786
|
+
export const getModClassSourceShape = {
|
|
787
|
+
jarPath: nonEmptyString.describe("Local path to the mod JAR file"),
|
|
788
|
+
className: nonEmptyString.describe("Fully-qualified class name (e.g. com.example.MyMixin)"),
|
|
789
|
+
maxLines: optionalPositiveInt.describe("Max lines to return"),
|
|
790
|
+
maxChars: optionalPositiveInt.describe("Hard character limit; truncates if exceeded"),
|
|
791
|
+
outputFile: optionalNonEmptyString.describe("Write full source to file, return placeholder in content")
|
|
792
|
+
};
|
|
793
|
+
export const getModClassSourceSchema = z.object(getModClassSourceShape);
|
|
794
|
+
export const MOD_SEARCH_TYPES = ["class", "method", "field", "content", "all"];
|
|
795
|
+
export const modSearchTypeSchema = z.enum(MOD_SEARCH_TYPES);
|
|
796
|
+
export const searchModSourceShape = {
|
|
797
|
+
jarPath: nonEmptyString.describe("Local path to the mod JAR file"),
|
|
798
|
+
query: nonEmptyString.describe("Search pattern (regex or literal string)"),
|
|
799
|
+
searchType: modSearchTypeSchema.default("all").describe("class | method | field | content | all"),
|
|
800
|
+
limit: optionalPositiveInt.default(50).describe("Max results (max 200)")
|
|
801
|
+
};
|
|
802
|
+
export const searchModSourceSchema = z.object(searchModSourceShape);
|
|
803
|
+
export const REMAP_TARGETS = ["yarn", "mojang"];
|
|
804
|
+
export const remapTargetSchema = z.enum(REMAP_TARGETS);
|
|
805
|
+
export const remapModJarShape = {
|
|
806
|
+
inputJar: nonEmptyString.describe("Path to the mod JAR file"),
|
|
807
|
+
outputJar: optionalNonEmptyString.describe("Output path for remapped JAR (auto-generated if omitted)"),
|
|
808
|
+
mcVersion: optionalNonEmptyString.describe("Minecraft version (auto-detected from mod metadata if omitted)"),
|
|
809
|
+
targetMapping: remapTargetSchema.describe("yarn | mojang")
|
|
810
|
+
};
|
|
811
|
+
export const remapModJarSchema = z.object(remapModJarShape);
|
|
812
|
+
export const emptySchema = z.object({}).passthrough();
|
|
813
|
+
//# sourceMappingURL=tool-schemas.js.map
|