Skip to content

Commit e9f5c8a

Browse files
authored
Merge pull request #16 from square/tidy
Tidy
2 parents 3857fc4 + 35ab475 commit e9f5c8a

File tree

2 files changed

+31
-43
lines changed

2 files changed

+31
-43
lines changed

package.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "goose-vscode",
3-
"version": "0.0.11",
3+
"version": "0.0.12",
44
"publisher": "michaelneale",
55
"icon": "goose-icon.png",
66
"main": "./out/extension.js",
@@ -18,7 +18,7 @@
1818
"@types/node": "^22.3.0",
1919
"@types/vscode": "^1.91.0",
2020
"typescript": "^5.5.4",
21-
"vsce": "^2.7.0"
21+
"vsce": "^2.15.0"
2222
},
2323
"dependencies": {
2424
"@vscode/l10n": "^0.0.18"
@@ -46,10 +46,6 @@
4646
}
4747
},
4848
"commands": [
49-
{
50-
"command": "extension.openGooseTerminal",
51-
"title": "Open Goose Terminal"
52-
},
5349
{
5450
"command": "extension.sendToGoose",
5551
"title": "🪿 Ask Goose 🪿"

src/extension.ts

+29-37
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,51 @@ import { execSync } from 'child_process';
66

77
let gooseTerminal: vscode.Terminal | undefined;
88
const terminalName = '🪿 goose chat 🪿';
9-
const tempFilePath = path.join(os.tmpdir(), 'goose_open_files.txt');
10-
const tempFilePathDirty = path.join(os.tmpdir(), 'goose_unsaved_files.txt');
11-
const FALLBACK_COMMAND = "goose session start"
129

1310
export function activate(context: vscode.ExtensionContext) {
14-
1511

1612
// Check if goose CLI is installed
1713
const config = vscode.workspace.getConfiguration('goose');
18-
let defaultCommand = config.get('defaultCommand', FALLBACK_COMMAND);
19-
14+
let defaultCommand = config.get('defaultCommand', "goose session start");
2015
try {
21-
execSync('goose');
16+
execSync('goose version');
2217
} catch (error) {
2318
try {
24-
execSync('sq');
25-
if (defaultCommand == FALLBACK_COMMAND) {
26-
defaultCommand = 'sq goose session start'
27-
}
19+
execSync('sq goose version');
20+
defaultCommand = 'sq goose session start'
2821
} catch (error) {
2922
vscode.window.showWarningMessage('If goose isn\'t working, please check the goose command line tool is installed and working.');
3023
}
3124
}
3225

33-
vscode.window.showInformationMessage('goose agent starting, this may take a minute.. ⏰');
26+
vscode.window.showInformationMessage('goose agent starting, this may take a minute.. ⏰');
27+
28+
let getTerminal = () => {
29+
if (!gooseTerminal || gooseTerminal.exitStatus !== undefined) {
30+
gooseTerminal = vscode.window.createTerminal({
31+
name: terminalName,
32+
location: { viewColumn: vscode.ViewColumn.Beside },
33+
message: 'Loading Goose Session...', // Add a message to make it clear what terminal is for
34+
});
35+
gooseTerminal.sendText(defaultCommand);
36+
}
3437

38+
console.log('Goose terminal created:', gooseTerminal.name);
39+
gooseTerminal.show(); // Delayed terminal show
40+
41+
return gooseTerminal
3542

36-
37-
43+
}
3844

3945
let openTerminalDisposable = vscode.commands.registerCommand('extension.openGooseTerminal', () => {
40-
gooseTerminal = vscode.window.createTerminal({
41-
name: terminalName,
42-
location: { viewColumn: vscode.ViewColumn.Beside }
43-
});
44-
gooseTerminal.sendText(defaultCommand + '\n\n');
45-
46-
gooseTerminal.show();
46+
getTerminal();
4747
});
4848
context.subscriptions.push(openTerminalDisposable);
49-
50-
// Automatically open the terminal when the extension activates
49+
50+
// Automatically open the terminal when the extension activates
5151
vscode.commands.executeCommand('extension.openGooseTerminal');
52-
52+
53+
5354
let sendToGooseDisposable = vscode.commands.registerCommand('extension.sendToGoose', async () => {
5455
const editor = vscode.window.activeTextEditor;
5556
if (!editor) {
@@ -85,8 +86,7 @@ export function activate(context: vscode.ExtensionContext) {
8586

8687
}
8788
editor.document.save();
88-
gooseTerminal?.sendText(textToAskGoose);
89-
gooseTerminal?.show();
89+
getTerminal().sendText(textToAskGoose);
9090
});
9191

9292
context.subscriptions.push(sendToGooseDisposable);
@@ -156,9 +156,8 @@ export function activate(context: vscode.ExtensionContext) {
156156

157157
document.save();
158158

159-
gooseTerminal?.sendText(`There is some unfinished code at line: ${startLine} in file: ${filePath}. ` +
159+
getTerminal().sendText(`There is some unfinished code at line: ${startLine} in file: ${filePath}. ` +
160160
`Complete the code based on the context, from that line onwards. Do not delete content.`);
161-
gooseTerminal?.show();
162161
});
163162
context.subscriptions.push(askGooseToFinishItCommand);
164163

@@ -175,17 +174,10 @@ export function activate(context: vscode.ExtensionContext) {
175174

176175
document.save();
177176

178-
gooseTerminal?.sendText(`Can you look at the code on line: ${startLine} in file: ${filePath}. ` +
179-
`and fix any problems you see on this line and near it. Try not to delete content.`);
180-
gooseTerminal?.show();
177+
getTerminal().sendText(`Can you look at the code on line: ${startLine} in file: ${filePath}. ` +
178+
`and fix any problems you see on this line and near it. Try not to delete content.`);
181179
});
182180
context.subscriptions.push(askGooseToFix);
183181

184182
}
185183

186-
export function deactivate() {
187-
if (gooseTerminal) {
188-
gooseTerminal.sendText('exit');
189-
gooseTerminal.dispose();
190-
}
191-
}

0 commit comments

Comments
 (0)