Files
memind/scripts/verify-chat-finish-sync.mjs
T
john 722b18326f feat(mindspace): 0630004 空间 UI、聊天连接、微信分享与 Agent 能力
含 MindSpace 三列布局与统计修复、聊天加载态与连接降级、平台页脚标记与 og:site_name 微信卡片、勾选资料删除 Agent 接口及内部话术过滤。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 18:08:06 +08:00

57 lines
2.3 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
const root = path.resolve(new URL('..', import.meta.url).pathname);
function read(relativePath) {
const absolutePath = path.join(root, relativePath);
assert.ok(fs.existsSync(absolutePath), `missing guarded file: ${relativePath}`);
return fs.readFileSync(absolutePath, 'utf8');
}
function assertIncludes(source, snippet, label) {
assert.ok(source.includes(snippet), `${label} must include guarded snippet: ${snippet}`);
}
function assertExcludes(source, snippet, label) {
assert.ok(!source.includes(snippet), `${label} must not regress to: ${snippet}`);
}
const useTKMindChat = read('src/hooks/useTKMindChat.ts');
assertIncludes(useTKMindChat, 'FINISH_SYNC_RETRY_DELAYS_MS', 'useTKMindChat.ts');
assertIncludes(
useTKMindChat,
'mergeConversationSnapshot(localMessages, detail.messages)',
'useTKMindChat.ts',
);
assertIncludes(useTKMindChat, 'chat-finish-sync.mjs', 'useTKMindChat.ts');
assertExcludes(
useTKMindChat,
'messagesRef.current = detail.messages;\n messageHistoryLoadedCountRef.current = detail.messages.length',
'useTKMindChat.ts Finish sync',
);
const messageTs = read('src/utils/message.ts');
assertIncludes(messageTs, 'deriveUserFacingText', 'message.ts');
assertIncludes(messageTs, 'deriveAssistantFacingText', 'message.ts');
assertIncludes(messageTs, 'chat-finish-sync.mjs', 'message.ts');
const conversationDisplay = read('conversation-display.mjs');
assertIncludes(conversationDisplay, 'TASK_ROUTING_HINT_RE', 'conversation-display.mjs');
assertIncludes(conversationDisplay, 'deriveUserFacingText', 'conversation-display.mjs');
assertIncludes(conversationDisplay, 'deriveAssistantFacingText', 'conversation-display.mjs');
const chatSkills = read('chat-skills.mjs');
assertIncludes(chatSkills, 'stripKnownChatSkillPrompt', 'chat-skills.mjs');
const server = read('server.mjs');
assertIncludes(server, 'canUseSnapshotCache', 'server.mjs');
assertIncludes(server, 'hintMc != null && hintUa != null', 'server.mjs');
const publicFinishSync = read('mindspace-public-finish-sync.mjs');
assertIncludes(publicFinishSync, 'applyPublicHtmlEdit', 'mindspace-public-finish-sync.mjs');
assertIncludes(publicFinishSync, 'isEditLikeHtmlTool', 'mindspace-public-finish-sync.mjs');
console.log('chat finish sync source guards ok');