Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Relax hooks.json top-level metadata validation (#30229)

charlesgong-openai2c5bc5e28440
diff --git a/codex-rs/config/src/hook_config.rs b/codex-rs/config/src/hook_config.rs
index a7ee820e60..8e18cb935a 100644
--- a/codex-rs/config/src/hook_config.rs
+++ b/codex-rs/config/src/hook_config.rs
@@ -10,6 +10,8 @@ use serde::Serialize;
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct HooksFile {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub description: Option<String>,
#[serde(default)]
pub hooks: HookEventsToml,
}
diff --git a/codex-rs/config/src/hooks_tests.rs b/codex-rs/config/src/hooks_tests.rs
index a2eb2d2322..3d51840fc2 100644
--- a/codex-rs/config/src/hooks_tests.rs
+++ b/codex-rs/config/src/hooks_tests.rs
@@ -13,6 +13,7 @@ use super::MatcherGroup;
fn hooks_file_deserializes_existing_json_shape() {
let parsed: HooksFile = serde_json::from_str(
r#"{
+ "description": "Optional stop-time review gate for Codex Companion.",
"hooks": {
"PreToolUse": [
{
@@ -35,6 +36,7 @@ fn hooks_file_deserializes_existing_json_shape() {
assert_eq!(
parsed,
HooksFile {
+ description: Some("Optional stop-time review gate for Codex Companion.".to_string()),
hooks: HookEventsToml {
pre_tool_use: vec![MatcherGroup {
matcher: Some("^Bash$".to_string()),