refactor(codex): deduplicate generated protocol schemas (#117382)

This commit is contained in:
Peter Steinberger
2026-08-01 05:32:37 -07:00
committed by GitHub
parent b830a65821
commit 8738fe1354
13 changed files with 3266 additions and 9346 deletions
+10 -3
View File
@@ -2,6 +2,7 @@
import fs from "node:fs/promises";
import path from "node:path";
import {
compactCodexAppServerProtocolJsonSchemas,
formatCodexAppServerProtocolJsonText,
generateExperimentalCodexAppServerProtocolSource,
selectedCodexAppServerJsonSchemas,
@@ -20,15 +21,21 @@ await main().catch((error: unknown) => {
async function main(): Promise<void> {
const source = await generateExperimentalCodexAppServerProtocolSource();
try {
const selectedSchemas = new Map<string, unknown>();
for (const schema of selectedCodexAppServerJsonSchemas) {
const schemaSource = await fs.readFile(path.join(source.jsonRoot, schema), "utf8");
selectedSchemas.set(schema, JSON.parse(schemaSource));
}
const compactedSchemas = compactCodexAppServerProtocolJsonSchemas(selectedSchemas);
await fs.rm(targetRoot, { recursive: true, force: true });
await fs.mkdir(targetRoot, { recursive: true });
for (const schema of selectedCodexAppServerJsonSchemas) {
for (const [schema, value] of compactedSchemas) {
await fs.mkdir(path.dirname(path.join(targetRoot, "json", schema)), { recursive: true });
const schemaSource = await fs.readFile(path.join(source.jsonRoot, schema), "utf8");
await fs.writeFile(
path.join(targetRoot, "json", schema),
formatCodexAppServerProtocolJsonText(schemaSource),
formatCodexAppServerProtocolJsonText(JSON.stringify(value)),
);
}
} finally {