CTX: 无需 LLM 的代码上下文加载器

📄 中文摘要

CTX 是一种无 LLM 的代码上下文加载器,旨在解决 AI 编程代理在提示中包含何种上下文的问题。传统方法通过将整个代码库直接转储来处理上下文,但这会消耗 100% 的令牌预算。更智能的方法使用 BM25 搜索,但往往会遗漏依赖文件、导入链和最近的编辑。CTX 通过确定性的方法,将每个查询分类为四种触发类型之一,并将其路由到相应的检索策略,从而有效地利用令牌预算,仅使用 5.2% 的令牌来加载所需的上下文。

📄 English Summary

CTX: I built a LLM-free code context loader that uses 5.2% of tokens

CTX is a deterministic, LLM-free code context loader designed to address the challenge faced by AI coding agents regarding what context to include in prompts. The naive approach of dumping the entire codebase consumes 100% of the token budget, while a more sophisticated BM25 search often misses critical elements such as dependency files, import chains, and recent edits. CTX classifies each query into one of four trigger types and routes it to the appropriate retrieval strategy, effectively utilizing only 5.2% of the token budget to load the necessary context.

Powered by Cloudflare Workers + Payload CMS + Claude 3.5

数据源: OpenAI, Google AI, DeepMind, AWS ML Blog, HuggingFace 等