LPM-cli

lpm query

CSS-like selector queries against installed packages and behavioral tags.

lpm query <selector> [flags]

Selector engine that targets behavioral tags, package state, and dependency relationships across the installed set. Pairs with lpm auditaudit is the broad report; query is the precision tool.

Use it in CI to gate on specific risky combinations, in shells to grep through installed packages by behavior, or in agents to ask structured questions about the dep tree.

Examples

lpm query :eval                                    # any package that uses eval()
lpm query :network                                 # any package making outbound HTTP
lpm query :scripts:not(:built)                     # has lifecycle scripts but they haven't run
lpm query ":root > :network"                       # direct deps that hit the network
lpm query "#lodash"                                # find lodash in the tree
lpm query :critical --assert-none                  # CI gate: fail if any critical-tagged pkg
lpm query --count                                  # tag counts across all packages
lpm query :eval --format mermaid > eval-graph.mmd  # subgraph diagram

Selectors

Each selector matches packages by behavioral tag, state, or identity. Tags are computed by the same static analysis pipeline that backs lpm audit.

Behavioral tags

TagMatches packages that
:evalUse eval, Function(), or vm.runInThisContext
:networkMake outbound HTTP / WS connections
:fsTouch the filesystem outside their own directory
:shellSpawn shells (spawn, exec, execSync)
:child-processUse child_process (any form)
:nativeShip native modules (.node, .wasm)
:cryptoUse cryptographic primitives
:dynamic-requireUse dynamic require() (variable arg)
:envRead process.env
:wsUse WebSockets
:obfuscatedShow signs of code obfuscation
:high-entropyContain high-entropy string blobs
:minifiedShip minified-only source
:telemetryMake telemetry / analytics calls
:url-stringsContain URL string literals
:trivialTiny — measured by AST node count
:protestwareMatch a curated list of known protest-license / sabotage packages

Dependency state

TagMatches
:git-depInstalled from a git URL
:http-depInstalled from an HTTP tarball URL
:wildcard-depDeclared with * or latest
:copyleftCopyleft license (GPL family)
:no-licenseNo license field
:scriptsDeclares lifecycle scripts (preinstall/postinstall/etc.)
:builtLifecycle scripts have been run (the package is in the trust set + executed)
:vulnerableListed in OSV / registry advisories
:deprecatedMarked deprecated by the publisher

Origin

TagMatches
:lpm@lpm.dev/* packages
:npmnpm packages

Severity

Severity selectors are aliases — each one expands to an OR of the underlying behavioral tags assigned to that level. Useful for "fail on any critical" gates without enumerating the tags by hand.

TagExpands to
:critical:obfuscated OR :protestware OR :high-entropy
:high:eval OR :child-process OR :shell OR :dynamic-require OR :scripts OR :vulnerable
:medium:network OR :git-dep OR :http-dep OR :wildcard-dep OR :no-license OR :native
:info:fs OR :crypto OR :env OR :ws OR :telemetry OR :trivial OR :copyleft OR :minified OR :url-strings

Structural

TagMatches
:rootThe invocation root — the package.json closest to where the command ran
:workspace-rootThe workspace container in a monorepo (same as :root outside monorepos, distinct when invoked from a workspace member)

Combinators

CombinatorMeaning
:a:bAND — package matches both tags
:a, :bOR — package matches either tag
:not(:a)NOT — package doesn't match :a
#nameIdentity — match a specific package by name
:root > :childDirect-dep — :child is a direct dependency of :root

CI gating

lpm query :critical --assert-none

Exits non-zero if any package matches the selector. Use to fail the build on specific risky combinations:

# fail on a vulnerable package that hasn't been patched
lpm query ":vulnerable:not(:built)" --assert-none

# fail on a transitively-pulled package that uses eval AND has lifecycle scripts
lpm query ":eval:scripts" --assert-none

--assert-none is the canonical CI-gate flag. For broader gating with severity policies, lpm audit --fail-on is usually a better fit.

Counts and details

lpm query --count

Tabulates tag counts across every installed package, grouped by severity. Useful for high-level "how risky is my tree right now" surveys.

lpm query :network --query-verbose

Human list output includes a second tags: line for each matched package that carries behavioral tags. --query-verbose keeps the same human shape and includes the full analysis fields in JSON output.

Output formats

lpm query :eval --format list      # default — names, one per line
lpm query :eval --format mermaid   # Mermaid subgraph diagram
FormatOutput
list (default)Package names plus an indented tags: detail line when tags are present
mermaidMermaid graph block showing the matched packages as a dependency subgraph

For broader graph rendering (full tree, DOT, JSON, HTML), use lpm graph.

Flags

FlagEffect
<selector>Optional selector expression. Required unless --count.
--countShow tag counts across all packages, grouped by severity
--query-verboseInclude full per-match analysis details in JSON output
--assert-noneExit non-zero if any package matches (CI gate)
--format <list|mermaid>Output format (default list)

Plus the global flags. --json emits an array of matched packages with name, version, optional path, and (under --query-verbose) analysis, hasScripts, isBuilt, isVulnerable.

See also