Feature: Discover custom agents from cwd, not just git root
- 主要言語
- Shell
- スター
- 11.2k
- フォーク
- 1.9k
- 平均マージ
- 14時間 16分
- マージ済み PR(30日)
- 6
説明
# Feature Request: Discover custom agents from cwd, not just git root
### Describe the feature or problem you'd like to solve
Custom agent profiles (`.github/agents/*.agent.md`) are currently only discovered at the **git repository root**. In contrast, custom instructions (`AGENTS.md`, `.github/instructions/**/*.instructions.md`) are discovered from **both** the git root and the current working directory.
This inconsistency is a problem for **monorepos and large repositories** where different subtrees represent distinct projects, each with their own specialized agents. Teams working in a subdirectory have no way to define agents scoped to their project — they must place agents at the repo root, where they're visible to (and may conflict with) every other project in the repository.
### Proposed solution
Extend agent profile discovery to mirror how custom instructions already work:
1. Search for `.github/agents/*.agent.md` in **both** the git root **and** the current working directory (or its ancestors up to the git root).
2. When agents with the same name exist at multiple levels, apply the same precedence rules already used for instructions (cwd-level overrides repo-level).
This would be consistent with how the CLI already handles:
- `AGENTS.md` → discovered in git root **and** cwd
- `.github/instructions/**/*.instructions.md` → discovered in git root **and** cwd
### Example prompts or workflows
**Scenario:** A monorepo at `~/repos/platform` with multiple projects:
```
platform/ ← git root
├── .github/agents/ ← repo-wide agents (works today)
│ └── deploy-agent.agent.md
├── frontend/
│ └── .github/agents/ ← frontend-specific agents (not discovered today)
│ └── component-gen.agent.md
└── backend/
└── .github/agents/ ← backend-specific agents (not discovered today)
└── api-scaffold.agent.md
```
**Today:** Running `copilot` from `~/repos/platform/frontend` only shows `deploy-agent`. The `component-gen` agent is invisible to `/agent`.
**Expected:** Running `copilot` from `~/repos/platform/frontend` should show both `deploy-agent` (from repo root) and `component-gen` (from cwd).
### Additional context
- The CLI help text explicitly notes that `AGENTS.md` and `.github/instructions/` are scoped to "git root & cwd" — agent profiles are the outlier.
- This would also benefit organizations that use a single repo but have multiple teams, each wanting to define team-specific agents without polluting the shared repo-root namespace.
- No existing issue appears to cover this request (searched April 2026).
コントリビューションガイド
調査の方向性
まず、AGENTS.md と .github/instructions/**/*.instructions.md の既存の検出経路を追跡し、.github/agents/*.agent.md の検出と比較します。リポジトリルートとネストされた作業ディレクトリからの動作を、同名の場合の優先順位も含めて確認します。/agent がルートのプロファイルと cwd-or-ancestor のプロファイルの両方を一覧表示し、より近いプロファイルを優先すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- git, shell
- 領域
- cli, developer-experience
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 52/100