MCPcopy Create free account
hub / github.com/astercloud/aster / FormatCheckResult

Method FormatCheckResult

pkg/tools/builtin/git_safety.go:299–335  ·  view source on GitHub ↗

FormatCheckResult 格式化检查结果为用户可读的消息

()

Source from the content-addressed store, hash-verified

297
298// FormatCheckResult 格式化检查结果为用户可读的消息
299func (c *GitSafetyCheck) FormatCheckResult() string {
300 if !c.IsGitCommand {
301 return ""
302 }
303
304 if c.Blocked {
305 return fmt.Sprintf("🚫 BLOCKED: This git command is not allowed.\nReason: %s\nCommand: %s", c.Reason, c.Command)
306 }
307
308 if c.RequiresApproval {
309 msg := fmt.Sprintf("⚠️ GIT SAFETY WARNING [%s risk]\n", strings.ToUpper(c.RiskName))
310 msg += fmt.Sprintf("Command: %s\n", c.Command)
311
312 if len(c.Warnings) > 0 {
313 msg += "\nWarnings:\n"
314 var msgSb314 strings.Builder
315 for _, w := range c.Warnings {
316 msgSb314.WriteString(fmt.Sprintf(" • %s\n", w))
317 }
318 msg += msgSb314.String()
319 }
320
321 if len(c.Recommendations) > 0 {
322 msg += "\nRecommendations:\n"
323 var msgSb321 strings.Builder
324 for _, r := range c.Recommendations {
325 msgSb321.WriteString(fmt.Sprintf(" • %s\n", r))
326 }
327 msg += msgSb321.String()
328 }
329
330 msg += "\nThis command requires user approval before execution."
331 return msg
332 }
333
334 return ""
335}
336
337// 全局 Git 安全验证器
338var globalGitSafetyValidator *GitSafetyValidator

Callers 2

ExecuteMethod · 0.80

Calls 1

StringMethod · 0.45

Tested by 1