lpm init
Create a package manifest for LPM.dev Registry or npm-compatible publishing, with agent guidance and registry configuration.
Create a new package.json with defaults for LPM.dev Registry or an npm-compatible registry.
lpm init [--lpm | --npm] [-y] [--name <name>] [--owner <owner>] [--no-agents]The command works in the current directory. It creates configuration files, not application code, dependencies, or a build setup.
Quickstart
mkdir widget
cd widget
lpm init --npm -y --name @acme/widgetFor an LPM.dev Registry package:
lpm init --lpm -y --owner acme --name widget| Mode | Package name | Publish configuration |
|---|---|---|
--npm | widget or @acme/widget | Sets publish.registries to ["npm"] in lpm.json |
--lpm | @lpm.dev/acme.widget | Keeps any existing lpm.json unchanged |
| No target flag | Prompts for a target | With -y, selects LPM.dev Registry naming |
LPM CLI supports npm-compatible registries as well as LPM.dev Registry. See registries for authentication and private registries.
Examples
# Choose the target, name, version, and description interactively
lpm init
# Create an unscoped npm package
lpm init --npm -y --name widget
# Use a complete LPM.dev Registry name without a profile lookup
lpm init --lpm -y --name @lpm.dev/acme.widget
# Keep existing agent guidance untouched
lpm init --npm -y --name widget --no-agents
# Create a package from a script
lpm init --npm -y --name @acme/widget --jsonPublish configuration
There is no init block in lpm.json. Command flags and interactive answers control initialization.
For --npm, LPM CLI creates this configuration:
{
"publish": {
"registries": ["npm"]
}
}This makes a later lpm publish use the npm target.
If lpm.json already exists, unrelated fields stay intact. Missing or empty publish.registries becomes ["npm"]. An existing ["npm"] stays unchanged. Other nonempty target lists cause an error.
--lpm selects the package naming format. It does not reset existing publish targets. Before you publish, review any existing publish configuration.
Generated files
Package manifest
{
"name": "@acme/widget",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"license": "MIT",
"files": ["dist"],
"packageManager": "lpm@<version>"
}For --lpm, the name uses @lpm.dev/<owner>.<name>. The other defaults are the same. Interactive initialization also adds a nonempty description.
Replace the entry paths and license to match your package. Create the source files and build setup before you publish. The command does not create dist/.
The packageManager field records the current LPM CLI version. Corepack does not install LPM CLI from this field.
Agent guidance
By default, the command creates or updates AGENTS.md with dependency, script, and JSON-output guidance. It writes no provider-specific files.
An existing managed block has these boundaries:
<!-- lpm:init:start -->
## Package Manager
This project uses lpm.
<!-- lpm:init:end -->LPM CLI replaces its managed block and preserves surrounding content. Without a managed block, it appends guidance unless equivalent LPM CLI guidance already exists.
Use --no-agents to skip all reads and writes of AGENTS.md for that run. Symbolic links, directories, special files, and oversized agent files cause an error without this flag.
Names and defaults
For LPM.dev Registry packages, these names are equivalent:
lpm init --lpm -y --owner acme --name widget
lpm init --lpm -y --owner acme --name acme.widget
lpm init --lpm -y --name @lpm.dev/acme.widgetAn explicit owner must match the owner in a qualified name. Names cannot contain a version or query suffix. Owner slugs and package names use lowercase letters, digits, and hyphens.
For npm packages, use an unscoped name or @scope/name. The same name rules apply during initialization and npm publishing. The @lpm.dev/ scope is reserved for LPM.dev Registry packages. --owner is invalid for the npm target.
| Value | Default with -y |
|---|---|
| Target | LPM.dev Registry naming |
| Package name | package, independent of the directory name |
| Owner | Account profile username, or the literal username |
| Version | 1.0.0 |
| Description | Omitted |
Without an explicit owner or qualified name, LPM CLI requests the account profile. This lookup has a three-second timeout. Offline or unavailable account data uses username.
Supply --owner or a qualified name to skip that lookup. During interactive initialization, versions must use valid semantic version syntax.
Automation
If standard input is not a terminal or you pass --json, use -y. Otherwise the command writes nothing and fails with confirmation_required. Target and name flags alone do not disable the remaining questions.
lpm init --lpm -y --owner acme --name widget --no-agents --jsonThe JSON result includes:
| Field | Meaning |
|---|---|
success, target, name, version | Initialization result and selected package values |
path, package_manager | Manifest path and LPM CLI version marker |
agents_path, agents_status | Agent file path and write status |
lpm_json_path, lpm_json_status | Publish configuration path and write status |
Write statuses are created, updated, unchanged, or skipped. Skipped files have a null path.
Existing projects and recovery
The command refuses an existing package.json, including a symbolic link. It also preserves a manifest that another process creates during the prompts.
For an existing project, edit its manifest directly. Use lpm install to install its dependencies.
If initialization fails, correct the reported file or configuration error before you retry. For malformed agent markers, repair the managed block or use --no-agents. LPM CLI attempts to restore its file changes after a write failure and preserves concurrent edits.
Flags
| Flag | Effect |
|---|---|
-y, --yes | Skip every prompt and use defaults for omitted values |
--lpm | Use LPM.dev Registry package naming |
--npm | Use npm-compatible naming and configure the npm publish target |
--name <name> | Set the package name |
--owner <owner> | Set the LPM.dev Registry user or organization slug |
--no-agents | Skip AGENTS.md |
--json | Print the result as JSON. Requires -y |
--lpm and --npm are mutually exclusive. See the global flags for other shared options.
See also
- lpm install — install dependencies
- lpm version — change a package version
- lpm publish — publish the package
- lpm.json — publish targets and project configuration
- Project setup — configure an existing project