Architecture

Module Organization

The codebase is organized into self-contained modules in src/:

Core Libraries (Lua + C):

Pure Lua Libraries:

C-only Libraries:

Shell Architecture

Consult SHELL.md for the Lilush Shell (src/shell/) detailed overview. The shell has three built-in modes: shell (F1), lua REPL (F2), and wiki viewer (F3). The wiki mode opens self-describing MNEME databases for browsing, searching, and viewing content — see WIKIDB.md.

Binary Preloading System

Lilush embeds all modules in the binary:

  1. Lua modules - Compiled to bytecode, embedded as C char arrays

  2. C modules - Statically linked, registered via luaL_Reg

  3. Preloading - Both registered in package.preload before Lua execution

The c_tmpl template generates:

Module Registration

Adding a new Lua module:

  1. Create files in src/yourmodule/*.lua

  2. Add module to buildgen/modinfo.lua luamods section

  3. Add to whichever app configs need it (e.g. buildgen/apps/lilush.lua, buildgen/apps/lilu.lua) luamods array

Adding a new C module:

  1. Create source in src/yourmodule/*.c with luaopen_* function

  2. Create src/yourmodule/Makefile

  3. Add to buildgen/modinfo.lua c_libs section

  4. Add to whichever app configs need it (e.g. buildgen/apps/lilush.lua, buildgen/apps/lilu.lua) c_libs array

File Paths and Package Loading

Lilush uses the LILPACK system for package loading. On startup, lilpack.init() strips all default Lua searchers except the preload searcher, then installs two custom searchers:

  1. LILPACK searcher - Loads modules from MNEME-backed .lilpack databases in ~/.local/share/lilush/packages/

  2. Script-local searcher - Tries ./module.lua and ./module/init.lua relative to CWD

After initialization, package.path is set to an empty string. See LILPACK.md for the full package system specification.