Skip to content

feat(cli): advertise VP_USER_AGENT to child processes#1958

Draft
fengmk2 wants to merge 2 commits into
mainfrom
vp-dlx-user-agent
Draft

feat(cli): advertise VP_USER_AGENT to child processes#1958
fengmk2 wants to merge 2 commits into
mainfrom
vp-dlx-user-agent

Conversation

@fengmk2

@fengmk2 fengmk2 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Problem

When vp runs a tool (e.g. vp dlx create-vite), the child can't tell it was launched by vp. The underlying package manager (pnpm/npm/yarn/bun) overwrites npm_config_user_agent with its own value, so that channel can't carry the vp signal.

Fix

Set a dedicated VP_USER_AGENT=vp/<version> env var once at startup, inherited by every child process. Tools like create-vite can read it to detect vp and scaffold with vp install / vp dev / vp dlx.

  • Added the VP_USER_AGENT constant to the central env_vars registry.
  • Set it as the first statement of main, before the async runtime starts (edition 2024 set_var must run single-threaded), mirroring the vite_installer pattern. This covers all dlx paths including the npx fallback used when there is no local package.json.

Companion

create-vite reads VP_USER_AGENT: vitejs/vite#22788

Set `VP_USER_AGENT=vp/<version>` once at startup so spawned tools can detect
vp as the package manager. Underlying package managers overwrite
`npm_config_user_agent`, so a dedicated variable is needed. Enables
`vp dlx create-vite` to scaffold with vp commands.
@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 2d9a056
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a3eb9ddbe899400086a4fe5

@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit deeab22
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a3f3137d13f7c00089f0480

@fengmk2

fengmk2 commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d9a056834

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vite_global_cli/src/main.rs
Comment thread crates/vite_global_cli/src/main.rs
When vp runs as a managed npm/npx/node shim, the user is invoking that tool,
not vp, so clear VP_USER_AGENT before dispatching the shim. Otherwise a child
like create-vite would wrongly scaffold vp commands.
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.

1 participant