mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00: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:
1 parent
914c8eeb4e
commit
2c5bc5e284
2 files changed
+4
No files matched your search
@@ -10,6 +10,8 @@ use serde::Serialize;
|
|||||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct HooksFile {
|
pub struct HooksFile {
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub description: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub hooks: HookEventsToml,
|
pub hooks: HookEventsToml,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use super::MatcherGroup;
|
|||||||
fn hooks_file_deserializes_existing_json_shape() {
|
fn hooks_file_deserializes_existing_json_shape() {
|
||||||
let parsed: HooksFile = serde_json::from_str(
|
let parsed: HooksFile = serde_json::from_str(
|
||||||
r#"{
|
r#"{
|
||||||
|
"description": "Optional stop-time review gate for Codex Companion.",
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"PreToolUse": [
|
"PreToolUse": [
|
||||||
{
|
{
|
||||||
@@ -35,6 +36,7 @@ fn hooks_file_deserializes_existing_json_shape() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
parsed,
|
parsed,
|
||||||
HooksFile {
|
HooksFile {
|
||||||
|
description: Some("Optional stop-time review gate for Codex Companion.".to_string()),
|
||||||
hooks: HookEventsToml {
|
hooks: HookEventsToml {
|
||||||
pre_tool_use: vec![MatcherGroup {
|
pre_tool_use: vec![MatcherGroup {
|
||||||
matcher: Some("^Bash$".to_string()),
|
matcher: Some("^Bash$".to_string()),
|
||||||
|
|||||||
Reference in new issue
Block a user