@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.
Files changed (176) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +40 -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 +102 -0
  47. package/dist/entry-tools/validate-project/cases/project-summary.js +415 -0
  48. package/dist/entry-tools/validate-project/internal.d.ts +142 -0
  49. package/dist/entry-tools/validate-project/internal.js +303 -0
  50. package/dist/entry-tools/validate-project-service.d.ts +67 -47
  51. package/dist/entry-tools/validate-project-service.js +13 -563
  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 +147 -1354
  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 +8 -145
  84. package/dist/mapping-service.js +30 -1207
  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 +111 -0
  100. package/dist/source/artifact-resolver.js +1271 -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 +522 -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 +26 -0
  134. package/dist/source/state.js +24 -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-resolver.d.ts +1 -0
  152. package/dist/source-resolver.js +1 -1
  153. package/dist/source-service.d.ts +164 -170
  154. package/dist/source-service.js +70 -6116
  155. package/dist/stage-emitter.d.ts +13 -0
  156. package/dist/stage-emitter.js +30 -0
  157. package/dist/stdio-supervisor.d.ts +61 -0
  158. package/dist/stdio-supervisor.js +326 -9
  159. package/dist/tool-contract-manifest.d.ts +1 -1
  160. package/dist/tool-contract-manifest.js +23 -6
  161. package/dist/tool-guidance.d.ts +82 -0
  162. package/dist/tool-guidance.js +734 -0
  163. package/dist/tool-schema-registry.d.ts +16 -0
  164. package/dist/tool-schema-registry.js +37 -0
  165. package/dist/tool-schemas.d.ts +3518 -0
  166. package/dist/tool-schemas.js +813 -0
  167. package/dist/types.d.ts +36 -0
  168. package/dist/version-service.js +7 -6
  169. package/dist/workspace-context-cache.d.ts +32 -0
  170. package/dist/workspace-context-cache.js +66 -0
  171. package/dist/workspace-mapping-service.d.ts +16 -0
  172. package/dist/workspace-mapping-service.js +173 -1
  173. package/docs/README-ja.md +416 -0
  174. package/docs/examples.md +483 -0
  175. package/docs/tool-reference.md +462 -0
  176. package/package.json +17 -4
@@ -0,0 +1,97 @@
1
+ import { buildSuggestedCall } from "../build-suggested-call.js";
2
+ import { compactResponse, compactMembersResponse, TOOL_PRESERVE_PAYLOAD_KEYS } from "../response-utils.js";
3
+ import { runBatch, splitEntryWarnings } from "./batch-runner.js";
4
+ export class BatchClassMembersService {
5
+ deps;
6
+ constructor(deps) {
7
+ this.deps = deps;
8
+ }
9
+ async execute(input) {
10
+ const concurrency = input.concurrency ?? 4;
11
+ const failFast = input.failFast ?? false;
12
+ const compact = input.compact ?? true;
13
+ return runBatch({
14
+ entries: input.entries,
15
+ concurrency,
16
+ failFast,
17
+ resolveSharedArtifact: async () => {
18
+ const resolved = await this.deps.resolveArtifact({
19
+ target: input.target,
20
+ mapping: input.mapping,
21
+ sourcePriority: input.sourcePriority,
22
+ allowDecompile: input.allowDecompile,
23
+ projectPath: input.projectPath,
24
+ scope: input.scope,
25
+ preferProjectVersion: input.preferProjectVersion,
26
+ strictVersion: input.strictVersion
27
+ });
28
+ return {
29
+ artifactId: resolved.artifactId,
30
+ provenance: resolved.provenance,
31
+ ...(Array.isArray(resolved.warnings) && resolved.warnings.length > 0
32
+ ? { warnings: [...resolved.warnings] }
33
+ : {})
34
+ };
35
+ },
36
+ artifactSummary: (artifact) => ({
37
+ sharedArtifactId: artifact.artifactId,
38
+ ...(artifact.provenance ? { sharedArtifactProvenance: artifact.provenance } : {}),
39
+ ...(artifact.warnings && artifact.warnings.length > 0
40
+ ? { sharedArtifactWarnings: artifact.warnings }
41
+ : {})
42
+ }),
43
+ perEntry: async (entry, _index, sharedArtifact) => {
44
+ if (!sharedArtifact) {
45
+ throw new Error("shared artifact not resolved");
46
+ }
47
+ const raw = (await this.deps.getClassMembers({
48
+ artifactId: sharedArtifact.artifactId,
49
+ className: entry.className,
50
+ access: entry.access,
51
+ includeSynthetic: entry.includeSynthetic,
52
+ includeInherited: entry.includeInherited,
53
+ memberPattern: entry.memberPattern,
54
+ maxMembers: entry.maxMembers,
55
+ mapping: input.mapping,
56
+ sourcePriority: input.sourcePriority,
57
+ allowDecompile: input.allowDecompile,
58
+ projectPath: input.projectPath,
59
+ scope: input.scope,
60
+ preferProjectVersion: input.preferProjectVersion,
61
+ strictVersion: input.strictVersion
62
+ }));
63
+ const { result, warnings } = splitEntryWarnings(raw);
64
+ const projected = compact
65
+ ? compactResponse(compactMembersResponse(result), TOOL_PRESERVE_PAYLOAD_KEYS["get-class-members"])
66
+ : result;
67
+ return { result: projected, warnings };
68
+ },
69
+ buildErrorSuggestedCall: (entry, sharedArtifact) => {
70
+ if (!sharedArtifact)
71
+ return undefined;
72
+ const params = {
73
+ target: { type: "artifact", artifactId: sharedArtifact.artifactId },
74
+ className: entry.className
75
+ };
76
+ if (entry.access !== undefined)
77
+ params.access = entry.access;
78
+ if (entry.includeSynthetic !== undefined)
79
+ params.includeSynthetic = entry.includeSynthetic;
80
+ if (entry.includeInherited !== undefined)
81
+ params.includeInherited = entry.includeInherited;
82
+ if (entry.memberPattern !== undefined)
83
+ params.memberPattern = entry.memberPattern;
84
+ if (entry.maxMembers !== undefined)
85
+ params.maxMembers = entry.maxMembers;
86
+ if (input.mapping !== undefined)
87
+ params.mapping = input.mapping;
88
+ const { suggestedCall } = buildSuggestedCall({
89
+ tool: "get-class-members",
90
+ params
91
+ });
92
+ return suggestedCall;
93
+ }
94
+ });
95
+ }
96
+ }
97
+ //# sourceMappingURL=batch-class-members-service.js.map
@@ -0,0 +1,37 @@
1
+ import type { GetClassSourceInput, GetClassSourceOutput, ResolveArtifactInput, ResolveArtifactOutput } from "../source-service.js";
2
+ import type { ArtifactScope, MappingSourcePriority, ResolveArtifactTargetInput, SourceMapping } from "../types.js";
3
+ import { type BatchOutput } from "./batch-runner.js";
4
+ type SourceMode = "metadata" | "snippet" | "full";
5
+ export type BatchClassSourceEntry = {
6
+ className: string;
7
+ mode?: SourceMode;
8
+ startLine?: number;
9
+ endLine?: number;
10
+ maxLines?: number;
11
+ maxChars?: number;
12
+ outputFile?: string;
13
+ };
14
+ export type BatchClassSourceInput = {
15
+ target: ResolveArtifactTargetInput;
16
+ mapping?: SourceMapping;
17
+ sourcePriority?: MappingSourcePriority;
18
+ allowDecompile?: boolean;
19
+ projectPath?: string;
20
+ scope?: ArtifactScope;
21
+ preferProjectVersion?: boolean;
22
+ strictVersion?: boolean;
23
+ concurrency?: number;
24
+ failFast?: boolean;
25
+ compact?: boolean;
26
+ entries: readonly BatchClassSourceEntry[];
27
+ };
28
+ export type BatchClassSourceDeps = {
29
+ resolveArtifact: (input: ResolveArtifactInput) => Promise<ResolveArtifactOutput>;
30
+ getClassSource: (input: GetClassSourceInput) => Promise<GetClassSourceOutput>;
31
+ };
32
+ export declare class BatchClassSourceService {
33
+ private readonly deps;
34
+ constructor(deps: BatchClassSourceDeps);
35
+ execute(input: BatchClassSourceInput): Promise<BatchOutput<Record<string, unknown>>>;
36
+ }
37
+ export {};
@@ -0,0 +1,100 @@
1
+ import { buildSuggestedCall } from "../build-suggested-call.js";
2
+ import { compactResponse, compactSourceResponse, TOOL_PRESERVE_PAYLOAD_KEYS } from "../response-utils.js";
3
+ import { runBatch, splitEntryWarnings } from "./batch-runner.js";
4
+ export class BatchClassSourceService {
5
+ deps;
6
+ constructor(deps) {
7
+ this.deps = deps;
8
+ }
9
+ async execute(input) {
10
+ const concurrency = input.concurrency ?? 4;
11
+ const failFast = input.failFast ?? false;
12
+ const compact = input.compact ?? true;
13
+ return runBatch({
14
+ entries: input.entries,
15
+ concurrency,
16
+ failFast,
17
+ resolveSharedArtifact: async () => {
18
+ const resolved = await this.deps.resolveArtifact({
19
+ target: input.target,
20
+ mapping: input.mapping,
21
+ sourcePriority: input.sourcePriority,
22
+ allowDecompile: input.allowDecompile,
23
+ projectPath: input.projectPath,
24
+ scope: input.scope,
25
+ preferProjectVersion: input.preferProjectVersion,
26
+ strictVersion: input.strictVersion
27
+ });
28
+ return {
29
+ artifactId: resolved.artifactId,
30
+ provenance: resolved.provenance,
31
+ ...(Array.isArray(resolved.warnings) && resolved.warnings.length > 0
32
+ ? { warnings: [...resolved.warnings] }
33
+ : {})
34
+ };
35
+ },
36
+ artifactSummary: (artifact) => ({
37
+ sharedArtifactId: artifact.artifactId,
38
+ ...(artifact.provenance ? { sharedArtifactProvenance: artifact.provenance } : {}),
39
+ ...(artifact.warnings && artifact.warnings.length > 0
40
+ ? { sharedArtifactWarnings: artifact.warnings }
41
+ : {})
42
+ }),
43
+ perEntry: async (entry, _index, sharedArtifact) => {
44
+ if (!sharedArtifact) {
45
+ throw new Error("shared artifact not resolved");
46
+ }
47
+ const raw = (await this.deps.getClassSource({
48
+ artifactId: sharedArtifact.artifactId,
49
+ className: entry.className,
50
+ mode: entry.mode,
51
+ startLine: entry.startLine,
52
+ endLine: entry.endLine,
53
+ maxLines: entry.maxLines,
54
+ maxChars: entry.maxChars,
55
+ outputFile: entry.outputFile,
56
+ mapping: input.mapping,
57
+ sourcePriority: input.sourcePriority,
58
+ allowDecompile: input.allowDecompile,
59
+ projectPath: input.projectPath,
60
+ scope: input.scope,
61
+ preferProjectVersion: input.preferProjectVersion,
62
+ strictVersion: input.strictVersion
63
+ }));
64
+ const { result, warnings } = splitEntryWarnings(raw);
65
+ const projected = compact
66
+ ? compactResponse(compactSourceResponse(result), TOOL_PRESERVE_PAYLOAD_KEYS["get-class-source"])
67
+ : result;
68
+ return { result: projected, warnings };
69
+ },
70
+ buildErrorSuggestedCall: (entry, sharedArtifact) => {
71
+ if (!sharedArtifact)
72
+ return undefined;
73
+ const params = {
74
+ target: { type: "artifact", artifactId: sharedArtifact.artifactId },
75
+ className: entry.className
76
+ };
77
+ if (entry.mode !== undefined)
78
+ params.mode = entry.mode;
79
+ if (entry.startLine !== undefined)
80
+ params.startLine = entry.startLine;
81
+ if (entry.endLine !== undefined)
82
+ params.endLine = entry.endLine;
83
+ if (entry.maxLines !== undefined)
84
+ params.maxLines = entry.maxLines;
85
+ if (entry.maxChars !== undefined)
86
+ params.maxChars = entry.maxChars;
87
+ if (entry.outputFile !== undefined)
88
+ params.outputFile = entry.outputFile;
89
+ if (input.mapping !== undefined)
90
+ params.mapping = input.mapping;
91
+ const { suggestedCall } = buildSuggestedCall({
92
+ tool: "get-class-source",
93
+ params
94
+ });
95
+ return suggestedCall;
96
+ }
97
+ });
98
+ }
99
+ }
100
+ //# sourceMappingURL=batch-class-source-service.js.map
@@ -0,0 +1,36 @@
1
+ import type { FindMappingInput, FindMappingOutput } from "../source-service.js";
2
+ import type { MappingSourcePriority, SourceMapping } from "../types.js";
3
+ export type BatchMappingsDeps = {
4
+ findMapping: (input: FindMappingInput) => Promise<FindMappingOutput>;
5
+ };
6
+ import { type BatchOutput } from "./batch-runner.js";
7
+ type SymbolKind = "class" | "field" | "method";
8
+ export type BatchMappingsEntry = {
9
+ kind: SymbolKind;
10
+ name: string;
11
+ owner?: string;
12
+ descriptor?: string;
13
+ sourceMapping: SourceMapping;
14
+ targetMapping: SourceMapping;
15
+ signatureMode?: "exact" | "name-only";
16
+ disambiguation?: {
17
+ ownerHint?: string;
18
+ descriptorHint?: string;
19
+ };
20
+ maxCandidates?: number;
21
+ };
22
+ export type BatchMappingsInput = {
23
+ version: string;
24
+ sourcePriority?: MappingSourcePriority;
25
+ projectPath?: string;
26
+ concurrency?: number;
27
+ failFast?: boolean;
28
+ compact?: boolean;
29
+ entries: readonly BatchMappingsEntry[];
30
+ };
31
+ export declare class BatchMappingsService {
32
+ private readonly deps;
33
+ constructor(deps: BatchMappingsDeps);
34
+ execute(input: BatchMappingsInput): Promise<BatchOutput<Record<string, unknown>>>;
35
+ }
36
+ export {};
@@ -0,0 +1,66 @@
1
+ import { buildSuggestedCall } from "../build-suggested-call.js";
2
+ import { compactResponse, compactMappingResponse } from "../response-utils.js";
3
+ import { runBatch, splitEntryWarnings } from "./batch-runner.js";
4
+ export class BatchMappingsService {
5
+ deps;
6
+ constructor(deps) {
7
+ this.deps = deps;
8
+ }
9
+ async execute(input) {
10
+ const concurrency = input.concurrency ?? 4;
11
+ const failFast = input.failFast ?? false;
12
+ const compact = input.compact ?? true;
13
+ return runBatch({
14
+ entries: input.entries,
15
+ concurrency,
16
+ failFast,
17
+ resolveSharedArtifact: async () => undefined,
18
+ perEntry: async (entry, _index) => {
19
+ const raw = (await this.deps.findMapping({
20
+ version: input.version,
21
+ kind: entry.kind,
22
+ name: entry.name,
23
+ owner: entry.owner,
24
+ descriptor: entry.descriptor,
25
+ sourceMapping: entry.sourceMapping,
26
+ targetMapping: entry.targetMapping,
27
+ sourcePriority: input.sourcePriority,
28
+ projectPath: input.projectPath,
29
+ signatureMode: entry.signatureMode,
30
+ disambiguation: entry.disambiguation,
31
+ maxCandidates: entry.maxCandidates
32
+ }));
33
+ const { result, warnings } = splitEntryWarnings(raw);
34
+ const projected = compact
35
+ ? compactResponse(compactMappingResponse(result))
36
+ : result;
37
+ return { result: projected, warnings };
38
+ },
39
+ buildErrorSuggestedCall: (entry) => {
40
+ const params = {
41
+ version: input.version,
42
+ kind: entry.kind,
43
+ name: entry.name,
44
+ sourceMapping: entry.sourceMapping,
45
+ targetMapping: entry.targetMapping
46
+ };
47
+ if (entry.owner !== undefined)
48
+ params.owner = entry.owner;
49
+ if (entry.descriptor !== undefined)
50
+ params.descriptor = entry.descriptor;
51
+ if (entry.signatureMode !== undefined)
52
+ params.signatureMode = entry.signatureMode;
53
+ if (entry.disambiguation !== undefined)
54
+ params.disambiguation = entry.disambiguation;
55
+ if (entry.maxCandidates !== undefined)
56
+ params.maxCandidates = entry.maxCandidates;
57
+ const { suggestedCall } = buildSuggestedCall({
58
+ tool: "find-mapping",
59
+ params
60
+ });
61
+ return suggestedCall;
62
+ }
63
+ });
64
+ }
65
+ }
66
+ //# sourceMappingURL=batch-mappings-service.js.map
@@ -0,0 +1,72 @@
1
+ import { type ProblemDetails, type SuggestedCall } from "../error-mapping.js";
2
+ export declare const BATCH_TOOLS_OFF: boolean;
3
+ export type BatchEntryOk<TResult> = {
4
+ index: number;
5
+ status: "ok";
6
+ result: TResult;
7
+ warnings: string[];
8
+ durationMs: number;
9
+ };
10
+ export type BatchEntryError = {
11
+ index: number;
12
+ status: "error";
13
+ error: ProblemDetails;
14
+ warnings: string[];
15
+ durationMs: number;
16
+ };
17
+ export type BatchEntryResult<TResult> = BatchEntryOk<TResult> | BatchEntryError;
18
+ export type BatchSummary = {
19
+ total: number;
20
+ ok: number;
21
+ error: number;
22
+ sharedArtifactId?: string;
23
+ sharedArtifactProvenance?: Record<string, unknown>;
24
+ /** Warnings from the one-shot shared `resolveArtifact` call (version
25
+ * approximation, mapping fallback, source coverage gaps, workspace /
26
+ * dependency resolution caveats). Per-entry dispatch is by `artifactId`
27
+ * and never re-runs resolution, so these warnings reach the caller only
28
+ * via this field. Omitted when the resolution emitted none. */
29
+ sharedArtifactWarnings?: string[];
30
+ };
31
+ export type BatchOutput<TResult> = {
32
+ results: BatchEntryResult<TResult>[];
33
+ summary: BatchSummary;
34
+ };
35
+ export type BatchRunOptions<TEntry, TResult, TArtifact> = {
36
+ entries: readonly TEntry[];
37
+ concurrency: number;
38
+ failFast: boolean;
39
+ /** Resolve the shared artifact once. May return undefined for batch tools that
40
+ * do not need a shared artifact (e.g. `batch-mappings`, where each entry is
41
+ * mapping-graph-only and does not depend on the artifact). Throws to abort the
42
+ * batch entirely with a top-level error envelope (handled by `runTool`). */
43
+ resolveSharedArtifact: () => Promise<TArtifact | undefined>;
44
+ /** Summary metadata derived from the resolved shared artifact. */
45
+ artifactSummary?: (artifact: TArtifact) => {
46
+ sharedArtifactId?: string;
47
+ sharedArtifactProvenance?: Record<string, unknown>;
48
+ sharedArtifactWarnings?: string[];
49
+ };
50
+ /** Per-entry handler. Returns `{ result, warnings }` on success. Errors thrown
51
+ * here are caught and converted to a per-entry ProblemDetails — the mapper
52
+ * itself never throws into `mapWithConcurrencyLimit`. */
53
+ perEntry: (entry: TEntry, index: number, sharedArtifact: TArtifact | undefined) => Promise<{
54
+ result: TResult;
55
+ warnings?: string[];
56
+ }>;
57
+ /** Synthesize the per-entry retry suggestedCall (proposing the matching single
58
+ * tool). Already validated through `buildSuggestedCall` by the caller; pass
59
+ * `undefined` when the suggestedCall could not be synthesized for this entry. */
60
+ buildErrorSuggestedCall: (entry: TEntry, sharedArtifact: TArtifact | undefined, error: unknown) => SuggestedCall | undefined;
61
+ /** Generate a fresh request-instance id per entry — defaults to the same
62
+ * scheme `runTool` uses (`<base36-time>-<base36-rand>`). Per-entry uniqueness
63
+ * is required so callers can correlate failed entries individually. */
64
+ buildEntryInstance?: (index: number) => string;
65
+ };
66
+ export declare function runBatch<TEntry, TResult, TArtifact>(opts: BatchRunOptions<TEntry, TResult, TArtifact>): Promise<BatchOutput<TResult>>;
67
+ /** Lift `warnings: string[]` off a service result onto the per-entry batch
68
+ * envelope, mirroring `runTool`'s `splitWarnings` for single-tool calls. */
69
+ export declare function splitEntryWarnings<T extends Record<string, unknown>>(raw: T): {
70
+ result: Omit<T, "warnings">;
71
+ warnings: string[];
72
+ };
@@ -0,0 +1,90 @@
1
+ import { mapWithConcurrencyLimit } from "../concurrency.js";
2
+ import { buildBatchAbortedProblem, errorToBatchEntryProblem } from "../error-mapping.js";
3
+ export const BATCH_TOOLS_OFF = process.env.BATCH_TOOLS_OFF === "1";
4
+ function defaultEntryInstance(index) {
5
+ return `${Date.now().toString(36)}-${index}-${Math.random().toString(36).slice(2, 10)}`;
6
+ }
7
+ export async function runBatch(opts) {
8
+ const sharedArtifact = await opts.resolveSharedArtifact();
9
+ const artifactSummary = sharedArtifact !== undefined && opts.artifactSummary
10
+ ? opts.artifactSummary(sharedArtifact)
11
+ : {};
12
+ let abort = false;
13
+ const buildInstance = opts.buildEntryInstance ?? defaultEntryInstance;
14
+ const results = await mapWithConcurrencyLimit(opts.entries, opts.concurrency, async (entry, index) => {
15
+ const startedAt = Date.now();
16
+ if (abort) {
17
+ return {
18
+ index,
19
+ status: "error",
20
+ error: buildBatchAbortedProblem(buildInstance(index)),
21
+ warnings: [],
22
+ durationMs: Date.now() - startedAt
23
+ };
24
+ }
25
+ try {
26
+ const { result, warnings } = await opts.perEntry(entry, index, sharedArtifact);
27
+ return {
28
+ index,
29
+ status: "ok",
30
+ result,
31
+ warnings: warnings ?? [],
32
+ durationMs: Date.now() - startedAt
33
+ };
34
+ }
35
+ catch (caught) {
36
+ const suggestedCall = opts.buildErrorSuggestedCall(entry, sharedArtifact, caught);
37
+ const problem = errorToBatchEntryProblem(caught, buildInstance(index), suggestedCall ? { suggestedCall } : undefined);
38
+ if (opts.failFast) {
39
+ abort = true;
40
+ }
41
+ return {
42
+ index,
43
+ status: "error",
44
+ error: problem,
45
+ warnings: [],
46
+ durationMs: Date.now() - startedAt
47
+ };
48
+ }
49
+ });
50
+ let okCount = 0;
51
+ let errorCount = 0;
52
+ for (const entry of results) {
53
+ if (entry.status === "ok")
54
+ okCount += 1;
55
+ else
56
+ errorCount += 1;
57
+ }
58
+ return {
59
+ results,
60
+ summary: {
61
+ total: results.length,
62
+ ok: okCount,
63
+ error: errorCount,
64
+ ...(artifactSummary.sharedArtifactId !== undefined
65
+ ? { sharedArtifactId: artifactSummary.sharedArtifactId }
66
+ : {}),
67
+ ...(artifactSummary.sharedArtifactProvenance !== undefined
68
+ ? { sharedArtifactProvenance: artifactSummary.sharedArtifactProvenance }
69
+ : {}),
70
+ ...(artifactSummary.sharedArtifactWarnings !== undefined &&
71
+ artifactSummary.sharedArtifactWarnings.length > 0
72
+ ? { sharedArtifactWarnings: artifactSummary.sharedArtifactWarnings }
73
+ : {})
74
+ }
75
+ };
76
+ }
77
+ /** Lift `warnings: string[]` off a service result onto the per-entry batch
78
+ * envelope, mirroring `runTool`'s `splitWarnings` for single-tool calls. */
79
+ export function splitEntryWarnings(raw) {
80
+ const { warnings, ...rest } = raw;
81
+ const list = [];
82
+ if (Array.isArray(warnings)) {
83
+ for (const w of warnings) {
84
+ if (typeof w === "string")
85
+ list.push(w);
86
+ }
87
+ }
88
+ return { result: rest, warnings: list };
89
+ }
90
+ //# sourceMappingURL=batch-runner.js.map
@@ -0,0 +1,46 @@
1
+ import type { CheckSymbolExistsInput, CheckSymbolExistsOutput, ResolveArtifactInput, ResolveArtifactOutput } from "../source-service.js";
2
+ import type { ArtifactScope, MappingSourcePriority, SourceMapping, WorkspaceTargetInput, SourceTargetInput } from "../types.js";
3
+ export type BatchSymbolExistsDeps = {
4
+ resolveArtifact: (input: ResolveArtifactInput) => Promise<ResolveArtifactOutput>;
5
+ checkSymbolExists: (input: CheckSymbolExistsInput) => Promise<CheckSymbolExistsOutput>;
6
+ };
7
+ import { type BatchOutput } from "./batch-runner.js";
8
+ type SymbolKind = "class" | "field" | "method";
9
+ export type BatchSymbolExistsEntry = {
10
+ kind: SymbolKind;
11
+ name: string;
12
+ owner?: string;
13
+ descriptor?: string;
14
+ nameMode?: "fqcn" | "auto";
15
+ signatureMode?: "exact" | "name-only";
16
+ maxCandidates?: number;
17
+ };
18
+ /**
19
+ * Subset of `ResolveArtifactTargetInput` accepted by `batch-symbol-exists`.
20
+ * Library/jar/coordinate targets carry the library's own version, not the
21
+ * Minecraft version, so querying the Minecraft mapping graph with that value
22
+ * would be a category error. The zod schema rejects the disallowed kinds.
23
+ */
24
+ export type BatchSymbolExistsTarget = (SourceTargetInput & {
25
+ kind: "version";
26
+ }) | WorkspaceTargetInput;
27
+ export type BatchSymbolExistsInput = {
28
+ target: BatchSymbolExistsTarget;
29
+ mapping?: SourceMapping;
30
+ sourcePriority?: MappingSourcePriority;
31
+ allowDecompile?: boolean;
32
+ projectPath?: string;
33
+ scope?: ArtifactScope;
34
+ preferProjectVersion?: boolean;
35
+ strictVersion?: boolean;
36
+ concurrency?: number;
37
+ failFast?: boolean;
38
+ compact?: boolean;
39
+ entries: readonly BatchSymbolExistsEntry[];
40
+ };
41
+ export declare class BatchSymbolExistsService {
42
+ private readonly deps;
43
+ constructor(deps: BatchSymbolExistsDeps);
44
+ execute(input: BatchSymbolExistsInput): Promise<BatchOutput<Record<string, unknown>>>;
45
+ }
46
+ export {};
@@ -0,0 +1,113 @@
1
+ import { buildSuggestedCall } from "../build-suggested-call.js";
2
+ import { createError, ERROR_CODES } from "../errors.js";
3
+ import { compactResponse, compactMappingResponse } from "../response-utils.js";
4
+ import { runBatch, splitEntryWarnings } from "./batch-runner.js";
5
+ function deriveMinecraftVersion(resolvedVersion, workspaceVersion) {
6
+ const candidate = resolvedVersion?.trim() || workspaceVersion?.trim();
7
+ if (!candidate) {
8
+ throw createError({
9
+ code: ERROR_CODES.WORKSPACE_VERSION_UNRESOLVED,
10
+ message: "batch-symbol-exists could not derive a Minecraft version from the shared artifact (use target.kind=version or set projectPath so the workspace resolution detects it).",
11
+ details: {
12
+ nextAction: "Pass target.kind=\"version\" with the desired Minecraft version, or ensure target.kind=\"workspace\" projectPath points to a Loom/Forge project whose gradle.properties carries minecraft_version."
13
+ }
14
+ });
15
+ }
16
+ return candidate;
17
+ }
18
+ export class BatchSymbolExistsService {
19
+ deps;
20
+ constructor(deps) {
21
+ this.deps = deps;
22
+ }
23
+ async execute(input) {
24
+ const concurrency = input.concurrency ?? 4;
25
+ const failFast = input.failFast ?? false;
26
+ const compact = input.compact ?? true;
27
+ return runBatch({
28
+ entries: input.entries,
29
+ concurrency,
30
+ failFast,
31
+ resolveSharedArtifact: async () => {
32
+ const resolved = await this.deps.resolveArtifact({
33
+ target: input.target,
34
+ mapping: input.mapping,
35
+ sourcePriority: input.sourcePriority,
36
+ allowDecompile: input.allowDecompile,
37
+ projectPath: input.projectPath,
38
+ scope: input.scope,
39
+ preferProjectVersion: input.preferProjectVersion,
40
+ strictVersion: input.strictVersion
41
+ });
42
+ const provenance = resolved.provenance;
43
+ const workspaceVersion = provenance?.workspaceResolution?.detected?.minecraftVersion;
44
+ const version = deriveMinecraftVersion(resolved.version, workspaceVersion);
45
+ return {
46
+ artifactId: resolved.artifactId,
47
+ provenance: resolved.provenance,
48
+ version,
49
+ sourceMapping: resolved.mappingApplied,
50
+ ...(Array.isArray(resolved.warnings) && resolved.warnings.length > 0
51
+ ? { warnings: [...resolved.warnings] }
52
+ : {})
53
+ };
54
+ },
55
+ artifactSummary: (artifact) => ({
56
+ sharedArtifactId: artifact.artifactId,
57
+ ...(artifact.provenance ? { sharedArtifactProvenance: artifact.provenance } : {}),
58
+ ...(artifact.warnings && artifact.warnings.length > 0
59
+ ? { sharedArtifactWarnings: artifact.warnings }
60
+ : {})
61
+ }),
62
+ perEntry: async (entry, _index, sharedArtifact) => {
63
+ if (!sharedArtifact) {
64
+ throw new Error("shared artifact not resolved");
65
+ }
66
+ const raw = (await this.deps.checkSymbolExists({
67
+ version: sharedArtifact.version,
68
+ kind: entry.kind,
69
+ name: entry.name,
70
+ owner: entry.owner,
71
+ descriptor: entry.descriptor,
72
+ sourceMapping: sharedArtifact.sourceMapping,
73
+ sourcePriority: input.sourcePriority,
74
+ nameMode: entry.nameMode,
75
+ signatureMode: entry.signatureMode,
76
+ maxCandidates: entry.maxCandidates,
77
+ projectPath: input.projectPath
78
+ }));
79
+ const { result, warnings } = splitEntryWarnings(raw);
80
+ const projected = compact
81
+ ? compactResponse(compactMappingResponse(result))
82
+ : result;
83
+ return { result: projected, warnings };
84
+ },
85
+ buildErrorSuggestedCall: (entry, sharedArtifact) => {
86
+ if (!sharedArtifact)
87
+ return undefined;
88
+ const params = {
89
+ version: sharedArtifact.version,
90
+ kind: entry.kind,
91
+ name: entry.name,
92
+ sourceMapping: sharedArtifact.sourceMapping
93
+ };
94
+ if (entry.owner !== undefined)
95
+ params.owner = entry.owner;
96
+ if (entry.descriptor !== undefined)
97
+ params.descriptor = entry.descriptor;
98
+ if (entry.nameMode !== undefined)
99
+ params.nameMode = entry.nameMode;
100
+ if (entry.signatureMode !== undefined)
101
+ params.signatureMode = entry.signatureMode;
102
+ if (entry.maxCandidates !== undefined)
103
+ params.maxCandidates = entry.maxCandidates;
104
+ const { suggestedCall } = buildSuggestedCall({
105
+ tool: "check-symbol-exists",
106
+ params
107
+ });
108
+ return suggestedCall;
109
+ }
110
+ });
111
+ }
112
+ }
113
+ //# sourceMappingURL=batch-symbol-exists-service.js.map