View Source Store (fnord v0.4.30)

This module provides the functionality for storing and retrieving embeddings and metadata for files.

Summary

Functions

Permanently deletes the specified file from the store. Note that this is only exposed for the sake of testing.

Permanently delete any files that are indexed but no longer exist on disk.

Permanently deletes the specified project's index directory and all its contents.

Get the metadata, summary, and embeddings for the specified file. Returns {:ok, info} if the file exists, or {:error, :not_found} if it does not.

Get the embeddings for the specified file. Returns {:ok, embeddings} if the file exists, or {:error, :not_found} if it does not. Note that if the input file was greater than 8192 tokens, the embeddings will be split into multiple chunks.

Get the path to the directory containing the metadata for the specified file.

Get the hash for the specified file. Returns {:ok, hash} if the file exists, or {:error, :not_found} if it does not.

Get the key for the specified file, which is based on the file's full path and is used as the directory name for the file's metadata.

Get the symbol/ctags style outline for the specified file. Returns {:ok, outline} if the file exists, or {:error, :not_found} if it does not.

Get the summary for the specified file. Returns {:ok, summary} if the file exists, or {:error, :not_found} if it does not.

Check if the specified file has embeddings. Returns true if any exist, false otherwise.

Check if the specified file has an outline outline. Returns true if the file exists, or false if it does not.

Check if the specified file has a summary file. Returns true if the file exists, or false if it does not.

Get the metadata for the specified file. Returns {:ok, data} if the file exists, or {:error, :not_found} if it does not. The structure of the metadata is as follows

List all indexed files in the project. Returns a list of absolute, expanded, file paths.

List all projects in the store. Returns a list of project names.

Create a new Store struct.

Returns true if the selected project exists in the store. A project exists in the store if

Store the metadata, summary, and embeddings for the specified file. If the file already exists in the store, it will be overwritten.

Functions

Link to this function

delete_file(store, file)

View Source

Permanently deletes the specified file from the store. Note that this is only exposed for the sake of testing.

Link to this function

delete_missing_files(store, root, callback \\ fn -> nil end)

View Source

Permanently delete any files that are indexed but no longer exist on disk.

Permanently deletes the specified project's index directory and all its contents.

Get the metadata, summary, and embeddings for the specified file. Returns {:ok, info} if the file exists, or {:error, :not_found} if it does not.

The structure of the returned info is as follows:

%{
  file: "path/to/file.ext",
  hash: "DEADBEEF",
  timestamp: "2021-01-01T00:00:00Z",
  summary: "AI-generated summary of the file",
  embeddings: [
    [0.1, 0.2, 0.3, ...],
    [0.4, 0.5, 0.6, ...],
    ...
  ]
}
Link to this function

get_embeddings(store, file)

View Source

Get the embeddings for the specified file. Returns {:ok, embeddings} if the file exists, or {:error, :not_found} if it does not. Note that if the input file was greater than 8192 tokens, the embeddings will be split into multiple chunks.

Link to this function

get_entry_path(store, file_path)

View Source

Get the path to the directory containing the metadata for the specified file.

Get the hash for the specified file. Returns {:ok, hash} if the file exists, or {:error, :not_found} if it does not.

Get the key for the specified file, which is based on the file's full path and is used as the directory name for the file's metadata.

Link to this function

get_outline(store, file)

View Source

Get the symbol/ctags style outline for the specified file. Returns {:ok, outline} if the file exists, or {:error, :not_found} if it does not.

Link to this function

get_summary(store, file)

View Source

Get the summary for the specified file. Returns {:ok, summary} if the file exists, or {:error, :not_found} if it does not.

Link to this function

has_embeddings?(store, file)

View Source

Check if the specified file has embeddings. Returns true if any exist, false otherwise.

Link to this function

has_outline?(store, file)

View Source

Check if the specified file has an outline outline. Returns true if the file exists, or false if it does not.

Link to this function

has_summary?(store, file)

View Source

Check if the specified file has a summary file. Returns true if the file exists, or false if it does not.

Get the metadata for the specified file. Returns {:ok, data} if the file exists, or {:error, :not_found} if it does not. The structure of the metadata is as follows:

%{
  file: "path/to/file.ext",
  hash: "DEADBEEF",
  timestamp: "2021-01-01T00:00:00Z",
  fnord_path: "path/to/store/FEEBDAED"
}

List all indexed files in the project. Returns a list of absolute, expanded, file paths.

List all projects in the store. Returns a list of project names.

Create a new Store struct.

Returns true if the selected project exists in the store. A project exists in the store if:

  1. The project directory exists in the store.
  2. There are entries in the project directory.
Link to this function

put(store, file, hash, summary, outline, embeddings)

View Source

Store the metadata, summary, and embeddings for the specified file. If the file already exists in the store, it will be overwritten.