feat(vfox): pass tool options to EnvKeys hook#7447
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enables vfox plugins to access tool options in their EnvKeys hook by adding an options parameter to EnvKeysContext. This allows plugins like vfox-poetry to implement exec-env style functionality, such as auto-activating virtualenvs based on configuration options.
Key Changes:
- Added generic
optionsparameter toEnvKeysContextand related methods - Updated
env_keysmethod signature to accept serializable options - Modified test to pass empty options object
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/backend/vfox.rs | Extracts tool options from request and passes them to env_keys call |
| crates/vfox/src/vfox.rs | Adds generic options parameter to env_keys method signature and updates test |
| crates/vfox/src/hooks/env_keys.rs | Adds generic options field to EnvKeysContext and serializes it to Lua table |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub async fn env_keys<T: serde::Serialize>( | ||
| &self, | ||
| sdk: &str, | ||
| version: &str, | ||
| options: T, | ||
| ) -> Result<Vec<EnvKey>> { |
There was a problem hiding this comment.
The generic parameter T should have a Clone bound in addition to serde::Serialize. The options parameter is moved into EnvKeysContext on line 218, but if this method is called multiple times or if the SDK implementation needs to clone the options internally, this will fail to compile.
| pub async fn env_keys<T: serde::Serialize>( | ||
| &self, | ||
| ctx: EnvKeysContext<T>, | ||
| ) -> Result<Vec<EnvKey>> { |
There was a problem hiding this comment.
The generic parameter T should have a Clone bound in addition to serde::Serialize. This matches the constraint needed in the parent method and ensures the context can be cloned if needed by plugin implementations.
Add options parameter to EnvKeysContext so vfox plugins can access tool options like pyproject in their EnvKeys hook. This enables exec-env style functionality for vfox plugins.
352f51b to
2ce506e
Compare
The previous implementation used only `tv.to_string()` as the cache
key, which doesn't include tool options. This caused stale cached
results when options changed (e.g., changing pyproject path) without
a version change.
Now the cache key includes a hash of the options for both:
- In-memory cache: `{tool_version}:{opts_hash}`
- Disk cache: `exec_env_{opts_hash}.msgpack.z`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.12 x -- echo |
16.4 ± 2.2 | 15.0 | 30.8 | 1.01 ± 0.14 |
mise x -- echo |
16.2 ± 0.4 | 15.4 | 17.7 | 1.00 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.12 env |
15.4 ± 0.5 | 14.8 | 20.9 | 1.00 |
mise env |
15.8 ± 0.5 | 14.6 | 20.2 | 1.02 ± 0.05 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.12 hook-env |
15.5 ± 0.6 | 14.6 | 23.4 | 1.00 |
mise hook-env |
15.8 ± 0.4 | 14.9 | 17.4 | 1.02 ± 0.05 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.12 ls |
14.1 ± 0.3 | 13.3 | 15.2 | 1.00 |
mise ls |
14.9 ± 0.5 | 13.9 | 19.6 | 1.06 ± 0.04 |
xtasks/test/perf
| Command | mise-2025.12.12 | mise | Variance |
|---|---|---|---|
| install (cached) | 82ms | 83ms | -1% |
| ls (cached) | 54ms | 54ms | +0% |
| bin-paths (cached) | 57ms | 57ms | +0% |
| task-ls (cached) | 2212ms | ✅ 229ms | +865% |
✅ Performance improvement: task-ls cached is 865%
Summary
Add
optionsparameter toEnvKeysContextso vfox plugins can access tool options likepyprojectin theirEnvKeyshook. This enables exec-env style functionality for vfox plugins.This change allows the vfox-poetry plugin to access the
pyprojectoption to enable virtualenv auto-activation:The options are now available in the Lua hook as
ctx.options:Test plan
e2e/env/test_poetry_path_slow- passes with virtualenv activation working🤖 Generated with Claude Code
Note
Plumbs serialized tool options into the
EnvKeyshook and updates backend exec-env caching and calls to vary by options.EnvKeysContextgeneric (EnvKeysContext<T: Serialize>) and addoptions.optionsinto Lua (ctx.options) viaLuaSerdeExt; updatePlugin::env_keysto accept generic context.Vfox::env_keysnow accepts anoptionsparam (genericSerialize) and passes it to plugins.vfox.env_keys(pathname, version, &opts.opts).env_keysCLI and tests to pass an empty options object.Written by Cursor Bugbot for commit 12a6572. This will update automatically on new commits. Configure here.