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); });