一句话:基于 TypeScript Compiler API 实现 abcoder-ts-parser,直接复用编译器 AST 与语义信息,为代码智能体高效构建函数级代码索引。
基于图的代码索引通过保留调用链与依赖关系,能改善 LLM 代码智能体的上下文检索,弥补关键词检索与相似度检索的不足。开源框架 ABCoder 将代码库解析为函数级的 UniAST 索引,但其现有解析器把轻量 AST 解析与语言服务器语义解析结合,每个符号查找都需一次 JSON-RPC 调用,在大型 TypeScript 仓库上成为性能瓶颈。本文提出 abcoder-ts-parser:它构建于 TypeScript Compiler API 之上,直接使用编译器自身的 AST、语义信息与模块解析逻辑,从而在一次编译分析中完成符号解析与索引构建。作者在三个开源 TypeScript 项目(最大约 120 万行代码)上评估该解析器,结果显示其生成的索引可靠,且效率显著优于原有架构。现场演示见所给视频链接。
Graph-based code indexing can improve context retrieval for LLM-based code agents by preserving call chains and dependency relationships that keyword search and similarity retrieval often miss. ABCoder is an open-source framework that parses codebases into a function-level code index called UniAST. Its existing parsers combine lightweight AST parsers for syntactic analysis with language servers for semantic resolution, but because such resolution requires a JSON-RPC call for each symbol lookup, these per-symbol calls become a bottleneck on large TypeScript repositories. We present abcoder-ts-parser, a TypeScript parser built on the TypeScript Compiler API that works directly with the compiler's AST, semantic information, and module resolution logic. We evaluate the parser on three open-source TypeScript projects with up to 1.2 million lines of code and find that it produces reliable indexes significantly more efficiently than the existing architecture. For a live demonstration, watch: https://youtu.be/ryssr7ouvdE