ci: isolate test setup and fix Windows PDF font paths

This commit is contained in:
amosblomqvist
2026-10-11 10:41:30 +03:00
parent e266c3c028
commit 0540bf697c
9 changed files with 32 additions and 45 deletions
+2 -9
View File
@@ -3,6 +3,7 @@ import { createRequire } from "node:module";
import * as os from "node:os";
import * as path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { standardFontsDir } from "./pdf-ops";
/**
* Verification engines for sub-agents: demos use the app's own Electron
@@ -483,9 +484,7 @@ async function renderPdfPages(
// Standard-font data as a directory path (live-smoke finding 2026-09-19:
// without it pdfjs renders non-embedded standard fonts via fallback);
// verbosity 0 = errors only (JBIG2 noise on scanned PDFs).
const standardFontDataUrl =
path.join(PATHS_nodeModules(), "pdfjs-dist", "standard_fonts") + path.sep;
const loadingTask = pdfjs.getDocument({ data, standardFontDataUrl, verbosity: 0 });
const loadingTask = pdfjs.getDocument({ data, standardFontDataUrl: standardFontsDir(), verbosity: 0 });
const doc = await loadingTask.promise;
try {
const out: RenderedPdfPage[] = [];
@@ -515,12 +514,6 @@ async function renderPdfPages(
}
}
/** node_modules — resolved from this module's location. */
function PATHS_nodeModules(): string {
// import.meta.url = .../src/agent/subagents/headless.ts → three up + node_modules
return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "node_modules");
}
// ─── the real API ────────────────────────────────────────────────────────────
export const realHeadless: HeadlessApi = {
+6 -5
View File
@@ -8,8 +8,8 @@ import { fileURLToPath } from "node:url";
* pdf_search / pdf_render), on the user-chosen hybrid stack:
*
* - TEXT (info / extract / search): pdfjs-dist — pure JS, no native deps.
* - RENDER: the shared headless-Chrome infra (subagents/headless.ts,
* puppeteer + system Chrome) screenshots pdfium-rendered pages.
* - RENDER: subagents/headless.ts uses the same pdfjs engine with
* @napi-rs/canvas (Skia), in-process — no browser needed.
*
* Doctrine (the skill's reading strategy, mirrored in the sub-agent's system
* prompt): triage with pdf_info FIRST, then size-based strategy — short PDFs
@@ -45,10 +45,11 @@ async function loadPdfjs() {
/** Standard-font data dir (live-smoke finding 2026-09-19: without it pdfjs
* warns and falls back on non-embedded standard fonts — Helvetica, Times…).
* The node side takes a plain filesystem path. Resolved from this module's
* location, the headless.ts PATHS_nodeModules idiom. */
* The node side takes a plain filesystem path, shared by text and rendering.
* pdfjs checks endsWith("/") even on Windows: use a literal trailing slash,
* NOT path.sep ("\\" on Windows). Node fs accepts this path on every OS. */
export function standardFontsDir(): string {
return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "node_modules", "pdfjs-dist", "standard_fonts") + path.sep;
return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "node_modules", "pdfjs-dist", "standard_fonts") + "/";
}
async function openDocument(filePath: string) {