Skip to content

Agent discovery flattens directories, misclassifies non-agent .md as agents, and silently drops non-.md sibling assets #2692

Description

Summary

When installing a local plugin.json "plugin collection" whose agents/<name>/ directories contain subfolders (e.g. guides/, templates/) alongside the real agent definition files, apm install's agent-primitive discovery:

  1. Flattens every discovered .md file into a single directory (.claude/agents/ or .github/agents/), losing the original per-agent grouping.
  2. Misclassifies any non-agent .md file in a nested subfolder as a real, invokable agent (e.g. a reference guide or a data template with placeholder frontmatter gets deployed as <name>.agent.md).
  3. Silently drops every non-.md file in those same directories — scripts, binaries, images — with no warning and no equivalent output anywhere. This is the more serious issue: if an agent's own instructions reference a sibling script or asset file relative to its directory, that file is never deployed, breaking the agent.

By contrast, the Skills primitive handles this correctly: an installed skill's whole directory (scripts/, references/, templates/, evals/, binary assets, everything) is preserved intact as a bundle under .agents/skills/<name>/.... Agents get none of this — they're treated as a flat glob of individual markdown files with no bundling concept.

Environment

  • apm version: 0.28.0 (e041462)
  • OS: macOS (darwin-arm64)
  • Install path exercised: local plugin.json "plugin collection", both --target claude and --target copilot

Repro

Given a plugin with:

my-plugin/
├── .claude-plugin/plugin.json      # "agents": ["./agents/my-agent"]
└── agents/
    └── my-agent/
        ├── my-agent.md              # real agent, valid frontmatter
        ├── guides/
        │   └── reference-doc.md     # NOT an agent — has frontmatter-shaped content but no agent schema
        ├── scripts/
        │   └── helper.py            # referenced by my-agent.md's instructions
        └── templates/
            └── starter.pptx         # referenced by my-agent.md's instructions

Run:

apm install /path/to/my-plugin --target claude
# or --target copilot

Actual result

.claude/agents/ (or .github/agents/) contains:

my-agent.agent.md
reference-doc.agent.md      # <- bogus: not an agent, deployed as one anyway

helper.py and starter.pptx are absent from the entire install output — not deployed anywhere, not referenced, not warned about.

Expected result

  • Only files that are actually agent definitions (matching whatever schema/frontmatter contract APM uses to identify an agent) should be deployed as agents.
  • Non-agent files nested under an agent's directory should either (a) be preserved as sibling assets alongside the deployed agent, the way the Skills primitive already does, or (b) at minimum, be skipped with a warning rather than silently dropped or silently misclassified.

Real-world impact (concrete example)

In our plugin, agents/gen-power-point/ contains 1 orchestrator + 6 subagents (correctly discovered), plus:

  • guides/manifest-schema.md, guides/role-template-map.md, guides/template-authoring-guide.md, templates/README.md — all 4 deployed as bogus agents
  • scripts/generate_pptx.py, scripts/validate_pptx.py, and 3 other .py scripts, plus 3 real .pptx starter templates (templates/executive.pptx, templates/status-review.pptx, templates/technical-deepdive.pptx) — all silently dropped

The agent's own generation workflow depends on those scripts and .pptx templates being present relative to its own directory. After apm install, the agent is deployed but non-functional — its own required assets never shipped, with no error or warning surfaced anywhere in the install output.

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