Sourcegraph Documentation

website·Indexed 41 days ago

https://sourcegraph.com/docs

Documentation for Sourcegraph's code intelligence platform, covering Code Search, Deep Search, Batch Changes, and Cody. Includes guides for site administration, API references, analytics, and enterprise configurations such as SCIM, OAuth apps, and audit logging.

Tokens
463.2K
Snippets
2K
Records
3.5K
Agent score
73%

What's inside Sourcegraph

  1. Overview of Sourcegraph Worker services

    The worker service is a collection of background jobs that run periodically or in response to external events. By default, all worker jobs are registered to a single instance of the worker service. For instances with high repository counts, large monorepos, or high commit frequency, a single instance may experience stability or throughput issues.
  2. Overview of Sourcegraph Auto-indexing

    Auto-indexing automatically analyzes repository contents to produce a code graph index file, enabling precise code navigation (e.g., Go to definition, Find references). Repositories are periodically cloned into an executor sandbox, analyzed, and the resulting index is uploaded to the Sourcegraph instance. This feature is supported on Enterprise plans and is currently available for Go, TypeScript, JavaScript, Python, Ruby, and JVM repositories.
  3. Overview of Cody AI coding assistant

    Cody is an AI coding assistant that leverages LLMs and Sourcegraph's Search API to provide context from local and remote codebases. It helps developers understand, write, and fix code by analyzing APIs, symbols, and usage patterns across the entire codebase. It integrates with code hosts such as GitHub and GitLab.
  4. Overview of Agentic Batch Changes

    Agentic Batch Changes allows developers to turn a natural language description of a change into multiple changesets (pull requests or merge requests) across a codebase. The agent uses Deep Search to research repositories, proposes a plan, tests the change on a single 'canary' repository, and rolls out the changes in controlled stages. It can also monitor CI failures or merge conflicts and iterate on the code to fix them.
  5. Overview of Cody modelConfiguration

    The modelConfiguration field in the Site config allows administrators to manage which LLM models are available for Cody chat and autocomplete. This configuration enables an LLM selector in the Cody chat UI for Enterprise instances. The configuration consists of several key sections:

    • sourcegraph: Configures access to Sourcegraph-provided models via Cody Gateway.
    • providerOverrides: Configures access to models using Bring Your Own Key (BYOK) or OpenAI-compatible endpoints.
    • modelOverrides: Extends or modifies the list of recognized models and their configurations.
    • selfHostedModels: Adds specific self-hosted models with Sourcegraph's default configurations.
    • defaultModels: Assigns specific models to Cody features (chat, fast chat, autocomplete).
  6. Overview of Sourcegraph Observability features

    Sourcegraph provides a suite of observability tools for monitoring and analyzing the health of production systems. These capabilities are available to users on Enterprise plans via the Web app. Key observability areas include metrics, dashboards, alerting, tracing, logs, OpenTelemetry integration, and health checks.
  7. Overview of local Batch Spec execution with src CLI

    When running src batch apply or src batch preview, the src CLI executes a batch spec locally by resolving and downloading target repositories, running each batch-spec step sequentially in a Docker container with the repository mounted as a workspace, and then sending the resulting changeset specifications and logs to Sourcegraph. This local workflow differs from server-side execution where Sourcegraph services orchestrate the work.
  8. Overview of Sourcegraph Monitoring Tools

    Sourcegraph uses a specific monitoring stack to track deployment health:

    • cadvisor: Exports container monitoring metrics for Prometheus and Grafana.
    • grafana: Visualizes data from Prometheus and Jaeger using customized Sourcegraph dashboards.
    • prometheus: Collects high-level and low-cardinality metrics across services.
  9. Overview of Cody Local Indexing with symf

    Cody uses a local keyword search engine called symf (symbol finder) to create and maintain code indexes for workspace folders. This allows for fast context retrieval directly from the local codebase. Symf starts automatically upon workspace opening and authentication, runs in the background, detects file changes for reindexing, and persists across restarts.
  10. Overview of writing a SCIP indexer

    To create a code indexer for Sourcegraph, you must implement a tool that emits data following the SCIP (Sourcegraph Code Intelligence Protocol) protobuf schema. The general workflow involves:

    1. Familiarizing yourself with the SCIP protobuf schema.
    2. Importing or generating SCIP bindings for your language.
    3. Generating a minimal index containing occurrence information.
    4. Testing the indexer using the scip CLI snapshot command.
    5. Progressively adding support for advanced language features.
  11. Overview of the Sourcegraph migrator service

    The migrator is a Sourcegraph service responsible for managing the state of the pgsql, codeintel-db, and codeinsights-db database schemas.

    In standard Kubernetes or Docker-compose deployments, migrator runs automatically with the up command during startup (e.g., as an initContainer in Kubernetes). The frontend service will not start until the migrator exits successfully.

    Version Guidance:

    • For the default up command: Always use the migrator image version that corresponds exactly with the Sourcegraph version being deployed.
    • For manual commands (upgrade, downgrade, drift, run-out-of-band-migrations): Always use the latest migrator image release, even when targeting older Sourcegraph instances (supported back to v3.20.x).
  12. Overview of Sourcegraph External Services

    The following services can be externalized to improve performance and reliability:

    • codeinsights-db: PostgreSQL instance for code insights data.
    • codeintel-db: PostgreSQL instance for large-volume code graph data.
    • jaeger: Distributed tracing instance.
    • blobstore: S3-compatible object storage for code-intel user uploads.
    • pgsql: PostgreSQL instance for long-term data (e.g., built-in authentication user info).
    • redis-cache: Redis instance for cache data.
    • redis-store: Redis instance for short-term data like user sessions.