Repository navigation
feat(cli): suggest the vp run order when package flags come first - #3500
Conversation
Snapshot cases wait for a milestone before they send keystrokes. The y/N prompt that offers a corrected command had no milestone, so a snapshot could not answer it.
move_flags_after_command takes the clap options that a command accepts. It moves those options from before the command name to after it, for example `--filter app run dev` to `run --filter app dev`. It returns None when an argument before the command is not one of those options, or when the command does not follow them.
`vp --filter backend run dev` fails at the top level, because only `vp run` accepts these flags. pnpm accepts them in that order, so users often type it. The global CLI now asks to run `vp run --filter backend dev`, as it does for a top-level typo. The local CLI has no prompt, so it prints the order with "Did you mean". Both CLIs pass vite-task's PackageQueryArgs to the helper, so the accepted flags are the same as `vp run`. Refs: voidzero-dev#2983
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d15531f91a
ℹ️ 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".
The suggested command joined the arguments with spaces, so a copied suggestion did not give the original arguments. For example, `--filter "@my/*"` became `--filter @my/*`, and zsh stops with "no matches found". The suggestion now quotes each argument for a POSIX shell with `shell_escape::unix::escape`. The `y` answer in the global CLI still runs the argument vector directly, so only the displayed text changes.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6073192c2
ℹ️ 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".
Both CLIs apply `-C <dir>` and remove it from the arguments before parsing. The suggestion for `vp -C ../other -r run build` was `vp run -r build`, which runs in the wrong workspace when the user copies it. When `-C` was used, the suggestion now starts with `-C <absolute dir>`, so it selects the same workspace from any shell.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a672665dda
ℹ️ 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".
Command Prompt passes single quotes through, so the POSIX quoting turned `--filter "@my/*"` into a filter that matches no package. On Windows, the suggestion now puts a value in double quotes, which Command Prompt and PowerShell both read as one argument. In double quotes, Command Prompt expands `%NAME%` and PowerShell expands `$name`, so no text gives both shells the same value. When a value has `%`, `$`, a backtick, or a double quote, the CLIs show no suggestion.
The suggestion used shell-escape on POSIX and a separate rule on Windows. It now uses one rule like `quoteArgument` in the migrator: a plain value stays as it is, a value with only spaces, `@`, `*`, `,`, backslashes, or letters goes in double quotes, and any other value gives no suggestion. POSIX shells, Command Prompt, and PowerShell read the double-quoted text as the same value. `vp_cli_help` no longer depends on shell-escape.
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Some CI systems run commands in a pseudo-terminal, so the TTY checks pass and `vp --filter backend run dev` waits at `(y/N)` until the job times out. Check `is_ci_environment()` before the prompt, and record a PTY step with `CI=1`.
The scan counts option lengths only, so it suggested commands that fail: `vp --filter -r run build` takes `-r` as the filter value, which clap rejects, and `vp -r --filter backend run build` combines options that vite-task rejects. Parse the moved options with clap, and let callers check them with `PackageQueryArgs::into_package_query`, so that `vp_cli_help` stays independent of vite-task.
Without a terminal or in CI, the global CLI printed only the argument error, while the local CLI also printed the corrected command. Print "Did you mean `vp run ...`?" in both CLIs and exit with code 2, without a prompt and without running the task, so that a CI log shows the fix.
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Context
vp -r run) #2983Right now, commands like
vp --filter backend run devfail with anUnknownArgumenterror because clap doesn't recognize the vite-taskPackageQueryArgsflags (--filter,-r,-t,-w, and--fail-if-no-match) beforerun. Since pnpm supports this order, it's easy to type this by muscle memory and end up having to re-enter the whole line.This PR fixes that by suggesting the command with those flags moved after
run.Command output
In an interactive terminal, the global CLI asks whether to run the corrected command. In this example, the
backendpackage has adevscript that printsdev from backend.Press
Enteror typento skip the task and exit with code2.In CI or when stdin or stderr is redirected, the global CLI prints the correction and exits with code
2. The project-local CLI also prints this hint and exits with code2.Both binaries wrap values in quotes so arguments parse properly across POSIX shells, Command Prompt, and PowerShell (for instance, keeping quotes in
--filter "@my/*"). However, if an argument has characters like!,$, or%that certain shells expand even inside double quotes, we skip the suggestion entirely to be safe.If you passed a
-Cflag, the suggestion will prepend-C "<absolute path>"so you can paste and run it from anywhere and still hit the right workspace.Note that this only covers
vp runand the specificPackageQueryArgsflags mentioned above. We don't suggest fixes for unrecognized flags or combined short flags like-rw.