feat: complete Aider Page Data review workflow

This commit is contained in:
john
2026-07-25 09:47:25 +08:00
parent be9c25f1d0
commit 104fb4e370
15 changed files with 914 additions and 30 deletions
+30
View File
@@ -52,6 +52,8 @@ const PAGE_DATA_INTENT_PATTERNS = [
/(?:页面|网页|H5|h5).{0,80}(?:每天|每日|新增|添加|填写|记录).{0,80}(?:所有记录|历史记录|管理|汇总|统计)/u,
/(?:页面|网页|商城|店铺).{0,80}(?:下单|订单|购物车).{0,80}(?:后台|管理|上架|商品|产品|库存)/u,
/(?:后台|管理).{0,80}(?:上架|下架|商品|产品|库存).{0,80}(?:下单|订单|购物车|页面|网页|商城|店铺)/u,
/(?:下单|订单).{0,40}(?:后台|管理|记录|保存|查询|状态)/u,
/(?:后台|管理).{0,40}(?:下单|订单)/u,
];
const INTERACTIVE_PAGE_DATA_SUBJECT_PATTERN = /(?:便签|便利贴|备忘录|待办|清单)/u;
@@ -180,6 +182,7 @@ export const CHAT_SKILL_DEFINITIONS = [
icon: 'spark',
skillName: AIDER_DEVELOPMENT_SKILL_NAME,
requiresSkill: AIDER_DEVELOPMENT_SKILL_NAME,
prefillOnly: true,
promptKey: AIDER_DEVELOPMENT_SKILL_NAME,
},
{
@@ -298,6 +301,33 @@ export function buildChatSkillPrompt(promptKey, skillName) {
}
}
export function mergeChatSkillPromptWithInput(prompt, currentInput) {
const normalizedPrompt = String(prompt ?? '');
const existing = String(currentInput ?? '').trim();
if (!existing) return normalizedPrompt;
if (existing.startsWith(normalizedPrompt)) return existing;
return `${normalizedPrompt}${existing}`;
}
export function extractAiderDevelopmentTask(userMessage) {
const metadata = userMessage?.metadata;
const displayText = String(metadata?.displayText ?? '').trim();
const contentText = Array.isArray(userMessage?.content)
? userMessage.content
.filter((item) => item?.type === 'text')
.map((item) => String(item.text ?? '').trim())
.filter(Boolean)
.join('\n')
: String(userMessage?.content ?? userMessage?.text ?? userMessage?.value ?? '').trim();
const source = displayText || contentText;
const prompt = buildChatSkillPrompt(
AIDER_DEVELOPMENT_SKILL_NAME,
AIDER_DEVELOPMENT_SKILL_NAME,
);
if (!source.startsWith(prompt)) return source;
return source.slice(prompt.length).trim();
}
function buildWebNewsSkillPrompt(skillName) {
return `请使用 ${skillName ?? 'web'} 技能:先搜索今天/最新相关的新闻与热点,优先一手来源和权威媒体,整理 3-5 条最相关结果,按时间或热度排序;然后给出中文摘要、关键信息、事件背景和来源链接。我的问题是:`;
}