@@ -226,7 +226,14 @@ mod markdown_generator {
226226
227227 writeln ! ( & mut self . output, "## Agent" ) . unwrap ( ) ;
228228 writeln ! ( & mut self . output) . unwrap ( ) ;
229- writeln ! ( & mut self . output, "{}" , side_docs. agent_trait) . unwrap ( ) ;
229+ writeln ! (
230+ & mut self . output,
231+ "Defines the interface that all ACP-compliant agents must implement.
232+
233+ Agents are programs that use generative AI to autonomously modify code. They handle
234+ requests from clients and execute tasks using language models and tools."
235+ )
236+ . unwrap ( ) ;
230237 writeln ! ( & mut self . output) . unwrap ( ) ;
231238
232239 for ( method, types) in agent_types {
@@ -235,7 +242,15 @@ mod markdown_generator {
235242
236243 writeln ! ( & mut self . output, "## Client" ) . unwrap ( ) ;
237244 writeln ! ( & mut self . output) . unwrap ( ) ;
238- writeln ! ( & mut self . output, "{}" , side_docs. client_trait) . unwrap ( ) ;
245+ writeln ! (
246+ & mut self . output,
247+ "Defines the interface that ACP-compliant clients must implement.
248+
249+ Clients are typically code editors (IDEs, text editors) that provide the interface
250+ between users and AI agents. They manage the environment, handle user interactions,
251+ and control access to resources."
252+ )
253+ . unwrap ( ) ;
239254
240255 for ( method, types) in client_types {
241256 self . generate_method ( & method, side_docs. client_method_doc ( & method) , types) ;
@@ -775,42 +790,44 @@ mod markdown_generator {
775790 }
776791
777792 struct SideDocs {
778- agent_trait : String ,
779793 agent_methods : HashMap < String , String > ,
780- client_trait : String ,
781794 client_methods : HashMap < String , String > ,
782795 }
783796
784797 impl SideDocs {
785798 fn agent_method_doc ( & self , method_name : & str ) -> & String {
786799 match method_name {
787- "initialize" => self . agent_methods . get ( "initialize " ) . unwrap ( ) ,
788- "authenticate" => self . agent_methods . get ( "authenticate " ) . unwrap ( ) ,
789- "session/new" => self . agent_methods . get ( "new_session " ) . unwrap ( ) ,
790- "session/load" => self . agent_methods . get ( "load_session " ) . unwrap ( ) ,
791- "session/set_mode" => self . agent_methods . get ( "set_session_mode " ) . unwrap ( ) ,
792- "session/prompt" => self . agent_methods . get ( "prompt " ) . unwrap ( ) ,
793- "session/cancel" => self . agent_methods . get ( "cancel " ) . unwrap ( ) ,
794- "session/set_model" => self . agent_methods . get ( "set_session_model " ) . unwrap ( ) ,
800+ "initialize" => self . agent_methods . get ( "InitializeRequest " ) . unwrap ( ) ,
801+ "authenticate" => self . agent_methods . get ( "AuthenticateRequest " ) . unwrap ( ) ,
802+ "session/new" => self . agent_methods . get ( "NewSessionRequest " ) . unwrap ( ) ,
803+ "session/load" => self . agent_methods . get ( "LoadSessionRequest " ) . unwrap ( ) ,
804+ "session/set_mode" => self . agent_methods . get ( "SetSessionModeRequest " ) . unwrap ( ) ,
805+ "session/prompt" => self . agent_methods . get ( "PromptRequest " ) . unwrap ( ) ,
806+ "session/cancel" => self . agent_methods . get ( "CancelNotification " ) . unwrap ( ) ,
807+ "session/set_model" => self . agent_methods . get ( "SetSessionModelRequest " ) . unwrap ( ) ,
795808 _ => panic ! ( "Introduced a method? Add it here :)" ) ,
796809 }
797810 }
798811
799812 fn client_method_doc ( & self , method_name : & str ) -> & String {
800813 match method_name {
801814 "session/request_permission" => {
802- self . client_methods . get ( "request_permission" ) . unwrap ( )
803- }
804- "fs/write_text_file" => self . client_methods . get ( "write_text_file" ) . unwrap ( ) ,
805- "fs/read_text_file" => self . client_methods . get ( "read_text_file" ) . unwrap ( ) ,
806- "session/update" => self . client_methods . get ( "session_notification" ) . unwrap ( ) ,
807- "terminal/create" => self . client_methods . get ( "create_terminal" ) . unwrap ( ) ,
808- "terminal/output" => self . client_methods . get ( "terminal_output" ) . unwrap ( ) ,
809- "terminal/release" => self . client_methods . get ( "release_terminal" ) . unwrap ( ) ,
810- "terminal/wait_for_exit" => {
811- self . client_methods . get ( "wait_for_terminal_exit" ) . unwrap ( )
815+ self . client_methods . get ( "RequestPermissionRequest" ) . unwrap ( )
812816 }
813- "terminal/kill" => self . client_methods . get ( "kill_terminal_command" ) . unwrap ( ) ,
817+ "fs/write_text_file" => self . client_methods . get ( "WriteTextFileRequest" ) . unwrap ( ) ,
818+ "fs/read_text_file" => self . client_methods . get ( "ReadTextFileRequest" ) . unwrap ( ) ,
819+ "session/update" => self . client_methods . get ( "SessionNotification" ) . unwrap ( ) ,
820+ "terminal/create" => self . client_methods . get ( "CreateTerminalRequest" ) . unwrap ( ) ,
821+ "terminal/output" => self . client_methods . get ( "TerminalOutputRequest" ) . unwrap ( ) ,
822+ "terminal/release" => self . client_methods . get ( "ReleaseTerminalRequest" ) . unwrap ( ) ,
823+ "terminal/wait_for_exit" => self
824+ . client_methods
825+ . get ( "WaitForTerminalExitRequest" )
826+ . unwrap ( ) ,
827+ "terminal/kill" => self
828+ . client_methods
829+ . get ( "KillTerminalCommandRequest" )
830+ . unwrap ( ) ,
814831 _ => panic ! ( "Introduced a method? Add it here :)" ) ,
815832 }
816833 }
@@ -845,48 +862,68 @@ mod markdown_generator {
845862 let doc: Value = serde_json:: from_str ( & json_content) . unwrap ( ) ;
846863
847864 let mut side_docs = SideDocs {
848- agent_trait : String :: new ( ) ,
849865 agent_methods : HashMap :: new ( ) ,
850- client_trait : String :: new ( ) ,
851866 client_methods : HashMap :: new ( ) ,
852867 } ;
853868
854869 if let Some ( index) = doc[ "index" ] . as_object ( ) {
855870 for ( _, item) in index {
856- if item[ "name" ] . as_str ( ) == Some ( "Agent" ) {
857- if let Some ( docs) = item[ "docs" ] . as_str ( ) {
858- side_docs. agent_trait = docs. to_string ( ) ;
871+ if item[ "name" ] . as_str ( ) == Some ( "ClientRequest" )
872+ && let Some ( variants) = item[ "inner" ] [ "enum" ] [ "variants" ] . as_array ( )
873+ {
874+ for variant_id in variants {
875+ if let Some ( variant) = doc[ "index" ] [ variant_id. to_string ( ) ] . as_object ( )
876+ && let Some ( name) = variant[ "name" ] . as_str ( )
877+ {
878+ side_docs. agent_methods . insert (
879+ name. to_string ( ) ,
880+ variant[ "docs" ] . as_str ( ) . unwrap_or_default ( ) . to_string ( ) ,
881+ ) ;
882+ }
859883 }
884+ }
860885
861- if let Some ( items) = item[ "inner" ] [ "trait" ] [ "items" ] . as_array ( ) {
862- for method_id in items {
863- if let Some ( method) = doc[ "index" ] [ method_id. to_string ( ) ] . as_object ( )
864- && let Some ( name) = method[ "name" ] . as_str ( )
865- {
866- side_docs. agent_methods . insert (
867- name. to_string ( ) ,
868- method[ "docs" ] . as_str ( ) . unwrap_or_default ( ) . to_string ( ) ,
869- ) ;
870- }
886+ if item[ "name" ] . as_str ( ) == Some ( "ClientNotification" )
887+ && let Some ( variants) = item[ "inner" ] [ "enum" ] [ "variants" ] . as_array ( )
888+ {
889+ for variant_id in variants {
890+ if let Some ( variant) = doc[ "index" ] [ variant_id. to_string ( ) ] . as_object ( )
891+ && let Some ( name) = variant[ "name" ] . as_str ( )
892+ {
893+ side_docs. agent_methods . insert (
894+ name. to_string ( ) ,
895+ variant[ "docs" ] . as_str ( ) . unwrap_or_default ( ) . to_string ( ) ,
896+ ) ;
871897 }
872898 }
873899 }
874900
875- if item[ "name" ] . as_str ( ) == Some ( "Client" ) {
876- if let Some ( docs) = item[ "docs" ] . as_str ( ) {
877- side_docs. client_trait = docs. to_string ( ) ;
901+ if item[ "name" ] . as_str ( ) == Some ( "AgentRequest" )
902+ && let Some ( variants) = item[ "inner" ] [ "enum" ] [ "variants" ] . as_array ( )
903+ {
904+ for variant_id in variants {
905+ if let Some ( variant) = doc[ "index" ] [ variant_id. to_string ( ) ] . as_object ( )
906+ && let Some ( name) = variant[ "name" ] . as_str ( )
907+ {
908+ side_docs. client_methods . insert (
909+ name. to_string ( ) ,
910+ variant[ "docs" ] . as_str ( ) . unwrap_or_default ( ) . to_string ( ) ,
911+ ) ;
912+ }
878913 }
914+ }
879915
880- if let Some ( items) = item[ "inner" ] [ "trait" ] [ "items" ] . as_array ( ) {
881- for method_id in items {
882- if let Some ( method) = doc[ "index" ] [ method_id. to_string ( ) ] . as_object ( )
883- && let Some ( name) = method[ "name" ] . as_str ( )
884- {
885- side_docs. client_methods . insert (
886- name. to_string ( ) ,
887- method[ "docs" ] . as_str ( ) . unwrap_or_default ( ) . to_string ( ) ,
888- ) ;
889- }
916+ if item[ "name" ] . as_str ( ) == Some ( "AgentNotification" )
917+ && let Some ( variants) = item[ "inner" ] [ "enum" ] [ "variants" ] . as_array ( )
918+ {
919+ for variant_id in variants {
920+ if let Some ( variant) = doc[ "index" ] [ variant_id. to_string ( ) ] . as_object ( )
921+ && let Some ( name) = variant[ "name" ] . as_str ( )
922+ {
923+ side_docs. client_methods . insert (
924+ name. to_string ( ) ,
925+ variant[ "docs" ] . as_str ( ) . unwrap_or_default ( ) . to_string ( ) ,
926+ ) ;
890927 }
891928 }
892929 }
0 commit comments