ipfrs-cli
Command-line interface for IPFRS.
Overview
ipfrs-cli provides a user-friendly CLI for interacting with IPFRS:
- Kubo-Compatible Commands: Drop-in replacement for
ipfsCLI - Enhanced Features: TensorLogic-specific operations
- Interactive Mode: REPL for exploration
- Daemon Management: Start/stop IPFRS node
Key Features
Kubo-Compatible Commands
Standard IPFS commands work out of the box:
TensorLogic Extensions
Advanced operations for AI workloads:
Daemon Management
Control IPFRS node lifecycle:
Interactive Mode
REPL for experimentation:
Terminal UI Dashboard
Interactive dashboard for real-time monitoring:
Features:
- Overview Tab: Peer count, storage usage, bandwidth gauges, node info
- Network Tab: Network activity sparkline, connected peers list
- Storage Tab: Block statistics, recent blocks, cache metrics
- Help Tab: Keyboard shortcuts and navigation guide
Navigation:
Tabor←/→- Switch between tabs1-4- Jump directly to a tabqorCtrl+C- Exit the dashboard
Architecture
The CLI is organized into modular components for maintainability and reusability:
ipfrs-cli/
├── src/
│ ├── commands/ # Modular command implementations (15+ modules)
│ │ ├── mod.rs # Module organization and exports
│ │ ├── common.rs # Shared validation utilities
│ │ ├── file.rs # File operations (init, add, get, cat, ls)
│ │ ├── block.rs # Block operations (get, put, stat, rm)
│ │ ├── dag.rs # DAG operations (get, put, resolve, export/import)
│ │ ├── daemon.rs # Daemon management (start, stop, status, restart)
│ │ ├── pin.rs # Pin management (add, rm, ls, verify)
│ │ ├── repo.rs # Repository management (gc, stat, fsck)
│ │ ├── network.rs # Network operations (swarm, dht, bootstrap)
│ │ ├── stats.rs # Statistics (repo, bw, bitswap)
│ │ ├── tensor.rs # Tensor operations (add, get, info, export)
│ │ ├── logic.rs # Logic programming (infer, prove, kb-*)
│ │ ├── semantic.rs # Semantic search (search, index, similar)
│ │ ├── model.rs # Model management (add, checkpoint, diff)
│ │ ├── gradient.rs # Gradient operations (push, pull, aggregate)
│ │ └── gateway.rs # HTTP gateway server
│ ├── main.rs # CLI entry point and dispatch (2,079 lines)
│ ├── lib.rs # Library interface for reusability
│ ├── config.rs # Configuration management with caching
│ ├── output.rs # Output formatting (colors, tables, JSON)
│ ├── progress.rs # Progress indicators (spinners, bars)
│ ├── shell.rs # Interactive REPL shell
│ ├── tui.rs # Terminal UI dashboard (ratatui)
│ ├── plugin.rs # Plugin system for extensibility
│ └── utils.rs # Utility functions (version, man pages)
└── tests/
└── integration_tests.rs # End-to-end CLI testing
↓
ipfrs (core library)
Recent Refactoring (2026-01-09):
- Reduced main.rs from 4,825 to 2,079 lines (57% code reduction)
- Extracted all command implementations to modular
commands/files - Total codebase: 8,652 lines across 15+ command modules
- Single source of truth for all command logic
Design Principles
- User-Friendly: Clear error messages, helpful hints
- Fast: Optimized for low startup time with config caching
- Compatible: Familiar to IPFS users
- Powerful: Expose advanced IPFRS features
Performance Optimizations
The CLI is optimized for fast startup and low latency:
- Config Caching: Configuration files are loaded once and cached globally using
OnceLockto avoid repeated disk I/O - Lazy Initialization: Heavy modules are only loaded when needed
- Minimal Dependencies: Core functionality uses lightweight dependencies
- Benchmarking: Comprehensive benchmark suite to track performance metrics
Run benchmarks with:
Key metrics:
- CLI startup time: < 100ms (measured via benchmarks)
- Config load (cached): < 1μs
- Config load (uncached): < 500μs
- Command parsing: < 10ms
Man Page Generation
Generate comprehensive man pages for all IPFRS commands:
# Generate man pages to target/man directory
# Generate to custom directory
# Install system-wide (Linux/macOS)
# View man pages
The man page generator creates:
- Main man page:
ipfrs.1 - Subcommand pages:
ipfrs-<command>.1for each command
Update Checking
Check for available updates using the hidden update command:
# Check for updates
# The command will notify you if a newer version is available
Troubleshooting
The CLI provides helpful troubleshooting hints for common errors. Use the troubleshooting_hint() function in your code or check error messages for diagnostic steps covering:
- Daemon not running
- Repository not initialized
- Connection failures
- Content not found
- Permission issues
- Configuration errors
- Network timeouts
Shell Script Integration
The CLI is designed to be script-friendly with proper exit codes and quiet mode:
Exit Codes
Standard exit codes for reliable error handling in scripts:
0- Success1- General error2- Invalid arguments or command-line usage3- File or content not found4- Permission denied or authentication failed5- Network or connection error6- I/O error (file system operations)7- Timeout error8- Configuration error
Example script:
#!/bin/bash
if ; then
else
fi
Quiet Mode
Use --quiet or -q to suppress non-essential output for pipelines:
# Get just the CID without progress messages
CID=
# Pipe content directly
|
# Combine with JSON output for parsing
|
Other Script-Friendly Features
--no-color- Disable colored output (useful for logs)--format json- Machine-readable JSON output- Consistent output to stdout (data) and stderr (diagnostics)
Migration from IPFS (Kubo)
IPFRS is designed to be compatible with IPFS workflows. If you're familiar with IPFS/Kubo, here's what you need to know:
Command Compatibility
Most IPFS commands work identically in IPFRS:
| IPFS Command | IPFRS Equivalent | Notes |
|---|---|---|
ipfs init |
ipfrs init |
✅ Same behavior |
ipfs add <file> |
ipfrs add <file> |
✅ Compatible CIDs |
ipfs cat <cid> |
ipfrs cat <cid> |
✅ Same output |
ipfs get <cid> |
ipfrs get <cid> |
✅ Same functionality |
ipfs daemon |
ipfrs daemon |
✅ Same API endpoints |
ipfs swarm peers |
ipfrs swarm peers |
✅ Compatible |
ipfs id |
ipfrs id |
✅ Same format |
ipfs pin add |
ipfrs pin add |
✅ Compatible |
ipfs dag get |
ipfrs dag get |
✅ IPLD compatible |
ipfs block get |
ipfrs block get |
✅ Compatible |
What's Different
Enhanced Features (IPFRS-specific):
# Tensor operations (new in IPFRS)
# Logic programming (new in IPFRS)
# Semantic search (new in IPFRS)
# Model versioning (new in IPFRS)
# Federated learning (new in IPFRS)
Configuration Differences:
- IPFRS config:
~/.ipfrs/config.toml(TOML format) - IPFS config:
~/.ipfs/config(JSON format) - Environment variable:
IPFRS_PATHvsIPFS_PATH
API Compatibility:
- IPFRS exposes the same HTTP API on port 5001 (configurable)
- IPFRS gateway runs on port 8080 (configurable)
- Most IPFS HTTP API endpoints work without modification
Migration Steps
- Install IPFRS:
- Initialize Repository:
# Create new IPFRS repository
# Or import existing IPFS data
- Test Compatibility:
# Add content with IPFRS
# Verify same CID as IPFS would generate
# (IPFRS uses the same CID format)
- Migrate Pins (if needed):
# Export pins from IPFS
# Import to IPFRS
| while ; do
done
- Update Scripts:
# Simply replace 'ipfs' with 'ipfrs' in most cases
Interoperability
IPFRS can communicate with IPFS nodes on the network:
# Connect to IPFS node
# Retrieve content from IPFS network
# Provide content to IPFS network
Key Differences Summary
Similarities:
- ✅ Same CID format (content addressing)
- ✅ Same DAG structure (IPLD)
- ✅ Same network protocol (libp2p)
- ✅ Compatible HTTP API
- ✅ Same pinning mechanism
New in IPFRS:
- 🆕 Native tensor support (Safetensors, NumPy, PyTorch)
- 🆕 Built-in logic programming and inference
- 🆕 Semantic search with vector embeddings
- 🆕 Model versioning and diffing
- 🆕 Federated learning support
- 🆕 Enhanced performance for ML workloads
Troubleshooting Migration
Issue: "Repository not found"
# Solution: Initialize IPFRS repo
Issue: "Cannot connect to daemon"
# Solution: Start IPFRS daemon
# Or run in foreground
Issue: "Different CID for same content"
# Ensure same chunking parameters
Issue: "IPFS peers not visible"
# IPFRS is compatible - check bootstrap peers
For more help, see the troubleshooting guide or visit the IPFRS documentation.
Installation
# Build from source
# Or use pre-built binary
|
Usage Examples
Basic File Operations
# Add a file
# Retrieve the file
# Add directory recursively
Tensor Operations
# Add model weights
)
# Query semantic similarity
)
)
Network Operations
# Show connected peers
# Find content providers
Shell Completions
Generate shell completion scripts for faster command-line interaction:
# Bash
# Or for user-only:
# Zsh
# Fish
# PowerShell
# Elvish
After installing, restart your shell or source the completion file to enable tab completion for ipfrs commands and arguments.
Remote Daemon Management
IPFRS CLI supports connecting to remote daemons, allowing you to manage multiple IPFRS nodes from a single machine.
Configuration
Configure remote daemon in ~/.ipfrs/config.toml:
[]
# Remote API URL (for connecting to remote daemon)
= "http://192.168.1.100:5001"
# API token (for authenticated connections)
= "your-secret-token"
# Connection timeout in seconds
= 60
Environment Variables
Override configuration using environment variables:
# Connect to remote daemon
# Now all commands connect to the remote daemon
Multiple Daemon Management
Manage multiple daemons using shell aliases:
# Add to ~/.bashrc or ~/.zshrc
# Usage
Secure Remote Connections
For production deployments, use HTTPS and authentication:
# Enable authentication on the daemon
# Connect from client
Remote Command Examples
# Check remote daemon status
IPFRS_API_URL=http://remote:5001
# Add file to remote daemon
IPFRS_API_URL=http://remote:5001
# Query remote daemon peers
IPFRS_API_URL=http://remote:5001
# Pin content on remote daemon
IPFRS_API_URL=http://remote:5001
Configuration
Configuration file: ~/.ipfrs/config.toml
[]
= ".ipfrs"
= "info"
[]
= "blocks"
= 104857600 # 100MB
[]
= ["/ip4/0.0.0.0/tcp/4001"]
= 256
[]
# Local daemon
= "127.0.0.1:5001"
# Remote daemon (optional)
# remote_url = "http://remote-host:5001"
= false
# api_token = "your-token"
= 60
[]
= "127.0.0.1:8080"
Environment Variables
Supported environment variables (override config):
IPFRS_PATH- Data directoryIPFRS_LOG_LEVEL- Log level (error, warn, info, debug, trace)IPFRS_API_URL- Remote API URLIPFRS_API_TOKEN- API authentication token
## Dependencies
- `clap` - Command-line argument parsing
- `tokio` - Async runtime
- `ipfrs` - Core library
- `colored` - Terminal colors
## References
- IPFRS v0.1.0 Whitepaper (CLI Design)
- IPFS CLI Documentation: https://docs.ipfs.tech/reference/kubo/cli/