fix: require docx generation for downloadable pages
This commit is contained in:
+21
-1
@@ -346,6 +346,12 @@ function looksLikeHtmlGenerationIntent(text) {
|
||||
return /(?:生成|创建|做|写|帮我.*(?:生成|创建|做|写)).*(?:html|页面|网页|page|文件)/i.test(normalized);
|
||||
}
|
||||
|
||||
function looksLikeDocxDownloadIntent(text) {
|
||||
const normalized = String(text ?? '').trim();
|
||||
if (!normalized) return false;
|
||||
return /(?:(?:word|docx|\.docx|\.doc|文档).*(?:下载|链接|导出|给我)|(?:下载|导出|提供|给我).*(?:word|docx|\.docx|\.doc|文档))/iu.test(normalized);
|
||||
}
|
||||
|
||||
function usedStaticPagePublishSkill(messages = []) {
|
||||
return messages.some((message) =>
|
||||
message?.content?.some((item) => {
|
||||
@@ -1067,8 +1073,19 @@ function normalizeWechatInboundIntent(inbound) {
|
||||
return base;
|
||||
}
|
||||
|
||||
function buildWechatAgentPrompt(intent) {
|
||||
export function buildWechatAgentPrompt(intent) {
|
||||
const msgType = String(intent?.msgType ?? 'text');
|
||||
const docxDownloadHint =
|
||||
looksLikeHtmlGenerationIntent(intent?.agentText ?? intent?.content) &&
|
||||
looksLikeDocxDownloadIntent(intent?.agentText ?? intent?.content)
|
||||
? [
|
||||
'【Word 下载要求】用户明确要求页面里可下载 Word / docx。',
|
||||
'开始前必须先调用 `load_skill` → `docx-generate`,并按技能说明生成目标 `public/*.docx`。',
|
||||
'生成后必须确认目标 `.docx` 已存在,再调用 `load_skill` → `static-page-publish` 写 `public/*.html`。',
|
||||
'HTML 中只能用同目录相对路径链接该文档;禁止只写下载按钮却没有先把 `.docx` 落盘。',
|
||||
'',
|
||||
].join('\n')
|
||||
: '';
|
||||
const pagePublishHint = looksLikeHtmlGenerationIntent(intent?.agentText ?? intent?.content)
|
||||
? [
|
||||
'【页面发布技能要求】这条消息是在生成可访问 HTML 页面。',
|
||||
@@ -1094,6 +1111,7 @@ function buildWechatAgentPrompt(intent) {
|
||||
: '';
|
||||
if (msgType === 'voice') {
|
||||
return [
|
||||
docxDownloadHint,
|
||||
scheduleAssistantHint,
|
||||
'【微信服务号语音消息】用户通过语音输入,以下是微信识别结果。',
|
||||
'',
|
||||
@@ -1104,6 +1122,7 @@ function buildWechatAgentPrompt(intent) {
|
||||
}
|
||||
if (msgType === 'image') {
|
||||
return [
|
||||
docxDownloadHint,
|
||||
scheduleAssistantHint,
|
||||
'【微信服务号图片消息】用户发送了图片。',
|
||||
'如用户没有明确要求,请先根据图片内容给出简短理解,并询问下一步。',
|
||||
@@ -1144,6 +1163,7 @@ function buildWechatAgentPrompt(intent) {
|
||||
}
|
||||
const content = String(intent?.agentText ?? intent?.content ?? '').trim();
|
||||
const lines = [];
|
||||
if (docxDownloadHint) lines.push(docxDownloadHint);
|
||||
if (pagePublishHint) lines.push(pagePublishHint);
|
||||
if (scheduleAssistantHint) lines.push(scheduleAssistantHint);
|
||||
lines.push(
|
||||
|
||||
Reference in New Issue
Block a user