Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,28 @@ Traditional Chat OSVM AI Chat (NEW!)

### Installation (5 Minutes)

**Linux:**
```bash
# Clone the repository
# Clone and build
git clone https://github.com/opensvm/osvm-cli.git
cd osvm-cli

# Build and install
cargo build --release
sudo cp target/release/osvm /usr/bin/osvm

# Verify installation
osvm --version # Should show 0.9.3
# Verify
osvm --version
```

**macOS (via Docker):**
```bash
# Clone and run via Docker
git clone https://github.com/opensvm/osvm-cli.git
cd osvm-cli
./scripts/docker-run-macos.sh --version

# Use any command
./scripts/docker-run-macos.sh snapshot --help
./scripts/docker-run-macos.sh ovsm eval '(+ 1 2 3)'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (typo): Possible typo: 'ovsm' should likely be 'osvm'.

Please update 'ovsm' to 'osvm' for consistency with the rest of the documentation and repository.

Suggested change
./scripts/docker-run-macos.sh ovsm eval '(+ 1 2 3)'
./scripts/docker-run-macos.sh osvm eval '(+ 1 2 3)'

```

### 🆕 Try the AI-Powered Chat (NEW!)
Expand Down
29 changes: 16 additions & 13 deletions crates/ovsm/src/runtime/lisp_evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3165,8 +3165,8 @@ impl LispEvaluator {
};

// Parse JSON string into serde_json::Value
let json_value: serde_json::Value = serde_json::from_str(&json_str)
.map_err(|e| Error::ToolExecutionError {
let json_value: serde_json::Value =
serde_json::from_str(&json_str).map_err(|e| Error::ToolExecutionError {
tool: "json-parse".to_string(),
reason: format!("Failed to parse JSON: {}", e),
})?;
Expand Down Expand Up @@ -3240,9 +3240,9 @@ impl LispEvaluator {
}
}
JV::String(s) => Value::String(s),
JV::Array(arr) => {
Value::Array(Arc::new(arr.into_iter().map(|v| self.json_to_value(v)).collect()))
}
JV::Array(arr) => Value::Array(Arc::new(
arr.into_iter().map(|v| self.json_to_value(v)).collect(),
)),
JV::Object(map) => {
let mut obj = HashMap::new();
for (k, v) in map {
Expand All @@ -3260,11 +3260,9 @@ impl LispEvaluator {
Value::Null => JV::Null,
Value::Bool(b) => JV::Bool(b),
Value::Int(i) => JV::Number(serde_json::Number::from(i)),
Value::Float(f) => {
serde_json::Number::from_f64(f)
.map(JV::Number)
.unwrap_or(JV::Null)
}
Value::Float(f) => serde_json::Number::from_f64(f)
.map(JV::Number)
.unwrap_or(JV::Null),
Value::String(s) => JV::String(s.to_string()),
Value::Array(arr) => {
let mut json_arr = Vec::new();
Expand Down Expand Up @@ -3896,7 +3894,8 @@ impl LispEvaluator {
for (key, values) in groups_obj.iter() {
// Create scope for aggregation function
self.env.enter_scope();
self.env.define(params[0].clone(), Value::String(key.clone()));
self.env
.define(params[0].clone(), Value::String(key.clone()));
self.env.define(params[1].clone(), values.clone());

// Evaluate aggregation function
Expand All @@ -3921,7 +3920,8 @@ impl LispEvaluator {
if args.len() < 2 || args.len() > 3 {
return Err(Error::InvalidArguments {
tool: "sort-by".to_string(),
reason: "Expected 2-3 arguments: collection, key-fn, and optional :desc flag".to_string(),
reason: "Expected 2-3 arguments: collection, key-fn, and optional :desc flag"
.to_string(),
});
}

Expand Down Expand Up @@ -3949,7 +3949,10 @@ impl LispEvaluator {
if params.len() != 1 {
return Err(Error::InvalidArguments {
tool: "sort-by".to_string(),
reason: format!("Key function must take exactly 1 parameter, got {}", params.len()),
reason: format!(
"Key function must take exactly 1 parameter, got {}",
params.len()
),
});
}

Expand Down
22 changes: 15 additions & 7 deletions crates/ovsm/src/tools/stdlib/advanced_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,11 +993,7 @@ impl Tool for AshTool {
let n = args[0].as_int()?;
let count = args[1].as_int()?;

let result = if count >= 0 {
n << count
} else {
n >> -count
};
let result = if count >= 0 { n << count } else { n >> -count };

Ok(Value::Int(result))
}
Expand Down Expand Up @@ -1062,11 +1058,23 @@ impl Tool for SignumTool {

match &args[0] {
Value::Int(n) => {
let sign = if *n < 0 { -1 } else if *n > 0 { 1 } else { 0 };
let sign = if *n < 0 {
-1
} else if *n > 0 {
1
} else {
0
};
Ok(Value::Int(sign))
}
Value::Float(f) => {
let sign = if *f < 0.0 { -1.0 } else if *f > 0.0 { 1.0 } else { 0.0 };
let sign = if *f < 0.0 {
-1.0
} else if *f > 0.0 {
1.0
} else {
0.0
};
Ok(Value::Float(sign))
}
_ => Err(Error::TypeError {
Expand Down
137 changes: 91 additions & 46 deletions crates/ovsm/src/tools/stdlib/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ impl Tool for ArefTool {
let array = args[0].as_array()?;
let index = args[1].as_int()? as usize;

array.get(index).cloned().ok_or_else(|| Error::IndexOutOfBounds {
index,
length: array.len(),
})
array
.get(index)
.cloned()
.ok_or_else(|| Error::IndexOutOfBounds {
index,
length: array.len(),
})
}
}

Expand Down Expand Up @@ -545,9 +548,12 @@ impl Tool for CaadrTool {
}

let second = list[1].as_array()?;
second.first().cloned().ok_or_else(|| Error::EmptyCollection {
operation: "CAADR".to_string(),
})
second
.first()
.cloned()
.ok_or_else(|| Error::EmptyCollection {
operation: "CAADR".to_string(),
})
}
}

Expand Down Expand Up @@ -670,18 +676,30 @@ impl Tool for CaaaarTool {
});
}

let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CAAAAR".to_string(),
})?;
let l2 = l1.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CAAAAR".to_string(),
})?;
let l3 = l2.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CAAAAR".to_string(),
})?;
let l4 = l3.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CAAAAR".to_string(),
})?;
let l1 = args[0]
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CAAAAR".to_string(),
})?;
let l2 = l1
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CAAAAR".to_string(),
})?;
let l3 = l2
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CAAAAR".to_string(),
})?;
let l4 = l3
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CAAAAR".to_string(),
})?;

Ok(l4.clone())
}
Expand All @@ -707,15 +725,24 @@ impl Tool for CdaaarTool {
});
}

let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CDAAAR".to_string(),
})?;
let l2 = l1.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CDAAAR".to_string(),
})?;
let l3 = l2.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CDAAAR".to_string(),
})?;
let l1 = args[0]
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CDAAAR".to_string(),
})?;
let l2 = l1
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CDAAAR".to_string(),
})?;
let l3 = l2
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CDAAAR".to_string(),
})?;
let l4 = l3.as_array()?;

if l4.is_empty() {
Expand Down Expand Up @@ -746,12 +773,18 @@ impl Tool for CadaarTool {
});
}

let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CADAAR".to_string(),
})?;
let l2 = l1.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CADAAR".to_string(),
})?;
let l1 = args[0]
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CADAAR".to_string(),
})?;
let l2 = l1
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CADAAR".to_string(),
})?;
let l3 = l2.as_array()?;

if l3.len() < 2 {
Expand Down Expand Up @@ -785,12 +818,18 @@ impl Tool for CddaarTool {
});
}

let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CDDAAR".to_string(),
})?;
let l2 = l1.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CDDAAR".to_string(),
})?;
let l1 = args[0]
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CDDAAR".to_string(),
})?;
let l2 = l1
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CDDAAR".to_string(),
})?;
let l3 = l2.as_array()?;

if l3.len() < 2 {
Expand Down Expand Up @@ -821,9 +860,12 @@ impl Tool for CaadarTool {
});
}

let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CAADAR".to_string(),
})?;
let l1 = args[0]
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CAADAR".to_string(),
})?;
let l2 = l1.as_array()?;

if l2.len() < 2 {
Expand All @@ -833,9 +875,12 @@ impl Tool for CaadarTool {
});
}

let l3 = l2[1].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
operation: "CAADAR".to_string(),
})?;
let l3 = l2[1]
.as_array()?
.first()
.ok_or_else(|| Error::EmptyCollection {
operation: "CAADAR".to_string(),
})?;

Ok(l3.clone())
}
Expand Down
Loading
Loading