Skip to content

feat(vfox): pass tool options to EnvKeys hook#7447

Merged
jdx merged 3 commits intomainfrom
feat/vfox-env-keys-options
Dec 19, 2025
Merged

feat(vfox): pass tool options to EnvKeys hook#7447
jdx merged 3 commits intomainfrom
feat/vfox-env-keys-options

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Dec 19, 2025

Summary

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.

This change allows the vfox-poetry plugin to access the pyproject option to enable virtualenv auto-activation:

[tools]
poetry = {version="1.8", pyproject="pyproject.toml"}

The options are now available in the Lua hook as ctx.options:

local pyproject = ctx.options and ctx.options.pyproject

Test plan

  • Run e2e/env/test_poetry_path_slow - passes with virtualenv activation working

🤖 Generated with Claude Code


Note

Plumbs serialized tool options into the EnvKeys hook and updates backend exec-env caching and calls to vary by options.

  • Hooks/API:
    • Make EnvKeysContext generic (EnvKeysContext<T: Serialize>) and add options.
    • Serialize options into Lua (ctx.options) via LuaSerdeExt; update Plugin::env_keys to accept generic context.
  • Vfox core:
    • Vfox::env_keys now accepts an options param (generic Serialize) and passes it to plugins.
  • Backend:
    • Include tool options in exec-env cache key and filename; call vfox.env_keys(pathname, version, &opts.opts).
  • CLI/Tests:
    • Update env_keys CLI and tests to pass an empty options object.

Written by Cursor Bugbot for commit 12a6572. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings December 19, 2025 04:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 options parameter to EnvKeysContext and related methods
  • Updated env_keys method 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.

Comment on lines +200 to +205
pub async fn env_keys<T: serde::Serialize>(
&self,
sdk: &str,
version: &str,
options: T,
) -> Result<Vec<EnvKey>> {
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +30
pub async fn env_keys<T: serde::Serialize>(
&self,
ctx: EnvKeysContext<T>,
) -> Result<Vec<EnvKey>> {
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.
@jdx jdx force-pushed the feat/vfox-env-keys-options branch from 352f51b to 2ce506e Compare December 19, 2025 04:58
@jdx jdx enabled auto-merge (squash) December 19, 2025 05:00
@jdx jdx disabled auto-merge December 19, 2025 05:05
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>
@jdx jdx enabled auto-merge (squash) December 19, 2025 05:17
@jdx jdx merged commit ac5c030 into main Dec 19, 2025
35 checks passed
@jdx jdx deleted the feat/vfox-env-keys-options branch December 19, 2025 05:18
@github-actions
Copy link

Hyperfine Performance

mise x -- echo

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%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants