Skip to content
Open
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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions shai-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ futures = "0.3"
termimad = "0.34"
tree-sitter = "0.25"
tree-sitter-highlight = "0.25"
json_comments = "0.2.2"

[target.'cfg(unix)'.dependencies]
libc = "0.2"
Expand Down
6 changes: 4 additions & 2 deletions shai-core/src/config/agent.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::collections::HashMap;
use std::path::PathBuf;
use json_comments::StripComments;
use serde::{Serialize, Deserialize};
use shai_llm::ToolCallMethod;
use crate::tools::mcp::McpConfig;
Expand Down Expand Up @@ -121,8 +122,9 @@ impl AgentConfig {
return Err(format!("Agent config '{}' does not exist", agent_name).into());
}

let content = std::fs::read_to_string(config_path)?;
let config: AgentConfig = serde_json::from_str(&content)?;
let content_bytes = std::fs::read(config_path)?;
let content_stripped = StripComments::new(&content_bytes[..]);
let config: AgentConfig = serde_json::from_reader(content_stripped)?;
Ok(config)
}

Expand Down
8 changes: 5 additions & 3 deletions shai-core/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fs;
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
use reqwest::Url;
use json_comments::StripComments;
use serde::{Serialize, Deserialize};
use shai_llm::{LlmClient, ToolCallMethod};
use crate::tools::mcp::McpConfig;
Expand Down Expand Up @@ -90,9 +91,10 @@ impl ShaiConfig {
return Err("config file does not exist".into());
}

let content = fs::read_to_string(config_path)?;
let mut config: ShaiConfig = serde_json::from_str(&content)?;

let content_bytes = fs::read(config_path)?;
let content_stripped = StripComments::new(&content_bytes[..]);
let mut config: ShaiConfig = serde_json::from_reader(content_stripped)?;

// Validate selected_provider index
if config.providers.is_empty() {
config.selected_provider = 0;
Expand Down