mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
parity/oracle/F.5-config.ts drives the real jsonc-parser, Effect decoder, Config layer, migration, model.json repository, storage, and JSONL parsers. config_interop.rs compares 293 JSONC cases, 46 decode and 20 resolve cases, the V1 migration, and byte-equal files over seven cli.json scenarios with TS-only, Rust-only, and alternating clients; TS also waits on the Rust locks. Fixes the array removal edge the corpus found and records the remaining edge cases as deviations.
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
// Writes crates/local/src/generated/config.rs: the keybind names `cli.json` accepts, in definition order (the
|
|
// order Effect Schema decodes them in), and the V1 names and command map the V1 migration reads.
|
|
import { Definitions } from "../../../tui/src/config/keybind"
|
|
import { TuiKeybind } from "../../../tui/src/config/v1/keybind"
|
|
|
|
const list = (name: string, doc: string, values: string[]) => [
|
|
`/// ${doc}`,
|
|
`pub const ${name}: &[&str] = &[`,
|
|
...values.map((value) => ` ${JSON.stringify(value)},`),
|
|
"];",
|
|
"",
|
|
]
|
|
const commands = Object.entries(TuiKeybind.CommandMap)
|
|
const lines = [
|
|
"// Generated by script/gen/config.ts from packages/tui/src/config/keybind.ts and v1/keybind.ts. Do not edit.",
|
|
"",
|
|
...list("KEYBIND_NAMES", "Keybind names of `cli.json`, in definition order.", Object.keys(Definitions)),
|
|
...list(
|
|
"V1_KEYBIND_NAMES",
|
|
"Keybind names of the V1 `tui.json`, in definition order.",
|
|
Object.keys(TuiKeybind.Definitions),
|
|
),
|
|
"/// The V1 `CommandMap`: legacy keybind name to the current name.",
|
|
"pub const V1_COMMAND_MAP: &[(&str, &str)] = &[",
|
|
...commands.map(([from, to]) => ` (${JSON.stringify(from)}, ${JSON.stringify(to)}),`),
|
|
"];",
|
|
"",
|
|
]
|
|
|
|
const file = new URL("../../crates/local/src/generated/config.rs", import.meta.url).pathname
|
|
await Bun.write(file, lines.join("\n"))
|
|
console.log(
|
|
`config: ${Object.keys(Definitions).length} keybinds, ${Object.keys(TuiKeybind.Definitions).length} V1 keybinds, ${commands.length} V1 commands`,
|
|
)
|