✨ feat(vscode): 代码阅读「了解一块代码」改成按路径列调用树:结果是几条路径(用户的一种操作一条),每条从入口一路调到后端服务、数据表,跨进程的写明怎么连过去(via),结构用扁平的 nodes 加 parent 连成树、不用递归;侧栏路径下面一层层展开节点,回答里用嵌套列表画树;回答和找的过程里的代码位置写成仓库链接,功能对话页上的链接按找代码用的工作区文件夹检查、打开、悬停;旧格式的结果当没有,栏上方提示打开对话重新找;删功能前先弹模态框确认,说清连带删掉调用树和问答记录,点「删除」才删

This commit is contained in:
cruldra committed 2026-10-14 21:28:40 +11:00
1 parent cc445e7123
commit c6de46ad37
17 files changed
+978 -253

No files matched your search

@@ -6,10 +6,12 @@
import type { WorkspaceFolder } from 'vscode'
import type { QaLocation } from '../folderStore'
import type { NamedFolder, RepoPlace } from './repoPath'
import * as path from 'node:path'
import { Uri, workspace } from 'vscode'
import { locateQa } from '../folderStore'
import { featureQaKey, pathQaKey, relativeQaKey } from '../qa/pathQa'
import { folderLinkPlace, repoRootOf } from './repoPath'
export const PATH_PREVIEW_SCHEME = 'code-reader-path'
@@ -36,6 +38,27 @@ export function featureIdOf(uri: Uri): string | undefined {
return uri.scheme === PATH_PREVIEW_SCHEME && uri.query.startsWith(FEATURE_QUERY) ? uri.query.slice(FEATURE_QUERY.length) : undefined
}
/** 「了解一块代码」找代码用的工作区文件夹:眼下打开的全部,claude 在第一个里面跑,别的加进来读。 */
export function featureFolders(): NamedFolder[] {
return (workspace.workspaceFolders ?? []).map(folder => ({ name: folder.name, path: folder.uri.fsPath }))
}
/** 把页面上一条仓库链接的路径换成磁盘上的位置;算不出来的没有。 */
export type LinkBase = (rel: string) => RepoPlace | undefined
/**
* 预览这一页上仓库链接的路径从哪儿算:功能对话页从这个功能找代码用的工作区文件夹算(见 [featureFolders]、[folderLinkPlace]),
* 别的页从文档所在的 git 仓库根算,不在 git 仓库里时一条也算不出来。
*/
export async function linkBaseOf(uri: Uri): Promise<LinkBase> {
if (featureIdOf(uri) !== undefined) {
const folders = featureFolders()
return rel => folderLinkPlace(folders, rel)
}
const root = await repoRootOf(uri.fsPath)
return rel => root === undefined ? undefined : { root, rel }
}
export function pathPreviewUri(target: Uri, kind: PathSubject): Uri {
return target.with({ scheme: PATH_PREVIEW_SCHEME, query: kind, fragment: '' })
}