# Sourcegraph

**Sourcegraph** 是一个代码智能平台，由同名公司开发，可对跨多个代码主机的庞大代码库建立索引并进行搜索，并提供代码导航、AI 辅助编程和大规模代码变更工具。该公司成立于 2013 年，将其市场定位为拥有大型或分布式代码库的企业团队，代码库规模从数百个仓库到横跨数百万行的单体仓库不等。<sup>[1](https://sourcegraph.com/docs/getting-started)</sup><sup> • </sup><sup>[2](https://techcrunch.com/2021/07/13/sourcegraph-raises-125m-series-d-on-2-6b-valuation-for-universal-code-search-tool/?tpcc=ECTW2020)</sup>

| 关键事实 | 详情 |
|---|---|
| 成立时间 | 2013 年，由联合创始人 Quinn Slack 和 Beyang Liu 创立<sup>[2](https://techcrunch.com/2021/07/13/sourcegraph-raises-125m-series-d-on-2-6b-valuation-for-universal-code-search-tool/?tpcc=ECTW2020)</sup> |
| 融资 | 2021 年 7 月 13 日完成 1.25 亿美元 D 轮融资，由 Andreessen Horowitz 领投，估值 26.25 亿美元<sup>[2](https://techcrunch.com/2021/07/13/sourcegraph-raises-125m-series-d-on-2-6b-valuation-for-universal-code-search-tool/?tpcc=ECTW2020)</sup> |
| 核心产品 | 代码搜索、代码导航、深度搜索、批量变更、代码洞察，以及 Cody AI 编程助手<sup>[1](https://sourcegraph.com/docs/getting-started)</sup> |
| 搜索引擎 | 对每个仓库的默认分支建立 Zoekt 三元组索引，对其他分支和提交则使用非索引的 `searcher` 路径<sup>[3](https://sourcegraph.com/docs/admin/architecture)</sup> |
| 代码主机 | 开箱即用的 GitHub、GitLab、Bitbucket Cloud 和 Server/Data Center、Perforce 集成，以及任何基于 Git 的主机<sup>[4](https://6.3.sourcegraph.com/getting-started/github-vs-sourcegraph)</sup> |
| 采用情况（2021 年） | 此前 12 个月约有 80 万名开发者使用；索引代码超过 540 亿行<sup>[2](https://techcrunch.com/2021/07/13/sourcegraph-raises-125m-series-d-on-2-6b-valuation-for-universal-code-search-tool/?tpcc=ECTW2020)</sup> |
| 近期变动 | Cody Free 和 Pro 于 2025 年 7 月 23 日停止服务；Amp 编程智能体于 2025 年 12 月 2 日分拆为独立公司<sup>[5](https://sourcegraph.com/blog/changes-to-cody-free-pro-and-enterprise-starter-plans)</sup><sup> • </sup><sup>[6](https://sourcegraph.com/blog/why-sourcegraph-and-amp-are-becoming-independent-companies)</sup> |

## 代码搜索

代码搜索是该平台的核心功能。默认情况下，Sourcegraph 使用 Zoekt 引擎为每个已连接仓库的默认分支构建三元组索引，使得搜索速度相对于代码主机通常提供的搜索而言更快。未被索引的代码（例如非默认分支）由名为 `searcher` 的独立非索引搜索服务处理；对大多数客户而言，为每个仓库的每个分支建立索引被视为对资源的不切实际的使用。<sup>[3](https://sourcegraph.com/docs/admin/architecture)</sup>

搜索支持全文、正则表达式和精确查询，并可限定到任意分支或提交、按语言或按文件模式进行。限定到特定仓库的搜索始终是最新的：平台会在用户对该仓库执行任何操作时获取仓库内容，使新的提交和分支立即可搜索。<sup>[7](https://sourcegraph.com/docs/code-search/features)</sup> 一个查询由搜索模式加上过滤器组成，例如 `lang:java`，关键词搜索则匹配文档或文件名中任意位置的单个词项。<sup>[8](https://sourcegraph.com/docs/code-search/queries)</sup>

并非每个文件都符合索引搜索的条件。默认情况下，大于 1 MB 的文件被排除，二进制文件、唯一三元组超过 20,000 个的文件，以及非有效 UTF-8 的文件同样被排除；管理员可以通过 `search.largeFiles` 设置强制将符合条件的大型文本文件纳入索引。<sup>[9](https://help.sourcegraph.com/article/why-files-are-skipped-from-indexing)</sup> 经常搜索非默认分支的组织可以为每个仓库配置最多 64 个分支的多分支索引。<sup>[7](https://sourcegraph.com/docs/code-search/features)</sup>

## 代码导航

代码导航在 Web 界面中以及通过与代码审查工具和代码主机的集成，提供跳转到定义、查找引用、悬停提示和符号搜索功能。<sup>[1](https://sourcegraph.com/docs/getting-started)</sup> 默认模式是基于搜索的[导航](https://www.edgepedia.org/zh/navigation)，它复用搜索架构，但可能产生误报或漏报。可选的精确模式使用从仓库构建流水线上传的预计算 SCIP 或 LSIF 代码图数据，提供编译器级精确的结果和跨仓库导航；它支持 11 种语言，包括 Go、TypeScript、JavaScript、C、C++、Java、Scala、Kotlin、Rust、Python 和 Ruby。没有 SCIP 或 LSIF 数据的仓库会回退到基于搜索的导航。<sup>[4](https://6.3.sourcegraph.com/getting-started/github-vs-sourcegraph)</sup>

## 深度搜索与 Cody

**深度搜索**是一种智能体式代码搜索工具，可回答关于代码库的自然语言问题。其底层是一个 AI 智能体，使用 Sourcegraph 自身的工具（如代码搜索和代码导航）来探索代码并综合出答案。<sup>[3](https://sourcegraph.com/docs/admin/architecture)</sup>

**Cody** 是该公司推出的 AI 编程助手，可在编辑器和 Web 中使用。它采用检索增强生成（RAG）：当用户提交请求时，Cody 检索相关代码片段，并将其与请求一同发送给大型语言模型。对于聊天和命令，上下文来自本地 IDE 上下文与远程 Sourcegraph 对用户所选仓库的搜索的组合，并使用 BM25 排序函数的改编形式进行排序；对于必须快速的自动补全，Cody 使用 Tree-Sitter 解析库对用户意图进行分类，并且仅依赖本地上下文。<sup>[10](https://sourcegraph.com/blog/how-cody-understands-your-codebase)</sup> Cody Enterprise 用 Sourcegraph 搜索取代了基于嵌入的检索，理由是需要在大量仓库中扩展，并避免将代码发送给第三方嵌入处理器。<sup>[10](https://sourcegraph.com/blog/how-cody-understands-your-codebase)</sup><sup> • </sup><sup>[11](https://sourcegraph.com/docs/cody/faq)</sup> 对于企业客户，Sourcegraph 声明不会用客户数据训练模型，并且代码检索会强制执行用户的读取权限；自动补全使用由 Fireworks.ai 在美国单租户环境中托管的开源 DeepSeek-Coder-V2 模型，该环境不存储任何客户聊天或自动补全数据。<sup>[11](https://sourcegraph.com/docs/cody/faq)</sup>

2025 年 7 月，Sourcegraph 停止了 Cody Free 和 Cody Pro，并自 2025 年 7 月 23 日起将 Cody 从 Enterprise Starter 计划中移除，引导个人用户转向 Amp；Cody Enterprise 仍获得完全支持。<sup>[5](https://sourcegraph.com/blog/changes-to-cody-free-pro-and-enterprise-starter-plans)</sup> 在 2026 年 2 月的一则更新日志中，该公司还宣布，对深度搜索客户而言，深度搜索将取代 Cody Web（浏览器聊天），而作为编辑器编程智能体的 Cody 不受影响。<sup>[12](https://sourcegraph.com/changelog/7-0-removals-deprecations)</sup>

## 批量变更与代码库演进

批量变更是一个跨多个仓库进行协调变更的引擎：开发者编写变更程序，工具在适用之处打开拉取请求，并跟踪它们直到合并。该公司报告称，客户已通过这种方式合并了数十万个变更集，而最大的单次批量变更从一个变更中合并了超过 2,200 个变更集。<sup>[13](https://sourcegraph.com/blog/introducing-agentic-batch-changes?trk=article-ssr-frontend-pulse_little-text-block)</sup> 2026 年 9 月，该公司推出了智能体式批量变更，构建于批量变更和深度搜索之上，它接收对变更的通俗语言描述，在已索引的代码库中确定其范围，并逐个仓库地实施变更，在可能的情况下编写脚本，在需要判断的地方将工作交给编程智能体。其定价按合并的变更集计费，而非按词元或席位计费。<sup>[13](https://sourcegraph.com/blog/introducing-agentic-batch-changes?trk=article-ssr-frontend-pulse_little-text-block)</sup> 代码洞察通过随时间跟踪迁移、版本使用和漏洞修复来补充这一功能。<sup>[1](https://sourcegraph.com/docs/getting-started)</sup>

## 公司历史

Quinn Slack 和 Beyang Liu 于 2013 年创立 Sourcegraph；Slack 曾表示，打造一款达到预期复杂度的产品花了将近五年时间。<sup>[2](https://techcrunch.com/2021/07/13/sourcegraph-raises-125m-series-d-on-2-6b-valuation-for-universal-code-search-tool/?tpcc=ECTW2020)</sup> 该公司于 2020 年 1 月全面转为远程办公，并跨时区异步运作。<sup>[2](https://techcrunch.com/2021/07/13/sourcegraph-raises-125m-series-d-on-2-6b-valuation-for-universal-code-search-tool/?tpcc=ECTW2020)</sup><sup> • </sup><sup>[14](https://sourcegraph.com/about)</sup> 2021 年 7 月，它完成了由 [Andreessen Horowitz](https://www.edgepedia.org/zh/andreessen-horowitz) 领投、[Insight Partners](https://www.edgepedia.org/zh/insight-partners) 和 [Geodesic Capital](https://www.edgepedia.org/zh/geodesic-capital) 参与的 1.25 亿美元 D 轮融资，估值 26.25 亿美元，约为其 2020 年 12 月估值的三倍；投资者包括 Andreessen Horowitz、Sequoia、Felicis、Redpoint、Craft Ventures 和 Goldcrest Capital。<sup>[2](https://techcrunch.com/2021/07/13/sourcegraph-raises-125m-series-d-on-2-6b-valuation-for-universal-code-search-tool/?tpcc=ECTW2020)</sup><sup> • </sup><sup>[14](https://sourcegraph.com/about)</sup>

该公司的许可模式随时间而变化：据一位参与开源可持续性工作的公司员工称，自 2022 年 2 月起，Sourcegraph 代码搜索不再是 OSI 批准的开源项目，不过 GitHub 上存在基于 Apache 2 许可证的代码分叉。<sup>[15](https://x.noodl3.net/jdorfman/status/1825998922105692542)</sup> 2024 年 8 月，公开的 sourcegraph.com 代码搜索实例受到限制，在 Hacker News 上引发了题为“Sourcegraph 关闭了”的讨论。<sup>[16](https://news.ycombinator.com/item?id=41296481)</sup>

2025 年 12 月 2 日，Sourcegraph 和 Amp 成为两家独立的公司。2016 年加入并曾担任 CFO 的 Dan Adler 出任 Sourcegraph 的 CEO，而联合创始人 Quinn Slack 和 Beyang Liu 创办了 Amp Inc.，专注于前沿编程智能体；共同的董事会投资者继续为两家公司服务。<sup>[6](https://sourcegraph.com/blog/why-sourcegraph-and-amp-are-becoming-independent-companies)</sup><sup> • </sup><sup>[17](https://ampcode.com/news/amp-frontier-corporation)</sup>

## 采用情况与实测影响

已发布的案例研究描述了在大型和异构代码库中的使用情况：CERN 管理着用于加速器控制的 1,500 万行 Java 代码库，Reddit 在 2,000 多个仓库中处理代码，Lyft 在其 PHP 单体到微服务的转型期间使用了多仓库搜索，Nutanix 使用代码搜索和批量变更来发现和修补 Log4j 漏洞，报告称其在五分钟内发现并修复了实例，并在四天内向客户交付了补丁。<sup>[18](https://sourcegraph.com/case-studies)</sup><sup> • </sup><sup>[19](https://sourcegraph.com/enterprise)</sup>

与工程智能平台 DX 的合作在 [Booking.com](https://www.edgepedia.org/zh/booking-com) 产生了第三方测量数据：Sourcegraph 的日活跃用户的拉取请求合并率比非用户高 16%，开发者对 Sourcegraph 的满意度在六个月内上升了 15 个百分点。<sup>[20](https://sourcegraph.com/blog/announcing-our-partnership-with-dx)</sup>

## 与 GitHub 代码搜索的比较

GitHub 代码搜索只能搜索存储在 GitHub 中的代码，而 Sourcegraph 可与多个代码主机集成，还支持使用 Comby 语法的多行搜索和结构化搜索，这些是 GitHub 不提供的。GitHub 索引了约 700 万个开源仓库，而 Sourcegraph 索引了 280 万个，此外 GitHub 还搜索议题、拉取请求和讨论，而 Sourcegraph 不提供这些功能。<sup>[4](https://6.3.sourcegraph.com/getting-started/github-vs-sourcegraph)</sup> Sourcegraph 将其平台定位为面向拥有众多仓库、大型单体仓库或代码分散在多个主机上的组织。<sup>[4](https://6.3.sourcegraph.com/getting-started/github-vs-sourcegraph)</sup>

## References

1. [Getting Started, Sourcegraph docs](https://sourcegraph.com/docs/getting-started)
2. [Sourcegraph raises $125M Series D on $2.6B valuation for universal code search tool, TechCrunch (July 13, 2021)](https://techcrunch.com/2021/07/13/sourcegraph-raises-125m-series-d-on-2-6b-valuation-for-universal-code-search-tool/?tpcc=ECTW2020)
3. [Sourcegraph architecture, Sourcegraph docs](https://sourcegraph.com/docs/admin/architecture)
4. [GitHub code search vs. Sourcegraph, Sourcegraph docs](https://6.3.sourcegraph.com/getting-started/github-vs-sourcegraph)
5. [Changes to Cody Free, Pro, and Enterprise Starter plans, Sourcegraph blog (June 25, 2025)](https://sourcegraph.com/blog/changes-to-cody-free-pro-and-enterprise-starter-plans)
6. [Why Sourcegraph and Amp are becoming independent companies, Sourcegraph blog (December 2, 2025)](https://sourcegraph.com/blog/why-sourcegraph-and-amp-are-becoming-independent-companies)
7. [Code Search Capabilities, Sourcegraph docs](https://sourcegraph.com/docs/code-search/features)
8. [Search Query Syntax, Sourcegraph docs](https://sourcegraph.com/docs/code-search/queries)
9. [Why files are skipped from indexing, Sourcegraph Help Center](https://help.sourcegraph.com/article/why-files-are-skipped-from-indexing)
10. [How Cody understands your codebase, Sourcegraph blog](https://sourcegraph.com/blog/how-cody-understands-your-codebase)
11. [Cody FAQs, Sourcegraph docs](https://sourcegraph.com/docs/cody/faq)
12. [Feature removals and deprecations, Sourcegraph changelog (February 25, 2026)](https://sourcegraph.com/changelog/7-0-removals-deprecations)
13. [Introducing Agentic Batch Changes, Sourcegraph blog (September 14, 2026)](https://sourcegraph.com/blog/introducing-agentic-batch-changes?trk=article-ssr-frontend-pulse_little-text-block)
14. [About, Sourcegraph](https://sourcegraph.com/about)
15. [Justin Dorfman on Sourcegraph's open source status (August 2024)](https://x.noodl3.net/jdorfman/status/1825998922105692542)
16. [Sourcegraph went dark, Hacker News (August 2024)](https://news.ycombinator.com/item?id=41296481)
17. [Amp Frontier Corporation, Amp (December 2, 2025)](https://ampcode.com/news/amp-frontier-corporation)
18. [Case Studies, Sourcegraph](https://sourcegraph.com/case-studies)
19. [Enterprise, Sourcegraph](https://sourcegraph.com/enterprise)
20. [Announcing Sourcegraph's partnership with DX, Sourcegraph blog](https://sourcegraph.com/blog/announcing-our-partnership-with-dx)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › AI companies, people, and products › AI startups and application companies › Enterprise and vertical AI applications

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/sourcegraph

English original: https://www.edgepedia.org/sourcegraph
