"""Filesystem layout. Everything is relative to the package so the tree relocates, except RUNTIME_DIR: the embedding server is shared machine-wide, so its path is fixed rather than following DATA_DIR, which callers point at a worktree.""" from __future__ import annotations import os PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) LLAMA_BIN = os.environ.get( "CODE_INDEX_LLAMA_BIN", os.path.join(PROJECT_ROOT, "vendor", "llama-b10483") ) LLAMA_LIB = LLAMA_BIN # The filename selects the pooling and task prefixes the model was trained with, # via embed.PROFILES, so pointing this at a model with no profile is refused # rather than run with someone else's settings. MODEL_PATH = os.environ.get( "CODE_INDEX_MODEL", os.path.join(PROJECT_ROOT, "models", "Qwen3-Embedding-0.6B-Q8_0.gguf"), ) # Index data lives outside the repo so nothing large is committable. Per worktree # in practice: tracks.json points CODE_INDEX_DATA at {worktree}/.index so a build # started while experimenting cannot overwrite the index every session searches. DATA_DIR = os.environ.get( "CODE_INDEX_DATA", os.path.join(os.path.expanduser("~"), ".local", "share", "code-index") ) # Server state, not index data: the embedding server is one process shared # machine-wide, so its pid file and log live on a fixed path independent of # DATA_DIR. A pid file that moved with a worktree's index directory could be # orphaned by deleting the worktree, leaving a running server nothing could stop. RUNTIME_DIR = os.environ.get( "CODE_INDEX_RUNTIME", os.path.join(os.path.expanduser("~"), ".local", "share", "code-index", "run"), ) DB_PATH = os.path.join(DATA_DIR, "index.sqlite3") # One file per generation rather than one file overwritten in place, so a reader # always has a matrix matching the metadata it holds. See store.py. VEC_DIR = os.path.join(DATA_DIR, "vectors") LOCK_PATH = os.path.join(DATA_DIR, "index.lock") # The tree `code-index index` walks when --root is not given: a directory whose # immediate children are git repositories. DEFAULT_ROOT = os.environ.get( "CODE_INDEX_ROOT", os.path.join(os.path.expanduser("~"), "workspace") ) # A useful eval query set is ground truth about real code, so it names real files # in whatever repositories it was written against and belongs outside the tree. # This default is gitignored; eval/score.py falls back to the committed example # set when nothing is here, so a fresh clone still scores something. EVAL_QUERIES = os.environ.get( "CODE_INDEX_EVAL_QUERIES", os.path.join(PROJECT_ROOT, "eval", "queries.local.jsonl") ) EVAL_QUERIES_EXAMPLE = os.path.join(PROJECT_ROOT, "eval", "queries.example.jsonl")