Files
memind/wechat/wechat-page-continuation.test.mjs
T
john c9b2fcba87
Memind CI / Test, build, and release guards (push) Has been cancelled
fix(wechat): treat report page follow-ups as session continuation
Phrases like "解读详细报告,做成页面" now bind to the in-session report
context instead of behaving like a brand-new page topic.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 22:53:00 +08:00

49 lines
2.0 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { classifyWechatIntent } from './intent/classifier.mjs';
import {
isWechatSessionPageContinuation,
isWechatPageRetryText,
isWechatPageEditText,
isWechatContentEditFollowup,
} from './intent/page-continuation.mjs';
test('WeChat page continuation detects retry and edit phrasings', () => {
assert.equal(isWechatPageRetryText('重试上次页面'), true);
assert.equal(isWechatPageEditText('修改刚才生成的页面,背景改成浅蓝色'), true);
assert.equal(isWechatContentEditFollowup('把诗里第三段改长一点'), true);
const retryIntent = classifyWechatIntent({ msgType: 'text', agentText: '重试上次页面' });
assert.equal(retryIntent.kind, 'page.generate');
assert.equal(isWechatSessionPageContinuation(retryIntent, '重试上次页面'), true);
const editIntent = classifyWechatIntent({
msgType: 'text',
agentText: '把页面标题改成《七月清晨》',
});
assert.equal(editIntent.kind, 'page.generate');
assert.equal(isWechatSessionPageContinuation(editIntent, editIntent.topic), true);
const poemEdit = classifyWechatIntent({ msgType: 'text', agentText: '把诗里第三段改长一点' });
assert.equal(poemEdit.kind, 'chat.general');
assert.equal(isWechatSessionPageContinuation(poemEdit, '把诗里第三段改长一点'), true);
});
test('WeChat page continuation rejects full new-topic page requests', () => {
const intent = classifyWechatIntent({
msgType: 'text',
agentText: '帮我做一个上海旅游攻略页面',
});
assert.equal(intent.kind, 'page.generate');
assert.equal(isWechatSessionPageContinuation(intent, intent.topic), false);
});
test('WeChat page continuation recognizes report interpretation follow-ups', () => {
const intent = classifyWechatIntent({
msgType: 'text',
agentText: '解读详细报告,做成页面',
});
assert.equal(intent.kind, 'page.generate');
assert.equal(isWechatSessionPageContinuation(intent, intent.topic), true);
});