Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at d64292e.

My earlier point is addressed. resourceToolVersion.parse in command.ts now rejects anything that doesn't match ^[A-Za-z0-9._-]+$ and gives a clear error, so ranges with > or ^ never reach npx or cmd.exe. The brief now says "Exact ResourceTool version or dist-tag". All four subcommands (mcp, eval, repl, script) share commonFlags, so the flag reaches each of them. If the flag is left out, callResourceTool still uses latest, so default behaviour doesn't change. init still calls ResourceTool at latest with no way to pin it. That's fine for this PR, but LTS users may want it there later. Looks good to me.

Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
16 changes: 16 additions & 0 deletions src/commands/resourcetool/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions src/commands/resourcetool/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { KnownError } from "~/error";
export interface CommonFlags {
cacheDir?: string;
config?: string;
resourceToolVersion?: string;
}

export async function run(
Expand Down Expand Up @@ -85,5 +86,6 @@ export async function run(
projectToolPath,
prefabsFolder: await cache.getSubDirPath(ctx, "prefabs"),
config: flags.config,
version: flags.resourceToolVersion,
});
}
5 changes: 4 additions & 1 deletion src/resource-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down Expand Up @@ -80,6 +82,7 @@ export async function callResourceTool(
prefabsFolder,
config,
ignoreStdio,
version = "latest",
}: ResourceToolArgs,
): Promise<void> {
const command = modeToArgs(run);
Expand All @@ -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}`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The version goes straight into the npx argument list, and on Windows npmExec runs it through cmd.exe /c. Node only quotes arguments that contain spaces or quotes, so a range like >=2026.0.17 or ^2026.0 gets mangled by cmd (> is a redirect, ^ is the escape character). We could reject anything that isn't [A-Za-z0-9._-]+ in the flag's parse and throw a clear error, or say in the brief that only exact versions or dist-tags are supported.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch, thanks. I went with the first option: the flag's parse now rejects anything that isn't [A-Za-z0-9._-]+ with a clear error, so ranges never reach npx/cmd.exe. The brief also says "exact version or dist-tag" now.

try {
await npmExec(ctx, {
packageName,
Expand Down
Loading