Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions crates/project/src/agent_server_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,13 @@ impl ExternalAgentServer for LocalRegistryNpxAgent {
/// security settings, as the args don't change often. The registry will need to support this better
/// at some point, but until then, this is a best-effort workaround that hopefully solves the issue
/// for most users.
///
/// We use npm's hyphen-range syntax (`0.0.0 - <version>`, equivalent to `<=<version>`) instead of
/// the more compact `<=<version>` form because on Windows, `npm` is `npm.cmd` (a batch file run by
/// cmd.exe), and the quotes our shell builder emits are PowerShell string-literal syntax that PS
/// strips during parsing. PS only re-adds CRT-style transport quotes around native command args
/// containing whitespace, so `package@<=0.25.3` reaches cmd.exe bare and the unquoted `<` is
/// interpreted as input redirection. See zed-industries/zed#55921.
fn bounded_npm_package_spec(package_spec: &str) -> String {
let Some((package_name, version)) = package_spec.rsplit_once('@') else {
return package_spec.to_string();
Expand All @@ -1614,7 +1621,7 @@ fn bounded_npm_package_spec(package_spec: &str) -> String {
return package_spec.to_string();
}

format!("{package_name}@<={version}")
format!("{package_name}@0.0.0 - {version}")
}

struct LocalCustomAgent {
Expand Down Expand Up @@ -2025,11 +2032,11 @@ mod tests {
fn builds_bounded_npm_package_specs() {
assert_eq!(
bounded_npm_package_spec("agent-package@1.2.3"),
"agent-package@<=1.2.3"
"agent-package@0.0.0 - 1.2.3"
);
assert_eq!(
bounded_npm_package_spec("@scope/agent-package@1.2.3-beta.1"),
"@scope/agent-package@<=1.2.3-beta.1"
"@scope/agent-package@0.0.0 - 1.2.3-beta.1"
);
assert_eq!(
bounded_npm_package_spec("@scope/agent-package"),
Expand Down
Loading