File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed
crates/chat-cli/src/cli/chat/cli Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -145,20 +145,26 @@ impl AgentSubcommand {
145
145
return Err ( ChatError :: Custom ( "Editor process did not exit with success" . into ( ) ) ) ;
146
146
}
147
147
148
- let Ok ( content) = os. fs . read ( & path_with_file_name) . await else {
149
- return Err ( ChatError :: Custom (
150
- format ! (
151
- "Post write validation failed. Error opening {}. Aborting" ,
152
- path_with_file_name. display( )
153
- )
154
- . into ( ) ,
155
- ) ) ;
156
- } ;
157
- if let Err ( e) = serde_json:: from_slice :: < Agent > ( & content) {
158
- return Err ( ChatError :: Custom (
159
- format ! ( "Post write validation failed for agent '{name}'. Malformed config detected: {e}" )
160
- . into ( ) ,
161
- ) ) ;
148
+ let new_agent = Agent :: load ( os, & path_with_file_name, & mut None ) . await ;
149
+ match new_agent {
150
+ Ok ( agent) => {
151
+ session. conversation . agents . agents . insert ( agent. name . clone ( ) , agent) ;
152
+ } ,
153
+ Err ( e) => {
154
+ execute ! (
155
+ session. stderr,
156
+ style:: SetForegroundColor ( Color :: Red ) ,
157
+ style:: Print ( "Error: " ) ,
158
+ style:: ResetColor ,
159
+ style:: Print ( & e) ,
160
+ style:: Print ( "\n " ) ,
161
+ ) ?;
162
+
163
+ return Err ( ChatError :: Custom (
164
+ format ! ( "Post write validation failed for agent '{name}'. Malformed config detected: {e}" )
165
+ . into ( ) ,
166
+ ) ) ;
167
+ } ,
162
168
}
163
169
164
170
execute ! (
You can’t perform that action at this time.
0 commit comments