feat: 实现LLM趋势告警历史上下文判断功能

新增功能:
- 在LLM趋势分析中集成历史告警上下文,提供最近3次已触发告警的记录
- LLM自动判断本次分析是否与历史告警相似,避免重复通知
- 新增shouldNotify和notifyReason字段,支持智能通知决策

技术改进:
- 扩展TrendAnalysisResponse类型,增加通知决策字段
- 数据库服务新增getRecentTriggeredAnalyses()方法
- LLM客户端新增analyzeTrendWithHistory()和相关方法
- 趋势分析服务集成历史上下文获取和通知决策逻辑

测试验证:
- 创建test-db-history-method.ts验证数据库方法
- 创建test-llm-history-context.ts测试历史上下文功能
- 通过TypeScript类型检查和构建验证

这个功能可以有效减少重复告警,提升告警质量,避免通知疲劳。

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hughhuangandClaude Sonnet 4.5 committed 2026-01-15 19:37:28 +08:00
commit ccf523543a
52 files changed
+7763

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
{
"permissions": {
"allow": [
"mcp__plugin_playwright_playwright__browser_navigate",
"mcp__plugin_playwright_playwright__browser_close",
"Bash(npm install:*)",
"Bash(npm run typecheck)",
"Bash(npm run build:*)",
"Bash(npx playwright install:*)",
"Bash(npm run dev)",
"mcp__plugin_playwright_playwright__browser_evaluate",
"mcp__plugin_playwright_playwright__browser_run_code",
"Bash(npx tsx:*)",
"Bash(test:*)",
"Bash(tsx test:*)",
"mcp__plugin_serena_serena__list_dir",
"Bash(dir /B D:projectrongtongjin)",
"Bash(openspec list:*)",
"Bash(npx openspec:*)",
"Bash(openspec:*)",
"Bash(node dist/index.js:*)",
"Bash(timeout:*)",
"Bash(npx dotenv-cli -e .env -- npx tsx test-llm-trend.ts:*)",
"Bash(npx dotenv-cli:*)",
"mcp__plugin_serena_serena__read_file"
]
}
}