feat(codex): install SessionStart graph orientation hook#207
Conversation
Add an idempotent Codex SessionStart hook upsert for ~/.codex/config.toml while preserving existing hooks and MCP config. Respect no-hooks for Codex hook installation, document the supported hook behavior, and cover fresh install, repeated install, merge, and no-hooks cases with focused tests.
| const DocsURL = "https://developers.openai.com/codex/mcp" | ||
|
|
||
| const codexSessionStartMatcher = "startup|resume|clear|compact" | ||
| const codexSessionStartMessage = "[Gortex] Prefer Gortex graph tools (search_symbols, get_callers, get_file_summary) before Read/Grep/Glob over large files." |
There was a problem hiding this comment.
I would love to get feedback from Codex users, but intuitively:
- I see zero value for duplication Gortex with
[Gortex] - I don't think
before Read/Grep/Glob over large files.will be a clear instruction:
- Why before?
- Why only large files?
| const codexSessionStartMessage = "[Gortex] Prefer Gortex graph tools (search_symbols, get_callers, get_file_summary) before Read/Grep/Glob over large files." | |
| const codexSessionStartMessage = "IMPORTANT: Prefer Gortex graph tools (search_symbols, get_callers, get_file_summary) over Read/Grep/Glob." |
One more point: tools like edit_file can be very useful to mention, too. Overall, the initial message makes sense to test.
There was a problem hiding this comment.
Yep, good point. I agree the original wording was too fuzzy: “before” made it sound like an ordering rule, and “large files” narrowed the guidance unnecessarily; I updated the message to remove the duplicate label, use “over” instead of “before”, drop the large-file qualifier, and mention edit_file as well: IMPORTANT: Prefer Gortex MCP tools (search_symbols, get_callers, get_file_summary, edit_file) over Read/Grep/Glob/Edit. This keeps the PR scoped to the lightweight SessionStart orientation hook; PreToolUse/PostToolUse behavior remains out of scope for a follow-up PR~
|
@blankanswer merged. Thank you for contribution. Follow up question if you're planning to cover other hooks, are you? |
Yep, I’m happy to continue working on the remaining Codex hook surface, but I’d prefer to split it into small follow-up PRs rather than trying to reach full Claude Code parity in one large change. My next step will be to validate the Codex PreToolUse and PostToolUse input/output contract against the current Codex CLI behavior. After that, I plan to open a lightweight PR for PreToolUse only, focused on soft nudging / additional context rather than deny or enforcement behavior. I’ll keep PostToolUse enrichment, PreCompact/Stop-style lifecycle handling if Codex supports equivalent events, and any broader hook dispatcher work as separate follow-up PRs~ |
Summary
Adds minimal Codex hook support by installing a
SessionStartorientation hook into~/.codex/config.toml.When Codex starts or resumes a session, the hook prints a short reminder to prefer Gortex graph tools before large direct file reads. This mirrors the existing agent onboarding intent without changing MCP
behavior or adding tool interception.
This intentionally keeps the first Codex hook PR small: it only covers
SessionStart, notPreToolUse/PostToolUse.Changes
SessionStarthook when hooks are enabledstartup|resume|clear|compactmcp_servers.gortexconfig--no-hooks/InstallHooks=falsefor Codex hook installationOut of scope:
PreToolUse/PostToolUsehooks--hooks-onlybeyond its current Claude Code behaviorTesting
go test ./internal/agents/...go test ./cmd/gortex/...go test -race ./internal/agents/codex ./internal/agentsgit diff --checkgo test -run '^$' -bench . ./internal/agents/...go test -race ./...)Benchmarks are not performance-relevant for this config-writing change; the scoped benchmark build passed and there are no benchmark cases in the changed agent packages.
Checklist
Meta["methods"]for interfaces (if applicable)EdgeMemberOfedges to their containing type (if applicable)Related to #206