vite icon indicating copy to clipboard operation
vite copied to clipboard

Feature Request: Support for enabling non-interactive mode using environment variables

Open atian25 opened this issue 1 month ago • 12 comments

Description

Background When AI Agent use vite to init project, the LLM is prefer to use interactive patterns at the moment.

Image

Suggested solution

Support for enabling non-interactive mode using environment variables, so AI IDE can set env as default to tell vite don't ask for input

Alternative

No response

Additional context

No response

Validations

atian25 avatar Oct 16 '25 04:10 atian25

It's already supported via --no-interactive or if the terminal is non-TTY. The LLM should learn of the flag itself otherwise. I don't think we should add special code paths for them as they're meant to be mimicking a real dev.

bluwy avatar Oct 16 '25 04:10 bluwy

Yesterday we discussed agent auto detection to tweak the default for https://github.com/vitejs/vite/pull/20916 and the same can be applied here.

hi-ogawa avatar Oct 16 '25 04:10 hi-ogawa

Also another way is to always put a short message about --no-interactive (or maybe --help) option before starting interactive cli, so that LLM will notice it by itself and try again. I'd like to have a discussion, so let me re-open the issue.

@atian25 From the screenshot, I cannot tell what is the use case of invoking create-vite from agent and how it's getting stuck. Can you explain what's the prompt and response on the left?

hi-ogawa avatar Oct 16 '25 05:10 hi-ogawa

I personally don't know if we should be hand-holding LLMs if they can't do tasks like selecting prompts. It sounds like a technical issue on their end than us.

At most we could document the CLI flags if they aren't already there so it's in /llms.txt. I would prefer not to turn on special options automatically if LLMs are detected because it'll be confusing when an actual dev tries to replicate the step and they get different results.

bluwy avatar Oct 16 '25 05:10 bluwy

It's already supported via --no-interactive or if the terminal is non-TTY. The LLM should learn of the flag itself otherwise. I don't think we should add special code paths for them as they're meant to be mimicking a real dev.

In the AI IDE scenario, there is human-machine collaboration, and the same Terminal can be operated by AI and taken over by humans, so it is not a non-TTY Terminal.

atian25 avatar Nov 13 '25 01:11 atian25

The current mainstream large models tend to use human scripts when generating initialization statements: npm create vite@latest . -- --template vue-ts.

As a general-purpose IDE Agent, the tasks entrusted to it may be backend scenarios, frontend scenarios, either vue or react. It may not be very appropriate to inject a prompt specific to vue in a general Agent.

Therefore, I would like to know if there is an environment variable similar to NODE_ENV to inject --no-interactive, so that we can inject this ENV at the Terminal project level of the IDE, rather than at the Agent's prompt level.

atian25 avatar Nov 13 '25 01:11 atian25

Also another way is to always put a short message about --no-interactive (or maybe --help) option before starting interactive cli, so that LLM will notice it by itself and try again. I'd like to have a discussion, so let me re-open the issue.

@atian25 From the screenshot, I cannot tell what is the use case of invoking create-vite from agent and how it's getting stuck. Can you explain what's the prompt and response on the left?

Image

We are developing TRAE IDE. The image shows a user scenario where the user wants to initialize a front-end project, and AI returns a vite skeleton initialization script.

Perhaps because LLM learns from vite documents on the internet that are meant for human readers, the scripts it provides are interactive and do not include this parameter.

As you can see, after this script finishes executing, it will keep waiting for human input, and the latest version will even start a dev server to watch it, preventing the process from exiting.

atian25 avatar Nov 13 '25 01:11 atian25

In the AI IDE scenario, there is human-machine collaboration, and the same Terminal can be operated by AI and taken over by humans, so it is not a non-TTY Terminal.

Yeah, this is the difficult point. Given that human interaction is desired depending on the scenario, I think it makes somewhat not-desirable for tools to adjust the behavior specifically for LLM.

Wouldn't adjusting logging like encouraging for LLM to pick --no-interactive by itself be better direction in general? (That's what I suggested in https://github.com/vitejs/vite/issues/20951#issuecomment-3409201065)

hi-ogawa avatar Nov 13 '25 01:11 hi-ogawa

In terms of trends, AI should be able to recognize that this is an interactive terminal and actively mimic human input.

We are also working in this direction, but it is not very economical to achieve it at present. The current operating system does not have a signal to tell us that it is waiting in stdin. We can only analyze stdout in a loop and let the AI guess that it should take over, which is not very economical at present.

Wouldn't adjusting logging like encouraging for LLM to pick --no-interactive by itself be better direction in general? (That's what I suggested in https://github.com/vitejs/vite/issues/20951#issuecomment-3409201065)

This approach might work, at least in terms of Terminal output, it gives the AI a chance to realize that there is another path it can take, but I don't know how effective it will be. Perhaps it needs some tweaking, as different models have different tendencies.

atian25 avatar Nov 13 '25 02:11 atian25

BTW, We've just discovered a new issue: the latest vite update starts the dev server at the very end, thus blocking the entire initialization process.

The AI, having learned from its vast knowledge of the world during the training phase, understands that the vite function will automatically exit after completion. Therefore, it didn't mark this initialization task as one that needs to be run in the background, resulting in it continuously blocking and waiting. Currently, the only solution is for the user to manually click "skip".

This may not be a problem with Vite, but as @yyx990803 and I discussed a few months ago, the era of AI and Tools interacting with each other has arrived. Perhaps Tools are not just for humans; we maybe need to consider how to make them AI-friendly.

llm.txt might be a good approach. We are discussing whether the Agent can proactively recall vite-related LLM documentation under certain circumstances to supplement its lack of world knowledge.

atian25 avatar Nov 13 '25 02:11 atian25

@atian25 I will refer to the approach used by Netlify CLI, allowing the CLI to output an Agent-friendly log prompt before entering interactive mode, telling the AI Agent how to handle parameter input. https://agentexperience.ax/ I will send a pull request later.

Image

fengmk2 avatar Nov 13 '25 02:11 fengmk2

In the AI IDE scenario, there is human-machine collaboration, and the same Terminal can be operated by AI and taken over by humans, so it is not a non-TTY Terminal.

So you'd want the terminal to still be interactive so users can take over where needed. But this feature request is to make it non-interactive, what if users want to make different choices in the CLI?

BTW, We've just discovered a new issue: the latest vite update starts the dev server at the very end, thus blocking the entire initialization process.

It doesn't start the dev server unless you confirm it in the prompt, it shouldn't confirm the prompt if it didn't want to do that. It's not something that you could put running in the background as we're starting the process as part of the CLI.


I'm also against detecting an AI env and perform the CLI differently. Unless we're expanding with AI-specific capabilities, currently we're only handicapping the CLI due to its limitation. What if a new tool figures out the interaction and doesn't want the handicap?

bluwy avatar Nov 13 '25 03:11 bluwy