Files
codex/codex-rs/hooks/schema/generated/post-tool-use.command.input.schema.json
T
Aismit 624fdeecee Run patch hooks for intercepted apply_patch commands (#65077)
## Why

Codex can intercept an `apply_patch` heredoc passed to `exec_command`
and apply the patch directly. That path ran shell hooks but bypassed
`apply_patch` hooks, so patch-specific rules could miss the same edit
when it was submitted through the shell tool.

## What changed

- Run `apply_patch` `PreToolUse` after shell hooks and before file
  verification. Hooks can block or rewrite the patch, and the final
  patch is checked against the selected environment's permissions.
- Report the executed patch through `apply_patch` `PostToolUse`. Link
  the patch hook events to the outer shell call with
  `parent_tool_use_id` and provide working-directory and filesystem
  metadata for hooks that inspect patch targets.
- Apply the same block and rewrite rules in recorded Guardian reviews.
  Mark those hook requests with `review_only` and review the resulting
  patch without executing it or publishing hook-provided context.

## Testing

Add coverage for hook blocks and rewrites, effective working directories,
environment permissions, and cancellation before and after a patch write.
Cover recorded reviews of rewritten patches and reviews stopped by a hook.

GitOrigin-RevId: 2115f26261a20d4a512669bc9e277a764b8f42f4
2026-12-01 20:18:13 +00:00

85 lines
2.0 KiB
JSON
Generated

{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {
"NullableString": {
"type": [
"string",
"null"
]
}
},
"properties": {
"agent_id": {
"type": "string"
},
"agent_type": {
"type": "string"
},
"cwd": {
"type": "string"
},
"hook_event_name": {
"const": "PostToolUse",
"type": "string"
},
"model": {
"type": "string"
},
"parent_tool_use_id": {
"description": "The outer shell hook's tool_use_id when Codex intercepts an apply_patch command.",
"type": "string"
},
"permission_mode": {
"enum": [
"default",
"acceptEdits",
"plan",
"dontAsk",
"bypassPermissions"
],
"type": "string"
},
"session_id": {
"type": "string"
},
"tool_input": true,
"tool_name": {
"type": "string"
},
"tool_response": true,
"tool_target_is_remote": {
"description": "True means the hook must skip local reads of the target. For apply_patch, MCP hooks receive true because their server may use a separate filesystem. False confirms a command hook shares the target filesystem. Omission leaves ownership unknown.",
"type": "boolean"
},
"tool_use_id": {
"type": "string"
},
"transcript_path": {
"$ref": "#/definitions/NullableString"
},
"turn_id": {
"description": "Codex extension: expose the active turn id to internal turn-scoped hooks.",
"type": "string"
},
"workspace_cwd": {
"description": "The hook owner's workspace directory before workdir or cd for an intercepted patch.",
"type": "string"
}
},
"required": [
"cwd",
"hook_event_name",
"model",
"permission_mode",
"session_id",
"tool_input",
"tool_name",
"tool_response",
"tool_use_id",
"transcript_path",
"turn_id"
],
"title": "post-tool-use.command.input",
"type": "object"
}