fix: require write_file for WeChat immediate-context page requests
Memind CI / Test, build, and release guards (push) Failing after 12m9s

Skip fresh thumbnail forcing and retry in-session when load_skill completes without HTML落盘, so「把刚才的诗做成页面」can deliver the prior poem as a static page.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-28 15:27:23 +08:00
parent e1ad094f93
commit 491a62aed6
3 changed files with 204 additions and 132 deletions
+25 -1
View File
@@ -29,7 +29,8 @@ import {
WECHAT_CUSTOMER_TEXT_MAX_BYTES,
} from './wechat-mp.mjs';
import { createChatIntentRouter } from './chat-intent-router.mjs';
import { buildPageGenerateAgentPrompt } from './wechat/prompts/page-generate.mjs';
import { buildPageGenerateAgentPrompt, buildImmediateContextPageRepairPrompt } from './wechat/prompts/page-generate.mjs';
import { resolveWechatImageGenerationPolicy, WECHAT_PAGE_THUMBNAIL_MODE } from './wechat/image-generation-policy.mjs';
import {
ensureWechatFreshPageThumbnailsAtWorkspace,
prepareWechatHtmlDeliveryAtWorkspace,
@@ -355,7 +356,30 @@ test('WeChat immediate-context page guard does not match complete page requests'
});
assert.match(guardedPrompt, /即时上下文优先/);
assert.match(guardedPrompt, /禁止用长期记忆、历史偏好或旧任务替换主题/);
assert.match(guardedPrompt, /write_file 硬门槛/);
assert.match(guardedPrompt, /禁止只调用 load_skill、todo_write 或 generate_image 就回复/);
assert.doesNotMatch(ordinaryPrompt, /即时上下文优先/);
assert.doesNotMatch(ordinaryPrompt, /write_file 硬门槛/);
});
test('WeChat immediate-context page skips fresh thumbnail requirement', () => {
const policy = resolveWechatImageGenerationPolicy({
text: '把刚才的诗做成页面',
isPageGenerate: true,
requireFreshPageThumbnail: false,
});
assert.equal(policy.pageThumbnailMode, WECHAT_PAGE_THUMBNAIL_MODE.AUTO);
const prompt = buildPageGenerateAgentPrompt(
{ agentText: '把刚才的诗做成页面' },
{ preferImmediateContext: true, imagePolicy: policy },
);
assert.doesNotMatch(prompt, /服务号页面新缩略图硬要求/);
});
test('WeChat immediate-context page repair prompt requires write_file', () => {
const repairPrompt = buildImmediateContextPageRepairPrompt({ agentText: '把刚才的诗做成页面' });
assert.match(repairPrompt, /未 write_file 落盘 HTML/);
assert.match(repairPrompt, /禁止再次只 generate_image/);
});
test('WeChat immediate-context page retains an unlinked route with adjacent snapshot', async () => {