Files
memind/intent-classifier.test.mjs
T
john d58dc2a251 feat(wechat): add Intent Transaction Layer with unified task schema
Introduce Draft → Confirm → Commit flow for WeChat schedule intents behind
feature flags, plus h5_tasks dual-write/read aggregation and rollout scripts
so reminders and automations get explicit user confirmation before persisting.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 15:59:17 +08:00

55 lines
2.0 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { classifyUserIntent } from './intent-classifier.mjs';
test('classifies query guard for scheduled task inventory', () => {
const result = classifyUserIntent('有没有我的新闻定时任务');
assert.equal(result.layer, 'L0');
assert.equal(result.action, 'answer_only');
});
test('classifies cancel daily task as L2 manage', () => {
const result = classifyUserIntent('取消每日新闻任务');
assert.equal(result.layer, 'L2');
assert.equal(result.kind, 'manage');
assert.equal(result.action, 'cancel_scheduled_task');
});
test('classifies bare set reminder as L1 slot fill', () => {
const result = classifyUserIntent('设置提醒');
assert.equal(result.layer, 'L1');
assert.equal(result.kind, 'timed_reminder');
assert.ok(result.clarify?.includes('reminder_time'));
});
test('classifies daily external send automation as L2', () => {
const result = classifyUserIntent('每天自动给客户发送报价单');
assert.equal(result.layer, 'L2');
assert.equal(result.kind, 'scheduled_task');
assert.ok(result.clarify?.includes('schedule'));
});
test('classifies daily monitoring automation as L2', () => {
const result = classifyUserIntent('帮我每天看看有没有新的招聘信息');
assert.equal(result.layer, 'L2');
assert.equal(result.kind, 'scheduled_task');
assert.match(result.detail?.taskSpec ?? '', /招聘/u);
});
test('classifies notify-vs-act ambiguity', () => {
const result = classifyUserIntent('明天提醒我自动生成日报');
assert.equal(result.layer, 'ambiguous');
assert.equal(result.kind, 'clarify');
});
test('classifies daily recurring reminder as L1 not L2', () => {
const result = classifyUserIntent('每天8点提醒我跑步');
assert.equal(result.layer, 'L1');
});
test('classifies daily report generation as L2', () => {
const result = classifyUserIntent('每天8点帮我生成跑步报告');
assert.equal(result.layer, 'L2');
assert.equal(result.kind, 'scheduled_task');
});