diff --git a/src/core/prompts/system.ts b/src/core/prompts/system.ts index 293828032..b91632546 100644 --- a/src/core/prompts/system.ts +++ b/src/core/prompts/system.ts @@ -214,6 +214,8 @@ The tool accepts these parameters: - \`command\` (required): The CLI command to execute. Must be valid for the user's operating system. - \`cwd\` (optional): The working directory to execute the command in. If not provided, the current working directory is used. Ensure this is always an absolute path, starting with \`/\`. If you are running the command in the root directly, skip this parameter. The command executor is defaulted to run in the root directory. You already have the Current Workspace Directory in . +CRITICAL: If the command is a very long running process, prefer to let the user to that they can run it manually in thier terminal. If the user specifically requests to run a long running command, you may proceed. + ## search_files The \`search_files\` tool allows you to search for patterns across files in a directory using regex. diff --git a/src/core/webview/webviewMessageHandler.ts b/src/core/webview/webviewMessageHandler.ts index bf10ec4ca..6b2d57374 100644 --- a/src/core/webview/webviewMessageHandler.ts +++ b/src/core/webview/webviewMessageHandler.ts @@ -18,6 +18,7 @@ import { TasksByIdRequestPayload, UpdateGlobalStateMessage, } from "../../shared/WebviewMessage" +import { myersDiff } from "../../services/continuedev/core/diff/myers" // kilocode_change end import { @@ -1268,28 +1269,17 @@ export const webviewMessageHandler = async ( // Process each edit to accumulate diff stats for (const editEntry of edit.edits) { - const beforeLines = (editEntry.originalContent || "").split("\n") - const afterLines = (editEntry.newContent || "").split("\n") - - // Simple line-based diff calculation for each edit - if (beforeLines.length === 0 && afterLines.length > 0) { - // New content added - totalAdditions += afterLines.length - } else if (beforeLines.length > 0 && afterLines.length === 0) { - // Content deleted - totalDeletions += beforeLines.length - } else { - // Modified content - use simple line count difference - const lineDiff = afterLines.length - beforeLines.length - if (lineDiff > 0) { - totalAdditions += lineDiff - } else { - totalDeletions += Math.abs(lineDiff) - } - // If same line count, assume at least some lines changed - if (lineDiff === 0 && beforeLines.some((line, i) => line !== afterLines[i])) { - totalAdditions += 1 - totalDeletions += 1 + const beforeContent = editEntry.originalContent || "" + const afterContent = editEntry.newContent || "" + + // Use proper diff algorithm to calculate changes + const diffLines = myersDiff(beforeContent, afterContent) + + for (const diffLine of diffLines) { + if (diffLine.type === "new") { + totalAdditions++ + } else if (diffLine.type === "old") { + totalDeletions++ } } } diff --git a/src/integrations/editor/FileEditReviewController.ts b/src/integrations/editor/FileEditReviewController.ts index 69c4c4955..81fe75bab 100644 --- a/src/integrations/editor/FileEditReviewController.ts +++ b/src/integrations/editor/FileEditReviewController.ts @@ -3,6 +3,7 @@ import { promises as fs } from "fs" import * as path from "path" import { getReadablePath } from "../../utils/path" +import { myersDiff } from "../../services/continuedev/core/diff/myers" type PendingFileEdit = { relPath: string @@ -282,32 +283,17 @@ export class FileEditReviewController implements vscode.Disposable { for (const edit of this.pendingEdits.values()) { for (const editEntry of edit.edits) { - const beforeLines = editEntry.originalContent ? editEntry.originalContent.split("\n") : [] - const afterLines = editEntry.newContent ? editEntry.newContent.split("\n") : [] - - if (beforeLines.length === 0) { - // New content added - linesAdded += afterLines.length - } else if (afterLines.length === 0) { - // Content deleted - linesDeleted += beforeLines.length - } else { - // Modified content - count changed lines - const commonLength = Math.min(beforeLines.length, afterLines.length) - let changedInCommon = 0 - for (let i = 0; i < commonLength; i++) { - if (beforeLines[i] !== afterLines[i]) { - changedInCommon++ - } - } - linesUpdated += changedInCommon - - // Account for added/deleted lines beyond common length - const diff = afterLines.length - beforeLines.length - if (diff > 0) { - linesAdded += diff - } else if (diff < 0) { - linesDeleted += Math.abs(diff) + const beforeContent = editEntry.originalContent || "" + const afterContent = editEntry.newContent || "" + + // Use proper diff algorithm to calculate changes + const diffLines = myersDiff(beforeContent, afterContent) + + for (const diffLine of diffLines) { + if (diffLine.type === "new") { + linesAdded++ + } else if (diffLine.type === "old") { + linesDeleted++ } } } diff --git a/src/package.json b/src/package.json index 3e9a1e9ed..a8f48650a 100644 --- a/src/package.json +++ b/src/package.json @@ -3,7 +3,7 @@ "displayName": "%extension.displayName%", "description": "%extension.description%", "publisher": "matterai", - "version": "5.2.4", + "version": "5.2.6", "icon": "assets/icons/matterai-ic.png", "galleryBanner": { "color": "#FFFFFF",