Files
codex/codex-rs/app-server-protocol/scripts/write_schema_fixtures.py
Michael Bolin acd540f158 Precompute app-server protocol exports (#36212)
## Why

Normal app-server protocol builds do not need the `ts-rs` and `schemars`
implementations used to generate schema exports.

## What changed

- Embed compressed stable and experimental TypeScript and JSON schema exports,
  and serve the existing export APIs from those artifacts.
- Use no-op schema derives in non-test builds while keeping the real generators
  available for fixture regeneration and tests.
- Move schema fixture regeneration behind a Python helper and update
  `just write-app-server-schema --experimental` to refresh the experimental
  embedded exports.

## Testing

- Verify embedded exports match freshly generated stable and experimental
  schemas.
- Verify export options and on-disk output remain compatible.

GitOrigin-RevId: e8536338b457e6eec34bdf29ec0684144bd13734
2026-07-30 19:47:30 +00:00

62 lines
1.5 KiB
Python

#!/usr/bin/env python3
import argparse
import os
from pathlib import Path
import subprocess
def main() -> None:
parser = argparse.ArgumentParser(
description="Regenerate vendored app-server schema fixtures"
)
parser.add_argument(
"--schema-root",
type=Path,
help="root directory containing the schema fixtures",
)
parser.add_argument(
"-p",
"--prettier",
type=Path,
help="optional Prettier executable used to format TypeScript files",
)
parser.add_argument(
"--experimental",
action="store_true",
help="regenerate the precomputed experimental exports",
)
args = parser.parse_args()
workspace_root = Path(__file__).resolve().parents[2]
schema_root = args.schema_root or workspace_root / "app-server-protocol" / "schema"
env = os.environ.copy()
env["CODEX_APP_SERVER_SCHEMA_ROOT"] = str(schema_root)
env["CODEX_APP_SERVER_SCHEMA_EXPERIMENTAL"] = (
"1" if args.experimental else "0"
)
if args.prettier:
env["CODEX_APP_SERVER_SCHEMA_PRETTIER"] = str(args.prettier)
subprocess.run(
[
"cargo",
"test",
"-p",
"codex-app-server-protocol",
"--lib",
"schema_fixtures_tests::write_schema_fixtures_from_env",
"--",
"--exact",
"--ignored",
],
cwd=workspace_root,
env=env,
check=True,
)
if __name__ == "__main__":
main()