Separate WeChat chat, page refine, and task flows with explicit routing.
Memind CI / Test, build, and release guards (push) Successful in 4m40s
Memind CI / Test, build, and release guards (push) Successful in 4m40s
Add channel prefixes, pin edit targets in Cursor prompts, and force fresh sessions for page refine URLs so DeepSeek/Goose chat history does not pollute page tasks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { parseWechatChannelPrefix, WECHAT_CHANNEL_PREFIX } from './channel-prefix.mjs';
|
||||
import {
|
||||
CONNECTIVITY_TEST_PATTERN,
|
||||
GREETING_PATTERN,
|
||||
@@ -43,27 +44,50 @@ import { WECHAT_SESSION_ACTION } from './session-action.mjs';
|
||||
* @param {{ msgType?: string, agentText?: string, displayText?: string }} intent
|
||||
* @returns {WechatIntent}
|
||||
*/
|
||||
function withChannelMeta(result, channelPrefix) {
|
||||
if (!channelPrefix) return result;
|
||||
return { ...result, channelPrefix };
|
||||
}
|
||||
|
||||
export function classifyWechatIntent(intent) {
|
||||
const msgType = String(intent?.msgType ?? 'text').toLowerCase();
|
||||
const text = String(intent?.agentText ?? intent?.displayText ?? '').trim();
|
||||
const rawText = String(intent?.agentText ?? intent?.displayText ?? '').trim();
|
||||
const { channel: channelPrefix, body: text } = parseWechatChannelPrefix(rawText);
|
||||
|
||||
if (msgType === 'text' || msgType === 'voice') {
|
||||
if (isTopicResetText(text)) {
|
||||
return { kind: 'session.reset', sessionAction: WECHAT_SESSION_ACTION.RESET };
|
||||
return withChannelMeta(
|
||||
{ kind: 'session.reset', sessionAction: WECHAT_SESSION_ACTION.RESET },
|
||||
channelPrefix,
|
||||
);
|
||||
}
|
||||
if (STATUS_PROBE_PATTERN.test(text)) {
|
||||
return withChannelMeta({ kind: 'status.probe' }, channelPrefix);
|
||||
}
|
||||
if (GREETING_PATTERN.test(text.replace(/[!!。.\s]+$/g, ''))) {
|
||||
return withChannelMeta({ kind: 'greeting' }, channelPrefix);
|
||||
}
|
||||
if (STATUS_PROBE_PATTERN.test(text)) return { kind: 'status.probe' };
|
||||
if (GREETING_PATTERN.test(text.replace(/[!!。.\s]+$/g, ''))) return { kind: 'greeting' };
|
||||
if (CONNECTIVITY_TEST_PATTERN.test(text.replace(/[!!。.\s]+$/g, ''))) {
|
||||
return { kind: 'connectivity.test' };
|
||||
return withChannelMeta({ kind: 'connectivity.test' }, channelPrefix);
|
||||
}
|
||||
if (isPageGenerateText(text)) {
|
||||
return {
|
||||
if (channelPrefix === WECHAT_CHANNEL_PREFIX.CHAT) {
|
||||
return withChannelMeta({ kind: 'chat.general', text }, channelPrefix);
|
||||
}
|
||||
if (channelPrefix === WECHAT_CHANNEL_PREFIX.PAGE) {
|
||||
return withChannelMeta({
|
||||
kind: 'page.generate',
|
||||
topic: text,
|
||||
wantsDocx: wantsDocxDownload(text),
|
||||
};
|
||||
}, channelPrefix);
|
||||
}
|
||||
return { kind: 'chat.general', text };
|
||||
if (isPageGenerateText(text)) {
|
||||
return withChannelMeta({
|
||||
kind: 'page.generate',
|
||||
topic: text,
|
||||
wantsDocx: wantsDocxDownload(text),
|
||||
}, channelPrefix);
|
||||
}
|
||||
return withChannelMeta({ kind: 'chat.general', text }, channelPrefix);
|
||||
}
|
||||
|
||||
if (msgType === 'event') {
|
||||
|
||||
Reference in New Issue
Block a user