feat: Support Codex CLI as integration target#504
Merged
danielmeppiel merged 12 commits intomainfrom Mar 31, 2026
Merged
Conversation
32 tasks
Agent-Logs-Url: https://github.com/microsoft/apm/sessions/4df682f5-8518-41bb-888a-e5474153262f Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
- Add deploy_root field to PrimitiveMapping for cross-root deployments - Register Codex target in KNOWN_TARGETS with agents (.toml), skills (.agents/), hooks (.codex/hooks.json) - Update get_integration_prefixes() to include deploy_root prefixes (.agents/) - Add "codex" to --target CLI choices (install, compile, pack) - Update partition_managed_files to handle deploy_root and empty subdirs - Add _write_codex_agent() MD->TOML transformer to AgentIntegrator - Add integrate_package_hooks_codex() to HookIntegrator (Cursor-pattern merge) - Teach SkillIntegrator about deploy_root for .agents/skills/ deployment - Update all integrator sync_for_target and path computation for deploy_root - Update install.py log output for Codex hook and deploy dirs - Update uninstall engine to handle deploy_root paths Agent-Logs-Url: https://github.com/microsoft/apm/sessions/4df682f5-8518-41bb-888a-e5474153262f Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
… integrations - Update test_partition_parity_with_old_buckets to include agents_codex key - Add codex target gating regression test - Add codex partition routing and prefix security tests - Add Codex agent TOML transformation tests (frontmatter, no-frontmatter, filename) - Add Codex hook integration tests (merge, preserve user hooks, missing dir) - Add Codex skill deploy_root tests (.agents/skills/ vs .github/skills/) - Add active_targets tests for codex detection and all-five-dirs scenario Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Add documentation for the new 'codex' target across all relevant pages: - ide-tool-integration.md: Add Codex CLI section with primitives table, update hook integration list, update compile references - cli-commands.md: Add 'codex' to --target for install, compile, pack; add codex row to auto-detection and target format tables - compilation.md: Add codex to auto-detection, output files, and tool compatibility tables; update intro and compile examples - manifest-schema.md: Add 'codex' to allowed target values in both top-level and compilation.target fields - skills.md: Document .agents/skills/ deploy path for Codex - CHANGELOG.md: Add Unreleased entries for Codex CLI support Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for Codex CLI as integration target
feat: Support Codex CLI as integration target
Mar 31, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Codex CLI as a first-class APM integration target by introducing per-primitive deploy_root overrides (to support Codex's split .codex/ + .agents/ layout) and extending integrators, CLI flags, tests, and docs accordingly.
Changes:
- Introduce
PrimitiveMapping.deploy_rootand propagate “effective root” pathing through integrators, uninstall sync, and prefix validation/partitioning. - Add Codex target profile and Codex-specific integrations (MD->TOML agent transform, hooks merge into
.codex/hooks.json, skills routed to.agents/skills/). - Add Codex-related tests and update CLI/docs/changelog to surface the new target.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/apm_cli/integration/targets.py |
Adds deploy_root and registers the codex target; expands integration prefix allowlist. |
src/apm_cli/integration/base_integrator.py |
Makes managed-file partitioning deploy-root-aware (but currently misroutes some Codex paths). |
src/apm_cli/integration/agent_integrator.py |
Uses deploy-root-aware target roots; adds Codex MD->TOML agent writer. |
src/apm_cli/integration/skill_integrator.py |
Routes skills via deploy_root and extends sync cleanup to .agents/skills/. |
src/apm_cli/integration/hook_integrator.py |
Adds Codex hook merge + script copy support and sync cleanup for .codex/hooks.json. |
src/apm_cli/integration/prompt_integrator.py |
Updates sync prefix/path computation for deploy_root-aware layouts. |
src/apm_cli/integration/command_integrator.py |
Updates install + sync to use deploy_root-aware paths. |
src/apm_cli/integration/instruction_integrator.py |
Updates install + sync to use deploy_root-aware paths. |
src/apm_cli/commands/uninstall/engine.py |
Makes uninstall sync deploy-root-aware and checks for skill dirs under deploy_root. |
src/apm_cli/commands/install.py |
Adds --target codex and updates integration logging paths. |
src/apm_cli/commands/compile/cli.py |
Adds --target codex option (but underlying target detection/compiler logic is not yet updated). |
src/apm_cli/commands/pack.py |
Adds --target codex option (but pack-time target filtering/detection is not yet updated). |
tests/unit/integration/test_targets.py |
Adds Codex auto-detection tests. |
tests/unit/integration/test_agent_integrator.py |
Adds Codex agent MD->TOML transformation tests and filename expectations. |
tests/unit/integration/test_hook_integrator.py |
Adds Codex hook merge tests for .codex/hooks.json. |
tests/unit/integration/test_skill_integrator.py |
Adds tests asserting Codex skills deploy to .agents/skills/. |
tests/unit/integration/test_data_driven_dispatch.py |
Adds Codex dispatch gating + partition routing + prefix security tests. |
docs/src/content/docs/reference/manifest-schema.md |
Documents codex as a target and mentions .codex/ auto-detection. |
docs/src/content/docs/reference/cli-commands.md |
Updates CLI reference to include codex in command options. |
docs/src/content/docs/integrations/ide-tool-integration.md |
Documents Codex destinations and behavior across primitives. |
docs/src/content/docs/guides/skills.md |
Updates skills guide for Codex routing to .agents/skills/. |
docs/src/content/docs/guides/compilation.md |
Updates compilation guide to include Codex behavior. |
CHANGELOG.md |
Adds Unreleased entries for Codex support and deploy_root. |
Comments suppressed due to low confidence (1)
src/apm_cli/integration/base_integrator.py:192
- partition_managed_files() adds hook prefixes using effective_root + '/' when mapping.subdir is empty. With Codex hooks mapped as subdir="", this makes the hook prefix ".codex/", which causes all ".codex/..." paths (including ".codex/agents/") to be bucketed under "hooks". That breaks uninstall/sync for Codex agents because AgentIntegrator.sync_for_target will get an empty managed_files subset while HookIntegrator won't delete ".codex/agents/" paths. Narrow the Codex hooks routing to only ".codex/hooks/" and ".codex/hooks.json" (or change the Codex hooks mapping to avoid an empty subdir) so ".codex/agents/*" routes to the agents_codex bucket.
effective_root = mapping.deploy_root or target.root_dir
prefix = f"{effective_root}/{mapping.subdir}/" if mapping.subdir else f"{effective_root}/"
if prim_name == "skills":
skill_prefixes.append(prefix)
elif prim_name == "hooks":
hook_prefixes.append(prefix)
- Fix partition routing: check component_map before broad hook prefix matching so .codex/agents/* routes to agents_codex, not hooks - Add codex to target_detection.py: TargetType, detect_target(), should_integrate_codex(), should_compile_agents_md(), auto-detection - Add codex to lockfile_enrichment _TARGET_PREFIXES and _CROSS_TARGET_MAPS - Fix CHANGELOG entries with (#504) PR references - Gate .agents/skills/ orphan cleanup behind .codex/ existence - Replace Unicode em dash with ASCII -- in targets.py comment - Add encoding='utf-8' to test_hook_integrator.py open() call Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- README.md: add Codex CLI to tagline - index.mdx: add Codex to feature card and quick start summary - why-apm.md: move Codex from 'bridges' to 'native integration' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
78f3422 to
5b02dd9
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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 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.
Description
Codex CLI uses a multi-directory config model that breaks APM's single-
root_dirassumption: skills deploy to.agents/skills/(cross-tool agent skills standard), while agents (TOML) and hooks live under.codex/.Core abstraction:
deploy_root: Optional[str] = NoneonPrimitiveMapping. When set, overridestarget.root_dirfor path computation. DefaultNone= zero behavior change for existing targets.targets.py,base_integrator.py):deploy_rootfield, Codex inKNOWN_TARGETS,get_integration_prefixes()emits.agents/,partition_managed_files()routes cross-root pathsagent_integrator.py):_write_codex_agent()— MD→TOML viaformat_id == "codex_agent", parsing YAML frontmatter forname/description, body asdeveloper_instructionshook_integrator.py):integrate_package_hooks_codex()— Cursor-pattern merge into.codex/hooks.jsonwith_apm_sourcemarkers, scripts to.codex/hooks/{pkg}/skill_integrator.py): All skill deploy paths usemapping.deploy_root or target.root_dir— Codex skills land in.agents/skills/, others unchangedsync_for_target()and path computation updated fordeploy_root(agent, command, instruction, prompt, skill, hook)engine.py): Deploy-root-aware sync,.agents/skills/cleanup--target codexon install, compile, packType of change
Testing
16 new tests across 5 files (3197 total passing): target auto-detection (
.codex/yes,.agents/alone no), dispatch gating, partition routing, MD→TOML transform, hook merge with_apm_sourcemarkers, skill deploy_root routing, security prefix validation.