@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,18 @@
|
|
|
1
|
+
import type { SourceService } from "../source-service.js";
|
|
2
|
+
import type { ArtifactScope, DependencyResolutionProvenance, DependencyTargetInput, SourceMapping, SourceTargetInput, WorkspaceResolutionProvenance, WorkspaceTargetInput } from "../types.js";
|
|
3
|
+
import type { WorkspaceContext } from "../workspace-context-cache.js";
|
|
4
|
+
import type { ResolveArtifactInput } from "../source-service.js";
|
|
5
|
+
export declare function loadOrDetectWorkspaceContext(svc: SourceService, projectPath: string): Promise<WorkspaceContext>;
|
|
6
|
+
export declare function synthesizeWorkspaceTarget(svc: SourceService, input: ResolveArtifactInput, workspace: WorkspaceTargetInput): Promise<{
|
|
7
|
+
target: SourceTargetInput;
|
|
8
|
+
scope?: ArtifactScope;
|
|
9
|
+
mapping?: SourceMapping;
|
|
10
|
+
provenance: WorkspaceResolutionProvenance;
|
|
11
|
+
warnings: string[];
|
|
12
|
+
}>;
|
|
13
|
+
export declare function synthesizeDependencyTarget(svc: SourceService, input: ResolveArtifactInput, dep: DependencyTargetInput): Promise<{
|
|
14
|
+
target: SourceTargetInput;
|
|
15
|
+
provenance: DependencyResolutionProvenance;
|
|
16
|
+
requestedMapping?: SourceMapping;
|
|
17
|
+
warnings: string[];
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { buildSuggestedCall } from "../build-suggested-call.js";
|
|
2
|
+
import { ERROR_CODES, createError } from "../errors.js";
|
|
3
|
+
import { isSafeMavenVersionToken } from "../workspace-mapping-service.js";
|
|
4
|
+
import { normalizeMapping } from "./shared-utils.js";
|
|
5
|
+
// Env toggles are read at call time, not at module load: tests dynamically
|
|
6
|
+
// re-import source-service.ts with a cache-busting query to flip the flag,
|
|
7
|
+
// but cannot bust this module's cache through that path.
|
|
8
|
+
export async function loadOrDetectWorkspaceContext(svc, projectPath) {
|
|
9
|
+
const cached = svc.workspaceContextCache.read(projectPath);
|
|
10
|
+
if (cached && !cached.partial) {
|
|
11
|
+
return cached;
|
|
12
|
+
}
|
|
13
|
+
const [minecraftVersion, mappingResult, loaderResult] = await Promise.all([
|
|
14
|
+
svc.workspaceMappingService.detectProjectMinecraftVersion(projectPath),
|
|
15
|
+
svc.workspaceMappingService.detectCompileMapping({ projectPath }).catch(() => undefined),
|
|
16
|
+
svc.workspaceMappingService.detectProjectLoader(projectPath).catch(() => undefined)
|
|
17
|
+
]);
|
|
18
|
+
const evidence = [];
|
|
19
|
+
if (minecraftVersion) {
|
|
20
|
+
evidence.push({
|
|
21
|
+
source: "gradle.properties",
|
|
22
|
+
field: "minecraft_version",
|
|
23
|
+
value: minecraftVersion
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (mappingResult?.resolved && mappingResult.evidence[0]) {
|
|
27
|
+
evidence.push({
|
|
28
|
+
source: mappingResult.evidence[0].filePath,
|
|
29
|
+
field: "compileMapping",
|
|
30
|
+
value: mappingResult.mappingApplied
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (loaderResult?.resolved && loaderResult.evidence[0]) {
|
|
34
|
+
evidence.push({
|
|
35
|
+
source: loaderResult.evidence[0].filePath,
|
|
36
|
+
field: "loader",
|
|
37
|
+
value: loaderResult.loader
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const ctx = {
|
|
41
|
+
projectPath,
|
|
42
|
+
minecraftVersion,
|
|
43
|
+
compileMapping: mappingResult?.resolved ? mappingResult.mappingApplied : undefined,
|
|
44
|
+
loader: loaderResult?.resolved ? loaderResult.loader : undefined,
|
|
45
|
+
detectedAt: Date.now(),
|
|
46
|
+
evidence,
|
|
47
|
+
dependencyVersions: cached?.dependencyVersions ?? new Map(),
|
|
48
|
+
partial: false
|
|
49
|
+
};
|
|
50
|
+
svc.workspaceContextCache.write(ctx);
|
|
51
|
+
return ctx;
|
|
52
|
+
}
|
|
53
|
+
export async function synthesizeWorkspaceTarget(svc, input, workspace) {
|
|
54
|
+
if (process.env.WORKSPACE_TARGET_OFF === "1") {
|
|
55
|
+
throw createError({
|
|
56
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
57
|
+
message: 'target.kind="workspace" is disabled by WORKSPACE_TARGET_OFF=1.',
|
|
58
|
+
details: {
|
|
59
|
+
fieldErrors: [{ path: "target.kind", message: 'target.kind="workspace" is disabled.' }]
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const projectPath = input.projectPath?.trim();
|
|
64
|
+
if (!projectPath) {
|
|
65
|
+
throw createError({
|
|
66
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
67
|
+
message: 'projectPath is required when target.kind="workspace".',
|
|
68
|
+
details: {
|
|
69
|
+
fieldErrors: [{ path: "projectPath", message: 'projectPath is required when target.kind="workspace".' }]
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const cachedBefore = svc.workspaceContextCache.read(projectPath);
|
|
74
|
+
const cacheHit = Boolean(cachedBefore && !cachedBefore.partial);
|
|
75
|
+
const ctx = cacheHit ? cachedBefore : await svc.loadOrDetectWorkspaceContext(projectPath);
|
|
76
|
+
const warnings = [];
|
|
77
|
+
const resolvedVersion = ctx.minecraftVersion;
|
|
78
|
+
if (!resolvedVersion) {
|
|
79
|
+
throw createError({
|
|
80
|
+
code: ERROR_CODES.WORKSPACE_VERSION_UNRESOLVED,
|
|
81
|
+
message: `Could not detect a Minecraft version for projectPath "${projectPath}".`,
|
|
82
|
+
details: {
|
|
83
|
+
projectPath,
|
|
84
|
+
strict: workspace.strict === true,
|
|
85
|
+
nextAction: "Set minecraft_version in gradle.properties or pass target.kind=\"version\" with an explicit Minecraft version.",
|
|
86
|
+
...buildSuggestedCall({
|
|
87
|
+
tool: "resolve-artifact",
|
|
88
|
+
params: {
|
|
89
|
+
target: { kind: "version", value: "<your-mc-version>" },
|
|
90
|
+
projectPath
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const requestedMapping = normalizeMapping(input.mapping);
|
|
97
|
+
let effectiveMapping;
|
|
98
|
+
if (input.mapping) {
|
|
99
|
+
effectiveMapping = requestedMapping;
|
|
100
|
+
if (ctx.compileMapping && ctx.compileMapping !== requestedMapping) {
|
|
101
|
+
warnings.push(`Compile mapping mismatch (workspace=${ctx.compileMapping}, requested=${requestedMapping}); using requested mapping.`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
effectiveMapping = ctx.compileMapping ?? "obfuscated";
|
|
106
|
+
}
|
|
107
|
+
const effectiveScope = workspace.scope ?? input.scope ?? (ctx.loader ? "merged" : "vanilla");
|
|
108
|
+
const provenance = {
|
|
109
|
+
projectPath,
|
|
110
|
+
detected: {
|
|
111
|
+
minecraftVersion: ctx.minecraftVersion,
|
|
112
|
+
compileMapping: ctx.compileMapping,
|
|
113
|
+
loader: ctx.loader
|
|
114
|
+
},
|
|
115
|
+
source: ctx.evidence
|
|
116
|
+
.map((entry) => `${entry.source}:${entry.field}`)
|
|
117
|
+
.join("; ") || (cacheHit ? "workspace-context-cache" : "workspace-detection"),
|
|
118
|
+
cacheHit,
|
|
119
|
+
warnings: [...warnings]
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
target: { kind: "version", value: resolvedVersion },
|
|
123
|
+
scope: effectiveScope,
|
|
124
|
+
mapping: effectiveMapping,
|
|
125
|
+
provenance,
|
|
126
|
+
warnings
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export async function synthesizeDependencyTarget(svc, input, dep) {
|
|
130
|
+
if (process.env.DEPENDENCY_TARGET_OFF === "1") {
|
|
131
|
+
throw createError({
|
|
132
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
133
|
+
message: 'target.kind="dependency" is disabled by DEPENDENCY_TARGET_OFF=1.',
|
|
134
|
+
details: {
|
|
135
|
+
fieldErrors: [{ path: "target.kind", message: 'target.kind="dependency" is disabled.' }]
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const group = dep.group?.trim();
|
|
140
|
+
const name = dep.name?.trim();
|
|
141
|
+
if (!group || !name) {
|
|
142
|
+
throw createError({
|
|
143
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
144
|
+
message: 'target.kind="dependency" requires non-empty group and name.',
|
|
145
|
+
details: {
|
|
146
|
+
fieldErrors: [
|
|
147
|
+
...(group ? [] : [{ path: "target.group", message: "group is required" }]),
|
|
148
|
+
...(name ? [] : [{ path: "target.name", message: "name is required" }])
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (group.includes("/") ||
|
|
154
|
+
group.includes("\\") ||
|
|
155
|
+
group.includes("..") ||
|
|
156
|
+
group.includes("\0") ||
|
|
157
|
+
name.includes("/") ||
|
|
158
|
+
name.includes("\\") ||
|
|
159
|
+
name.includes("..") ||
|
|
160
|
+
name.includes("\0")) {
|
|
161
|
+
throw createError({
|
|
162
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
163
|
+
message: 'target.kind="dependency" group/name must not contain path traversal characters.',
|
|
164
|
+
details: {
|
|
165
|
+
fieldErrors: [{ path: "target", message: "group and name must not contain '/', '\\', '..', or NUL." }]
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (dep.version) {
|
|
170
|
+
if (!isSafeMavenVersionToken(dep.version)) {
|
|
171
|
+
throw createError({
|
|
172
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
173
|
+
message: 'target.kind="dependency" version must be a safe Maven coordinate segment.',
|
|
174
|
+
details: {
|
|
175
|
+
fieldErrors: [
|
|
176
|
+
{
|
|
177
|
+
path: "target.version",
|
|
178
|
+
message: "version must contain only [A-Za-z0-9._+-] characters, must not start with '.', and must not include '..'."
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const coordinate = `${group}:${name}:${dep.version}`;
|
|
185
|
+
return {
|
|
186
|
+
target: { kind: "coordinate", value: coordinate },
|
|
187
|
+
requestedMapping: input.mapping ? normalizeMapping(input.mapping) : undefined,
|
|
188
|
+
warnings: [],
|
|
189
|
+
provenance: {
|
|
190
|
+
group,
|
|
191
|
+
name,
|
|
192
|
+
resolvedVersion: dep.version,
|
|
193
|
+
source: "explicit",
|
|
194
|
+
cacheHit: false
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (dep.versionFromProject === false) {
|
|
199
|
+
throw createError({
|
|
200
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
201
|
+
message: 'target.kind="dependency" requires version when versionFromProject=false.',
|
|
202
|
+
details: {
|
|
203
|
+
fieldErrors: [
|
|
204
|
+
{ path: "target.version", message: "version is required when versionFromProject=false." }
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const projectPath = input.projectPath?.trim();
|
|
210
|
+
if (!projectPath) {
|
|
211
|
+
throw createError({
|
|
212
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
213
|
+
message: 'projectPath is required when target.kind="dependency" without an explicit version.',
|
|
214
|
+
details: {
|
|
215
|
+
fieldErrors: [{ path: "projectPath", message: 'projectPath is required for dependency target without version.' }]
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const cacheKey = `${group}:${name}`;
|
|
220
|
+
const ctxBefore = svc.workspaceContextCache.read(projectPath);
|
|
221
|
+
const cachedVersion = ctxBefore?.dependencyVersions.get(cacheKey);
|
|
222
|
+
const warningsBucket = [];
|
|
223
|
+
if (cachedVersion) {
|
|
224
|
+
const coordinate = `${group}:${name}:${cachedVersion}`;
|
|
225
|
+
return {
|
|
226
|
+
target: { kind: "coordinate", value: coordinate },
|
|
227
|
+
requestedMapping: input.mapping ? normalizeMapping(input.mapping) : undefined,
|
|
228
|
+
warnings: [],
|
|
229
|
+
provenance: {
|
|
230
|
+
group,
|
|
231
|
+
name,
|
|
232
|
+
resolvedVersion: cachedVersion,
|
|
233
|
+
source: "workspace-context-cache",
|
|
234
|
+
cacheHit: true
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const result = await svc.workspaceMappingService.detectDependencyVersion(projectPath, group, name);
|
|
239
|
+
if (!result.resolved) {
|
|
240
|
+
const ambiguous = result.candidatesSeen.length > 1;
|
|
241
|
+
const message = ambiguous
|
|
242
|
+
? `Multiple cached versions for ${group}:${name} in ~/.gradle/caches/modules-2 (${result.candidatesSeen.join(", ")}); refusing to pick without project-specific evidence.`
|
|
243
|
+
: `Could not resolve a version for dependency ${group}:${name} from gradle.properties or modules-2 cache.`;
|
|
244
|
+
const nextAction = ambiguous
|
|
245
|
+
? `Set ${name}_version (or another supported gradle.properties key) so the project's intended version is unambiguous, or pass an explicit version on the dependency target.`
|
|
246
|
+
: "Provide an explicit version on the dependency target, or add a property to gradle.properties so detectDependencyVersion can find it.";
|
|
247
|
+
throw createError({
|
|
248
|
+
code: ERROR_CODES.DEPENDENCY_VERSION_UNRESOLVED,
|
|
249
|
+
message,
|
|
250
|
+
details: {
|
|
251
|
+
group,
|
|
252
|
+
name,
|
|
253
|
+
attempts: result.attempts,
|
|
254
|
+
candidatesSeen: result.candidatesSeen,
|
|
255
|
+
ambiguous,
|
|
256
|
+
nextAction,
|
|
257
|
+
...buildSuggestedCall({
|
|
258
|
+
tool: "resolve-artifact",
|
|
259
|
+
params: {
|
|
260
|
+
target: {
|
|
261
|
+
kind: "dependency",
|
|
262
|
+
group,
|
|
263
|
+
name,
|
|
264
|
+
version: "<your-version>"
|
|
265
|
+
},
|
|
266
|
+
projectPath
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
const ctxAfter = svc.workspaceContextCache.read(projectPath);
|
|
273
|
+
if (ctxAfter) {
|
|
274
|
+
const updatedDeps = new Map(ctxAfter.dependencyVersions);
|
|
275
|
+
updatedDeps.set(cacheKey, result.version);
|
|
276
|
+
svc.workspaceContextCache.write({ ...ctxAfter, dependencyVersions: updatedDeps });
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
const updatedDeps = new Map();
|
|
280
|
+
updatedDeps.set(cacheKey, result.version);
|
|
281
|
+
svc.workspaceContextCache.write({
|
|
282
|
+
projectPath,
|
|
283
|
+
detectedAt: Date.now(),
|
|
284
|
+
evidence: [],
|
|
285
|
+
dependencyVersions: updatedDeps,
|
|
286
|
+
partial: true
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
const coordinate = `${group}:${name}:${result.version}`;
|
|
290
|
+
return {
|
|
291
|
+
target: { kind: "coordinate", value: coordinate },
|
|
292
|
+
requestedMapping: input.mapping ? normalizeMapping(input.mapping) : undefined,
|
|
293
|
+
warnings: warningsBucket,
|
|
294
|
+
provenance: {
|
|
295
|
+
group,
|
|
296
|
+
name,
|
|
297
|
+
resolvedVersion: result.version,
|
|
298
|
+
source: result.source,
|
|
299
|
+
candidatesSeen: result.candidatesSeen,
|
|
300
|
+
attempts: result.attempts,
|
|
301
|
+
cacheHit: false
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=workspace-target.js.map
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import type { Config, ResolvedSourceArtifact, SourceTargetInput } from "./types.js";
|
|
1
|
+
import type { Config, MappingVariant, ResolvedSourceArtifact, SourceTargetInput } from "./types.js";
|
|
2
|
+
export type { MappingVariant } from "./types.js";
|
|
2
3
|
export interface ResolveSourceTargetOptions {
|
|
3
4
|
allowDecompile: boolean;
|
|
4
5
|
preferBinaryOnly?: boolean;
|
|
5
6
|
preferredRepos?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* When set to "mojang-remapped", the artifactId hash gets a dedicated
|
|
9
|
+
* suffix so the mojang-remapped variant of an otherwise binary-only artifact
|
|
10
|
+
* occupies its own cache slot. Defaults to "pass" which preserves the
|
|
11
|
+
* legacy hash for obfuscated and source-backed artifacts.
|
|
12
|
+
*/
|
|
13
|
+
mappingVariant?: MappingVariant;
|
|
6
14
|
onRepoFailover?: (event: {
|
|
7
15
|
stage: "source" | "binary";
|
|
8
16
|
repoUrl: string;
|
package/dist/source-resolver.js
CHANGED
|
@@ -133,11 +133,19 @@ async function resolveGradleCacheCoordinateCandidate(coordinate) {
|
|
|
133
133
|
function resolveRemoteBinaryCandidate(coordinate, repos) {
|
|
134
134
|
return buildRemoteBinaryUrls(repos, coordinate);
|
|
135
135
|
}
|
|
136
|
-
function artifactIdForJar(inputKind, artifactPath, signature, suffix) {
|
|
137
|
-
|
|
136
|
+
function artifactIdForJar(inputKind, artifactPath, signature, suffix, mappingVariant = "pass") {
|
|
137
|
+
const parts = [inputKind, artifactPath, signature, suffix ?? "source"];
|
|
138
|
+
if (mappingVariant === "mojang-remapped") {
|
|
139
|
+
parts.push("mojang-remapped");
|
|
140
|
+
}
|
|
141
|
+
return stableArtifactId(parts);
|
|
138
142
|
}
|
|
139
|
-
function artifactIdForCoordinate(coordinate, source, signature) {
|
|
140
|
-
|
|
143
|
+
function artifactIdForCoordinate(coordinate, source, signature, mappingVariant = "pass") {
|
|
144
|
+
const parts = ["coord", coordinate, source, signature];
|
|
145
|
+
if (mappingVariant === "mojang-remapped") {
|
|
146
|
+
parts.push("mojang-remapped");
|
|
147
|
+
}
|
|
148
|
+
return stableArtifactId(parts);
|
|
141
149
|
}
|
|
142
150
|
function resolvedAtNow() {
|
|
143
151
|
return new Date().toISOString();
|
|
@@ -191,7 +199,7 @@ export async function resolveSourceTarget(input, options, explicitConfig) {
|
|
|
191
199
|
});
|
|
192
200
|
}
|
|
193
201
|
return {
|
|
194
|
-
artifactId: artifactIdForJar("jar", resolvedJarPath, `${binarySignature}:decompile
|
|
202
|
+
artifactId: artifactIdForJar("jar", resolvedJarPath, `${binarySignature}:decompile`, undefined, options.mappingVariant ?? "pass"),
|
|
195
203
|
artifactSignature: `${binarySignature}:decompile`,
|
|
196
204
|
origin: "decompiled",
|
|
197
205
|
binaryJarPath: resolvedJarPath,
|
|
@@ -326,7 +334,7 @@ export async function resolveSourceTarget(input, options, explicitConfig) {
|
|
|
326
334
|
}
|
|
327
335
|
const signature = readStatsSignature(downloaded.path);
|
|
328
336
|
return {
|
|
329
|
-
artifactId: artifactIdForCoordinate(coordinate, "decompiled", signature),
|
|
337
|
+
artifactId: artifactIdForCoordinate(coordinate, "decompiled", signature, options.mappingVariant ?? "pass"),
|
|
330
338
|
artifactSignature: signature,
|
|
331
339
|
origin: "decompiled",
|
|
332
340
|
binaryJarPath: downloaded.path,
|