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.

For exact license inventory and compliance policy, use lpm licenses. lpm query :copyleft and :no-license are selector tags, not a full license report.

Examples

lpm query :eval                                    # any package that uses eval()
lpm query :network                                 # any package making outbound HTTP
lpm query :info                                    # common capabilities and artifact signals
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
:possible-obfuscationShow possible code obfuscation at moderate confidence
: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 selector expands to an OR of the behavioral tags assigned to that level. Install summaries and audits use the same assignments.

Info tags are behavioral metadata, not confirmed vulnerabilities. They identify common capabilities and artifact traits that can be useful during investigation.

TagExpands to
:critical:obfuscated OR :protestware
: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 :possible-obfuscation OR :high-entropy OR :telemetry OR :trivial OR :copyleft OR :minified OR :url-strings

Structural

TagMatches
:rootThe invocation project. Use :root > <selector> to match its direct dependency instances.
:workspace-rootThe owning workspace container. Use :workspace-root > <selector> to match its direct dependency instances.

When you run the command in a workspace member, :workspace-root still uses the owning container projection. It does not use a same-name instance from the member.

The behavior is the same from a nested directory inside that member. Outside a workspace, :workspace-root and :root use the same project.

If the workspace lockfile has no root projection, :workspace-root matches no direct dependencies. It does not fall back to the current 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 exact package instances and dependency edges

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

Exact instances and paths

lpm --json query :eval

Each JSON result includes name and version. An exact LPM CLI-managed result also includes instanceId.

The optional path value identifies the directory that the query analyzed. It points to the exact installed package materialization when that path is available.

For a file: or link: dependency, path identifies the original live source directory. Foreign lockfile formats can omit instanceId.

Results with the same name and version remain separate when their instance or path differs. Use instanceId as the row key when it exists.

Mermaid output also keeps these instances separate. A node label includes the first 12 characters of its instance ID when exact identity is available.

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 name, version, optional instanceId, and optional path for each match.

With --query-verbose, each match also includes analysis, hasScripts, isBuilt, and isVulnerable.

See also