NAME
Developer::Dashboard::CLI::Which - lightweight command and hook locator
SYNOPSIS
use Developer::Dashboard::CLI::Which ();
Developer::Dashboard::CLI::Which::run_which_command(
command => 'which',
args => \@ARGV,
);
# d2 which [--edit] jq
DESCRIPTION
Implements the lightweight d2 which helper so the public entrypoint can show the resolved runnable file plus the participating hook files for a built-in command, layered custom command, or dotted skill command without loading the full runtime. When users pass --edit, it re-enters the public d2 open-file command with the resolved command file path instead of printing the inspection output.
PURPOSE
This module is the command runtime behind d2 which. It resolves the actual runnable file that the switchboard or skill dispatcher will exec, then lists the hook files that will run before that target so contributors can see the real execution chain.
WHY IT EXISTS
It exists because command resolution now spans built-in staged helpers, layered custom commands, and dotted skill commands. Without one lightweight locator, users would have to inspect multiple runtime roots by hand to understand which file wins and which hooks will participate.
WHEN TO USE
Use this file when changing the public d2 which contract, the way the switchboard resolves built-in versus custom commands, or the way skill command and hook discovery should be presented for debugging, or the way --edit hands off to d2 open-file.
HOW TO USE
Call run_which_command(command => 'which', args => \@ARGV). The module builds a lightweight path registry, detects whether the target is a built-in helper, a layered custom command, or a dotted skill command, then prints one COMMAND /full/path line followed by zero or more HOOK /full/path lines in the same order the runtime would execute them: the main-gate hooks (every executable file directly under a layer's hooks/ directory, deepest layer first and the home layer last) come before the per-command <command>.d/ hooks, because the switchboard runs the main gate once before it resolves the command. When users add --edit, the module skips the printed inspection output and re-enters d2 open-file with the resolved command file path so the existing editor-selection behavior is reused.
WHAT USES IT
It is used by the staged which private helper, by CLI smoke tests that pin the visible shell contract, by users who want to open the resolved command file through the public d2 open-file path, and by contributors debugging DD-OOP-LAYERS command resolution and skill hook chains.
EXAMPLES
d2 which jq
d2 which layered-tool
d2 which example-skill.run-test
d2 which example-skill.level1.level2.here
d2 which --edit jq