Files
memind/wechat/intent/patterns.mjs
T
john 1d165bc6e3 feat(goose): complete v1.49 phase3 closeout gates and context fusion plan
Expand Goose v1.49 smoke coverage (memory chat, portal resume, page e2e,
multiturn provider), add canary memory policy lock, refresh baselines, and
ignore one-off evidence artifacts. Document headroom-based context runtime
fusion plan; include auth, scheduled-task, and wechat intent fixes on branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 18:11:39 +08:00

87 lines
3.8 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';
export const PAGE_GENERATE_PATTERN =
/(?:生成|创建|做|写|帮我.*(?:生成|创建|做|写)).*(?:html|页面|网页|page|文件)/iu;
export const PAGE_GENERATE_AFTER_PAGE_PATTERN =
/(?:html|页面|网页|page|文件).*(?:做出来|做好|做完|弄出来|生成好|制作好|发我|给我)/iu;
export const PAGE_GENERATE_NEWS_PATTERN =
/(?:新闻|早报).{0,16}(?:页面|网页|html)/iu;
export const PAGE_GENERATE_FORMAT_PATTERN =
/按照.{0,32}格式.{0,32}(?:页面|网页|html)/iu;
/** 用户口头说「做攻略/行程」但未显式说「页面」——服务号仍应走 page.generate + Cursor */
export const PAGE_GENERATE_GUIDE_PATTERN =
/(?:帮我.{0,12})?(?:做|写|生成|整理).{0,48}(?:游玩|旅行|旅游)?(?:攻略|指南|行程)(?!.*(?:不要|别|无需).*(?:页面|网页))/iu;
/** 「我要旅游线路图/行程表」等未显式说页面的交付请求 */
export const PAGE_GENERATE_ROUTE_MAP_PATTERN =
/(?:我要|我想|想要|需要|帮我|给我).{0,16}(?:做|来|一个|一份|个)?.{0,24}(?:游玩|旅行|旅游)?(?:线路图|路线图|行程图|行程表)/iu;
/** 已有页面的补充/细化(含带 MindSpace URL 的改页请求) */
export const PAGE_REFINE_DETAIL_PATTERN =
/(?:页面|网页|html|攻略).{0,40}(?:不够详细|不够完整|更详细|详细到|补充|完善|优化)|(?:把|将).{0,16}(?:页面|网页|攻略).{0,32}(?:更新|改|完善|补充|优化|加长)/iu;
export const PAGE_MINDSPACE_PUBLIC_URL_PATTERN =
/(?:https?:\/\/[^\s]+)?\/?mindspace\/[0-9a-f-]{36}\/public\/[\w.-]+\.html/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 (PAGE_GENERATE_NEGATION_PATTERN.test(normalized)) return false;
if (PAGE_REFINE_DETAIL_PATTERN.test(normalized)) return true;
if (
PAGE_MINDSPACE_PUBLIC_URL_PATTERN.test(normalized)
&& /(?:页面|网页|更新|详细|改|完善|补充)/iu.test(normalized)
) {
return true;
}
return (
PAGE_GENERATE_PATTERN.test(normalized)
|| PAGE_GENERATE_AFTER_PAGE_PATTERN.test(normalized)
|| PAGE_GENERATE_NEWS_PATTERN.test(normalized)
|| PAGE_GENERATE_FORMAT_PATTERN.test(normalized)
|| PAGE_GENERATE_GUIDE_PATTERN.test(normalized)
|| PAGE_GENERATE_ROUTE_MAP_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);
}