mirror of
https://github.com/dtzp555-max/memory-continuity.git
synced 2026-07-21 21:15:07 +00:00
fix: ignorePatterns tests message text not object, add warn for bad regex
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -340,8 +340,9 @@ const plugin = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Count real user messages (exclude system, metadata-only, short commands)
|
// Count real user messages (exclude system, metadata-only, short commands)
|
||||||
const realUserMsgs = messages.filter(m => {
|
// Returns cleaned text strings so ignore-pattern regex can test against actual content.
|
||||||
if (m?.role !== "user") return false;
|
const realUserMsgs = messages.reduce((acc, m) => {
|
||||||
|
if (m?.role !== "user") return acc;
|
||||||
const text = typeof m?.content === "string" ? m.content
|
const text = typeof m?.content === "string" ? m.content
|
||||||
: Array.isArray(m?.content) ? m.content.filter(b => b?.type === "text").map(b => b.text).join("\n")
|
: Array.isArray(m?.content) ? m.content.filter(b => b?.type === "text").map(b => b.text).join("\n")
|
||||||
: "";
|
: "";
|
||||||
@@ -350,12 +351,13 @@ const plugin = {
|
|||||||
.replace(/^Sender \(untrusted metadata\):[\s\S]*?\n\n/m, "")
|
.replace(/^Sender \(untrusted metadata\):[\s\S]*?\n\n/m, "")
|
||||||
.trim();
|
.trim();
|
||||||
// Skip very short messages like "/new", "/status", single-word queries
|
// Skip very short messages like "/new", "/status", single-word queries
|
||||||
return cleaned.length > 10;
|
if (cleaned.length > 10) acc.push(cleaned);
|
||||||
});
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Check ignore patterns — skip sessions matching cron/subagent noise
|
// Check ignore patterns — skip sessions matching cron/subagent noise
|
||||||
const ignorePatterns = (config.ignorePatterns || [])
|
const ignorePatterns = (config.ignorePatterns || [])
|
||||||
.map(p => { try { return new RegExp(p, "i"); } catch { return null; } })
|
.map(p => { try { return new RegExp(p, "i"); } catch { log.warn?.("[memory-continuity] ignorePatterns: invalid regex, skipping: " + p); return null; } })
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
if (ignorePatterns.length > 0 && realUserMsgs.length > 0) {
|
if (ignorePatterns.length > 0 && realUserMsgs.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user