(in *SkillScanInput, reason string)
| 1184 | } |
| 1185 | |
| 1186 | func fallbackSkillScanOutput(in *SkillScanInput, reason string) *SkillScanOutput { |
| 1187 | riskLevel := model.SkillRiskLevelMedium |
| 1188 | message := "扫描模型未返回有效结果,已启用基础兜底" |
| 1189 | |
| 1190 | contentToCheck := strings.ToLower(strings.TrimSpace(in.SkillMD) + "\n" + strings.Join(in.FileEntries, "\n")) |
| 1191 | if looksLikeHighRiskSkill(contentToCheck) { |
| 1192 | riskLevel = model.SkillRiskLevelHigh |
| 1193 | message = "基础兜底检测到明显高风险内容,禁止使用" |
| 1194 | } |
| 1195 | |
| 1196 | payload, _ := json.Marshal(map[string]interface{}{ |
| 1197 | "scan_model": in.ScanModel, |
| 1198 | "entry_count": len(in.FileEntries), |
| 1199 | "skill_md_size": len(in.SkillMD), |
| 1200 | "risk_level": riskLevel, |
| 1201 | "fallback_reason": reason, |
| 1202 | }) |
| 1203 | |
| 1204 | output := &SkillScanOutput{ |
| 1205 | RiskLevel: riskLevel, |
| 1206 | ScoreIntegrity: fallbackSkillScore(riskLevel), |
| 1207 | ScorePracticality: fallbackSkillScore(riskLevel), |
| 1208 | ScoreSafety: fallbackSkillScore(riskLevel), |
| 1209 | ScoreCodeQuality: fallbackSkillScore(riskLevel), |
| 1210 | ScoreDocQuality: fallbackSkillScore(riskLevel), |
| 1211 | Message: message, |
| 1212 | ScanPayload: string(payload), |
| 1213 | Retryable: false, |
| 1214 | } |
| 1215 | |
| 1216 | return output |
| 1217 | } |
| 1218 | |
| 1219 | func truncateForDebug(text string, maxLen int) string { |
| 1220 | text = strings.TrimSpace(text) |
no test coverage detected