ExternalConfigs.CursorRule (fnord v0.9.29)

View Source

A parsed Cursor rule (.mdc file or legacy .cursorrules).

Cursor rules have four application modes determined by which frontmatter fields are set:

  • :always - alwaysApply: true. Injected unconditionally.
  • :auto_attached - globs non-empty. Injected when a file already in the chat context matches one of the globs (fnord triggers on file read/write).
  • :agent_requested - description set, no globs, not always. The model sees the description and chooses whether to fetch.
  • :manual - none of the above. Only fetched on explicit request.

Legacy .cursorrules files at the project root are treated as a single :always rule.

Summary

Functions

Load a .mdc rule file. The rule name is derived from the file basename (without the .mdc extension).

Load a legacy .cursorrules file as a single :always rule. The body is the full file contents (there is no frontmatter in the legacy format).

Returns true when any of the rule's globs match the given path (relative to the project source root).

Types

mode()

@type mode() :: :always | :auto_attached | :agent_requested | :manual

source()

@type source() :: :global | :project | :legacy

t()

@type t() :: %ExternalConfigs.CursorRule{
  always_apply: boolean(),
  body: String.t(),
  description: String.t() | nil,
  globs: [String.t()],
  mode: mode(),
  name: String.t(),
  path: String.t(),
  source: source()
}

Functions

from_file(path, source)

@spec from_file(String.t(), source()) :: {:ok, t()} | {:error, term()}

Load a .mdc rule file. The rule name is derived from the file basename (without the .mdc extension).

from_legacy_file(path)

@spec from_legacy_file(String.t()) :: {:ok, t()} | {:error, term()}

Load a legacy .cursorrules file as a single :always rule. The body is the full file contents (there is no frontmatter in the legacy format).

matches_path?(cursor_rule, path)

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

Returns true when any of the rule's globs match the given path (relative to the project source root).