diff --git a/wechat-intent-router.test.mjs b/wechat-intent-router.test.mjs index e0179aa..263f00c 100644 --- a/wechat-intent-router.test.mjs +++ b/wechat-intent-router.test.mjs @@ -12,6 +12,18 @@ import { createWechatIntentRouterConfigService, defaultsFromEnv, } from './wechat-intent-router-config.mjs'; +import { isPageGenerateText } from './wechat/intent/patterns.mjs'; + +test('isPageGenerateText matches travel guide requests without explicit 页面', () => { + assert.equal( + isPageGenerateText('帮我做一个嵊泗 3 天 2 晚的游玩攻略吧,可能'), + true, + ); + assert.equal( + isPageGenerateText('现帮我做一个嵊泗 3 天 2 晚的游玩攻略页面,'), + true, + ); +}); test('resolveWechatIntentRouterPolicy reads env defaults', () => { const policy = resolveWechatIntentRouterPolicy({ diff --git a/wechat-mp.mjs b/wechat-mp.mjs index a3d9c61..7179ce3 100644 --- a/wechat-mp.mjs +++ b/wechat-mp.mjs @@ -3001,6 +3001,7 @@ export function createWechatMpService({ } } if (!reply) { + await ensureSessionProvider(sessionId, user.userId, { intentKind: wechatIntent.kind }); reply = await executeSessionReply( (pathname, init) => fetchForSession(sessionId, pathname, init), sessionId, diff --git a/wechat/intent/patterns.mjs b/wechat/intent/patterns.mjs index a5ef51d..b4dda70 100644 --- a/wechat/intent/patterns.mjs +++ b/wechat/intent/patterns.mjs @@ -17,6 +17,10 @@ export const PAGE_GENERATE_NEWS_PATTERN = 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_NEGATION_PATTERN = /(?:不要|无需|不用|别|不需要)\s*(?:再\s*)?(?:生成|创建|制作|做|写)\s*(?:任何|一个|新的)?\s*(?:html|页面|网页|page|文件)/iu; @@ -44,6 +48,7 @@ export function isPageGenerateText(text) { || 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) || isWechatPageRetryText(normalized) || isWechatPageEditText(normalized) );