diff --git a/src/components/chat-view/ChatView.tsx b/src/components/chat-view/ChatView.tsx index 7a2c762..610e330 100644 --- a/src/components/chat-view/ChatView.tsx +++ b/src/components/chat-view/ChatView.tsx @@ -29,7 +29,10 @@ import { LLMBaseUrlNotSetException, LLMModelNotSetException, } from '../../core/llm/exception' -import { regexSearchFiles } from '../../core/ripgrep' +import { matchSearchUsingCorePlugin } from '../../core/file-search/match/coreplugin-match' +import { matchSearchUsingOmnisearch } from '../../core/file-search/match/omnisearch-match' +import { regexSearchUsingRipgrep } from '../../core/file-search/regex/ripgrep-regex' +import { regexSearchUsingCorePlugin } from '../../core/file-search/regex/coreplugin-regex' import { useChatHistory } from '../../hooks/use-chat-history' import { useCustomModes } from '../../hooks/use-custom-mode' import { t } from '../../lang/helpers' @@ -607,12 +610,40 @@ const Chat = forwardRef((props, ref) => { mentionables: [], } } + } else if (toolArgs.type === 'match_search_files') { + const searchBackend = settings.filesSearchSettings.matchBackend + let results: string; + if (searchBackend === 'omnisearch') { + results = await matchSearchUsingOmnisearch(toolArgs.query, app) + } else { + results = await matchSearchUsingCorePlugin(toolArgs.query, app) + } + const formattedContent = `[match_search_files for '${toolArgs.filepath}'] Result:\n${results}\n`; + return { + type: 'match_search_files', + applyMsgId, + applyStatus: ApplyStatus.Applied, + returnMsg: { + role: 'user', + applyStatus: ApplyStatus.Idle, + content: null, + promptContent: formattedContent, + id: uuidv4(), + mentionables: [], + } + } } else if (toolArgs.type === 'regex_search_files') { - // @ts-expect-error Obsidian API type mismatch - const baseVaultPath = String(app.vault.adapter.getBasePath()) - const ripgrepPath = settings.ripgrepPath - const absolutePath = path.join(baseVaultPath, toolArgs.filepath) - const results = await regexSearchFiles(absolutePath, toolArgs.regex, ripgrepPath) + const searchBackend = settings.filesSearchSettings.regexBackend + let results: string; + if (searchBackend === 'coreplugin') { + results = await regexSearchUsingCorePlugin(toolArgs.regex, app) + } else { + // @ts-expect-error Obsidian API type mismatch + const baseVaultPath = String(app.vault.adapter.getBasePath()) + const absolutePath = path.join(baseVaultPath, toolArgs.filepath) + const ripgrepPath = settings.filesSearchSettings.ripgrepPath + results = await regexSearchUsingRipgrep(absolutePath, toolArgs.regex, ripgrepPath) + } const formattedContent = `[regex_search_files for '${toolArgs.filepath}'] Result:\n${results}\n`; return { type: 'regex_search_files', diff --git a/src/components/chat-view/CustomModeView.tsx b/src/components/chat-view/CustomModeView.tsx index ce89927..20135c6 100644 --- a/src/components/chat-view/CustomModeView.tsx +++ b/src/components/chat-view/CustomModeView.tsx @@ -367,7 +367,7 @@ const CustomModeView = () => { {t('prompt.overrideWarning')}