repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix(diff-review): use content hashes for bundle freshness

26bc699537b17bee36a6903d5d37d8792b172cf1

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

pi/agent/extensions/diff-review/bundle.ts

Modified
1 1 import { createHash } from "node:crypto";
2 -import { existsSync, statSync } from "node:fs";
2 +import { existsSync } from "node:fs";
3 3 import { readdir, readFile } from "node:fs/promises";
4 4 import { dirname, join, relative } from "node:path";
5 5 import { fileURLToPath } from "node:url";
34 34 const manifestPath = join(STATIC_DIR, "manifest.json");
35 35 if (!existsSync(index) || !existsSync(app) || !existsSync(manifestPath)) return "Browser bundle missing";
36 36 try {
37 - const manifest = JSON.parse(await readFile(manifestPath, "utf8")) as { sources?: Record<string, { sha256: string; mtimeMs: number }> };
37 + const manifest = JSON.parse(await readFile(manifestPath, "utf8")) as { sources?: Record<string, { sha256: string }> };
38 38 const current = await sourceManifest();
39 39 for (const [path, entry] of Object.entries(current)) {
40 40 const existing = manifest.sources?.[path];
41 - if (!existing || existing.sha256 !== entry.sha256 || existing.mtimeMs !== entry.mtimeMs) return "Browser bundle stale";
41 + if (!existing || existing.sha256 !== entry.sha256) return "Browser bundle stale";
43 43 return undefined;
44 44 } catch {
49 49 export async function sourceManifest() {
50 50 const files = await listFiles(BROWSER_DIR);
51 - const sources: Record<string, { sha256: string; mtimeMs: number }> = {};
51 + const sources: Record<string, { sha256: string }> = {};
52 52 for (const file of files) {
53 53 const data = await readFile(file);
54 54 const rel = relative(EXT_DIR, file);
55 - sources[rel] = { sha256: createHash("sha256").update(data).digest("hex"), mtimeMs: statSync(file).mtimeMs };
55 + sources[rel] = { sha256: createHash("sha256").update(data).digest("hex") };
57 57 return sources;

pi/agent/extensions/diff-review/scripts/build-browser.ts

Modified
45 45 await writeFile(join(STATIC_DIR, "manifest.json"), JSON.stringify({
46 - builtAt: new Date().toISOString(),
47 46 bunVersion: Bun.version,
48 47 packageVersions: {
49 48 "@pierre/diffs": pkg.dependencies["@pierre/diffs"],

pi/agent/extensions/diff-review/static/manifest.json

Modified
2 - "builtAt": "2026-05-19T00:39:16.565Z",
3 2 "bunVersion": "1.3.13",
4 3 "packageVersions": {
5 4 "@pierre/diffs": "^1.1.22",
8 7 "sources": {
9 8 "browser/assets/JetBrainsMonoNuguCode.woff2": {
10 - "sha256": "dc73d827bd8ee4b269745ea7ed084335e492d29f79c688db92e380dcb9c30bae",
11 - "mtimeMs": 1779149274834.4478
9 + "sha256": "dc73d827bd8ee4b269745ea7ed084335e492d29f79c688db92e380dcb9c30bae"
13 11 "browser/index.html": {
14 - "sha256": "fd612bc0636ac42caabe4a53dc9d6d3240bb8e6f2ef7baacac1dce8cfc9a44ea",
15 - "mtimeMs": 1779150578331.1995
12 + "sha256": "fd612bc0636ac42caabe4a53dc9d6d3240bb8e6f2ef7baacac1dce8cfc9a44ea"
17 14 "browser/index.ts": {
18 - "sha256": "b916145303a601d5b4f2b80aa679c3cca07154907718f3f4d225835fafa3bdbd",
19 - "mtimeMs": 1779150682742.9077
15 + "sha256": "b916145303a601d5b4f2b80aa679c3cca07154907718f3f4d225835fafa3bdbd"
21 17 "browser/style.css": {
22 - "sha256": "6097978399286d3eee84f6326586f834f725b5884e1f5f72503ebdcc6a943ab3",
23 - "mtimeMs": 1779150648674.6768
18 + "sha256": "6097978399286d3eee84f6326586f834f725b5884e1f5f72503ebdcc6a943ab3"