MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / termDiff

Function termDiff

src/context/approach-diff.ts:32–39  ·  view source on GitHub ↗
(refText: string, otherText: string, cap = 8)

Source from the content-addressed store, hash-verified

30
31/** Vocabulary diff of `other` against `ref`, compared by stem, displayed as surface words. PURE. */
32export function termDiff(refText: string, otherText: string, cap = 8): TermDiff {
33 const ref = surfaceByStem(refText);
34 const other = surfaceByStem(otherText);
35 const shared: string[] = [], added: string[] = [], missing: string[] = [];
36 for (const [s, w] of other) (ref.has(s) ? shared : added).push(w);
37 for (const [s, w] of ref) if (!other.has(s)) missing.push(w);
38 return { shared: shared.slice(0, cap), added: added.slice(0, cap), missing: missing.slice(0, cap) };
39}
40
41/** Classic LCS line diff → unified-style lines (' ctx' / '- old' / '+ new'). PURE. */
42export function lineDiff(a: string, b: string): string[] {

Callers 2

renderApproachDiffsFunction · 0.85

Calls 3

surfaceByStemFunction · 0.85
pushMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected