mirror of
https://github.com/openai/codex.git
synced 2026-11-02 08:19:52 +00:00
### 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
117 lines
2.9 KiB
Rust
117 lines
2.9 KiB
Rust
use super::Feature;
|
|
use super::Features;
|
|
use tracing::info;
|
|
|
|
#[derive(Clone, Copy)]
|
|
struct Alias {
|
|
legacy_key: &'static str,
|
|
feature: Feature,
|
|
}
|
|
|
|
const ALIASES: &[Alias] = &[
|
|
Alias {
|
|
legacy_key: "enable_experimental_windows_sandbox",
|
|
feature: Feature::WindowsSandbox,
|
|
},
|
|
Alias {
|
|
legacy_key: "experimental_use_unified_exec_tool",
|
|
feature: Feature::UnifiedExec,
|
|
},
|
|
Alias {
|
|
legacy_key: "experimental_use_freeform_apply_patch",
|
|
feature: Feature::ApplyPatchFreeform,
|
|
},
|
|
Alias {
|
|
legacy_key: "include_apply_patch_tool",
|
|
feature: Feature::ApplyPatchFreeform,
|
|
},
|
|
Alias {
|
|
legacy_key: "web_search",
|
|
feature: Feature::WebSearchRequest,
|
|
},
|
|
];
|
|
|
|
pub(crate) fn legacy_feature_keys() -> impl Iterator<Item = &'static str> {
|
|
ALIASES.iter().map(|alias| alias.legacy_key)
|
|
}
|
|
|
|
pub(crate) fn feature_for_key(key: &str) -> Option<Feature> {
|
|
ALIASES
|
|
.iter()
|
|
.find(|alias| alias.legacy_key == key)
|
|
.map(|alias| {
|
|
log_alias(alias.legacy_key, alias.feature);
|
|
alias.feature
|
|
})
|
|
}
|
|
|
|
#[derive(Debug, Default)]
|
|
pub struct LegacyFeatureToggles {
|
|
pub include_apply_patch_tool: Option<bool>,
|
|
pub experimental_use_freeform_apply_patch: Option<bool>,
|
|
pub experimental_use_unified_exec_tool: Option<bool>,
|
|
pub tools_web_search: Option<bool>,
|
|
}
|
|
|
|
impl LegacyFeatureToggles {
|
|
pub fn apply(self, features: &mut Features) {
|
|
set_if_some(
|
|
features,
|
|
Feature::ApplyPatchFreeform,
|
|
self.include_apply_patch_tool,
|
|
"include_apply_patch_tool",
|
|
);
|
|
set_if_some(
|
|
features,
|
|
Feature::ApplyPatchFreeform,
|
|
self.experimental_use_freeform_apply_patch,
|
|
"experimental_use_freeform_apply_patch",
|
|
);
|
|
set_if_some(
|
|
features,
|
|
Feature::UnifiedExec,
|
|
self.experimental_use_unified_exec_tool,
|
|
"experimental_use_unified_exec_tool",
|
|
);
|
|
set_if_some(
|
|
features,
|
|
Feature::WebSearchRequest,
|
|
self.tools_web_search,
|
|
"tools.web_search",
|
|
);
|
|
}
|
|
}
|
|
|
|
fn set_if_some(
|
|
features: &mut Features,
|
|
feature: Feature,
|
|
maybe_value: Option<bool>,
|
|
alias_key: &'static str,
|
|
) {
|
|
if let Some(enabled) = maybe_value {
|
|
set_feature(features, feature, enabled);
|
|
log_alias(alias_key, feature);
|
|
features.record_legacy_usage(alias_key, feature);
|
|
}
|
|
}
|
|
|
|
fn set_feature(features: &mut Features, feature: Feature, enabled: bool) {
|
|
if enabled {
|
|
features.enable(feature);
|
|
} else {
|
|
features.disable(feature);
|
|
}
|
|
}
|
|
|
|
fn log_alias(alias: &str, feature: Feature) {
|
|
let canonical = feature.key();
|
|
if alias == canonical {
|
|
return;
|
|
}
|
|
info!(
|
|
%alias,
|
|
canonical,
|
|
"legacy feature toggle detected; prefer `[features].{canonical}`"
|
|
);
|
|
}
|