@@ -9,6 +9,7 @@ const terminalName = '🪿 goose chat 🪿';
9
9
10
10
export function activate ( context : vscode . ExtensionContext ) {
11
11
12
+
12
13
// Check if goose CLI is installed
13
14
const config = vscode . workspace . getConfiguration ( 'goose' ) ;
14
15
let defaultCommand = config . get ( 'defaultCommand' , "goose session start" ) ;
@@ -29,7 +30,6 @@ export function activate(context: vscode.ExtensionContext) {
29
30
if ( ! gooseTerminal || gooseTerminal . exitStatus !== undefined ) {
30
31
gooseTerminal = vscode . window . createTerminal ( {
31
32
name : terminalName ,
32
- location : { viewColumn : vscode . ViewColumn . Beside } ,
33
33
message : 'Loading Goose Session...' , // Add a message to make it clear what terminal is for
34
34
} ) ;
35
35
gooseTerminal . sendText ( defaultCommand ) ;
@@ -106,15 +106,26 @@ export function activate(context: vscode.ExtensionContext) {
106
106
}
107
107
} ) ;
108
108
109
+ // Completion suggestion: ask Goose to explain it
110
+ vscode . languages . registerCodeActionsProvider ( '*' , {
111
+ provideCodeActions ( document : vscode . TextDocument , range : vscode . Range , context : vscode . CodeActionContext , token : vscode . CancellationToken ) {
112
+ const codeAction = new vscode . CodeAction ( 'Ask goose to explain it' , vscode . CodeActionKind . QuickFix ) ;
113
+ codeAction . command = { command : 'extension.askGooseToExplainIt' , title : 'Ask goose to explain it' } ;
114
+ return [ codeAction ] ;
115
+ }
116
+ } ) ;
117
+
118
+
109
119
// Completion suggestion: ask Goose to finish it
110
120
vscode . languages . registerCodeActionsProvider ( '*' , {
111
121
provideCodeActions ( document : vscode . TextDocument , range : vscode . Range , context : vscode . CodeActionContext , token : vscode . CancellationToken ) {
112
- const codeAction = new vscode . CodeAction ( 'Ask Goose to fix it' , vscode . CodeActionKind . QuickFix ) ;
113
- codeAction . command = { command : 'extension.askGooseToFinishIt ' , title : 'Ask Goose to fix it' } ;
122
+ const codeAction = new vscode . CodeAction ( 'Ask goose to fix it' , vscode . CodeActionKind . QuickFix ) ;
123
+ codeAction . command = { command : 'extension.askGooseToFix ' , title : 'Ask goose to fix it' } ;
114
124
return [ codeAction ] ;
115
125
}
116
126
} ) ;
117
127
128
+
118
129
119
130
// Register inline completion provider
120
131
vscode . languages . registerInlineCompletionItemProvider ( '*' , {
@@ -124,17 +135,17 @@ export function activate(context: vscode.ExtensionContext) {
124
135
return ;
125
136
}
126
137
127
- const completionItem = new vscode . InlineCompletionItem ( 'Ask Goose to complete this code ' ) ;
138
+ const completionItem = new vscode . InlineCompletionItem ( 'complete with goose ' ) ;
128
139
completionItem . insertText = '' ;
129
- completionItem . command = { command : 'extension.askGooseToFinishIt' , title : 'Ask Goose to complete this code ' } ;
140
+ completionItem . command = { command : 'extension.askGooseToFinishIt' , title : 'complete with goose ' } ;
130
141
return [ completionItem ] ;
131
142
}
132
143
} ) ;
133
144
134
145
// Register content completion extension
135
146
vscode . languages . registerCompletionItemProvider ( '*' , {
136
147
provideCompletionItems ( document : vscode . TextDocument , position : vscode . Position ) {
137
- const completionItem = new vscode . CompletionItem ( 'Ask Goose to finish this code' , vscode . CompletionItemKind . Snippet ) ;
148
+ const completionItem = new vscode . CompletionItem ( 'Ask Goose to finish this code' , vscode . CompletionItemKind . Text ) ;
138
149
completionItem . insertText = '' ;
139
150
completionItem . command = { command : 'extension.askGooseToFinishIt' , title : 'Ask Goose to finish this code' } ;
140
151
return [ completionItem ] ;
@@ -161,6 +172,24 @@ export function activate(context: vscode.ExtensionContext) {
161
172
} ) ;
162
173
context . subscriptions . push ( askGooseToFinishItCommand ) ;
163
174
175
+ const askGooseToExplainItCommand = vscode . commands . registerCommand ( 'extension.askGooseToExplainIt' , async ( ) => {
176
+ const editor = vscode . window . activeTextEditor ;
177
+ if ( ! editor ) {
178
+ return ;
179
+ }
180
+
181
+ const document = editor . document ;
182
+ const selection = editor . selection ;
183
+ const filePath = document . uri . fsPath ;
184
+ const startLine = selection . start . line + 1 ;
185
+
186
+ document . save ( ) ;
187
+
188
+ getTerminal ( ) . sendText ( `Explain the code on line: ${ startLine } in file: ${ filePath } . ` ) ;
189
+
190
+ } ) ;
191
+ context . subscriptions . push ( askGooseToExplainItCommand ) ;
192
+
164
193
const askGooseToFix = vscode . commands . registerCommand ( 'extension.askGooseToFix' , async ( ) => {
165
194
const editor = vscode . window . activeTextEditor ;
166
195
if ( ! editor ) {
0 commit comments