diff --git a/README.md b/README.md index f87f450..34dd081 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Recent Updates [0.2.4](https://github.com/infiolab/infio-copilot/releases/tag/0.2.4) Added multilingual support -[0.2.3](https://github.com/infiolab/infio-copilot/releases/tag/0.2.3) Add custom mode config, you can't create you own agent now +[0.2.3](https://github.com/infiolab/infio-copilot/releases/tag/0.2.3) Add custom mode config, you can create you own agent now [0.1.7](https://github.com/infiolab/infio-copilot/releases/tag/0.1.7) Added image selector modal, allowing users to search, select, and upload images in obsidian vault or local file browser diff --git a/src/components/chat-view/ChatView.tsx b/src/components/chat-view/ChatView.tsx index 361f17a..52900d0 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' @@ -609,12 +612,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')}