Source configuration
lpm.config.json tells LPM CLI how to deliver a source package with lpm add. The consumer is the developer who runs lpm add. The file is at the root of the published tarball, next to package.json.
my-package/
├── package.json
├── lpm.config.json
├── components/
└── lib/
If a version has a valid lpm.config.json, lpm add uses the configured delivery path for that version. Its package page then shows lpm add. The optional type field sets the LPM.dev Registry classification separately.
Start with the schema
Add the LPM CLI schema to get validation and autocomplete in your editor:
{
"$schema": "https://cli.lpm.dev/schemas/lpm.config.json",
"type": "source",
"ecosystem": "js"
}
The optional top-level type field sets the LPM.dev Registry classification. It accepts package or source. If you omit it, the Registry infers the classification from the published contents. The classification does not turn off the config. A valid lpm.config.json activates the configured lpm add path also when type is package.
| Top-level field | Purpose |
|---|---|
$schema | Editor validation and autocomplete |
type | Optional LPM.dev Registry classification: package or source |
ecosystem | Source project defaults: js or the legacy swift source path |
importAlias | Alias prefix that the imports in the package source use |
configSchema | Fields that lpm add asks the consumer to set |
defaultConfig | Defaults that override the matching field-level defaults |
files | Source selection, destination, and conditional inclusion rules |
dependencies | Dependencies that the consumer configuration selects |
The LPM CLI lpm.config.json reference has the complete machine-readable schema and the LPM CLI behavior.
Consumer configuration
In an interactive run, lpm add asks for each configured field that the consumer did not set:
lpm add @lpm.dev/acme.ui-kit
The consumer can set fields in the package spec:
lpm add "@lpm.dev/acme.ui-kit?component=dialog,button&styling=panda"
LPM CLI does not ask for a field that the spec sets. Separate the values of a multi-select field with commas.
With --yes, LPM CLI does not prompt. It fills each field that the spec does not set from defaultConfig or the field's default. An optional field without a default stays unset. A condition on an unset field does not exclude a file, so optional component filters include every component. --json and a run without a terminal follow the same rules.
A required field without a default gets a value only in two cases. A boolean field becomes false, and a field with one option uses that option. Otherwise, lpm add fails and tells the consumer to set the field in the spec.
Config fields
Each key in configSchema defines one field that the consumer sets:
{
"configSchema": {
"name": {
"type": "string",
"label": "Component name",
"default": "Example"
},
"styling": {
"type": "select",
"label": "Styling framework",
"required": true,
"default": "panda",
"options": [
{ "value": "panda", "label": "Panda CSS" },
{ "value": "tailwind", "label": "Tailwind CSS" }
]
},
"withTests": {
"type": "boolean",
"label": "Include tests?",
"default": false
}
}
}
| Property | Accepted value | Behavior |
|---|---|---|
type | string, boolean, or select | Defaults to string |
label | String | Prompt label. Defaults to the field key |
default | String, boolean, or number | Initial prompt value and the --yes value |
required | Boolean | If true, the field must have a value |
multiSelect | Boolean | Allows more than one selection in a select field |
options | Strings or { value, label } objects | Choices for a select field |
Give every select field at least one option. LPM CLI and the LPM.dev Registry reject a select field with an empty or missing option list.
Give each required field a default, so that lpm add --yes can fill it.
Default precedence
A value in defaultConfig overrides the default of the matching field:
{
"configSchema": {
"styling": {
"type": "select",
"required": true,
"default": "tailwind",
"options": ["panda", "tailwind"]
}
},
"defaultConfig": {
"styling": "panda"
}
}
In this example, the prompt starts at panda, and --yes also uses panda.
File rules
The files array selects source paths. It maps each path into the install directory that the consumer chose:
{
"files": [
{
"src": "components/dialog/**",
"dest": "components/ui/dialog",
"include": "when",
"condition": { "component": "dialog" }
},
{
"src": "styles/*.css",
"dest": "styles/",
"include": "always"
},
{
"src": "internal/test-utils.ts",
"include": "never"
}
]
}
| Property | Behavior |
|---|---|
src | Required source path relative to the tarball root |
dest | Destination relative to the consumer's install directory. If you omit it, LPM CLI uses the src path |
include | always by default, when for a condition, or never |
condition | Config key and value pairs. Required when include is when |
src accepts these patterns:
- Exact paths such as
lib/utils.ts. - A trailing recursive
/**, such ascomponents/dialog/**. - A
*in the file name of one directory, such asstyles/*.css.
If src contains a *, LPM CLI puts each matched file under dest. The file keeps its path relative to the directories in src before the *. If src is an exact path and dest ends in /, the file keeps its name. Otherwise, dest is the path of the file.
If you omit files, LPM CLI copies the package.json > lpm.source path. If that path is not set, LPM CLI copies the package files. It leaves out the manifests, test directories, node_modules, and LPM records. If files is an empty array, no file matches, and lpm add stops.
Conditional inclusion
LPM CLI selects a when rule only if every condition entry matches. For a multi-select field, an entry matches if its value is one of the selected values.
If the consumer did not set a field, a condition on that field does not exclude the file. Thus an optional component filter includes every component by default:
# component absent: include every component rule
lpm add "@lpm.dev/acme.ui-kit?styling=panda"
# include only dialog rules
lpm add "@lpm.dev/acme.ui-kit?component=dialog&styling=panda"
If two rules write to the same destination, select them with a required field that has a default. If both rules apply, lpm add stops with a duplicate destination error.
Import aliases
importAlias declares the import prefix that the package source uses:
{
"importAlias": "@/"
}
LPM CLI rewrites the imports that use this prefix to the consumer alias. The consumer alias comes from --alias, tsconfig.json, jsconfig.json, or the interactive prompt:
// Package source
import { cn } from "@/lib/cn"
// Delivered source
import { cn } from "@/components/ui/lib/cn"
If the consumer has an alias, LPM CLI also rewrites relative imports between delivered files. This works without importAlias. LPM CLI does not change imports of external packages.
Conditional dependencies
The outer key matches a configuration field. The inner key matches a selected value:
{
"dependencies": {
"styling": {
"panda": ["@pandacss/dev"],
"tailwind": ["tailwindcss", "autoprefixer"]
},
"iconLibrary": {
"lucide": ["lucide-react"],
"internal": ["@lpm.dev/acme.icons@^2"]
}
}
}
LPM CLI adds the matching dependencies to the consumer's package.json. Then it installs them with the package manager that --pm selects. Packages from npm, the LPM.dev Registry, and private registries in .npmrc use the same steps.
LPM CLI resolves bare names and dist-tags against their registry before it changes the consumer's package.json. It saves explicit versions and ranges as they are. The LPM CLI schema reference describes the save policy.
If you omit dependencies, LPM CLI uses the dependencies and peerDependencies in the source package's package.json. If you declare the field, LPM CLI does not use that fallback, even when the consumer's choices match no branch.
Complete example
{
"$schema": "https://cli.lpm.dev/schemas/lpm.config.json",
"ecosystem": "js",
"importAlias": "@/",
"configSchema": {
"component": {
"type": "select",
"label": "Components",
"multiSelect": true,
"options": ["dialog", "button"]
},
"styling": {
"type": "select",
"label": "Styling framework",
"required": true,
"options": ["panda", "tailwind"]
},
"withTests": {
"type": "boolean",
"label": "Include tests?",
"required": true
}
},
"defaultConfig": {
"styling": "panda",
"withTests": false
},
"files": [
{
"src": "components/dialog/**",
"dest": "components/ui/dialog",
"include": "when",
"condition": { "component": "dialog" }
},
{
"src": "components/button/**",
"dest": "components/ui/button",
"include": "when",
"condition": { "component": "button" }
},
{
"src": "styles/panda.css",
"dest": "styles/theme.css",
"include": "when",
"condition": { "styling": "panda" }
},
{
"src": "styles/tailwind.css",
"dest": "styles/theme.css",
"include": "when",
"condition": { "styling": "tailwind" }
},
{
"src": "tests/**",
"dest": "__tests__",
"include": "when",
"condition": { "withTests": true }
}
],
"dependencies": {
"styling": {
"panda": ["@pandacss/dev"],
"tailwind": ["tailwindcss"]
},
"withTests": {
"true": ["vitest"]
}
}
}
If the consumer does not set component, LPM CLI includes both component rules. Under --yes, styling and withTests get their defaultConfig values.
LPM.dev Registry validation
The LPM.dev Registry validates lpm.config.json before it accepts a publish. It rejects a config that exceeds one of these limits:
| Limit | Maximum |
|---|---|
lpm.config.json size | 128 KiB |
| File rules | 1,000 |
| Options per select field | 64 |
src or dest | 512 characters |
importAlias | 200 characters |
| Labels, option values, and dependency entries | 200 characters each |
| Dependencies in one selected branch | 200 |
The Registry also rejects fields and file rules with the wrong shape. When the consumer runs lpm add, LPM CLI refuses some destination paths. It refuses a path that is absolute, contains .., or leaves the install directory through an existing symlink.
Use the schema while you write the file. Before you publish, run the local publish check:
lpm publish --check
lpm publish --check validates lpm.config.json against the LPM CLI schema. It does not apply the Registry limits in the table above. The Registry applies those limits when you upload the package.
Optional authoring help
The LPM Guide skill can draft lpm.config.json from a package source tree:
npx skills add lpm-dev/lpm-guide
Before you publish, compare the generated file with the schema and with the delivery behavior on this page.
See also
- Source code delivery describes the consumer workflow.
- Package types explains how the Registry detects a source package.
- Publish packages to LPM.dev Registry covers private publishing and reviewed public distribution.
- The LPM CLI
lpm.config.jsonreference has the complete schema and command behavior. - The LPM CLI
addreference lists the consumer flags, registry routing, and JSON output.