Merge remote-tracking branch 'origin/master'

This commit is contained in:
duanfuxiang
2025-06-11 15:05:43 +08:00
25 changed files with 626 additions and 95 deletions

View File

@@ -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) => {
}

View File

@@ -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')

View File

@@ -209,7 +209,7 @@ export class PromptGenerator {
},
]
let filesSearchMethod = this.settings.filesSearchMethod
let filesSearchMethod = this.settings.filesSearchSettings.method
if (filesSearchMethod === 'auto' && this.settings.embeddingModelId && this.settings.embeddingModelId !== '') {
filesSearchMethod = 'semantic'
}
@@ -755,6 +755,7 @@ export class PromptGenerator {
this.app.vault.getRoot().path,
false,
mode,
this.settings.filesSearchSettings,
filesSearchMethod,
preferredLanguage,
this.diffStrategy,