npm Plugins
npm plugins combine tool contracts with reproducible dependency management. Project scope records a manifest and lockfile, while global scope belongs to the user. Installation transactions avoid partial state where possible. Lifecycle scripts are disabled by default, but entry validation still imports and executes package code.
npm Plugin Management
Section titled “npm Plugin Management”Install
Section titled “Install”coden plugin install npm:@scope/coden-plugin-examplecoden plugin install npm:@scope/coden-plugin-example@^2 --globalcoden plugin remove @scope/coden-plugin-examplecoden plugin listcoden plugin sync- Default scope is project;
--globalinstalls into the user-global scope. - Specifiers accept only
npm:<package>ornpm:<package>@<version-or-tag>;https://registry.npmjs.orgis always used — private registries, Git, URLs, and local directory sources are unsupported. - Install validation imports the entry: top-level code runs with the current user’s permissions.
- Install/remove/upgrade require a CodeN restart;
/reloadre-reads local.tsplugins only.
Project files
Section titled “Project files”<workspace>/.coden/plugins.json # manifest (commit)<workspace>/.coden/plugin-runtime/.gitignore # excludes node_modules (commit)<workspace>/.coden/plugin-runtime/bun.lock # locked dependencies (commit)plugin-runtime/package.json is generated deterministically from plugins.json; node_modules/ is never committed. Global plugins live at $XDG_DATA_HOME/coden/plugins/ (default ~/.local/share/coden/plugins/) and are not part of the project repository.
coden plugin synccoden plugin sync --global- Project
syncrequiresplugin-runtime/bun.lockto exist, otherwise it reportsplugin.lock_missing. - Sync runs
bun installwith--frozen-lockfile: an outdated lock file reportsplugin.lock_outdated; update and commit the lock file. - Sync rebuilds the runtime and re-validates every plugin entry.
Lifecycle scripts
Section titled “Lifecycle scripts”| Behavior | Meaning |
|---|---|
| disabled by default | equivalent to bun install --ignore-scripts; preinstall/install/postinstall do not run |
--allow-scripts |
lets this package and transitive deps run scripts with user permissions; prints a warning and asks again |
--yes |
skips confirmations only, and never enables scripts on its own |
Listing and shadowing
Section titled “Listing and shadowing”coden plugin list prints project and global sections: package name, installed version, requested version, tool count. When the same package exists in both scopes, the project row is marked as shadowed (shadowed by project) and the global version is inactive.
Transactions and concurrency
Section titled “Transactions and concurrency”- Install/sync/remove commit transactionally (manifest + runtime backups with crash recovery).
- Only one transaction per scope at a time; concurrent operations report
plugin.install_busy(stale locks are cleaned automatically).
Runtime requirement
Section titled “Runtime requirement”Loading npm plugins requires only a built .js/.mjs entry (Node or Bun); install and sync run bun install internally and need Bun on PATH.
Related references
Section titled “Related references”Marketplace
Section titled “Marketplace”Marketplace entry
Section titled “Marketplace entry”The marketplace lists curated npm plugins for CodeN (name, version, description, and compatibility status) with filtering by package name and description. Data comes from live npm registry snapshots.
Installing a listed plugin
Section titled “Installing a listed plugin”coden plugin install npm:coden-modern-unixcoden plugin install npm:coden-msbRestart CodeN after installing; coden plugin list confirms the registered tools (see npm Plugin Management).
If a package violates the author protocol (missing metadata, unsupported apiVersion, etc.), installation fails with the matching error code; see the Author Protocol and Troubleshooting.
Submitting a plugin
Section titled “Submitting a plugin”Authors can publish their npm package to a public registry to make it browsable; the package must satisfy the Author Protocol. Inclusion criteria are as shown on the marketplace page.