opencode/packages/cli-rs/script/gen/themes.ts
Simon Klee 6b1df0cceb
feat(cli-rs): add the native CLI and TUI (#63477)
Add packages/cli-rs, an OpenCode client written in Rust on OpenTUI's Rust crates. It is a client only.
2026-11-22 00:07:01 +01:00

22 lines
1.2 KiB
TypeScript

// Writes crates/ui/src/theme/generated/themes.json: every built-in theme as the V2 document the TypeScript TUI
// resolves under the `new-designs` experiment, so the Rust resolver starts from the same documents. V1 themes are
// migrated here, once per migration: `mini` is the `migrateV1` document, as mini parses without the experiment.
import { DEFAULT_THEMES, getOpenCodeClassicTheme, getOpenCodeTheme, parseTheme } from "../../../tui/src/theme/index.ts"
const output = new URL("../../crates/ui/src/theme/generated/themes.json", import.meta.url).pathname
// The order of the theme context's list (`allThemes`): the V1 defaults, opencode, then opencode-classic.
const themes = [
...Object.entries(DEFAULT_THEMES).map(([name, source]) => ({
name,
document: parseTheme(source, name, { newDesigns: true }),
mini: parseTheme(source, name),
})),
{ name: "opencode", document: getOpenCodeTheme() },
{ name: "opencode-classic", document: getOpenCodeClassicTheme() },
]
// One theme per line keeps the committed file small and its diffs readable.
const lines = themes.map((theme) => JSON.stringify(theme)).join(",\n")
await Bun.write(output, `{"themes":[\n${lines}\n]}\n`)
console.log(`themes: wrote ${themes.length} themes to ${output}`)