dsh-which: Command Resolution Forensics — See Who Wins and Who Gets Blocked on PATH

Introduction

When having agents execute node, python, or project scripts in DSH, shell resolution rules often outlive memory: PATH ordering, PATHEXT on Windows, executable bits, and built-in command short-circuiting all together determine “which file actually runs when you type that name.” A common situation is that the command works, but it’s not the one you think—two Node installations are both on PATH, and nothing will actively tell you which one is the winner.

The system-bundled which is unavailable on Windows, and even where it exists, it usually only answers “who was found,” not “who was skipped.” dsh-which is a plugin for DeepSeek Harness that organizes resolution results, shadowed same-name copies, PATH health itself, and (optionally) versions reported by each copy into a readable diagnostic report.

What Is This

dsh-which (GitHub: 11111353535/dsh-which, maintainer 11111353535) is positioned as Command resolution forensics: reporting which file a command actually resolves to, which same-name paths it shadows, what shape PATH has, and whether multiple copies agree on version claims. The community catalog classifies it as admin-security.

The plugin does not modify PATH; the README explicitly states it only produces reports, avoiding silent environment rewriting.

Differences from which (Design Motivation)

The following points come from the official README, explaining why a separate set of resolution logic was built:

  1. There is no universal which on Windows; environments that have which also cover a narrower set of problems.
  2. Using the shell’s own resolver to explain “resolution rules” amounts to trusting the object being debugged. This plugin reimplements the rules in lib/resolve.js as pure functions with an injectable file system, making it easy to test with fixtures.
  3. Built-in commands (like cd) are not files; the plugin marks them as builtin and notes that PATH was not consulted.
  4. Diagnostic value often lies in shadowed entries: a global old installation blocking a local new one, a .cmd shim blocking the real binary, files that exist but are not executable, etc.
  5. By default it does not modify PATH, avoiding “fix the environment” style plugins silently breaking machines.

Core Capabilities: Four Tools

After installation, the following tools are exposed through Cordis (names and parameters per the README).

which_resolve

Resolves a single command name or explicit path, outputting the winner, type, which PATH entry it came from, size, modification time, etc.; optionally performs version probing on the winner and shadowed copies.

Parameter Description
command (required) Command name (e.g. node) or path (e.g. ./build.sh)
probe Run version probing on the winner
probeShadowed Also probe shadowed copies, for version comparison

Explicit paths do not consult PATH; the report will state given as a path, PATH was not consulted. Not resolving is also a valid answer (e.g. not found, with an explanation that the name exists on PATH but has no executable).

which_path

Lists each PATH entry in resolution order: duplicates, directories that no longer exist (dead entries), unexpanded variables, etc.; by default omits /usr/bin and similar “noise” directories, can be turned on with showNoise.

Parameter Description
showNoise Whether to include common system directories
limit Maximum number of entries to list, default 40

which_env

A one-page summary of the command environment: platform, shell, working directory, PATH summary, PATHEXT (Windows), and where each runtime in the runtimes list from config resolves to.

Parameter Description
limit Maximum number of runtimes to list, default 30

which_sweep

Scans a specified directory for scripts that look like command names, explaining item by item “if only this directory had this name, would global resolution go elsewhere.”

Parameter Description
directory (required) Absolute path or relative to workspace
limit Maximum number of rows, default 60

Installation and Configuration

Run the official installation command in the DSH environment:

dsh plugin add https://github.com/11111353535/dsh-which

If installing from a local checkout directory, use an absolute path:

dsh plugin add /absolute/path/to/dsh-which

Optional configuration is written in the profile’s cordis.patch.yml, with the plugin id being which:

- id: which
  name: 'dsh-which'
  config:
    probeByDefault: false        # Run version probing on every resolution
    probeShadowedByDefault: false # Also probe shadowed copies
    probeTimeoutMs: 4000
    maxSweepFiles: 400
    runtimes: [node, npm, pnpm, python, git]
Config Key Default Purpose
probeTimeoutMs 4000 Version probe timeout (milliseconds)
probeByDefault false Whether to probe every resolution by default (slower)
probeShadowedByDefault false Whether to probe shadowed copies by default
maxSweepFiles 400 Maximum number of files checked in one sweep
runtimes see README table List of common command names for which_env to resolve

Probing is disabled by default because it spawns child processes; the README states that if every invocation adds a few extra seconds of waiting, users will often turn the feature off.

package.json specifies the engine requirement as Node ^22.19.0 || >=24.0.0, license MIT, current version 0.1.0.

Typical Output Examples

When resolving node, the report marks the winner, the PATH index it comes from, other directories it shadows, and warnings when versions disagree (the one that actually executes is the one earlier in PATH order):

dsh-which · node
  winner:   C:\Program Files\nodejs\node.EXE
  kind:     native binary
  from:     PATH[0]  C:\Program Files\nodejs
  ...
  shadowed — 1 other directory holds this name:
    PATH[6]  C:\Users\me\scoop\shims\node.EXE  ...
      ↳ reports v20.11.1

  ⚠ the copies behind this name report different versions — the one that runs is the one at PATH[0].

When viewing PATH shape, it counts duplicates and dead entries, and warns about problems like “you changed PATH in one place but the duplicate remains in another.”

Typical agent-side usage: when the environment is abnormal, versions don’t match, or a script “is clearly in the directory but runs the wrong one,” call which_resolve or which_env first, then probe / probeShadowed as needed; when a project script directory conflicts with global commands, use which_sweep for comparison.

Use Cases and Notes

Who it’s for: developers and operators who need to do command and environment forensics inside DSH / agent sessions—multiple runtime versions, package manager shims, PATH being repeatedly prepended by installers, or silent failures like “the command exists but is not executable.”

Permissions and security: the plugin runs with the permissions and environment of the current dsh process, reading PATH, probing executables, and launching child processes when probing is enabled. Before installing, you should review the source code and MIT license on GitHub to confirm it meets your security policy; the community catalog (SkillHub) is an independent site, with no official affiliation with DeepSeek / High-Flyer, and should not be treated as an official app store.

Limitations: it only produces diagnostic reports and does not edit PATH; sweeping large directories is limited by maxSweepFiles; version probing is disabled by default and must be explicitly turned on via tool parameters or configuration when needed.

Conclusion

dsh-which lays out the resolution decisions the shell has already made as a structured report: who wins, who gets blocked, whether PATH is duplicated or incomplete, whether same-name copies agree on versions. In the DSH ecosystem of “everything is a plugin,” it belongs to the admin-security class of auxiliary capabilities, used to reduce the time spent debugging “the command works but it’s not the one you think.”

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye