@@ -11,13 +11,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
11116 . [ Core Utilities] ( #core-utilities )
12127 . [ SSH Deployment System] ( #ssh-deployment-system )
13138 . [ AI Integration] ( #ai-integration )
14-
15149 . [ MCP Server Integration] ( #mcp-server-integration )
16- 10 . [ Testing Strategy] ( #testing-strategy )
17- 11 . [ Error Handling] ( #error-handling )
18- 12 . [ Configuration Management] ( #configuration-management )
19- 13 . [ Common Development Patterns] ( #common-development-patterns )
20- 14 . [ Debugging and Troubleshooting] ( #debugging-and-troubleshooting )
15+ 10 . [ OVSM Script Language Integration] ( #ovsm-script-language-integration )
16+ 11 . [ Testing Strategy] ( #testing-strategy )
17+ 12 . [ Error Handling] ( #error-handling )
18+ 13 . [ Configuration Management] ( #configuration-management )
19+ 14 . [ Common Development Patterns] ( #common-development-patterns )
20+ 15 . [ Debugging and Troubleshooting] ( #debugging-and-troubleshooting )
2121
2222## Development Environment Setup
2323
@@ -154,7 +154,8 @@ osvm-cli/
154154│ │ ├── mod.rs # Service module exports
155155│ │ ├── ai_service.rs # AI query processing, OpenAI/Ollama integration
156156│ │ ├── audit_service.rs # Security auditing with AI analysis
157- │ │ └── mcp_service.rs # Model Context Protocol server management
157+ │ │ ├── mcp_service.rs # Model Context Protocol server management
158+ │ │ └── ovsm_service.rs # OVSM script language integration
158159│ └── utils/ # Core utilities and implementations
159160│ ├── mod.rs # Utils module exports
160161│ ├── agent_chat.rs # Basic agent chat UI
@@ -245,6 +246,14 @@ osvm-cli/
245246- ** setup** : Quick setup for Solana MCP
246247- ** search** : Search servers by query
247248
249+ #### ` osvm ovsm <SUBCOMMAND> `
250+ - ** run <SCRIPT >** : Execute OVSM script file
251+ - ** eval <CODE >** : Execute inline OVSM code
252+ - ** check <SCRIPT >** : Syntax check without execution
253+ - ** repl** : Interactive REPL for live coding
254+ - ** examples** : Show example scripts
255+ - Works independently (no Solana config required)
256+
248257#### ` osvm chat [--advanced] [--test] `
249258- Interactive chat interface
250259- Basic mode: Simple chat UI
@@ -363,6 +372,37 @@ McpServerConfig {
363372- GitHub repository integration
364373- Configuration persistence in ` ~/.osvm/mcp_config.json `
365374
375+ ### OVSM Service (` services/ovsm_service.rs ` )
376+
377+ ** Architecture:**
378+ - Wraps OVSM language interpreter (scanner, parser, evaluator)
379+ - Script execution from files or inline code
380+ - Syntax checking without execution
381+ - Multiple output formats (text, JSON)
382+ - Works independently of OSVM configuration
383+
384+ ** Service Structure:**
385+ ``` rust
386+ OvsmService {
387+ evaluator : Evaluator , // OVSM runtime
388+ verbose : bool ,
389+ debug : bool ,
390+ }
391+ ```
392+
393+ ** Key Methods:**
394+ - ` execute_code() ` : Run OVSM code from string
395+ - ` execute_file() ` : Run OVSM script file
396+ - ` check_syntax() ` : Validate syntax without execution
397+ - ` format_value() ` : Convert OVSM value to string
398+ - ` format_value_json() ` : Convert OVSM value to JSON
399+
400+ ** Integration Points:**
401+ - Main command router for ` osvm ovsm ` subcommand
402+ - Early command handling (before config loading)
403+ - Example scripts in ` examples/ovsm_scripts/ `
404+ - Integration tests in ` tests/ovsm_integration_tests.rs `
405+
366406## Core Utilities
367407
368408### SSH Deployment System (` utils/ssh_deploy/ ` )
@@ -637,6 +677,227 @@ osvm mcp add-github my-server https://github.com/org/mcp-server --enabled
637677# Registers server
638678```
639679
680+ ## OVSM Script Language Integration
681+
682+ OVSM (Open Versatile Seeker Mind) is a production-ready scripting language integrated into OSVM-CLI for blockchain automation. It provides a simple yet powerful syntax for writing automation scripts with 97.3% test coverage.
683+
684+ ### OVSM Service (` services/ovsm_service.rs ` )
685+
686+ ** Architecture:**
687+ - Wraps the OVSM language interpreter (scanner, parser, evaluator)
688+ - Handles script execution from files or inline code
689+ - Provides syntax checking without execution
690+ - Supports multiple output formats (text, JSON)
691+ - No OSVM configuration required (works independently)
692+
693+ ** Service Structure:**
694+ ``` rust
695+ pub struct OvsmService {
696+ evaluator : Evaluator , // OVSM runtime
697+ verbose : bool ,
698+ debug : bool ,
699+ }
700+ ```
701+
702+ ** Key Methods:**
703+ ``` rust
704+ // Execute OVSM code from string
705+ pub fn execute_code (& mut self , code : & str ) -> Result <Value >
706+
707+ // Execute OVSM script file
708+ pub fn execute_file <P : AsRef <Path >>(& mut self , script_path : P ) -> Result <Value >
709+
710+ // Check syntax without execution
711+ pub fn check_syntax (& self , code : & str ) -> Result <()>
712+
713+ // Format output
714+ pub fn format_value (& self , value : & Value ) -> String
715+ pub fn format_value_json (& self , value : & Value ) -> Result <String >
716+ ```
717+
718+ ### OVSM Commands
719+
720+ #### `osvm ovsm run <SCRIPT >`
721+ Execute an OVSM script file :
722+ ```bash
723+ osvm ovsm run script . ovsm
724+ osvm ovsm run script . ovsm -- json
725+ osvm ovsm run script . ovsm -- verbose
726+ ```
727+
728+ #### `osvm ovsm eval <CODE >`
729+ Execute inline OVSM code :
730+ ```bash
731+ osvm ovsm eval '$x = 42; RETURN $x'
732+ osvm ovsm eval 'FOR $ i IN [1 .. 6 ]: $ sum = $ sum + $ i ; RETURN $ sum '
733+ osvm ovsm eval --json ' RETURN {" result" : 42 }'
734+ ```
735+
736+ #### `osvm ovsm check <SCRIPT>`
737+ Check script syntax without execution:
738+ ```bash
739+ osvm ovsm check script.ovsm
740+ ```
741+
742+ #### `osvm ovsm repl`
743+ Interactive REPL for live coding:
744+ ```bash
745+ osvm ovsm repl
746+ # ovsm> $x = 10
747+ # ovsm> RETURN $x * 2
748+ # 20
749+ ```
750+
751+ #### `osvm ovsm examples`
752+ Display example scripts and usage:
753+ ```bash
754+ osvm ovsm examples
755+ osvm ovsm examples --category basics
756+ ```
757+
758+ ### OVSM Language Overview
759+
760+ **Core Syntax:**
761+ ```ovsm
762+ // Variables
763+ $variable = "value"
764+ $number = 42
765+
766+ // Control flow
767+ IF condition THEN
768+ // code
769+ ELSE
770+ // code
771+
772+ FOR $item IN collection:
773+ // code
774+
775+ WHILE condition:
776+ // code
777+
778+ // Return value
779+ RETURN result
780+ ```
781+
782+ **Data Types:**
783+ - Numbers: `42`, `3.14`
784+ - Strings: `"text"`
785+ - Booleans: `true`, `false`
786+ - Arrays: `[1, 2, 3]`
787+ - Objects: `{"key": "value"}`
788+ - Ranges: `[1..10]` (exclusive end)
789+ - Null: `null`
790+
791+ **Operators:**
792+ - Arithmetic: `+`, `-`, `*`, `/`, `%`, `**` (power)
793+ - Comparison: `<`, `>`, `<=`, `>=`, `==`, `!=`
794+ - Logical: `AND`, `OR`, `NOT`
795+
796+ **Example Scripts:**
797+ Located in `examples/ovsm_scripts/`:
798+ ```bash
799+ # Hello world
800+ osvm ovsm run examples/ovsm_scripts/01_hello_world.ovsm
801+
802+ # Control flow
803+ osvm ovsm run examples/ovsm_scripts/02_control_flow.ovsm
804+
805+ # Arithmetic operations
806+ osvm ovsm run examples/ovsm_scripts/03_arithmetic.ovsm
807+
808+ # Conditionals
809+ osvm ovsm run examples/ovsm_scripts/04_conditionals.ovsm
810+
811+ # Factorial calculation
812+ osvm ovsm run examples/ovsm_scripts/05_factorial.ovsm
813+ ```
814+
815+ ### Integration Architecture
816+
817+ **Early Command Handling:**
818+ OVSM commands are handled early in `main.rs` (before Solana config loading) to ensure they work independently:
819+
820+ ```rust
821+ // In main.rs
822+ if sub_command == "ovsm" {
823+ return handle_ovsm_command(sub_matches).await;
824+ }
825+ ```
826+
827+ **Handler Implementation:**
828+ ```rust
829+ async fn handle_ovsm_command(matches: &clap::ArgMatches) -> Result<()> {
830+ match matches.subcommand() {
831+ Some(("run", sub_m)) => { /* execute script file */ },
832+ Some(("eval", sub_m)) => { /* execute inline code */ },
833+ Some(("check", sub_m)) => { /* syntax check */ },
834+ Some(("repl", _)) => { /* interactive REPL */ },
835+ Some(("examples", _)) => { /* show examples */ },
836+ _ => { /* show help */ },
837+ }
838+ }
839+ ```
840+
841+ ### Testing OVSM Integration
842+
843+ **Unit Tests:**
844+ Located in `src/services/ovsm_service.rs`:
845+ ```rust
846+ #[test]
847+ fn test_execute_simple_code() {
848+ let mut service = OvsmService::new();
849+ let result = service.execute_code("$x = 42\ n RETURN $x").unwrap();
850+ assert_eq!(result, Value::Int(42));
851+ }
852+ ```
853+
854+ **Integration Tests:**
855+ Located in `tests/ovsm_integration_tests.rs`:
856+ ```bash
857+ # Run OVSM integration tests
858+ cargo test --test ovsm_integration_tests
859+
860+ # Run specific test
861+ cargo test test_ovsm_eval_simple_arithmetic
862+ ```
863+
864+ **Test Coverage:**
865+ - 22 integration tests covering all OVSM commands
866+ - Tests for eval, run, check, syntax errors, JSON output
867+ - Verification that OVSM works without Solana config
868+
869+ ### Important OVSM Notes
870+
871+ 1. **Independent Operation**: OVSM commands do NOT require Solana configuration or keypair. They work standalone.
872+
873+ 2. **Indentation-Based**: Like Python, OVSM uses indentation for block structure.
874+
875+ 3. **Range Syntax**: Ranges are exclusive of the end value: `[1..5]` creates `[1, 2, 3, 4]`
876+
877+ 4. **Boolean Literals**: Use lowercase `true` and `false` (not `TRUE`/`FALSE`)
878+
879+ 5. **Test Coverage**: The OVSM interpreter has 97.3% test coverage, ensuring production reliability
880+
881+ 6. **No PRINT Statement**: Use `RETURN` for output. There' s a `LOG ` tool for debugging but it 's not in the standard examples .
882+
883+ 7 . * * Loop Syntax ** : Loops use `: ` at the end: `FOR $ i IN [1.. 10]: `
884+
885+ ### Future OVSM Enhancements (Phase 2+ )
886+
887+ - * * Blockchain Operations ** : TOOL calls for validator deployment, RPC queries, etc.
888+ - * * MCP Integration ** : Access MCP servers from OVSM scripts
889+ - * * AI Code Generation ** : Generate OVSM scripts from natural language
890+ - * * MicroVM Isolation ** : Run untrusted scripts in isolated microVMs
891+ - * * Script Library ** : Shared repository of automation scripts
892+
893+ ### OVSM Resources
894+
895+ - Language Specification : `crates/ ovsm/ README . md`
896+ - Usage Guide : `crates/ ovsm/ USAGE_GUIDE . md`
897+ - How - To Guide : `crates/ ovsm/ HOW_TO_USE . md`
898+ - Example Scripts : `examples/ ovsm_scripts/ README . md`
899+ - Integration Tests : `tests/ ovsm_integration_tests. rs`
900+
640901## Testing Strategy
641902
642903### Unit Tests
0 commit comments