feat(codexcli): follow the SessionEnd hook, Windows command override, and MCP environment targeting - #2470
Merged
Merged
Conversation
… and MCP environment targeting
Adds the SessionEnd hook event (Codex CLI 0.145.0) and the per-hook commandWindows/statusMessage fields (0.131.0), accepts the { name, source } object form of MCP env_vars, and models experimental_environment as a codex-scoped canonical field so it reaches Codex without leaking into every other tool's MCP config.
…rections Review follow-ups: the env_vars object entry is a strict schema, since upstream denies unknown fields there and one stray key rejects the whole config.toml. The import guard now shares that schema, so a config.toml entry of some other shape is dropped with a warning instead of being written into a .rulesync/mcp.jsonc the next generate would refuse to parse. Also moves the experimentalEnvironment docs section out of the middle of the envVars one and derives the reverse scalar field map.
This was referenced Jul 29, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
Related issue: #2398
Codex CLI added a
SessionEndhook event (0.145.0, PR #33895), the per-hookcommandWindowsoverride (0.131.0, PR #22159) andstatusMessage, and per-server MCP environment targeting (0.134.0, PR #23583). Rulesync followed none of them. Each was re-verified against the hooks reference and the MCP reference before implementing — note thatdevelopers.openai.com/codex/*now 308-redirects tolearn.chatgpt.com/docs/*.Changes
hooks —
SessionEnd. Added toCODEXCLI_HOOK_EVENTSandCANONICAL_TO_CODEXCLI_EVENT_NAMES. The canonicalsessionEndevent already existed, so a.rulesync/hooks.jsoncblock that was silently dropped forcodexclinow generates, and an existing.codex/hooks.jsonimports back.hooks —
commandWindows/statusMessage.commandWindowsis new onHookDefinitionSchema;statusMessagewas already there for Qwen Code. Both are wired throughstringPassthroughFieldsforcodexcli, whose canonical union widened accordingly.commandWindowsis the material one: without it a rulesync-generated hook set cannot be made cross-platform.mcp —
env_varsobject entries.envVarsentries may now be{ name, source }as well as bare names, matching the documentedenv_vars = ["LOCAL_TOKEN", { name = "REMOTE_TOKEN", source = "remote" }]. TheisStringArrayguard incodexcli-mcp.tsis relaxed forenv_varsonly —enabled_tools/disabled_toolsstill require plain string arrays.mcp —
experimental_environment. Modelled as the codex-scoped canonicalexperimentalEnvironment, following theenvVarsprecedent: declared inMcpServerSchema, stripped inRulesyncMcp.getMcpServers(), re-added inCodexcliMcp.fromRulesyncMcp. This fixes a real leak — it previously reached.codex/config.tomlonly as unmodelled passthrough, which meant it was also copied into every other tool's MCP config. The raw snake_case spelling is stripped and re-read too, so a server config pasted out of aconfig.tomlkeeps working.Verified by hand that both directions round-trip exactly and that nothing leaks into a sibling target's config.
Not changed
Gap 5 of the issue (surface the custom-prompts deprecation) is already done:
docs/reference/file-formats.mdhas carried the "Custom prompts are deprecated. Use skills for reusable instructions" note since an earlier merge. No further action.Verification
pnpm cicheck(full: code + content)npx vitest run --config vitest.e2e.config.ts src/e2e/e2e-hooks.spec.ts src/e2e/e2e-mcp.spec.tsCloses #2398