rustchain-community 1.0.0

Open-source AI agent framework with core functionality and plugin system
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
# 🚀 RustChain CLI Usage Guide

*Complete command-line reference with examples and best practices*

## 📋 Table of Contents

- [Quick Start]#quick-start
- [Core Commands]#core-commands
- [Mission Management]#mission-management
- [AI & LLM Integration]#ai--llm-integration
- [Tools & Execution]#tools--execution
- [Security & Safety]#security--safety
- [Enterprise Features]#enterprise-features
- [Advanced Usage]#advanced-usage
- [Troubleshooting]#troubleshooting

## 🎯 Quick Start

### Basic Command Structure
```bash
rustchain <COMMAND> [OPTIONS] [ARGS]
```

### Most Common Commands
```bash
# Run a mission file
rustchain run examples/hello_world.yaml

# Validate a mission before execution
rustchain mission validate my_mission.yaml

# Chat with an LLM
rustchain llm chat "Explain Rust ownership"

# List available tools
rustchain tools list

# Check system health
rustchain build status
```

### Help & Version Information
```bash
rustchain --help           # Show all available commands
rustchain --version        # Show RustChain version
rustchain run --help       # Show help for specific command
```

## 🎯 Core Commands

### Interactive Mode
Start conversational mode similar to Claude Code:

```bash
# Start interactive session
rustchain interactive

# Example session:
$ rustchain interactive
RustChain Interactive Mode - Type 'exit' to quit
> create a simple mission to analyze a codebase
> run the generated mission
> show me the results in a formatted report
```

### Mission Execution
Execute YAML-defined mission files:

```bash
# Basic execution
rustchain run path/to/mission.yaml

# Dry run (validate without executing)
rustchain run mission.yaml --dry-run

# Skip safety validation (use with caution)
rustchain run mission.yaml --skip-safety

# Combine flags
rustchain run mission.yaml --dry-run --skip-safety
```

**Example Mission File:**
```yaml
# simple_analysis.yaml
name: "Code Analysis"
description: "Analyze codebase for patterns"
version: "1.0"
steps:
  - id: "analyze"
    step_type: "llm"
    parameters:
      provider: "openai"
      model: "gpt-4"
      prompt: "Analyze this Rust codebase for common patterns"
```

## 📊 Mission Management

### Mission Operations
```bash
# List available example missions
rustchain mission list

# Validate mission syntax and structure
rustchain mission validate path/to/mission.yaml

# Show detailed mission information
rustchain mission info path/to/mission.yaml
```

**Example Output:**
```bash
$ rustchain mission info examples/hello_world.yaml
Mission: Hello World Demo
Description: Simple demonstration of RustChain capabilities
Version: 1.0
Steps: 3
- create_file: Create greeting file
- llm: Generate personalized message
- command: Display results
Safety Level: LOW
Estimated Duration: 30 seconds
```

### Mission Validation Examples
```bash
# Basic validation
$ rustchain mission validate mission.yaml
✅ Mission syntax valid
✅ All required fields present
✅ Step dependencies resolved
✅ Safety checks passed

# Validation with errors
$ rustchain mission validate broken_mission.yaml
❌ Mission validation failed
- Line 15: Unknown step_type 'invalid_step'
- Line 22: Missing required parameter 'prompt'
- Step 'step2' depends on non-existent 'step0'
```

## 🤖 AI & LLM Integration

### LLM Provider Management
```bash
# List all available models
rustchain llm models

# List models from specific provider
rustchain llm models --provider openai
rustchain llm models --provider anthropic
rustchain llm models --provider ollama

# Test connectivity to providers
rustchain llm test
rustchain llm test openai
rustchain llm test anthropic
```

### Interactive Chat
```bash
# Basic chat with default model
rustchain llm chat "What is Rust ownership?"

# Specify model and provider
rustchain llm chat "Explain async/await" --model gpt-4 --provider openai

# Adjust temperature for creativity
rustchain llm chat "Write a creative story" --temperature 1.2

# Technical discussion with low temperature
rustchain llm chat "Explain memory safety" --temperature 0.1 --model claude-3-sonnet
```

**Example Chat Session:**
```bash
$ rustchain llm chat "How do I implement a trait in Rust?" --model gpt-4
🤖 GPT-4 Response:

To implement a trait in Rust, you use the `impl` keyword followed by the trait name for your type:

```rust
// Define a trait
trait Drawable {
    fn draw(&self);
}

// Implement the trait for a struct
struct Circle {
    radius: f64,
}

impl Drawable for Circle {
    fn draw(&self) {
        println!("Drawing a circle with radius {}", self.radius);
    }
}
```

Key points:
- Use `impl TraitName for TypeName`
- Implement all required methods
- You can add default implementations in the trait definition
```

## 🔧 Tools & Execution

### Tool Management
```bash
# List all available tools
rustchain tools list

# Get detailed information about a specific tool
rustchain tools info file_create
rustchain tools info http_request
rustchain tools info command_execute

# Execute a tool directly
rustchain tools execute file_create --params '{"path":"test.txt","content":"Hello World"}'
rustchain tools execute command_execute --params '{"command":"ls","args":["-la"]}'
```

**Example Tool Execution:**
```bash
$ rustchain tools execute http_request --params '{
    "url": "https://api.github.com/repos/rust-lang/rust",
    "method": "GET",
    "headers": {"User-Agent": "RustChain-CLI"}
}'

🔧 Tool Execution Result:
Status: 200 OK
Response Time: 234ms
Body: {
  "name": "rust",
  "full_name": "rust-lang/rust",
  "description": "Empowering everyone to build reliable and efficient software.",
  "stargazers_count": 89234,
  ...
}
```

### Available Tools Categories
```bash
# File operations
rustchain tools info file_create     # Create files
rustchain tools info file_read       # Read file contents
rustchain tools info file_write      # Write to files

# Network operations  
rustchain tools info http_request    # HTTP requests
rustchain tools info websocket       # WebSocket connections

# System operations
rustchain tools info command_execute # Run system commands
rustchain tools info process_info    # Process information

# AI operations
rustchain tools info llm_call        # Direct LLM calls
rustchain tools info embedding       # Generate embeddings
```

## 🛡️ Security & Safety

### Safety Validation
```bash
# Validate mission safety
rustchain safety validate path/to/mission.yaml

# Strict mode (fail on warnings)
rustchain safety validate mission.yaml --strict

# Comprehensive safety check
rustchain safety check

# Include policy validation
rustchain safety check --include-policies

# Generate safety report
rustchain safety report mission.yaml
rustchain safety report mission.yaml --format json
rustchain safety report mission.yaml --format yaml
```

**Example Safety Report:**
```bash
$ rustchain safety validate examples/file_operations.yaml
🛡️ Safety Validation Report

Overall Risk Level: LOW
Issues Found: 2 warnings, 0 errors

Warnings:
⚠️  Step 'create_file': Writing to system directory
    - Path: /tmp/rustchain_output.txt
    - Recommendation: Use relative paths when possible

⚠️  Step 'command_exec': Shell command execution
    - Command: ls -la /tmp
    - Recommendation: Validate command parameters

Safety Checks Passed:
✅ No network access to external services
✅ No file system access outside sandbox
✅ No privileged operations requested
✅ All LLM prompts reviewed for safety
```

### Policy Management
```bash
# List active policies
rustchain policy list

# Validate policy configuration
rustchain policy validate

# Show policy enforcement status
rustchain policy status
```

**Example Policy Status:**
```bash
$ rustchain policy status
📋 Policy Enforcement Status

Active Policies: 8
├── File Access Policy: ENFORCED
│   ├── Allowed directories: ./workspace, /tmp
│   └── Blocked patterns: /etc/*, /root/*
├── Network Policy: ENFORCED  
│   ├── Allowed domains: api.openai.com, api.anthropic.com
│   └── Blocked IPs: All private ranges
├── Command Execution Policy: ENFORCED
│   ├── Allowed commands: ls, cat, echo, find
│   └── Blocked patterns: rm -rf, sudo, chmod
└── LLM Safety Policy: ENFORCED
    ├── Content filtering: ENABLED
    └── Prompt injection detection: ENABLED

Policy Violations (Last 24h): 0
```

## 🏢 Enterprise Features

### Authentication & RBAC
```bash
# Initialize JWT authentication
rustchain enterprise auth init-jwt

# Setup OAuth2 integration
rustchain enterprise auth setup-oauth2 google --client-id your-client-id

# Configure RBAC system
rustchain enterprise auth setup-rbac --roles-file roles.yaml

# Test authentication
rustchain enterprise auth test
```

### Compliance & Auditing
```bash
# Verify mission compliance
rustchain enterprise compliance verify mission.yaml

# Check against specific standard
rustchain enterprise compliance verify mission.yaml --standard GDPR

# Check against all standards
rustchain enterprise compliance verify mission.yaml --all-standards

# Generate compliance report
rustchain enterprise compliance report mission.yaml --output compliance_report.pdf

# List available compliance standards
rustchain enterprise compliance list-standards

# Run compliance audit
rustchain enterprise compliance audit
```

**Example Compliance Check:**
```bash
$ rustchain enterprise compliance verify data_processing.yaml --standard GDPR
🏛️ GDPR Compliance Check

Mission: Data Processing Pipeline
Standard: GDPR (General Data Protection Regulation)

✅ COMPLIANT - Overall Assessment

Compliance Checks:
✅ Data minimization: Only necessary data processed
✅ Purpose limitation: Clear processing purpose stated
✅ Storage limitation: Retention period specified (30 days)
✅ Consent mechanism: User consent collection implemented
✅ Data subject rights: Access and deletion capabilities present
✅ Security measures: Encryption and access controls in place

Recommendations:
💡 Consider implementing automated data anonymization
💡 Add data breach notification procedures
💡 Document legal basis for processing
```

### Monitoring & Performance
```bash
# Start metrics collection
rustchain enterprise monitoring start-metrics --port 9090

# Show performance dashboard
rustchain enterprise monitoring dashboard

# Configure alerting
rustchain enterprise monitoring setup-alerts --config alerts.yaml

# Show current metrics
rustchain enterprise monitoring metrics
```

### Multi-Tenancy
```bash
# Create new tenant
rustchain enterprise multi-tenant create-tenant acme-corp "ACME Corporation"

# List all tenants
rustchain enterprise multi-tenant list-tenants

# Configure tenant isolation
rustchain enterprise multi-tenant setup-isolation acme-corp --level strict
```

## 🔧 Advanced Usage

### RAG (Retrieval-Augmented Generation)
```bash
# Add documents to RAG system
rustchain rag add --id doc1 --file document.pdf --metadata '{"type":"technical"}'
rustchain rag add --id doc2 --file readme.md --metadata '{"type":"documentation"}'

# Search documents
rustchain rag search "machine learning algorithms" --limit 5 --threshold 0.8

# List all documents
rustchain rag list --offset 0 --limit 10

# Get context for a query
rustchain rag context "How to implement neural networks" --max-length 2000

# Delete document
rustchain rag delete doc1
```

### Sandbox Operations
```bash
# Create isolated sandbox
rustchain sandbox create

# Execute commands in sandbox
rustchain sandbox execute --session session1 "ls -la"

# Write files to sandbox
rustchain sandbox write --session session1 --file test.py --content "print('Hello')"

# Read files from sandbox
rustchain sandbox read --session session1 --file test.py

# List sandbox files
rustchain sandbox files --session session1

# Get sandbox information
rustchain sandbox info --session session1

# Clean up sandbox
rustchain sandbox destroy --session session1
```

### Server Mode
```bash
# Start API server
rustchain server start --host 0.0.0.0 --port 8080 --cors

# Get server configuration
rustchain server config

# Custom configuration
rustchain server start --host 127.0.0.1 --port 9090
```

### Audit & Compliance
```bash
# Query audit logs
rustchain audit query --start-time 2024-01-01T00:00:00Z --limit 50

# Generate audit report
rustchain audit report --format csv --start-time 2024-01-01T00:00:00Z

# Verify audit chain integrity
rustchain audit verify

# Export audit data
rustchain audit export --format json --output audit_dump.json

# Show audit statistics
rustchain audit stats
```

### Configuration Management
```bash
# Show current configuration
rustchain config show

# Validate configuration
rustchain config validate

# Initialize default configuration
rustchain config init
```

**Example Configuration Output:**
```yaml
# rustchain config show
server:
  host: "127.0.0.1"
  port: 8080
  workers: 4

llm:
  providers:
    openai:
      enabled: true
      model: "gpt-4"
    anthropic:
      enabled: true
      model: "claude-3-sonnet"

safety:
  enforce_policies: true
  sandbox_enabled: true
  max_execution_time: 300

storage:
  type: "sqlite"
  path: "./rustchain.db"

memory:
  type: "in_memory"
  capacity_mb: 512
```

### Feature Detection
```bash
# List all features and their status
rustchain features list

# Filter by category
rustchain features list --category llm
rustchain features list --category enterprise

# Show only available features
rustchain features list --available-only

# Check specific feature
rustchain features check agent
rustchain features check compliance

# Show feature summary
rustchain features summary

# Show upgrade recommendations
rustchain features upgrade
```

## 🐛 Troubleshooting

### Common Issues & Solutions

#### Command Not Found
```bash
$ rustchain: command not found

Solution:
# Ensure RustChain is in your PATH
export PATH="$PATH:/usr/local/bin"

# Or use full path
/usr/local/bin/rustchain --version
```

#### Mission Validation Errors
```bash
$ rustchain mission validate fails

Solution:
# Check YAML syntax
rustchain mission validate mission.yaml
# Fix errors shown in output
# Common issues: indentation, missing required fields, unknown step types
```

#### LLM Connection Issues
```bash
$ rustchain llm test fails

Solution:
# Check API keys
export OPENAI_API_KEY="your-key-here"
export ANTHROPIC_API_KEY="your-key-here"

# Test connectivity
curl -H "Authorization: Bearer $OPENAI_API_KEY" https://api.openai.com/v1/models

# Check configuration
rustchain config show
```

#### Permission Denied Errors
```bash
$ Permission denied when running tools

Solution:
# Check sandbox configuration
rustchain policy status

# Verify file permissions
ls -la /path/to/files

# Run with appropriate user permissions
```

### Debug Mode
```bash
# Enable verbose logging
RUST_LOG=debug rustchain run mission.yaml

# Show additional verbose information
RUST_LOG=debug rustchain mission validate mission.yaml

# Trace execution steps
RUST_LOG=trace rustchain run mission.yaml --dry-run
```

### Performance Tuning
```bash
# Monitor execution time
time rustchain run mission.yaml

# Profile memory usage
RUST_LOG=info rustchain run large_mission.yaml

# Optimize for speed
rustchain run mission.yaml --skip-safety  # Use carefully!
```

## 📚 Best Practices

### Mission Design
1. **Start Small**: Begin with simple missions and add complexity gradually
2. **Validate Early**: Always validate missions before execution
3. **Use Dry Runs**: Test missions with `--dry-run` first
4. **Safety First**: Don't skip safety checks unless absolutely necessary

### LLM Usage
1. **Be Specific**: Provide clear, detailed prompts
2. **Set Appropriate Temperature**: Low (0.1-0.3) for factual, high (0.7-1.2) for creative
3. **Choose Right Model**: GPT-4 for complex reasoning, GPT-3.5 for speed
4. **Monitor Costs**: Track API usage and costs

### Security
1. **Review Policies**: Regularly check `rustchain policy status`
2. **Monitor Audit Logs**: Use `rustchain audit stats` frequently
3. **Validate Inputs**: Always validate external data
4. **Use Sandboxes**: Isolate untrusted operations

### Performance
1. **Cache Results**: Reuse LLM responses when possible
2. **Batch Operations**: Group similar tasks together
3. **Monitor Resources**: Check memory and CPU usage
4. **Optimize Models**: Use smaller models for simple tasks

---

*For additional help, see [API Reference](API_REFERENCE.md), [Deployment Guide](DEPLOYMENT.md), or visit [GitHub Discussions](https://github.com/rustchain-community/rustchain-community/discussions).*