Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

2.2 KB
Raw Blame
// reifyui/agent-chat's stylesheets, scoped under #hrui: agent-chat.css, file.css (the file card and
// the preview) and chat.css (the code block the preview highlights code in).
//
// The console's redesign resets every element under #hrui (`#hrui :where(...) { all: revert }` and
// `#hrui button {…}`, hrui.css), and an id outranks any class, so the package's own rules would lose
// to the reset everywhere. This writes the same rules with `#hrui ` in front of each selector, which
// puts them back on top. Keyframes are left as they are.
//   node scripts/scope-agent-chat-css.mjs           (writes the file)
//   node scripts/scope-agent-chat-css.mjs --check   (exits 1 when the file is not what the installed package gives)
// Run it after every reifyui bump; the jest test beside the output fails when it was not.
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import postcss from 'postcss';

const here = path.dirname(fileURLToPath(import.meta.url));
const root = path.resolve(here, '..');
const SHEETS = ['agent-chat.css', 'file.css', 'chat.css'];
const out = path.join(root, 'src/components/hrui/setup/agent-chat.scoped.css');

export function scope(css, version) {
  const ast = postcss.parse(css);
  ast.walkRules((rule) => {
    if (rule.parent && rule.parent.type === 'atrule' && /keyframes$/i.test(rule.parent.name)) return;
    rule.selectors = rule.selectors.map((s) => `#hrui ${s}`);
  });
  return ast.toString();
}

const version = JSON.parse(fs.readFileSync(path.join(root, 'node_modules/reifyui/package.json'), 'utf8')).version;
const next = `/* Generated by scripts/scope-agent-chat-css.mjs from reifyui@${version} styles/${SHEETS.join(', ')}. Do not edit. */\n`
  + SHEETS.map((f) => `\n/* ── ${f} ── */\n${scope(fs.readFileSync(path.join(root, 'node_modules/reifyui/styles', f), 'utf8'), version)}`).join('\n');
if (process.argv.includes('--check')) {
  const cur = fs.existsSync(out) ? fs.readFileSync(out, 'utf8') : '';
  if (cur !== next) { console.error(`${path.relative(root, out)} is stale: run node scripts/scope-agent-chat-css.mjs`); process.exit(1); }
} else {
  fs.writeFileSync(out, next);
  console.log(`wrote ${path.relative(root, out)} from reifyui@${version}`);
}