dsh-mnemon-source-runtime 0.5.6 → 0.5.7

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/lib/index.js +7 -2
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -207,7 +207,9 @@ function prepareMutation(before, request, now) {
207
207
  };
208
208
  }
209
209
  const oldText = normalizeContent(request.oldText, "oldText");
210
- const matches = entries.map((entry, index) => entry.target === request.target && entry.content.includes(oldText) ? index : -1).filter((index) => index >= 0);
210
+ const substringMatches = entries.map((entry, index) => entry.target === request.target && entry.content.includes(oldText) ? index : -1).filter((index) => index >= 0);
211
+ const exactMatches = substringMatches.filter((index) => entries[index].content === oldText);
212
+ const matches = exactMatches.length > 0 ? exactMatches : substringMatches;
211
213
  if (matches.length === 0) throw new Error(`No ${request.target} entry contains ${JSON.stringify(oldText)}.`);
212
214
  if (matches.length > 1) throw new Error(`Multiple ${request.target} entries contain ${JSON.stringify(oldText)}; use a unique substring.`);
213
215
  const index = matches[0];
@@ -732,7 +734,10 @@ function createRuntimeMemorySource(config = {}) {
732
734
  enum: ["memory", "user"]
733
735
  },
734
736
  content: { type: "string" },
735
- oldText: { type: "string" },
737
+ oldText: {
738
+ type: "string",
739
+ description: "Full content of the existing entry, or a unique substring. A unique full-content match takes precedence within the selected target. Required for replace and remove."
740
+ },
736
741
  importance: {
737
742
  type: "string",
738
743
  enum: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mnemon-source-runtime",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "Self-contained runtime Source for Composable View Memory.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -61,7 +61,7 @@
61
61
  "@types/node": "^22.0.0",
62
62
  "@types/react": "^18.3.0",
63
63
  "@types/react-dom": "^18.3.0",
64
- "dsh-mnemon": "^0.5.7",
64
+ "dsh-mnemon": "^0.5.10",
65
65
  "jsdom": "^26.0.0",
66
66
  "react": "^18.2.0",
67
67
  "react-dom": "^18.2.0",