This repository was archived by the owner on Sep 11, 2026. It is now read-only.
Repository navigation
feat(npm): sync Codex CLI hooks (.codex/hooks.json) - #266
Merged
Merged
Conversation
Adds Codex CLI as a third hook sync target alongside Claude Code and Cursor: per-file PostToolUse lint hook (matcher `apply_patch`, V4A-patch path extraction) plus opt-in ADR Stop-hooks and rtk PreToolUse group, mirroring the existing Claude/Cursor mechanics in sync-claude-config.mjs. Known risks documented inline: Codex's apply_patch PostToolUse coverage is unconfirmed upstream (openai/codex#16732), and the rtk PreToolUse subcommand for Codex is a best-guess (rtk's actual Codex integration is AGENTS.md-based, not hook-rewrite-based). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
bun.lock was out of sync with workspace package.json versions (pre-existing drift, unrelated to the Codex hooks change) — CI's bun install --frozen-lockfile failed on this PR because of it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Main advanced past this branch's base with a release commit (llm-lib 2.12.0, rules 1.53.0, plugin version bumps) — GitHub's PR merge-preview checkout combines that with this branch, so bun.lock needs to match the merged package.json state, not just the branch tip. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
syncClaudeConfig()innpm/scripts/sync-claude-config.mjs..codex/hooks.jsongets a base PostToolUse lint hook (matcherapply_patch, always synced), plus opt-in ADR Stop-hook groups (ruleadr) and an rtk PreToolUse group (rulelocal-ai), mirroring the existing Claude/Cursor mechanics (same managed-marker merge/dedupe logic viamergeHooks).npm/scripts/hook.mjs:extractFilePaths()now also parses Codex'sapply_patchV4A patch format (*** Add/Update/Move to/Delete File) out oftool_input.command, in addition to Claude'stool_input.file_path.npm/.claude-template/codex-hooks.template.json;.v8rignoreentry added for it (mirrorssettings.template.json's existing exemption — the repo already vendors a schema for the real.codex/hooks.jsonpath).npm/bin/n-rules-cli.mjsreports.codex/hooks.jsonin the sync summary.Known risks (documented inline in code)
apply_patchis unconfirmed upstream — there's an open issue, openai/codex#16732, suggestingapply_patchmay not emit PostToolUse on all Codex versions. The Stop-hook (git diff, payload-independent) remains a reliable fallback regardless.asyncis intentionally omitted on the Codex ADR hook groups — per the vendoredvendor/codex-hooks.jsonschema, async command handlers are "not supported yet and async handlers are skipped" in the current Codex runtime; settingasync: true(as Claude/Cursor do) would silently no-op the hook.rtk hook codex, unverified subcommand) — rtk's actual Codex integration is AGENTS.md-instruction-based ( feat(init): add Codex CLI support via AGENTS.md + RTK.md workflow rtk-ai/rtk#377), not a programmatic PreToolUse rewrite like Claude/Cursor. If the subcommand doesn't exist, rtk's own nonzero exit could block the tool call (no fail-open guard for that specific case, only for "rtk not installed").Test plan
bunx vitest run scripts/tests/hook.test.mjs scripts/tests/sync-claude-config.test.mjs bin/tests/n-rules-cli.test.mjs— 87 tests passbunx oxlint/bunx oxfmt --checkon touched files — cleanhook.mjsandsync-claude-config.mjs(npx @7n/rules lint doc-files --path npm/scripts)🤖 Generated with Claude Code