mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Relax hooks.json top-level metadata validation (#30229)
## Summary - Allow a top-level `description` string in `hooks.json`. - Continue rejecting unknown top-level keys and root-level hook events; events must remain under `hooks`. ## Testing - `just test -p codex-config`
This commit is contained in:
committed by
GitHub
Unverified
parent
914c8eeb4e
commit
2c5bc5e284
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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()),
|
||||
|
||||
Reference in New Issue
Block a user