Skip to content

feat(codex): add Bash PreToolUse graph guidance#209

Merged
zzet merged 1 commit into
zzet:mainfrom
blankanswer:feat/codex-pretooluse-bash-nudge
Jul 1, 2026
Merged

feat(codex): add Bash PreToolUse graph guidance#209
zzet merged 1 commit into
zzet:mainfrom
blankanswer:feat/codex-pretooluse-bash-nudge

Conversation

@blankanswer

@blankanswer blankanswer commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Codex-specific Bash PreToolUse hook that nudges shell search/read commands toward Gortex graph tools in soft enrich mode only.

Changes

  • Install a Codex PreToolUse hook for ^Bash$ alongside the existing SessionStart hook.
  • Route gortex hook --agent=codex through a Codex-specific dispatcher.
  • Force Codex PreToolUse handling through ModeEnrich, so it emits hookSpecificOutput.additionalContext without denying tool calls.
  • Preserve existing user Codex hooks and keep repeated installs idempotent.
  • Replace only Gortex-owned Codex hook entries under --force.
  • Document Codex SessionStart plus Bash-only soft PreToolUse behavior.

Design notes

From the Codex hook behavior spike:

  • Codex can consume hookSpecificOutput.additionalContext, so this uses the existing HookOutput JSON shape instead of plain stdout guidance.
  • The installed hook command includes --mode=enrich for readability, but Codex handling is clamped in code: RunCodex always calls runPreToolUse(..., ModeEnrich) and does not read the CLI --mode flag. This keeps Codex soft-only even if the hook command is hand-edited.
  • This PR adds only the portable command form for the Codex PreToolUse hook. Unlike SessionStart, this command just invokes gortex hook; it does not rely on POSIX-only shell text like printf. A Windows-specific command_windows override can be added later if native Windows hook behavior needs it.
  • Codex uses a dedicated dispatcher rather than extending RunExternalAgent, keeping Gemini / Antigravity lifecycle hook behavior unchanged.

Testing

  • New tests added for new functionality
  • Benchmarks run if performance-relevant (not performance-relevant)

Ran:

  • go test ./internal/agents/codex
  • go test ./internal/hooks
  • go test ./cmd/gortex
  • git diff --check

Checklist

  • Code follows existing patterns in the codebase
  • No unnecessary abstractions added
  • Language extractor includes Meta["methods"] for interfaces (if applicable)
  • Methods have EdgeMemberOf edges to their containing type (if applicable)

Related to #206

@zzet zzet merged commit aa79ad7 into zzet:main Jul 1, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants