Add per-session env overrides for built-in shell tool child processes
- 主要语言
- Java
- 星标
- 10.5k
- 派生
- 1.5k
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 128
描述
Follow up to #1911. The `initScripts` half of that ask shipped through the runtime in github/copilot-agent-runtime#12710, but the per-session `env` part was deferred out of that PR.
Context: https://github.com/microsoft/vscode/issues/323164
`initScripts` covers the Python activation case since the host can materialize a shell-specific activation file and have the runtime source it before each command. An explicit env map is still worth having for hosts that just want to set or unset a few variables without generating script files, and without dealing with per-shell quoting.
Current wire shape:
```ts
export interface ShellOptions {
initProfile?: "none" | "non-interactive";
initScripts?: ShellInitScript[];
processFlags?: string[];
}
```
Add the `env` map from the original proposal:
```ts
export interface ShellOptions {
/** Env applied to built-in shell tool child processes. `null` unsets/removes. */
env?: Record;
}
```
The reason this was deferred is that the update semantics should be pinned down before the wire shape ships:
- Whether `session.rpc.options.update` with `shell.env` replaces the whole overlay or merges per key. Replace seems right: it stays idempotent and a host can revert a variable to the inherited value by omitting it. With merge there is no way to un-touch a variable once set.
- Precedence: overlay applied to the spawned process env first, `initScripts` sourced after, so scripts can override.
- `null` meaning remove-from-env vs revert-to-inherited.
- Whether the overlay persists across resume or the host re-sends it, matching how the rest of `shell` behaves today.
(generated by copilot)
贡献指南
调研方向
首先跟踪 issue 中描述的 ShellOptions wire 结构以及 session.rpc.options.update 的处理方式。检查 shell 和 initScripts 在更新和恢复过程中如何运行,然后明确替换、优先级、通过 null 删除以及持久化的语义;当 env overlay 能够一致地表示并应用于内置 shell 的子进程时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- shell, typescript
- 领域
- api, cli
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100