bun-runnable TypeScript script (codegen/generate.ts) that:
- Validates each schemas/modes/*.json against the meta-schema via
ajv (Draft 2020-12).
- Cross-checks params.length == ml.output_size and
ml.input_channels.length == ml.input_size.
- Emits constexpr C++ data into nisps/modes/generated/ (one
schema_types.hpp + one <mode_id>_schema.hpp per mode). Uses
std::string_view + std::array; no std::vector, no heap, .f
suffixed float literals (perf contract §3.3).
- Emits TS modules into playground/src/modes/generated/ (one
types.ts + one <mode_id>_schema.ts + index.ts barrel).
- Idempotent: re-running yields byte-identical output.
- Exits non-zero on schema validation failure.
Reference templates live in codegen/templates/ (not consumed at
codegen time -- for human reviewers).
Golden test (codegen/tests/golden_test.ts) snapshots
paf_synth_schema.{hpp,ts} and verifies regeneration matches the
golden + that a second run is idempotent.
Until stream 1 lands nisps/core/math.hpp, schema_types.hpp ships
its own minimal Curve enum with a TODO marker pointing at the
eventual include.
19 lines
438 B
JSON
19 lines
438 B
JSON
{
|
|
"name": "memlnaut-codegen",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"description": "Codegen for MEMLNaut mode schemas (JSON -> C++ + TypeScript).",
|
|
"type": "module",
|
|
"scripts": {
|
|
"generate": "bun run generate.ts",
|
|
"test": "bun run tests/golden_test.ts"
|
|
},
|
|
"dependencies": {
|
|
"ajv": "^8.17.1",
|
|
"ajv-formats": "^3.0.1"
|
|
},
|
|
"devDependencies": {
|
|
"typescript": "^5.6.3",
|
|
"@types/node": "^22.9.0"
|
|
}
|
|
}
|