Files
can1357 5a044dc0da feat: consolidated and automate changelog management
- Added `rewrite-changelog.ts` and `fix-changelogs.ts` utilities to automate the consolidation of release notes using LLM-assisted processing.
- Updated multiple internal changelog files by consolidating redundant entries and improving phrasing for readability.
- Implemented `previewLine` utility in `coding-agent` to prevent visual spillover in status rows by managing text truncation and whitespace.
- Updated `package.json` with new workflow scripts for managing package-level change histories and documentation indexes.
2026-06-27 03:08:52 +02:00

52 lines
2.0 KiB
TypeScript
Executable File

#!/usr/bin/env bun
/**
* Bundle the shared React tool renderers + the `<omp-tool-view>` web component
* into a single self-contained script (React included, CSS inlined) for
* embedding in coding-agent HTML session exports.
*
* Output: packages/coding-agent/src/export/html/tool-views.generated.js
* Run via `bun run gen:tool-views` after changing src/tool-render/.
*/
import * as path from "node:path";
const root = path.join(import.meta.dir, "..");
const outFile = path.join(root, "../coding-agent/src/export/html/tool-views.generated.js");
const result = await Bun.build({
entrypoints: [path.join(root, "src/tool-render/standalone.tsx")],
target: "browser",
format: "iife",
minify: true,
define: { "process.env.NODE_ENV": JSON.stringify("production") },
});
if (!result.success) {
for (const log of result.logs) console.error(String(log));
process.exit(1);
}
let js = "";
let css = "";
for (const artifact of result.outputs) {
if (artifact.path.endsWith(".css")) css += await artifact.text();
else if (artifact.path.endsWith(".js")) js += await artifact.text();
}
if (!js) {
console.error("bundle produced no JS output");
process.exit(1);
}
// The bundle is inlined into a `<script>` tag by coding-agent's
// `src/export/html` `getTemplate()`; a literal `</script` inside a JS string (react-dom
// emits one) would terminate that tag early. `<\/script` is byte-identical
// to the parser inside string literals, so escape unconditionally.
const escapeInlineScript = (s: string): string => s.replaceAll("</script", "<\\/script");
const styleInject = css
? `(()=>{var s=document.createElement("style");s.dataset.ompToolViews="";s.textContent=${JSON.stringify(css.trim())};(document.head||document.documentElement).appendChild(s);})();\n`
: "";
const banner = "// Auto-generated by packages/collab-web/scripts/build-tool-views.ts - DO NOT EDIT\n";
await Bun.write(outFile, banner + escapeInlineScript(styleInject + js));
console.log(
`Generated ${path.relative(process.cwd(), outFile)} (${((banner.length + styleInject.length + js.length) / 1024).toFixed(1)} KiB)`,
);