Skip to content

Commit aea3780

Browse files
authored
Merge pull request #4 from square/goose_fix_it
ask goose to finish it feature
2 parents b3471fe + 5f6ea4d commit aea3780

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

src/extension.ts

+34-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path';
55
import { execSync } from 'child_process';
66

77
let gooseTerminal: vscode.Terminal | undefined;
8-
const terminalName = '🪿 goose agent 🪿';
8+
const terminalName = '🪿 goose chat 🪿';
99
const tempFilePath = path.join(os.tmpdir(), 'goose_open_files.txt');
1010
const tempFilePathDirty = path.join(os.tmpdir(), 'goose_unsaved_files.txt');
1111

@@ -24,7 +24,7 @@ export function activate(context: vscode.ExtensionContext) {
2424
return; // Exit activation if goose is not installed
2525
}
2626

27-
vscode.window.showInformationMessage('goose agent starting, this may take a minute.. 🕐');
27+
vscode.window.showInformationMessage('goose agent starting, this may take a minute.. ');
2828

2929

3030
const updateOpenFiles = () => {
@@ -59,7 +59,6 @@ export function activate(context: vscode.ExtensionContext) {
5959
gooseTerminal.show();
6060

6161
});
62-
6362
context.subscriptions.push(openTerminalDisposable);
6463

6564
// Automatically open the terminal when the extension activates
@@ -94,8 +93,39 @@ export function activate(context: vscode.ExtensionContext) {
9493

9594
gooseTerminal?.show();
9695
});
97-
96+
9897
context.subscriptions.push(sendToGooseDisposable);
98+
99+
100+
101+
102+
// Completion suggestion: ask Goose to finish it
103+
vscode.languages.registerCodeActionsProvider('*', {
104+
provideCodeActions(document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken) {
105+
const codeAction = new vscode.CodeAction('Ask Goose to finish it', vscode.CodeActionKind.QuickFix);
106+
codeAction.command = { command: 'extension.askGooseToFinishIt', title: 'Ask Goose to finish it' };
107+
return [codeAction];
108+
}
109+
});
110+
111+
const askGooseToFinishItCommand = vscode.commands.registerCommand('extension.askGooseToFinishIt', async () => {
112+
const editor = vscode.window.activeTextEditor;
113+
if (!editor) {
114+
return;
115+
}
116+
117+
const document = editor.document;
118+
const selection = editor.selection;
119+
const filePath = document.uri.fsPath;
120+
const startLine = selection.start.line + 1;
121+
122+
document.save();
123+
124+
125+
gooseTerminal?.sendText(`There is some unfinished code around ${startLine} in file ${filePath}, can you please try to complete it as best makes sense.`);
126+
gooseTerminal?.show();
127+
});
128+
context.subscriptions.push(askGooseToFinishItCommand);
99129
}
100130

101131
export function deactivate() {

0 commit comments

Comments
 (0)