@@ -51,30 +51,42 @@ export async function activateChatParticipant(state: ExtensionState) {
51
51
if ( token . isCancellationRequested ) return
52
52
53
53
const md = ( t : string ) => {
54
- response . markdown ( new vscode . MarkdownString ( t , true ) )
54
+ response . markdown ( new vscode . MarkdownString ( t + "\n" , true ) )
55
55
}
56
56
57
57
const { project } = state
58
58
const { templates } = project
59
- const mdEmpty = ( ) =>
59
+ const mdHelp = ( ) =>
60
60
md (
61
- `$(error) Oops, I could not find any genaiscript. Try **GenAIScript: Create new script...** to create one or checkout [samples ](https://microsoft.github.io/genaiscript/reference/vscode/github-copilot-chat/). `
61
+ `\n\n[Docs ](https://microsoft.github.io/genaiscript/reference/vscode/github-copilot-chat/) | [Samples](https://microsoft.github.io/genaiscript/samples/)\n `
62
62
)
63
- const mdTemplateList = ( ) =>
63
+ const mdEmpty = ( ) =>
64
64
md (
65
- state . project . templates
66
- . filter ( ( s ) => ! s . system && ! s . unlisted )
67
- . map (
68
- ( s ) =>
69
- `- [${ [ s . id ] } ](${ vscode . workspace . asRelativePath ( s . filename ) } ): ${ s . title } `
70
- )
71
- . join ( "\n" )
65
+ `$(error) Oops, I could not find any genaiscript. Try **GenAIScript: Create new script...** to create one.\n`
72
66
)
67
+ const mdTemplateList = ( ) => {
68
+ templates
69
+ . filter ( ( s ) => ! s . system && ! s . unlisted )
70
+ . sort ( ( a , b ) => a . id . localeCompare ( b . id ) )
71
+ . forEach ( ( s ) => {
72
+ response . markdown ( "- " )
73
+ if ( s . filename )
74
+ response . anchor ( vscode . Uri . file ( s . filename ) , s . id )
75
+ else response . markdown ( `\`${ s . id } \`` )
76
+ response . markdown ( `: ${ s . title } \n` )
77
+ } )
78
+ }
73
79
if ( command === "list" ) {
74
- if ( state . project . templates . length ) {
75
- md ( "Use `@genaiscript /run ...` with one of these scripts:" )
80
+ if ( templates . length ) {
81
+ md (
82
+ "Use `@genaiscript /run ...` with one of these scripts:\n"
83
+ )
76
84
mdTemplateList ( )
77
- } else mdEmpty ( )
85
+ mdHelp ( )
86
+ } else {
87
+ mdEmpty ( )
88
+ mdHelp ( )
89
+ }
78
90
return
79
91
}
80
92
@@ -84,22 +96,25 @@ export async function activateChatParticipant(state: ExtensionState) {
84
96
prompt = prompt . slice ( scriptid . length ) . trim ( )
85
97
template = templates . find ( ( t ) => t . id === scriptid )
86
98
if ( ! template ) {
87
- if ( state . project . templates . length === 0 ) {
99
+ if ( templates . length === 0 ) {
88
100
mdEmpty ( )
89
101
} else {
90
102
if ( scriptid === "" )
91
- md ( `$(error) Please specify a genaiscript to run.` )
103
+ md (
104
+ `$(error) Please specify a genaiscript to run.\n`
105
+ )
92
106
else
93
107
md (
94
- `$(error) Oops, I could not find any genaiscript matching \`${ scriptid } \`.`
108
+ `$(error) Oops, I could not find any genaiscript matching \`${ scriptid } \`.\n `
95
109
)
96
110
md ( `Try one of the following:\n` )
97
111
mdTemplateList ( )
112
+ mdHelp ( )
98
113
}
99
114
return
100
115
}
101
116
} else {
102
- template = state . project . templates . find (
117
+ template = templates . find (
103
118
( t ) => t . id === COPILOT_CHAT_PARTICIPANT_SCRIPT_ID
104
119
)
105
120
if ( ! template ) {
0 commit comments