✨ feat(vscode): FastAPI 接口卡片的调用树带上前端调用它的地方

This commit is contained in:
cruldra committed 2026-10-12 12:22:51 +11:00
1 parent d4459e93b3
commit 29cedcb751
30 files changed
+1316 -130

No files matched your search

@@ -169,4 +169,29 @@ describe('顺着调用者往上收集调用边', () => {
expect(asked).toEqual(['mask_phone'])
expect(edges).toEqual([])
})
it('前端发请求的调用者带着请求写法进边,前端节点往上照常问;前端测试文件里发的请求不算', async () => {
const route = symbolIn('api/agent/routes.py', 'get_default_agent')
const fetchDefault = symbolIn('web/src/lib/agents.ts', 'fetchDefaultAgent')
const inTest = symbolIn('web/src/lib/__tests__/agents.ts', 'mocked')
const page = symbolIn('web/src/app/(main)/my-agents/page.tsx', 'MyAgentsPage')
const asked: string[] = []
const edges = await collectCallEdges(route, async (node) => {
asked.push(node.name)
if (node.name === 'get_default_agent') {
return [
{ from: fetchDefault, ranges: [range(10, 20)], request: 'GET /api/v1/agents/default' },
{ from: inTest, ranges: [range(3)], request: 'GET /api/v1/agents/default' },
{ from: symbolIn('web/src/lib/agents.test.ts', 'spec'), ranges: [range(4)], request: 'GET /api/v1/agents/default' },
]
}
if (node.name === 'fetchDefaultAgent')
return [{ from: page, ranges: [range(6)] }]
return []
}, async () => [])
expect(asked).toEqual(['get_default_agent', 'fetchDefaultAgent', 'MyAgentsPage'])
expect(edges).toEqual([
{ caller: fetchDefault, callee: route, at: range(10, 20), request: 'GET /api/v1/agents/default' },
{ caller: page, callee: fetchDefault, at: range(6) },
])
})
})