gdharness 1.2.24 → 1.2.25

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/build/keeper.js CHANGED
@@ -105,8 +105,10 @@ public static class GdharnessDesktop {
105
105
  // what a program's first ShowWindow does whatever it asks for when the start names a show state,
106
106
  // and the foreground is held while it starts, since Godot also asks for it outright. The process
107
107
  // is ended through the handle held here once stopFile appears, which is how a keeper ends a game
108
- // it did not start itself: a handle names one process, where a pid can name the next one too.
109
- public static int Run(string desktop, string commandLine, string pidFile, bool noActivate, string stopFile) {
108
+ // it did not start itself: a handle names one process, where a pid can name the next one too. The
109
+ // process starts in directory rather than in this one's, which is a temporary directory: Windows
110
+ // PowerShell saves its module cache relative to where it runs when the profile does not resolve.
111
+ public static int Run(string desktop, string commandLine, string pidFile, bool noActivate, string stopFile, string directory) {
110
112
  StartupInfo startup = new StartupInfo();
111
113
  startup.cb = Marshal.SizeOf(typeof(StartupInfo));
112
114
  if (desktop.Length > 0) {
@@ -129,7 +131,7 @@ public static class GdharnessDesktop {
129
131
  LockSetForegroundWindow(LockForeground);
130
132
  }
131
133
  try {
132
- if (!CreateProcessW(null, new StringBuilder(commandLine), IntPtr.Zero, IntPtr.Zero, true, DetachedProcess, IntPtr.Zero, null, ref startup, out started)) {
134
+ if (!CreateProcessW(null, new StringBuilder(commandLine), IntPtr.Zero, IntPtr.Zero, true, DetachedProcess, IntPtr.Zero, directory, ref startup, out started)) {
133
135
  throw new Win32Exception(Marshal.GetLastWin32Error(), "CreateProcessW " + commandLine);
134
136
  }
135
137
  File.WriteAllText(pidFile, started.processId.ToString());
@@ -186,6 +188,7 @@ function throughHelper(how, command, args, files) {
186
188
  commandLine: windowsCommandLine(command, args),
187
189
  pidFile: files.pid,
188
190
  stopFile: files.stop,
191
+ directory: how.directory,
189
192
  source: SOURCE,
190
193
  digest: createHash("sha256").update(SOURCE).digest("hex").slice(0, 16)
191
194
  };
@@ -202,7 +205,7 @@ function throughHelper(how, command, args, files) {
202
205
  " try { Move-Item -LiteralPath $partial -Destination $assembly } catch { Remove-Item -LiteralPath $partial -ErrorAction SilentlyContinue }",
203
206
  " }",
204
207
  " Add-Type -LiteralPath $assembly",
205
- " $code = [GdharnessDesktop]::Run($spec.desktop, $spec.commandLine, $spec.pidFile, [bool]$spec.noActivate, $spec.stopFile)",
208
+ " $code = [GdharnessDesktop]::Run($spec.desktop, $spec.commandLine, $spec.pidFile, [bool]$spec.noActivate, $spec.stopFile, $spec.directory)",
206
209
  "} catch {",
207
210
  ` [IO.File]::WriteAllText(${literal(files.error)}, $_.Exception.Message)`,
208
211
  " exit 1",
@@ -1331,13 +1334,14 @@ class ProfileListener {
1331
1334
  }
1332
1335
 
1333
1336
  // src/keeper.ts
1334
- async function startDirectly(spec, output, hidden, detached = true, errors = output) {
1337
+ async function startDirectly(spec, output, hidden, detached = true, errors = output, directory = process.cwd()) {
1335
1338
  return await new Promise((resolve) => {
1336
1339
  const child = spawn(spec.command, [...spec.args], {
1337
1340
  stdio: ["ignore", output, errors],
1338
1341
  detached,
1339
1342
  windowsHide: hidden,
1340
- env: withChanges(process.env, spec.envChanges)
1343
+ env: withChanges(process.env, spec.envChanges),
1344
+ cwd: directory
1341
1345
  });
1342
1346
  child.once("error", (error) => {
1343
1347
  resolve({ error: error.message });
@@ -1353,14 +1357,14 @@ async function startThroughHelper(spec, output, stopFile) {
1353
1357
  const errorFile = join5(scratch, "error");
1354
1358
  const where = spec.desktop === undefined ? "without activation" : `on the ${spec.desktop} desktop`;
1355
1359
  try {
1356
- const wrapper = throughHelper(spec, spec.command, spec.args, {
1360
+ const wrapper = throughHelper({ ...spec, directory: process.cwd() }, spec.command, spec.args, {
1357
1361
  spec: join5(scratch, "spec.json"),
1358
1362
  pid: pidFile,
1359
1363
  error: errorFile,
1360
1364
  stop: stopFile
1361
1365
  });
1362
1366
  const envChanges = spec.desktop === undefined ? spec.envChanges : { ...spec.envChanges, [DESKTOP_VARIABLE]: spec.desktop };
1363
- const started = await startDirectly({ ...spec, command: wrapper.command, args: wrapper.args, envChanges }, output, true, false, "ignore");
1367
+ const started = await startDirectly({ ...spec, command: wrapper.command, args: wrapper.args, envChanges }, output, true, false, "ignore", tmpdir4());
1364
1368
  if ("error" in started) {
1365
1369
  return started;
1366
1370
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdharness",
3
- "version": "1.2.24",
3
+ "version": "1.2.25",
4
4
  "mcpName": "io.github.Aureliolo/gdharness",
5
5
  "description": "A harness for driving a Godot 4 project from an agent: editor addons, a runtime bridge into the running game, an MCP server in front of them, and a CLI that installs and diagnoses the Godot side.",
6
6
  "type": "module",