@mrrlin-dev/mcp 0.4.209 → 0.4.211

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/dist/bin.cjs +72 -26
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -92430,7 +92430,7 @@ function git2(checkout, args, hooksDir, baseEnv = process.env) {
92430
92430
  async function createRunWorktree(opts) {
92431
92431
  const signal = opts.signal;
92432
92432
  signal?.throwIfAborted();
92433
- const worktreePath = (0, import_node_path23.join)(opts.worktreeRoot, opts.slug, opts.runId);
92433
+ const worktreePath = (0, import_node_path23.resolve)(opts.worktreeRoot, opts.slug, opts.runId);
92434
92434
  const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, opts.runId);
92435
92435
  const runGit2 = async (args) => {
92436
92436
  if (!signal) return git2(opts.checkout, args, hooksDir);
@@ -92448,7 +92448,7 @@ async function createRunWorktree(opts) {
92448
92448
  (0, import_node_fs17.mkdirSync)(opts.worktreeRoot, { recursive: true });
92449
92449
  const base = opts.local ? `refs/heads/${opts.defaultBranch}` : `origin/${opts.defaultBranch}`;
92450
92450
  try {
92451
- if (!opts.local) await runGit2(["fetch", "origin", opts.defaultBranch]);
92451
+ if (!opts.local) await runGit2(["fetch", "--no-auto-gc", "origin", opts.defaultBranch]);
92452
92452
  if (!(0, import_node_fs17.existsSync)(worktreePath)) {
92453
92453
  await runGit2([
92454
92454
  "worktree",
@@ -92470,14 +92470,14 @@ async function createRunWorktree(opts) {
92470
92470
  return worktreePath;
92471
92471
  }
92472
92472
  async function openRunWorktree(opts) {
92473
- const worktreePath = (0, import_node_path23.join)(opts.worktreeRoot, opts.slug, opts.runId);
92473
+ const worktreePath = (0, import_node_path23.resolve)(opts.worktreeRoot, opts.slug, opts.runId);
92474
92474
  const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, opts.runId);
92475
92475
  const branch = worktreeBranch(opts.runId);
92476
92476
  const env = buildLocalStepEnv();
92477
92477
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
92478
92478
  if ((0, import_node_fs17.existsSync)(worktreePath)) {
92479
92479
  const real = (0, import_node_fs17.realpathSync)(worktreePath);
92480
- const listed = git2(opts.checkout, ["worktree", "list", "--porcelain"], hooksDir, env).split(/\n\s*\n/).map((block) => block.split("\n")).find((lines2) => {
92480
+ const listed = git2(opts.checkout, ["-c", "core.quotePath=false", "worktree", "list", "--porcelain"], hooksDir, env).split(/\n\s*\n/).map((block) => block.split("\n")).find((lines2) => {
92481
92481
  const listedPath = lines2.find((line) => line.startsWith("worktree "))?.slice("worktree ".length);
92482
92482
  return listedPath !== void 0 && (0, import_node_fs17.existsSync)(listedPath) && (0, import_node_fs17.realpathSync)(listedPath) === real;
92483
92483
  });
@@ -92495,19 +92495,48 @@ async function openRunWorktree(opts) {
92495
92495
  throw new Error(`run_branch_missing: ${opts.checkout} has no branch ${branch}`);
92496
92496
  }
92497
92497
  (0, import_node_fs17.mkdirSync)(opts.worktreeRoot, { recursive: true });
92498
- git2(opts.checkout, ["worktree", "prune"], hooksDir, env);
92499
- git2(opts.checkout, ["worktree", "add", worktreePath, branch], hooksDir, env);
92498
+ git2(opts.checkout, ["worktree", "add", "--", worktreePath, branch], hooksDir, env);
92500
92499
  });
92501
92500
  return worktreePath;
92502
92501
  }
92503
92502
  async function removeRunWorktree(opts) {
92503
+ if (!(0, import_node_path23.isAbsolute)(opts.worktreePath) || (0, import_node_path23.normalize)(opts.worktreePath) !== opts.worktreePath) {
92504
+ throw new Error("run_worktree_invalid: removal requires a normalized absolute path");
92505
+ }
92504
92506
  const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, (0, import_node_path23.basename)(opts.worktreePath));
92505
92507
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
92508
+ let target;
92506
92509
  try {
92507
- git2(opts.checkout, ["worktree", "remove", "--force", opts.worktreePath], hooksDir);
92508
- } catch {
92510
+ if ((0, import_node_fs17.lstatSync)(opts.worktreePath).isSymbolicLink()) {
92511
+ throw new Error("run_worktree_invalid: removal target is a symbolic link");
92512
+ }
92513
+ target = (0, import_node_path23.normalize)(import_node_fs17.realpathSync.native(opts.worktreePath));
92514
+ } catch (error51) {
92515
+ if (error51.code !== "ENOENT") throw error51;
92516
+ }
92517
+ if (target) {
92518
+ const listing = git2(opts.checkout, ["-c", "core.quotePath=false", "worktree", "list", "--porcelain"], hooksDir);
92519
+ const pathKey = (path40) => process.platform === "win32" ? (0, import_node_path23.normalize)(path40).toLowerCase() : (0, import_node_path23.normalize)(path40);
92520
+ const records = listing.split(/\r?\n\r?\n/).filter(Boolean).map((record2) => {
92521
+ const [line, ...fields] = record2.split(/\r?\n/);
92522
+ const registered = line?.startsWith("worktree ") ? line.slice("worktree ".length) : "";
92523
+ if (/^"(?:[^"\\]|\\.)*"$/.test(registered)) return null;
92524
+ if (/[\x00-\x1f\x7f]/.test(registered)) return null;
92525
+ if (!(0, import_node_path23.isAbsolute)(registered)) throw new Error("run_worktree_invalid: ambiguous Git worktree registration");
92526
+ return { registered, locked: fields.some((field) => /^locked(?: |$)/.test(field)) };
92527
+ });
92528
+ const requestedKey = pathKey(opts.worktreePath);
92529
+ const targetKey = pathKey(target);
92530
+ if (requestedKey !== targetKey && records.some((record2) => record2 !== null && pathKey(record2.registered) === requestedKey)) {
92531
+ throw new Error("run_worktree_invalid: registered path resolves to another location");
92532
+ }
92533
+ const matches = records.filter((record2) => record2 !== null && pathKey(record2.registered) === targetKey);
92534
+ if (matches.length !== 1) {
92535
+ throw new Error("run_worktree_invalid: expected one exact Git worktree registration");
92536
+ }
92537
+ const match = matches[0];
92538
+ if (!match.locked) git2(opts.checkout, ["worktree", "remove", "--force", "--", match.registered], hooksDir);
92509
92539
  }
92510
- git2(opts.checkout, ["worktree", "prune"], hooksDir);
92511
92540
  removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path23.basename)(opts.worktreePath));
92512
92541
  });
92513
92542
  }
@@ -92639,7 +92668,7 @@ async function doPushRunBranch(opts, execGit) {
92639
92668
  }
92640
92669
  return { pushedSha: localSha };
92641
92670
  }
92642
- async function sweepOrphanWorktrees(opts) {
92671
+ async function sweepOrphanWorktrees(opts, runGit2 = git2) {
92643
92672
  const reaped = [];
92644
92673
  const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, `sweep:${opts.slug}`);
92645
92674
  const ownedPrefix = (() => {
@@ -92653,32 +92682,49 @@ async function sweepOrphanWorktrees(opts) {
92653
92682
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
92654
92683
  await withCheckoutLock(opts.worktreeRoot, worktreeRootSweepLock, async () => {
92655
92684
  if (!canSweepColdWorkRoot(opts.worktreeRoot)) return;
92656
- const listing = git2(opts.checkout, ["worktree", "list", "--porcelain"], hooksDir);
92657
- for (const block of listing.split("\n\n")) {
92685
+ const listing = runGit2(opts.checkout, ["-c", "core.quotePath=false", "worktree", "list", "--porcelain"], hooksDir);
92686
+ const blocks = listing.split(/\r?\n\r?\n/).filter(Boolean);
92687
+ const paths = blocks.map((block) => {
92688
+ const [path40, head, branch, ...flags] = block.split(/\r?\n/);
92689
+ if (!path40?.startsWith("worktree ")) return void 0;
92690
+ if (!/^HEAD (?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(head ?? "")) return void 0;
92691
+ if (!/^(?:branch refs\/heads\/[^\x00-\x20\x7f]+|detached)$/.test(branch ?? "")) return void 0;
92692
+ if (flags.some((flag) => !/^(?:locked|prunable)(?: [^\x00-\x1f\x7f]*)?$/.test(flag))) return void 0;
92693
+ return path40.slice("worktree ".length);
92694
+ });
92695
+ const counts = /* @__PURE__ */ new Map();
92696
+ for (const path40 of paths) {
92697
+ if (!path40 || !(0, import_node_path23.isAbsolute)(path40) || /[\x00-\x1f\x7f]/.test(path40)) continue;
92698
+ const key = process.platform === "win32" ? (0, import_node_path23.normalize)(path40).toLowerCase() : (0, import_node_path23.normalize)(path40);
92699
+ counts.set(key, (counts.get(key) ?? 0) + 1);
92700
+ }
92701
+ for (const [index, block] of blocks.entries()) {
92658
92702
  if (/^locked(?: |$)/m.test(block)) continue;
92659
- const m = /^worktree (.+)$/m.exec(block);
92660
- const wt = m?.[1]?.trim();
92661
- if (!wt) continue;
92662
- const canonicalWt = (() => {
92663
- try {
92664
- return (import_node_fs17.realpathSync.native ?? import_node_fs17.realpathSync)(wt);
92665
- } catch {
92666
- return wt;
92667
- }
92668
- })();
92703
+ const wt = paths[index];
92704
+ if (!wt || !(0, import_node_path23.isAbsolute)(wt) || /[\x00-\x1f\x7f]/.test(wt)) continue;
92705
+ const key = process.platform === "win32" ? (0, import_node_path23.normalize)(wt).toLowerCase() : (0, import_node_path23.normalize)(wt);
92706
+ if (counts.get(key) !== 1) continue;
92707
+ let canonicalWt;
92708
+ try {
92709
+ if ((0, import_node_fs17.lstatSync)(wt).isSymbolicLink()) continue;
92710
+ canonicalWt = import_node_fs17.realpathSync.native(wt);
92711
+ } catch {
92712
+ continue;
92713
+ }
92669
92714
  const normWt = (0, import_node_path23.normalize)(canonicalWt);
92715
+ const canonicalKey = process.platform === "win32" ? normWt.toLowerCase() : normWt;
92716
+ if (canonicalKey !== key) continue;
92670
92717
  const normPrefix = (0, import_node_path23.normalize)(ownedPrefix);
92671
92718
  const isMatch = process.platform === "win32" ? normWt.toLowerCase().startsWith(normPrefix.toLowerCase()) : normWt.startsWith(normPrefix);
92672
- if (isMatch && opts.isReapable(wt)) {
92719
+ if (isMatch && (0, import_node_path23.isAbsolute)(wt) && opts.isReapable(wt)) {
92673
92720
  try {
92674
- git2(opts.checkout, ["worktree", "remove", "--force", wt], hooksDir);
92721
+ runGit2(opts.checkout, ["worktree", "remove", "--force", "--", wt], hooksDir);
92675
92722
  removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path23.basename)(wt));
92676
92723
  reaped.push(wt);
92677
92724
  } catch {
92678
92725
  }
92679
92726
  }
92680
92727
  }
92681
- git2(opts.checkout, ["worktree", "prune"], hooksDir);
92682
92728
  });
92683
92729
  });
92684
92730
  } finally {
@@ -99454,7 +99500,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
99454
99500
  }
99455
99501
 
99456
99502
  // src/_generated/version.ts
99457
- var PKG_VERSION = "0.4.209";
99503
+ var PKG_VERSION = "0.4.211";
99458
99504
 
99459
99505
  // src/bridge-allowed-origins.ts
99460
99506
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.209",
3
+ "version": "0.4.211",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"