@adhisang/minecraft-modding-mcp 6.1.1 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +40 -1
  2. package/README.md +12 -4
  3. package/dist/cache-registry.d.ts +1 -1
  4. package/dist/cache-registry.js +3 -0
  5. package/dist/entry-tools/analyze-mod-service.d.ts +12 -6
  6. package/dist/entry-tools/analyze-mod-service.js +37 -3
  7. package/dist/entry-tools/analyze-symbol-service.d.ts +6 -4
  8. package/dist/entry-tools/analyze-symbol-service.js +37 -2
  9. package/dist/entry-tools/inspect-minecraft/internal.d.ts +7 -3
  10. package/dist/entry-tools/inspect-minecraft/internal.js +43 -15
  11. package/dist/entry-tools/inspect-minecraft-service.d.ts +12 -12
  12. package/dist/entry-tools/inspect-minecraft-service.js +1 -1
  13. package/dist/entry-tools/manage-cache-service.d.ts +4 -4
  14. package/dist/error-mapping.d.ts +13 -0
  15. package/dist/error-mapping.js +35 -2
  16. package/dist/errors.d.ts +2 -0
  17. package/dist/errors.js +2 -0
  18. package/dist/index.js +39 -20
  19. package/dist/mapping/internal-types.d.ts +7 -0
  20. package/dist/mapping/types.d.ts +18 -0
  21. package/dist/mapping-service.js +16 -3
  22. package/dist/minecraft-explorer-service.d.ts +4 -0
  23. package/dist/minecraft-explorer-service.js +156 -17
  24. package/dist/mod-analyzer.d.ts +7 -0
  25. package/dist/mod-analyzer.js +28 -7
  26. package/dist/source/artifact-resolver.d.ts +2 -0
  27. package/dist/source/artifact-resolver.js +24 -1
  28. package/dist/source/class-source/members-builder.d.ts +4 -0
  29. package/dist/source/class-source/members-builder.js +3 -1
  30. package/dist/source/class-source.d.ts +3 -1
  31. package/dist/source/class-source.js +192 -19
  32. package/dist/source/did-you-mean.d.ts +14 -0
  33. package/dist/source/did-you-mean.js +79 -0
  34. package/dist/source/file-access.js +159 -3
  35. package/dist/source/indexer.js +72 -2
  36. package/dist/source/lifecycle/runtime-check.js +9 -5
  37. package/dist/source/nested-jars.d.ts +78 -0
  38. package/dist/source/nested-jars.js +267 -0
  39. package/dist/source/workspace-target.js +5 -2
  40. package/dist/source-jar-reader.d.ts +16 -0
  41. package/dist/source-jar-reader.js +82 -0
  42. package/dist/source-service.d.ts +37 -0
  43. package/dist/source-service.js +52 -6
  44. package/dist/stage-emitter.js +24 -8
  45. package/dist/stdio-supervisor.d.ts +92 -9
  46. package/dist/stdio-supervisor.js +915 -103
  47. package/dist/tool-contract-manifest.js +2 -2
  48. package/dist/tool-guidance.js +115 -7
  49. package/dist/tool-schemas.d.ts +1343 -149
  50. package/dist/tool-schemas.js +39 -7
  51. package/dist/types.d.ts +23 -0
  52. package/dist/workspace-mapping-service.d.ts +1 -0
  53. package/dist/workspace-mapping-service.js +120 -8
  54. package/docs/README-ja.md +4 -0
  55. package/docs/tool-reference.md +92 -6
  56. package/package.json +5 -5
@@ -15,7 +15,7 @@ const SECTION_ROWS = {
15
15
  "| `inspect-minecraft` | Inspect versions, artifacts, classes, files, source text, and workspace-aware lookup flows |",
16
16
  "| `analyze-symbol` | Handle symbol existence checks, namespace mapping, lifecycle tracing, workspace symbol resolution, and API overviews |",
17
17
  "| `compare-minecraft` | Compare version pairs, class diffs, registry diffs, and migration-oriented summaries |",
18
- "| `analyze-mod` | Summarize mod metadata, decompile and search mod code, inspect class source, and preview or apply remaps |",
18
+ "| `analyze-mod` | Summarize mod metadata, decompile and search mod code, inspect class source, read class members from bytecode, and preview or apply remaps |",
19
19
  "| `validate-project` | Summarize workspaces and run direct Mixin, Access Widener, or Access Transformer validation |",
20
20
  "| `manage-cache` | List, verify, and preview or apply cache cleanup and rebuild operations |"
21
21
  ],
@@ -32,7 +32,7 @@ const SECTION_ROWS = {
32
32
  en: [
33
33
  "| `list-versions` | List available Minecraft versions from Mojang metadata and local cache |",
34
34
  "| `resolve-artifact` | Resolve source artifacts from versions, JAR paths, or Maven coordinates |",
35
- "| `find-class` | Find simple or fully-qualified class names inside an artifact |",
35
+ "| `find-class` | Find simple or fully-qualified class names, including classes bundled in nested JARs |",
36
36
  "| `get-class-source` | Read class source from an artifact or resolve the backing artifact on demand |",
37
37
  "| `get-class-members` | List constructors, fields, and methods from bytecode |",
38
38
  "| `search-class-source` | Search indexed class source by symbol, text, or path |",
@@ -1,7 +1,7 @@
1
1
  import { ZodError } from "zod";
2
2
  import { buildSuggestedCall } from "./build-suggested-call.js";
3
3
  import { ERROR_CODES, isAppError } from "./errors.js";
4
- import { extractAllowlistedContext, issueOriginForErrorCode, retryClassForErrorCode, statusForErrorCode } from "./error-mapping.js";
4
+ import { extractAllowlistedContext, extractDidYouMean, issueOriginForErrorCode, retryClassForErrorCode, statusForErrorCode } from "./error-mapping.js";
5
5
  export const SUGGESTED_CALL_DEFAULTS = {
6
6
  allowDecompile: true,
7
7
  preferProjectVersion: false,
@@ -656,7 +656,103 @@ function gatedGuidance(tool, hints, params) {
656
656
  primaryDropped: !validated.suggestedCall
657
657
  };
658
658
  }
659
+ function buildInspectWorkspaceSubject(source) {
660
+ const subject = {
661
+ kind: "workspace",
662
+ projectPath: asNonEmptyString(source.projectPath) ?? "<workspace-path>"
663
+ };
664
+ if (typeof source.mapping === "string" &&
665
+ ["obfuscated", "mojang", "intermediary", "yarn"].includes(source.mapping)) {
666
+ subject.mapping = source.mapping;
667
+ }
668
+ if (typeof source.scope === "string" &&
669
+ ["vanilla", "merged", "loader"].includes(source.scope)) {
670
+ subject.scope = source.scope;
671
+ }
672
+ const gradleUserHome = asNonEmptyString(source.gradleUserHome);
673
+ if (gradleUserHome) {
674
+ subject.gradleUserHome = gradleUserHome;
675
+ }
676
+ if (typeof source.preferProjectVersion === "boolean") {
677
+ subject.preferProjectVersion = source.preferProjectVersion;
678
+ }
679
+ if (typeof source.strictVersion === "boolean") {
680
+ subject.strictVersion = source.strictVersion;
681
+ }
682
+ return subject;
683
+ }
684
+ function inspectTaskForFocus(task, focusKind) {
685
+ if (focusKind === "class" &&
686
+ (task === "auto" || task === "class-overview" || task === "class-source" || task === "class-members")) {
687
+ return task;
688
+ }
689
+ if (focusKind === "search" && (task === "auto" || task === "search")) {
690
+ return task;
691
+ }
692
+ if (focusKind === "file" && (task === "auto" || task === "file")) {
693
+ return task;
694
+ }
695
+ return "auto";
696
+ }
697
+ function buildInspectMinecraftInvalidFocusGuidance(normalizedInput) {
698
+ const input = asObjectRecord(normalizedInput);
699
+ const originalSubject = asObjectRecord(input?.subject);
700
+ if (originalSubject?.kind !== "workspace" ||
701
+ originalSubject.focus === undefined ||
702
+ asObjectRecord(originalSubject.focus)) {
703
+ return undefined;
704
+ }
705
+ const requestedTask = asNonEmptyString(input?.task);
706
+ const workspaceSubject = buildInspectWorkspaceSubject(originalSubject);
707
+ const examples = [
708
+ {
709
+ params: {
710
+ task: inspectTaskForFocus(requestedTask, "class"),
711
+ subject: {
712
+ ...workspaceSubject,
713
+ focus: { kind: "class", className: "<fully-qualified-class-name>" }
714
+ }
715
+ },
716
+ reason: "Use class focus for class overview, source, or member inspection."
717
+ },
718
+ {
719
+ params: {
720
+ task: inspectTaskForFocus(requestedTask, "search"),
721
+ subject: {
722
+ ...workspaceSubject,
723
+ focus: { kind: "search", query: "<search-query>" }
724
+ }
725
+ },
726
+ reason: "Use search focus for symbol, text, or path search."
727
+ },
728
+ {
729
+ params: {
730
+ task: inspectTaskForFocus(requestedTask, "file"),
731
+ subject: {
732
+ ...workspaceSubject,
733
+ focus: { kind: "file", filePath: "<artifact-relative-file-path>" }
734
+ }
735
+ },
736
+ reason: "Use file focus for an artifact-relative file read."
737
+ }
738
+ ];
739
+ const validated = buildSuggestedCall({
740
+ tool: "inspect-minecraft",
741
+ params: undefined,
742
+ examples
743
+ });
744
+ return {
745
+ hints: [
746
+ "inspect-minecraft subject.focus must be a structured object, not a string.",
747
+ "Choose focus.kind=class with className, search with query, or file with filePath; task=auto dispatches from that kind and does not interpret prose."
748
+ ],
749
+ ...(validated.exampleCalls ? { exampleCalls: validated.exampleCalls } : {})
750
+ };
751
+ }
659
752
  export function buildInvalidInputGuidance(tool, normalizedInput) {
753
+ if (tool === "inspect-minecraft") {
754
+ return buildInspectMinecraftInvalidFocusGuidance(normalizedInput);
755
+ }
660
756
  if (tool === "validate-mixin") {
661
757
  return gatedGuidance(tool, [
662
758
  "validate-mixin.input must be an object with input.mode = \"inline\" | \"path\" | \"paths\" | \"config\" | \"project\".",
@@ -719,17 +815,28 @@ export function mapErrorToProblem(caughtError, requestId, context) {
719
815
  }
720
816
  if (isAppError(caughtError)) {
721
817
  const { suggestedCall, exampleCalls, primaryDropped } = extractValidatedSuggestionAndExamples(caughtError.details);
818
+ const invalidInputGuidance = context?.tool === "inspect-minecraft" && caughtError.code === ERROR_CODES.INVALID_INPUT
819
+ ? buildInvalidInputGuidance(context.tool, context.normalizedInput)
820
+ : undefined;
821
+ const effectiveSuggestedCall = invalidInputGuidance
822
+ ? invalidInputGuidance.suggestedCall
823
+ : suggestedCall;
824
+ const effectiveExampleCalls = invalidInputGuidance?.exampleCalls ?? exampleCalls;
722
825
  const sanitizedContext = extractAllowlistedContext(caughtError.details);
826
+ const extractedDidYouMean = extractDidYouMean(caughtError.details);
723
827
  let failedStage = extractFailedStageFromDetails(caughtError.details);
724
828
  if (!failedStage
725
829
  && context?.tool === "validate-mixin"
726
830
  && caughtError.code === ERROR_CODES.INVALID_INPUT) {
727
831
  failedStage = "input-validation";
728
832
  }
729
- const baseHints = toHints(caughtError.details);
730
- const hintsWithFallback = primaryDropped && !suggestedCall
731
- ? [...(baseHints ?? []), VALIDATION_FALLBACK_HINT]
732
- : baseHints;
833
+ const baseHints = [
834
+ ...(toHints(caughtError.details) ?? []),
835
+ ...(invalidInputGuidance?.hints ?? [])
836
+ ];
837
+ const hintsWithFallback = primaryDropped && !effectiveSuggestedCall
838
+ ? [...baseHints, VALIDATION_FALLBACK_HINT]
839
+ : baseHints.length > 0 ? baseHints : undefined;
733
840
  return {
734
841
  type: `https://minecraft-modding-mcp.dev/problems/${caughtError.code.toLowerCase()}`,
735
842
  title: "Tool execution error",
@@ -741,8 +848,9 @@ export function mapErrorToProblem(caughtError, requestId, context) {
741
848
  issueOrigin: issueOriginForErrorCode(caughtError.code),
742
849
  fieldErrors: extractFieldErrorsFromDetails(caughtError.details),
743
850
  hints: hintsWithFallback,
744
- ...(suggestedCall ? { suggestedCall } : {}),
745
- ...(exampleCalls ? { exampleCalls } : {}),
851
+ ...(effectiveSuggestedCall ? { suggestedCall: effectiveSuggestedCall } : {}),
852
+ ...(effectiveExampleCalls ? { exampleCalls: effectiveExampleCalls } : {}),
853
+ ...(extractedDidYouMean ? { didYouMean: extractedDidYouMean } : {}),
746
854
  ...(failedStage ? { failedStage } : {}),
747
855
  ...(sanitizedContext ? { context: sanitizedContext } : {})
748
856
  };