@remixhq/mcp 0.1.19 → 0.1.20

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/dist/index.js CHANGED
@@ -1719,13 +1719,34 @@ async function accessDebug(params) {
1719
1719
 
1720
1720
  // src/tools/collab/autoSpawnHistoryImport.ts
1721
1721
  import { spawn } from "child_process";
1722
- import { existsSync, mkdirSync, openSync } from "fs";
1722
+ import { createHash } from "crypto";
1723
+ import { existsSync } from "fs";
1724
+ import os from "os";
1723
1725
  import path2 from "path";
1724
- var MARKER_REL_PATH = path2.join(".remix", ".history-imported");
1725
- var LOG_REL_PATH = path2.join(".remix", "history-import.log");
1726
- function shouldAutoSpawnHistoryImport(repoRoot) {
1726
+ var LEGACY_MARKER_REL_PATH = path2.join(".remix", ".history-imported");
1727
+ function collabStateRoot() {
1728
+ const configured = process.env.REMIX_COLLAB_STATE_ROOT?.trim();
1729
+ return configured || path2.join(os.homedir(), ".remix", "collab-state");
1730
+ }
1731
+ function sha256Hex(value) {
1732
+ return createHash("sha256").update(value).digest("hex");
1733
+ }
1734
+ function autoSpawnMarkerPath(repoRoot, repoFingerprint) {
1735
+ const identityKey = typeof repoFingerprint === "string" && repoFingerprint.trim() ? `repoFingerprint:${repoFingerprint.trim()}` : `repoRoot:${repoRoot}`;
1736
+ return path2.join(collabStateRoot(), "history-import", sha256Hex(identityKey), "history-imported.json");
1737
+ }
1738
+ function fallbackRepoRootMarkerPath(repoRoot) {
1739
+ return autoSpawnMarkerPath(repoRoot, null);
1740
+ }
1741
+ function legacyLocalRepoRootMarkerPath(repoRoot) {
1742
+ return path2.join(collabStateRoot(), "history-import", sha256Hex(repoRoot), "history-imported.json");
1743
+ }
1744
+ function legacyAutoSpawnMarkerPath(repoRoot) {
1745
+ return path2.join(repoRoot, LEGACY_MARKER_REL_PATH);
1746
+ }
1747
+ function shouldAutoSpawnHistoryImport(repoRoot, repoFingerprint) {
1727
1748
  try {
1728
- return !existsSync(path2.join(repoRoot, MARKER_REL_PATH));
1749
+ return !existsSync(autoSpawnMarkerPath(repoRoot, repoFingerprint)) && !existsSync(fallbackRepoRootMarkerPath(repoRoot)) && !existsSync(legacyLocalRepoRootMarkerPath(repoRoot)) && !existsSync(legacyAutoSpawnMarkerPath(repoRoot));
1729
1750
  } catch {
1730
1751
  return false;
1731
1752
  }
@@ -1734,14 +1755,6 @@ function isAutoSpawnEligibleBindingMode(bindingMode) {
1734
1755
  return bindingMode === "explicit_root";
1735
1756
  }
1736
1757
  function spawnHistoryImportDetached(repoRoot, options) {
1737
- const remixDir = path2.join(repoRoot, ".remix");
1738
- try {
1739
- mkdirSync(remixDir, { recursive: true });
1740
- } catch {
1741
- }
1742
- const logPath = path2.join(repoRoot, LOG_REL_PATH);
1743
- const out = openSync(logPath, "a");
1744
- const err = openSync(logPath, "a");
1745
1758
  const child = spawn(
1746
1759
  "remix",
1747
1760
  [
@@ -1758,12 +1771,12 @@ function spawnHistoryImportDetached(repoRoot, options) {
1758
1771
  ],
1759
1772
  {
1760
1773
  detached: true,
1761
- stdio: ["ignore", out, err],
1774
+ stdio: "ignore",
1762
1775
  env: { ...process.env, REMIX_HISTORY_AUTO_SPAWN: "1" }
1763
1776
  }
1764
1777
  );
1765
1778
  child.unref();
1766
- return { pid: child.pid, logPath };
1779
+ return { pid: child.pid };
1767
1780
  }
1768
1781
 
1769
1782
  // src/tools/collab/register.ts
@@ -1933,12 +1946,14 @@ function registerCollabTools(server, context) {
1933
1946
  try {
1934
1947
  const repoRoot = result && typeof result === "object" && "data" in result && result.data && typeof result.data.repoRoot === "string" ? result.data.repoRoot : null;
1935
1948
  const bindingMode = result && typeof result === "object" && "data" in result && result.data && typeof result.data.bindingMode === "string" ? result.data.bindingMode : null;
1936
- if (repoRoot && isAutoSpawnEligibleBindingMode(bindingMode) && shouldAutoSpawnHistoryImport(repoRoot)) {
1949
+ const resultData = result && typeof result === "object" && "data" in result && result.data && typeof result.data === "object" ? result.data : null;
1950
+ const repoFingerprint = typeof resultData?.repoFingerprint === "string" ? resultData.repoFingerprint : null;
1951
+ if (repoRoot && isAutoSpawnEligibleBindingMode(bindingMode) && shouldAutoSpawnHistoryImport(repoRoot, repoFingerprint)) {
1937
1952
  const cutoffAt = (/* @__PURE__ */ new Date()).toISOString();
1938
1953
  const spawned = spawnHistoryImportDetached(repoRoot, { cutoffAt });
1939
1954
  context.logger.log({
1940
1955
  level: "info",
1941
- message: `history_import_auto_spawned pid=${spawned.pid ?? "?"} log=${spawned.logPath} cutoffAt=${cutoffAt}`,
1956
+ message: `history_import_auto_spawned pid=${spawned.pid ?? "?"} cutoffAt=${cutoffAt}`,
1942
1957
  tool: "remix_collab_init",
1943
1958
  repoRoot
1944
1959
  });