crbench//

← all cases

fix(npm): handle deno run/install of npm package with only directories.bin

Tier 2 easy rust · local · real merged PR from denoland/deno #30919

Ground-truth defects

d1 · correctness · high · libs/node_resolver/resolution.rs
The rewrite narrows how a package's bin entry is chosen. `resolve_bin_entry_value` used to take `bin_name: Option<&str>` and treat `None` — no subpath given — as its own case: with a single bin entry it returned that entry whatever its key. The new caller resolves a name eagerly before the lookup (`match sub_path { Some(n) => n, None => pkg_json.resolve_default_bin_name()? }`) and passes a plain `&str`, so `None` no longer reaches the lookup and the single-entry case is gone. The default bin name is derived from the package name, which for a scoped package is the part after the slash — so any package whose one bin entry is named something other than the tail of its own name stops resolving. It is not a rare shape: `npm:@arethetypeswrong/cli` has a single bin called `attw`, and after this change `deno run -A npm:@arethetypeswrong/cli` fails outright with "did not have a bin entry for 'cli'". The regression is invisible in the diff's own tests because the fixtures it adds (`@denotest/directories-bin`, bin `cli`) are all packages whose bin key does match the name.

The change under review

diff (truncated — full diff)
diff --git a/Cargo.lock b/Cargo.lock
index 56d4931f91b2b6..a9e548638d3a58 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6290,6 +6290,7 @@ dependencies = [
  "deno_semver",
  "futures",
  "lazy-regex",
+ "log",
  "once_cell",
  "path-clean",
  "pretty_assertions",
diff --git a/cli/task_runner.rs b/cli/task_runner.rs
index 0b06baba3fb7ac..4133246e611237 100644
--- a/cli/task_runner.rs
+++ b/cli/task_runner.rs
@@ -10,7 +10,6 @@ use std::rc::Rc;
 use deno_core::anyhow::Context;
 use deno_core::error::AnyError;
 use deno_core::futures::future::LocalBoxFuture;
-use deno_semver::package::PackageNv;
 use deno_task_shell::ExecutableCommand;
 use deno_task_shell::ExecuteResult;
 use deno_task_shell::KillSignal;
@@ -18,8 +17,6 @@ use deno_task_shell::ShellCommand;
 use deno_task_shell::ShellCommandContext;
 use deno_task_shell::ShellPipeReader;
 use deno_task_shell::ShellPipeWriter;
-use lazy_regex::Lazy;
-use regex::Regex;
 use tokio::task::JoinHandle;
 use tokio::task::LocalSet;
 use tokio_util::sync::CancellationToken;
@@ -400,37 +397,6 @@ impl ShellCommand for NpxCommand {
   }
 }
 
-#[derive(Clone)]
-struct NpmPackageBinCommand {
-  name: String,
-  npm_package: PackageNv,
-}
-
-impl ShellCommand for NpmPackageBinCommand {
-  fn execute(
-    &self,
-    context: ShellCommandContext,
-  ) -> LocalBoxFuture<'static, ExecuteResult> {
-    let mut args: Vec<OsString> = vec![
-      "run".into(),
-      "-A".into(),
-      if self.npm_package.name == self.name {
-        format!("npm:{}", self.npm_package)
-      } else {
-        format!("npm:{}/{}", self.npm_package, self.name)
-      }
-      .into(),
-    ];
-
-    args.extend(context.args);
-    let executable_command = deno_task_shell::ExecutableCommand::new(
-      "deno".to_string(),
-      std::env::current_exe().unwrap(),
-    );
-    executable_command.execute(ShellCommandContext { args, ..context })
-  }
-}
-
 /// Runs a module in the node_modules folder.
 #[derive(Clone)]
 pub struct NodeModulesFileRunCommand {
@@ -464,16 +430,17 @@ impl ShellCommand for NodeModulesFileRunCommand {
 }
 
 pub fn resolve_custom_commands(
-  npm_resolver: &CliNpmResolver,
   node_resolver: &CliNodeResolver,
+  npm_resolver: &CliNpmResolver,
 ) -> Result<HashMap<String, Rc<dyn ShellCommand>>, AnyError> {
   let mut commands = match npm_resolver {
     CliNpmResolver::Byonm(npm_resolver) => {
       let node_modules_dir = npm_resolver.root_node_modules_path().unwrap();
-      resolve_npm_commands_from_bin_dir(node_modules_dir)
+      let bin_dir = node_modules_dir.join(".bin");
+      resolve_npm_commands_from_bin_dir(&bin_dir, node_resolver)
     }
     CliNpmResolver::Managed(npm_resolver) => {
-      resolve_managed_npm_commands(npm_resolver, node_resolver)?
+      resolve_managed_npm_commands(node_resolver, npm_resolver)?
     }
   };
   commands.insert("npm".to_string(), Rc::new(NpmCommand));
@@ -481,113 +448,38 @@ pub fn resolve_custom_commands(
 }
 
 pub fn resolve_npm_commands_from_bin_dir(
-  node_modules_dir: &Path,
+  bin_dir: &Path,
+  node_resolver: &CliNodeResolver,
 ) -> HashMap<String, Rc<dyn ShellCommand>> {
-  let mut result = HashMap::<String, Rc<dyn ShellCommand>>::new();
-  let bin_dir = node_modules_dir.join(".bin");
-  log::debug!("Resolving commands in '{}'.", bin_dir.display());
-  match std::fs::read_dir(&bin_dir) {
-    Ok(entries) => {
-      for entry in entries {
-        let Ok(entry) = entry else {
-          continue;
-        };
-        if let Some(command) = resolve_bin_dir_entry_command(entry) {
-          result.insert(command.command_name.clone(), Rc::new(command));
-        }
-      }
-    }
-    Err(err) => {
-      log::debug!("Failed read_dir for '{}': {:#}", bin_dir.display(), err);
-    }
-  }
-  result
-}
-
-fn resolve_bin_dir_entry_command(
-  entry: std::fs::DirEntry,
-) -> Option<NodeModulesFileRunCommand> {
-  if entry.path().extension().is_some() {
-    return None; // only look at files without extensions (even on Windows)
-  }
-  let file_type = entry.file_type().ok()?;
-  let path = if file_type.is_file() {
-    entry.path()
-  } else if file_type.is_symlink() {
-    entry.path().canonicalize().ok()?
-  } else {
-    return None;
-  };
-  let text = std::fs::read_to_string(&path).ok()?;
-  let command_name = entry.file_name().to_string_lossy().into_owned();
-  if let Some(path) = resolve_execution_path_from_npx_shim(path, &text) {
-    log::debug!(
-      "Resolved npx command '{}' to '{}'.",
-      command_name,
-      path.display()
-    );
-    Some(NodeModulesFileRunCommand { command_name, path })
-  } else {
-    log::debug!("Failed resolving npx command '{}'.", command_name);
-    None
-  }
-}
-
-/// This is not ideal, but it works ok because it allows us to bypass
-/// the shebang and execute the script directly with Deno.
-fn resolve_execution_path_from_npx_shim(
-  file_path: PathBuf,
-  text: &str,
-) -> Option<PathBuf> {
-  static SCRIPT_PATH_RE: Lazy<Regex> =
-    lazy_regex::lazy_regex!(r#""\$basedir\/([^"]+)" "\$@""#);
-
-  let maybe_first_line = {
-    let index = text.find("\n")?;
-    Some(&text[0..index])
-  };
-
-  if let Some(first_line) = maybe_first_line {
-    // NOTE(bartlomieju): this is not perfect, but handle two most common scenarios
-    // where Node is run without any args. If there are args then we use `NodeCommand`
-    // struct.
-    if first_line == "#!/usr/bin/env node"
-      || first_line == "#!/usr/bin/env -S node"
-    {
-      // launch this file itself because it's a JS file
-      return Some(file_path);
-    }
-  }
-
-  // Search for...
-  // > "$basedir/../next/dist/bin/next" "$@"
-  // ...which is what it will look like on Windows
-  SCRIPT_PATH_RE
-    .captures(text)
-    .and_then(|c| c.get(1))
-    .map(|relative_path| {
-      file_path.parent().unwrap().join(relative_path.as_str())
+  let bin_commands = node_resolver.resolve_npm_commands_from_bin_dir(bin_dir);
+  bin_commands
+    .into_iter()
+    .map(|(command_name, path)| {
+      (
+        command_name.clone(),
+        Rc::new(NodeModulesFileRunCommand { command_name, path })
+          as Rc<dyn ShellCommand>,
+      )
     })
+    .collect()
 }
 
 fn resolve_managed_npm_commands(
-  npm_resolver: &CliManagedNpmResolver,
   node_resolver: &CliNodeResolver,
+  npm_resolver: &CliManagedNpmResolver,
 ) -> Result<HashMap<String, Rc<dyn ShellCommand>>, AnyError> {
   let mut result = HashMap::new();
   for id in npm_resolver.resolution().top_level_packages() {
     let package_folder = npm_resolver.resolve_pkg_folder_from_pkg_id(&id)?;
-    let bin_commands =
-      node_resolver.resolve_binary_commands(&package_folder)?;
-    for bin_command in bin_commands {
-      result.insert(
-        bin_command.to_string(),
-        Rc::new(NpmPackageBinCommand {
-          name: bin_command,
-          npm_package: id.nv.clone(),
-        }) as Rc<dyn ShellCommand>,
-      );
-    }
+    let bins =
+      node_resolver.resolve_npm_binary_commands_for_package(&package_folder)?;
+    result.extend(bins.into_iter().map(|(command_name, path)| {
+      (
+        command_name.clone(),
+        Rc::new(NodeModulesFileRunCommand { command_name, path })
+          as Rc<dyn ShellCommand>,
+      )
+    }));
   }
   if !result.contains_key("npx") {
     result.insert("npx".to_string(), Rc::new(NpxCommand));
@@ -705,45 +597,4 @@ mod test {
       HashMap::from([("PATH".into(), "/example".into())])
     );
   }
-
-  #[test]
-  fn test_resolve_execution_path_from_npx_shim() {
-    // example shim on unix
-    let unix_shim = r#"#!/usr/bin/env node
-"use strict";
-console.log('Hi!');
-"#;
-    let path = PathBuf::from("/node_modules/.bin/example");
-    assert_eq!(
-      resolve_execution_path_from_npx_shim(path.clone(), unix_shim).unwrap(),
-      path
-    );
-    // example shim on unix
-    let unix_shim = r#"#!/usr/bin/env -S node
-"use strict";
-console.log('Hi!');
-"#;
-    let path = PathBuf::from("/node_modules/.bin/example");
-    assert_eq!(
-      resolve_execution_path_from_npx_shim(path.clone(), unix_shim).unwrap(),
-      path
-    );
-    // example shim on windows
-    let windows_shim = r#"#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
-    *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
-esac
-
-if [ -x "$basedir/node" ]; then
-  exec "$basedir/node"  "$basedir/../example/bin/example" "$@"
-else
-  exec node  "$basedir/../example/bin/example" "$@"
-fi"#;
-    assert_eq!(
-      resolve_execution_path_from_npx_shim(path.clone(), windows_shim).unwrap(),
-      path.parent().unwrap().join("../example/bin/example")
-    );
-  }
 }
diff --git a/cli/tools/task.rs b/cli/tools/task.rs
index 9fbce0e3e6d729..2b76b47bc34970 100644
--- a/cli/tools/task.rs
+++ b/cli/tools/task.rs
@@ -462,8 +462,8 @@ impl<'a> TaskRunner<'a> {
     };
 
     let custom_commands = task_runner::resolve_custom_commands(
-      self.npm_resolver,
       self.node_resolver,
+      self.npm_resolver,
     )?;
 
     self
@@ -505,8 +505,8 @@ impl<'a> TaskRunner<'a> {
       format!("post{}", task_name),
     ];
     let custom_commands = task_runner::resolve_custom_commands(
-      self.npm_resolver,
       self.node_resolver,
+      self.npm_resolver,
     )?;
 
     for task_name in &task_names {
diff --git a/ext/node/lib.rs b/ext/node/lib.rs
index e98820f894863c..2d20b4ecb4c8a8 100644
--- a/ext/node/lib.rs
+++ b/ext/node/lib.rs
@@ -881,11 +881,7 @@ deno_core::extension!(deno_node,
 
 #[sys_traits::auto_impl]
 pub trait ExtNodeSys:
-  sys_traits::BaseFsCanonicalize
-  + sys_traits::BaseFsMetadata
-  + sys_traits::BaseFsRead
-  + sys_traits::EnvCurrentDir
-  + Clone
+  node_resolver::NodeResolverSys + sys_traits::EnvCurrentDir + Clone
 {
 }
 
diff --git a/ext/node/ops/require.rs b/ext/node/ops/require.rs
index 88d583f1ab6eec..a03d3f3a7e981e 100644
--- a/ext/node/ops/require.rs
+++ b/ext/node/ops/require.rs
@@ -26,8 +26,6 @@ use node_resolver::UrlOrPath;
 use node_resolver::UrlOrPathRef;
 use node_resolver::cache::NodeResolutionThreadLocalCache;
 use node_resolver::errors::PackageJsonLoadError;
-use sys_traits::FsCanonicalize;
-use sys_traits::FsMetadata;
 use sys_traits::FsMetadataValue;
 
 use crate::ExtNodeSys;
diff --git a/ext/node/ops/worker_threads.rs b/ext/node/ops/worker_threads.rs
index 4293c20cb0b9b5..36fee525dfe8bf 100644
--- a/ext/node/ops/worker_threads.rs
+++ b/ext/node/ops/worker_threads.rs
@@ -8,8 +8,6 @@ use deno_core::OpState;
 use deno_core::op2;
 use deno_core::url::Url;
 use deno_error::JsErrorBox;
-use sys_traits::FsCanonicalize;
-use sys_traits::FsMetadata;
 
 use crate::ExtNodeSys;
 use crate::NodePermissions;
diff --git a/libs/node_resolver/Cargo.toml b/libs/node_resolver/Cargo.toml
index 08f07cfa0c45b1..3e4614c78a0c88 100644
--- a/libs/node_resolver/Cargo.toml
+++ b/libs/node_resolver/Cargo.toml
@@ -32,6 +32,7 @@ deno_path_util.workspace = true
 deno_semver.workspace = true
 futures.workspace = true
 lazy-regex.workspace = true
+log.workspace = true
 once_cell.workspace = true
 path-clean.workspace = true
 pretty_assertions.workspace = true
diff --git a/libs/node_resolver/analyze.rs b/libs/node_resolver/analyze.rs
index 05a3bb9bb987f2..ee02646e3f5a16 100644
--- a/libs/node_resolver/analyze.rs
+++ b/libs/node_resolver/analyze.rs
@@ -15,14 +15,12 @@ use futures::stream::FuturesUnordered;
 use once_cell::sync::Lazy;
 use serde::Deserialize;
 use serde::Serialize;
-use sys_traits::FsCanonicalize;
-use sys_traits::FsMetadata;
-use sys_traits::FsRead;
 use url::Url;
 
 use crate::InNpmPackageChecker;
 use crate::IsBuiltInNodeModuleChecker;
 use crate::NodeResolutionKind;
+use crate::NodeResolverSys;
 use crate::NpmPackageFolderResolver;
 use crate::PackageJsonResolverRc;
 use crate::PathClean;
@@ -77,6 +75,9 @@ pub enum ResolvedCjsAnalysis<'a> {
   Cjs(BTreeSet<String>),
 }
 
+#[sys_traits::auto_impl]
+pub trait CjsModuleExportAnalyzerSys: NodeResolverSys {}
+
 #[allow(clippy::disallowed_types)]
 pub type CjsModuleExportAnalyzerRc<
   TCjsCodeAnalyzer,
@@ -99,7 +100,7 @@ pub struct CjsModuleExportAnalyzer<
   TInNpmPackageChecker: InNpmPackageChecker,
   TIsBuiltInNodeModuleChecker: IsBuiltInNodeModuleChecker,
   TNpmPackageFolderResolver: NpmPackageFolderResolver,
-  TSys: FsCanonicalize + FsMetadata + FsRead,
+  TSys: CjsModuleExportAnalyzerSys,
 > {
   cjs_code_analyzer: TCjsCodeAnalyzer,
   in_npm_pkg_checker: TInNpmPackageChecker,
@@ -119,7 +120,7 @@ impl<
   TInNpmPackageChecker: InNpmPackageChecker,
   TIsBuiltInNodeModuleChecker: IsBuiltInNodeModuleChecker,
   TNpmPackageFolderResolver: NpmPackageFolderResolver,
-  TSys: FsCanonicalize + FsMetadata + FsRead,
+  TSys: CjsModuleExportAnalyzerSys,
 >
   CjsModuleExportAnalyzer<
     TCjsCodeAnalyzer,
@@ -516,7 +517,7 @@ pub struct CjsAnalysisCouldNotLoadError {
 }
 
 #[sys_traits::auto_impl]
-pub trait NodeCodeTranslatorSys: FsCanonicalize + FsMetadata + FsRead {}
+pub trait NodeCodeTranslatorSys: CjsModuleExportAnalyzerSys {}
 
 #[allow(clippy::disallowed_types)]
 pub type NodeCodeTranslatorRc<
diff --git a/libs/node_resolver/errors.rs b/libs/node_resolver/errors.rs
index bbe7c1af2b867d..99ccc7e5e103cd 100644
--- a/libs/node_resolver/errors.rs
+++ b/libs/node_resolver/errors.rs
@@ -6,6 +6,7 @@ use std::path::PathBuf;
 
 use boxed_error::Boxed;
 use deno_error::JsError;
+use deno_package_json::MissingPkgJsonNameError;
 use deno_path_util::UrlToFilePathError;
 use thiserror::Error;
 use url::Url;
@@ -1036,27 +1037,34 @@ impl NodeJsErrorCoded for UnsupportedEsmUrlSchemeError {
   }
 }
 
+#[derive(Debug, Error, JsError)]
+#[class(generic)]
+#[error("Failed resolving binary export. '{}' did not exist", pkg_json_path.display())]
+pub struct MissingPkgJsonError {
+  pub pkg_json_path: PathBuf,
+}
+
 #[derive(Debug, Error, JsError)]
 pub enum ResolvePkgJsonBinExportError {
   #[class(inherit)]
   #[error(transparent)]
-  PkgJsonLoad(#[from] PackageJsonLoadError),
-  #[class(generic)]
-  #[error("Failed resolving binary export. '{}' did not exist", pkg_json_path.display())]
-  MissingPkgJson { pkg_json_path: PathBuf },
+  ResolvePkgNpmBinaryCommands(#[from] ResolvePkgNpmBinaryCommandsError),
   #[class(generic)]
   #[error("Failed resolving binary export. {message}")]
   InvalidBinProperty { message: String },
 }
 
 #[derive(Debug, Error, JsError)]
-pub enum ResolveBinaryCommandsError {
+pub enum ResolvePkgNpmBinaryCommandsError {
   #[class(inherit)]
   #[error(transparent)]
   PkgJsonLoad(#[from] PackageJsonLoadError),
   #[class(generic)]
-  #[error("'{}' did not have a name", pkg_json_path.display())]
-  MissingPkgJsonName { pkg_json_path: PathBuf },
+  #[error(transparent)]
+  MissingPkgJson(#[from] MissingPkgJsonError),
+  #[class(inherit)]
+  #[error(transparent)]
+  MissingPkgJsonName(#[from] MissingPkgJsonNameError),
 }
 
 #[derive(Error, Debug, Clone, deno_error::JsError)]
diff --git a/libs/node_resolver/resolution.rs b/libs/node_resolver/resolution.rs
index d77e34cbe73917..3025f6ae55dd49 100644
--- a/libs/node_resolver/resolution.rs
+++ b/libs/node_resolver/resolution.rs
@@ -1,6 +1,7 @@
 // Copyright 2018-2025 the Deno authors. MIT license.
 
 use std::borrow::Cow;
+use std::collections::BTreeMap;
 use std::fmt::Debug;
 use std::path::Path;
 use std::path::PathBuf;
@@ -9,15 +10,20 @@ use anyhow::Error as AnyError;
 use anyhow::bail;
 use deno_media_type::MediaType;
 use deno_package_json::PackageJson;
+use deno_package_json::PackageJsonRc;
 use deno_path_util::url_to_file_path;
 use deno_semver::Version;
 use deno_semver::VersionReq;
+use lazy_regex::Lazy;
+use regex::Regex;
 use serde_json::Map;
 use serde_json::Value;
 use sys_traits::FileType;
 use sys_traits::FsCanonicalize;
+use sys_traits::FsDirEntry;
 use sys_traits::FsMetadata;
 use sys_traits::FsRead;
+use sys_traits::FsReadDir;
 use url::Url;
 
 use crate::InNpmPackageChecker;
@@ -32,6 +38,7 @@ use crate::errors::FinalizeResolutionError;
 use crate::errors::InvalidModuleSpecifierError;
 use crate::errors::InvalidPackageTargetError;

Leaderboard for this case

easy · 9 of 9 bots fully caught it (100% solve rate) · 100% avg coverage.

#BotResultCaughtCoverageFindingsFalse alarms
1 Claude Code (Opus 5.5) solved 1/1 100.0% 4 0
2 Cubic solved 1/1 100.0% 2 0
3 cursor solved 1/1 100.0% 2 0
4 Drape (Deep Review) solved 1/1 100.0% 6 0
5 Drape (Review) solved 1/1 100.0% 5 0
6 greptile solved 1/1 100.0% 3 0
7 Mjolnir (Opus 5.5) solved 1/1 100.0% 4 0
8 Mjolnir (Sonnet 5.5) solved 1/1 100.0% 5 0
9 qodo solved 1/1 100.0% 3 0

Bot results

Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
valid · impact low
Previously, with sub_path None, a string bin returned the bin directly and an object bin with one entry (or all-identical values) returned its first value, with no name needed. Now resolve_bins errors on a string bin with no name, and resolve_default_bin_name()? runs before the bins are looked up, so nameless packages fail. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The old resolve_binary_commands returned Ok(Vec::new()) when package.json was missing. The new shared helper returns a MissingPkgJson error, and resolve_managed_npm_commands propagates it with `?`, which fails custom command resolution for the whole task. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The new directories.bin support sends the folder through the .bin shim heuristics, which skip any file with an extension and require a node shebang or a Windows shim pattern. So plain .js bin files in a directories.bin folder are dropped. The secondary note about the missing-bin error was already true before this change, but the main claim is about newly added code. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
libs/node_resolver/resolution.rs:2246
`resolve_bin_entry_value` regresses the single-entry case. Before this change, when no sub path was given and the `bin` object had exactly one entry, that entry was used (`o.len() == 1`). Now the lookup uses the default bin name, which is the package name, and the fallback only runs when `bins.len() > 1` and every value is the same. A package like `@angular/cli` with `bin: {"ng": ...}` therefore no longer resolves for `deno run npm:@angular/cli`. `resolve_npm_binary_entrypoint` then falls back to regular node resolution and runs the package's main module instead of its binary, or errors. The condition should be `bins.len() >= 1` (or the old single-entry rule should be kept).
libs/node_resolver/resolution.rs:762
`resolve_binary_export` now requires a package name whenever no sub path is given: `resolve_default_bin_name()?` runs before the bins are looked at, and `resolve_bins()` fails for a string `bin` with no `name`. Before, a package with no name but a string `bin`, or an object `bin` with one entry or all-identical values, resolved correctly. Those packages now fail with a MissingPkgJsonName error.
cli/task_runner.rs:476
`resolve_managed_npm_commands` now propagates `MissingPkgJson` with `?`. The old `resolve_binary_commands` returned an empty list when `package.json` couldn't be loaded. If any top-level package folder lacks a `package.json` (for example a partial or corrupted install), every `deno task` invocation now fails, even when the task doesn't use that package's binaries.
libs/node_resolver/resolution.rs:802
Packages that declare `directories.bin` (and no `bin`) are handled by `resolve_npm_commands_from_bin_dir`, which uses the `.bin` npx-shim heuristics. Those rules skip every file with an extension and require a `#!/usr/bin/env node` shebang or a Windows shim pattern. Real `directories.bin` folders usually hold plain `.js` files, which npm exposes as bins, so most of them are silently dropped. Also, when `bin` is absent, `resolve_binary_export` errors with "did not have a bin property".
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ off by one
valid · impact low
This change adds `directories.bin` support: `PackageJsonBins::Directory` now goes through `resolve_npm_commands_from_bin_dir`. That scanner was written for `node_modules/.bin` shims and skips every file that has an extension. In a package's own bin directory, npm exposes every file as a command, so files like `cli.js` are now silently dropped. The gap comes from the new code path this change adds. [grounded: diff] [consensus 5/5: valid=5]
valid · matches d1 · impact high
raw comments (3)
libs/node_resolver/resolution.rs:840
<!-- cubic:v=59149f87-5b34-458c-89dd-ff2729438847 --> <!-- cubic:review-run=a81f1de6-92da-5db1-bdbf-7dc022b8a86d --> <!-- metadata:{"confidence":8} --> P2: The scanner also handles `directories.bin`, but this guard drops every file with an extension, so a directory containing `cli.js` exposes no command. Keep the extensionless filter for generated `.bin` shims while allowing extension-bearing files in a package's bin directory. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At libs/node_resolver/resolution.rs, line 840: <comment>The scanner also handles `directories.bin`, but this guard drops every file with an extension, so a directory containing `cli.js` exposes no command. Keep the extensionless filter for generated `.bin` shims while allowing extension-bearing files in a package's bin directory.</comment> <file context> @@ -736,61 +746,121 @@ impl< + &self, + entry: TSys::ReadDirEntry, + ) -> Option<(String, PathBuf)> { + if entry.path().extension().is_some() { + return None; // only look at files without extensions (even on Windows) + } </file context> ``` </details>
libs/node_resolver/resolution.rs:2244
<!-- cubic:v=19217093-fe12-402b-b3f7-1e2d5750eb6c --> <!-- cubic:review-run=a81f1de6-92da-5db1-bdbf-7dc022b8a86d --> <!-- metadata:{"confidence":9} --> P2: A package with one `bin` entry keyed differently from its package name no longer resolves through `npm:pkg`: the caller requests the package-name key, and this guard excludes the sole-bin fallback. Preserve the singleton fallback so the unambiguous executable still resolves. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At libs/node_resolver/resolution.rs, line 2242: <comment>A package with one `bin` entry keyed differently from its package name no longer resolves through `npm:pkg`: the caller requests the package-name key, and this guard excludes the sole-bin fallback. Preserve the singleton fallback so the unambiguous executable still resolves.</comment> <file context> @@ -2119,50 +2189,62 @@ fn resolve_pkg_json_import<'a>( + match bins.get(bin_name) { + Some(e) => Ok(e), None => { + if bins.len() > 1 + && let Some(first) = bins.values().next() + && bins.values().all(|path| path == first) </file context> ``` </details> ```suggestion if let Some(first) = bins.values().next() && bins.values().all(|path| path == first) { ```
PR-level
<!-- cubic:review-summary:start --> **2 issues found** across 11 files <!-- cubic:review-summary:end --> <details> <summary>Prompt for AI agents (unresolved issues)</summary> ```text Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately. <file name="libs/node_resolver/resolution.rs"> <violation number="1" location="libs/node_resolver/resolution.rs:840"> P2: The scanner also handles `directories.bin`, but this guard drops every file with an extension, so a directory containing `cli.js` exposes no command. Keep the extensionless filter for generated `.bin` shims while allowing extension-bearing files in a package's bin directory.</violation> <violation number="2" location="libs/node_resolver/resolution.rs:2242"> P2: A package with one `bin` entry keyed differently from its package name no longer resolves through `npm:pkg`: the caller requests the package-name key, and this guard excludes the sole-bin fallback. Preserve the singleton fallback so the unambiguous executable still resolves.</violation> </file> ``` </details> <sub>Reply with feedback, questions, or to request a fix.<br /><br />[View guided diff](https://www.cubic.dev/pr/drape-io/crbench-cubic-2026-09/pull/117?utm_source=github&utm_medium=review_footer) | [Turn on auto-fix](https://www.cubic.dev/action/auto-fix/pr/drape-io/crbench-cubic-2026-09/117?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F117) | [Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/117/ai_pr_review_github_delivery_ee00158ff59f7272f0d666a542fcb1cd710a526391bef3cdfd7da7e09a9e3ae3?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F117)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_ee00158ff59f7272f0d666a542fcb1cd710a526391bef3cdfd7da7e09a9e3ae3:5a0df352fc3b6f9a7050f845bd25700b6ebe6539:a81f1de6-92da-5db1-bdbf-7dc022b8a86d -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
valid · impact low
This PR adds `directories.bin` support: `resolve_bins` now returns `PackageJsonBins::Directory`. That directory is then passed to `resolve_npm_commands_from_bin_dir`, which uses the `node_modules/.bin` shim heuristics. Those heuristics skip any file with an extension (`return None; // only look at files without extensions`) and drop files that lack a `#!/usr/bin/env node` shebang or the Windows shim pattern. So common `directories.bin` scripts such as `bin/cli.js` never become commands. The gap comes from new code, though before this change none of these scripts were supported at all. [grounded: diff] [consensus 5/5: valid=5]
raw comments (3)
libs/node_resolver/resolution.rs:771
### Default bin skips sole named entry **High Severity** <!-- DESCRIPTION START --> `resolve_binary_export` with no `sub_path` now always looks up the package short name, and the same-path fallback in `resolve_bin_entry_value` only runs when there are multiple bins. A package whose only `bin` key differs from that short name no longer resolves, so `deno run npm:pkg` fails for common scoped CLIs. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 8f4c194e-e456-4fe3-905c-dba02327667c --> <!-- LOCATIONS START libs/node_resolver/resolution.rs#L758-L771 libs/node_resolver/resolution.rs#L2240-L2247 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`libs/node_resolver/resolution.rs#L2240-L2247`](https://github.com/drape-io/crbench-cursor-2026-09/blob/28ae6c86e551d52ac037c2314482711074474650/libs/node_resolver/resolution.rs#L2240-L2247) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmE0NWUxNzAyLWIxYjAtNGY0OC1hYTRhLWZlNjU5NWE1YWY1NSIsImVuY3J5cHRpb25LZXkiOiJfLUtMekNCVWVGSTM1a2g2YWZ3UHRDc2x6eG9yU1dRNE9ycGNnbTVlSXFJIiwiYnJhbmNoIjoicHItZjg0NjIxMzIwNiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmE0NWUxNzAyLWIxYjAtNGY0OC1hYTRhLWZlNjU5NWE1YWY1NSIsImVuY3J5cHRpb25LZXkiOiJfLUtMekNCVWVGSTM1a2g2YWZ3UHRDc2x6eG9yU1dRNE9ycGNnbTVlSXFJIiwiYnJhbmNoIjoicHItZjg0NjIxMzIwNiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjExNywiY29tbWl0U2hhIjoiMjhhZTZjODZlNTUxZDUyYWMwMzdjMjMxNDQ4MjcxMTA3NDQ3NDY1MCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 28ae6c86e551d52ac037c2314482711074474650. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
libs/node_resolver/resolution.rs:804
### Directories bin scan skips scripts **Medium Severity** <!-- DESCRIPTION START --> When `bin` is absent, `resolve_bins` returns `directories.bin` as a directory, then `resolve_npm_commands_from_bin_dir` treats those files as `node_modules/.bin` shims. It skips any file with an extension and drops entries that are not npx shims, so typical `directories.bin` scripts never become commands. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 5470072d-af7c-4002-b4bf-bf05d0779056 --> <!-- LOCATIONS START libs/node_resolver/resolution.rs#L800-L804 libs/package_json/lib.rs#L567-L574 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`libs/package_json/lib.rs#L567-L574`](https://github.com/drape-io/crbench-cursor-2026-09/blob/28ae6c86e551d52ac037c2314482711074474650/libs/package_json/lib.rs#L567-L574) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmNmNDMyN2YyLWM3OGUtNGJiZS1hZDM3LWVhNzM1YjhhYjlhOCIsImVuY3J5cHRpb25LZXkiOiJhdjV3ZUtZZkdncGJXTDVTVTBVNV9TeUtLQ0VyaWQxUV9QdEh0bGV6T3ljIiwiYnJhbmNoIjoicHItZjg0NjIxMzIwNiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmNmNDMyN2YyLWM3OGUtNGJiZS1hZDM3LWVhNzM1YjhhYjlhOCIsImVuY3J5cHRpb25LZXkiOiJhdjV3ZUtZZkdncGJXTDVTVTBVNV9TeUtLQ0VyaWQxUV9QdEh0bGV6T3ljIiwiYnJhbmNoIjoicHItZjg0NjIxMzIwNiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjExNywiY29tbWl0U2hhIjoiMjhhZTZjODZlNTUxZDUyYWMwMzdjMjMxNDQ4MjcxMTA3NDQ3NDY1MCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 28ae6c86e551d52ac037c2314482711074474650. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTozMWQzNjdkNi0wNTg0LTQwN2QtYTI1Yi0zZDFjNWMzMTI4NDUiLCJlbmNyeXB0aW9uS2V5IjoiYnM4OTB1c01Tc045dkxnRmc2QUZIVEJ0dGR4SU1TOHNxeFVuTnRuT0RWcyIsImJyYW5jaCI6InByLWY4NDYyMTMyMDYiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 28ae6c86e551d52ac037c2314482711074474650. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · impact low
Before the change, an explicit bin name went through `o.get(bin_name)` with no fallback, so an unknown name was an error. Now the same-value fallback runs on any lookup miss, explicit names included, so a typo silently runs the shared file. [grounded: tree libs/node_resolver/resolution.rs] [consensus 3/3: valid=3]
valid · matches d1 · impact high
valid · impact medium
Before the change, a package with no name and a single-entry or same-value bin object still resolved when no sub path was given. Now `resolve_default_bin_name` errors out before those fallbacks are tried. [grounded: tree libs/node_resolver/resolution.rs] [consensus 3/3: valid=3]
valid · impact low
The new `directories.bin` support reuses the `.bin` shim parser. That parser skips files that have an extension and files without a node shebang or shim pattern, so many scripts in a bin directory are dropped. [grounded: tree libs/node_resolver/resolution.rs] [consensus 3/3: valid=3]
valid · impact low
Non-string bin values are now filtered out without an error, so users get a generic missing-entry error instead of the old specific 'non-string sub property of bin' message. Only the error message changes; the resolution still fails. [grounded: tree libs/package_json/lib.rs] [consensus 3/3: valid=3]
valid · impact medium
The old `resolve_binary_commands` returned an empty Vec when package.json was missing. The new code returns MissingPkgJson, and `resolve_managed_npm_commands` passes it up with `?`, so `deno task` fails. [grounded: diff-section libs/node_resolver/resolution.rs] [consensus 3/3: valid=3]
raw comments (6)
libs/node_resolver/resolution.rs:2244
**Unknown bin name runs a different bin** The fallback for "every bin points to the same file" now also runs when the user names a bin explicitly. So `npm:pkg/typo` quietly runs that shared file instead of reporting that the bin doesn't exist. Only use this fallback when no sub path was given. ``` libs/node_resolver/resolution.rs:2240 Some(e) => Ok(e), libs/node_resolver/resolution.rs:2241 None => { libs/node_resolver/resolution.rs:2242 if bins.len() > 1 libs/node_resolver/resolution.rs:2243 && let Some(first) = bins.values().next() libs/node_resolver/resolution.rs:2146 (base) } libs/node_resolver/resolution.rs:2147 (base) Value::Object(o) => { libs/node_resolver/resolution.rs:2148 (base) if let Some(bin_name) = bin_name { ```
libs/node_resolver/resolution.rs:2240
**Single-bin packages no longer run without a subpath** With no bin name given, `resolve_bin_entry_value` drops the old "exactly one entry" fallback. So a package like `@angular/cli`, whose only bin is `ng`, fails. When `bins.len() == 1` and no sub path was given, return the single entry. ``` libs/node_resolver/resolution.rs:2229 package_json: &PackageJson, libs/node_resolver/resolution.rs:2230 bins: &'a BTreeMap<String, PathBuf>, libs/node_resolver/resolution.rs:2231 bin_name: &str, libs/node_resolver/resolution.rs:2232 ) -> Result<&'a Path, AnyError> { libs/node_resolver/resolution.rs:2146 (base) } libs/node_resolver/resolution.rs:2147 (base) Value::Object(o) => { libs/node_resolver/resolution.rs:2148 (base) if let Some(bin_name) = bin_name { libs/node_resolver/resolution.rs:2149 (base) o.get(bin_name) libs/node_resolver/resolution.rs:2150 (base) } else if o.len() == 1 libs/node_resolver/resolution.rs:2151 (base) || o.len() > 1 && o.values().all(|v| v == o.values().next().unwrap()) ```
libs/node_resolver/resolution.rs:762
**Nameless packages can't resolve a default bin** With no sub path, `resolve_binary_export` calls `resolve_default_bin_name` first, which fails when package.json has no `name`. Before, single-entry or same-value object bins still resolved. If the name is missing, still try the single-entry and same-value fallbacks before returning an error. ``` libs/node_resolver/resolution.rs:759 let bin_name = match sub_path { libs/node_resolver/resolution.rs:760 Some(bin_name) => bin_name, libs/node_resolver/resolution.rs:761 None => pkg_json libs/node_resolver/resolution.rs:762 .resolve_default_bin_name() libs/package_json/lib.rs:535 pub fn resolve_default_bin_name( libs/package_json/lib.rs:536 &self, libs/package_json/lib.rs:537 ) -> Result<&str, MissingPkgJsonNameError> { libs/package_json/lib.rs:538 let Some(name) = &self.name else { libs/package_json/lib.rs:539 return Err(MissingPkgJsonNameError { libs/package_json/lib.rs:540 pkg_json_path: self.path.clone(), ```
libs/node_resolver/resolution.rs:803
**`directories.bin` scripts mostly ignored** Bin directories go through the `.bin` shim parser `resolve_npm_commands_from_bin_dir`. It skips files with an extension (like `cli.js`) and any file whose first line isn't exactly `#!/usr/bin/env node`. npm exposes every file there. List the directory's files as bins named after each file, without shim parsing. ``` libs/node_resolver/resolution.rs:801 let items = match bins { libs/node_resolver/resolution.rs:802 deno_package_json::PackageJsonBins::Directory(path_buf) => { libs/node_resolver/resolution.rs:803 self.resolve_npm_commands_from_bin_dir(&path_buf) libs/node_resolver/resolution.rs:804 } libs/package_json/lib.rs:568 _ => { libs/package_json/lib.rs:569 let bin_directory = libs/package_json/lib.rs:570 self.directories.as_ref().and_then(|d| d.get("bin")); libs/package_json/lib.rs:571 match bin_directory { libs/package_json/lib.rs:572 Some(Value::String(bin_dir)) => { libs/package_json/lib.rs:573 let bin_dir = self.dir_path().join(bin_dir); ```
libs/package_json/lib.rs:562
**Non-string bin entries dropped without error** When a bin object has a non-string value, resolve_bins drops it silently. Users get a generic "no bin entry" or "no bin property" error instead of the old "non-string sub property of bin" error. Fix: return an error for non-string values instead of filtering them out. ``` libs/package_json/lib.rs:557 } libs/package_json/lib.rs:558 Some(Value::Object(o)) => Ok(PackageJsonBins::Bins( libs/package_json/lib.rs:559 o.iter() libs/package_json/lib.rs:560 .filter_map(|(key, value)| { libs/node_resolver/resolution.rs:2201 (base) }; libs/node_resolver/resolution.rs:2202 (base) match bin_entry { libs/node_resolver/resolution.rs:2203 (base) Value::String(s) => Ok(s), libs/node_resolver/resolution.rs:2204 (base) _ => bail!( libs/node_resolver/resolution.rs:2205 (base) "'{}' had a non-string sub property of bin", libs/node_resolver/resolution.rs:2206 (base) package_json.path.display(), ```
libs/node_resolver/resolution.rs:791
**Missing package.json now aborts deno task** `resolve_npm_binary_commands_for_package` now returns MissingPkgJson when a top-level package has no package.json. The old `resolve_binary_commands` returned an empty list, and `resolve_managed_npm_commands` passes the error up with `?`. Treat a missing package.json as no bins in the task-runner path. ``` libs/node_resolver/resolution.rs:788 ResolvePkgNpmBinaryCommandsError, libs/node_resolver/resolution.rs:789 > { libs/node_resolver/resolution.rs:790 let pkg_json_path = package_folder.join("package.json"); libs/node_resolver/resolution.rs:791 let Some(package_json) = libs/node_resolver/resolution.rs:746 (base) package_folder: &Path, libs/node_resolver/resolution.rs:747 (base) ) -> Result<Vec<String>, ResolveBinaryCommandsError> { libs/node_resolver/resolution.rs:748 (base) let pkg_json_path = package_folder.join("package.json"); libs/node_resolver/resolution.rs:749 (base) let Some(package_json) = libs/node_resolver/resolution.rs:750 (base) self.pkg_json_resolver.load_package_json(&pkg_json_path)? libs/node_resolver/resolution.rs:751 (base) else { ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · impact low
When package.json was missing, the old resolve_binary_commands returned Ok(Vec::new()). The new shared helper returns a MissingPkgJson error, and resolve_managed_npm_commands passes it up with `?`, so building the task commands now fails. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d1 · impact high
valid · impact low
With no bin name given, the old code returned the only value of a single-entry bin object, or the shared value when all entries matched, without needing a package name. The new code calls resolve_default_bin_name() unconditionally, which errors when the name is missing. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The old code fell back to `o.get(n)` with the full package name. The new code looks up only the last segment of a scoped name, so a bin key equal to the full scoped name is no longer matched. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The old code used the identical-values fallback only when bin_name was None; an explicit name went through o.get and failed if absent. The new fallback runs whenever the lookup misses, so an explicit nonexistent bin name silently returns the first bin. [grounded: diff] [consensus 3/3: valid=3]
raw comments (5)
libs/node_resolver/resolution.rs:793
**Task fails if a top-level package lacks package.json** `resolve_npm_binary_commands_for_package_with_pkg_json` now returns `MissingPkgJson` as an error, and `resolve_managed_npm_commands` propagates it with `?`. The old `resolve_binary_commands` returned an empty list in this case. In resolve_npm_binary_commands_for_package, return an empty map when package.json is missing; keep the error only for resolve_binary_export. ``` libs/node_resolver/resolution.rs:787 (PackageJsonRc, BTreeMap<String, PathBuf>), libs/node_resolver/resolution.rs:788 ResolvePkgNpmBinaryCommandsError, libs/node_resolver/resolution.rs:789 > { libs/node_resolver/resolution.rs:790 let pkg_json_path = package_folder.join("package.json"); ```
libs/node_resolver/resolution.rs:2240
**Single-bin packages no longer resolve by default** With no bin name, `resolve_binary_export` looks up the package's last name segment in the bins map. A package whose `bin` object has one entry under a different key now fails; the old code returned the only entry. In `resolve_bin_entry_value`, return the only entry when `bins.len() == 1`. ``` libs/node_resolver/resolution.rs:752 pub fn resolve_binary_export( libs/node_resolver/resolution.rs:753 &self, libs/node_resolver/resolution.rs:754 package_folder: &Path, libs/node_resolver/resolution.rs:755 sub_path: Option<&str>, ```
libs/node_resolver/resolution.rs:760
**Nameless package.json now fails bin resolution** `resolve_binary_export` now calls `resolve_default_bin_name()` whenever there is no sub_path, and fails if `name` is missing. Before, a bin object with one entry (or all identical values) resolved without needing a package name. Only require the default name when bin is a string, or when a name lookup is actually needed. ``` libs/node_resolver/resolution.rs:759 let bin_name = match sub_path { libs/node_resolver/resolution.rs:760 Some(bin_name) => bin_name, libs/node_resolver/resolution.rs:761 None => pkg_json libs/node_resolver/resolution.rs:762 .resolve_default_bin_name() ```
libs/node_resolver/resolution.rs:757
**Scoped bin keyed by full name not found** The default bin name is now only the last segment of the package name. A `bin` key equal to the full scoped name is no longer found. The old code tried `o.get(name)` with the full name. Also try the full package name as a key before failing. ``` libs/node_resolver/resolution.rs:757 let (pkg_json, items) = self libs/node_resolver/resolution.rs:758 .resolve_npm_binary_commands_for_package_with_pkg_json(package_folder)?; libs/node_resolver/resolution.rs:759 let bin_name = match sub_path { libs/node_resolver/resolution.rs:760 Some(bin_name) => bin_name, ```
libs/node_resolver/resolution.rs:2243
**Unknown bin name falls back to first bin** In `resolve_bin_entry_value`, the all-identical-values fallback now also applies when an explicit sub_path names a nonexistent bin. Before, it applied only when no bin name was given. Apply the identical-values fallback only when sub_path is None. ``` libs/node_resolver/resolution.rs:2243 && let Some(first) = bins.values().next() libs/node_resolver/resolution.rs:2244 && bins.values().all(|path| path == first) libs/node_resolver/resolution.rs:2245 { libs/node_resolver/resolution.rs:2246 return Ok(first); ```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
valid · impact medium
Previously an explicit bin_name on an object bin did `o.get(bin_name)` and errored if missing, letting cli/lib/worker.rs fall back to normal subpath resolution. Now the equal-paths fallback runs for any name that isn't found, including explicit ones, so `npm:pkg/other` returns the binary and the subpath fallback never runs. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The new `PackageJsonBins::Directory` branch passes the directory to `resolve_npm_commands_from_bin_dir`. That scanner was built for `.bin` shims and skips any entry with an extension, so `bin/tool.js` in a `directories.bin` directory is never exposed as a command. The directory support is new in this change, so it ships incomplete. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
libs/node_resolver/resolution.rs:2244
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Sole binary cannot run** A package named `foo` with `"bin": {"bar": "./cli.js"}` now fails on `deno run npm:foo`. The lookup uses `foo`, and `bins.len() > 1` excludes the sole-entry fallback. Previously, the sole value was selected. Preserve that fallback when no binary name was requested.
libs/node_resolver/resolution.rs:2246
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Subpath runs the wrong command** With `"bin": {"a": "./cli.js", "b": "./cli.js"}`, `npm:pkg/other` now runs `cli.js` even though `other` is not a binary name. This skips the caller's fallback that would resolve `other` as a package subpath. Keep the distinction between an omitted name and an explicit name; use the equal-path fallback only for the omitted case.
libs/node_resolver/resolution.rs:803
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Directory commands disappear** The new `directories.bin` branch uses a scanner meant for generated `.bin` shims, which drops every filename with an extension. A package with `"directories": {"bin": "bin"}` and a valid `bin/tool.js` script therefore exposes no `tool.js` command, even with the accepted Node shebang. Enumerate package directory entries separately from generated shims so valid filenames are retained.
PR-level
<!-- greptile_summary --> <h2><a href="https://app.greptile.com/api/retrigger?id=76825668"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a>Confidence Score: 2/5</h2> **[High risk]** Refactors module resolution and dependency trait boundaries\. Fix binary selection and package directory discovery before merging. <h2>Findings</h2> 1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;**Sole binary cannot run** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/117#discussion_r4214147293">▶</a> 2. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;**Subpath runs the wrong command** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/117#discussion_r4214147297">▶</a> 3. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;**Directory commands disappear** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/117#discussion_r4214147300">▶</a> <h3>Summary</h3> This PR moves npm binary discovery into `node_resolver`, adds `directories.bin` support, and launches managed task commands by resolved file path. - Bare entrypoints lose the sole-binary fallback. - Explicit subpaths can select an unrelated binary. - Package binary directories incorrectly inherit filename restrictions from the shim scanner. <details open><summary>Diagram</summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD Package[Package JSON] --> Bins[resolve_bins] Bins --> Map[Named binary paths] Bins --> Directory[Binary directory] Directory --> Scanner[Shim scanner] Scanner --> Map Map --> Entrypoint[resolve_binary_export] Map --> Task[Managed task commands] Entrypoint --> Run[Run selected file] Task --> Run ``` </details> <!-- greptile_confidence_score:2 --> <sub>Reviews (1) · Last reviewed commit: ["Update Cargo.lock and 10 more files"](https://github.com/drape-io/crbench-greptile-2026-09/commit/99d39512f63a1e5c913396a6a51424d0ca36bffb) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_expert&utm_medium=github&utm_campaign=code_reviews&utm_content=drape-io/crbench-greptile-2026-09)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · impact high
The old code returned the single value when `o.len() == 1` and no bin name was given. That branch was removed: the lookup now uses the default bin name, and the fallback only fires when `len > 1`. A single bin whose key differs from the package name, or a package with no name, now errors. The worker.rs fallback returns None when no sub-path is given, so it doesn't rescue this. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The new `PackageJsonBins::Directory` branch passes the directory to the .bin shim scanner. That scanner skips files with extensions and files without a node shebang, so typical files like bin/cli.js in a `directories.bin` folder are never exposed as commands. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d1 · impact high
valid · impact low
Before, an explicit `Some(bin_name)` used `o.get(bin_name)` and errored on a miss. Now any miss falls into the all-same-values fallback, even when the user named the bin explicitly, so a typo silently runs the shared file. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
PR-level
[P1] `deno run npm:‹pkg›` no longer runs a package's only bin when its name differs from the package name libs/node_resolver/resolution.rs:2236-2243 When no sub-path is given, `resolve_binary_export` now looks up the bin by the default bin name, which is the last segment of the package name. If that lookup misses, `resolve_bin_entry_value` only falls back when `bins.len() › 1` and every value is the same path. The old code also accepted a `bin` object with exactly one entry (`o.len() == 1`), and that case is gone. So a package like `@angular/cli` with `"bin": {"ng": ...}` now fails with "did not have a bin entry for 'cli'". The fallback in `cli/lib/worker.rs` (`resolve_binary_entrypoint_fallback`) returns `None` when no sub-path was given, so it doesn't help. The `@angular/cli` failure is an inference from the code; I didn't run it. A related case also broke: `resolve_binary_export` now calls `resolve_default_bin_name()`, and `resolve_bins()` also needs `name` for string bins. A package.json with no `name` therefore errors even though its single bin entry used to resolve.
PR-level
[P2] Packages that use `directories.bin` lose every bin file that has an extension libs/node_resolver/resolution.rs:801-804 The new `PackageJsonBins::Directory` case runs the directory through `resolve_npm_commands_from_bin_dir`. That scanner was written for `node_modules/.bin` shims. It skips any file with an extension ("only look at files without extensions") and only accepts files whose first line is a node shebang or that match the Windows shim pattern. npm adds every file in `directories.bin` as a command. A package with `"directories": {"bin": "./bin"}` and a file like `bin/cli.js` will get no commands from `deno task` and can't be used with `deno run npm:‹pkg›`, so this new feature is incomplete for typical layouts.
libs/node_resolver/resolution.rs:2236
[P1] Packages with a single bin under a different name no longer resolve by default Before this change, `resolve_bin_entry_value` used the only entry when `bin` was an object with exactly one key (`o.len() == 1`). Now, when no sub path is given, it looks up the default name, which is the last segment of the package name. On a miss, the only fallback is the `bins.len() › 1` check for entries that all have the same value. Single-entry maps whose key differs from the package name now fail. Examples are `@angular/cli` (`{"ng": ...}`) and `@playwright/test` (`{"playwright": ...}`). As a result, `deno run npm:@angular/cli` and the bundle path no longer get the package's binary. `resolve_npm_binary_entrypoint` in cli/lib/worker.rs then falls back to normal node resolution, so it silently runs the package's main library export instead of the CLI, or it errors. The `len() == 1` case needs to be kept, for example by using `›= 1` together with the all-same check, or by special-casing a single entry.
libs/node_resolver/resolution.rs:2236
[P3] The all-same-value fallback now also applies to explicitly requested bin names Before, the "all values identical" fallback ran only when no bin name was given; an explicit `Some(bin_name)` that didn't exist was an error. Now `resolve_binary_export` always passes a concrete name, and the fallback runs on any miss. If a package's bins all point to the same file, a typo such as `npm:pkg/nonexistent` silently runs that file instead of reporting the missing entry with the list of possible names. The fallback should only apply when `sub_path` is `None`.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
valid · impact low
The old resolve_binary_commands returned Ok(Vec::new()) when package.json was missing. The new shared helper returns MissingPkgJson instead, and resolve_managed_npm_commands propagates it with `?`, so task command resolution aborts. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
With sub_path None, resolve_default_bin_name is always called and fails for nameless packages. The old code returned the single object entry, or the string bin, without needing a name. [grounded: diff] [consensus 3/3: valid=3]
valid · impact high
The old code returned the sole bin when o.len() == 1 and no name was given. Now bin_name defaults to the last segment of the package name, and a mismatch only falls back when len > 1. Single-bin packages like @angular/cli (bin 'ng') therefore fail, and the worker fallback does not apply because sub_path is None. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
Same issue as findings 1 and 2: a missing package.json now becomes an error that resolve_managed_npm_commands propagates, and nameless single-bin packages now fail in resolve_binary_export. [grounded: diff] [consensus 3/3: valid=3]
raw comments (5)
libs/node_resolver/resolution.rs:2239
[P1] Single-entry `bin` object no longer resolves when its key differs from the package name resolve_bin_entry_value` used to return the sole value whenever the `bin` object had exactly one entry (`o.len() == 1`), whatever its key. It now only does `bins.get(bin_name)`, then falls back only when `bins.len() › 1` and all values are equal. With `resolve_binary_export(.., None)` (used by `deno run npm:pkg` in cli/lib/worker.rs and the bundler), `bin_name` is the package's default name. For a package such as `@scope/foo-cli` with `"bin": {"foo": "./cli.js"}`, or an unscoped package whose single bin has a different name, the lookup misses and returns "did not have a bin entry". The single-entry case needs the fallback restored
libs/node_resolver/resolution.rs:783
[P2] Missing `package.json` in a top-level package now aborts task command resolution The old `resolve_binary_commands` returned `Ok(Vec::new())` when `package.json` was absent. The new `resolve_npm_binary_commands_for_package` goes through a helper that returns `MissingPkgJson` in that case. `resolve_managed_npm_commands` in cli/task_runner.rs propagates that error with `?`. A top-level managed npm package folder without a readable `package.json` therefore fails every `deno task` run instead of being skipped. Only the `resolve_binary_export` path should treat this as an error
libs/node_resolver/resolution.rs:758
[P2] `resolve_binary_export` now requires a package name even when `bin` is an object with a single entry With `sub_path` as `None`, `resolve_default_bin_name()` is called unconditionally and fails with `MissingPkgJsonName` for a nameless `package.json`. Previously a lone `bin` entry (string or object) resolved without needing `name`. This only matters for nameless packages, but it is a behaviour change
libs/node_resolver/resolution.rs:778
[P1] Single-bin packages whose bin name differs from the package name no longer resolve `resolve_binary_export` now sets `bin_name` to the package-name default (`resolve_default_bin_name`) when no sub path is given. In `resolve_bin_entry_value`, the fallback after a failed `bins.get(bin_name)` only applies when `bins.len() › 1` and all paths are equal. The old code returned the sole entry whenever `o.len() == 1`. This breaks `deno run npm:‹pkg›` for packages with exactly one bin whose key differs from the package's last name segment. Example: `@angular/cli` has `bin: {"ng": ...}`, so the default name is `cli` and the lookup fails with "did not have a bin entry for 'cli'". The `len() › 1` guard looks wrong. The fallback should also apply when there is exactly one bin (`!bins.is_empty()`). Callers are cli/lib/worker.rs:732 and cli/tools/bundle/mod.rs:1726.
libs/node_resolver/resolution.rs:581
[P2] A missing package.json now makes custom task command resolution fail (via cli/task_runner.rs `resolve_managed_npm_commands`) `resolve_binary_commands` used to return an empty list when a top-level package had no package.json. `resolve_npm_binary_commands_for_package` now returns `MissingPkgJson` in that case, and `resolve_managed_npm_commands` propagates it with `?`. `deno task` would then abort for every task instead of skipping that package, but only when a top-level package folder lacks a package.json (e.g. a corrupted cache). The same shared helper now also makes `resolve_default_bin_name` fail with `MissingPkgJsonName` for object-form bins in `resolve_binary_export` when no sub path is given and the package has no `name`. The old code accepted that case when there was a single bin entry.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · impact medium
New directories.bin support routes to resolve_npm_commands_from_bin_dir, whose entry resolver rejects any file with an extension, so bin/foo.js in a declared bin directory is never registered. [grounded: tree libs/node_resolver/resolution.rs] [consensus 3/3: valid=3]
valid · matches d1 · impact high
valid · impact low
Previously an explicit missing bin name in an object bin errored (o.get(bin_name) → None); now resolve_binary_export always passes a concrete name and the identical-target fallback returns the shared binary for any missing name, including typos. [grounded: tree libs/node_resolver/resolution.rs] [consensus 3/3: valid=3]
raw comments (5)
libs/node_resolver/resolution.rs:804
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 2\. Directory-declared javascript bins vanish <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>resolve_npm_binary_commands_for_package_with_pkg_json</i></b> sends <b><i>directories.bin</i></b> to the <b><i>.bin</i></b> shim scanner, which rejects filenames with extensions before reading them. For a package declaring <b><i>&quot;directories&quot;: {&quot;bin&quot;: &quot;./bin&quot;}</i></b> with <b><i>bin/foo.js</i></b>, the command map omits <b><i>foo</i></b>, so task registration cannot expose it and default npm binary resolution cannot find it. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The new directories.bin path uses a scanner for extensionless npm shims, discarding ordinary JavaScript executables in the declared directory. ## Fix Focus Areas - libs/node_resolver/resolution.rs[798-805] - libs/node_resolver/resolution.rs[810-864] ## Recommended Fix Resolve directories.bin entries with directory-bin rules rather than .bin shim rules. Preserve the existing shim scanner for node_modules/.bin and add a test with a directories.bin entry named foo.js. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details> [Dismiss ↗](https://app.qodo.ai/findings/ba455da6-1dd1-4e92-b2e7-84845a421736?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/ba455da6-1dd1-4e92-b2e7-84845a421736)
libs/node_resolver/resolution.rs:2247
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 1\. Packages with one differently-named bin no longer run <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>resolve_binary_export</i></b> calls <b><i>resolve_default_bin_name()?</i></b> before inspecting the bins, while <b><i>resolve_bin_entry_value</i></b> no longer returns the sole entry when its key differs from the package-derived name. For an npm specifier without a subpath, such as <b><i>npm:@angular/cli</i></b> with a single <b><i>ng</i></b> bin, binary resolution now fails; a nameless package with a single bin fails at the earlier name lookup. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description An npm specifier without a subpath no longer resolves a package's sole bin when its key differs from the package name, such as `@angular/cli` with `ng`. A nameless package with a single bin also fails because default-name resolution runs before bin inspection. ## Fix Focus Areas - libs/node_resolver/resolution.rs[752-772] - libs/node_resolver/resolution.rs[2228-2250] ## Recommended Fix Make `resolve_bin_entry_value` accept `bin_name: Option<&str>` and preserve whether the caller omitted the subpath. When it is `None`, return the sole entry if `bins.len() == 1`; for multiple entries, return the first if all values are equal, and otherwise look up `package_json.resolve_default_bin_name()`. In `resolve_binary_export`, do not call `resolve_default_bin_name()?` up front; pass `sub_path` through. Add regression tests for a single bin whose key differs from the package name and for a nameless package with a single bin. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details> [Dismiss ↗](https://app.qodo.ai/findings/963642f6-01f5-4c8f-b874-454077914fa5?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/963642f6-01f5-4c8f-b874-454077914fa5)
libs/node_resolver/resolution.rs:2247
<img src="https://img.shields.io/badge/Low-634FD1?style=flat-square" height="20px" alt="Informational"> 3\. Typo'd bin names silently run another binary <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>resolve_bin_entry_value</i></b> applies the identical-target fallback to a missing explicit bin name because <b><i>resolve_binary_export</i></b> passes both explicit subpaths and default names through the same parameter. When a package has multiple bins pointing to the same file, <b><i>npm:pkg/tool</i></b> can run that file instead of reaching ordinary package-subpath resolution, even if <b><i>tool</i></b> was the intended subpath. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description A missing explicit bin name is treated as a default-bin request when multiple bin names share a target, preventing ordinary package-subpath resolution. ## Fix Focus Areas - libs/node_resolver/resolution.rs[752-771] - libs/node_resolver/resolution.rs[2228-2250] ## Recommended Fix Carry whether the subpath was explicit into bin lookup, using an `Option<&str>` or an explicitness flag. Apply the identical-target fallback only when no subpath was provided, and test an explicit subpath absent from a shared-target bin map. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details> [Dismiss ↗](https://app.qodo.ai/findings/71c4c997-07b5-436f-96c5-be72cd79443c?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/71c4c997-07b5-436f-96c5-be72cd79443c)
PR-level
<h3>PR Summary by Qodo</h3> Unify npm binary resolution across tasks and package exports <code>✨ Enhancement</code> <code>🕐 20-40 Minutes</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <details> <summary>AI Description</summary> <dl> <dd> <br/> ><pre> >• Centralize npm binary discovery so tasks and package exports use shared resolution logic. >• Support package bin directories and run managed npm binaries directly by resolved path. >• Move shim parsing into the node resolver and update binary-resolution tests. ></pre> </dd> </dl> </details> <details> <summary>Diagram</summary> <dl> <dd> <br/> ```mermaid graph TD A["Task runner"] --> B{"npm mode"} -->|managed| C["Package bins"] --> F["Command paths"] --> G["Deno runner"] B -->|BYONM| D["Bin directory"] --> F C -->|directory bins| D E["Node resolver"] --> C E --> D ``` </dd> </dl> </details> <details> <summary>High-Level Assessment</summary> <dl> <dd> <br/> >The following are alternative approaches to this PR: <details> <summary><b>1. Keep binary discovery in the CLI</b></summary> <dl> <dd> - ➕ Smaller immediate change to resolver and filesystem traits. - ➖ Duplicates bin-directory handling and leaves task execution separate from package-export resolution. </dd> </dl> </details> >**Recommendation:** Prefer the shared resolver approach: it gives tasks and package exports one source for binary paths and enables directory-based bins. Review the changed managed-task execution behavior and missing-package-json errors carefully. </dd> </dl> </details> <details> <summary> Files changed (11) <code> +493 / -418 </code> </summary> <dl> <dd> <br/> <details> <summary>Enhancement (3) <code> +466 / -394 </code></summary> <dl> <dd> <details> <summary>task_runner.rs<code>Run npm task commands from resolved binary paths</code> <code>+26/-175</code></summary> <br/> >Run npm task commands from resolved binary paths > ><pre> >• Delegates bin-directory discovery to the node resolver and wraps returned paths as Deno-run commands. Managed tasks no longer construct npm specifiers for each binary; the CLI-local shim parser and its test are removed. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-0022f87807f9b3123b4ce162db890e6437b04d086fcc2f3b93871c9659f2b864'>cli/task_runner.rs</a> </details> <details> <summary>resolution.rs<code>Centralize package bin and shim resolution</code> <code>+377/-217</code></summary> <br/> >Centralize package bin and shim resolution > ><pre> >• Resolves package binaries to paths using package-json metadata or a filesystem-backed bin-directory scan, and reuses those paths for binary exports. Moves shim parsing and its tests from the CLI, and updates export-selection tests and suggestions. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-22ed91feda1c5db86f62d5fdb616a785d0ec5fd27393cfbcc000bb70d10e7221'>libs/node_resolver/resolution.rs</a> </details> <details> <summary>lib.rs<code>Expose package binary names and paths</code> <code>+63/-2</code></summary> <br/> >Expose package binary names and paths > ><pre> >• Adds helpers for default binary names and for resolving string, object, or directories.bin declarations into binary paths or a directory. Introduces a typed error for packages without a name when one is required. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-f715424f50f88ae3d914ed38fd5258fab54b5acd35e9bca25789b7edb3be4f7b'>libs/package_json/lib.rs</a> </details> </dd> </dl> </details> <details> <summary>Refactor (6) <code> +25 / -24 </code></summary> <dl> <dd> <details> <summary>task.rs<code>Adjust task command resolution calls</code> <code>+2/-2</code></summary> <br/> >Adjust task command resolution calls > ><pre> >• Updates both task execution paths to pass the resolvers in the new argument order. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-25b821ac9f791d719c4d772c106c89752c2da633d53159d615e048990ccc9613'>cli/tools/task.rs</a> </details> <details> <summary>lib.rs<code>Adopt the expanded node resolver filesystem trait</code> <code>+1/-5</code></summary> <br/> >Adopt the expanded node resolver filesystem trait > ><pre> >• Makes ExtNodeSys extend NodeResolverSys, providing the directory-reading capability required by shared binary discovery. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-c9f6cb73bda1dc25a81e980cfeac68ecbf34e91a3ee5813611cc6c5d66dd28a1'>ext/node/lib.rs</a> </details> <details> <summary>require.rs<code>Remove redundant require filesystem trait imports</code> <code>+0/-2</code></summary> <br/> >Remove redundant require filesystem trait imports > ><pre> >• Removes imports now supplied through ExtNodeSys&#x27;s updated trait bound. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-b5b56b3d6859a904efd649cd3015aa52450f340cd6632dd1d94971f4aca9750e'>ext/node/ops/require.rs</a> </details> <details> <summary>worker_threads.rs<code>Remove redundant worker filesystem trait imports</code> <code>+0/-2</code></summary> <br/> >Remove redundant worker filesystem trait imports > ><pre> >• Removes imports made unnecessary by the updated ExtNodeSys bound. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-8f2e8d76bdd3b6cd08a2d30415a859790031b7240e6ba68564cefc2e7fa51acb'>ext/node/ops/worker_threads.rs</a> </details> <details> <summary>analyze.rs<code>Align CJS analysis filesystem bounds</code> <code>+7/-6</code></summary> <br/> >Align CJS analysis filesystem bounds > ><pre> >• Introduces a CJS analyzer system trait based on NodeResolverSys and reuses it for code translation. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-e96471a25f74f74faff0a1d1161feb94ed3d65560972065310bde27793420001'>libs/node_resolver/analyze.rs</a> </details> <details> <summary>errors.rs<code>Restructure npm binary resolution errors</code> <code>+15/-7</code></summary> <br/> >Restructure npm binary resolution errors > ><pre> >• Adds a missing-package-json error and separates package binary discovery errors from binary-export selection errors. Missing package names now use the package-json crate&#x27;s error type. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-67c6c2a8283ec289509ed98d35ecc25b9392f9fcf285bbfe5391fd0860275c07'>libs/node_resolver/errors.rs</a> </details> </dd> </dl> </details> <details> <summary>Other (2) <code> +2 / -0 </code></summary> <dl> <dd> <details> <summary>Cargo.lock<code>Record node resolver logging dependency</code> <code>+1/-0</code></summary> <br/> >Record node resolver logging dependency > ><pre> >• Adds log to the node resolver&#x27;s recorded dependencies. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-13ee4b2252c9e516a0547f2891aa2105c3ca71c6d7a1e682c69be97998dfc87e'>Cargo.lock</a> </details> <details> <summary>Cargo.toml<code>Enable resolver debug logging</code> <code>+1/-0</code></summary> <br/> >Enable resolver debug logging > ><pre> >• Adds the workspace log dependency for bin-directory discovery diagnostics. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-609738eaeef541ca012d0a99086f57ae1020522e96d0322313c09ea1fd30eda6'>libs/node_resolver/Cargo.toml</a> </details> </dd> </dl> </details> </dd> </dl> </details>
PR-level
<h3>Code Review by Qodo</h3> <code>🐞 Bugs (3)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <br/> <img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> <details> <summary> 1. Packages with one differently-named bin no longer run <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>resolve_binary_export</i></b> calls <b><i>resolve_default_bin_name()?</i></b> before inspecting the bins, while ><b><i>resolve_bin_entry_value</i></b> no longer returns the sole entry when its key differs from the >package-derived name. For an npm specifier without a subpath, such as <b><i>npm:@angular/cli</i></b> with a >single <b><i>ng</i></b> bin, binary resolution now fails; a nameless package with a single bin fails at the >earlier name lookup. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[libs/node_resolver/resolution.rs[R2242-2247]](https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-22ed91feda1c5db86f62d5fdb616a785d0ec5fd27393cfbcc000bb70d10e7221R2242-R2247)</code> > >```diff >+ if bins.len() > 1 >+ && let Some(first) = bins.values().next() >+ && bins.values().all(|path| path == first) >+ { >+ return Ok(first); >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The removed code returned the only bin value when the object had one entry, but the new first-entry >fallback requires multiple entries with equal paths. <b><i>resolve_binary_export</i></b> derives the default >name before the bin lookup, so a nameless package fails even if it has one bin. Worker startup calls >this resolver with no subpath for an npm specifier that omits one, and ><b><i>resolve_binary_entrypoint_fallback</i></b> returns <b><i>Ok(None)</i></b> in that case, leaving the resolution error >to reach the user. ></pre> > > <code>[libs/node_resolver/resolution.rs\[752-772\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L752-L772)</code> > <code>[libs/node_resolver/resolution.rs\[2228-2250\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L2228-L2250)</code> > <code>[cli/lib/worker.rs\[723-767\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/cli/lib/worker.rs/#L723-L767)</code> > <code>[cli/tools/bundle/mod.rs\[1720-1730\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/cli/tools/bundle/mod.rs/#L1720-L1730)</code> > <code>[libs/node_resolver/resolution.rs\[752-771\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L752-L771)</code> > <code>[libs/node_resolver/resolution.rs\[2228-2247\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L2228-L2247)</code> > <code>[cli/lib/worker.rs\[724-751\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/cli/lib/worker.rs/#L724-L751)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >An npm specifier without a subpath no longer resolves a package's sole bin when its key differs from the package name, such as `@angular/cli` with `ng`. A nameless package with a single bin also fails because default-name resolution runs before bin inspection. > >## Fix Focus Areas >- libs/node_resolver/resolution.rs[752-772] >- libs/node_resolver/resolution.rs[2228-2250] > >## Recommended Fix >Make `resolve_bin_entry_value` accept `bin_name: Option<&str>` and preserve whether the caller omitted the subpath. When it is `None`, return the sole entry if `bins.len() == 1`; for multiple entries, return the first if all values are equal, and otherwise look up `package_json.resolve_default_bin_name()`. In `resolve_binary_export`, do not call `resolve_default_bin_name()?` up front; pass `sub_path` through. Add regression tests for a single bin whose key differs from the package name and for a nameless package with a single bin. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> [Dismiss ↗](https://app.qodo.ai/findings/963642f6-01f5-4c8f-b874-454077914fa5?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/963642f6-01f5-4c8f-b874-454077914fa5) <hr/> </details> <br/> <img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> <details> <summary> 2. Directory-declared JavaScript bins vanish <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>resolve_npm_binary_commands_for_package_with_pkg_json</i></b> sends <b><i>directories.bin</i></b> to the <b><i>.bin</i></b> shim >scanner, which rejects filenames with extensions before reading them. For a package declaring ><b><i>&quot;directories&quot;: {&quot;bin&quot;: &quot;./bin&quot;}</i></b> with <b><i>bin/foo.js</i></b>, the command map omits <b><i>foo</i></b>, so task >registration cannot expose it and default npm binary resolution cannot find it. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[libs/node_resolver/resolution.rs[R802-804]](https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-22ed91feda1c5db86f62d5fdb616a785d0ec5fd27393cfbcc000bb70d10e7221R802-R804)</code> > >```diff >+ deno_package_json::PackageJsonBins::Directory(path_buf) => { >+ self.resolve_npm_commands_from_bin_dir(&path_buf) >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Package JSON resolution produces a Directory variant, and the changed dispatch uses the shim scanner >for it. That scanner rejects foo.js at its extension check, while the task runner registers only >returned command-map entries. ></pre> > > <code>[libs/package_json/lib.rs\[568-579\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/package_json/lib.rs/#L568-L579)</code> > <code>[libs/node_resolver/resolution.rs\[798-805\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L798-L805)</code> > <code>[libs/node_resolver/resolution.rs\[836-853\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L836-L853)</code> > <code>[cli/task_runner.rs\[469-482\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/cli/task_runner.rs/#L469-L482)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The new directories.bin path uses a scanner for extensionless npm shims, discarding ordinary JavaScript executables in the declared directory. >## Fix Focus Areas >- libs/node_resolver/resolution.rs[798-805] >- libs/node_resolver/resolution.rs[810-864] >## Recommended Fix >Resolve directories.bin entries with directory-bin rules rather than .bin shim rules. Preserve the existing shim scanner for node_modules/.bin and add a test with a directories.bin entry named foo.js. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> [Dismiss ↗](https://app.qodo.ai/findings/ba455da6-1dd1-4e92-b2e7-84845a421736?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/ba455da6-1dd1-4e92-b2e7-84845a421736) <hr/> </details> <br/> <img src="https://img.shields.io/badge/Low-634FD1?style=flat-square" height="20px" alt="Informational"> <details> <summary> 3. Typo&#x27;d bin names silently run another binary <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>resolve_bin_entry_value</i></b> applies the identical-target fallback to a missing explicit bin name >because <b><i>resolve_binary_export</i></b> passes both explicit subpaths and default names through the same >parameter. When a package has multiple bins pointing to the same file, <b><i>npm:pkg/tool</i></b> can run that >file instead of reaching ordinary package-subpath resolution, even if <b><i>tool</i></b> was the intended >subpath. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[libs/node_resolver/resolution.rs[R2239-2247]](https://github.com/drape-io/crbench-qodo-2026-09/pull/117/files#diff-22ed91feda1c5db86f62d5fdb616a785d0ec5fd27393cfbcc000bb70d10e7221R2239-R2247)</code> > >```diff >+ match bins.get(bin_name) { >+ Some(e) => Ok(e), > None => { >+ if bins.len() > 1 >+ && let Some(first) = bins.values().next() >+ && bins.values().all(|path| path == first) >+ { >+ return Ok(first); >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> ><b><i>resolve_binary_export</i></b> passes an explicit <b><i>sub_path</i></b> or the default name as <b><i>bin_name</i></b>, losing the >distinction between them. Previously, the all-equal fallback ran only when <b><i>bin_name</i></b> was <b><i>None</i></b>, >while lookup of a missing explicit name returned <b><i>None</i></b>; the new fallback accepts that missing name >when all targets match, and the worker attempts ordinary package-subpath resolution only after >binary resolution returns an error. ></pre> > > <code>[libs/node_resolver/resolution.rs\[759-764\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L759-L764)</code> > <code>[libs/node_resolver/resolution.rs\[2239-2247\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L2239-L2247)</code> > <code>[libs/node_resolver/resolution.rs\[752-766\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/libs/node_resolver/resolution.rs/#L752-L766)</code> > <code>[cli/lib/worker.rs\[724-786\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fbe056efc7733daab02d57efbff203b218b85fb6/cli/lib/worker.rs/#L724-L786)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >A missing explicit bin name is treated as a default-bin request when multiple bin names share a target, preventing ordinary package-subpath resolution. > >## Fix Focus Areas >- libs/node_resolver/resolution.rs[752-771] >- libs/node_resolver/resolution.rs[2228-2250] > >## Recommended Fix >Carry whether the subpath was explicit into bin lookup, using an `Option<&str>` or an explicitness flag. Apply the identical-target fallback only when no subpath was provided, and test an explicit subpath absent from a shared-target bin map. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> [Dismiss ↗](https://app.qodo.ai/findings/71c4c997-07b5-436f-96c5-be72cd79443c?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/71c4c997-07b5-436f-96c5-be72cd79443c) <hr/> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-context:start --> <details><summary><strong>Context sources</strong></summary> <div>Review mode: <code>Auto: 🧠 Deep</code>: Broad resolver refactor spans many independent, bug-prone behavior paths.</div> <!-- qodo-context:end --> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:start --> <details> <summary><strong>Tip of the day</strong></summary> <br/> <pre>💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link</pre> <a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:end --> <!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/fbe056efc7733daab02d57efbff203b218b85fb6 --> <a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>