@remixhq/mcp 0.1.19 → 0.1.21

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