From bf9424b9d7f211712d41a391eba94f08bbdc2018 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Thu, 16 Jan 2025 16:52:23 +0100 Subject: [PATCH 01/35] chore(hidden features): add defaults to initail state. --- src/sidebar.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sidebar.ts b/src/sidebar.ts index 804ad0af..7452f227 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -874,6 +874,9 @@ export class PanelWebview implements vscode.WebviewViewProvider { features: { vecdb, ast, + images: true, + statistics: true, + knowledge: false, }, keyBindings: { completeManual, From ec56c232e409361a71c51d5556973c86c61ffed0 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Fri, 24 Jan 2025 14:08:09 +0100 Subject: [PATCH 02/35] feat(knowledge): add workspace to initial state and event handler for changing workspace. --- src/sidebar.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sidebar.ts b/src/sidebar.ts index 7452f227..f6fa184a 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -34,6 +34,7 @@ import { ideChatPageChange, ideEscapeKeyPressed, ideIsChatStreaming, + setCurrentProjectInfo } from "refact-chat-js/dist/events"; import { basename, join } from "path"; import { diff_paste_back } from "./chatTab"; @@ -119,6 +120,10 @@ export class PanelWebview implements vscode.WebviewViewProvider { } })); + this._disposables.push(vscode.workspace.onDidChangeWorkspaceFolders((event) => { + this.sendCurrentProjectInfo(); + })); + // this._disposables.push(vscode.workspace.onDidOpenTextDocument((event) => { // console.log("onDidOpenTextDocument"); @@ -848,6 +853,11 @@ export class PanelWebview implements vscode.WebviewViewProvider { } } + sendCurrentProjectInfo() { + const action = setCurrentProjectInfo({name: vscode.workspace.name ?? ""}); + this._view?.webview.postMessage(action); + } + async createInitialState(thread?: ChatThread, tabbed = false): Promise> { const fontSize = vscode.workspace.getConfiguration().get("editor.fontSize") ?? 12; @@ -887,6 +897,7 @@ export class PanelWebview implements vscode.WebviewViewProvider { }; const state: Partial = { + current_project: {name: vscode.workspace.name ?? ""}, config, }; From 3f1662311ccd9d5df100ea7fccfb29312850c365 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Tue, 11 Feb 2025 12:32:33 +0100 Subject: [PATCH 03/35] chore(hcat-js): bump to `v2.0.6-alpha.0` for knowledge. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5836ec3..8c8c280b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "fetch-h2": "^3.0.2", "json5": "^2.2.3", "marked": "^4.0.8", - "refact-chat-js": "~v2.0.5", + "refact-chat-js": "~v2.0.6-alpha.0", "uuid": "^9.0.1", "vscode-languageclient": "^7.0.0" }, From 21ac3109238f99a8cb393811a6efd50ba46ebf6e Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Tue, 11 Feb 2025 14:15:24 +0100 Subject: [PATCH 04/35] chore(chat): version "~v2.0.6-alpha.1, type export fixes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8c8c280b..d0090de7 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "fetch-h2": "^3.0.2", "json5": "^2.2.3", "marked": "^4.0.8", - "refact-chat-js": "~v2.0.6-alpha.0", + "refact-chat-js": "~v2.0.6-alpha.1", "uuid": "^9.0.1", "vscode-languageclient": "^7.0.0" }, From 2816d763cbb9dc59b1542c2a27fdc8f5eb740bf6 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Thu, 13 Feb 2025 17:51:45 +0100 Subject: [PATCH 05/35] chore(new patches): remove code no longer used by chat --- src/sidebar.ts | 75 ++++++++------------------------------------------ 1 file changed, 11 insertions(+), 64 deletions(-) diff --git a/src/sidebar.ts b/src/sidebar.ts index f6fa184a..76edef52 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -23,18 +23,14 @@ import { ideNewFileAction, ideOpenSettingsAction, ideDiffPasteBackAction, - ideDiffPreviewAction, type ChatThread, - type DiffPreviewResponse, - resetDiffApi, ideAnimateFileStart, ideAnimateFileStop, - ideWriteResultsToFile, - type PatchResult, ideChatPageChange, ideEscapeKeyPressed, ideIsChatStreaming, - setCurrentProjectInfo + setCurrentProjectInfo, + ideCreateNewFile } from "refact-chat-js/dist/events"; import { basename, join } from "path"; import { diff_paste_back } from "./chatTab"; @@ -267,10 +263,7 @@ export class PanelWebview implements vscode.WebviewViewProvider { this._view?.webview.postMessage(message); } - sendClearDiffCacheMessage() { - const message = resetDiffApi(); - this._view?.webview.postMessage(message); - } + public new_statistic(view: vscode.WebviewView) @@ -545,9 +538,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { return this.handleDiffPasteBack(e.payload); } - if (ideDiffPreviewAction.match(e)) { - return this.handleDiffPreview(e.payload); - } if(ideAnimateFileStart.match(e)) { return this.startFileAnimation(e.payload); @@ -557,10 +547,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { return this.stopFileAnimation(e.payload); } - if(ideWriteResultsToFile.match(e)) { - return this.writeResultsToFile(e.payload); - } - if(ideChatPageChange.match(e)) { return this.handleCurrentChatPage(e.payload); } @@ -572,6 +558,10 @@ export class PanelWebview implements vscode.WebviewViewProvider { if(ideEscapeKeyPressed.match(e)) { return this.handleEscapePressed(e.payload); } + + if(ideCreateNewFile.match(e)) { + return this.createNewFileWithContent(e.payload.path, e.payload.content); + } // if(ideOpenChatInNewTab.match(e)) { // return this.handleOpenInTab(e.payload); @@ -605,6 +595,8 @@ export class PanelWebview implements vscode.WebviewViewProvider { // } + + // This isn't called async deleteFile(fileName: string) { const uri = this.filePathToUri(fileName); const edit = new vscode.WorkspaceEdit(); @@ -625,7 +617,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { return vscode.workspace.applyEdit(edit).then(success => { if (success) { vscode.window.showTextDocument(document); - this.refetchDiffsOnSave(document); } else { vscode.window.showInformationMessage('Error: creating file ' + fileName); } @@ -633,6 +624,7 @@ export class PanelWebview implements vscode.WebviewViewProvider { }); } + // this isn't called async addDiffToFile(fileName: string, content: string) { const uri = this.filePathToUri(fileName); const document = await vscode.workspace.openTextDocument(uri); @@ -648,10 +640,9 @@ export class PanelWebview implements vscode.WebviewViewProvider { range, content ); - // TODO: can remove this when diff api is removed. - this.refetchDiffsOnSave(document); } + // this isn't called async editFileWithContent(fileName: string, content: string) { const uri = this.filePathToUri(fileName); const document = await vscode.workspace.openTextDocument(uri); @@ -673,17 +664,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { } - async writeResultsToFile(results: PatchResult[]) { - for(const result of results) { - if(result.file_name_add) { - this.createNewFileWithContent(result.file_name_add, result.file_text); - } else if(result.file_name_edit) { - this.editFileWithContent(result.file_name_edit, result.file_text); - } else if (result.file_name_delete) { - this.deleteFile(result.file_name_delete); - } - } - } async handleCurrentChatPage(page: string) { this.context.globalState.update("chat_page", JSON.stringify(page)); @@ -795,39 +775,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { } - private refetchDiffsOnSave(document: vscode.TextDocument) { - const disposables: vscode.Disposable[] = []; - const dispose = () => disposables.forEach(d => d.dispose()); - disposables.push(vscode.workspace.onDidSaveTextDocument((savedDocument) => { - if(savedDocument.uri.fsPath === document.uri.fsPath) { - this.sendClearDiffCacheMessage(); - dispose(); - } - })); - disposables.push(vscode.workspace.onDidCloseTextDocument((closedDocument) => { - if(closedDocument.uri.fsPath === document.uri.fsPath) { - dispose(); - } - })); - } - - private async handleDiffPreview(response: DiffPreviewResponse) { - - const openFiles = this.getOpenFiles(); - - for (const change of response.results) { - if (change.file_name_edit !== null && change.file_text !== null) { - this.addDiffToFile(change.file_name_edit, change.file_text); - } else if(change.file_name_add !== null && change.file_text!== null && openFiles.includes(change.file_name_add) === false) { - this.createNewFileWithContent(change.file_name_add, change.file_text); - } else if(change.file_name_add !== null && change.file_text!== null && openFiles.includes(change.file_name_add)) { - this.addDiffToFile(change.file_name_add, change.file_text); - } else if(change.file_name_delete) { - this.deleteFile(change.file_name_delete); - } - } - } - async handleOpenFile(file: {file_name:string, line?: number}) { const uri = this.filePathToUri(file.file_name); From 0469153275d04a566c5223610d251b3d4630b824 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Fri, 14 Feb 2025 20:50:07 +0100 Subject: [PATCH 06/35] feat: handle tool edit results from chat. --- src/sidebar.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/sidebar.ts b/src/sidebar.ts index 76edef52..5dceeea6 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -30,7 +30,9 @@ import { ideEscapeKeyPressed, ideIsChatStreaming, setCurrentProjectInfo, - ideCreateNewFile + ideCreateNewFile, + ideToolEdit, + ToolEditResult, } from "refact-chat-js/dist/events"; import { basename, join } from "path"; import { diff_paste_back } from "./chatTab"; @@ -558,7 +560,12 @@ export class PanelWebview implements vscode.WebviewViewProvider { if(ideEscapeKeyPressed.match(e)) { return this.handleEscapePressed(e.payload); } + + if(ideToolEdit.match(e)) { + return this.handleToolEdit(e.payload.path, e.payload.edit); + } + // TODO: can remove if(ideCreateNewFile.match(e)) { return this.createNewFileWithContent(e.payload.path, e.payload.content); } @@ -595,6 +602,14 @@ export class PanelWebview implements vscode.WebviewViewProvider { // } + async handleToolEdit(path: string, toolEdit: ToolEditResult) { + if(!toolEdit.file_before && toolEdit.file_after) { + return this.createNewFileWithContent(path, toolEdit.file_after); + } + + return this.addDiffToFile(path, toolEdit.file_after); + } + // This isn't called async deleteFile(fileName: string) { @@ -624,7 +639,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { }); } - // this isn't called async addDiffToFile(fileName: string, content: string) { const uri = this.filePathToUri(fileName); const document = await vscode.workspace.openTextDocument(uri); From d65357e334032bad03383719ba27a0e2af1a948d Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Mon, 17 Feb 2025 12:52:35 +0100 Subject: [PATCH 07/35] refactor(patch actions): remove `ideCreateNewFile.match(e)`. --- src/sidebar.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/sidebar.ts b/src/sidebar.ts index 5dceeea6..ad8fed0a 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -30,7 +30,6 @@ import { ideEscapeKeyPressed, ideIsChatStreaming, setCurrentProjectInfo, - ideCreateNewFile, ideToolEdit, ToolEditResult, } from "refact-chat-js/dist/events"; @@ -564,12 +563,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { if(ideToolEdit.match(e)) { return this.handleToolEdit(e.payload.path, e.payload.edit); } - - // TODO: can remove - if(ideCreateNewFile.match(e)) { - return this.createNewFileWithContent(e.payload.path, e.payload.content); - } - // if(ideOpenChatInNewTab.match(e)) { // return this.handleOpenInTab(e.payload); // } From 031b799054db83debb029d53b2c2d38cc09f8969 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Mon, 17 Feb 2025 17:02:54 +0100 Subject: [PATCH 08/35] fix(chat): thread type update. --- src/sidebar.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sidebar.ts b/src/sidebar.ts index ad8fed0a..c2b8344b 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -66,6 +66,9 @@ export async function open_chat_tab( {role: "user", content: question}, ] : [], model: model, + new_chat_suggested: { + wasSuggested: false, + } }; global.side_panel.goto_chat(chat); // changes html From 420bf4253f0303ca9e6cd4d90f248a9042ef4852 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Tue, 18 Feb 2025 13:45:44 +0100 Subject: [PATCH 09/35] chore: bump chat to `v2.0.8-alpha.2` for new patch actions. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0090de7..00aaad6a 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "fetch-h2": "^3.0.2", "json5": "^2.2.3", "marked": "^4.0.8", - "refact-chat-js": "~v2.0.6-alpha.1", + "refact-chat-js": "~v2.0.8-alpha.2", "uuid": "^9.0.1", "vscode-languageclient": "^7.0.0" }, From 2c86d62682697e0ac2452748f2daef19e8d0d220 Mon Sep 17 00:00:00 2001 From: Andrii Lashchov <84778697+alashchev17@users.noreply.github.com> Date: Wed, 19 Feb 2025 20:43:20 +0100 Subject: [PATCH 10/35] Version bump 190225 (#189) * 6.1.1 * 6.1.2 * 6.1.3 * fix workflow for refact repo * readme update * sublist * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update package.json * Update README.md * Update README.md * Update package.json * version bump 6.1.4 & refact-chat-js@v2.0.8-alpha.8 --------- Co-authored-by: Kirill Starkov Co-authored-by: oxyplay --- .github/workflows/build.yml | 4 +- .github/workflows/publish.yml | 4 +- README.md | 122 +++++++++++++++++++++++----------- package.json | 18 ++--- 4 files changed, 97 insertions(+), 51 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 481d0899..d1d1c4fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,8 +62,8 @@ jobs: uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} - workflow: build.yml - repo: smallcloudai/refact-lsp + workflow: agent_engine_build.yml + repo: smallcloudai/refact branch: ${{ inputs.lsp_branch }} path: ./assets name: dist-${{ matrix.target }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e6292d17..ae86a1f7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -66,8 +66,8 @@ jobs: uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} - workflow: build.yml - repo: smallcloudai/refact-lsp + workflow: agent_engine_build.yml + repo: smallcloudai/refact branch: ${{ inputs.lsp_branch }} path: ./assets name: dist-${{ matrix.target }} diff --git a/README.md b/README.md index d10975c9..3c6c1bc8 100644 --- a/README.md +++ b/README.md @@ -8,47 +8,91 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/refact_ai)](https://twitter.com/intent/follow?screen_name=refact_ai) ![License](https://img.shields.io/github/license/smallcloudai/refact-vscode) -## Refact.ai Open Source, Customizable AI Coding Assistant -Refact.ai is an open-source AI coding assistant that boosts developer's productivity. It's suitable for both individual and enterprise use, supporting 25+ programming languages including Python, Javascript, Java, Rust, Typescript, PHP, Java, C++, C#, Go and more. - -Download the extension for VS Code from [here](https://marketplace.visualstudio.com/items?itemName=smallcloud.codify). - -Simplify your coding experience with Refact.ai's functions: - -- **Code-completion:** helps you write code faster. It looks up and down from the cursor position in the current file, as well as other files in your project for context. After fine-tuning (available in Self-Hosting and Enterprise versions) a code completion model will provide you with more relevant suggestions: it can memorize your coding style, the right way to use your internal APIs, and the tech stack you use. -- **AI Toolbox:** helps explain, refactor your code, write documentation, find bugs, you can ask in natural language to generate new code for you. The Toolbox is customizable, you can create your own commands. -- **Integrated in-IDE Chat:** It's better than switching between IDE and a browser: select a piece of code in the editor, ask a question without the need to copy-paste anything, and apply changes back as a diff. Chat can either automatically include the relevant files within the project for context, or you can use @-commands to control what context to use to answer your question. -- **Self-hosting or cloud version:** enables you to host code completion and chat models yourself. The Refact.ai self-hosting server supports many recent models, offers efficient inference, and facilitates fine-tuning. - -## Refact.ai For Enterprise -Are you part of an Enterprise and want to **boost developers' efficiency by 45%**? The Refact.ai Enterprise plan offers: -- **Knows Your Code:** Refact.ai focuses on automated customization for internal codebases and improving over time. -- **Ultimate Security:** Deploy Refact.ai on-premise: on your own servers or private cloud. Your data never leaves your control. Telemetry from the plugins goes to your server and nowhere else. You can verify what the code does, it's open source. -- **Fine-Tuning:** We've solved all the complexity for you, no data engineer required. A fine-tuned code completion model will provide you with more relevant suggestions: it can memorize your coding style, the right way to use your internal APIs, and the tech stack you use. After fine-tuning, auto-completion helps our clients to write around 45% of their code. -- **User Statistics:** Keep track of how much code Refact.ai helps to write for each team member. Measure productivity gains with real numbers. -- **Efficient Inference:** The Enterprise version supports paged attention and continuous batching, supporting up to 50 engineers per GPU for code completion. +## Refact.ai - Your Customizable Open-Source AI Software Engineering Agent + +Refact.ai is a free, **open-source** AI Agent that handles engineering tasks end-to-end. It deeply understands your codebases and integrates with your tools, databases, and browsers to automate complex, multi-step tasks. + +- Integrate AI Agent with the tools you already use, allowing it to complete tasks for you end-to-end. +- Deploy Refact.ai on-premise and maintain **100% control over your codebase**. +- Access State-of-the-Art Models (Claude 3.5 Sonnet, GPT-4o, o3-mini, etc.) +- Bring your own key (BYOK) - Use your own API keys for external LLMs. +- Stop switching between your IDE and chat—Refact.ai has an integrated chat right in your IDE. +- Get free, unlimited, context-aware auto-completion. + +Suitable for both individual and enterprise use, supporting 25+ programming languages, including Python, JavaScript, Java, Rust, TypeScript, PHP, C++, C#, Go, and more. + +We can't say it better than our users: *'Refact.ai understands me better than my human coworkers. It's like working in perfect sync with an ideal partner.'* + +## How does Refact.ai Agent empower developers? + +- **Unlimited accurate auto-completion with context awareness for free** - Powered by Qwen2.5-Coder-1.5B, Refact.ai uses Retrieval-Augmented Generation (RAG) to provide precise, context-aware code suggestions. By retrieving relevant snippets and project-specific insights, it ensures completions that align with your coding style and architecture.![auto-completion](https://github.com/user-attachments/assets/0ffab638-c807-4863-8d62-a663b1459805) +- **Integrated in-IDE Chat** - By deeply understanding your codebases, Refact.ai provides relevant, intelligent answers to your questions—right inside your development environment.![refactor](https://github.com/user-attachments/assets/e7b2e779-85c5-46a0-99ad-ea909a69ddc7) +- **Integrated with the tools** - Refact.ai goes beyond codebases, connecting with GitHub, GitLab, databases (PostgreSQL, MySQL), Pdb, Docker, and any shell command, so AI Agent can autonomously complete tasks—from code generation to deployment.![integrations](https://github.com/user-attachments/assets/daf8d0ee-0a54-4aa8-82e5-f968fded0c7a) +- **State-of-the-Art Models** - Refact.ai supports **Claude 3.5 Sonnet, GPT-4o, and o3-mini**, allowing you to choose the best model for each task based on its complexity. +- **Bring your own key (BYOK)** - Use your own API keys for external LLMs, ensuring flexibility and control over your AI infrastructure.![BYOK](https://github.com/user-attachments/assets/44e416f7-fb4d-4846-a1e0-1b7da32c2c75) +- **Upload images**: Click the image button to add visual context to your chat. +- **Use @-commands** to control what context to use to answer your question: + - **@web** - define a webpage. + - **@file** - upload and attach a single file. + - **@definition** - find and attach a definition. + - **@references** - locate all references and attach them. + - **@tree** - display the workspace directory and files tree. + - Create your own **custom system prompt** for a more personalized workflow.![@-commands](https://github.com/user-attachments/assets/28e1db76-3490-4195-a3e0-de30496239a9) + +## Refact.ai Agent For Enterprise +Deploying Refact.ai Agent is like adding a 24/7 engineer to your team—one that instantly understands your codebase, adapts to your workflows, accelerates development from day one, and becomes a shared knowledge base for your entire team. + +1. **Refact.ai already understands your company's context:** AI Agent captures the unique structure, tools, and workflows of your organization, using your company's databases, documentation, and code architecture to deliver customized solutions. +2. **Gets smarter over time:** With each interaction and feedback, Refact.ai Agent adapts to your organization's needs, becoming more accurate and powerful. +3. **Organizes experience into the knowledge base:** Refact.ai Agent captures and shares knowledge from interactions with each team member. It not only streamlines workflows but also supports faster onboarding and smoother cross-functional collaboration across projects. + +### Take full control of your AI Agent, tailored to your company: +- **Deploy Refact.ai on-premise:** on your own servers or private cloud. Your data never leaves your control. Telemetry from the plugins goes to your server and nowhere else. You can verify what the code does, it's open source. +- **Fine-tune a model on your codebase:** A fine-tuned code completion model will provide you with more relevant suggestions: it can memorize your coding style, the right way to use your internal APIs, and the tech stack you use. - **Priority Support:** Our engineers are always available to assist you at every stage, from setup to fine-tuning and beyond. -- **Access to 20+ LLMs:** (including Refact/1.6B, GPT-4, Code Llama, StarCoder2, Mistral, Mixtral, etc.) some of them with the opportunity to fine-tune. - -**To get a 2-Week free trial** for your team, just fill out the form on [our website](https://refact.ai/enterprise/?utm_source=vscode&utm_medium=marketplace&utm_campaign=enterprise). We'll reach out with more details! - -## Check Out How Easy Refact.ai Is to Use -### Boost coding productivity with fine-tuned auto-completions -![Comp_brand](https://github.com/smallcloudai/refact-vscode/assets/15157041/59bd60e2-4680-4bf5-87c5-6f57dc96cef7) - - -### Get the answer to your question in the embedded Chat -![Chat_brand](https://github.com/smallcloudai/refact-vscode/assets/15157041/7e10a353-bb6f-4c79-b65e-c01a7ab6aece) - -### Just highlight part of the code and ask Toolbox to explain it -![Explain_brand](https://github.com/smallcloudai/refact-vscode/assets/15157041/a5f8519f-284f-43c7-9cce-163dbac86ef7) - -### Ask Toolbox to shorten your code -![Shorter_brand](https://github.com/smallcloudai/refact-vscode/assets/15157041/d3724ac7-076c-43d6-a300-2617952ebc8e) +**To get a 2-week free trial** for your team, just fill out the form on [our website](https://refact.ai/contact/?utm_source=vscode&utm_medium=marketplace&utm_campaign=enterprise). We'll reach out with more details! +\ +  +\ +  +## Which tasks can Refact.ai help me with? + +- **Generate code from natural language prompts (even if you make typos)** - Instantly turn ideas into functional code, accelerating development and eliminating the blank-screen problem. +\ +  + ![gen](https://github.com/user-attachments/assets/ef4acec7-4967-400a-900e-9d3382d05b1b) +\ +  +- **Refactor code** - Improve code quality, readability, and efficiency with automated refactoring that aligns with best practices. +\ +  + ![refactor](https://github.com/user-attachments/assets/2cae4467-f363-4033-8ecf-2854dcc74aaa) +\ +  +- **Explain code** - Quickly understand complex or unfamiliar code with AI-generated explanations, making collaboration and onboarding faster. +\ +  +![explain](https://github.com/user-attachments/assets/bd43d9aa-15c9-49dc-9fa9-b5ab5c4ecdfe) +\ +  +- **Debug code** - Detect and fix errors faster with intelligent debugging, reducing time spent troubleshooting issues. +\ +  +![ddbg](https://github.com/user-attachments/assets/45e917b5-f47b-4b84-b1f4-f4918c8a00c7) +\ +  +- **Generate unit tests** - Ensure code reliability by automatically creating comprehensive unit tests. +\ +  + ![unit](https://github.com/user-attachments/assets/5168ee57-e35b-4484-bf19-70cc0f3a6299) +\ +  + +- **Code Review** - Get AI-assisted code reviews for cleaner, more secure, and more efficient code, addressing developers' top concern: accuracy. +- **Create Documentation** - Automate documentation generation to keep knowledge accessible and up to date. +- **Generate Docstrings** - Enhance maintainability with clear, structured documentation generated for functions and classes in seconds. ## Join Our Discord Community -Connect with other developers who care about AI tools in our [**Discord community**](https://www.smallcloud.ai/discord). Ask questions, share your opinion, propose new features. - -Implement a feature you want, and contribute to the future of programming! +Connect with other developers in our [Discord community](https://www.smallcloud.ai/discord). Ask questions, share your opinion, propose new features. diff --git a/package.json b/package.json index 00aaad6a..ae7f29c2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "codify", - "displayName": "Refact", - "description": "Refact AI Assistant for Code Writing and Refactoring", + "displayName": "Refact – Open-Source AI Agent, Code Generator & Chat for JavaScript, Python, TypeScript, Java, PHP, Go, and more.", + "description": "Refact.ai is a free, open-source AI Agent that adapts to your workflow. It tracks your cursor to provide instant assistance, connects with tools, databases and browsers, works with debuggers, and runs shell commands. As your AI copilot, it handles code generation, testing, review, and refactoring.", "publisher": "smallcloud", "icon": "logo-small.png", "galleryBanner": { @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.0", + "version": "6.1.4", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", @@ -27,7 +27,7 @@ "fetch-h2": "^3.0.2", "json5": "^2.2.3", "marked": "^4.0.8", - "refact-chat-js": "~v2.0.8-alpha.2", + "refact-chat-js": "~v2.0.8-alpha.8", "uuid": "^9.0.1", "vscode-languageclient": "^7.0.0" }, @@ -57,7 +57,9 @@ "Machine Learning", "Education", "Testing", - "Data Science" + "Data Science", + "AI", + "Chat" ], "keywords": [ "refact", @@ -95,14 +97,12 @@ "react", "swift", "objective-c", - "objectivec", "ai", "method completion", "intellicode", "intellisense", "snippets", "kite", - "nodejs", "node", "node.js", "jupyter", @@ -114,7 +114,9 @@ "llm", "test", "security", - "coding" + "coding", + "copilot", + "cursor" ], "activationEvents": [ "onStartupFinished" From 47cdac8196b0547c9d1738db40bf5b043b1aa543 Mon Sep 17 00:00:00 2001 From: alashchev17 Date: Mon, 24 Feb 2025 16:15:09 +0100 Subject: [PATCH 11/35] chore: version bump 6.1.5 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ae7f29c2..be0c1406 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.4", + "version": "6.1.5", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", @@ -27,7 +27,7 @@ "fetch-h2": "^3.0.2", "json5": "^2.2.3", "marked": "^4.0.8", - "refact-chat-js": "~v2.0.8-alpha.8", + "refact-chat-js": "~v2.0.9", "uuid": "^9.0.1", "vscode-languageclient": "^7.0.0" }, From ac34e1a901781ceb6c851f96385fa1669a47c997 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Wed, 26 Feb 2025 13:45:01 +0100 Subject: [PATCH 12/35] Apply accept reject (#191) * feat(chat): send events back to chat when accepting changes in the ide. * fix(chat ide tool call): pass chatId ide back to chat when done. * refactor(tool edit): remove chat id from the payload. * Revert "refactor(tool edit): remove chat id from the payload." This reverts commit 8defbcf6a473b17944ac68b84d94d6a59283e3ed. Changes to be committed: modified: src/sidebar.ts * diff: save on accept. * refact-chat-js@2.0.10-alpha.2 version bump --------- Co-authored-by: alashchev17 Co-authored-by: Andrii Lashchov <84778697+alashchev17@users.noreply.github.com> --- package.json | 2 +- src/extension.ts | 1 + src/interactiveDiff.ts | 2 ++ src/sidebar.ts | 56 ++++++++++++++++++++++++++++++++++++------ 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index be0c1406..bf59820f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "fetch-h2": "^3.0.2", "json5": "^2.2.3", "marked": "^4.0.8", - "refact-chat-js": "~v2.0.9", + "refact-chat-js": "^2.0.10-alpha.2", "uuid": "^9.0.1", "vscode-languageclient": "^7.0.0" }, diff --git a/src/extension.ts b/src/extension.ts index bf502db6..185f8a49 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -89,6 +89,7 @@ async function pressed_escape() } if (editor) { let state = estate.state_of_editor(editor, "pressed_escape"); + global.side_panel?.toolEditChange(editor.document.uri.fsPath, false); if (state) { state.diff_lens_pos = Number.MAX_SAFE_INTEGER; state.completion_lens_pos = Number.MAX_SAFE_INTEGER; diff --git a/src/interactiveDiff.ts b/src/interactiveDiff.ts index f8e0d7f0..884529d8 100644 --- a/src/interactiveDiff.ts +++ b/src/interactiveDiff.ts @@ -589,6 +589,8 @@ export async function like_and_accept(editor: vscode.TextEditor) // dataCollection.data_feedback_candidate_reset(state); }); await thenable; + global.side_panel?.toolEditChange(editor.document.uri.fsPath, true); + await editor.document.save(); } diff --git a/src/sidebar.ts b/src/sidebar.ts index c2b8344b..e2523b19 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -30,8 +30,10 @@ import { ideEscapeKeyPressed, ideIsChatStreaming, setCurrentProjectInfo, - ideToolEdit, + ideToolCall, ToolEditResult, + ideToolCallResponse, + TextDocToolCall, } from "refact-chat-js/dist/events"; import { basename, join } from "path"; import { diff_paste_back } from "./chatTab"; @@ -86,6 +88,7 @@ export class PanelWebview implements vscode.WebviewViewProvider { public chat: chatTab.ChatTab | null = null; public statistic: statisticTab.StatisticTab | null = null; + public tool_edit_in_progress: null | {chatId: string, toolCallId?: string} = null; // public fim_debug: fimDebug.FimDebug | null = null; // public chatHistoryProvider: ChatHistoryProvider|undefined; @@ -539,7 +542,8 @@ export class PanelWebview implements vscode.WebviewViewProvider { } if(ideDiffPasteBackAction.match(e)) { - return this.handleDiffPasteBack(e.payload); + this.tool_edit_in_progress = e.payload.chatId ? {chatId: e.payload.chatId, toolCallId: e.payload.toolCallId} : null; + return this.handleDiffPasteBack(e.payload.content); } @@ -563,8 +567,9 @@ export class PanelWebview implements vscode.WebviewViewProvider { return this.handleEscapePressed(e.payload); } - if(ideToolEdit.match(e)) { - return this.handleToolEdit(e.payload.path, e.payload.edit); + if(ideToolCall.match(e)) { + this.tool_edit_in_progress = {chatId: e.payload.chatId, toolCallId: e.payload.toolCall.id}; + return this.handleToolEdit(e.payload.toolCall, e.payload.edit); } // if(ideOpenChatInNewTab.match(e)) { // return this.handleOpenInTab(e.payload); @@ -598,12 +603,12 @@ export class PanelWebview implements vscode.WebviewViewProvider { // } - async handleToolEdit(path: string, toolEdit: ToolEditResult) { + async handleToolEdit(toolCall: TextDocToolCall, toolEdit: ToolEditResult) { if(!toolEdit.file_before && toolEdit.file_after) { - return this.createNewFileWithContent(path, toolEdit.file_after); + return this.createNewFileWithContent(toolCall.function.arguments.path, toolEdit.file_after); } - return this.addDiffToFile(path, toolEdit.file_after); + return this.addDiffToFile(toolCall.function.arguments.path, toolEdit.file_after); } @@ -627,7 +632,9 @@ export class PanelWebview implements vscode.WebviewViewProvider { edit.insert(newFile, new vscode.Position(0, 0), content); return vscode.workspace.applyEdit(edit).then(success => { if (success) { + this.watchFileForSaveOrClose(document); vscode.window.showTextDocument(document); + // TOOD: send message to ide when file is saved, or closed } else { vscode.window.showInformationMessage('Error: creating file ' + fileName); } @@ -635,6 +642,41 @@ export class PanelWebview implements vscode.WebviewViewProvider { }); } + watchFileForSaveOrClose(document: vscode.TextDocument) { + const disposables: vscode.Disposable[] = []; + const saveDisposable = vscode.workspace.onDidSaveTextDocument((savedDoc) => { + if (savedDoc.uri.toString() === document.uri.toString()) { + // Send message to webview that file was saved + this.toolEditChange(document.uri.fsPath, true); + disposables.forEach(d => d.dispose()); + } + }); + disposables.push(saveDisposable); + + const closeDisposable = vscode.workspace.onDidCloseTextDocument((closedDoc) => { + if (closedDoc.uri.toString() === document.uri.toString()) { + // Send message to webview that file was closed + this.toolEditChange(document.uri.fsPath, false); + disposables.forEach(d => d.dispose()); + } + }); + disposables.push(closeDisposable); + + this._disposables.push(...disposables); + } + + toolEditChange(path: string, accepted: boolean | "indeterminate") { + if(this.tool_edit_in_progress) { + const action = ideToolCallResponse({ + chatId: this.tool_edit_in_progress.chatId, + toolCallId: this.tool_edit_in_progress.toolCallId ?? "", + accepted + }); + this._view?.webview.postMessage(action); + this.tool_edit_in_progress = null; + } + } + async addDiffToFile(fileName: string, content: string) { const uri = this.filePathToUri(fileName); const document = await vscode.workspace.openTextDocument(uri); From 0fdc6b76ace955e9e8af0b5be62f6cd37d64c409 Mon Sep 17 00:00:00 2001 From: alashchev17 Date: Wed, 26 Feb 2025 13:45:52 +0100 Subject: [PATCH 13/35] 6.1.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf59820f..0fd0ad3e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.5", + "version": "6.1.6", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 80869a7d0d43b6bc4a8fbcfeeb33457cee66452a Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Thu, 27 Feb 2025 11:14:08 +0100 Subject: [PATCH 14/35] 6.1.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fd0ad3e..ce439c98 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.6", + "version": "6.1.7", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From e571705508f5717d24575429f17e9b0b8349cf99 Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Thu, 27 Feb 2025 11:17:28 +0100 Subject: [PATCH 15/35] 6.1.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce439c98..54346b82 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.7", + "version": "6.1.8", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 5cf222daf7b3f6be66bdf62f035c90a21ada8aef Mon Sep 17 00:00:00 2001 From: Kirill Starkov Date: Thu, 27 Feb 2025 18:23:51 +0800 Subject: [PATCH 16/35] 6.1.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54346b82..6119c382 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.8", + "version": "6.1.9", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 991a54bb9b5c67e7427e3ee7967fecd4c0fea968 Mon Sep 17 00:00:00 2001 From: Kirill Starkov Date: Thu, 27 Feb 2025 18:31:17 +0800 Subject: [PATCH 17/35] fix gh release flow --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae86a1f7..9ad0a85d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -97,6 +97,7 @@ jobs: prerelease: ${{ !inputs.stable_release }} tag: v${{ steps.get_version.outputs.version }} # Use the version from previous step with 'v' prefix overwrite: true + target_commit: ${{ github.sha }} file_glob: true - name: Publish VSCE extension From 43ed0dc0ac4910fa7803c60852a359aa37f1751b Mon Sep 17 00:00:00 2001 From: Kirill Starkov Date: Fri, 28 Feb 2025 13:53:52 +0800 Subject: [PATCH 18/35] cicd: use refact repo chat artifacts instead npm --- .github/workflows/build.yml | 32 +++++++++++++++++++++++++---- .github/workflows/publish.yml | 38 ++++++++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1d1c4fc..7ca1f64d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,9 @@ on: lsp_branch: description: "Branch name of lsp" default: "main" + chat_js_branch: + description: "Branch name of chat-js" + default: "main" jobs: dist: @@ -57,8 +60,8 @@ jobs: with: fetch-depth: ${{ env.FETCH_DEPTH }} - - name: Download artifact - id: download-artifact + - name: Download lsp artifacts + id: download-artifact-lsp uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} @@ -67,13 +70,34 @@ jobs: branch: ${{ inputs.lsp_branch }} path: ./assets name: dist-${{ matrix.target }} + + - name: Download chat artifacts + id: download-artifact-chat + uses: dawidd6/action-download-artifact@v9 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: agent_gui_build.yml + repo: smallcloudai/refact + branch: ${{ inputs.chat_js_branch }} + path: ./chat_package + name: lts-refact-chat-js-.*\.tgz + name_is_regexp: true + + - name: Prepare chat package + shell: bash + run: | + mkdir -p ./chat_package_fixed + find ./chat_package -name "*.tgz" -type f -exec cp {} ./chat_package_fixed/ \; + ls -la ./chat_package_fixed - name: Install VSCE + shell: bash run: | - npm install + npm install ./chat_package_fixed/*.tgz npm install -g @vscode/vsce + rm -rf ./chat_package ./chat_package_fixed - - name: Pakckage VSCE extension + - name: Package VSCE extension run: | chmod +x ./assets/refact-lsp* vsce package --target ${{ matrix.code-target }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9ad0a85d..a487334f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,6 +6,9 @@ on: lsp_branch: description: "Branch name of lsp" default: "main" + chat_js_branch: + description: "Branch name of chat-js" + default: "main" stable_release: description: "Publish stable release version" default: false @@ -56,13 +59,8 @@ jobs: with: fetch-depth: ${{ env.FETCH_DEPTH }} - - name: Install VSCE - run: | - npm install - npm install -g @vscode/vsce - - - name: Download artifact - id: download-artifact + - name: Download lsp artifacts + id: download-artifact-lsp uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} @@ -71,6 +69,32 @@ jobs: branch: ${{ inputs.lsp_branch }} path: ./assets name: dist-${{ matrix.target }} + + - name: Download chat artifacts + id: download-artifact-chat + uses: dawidd6/action-download-artifact@v9 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: agent_gui_build.yml + repo: smallcloudai/refact + branch: ${{ inputs.chat_js_branch }} + path: ./chat_package + name: lts-refact-chat-js-.*\.tgz + name_is_regexp: true + + - name: Prepare chat package + shell: bash + run: | + mkdir -p ./chat_package_fixed + find ./chat_package -name "*.tgz" -type f -exec cp {} ./chat_package_fixed/ \; + ls -la ./chat_package_fixed + + - name: Install VSCE + shell: bash + run: | + npm install ./chat_package_fixed/*.tgz + npm install -g @vscode/vsce + rm -rf ./chat_package ./chat_package_fixed - name: Package VSCE extension shell: bash From 9be1e64eda22ae9ecefb68c5aa7fc16b4151a2e3 Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Fri, 28 Feb 2025 09:25:21 +0100 Subject: [PATCH 19/35] 6.1.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6119c382..b1de43d0 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.9", + "version": "6.1.10", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 915a67a76aefda4f8d0672e7d64772d714c5e774 Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Fri, 28 Feb 2025 13:27:26 +0100 Subject: [PATCH 20/35] 6.1.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b1de43d0..f4e782e9 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.10", + "version": "6.1.11", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 1d94514db9e5fa44d745a116d914338835c54bef Mon Sep 17 00:00:00 2001 From: alashchev17 Date: Fri, 28 Feb 2025 20:42:51 +0100 Subject: [PATCH 21/35] 6.1.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f4e782e9..1b3e6bcd 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.11", + "version": "6.1.12", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 0154c5ce7c1255872c5b59f806258aea5faf5a2d Mon Sep 17 00:00:00 2001 From: alashchev17 Date: Sat, 1 Mar 2025 00:08:12 +0100 Subject: [PATCH 22/35] 6.1.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b3e6bcd..bb382e78 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.12", + "version": "6.1.13", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 77a2f86e41702a909c5f8ddb215431c1123e5269 Mon Sep 17 00:00:00 2001 From: alashchev17 Date: Sat, 1 Mar 2025 00:08:12 +0100 Subject: [PATCH 23/35] 6.1.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b3e6bcd..bb382e78 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.12", + "version": "6.1.13", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 38e6d9af2d7f3f2ccfd81a6bd7cfe4df7d86498f Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Mon, 3 Mar 2025 18:48:15 +0100 Subject: [PATCH 24/35] 6.1.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bb382e78..67ddbed6 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.13", + "version": "6.1.14", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From e4837e44a1b72d82af2f56fce3a36d39b4bdf63d Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Tue, 4 Mar 2025 08:18:38 +0100 Subject: [PATCH 25/35] 6.1.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 67ddbed6..c9ab28f8 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.14", + "version": "6.1.15", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 6849a3d525d6e265c1cef41fa80c8033ad8ee0fd Mon Sep 17 00:00:00 2001 From: Andrii Lashchov <84778697+alashchev17@users.noreply.github.com> Date: Tue, 4 Mar 2025 16:05:01 +0100 Subject: [PATCH 26/35] Version bump/6.1.16 (#197) * version bump 6.1.16 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9ab28f8..e553470e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.15", + "version": "6.1.16", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From b35a0553a4b38e781b98e228dfe9e4e7ff654f42 Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Wed, 5 Mar 2025 11:31:29 +0100 Subject: [PATCH 27/35] 6.1.17 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e553470e..9e8e386c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.16", + "version": "6.1.17", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 0bcb8d3733310cb7d079e141004b890bc8702ef4 Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Wed, 5 Mar 2025 11:51:05 +0100 Subject: [PATCH 28/35] 6.1.18 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e8e386c..f266c594 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.17", + "version": "6.1.18", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 600f7ea72377bdf479bff87c643b229acff8bd4c Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Wed, 5 Mar 2025 11:57:14 +0100 Subject: [PATCH 29/35] 6.1.19 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f266c594..25376f4e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.18", + "version": "6.1.19", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From a5b6cb901c66ee48f567837882c0b768dc6847b0 Mon Sep 17 00:00:00 2001 From: Oleg Klimov Date: Thu, 6 Mar 2025 13:20:01 +0100 Subject: [PATCH 30/35] 6.1.20 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 25376f4e..7c95e1b0 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.19", + "version": "6.1.20", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From b2f31b4fa53655c6b59b00fc5228282691e73fb6 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Fri, 7 Mar 2025 14:59:38 +0100 Subject: [PATCH 31/35] feat: keep indent for selected snippet. --- src/sidebar.ts | 54 ++++++++------------------------------------------ 1 file changed, 8 insertions(+), 46 deletions(-) diff --git a/src/sidebar.ts b/src/sidebar.ts index e2523b19..c0c0b8a5 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -155,6 +155,7 @@ export class PanelWebview implements vscode.WebviewViewProvider { sendSnippetToChat() { const snippet = this.getSnippetFromEditor(); + console.log({snippet}) if(!snippet) { return; } const message = setSelectedSnippet(snippet); this._view?.webview.postMessage(message); @@ -184,10 +185,8 @@ export class PanelWebview implements vscode.WebviewViewProvider { const fileName = basename(filePath); - const indentedCode = this.trimIndent(code); - return { - code: indentedCode, + code: code, language, path: filePath, basename: fileName @@ -687,7 +686,7 @@ export class PanelWebview implements vscode.WebviewViewProvider { const range = new vscode.Range(start, end); - diff_paste_back( + return diff_paste_back( document, range, content @@ -774,55 +773,18 @@ export class PanelWebview implements vscode.WebviewViewProvider { } - private getTrimmedSelectedRange(editor: vscode.TextEditor): vscode.Range { - - const selection = editor.selection; - const document = editor.document; - let start = selection.start; - let end = selection.end; - - // Get the text of the selected range - let selectedText = document.getText(selection); - - // Trim leading and trailing whitespace and new lines - const trimmedText = selectedText.trim(); - - // If the trimmed text is empty, return the original selection - if (trimmedText.length === 0) { - return selection; - } - - // Find the start and end positions of the trimmed text within the selected range - const leadingWhitespaceLength = selectedText.length - selectedText.trimStart().length; - const trailingWhitespaceLength = selectedText.length - selectedText.trimEnd().length; - - start = document.positionAt(document.offsetAt(start) + leadingWhitespaceLength); - end = document.positionAt(document.offsetAt(end) - trailingWhitespaceLength); - - return new vscode.Range(start, end); - } - - private async handleDiffPasteBack(code_block: string) { const editor = vscode.window.activeTextEditor; if(!editor) { return; } - const trimmedRange = this.getTrimmedSelectedRange(editor); - const startOfLine = new vscode.Position(trimmedRange.start.line, 0); - const endOfLine = new vscode.Position(trimmedRange.start.line + 1, 0); + const range = editor.selection + const startOfLine = new vscode.Position(range.start.line, 0); + const endOfLine = new vscode.Position(range.start.line + 1, 0); const firstLineRange = new vscode.Range(startOfLine, endOfLine); - const spaceRegex = /^[ \t]+/; - const selectedLine = editor.document.getText( - firstLineRange - ); - const indent = selectedLine.match(spaceRegex)?.[0] ?? ""; - const indentedCode = code_block.replace(/\n/gm, "\n" + indent); - const rangeToReplace = new vscode.Range(trimmedRange.start, trimmedRange.end); - return diff_paste_back( editor.document, - rangeToReplace, - indentedCode, + firstLineRange, + code_block ); } From ea0f84775d990f407d3107d7537db3fbb98bd061 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Fri, 7 Mar 2025 15:44:37 +0100 Subject: [PATCH 32/35] chore: remove console.log. --- src/sidebar.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sidebar.ts b/src/sidebar.ts index c0c0b8a5..3aad5146 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -155,7 +155,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { sendSnippetToChat() { const snippet = this.getSnippetFromEditor(); - console.log({snippet}) if(!snippet) { return; } const message = setSelectedSnippet(snippet); this._view?.webview.postMessage(message); From ab71da7ef10e55fb9742109afcc0ff4b7e83e156 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Fri, 7 Mar 2025 16:17:28 +0100 Subject: [PATCH 33/35] remove knowledge flag. --- src/sidebar.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sidebar.ts b/src/sidebar.ts index 3aad5146..77c12982 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -846,7 +846,6 @@ export class PanelWebview implements vscode.WebviewViewProvider { ast, images: true, statistics: true, - knowledge: false, }, keyBindings: { completeManual, From 14fefa875a8f196836238a8e1cb057e9069360dd Mon Sep 17 00:00:00 2001 From: Kirill Starkov Date: Wed, 12 Mar 2025 18:26:28 +0800 Subject: [PATCH 34/35] 6.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c95e1b0..9b283451 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/smallcloudai/refact-vscode/issues", "email": "support@smallcloud.tech" }, - "version": "6.1.20", + "version": "6.2.1", "dependencies": { "@types/marked": "^4.0.8", "@types/vscode": "^1.69.0", From 328989a0fff35da9d6b96532622520c70d08aa37 Mon Sep 17 00:00:00 2001 From: alashchev17 Date: Wed, 12 Mar 2025 15:27:34 +0100 Subject: [PATCH 35/35] chore: added logs for file openings --- src/sidebar.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/sidebar.ts b/src/sidebar.ts index 77c12982..b90b1ffd 100644 --- a/src/sidebar.ts +++ b/src/sidebar.ts @@ -791,18 +791,23 @@ export class PanelWebview implements vscode.WebviewViewProvider { async handleOpenFile(file: {file_name:string, line?: number}) { const uri = this.filePathToUri(file.file_name); - const document = await vscode.workspace.openTextDocument(uri); - - if(file.line !== undefined) { - const position = new vscode.Position(file.line ?? 0, 0); - const editor = await vscode.window.showTextDocument(document); - const range = new vscode.Range(position, position); - editor.revealRange(range); - } else { - await vscode.window.showTextDocument(document); + try { + const document = await vscode.workspace.openTextDocument(uri); + + if(file.line !== undefined) { + const position = new vscode.Position(file.line ?? 0, 0); + const editor = await vscode.window.showTextDocument(document); + const range = new vscode.Range(position, position); + editor.revealRange(range); + } else { + await vscode.window.showTextDocument(document); + } + + console.log(`opening document ${document.uri}`); + return document; + } catch (e) { + console.error(e); } - - return document; } getColorTheme(): "light" | "dark" {