Files
memind/wechat/intent/patterns.mjs
T
john 26fe5912a3 fix(wechat): guard ambiguous memory recall and scheduled task execution
Skip memory injection for short filler messages, demote page-workflow memory
pollution, keep scheduled automation off page.generate, and fail scheduled
tasks that only return clarification instead of deliverables.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 22:50:46 +08:00

53 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** WeChat channel intent patterns — not shared with H5 chat-skills routing. */
import {
isWechatPageEditText,
isWechatPageRetryText,
} from './page-continuation.mjs';
import { shouldUseScheduledTaskAutomation } from '../../scheduled-task-intent.mjs';
export const PAGE_GENERATE_PATTERN =
/(?:生成|创建|做|写|帮我.*(?:生成|创建|做|写)).*(?:html|页面|网页|page|文件)/iu;
export const PAGE_GENERATE_NEGATION_PATTERN =
/(?:不要|无需|不用|别|不需要)\s*(?:再\s*)?(?:生成|创建|制作|做|写)\s*(?:任何|一个|新的)?\s*(?:html|页面|网页|page|文件)/iu;
export const DOCX_DOWNLOAD_PATTERN =
/(?:(?:word|docx|\.docx|\.doc|文档).*(?:下载|链接|导出|给我)|(?:下载|导出|提供|给我).*(?:word|docx|\.docx|\.doc|文档))/iu;
export const TOPIC_RESET_PATTERN =
/^(换(个)?话题|换新会话|新会话|开新会话|另开会话|清空上下文|新问题|忽略之前|不管之前|重新开始|reset)$/iu;
export const TOPIC_RESET_LOOSE_PATTERN = /忽略.*之前|不要管.*之前|别管.*之前/u;
export const STATUS_PROBE_PATTERN = /^[?]+$/u;
export const GREETING_PATTERN =
/^(你好|您好|在吗|在不在|嗨|hi|hello|hey)[!!。.\s]*$/iu;
export const CONNECTIVITY_TEST_PATTERN = /^(测试\s*\d*|test\s*\d*)[!!。.\s]*$/iu;
export function isPageGenerateText(text) {
const normalized = String(text ?? '').trim();
if (!normalized) return false;
if (shouldUseScheduledTaskAutomation(normalized)) return false;
if (PAGE_GENERATE_NEGATION_PATTERN.test(normalized)) return false;
return (
PAGE_GENERATE_PATTERN.test(normalized)
|| isWechatPageRetryText(normalized)
|| isWechatPageEditText(normalized)
);
}
export function isTopicResetText(text) {
const normalized = String(text ?? '').trim();
if (!normalized) return false;
return TOPIC_RESET_PATTERN.test(normalized) || TOPIC_RESET_LOOSE_PATTERN.test(normalized);
}
export function wantsDocxDownload(text) {
const normalized = String(text ?? '').trim();
if (!normalized) return false;
return DOCX_DOWNLOAD_PATTERN.test(normalized);
}