@edihasaj/recall 1.0.0 → 1.0.1

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
@@ -140,7 +140,7 @@ import {
140
140
  // src/cli.ts
141
141
  import { Command } from "commander";
142
142
  import { resolve as resolve8 } from "path";
143
- import { writeFileSync as writeFileSync7, readFileSync as readFileSync8, realpathSync } from "fs";
143
+ import { writeFileSync as writeFileSync7, readFileSync as readFileSync8, realpathSync as realpathSync2 } from "fs";
144
144
  import { join as join12 } from "path";
145
145
 
146
146
  // src/ump/serve.ts
@@ -506,6 +506,7 @@ import {
506
506
  existsSync,
507
507
  mkdirSync,
508
508
  readFileSync,
509
+ realpathSync,
509
510
  renameSync,
510
511
  writeFileSync
511
512
  } from "fs";
@@ -817,7 +818,8 @@ function installClaudeCodeMemoryOverride(options = {}) {
817
818
  mkdirSync(targetDir, { recursive: true });
818
819
  }
819
820
  const desired = buildClaudeMdBlock();
820
- const existingContent = readUtf8FileIfExists(targetPath) ?? "";
821
+ const filePath = resolveClaudeMdFilePath(targetPath);
822
+ const existingContent = readUtf8FileIfExists(filePath) ?? "";
821
823
  if (existingContent.includes(CLAUDE_MD_BEGIN) && existingContent.includes(desired.trim())) {
822
824
  return {
823
825
  ok: true,
@@ -836,7 +838,7 @@ function installClaudeCodeMemoryOverride(options = {}) {
836
838
  const separator = existingContent.endsWith("\n\n") ? "" : existingContent.endsWith("\n") ? "\n" : "\n\n";
837
839
  nextContent = `${existingContent}${separator}${desired}`;
838
840
  }
839
- atomicWriteUtf8File(targetPath, nextContent);
841
+ atomicWriteUtf8File(filePath, nextContent);
840
842
  return {
841
843
  ok: true,
842
844
  changed: true,
@@ -846,7 +848,8 @@ function installClaudeCodeMemoryOverride(options = {}) {
846
848
  }
847
849
  function uninstallClaudeCodeMemoryOverride(options = {}) {
848
850
  const targetPath = options.configPath ?? claudeMdPath();
849
- const existingContent = readUtf8FileIfExists(targetPath);
851
+ const filePath = resolveClaudeMdFilePath(targetPath);
852
+ const existingContent = readUtf8FileIfExists(filePath);
850
853
  if (existingContent === null) {
851
854
  return {
852
855
  ok: true,
@@ -867,10 +870,10 @@ function uninstallClaudeCodeMemoryOverride(options = {}) {
867
870
  CLAUDE_MD_BLOCK_RE.lastIndex = 0;
868
871
  const stripped = existingContent.replace(CLAUDE_MD_BLOCK_RE, "").replace(/\n{3,}/g, "\n\n");
869
872
  if (stripped.trim().length === 0) {
870
- atomicWriteUtf8File(targetPath, "");
873
+ atomicWriteUtf8File(filePath, "");
871
874
  } else {
872
875
  atomicWriteUtf8File(
873
- targetPath,
876
+ filePath,
874
877
  stripped.endsWith("\n") ? stripped : `${stripped}
875
878
  `
876
879
  );
@@ -882,6 +885,16 @@ function uninstallClaudeCodeMemoryOverride(options = {}) {
882
885
  message: "Removed Recall-managed block from CLAUDE.md"
883
886
  };
884
887
  }
888
+ function resolveClaudeMdFilePath(targetPath) {
889
+ try {
890
+ return realpathSync(targetPath);
891
+ } catch (error) {
892
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
893
+ return targetPath;
894
+ }
895
+ throw error;
896
+ }
897
+ }
885
898
  function checkClaudeCodeMemoryOverride(options = {}) {
886
899
  const targetPath = options.configPath ?? claudeMdPath();
887
900
  if (!existsSync(targetPath)) {
@@ -1540,8 +1553,11 @@ function anyBeginMarkerRe(block) {
1540
1553
  return new RegExp(`<!--\\s*recall:managed:${escapeRegExp2(block.name)}:begin(?:\\s+v\\d+)?\\s*-->`);
1541
1554
  }
1542
1555
  function blockRe(block) {
1556
+ return blockReForName(block.name);
1557
+ }
1558
+ function blockReForName(name) {
1543
1559
  return new RegExp(
1544
- `<!--\\s*recall:managed:${escapeRegExp2(block.name)}:begin(?:\\s+v\\d+)?\\s*-->[\\s\\S]*?<!--\\s*recall:managed:${escapeRegExp2(block.name)}:end\\s*-->\\n?`,
1560
+ `<!--\\s*recall:managed:${escapeRegExp2(name)}:begin(?:\\s+v\\d+)?\\s*-->[\\s\\S]*?<!--\\s*recall:managed:${escapeRegExp2(name)}:end\\s*-->\\n?`,
1545
1561
  "g"
1546
1562
  );
1547
1563
  }
@@ -1577,7 +1593,9 @@ function uninstallManagedRules(targetPath, block) {
1577
1593
  return { ok: true, changed: false, config_path: targetPath, message: `${targetPath} not present` };
1578
1594
  }
1579
1595
  const existing = readFileSync4(targetPath, "utf-8");
1580
- if (!anyBeginMarkerRe(block).test(existing)) {
1596
+ const hasCurrent = anyBeginMarkerRe(block).test(existing);
1597
+ const hasLegacy = findLegacyBlock(existing, block) !== null;
1598
+ if (!hasCurrent && !hasLegacy) {
1581
1599
  return {
1582
1600
  ok: true,
1583
1601
  changed: false,
@@ -1585,7 +1603,7 @@ function uninstallManagedRules(targetPath, block) {
1585
1603
  message: `No Recall-managed rules in ${targetPath}`
1586
1604
  };
1587
1605
  }
1588
- const stripped = existing.replace(blockRe(block), "").replace(/\n{3,}/g, "\n\n");
1606
+ const stripped = removeLegacyBlocks(existing.replace(blockRe(block), ""), block).replace(/\n{3,}/g, "\n\n");
1589
1607
  if (block.ownsFile && stripped.trim() === (block.preamble ?? "").trim()) {
1590
1608
  rmSync(targetPath, { force: true });
1591
1609
  return { ok: true, changed: true, config_path: targetPath, message: `Removed ${targetPath}` };
@@ -1604,6 +1622,9 @@ function checkManagedRules(targetPath, block) {
1604
1622
  }
1605
1623
  const content = readFileSync4(targetPath, "utf-8");
1606
1624
  if (!anyBeginMarkerRe(block).test(content)) {
1625
+ if (findLegacyBlock(content, block)) {
1626
+ return { status: "stale", config_path: targetPath };
1627
+ }
1607
1628
  return { status: "missing", config_path: targetPath };
1608
1629
  }
1609
1630
  return {
@@ -1615,10 +1636,29 @@ function mergeIntoExisting(existing, desired, block) {
1615
1636
  if (anyBeginMarkerRe(block).test(existing)) {
1616
1637
  return existing.replace(blockRe(block), desired);
1617
1638
  }
1639
+ const legacy = findLegacyBlock(existing, block);
1640
+ if (legacy) return existing.replace(legacy, desired);
1618
1641
  if (existing.length === 0) return desired;
1619
1642
  const separator = existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
1620
1643
  return `${existing}${separator}${desired}`;
1621
1644
  }
1645
+ function findLegacyBlock(existing, block) {
1646
+ for (const name of block.legacyNames ?? []) {
1647
+ for (const match of existing.matchAll(blockReForName(name))) {
1648
+ if (match[0].includes(block.body)) return match[0];
1649
+ }
1650
+ }
1651
+ return null;
1652
+ }
1653
+ function removeLegacyBlocks(existing, block) {
1654
+ let next = existing;
1655
+ let match = findLegacyBlock(next, block);
1656
+ while (match) {
1657
+ next = next.replace(match, "");
1658
+ match = findLegacyBlock(next, block);
1659
+ }
1660
+ return next;
1661
+ }
1622
1662
  function ensureTrailingNewline(content) {
1623
1663
  return content.endsWith("\n") ? content : `${content}
1624
1664
  `;
@@ -1749,7 +1789,8 @@ var cursorAdapter = createHooklessAdapter({
1749
1789
  }),
1750
1790
  rulesPath: (options) => cursorRulesPath(options),
1751
1791
  rulesBlock: {
1752
- name: "memory",
1792
+ name: "cursor-memory",
1793
+ legacyNames: ["memory"],
1753
1794
  version: 1,
1754
1795
  body: buildRecallRulesBody(LABEL),
1755
1796
  ownsFile: true,
@@ -1824,7 +1865,8 @@ var githubCopilotAdapter = createHooklessAdapter({
1824
1865
  }),
1825
1866
  rulesPath: (options) => copilotInstructionsPath(options),
1826
1867
  rulesBlock: {
1827
- name: "memory",
1868
+ name: "github-copilot-memory",
1869
+ legacyNames: ["memory"],
1828
1870
  version: 1,
1829
1871
  body: buildRecallRulesBody(LABEL2)
1830
1872
  },
@@ -1856,7 +1898,8 @@ var opencodeAdapter = createHooklessAdapter({
1856
1898
  }),
1857
1899
  rulesPath: (options) => opencodeAgentsPath(options),
1858
1900
  rulesBlock: {
1859
- name: "memory",
1901
+ name: "opencode-memory",
1902
+ legacyNames: ["memory"],
1860
1903
  version: 1,
1861
1904
  body: buildRecallRulesBody(LABEL3)
1862
1905
  },
@@ -1928,7 +1971,8 @@ var windsurfAdapter = createHooklessAdapter({
1928
1971
  }),
1929
1972
  rulesPath: (options) => windsurfGlobalRulesPath(options),
1930
1973
  rulesBlock: {
1931
- name: "memory",
1974
+ name: "windsurf-memory",
1975
+ legacyNames: ["memory"],
1932
1976
  version: 1,
1933
1977
  body: buildRecallRulesBody(LABEL4)
1934
1978
  },
@@ -2952,7 +2996,8 @@ function inspectHooklessInstall(agent, home) {
2952
2996
  }
2953
2997
  function inspectClaudeCodeInstall(home) {
2954
2998
  const configPath3 = join10(home, ".claude", "settings.json");
2955
- const detected = existsSync9(configPath3) || hasCommand("claude");
2999
+ const userConfigPath = join10(home, ".claude.json");
3000
+ const detected = existsSync9(configPath3) || existsSync9(userConfigPath) || hasCommand("claude");
2956
3001
  const notes = [];
2957
3002
  let mcp = false;
2958
3003
  let hooks = false;
@@ -2966,7 +3011,6 @@ function inspectClaudeCodeInstall(home) {
2966
3011
  (group) => isHookGroupManagedBy(group, "recall:managed:claude-code")
2967
3012
  )
2968
3013
  );
2969
- if (!mcp) notes.push("MCP server 'recall' not registered in mcpServers");
2970
3014
  if (!hooks) notes.push("No Recall-managed hooks found in settings.json");
2971
3015
  } catch (err) {
2972
3016
  notes.push(`Could not parse ${configPath3}: ${err.message}`);
@@ -2974,6 +3018,15 @@ function inspectClaudeCodeInstall(home) {
2974
3018
  } else if (detected) {
2975
3019
  notes.push("Claude CLI detected but settings.json missing");
2976
3020
  }
3021
+ if (!mcp && existsSync9(userConfigPath)) {
3022
+ try {
3023
+ const parsed = JSON.parse(readFileSync6(userConfigPath, "utf-8"));
3024
+ mcp = Boolean(parsed?.mcpServers?.recall);
3025
+ } catch (err) {
3026
+ notes.push(`Could not parse ${userConfigPath}: ${err.message}`);
3027
+ }
3028
+ }
3029
+ if (!mcp) notes.push("MCP server 'recall' not registered in user configuration");
2977
3030
  const claudeMd = checkClaudeCodeMemoryOverride({
2978
3031
  configPath: join10(home, ".claude", "CLAUDE.md")
2979
3032
  });
@@ -5230,7 +5283,7 @@ function findByPrefix(db, prefix) {
5230
5283
  function isDirectCliInvocation(moduleUrl, argvPath) {
5231
5284
  if (!argvPath) return false;
5232
5285
  try {
5233
- return realpathSync(fileURLToPath5(moduleUrl)) === realpathSync(argvPath);
5286
+ return realpathSync2(fileURLToPath5(moduleUrl)) === realpathSync2(argvPath);
5234
5287
  } catch {
5235
5288
  return false;
5236
5289
  }