✨ feat(vscode): 代码阅读预览里工作区外的库文件也能问 AI,问答记进第一个工作区文件夹,重写注释不对库文件开放
This commit is contained in:
1 parent
cecae0e244
commit
39dfd9b084
24 files changed
+463
-79
No files matched your search
@@ -1,20 +1,23 @@
|
||||
/**
|
||||
* 顶部问答带给模型的材料:文件是相对路径加开头若干行,文件夹是相对路径加这一层的名字。
|
||||
* 顶部问答带给模型的材料:文件是路径加开头若干行,文件夹是路径加这一层的名字。
|
||||
* 路径见 [QaLocation.promptPath]:工作区里的是相对路径,工作区外的库文件是绝对路径。
|
||||
*/
|
||||
|
||||
import type { Uri, WorkspaceFolder } from 'vscode'
|
||||
import type { ExcludeSetting } from '../explorer/fileEntries'
|
||||
import type { QaLocation } from '../folderStore'
|
||||
import type { PathAskSubject, PathChild } from './pathAskPrompt'
|
||||
import { FileType, workspace } from 'vscode'
|
||||
import { createExcludeMatcher, sortEntries } from '../explorer/fileEntries'
|
||||
import { readFileHead } from './pathAskContext'
|
||||
import { displayRelativePath } from './pathQa'
|
||||
|
||||
export async function describePath(target: { uri: Uri, folder: WorkspaceFolder, isDirectory: boolean, relativePath: string }): Promise<PathAskSubject> {
|
||||
const relativePath = displayRelativePath(target.relativePath)
|
||||
if (target.isDirectory)
|
||||
return { kind: 'folder', relativePath, children: await folderChildren(target.uri, target.folder, target.relativePath) }
|
||||
return { kind: 'file', relativePath, head: await readFileHead(target.uri.fsPath) }
|
||||
export async function describePath(target: { uri: Uri, isDirectory: boolean, at: QaLocation }): Promise<PathAskSubject> {
|
||||
const { uri, isDirectory, at } = target
|
||||
const where = { path: displayRelativePath(at.promptPath), ...(at.outsideDir !== undefined && { outside: true as const }) }
|
||||
if (isDirectory)
|
||||
return { kind: 'folder', ...where, children: await folderChildren(uri, at.folder, at.key) }
|
||||
return { kind: 'file', ...where, head: await readFileHead(uri.fsPath) }
|
||||
}
|
||||
|
||||
/** 文件夹这一层的子文件和子目录;files.exclude 排除的不列。列不出来时只留原因。 */
|
||||
|
||||
Reference in new issue
Block a user