toon-memory 2.11.0 → 3.1.0

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.
@@ -48,8 +48,9 @@ export function findRelatedEntries(text: string, excludeKey: string = "", limit:
48
48
  }
49
49
 
50
50
  /**
51
- * Increment the `accessed` counter for the given entry ids.
52
- * Used by recall/suggest so frequently-used memories rank higher.
51
+ * Increment the `accessed` counter and update `lastAccessed` timestamp
52
+ * for the given entry ids. Used by recall/suggest so frequently-used
53
+ * memories rank higher.
53
54
  */
54
55
  export function bumpAccessed(ids: string[]): void {
55
56
  if (ids.length === 0) return
@@ -59,6 +60,7 @@ export function bumpAccessed(ids: string[]): void {
59
60
  const headerIdx = lines.findIndex((l) => l.startsWith("entries[") || /^\[\d+\|]/.test(l))
60
61
  if (headerIdx === -1) return
61
62
 
63
+ const now = new Date().toISOString()
62
64
  for (let i = headerIdx + 1; i < lines.length; i++) {
63
65
  const line = lines[i]
64
66
  if (!line.startsWith(" ") || !line.includes("|")) continue
@@ -67,6 +69,9 @@ export function bumpAccessed(ids: string[]): void {
67
69
  if (idSet.has(parts[0])) {
68
70
  const accessed = parts.length > 8 ? (parseInt(parts[8]) || 0) + 1 : 1
69
71
  parts[8] = String(accessed)
72
+ // Ensure we have enough fields for lastAccessed (field 12)
73
+ while (parts.length < 13) parts.push("")
74
+ parts[12] = now
70
75
  lines[i] = ` ${parts.join("|")}`
71
76
  }
72
77
  }