Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Optional-auth MCP registry servers now install without token prompts when values are unset; `apm install` also omits empty runtime config entries and preserves user-edited optional values on reinstall; refs #20. (#1734)
- Dependencies with the same path on different git hosts no longer collide in `apm.lock.yaml`; `apm install` keeps GitHub/GitLab PATs off generic-host file downloads, routes bespoke GitLab hosts through `type: gitlab`, and surfaces non-404 download failures with host and endpoint context. Reading private files from a generic non-default host now requires a whole-repo git dependency or explicit backend signal; see the dependency and lockfile docs (closes #773). (#1735)
- GitLab `path:` files now just work on self-hosted instances where the REST API is disabled or restricted -- APM fetches via git transport automatically. `GITLAB_APM_PAT` / `GITLAB_TOKEN` remain available as a thin REST API fallback; closes #1014. (#1740)
- `apm compile --target copilot` no longer writes empty `AGENTS.md`
shell files when `.github/instructions/` already holds deployed
instructions; `--clean` also removes stale APM-generated shells while
preserving hand-authored files. Use `--no-dedup` / `--force-instructions`
to write full `AGENTS.md` files anyway. (by @tillig; closes #1730, related:
#1138, #1550) (#1742)

## [0.19.0] - 2026-06-09

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mcp: in apm.yml -> per target: .mcp.json / settings.json / equivalent

Not every target supports every primitive type. When a primitive can't land on a target, APM emits a warning at install time. Skim [Targets matrix](../reference/targets-matrix/) to set expectations before adding a primitive.

> **Deduplication**: When `.github/instructions/` already contains `.instructions.md` files (deployed by `apm install --target copilot`), `apm compile --target copilot` omits the instructions section from `AGENTS.md` to avoid Copilot reading duplicate context. When `.claude/rules/` already contains `.md` files (deployed by `apm install --target claude`), `apm compile --target claude` omits the instructions section from `CLAUDE.md` for the same reason. In both cases the root context file is still generated when it carries a constitution or dependency imports.
> **Deduplication**: When `.github/instructions/` already contains `.instructions.md` files (deployed by `apm install --target copilot`), `apm compile --target copilot` omits `AGENTS.md` entirely when its only content would be the duplicated instructions section. When `.claude/rules/` already contains `.md` files (deployed by `apm install --target claude`), `apm compile --target claude` omits the instructions section from `CLAUDE.md` for the same reason. The context file is still generated when it carries non-instruction content such as a constitution. See [Copilot deduplication](../producer/compile/#copilot-deduplication) for details.

## Common workflows

Expand Down
9 changes: 5 additions & 4 deletions docs/src/content/docs/producer/compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ do not want install's side effects.
<a id="copilot-deduplication"></a>
When `.github/instructions/` is already populated with `.instructions.md` files
(deployed by `apm install --target copilot`), `apm compile --target copilot`
automatically omits the instructions section from `AGENTS.md` to avoid
duplicate context in Copilot's context window. `AGENTS.md` is still generated
when it carries a constitution or dependency `@import` paths. If
omits `AGENTS.md` entirely when the only content it would carry is the
instructions section -- Copilot already reads `.github/instructions/` directly,
so an instructions-only `AGENTS.md` would be redundant. `AGENTS.md` is still
written when it carries non-instruction content such as a constitution. If
`.github/instructions/` is later cleared, re-running `apm compile` restores
the instructions section to `AGENTS.md`.
`AGENTS.md` with the full instructions section.

This deduplication is **target-aware**: it only activates when the sole
AGENTS.md consumer is Copilot. When compiling for targets that do not read
Expand Down
4 changes: 3 additions & 1 deletion packages/apm-guide/.apm/skills/apm-usage/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ If no `--target`, no `targets:` in `apm.yml`, and no harness signal is present,

| Command | Purpose | Key flags |
|---------|---------|-----------|
| `apm compile` | Compile agent context | `-o` output, `-t` target (comma-separated; resolution chain `--target` > apm.yml `targets:` > auto-detect), `--all` compile for every canonical target (preferred over deprecated `--target all`), `--chatmode`, `--dry-run`, `--no-links`, `--watch`, `--validate`, `--single-agents`, `-v` verbose, `--local-only`, `--clean`, `--with-constitution/--no-constitution`, `--no-dedup` / `--force-instructions` (opt out of Claude deduplication), `--root DIR` redirect generated artifacts under DIR while sources resolve from `$PWD` (mirrors `pip install --target`; not valid with `--watch`) |
| `apm compile` | Compile agent context | `-o` output, `-t` target (comma-separated; resolution chain `--target` > apm.yml `targets:` > auto-detect), `--all` compile for every canonical target (preferred over deprecated `--target all`), `--chatmode`, `--dry-run`, `--no-links`, `--watch`, `--validate`, `--single-agents`, `-v` verbose, `--local-only`, `--clean`, `--with-constitution/--no-constitution`, `--no-dedup` / `--force-instructions` (opt out of Claude/Copilot deduplication), `--root DIR` redirect generated artifacts under DIR while sources resolve from `$PWD` (mirrors `pip install --target`; not valid with `--watch`) |

`apm compile --watch` live-reloads `apm.yml`: editing `target:` / `targets:` mid-session takes effect on the next file event without restarting the watcher. The CLI `--target` flag, when passed to `apm compile --watch`, still outranks `apm.yml`. Re-resolution is gated on the changed file's basename being `apm.yml`, so `.instructions.md` edits do not pay an extra resolver round-trip and a stray `backup_apm.yml` cannot trigger a reload. `--clean` is ignored in watch mode and the watcher prints an explicit `[!]` warning at startup (`--clean is ignored in watch mode; run 'apm compile --clean' separately to remove orphaned outputs.`); run `apm compile --clean` separately between watch sessions to remove orphans.

When `apm install` has already deployed instructions to `.claude/rules/`, `apm compile --target claude` omits the Project Standards section from `CLAUDE.md` to avoid Claude Code seeing every instruction twice. Detection is a simple glob (`.claude/rules/*.md`). `CLAUDE.md` is still generated when it carries a constitution block or dependency `@import` paths -- only the instructions section is suppressed. An informational log message is emitted when zero `CLAUDE.md` files are generated because all content was already deployed via rules. Pass `--no-dedup` (alias: `--force-instructions`) to override this behaviour and always include the instructions section in `CLAUDE.md`.

When `apm install --target copilot` has already deployed instructions to `.github/instructions/`, `apm compile --target copilot` omits `AGENTS.md` entirely if its only content would be the duplicated instructions section. `AGENTS.md` is still generated when it carries non-instruction content such as a constitution. Pass `--no-dedup` (alias: `--force-instructions`) to force full `AGENTS.md` output.

## Scripts

| Command | Purpose | Key flags |
Expand Down
41 changes: 39 additions & 2 deletions src/apm_cli/compilation/agents_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,18 +485,26 @@ def _compile_distributed(
"clean_orphaned": config.clean_orphaned,
"dry_run": config.dry_run,
"skip_instructions": skip_instructions,
"with_constitution": config.with_constitution,
}

# Compile distributed
distributed_result = distributed_compiler.compile_distributed(
primitives, distributed_config
)

# Display professional compilation output (always show, not just in debug)
# Display professional compilation output (always show, not just in debug).
# Guard: when ALL placements were suppressed (skip_instructions active and
# content_map is empty), skip the placement-table formatter so the terminal
# does not print "placing N files" immediately before "AGENTS.md not generated
# (N files)" -- the two messages would be contradictory. The INFO suppression
# message below still fires unconditionally.
# Mirrors the CLAUDE.md guard: `if compilation_results and not (skip_instructions
# and files_written == 0)`.
compilation_results = distributed_compiler.get_compilation_results_for_display(
config.dry_run
)
if compilation_results:
if compilation_results and not distributed_result.all_suppressed:
if config.debug or config.trace:
# Verbose mode with mathematical analysis
output = distributed_compiler.output_formatter.format_verbose(compilation_results)
Expand All @@ -522,6 +530,35 @@ def _compile_distributed(
stats=distributed_result.stats,
)

# Emit the user-visible INFO message for suppressed empty-shell placements.
# Mirrors the CLAUDE.md analogue (agents_compiler.py:785-791).
# This fires for both normal and dry-run modes so the user understands
# why certain AGENTS.md files are absent.
# Under partial suppression (some placements written, some suppressed) the
# message clarifies that only the *suppressed* placements are absent so
# users are not confused by the AGENTS.md files that *were* written.
if distributed_result.suppressed_empty_paths:
suppressed_count = len(distributed_result.suppressed_empty_paths)
noun = "file" if suppressed_count == 1 else "files"
if distributed_result.content_map:
# Partial suppression: at least one AGENTS.md was written
self._log(
"progress",
f"Skipped {suppressed_count} empty AGENTS.md {noun} -- "
".github/instructions/ already covers Copilot; "
"pass --no-dedup to write all AGENTS.md files",
symbol="info",
)
Comment thread
tillig marked this conversation as resolved.
Resolved
else:
# Full suppression: no AGENTS.md written at all
self._log(
"progress",
f"AGENTS.md not generated ({suppressed_count} {noun}) -- "
".github/instructions/ already covers Copilot; "
"pass --no-dedup to write AGENTS.md",
symbol="info",
)

# Handle dry-run mode (preview placement without writing files)
if config.dry_run:
# Count files that would be written (directories that exist)
Expand Down
Loading
Loading