Files
aitbc/docs/23_cli/README.md
oib bb5363bebc refactor: consolidate blockchain explorer into single app and update backup ignore patterns
- Remove standalone explorer-web app (README, HTML, package files)
- Add /web endpoint to blockchain-explorer for web interface access
- Update .gitignore to exclude application backup archives (*.tar.gz, *.zip)
- Add backup documentation files to .gitignore (BACKUP_INDEX.md, README.md)
- Consolidate explorer functionality into main blockchain-explorer application
2026-03-06 18:14:49 +01:00

710 lines
19 KiB
Markdown

# AITBC CLI Documentation
## Overview
The AITBC CLI is a comprehensive command-line interface for interacting with the AITBC network. It provides enhanced features for clients, miners, agents, and platform operators with complete testing integration and multi-chain support.
## 📋 Testing Integration
### **Testing Skill**
For comprehensive testing capabilities and automated test execution, see the **AITBC Testing Skill**:
```
/windsurf/skills/test
```
### **Test Workflow**
For step-by-step testing procedures and CLI testing guidance, see:
```
/windsurf/workflows/test
```
### **Test Documentation**
For detailed CLI testing scenarios and multi-chain testing, see:
```
docs/10_plan/89_test.md
```
### **Test Suite**
Complete CLI test suite located at:
```
tests/cli/
├── test_agent_commands.py # Agent command testing
├── test_wallet.py # Wallet command testing
├── test_marketplace.py # Marketplace command testing
└── test_cli_integration.py # CLI integration testing
```
## Installation
```bash
# From monorepo root
pip install -e .
# Verify installation
aitbc --version
aitbc --help
# Test CLI installation
python -c "from aitbc_cli.main import cli; print('CLI import successful')"
```
## Testing the CLI
### **Installation Testing**
```bash
# Test CLI import and basic functionality
cd /home/oib/windsurf/aitbc/cli
source venv/bin/activate
python -c "from aitbc_cli.main import cli; print('CLI import successful')"
# Run CLI help commands
python -m aitbc_cli --help
python -m aitbc_cli agent --help
python -m aitbc_cli wallet --help
python -m aitbc_cli marketplace --help
```
### **Automated Testing**
```bash
# Run all CLI tests
python -m pytest tests/cli/ -v
# Run specific CLI test categories
python -m pytest tests/cli/test_agent_commands.py -v
python -m pytest tests/cli/test_wallet.py -v
python -m pytest tests/cli/test_marketplace.py -v
python -m pytest tests/cli/test_cli_integration.py -v
# Run comprehensive test suite
./tests/run_all_tests.sh
```
### **Multi-Chain Testing**
```bash
# Test multi-chain CLI functionality
python -m aitbc_cli --url http://127.0.0.1:8000 --api-key test-key blockchain chains
# Test CLI connectivity to coordinator
python -m aitbc_cli --url http://127.0.0.1:8000 --api-key test-key health
# Execute multi-chain test scenarios
python -m pytest tests/integration/test_multichain.py -v
```
## Quick Start
### Basic Setup
```bash
# Configure CLI
aitbc config set coordinator_url http://localhost:8000
export AITBC_API_KEY=your-key
# Test connectivity
aitbc blockchain status
aitbc --config
```
### Create Wallet
```bash
aitbc wallet create --name my-wallet
aitbc wallet balance
```
## Complete Command Reference
The AITBC CLI provides 24 command groups with over 150 individual commands:
### **Core Commands**
- **`admin`** — System administration
- **`agent`** — Advanced AI agent workflow and execution
- **`agent-comm`** — Cross-chain agent communication
- **`analytics`** — Chain analytics and monitoring
- **`auth`** — API key and authentication management
- **`blockchain`** — Blockchain queries and operations
- **`chain`** — Multi-chain management
- **`client`** — Job submission and management
- **`config`** — CLI configuration management
- **`cross-chain`** — Cross-chain trading operations
- **`deploy`** — Production deployment and scaling
- **`exchange`** — Bitcoin exchange operations
- **`genesis`** — Genesis block generation and management
- **`governance`** — Governance proposals and voting
- **`marketplace`** — GPU marketplace operations
- **`miner`** — Mining operations and job processing
- **`monitor`** — Monitoring, metrics, and alerting
- **`multimodal`** — Multi-modal agent processing
- **`node`** — Node management
- **`optimize`** — Autonomous optimization and predictive operations
- **`plugin`** — CLI plugin management
- **`simulate`** — Simulations and test user management
- **`swarm`** — Swarm intelligence and collective optimization
- **`test`** — Testing and debugging commands
- **`version`** — Version information
- **`wallet`** — Wallet and transaction management
### **Global Options**
```bash
--url TEXT # Override coordinator API URL
--api-key TEXT # Override API key
--output [table|json|yaml] # Output format
-v, --verbose # Increase verbosity (-v, -vv, -vvv)
--debug # Enable debug mode
--config-file TEXT # Path to config file
--test-mode # Enable test mode (mock data)
--dry-run # Show what would be done
--timeout INTEGER # Request timeout
--no-verify # Skip SSL verification (testing only)
--version # Show version
--help # Show help
```
## Command Groups
### 🔗 Blockchain Operations
```bash
# Status and synchronization
aitbc blockchain status
aitbc blockchain sync-status
aitbc blockchain info
# Network information
aitbc blockchain peers
aitbc blockchain blocks --limit 10
aitbc blockchain validators
# Multi-chain operations
aitbc blockchain chains
aitbc blockchain genesis --chain-id ait-devnet
aitbc blockchain send --chain-id ait-healthchain --from alice --to bob --data "test"
# Transaction operations
aitbc blockchain transaction <TX_ID>
aitbc blockchain transactions
aitbc blockchain balance <ADDRESS>
aitbc blockchain faucet <ADDRESS>
aitbc blockchain supply
```
### 👛 Wallet Management
```bash
# Wallet operations
aitbc wallet create --name my-wallet
aitbc wallet balance
aitbc wallet send --to <ADDRESS> --amount 1.0
aitbc wallet stake --amount 10.0
aitbc wallet earn --job-id <JOB_ID>
aitbc wallet history
aitbc wallet stats
# Multi-signature wallets
aitbc wallet multisig-create --participants alice,bob,charlie --threshold 2
aitbc wallet multisig-propose --wallet-id <ID> --to <ADDRESS> --amount 1.0
aitbc wallet multisig-sign --wallet-id <ID> --proposal-id <PID>
aitbc wallet backup --name my-wallet
# Liquidity and rewards
aitbc wallet liquidity-stake --amount 10.0 --pool gpu-market
aitbc wallet liquidity-unstake --amount 5.0 --pool gpu-market
aitbc wallet rewards
```
### 🤖 Agent Operations
```bash
# Agent workflows
aitbc agent create \
--name "ai_inference" \
--description "AI inference workflow" \
--config '{"model": "gpt2", "type": "inference"}'
aitbc agent execute ai_inference \
--input '{"prompt": "Hello world"}' \
--priority normal
# Agent learning and optimization
aitbc agent learning enable --agent-id agent_123 \
--mode performance --auto-tune
# Agent networks
aitbc agent network create \
--name "compute_network" \
--type "resource_sharing"
# Agent status and receipts
aitbc agent status --agent-id agent_123
aitbc agent receipt --execution-id exec_456
```
### 🚀 OpenClaw Deployment
```bash
# Application deployment
aitbc openclaw deploy \
--name "web_app" \
--image "nginx:latest" \
--replicas 3 \
--region "us-west"
# Deployment management
aitbc openclaw status web_app
aitbc openclaw optimize web_app \
--target performance --auto-tune
# Edge deployments
aitbc openclaw edge deploy \
--name "edge_service" \
--compute "gpu" \
--region "edge_location"
```
### ⚡ Optimization Features
```bash
# Enable agent optimization
aitbc optimize enable --agent-id agent_123 \
--mode performance --auto-tune
# Get recommendations
aitbc optimize recommendations --agent-id agent_123
# Apply optimizations
aitbc optimize apply --agent-id agent_123 \
--recommendation-id rec_456
# Predictive scaling
aitbc optimize predict --agent-id agent_123 \
--metric cpu_usage --horizon 1h
# Auto-tuning
aitbc optimize tune --agent-id agent_123 \
--objective performance \
--constraints '{"cost": "<100"}'
```
### 🏪 Marketplace Operations
```bash
# List available resources
aitbc marketplace gpu list
aitbc marketplace offers list
# Register GPU offers
aitbc marketplace offers create \
--gpu-id gpu_123 \
--price-per-hour 0.05 \
--min-hours 1 \
--max-hours 24 \
--models "gpt2,llama"
# Rent GPUs
aitbc marketplace gpu book --gpu-id gpu_789 --hours 2
# Order management
aitbc marketplace orders --status active
aitbc marketplace reviews --miner-id gpu_miner_123
aitbc marketplace pricing --model "RTX-4090"
# Bidding system
aitbc marketplace bid submit --gpu-id gpu_123 --amount 0.04 --hours 2
```
### 👤 Client Operations
```bash
# Job submission
aitbc client submit \
--prompt "What is AI?" \
--model gpt2 \
--priority normal \
--timeout 3600
# Job management
aitbc client status --job-id <JOB_ID>
aitbc client result --job-id <JOB_ID> --wait
aitbc client history --status completed
aitbc client cancel --job-id <JOB_ID>
# Payment operations
aitbc client pay --job-id <JOB_ID> --amount 1.5
aitbc client payment-status --job-id <JOB_ID>
aitbc client payment-receipt --job-id <JOB_ID>
aitbc client refund --job-id <JOB_ID>
# Batch operations
aitbc client batch-submit --jobs-file jobs.json
# Receipts
aitbc client receipts --job-id <JOB_ID>
```
### ⛏️ Miner Operations
```bash
# Miner registration
aitbc miner register \
--gpu "NVIDIA RTX 4090" \
--memory 24 \
--cuda-cores 16384 \
--miner-id "at1-gpu-miner"
# Mining operations
aitbc miner poll
aitbc miner status
aitbc miner earnings --period daily
aitbc miner jobs --status completed
# Ollama-powered mining
aitbc miner mine-ollama \
--jobs 10 \
--miner-id "at1-gpu-miner" \
--ollama-url "http://localhost:11434" \
--model "gemma3:1b"
# Advanced features
aitbc miner concurrent-mine --workers 4
aitbc miner deregister --miner-id my-gpu
aitbc miner update-capabilities --gpu "RTX-4090" --memory 24
```
### 🔧 Configuration Management
```bash
# Basic configuration
aitbc config show
aitbc config set coordinator_url http://localhost:8000
aitbc config get api_key
# Configuration profiles
aitbc config profiles create development
aitbc config profiles set development gpu_count 4
aitbc config profiles use development
# Secrets management
aitbc config set-secret api_key your_secret_key
aitbc config get-secret api_key
aitbc config validate
```
### 📊 Monitoring and Analytics
```bash
# Real-time monitoring
aitbc monitor dashboard
aitbc monitor metrics --component gpu
aitbc monitor alerts --type gpu_temperature
# Chain analytics
aitbc analytics dashboard
aitbc analytics monitor --chain ait-devnet
aitbc analytics predict --metric cpu_usage --horizon 1h
# Campaign monitoring
aitbc monitor campaigns
aitbc monitor campaign-stats --campaign-id camp_123
```
### 🌐 Multi-Chain Management
```bash
# Chain operations
aitbc chain list
aitbc chain create --config chain.yaml
aitbc chain info --chain-id ait-devnet
aitbc chain monitor --chain-id ait-devnet
# Node management
aitbc node list
aitbc node add --name node2 --endpoint http://localhost:8001
aitbc node test --name node2
```
### 🏛️ Governance
```bash
# Proposal management
aitbc governance list --status active
aitbc governance propose --title "GPU pricing update" --description "Update pricing model"
aitbc governance vote --proposal-id prop_123 --choice yes
aitbc governance result --proposal-id prop_123
```
### 🤝 Cross-Chain Agent Communication
```bash
# Agent communication
aitbc agent-comm register --agent-id agent_123 --chain-id ait-devnet
aitbc agent-comm discover --chain-id ait-devnet
aitbc agent-comm send --to agent_456 --message "Hello"
aitbc agent-comm reputation --agent-id agent_123 --score 5.0
```
### 🐝 Swarm Intelligence
```bash
# Swarm operations
aitbc swarm join --swarm-id swarm_123 --agent-id agent_456
aitbc swarm coordinate --swarm-id swarm_123 --task "inference"
aitbc swarm consensus --swarm-id swarm_123 --proposal-id prop_789
aitbc swarm status --swarm-id swarm_123
```
### 🧪 Testing and Simulation
```bash
# CLI testing
aitbc test api
aitbc test blockchain
aitbc test wallet
aitbc test marketplace
# Simulations
aitbc simulate workflow --test-scenario basic
aitbc simulate load-test --concurrent-users 10
aitbc simulate user create --name test_user
aitbc simulate results --scenario-id scenario_123
```
### 🧪 Simulation and Testing
```bash
# Workflow simulation
aitbc simulate workflow --test-scenario basic
aitbc simulate load-test --concurrent-users 10
# Scenario testing
aitbc simulate scenario --name market_stress_test
```
## Global Options
| Option | Description |
|--------|-------------|
| `--url TEXT` | Override coordinator API URL |
| `--api-key TEXT` | Override API key for authentication |
| `--output [table|json|yaml]` | Output format |
| `-v / -vv / -vvv` | Increase verbosity level |
| `--debug` | Enable debug mode with system information |
| `--config-file TEXT` | Path to config file |
| `--test-mode` | Enable test mode (uses mock data) |
| `--dry-run` | Show what would be done without executing |
| `--timeout INTEGER` | Request timeout in seconds |
| `--no-verify` | Skip SSL certificate verification (testing only) |
| `--version` | Show version and exit |
| `--help` | Show help message |
## Configuration Files
### Default Configuration Location
- **Linux/macOS**: `~/.config/aitbc/config.yaml`
- **Windows**: `%APPDATA%\aitbc\config.yaml`
### Environment Variables
```bash
export AITBC_API_KEY=your-api-key
export AITBC_COORDINATOR_URL=http://localhost:8000
export AITBC_OUTPUT_FORMAT=table
export AITBC_LOG_LEVEL=INFO
```
## Troubleshooting
### Common Issues
```bash
# Check CLI installation
aitbc --version
# Test connectivity
aitbc test api
aitbc blockchain status
# Verify configuration
aitbc config show
aitbc config validate
# Debug mode
aitbc --debug
```
### Performance Issues
```bash
# Check system resources
aitbc monitor metrics --component system
# Optimize CLI performance
aitbc config set cache_enabled true
aitbc config set parallel_requests 4
```
### Network Issues
```bash
# Test API connectivity
aitbc test api
curl http://localhost:8000/health/live
# Check coordinator status
aitbc blockchain status
aitbc blockchain sync-status
# Verify API endpoints
aitbc config show
```
### Miner Issues
```bash
# Check miner registration
aitbc miner status
# Test Ollama connectivity
curl http://localhost:11434/api/tags
# Check GPU availability
aitbc marketplace gpu list
```
## Best Practices
1. **Use configuration profiles** for different environments
2. **Enable debug mode** when troubleshooting issues
3. **Monitor performance** with the built-in dashboard
4. **Use batch operations** for multiple similar tasks
5. **Secure your API keys** with secrets management
6. **Regular backups** of wallet configurations
## Advanced Features
### End-to-End GPU Rental Example
```bash
# 1. Register miner (at1)
aitbc miner register --gpu "NVIDIA RTX 4090" --memory 24 --cuda-cores 16384 --miner-id "at1-gpu-miner"
# 2. Register GPU on marketplace
aitbc marketplace gpu register --name "NVIDIA RTX 4090" --memory 24 --cuda-cores 16384 --price-per-hour 1.5 --miner-id "at1-gpu-miner"
# 3. List available GPUs (user perspective)
aitbc marketplace gpu list
# 4. Book GPU
aitbc marketplace gpu book gpu_c72b40d2 --hours 1
# 5. Submit inference job
aitbc client submit --type inference --prompt "What is AITBC?" --model gemma3:1b
# 6. Start Ollama miner
aitbc miner mine-ollama --jobs 1 --miner-id "at1-gpu-miner" --model "gemma3:1b"
# 7. Get result
aitbc client result 580b8ba84ea34d99b6fc78950bf8ff66 --wait
```
### Custom Workflows
```bash
# Create custom agent workflow
aitbc agent create \
--name custom_pipeline \
--description "Custom processing pipeline" \
--config '{"steps": ["preprocess", "inference", "postprocess"]}'
# Execute with custom parameters
aitbc agent execute custom_pipeline \
--input '{"data": "sample"}' \
--workflow-config '{"batch_size": 32}'
```
### Automation Scripts
```bash
#!/bin/bash
# Example automation script
# Check wallet balance
BALANCE=$(aitbc wallet balance --output json | jq '.balance')
if [ "$BALANCE" -lt 1.0 ]; then
echo "Low balance detected"
aitbc monitor alerts create --type low_balance --message "Wallet balance below 1.0 AITBC"
fi
# Check miner status
aitbc miner status
aitbc monitor metrics --component gpu
```
### Integration with Other Tools
```bash
# Pipe results to other tools
aitbc marketplace gpu list --output json | jq '.[] | select(.price_per_hour < 0.05)'
# Use in scripts
for gpu in $(aitbc marketplace gpu list --output json | jq -r '.[].gpu_id'); do
echo "Processing GPU: $gpu"
# Additional processing
done
```
## Cross-Chain Trading Commands
The `cross-chain` command group provides comprehensive cross-chain trading functionality:
### **Cross-Chain Swap Operations**
```bash
# Create cross-chain swap
aitbc cross-chain swap --from-chain ait-devnet --to-chain ait-testnet \
--from-token AITBC --to-token AITBC --amount 100 --min-amount 95
# Check swap status
aitbc cross-chain status {swap_id}
# List all swaps
aitbc cross-chain swaps --limit 10
```
### **Cross-Chain Bridge Operations**
```bash
# Create bridge transaction
aitbc cross-chain bridge --source-chain ait-devnet --target-chain ait-testnet \
--token AITBC --amount 50 --recipient 0x1234567890123456789012345678901234567890
# Check bridge status
aitbc cross-chain bridge-status {bridge_id}
```
### **Cross-Chain Information**
```bash
# Get exchange rates
aitbc cross-chain rates
# View liquidity pools
aitbc cross-chain pools
# Trading statistics
aitbc cross-chain stats
```
### **Cross-Chain Features**
- **✅ Atomic swap execution** with rollback protection
- **✅ Slippage protection** and minimum amount guarantees
- **✅ Real-time status tracking** and monitoring
- **✅ Bridge transactions** between chains
- **✅ Liquidity pool management**
- **✅ Fee transparency** (0.3% total fee)
## Migration from Old CLI
If you're migrating from the previous CLI version:
1. **Update installation**: `pip install -e .`
2. **Migrate configuration**: Old config files should work, but new features are available
3. **Check new commands**: `aitbc --help` to see all available commands
4. **Test connectivity**: `aitbc blockchain status` to verify connection
## Support and Community
- **Documentation**: [Full documentation](../README.md)
- **Issues**: [GitHub Issues](https://github.com/aitbc/aitbc/issues)
- **Community**: [Discord/Forum links]
- **Updates**: Check `aitbc --version` for current version
---
*This documentation covers the enhanced AITBC CLI with all new features and capabilities, including:*
- **New Commands**: `miner mine-ollama`, `client result`, `marketplace offers create`
- **Enhanced GPU Rental Flow**: Complete end-to-end marketplace with Ollama integration
- **Multi-Chain Support**: Advanced blockchain and node management
- **Agent Communication**: Cross-chain agent messaging and reputation
- **Swarm Intelligence**: Collective optimization and consensus
- **Comprehensive Testing**: Built-in test suite and simulation tools
- **Advanced Monitoring**: Real-time analytics and alerting
- **Governance**: Proposal system and voting mechanisms
*Last updated: March 5, 2026*