mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-01-16 08:21:55 +00:00
- 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.
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { minimatch } from 'minimatch'
|
|
import { TFile, TFolder, Vault } from 'obsidian'
|
|
|
|
export const findFilesMatchingPatterns = async (
|
|
patterns: string[],
|
|
vault: Vault,
|
|
) => {
|
|
const files = vault.getMarkdownFiles()
|
|
return files.filter((file) => {
|
|
return patterns.some((pattern) => minimatch(file.path, pattern))
|
|
})
|
|
}
|
|
|
|
export const listFilesAndFolders = async (vault: Vault, path: string) => {
|
|
const folder = vault.getAbstractFileByPath(path)
|
|
const childrenFiles: string[] = []
|
|
const childrenFolders: string[] = []
|
|
if (folder instanceof TFolder) {
|
|
folder.children.forEach((child) => {
|
|
if (child instanceof TFile) {
|
|
childrenFiles.push(child.path)
|
|
} else if (child instanceof TFolder) {
|
|
childrenFolders.push(child.path + "/")
|
|
}
|
|
})
|
|
return [...childrenFolders, ...childrenFiles]
|
|
}
|
|
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) => {
|
|
|
|
}
|