Skip to content
This repository was archived by the owner on Sep 11, 2026. It is now read-only.

feat(npm): sync Codex CLI hooks (.codex/hooks.json) - #266

Merged
vitaliytv merged 14 commits into
mainfrom
claude/7n-rules-auto-plugins-246d65
Jul 29, 2026
Merged

vitaliytv merged 14 commits into
mainfrom
claude/7n-rules-auto-plugins-246d65

Conversation

@vitaliytv

Copy link
Copy Markdown
Member

Summary

  • Adds Codex CLI as a third hook sync target alongside Claude Code and Cursor, wired into syncClaudeConfig() in npm/scripts/sync-claude-config.mjs.
  • .codex/hooks.json gets a base PostToolUse lint hook (matcher apply_patch, always synced), plus opt-in ADR Stop-hook groups (rule adr) and an rtk PreToolUse group (rule local-ai), mirroring the existing Claude/Cursor mechanics (same managed-marker merge/dedupe logic via mergeHooks).
  • npm/scripts/hook.mjs: extractFilePaths() now also parses Codex's apply_patch V4A patch format (*** Add/Update/Move to/Delete File) out of tool_input.command, in addition to Claude's tool_input.file_path.
  • New template npm/.claude-template/codex-hooks.template.json; .v8rignore entry added for it (mirrors settings.template.json's existing exemption — the repo already vendors a schema for the real .codex/hooks.json path).
  • npm/bin/n-rules-cli.mjs reports .codex/hooks.json in the sync summary.

Known risks (documented inline in code)

  • PostToolUse coverage for apply_patch is unconfirmed upstream — there's an open issue, openai/codex#16732, suggesting apply_patch may not emit PostToolUse on all Codex versions. The Stop-hook (git diff, payload-independent) remains a reliable fallback regardless.
  • async is intentionally omitted on the Codex ADR hook groups — per the vendored vendor/codex-hooks.json schema, async command handlers are "not supported yet and async handlers are skipped" in the current Codex runtime; setting async: true (as Claude/Cursor do) would silently no-op the hook.
  • rtk PreToolUse for Codex is a best guess (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 pass
  • bunx oxlint / bunx oxfmt --check on touched files — clean
  • Doc-files regenerated for hook.mjs and sync-claude-config.mjs (npx @7n/rules lint doc-files --path npm/scripts)
  • Manual verification against a real Codex CLI install (not done in this session — no Codex CLI available in the sandbox)

🤖 Generated with Claude Code

vitaliytv and others added 14 commits July 28, 2026 17:17
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>
@vitaliytv
vitaliytv merged commit f16ed4a into main Jul 29, 2026
4 checks passed
@vitaliytv
vitaliytv deleted the claude/7n-rules-auto-plugins-246d65 branch August 15, 2026 04:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant