lilpack

index

Overview

LILPACK package system for Lilush.

Discovers and loads Lua modules from MNEME-backed .lilpack databases installed in ~/.local/share/lilush/packages/.

Replaces filesystem-based package.path lookups to avoid clashing with system Lua modules.

Convention: each .lilpack file is a MNEME database with a __lilpack manifest keyspace (version, name, modules list, etc.) and a modules KV keyspace mapping dot-separated module names to Lua source code.

The pack's version

A pack keeps its version in one place, its lilpack.json. The runtime hands it to Lua as the global PACK_VERSION:

the process runsPACK_VERSION is
a pack binarythe version of the pack's lilpack.json at build time, set by the binary before any Lua runs
a script, from a pack's checkoutthe version of ./lilpack.json, set by init
anything elseunset

The global names one pack: the one in the binary, or the one in the start directory. A pack installed as a .lilpack reads its own version from packages()[name].manifest.pkg_version.

Submodules

ModuleDescription
lilpack.semverMinimal semantic-version parsing and constraint matching for LILPACK dependency resolution.

Functions

NameSignature
compute_digestcompute_digest(db) -> digest
pubkey_fingerprintpubkey_fingerprint(pubkey) -> fingerprint
load_trusted_pubkeyload_trusted_pubkey(key_path) -> pubkey, err
verify_signatureverify_signature(db_path, trusted_pubkey) -> ok, err, pubkey
read_manifestread_manifest(db_path) -> manifest, err
runtime_checkruntime_check(manifest) -> nil | err
initinit() -> extensions
packagespackages() -> registry
modulesmodules() -> registry
extensionsextensions() -> extensions

compute_digest(db) -> digest

Compute the canonical SHA-256 digest of a package

Computes a deterministic SHA-256 hash over all package content in a MNEME database. The digest covers manifest fields in fixed order, module sources sorted by name, and CLI script sources sorted by name. The signature and pubkey fields are excluded from the digest. Used for both signing and verification.

pubkey_fingerprint(pubkey) -> fingerprint

Compute a short fingerprint for a public key

load_trusted_pubkey(key_path) -> pubkey, err

Load the trusted public key for signature verification

Loads the trusted Ed25519 public key used for package verification. If key_path is provided, reads from that file. Otherwise checks the LILPACK_PUB_KEY environment variable. Falls back to the built-in default public key.

verify_signature(db_path, trusted_pubkey) -> ok, err, pubkey

Verify the Ed25519 signature of a .lilpack file

Opens the MNEME database at db_path, recomputes the canonical digest, and verifies the embedded Ed25519 signature. If trusted_pubkey is provided, the signature is verified against it; otherwise falls back to the default trusted key (from LILPACK_PUB_KEY env or built-in). Returns true, nil, pubkey on success, or nil, error_message on failure.

read_manifest(db_path) -> manifest, err

Read and validate a LILPACK manifest from a MNEME database

Opens the MNEME database at db_path and reads the __lilpack manifest keyspace. Validates required fields (version, name, modules, signature, pubkey) and decodes optional JSON fields (dependencies, builtins, modes, cli). Returns the manifest table on success, or nil and an error message on failure. Unsigned packages are rejected.

runtime_check(manifest) -> nil | err

Check a manifest's minimum version against the running runtime

The binary sets one global at startup, named after the base it was built on: LILUSH_VERSION under lilush, LILGAME_VERSION under lilgame. The check reads the manifest key that matches the global it finds, min_lilush_version or min_lilgame_version, and ignores the other. Returns nil when the key is satisfied or absent, or when no global is set (plain luajit in tests). Returns requires <base> >= <min> (running <cur>) on a miss.

init() -> extensions

Initialize the LILPACK package system

Initializes the package system: strips standard Lua searchers, discovers and verifies installed packages, and installs the LILPACK and script-local searchers into the require chain. Returns a table of discovered extensions (builtins, modes, cli). Safe to call multiple times; subsequent calls return the cached extensions table.

It also sets the global PACK_VERSION to the version of ./lilpack.json, when the start directory holds one and no pack binary set the global already. See "The pack's version" above.

packages() -> registry

Return the package registry

modules() -> registry

Return the module registry

extensions() -> extensions

Return discovered shell extensions from installed packages