Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/core/mentions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { isBinaryFile } from "isbinaryfile"
import { mentionRegexGlobal, unescapeSpaces } from "../../shared/context-mentions"

import { getCommitInfo, getWorkingState } from "../../utils/git"
import { getSvnCommitInfo, getSvnWorkingState } from "../../utils/svn"
import { getWorkspacePath } from "../../utils/path"

import { openFile } from "../../integrations/misc/open-file"
Expand Down Expand Up @@ -95,8 +96,12 @@ export async function parseMentions(
return `Workspace Problems (see below for diagnostics)`
} else if (mention === "git-changes") {
return `Working directory changes (see below for details)`
} else if (mention === "svn-changes") {
return `SVN working directory changes (see below for details)`
} else if (/^[a-f0-9]{7,40}$/.test(mention)) {
return `Git commit '${mention}' (see below for commit info)`
} else if (/^r?\d+$/.test(mention)) {
return `SVN revision '${mention}' (see below for revision info)`
} else if (mention === "terminal") {
return `Terminal Output (see below for output)`
}
Expand Down Expand Up @@ -177,13 +182,27 @@ export async function parseMentions(
} catch (error) {
parsedText += `\n\n<git_working_state>\nError fetching working state: ${error.message}\n</git_working_state>`
}
} else if (mention === "svn-changes") {
try {
const workingState = await getSvnWorkingState(cwd)
parsedText += `\n\n<svn_working_state>\n${workingState}\n</svn_working_state>`
} catch (error) {
parsedText += `\n\n<svn_working_state>\nError fetching SVN working state: ${error.message}\n</svn_working_state>`
}
} else if (/^[a-f0-9]{7,40}$/.test(mention)) {
try {
const commitInfo = await getCommitInfo(mention, cwd)
parsedText += `\n\n<git_commit hash="${mention}">\n${commitInfo}\n</git_commit>`
} catch (error) {
parsedText += `\n\n<git_commit hash="${mention}">\nError fetching commit info: ${error.message}\n</git_commit>`
}
} else if (/^r?\d+$/.test(mention)) {
try {
const commitInfo = await getSvnCommitInfo(mention, cwd)
parsedText += `\n\n<svn_revision revision="${mention}">\n${commitInfo}\n</svn_revision>`
} catch (error) {
parsedText += `\n\n<svn_revision revision="${mention}">\nError fetching SVN revision info: ${error.message}\n</svn_revision>`
}
} else if (mention === "terminal") {
try {
const terminalOutput = await getLatestTerminalOutput()
Expand Down
19 changes: 19 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { fileExistsAtPath } from "../../utils/fs"
import { playTts, setTtsEnabled, setTtsSpeed, stopTts } from "../../utils/tts"
import { singleCompletionHandler } from "../../utils/single-completion-handler"
import { searchCommits } from "../../utils/git"
import { searchSvnCommits } from "../../utils/svn"
import { exportSettings, importSettingsWithFeedback } from "../config/importExport"
import { getOpenAiModels } from "../../api/providers/openai"
import { getVsCodeLmModels } from "../../api/providers/vscode-lm"
Expand Down Expand Up @@ -1384,6 +1385,24 @@ export const webviewMessageHandler = async (
}
break
}
case "searchSvnCommits": {
const cwd = provider.cwd
if (cwd) {
try {
const svnCommits = await searchSvnCommits(message.query || "", cwd)
await provider.postMessageToWebview({
type: "svnCommitSearchResults",
svnCommits,
})
} catch (error) {
provider.log(
`Error searching SVN commits: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
)
vscode.window.showErrorMessage(t("common:errors.search_commits"))
}
}
break
}
case "searchFiles": {
const workspacePath = getWorkspacePath()

Expand Down
3 changes: 3 additions & 0 deletions src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
} from "@roo-code/types"

import { GitCommit } from "../utils/git"
import { SvnCommit } from "../utils/svn"

import { McpServer } from "./mcp"
import { Mode } from "./modes"
Expand Down Expand Up @@ -61,6 +62,7 @@ export interface ExtensionMessage {
| "mcpServers"
| "enhancedPrompt"
| "commitSearchResults"
| "svnCommitSearchResults"
| "listApiConfig"
| "routerModels"
| "openAiModels"
Expand Down Expand Up @@ -137,6 +139,7 @@ export interface ExtensionMessage {
vsCodeLmModels?: { vendor?: string; family?: string; version?: string; id?: string }[]
mcpServers?: McpServer[]
commits?: GitCommit[]
svnCommits?: SvnCommit[]
listApiConfig?: ProviderSettingsEntry[]
mode?: Mode
customMode?: ModeConfig
Expand Down
1 change: 1 addition & 0 deletions src/shared/WebviewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export interface WebviewMessage {
| "mcpEnabled"
| "enableMcpServerCreation"
| "searchCommits"
| "searchSvnCommits"
| "alwaysApproveResubmit"
| "requestDelaySeconds"
| "setApiConfigPassword"
Expand Down
34 changes: 31 additions & 3 deletions src/shared/context-mentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,20 @@ Mention regex:
- URLs that start with a protocol (like 'http://') followed by any non-whitespace characters (including query parameters).
- The exact word 'problems'.
- The exact word 'git-changes'.
- The exact word 'terminal'.
- The exact word 'svn-changes'.
- The exact word 'terminal'.
- It ensures that any trailing punctuation marks (such as ',', '.', '!', etc.) are not included in the matched mention, allowing the punctuation to follow the mention naturally in the text.

- **Global Regex**:
- `mentionRegexGlobal`: Creates a global version of the `mentionRegex` to find all matches within a given string.

*/
export const mentionRegex =
/(?<!\\)@((?:\/|\w+:\/\/)(?:[^\s\\]|\\ )+?|[a-f0-9]{7,40}\b|problems\b|git-changes\b|terminal\b)(?=[.,;:!?]?(?=[\s\r\n]|$))/
/(?<!\\)@((?:\/|\w+:\/\/)(?:[^\s\\]|\\ )+?|[a-f0-9]{7,40}\b|r?\d+\b|problems\b|git-changes\b|svn-changes\b|terminal\b)(?=[.,;:!?]?(?=[\s\r\n]|$))/
export const mentionRegexGlobal = new RegExp(mentionRegex.source, "g")

export interface MentionSuggestion {
type: "file" | "folder" | "git" | "problems"
type: "file" | "folder" | "git" | "svn" | "problems"
label: string
description?: string
value: string
Expand Down Expand Up @@ -95,6 +96,33 @@ export function formatGitSuggestion(commit: {
}
}

export interface SvnMentionSuggestion extends MentionSuggestion {
type: "svn"
revision: string
author: string
date: string
message: string
}

export function formatSvnSuggestion(commit: {
revision: string
author: string
date: string
message: string
}): SvnMentionSuggestion {
return {
type: "svn",
label: commit.message,
description: `${commit.revision} by ${commit.author} on ${commit.date}`,
value: commit.revision,
icon: "$(git-commit)", // Using same icon as Git for consistency
revision: commit.revision,
author: commit.author,
date: commit.date,
message: commit.message,
}
}

// Helper function to unescape paths with backslash-escaped spaces
export function unescapeSpaces(path: string): string {
return path.replace(/\\ /g, " ")
Expand Down
Loading
Loading