00a00a1f69
- Free stale Memind listeners on 8081 before startup and exit cleanly on EADDRINUSE - Backfill owned sessions missing from Goose via h5_conversation_messages summaries - Strip Memind task orchestration prefixes from user-facing chat text - Repair missing public docx links before release MindSpace link checks Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
2.6 KiB
JavaScript
49 lines
2.6 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { buildAutoChatSkillPrefix, stripKnownChatSkillPrompt } from './chat-skills.mjs';
|
|
import { deriveUserFacingText, deriveAssistantFacingText } from './conversation-display.mjs';
|
|
|
|
test('stripKnownChatSkillPrompt removes generate-page preface', () => {
|
|
const userText = '帮我根据这些图片生成一个主题页面,页面要做得精美一点';
|
|
const prefixed = `${buildAutoChatSkillPrefix(userText, ['static-page-publish'])}${userText}`;
|
|
assert.match(prefixed, /static-page-publish/);
|
|
assert.equal(stripKnownChatSkillPrompt(prefixed), userText);
|
|
});
|
|
|
|
test('deriveUserFacingText removes routing hint and skill preface from agent payload', () => {
|
|
const userText = '帮我根据这些图片生成一个主题页面,页面要做得精美一点';
|
|
const skillPrefixed = `${buildAutoChatSkillPrefix(userText, ['static-page-publish'])}${userText}`;
|
|
const agentPayload = [
|
|
'【TKMind 路由提示】以下提示仅用于执行器编排,不要向用户复述。',
|
|
'当前代码任务建议优先委托给:aider。',
|
|
'原因:任务看起来更像局部补丁、小范围修复或较轻量的代码修改。',
|
|
'若首选执行器当前不可用或明显不适合,可回退到另一个已授权执行器,并在最终回复里简述原因。',
|
|
'',
|
|
skillPrefixed,
|
|
].join('\n');
|
|
assert.equal(deriveUserFacingText(agentPayload), userText);
|
|
});
|
|
|
|
test('deriveUserFacingText removes Memind task orchestration prefix', () => {
|
|
const userText = '帮我生成深度搜索报告';
|
|
const agentPayload = [
|
|
'【Memind 任务编排】以下为用户任务,请使用工具与技能实际执行并产出结果,不要只做文字描述。',
|
|
'路由判定:用户要求深度搜索并形成报告。',
|
|
`用户任务:${userText}`,
|
|
].join('\n');
|
|
assert.equal(deriveUserFacingText(agentPayload), userText);
|
|
});
|
|
|
|
test('deriveAssistantFacingText hides skill/process narration without a deliverable link', () => {
|
|
const internal =
|
|
'好的,John!注意到技能更新了几个细节要求,比如页脚要用`data-mindspace-page-tag="platform-brand"`和`tkmind.cn`。我来为你重新生成全面增强版的AI机器人研究报告页面:';
|
|
assert.equal(deriveAssistantFacingText(internal), '');
|
|
});
|
|
|
|
test('deriveAssistantFacingText keeps user-facing replies with public links', () => {
|
|
const external =
|
|
'页面已生成:[AI 机器人研究报告 2026](https://m.tkmind.cn/MindSpace/john/public/ai-robot-report.html)';
|
|
assert.equal(deriveAssistantFacingText(external), external);
|
|
});
|