legion pkg — Package Manager
The Legion package manager provides npm-quality tooling for managing legionhjyu packages.
Registry: legion-registry.pages.dev · Workers URL
Installation
sh
# Linux/macOS — one-liner
curl -fsSL https://legion-registry.pages.dev/install.sh | sh
# Or download binary directly
# Linux: https://legionhjyu-docs.pages.dev/downloads/legion-linux-x64
# macOS: https://legionhjyu-docs.pages.dev/downloads/legion-macos-x64
# Windows: https://legionhjyu-docs.pages.dev/downloads/legion-windows-x64.exeQuick Start
sh
legion pkg init my-project # Initialize project
legion pkg install legion-colors # Install a package
legion pkg install legion-http -D # Install as dev dependency
legion pkg run start # Run a script
legion pkg publish # Publish to registryCommands
Package Management
| Command | Description |
|---|---|
legion pkg install [pkg...] | Install packages (from manifest if no args) |
legion pkg install pkg@1.2.0 | Install specific version |
legion pkg install pkg -D | Install as dev dependency |
legion pkg install pkg --global | Install globally |
legion pkg remove | Uninstall a package |
legion pkg update [pkg...] | Update to latest versions |
legion pkg outdated | Show packages with newer versions |
legion pkg list | List installed packages |
legion pkg list --depth=2 | Show dependency tree |
legion pkg ci | Clean install from lockfile (like npm ci) |
Registry & Search
| Command | Description |
|---|---|
legion pkg search | Search registry with relevance scoring |
legion pkg info | Show full package details + versions |
legion pkg info | JSON output |
Project
| Command | Description |
|---|---|
legion pkg init [name] | Initialize new project (interactive) |
legion pkg init --yes | Skip prompts, use defaults |
legion pkg run | Run scripts from legion.pkg |
legion pkg run | List available scripts |
legion pkg pack | Create .tar.gz tarball |
legion pkg link | Symlink package globally |
legion pkg exec | Execute package binary |
Auth & Publishing
| Command | Description |
|---|---|
legion pkg login | Interactive login |
legion pkg login --token lgn_... | Login with token |
legion pkg logout | Clear credentials |
legion pkg whoami | Show current user |
legion pkg publish | Publish package to registry |
legion pkg publish --dry-run | Preview without uploading |
legion pkg publish --tag beta | Publish with tag |
Maintenance
| Command | Description |
|---|---|
legion pkg audit | Security audit of dependencies |
legion pkg audit --fix | Auto-update vulnerable packages |
legion pkg config | List config values |
legion pkg config key value | Set a config value |
legion pkg doctor | Diagnose environment issues |
The legion.pkg Manifest
json
{
"name": "my-package",
"version": "1.0.0",
"description": "A legionhjyu package",
"author": "your-username",
"license": "MIT",
"keywords": ["legion", "utility"],
"entry": "main.lhj",
"scripts": {
"start": "legion main.lhj",
"test": "legion tests/",
"build": "echo 'No build step'"
},
"deps": {
"legion-colors": ">=1.0.0"
},
"devDeps": {
"legion-test": ">=1.0.0"
}
}Available Packages
| Package | Version | Downloads | Description |
|---|---|---|---|
legion-http | 1.2.0 | 4,821 | HTTP client — GET, POST, PUT, DELETE |
legion-json | 1.3.2 | 5,230 | JSON parse, stringify, schema validation |
legion-fmt | 1.0.3 | 3,107 | String formatting, tables, human sizes |
legion-test | 2.0.1 | 2,944 | Unit testing framework with describe/it |
legion-fs | 1.1.5 | 2,618 | File system — read, write, glob, JSON I/O |
legion-colors | 1.1.0 | 1,873 | Terminal ANSI colors, rainbow, gradient |
legion-regex | 1.0.1 | 1,456 | Regex utilities, email/URL/semver validators |
legion-cli | 1.0.0 | 988 | CLI argument parser and command builder |
Authentication
sh
# Sign up at legion-registry.pages.dev/dev/signup
# Then login via CLI:
legion pkg login
# Username: your-username
# Password: ********
# Or with token from the dashboard:
legion pkg login --token lgn_your_token_hereCredentials are stored in ~/.legion/config.json (chmod 600).
Publishing a Package
sh
mkdir my-lib && cd my-lib
legion pkg init # Initialize manifest
# ... write your .lhj files ...
legion pkg login # Authenticate
legion pkg publish # Publish!View your package at https://legion-registry.pages.dev/pkg/my-lib
Semver Support
sh
legion pkg install legion-http@1.2.0 # Exact version
legion pkg install legion-http@^1.0.0 # Compatible (^)
legion pkg install legion-http@~1.2.0 # Approximate (~)
legion pkg install legion-http@>=1.0.0 # Range
legion pkg install legion-http@latest # LatestConfig
sh
legion pkg config # List all
legion pkg config registry # Get value
legion pkg config registry https://... # Set valueConfig file: ~/.legion/config.json