Skip to content

Commit 40e2405

Browse files
authored
add generated jsonschema for config.toml (#8956)
### What Add JSON Schema generation for `config.toml`, with checked‑in `docs/config.schema.json`. We can move the schema elsewhere if preferred (and host it if there's demand). Add fixture test to prevent drift and `just write-config-schema` to regenerate on schema changes. Generate MCP config schema from `RawMcpServerConfig` instead of `McpServerConfig` because that is the runtime type used for deserialization. Populate feature flag values into generated schema so they can be autocompleted. ### Tests Added tests + regenerate script to prevent drift. Tested autocompletions using generated jsonschema locally with Even Better TOML. https://github.com/user-attachments/assets/5aa7cd39-520c-4a63-96fb-63798183d0bc
1 parent fe03320 commit 40e2405

File tree

20 files changed

+1757
-83
lines changed

20 files changed

+1757
-83
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ In the codex-rs folder where the rust code lives:
1313
- Use method references over closures when possible per https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
1414
- When writing tests, prefer comparing the equality of entire objects over fields one by one.
1515
- When making a change that adds or changes an API, ensure that the documentation in the `docs/` folder is up to date if applicable.
16+
- If you change `ConfigToml` or nested config types, run `just write-config-schema` to update `codex-rs/core/config.schema.json`.
1617

1718
Run `just fmt` (in `codex-rs` directory) automatically after making Rust code changes; do not ask for approval to run it. Before finalizing a change to `codex-rs`, run `just fix -p <project>` (in `codex-rs` directory) to fix any linter issues in the code. Prefer scoping with `-p` to avoid slow workspace‑wide Clippy builds; only run `just fix` without `-p` if you changed shared crates. Additionally, run the tests:
1819

MODULE.bazel.lock

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/core/BUILD.bazel

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ codex_rust_crate(
2020
"//codex-rs/apply-patch:apply_patch_tool_instructions.md",
2121
"prompt.md",
2222
],
23-
# This is a bit of a hack, but empirically, some of our integration tests
24-
# are relying on the presence of this file as a repo root marker. When
25-
# running tests locally, this "just works," but in remote execution,
26-
# the working directory is different and so the file is not found unless it
27-
# is explicitly added as test data.
28-
#
29-
# TODO(aibrahim): Update the tests so that `just bazel-remote-test` succeeds
30-
# without this workaround.
31-
test_data_extra = ["//:AGENTS.md"],
23+
test_data_extra = [
24+
"config.schema.json",
25+
# This is a bit of a hack, but empirically, some of our integration tests
26+
# are relying on the presence of this file as a repo root marker. When
27+
# running tests locally, this "just works," but in remote execution,
28+
# the working directory is different and so the file is not found unless it
29+
# is explicitly added as test data.
30+
#
31+
# TODO(aibrahim): Update the tests so that `just bazel-remote-test`
32+
# succeeds without this workaround.
33+
"//:AGENTS.md",
34+
],
3235
integration_deps_extra = ["//codex-rs/core/tests/common:common"],
3336
test_tags = ["no-sandbox"],
3437
extra_binaries = [

codex-rs/core/Cargo.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ doctest = false
99
name = "codex_core"
1010
path = "src/lib.rs"
1111

12+
[[bin]]
13+
name = "codex-write-config-schema"
14+
path = "src/bin/config_schema.rs"
15+
1216
[lints]
1317
workspace = true
1418

1519
[dependencies]
1620
anyhow = { workspace = true }
21+
arc-swap = "1.7.1"
1722
async-channel = { workspace = true }
1823
async-trait = { workspace = true }
19-
arc-swap = "1.7.1"
2024
base64 = { workspace = true }
2125
chardetng = { workspace = true }
2226
chrono = { workspace = true, features = ["serde"] }
27+
clap = { workspace = true, features = ["derive"] }
2328
codex-api = { workspace = true }
2429
codex-app-server-protocol = { workspace = true }
2530
codex-apply-patch = { workspace = true }
@@ -45,8 +50,8 @@ eventsource-stream = { workspace = true }
4550
futures = { workspace = true }
4651
http = { workspace = true }
4752
include_dir = { workspace = true }
48-
indoc = { workspace = true }
4953
indexmap = { workspace = true }
54+
indoc = { workspace = true }
5055
keyring = { workspace = true, features = ["crypto-rust"] }
5156
libc = { workspace = true }
5257
mcp-types = { workspace = true }
@@ -56,6 +61,7 @@ rand = { workspace = true }
5661
regex = { workspace = true }
5762
regex-lite = { workspace = true }
5863
reqwest = { workspace = true, features = ["json", "stream"] }
64+
schemars = { workspace = true }
5965
serde = { workspace = true, features = ["derive"] }
6066
serde_json = { workspace = true }
6167
serde_yaml = { workspace = true }
@@ -123,8 +129,12 @@ keyring = { workspace = true, features = ["sync-secret-service"] }
123129
assert_cmd = { workspace = true }
124130
assert_matches = { workspace = true }
125131
codex-arg0 = { workspace = true }
126-
codex-core = { path = ".", default-features = false, features = ["deterministic_process_ids"] }
127-
codex-otel = { workspace = true, features = ["disable-default-metrics-exporter"] }
132+
codex-core = { path = ".", default-features = false, features = [
133+
"deterministic_process_ids",
134+
] }
135+
codex-otel = { workspace = true, features = [
136+
"disable-default-metrics-exporter",
137+
] }
128138
codex-utils-cargo-bin = { workspace = true }
129139
core_test_support = { workspace = true }
130140
ctor = { workspace = true }

0 commit comments

Comments
 (0)