@@ -3,12 +3,9 @@ import * as process from "node:process";
3
3
import monkeyAgent from "./agent/monkey-agent" ;
4
4
import * as cp from "node:child_process" ;
5
5
import "./fetch-polyfill" ;
6
- import communicator from "./agent/communicator" ;
7
6
8
7
const apiKeyName = "MSC_OPENAI_API_KEY" ;
9
8
10
- let currentFilePath : string | undefined ;
11
-
12
9
async function getApiKey (
13
10
context : vscode . ExtensionContext
14
11
) : Promise < string | undefined > {
@@ -67,17 +64,8 @@ export async function activate(context: vscode.ExtensionContext) {
67
64
console . log ( `Node.js version: ${ stdout . trim ( ) } ` ) ;
68
65
} ) ;
69
66
70
- const document = vscode . window . activeTextEditor ?. document ;
71
- if ( document && document . uri . scheme === "file" ) {
72
- currentFilePath = document . uri . fsPath ;
73
- }
74
-
75
- const disposable = vscode . window . onDidChangeActiveTextEditor ( ( editor ) => {
76
- const document = editor ?. document ;
77
- if ( document && document . uri . scheme === "file" ) {
78
- currentFilePath = document . uri . fsPath ;
79
- }
80
- } ) ;
67
+ // eslint-disable-next-line no-unused-vars
68
+ const disposable = vscode . window . onDidChangeActiveTextEditor ( ( _editor ) => { } ) ;
81
69
82
70
context . subscriptions . push (
83
71
vscode . window . registerWebviewViewProvider (
@@ -91,6 +79,7 @@ export async function activate(context: vscode.ExtensionContext) {
91
79
class ChatSidebarViewProvider implements vscode . WebviewViewProvider {
92
80
_view ?: vscode . WebviewView ;
93
81
82
+ // eslint-disable-next-line no-unused-vars
94
83
constructor ( private readonly _extensionUri : vscode . Uri ) { }
95
84
96
85
async resolveWebviewView ( webviewView : vscode . WebviewView ) {
@@ -107,8 +96,6 @@ class ChatSidebarViewProvider implements vscode.WebviewViewProvider {
107
96
content,
108
97
} ) ;
109
98
} ;
110
- const communicatorAgent = await communicator ( sendMessage ) ;
111
- const agent = await monkeyAgent ( communicatorAgent ) ;
112
99
this . _view = webviewView ;
113
100
webviewView . webview . options = {
114
101
enableScripts : true ,
@@ -122,8 +109,20 @@ class ChatSidebarViewProvider implements vscode.WebviewViewProvider {
122
109
let response : string ;
123
110
try {
124
111
setLoading ( true ) ;
125
- response = await agent . call ( currentFilePath , message . content ) ;
126
- await communicatorAgent . call ( response ) ;
112
+ // Perform a call like { "question": "How can I create a command that represents the level up of a player?"} to https://asktoai.boosterframework.com/api/answer using cross-fetch
113
+ response = await fetch (
114
+ "https://asktoai.boosterframework.com/api/answer" ,
115
+ {
116
+ method : "POST" ,
117
+ headers : {
118
+ "Content-Type" : "application/json" ,
119
+ } ,
120
+ body : JSON . stringify ( {
121
+ question : message . content ,
122
+ } ) ,
123
+ }
124
+ ) . then ( ( response ) => response . text ( ) ) ;
125
+ sendMessage ( response ) ;
127
126
} catch ( error ) {
128
127
const parsedError = error as Error ;
129
128
response = `
0 commit comments