M Mozhi v3.7.0 code
packages
These libraries install with the package manager too — mz install mozhi-html, mz install mozhi-json… For full packages with tests, examples and tagged releases, see the package guide.

📚 Mozhi Libraries

Install community libraries with mozhi add <name> and import them in your .mz programs.

5Packages
112Functions
2Constants
1.0.0Version

Quick Start

# Install the CLI
curl -fsSL https://github.com/crossberry-in/mozhi-doc/raw/main/install.sh | bash

# Install a library
mozhi add mozhi-http
mozhi add mozhi-html

# Write a program
cat > server.mz << 'EOF'
import http from "mozhi-http"
import html from "mozhi-html"

fn handler(method, path) {
    body = html.html_page("Hello", html.html_h1("It works!"))
    return http.http_ok_html(body)
}

server = http.http_start(8080)
http.http_serve_loop(server, handler)
EOF

# Run it
mozhi run server.mz

Available Packages

Loading registry...

CLI Commands

mozhi add <package>     # Install a package
mozhi add --all         # Install all packages
mozhi add --list        # List installed packages
mozhi update            # Refresh cache + reinstall installed
mozhi update --all      # Refresh + install everything
mozhi update --registry # Only refresh the cache

Import Syntax

The first non-comment, non-blank lines of a .mz file may declare imports:

import http from "mozhi-http"
import html from "mozhi-html"
import json from "mozhi-json"
import math_utils from "mozhi-math-utils"
import strings from "mozhi-strings"

After the import lines, all functions are available as library.function(...):

import strings from "mozhi-strings"

echo(strings.reverse("hello"))        # olleh
echo(strings.capitalize("mozhi"))     # Mozhi
echo(strings.snake_case("camelCase")) # camel_case

Direct Download

You can also fetch a library directly without the CLI:

curl -fsSL https://raw.githubusercontent.com/crossberry-in/mozhi-doc/main/libs/html/html.mz \
  -o ~/.mozhi/libs/html/html.mz

# Or download all libraries as a tarball:
curl -fsSL https://github.com/crossberry-in/mozhi-doc/releases/download/v-libs-latest/mozhi-libs-all-1.0.0.tar.gz \
  -o mozhi-libs.tar.gz
tar -xzf mozhi-libs.tar.gz -C ~/.mozhi/libs

Verification

Every release ships a SHA-256 checksum file:

curl -fsSL https://raw.githubusercontent.com/crossberry-in/mozhi-doc/main/libs/checksums-sha256.txt -o /tmp/checksums.txt
sha256sum ~/.mozhi/libs/html/html.mz
grep html.mz /tmp/checksums.txt

Creating Your Own Library

Add an entry to mozhi-registry.json and commit. The CI workflow will automatically build, package, and publish your library.

{
  "name": "mozhi-mylib",
  "version": "1.0.0",
  "description": "My custom library",
  "source": "libs/mylib/mylib.mz",
  "install": "mylib/mylib.mz",
  "import_as": "mylib",
  "functions": ["greet"]
}

Then users install it with mozhi add mozhi-mylib.

CI/CD Workflow

The libs-release.yml GitHub Action triggers on every push that changes anything under libs/. It:

  • Validates every .mz file (non-empty, balanced braces)
  • Validates the registry JSON
  • Builds per-package .tar.gz and raw .mz artifacts
  • Bundles all libraries into mozhi-libs-all-<version>.tar.gz
  • Generates SHA-256 checksums
  • Publishes to the docs site and a GitHub Release tagged v-libs-<version>
  • Updates a rolling v-libs-latest tag

Mozhi Libraries v1.0.0 · Source on GitHub · MIT License

📦 PKG Manager (mzpkg)

Install mzpkg CLI

curl -fsSL https://pkgs-mz.vercel.app/install.sh | bash
source ~/.bashrc

Account

mzpkg register           # Create account
mzpkg login              # Log in
mzpkg status             # Show profile
mzpkg logout             # Sign out

Install Packages

# Official packages (no login required)
mzpkg install strings
mzpkg install http
mzpkg install math_utils

# User-published packages
mzpkg install tree              # finds Cross/tree
mzpkg install cross/tree        # explicit author

# Global tools (interpreters)
mzpkg install -g interpreter-fast
mzpkg install -g interpreter

Search & List

mzpkg search http
mzpkg search tree
mzpkg list
mzpkg info strings

Publish Your Package

mzpkg init mylib         # Create template
cd mylib
# Edit src/mod.mz
mzpkg login              # Must be logged in
mzpkg push               # Uploads to cloud

Pushed packages appear in search as username/pkg-name. Only the owner can update their packages.

Package Template

mylib/
├── package.json      # name, version, description
├── README.md
├── src/
│   └── mod.mz        # your code
└── tests/
    └── test.mz

Storage

~/.mzpkg/libs/<name>/Installed packages
~/.mzpkg/bin/Global binaries (interpreters)
~/.mzpkg/config.jsonLogin session
~/.mzpkg/cache/Registry cache

Cloud Registry

Browse packages online: pkgs-mz.vercel.app/packages

API docs: pkgs-mz.vercel.app/api/docs