Publish a component
Build a component package, publish it to a registry, and let projects install it by name and digest. registry.docsloth.dev serves the official packages and does not accept uploads yet; you can run your own registry today.
What a package is
A package is a directory with a manifest (component-package.json), a payload and a JSON Schema for its props. The manifest lists every file with its sha256 digest, and the package digest is computed from the manifest, so changing one byte of one file changes the package digest.
| Kind | What it ships | Here today |
|---|---|---|
block | Declarative document blocks: props schemas and specifications | 57 official packages |
theme | Tokens and stylesheets | none yet |
adapter | Conversions from other documentation formats | none yet |
plugin | Third-party executable code | none yet; refused by default: the CLI installs a plugin only when the operator trust policy sets allow_plugins and --allow-plugin is passed; neither the registry nor the CLI ever runs plugin code |
From source to install
The docsloth CLI is not on npm yet: it runs from a checkout of the Docsloth engine, and the quickstart shows the setup.
Describe the package
The CLI reads the fields from the
docslothobject inpackage.jsonor from flags.blocks,propsandcapabilitieshave no flags, so they must be inpackage.json.{ "name": "@acme/heatmaps", "version": "1.0.0", "license": "Apache-2.0", "docsloth": { "kind": "block", "engine": ">=1 <2", "entry": "blocks/heatmap.json", "props": "props.schema.json", "blocks": [ "acme.heatmaps.tile" ], "capabilities": [ "render.html" ], "publisher": "acme" } }Build it
docsloth component build --dir ./packageValidates the payload and writes
component-package.json. With--dry-runit reports the name, version, digest and file count without writing.Publish it to a registry you run
docsloth component publish --dir ./package --registry ./registryA directory registry needs no server: the CLI writes
index.jsonandpackages/<name>/<version>/with the manifest and every file. Serve that directory from any static host.Install it in a project
docsloth component add @acme/heatmaps@1.0.0 \ --registry https://components.example.comProjects install from your registry exactly as they install the official packages from registry.docsloth.dev.
Rules every package follows
- Versions never change
- Publishing a name and version that exists with different bytes is refused: a directory registry reports
DSL1705; an HTTP registry answers409, which the CLI reports asDSL1714. Publishing identical bytes again changes nothing. - Digests are checked on install
- The registry pins one digest per package version.
docsloth component addrecomputes it and the digest of every file, and writes nothing on a mismatch (DSL1708,DSL1709). - Nothing runs
- There are no install scripts and no post-install hooks. Block, theme and adapter packages are data; plugin packages are refused by default: the CLI installs a plugin only when the operator trust policy sets
allow_pluginsand--allow-pluginis passed; neither the registry nor the CLI ever runs plugin code. - Capabilities are declarations
- A package declares capabilities such as
render.html; it never grants them. The CLI derives the install trust class from those declarations, not from the catalog's runtime trust class: by default it installs pure and interactive packages and refuses the rest (DSL1716) unless a trust policy allows them. Every official package declares onlyrender.html, so each one installs as interactive without a trust policy, including the components whose runtime class is connected or agentic. - Limits
- At most 512 files and 16 MiB per package, no symlinks, no paths outside the package, and an allowlisted SPDX licence.
- Block names
- A block is a built-in block name or is namespaced with the package name:
@acme/heatmapsmay declareacme.heatmaps.tile.
Publishing over HTTP
A registry that accepts uploads takes the same package over HTTP. registry.docsloth.dev is static and does not accept uploads yet; this is the contract the CLI sends:
| Field | Value |
|---|---|
| Method and path | POST /v1/packages |
| Authorization | Bearer <token> from --token or DOCSLOTH_TOKEN, sent only as the Authorization header; never written to the manifest, the index or the CLI output (DSL1713 refuses a manifest that contains it) |
| Body | { "manifest": { … }, "files": { "<path>": "<base64>" } } |
| Success | 2xx { "ok": true, "digest": "sha256:…", "unchanged": true|false } |
| Refusal | Any non-2xx status (409 when the version exists with different bytes) fails the publish with DSL1714 |
The same contract as JSON: /api/v1/publish.json.
Signing an index
A registry operator can sign index.json with an Ed25519 key using the registry package of the Docsloth engine, which writes index.json.sig. A signature shows the index was not rewritten after signing; it does not show who published a package, and docsloth component add does not verify it. This registry's index is not signed.
Errors you may see
| Code | Meaning | What to do |
|---|---|---|
DSL1705 | Registry refuses overwrite: a directory registry already holds this name and version with different bytes | Increase the version and publish again |
DSL1706 | Registry index unusable | Point --registry at a directory or URL that serves index.json |
DSL1707 | Unknown package version: the error lists the versions the registry has published | Install one of the listed versions, or publish the version first |
DSL1708 | Manifest digest mismatch | Do not install; the registry entry and its manifest disagree |
DSL1709 | File digest mismatch (the error names the file) | Do not install; the file changed after publishing |
DSL1710 | Registry unreachable | Check the URL or directory and that the host is serving |
DSL1712 | Project config unusable | Run docsloth init in the project first |
DSL1713 | Secret in package manifest: the token passed to publish appears in the manifest | Remove the credential and rotate it |
DSL1714 | Registry request failed: an HTTP registry answered with a non-2xx status (409 when the version exists with different bytes, 401 without a valid token) | For 409, increase the version; for 401, pass a valid --token |
DSL1715 | Manifest identity mismatch: the manifest the index points at declares another name or version | Do not install; the registry index points at the wrong manifest |
DSL1716 | Component trust policy refused | Allow the trust class with --trust-policy <file>, or choose another package |
DSL1718 | Unsafe registry URL: not http(s), credentials in the URL, a link-local or metadata address, or a private address | Use an http(s) URL or a directory and pass credentials with --token; an internal registry needs DOCSLOTH_COMPONENT_REGISTRY_ALLOW_PRIVATE=true |