CLI reference

Reference CLI for the Leji specification: validate, index, changelog, freshness, conformance, docs, and init for a shared context layer.

The command surface is identical across all runtimes; see the Quickstart for install commands. Every command takes --root <dir> and --json. The same spec generates both this reference and leji --help.

Currently supported Node.js Node.js 22+ Python Python 3.10+ Go Go 1.23+
leji <command> [options]

Commands

validate Validate the context layer: manifest, artifacts, frontmatter, and lint rules.
index Generate the context index at the declared path, or verify it is current.
changelog check Verify the machine changelog: schema and append-only discipline.
freshness Report review horizons across category documents and agent profiles.
conformance Score the context layer against its claimed conformance level.
docs Generate the static docs viewer, and optionally serve it locally.
init Bootstrap a new context layer from the templates.

Exit codes

CodeMeaning
0 Clean. No errors; warnings are allowed.
1 Findings. At least one error was reported.
2 Usage error, or an internal failure (e.g. init refusing to overwrite).

Global options

--root <dir> Repository root to operate on (default: the current directory).
--json Machine-readable JSON output instead of human-readable text.
-V, --version Print the SDK version and exit.
-h, --help Show help and exit.

leji validate

Loads leji.json and checks it against the schemas and the lint rules: declared files exist, categories are populated, vendor entrypoints redirect to the boot profile, frontmatter is valid, and (per the claimed conformance level) the index is current and the changelog is append-only. The single command CI runs to keep a context layer honest.

leji validate [--root <dir>] [--json]

Examples

leji validate
leji validate --root . --json

leji index

Scans the mapped category paths and writes the context index to machine.indexPath. Ids are stable: a renamed or moved document keeps its id. With --check it writes nothing and instead fails when the stored index no longer matches the tree (a stale index is a hard failure).

leji index [--check] [--root <dir>] [--json]
--check Verify the stored index is current with the tree; write nothing.

Examples

leji index
leji index --check

leji changelog check

Validates the declared changelog against its schema and enforces append-only discipline against the git baseline: surviving entries are immutable, and entries may be removed only from the oldest end and only alongside a compaction entry. Without a git baseline the discipline is unverifiable and reported as a warning.

leji changelog check [--strict] [--root <dir>] [--json]
--strict Treat an unverifiable append-only check (no git baseline) as an error.

Examples

leji changelog check
leji changelog check --strict

leji freshness

Lists documents whose freshness.reviewAfter horizon has passed (expired) or falls within the next 30 days (upcoming). Report-only by default; expired horizons are warnings.

leji freshness [--strict] [--root <dir>] [--json]
--strict Treat expired horizons as errors instead of warnings.

Examples

leji freshness
leji freshness --strict --json

leji conformance

Runs the core, indexed, governed, and federated checklists. Machine-checkable items pass or fail; process items (review gate, CI, external consumers) are reported as manual. A claim above the verified level is an error.

leji conformance [--root <dir>] [--json]

Examples

leji conformance
leji conformance --json

leji docs

Projects the context index into a browsable Docsify viewer: writes index.html (with a frontmatter-stripping hook) and a deterministic _sidebar.md into the context root. Presentation is non-normative; this is the reference projection. With --serve it then serves the repository on 127.0.0.1 (a local preview, never hosting).

leji docs [--serve] [--port <n>] [--root <dir>] [--json]
--serve Serve the repository on 127.0.0.1 after generating.
--port <n> Port for --serve. Overrides the manifest docs.port; default 5354 (LEJI on a phone keypad); 0 picks a free port.

Examples

leji docs
leji docs --serve
leji docs --serve --port 0

leji init

Interactively scaffolds a context layer: leji.json, a boot profile, seeded category documents, a first decision record, and (at the indexed level) a generated index and machine changelog. Refuses to overwrite an existing leji.json. The same entrypoint backs `npm create leji`.

leji init [--dir <path>] [--yes] [--level <core|indexed>] [--name <name>]
--dir <path> Target directory (default: the current directory).
--yes, -y Accept all defaults; run non-interactively.
--level <level> Conformance level to claim: core or indexed (default: core).
--name <name> Context layer name (default: derived from the directory).

Examples

leji init
leji init --yes --level indexed --name acme-context