Expand description
Detect project roots and technology stacks from generic process metadata.
what-stack is a small standalone library. It does not depend on Docker,
socket collection, async runtimes, logging, serialization, CLI parsing, or
any application-specific types. Callers pass ordinary strings and paths:
image names, project directories, process names, executable paths, working
directories, and command-line arguments.
§Detection Model
The crate exposes focused single-purpose functions plus StackDetector
for repeated lookups with caching:
detect_from_imageparses container or artifact image names.detect_from_configscans one project-root directory for known project files.detect_from_processmaps known runtime, server, database, and tool executable names;detect_from_process_namesadds an executable-name fallback.find_project_rootwalks upward from one directory until it finds a project marker.resolve_project_rootapplies the project-root fallback order used by process collectors: current working directory, executable parent, then absolute command-line argument parents.StackDetectorcombines those rules and caches filesystem results.
Every detected StackLabel carries a StackKind (runtime, framework,
tool, database, or service).
High-level stack detection in StackDetector::detect_stack uses this
priority:
- Image label.
- Process label, when it is final (framework, database, or service).
- Project config label.
- Process label (runtime or tool).
Config labels are guarded: a project config is used only when the process
is a known runtime or tool, or when the process is unknown but its
executable belongs to the project. This keeps a postgres or
nginx process started from a Next.js folder labeled as itself, and keeps
unrelated helper shells from inheriting a project’s framework label just
because their working directory happens to be inside that project.
Config labels are also ecosystem-aware: a known runtime or tool accepts
only config labels from its own ecosystem. In a Laravel project with
vite.config.js, php is Laravel and node is Vite; a python
process in a Next.js folder stays Python.
§Scope
This crate only detects labels. It does not discover running processes, inspect network ports, query container engines, kill processes, read custom rule files, or format user-facing output.
§Examples
Direct image and process detection:
use what_stack::{StackKind, detect_from_image, detect_from_process};
let nginx = detect_from_image("ghcr.io/org/nginx:latest").expect("known image");
assert_eq!(nginx, "Nginx");
assert_eq!(nginx.kind(), StackKind::Service);
assert_eq!(detect_from_process("node.exe").expect("known process"), "Node.js");Cached high-level detection:
use what_stack::{StackDetector, StackInput};
let mut detector = StackDetector::new();
let label = detector.detect_stack(StackInput::new("").image("redis:7-alpine"));
assert_eq!(label.expect("known image"), "Redis");Structs§
- Project
Input - Process-like path inputs used to resolve a project root.
- Stack
Detector - Cache-owning detector for repeated stack and project lookups.
- Stack
Input - Inputs used by
StackDetectorto resolve a stack. - Stack
Label - Human-readable application, framework, runtime, or service label.
Enums§
- Stack
Kind - Broad category of a detected
StackLabel.
Constants§
- MAX_
WALK_ DEPTH - Maximum number of directories tested during one upward project walk.
Functions§
- detect_
from_ config - Detect a stack label from configuration files in a project root.
- detect_
from_ image - Detect a stack label from a container or artifact image name.
- detect_
from_ process - Detect a stack label from a process executable name.
- detect_
from_ process_ names - Detect a stack label from a process name, falling back to an executable name.
- find_
project_ root - Walk upward from
startlooking for project marker files. - home_
dir - Return the current user’s home directory, when it can be determined.
- project_
name - Return the display name for a project root path.
- resolve_
project_ root - Resolve a project root from process-like path inputs without caching.