feat(llm): enhance DEEP_SYSTEM_PROMPT for multi-mode detection
🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
@@ -17,33 +17,75 @@ const DEEP_SYSTEM_PROMPT = `你是一个场景代码分析专家。分析场景
|
||||
|
||||
## 分析目标
|
||||
|
||||
1. **API 端点**: 识别所有 HTTP 请求地址 (URL, method, 用途)
|
||||
2. **静态参数**: 识别硬编码的业务参数 (key-value pairs)
|
||||
3. **列定义**: 识别数据表格/导出的列配置 ([field, label] pairs)
|
||||
4. **业务逻辑**: 理解数据获取和转换流程
|
||||
5. **场景类型**: 判断是 report_collection 还是 monitoring
|
||||
1. **多模式识别** (关键):
|
||||
- 查找条件分支逻辑 (if/switch) 中基于 period_mode、reportType 等字段的分支
|
||||
- 识别不同分支对应的 API 端点、列定义、请求格式
|
||||
- 如果发现多模式,使用 modes 数组格式输出
|
||||
|
||||
2. **API 端点**: 识别所有 HTTP 请求地址 (URL, method, contentType, 用途)
|
||||
- 从 \$.ajax/fetch 调用中提取 contentType
|
||||
- 检测请求格式: application/json 或 application/x-www-form-urlencoded
|
||||
|
||||
3. **请求模板**: 识别请求参数结构
|
||||
- 提取硬编码的分页参数 (rows, page, sidx, sord)
|
||||
- 识别模板变量如 \${args.org_code}
|
||||
|
||||
4. **数据归一化**: 识别数据处理规则
|
||||
- 查找数据渲染/表格填充逻辑
|
||||
- 检测数据验证条件 (哪些字段不能为空)
|
||||
|
||||
5. **响应路径**: 识别数据在响应中的位置
|
||||
- 如 response.content 或 response.data
|
||||
|
||||
## 输出格式
|
||||
|
||||
请以 JSON 格式返回:
|
||||
### 单模式场景 (无 modes 数组):
|
||||
{
|
||||
"sceneId": "string - 场景标识 (英文短横线)",
|
||||
"sceneName": "string - 场景中文名",
|
||||
"sceneId": "string",
|
||||
"sceneName": "string",
|
||||
"sceneKind": "report_collection | monitoring",
|
||||
"sourceSystem": "string - 来源系统名 (可选)",
|
||||
"expectedDomain": "string - 目标域名 (可选)",
|
||||
"targetUrl": "string | null - 目标页面URL",
|
||||
"apiEndpoints": [
|
||||
{"name": "string", "url": "string", "method": "GET|POST", "description": "string"}
|
||||
],
|
||||
"expectedDomain": "string",
|
||||
"targetUrl": "string",
|
||||
"apiEndpoints": [{"name": "", "url": "", "method": "POST"}],
|
||||
"staticParams": {"key": "value"},
|
||||
"columnDefs": [["fieldName", "中文列名"]],
|
||||
"entryMethod": "string - 入口方法名",
|
||||
"businessLogic": {
|
||||
"dataFetch": "string - 数据获取逻辑描述",
|
||||
"dataTransform": "string - 数据转换逻辑描述"
|
||||
"columnDefs": [["fieldName", "中文列名"]]
|
||||
}
|
||||
|
||||
### 多模式场景 (有 modes 数组):
|
||||
{
|
||||
"sceneId": "tq-lineloss-report",
|
||||
"sceneName": "台区线损报表",
|
||||
"sceneKind": "report_collection",
|
||||
"modes": [
|
||||
{
|
||||
"name": "month",
|
||||
"label": "月度报表",
|
||||
"condition": {"field": "period_mode", "operator": "equals", "value": "month"},
|
||||
"apiEndpoint": {
|
||||
"name": "月度线损查询",
|
||||
"url": "http://...",
|
||||
"method": "POST",
|
||||
"contentType": "application/x-www-form-urlencoded"
|
||||
},
|
||||
"columnDefs": [["ORG_NAME", "供电单位"], ...],
|
||||
"requestTemplate": {"orgno": "\${args.org_code}", "rows": 1000, "page": 1},
|
||||
"normalizeRules": {"type": "validate_all_columns", "filterNull": true},
|
||||
"responsePath": "content"
|
||||
},
|
||||
{
|
||||
"name": "week",
|
||||
"label": "周报表",
|
||||
"condition": {"field": "period_mode", "operator": "equals", "value": "week"},
|
||||
"apiEndpoint": {...},
|
||||
"columnDefs": [...],
|
||||
...
|
||||
}
|
||||
}`;
|
||||
],
|
||||
"defaultMode": "month",
|
||||
"modeSwitchField": "period_mode"
|
||||
}
|
||||
|
||||
**重要**: 如果发现代码中有基于 period_mode 的 if/switch 分支,必须使用多模式格式输出!`;
|
||||
|
||||
function buildAnalyzePrompt(sourceDir, dirContents) {
|
||||
const parts = [];
|
||||
|
||||
Reference in New Issue
Block a user