feat: Enhance file search with core plugin and Omnisearch integration
- Introduces a new match_search_files tool for fuzzy/keyword search, integrating with Obsidian's core search plugin and updating Omnisearch integration for improved file search capabilities. - Adds settings for selecting search backends (core plugin, Omnisearch, ripgrep) for both regex and match searches. - Updates language files, prompts, and types to support the new functionality. - Restructures search-related files for better organization.
This commit is contained in:
@@ -28,6 +28,10 @@ export const listFilesAndFolders = async (vault: Vault, path: string) => {
|
||||
return []
|
||||
}
|
||||
|
||||
export const matchSearchFiles = async (vault: Vault, path: string, query: string, file_pattern: string) => {
|
||||
|
||||
}
|
||||
|
||||
export const regexSearchFiles = async (vault: Vault, path: string, regex: string, file_pattern: string) => {
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@ export type ParsedMsgBlock =
|
||||
path: string
|
||||
recursive?: boolean
|
||||
finish: boolean
|
||||
} | {
|
||||
type: 'match_search_files'
|
||||
path: string
|
||||
query: string
|
||||
finish: boolean
|
||||
} | {
|
||||
type: 'regex_search_files'
|
||||
path: string
|
||||
@@ -226,6 +231,36 @@ export function parseMsgBlocks(
|
||||
finish: node.sourceCodeLocation.endTag !== undefined
|
||||
})
|
||||
lastEndOffset = endOffset
|
||||
} else if (node.nodeName === 'match_search_files') {
|
||||
if (!node.sourceCodeLocation) {
|
||||
throw new Error('sourceCodeLocation is undefined')
|
||||
}
|
||||
const startOffset = node.sourceCodeLocation.startOffset
|
||||
const endOffset = node.sourceCodeLocation.endOffset
|
||||
if (startOffset > lastEndOffset) {
|
||||
parsedResult.push({
|
||||
type: 'string',
|
||||
content: input.slice(lastEndOffset, startOffset),
|
||||
})
|
||||
}
|
||||
let path: string | undefined
|
||||
let query: string | undefined
|
||||
|
||||
for (const childNode of node.childNodes) {
|
||||
if (childNode.nodeName === 'path' && childNode.childNodes.length > 0) {
|
||||
path = childNode.childNodes[0].value
|
||||
} else if (childNode.nodeName === 'query' && childNode.childNodes.length > 0) {
|
||||
query = childNode.childNodes[0].value
|
||||
}
|
||||
}
|
||||
|
||||
parsedResult.push({
|
||||
type: 'match_search_files',
|
||||
path: path,
|
||||
query: query,
|
||||
finish: node.sourceCodeLocation.endTag !== undefined
|
||||
})
|
||||
lastEndOffset = endOffset
|
||||
} else if (node.nodeName === 'regex_search_files') {
|
||||
if (!node.sourceCodeLocation) {
|
||||
throw new Error('sourceCodeLocation is undefined')
|
||||
|
||||
Reference in New Issue
Block a user