// Adapted from ego lite (MIT): package/ego-browser/scripts/render-guide.mjs export const GUIDE_MAX_CHARS = 18_000; export const GUIDE_HEADER_PREFIX = '[browserclaw:skill] browserclaw usage guide v'; export const GUIDE_END_PREFIX = '[browserclaw:skill] end of guide v'; export function renderGuide(body: string, version: string): string { const content = body.trim(); const lines = content.split('\n').length + 4; const guide = `${GUIDE_HEADER_PREFIX}${version}\n\n${content}\n\n${GUIDE_END_PREFIX}${version} (${String(lines)} lines)\n`; if (guide.length > GUIDE_MAX_CHARS) { throw new Error( `agent guide is ${String(guide.length)} characters; the cap is ${String(GUIDE_MAX_CHARS)}. Move reference material into JSDoc (npx browserclaw help) or trim.`, ); } return guide; }