Store.Project (fnord v0.9.34)

View Source

Summary

Functions

Resolves path within the project's source root. Returns {:ok, path} if the file exists, or {:error, :enoent} if it does not.

Returns the status of the index for the given project.

Returns the project's source root as configured in settings, ignoring any in-memory override (e.g. from a worktree session). Used by tools that need to access files outside the worktree's view, such as gitignored files that exist in source but were not propagated to the worktree.

Returns true if the given absolute path is excluded by the project's exclusion policy (user-defined patterns or gitignore).

Reads the project prompt from FNORD.md and FNORD.local.md in the source root.

Returns no source files when source_root is nil to avoid crashing.

Types

index_status()

@type index_status() :: %{
  new: [Store.Project.Entry.t()],
  stale: [Store.Project.Entry.t()],
  deleted: [Store.Project.Entry.t()]
}

t()

@type t() :: %Store.Project{
  conversation_dir: term(),
  exclude: term(),
  exclude_cache: term(),
  name: term(),
  source_root: term(),
  store_path: term()
}

Functions

conversations(project)

@spec conversations(t()) :: [Store.Project.Conversation.t()]

create(project)

@spec create(t()) :: t()

delete(project)

@spec delete(t()) :: :ok

delete_missing_files(project)

@spec delete_missing_files(t()) :: {t(), Enumerable.t()}

exists_in_store?(project)

@spec exists_in_store?(t()) :: boolean()

expand_path(path, project)

@spec expand_path(String.t(), t()) :: String.t()

files_root(project)

@spec files_root(t()) :: String.t()

find_entry(project, path)

@spec find_entry(t(), String.t()) ::
  {:ok, Store.Project.Entry.t()} | {:error, :enoent}

find_file(project, path)

@spec find_file(t(), binary()) ::
  {:ok, binary()} | {:error, :enoent} | {:error, File.posix()}

Resolves path within the project's source root. Returns {:ok, path} if the file exists, or {:error, :enoent} if it does not.

find_path_in_source_root(project, path)

@spec find_path_in_source_root(t(), String.t()) ::
  {:ok, :dir | :file | :enoent, String.t()}

has_index?(project)

@spec has_index?(t()) :: boolean()

index_status(project)

@spec index_status(t()) :: index_status()

Returns the status of the index for the given project.

It classifies entries into:

  • :deleted - entries that were indexed but the source files have been removed
  • :stale - entries whose indexed metadata is stale compared to the source file
  • :new - entries for unindexed files that exist in the source

index_status(project, opts)

@spec index_status(
  t(),
  keyword()
) :: index_status()

make_default_for_session(project)

@spec make_default_for_session(t()) :: t()

new(project_name, store_path)

@spec new(String.t(), String.t()) :: t()

original_source_root()

@spec original_source_root() :: String.t() | nil

Returns the project's source root as configured in settings, ignoring any in-memory override (e.g. from a worktree session). Used by tools that need to access files outside the worktree's view, such as gitignored files that exist in source but were not propagated to the worktree.

Cached in Services.Globals at session start by Cmd.Ask. Returns nil when no session has cached the value (e.g. in tests that bypass Cmd.Ask).

path_excluded?(project, abs_path)

@spec path_excluded?(t(), String.t()) :: boolean()

Returns true if the given absolute path is excluded by the project's exclusion policy (user-defined patterns or gitignore).

project_prompt(project)

@spec project_prompt(t()) :: {:ok, binary()} | {:error, :not_found}

Reads the project prompt from FNORD.md and FNORD.local.md in the source root.

Returns:

  • {:ok, prompt} (at least one file has content)
  • {:error, :not_found}

When both files have content, the resulting prompt will include instructions from both files, along with a short note indicating priority.

relative_path(path, project)

@spec relative_path(String.t(), t()) :: String.t()

save_settings(project, source_root \\ nil, exclude \\ nil)

@spec save_settings(t(), String.t() | nil, String.t() | nil) :: t()

source_files(project)

@spec source_files(t()) :: {t(), Enumerable.t()}

Returns no source files when source_root is nil to avoid crashing.

stored_files(project)

@spec stored_files(t()) :: Enumerable.t()

torch(project)

@spec torch(t()) :: :ok