File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ futures = "0.3"
1616termimad = " 0.34"
1717tree-sitter = " 0.25"
1818tree-sitter-highlight = " 0.25"
19+ json_comments = " 0.2.2"
1920
2021[target .'cfg(unix)' .dependencies ]
2122libc = " 0.2"
Original file line number Diff line number Diff line change 11use std:: collections:: HashMap ;
22use std:: path:: PathBuf ;
3+ use json_comments:: StripComments ;
34use serde:: { Serialize , Deserialize } ;
45use shai_llm:: ToolCallMethod ;
56use crate :: tools:: mcp:: McpConfig ;
@@ -121,8 +122,9 @@ impl AgentConfig {
121122 return Err ( format ! ( "Agent config '{}' does not exist" , agent_name) . into ( ) ) ;
122123 }
123124
124- let content = std:: fs:: read_to_string ( config_path) ?;
125- let config: AgentConfig = serde_json:: from_str ( & content) ?;
125+ let content_bytes = std:: fs:: read ( config_path) ?;
126+ let content_stripped = StripComments :: new ( & content_bytes[ ..] ) ;
127+ let config: AgentConfig = serde_json:: from_reader ( content_stripped) ?;
126128 Ok ( config)
127129 }
128130
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use std::fs;
33#[ cfg( unix) ]
44use std:: os:: unix:: fs:: PermissionsExt ;
55use reqwest:: Url ;
6+ use json_comments:: StripComments ;
67use serde:: { Serialize , Deserialize } ;
78use shai_llm:: { LlmClient , ToolCallMethod } ;
89use crate :: tools:: mcp:: McpConfig ;
@@ -90,9 +91,10 @@ impl ShaiConfig {
9091 return Err ( "config file does not exist" . into ( ) ) ;
9192 }
9293
93- let content = fs:: read_to_string ( config_path) ?;
94- let mut config: ShaiConfig = serde_json:: from_str ( & content) ?;
95-
94+ let content_bytes = fs:: read ( config_path) ?;
95+ let content_stripped = StripComments :: new ( & content_bytes[ ..] ) ;
96+ let mut config: ShaiConfig = serde_json:: from_reader ( content_stripped) ?;
97+
9698 // Validate selected_provider index
9799 if config. providers . is_empty ( ) {
98100 config. selected_provider = 0 ;
You can’t perform that action at this time.
0 commit comments