fibcheck 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +203 -2
- package/dist/app/docker.js +55 -0
- package/dist/attack-run.js +64 -0
- package/dist/attack.js +143 -0
- package/dist/card.js +159 -0
- package/dist/check.js +233 -0
- package/dist/claims/cache.js +45 -0
- package/dist/claims/documents.js +54 -0
- package/dist/claims/extract.js +144 -0
- package/dist/claims/quotes.js +52 -0
- package/dist/claims/rank.js +36 -0
- package/dist/claims/types.js +2 -0
- package/dist/cli.js +235 -0
- package/dist/confirm.js +83 -0
- package/dist/diagnose.js +150 -0
- package/dist/frozen.js +112 -0
- package/dist/general-loop.js +122 -0
- package/dist/github.js +214 -0
- package/dist/kane/evidence.js +66 -0
- package/dist/kane/parse.js +105 -0
- package/dist/kane/runner.js +58 -0
- package/dist/linkding-tags.js +207 -0
- package/dist/loop-types.js +1 -0
- package/dist/loop.js +186 -0
- package/dist/model/budget.js +82 -0
- package/dist/model/client.js +59 -0
- package/dist/model/config.js +124 -0
- package/dist/model/gemini.js +100 -0
- package/dist/model/openai-compatible.js +146 -0
- package/dist/model/types.js +28 -0
- package/dist/report/report.js +297 -0
- package/dist/target.js +70 -0
- package/package.json +46 -4
- package/targets/linkding.json +17 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
export function writeReport(inputPath) {
|
|
4
|
+
const directory = dirname(resolve(inputPath));
|
|
5
|
+
const htmlPath = join(directory, "report.html");
|
|
6
|
+
const badgePath = join(directory, "badge.svg");
|
|
7
|
+
if ([htmlPath, badgePath].includes(resolve(inputPath))) {
|
|
8
|
+
throw new Error("Choose the check JSON as input. report.html and badge.svg are output files.");
|
|
9
|
+
}
|
|
10
|
+
let html;
|
|
11
|
+
let badge;
|
|
12
|
+
try {
|
|
13
|
+
const report = JSON.parse(readFileSync(inputPath, "utf8"));
|
|
14
|
+
if (!Array.isArray(report?.claims) || !Array.isArray(report.tested) || !Array.isArray(report.notTested)) {
|
|
15
|
+
throw new Error("Expected a saved fibcheck check with claims and Kane results.");
|
|
16
|
+
}
|
|
17
|
+
const counts = countResults(report);
|
|
18
|
+
const artwork = renderBadge(counts);
|
|
19
|
+
html = renderReport(report, counts, artwork, directory, basename(inputPath));
|
|
20
|
+
badge = artwork.svg;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
24
|
+
throw new Error(`Could not read check report at ${inputPath}: ${message}`);
|
|
25
|
+
}
|
|
26
|
+
writeFileSync(badgePath, badge);
|
|
27
|
+
writeFileSync(htmlPath, html);
|
|
28
|
+
return { htmlPath, badgePath };
|
|
29
|
+
}
|
|
30
|
+
const RESULT_LABELS = {
|
|
31
|
+
passed: "Kane passed",
|
|
32
|
+
failed: "Kane failed",
|
|
33
|
+
error: "Kane error",
|
|
34
|
+
cancelled: "Kane cancelled",
|
|
35
|
+
};
|
|
36
|
+
const VERDICT_LABELS = {
|
|
37
|
+
true: "True",
|
|
38
|
+
worded_differently: "True, worded differently",
|
|
39
|
+
false: "False",
|
|
40
|
+
outdated: "Outdated",
|
|
41
|
+
unconfirmed: "Unconfirmed",
|
|
42
|
+
};
|
|
43
|
+
function runByClaim(report) {
|
|
44
|
+
return new Map(report.tested.map((entry) => [entry.claim.id, entry]));
|
|
45
|
+
}
|
|
46
|
+
export function countResults(report) {
|
|
47
|
+
const runs = runByClaim(report);
|
|
48
|
+
const skipped = new Set(report.notTested);
|
|
49
|
+
const counts = {
|
|
50
|
+
tested: runs.size, passed: 0, failed: 0, error: 0, cancelled: 0, skipped: 0, untestable: 0, withoutVerdict: 0, verifiedPasses: 0,
|
|
51
|
+
verdicts: { true: 0, worded_differently: 0, false: 0, outdated: 0, unconfirmed: 0 },
|
|
52
|
+
};
|
|
53
|
+
for (const { kane, questioning } of runs.values()) {
|
|
54
|
+
if (!Object.hasOwn(RESULT_LABELS, kane.status))
|
|
55
|
+
throw new Error("Unknown Kane result status.");
|
|
56
|
+
counts[kane.status]++;
|
|
57
|
+
if (questioning) {
|
|
58
|
+
if (!Object.hasOwn(VERDICT_LABELS, questioning.verdict))
|
|
59
|
+
throw new Error("Unknown claim verdict.");
|
|
60
|
+
counts.verdicts[questioning.verdict]++;
|
|
61
|
+
const decisive = questioning.followUps.at(-1)?.kane ?? kane;
|
|
62
|
+
const held = questioning.verdict === "true" || questioning.verdict === "worded_differently";
|
|
63
|
+
if (held && decisive.status === "passed" && decisive.exitCode === 0)
|
|
64
|
+
counts.verifiedPasses++;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
counts.withoutVerdict++;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const claim of report.claims) {
|
|
71
|
+
if (runs.has(claim.id))
|
|
72
|
+
continue;
|
|
73
|
+
if (skipped.has(claim.id))
|
|
74
|
+
counts.skipped++;
|
|
75
|
+
else
|
|
76
|
+
counts.untestable++;
|
|
77
|
+
}
|
|
78
|
+
return counts;
|
|
79
|
+
}
|
|
80
|
+
/** Claims that were not run come first, in the order the specificity ranking put them; untestable claims follow. */
|
|
81
|
+
function remainingInRankOrder(report, runs) {
|
|
82
|
+
const order = new Map(report.notTested.map((id, index) => [id, index]));
|
|
83
|
+
const position = (claim) => order.get(claim.id) ?? Number.MAX_SAFE_INTEGER;
|
|
84
|
+
return report.claims.filter((claim) => !runs.has(claim.id)).sort((a, b) => position(a) - position(b));
|
|
85
|
+
}
|
|
86
|
+
/** Claims whose behaviour held but whose visible wording differs from the docs. Suggestions, never fibs. */
|
|
87
|
+
function renderWordingSuggestions(report) {
|
|
88
|
+
const items = report.tested.flatMap(({ claim, questioning }) => (questioning?.verdict === "worded_differently" && questioning.wording ? [{ claim, wording: questioning.wording }] : []));
|
|
89
|
+
if (items.length === 0)
|
|
90
|
+
return "";
|
|
91
|
+
return `<section aria-labelledby="wording">
|
|
92
|
+
<h2 id="wording">Wording suggestions</h2>
|
|
93
|
+
<p class="meta">The behaviour held in each case, so none of these counts as a fib. The documentation could use the interface's own words.</p>
|
|
94
|
+
<ul>${items.map(({ claim, wording }) => `<li><strong>${escapeHtml(claim.source.file)}, line ${claim.source.startLine}:</strong> “${escapeHtml(wording.documented)}”. The app shows ${escapeHtml(wording.visible)}.</li>`).join("")}</ul>
|
|
95
|
+
</section>`;
|
|
96
|
+
}
|
|
97
|
+
function modelNote(report) {
|
|
98
|
+
const models = report.model?.models;
|
|
99
|
+
const limit = report.model?.spendingLimit ? ` (${escapeHtml(report.model.spendingLimit)})` : "";
|
|
100
|
+
const unusable = report.unusableModelOutput?.length ? `${report.unusableModelOutput.length} document part(s) with unusable model output · ` : "";
|
|
101
|
+
return models?.length ? `Model: ${escapeHtml(models.join(", "))}${limit} · ${unusable}` : unusable;
|
|
102
|
+
}
|
|
103
|
+
function renderReport(report, counts, badge, directory, inputName) {
|
|
104
|
+
const runs = runByClaim(report);
|
|
105
|
+
const skipped = new Set(report.notTested);
|
|
106
|
+
const tested = report.claims.filter((claim) => runs.has(claim.id));
|
|
107
|
+
const remaining = remainingInRankOrder(report, runs);
|
|
108
|
+
const name = escapeHtml(report.target);
|
|
109
|
+
const questioned = counts.withoutVerdict < counts.tested;
|
|
110
|
+
return `<!doctype html>
|
|
111
|
+
<html lang="en">
|
|
112
|
+
<head>
|
|
113
|
+
<meta charset="utf-8">
|
|
114
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
115
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src 'self' file:">
|
|
116
|
+
<title>${name} · fibcheck</title>
|
|
117
|
+
<style>${REPORT_STYLE}</style>
|
|
118
|
+
</head>
|
|
119
|
+
<body>
|
|
120
|
+
<main>
|
|
121
|
+
<header>
|
|
122
|
+
<img src="badge.svg" alt="fibcheck · ${escapeHtml(badge.label)}" width="${badge.width}" height="34">
|
|
123
|
+
<h1>${name}</h1>
|
|
124
|
+
<p class="meta">${escapeHtml(report.repo)}${report.commit ? ` · <code>${escapeHtml(report.commit.slice(0, 12))}</code>` : ""}</p>
|
|
125
|
+
<p class="meta">Run <time datetime="${escapeHtml(report.startedAt)}">${escapeHtml(report.startedAt)}</time> · ${report.kaneCredits.toFixed(1)} Kane credits reported · ${modelNote(report)}<a href="${encodeURIComponent(inputName)}">Check JSON</a></p>
|
|
126
|
+
</header>
|
|
127
|
+
${questioned ? renderVerdictScore(counts) : ""}
|
|
128
|
+
${renderWordingSuggestions(report)}
|
|
129
|
+
<section aria-labelledby="results">
|
|
130
|
+
<h2 id="results">${questioned ? "Initial Kane results" : "Kane results"}</h2>
|
|
131
|
+
${questioned ? "" : "<p>These results describe individual browser checks. Claim verdicts require the questioning loop.</p>"}
|
|
132
|
+
${renderKaneCounts(counts, questioned)}
|
|
133
|
+
<p class="meta">${report.claims.length} ${report.claims.length === 1 ? "claim" : "claims"} across ${report.documents.length} ${report.documents.length === 1 ? "document" : "documents"} · ${report.rejected.length} rejected quotes</p>
|
|
134
|
+
</section>
|
|
135
|
+
<section aria-labelledby="tested">
|
|
136
|
+
<h2 id="tested">Tested claims</h2>
|
|
137
|
+
${tested.map((claim) => renderClaim(claim, runs.get(claim.id), false, directory)).join("\n") || "<p>No Kane runs in this check.</p>"}
|
|
138
|
+
</section>
|
|
139
|
+
<section aria-labelledby="remaining">
|
|
140
|
+
<h2 id="remaining">Remaining claims</h2>
|
|
141
|
+
${remaining.map((claim) => renderClaim(claim, undefined, skipped.has(claim.id), directory)).join("\n") || "<p>All extracted claims were run.</p>"}
|
|
142
|
+
</section>
|
|
143
|
+
</main>
|
|
144
|
+
</body>
|
|
145
|
+
</html>
|
|
146
|
+
`;
|
|
147
|
+
}
|
|
148
|
+
function renderKaneCounts(counts, questioned) {
|
|
149
|
+
const initial = [
|
|
150
|
+
...Object.entries(RESULT_LABELS).map(([status, label]) => [label, counts[status]]),
|
|
151
|
+
];
|
|
152
|
+
return questioned ? renderMetrics(initial) : renderMetrics([
|
|
153
|
+
["Tested", counts.tested], ...initial, ["Not run", counts.skipped], ["Untestable", counts.untestable],
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
function renderVerdictScore(counts) {
|
|
157
|
+
const metrics = [
|
|
158
|
+
["Tested", counts.tested],
|
|
159
|
+
...Object.entries(VERDICT_LABELS).map(([verdict, label]) => [label, counts.verdicts[verdict]]),
|
|
160
|
+
["Not run", counts.skipped], ["Untestable", counts.untestable],
|
|
161
|
+
];
|
|
162
|
+
if (counts.withoutVerdict)
|
|
163
|
+
metrics.push(["Without verdict", counts.withoutVerdict]);
|
|
164
|
+
return `<section aria-labelledby="score">
|
|
165
|
+
<h2 id="score">fibcheck score</h2>
|
|
166
|
+
${renderMetrics(metrics)}
|
|
167
|
+
</section>`;
|
|
168
|
+
}
|
|
169
|
+
function renderMetrics(metrics) {
|
|
170
|
+
return `<dl class="metrics">${metrics.map(([label, count]) => `<div><dt>${label}</dt><dd>${count}</dd></div>`).join("")}</dl>`;
|
|
171
|
+
}
|
|
172
|
+
function renderClaim(claim, entry, skipped, directory) {
|
|
173
|
+
const { file, startLine, endLine } = claim.source;
|
|
174
|
+
const line = startLine === endLine ? `line ${startLine}` : `lines ${startLine}–${endLine}`;
|
|
175
|
+
const question = entry?.questioning;
|
|
176
|
+
const status = question ? `Verdict ${question.verdict}${question.candidateFinding ? " · candidate finding, awaiting review" : ""}` : entry ? RESULT_LABELS[entry.kane.status] : skipped ? "Not run" : "Untestable";
|
|
177
|
+
return `<article>
|
|
178
|
+
<div class="claim-meta"><span class="status ${question ? "pending" : entry?.kane.status ?? "pending"}">${escapeHtml(status)}</span>
|
|
179
|
+
<span class="meta">${escapeHtml(file)} · ${escapeHtml(line)}</span></div>
|
|
180
|
+
<blockquote>${escapeHtml(claim.quote)}</blockquote>
|
|
181
|
+
${entry ? renderClaimRuns(entry, directory) : claim.reason ? `<p class="meta">${escapeHtml(claim.reason)}</p>` : ""}
|
|
182
|
+
</article>`;
|
|
183
|
+
}
|
|
184
|
+
function renderClaimRuns({ kane, questioning }, directory) {
|
|
185
|
+
if (!questioning)
|
|
186
|
+
return renderRun(kane, directory);
|
|
187
|
+
const rounds = [{ purpose: "initial", reason: questioning.initialReason, kane }, ...questioning.followUps];
|
|
188
|
+
const roundNames = { initial: "Initial check", reword: "Reworded check", retry: "Reproduction", control: "Control" };
|
|
189
|
+
const roundsHtml = rounds.map((round) => `<section class="round">
|
|
190
|
+
<h3>${roundNames[round.purpose]} · ${RESULT_LABELS[round.kane.status]}</h3>
|
|
191
|
+
<p class="meta">${escapeHtml(round.reason)}</p>
|
|
192
|
+
${(questioning.diagnoses ?? []).filter((entry) => entry.round === round.purpose).map((entry) => (`<p class="meta"><strong>Model reading</strong> · ${readingLabel(entry)}. ${escapeHtml(entry.reason)}</p>`)).join("")}
|
|
193
|
+
${renderRun(round.kane, directory)}
|
|
194
|
+
${questioning.overrides.filter((entry) => entry.round === round.purpose).map((entry) => (`<p class="override"><strong>Blame override</strong> · Kane reported ${escapeHtml(entry.family)} / ${escapeHtml(entry.category)}. ${escapeHtml(entry.hypothesis)} ${escapeHtml(entry.evidence)}</p>`)).join("")}
|
|
195
|
+
</section>`).join("\n");
|
|
196
|
+
return `<p>${escapeHtml(questioning.reason)}</p>${roundsHtml}`;
|
|
197
|
+
}
|
|
198
|
+
function renderRun(kane, directory) {
|
|
199
|
+
const message = kane.oneLiner || kane.reason;
|
|
200
|
+
const steps = kane.evidence.map((step) => {
|
|
201
|
+
const screenshot = evidenceLink(directory, kane, step.screenshot);
|
|
202
|
+
const annotated = evidenceLink(directory, kane, step.annotated);
|
|
203
|
+
const links = [
|
|
204
|
+
screenshot && `<a href="${screenshot}">Screenshot</a>`,
|
|
205
|
+
annotated && `<a href="${annotated}">Annotated screenshot</a>`,
|
|
206
|
+
].filter(Boolean);
|
|
207
|
+
const description = step.summary || step.kind;
|
|
208
|
+
return `<li>Step ${escapeHtml(String(step.ordinal))}${description ? ` · ${escapeHtml(description)}` : ""}<span>${links.join(" · ") || "Screenshot unavailable"}</span></li>`;
|
|
209
|
+
});
|
|
210
|
+
return `${message ? `<p>${escapeHtml(message)}</p>` : ""}
|
|
211
|
+
${kane.failedStep?.remark && kane.failedStep.remark !== message ? `<p class="meta">Failed step ${escapeHtml(String(kane.failedStep.step))} · ${escapeHtml(kane.failedStep.remark)}</p>` : ""}
|
|
212
|
+
${steps.length ? `<details><summary>Step evidence (${steps.length})</summary><ul>${steps.join("")}</ul></details>` : "<p class=\"meta\">No step screenshots were collected.</p>"}`;
|
|
213
|
+
}
|
|
214
|
+
function evidenceLink(directory, kane, path) {
|
|
215
|
+
if (!path || isAbsolute(path))
|
|
216
|
+
return undefined;
|
|
217
|
+
// Kane saves an absolute outDir. The claim folder and the evidence paths stay
|
|
218
|
+
// relative to the saved check so a copied run can still be opened.
|
|
219
|
+
const root = resolve(directory, "claims", basename(kane.outDir), "evidence");
|
|
220
|
+
const file = resolve(root, path);
|
|
221
|
+
const insideEvidence = relative(root, file);
|
|
222
|
+
if (!insideEvidence || insideEvidence === ".." || insideEvidence.startsWith(`..${sep}`) || !existsSync(file))
|
|
223
|
+
return undefined;
|
|
224
|
+
return relative(directory, file).split(sep).map(encodeURIComponent).join("/");
|
|
225
|
+
}
|
|
226
|
+
function escapeHtml(value) {
|
|
227
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
228
|
+
}
|
|
229
|
+
function renderBadge({ tested, verifiedPasses, verdicts }) {
|
|
230
|
+
const findings = verdicts.false + verdicts.outdated;
|
|
231
|
+
const verified = tested > 0 && verifiedPasses === tested;
|
|
232
|
+
let label = `${tested} claim${tested === 1 ? "" : "s"} tested by Kane`;
|
|
233
|
+
if (verified)
|
|
234
|
+
label = `Kane swore it's true · ${tested} tested`;
|
|
235
|
+
if (findings)
|
|
236
|
+
label = `${findings} confirmed finding${findings === 1 ? "" : "s"}`;
|
|
237
|
+
const state = findings ? "findings" : verified ? "verified" : "tested";
|
|
238
|
+
const dot = { findings: "#d9534f", verified: "#5cb37a", tested: "#c9b48a" }[state];
|
|
239
|
+
const divider = 104;
|
|
240
|
+
const labelWidth = verified ? 225 : 162;
|
|
241
|
+
const width = divider + labelWidth;
|
|
242
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="34" viewBox="0 0 ${width} 34" role="img" aria-labelledby="badge-title" data-state="${state}">
|
|
243
|
+
<title id="badge-title">fibcheck · ${escapeHtml(label)}</title>
|
|
244
|
+
<rect width="${width}" height="34" rx="6" fill="#233f33"/>
|
|
245
|
+
<path d="M${divider} 0h${labelWidth - 6}a6 6 0 0 1 6 6v22a6 6 0 0 1-6 6H${divider}Z" fill="${verified ? "#dce9dd" : "#eee5d4"}"/>
|
|
246
|
+
<circle cx="20" cy="17" r="6" fill="${dot}"/>
|
|
247
|
+
<g font-family="system-ui, sans-serif" font-size="12">
|
|
248
|
+
<text x="34" y="21" fill="#fff" font-weight="700">fibcheck</text>
|
|
249
|
+
<text x="${divider + labelWidth / 2}" y="21" fill="#233f33" text-anchor="middle">${escapeHtml(label)}</text>
|
|
250
|
+
</g>
|
|
251
|
+
</svg>
|
|
252
|
+
`;
|
|
253
|
+
return { svg, width, label };
|
|
254
|
+
}
|
|
255
|
+
const REPORT_STYLE = `
|
|
256
|
+
:root {
|
|
257
|
+
color-scheme: light;
|
|
258
|
+
background: #f5f1e9;
|
|
259
|
+
color: #24332b;
|
|
260
|
+
font: 16px/1.55 system-ui, sans-serif;
|
|
261
|
+
}
|
|
262
|
+
body { margin: 0; }
|
|
263
|
+
main { max-width: 58rem; margin: auto; padding: clamp(1.25rem, 5vw, 4.25rem); }
|
|
264
|
+
header { border-bottom: 1px solid #b9beae; padding-bottom: 1.5rem; }
|
|
265
|
+
header img { max-width: 100%; height: auto; }
|
|
266
|
+
h1, h2 { font-family: Georgia, serif; font-weight: 500; line-height: 1.13; }
|
|
267
|
+
h1 { font-size: clamp(2.6rem, 8vw, 5rem); margin: .55rem 0; overflow-wrap: anywhere; }
|
|
268
|
+
h2 { font-size: 2rem; margin: 0 0 .75rem; }
|
|
269
|
+
section { margin: 2rem 0; }
|
|
270
|
+
p { margin: .45rem 0; }
|
|
271
|
+
.meta { color: #4f5d54; font-size: .88rem; overflow-wrap: anywhere; }
|
|
272
|
+
a { color: #245544; text-underline-offset: .2em; }
|
|
273
|
+
a:focus-visible, summary:focus-visible { outline: 2px solid #245544; outline-offset: 3px; }
|
|
274
|
+
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .5rem; margin: 1rem 0; }
|
|
275
|
+
.metrics div { display: flex; flex-direction: column-reverse; padding: .65rem; background: #e9eade; }
|
|
276
|
+
.metrics dd { margin: 0; font: 1.65rem Georgia, serif; }
|
|
277
|
+
.metrics dt { font-size: .8rem; }
|
|
278
|
+
article { background: #fffdf7; border: 1px solid #d7d7c8; padding: .9rem 1.15rem; margin: .55rem 0; overflow-wrap: anywhere; }
|
|
279
|
+
.claim-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: .45rem .65rem; }
|
|
280
|
+
.status { border-radius: .25rem; padding: .08rem .45rem; background: #ece9df; font-size: .8rem; font-weight: 650; }
|
|
281
|
+
.passed { background: #dce9dd; color: #244734; }
|
|
282
|
+
.failed { background: #f4dfd7; color: #792b26; }
|
|
283
|
+
blockquote { margin: .55rem 0; padding-left: .7rem; border-left: 2px solid #acae9a; white-space: pre-wrap; }
|
|
284
|
+
details { margin-top: .55rem; font-size: .875rem; }
|
|
285
|
+
.round { margin: 1rem 0 .3rem; padding: .55rem 0 0; border-top: 1px solid #d7d7c8; }
|
|
286
|
+
.round h3 { font-size: 1rem; margin: 0; }
|
|
287
|
+
.override { border-left: 2px solid #9a6231; background: #f8eddd; padding: .45rem .65rem; }
|
|
288
|
+
summary { cursor: pointer; color: #245544; font-weight: 600; }
|
|
289
|
+
ul { margin: .45rem 0; padding-left: 1.4rem; }
|
|
290
|
+
li { margin: .25rem 0; }
|
|
291
|
+
li span { display: block; }
|
|
292
|
+
`;
|
|
293
|
+
function readingLabel({ cause, exercisedClaim }) {
|
|
294
|
+
if (cause === "unclear" && exercisedClaim)
|
|
295
|
+
return "tested the claim as written";
|
|
296
|
+
return `${escapeHtml(cause.replace(/_/g, " "))}${exercisedClaim ? "" : " · did not test the claim as written"}`;
|
|
297
|
+
}
|
package/dist/target.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
/** The .env name that holds a login value for an app that is already running, for example FIBCHECK_LOGIN_APP_PASS. */
|
|
5
|
+
export function loginEnvName(name) {
|
|
6
|
+
return `FIBCHECK_LOGIN_${name.toUpperCase()}`;
|
|
7
|
+
}
|
|
8
|
+
/** Reads the login values a login sentence refers to ({{NAME}}) from the environment. Missing values are left out. */
|
|
9
|
+
export function loginSecretsFromEnv(login, env = process.env) {
|
|
10
|
+
const names = Array.from((login ?? "").matchAll(/\{\{([A-Za-z_][A-Za-z0-9_]*)\}\}/g), (match) => match[1]);
|
|
11
|
+
return Object.fromEntries(names.flatMap((name) => {
|
|
12
|
+
const value = env[loginEnvName(name)];
|
|
13
|
+
return value ? [[name, value]] : [];
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
export function runningAppVariables(login, secrets) {
|
|
17
|
+
const names = new Set(Array.from((login ?? "").matchAll(/\{\{([A-Za-z_][A-Za-z0-9_]*)\}\}/g), (match) => match[1]));
|
|
18
|
+
return Object.fromEntries(Array.from(names, (name) => {
|
|
19
|
+
const value = Object.hasOwn(secrets, name) ? secrets[name] : undefined;
|
|
20
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
21
|
+
throw new Error(`Missing login value "${name}" for the running app. Put ${loginEnvName(name)}=... in .env.`);
|
|
22
|
+
}
|
|
23
|
+
return [name, { value, secret: true }];
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
export function targetPathFor(input) {
|
|
27
|
+
if (existsSync(input))
|
|
28
|
+
return input;
|
|
29
|
+
if (input === "sissbruecker/linkding" || isLinkdingRepo(input)) {
|
|
30
|
+
return fileURLToPath(new URL("../targets/linkding.json", import.meta.url));
|
|
31
|
+
}
|
|
32
|
+
throw new Error("No target file or bundled repository matches the input. Pass a target JSON file for a custom app.");
|
|
33
|
+
}
|
|
34
|
+
export function isLinkdingRepo(repo) {
|
|
35
|
+
if (!URL.canParse(repo))
|
|
36
|
+
return false;
|
|
37
|
+
const url = new URL(repo);
|
|
38
|
+
return url.protocol === "https:" && url.host === "github.com"
|
|
39
|
+
&& !url.username && !url.password && !url.search && !url.hash
|
|
40
|
+
&& url.pathname.replace(/\/$/, "").replace(/\.git$/, "") === "/sissbruecker/linkding";
|
|
41
|
+
}
|
|
42
|
+
export function loadTarget(path) {
|
|
43
|
+
let target;
|
|
44
|
+
try {
|
|
45
|
+
target = JSON.parse(readFileSync(path, "utf8"));
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new Error(`Could not read target ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
49
|
+
}
|
|
50
|
+
for (const key of ["name", "repo"]) {
|
|
51
|
+
if (!target[key])
|
|
52
|
+
throw new Error(`Target ${path} is missing "${key}".`);
|
|
53
|
+
}
|
|
54
|
+
if (target.app && (!target.app.image || !target.app.port || !target.app.containerPort)) {
|
|
55
|
+
throw new Error(`Target ${path} needs app.image, app.port and app.containerPort, or no app section at all for use with --url.`);
|
|
56
|
+
}
|
|
57
|
+
return target;
|
|
58
|
+
}
|
|
59
|
+
/** Fills in generated secrets for one run. */
|
|
60
|
+
export function resolveTarget(target, generate = () => `Pk${randomBytes(12).toString("hex")}`) {
|
|
61
|
+
const secrets = new Map();
|
|
62
|
+
const fill = (text) => text.replace(/\{\{secret:([A-Za-z_][A-Za-z0-9_]*)\}\}/g, (_m, name) => {
|
|
63
|
+
if (!secrets.has(name))
|
|
64
|
+
secrets.set(name, generate());
|
|
65
|
+
return secrets.get(name) ?? "";
|
|
66
|
+
});
|
|
67
|
+
const resolvedEnv = Object.fromEntries(Object.entries(target.app?.env ?? {}).map(([k, v]) => [k, fill(v)]));
|
|
68
|
+
const kaneVariables = Object.fromEntries([...secrets].map(([name, value]) => [name, { value, secret: true }]));
|
|
69
|
+
return { ...target, baseUrl: target.app ? `http://localhost:${target.app.port}` : "", resolvedEnv, kaneVariables };
|
|
70
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fibcheck",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A lie detector for READMEs and docs: checks each claim in a real browser with Kane CLI, and proves the fix.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"documentation",
|
|
7
|
+
"readme",
|
|
8
|
+
"docs",
|
|
9
|
+
"testing",
|
|
10
|
+
"browser-testing",
|
|
11
|
+
"kane-cli",
|
|
12
|
+
"github-action"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/Ololadestephen/fibcheck.git"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/Ololadestephen/fibcheck#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Ololadestephen/fibcheck/issues"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20.12"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/",
|
|
29
|
+
"targets/linkding.json"
|
|
30
|
+
],
|
|
31
|
+
"bin": {
|
|
32
|
+
"fibcheck": "dist/cli.js"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.build.json",
|
|
36
|
+
"prepack": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && npm run build",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"test": "vitest run --dir src"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.20.5",
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"vitest": "^4.1.12"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@google/genai": "^3.3.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "linkding",
|
|
3
|
+
"repo": "https://github.com/sissbruecker/linkding",
|
|
4
|
+
"docs": ["docs/src/content/docs/admin.md"],
|
|
5
|
+
"app": {
|
|
6
|
+
"image": "sissbruecker/linkding:1.47.0",
|
|
7
|
+
"port": 9090,
|
|
8
|
+
"containerPort": 9090,
|
|
9
|
+
"env": {
|
|
10
|
+
"LD_SUPERUSER_NAME": "pinotest",
|
|
11
|
+
"LD_SUPERUSER_PASSWORD": "{{secret:app_pass}}"
|
|
12
|
+
},
|
|
13
|
+
"readyPath": "/login/"
|
|
14
|
+
},
|
|
15
|
+
"startPath": "/login/",
|
|
16
|
+
"login": "If a login form is shown, log in with username pinotest and password {{app_pass}}."
|
|
17
|
+
}
|