MCPcopy Create free account
hub / github.com/agenticsorg/edge-agents / areSimilar

Function areSimilar

scripts/sparc2/src/diff/diffTracker.ts:244–257  ·  view source on GitHub ↗

* Check if two strings are similar (used for detecting changed lines) * @param a First string * @param b Second string * @returns True if the strings are similar

(a: string, b: string)

Source from the content-addressed store, hash-verified

242 * @returns True if the strings are similar
243 */
244function areSimilar(a: string, b: string): boolean {
245 // Simple similarity check: more than 60% of characters are the same
246 const maxLength = Math.max(a.length, b.length);
247 if (maxLength === 0) return true;
248
249 let sameChars = 0;
250 const minLength = Math.min(a.length, b.length);
251
252 for (let i = 0; i < minLength; i++) {
253 if (a[i] === b[i]) sameChars++;
254 }
255
256 return sameChars / maxLength > 0.6;
257}
258
259/**
260 * Compute a diff between two files, focusing on function-level changes

Callers 1

computeFileDiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected