memento-mcp 0.3.7 → 0.3.8
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/package.json +1 -1
- package/scripts/memento-stop-recall.sh +11 -22
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@ print('true' if hook.get('enabled', True) else 'false')
|
|
|
42
42
|
MEMENTO_WORKSPACE="${MEMENTO_WORKSPACE:-$(echo "$CONFIG_JSON" | python3 -c "import json,sys; print(json.load(sys.stdin).get('workspace',''))" 2>/dev/null)}"
|
|
43
43
|
|
|
44
44
|
RECALL_LIMIT=$(echo "$CONFIG_JSON" | python3 -c "import json,sys; print(json.load(sys.stdin).get('hooks',{}).get('$HOOK_NAME',{}).get('limit',5))" 2>/dev/null)
|
|
45
|
-
RECALL_MAX_LENGTH=$(echo "$CONFIG_JSON" | python3 -c "import json,sys; print(json.load(sys.stdin).get('hooks',{}).get('$HOOK_NAME',{}).get('maxLength',
|
|
45
|
+
RECALL_MAX_LENGTH=$(echo "$CONFIG_JSON" | python3 -c "import json,sys; print(json.load(sys.stdin).get('hooks',{}).get('$HOOK_NAME',{}).get('maxLength',120))" 2>/dev/null)
|
|
46
46
|
fi
|
|
47
47
|
# --- End config block ---
|
|
48
48
|
|
|
@@ -92,34 +92,24 @@ try:
|
|
|
92
92
|
data = json.load(sys.stdin)
|
|
93
93
|
lines = []
|
|
94
94
|
count = 0
|
|
95
|
+
abbrev = {'instruction':'instr','observation':'obs','decision':'dec','preference':'pref'}
|
|
95
96
|
|
|
96
97
|
memories = data.get('memories', {}).get('matches', [])
|
|
97
98
|
if memories:
|
|
98
99
|
for m in memories[:${RECALL_LIMIT:-5}]:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
content
|
|
102
|
-
score = m.get('score', '?')
|
|
103
|
-
date_str = f' {m[\"created_at\"][:10]}' if m.get('created_at') else ''
|
|
104
|
-
lines.append(f' {m[\"id\"]} ({m[\"type\"]}, {score}{date_str}){tag_str} — {content}')
|
|
100
|
+
content = m['content'][:${RECALL_MAX_LENGTH:-120}]
|
|
101
|
+
t = abbrev.get(m['type'], m['type'])
|
|
102
|
+
lines.append(f' · {content} [{m[\"id\"]} {t}]')
|
|
105
103
|
count += 1
|
|
106
104
|
|
|
107
105
|
skip_matches = data.get('skip_matches', [])
|
|
108
106
|
if skip_matches:
|
|
109
|
-
lines.append('')
|
|
110
|
-
lines.append('SKIP LIST WARNINGS:')
|
|
111
107
|
for s in skip_matches:
|
|
112
|
-
lines.append(f'
|
|
108
|
+
lines.append(f' Skip: {s[\"item\"]} — {s[\"reason\"]} (expires {s[\"expires\"]})')
|
|
113
109
|
|
|
114
|
-
# Auto-extracted memories
|
|
115
110
|
extracted = data.get('extracted', [])
|
|
116
111
|
if extracted:
|
|
117
|
-
lines.append('')
|
|
118
|
-
lines.append('MEMORIES STORED:')
|
|
119
|
-
for e in extracted:
|
|
120
|
-
etags = [t for t in e.get('tags', []) if t != 'source:auto-extract']
|
|
121
|
-
etag_str = f' [{\", \".join(etags)}]' if etags else ''
|
|
122
|
-
lines.append(f' {e[\"id\"]} ({e.get(\"type\", \"observation\")}){etag_str} — {e[\"content\"]}')
|
|
112
|
+
lines.append(f' Stored: {len(extracted)} new memories')
|
|
123
113
|
|
|
124
114
|
# Output: recall_count \t extracted_count \t detail
|
|
125
115
|
extracted_count = len(extracted)
|
|
@@ -156,17 +146,16 @@ if [ "$SAAS_COUNT" != "0" ]; then
|
|
|
156
146
|
fi
|
|
157
147
|
|
|
158
148
|
# Build summary line
|
|
159
|
-
SUMMARY="
|
|
149
|
+
SUMMARY="Recall (${SAAS_COUNT})"
|
|
160
150
|
if [ -n "$EXTRACTED_COUNT" ] && [ "$EXTRACTED_COUNT" != "0" ]; then
|
|
161
|
-
SUMMARY="${
|
|
151
|
+
SUMMARY="Recall (${SAAS_COUNT}), stored ${EXTRACTED_COUNT}"
|
|
162
152
|
fi
|
|
163
153
|
|
|
164
154
|
# Block the Stop so recalled memories are injected into context.
|
|
165
155
|
# If no memories are relevant, respond with <...> to signal active silence.
|
|
166
|
-
REASON="${SUMMARY}
|
|
156
|
+
REASON="${SUMMARY}:
|
|
167
157
|
${SAAS_DETAIL}
|
|
168
|
-
|
|
169
|
-
You have absorbed these memories into context. If any recalled memory is stale, wrong, or overlaps with others — update, delete, or consolidate it now. Otherwise respond with <...> to continue naturally."
|
|
158
|
+
Stale or wrong? Update or consolidate."
|
|
170
159
|
|
|
171
160
|
python3 -c "
|
|
172
161
|
import json, sys
|