reference

Configuration

Configure storage, embedding context, managed and external server modes, devices, and vector backends.

sgrep works without configuration. Environment variables are intended for alternate storage locations, compatible external embedding servers, and reproducible backend experiments.

Core settings

VariableDefaultPurpose
SGREP_HOME~/.sgrepModels, repository indexes, and managed-server state
SGREP_DIMS768Embedding dimensions; changing it requires reindexing
SGREP_CONTEXT_TOKENS512Per-slot embedding context; changing it requires reindexing
SGREP_MAX_TOKENScontext budget minus reserveOptional source-chunk budget override

The model format adds search_query: to queries and search_document: to indexed material. Index metadata records the format and context budget so incompatible indexes fail validation instead of mixing embeddings.

Managed server mode

With no endpoint override, sgrep owns a local llama.cpp server and starts it when needed.

VariableDefaultPurpose
SGREP_PORT8080Port for the managed server
SGREP_DEVICEautomaticllama.cpp device selection
SGREP_N_GPU_LAYERSautomaticllama.cpp GPU layer count

The manager persists process identity under SGREP_HOME and validates the executable, process start identity, port, and embedding capability before treating a process as owned.

SGREP_PORT=8082 sgrep "authentication"
sgrep server status
sgrep server stop

External endpoint mode

Setting SGREP_ENDPOINT opts into an externally managed compatible endpoint. In this mode sgrep validates embedding capability but does not start or stop the process.

SGREP_ENDPOINT=http://localhost:9090 sgrep index .

Do not set both variables expecting SGREP_PORT to rewrite the external URL; SGREP_ENDPOINT is the complete endpoint override.

Vector backend overrides

The normal code-search path selects the compatible local artifact automatically. These variables are mainly useful for benchmark isolation and diagnostics:

VariableValuesPurpose
SGREP_VECTOR_BACKENDtqmse, sqlite, libsqlForce compact TQ-MSE or legacy SQL search
SGREP_CONV_VECTOR_BACKENDtqmse, sqlite, libsqlOverride conversation search independently

Forcing sqlite or libsql requires an index built with sgrep index --sql-vectors. Forcing tqmse fails if the required compact sidecar is absent.

Reranker settings

VariablePurpose
SGREP_RERANKER_PORTPort for the optional reranker server
SGREP_RERANK_MODELPath to an alternate reranker model

Install the default reranker model with sgrep setup --with-rerank before using --rerank.