Skip to content

Config

Brain configuration, .spikuit/ discovery, and initialization.

EmbedderConfig dataclass

EmbedderConfig(provider: str = 'none', base_url: str = '', model: str = '', dimension: int = 768, api_key: str = 'not-needed', timeout: float = 30.0, prefix_style: str = 'none', max_searchable_chars: int = 500)

Embedder configuration parsed from config.toml.

Attributes:

Name Type Description
provider str

"openai-compat", "ollama", or "none".

base_url str

API base URL.

model str

Model identifier.

dimension int

Embedding vector dimension.

api_key str

Bearer token (OpenAI-compat only).

timeout float

HTTP request timeout in seconds.

BrainConfig dataclass

BrainConfig(name: str = 'default', root: Path = (lambda: Path.cwd())(), embedder: EmbedderConfig = EmbedderConfig(), git: GitConfig = GitConfig())

Full Brain configuration — parsed from .spikuit/config.toml.

Attributes:

Name Type Description
name str

Brain name (defaults to directory name).

root Path

Directory containing .spikuit/.

embedder EmbedderConfig

Embedder settings.

git GitConfig

Git versioning settings.

spikuit_dir property

spikuit_dir: Path

Path to the .spikuit/ directory.

db_path property

db_path: Path

Path to the SQLite database file.

config_path property

config_path: Path

Path to config.toml.

cache_path property

cache_path: Path

Path to the cache directory.

Functions

find_spikuit_root

find_spikuit_root(start: Path | None = None) -> Path | None

Walk up from start to find a directory containing .spikuit/.

Behaves like git's root discovery — walks parent directories until .spikuit/ is found or the filesystem root is reached.

Parameters:

Name Type Description Default
start Path | None

Starting directory (defaults to CWD).

None

Returns:

Type Description
Path | None

The directory containing .spikuit/, or None if not found.

init_brain

init_brain(path: Path | None = None, *, name: str | None = None, embedder_provider: str = 'none', embedder_base_url: str = '', embedder_model: str = '', embedder_dimension: int = 768, embedder_prefix_style: str = 'none') -> BrainConfig

Initialize a new .spikuit/ directory with config.toml.

Creates the directory structure and writes a config file. Equivalent to spkt init.

Parameters:

Name Type Description Default
path Path | None

Target directory (defaults to CWD).

None
name str | None

Brain name (defaults to directory name).

None
embedder_provider str

"openai-compat", "ollama", or "none".

'none'
embedder_base_url str

API base URL for embedder.

''
embedder_model str

Model identifier for embedder.

''
embedder_dimension int

Embedding vector dimension.

768

Returns:

Type Description
BrainConfig

The BrainConfig for the initialized brain.

Raises:

Type Description
FileExistsError

If .spikuit/ already exists.

load_config

load_config(root: Path | None = None) -> BrainConfig

Load BrainConfig from .spikuit/config.toml.

If root is None, walks up from CWD to find .spikuit/. Falls back to ~/.spikuit/ if no project-local config found.