@@ -768,6 +768,46 @@ describe('ShellTool', () => {
768768 const shellTool = new ShellTool ( mockConfig , createMockMessageBus ( ) ) ;
769769 expect ( shellTool . description ) . not . toContain ( 'Efficiency Guidelines:' ) ;
770770 } ) ;
771+
772+ it ( 'should return the command if description is not provided' , ( ) => {
773+ const invocation = shellTool . build ( {
774+ command : 'echo "hello"' ,
775+ } ) ;
776+ expect ( invocation . getDescription ( ) ) . toBe ( 'echo "hello"' ) ;
777+ } ) ;
778+
779+ it ( 'should return the command if it is short (<= 150 chars), even if description is provided' , ( ) => {
780+ const invocation = shellTool . build ( {
781+ command : 'echo "hello"' ,
782+ description : 'Prints a friendly greeting.' ,
783+ } ) ;
784+ expect ( invocation . getDescription ( ) ) . toBe ( 'echo "hello"' ) ;
785+ } ) ;
786+
787+ it ( 'should return the description if the command is long (> 150 chars)' , ( ) => {
788+ const longCommand = 'echo "hello" && ' . repeat ( 15 ) + 'echo "world"' ; // Length > 150
789+ const invocation = shellTool . build ( {
790+ command : longCommand ,
791+ description : 'Prints multiple greetings.' ,
792+ } ) ;
793+ expect ( invocation . getDescription ( ) ) . toBe ( 'Prints multiple greetings.' ) ;
794+ } ) ;
795+
796+ it ( 'should return the raw command if description is an empty string' , ( ) => {
797+ const invocation = shellTool . build ( {
798+ command : 'echo hello' ,
799+ description : '' ,
800+ } ) ;
801+ expect ( invocation . getDescription ( ) ) . toBe ( 'echo hello' ) ;
802+ } ) ;
803+
804+ it ( 'should return the raw command if description is just whitespace' , ( ) => {
805+ const invocation = shellTool . build ( {
806+ command : 'echo hello' ,
807+ description : ' ' ,
808+ } ) ;
809+ expect ( invocation . getDescription ( ) ) . toBe ( 'echo hello' ) ;
810+ } ) ;
771811 } ) ;
772812
773813 describe ( 'getDisplayTitle and getExplanation' , ( ) => {
@@ -803,32 +843,6 @@ describe('ShellTool', () => {
803843 } ) ;
804844 } ) ;
805845
806- describe ( 'invocation getDescription' , ( ) => {
807- it ( 'should return the description if it is present and not empty whitespace' , ( ) => {
808- const invocation = shellTool . build ( {
809- command : 'echo hello' ,
810- description : 'prints hello' ,
811- } ) ;
812- expect ( invocation . getDescription ( ) ) . toBe ( 'prints hello' ) ;
813- } ) ;
814-
815- it ( 'should return the raw command if description is an empty string' , ( ) => {
816- const invocation = shellTool . build ( {
817- command : 'echo hello' ,
818- description : '' ,
819- } ) ;
820- expect ( invocation . getDescription ( ) ) . toBe ( 'echo hello' ) ;
821- } ) ;
822-
823- it ( 'should return the raw command if description is just whitespace' , ( ) => {
824- const invocation = shellTool . build ( {
825- command : 'echo hello' ,
826- description : ' ' ,
827- } ) ;
828- expect ( invocation . getDescription ( ) ) . toBe ( 'echo hello' ) ;
829- } ) ;
830- } ) ;
831-
832846 describe ( 'llmContent output format' , ( ) => {
833847 const mockAbortSignal = new AbortController ( ) . signal ;
834848
0 commit comments