lens-content-processor 0.37.0 → 0.37.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.
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { ContentError } from "../index.js";
|
|
2
|
-
export declare const ARTICLE_REVIEW_FIELDS: readonly ["llm_reviewed", "llm_review_version", "llm_review_model", "
|
|
3
|
-
export declare function canonicalArticleForReview(content: string): string;
|
|
4
|
-
export declare function articleReviewDigest(content: string): string;
|
|
2
|
+
export declare const ARTICLE_REVIEW_FIELDS: readonly ["llm_reviewed", "llm_review_version", "llm_review_model", "llm_review_source_fetched", "llm_review_source_kind"];
|
|
5
3
|
export declare function validateArticleReviewProvenance(content: string, file: string): ContentError[];
|
|
@@ -1,39 +1,8 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import { parseFrontmatter } from "../parser/frontmatter.js";
|
|
3
2
|
export const ARTICLE_REVIEW_FIELDS = [
|
|
4
3
|
"llm_reviewed", "llm_review_version", "llm_review_model",
|
|
5
|
-
"llm_review_digest", "llm_review_source_digest",
|
|
6
4
|
"llm_review_source_fetched", "llm_review_source_kind",
|
|
7
5
|
];
|
|
8
|
-
export function canonicalArticleForReview(content) {
|
|
9
|
-
const normalized = content.replace(/\r\n?/g, "\n");
|
|
10
|
-
const lines = normalized.split("\n");
|
|
11
|
-
const out = [];
|
|
12
|
-
let inFrontmatter = false;
|
|
13
|
-
let frontmatterDone = false;
|
|
14
|
-
let inComment = false;
|
|
15
|
-
for (const line of lines) {
|
|
16
|
-
if (!frontmatterDone && line.trim() === "---") {
|
|
17
|
-
inFrontmatter = !inFrontmatter;
|
|
18
|
-
if (!inFrontmatter)
|
|
19
|
-
frontmatterDone = true;
|
|
20
|
-
out.push(line.trimEnd());
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (inFrontmatter && ARTICLE_REVIEW_FIELDS.some((field) => new RegExp(`^${field}\\s*:`).test(line)))
|
|
24
|
-
continue;
|
|
25
|
-
if (!inFrontmatter && line.trim() === "%%") {
|
|
26
|
-
inComment = !inComment;
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (!inComment)
|
|
30
|
-
out.push(line.replace(/[ \t]+$/g, ""));
|
|
31
|
-
}
|
|
32
|
-
return `${out.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd()}\n`;
|
|
33
|
-
}
|
|
34
|
-
export function articleReviewDigest(content) {
|
|
35
|
-
return `sha256:${createHash("sha256").update(canonicalArticleForReview(content)).digest("hex")}`;
|
|
36
|
-
}
|
|
37
6
|
export function validateArticleReviewProvenance(content, file) {
|
|
38
7
|
const parsed = parseFrontmatter(content, file);
|
|
39
8
|
if (parsed.error)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"article-review-provenance.js","sourceRoot":"","sources":["../../src/validator/article-review-provenance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"article-review-provenance.js","sourceRoot":"","sources":["../../src/validator/article-review-provenance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,cAAc,EAAE,oBAAoB,EAAE,kBAAkB;IACxD,2BAA2B,EAAE,wBAAwB;CAC7C,CAAC;AAEX,MAAM,UAAU,+BAA+B,CAAC,OAAe,EAAE,IAAY;IAC3E,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC/C,IAAI,MAAM,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CAAC;IACjG,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC,CAAC,2DA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