github / github/copilot-cli

Repository-level custom agents resolved relative to git root, but skills and .mcp.json relative to cwd

Đang mở
#3,688 3 bình luận 3 reaction 0 người được giao Xem trên GitHub
area:agents area:configuration
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

### Describe the bug

The three repository-scoped customization sources are discovered using two
*different* base directories:

| Source | Discovered at | Base directory |
|-------------------|------------------------------|----------------|
| Custom agents | `/.github/agents/` | **git root** |
| Skills | `/.github/skills/` | **cwd** |
| MCP servers | `/.mcp.json` | **cwd** |

Because agents are bound to the git root while skills and MCP are bound to the
current working directory, it is impossible to keep all three together in a
subdirectory of a repository. In a monorepo (or any repo where you want to keep
Copilot config in a subfolder, e.g. `agent/`), you must either:

- put `.github/agents/` at the git root (so the agent loads) — but then skills
and `.mcp.json` must ALSO be at the git root, forcing you to run from the git
root and scattering config across the tree; or
- copy the agent into the user-level `~/.copilot/agents/` directory, which is
machine-global and not committed to the repo.

There is no cwd from which a subdirectory-local agent + skills + MCP all load
together.

### Affected version

GitHub Copilot CLI 1.0.60-0 (Windows)

### Steps to reproduce the behavior

1. In a git repo, create a subdirectory `sub/` and place all three there:
- `sub/.github/agents/myagent.agent.md`
- `sub/.github/skills/myskill/SKILL.md`
- `sub/.mcp.json`
2. `cd sub` and run `copilot --agent myagent -p "..."`.
- Skills and MCP from `sub/` **do** load (cwd-relative).
- The agent does **not** load: `No such agent: myagent, available:` (empty).
3. Run the same command from the git root — the agent still does not load,
because `/.github/agents/` does not exist.
4. Move `.github/` and `.mcp.json` up to the git root and run from the git root —
now all three load. This is the only working layout, and it forces config to
the git root.

A sharper probe: with an agent at `/.github/agents/A.agent.md` AND a
different agent at `/sub/.github/agents/B.agent.md`, running from
`cwd=/sub` lists only `A` (the git-root one), never `B`. This shows the
loader goes straight to the git root rather than searching upward from cwd the
way skills do.

### Expected behavior

Custom agents should be discoverable using the same base directory as skills and
MCP (cwd, ideally searching upward toward the git root), OR there should be a
configurable `agentDirectories` setting analogous to `skillDirectories`, so that
agents + skills + MCP can be co-located in a subdirectory and loaded together.

### Additional context

- Related: #3505 (asymmetry — skills support multiple directories via
`skillDirectories`, agents do not) and #3572 (agent discovery tied to the
working directory's git remote). This report is specifically about the
**git-root vs cwd base-directory inconsistency** between agents and
skills/MCP, which neither of those covers directly.
- Our repo uses Azure DevOps for source control with config kept under a
`agent/` subfolder, which is what surfaced this.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.