Custom cwd not honored by built-in tools after ctx.cwd change - restore via opt-in customCwd
What do you want to change?
PR #8627 changed the built-in tools in packages/coding-agent (read, write, edit, grep, find, ls, bash, powershell) to prefer ctx.cwd from ExtensionContext over the cwd captured at tool creation time. Restore backward compatibility: when a consumer explicitly creates tools with a custom cwd, that value must take precedence over ctx.cwd.
Why?
The change broke existing consumers. Extensions that construct the built-in tools with an explicit cwd (e.g. per-workspace or per-project instances) now have that value silently ignored in favor of the session's ExtensionContext.cwd. This was reported in https://github.com/earendil-works/pi/pull/8627#issuecomment-5580874018.
How? (optional)
Rename the tool-construction parameter from cwd to customCwd to make the intent explicit, and change the resolution logic so that:
- If
customCwdis provided, it is always used (opt-out of the new behavior, restores backward compatibility). - Otherwise, fall back to
ctx.cwdfromExtensionContext(the fix introduced in #8627). - Fall back to
process.cwd()when neither is available.
PR: #9483
Source: earendil-works/pi