Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

1.9 KB
Raw Blame
// LHCI 0.15.1 still calls safeLoad(), which js-yaml 4 renamed to load().
// Upgrade the parser to remove its argparse 1 / sprintf-js dependency, then
// adapt this single call in the installed, pinned upstream package. Keeping
// the normal CLI entrypoint also covers autorun's child processes.
// Remove this patch when an upstream LHCI release supports js-yaml 4.
import { createHash } from 'node:crypto';
import { readFileSync, writeFileSync } from 'node:fs';
import { createRequire } from 'node:module';

const ORIGINAL_SHA256 = '904e3eb32708ed0171dc17b1d11e0bebfd76765bd310af2060dc1b50d2f033fc';
const PATCHED_SHA256 = '3f3bbc4e2b2f1b7b22ff2b8ed013322f3b7b5bfb7cf296fbb7605a6570b6e493';

function patchInstalledLhci() {
  const require = createRequire(import.meta.url);
  const cliRequire = createRequire(require.resolve('@lhci/cli/package.json'));
  const utilsRequire = createRequire(cliRequire.resolve('@lhci/utils/package.json'));
  if (cliRequire('./package.json').version !== '0.15.1' ||
      utilsRequire('./package.json').version !== '0.15.1' ||
      !utilsRequire('js-yaml/package.json').version.startsWith('4.')) {
    throw new Error('Review the LHCI YAML compatibility patch before changing tool versions');
  }

  const filename = utilsRequire.resolve('./src/lighthouserc.js');
  const source = readFileSync(filename, 'utf8');
  const digest = createHash('sha256').update(source).digest('hex');
  if (digest === PATCHED_SHA256) return;
  if (digest !== ORIGINAL_SHA256) {
    throw new Error('Unexpected LHCI configuration loader; refusing to patch unknown source');
  }

  writeFileSync(filename, source.replace('return yaml.safeLoad(contents);', 'return yaml.load(contents);'));
}

// Lockfile-only updates do not install a dependency tree. npm ci applies the
// patch later, including in the automated dependency-update workflow.
if (process.env.npm_config_package_lock_only !== 'true') patchInstalledLhci();