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:
@@ -0,0 +1,49 @@
|
||||
/** Explicit WeChat channel prefixes so users can separate chat, page, and scheduled tasks. */
|
||||
|
||||
export const WECHAT_CHANNEL_PREFIX = Object.freeze({
|
||||
CHAT: 'chat',
|
||||
PAGE: 'page',
|
||||
SCHEDULED_TASK: 'scheduled_task',
|
||||
});
|
||||
|
||||
const PREFIX_ENTRIES = Object.freeze([
|
||||
{
|
||||
channel: WECHAT_CHANNEL_PREFIX.CHAT,
|
||||
pattern: /^【?\s*聊天\s*】?[::\s]*/iu,
|
||||
},
|
||||
{
|
||||
channel: WECHAT_CHANNEL_PREFIX.PAGE,
|
||||
pattern: /^【?\s*(?:改页|做页|页面)\s*】?[::\s]*/iu,
|
||||
},
|
||||
{
|
||||
channel: WECHAT_CHANNEL_PREFIX.SCHEDULED_TASK,
|
||||
pattern: /^【?\s*定时任务\s*】?[::\s]*/iu,
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* @returns {{ channel: string|null, body: string, hadPrefix: boolean }}
|
||||
*/
|
||||
export function parseWechatChannelPrefix(text) {
|
||||
const normalized = String(text ?? '').trim();
|
||||
if (!normalized) {
|
||||
return { channel: null, body: '', hadPrefix: false };
|
||||
}
|
||||
for (const entry of PREFIX_ENTRIES) {
|
||||
if (!entry.pattern.test(normalized)) continue;
|
||||
return {
|
||||
channel: entry.channel,
|
||||
body: normalized.replace(entry.pattern, '').trim(),
|
||||
hadPrefix: true,
|
||||
};
|
||||
}
|
||||
return { channel: null, body: normalized, hadPrefix: false };
|
||||
}
|
||||
|
||||
export function stripWechatChannelPrefix(text) {
|
||||
return parseWechatChannelPrefix(text).body;
|
||||
}
|
||||
|
||||
export function hasWechatPageChannelPrefix(text) {
|
||||
return parseWechatChannelPrefix(text).channel === WECHAT_CHANNEL_PREFIX.PAGE;
|
||||
}
|
||||
Reference in New Issue
Block a user