Skip to content

feat: install codex self-serve hooks#320

Open
tumberger wants to merge 1 commit into
feat/codex-agent-adapterfrom
feat/codex-self-serve-hooks
Open

feat: install codex self-serve hooks#320
tumberger wants to merge 1 commit into
feat/codex-agent-adapterfrom
feat/codex-self-serve-hooks

Conversation

@tumberger

@tumberger tumberger commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Install and remove Codex self-serve hooks in ~/.codex/hooks.json.
  • Install only Codex-supported event keys from this stack and use Stop as turn-scoped telemetry.
  • Skip backup/write work when rerunning setup leaves the canonical Codex hooks file unchanged.

Review notes

  • Codex command hooks do not use async: true; current Codex behavior skips async handlers rather than running them in the background.
  • Codex hooks are enabled by default in current Codex releases; /hooks trust review remains the user action setup needs to call out.

Verification

  • go test ./...

tumberger commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from 8bb272c to 8814da9 Compare June 24, 2026 11:53
@tumberger tumberger force-pushed the feat/codex-self-serve-hooks branch 2 times, most recently from 3ebd4b5 to 6fd0a97 Compare June 24, 2026 13:11
@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from 8814da9 to e573160 Compare June 24, 2026 13:11
@tumberger tumberger force-pushed the feat/codex-self-serve-hooks branch from 6fd0a97 to 9455fff Compare June 24, 2026 13:47
@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from e573160 to 67914ca Compare June 24, 2026 14:26
@tumberger tumberger force-pushed the feat/codex-self-serve-hooks branch from 9455fff to 0e340bd Compare June 24, 2026 14:26
@tumberger tumberger changed the base branch from feat/codex-agent-adapter to graphite-base/320 June 24, 2026 15:40
@tumberger tumberger force-pushed the graphite-base/320 branch from 67914ca to 9bd0124 Compare June 24, 2026 15:55
@tumberger tumberger force-pushed the feat/codex-self-serve-hooks branch from 0e340bd to e4d2624 Compare June 24, 2026 15:55
@tumberger tumberger changed the base branch from graphite-base/320 to feat/codex-agent-adapter June 24, 2026 15:55
@tumberger tumberger marked this pull request as ready for review June 24, 2026 16:06
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds Codex hook management to self-serve setup. The main changes are:

  • Installs Codex hooks into ~/.codex/hooks.json.
  • Removes Codex managed hooks during uninstall.
  • Shares JSON hook-file helpers between Claude and Codex hook management.
  • Adds Codex setup, uninstall, idempotency, and validation tests.
  • Updates setup messaging for supported local agents.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the latest changed code.
  • The Codex malformed-file paths now fail earlier during setup and no longer stop later uninstall cleanup.

Important Files Changed

Filename Overview
internal/setup/setup.go Adds Codex hook preflight and install flow to setup.
internal/setup/uninstall.go Adds Codex hook cleanup while allowing later uninstall cleanup to continue after Codex hook errors.
internal/codexmanaged/hooks.go Adds Codex hook templates, validation, merge, removal, and managed-command detection.
internal/agenthooks/jsonfile.go Adds shared JSON read, write, backup, and shell quoting helpers for hook files.

Reviews (3): Last reviewed commit: "feat: install codex self-serve hooks" | Re-trigger Greptile

Comment thread internal/codexmanaged/hooks.go
Comment thread internal/setup/setup.go
Comment thread internal/setup/uninstall.go Outdated
@tumberger tumberger changed the base branch from feat/codex-agent-adapter to graphite-base/320 June 24, 2026 16:26
@tumberger tumberger force-pushed the graphite-base/320 branch from 9bd0124 to 7b65108 Compare June 24, 2026 16:26
@tumberger tumberger force-pushed the feat/codex-self-serve-hooks branch from e4d2624 to 78328dc Compare June 24, 2026 16:26
@tumberger tumberger changed the base branch from graphite-base/320 to feat/codex-agent-adapter June 24, 2026 16:26
@tumberger tumberger force-pushed the feat/codex-self-serve-hooks branch from 78328dc to 1090bca Compare June 24, 2026 16:35
@tumberger

Copy link
Copy Markdown
Contributor Author

@greptile check again

Comment thread internal/setup/setup.go

@hasandemirkiran hasandemirkiran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of my comments land here; the headline is the Codex event set, flagged inline on SupportedEvents.

Comment thread internal/codexmanaged/hooks.go
Comment thread internal/codexmanaged/hooks.go
Comment thread internal/setup/setup.go
Comment thread internal/setup/setup.go
return fmt.Errorf("install Codex hooks: %w\n\nFix or move ~/.codex/hooks.json, then rerun setup.", err)
}
fmt.Fprintf(opts.Stdout, " ✓ Codex hooks installed (%s)\n", codexHooksPath)
fmt.Fprintln(opts.Stderr, "note: Codex hooks require review before they run; open `/hooks` in Codex to trust the Kontext hooks.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call pointing them at /hooks to trust the hooks. The gap: Codex hooks are still experimental and off by default — they only run with [features] codex_hooks = true in ~/.codex/config.toml. As written, we install them and tell the user to trust them, but if that flag is not set, nothing fires and we silently do not observe Codex at all. Could we detect the flag and warn, or at least name it in this note?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in #320 PR notes: current Codex hooks are enabled by default, and codex_hooks is now a deprecated alias for disabling/enabling hooks behavior. The setup note remains focused on the action users still need after install: open /hooks and trust the Kontext hooks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for digging in on this! One thing still nags me on the default — the OpenAI hook docs read as opt-in to me: codex_hooks is deprecated in favor of [features].hooks, but hooks seem to be off by default and silent until that key is set (https://developers.openai.com/codex/hooks). If that holds, someone who runs setup and trusts the hooks via /hooks but never sets [features].hooks = true would silently go unobserved. Are you seeing them on by default in the Codex version we target? If it's still opt-in, might be worth naming [features].hooks in the note so folks aren't left uncovered without realizing it.

@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from 7b65108 to 9c59eee Compare June 25, 2026 10:03
@tumberger tumberger force-pushed the feat/codex-self-serve-hooks branch from 1090bca to 0de8a0f Compare June 25, 2026 10:03
@tumberger

Copy link
Copy Markdown
Contributor Author

@greptile review given all changes and updates and review

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