@hir4ta/mneme 0.25.1 → 0.25.3

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mneme",
3
3
  "description": "A plugin that provides long-term memory for Claude Code. It automatically saves context lost during auto-compact, offering features for session restoration, recording technical decisions, and learning developer patterns.",
4
- "version": "0.25.1",
4
+ "version": "0.25.3",
5
5
  "author": {
6
6
  "name": "hir4ta"
7
7
  },
package/README.ja.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # mneme
2
2
 
3
- ![Version](https://img.shields.io/badge/version-0.25.1-blue)
3
+ ![Version](https://img.shields.io/badge/version-0.25.3-blue)
4
4
  ![Node.js](https://img.shields.io/badge/node-%3E%3D22.5.0-brightgreen)
5
5
  [![NPM Version](https://img.shields.io/npm/v/%40hir4ta%2Fmneme)](https://www.npmjs.com/package/@hir4ta/mneme)
6
6
  [![MIT License](https://img.shields.io/npm/l/%40hir4ta%2Fmneme)](https://github.com/hir4ta/mneme/blob/main/LICENSE)
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # mneme
2
2
 
3
- ![Version](https://img.shields.io/badge/version-0.25.1-blue)
3
+ ![Version](https://img.shields.io/badge/version-0.25.3-blue)
4
4
  ![Node.js](https://img.shields.io/badge/node-%3E%3D22.5.0-brightgreen)
5
5
  [![NPM Version](https://img.shields.io/npm/v/%40hir4ta%2Fmneme)](https://www.npmjs.com/package/@hir4ta/mneme)
6
6
  [![MIT License](https://img.shields.io/npm/l/%40hir4ta%2Fmneme)](https://github.com/hir4ta/mneme/blob/main/LICENSE)
@@ -658,6 +658,50 @@ var IGNORED_PREFIXES = [
658
658
  ".claude/"
659
659
  ];
660
660
  var IGNORED_FILES = ["package-lock.json", "pnpm-lock.yaml", "yarn.lock"];
661
+ function ensureCompactSessionLink(projectPath, currentClaudeSessionId) {
662
+ const mnemeDir = path4.join(projectPath, ".mneme");
663
+ const pendingFile = path4.join(mnemeDir, ".pending-compact.json");
664
+ if (!fs5.existsSync(pendingFile)) return;
665
+ const sessionLinksDir = path4.join(mnemeDir, "session-links");
666
+ const linkFile = path4.join(sessionLinksDir, `${currentClaudeSessionId}.json`);
667
+ if (fs5.existsSync(linkFile)) return;
668
+ try {
669
+ const pending = JSON.parse(fs5.readFileSync(pendingFile, "utf8"));
670
+ const oldClaudeSessionId = pending.claudeSessionId || "";
671
+ const timestamp = pending.timestamp || "";
672
+ if (timestamp) {
673
+ const age = Date.now() - new Date(timestamp).getTime();
674
+ if (age > 5 * 60 * 1e3) return;
675
+ }
676
+ if (!oldClaudeSessionId || oldClaudeSessionId === currentClaudeSessionId) {
677
+ return;
678
+ }
679
+ const masterSessionId = resolveMnemeSessionId(
680
+ projectPath,
681
+ oldClaudeSessionId
682
+ );
683
+ if (!fs5.existsSync(sessionLinksDir)) {
684
+ fs5.mkdirSync(sessionLinksDir, { recursive: true });
685
+ }
686
+ fs5.writeFileSync(
687
+ linkFile,
688
+ JSON.stringify(
689
+ {
690
+ masterSessionId,
691
+ claudeSessionId: currentClaudeSessionId,
692
+ linkedAt: (/* @__PURE__ */ new Date()).toISOString()
693
+ },
694
+ null,
695
+ 2
696
+ )
697
+ );
698
+ console.error(
699
+ `[mneme] Save: compact continuation linked: ${currentClaudeSessionId} \u2192 ${masterSessionId}`
700
+ );
701
+ } catch (e) {
702
+ console.error(`[mneme] Error in ensureCompactSessionLink: ${e}`);
703
+ }
704
+ }
661
705
  function detectCompactContinuation(interactions, projectPath) {
662
706
  const compactInteraction = interactions.find((i) => i.isCompactSummary);
663
707
  if (!compactInteraction?.user) return null;
@@ -764,6 +808,7 @@ async function incrementalSave(claudeSessionId, transcriptPath, projectPath) {
764
808
  message: `Transcript not found: ${transcriptPath}`
765
809
  };
766
810
  }
811
+ ensureCompactSessionLink(projectPath, claudeSessionId);
767
812
  const dbPath = path4.join(projectPath, ".mneme", "local.db");
768
813
  const db = initDatabase(dbPath);
769
814
  let mnemeSessionId = resolveMnemeSessionId(projectPath, claudeSessionId);
@@ -662,6 +662,50 @@ var IGNORED_PREFIXES = [
662
662
  ".claude/"
663
663
  ];
664
664
  var IGNORED_FILES = ["package-lock.json", "pnpm-lock.yaml", "yarn.lock"];
665
+ function ensureCompactSessionLink(projectPath, currentClaudeSessionId) {
666
+ const mnemeDir = path4.join(projectPath, ".mneme");
667
+ const pendingFile = path4.join(mnemeDir, ".pending-compact.json");
668
+ if (!fs5.existsSync(pendingFile)) return;
669
+ const sessionLinksDir = path4.join(mnemeDir, "session-links");
670
+ const linkFile = path4.join(sessionLinksDir, `${currentClaudeSessionId}.json`);
671
+ if (fs5.existsSync(linkFile)) return;
672
+ try {
673
+ const pending = JSON.parse(fs5.readFileSync(pendingFile, "utf8"));
674
+ const oldClaudeSessionId = pending.claudeSessionId || "";
675
+ const timestamp = pending.timestamp || "";
676
+ if (timestamp) {
677
+ const age = Date.now() - new Date(timestamp).getTime();
678
+ if (age > 5 * 60 * 1e3) return;
679
+ }
680
+ if (!oldClaudeSessionId || oldClaudeSessionId === currentClaudeSessionId) {
681
+ return;
682
+ }
683
+ const masterSessionId = resolveMnemeSessionId(
684
+ projectPath,
685
+ oldClaudeSessionId
686
+ );
687
+ if (!fs5.existsSync(sessionLinksDir)) {
688
+ fs5.mkdirSync(sessionLinksDir, { recursive: true });
689
+ }
690
+ fs5.writeFileSync(
691
+ linkFile,
692
+ JSON.stringify(
693
+ {
694
+ masterSessionId,
695
+ claudeSessionId: currentClaudeSessionId,
696
+ linkedAt: (/* @__PURE__ */ new Date()).toISOString()
697
+ },
698
+ null,
699
+ 2
700
+ )
701
+ );
702
+ console.error(
703
+ `[mneme] Save: compact continuation linked: ${currentClaudeSessionId} \u2192 ${masterSessionId}`
704
+ );
705
+ } catch (e) {
706
+ console.error(`[mneme] Error in ensureCompactSessionLink: ${e}`);
707
+ }
708
+ }
665
709
  function detectCompactContinuation(interactions, projectPath) {
666
710
  const compactInteraction = interactions.find((i) => i.isCompactSummary);
667
711
  if (!compactInteraction?.user) return null;
@@ -768,6 +812,7 @@ async function incrementalSave(claudeSessionId, transcriptPath, projectPath) {
768
812
  message: `Transcript not found: ${transcriptPath}`
769
813
  };
770
814
  }
815
+ ensureCompactSessionLink(projectPath, claudeSessionId);
771
816
  const dbPath = path4.join(projectPath, ".mneme", "local.db");
772
817
  const db = initDatabase(dbPath);
773
818
  let mnemeSessionId = resolveMnemeSessionId(projectPath, claudeSessionId);