Tool-callable `cwd` (equivalent of TUI `/cwd`)
- 主要语言
- Shell
- 星标
- 11.2k
- 派生
- 1.9k
- 平均合并
- 14 小时 16 分钟
- 30 天内合并 PR
- 6
描述
# Feature request: tool-callable `cwd`
## Summary
`/cwd ` already exists as a TUI command, and as a side effect it triggers a skill rescan so any `.github/skills/` under the new directory are picked up without restarting. It works great for users, but it can't be invoked by skills or the agent — there's no equivalent tool. This means workflows that change context mid-session (e.g., a skill that switches into a repo) can't programmatically move the session into the right directory or pick up the new repo's skills. The user has to remember to type the command.
Please expose `/cwd` as a tool-callable operation so skills and agents can change the session's working directory after they've decided where work should happen.
## Repro
1. From `~`, launch `copilot`.
2. A skill (or the user) decides work should happen in a different directory — for example, `Azure/azure-sdk-for-net`, which ships ~10 skills under `.github/skills/` (`pre-commit-checks`, `mgmt-review-comment-resolution`, etc.).
3. The skill has no way to move the session there. Its powershell tool `Set-Location` only changes the child-process cwd; copilot's own cwd stays at `~`. There's no tool to invoke `/cwd` either.
**Expected:** A tool the skill can call to change the session's working directory (matching `/cwd ` semantics, including the skill rescan side effect).
**Actual:** Skill must instruct the user to type the command themselves.
## Why this matters
If you work across many repos regularly, the natural workflow is to launch `copilot` once from your home directory and just say *"we need to work on issue \"* — letting the agent figure out which repo the issue belongs to, where its clone lives on disk, claim a free copy, branch, and start. Forcing the user to `cd` into the right repo *before* launching defeats this entirely (you'd have to know which repo every time, manually navigate there, and start a fresh session per repo).
A common pattern: launch `copilot` from a stable home dir and let an agent/skill route work to the right repo (e.g., we maintain a `repo-finder` skill that resolves an issue link → repo, scans `C:\git\` for a free clone, claims it, creates a branch, and starts work). Today, repo-level skills like `pre-commit-checks` silently don't run because they were never registered for this session, and the user has to know to manually run `/cwd ` before the agent does anything that depends on the missing skill.
There's no way for the skill to detect-and-fix this from inside the session.
## Proposed shape
```
cwd() # returns current cwd (matches `/cwd` with no args)
cwd(path: "...") # change cwd to path; triggers skill rescan as today
```
Treated like other state-changing tools for permissions: agent must request approval the first time, persistent thereafter.
With this, our `repo-finder` skill could simply call `cwd(path)` after picking the repo and the user wouldn't need to do anything.
## Environment
- copilot CLI: 1.0.40-0
- OS: Windows 11
贡献指南
调研方向
Start by tracing the existing `/cwd ` TUI command and its skill-rescan side effect, then inspect how state-changing tool permissions are handled. Use the proposed `cwd()` and `cwd(path)` behavior as the acceptance target, including session cwd updates, approval persistence, and skill discovery after a directory change.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- powershell, shell
- 领域
- cli
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100