agent-gate-installer 1.9.1 → 1.9.2

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 (2) hide show
  1. package/bin/install.mjs +25 -7
  2. package/package.json +1 -1
package/bin/install.mjs CHANGED
@@ -38,6 +38,22 @@ function run(command, options = {}) {
38
38
  return execSync(command, { encoding: "utf8", stdio, ...options });
39
39
  }
40
40
 
41
+ function getOriginDefaultBranch(installDirectory) {
42
+ const fullRemoteHead = run(`git -C "${installDirectory}" symbolic-ref --short refs/remotes/origin/HEAD`).trim();
43
+ const prefix = "origin/";
44
+ if (!fullRemoteHead.startsWith(prefix)) {
45
+ throw new Error(`Unexpected origin HEAD ref: ${fullRemoteHead}`);
46
+ }
47
+ return fullRemoteHead.slice(prefix.length);
48
+ }
49
+
50
+ function syncRepositoryToOriginDefaultBranch(installDirectory) {
51
+ run(`git -C "${installDirectory}" fetch --prune origin`);
52
+ const defaultBranch = getOriginDefaultBranch(installDirectory);
53
+ run(`git -C "${installDirectory}" checkout -B "${defaultBranch}" "origin/${defaultBranch}"`);
54
+ run(`git -C "${installDirectory}" reset --hard "origin/${defaultBranch}"`);
55
+ }
56
+
41
57
  function detectPython() {
42
58
  const candidates = IS_WINDOWS
43
59
  ? ["python", "python3", "py -3"]
@@ -214,11 +230,11 @@ async function install() {
214
230
  registerMcpInClaudeJson(venvPython);
215
231
 
216
232
  if (existsSync(join(INSTALL_DIR, ".git"))) {
217
- log(" ~ agent-gate already cloned, pulling latest...");
233
+ log(" ~ agent-gate already cloned, syncing latest...");
218
234
  try {
219
- run(`git -C "${INSTALL_DIR}" pull`);
235
+ syncRepositoryToOriginDefaultBranch(INSTALL_DIR);
220
236
  } catch {
221
- log(" ! git pull failed (continuing with existing checkout)");
237
+ log(" ! repository sync failed (continuing with existing checkout)");
222
238
  }
223
239
  } else {
224
240
  log(" + Cloning agent-gate...");
@@ -334,10 +350,12 @@ function update() {
334
350
  }
335
351
 
336
352
  try {
337
- run(`git -C "${INSTALL_DIR}" pull`);
338
- log(" + Pulled latest changes");
339
- } catch {
340
- log("Error: git pull failed.");
353
+ syncRepositoryToOriginDefaultBranch(INSTALL_DIR);
354
+ log(" + Synced latest changes from origin default branch");
355
+ } catch (error) {
356
+ const message = error?.message || "Unknown git error";
357
+ log(`Error: repository sync failed. ${message}`);
358
+ log("Try rerunning with --verbose for command output.");
341
359
  process.exit(1);
342
360
  }
343
361
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-gate-installer",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "One-command installer for agent-gate prompt evaluation gate",
5
5
  "type": "module",
6
6
  "bin": {