fix: recover WeChat page thumbnail delivery
Memind CI / Test, build, and release guards (pull_request) Successful in 5m1s

This commit is contained in:
john
2026-07-22 11:51:15 +08:00
parent 57d2c14fca
commit cb62b36cd5
13 changed files with 366 additions and 26 deletions
+26 -1
View File
@@ -7,6 +7,10 @@ import {
WECHAT_PAGE_THUMBNAIL_MODE,
} from './image-generation-policy.mjs';
import { classifyWechatIntent } from './intent/classifier.mjs';
import {
buildPageGenerateAgentPrompt,
buildPagePublishFailureText,
} from './prompts/page-generate.mjs';
test('service-account page always requires a fresh thumbnail without forcing body images', () => {
const policy = resolveWechatImageGenerationPolicy({
@@ -18,7 +22,11 @@ test('service-account page always requires a fresh thumbnail without forcing bod
assert.equal(policy.imageGenerationMode, 'required');
assert.equal(policy.inlineImageMode, 'auto');
assert.equal(policy.standaloneImageMode, 'auto');
assert.match(buildWechatPageImageInstruction(policy), /每个本轮交付给用户的正式内容页面/);
const instruction = buildWechatPageImageInstruction(policy);
assert.match(instruction, /每个本轮交付给用户的正式内容页面/);
assert.match(instruction, /Agent 层只调用一次 generate_image/);
assert.match(instruction, /工具内部会完成语义重试/);
assert.match(instruction, /禁止自行更换提示词并重复调用/);
});
test('no-image page request disables body images but keeps required fresh thumbnail', () => {
@@ -62,3 +70,20 @@ test('explicitly declining a page keeps standalone image generation out of page
assert.equal(policy.pageThumbnailMode, 'auto');
assert.equal(policy.standaloneImageMode, 'required');
});
test('page generation prompt forbids unsupported commercial and security claims', () => {
const prompt = buildPageGenerateAgentPrompt({
agentText: '生成 TKMind 舌战群儒页面',
msgId: 'message-1',
});
assert.match(prompt, /禁止编造用户未提供的产品指标、客户数量、SLA、认证、案例、排名或承诺/);
assert.match(prompt, /不得杜撰数字/);
});
test('missing-thumbnail copy preserves the page and does not ask for the full requirement again', () => {
const text = buildPagePublishFailureText({ missingFreshThumbnail: true });
assert.match(text, /页面内容已经保留/);
assert.match(text, /重试上次页面/);
assert.match(text, /无需重新描述完整需求/);
assert.doesNotMatch(text, /重发一次完整页面需求/);
});