TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Effectful-Tech/clanka/llms.txt
Use this file to discover all available pages before exploring further.
SemanticSearch module indexes a codebase with vector embeddings and exposes a similarity search interface. It handles initial indexing on startup, incremental updates when files change, and a periodic re-index schedule — all transparently within the Effect runtime.
SemanticSearch service
Context.Service. Obtain it from context with yield* SemanticSearch or use the layer constructor described below to provide it.
search
Run a similarity query against the indexed embeddings and return the best matching code chunks.
Natural-language description of what you are looking for.
Maximum number of chunks to return.
Effect<string> — the matching chunk contents joined with double newlines. The initial index run must complete before the first search resolves; subsequent calls are not blocked.
updateFile
Re-index a single file. All existing embeddings for that path are removed and new ones are computed from the current file content.
Path to the file, relative to the root directory supplied to
layer.Effect<void>. Resolves immediately if the path falls outside the configured root or the file has no meaningful content.
The
writeFile, renameFile, and applyPatch tools in AgentTools call maybeUpdateFile automatically. You only need to call updateFile directly when managing the index outside of those tools.removeFile
Remove all embeddings for a file path from the index.
Path to the file, relative to the root directory.
Effect<void>.
SemanticSearch.layer
SemanticSearch. Returns a scoped Layer that, when mounted, immediately starts an initial full-codebase index and schedules a re-index every 3 minutes.
Options
Absolute path to the root of the codebase to index.
Path to the SQLite database file used to persist embeddings. Defaults to
".clanka/search.sqlite" relative to the process working directory.Maximum number of embedding requests batched into a single model call. Defaults to
300.Delay between batched embedding requests. Defaults to
Duration.millis(50).Number of chunk embedding operations to run in parallel during indexing. Defaults to
2000.Maximum character length per code chunk. Defaults to
10000. Chunks exceeding this limit are split further.Layer requirements
The layer requires the following services to be provided by the caller:EmbeddingModel.EmbeddingModel— produces embedding vectors from text.EmbeddingModel.Dimensions— the dimensionality of the embedding vectors.Path.Path— Effect platform path service.ChildProcessSpawner.ChildProcessSpawner— used internally byCodeChunkerto enumerate files viarg.FileSystem.FileSystem— used internally byCodeChunkerto read file content.
Auto-indexing behaviour
When the layer is mounted it:- Runs an immediate full-codebase index in a background fiber.
- The first
searchcall waits for that initial index fiber to complete. - After the initial index, a recurring fiber re-indexes the full codebase every 3 minutes, skipping any chunk whose embedding hash is already stored.
Utilities
makeEmbeddingResolver
resolver with batching and delay middleware. Used internally by SemanticSearch.layer but exported for cases where you need a pre-configured resolver outside of the layer.
The base resolver from an
EmbeddingModel service instance.Batch size. Defaults to
300.Inter-batch delay. Defaults to
Duration.millis(50).chunkEmbeddingInput
CodeChunk into the text string that is sent to the embedding model. The output includes a YAML-style frontmatter header followed by the chunk content with 1-based line numbers prepended to each line.
Output format:
name, type, and parent are omitted when the corresponding chunk fields are undefined.