Files
memind/chat-skills.mjs
T
John 6ee6fd64dd Add MindSpace page live edit, chat skills, and H5 deploy tooling.
Introduce page edit sessions with draft preview and patch API, chat skill picker, user memory profile, h5ApiBase resolution, voice WAV transport, and scripts for 105/g2 deployment and Plaza local dev.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 22:09:38 -07:00

93 lines
2.9 KiB
JavaScript

// Keep browser-safe: do not import user-publish.mjs (uses node:fs/path/url).
const PUBLISH_SKILL_NAME = 'static-page-publish';
export const CHAT_SKILL_DEFINITIONS = [
{
id: 'web-search',
label: '查资料',
icon: 'web',
skillName: 'web',
requiresSkill: 'web',
prefillOnly: true,
promptKey: 'web',
},
{
id: 'code-search',
label: '搜代码',
icon: 'search',
skillName: 'search',
requiresSkill: 'search',
prefillOnly: true,
promptKey: 'search',
},
{
id: 'form-collect',
label: '表单收集',
icon: 'form',
skillName: 'form-builder',
requiresSkill: 'form-builder',
prefillOnly: true,
promptKey: 'form-builder',
},
{
id: 'table-view',
label: '数据表格',
icon: 'table',
skillName: 'table-viewer',
requiresSkill: 'table-viewer',
prefillOnly: true,
promptKey: 'table-viewer',
},
{
id: 'summarize',
label: '总结内容',
icon: 'summary',
prefillOnly: true,
promptKey: 'summarize',
},
{
id: 'analyze',
label: '深度分析',
icon: 'analyze',
prefillOnly: true,
promptKey: 'analyze',
},
{
id: 'generate-page',
label: '生成页面',
icon: 'page',
skillName: PUBLISH_SKILL_NAME,
requiresPublish: true,
promptKey: 'generate-page',
},
];
export function buildChatSkillPrompt(promptKey, skillName) {
switch (promptKey) {
case 'web':
return `请使用 ${skillName ?? 'web'} 技能:帮我搜索并查阅相关资料(优先官方文档),并给出中文摘要与来源链接。我的问题是:`;
case 'search':
return `请使用 ${skillName ?? 'search'} 技能:帮我在工作区中查找代码或文件。我要找的是:`;
case 'form-builder':
return `请使用 ${skillName ?? 'form-builder'} 技能:请用交互式表单收集以下场景所需的结构化字段(字段不超过 8 个):`;
case 'table-viewer':
return `请使用 ${skillName ?? 'table-viewer'} 技能:请把以下数据整理成可排序、可筛选的交互式表格:`;
case 'summarize':
return '请总结以下内容,提炼核心结论、重点信息和可执行建议(条理清晰、中文输出):';
case 'analyze':
return '请深入分析以下内容,给出结构化解读:背景、关键发现、风险或机会、以及建议下一步:';
case 'generate-page':
return `请使用 ${skillName ?? PUBLISH_SKILL_NAME} 技能:在我的专属 MindSpace 发布目录生成静态 HTML 页面,并给出可公网访问的完整链接。`;
default:
return '';
}
}
export function filterChatSkills(options, ctx) {
return options.filter((skill) => {
if (skill.requiresPublish && !ctx.canPublish) return false;
if (skill.requiresSkill && !ctx.grantedSkills?.includes(skill.requiresSkill)) return false;
return true;
});
}