722b18326f
含 MindSpace 三列布局与统计修复、聊天加载态与连接降级、平台页脚标记与 og:site_name 微信卡片、勾选资料删除 Agent 接口及内部话术过滤。 Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
2.2 KiB
JavaScript
67 lines
2.2 KiB
JavaScript
import { stripKnownChatSkillPrompt } from './chat-skills.mjs';
|
|
|
|
/**
|
|
* Strip agent-only prefixes from persisted user messages for UI display.
|
|
* Regression guard — see docs/regression-guards/mindspace-publish-and-chat-finish.md
|
|
*/
|
|
|
|
export const TASK_ROUTING_HINT_RE = /^【TKMind 路由提示】[\s\S]*?\n\n/;
|
|
export const MINDSPACE_CONTEXT_RE = /^\[MindSpace 上下文\][\s\S]*?\n\n/;
|
|
const USER_IDENTITY_BLOCK_RE = /^\[用户身份\][\s\S]*?\n\n/;
|
|
|
|
export function stripUserIdentityPrefix(text) {
|
|
return String(text ?? '').replace(USER_IDENTITY_BLOCK_RE, '').trimStart();
|
|
}
|
|
|
|
export function stripTaskRoutingHint(text) {
|
|
return String(text ?? '').replace(TASK_ROUTING_HINT_RE, '').trimStart();
|
|
}
|
|
|
|
export function stripMindSpaceContextPrefix(text) {
|
|
let next = String(text ?? '');
|
|
while (MINDSPACE_CONTEXT_RE.test(next)) {
|
|
next = next.replace(MINDSPACE_CONTEXT_RE, '').trimStart();
|
|
}
|
|
return next;
|
|
}
|
|
|
|
const ASSISTANT_DELIVERABLE_RE =
|
|
/\[[^\]]+\]\(https?:\/\/[^)]+\)|https?:\/\/(?:m\.)?[^/\s]*tkmind\.(?:cn|ai)\/MindSpace\//i;
|
|
|
|
const INTERNAL_ASSISTANT_MARKERS = [
|
|
/data-mindspace-page-tag/i,
|
|
/mindspace-cover/i,
|
|
/\bload_skill\b/i,
|
|
/static-page-publish/i,
|
|
/\.agents\/skills/i,
|
|
/SKILL\.md/i,
|
|
/注意到技能/u,
|
|
/技能更新/u,
|
|
/页脚要用.*platform-brand/u,
|
|
];
|
|
|
|
/** Agent-only process narration that should not appear in the chat UI. */
|
|
export function isInternalAssistantProcessNarration(text) {
|
|
const trimmed = String(text ?? '').trim();
|
|
if (!trimmed) return false;
|
|
if (ASSISTANT_DELIVERABLE_RE.test(trimmed)) return false;
|
|
return INTERNAL_ASSISTANT_MARKERS.some((pattern) => pattern.test(trimmed));
|
|
}
|
|
|
|
export function deriveAssistantFacingText(text) {
|
|
const trimmed = String(text ?? '').trim();
|
|
if (!trimmed) return '';
|
|
if (isInternalAssistantProcessNarration(trimmed)) return '';
|
|
return trimmed;
|
|
}
|
|
|
|
/** Strip agent-only prefixes from persisted user message content for UI display. */
|
|
export function deriveUserFacingText(text) {
|
|
let next = String(text ?? '');
|
|
next = stripUserIdentityPrefix(next);
|
|
next = stripTaskRoutingHint(next);
|
|
next = stripMindSpaceContextPrefix(next);
|
|
next = stripKnownChatSkillPrompt(next);
|
|
return next.trim();
|
|
}
|