From f0be561cfc59525f2cbba1968f1f418c9c58b84f Mon Sep 17 00:00:00 2001 From: travertexg Date: Tue, 10 Jun 2025 06:54:25 +0000 Subject: [PATCH] refactor: Restructure file search settings This commit restructures the file search settings. The previously individual settings for file search method, regex search backend, match search backend, and ripgrep path have been grouped into a new filesSearchSettings object. --- src/components/chat-view/ChatView.tsx | 6 ++--- src/components/chat-view/CustomModeView.tsx | 2 +- src/core/prompts/system.ts | 5 ++++ src/core/prompts/tools/index.ts | 3 +++ src/core/prompts/tools/search-files.ts | 4 +-- src/core/prompts/tools/types.ts | 2 ++ src/settings/SettingTab.tsx | 28 +++++++++++++++------ src/types/settings.test.ts | 20 +++++++++------ src/types/settings.ts | 18 ++++++++++--- src/utils/prompt-generator.ts | 3 ++- 10 files changed, 63 insertions(+), 28 deletions(-) diff --git a/src/components/chat-view/ChatView.tsx b/src/components/chat-view/ChatView.tsx index d236812..e6422d2 100644 --- a/src/components/chat-view/ChatView.tsx +++ b/src/components/chat-view/ChatView.tsx @@ -611,7 +611,7 @@ const Chat = forwardRef((props, ref) => { } } } else if (toolArgs.type === 'match_search_files') { - const searchBackend = settings.matchSearchBackend + const searchBackend = settings.filesSearchSettings.matchBackend let results: string; if (searchBackend === 'omnisearch') { results = await matchSearchUsingOmnisearch(toolArgs.query, app) @@ -633,7 +633,7 @@ const Chat = forwardRef((props, ref) => { } } } else if (toolArgs.type === 'regex_search_files') { - const searchBackend = settings.regexSearchBackend + const searchBackend = settings.filesSearchSettings.regexBackend let results: string; if (searchBackend === 'coreplugin') { results = await regexSearchUsingCorePlugin(toolArgs.regex, app) @@ -641,7 +641,7 @@ const Chat = forwardRef((props, ref) => { // @ts-expect-error Obsidian API type mismatch const baseVaultPath = String(app.vault.adapter.getBasePath()) const absolutePath = path.join(baseVaultPath, toolArgs.filepath) - const ripgrepPath = settings.ripgrepPath + const ripgrepPath = settings.filesSearchSettings.ripgrepPath results = await regexSearchUsingRipgrep(absolutePath, toolArgs.regex, ripgrepPath) } const formattedContent = `[regex_search_files for '${toolArgs.filepath}'] Result:\n${results}\n`; 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')}