@refract-org/analyzers 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/src/category-tracker.d.ts +8 -0
- package/dist/src/category-tracker.d.ts.map +1 -0
- package/dist/src/category-tracker.js +60 -0
- package/dist/src/category-tracker.js.map +1 -0
- package/dist/src/citation-tracker.d.ts +13 -0
- package/dist/src/citation-tracker.d.ts.map +1 -0
- package/dist/src/citation-tracker.js +200 -0
- package/dist/src/citation-tracker.js.map +1 -0
- package/dist/src/claim-differ.d.ts +2 -0
- package/dist/src/claim-differ.d.ts.map +1 -0
- package/dist/src/claim-differ.js +6 -0
- package/dist/src/claim-differ.js.map +1 -0
- package/dist/src/edit-cluster-detector.d.ts +14 -0
- package/dist/src/edit-cluster-detector.d.ts.map +1 -0
- package/dist/src/edit-cluster-detector.js +57 -0
- package/dist/src/edit-cluster-detector.js.map +1 -0
- package/dist/src/heuristic-classifier.d.ts +9 -0
- package/dist/src/heuristic-classifier.d.ts.map +1 -0
- package/dist/src/heuristic-classifier.js +33 -0
- package/dist/src/heuristic-classifier.js.map +1 -0
- package/dist/src/index.d.ts +70 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +16 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/observation-differ.d.ts +8 -0
- package/dist/src/observation-differ.d.ts.map +1 -0
- package/dist/src/observation-differ.js +16 -0
- package/dist/src/observation-differ.js.map +1 -0
- package/dist/src/page-move-detector.d.ts +11 -0
- package/dist/src/page-move-detector.d.ts.map +1 -0
- package/dist/src/page-move-detector.js +21 -0
- package/dist/src/page-move-detector.js.map +1 -0
- package/dist/src/protection-tracker.d.ts +23 -0
- package/dist/src/protection-tracker.d.ts.map +1 -0
- package/dist/src/protection-tracker.js +74 -0
- package/dist/src/protection-tracker.js.map +1 -0
- package/dist/src/revert-detector.d.ts +3 -0
- package/dist/src/revert-detector.d.ts.map +1 -0
- package/dist/src/revert-detector.js +43 -0
- package/dist/src/revert-detector.js.map +1 -0
- package/dist/src/section-differ.d.ts +26 -0
- package/dist/src/section-differ.d.ts.map +1 -0
- package/dist/src/section-differ.js +268 -0
- package/dist/src/section-differ.js.map +1 -0
- package/dist/src/talk-activity-detector.d.ts +16 -0
- package/dist/src/talk-activity-detector.d.ts.map +1 -0
- package/dist/src/talk-activity-detector.js +76 -0
- package/dist/src/talk-activity-detector.js.map +1 -0
- package/dist/src/talk-correlator.d.ts +7 -0
- package/dist/src/talk-correlator.d.ts.map +1 -0
- package/dist/src/talk-correlator.js +53 -0
- package/dist/src/talk-correlator.js.map +1 -0
- package/dist/src/talk-section-parser.d.ts +22 -0
- package/dist/src/talk-section-parser.d.ts.map +1 -0
- package/dist/src/talk-section-parser.js +109 -0
- package/dist/src/talk-section-parser.js.map +1 -0
- package/dist/src/template-tracker.d.ts +12 -0
- package/dist/src/template-tracker.d.ts.map +1 -0
- package/dist/src/template-tracker.js +225 -0
- package/dist/src/template-tracker.js.map +1 -0
- package/dist/src/wikilink-extractor.d.ts +8 -0
- package/dist/src/wikilink-extractor.d.ts.map +1 -0
- package/dist/src/wikilink-extractor.js +81 -0
- package/dist/src/wikilink-extractor.js.map +1 -0
- package/dist/src/wikitext-parser.d.ts +15 -0
- package/dist/src/wikitext-parser.d.ts.map +1 -0
- package/dist/src/wikitext-parser.js +85 -0
- package/dist/src/wikitext-parser.js.map +1 -0
- package/dist/tsconfig 2.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +28 -0
- package/src/__tests__/category-tracker.test.ts +79 -0
- package/src/__tests__/citation-tracker.test.ts +185 -0
- package/src/__tests__/edit-cluster-detector.test.ts +79 -0
- package/src/__tests__/heuristic-classifier.test.ts +67 -0
- package/src/__tests__/observation-differ.test.ts +58 -0
- package/src/__tests__/page-move-detector.test.ts +64 -0
- package/src/__tests__/protection-tracker.test.ts +72 -0
- package/src/__tests__/revert-detector.test.ts +76 -0
- package/src/__tests__/section-differ.test.ts +120 -0
- package/src/__tests__/talk-activity-detector.test.ts +112 -0
- package/src/__tests__/talk-correlator.test.ts +71 -0
- package/src/__tests__/talk-section-parser.test.ts +105 -0
- package/src/__tests__/template-tracker.test.ts +159 -0
- package/src/__tests__/wikilink-extractor.test.ts +101 -0
- package/src/__tests__/wikitext-parser.test.ts +142 -0
- package/src/category-tracker.ts +75 -0
- package/src/citation-tracker.ts +226 -0
- package/src/claim-differ.ts +4 -0
- package/src/edit-cluster-detector.ts +78 -0
- package/src/heuristic-classifier.ts +59 -0
- package/src/index.ts +88 -0
- package/src/observation-differ.ts +26 -0
- package/src/page-move-detector.ts +32 -0
- package/src/protection-tracker.ts +103 -0
- package/src/revert-detector.ts +51 -0
- package/src/section-differ.ts +315 -0
- package/src/talk-activity-detector.ts +105 -0
- package/src/talk-correlator.ts +70 -0
- package/src/talk-section-parser.ts +151 -0
- package/src/template-tracker.ts +253 -0
- package/src/wikilink-extractor.ts +100 -0
- package/src/wikitext-parser.ts +92 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @refract-org/analyzers
|
|
2
|
+
|
|
3
|
+
Deterministic analyzers. Byte-for-byte reproducible, no model involved.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
bun add @refract-org/analyzers
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Exports
|
|
10
|
+
|
|
11
|
+
### Analyzers
|
|
12
|
+
|
|
13
|
+
- `sectionDiffer` — section extraction and diffing between revisions
|
|
14
|
+
- `citationTracker` — citation extraction, diffing, and source lineage
|
|
15
|
+
- `revertDetector` — revert comment matching and revert chain detection
|
|
16
|
+
- `templateTracker` — template extraction and diffing (citation, neutrality, BLP, etc.)
|
|
17
|
+
- `classifyHeuristic` — heuristic edit classification (revert, vandalism, sourcing, cosmetic, minor)
|
|
18
|
+
|
|
19
|
+
### Utilities
|
|
20
|
+
|
|
21
|
+
- `sanitizeWikitext`, `extractHeadingMap`, `deriveSectionHeading`, `countCitations`, `countKeywordMentions`, `extractAnchorSnippet` — wikitext parsing helpers
|
|
22
|
+
|
|
23
|
+
### Builders
|
|
24
|
+
|
|
25
|
+
- `buildSectionLineage` — full section ancestry chain across revisions
|
|
26
|
+
- `buildSourceLineage`, `buildSourceId` — citation ancestry
|
|
27
|
+
|
|
28
|
+
### Types
|
|
29
|
+
|
|
30
|
+
- `SectionDiffer`, `CitationTracker`, `RevertDetector`, `TemplateTracker` — analyzer interfaces
|
|
31
|
+
- `CitationRef`, `CitationChange`, `RevertChain`, `Template`, `TemplateChange`, `TemplateType` — domain types
|
|
32
|
+
- `HeuristicKind`, `SectionEvent`, `SectionLineage`, `HeadingPosition` — supporting types
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { sectionDiffer, citationTracker, revertDetector } from "@refract-org/analyzers";
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
[Refract](https://github.com/refract-org/sequent) · [Docs](https://github.com/refract-org/sequent-docs) · [npm](https://www.npmjs.com/package/@refract-org/analyzers)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DeterministicFact, EvidenceEvent } from "@refract-org/evidence-graph";
|
|
2
|
+
export declare function extractCategories(wikitext: string): string[];
|
|
3
|
+
export declare function diffCategories(before: string[], after: string[]): {
|
|
4
|
+
added: string[];
|
|
5
|
+
removed: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function buildCategoryEvents(beforeWikitext: string, afterWikitext: string, fromRevId: number, toRevId: number, timestamp: string, extraFacts?: DeterministicFact[]): EvidenceEvent[];
|
|
8
|
+
//# sourceMappingURL=category-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-tracker.d.ts","sourceRoot":"","sources":["../../src/category-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAIpF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB5D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAQxG;AAED,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,iBAAiB,EAAE,GAC/B,aAAa,EAAE,CAmCjB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const CATEGORY_REGEX = /\[\[Category:([^\]|]+)(?:\|[^\]]*)?\]\]/gi;
|
|
2
|
+
export function extractCategories(wikitext) {
|
|
3
|
+
const categories = [];
|
|
4
|
+
const seen = new Set();
|
|
5
|
+
let match;
|
|
6
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: Standard regex loop pattern
|
|
7
|
+
while ((match = CATEGORY_REGEX.exec(wikitext)) !== null) {
|
|
8
|
+
const name = match[1].trim();
|
|
9
|
+
if (!name)
|
|
10
|
+
continue;
|
|
11
|
+
const normalized = name.toLowerCase().replace(/_/g, " ");
|
|
12
|
+
if (seen.has(normalized))
|
|
13
|
+
continue;
|
|
14
|
+
seen.add(normalized);
|
|
15
|
+
categories.push(normalized);
|
|
16
|
+
}
|
|
17
|
+
return categories;
|
|
18
|
+
}
|
|
19
|
+
export function diffCategories(before, after) {
|
|
20
|
+
const beforeSet = new Set(before);
|
|
21
|
+
const afterSet = new Set(after);
|
|
22
|
+
return {
|
|
23
|
+
added: after.filter((c) => !beforeSet.has(c)),
|
|
24
|
+
removed: before.filter((c) => !afterSet.has(c)),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function buildCategoryEvents(beforeWikitext, afterWikitext, fromRevId, toRevId, timestamp, extraFacts) {
|
|
28
|
+
const events = [];
|
|
29
|
+
const before = extractCategories(beforeWikitext);
|
|
30
|
+
const after = extractCategories(afterWikitext);
|
|
31
|
+
const { added, removed } = diffCategories(before, after);
|
|
32
|
+
for (const cat of added) {
|
|
33
|
+
events.push({
|
|
34
|
+
eventType: "category_added",
|
|
35
|
+
fromRevisionId: fromRevId,
|
|
36
|
+
toRevisionId: toRevId,
|
|
37
|
+
section: "",
|
|
38
|
+
before: "",
|
|
39
|
+
after: cat,
|
|
40
|
+
deterministicFacts: [{ fact: "category_added", detail: `category=${cat}` }, ...(extraFacts ?? [])],
|
|
41
|
+
layer: "observed",
|
|
42
|
+
timestamp,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
for (const cat of removed) {
|
|
46
|
+
events.push({
|
|
47
|
+
eventType: "category_removed",
|
|
48
|
+
fromRevisionId: fromRevId,
|
|
49
|
+
toRevisionId: toRevId,
|
|
50
|
+
section: "",
|
|
51
|
+
before: cat,
|
|
52
|
+
after: "",
|
|
53
|
+
deterministicFacts: [{ fact: "category_removed", detail: `category=${cat}` }, ...(extraFacts ?? [])],
|
|
54
|
+
layer: "observed",
|
|
55
|
+
timestamp,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return events;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=category-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-tracker.js","sourceRoot":"","sources":["../../src/category-tracker.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,2CAA2C,CAAC;AAEnE,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,KAA6B,CAAC;IAElC,kFAAkF;IAClF,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,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AAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC;YACV,SAAS,EAAE,gBAAgB;YAC3B,cAAc,EAAE,SAAS;YACzB,YAAY,EAAE,OAAO;YACrB,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,GAAG;YACV,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YAClG,KAAK,EAAE,UAAU;YACjB,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC;YACV,SAAS,EAAE,kBAAkB;YAC7B,cAAc,EAAE,SAAS;YACzB,YAAY,EAAE,OAAO;YACrB,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,EAAE;YACT,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YACpG,KAAK,EAAE,UAAU;YACjB,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SourceLineage, SourceRecord } from "@refract-org/evidence-graph";
|
|
2
|
+
import type { CitationRef, CitationTracker } from "./index.js";
|
|
3
|
+
export declare const citationTracker: CitationTracker;
|
|
4
|
+
export declare function buildSourceLineage(revisions: {
|
|
5
|
+
revId: number;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}[]): {
|
|
9
|
+
sources: SourceRecord[];
|
|
10
|
+
lineage: SourceLineage[];
|
|
11
|
+
};
|
|
12
|
+
export declare function buildSourceId(ref: CitationRef): string;
|
|
13
|
+
//# sourceMappingURL=citation-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citation-tracker.d.ts","sourceRoot":"","sources":["../../src/citation-tracker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,aAAa,EAAE,YAAY,EAAc,MAAM,6BAA6B,CAAC;AAC5G,OAAO,KAAK,EAAkB,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/E,eAAO,MAAM,eAAe,EAAE,eA2E7B,CAAC;AAWF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG;IACtG,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B,CAuEA;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAQtD"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export const citationTracker = {
|
|
3
|
+
extractCitations(wikitext) {
|
|
4
|
+
const refs = [];
|
|
5
|
+
const seen = new Set();
|
|
6
|
+
const refRegex = /<ref\b([^>]*?)>(.*?)<\/ref\s*>/gs;
|
|
7
|
+
let match;
|
|
8
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: Standard regex loop pattern
|
|
9
|
+
while ((match = refRegex.exec(wikitext)) !== null) {
|
|
10
|
+
const attrs = match[1];
|
|
11
|
+
const content = match[2].trim();
|
|
12
|
+
const nameMatch = attrs.match(/name\s*=\s*["']?([^"'\s>]+)/i);
|
|
13
|
+
const urlMatch = content.match(/url\s*=\s*([^\s|}\]]+)/i);
|
|
14
|
+
const titleMatch = content.match(/title\s*=\s*([^|}\]]+?)(?:\s*[|}\]])/i);
|
|
15
|
+
const raw = match[0];
|
|
16
|
+
const key = nameMatch ? nameMatch[1] : raw;
|
|
17
|
+
if (seen.has(key))
|
|
18
|
+
continue;
|
|
19
|
+
seen.add(key);
|
|
20
|
+
refs.push({
|
|
21
|
+
refName: nameMatch?.[1],
|
|
22
|
+
url: urlMatch ? urlMatch[1].trim() : undefined,
|
|
23
|
+
title: titleMatch ? titleMatch[1].trim() : undefined,
|
|
24
|
+
raw,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const selfClosingRegex = /<ref\b([^>]*?)\/\s*>/g;
|
|
28
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: Standard regex loop pattern
|
|
29
|
+
while ((match = selfClosingRegex.exec(wikitext)) !== null) {
|
|
30
|
+
const attrs = match[1];
|
|
31
|
+
const nameMatch = attrs.match(/name\s*=\s*["']?([^"'\s>]+)/i);
|
|
32
|
+
if (!nameMatch)
|
|
33
|
+
continue;
|
|
34
|
+
const key = nameMatch[1];
|
|
35
|
+
if (seen.has(key))
|
|
36
|
+
continue;
|
|
37
|
+
seen.add(key);
|
|
38
|
+
refs.push({
|
|
39
|
+
refName: key,
|
|
40
|
+
raw: match[0],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return refs;
|
|
44
|
+
},
|
|
45
|
+
diffCitations(before, after) {
|
|
46
|
+
const changes = [];
|
|
47
|
+
const beforeMap = indexByKey(before);
|
|
48
|
+
const afterMap = indexByKey(after);
|
|
49
|
+
for (const [key, afterRef] of afterMap) {
|
|
50
|
+
const beforeRef = beforeMap.get(key);
|
|
51
|
+
if (!beforeRef) {
|
|
52
|
+
changes.push({ type: "added", after: afterRef });
|
|
53
|
+
}
|
|
54
|
+
else if (beforeRef.raw !== afterRef.raw) {
|
|
55
|
+
changes.push({ type: "replaced", before: beforeRef, after: afterRef });
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
changes.push({ type: "unchanged", after: afterRef });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const [key, beforeRef] of beforeMap) {
|
|
62
|
+
if (!afterMap.has(key)) {
|
|
63
|
+
changes.push({ type: "removed", before: beforeRef });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return changes;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
function indexByKey(refs) {
|
|
70
|
+
const map = new Map();
|
|
71
|
+
for (const ref of refs) {
|
|
72
|
+
const key = ref.refName ?? ref.raw;
|
|
73
|
+
map.set(key, ref);
|
|
74
|
+
}
|
|
75
|
+
return map;
|
|
76
|
+
}
|
|
77
|
+
export function buildSourceLineage(revisions) {
|
|
78
|
+
const sourceMap = new Map();
|
|
79
|
+
const replacementMap = new Map();
|
|
80
|
+
function ensureSource(ref, seenAtRevId, seenAtTimestamp) {
|
|
81
|
+
const sourceId = buildSourceId(ref);
|
|
82
|
+
if (!sourceMap.has(sourceId)) {
|
|
83
|
+
sourceMap.set(sourceId, {
|
|
84
|
+
sourceId,
|
|
85
|
+
url: ref.url,
|
|
86
|
+
title: ref.title,
|
|
87
|
+
sourceType: classifySourceType(ref),
|
|
88
|
+
authority: classifyAuthority(ref),
|
|
89
|
+
firstSeenRevisionId: seenAtRevId,
|
|
90
|
+
firstSeenAt: seenAtTimestamp,
|
|
91
|
+
claimsReferencing: [],
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return sourceId;
|
|
95
|
+
}
|
|
96
|
+
const allCitations = revisions.map((r) => citationTracker.extractCitations(r.content));
|
|
97
|
+
// Seed sources from the first revision
|
|
98
|
+
if (revisions.length > 0) {
|
|
99
|
+
for (const ref of allCitations[0]) {
|
|
100
|
+
ensureSource(ref, revisions[0].revId, revisions[0].timestamp);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
for (let i = 0; i < revisions.length - 1; i++) {
|
|
104
|
+
const before = revisions[i];
|
|
105
|
+
const after = revisions[i + 1];
|
|
106
|
+
const beforeRefs = allCitations[i];
|
|
107
|
+
const afterRefs = allCitations[i + 1];
|
|
108
|
+
const changes = citationTracker.diffCitations(beforeRefs, afterRefs);
|
|
109
|
+
for (const change of changes) {
|
|
110
|
+
if (change.after) {
|
|
111
|
+
const id = ensureSource(change.after, after.revId, after.timestamp);
|
|
112
|
+
if (change.type === "replaced" && change.before) {
|
|
113
|
+
const oldId = ensureSource(change.before, after.revId, after.timestamp);
|
|
114
|
+
const replacements = replacementMap.get(oldId) ?? [];
|
|
115
|
+
replacements.push({
|
|
116
|
+
replacedById: id,
|
|
117
|
+
atRevisionId: after.revId,
|
|
118
|
+
atTimestamp: after.timestamp,
|
|
119
|
+
});
|
|
120
|
+
replacementMap.set(oldId, replacements);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if ((change.type === "removed" || change.type === "replaced") && change.before) {
|
|
124
|
+
const sourceId = ensureSource(change.before, before.revId, before.timestamp);
|
|
125
|
+
const record = sourceMap.get(sourceId);
|
|
126
|
+
if (record) {
|
|
127
|
+
record.lastSeenRevisionId = before.revId;
|
|
128
|
+
record.lastSeenAt = before.timestamp;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const sources = Array.from(sourceMap.values());
|
|
134
|
+
const lineage = [];
|
|
135
|
+
for (const [sourceId, replacements] of replacementMap) {
|
|
136
|
+
lineage.push({ sourceId, replacements });
|
|
137
|
+
}
|
|
138
|
+
return { sources, lineage };
|
|
139
|
+
}
|
|
140
|
+
export function buildSourceId(ref) {
|
|
141
|
+
if (ref.url) {
|
|
142
|
+
return createHash("sha256").update(ref.url).digest("hex").slice(0, 16);
|
|
143
|
+
}
|
|
144
|
+
if (ref.refName) {
|
|
145
|
+
return createHash("sha256").update(`ref:${ref.refName}`).digest("hex").slice(0, 16);
|
|
146
|
+
}
|
|
147
|
+
return createHash("sha256").update(ref.raw).digest("hex").slice(0, 16);
|
|
148
|
+
}
|
|
149
|
+
const NEWS_DOMAINS = [
|
|
150
|
+
"cnn.com",
|
|
151
|
+
"nytimes.com",
|
|
152
|
+
"bbc.com",
|
|
153
|
+
"reuters.com",
|
|
154
|
+
"apnews.com",
|
|
155
|
+
"washingtonpost.com",
|
|
156
|
+
"wsj.com",
|
|
157
|
+
"theguardian.com",
|
|
158
|
+
"bloomberg.com",
|
|
159
|
+
"npr.org",
|
|
160
|
+
"thehill.com",
|
|
161
|
+
"politico.com",
|
|
162
|
+
"foxnews.com",
|
|
163
|
+
"nbcnews.com",
|
|
164
|
+
"cbsnews.com",
|
|
165
|
+
"abcnews.net",
|
|
166
|
+
"usatoday.com",
|
|
167
|
+
"latimes.com",
|
|
168
|
+
"chicagotribune.com",
|
|
169
|
+
"huffpost.com",
|
|
170
|
+
"buzzfeednews.com",
|
|
171
|
+
];
|
|
172
|
+
function classifySourceType(ref) {
|
|
173
|
+
const url = ref.url?.toLowerCase() ?? "";
|
|
174
|
+
if (!url)
|
|
175
|
+
return "unknown";
|
|
176
|
+
if (url.includes("doi.org") || /journal|jstor|springer|sciencedirect/i.test(url)) {
|
|
177
|
+
return "academic";
|
|
178
|
+
}
|
|
179
|
+
if (url.includes(".gov"))
|
|
180
|
+
return "government";
|
|
181
|
+
if (url.includes(".edu"))
|
|
182
|
+
return "secondary";
|
|
183
|
+
if (NEWS_DOMAINS.some((d) => url.includes(d)))
|
|
184
|
+
return "news";
|
|
185
|
+
return "unknown";
|
|
186
|
+
}
|
|
187
|
+
function classifyAuthority(ref) {
|
|
188
|
+
const url = ref.url?.toLowerCase() ?? "";
|
|
189
|
+
if (!url)
|
|
190
|
+
return "unrated";
|
|
191
|
+
if (url.includes("doi.org") || /journal|jstor|springer/i.test(url)) {
|
|
192
|
+
return "medium";
|
|
193
|
+
}
|
|
194
|
+
if (/\.(edu|gov|org)\b/.test(url))
|
|
195
|
+
return "high";
|
|
196
|
+
if (/\.(com|net)\b/.test(url))
|
|
197
|
+
return "medium";
|
|
198
|
+
return "unrated";
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=citation-tracker.js.map
|
|
@@ -0,0 +1 @@
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-0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-differ.d.ts","sourceRoot":"","sources":["../../src/claim-differ.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
// claim-differ has been removed.
|
|
3
|
+
// Text comparison utilities (stripWikitext, fuzzyFindClaim) moved to wikitext-parser.ts.
|
|
4
|
+
// Semantic direction classification (classifyClaimChange) removed — Refract observes mechanical
|
|
5
|
+
// text appearance/disappearance, not semantic interpretation of direction.
|
|
6
|
+
//# sourceMappingURL=claim-differ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-differ.js","sourceRoot":"","sources":["../../src/claim-differ.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,yFAAyF;AACzF,gGAAgG;AAChG,2EAA2E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EvidenceEvent, Revision } from "@refract-org/evidence-graph";
|
|
2
|
+
export interface EditClusterOptions {
|
|
3
|
+
windowMs?: number;
|
|
4
|
+
minClusterSize?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface EditCluster {
|
|
7
|
+
revisionIds: number[];
|
|
8
|
+
timestamp: string;
|
|
9
|
+
editor?: string;
|
|
10
|
+
section?: string;
|
|
11
|
+
eventCount: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function detectEditClusters(revisions: Revision[], options?: EditClusterOptions): EvidenceEvent[];
|
|
14
|
+
//# sourceMappingURL=edit-cluster-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-cluster-detector.d.ts","sourceRoot":"","sources":["../../src/edit-cluster-detector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAK3E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,EAAE,CAqDvG"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const DEFAULT_WINDOW_MS = 60 * 60 * 1000; // 1 hour
|
|
2
|
+
const DEFAULT_MIN_CLUSTER_SIZE = 3;
|
|
3
|
+
export function detectEditClusters(revisions, options) {
|
|
4
|
+
const windowMs = options?.windowMs ?? DEFAULT_WINDOW_MS;
|
|
5
|
+
const minSize = options?.minClusterSize ?? DEFAULT_MIN_CLUSTER_SIZE;
|
|
6
|
+
const events = [];
|
|
7
|
+
if (revisions.length < minSize)
|
|
8
|
+
return events;
|
|
9
|
+
const sorted = [...revisions].sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
10
|
+
const clustered = new Set();
|
|
11
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
12
|
+
if (clustered.has(i))
|
|
13
|
+
continue;
|
|
14
|
+
const windowStart = new Date(sorted[i].timestamp).getTime();
|
|
15
|
+
const windowEnd = windowStart + windowMs;
|
|
16
|
+
const cluster = [];
|
|
17
|
+
for (let j = i; j < sorted.length; j++) {
|
|
18
|
+
const t = new Date(sorted[j].timestamp).getTime();
|
|
19
|
+
if (t <= windowEnd) {
|
|
20
|
+
cluster.push(j);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (cluster.length >= minSize) {
|
|
27
|
+
const hasSingleEditor = singleEditorCluster(sorted, cluster);
|
|
28
|
+
const _revIds = cluster.map((idx) => sorted[idx].revId);
|
|
29
|
+
for (const idx of cluster)
|
|
30
|
+
clustered.add(idx);
|
|
31
|
+
events.push({
|
|
32
|
+
eventType: "edit_cluster_detected",
|
|
33
|
+
fromRevisionId: sorted[cluster[0]].revId,
|
|
34
|
+
toRevisionId: sorted[cluster[cluster.length - 1]].revId,
|
|
35
|
+
section: "",
|
|
36
|
+
before: "",
|
|
37
|
+
after: "",
|
|
38
|
+
deterministicFacts: [
|
|
39
|
+
{
|
|
40
|
+
fact: "edit_cluster",
|
|
41
|
+
detail: `revisions=${cluster.length} window_ms=${windowMs} single_editor=${hasSingleEditor}`,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
layer: "observed",
|
|
45
|
+
timestamp: sorted[cluster[0]].timestamp,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return events;
|
|
50
|
+
}
|
|
51
|
+
function singleEditorCluster(revisions, indices) {
|
|
52
|
+
const firstUser = revisions[indices[0]].user;
|
|
53
|
+
if (!firstUser)
|
|
54
|
+
return false;
|
|
55
|
+
return indices.every((i) => revisions[i].user === firstUser);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=edit-cluster-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-cluster-detector.js","sourceRoot":"","sources":["../../src/edit-cluster-detector.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AACnD,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAenC,MAAM,UAAU,kBAAkB,CAAC,SAAqB,EAAE,OAA4B;IACpF,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,iBAAiB,CAAC;IACxD,MAAM,OAAO,GAAG,OAAO,EAAE,cAAc,IAAI,wBAAwB,CAAC;IACpE,MAAM,MAAM,GAAoB,EAAE,CAAC;IAEnC,IAAI,SAAS,CA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
export interface HeuristicOptions {
|
|
3
|
+
majorAdditionThreshold?: number;
|
|
4
|
+
majorRemovalThreshold?: number;
|
|
5
|
+
cosmeticThreshold?: number;
|
|
6
|
+
minorThreshold?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function classifyHeuristic(comment: string, sizeDelta: number, options?: HeuristicOptions): HeuristicKind;
|
|
9
|
+
//# sourceMappingURL=heuristic-classifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heuristic-classifier.d.ts","sourceRoot":"","sources":["../../src/heuristic-classifier.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,WAAW,GACX,gBAAgB,GAChB,eAAe,GACf,UAAU,GACV,UAAU,GACV,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAWD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAgC/G"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const VANDALISM_PATTERNS = /\b(vandal|vandalism|spam|blanking|test edit)\b/i;
|
|
2
|
+
const SOURCING_PATTERNS = /\b(cite|ref|source|reference|citation|add ref|rm ref)\b/i;
|
|
3
|
+
const REVERT_PATTERNS = /\b(rv|revert|reverted|undo|undid|rollback|rvv)\b/i;
|
|
4
|
+
const DEFAULT_MAJOR_ADDITION = 2000;
|
|
5
|
+
const DEFAULT_MAJOR_REMOVAL = -2000;
|
|
6
|
+
const DEFAULT_COSMETIC = 20;
|
|
7
|
+
const DEFAULT_MINOR = 100;
|
|
8
|
+
export function classifyHeuristic(comment, sizeDelta, options) {
|
|
9
|
+
const norm = comment.toLowerCase().trim();
|
|
10
|
+
if (REVERT_PATTERNS.test(norm)) {
|
|
11
|
+
return "revert";
|
|
12
|
+
}
|
|
13
|
+
if (VANDALISM_PATTERNS.test(norm)) {
|
|
14
|
+
return "vandalism";
|
|
15
|
+
}
|
|
16
|
+
if (SOURCING_PATTERNS.test(norm)) {
|
|
17
|
+
return "sourcing";
|
|
18
|
+
}
|
|
19
|
+
if (sizeDelta > (options?.majorAdditionThreshold ?? DEFAULT_MAJOR_ADDITION)) {
|
|
20
|
+
return "major_addition";
|
|
21
|
+
}
|
|
22
|
+
if (sizeDelta < (options?.majorRemovalThreshold ?? DEFAULT_MAJOR_REMOVAL)) {
|
|
23
|
+
return "major_removal";
|
|
24
|
+
}
|
|
25
|
+
if (Math.abs(sizeDelta) < (options?.cosmeticThreshold ?? DEFAULT_COSMETIC) && !norm) {
|
|
26
|
+
return "cosmetic";
|
|
27
|
+
}
|
|
28
|
+
if (Math.abs(sizeDelta) < (options?.minorThreshold ?? DEFAULT_MINOR)) {
|
|
29
|
+
return "minor";
|
|
30
|
+
}
|
|
31
|
+
return "unknown";
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=heuristic-classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heuristic-classifier.js","sourceRoot":"","sources":["../../src/heuristic-classifier.ts"],"names":[],"mappings":"AAiBA,MAAM,kBAAkB,GAAG,iDAAiD,CAAC;AAC7E,MAAM,iBAAiB,GAAG,0DAA0D,CAAC;AACrF,MAAM,eAAe,GAAG,mDAAmD,CAAC;AAE5E,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,qBAAqB,GAAG,CAAC,IAAI,CAAC;AACpC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,SAAiB,EAAE,OAA0B;IAC9F,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAE1C,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,SAAS,GAAG,CAAC,OAAO,EAAE,sBAAsB,IAAI,sBAAsB,CAAC,EAAE,CAAC;QAC5E,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS,GAAG,CAAC,OAAO,EAAE,qBAAqB,IAAI,qBAAqB,CAAC,EAAE,CAAC;QAC1E,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACpF,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,IAAI,aAAa,CAAC,EAAE,CAAC;QACrE,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Revision, Section, SectionChange } from "@refract-org/evidence-graph";
|
|
2
|
+
export interface SectionDiffer {
|
|
3
|
+
extractSections(wikitext: string): Section[];
|
|
4
|
+
diffSections(before: Section[], after: Section[]): SectionChange[];
|
|
5
|
+
}
|
|
6
|
+
export interface CitationTracker {
|
|
7
|
+
extractCitations(wikitext: string): CitationRef[];
|
|
8
|
+
diffCitations(before: CitationRef[], after: CitationRef[]): CitationChange[];
|
|
9
|
+
}
|
|
10
|
+
export interface CitationRef {
|
|
11
|
+
url?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
refName?: string;
|
|
14
|
+
raw: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CitationChange {
|
|
17
|
+
type: "added" | "removed" | "replaced" | "unchanged";
|
|
18
|
+
before?: CitationRef;
|
|
19
|
+
after?: CitationRef;
|
|
20
|
+
}
|
|
21
|
+
export interface RevertDetector {
|
|
22
|
+
isRevert(comment: string): boolean;
|
|
23
|
+
detectRevertChain(revisions: Revision[]): RevertChain[];
|
|
24
|
+
}
|
|
25
|
+
export interface RevertChain {
|
|
26
|
+
startRevisionId: number;
|
|
27
|
+
endRevisionId: number;
|
|
28
|
+
revertedToRevisionId: number;
|
|
29
|
+
participants: number;
|
|
30
|
+
}
|
|
31
|
+
export interface TemplateTracker {
|
|
32
|
+
extractTemplates(wikitext: string): Template[];
|
|
33
|
+
diffTemplates(before: Template[], after: Template[]): TemplateChange[];
|
|
34
|
+
}
|
|
35
|
+
export interface Template {
|
|
36
|
+
name: string;
|
|
37
|
+
type: TemplateType;
|
|
38
|
+
params?: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
export type TemplateType = "citation" | "neutrality" | "blp" | "dispute" | "cleanup" | "protection" | "other";
|
|
41
|
+
export interface TemplateChange {
|
|
42
|
+
type: "added" | "removed" | "unchanged";
|
|
43
|
+
template: Template;
|
|
44
|
+
}
|
|
45
|
+
export { buildCategoryEvents, diffCategories, extractCategories } from "./category-tracker.js";
|
|
46
|
+
export { buildSourceId, buildSourceLineage, citationTracker } from "./citation-tracker.js";
|
|
47
|
+
export type { EditClusterOptions } from "./edit-cluster-detector.js";
|
|
48
|
+
export { detectEditClusters } from "./edit-cluster-detector.js";
|
|
49
|
+
export type { HeuristicKind, HeuristicOptions } from "./heuristic-classifier.js";
|
|
50
|
+
export { classifyHeuristic } from "./heuristic-classifier.js";
|
|
51
|
+
export type { ObservationDiff } from "./observation-differ.js";
|
|
52
|
+
export { diffObservations } from "./observation-differ.js";
|
|
53
|
+
export { buildPageMoveEvents } from "./page-move-detector.js";
|
|
54
|
+
export type { ProtectionChange, ProtectionTracker } from "./protection-tracker.js";
|
|
55
|
+
export { protectionTracker } from "./protection-tracker.js";
|
|
56
|
+
export { revertDetector } from "./revert-detector.js";
|
|
57
|
+
export type { SectionEvent, SectionLineage } from "./section-differ.js";
|
|
58
|
+
export { buildSectionLineage, sectionDiffer } from "./section-differ.js";
|
|
59
|
+
export type { TalkActivityOptions, TalkActivityResult } from "./talk-activity-detector.js";
|
|
60
|
+
export { detectTalkActivitySpikes } from "./talk-activity-detector.js";
|
|
61
|
+
export type { TalkCorrelationOptions } from "./talk-correlator.js";
|
|
62
|
+
export { correlateTalkRevisions } from "./talk-correlator.js";
|
|
63
|
+
export type { TalkReply, TalkThread, TalkThreadChange } from "./talk-section-parser.js";
|
|
64
|
+
export { buildTalkThreadEvents, diffTalkThreads, parseTalkThreads } from "./talk-section-parser.js";
|
|
65
|
+
export type { ParamChange } from "./template-tracker.js";
|
|
66
|
+
export { buildParamChangeEvents, diffTemplateParams, templateTracker } from "./template-tracker.js";
|
|
67
|
+
export { buildWikilinkEvents, diffWikilinks, extractWikilinks } from "./wikilink-extractor.js";
|
|
68
|
+
export type { HeadingPosition } from "./wikitext-parser.js";
|
|
69
|
+
export { countCitations, countKeywordMentions, deriveSectionHeading, extractAnchorSnippet, extractHeadingMap, sanitizeWikitext, stripWikitext, } from "./wikitext-parser.js";
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEpF,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,QAAQ,EAAE,MAAM,GAA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AAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACpG,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC/F,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { buildCategoryEvents, diffCategories, extractCategories } from "./category-tracker.js";
|
|
2
|
+
export { buildSourceId, buildSourceLineage, citationTracker } from "./citation-tracker.js";
|
|
3
|
+
export { detectEditClusters } from "./edit-cluster-detector.js";
|
|
4
|
+
export { classifyHeuristic } from "./heuristic-classifier.js";
|
|
5
|
+
export { diffObservations } from "./observation-differ.js";
|
|
6
|
+
export { buildPageMoveEvents } from "./page-move-detector.js";
|
|
7
|
+
export { protectionTracker } from "./protection-tracker.js";
|
|
8
|
+
export { revertDetector } from "./revert-detector.js";
|
|
9
|
+
export { buildSectionLineage, sectionDiffer } from "./section-differ.js";
|
|
10
|
+
export { detectTalkActivitySpikes } from "./talk-activity-detector.js";
|
|
11
|
+
export { correlateTalkRevisions } from "./talk-correlator.js";
|
|
12
|
+
export { buildTalkThreadEvents, diffTalkThreads, parseTalkThreads } from "./talk-section-parser.js";
|
|
13
|
+
export { buildParamChangeEvents, diffTemplateParams, templateTracker } from "./template-tracker.js";
|
|
14
|
+
export { buildWikilinkEvents, diffWikilinks, extractWikilinks } from "./wikilink-extractor.js";
|
|
15
|
+
export { countCitations, countKeywordMentions, deriveSectionHeading, extractAnchorSnippet, extractHeadingMap, sanitizeWikitext, stripWikitext, } from "./wikitext-parser.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAuDA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE/F,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EvidenceEvent } from "@refract-org/evidence-graph";
|
|
2
|
+
export interface ObservationDiff {
|
|
3
|
+
new: EvidenceEvent[];
|
|
4
|
+
resolved: EvidenceEvent[];
|
|
5
|
+
unchanged: EvidenceEvent[];
|
|
6
|
+
}
|
|
7
|
+
export declare function diffObservations(prior: EvidenceEvent[], current: EvidenceEvent[]): ObservationDiff;
|
|
8
|
+
//# sourceMappingURL=observation-differ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observation-differ.d.ts","sourceRoot":"","sources":["../../src/observation-differ.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,aAAa,EAAE,CAAC;IACrB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,eAAe,CAalG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function eventKey(event) {
|
|
2
|
+
return `${event.eventType}|${event.fromRevisionId}|${event.toRevisionId}|${event.section}`;
|
|
3
|
+
}
|
|
4
|
+
export function diffObservations(prior, current) {
|
|
5
|
+
const priorKeys = new Set(prior.map(eventKey));
|
|
6
|
+
const currentKeys = new Set(current.map(eventKey));
|
|
7
|
+
const newEvents = current.filter((e) => !priorKeys.has(eventKey(e)));
|
|
8
|
+
const unchangedEvents = current.filter((e) => priorKeys.has(eventKey(e)));
|
|
9
|
+
const resolvedEvents = prior.filter((e) => !currentKeys.has(eventKey(e)));
|
|
10
|
+
return {
|
|
11
|
+
new: newEvents,
|
|
12
|
+
resolved: resolvedEvents,
|
|
13
|
+
unchanged: unchangedEvents,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=observation-differ.js.map
|