✨ feat(vscode): 代码阅读预览里工作区外的库文件也能问 AI,问答记进第一个工作区文件夹,重写注释不对库文件开放

This commit is contained in:
cruldra committed 2026-10-13 21:50:54 +11:00
1 parent cecae0e244
commit 39dfd9b084
24 files changed
+463 -79

No files matched your search

+10 -8
View File
@@ -5,8 +5,10 @@
*/
import type { WorkspaceFolder } from 'vscode'
import type { QaLocation } from '../folderStore'
import * as path from 'node:path'
import { Uri, workspace } from 'vscode'
import { locateQa } from '../folderStore'
import { featureQaKey, pathQaKey, relativeQaKey } from '../qa/pathQa'
export const PATH_PREVIEW_SCHEME = 'code-reader-path'
@@ -56,20 +58,20 @@ export function topSubjectOf(uri: Uri): { uri: Uri, kind: TopSubject } {
}
/**
* 这条路径在哪个工作区文件夹、相对路径是什么。
* 工作区根本身的相对路径是空字符串(locate 不认根,顶部问答要认)。
* 这条路径的顶部问答记在哪、发给模型时怎么写它:同 [locateQa](工作区外的库文件也能问),
* 另外认工作区根本身,键和发给模型的路径都是空字符串(locate 不认根,顶部问答要认)。
*/
export function pathQaLocation(uri: Uri): { folder: WorkspaceFolder, key: string } | undefined {
export function pathQaLocation(uri: Uri): QaLocation | undefined {
const folder = workspace.getWorkspaceFolder(uri)
if (!folder)
return undefined
const key = relativeQaKey(path.posix.normalize(folder.uri.path), path.posix.normalize(uri.path))
return key === undefined ? undefined : { folder, key }
if (folder && relativeQaKey(path.posix.normalize(folder.uri.path), path.posix.normalize(uri.path)) === '')
return { folder, key: '', promptPath: '' }
return locateQa(uri)
}
/**
* 顶部问答记在哪:在哪个工作区文件夹(claude 在它里面跑,带的图片存在它的 `.spx/code-qa/`)、记录表里的键(见 pathQa.ts)。
* 文件、文件夹按「工作区文件夹 + 相对路径」;功能对话页按功能的 id,记在第一个工作区文件夹。不在工作区里、没打开文件夹时没有。
* 文件、文件夹按「工作区文件夹 + 键」(见 [pathQaLocation],工作区外的库文件记在第一个工作区文件夹);功能对话页按功能的 id,记在第一个工作区文件夹。
* 没打开文件夹时没有。
*/
export function topQaLocation(uri: Uri): { folder: WorkspaceFolder, key: string } | undefined {
const feature = featureIdOf(uri)