Skip to content

apm compile --target codex --single-agents appends CLAUDE.md Preview to the generated AGENTS output #765

@OKKU-Okuda

Description

@OKKU-Okuda

Describe the bug
apm compile --target codex --single-agents creates AGENTS output, but it appends a Claude dry-run preview block to the end of the file.

Instead of producing only AGENTS content, the generated file ends with:

---
CLAUDE.md Preview: Would generate 1 files
  CLAUDE.md

This reproduces on both:

  • PyPI apm-cli 0.8.11
  • latest main source at 522c24690ea2f42aea5a2d80441c742f0a67d607

To Reproduce
Steps to reproduce the behavior:

  1. Create a minimal project with this layout:

    codex-compile-repro/
    ├─ apm.yml
    └─ packages/
       ├─ pkg-a/
       │  ├─ apm.yml
       │  └─ .apm/instructions/a.instructions.md
       └─ pkg-b/
          ├─ apm.yml
          └─ .apm/instructions/b.instructions.md
    
  2. Use this root apm.yml:

    name: codex-compile-repro
    version: 1.0.0
    dependencies:
      apm:
        - ./packages/pkg-a
        - ./packages/pkg-b
      mcp: []
    scripts: {}
  3. Put one simple instruction in each package:

    ---
    applyTo: "**"
    ---
    
    # Package A
    
    - Rule from package A.
    ---
    applyTo: "**"
    ---
    
    # Package B
    
    - Rule from package B.
  4. Run:

    apm install
    apm compile --target codex --single-agents --output codex-single.md
  5. Open codex-single.md

  6. See that the file contains AGENTS content plus an appended Claude preview block

Expected behavior

  • apm compile --target codex --single-agents should write only AGENTS content
  • Claude dry-run preview text should never be appended to the final AGENTS output

Environment (please complete the following information):

  • OS: Windows
  • Python Version: 3.14.3
  • APM Version: 0.8.11
  • VSCode Version (if relevant): N/A

Also reproduced against latest main source:

  • commit: 522c24690ea2f42aea5a2d80441c742f0a67d607

Logs
Generated codex-single.md:

# AGENTS.md
<!-- Generated by APM CLI from .apm/ primitives -->
<!-- Build ID: 765b26c69877 -->
<!-- APM Version: 0.8.11 -->

## Files matching `**`

<!-- Source: packages/pkg-a/.apm/instructions/a.instructions.md -->
# Package A

- Rule from package A.
<!-- End source: packages/pkg-a/.apm/instructions/a.instructions.md -->

<!-- Source: packages/pkg-b/.apm/instructions/b.instructions.md -->
# Package B

- Rule from package B.
<!-- End source: packages/pkg-b/.apm/instructions/b.instructions.md -->

---
*This file was generated by APM CLI. Do not edit manually.*
*To regenerate: `specify apm compile`*

---
CLAUDE.md Preview: Would generate 1 files
  CLAUDE.md

Additional context
This looks like the intermediate compile created inside the single-file CLI path is not preserving the original target.

Suspected flow:

  • the CLI enters the single-file path
  • it creates an intermediate dry-run CompilationConfig(...)
  • that intermediate config does not preserve target=config.target
  • so it falls back to the default target (all)
  • _compile_claude_md() runs in dry-run mode and returns the literal preview string CLAUDE.md Preview: Would generate ...
  • that preview text gets merged into the content that is later written as AGENTS output

This looks related to the Codex distributed compile routing issue, but the symptom and fix seem distinct enough that I split it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions