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
/// Enhanced CLI help text with detailed examples and usage patterns
/// This module provides rich help content for all RustChain CLI commands
pub struct CommandExamples;

impl CommandExamples {
    /// Get detailed help for the main rustchain command
    pub fn main_help() -> &'static str {
        r#"RustChain - Advanced AI Agent Framework

USAGE:
    rustchain <COMMAND>

EXAMPLES:
    # Quick start - run your first mission
    rustchain run examples/hello_world.yaml

    # Interactive mode (like Claude Code)
    rustchain interactive

    # Validate mission before execution
    rustchain mission validate my_mission.yaml

    # Validate mission before execution
    rustchain mission validate my_mission.yaml

    # List available missions
    rustchain mission list

COMMANDS:
    interactive    Start conversational mode
    run            Execute a mission file
    mission        Mission management operations
    Note: llm and tools commands require respective feature flags to be compiled in
    safety         Security validation
    policy         Policy enforcement
    audit          Audit trail operations
    config         Configuration management
    features       Feature detection
    enterprise     Enterprise features

For detailed help on any command, use:
    rustchain <COMMAND> --help"#
    }

    /// Get detailed help for the run command
    pub fn run_help() -> &'static str {
        r#"Execute a RustChain mission file

USAGE:
    rustchain run [OPTIONS] <MISSION>

ARGUMENTS:
    <MISSION>    Path to the YAML mission file to execute

OPTIONS:
    -d, --dry-run       Validate and plan execution without running tools
    -s, --skip-safety   Skip safety validation (use with caution)
    -h, --help          Print help

EXAMPLES:
    # Basic execution
    rustchain run examples/hello_world.yaml

    # Test mission without executing (recommended first)
    rustchain run my_mission.yaml --dry-run

    # Skip safety checks (only if you trust the mission)
    rustchain run trusted_mission.yaml --skip-safety

    # Combine options
    rustchain run mission.yaml --dry-run --skip-safety

MISSION FILE FORMAT:
    name: "Mission Name"
    description: "What this mission does"
    version: "1.0"
    steps:
      - id: "step1"
        step_type: "llm"
        parameters:
          provider: "openai"
          model: "gpt-4"
          prompt: "Your prompt here"

For mission examples, see: examples/ directory
For mission validation: rustchain mission validate <file>"#
    }

    /// Get detailed help for mission commands
    pub fn mission_help() -> &'static str {
        r#"Mission management operations

USAGE:
    rustchain mission <COMMAND>

COMMANDS:
    list        List available example missions
    validate    Validate mission file syntax and structure
    info        Show detailed mission information

EXAMPLES:
    # See all available example missions
    rustchain mission list

    # Validate before running (recommended)
    rustchain mission validate my_mission.yaml

    # Get detailed mission information
    rustchain mission info examples/hello_world.yaml

VALIDATION CHECKS:
    CHECKS: YAML syntax correctness
    CHECKS: Required fields present
    CHECKS: Step type validity
    CHECKS: Parameter requirements
    CHECKS: Dependency resolution
    CHECKS: Safety assessment

For mission creation guide, see: docs/MISSION_GUIDE.md"#
    }

    /// Get detailed help for LLM commands
    pub fn llm_help() -> &'static str {
        r#"AI model interactions and management

USAGE:
    rustchain llm <COMMAND>

COMMANDS:
    models    List available models from providers
    chat      Interactive chat with AI models
    test      Test connectivity to LLM providers

EXAMPLES:
    # List all available models
    rustchain llm models

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

    # 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 creativity (temperature)
    rustchain llm chat "Write a story" --temperature 1.2

    # Technical discussion (low temperature)
    rustchain llm chat "Explain memory safety" --temperature 0.1

    # Test provider connectivity
    rustchain llm test
    rustchain llm test openai

SUPPORTED PROVIDERS:
    • OpenAI (GPT-3.5, GPT-4, GPT-4 Turbo)
    • Anthropic (Claude 3 family)
    • Ollama (Local models)
    • Custom providers via configuration

TEMPERATURE GUIDE:
    0.0-0.3  Factual, precise responses
    0.4-0.7  Balanced creativity and accuracy
    0.8-2.0  Creative, experimental responses

Setup: Configure API keys in environment or config file"#
    }

    /// Get detailed help for tools commands
    pub fn tools_help() -> &'static str {
        r#"Tool management and execution

USAGE:
    rustchain tools <COMMAND>

COMMANDS:
    list      List all available tools
    info      Get detailed information about a tool
    execute   Execute a tool directly with parameters

EXAMPLES:
    # List all available tools
    rustchain tools list

    # Get tool documentation
    rustchain tools info file_create
    rustchain tools info http_request

    # Execute tools directly
    rustchain tools execute file_create --params '{
        "path": "hello.txt",
        "content": "Hello, World!"
    }'

    rustchain tools execute http_request --params '{
        "url": "https://api.github.com",
        "method": "GET"
    }'

    rustchain tools execute command_execute --params '{
        "command": "ls",
        "args": ["-la", "/tmp"]
    }'

AVAILABLE TOOL CATEGORIES:
    FILE OPERATIONS:
       • file_create, file_read, file_write
       • file_delete, file_exists, directory_list

    NETWORK OPERATIONS:
       • http_request, websocket_connect
       • api_call, webhook_trigger

    SYSTEM OPERATIONS:
       • command_execute, process_info
       • environment_get, path_resolve

    AI OPERATIONS:
       • llm_call, embedding_generate
       • text_summarize, sentiment_analyze

PARAMETER FORMAT:
    Use JSON format for --params option
    Example: --params '{"key": "value", "number": 42}'

SECURITY:
    All tools run within safety policy constraints
    Use 'rustchain policy status' to see current restrictions"#
    }

    /// Get detailed help for safety commands
    pub fn safety_help() -> &'static str {
        r#"Security validation and safety checks

USAGE:
    rustchain safety <COMMAND>

COMMANDS:
    validate    Validate mission file for security risks
    check       Run comprehensive system safety checks
    report      Generate detailed safety assessment

EXAMPLES:
    # Validate a mission file
    rustchain safety validate mission.yaml

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

    # System-wide 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

SAFETY CHECKS:
    MISSION ANALYSIS:
       • Step type validation
       • Parameter safety review
       • Dependency security

    RISK ASSESSMENT:
       • File system access patterns
       • Network communication review
       • Command execution analysis

    POLICY COMPLIANCE:
       • Corporate policy adherence
       • Security standard compliance
       • Access control validation

RISK LEVELS:
    LOW: Safe to execute
    MEDIUM: Review recommended
    HIGH: Caution required
    CRITICAL: Do not execute

REPORT FORMATS:
    • text (human-readable, default)
    • json (machine-readable)
    • yaml (structured format)

Best Practice: Always validate missions before execution"#
    }

    /// Get detailed help for policy commands
    pub fn policy_help() -> &'static str {
        r#"Policy enforcement and compliance management

USAGE:
    rustchain policy <COMMAND>

COMMANDS:
    list        List all active security policies
    validate    Validate policy configuration
    status      Show policy enforcement status

EXAMPLES:
    # Show all active policies
    rustchain policy list

    # Validate policy configuration
    rustchain policy validate

    # Check enforcement status
    rustchain policy status

POLICY CATEGORIES:
    FILE ACCESS POLICY:
       • Allowed/blocked directories
       • File operation restrictions
       • Permission requirements

    NETWORK POLICY:
       • Allowed domains and IPs
       • Port restrictions
       • Protocol limitations

    COMMAND EXECUTION POLICY:
       • Allowed/blocked commands
       • Parameter validation
       • Privilege restrictions

    LLM SAFETY POLICY:
       • Content filtering
       • Prompt injection detection
       • Response validation

POLICY STATUS INDICATORS:
    ENFORCED: Policy active and blocking violations
    WARNING: Policy active but only logging violations
    DISABLED: Policy not enforced
    CONFIGURING: Policy being set up

CONFIGURATION:
    Policies are configured in:
    • System config: /etc/rustchain/policies/
    • User config: ~/.rustchain/policies/
    • Project config: ./rustchain/policies/"#
    }

    /// Get detailed help for interactive mode
    pub fn interactive_help() -> &'static str {
        r#"Start interactive conversational mode

USAGE:
    rustchain interactive

DESCRIPTION:
    Interactive mode provides a conversational interface similar to
    Claude Code, allowing you to:

    • Have natural conversations with AI models
    • Create and execute missions dynamically
    • Get real-time help and guidance
    • Explore RustChain capabilities interactively

EXAMPLES:
    $ rustchain interactive
    RustChain Interactive Mode - Type 'help' or 'exit'

    > create a mission to analyze my Rust codebase
    > run the generated mission
    > show me performance metrics
    > help with optimizing the analysis
    > exit

INTERACTIVE COMMANDS:
    help           Show available commands
    exit, quit     Exit interactive mode
    clear          Clear screen
    history        Show command history
    save <file>    Save session to file
    load <file>    Load previous session

FEATURES:
    • Intelligent conversation flow
    • Context-aware suggestions
    • Mission generation assistance
    • Real-time execution feedback
    • Error explanation and fixes
    • Best practice recommendations

Note: Interactive mode requires LLM provider configuration"#
    }

    /// Get detailed help for enterprise commands
    pub fn enterprise_help() -> &'static str {
        r#"Enterprise features and advanced capabilities

USAGE:
    rustchain enterprise <COMMAND>

COMMANDS:
    auth           Authentication and authorization
    compliance     Compliance and auditing features
    monitoring     Performance monitoring and metrics
    multi-tenant   Multi-tenancy management

ENTERPRISE FEATURES:
    AUTHENTICATION & RBAC:
       • JWT token management
       • OAuth2 integration
       • Role-based access control
       • Multi-factor authentication

    COMPLIANCE & AUDITING:
       • GDPR compliance checking
       • HIPAA compliance validation
       • SOX audit trail requirements
       • Custom compliance standards

    MONITORING & PERFORMANCE:
       • Real-time metrics collection
       • Performance dashboards
       • Alerting and notifications
       • Resource usage tracking

    MULTI-TENANCY:
       • Tenant isolation
       • Resource quotas
       • Billing integration
       • Custom branding

EXAMPLES:
    # Setup authentication
    rustchain enterprise auth init-jwt
    rustchain enterprise auth setup-oauth2 google --client-id <id>

    # Compliance checking
    rustchain enterprise compliance verify mission.yaml --standard GDPR
    rustchain enterprise compliance audit

    # Performance monitoring
    rustchain enterprise monitoring dashboard
    rustchain enterprise monitoring start-metrics

    # Multi-tenancy
    rustchain enterprise multi-tenant create-tenant acme "ACME Corp"

LICENSING:
    Enterprise features require RustChain Enterprise license
    Contact: enterprise@rustchain.dev"#
    }

    /// Get comprehensive feature help
    pub fn features_help() -> &'static str {
        r#"Feature detection and capability management

USAGE:
    rustchain features <COMMAND>

COMMANDS:
    list      List all features and their availability
    check     Check if a specific feature is available
    summary   Show comprehensive feature overview
    upgrade   Show upgrade recommendations

EXAMPLES:
    # List all features
    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

    # Get feature summary
    rustchain features summary

    # See upgrade options
    rustchain features upgrade

FEATURE CATEGORIES:
    CORE FEATURES (Always Available):
       • Mission execution
       • Safety validation
       • Basic tool support

    AI FEATURES (Require Configuration):
       • LLM integration
       • Agent reasoning
       • RAG capabilities

    ENTERPRISE FEATURES (License Required):
       • RBAC authentication
       • Compliance checking
       • Multi-tenancy

    OPTIONAL FEATURES (Compile-time):
       • Server mode
       • Sandbox isolation
       • Advanced monitoring

FEATURE STATUS:
    AVAILABLE: Feature ready to use
    CONFIGURABLE: Requires setup (API keys, etc.)
    LICENSED: Requires enterprise license
    UNAVAILABLE: Not compiled or not supported

UPGRADE PATHS:
    Community → Professional → Enterprise

For licensing information: https://rustchain.dev/pricing"#
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_help_examples_content() {
        // Test that all help content is non-empty and contains expected keywords
        assert!(CommandExamples::main_help().contains("RustChain"));
        assert!(CommandExamples::run_help().contains("Execute"));
        assert!(CommandExamples::mission_help().contains("Mission"));
        assert!(CommandExamples::llm_help().contains("AI model"));
        assert!(CommandExamples::tools_help().contains("Tool management"));
        assert!(CommandExamples::safety_help().contains("Security"));
        assert!(CommandExamples::policy_help().contains("Policy"));
        assert!(CommandExamples::interactive_help().contains("conversational"));
        assert!(CommandExamples::enterprise_help().contains("Enterprise"));
        assert!(CommandExamples::features_help().contains("Feature"));
    }

    #[test]
    fn test_help_examples_structure() {
        // Test that help content follows expected structure
        let main_help = CommandExamples::main_help();
        assert!(main_help.contains("USAGE:"));
        assert!(main_help.contains("EXAMPLES:"));
        assert!(main_help.contains("COMMANDS:"));

        let run_help = CommandExamples::run_help();
        assert!(run_help.contains("USAGE:"));
        assert!(run_help.contains("ARGUMENTS:"));
        assert!(run_help.contains("OPTIONS:"));
        assert!(run_help.contains("EXAMPLES:"));
    }

    #[test]
    fn test_help_examples_formatting() {
        // Test that help content is properly formatted
        for help_text in [
            CommandExamples::main_help(),
            CommandExamples::run_help(),
            CommandExamples::mission_help(),
            CommandExamples::llm_help(),
            CommandExamples::tools_help(),
            CommandExamples::safety_help(),
        ] {
            // Should not be empty
            assert!(!help_text.is_empty());

            // Should contain proper formatting
            assert!(help_text.contains("USAGE:") || help_text.contains("DESCRIPTION:"));

            // Should not have excessive trailing whitespace on lines
            for line in help_text.lines() {
                // Allow single trailing space for formatting, but not multiple
                let trimmed = line.trim_end();
                if line.len() > trimmed.len() + 1 {
                    panic!("Line has excessive trailing whitespace: '{}'", line);
                }
            }
        }
    }
}