Skip to content

lnmplang/lnmp-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LNMP CLI Tools

Command-line tools for working with the LNMP protocol.

Features

  • 11 Command Groups with 60+ subcommands
  • Performance Benchmarking - Quantify LNMP's advantages
  • Format Conversion - JSON, binary, shortform
  • Vector Operations - Embeddings with quantization and delta encoding
  • Spatial Data - Position, rotation, streaming
  • Transport Bindings - HTTP, Kafka, gRPC, NATS
  • Validation & Security - Sanitization, compliance checking

Installation

cd tools/cli
cargo build --release
cargo install --path .

Quick Start

# Parse an LNMP file
lnmp-cli codec parse input.lnmp

# Inspect a container file
lnmp-cli container inspect file.lnmp

# Benchmark performance
lnmp-cli perf benchmark codec

# Compare with JSON
lnmp-cli perf compare json

# Get version info
lnmp-cli info version

Command Groups

1. container - Container File Operations

Inspect and manipulate .lnmp container files.

# Inspect container metadata
lnmp-cli container inspect file.lnmp

# Decode container to text
lnmp-cli container decode file.lnmp

# Encode text to container
lnmp-cli container encode --mode text input.txt -o output.lnmp

# Extract metadata
lnmp-cli container metadata file.lnmp

Subcommands:

  • inspect - Show container structure
  • decode - Extract content from container
  • encode - Create container (text/binary/stream/delta modes)
  • metadata - Show/modify metadata

2. codec - Text Codec Operations

Parse, format, and validate LNMP text format.

# Parse LNMP text
lnmp-cli codec parse input.lnmp

# Format with pretty-printing
lnmp-cli codec format input.lnmp

# Validate syntax
lnmp-cli codec validate input.lnmp

# Compute semantic checksum
lnmp-cli codec checksum input.lnmp

Subcommands:

  • parse - Parse and display structure
  • format - Pretty-print LNMP text
  • validate - Check syntax validity
  • checksum - Compute SC32 checksum
  • normalize - Normalize to canonical form

3. embedding - Vector Embedding Operations

Work with embedding vectors, quantization, and deltas.

# Encode vector
lnmp-cli embedding encode vector.txt

# Compute delta between vectors
lnmp-cli embedding delta compute base.bin target.bin -o delta.bin

# Calculate similarity
lnmp-cli embedding similarity vec1.bin vec2.bin --metric cosine

Subcommands:

  • encode - Encode f32 vector to binary
  • decode - Decode binary to f32 vector
  • delta - Compute/apply vector deltas
  • similarity - Calculate vector similarity

4. spatial - Spatial Data Operations

Handle position, rotation, velocity data.

# Encode spatial data
lnmp-cli spatial encode spatial.txt

# Stream spatial updates
lnmp-cli spatial stream --rate 60hz

# Validate spatial data
lnmp-cli spatial validate data.bin

Subcommands:

  • encode - Encode spatial data
  • decode - Decode spatial data
  • delta - Compute spatial deltas
  • stream - Stream spatial updates
  • validate - Validate spatial data

5. quant - Quantization Operations

Compress embeddings with quantization.

# Quantize to QInt8
lnmp-cli quant quantize vec.bin --scheme qint8

# Dequantize back to FP32
lnmp-cli quant dequantize quantized.bin

# Adaptive quantization
lnmp-cli quant adaptive vec.bin --target high

# Batch quantization
lnmp-cli quant batch vectors/ --output quantized/

Subcommands:

  • quantize - Quantize vectors (QInt8/QInt4/Binary/FP16)
  • dequantize - Restore to FP32
  • adaptive - Auto-select scheme
  • batch - Batch processing
  • benchmark - Performance testing

6. transport - Transport Protocol Bindings

Encode/decode for different transport protocols.

# Encode for HTTP
lnmp-cli transport http encode data.lnmp

# Decode from Kafka
lnmp-cli transport kafka decode message.bin

# gRPC payload
lnmp-cli transport grpc encode data.lnmp

# NATS message
lnmp-cli transport nats encode data.lnmp

Protocols:

  • http - HTTP transport
  • kafka - Apache Kafka
  • grpc - gRPC
  • nats - NATS messaging

7. envelope - Metadata Envelope Operations

Wrap data with envelope metadata (trace IDs, timestamps, etc.).

# Create envelope
lnmp-cli envelope create --trace-id abc123

# Wrap data
lnmp-cli envelope wrap data.lnmp

# Unwrap envelope
lnmp-cli envelope unwrap wrapped.lnmp

# Extract metadata
lnmp-cli envelope extract wrapped.lnmp

Subcommands:

  • create - Create new envelope
  • wrap - Add envelope to data
  • unwrap - Remove envelope
  • extract - Get envelope metadata

8. convert - Format Conversion

Convert between LNMP, JSON, binary, and shortform.

# LNMP to JSON
lnmp-cli convert to-json input.lnmp

# JSON to LNMP
lnmp-cli convert from-json input.json

# To binary format
lnmp-cli convert to-binary input.lnmp

# To shortform
lnmp-cli convert to-shortform input.lnmp

Subcommands:

  • to-json / from-json
  • to-binary / from-binary
  • to-shortform / from-shortform

9. info - Information & Diagnostics

Get version, features, and statistics.

# Version information
lnmp-cli info version

# Supported features
lnmp-cli info features

# Statistics for a file
lnmp-cli info stats file.lnmp

# Performance profile
lnmp-cli info profile

Subcommands:

  • version - CLI and protocol version
  • features - Supported LNMP features
  • stats - File statistics
  • profile - Performance profile

10. validate - Validation & Security

Sanitize and validate LNMP data.

# Sanitize untrusted input
lnmp-cli validate sanitize untrusted.lnmp

# Quick validation check
lnmp-cli validate check file.lnmp

# Strict validation
lnmp-cli validate strict file.lnmp

# LNMP compliance check
lnmp-cli validate compliance file.lnmp

Subcommands:

  • sanitize - Clean untrusted input
  • check - Basic validation
  • strict - Strict mode validation
  • compliance - Spec compliance check

11. perf - Performance Benchmarking ⭐

NEW! Quantify LNMP's performance advantages.

# Benchmark codec performance
lnmp-cli perf benchmark codec --iterations 10000

# Benchmark embedding operations
lnmp-cli perf benchmark embedding --dimensions 384

# Compare with JSON
lnmp-cli perf compare json

# Generate performance report
lnmp-cli perf report summary

Example Output:

🎯 LNMP Codec Benchmark
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Parse Performance:
  Speed:    284.58K ops/sec
  Latency:  3.51 ΞΌs
  Memory:   142 B

πŸ’‘ Comparison:
  βœ“ LNMP parsing is typically 3-4x faster than JSON
  βœ“ Lower memory overhead due to streaming parser

Subcommands:

  • benchmark - Run performance tests (codec/embedding/transport/full)
  • compare - Compare with JSON/gRPC/Protobuf
  • report - Generate performance reports (summary/details/export)

Performance Highlights:

  • 3-4x faster parsing than JSON
  • 2-3x smaller payload size
  • 991K ops/sec quantization performance
  • 757K ops/sec delta computation

Configuration

Configure via environment variables:

# Log level
export LNMP_LOG_LEVEL=debug       # error, warn, info, debug, trace

# Default output format
export LNMP_FORMAT=json           # text, json, binary, compact

# Verbose/quiet mode
export LNMP_VERBOSE=1
export LNMP_QUIET=1

# Color output
export LNMP_COLOR=always          # auto, always, never
export NO_COLOR=1                 # Standard disable colors

# Validation profile
export LNMP_PROFILE=strict        # loose, standard, strict

See CONFIG.md for details.

Examples

LLM Token Exchange

# Prepare LLM response in LNMP format
echo 'F1="token_text"\nF2=0.95\nF3=[1,2,3]' | lnmp-cli codec parse

# Compare size with JSON
lnmp-cli perf compare json
# Result: 1.4x smaller payload, 73% bandwidth savings

Vector Similarity Search

# Encode query vector
lnmp-cli embedding encode query.txt -o query.bin

# Quantize for faster search (4x compression)
lnmp-cli quant quantize query.bin --scheme qint8 -o query_q.bin

# Calculate similarity
lnmp-cli embedding similarity query_q.bin doc1_q.bin --metric cosine

Multi-Agent Coordination

# Agent state delta
lnmp-cli embedding delta compute old_state.bin new_state.bin -o delta.bin

# Encode for transport
lnmp-cli transport kafka encode delta.bin -o kafka_message.bin

# Wrap with envelope (trace ID, timestamp)
lnmp-cli envelope wrap kafka_message.bin --trace-id agent-001

Edge Deployment

# Validate data before deployment
lnmp-cli validate strict edge_data.lnmp

# Convert to binary for efficiency
lnmp-cli convert to-binary edge_data.lnmp -o edge_data.bin

# Benchmark performance
lnmp-cli perf benchmark codec
# Result: 280K ops/sec on edge hardware

Development

# Build
cargo build

# Run tests
cargo test

# Format code
cargo fmt

# Lint
cargo clippy

# Run with logging
LNMP_LOG_LEVEL=debug cargo run -- info version

Architecture

src/
β”œβ”€β”€ main.rs           # Entry point
β”œβ”€β”€ cli.rs            # Command definitions (clap)
β”œβ”€β”€ commands/         # Command implementations
β”‚   β”œβ”€β”€ container.rs  # Container operations
β”‚   β”œβ”€β”€ codec.rs      # Text codec
β”‚   β”œβ”€β”€ embedding.rs  # Vector operations
β”‚   β”œβ”€β”€ spatial.rs    # Spatial data
β”‚   β”œβ”€β”€ quant.rs      # Quantization
β”‚   β”œβ”€β”€ transport.rs  # Transport protocols
β”‚   β”œβ”€β”€ envelope.rs   # Envelope metadata
β”‚   β”œβ”€β”€ convert.rs    # Format conversion
β”‚   β”œβ”€β”€ info.rs       # Information
β”‚   β”œβ”€β”€ validate.rs   # Validation
β”‚   └── perf.rs       # Performance benchmarking ⭐
β”œβ”€β”€ config.rs         # Global configuration
β”œβ”€β”€ error.rs          # Error types
β”œβ”€β”€ io.rs             # I/O helpers
β”œβ”€β”€ print.rs          # Output formatting
β”œβ”€β”€ perf/             # Performance module
β”‚   β”œβ”€β”€ mod.rs
β”‚   └── metrics.rs    # Benchmark metrics
└── utils.rs          # Shared utilities

Documentation

License

Part of the LNMP Protocol implementation.

Version

CLI: v0.5.7
Protocol: v0.5.7


Performance is now measurable. Run lnmp-cli perf report summary to see LNMP's advantages quantified.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages