server-memory-enhanced 2.2.0 → 2.2.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.
@@ -10,8 +10,9 @@ export const MAX_OBSERVATION_LENGTH = 150;
10
10
  /**
11
11
  * Maximum number of sentences allowed per observation
12
12
  * Per spec Section 2: Hard Limits on Observation Length
13
+ * Increased to 3 to accommodate technical facts with version numbers and metrics
13
14
  */
14
- export const MAX_SENTENCES = 2;
15
+ export const MAX_SENTENCES = 3;
15
16
  /**
16
17
  * Minimum observation length in characters
17
18
  */
@@ -2,11 +2,26 @@
2
2
  * Validation logic for save_memory tool (Section 1 of spec)
3
3
  */
4
4
  import { MAX_OBSERVATION_LENGTH, MIN_OBSERVATION_LENGTH, MAX_SENTENCES, SENTENCE_TERMINATORS, TARGET_AVG_RELATIONS, RELATION_SCORE_WEIGHT, OBSERVATION_SCORE_WEIGHT } from './constants.js';
5
+ /**
6
+ * Counts actual sentences in text, ignoring periods in version numbers and decimals
7
+ * @param text The text to analyze
8
+ * @returns Number of actual sentences
9
+ */
10
+ function countSentences(text) {
11
+ // Remove version numbers (e.g., 1.2.0, v5.4.3, V2.1.0) and decimal numbers before counting
12
+ // This prevents false positives where technical data is incorrectly counted as sentences
13
+ // Using explicit case handling [vV] for version prefix
14
+ const cleaned = text
15
+ .replace(/\b[vV]?\d+\.\d+(\.\d+)*\b/g, 'VERSION'); // handles version numbers and decimals
16
+ // Split on actual sentence terminators
17
+ const sentences = cleaned.split(SENTENCE_TERMINATORS).filter(s => s.trim().length > 0);
18
+ return sentences.length;
19
+ }
5
20
  /**
6
21
  * Validates a single observation according to spec requirements:
7
22
  * - Min 5 characters
8
23
  * - Max 150 characters
9
- * - Max 2 sentences (simple count by periods)
24
+ * - Max 3 sentences (ignoring periods in version numbers and decimals)
10
25
  */
11
26
  export function validateObservation(obs) {
12
27
  if (obs.length < MIN_OBSERVATION_LENGTH) {
@@ -23,12 +38,12 @@ export function validateObservation(obs) {
23
38
  suggestion: `Split into multiple observations.`
24
39
  };
25
40
  }
26
- const sentences = obs.split(SENTENCE_TERMINATORS).filter(s => s.trim().length > 0);
27
- if (sentences.length > MAX_SENTENCES) {
41
+ const sentenceCount = countSentences(obs);
42
+ if (sentenceCount > MAX_SENTENCES) {
28
43
  return {
29
44
  valid: false,
30
- error: `Too many sentences (${sentences.length}). Max ${MAX_SENTENCES}.`,
31
- suggestion: `One fact per observation. Split this into ${sentences.length} separate observations.`
45
+ error: `Too many sentences (${sentenceCount}). Max ${MAX_SENTENCES}.`,
46
+ suggestion: `One fact per observation. Split this into ${sentenceCount} separate observations.`
32
47
  };
33
48
  }
34
49
  return { valid: true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "server-memory-enhanced",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Enhanced MCP server for memory with agent threading, timestamps, and confidence scoring",
5
5
  "license": "MIT",
6
6
  "mcpName": "io.github.modelcontextprotocol/server-memory-enhanced",