Add page data delivery and publication guards
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
buildChatSkillPrompt,
|
||||
CHAT_SKILL_DEFINITIONS,
|
||||
filterChatSkills,
|
||||
isPageDataIntent,
|
||||
isPageGenerationIntent,
|
||||
} from './chat-skills.mjs';
|
||||
|
||||
@@ -43,6 +44,14 @@ test('filterChatSkills shows service integration smoke when granted', () => {
|
||||
assert.ok(visible.some((item) => item.id === 'service-integration-smoke'));
|
||||
});
|
||||
|
||||
test('filterChatSkills shows page-data-collect when granted without static publish', () => {
|
||||
const visible = filterChatSkills(CHAT_SKILL_DEFINITIONS, {
|
||||
canPublish: false,
|
||||
grantedSkills: ['page-data-collect'],
|
||||
});
|
||||
assert.ok(visible.some((item) => item.id === 'page-data-collect'));
|
||||
});
|
||||
|
||||
test('filterChatSkills shows generate-page when publish is allowed', () => {
|
||||
const visible = filterChatSkills(CHAT_SKILL_DEFINITIONS, { canPublish: true });
|
||||
assert.ok(visible.some((item) => item.id === 'generate-page'));
|
||||
@@ -57,6 +66,8 @@ test('buildChatSkillPrompt includes skill name for platform skills', () => {
|
||||
assert.match(buildChatSkillPrompt('generate-page'), /public\/\*\.docx/);
|
||||
assert.match(buildChatSkillPrompt('generate-page'), /long-image-download/);
|
||||
assert.match(buildChatSkillPrompt('generate-page'), /generate_long_image/);
|
||||
assert.match(buildChatSkillPrompt('page-data-collect'), /Page Data API/);
|
||||
assert.match(buildChatSkillPrompt('page-data-collect'), /禁止自建 Express/);
|
||||
});
|
||||
|
||||
test('prefillOnly is set for open-ended chat skills', () => {
|
||||
@@ -87,6 +98,18 @@ test('isPageGenerationIntent matches implicit travel guide page requests', () =>
|
||||
assert.equal(isPageGenerationIntent('你好'), false);
|
||||
});
|
||||
|
||||
test('buildAutoChatSkillPrefix prefers page-data-collect for survey requests', () => {
|
||||
const text = '帮我在这个页面增加一个调查问卷,出三个问题,密码 888 查看提交记录';
|
||||
const prefix = buildAutoChatSkillPrefix(text, ['page-data-collect', 'static-page-publish']);
|
||||
assert.match(prefix, /page-data-collect/);
|
||||
assert.doesNotMatch(prefix, /static-page-publish 技能:在我的专属 MindSpace 发布目录生成静态 HTML/);
|
||||
});
|
||||
|
||||
test('isPageDataIntent matches survey and backend keywords', () => {
|
||||
assert.equal(isPageDataIntent('增加调查问卷和后台入口,密码 888'), true);
|
||||
assert.equal(isPageDataIntent('帮我做一个苏州攻略页面'), false);
|
||||
});
|
||||
|
||||
test('buildAutoChatSkillPrefix enables publish for implicit page requests', () => {
|
||||
const prefix = buildAutoChatSkillPrefix('苏州攻略页面', ['static-page-publish']);
|
||||
assert.match(prefix, /static-page-publish/);
|
||||
|
||||
Reference in New Issue
Block a user