This directory contains scripts for setting up and managing SCIP (Source Code Intelligence Protocol) integration.
The scip_pb2.py file is generated from the official SCIP Protocol Buffer definition. Here's how it was created:
# Download the official scip.proto file from the SCIP repository
curl -o scip.proto https://raw.githubusercontent.com/sourcegraph/scip/main/scip.proto# Install protobuf compiler (if not already installed)
# macOS:
brew install protobuf
# Ubuntu/Debian:
sudo apt-get install protobuf-compiler
# Generate Python bindings
protoc --python_out=. scip.protoThis creates scip_pb2.py with all the necessary Python classes to read/write SCIP protocol buffer files.
The current scip_pb2.py was generated with:
- Protocol Buffer compiler: version varies
- Protobuf Python version: 5.29.3 (as seen in the file header)
- Source: https://github.com/sourcegraph/scip/blob/main/scip.proto
# Initialize SCIP for current directory
python scripts/initialize_scip.py
# Initialize SCIP for a specific project
python scripts/initialize_scip.py /path/to/project --project-name "my-project"
# Verbose output
python scripts/initialize_scip.py --verbose- Checks Prerequisites: Verifies
scip-pythonandprotocare installed - Downloads scip.proto: Gets the latest protocol definition
- Generates Bindings: Creates fresh
scip_pb2.py(if protoc available) - Tests Bindings: Verifies the protobuf bindings work
- Creates Index: Generates the SCIP index for your project
# Install scip-python (Node.js tool)
npm install -g @sourcegraph/scip-python
# Install protobuf compiler (optional, for regenerating bindings)
# macOS:
brew install protobuf
# Ubuntu/Debian:
sudo apt-get install protobuf-compilerIf you prefer to set up SCIP manually:
npm install -g @sourcegraph/scip-python# In your project directory
scip-python index --project-name "your-project" --output index.scipfrom blarify.code_references.scip_helper import ScipReferenceResolver
# Initialize resolver
resolver = ScipReferenceResolver("/path/to/project")
# Get references for a node
references = resolver.get_references_for_node(node)If you need to update the protobuf bindings (e.g., when SCIP protocol is updated):
# Download latest scip.proto
curl -o scip.proto https://raw.githubusercontent.com/sourcegraph/scip/main/scip.proto
# Regenerate Python bindings
protoc --python_out=. scip.proto
# Move to project root
mv scip_pb2.py ../# Install via npm
npm install -g @sourcegraph/scip-python
# Verify installation
scip-python --version# macOS
brew install protobuf
# Ubuntu/Debian
sudo apt-get install protobuf-compiler
# Verify installation
protoc --version- Ensure
scip_pb2.pyis in your project root or Python path - Try regenerating with the initialization script
- Check that protobuf Python package is installed:
pip install protobuf
The warning about protobuf gencode version is expected when the runtime protobuf version is newer than the version used to generate scip_pb2.py. This doesn't affect functionality but can be resolved by regenerating the bindings.
Once properly set up, SCIP provides:
- 330x faster reference resolution compared to LSP
- Identical accuracy to LSP results
- Automatic index management (regenerates when files change)
- No runtime dependencies on language servers