MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / executeBackground

Method executeBackground

tools/builtin.go:1497–1529  ·  view source on GitHub ↗
(command, description, cwd string, timeout time.Duration)

Source from the content-addressed store, hash-verified

1495 bestScore = score
1496 bestIdx = i
1497 }
1498 }
1499 if bestScore < 0.3 {
1500 return fmt.Sprintf(" No similar lines found. Searched for: '%s'", truncateForMsg(oldFirst, 100))
1501 }
1502 start := max(0, bestIdx-2)
1503 end := min(len(lines), bestIdx+2)
1504 out := []string{fmt.Sprintf(" Closest match at line %d (%.0f%% similarity):", bestIdx+1, bestScore*100)}
1505 for i := start; i < end; i++ {
1506 marker := " "
1507 if i == bestIdx {
1508 marker = ">>>"
1509 }
1510 out = append(out, fmt.Sprintf(" %s L%4d %s", marker, i+1, truncateForMsg(lines[i], 120)))
1511 }
1512 return strings.Join(out, "\n")
1513}
1514
1515func lineSimilarity(a, b string) float64 {
1516 if a == b {
1517 return 1
1518 }
1519 aTokens := strings.Fields(a)
1520 if len(aTokens) == 0 {
1521 return 0
1522 }
1523 bSet := map[string]struct{}{}
1524 for _, tok := range strings.Fields(b) {
1525 bSet[tok] = struct{}{}
1526 }
1527 intersect := 0
1528 for _, tok := range aTokens {
1529 if _, ok := bSet[tok]; ok {
1530 intersect++
1531 }
1532 }

Callers 1

ExecuteMethod · 0.95

Calls 4

firstCharsFunction · 0.85
ActiveCountMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected