diff --git a/README.md b/README.md index 9ab1abb..f04b7a2 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ Use `gm-cli resourcetool` to programmatically make changes to your project files gm-cli resourcetool eval "resource list" ``` There are many ways of using ResourceTool, the most convenient is with an AI agent using the [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro) `gm-cli resourcetool mcp`. But you can also use it yourself in interactive session `gm-cli resourcetool repl` or as a script. + +ResourceTool saves the project with its own resource record versions. If a newer ResourceTool upgrades files your IDE can no longer open, pin a version that matches your IDE with `--resource-tool-version`, for example `gm-cli resourcetool mcp --resource-tool-version=2026.0.17`. ### Signing-in GameMaker CLI automatically gives you a guest license, so there is no need to sign in. But if you prefer to use your own access key from https://gamemaker.io/en/account/access-keys. You may run: ``` diff --git a/src/commands/resourcetool/command.ts b/src/commands/resourcetool/command.ts index 572cd40..5de86a9 100644 --- a/src/commands/resourcetool/command.ts +++ b/src/commands/resourcetool/command.ts @@ -31,6 +31,22 @@ const commonFlags = { brief: "GameMaker project config to use (default: 'Default')", optional: true as const, }, + resourceToolVersion: { + kind: "parsed" as const, + // Exact versions and dist-tags only: on Windows npx runs through cmd.exe, where ranges like + // ">=2026.0.17" or "^2026.0" are mangled (">" redirects, "^" escapes). + parse: (value: string) => { + if (!/^[A-Za-z0-9._-]+$/.test(value)) { + throw new Error( + `Expected an exact version or dist-tag (e.g. 2026.0.17 or latest), got '${value}'`, + ); + } + return value; + }, + brief: + "Exact ResourceTool version or dist-tag, e.g. 2026.0.17 (default: 'latest'). Pin it to match your IDE release", + optional: true as const, + }, }; const projectParam = { diff --git a/src/commands/resourcetool/impl.ts b/src/commands/resourcetool/impl.ts index 07d2326..40d3341 100644 --- a/src/commands/resourcetool/impl.ts +++ b/src/commands/resourcetool/impl.ts @@ -30,6 +30,7 @@ import { KnownError } from "~/error"; export interface CommonFlags { cacheDir?: string; config?: string; + resourceToolVersion?: string; } export async function run( @@ -85,5 +86,6 @@ export async function run( projectToolPath, prefabsFolder: await cache.getSubDirPath(ctx, "prefabs"), config: flags.config, + version: flags.resourceToolVersion, }); } diff --git a/src/resource-tool.ts b/src/resource-tool.ts index 4cb473a..79e8a73 100644 --- a/src/resource-tool.ts +++ b/src/resource-tool.ts @@ -32,6 +32,8 @@ export interface ResourceToolArgs { prefabsFolder?: string; config?: string; ignoreStdio?: boolean; + /** npm version or dist-tag of the ResourceTool package (default: "latest") */ + version?: string; } function splitCommand(input: string): string[] { @@ -80,6 +82,7 @@ export async function callResourceTool( prefabsFolder, config, ignoreStdio, + version = "latest", }: ResourceToolArgs, ): Promise { const command = modeToArgs(run); @@ -92,7 +95,7 @@ export async function callResourceTool( ...(config ? [`config=${config}`] : []), ]; const platformSuffix = getPlatformSuffix(ctx); - const packageName = `@gm-tools/resource-tool-${platformSuffix}@latest`; + const packageName = `@gm-tools/resource-tool-${platformSuffix}@${version}`; try { await npmExec(ctx, { packageName,