Slight refactorings and remove maven-model dependency (#1365) (#1366)

* trying to allow manual trigger for publishing vscode pre-releases

* remove usage of proposed chat variable resolver api for now

* remove maven-model dependency and clean up code

---------

Co-authored-by: Udayani Vaka <79973862+vudayani@users.noreply.github.com>
Co-authored-by: Martin Lippert <martin.lippert@broadcom.com>
This commit is contained in:
Alex Boyko
2024-10-03 08:36:38 -04:00
committed by GitHub
parent 53dbdeaaec
commit 19e3b38804
8 changed files with 12 additions and 107 deletions

View File

@@ -21,7 +21,7 @@ export async function applyLspEdit(uri: Uri) {
}, async (progress, cancellation) => {
progress.report({ message: "applying edits..." });
const fileContent = (await readResponseFromFile(uri)).toString();
const lspEdit = await commands.executeCommand("sts/copilot/agent/lspEdits", uri.toString(), path.dirname(uri.fsPath), fileContent);
const lspEdit = await commands.executeCommand("sts/copilot/agent/lspEdits", uri.toString(), fileContent);
const workspaceEdit = await CONVERTER.asWorkspaceEdit(lspEdit);

View File

@@ -65,23 +65,21 @@ export default class SpringBootChatAgent {
// Chat request to copilot LLM
const response = await this.copilotRequest.chatRequest(messages, {}, cancellationToken);
// write the response to markdown file
const targetMarkdownUri = await writeResponseToFile(response, bootProjInfo.name, selectedProject.fsPath);
let documentContent;
if (!targetMarkdownUri) {
documentContent = 'Note: The code provided is just an example and may not be suitable for production use. \n ' + response;
if (response == null || response === '') {
documentContent = 'Failed to process the request. Please try again.';
} else {
// modify the response from copilot LLM i.e. make response Boot 3 compliant if necessary
if (bootProjInfo.springBootVersion.startsWith('3')) {
const enhancedResponse = await commands.executeCommand("sts/copilot/agent/enhanceResponse", response) as string;
await writeResponseToFile(enhancedResponse, bootProjInfo.name, selectedProject.fsPath);
documentContent = await commands.executeCommand("sts/copilot/agent/enhanceResponse", response) as string;
} else {
documentContent = 'Note: The code provided is just an example and may not be suitable for production use. \n ' + response;
}
documentContent = await workspace.fs.readFile(targetMarkdownUri);
}
// write the final response to markdown file
await writeResponseToFile(documentContent, bootProjInfo.name, selectedProject.fsPath);
const chatResponse = Buffer.from(documentContent).toString();
stream.markdown(chatResponse);
stream.button({