✨ feat(vscode): 代码阅读预览里工作区外的库文件也能问 AI,问答记进第一个工作区文件夹,重写注释不对库文件开放
This commit is contained in:
1 parent
cecae0e244
commit
39dfd9b084
24 files changed
+463
-79
No files matched your search
@@ -9,7 +9,7 @@ describe('问路径时发给模型的话', () => {
|
||||
it('文件:写明是文件,带相对路径和开头', () => {
|
||||
const prompt = pathAskPrompt({
|
||||
kind: 'file',
|
||||
relativePath: FILE,
|
||||
path: FILE,
|
||||
head: { lines: ['export default function Page() {', ' return null', '}'], truncated: false },
|
||||
}, '这个名字是什么意思')
|
||||
expect(prompt).toContain(`这是一个文件,相对路径:${FILE}`)
|
||||
@@ -24,7 +24,7 @@ describe('问路径时发给模型的话', () => {
|
||||
const lines = Array.from({ length: PATH_ASK_HEAD_LINES }, (_, index) => `line ${index}`)
|
||||
const prompt = pathAskPrompt({
|
||||
kind: 'file',
|
||||
relativePath: FILE,
|
||||
path: FILE,
|
||||
head: { lines, truncated: true },
|
||||
}, '?')
|
||||
expect(prompt).toContain(`这是一个文件,相对路径:${FILE}`)
|
||||
@@ -33,10 +33,17 @@ describe('问路径时发给模型的话', () => {
|
||||
expect(prompt).not.toContain('line 80')
|
||||
})
|
||||
|
||||
it('工作区外的库文件:写明在项目外、给绝对路径(相对路径它读不到)', () => {
|
||||
const library = '/Users/me/.local/share/uv/python/cpython-3.12/lib/python3.12/pathlib.py'
|
||||
const prompt = pathAskPrompt({ kind: 'file', path: library, outside: true, head: { lines: ['"""Object-oriented filesystem paths."""'], truncated: true } }, 'rglob 怎么实现的')
|
||||
expect(prompt).toContain(`这是项目外的一个文件(比如依赖库的源码),绝对路径:${library}`)
|
||||
expect(prompt).not.toContain('相对路径:')
|
||||
})
|
||||
|
||||
it('文件夹:写明是文件夹,带相对路径,只列这一层的名字', () => {
|
||||
const prompt = pathAskPrompt({
|
||||
kind: 'folder',
|
||||
relativePath: FOLDER,
|
||||
path: FOLDER,
|
||||
children: [
|
||||
{ name: 'components', kind: 'folder' },
|
||||
{ name: 'page.tsx', kind: 'file' },
|
||||
|
||||
Reference in new issue
Block a user