Outputs (fnord v0.9.29)

View Source

Helpers for persisting raw assistant outputs for a project.

Outputs are written under:

~/fnord/outputs/<project_id>/<slug>.md

The content saved is the raw assistant response.

Summary

Types

A conversation identifier used for default slug generation.

The path to an output file.

Represents a project identifier.

The raw response text from the assistant.

Options for the save function, currently supported keys

Result of a save operation. On success returns {:ok, output_path}, on failure {:error, reason}.

A slug generated for output filenames.

Functions

Extracts the title from the raw response. Expects the first line in the format "# Title: <title>" (case-insensitive). Returns the trimmed title or nil if missing or blank.

Returns the directory path for outputs for a given project. Uses Settings.get_user_home() and returns ~/fnord/outputs/<project_id>.

Saves the raw assistant markdown response for a project. Derives the filename slug from the first line "# Title: ..." if present, falls back to "conversation-<conversation_id>" or "untitled". Resolves filename collisions by appending "-N". Uses FileLock.with_lock and Settings.write_atomic! for atomic writes. Returns {:ok, output_path} on success or {:error, reason} on failure.

Converts a text string into a URL-friendly slug. Lowercases, trims whitespace, replaces non-alphanumeric characters with hyphens, and trims leading/trailing hyphens.

Types

conversation_id()

@type conversation_id() :: String.t()

A conversation identifier used for default slug generation.

output_path()

@type output_path() :: String.t()

The path to an output file.

project_id()

@type project_id() :: String.t()

Represents a project identifier.

raw_response()

@type raw_response() :: String.t()

The raw response text from the assistant.

save_opts()

@type save_opts() :: [{:conversation_id, conversation_id()}]

Options for the save function, currently supported keys:

  • :conversation_id - a conversation_id

save_result()

@type save_result() :: {:ok, output_path()} | {:error, term()}

Result of a save operation. On success returns {:ok, output_path}, on failure {:error, reason}.

slug()

@type slug() :: String.t()

A slug generated for output filenames.

Functions

extract_title(raw_response)

@spec extract_title(raw_response()) :: String.t() | nil

Extracts the title from the raw response. Expects the first line in the format "# Title: <title>" (case-insensitive). Returns the trimmed title or nil if missing or blank.

outputs_dir(project_id)

@spec outputs_dir(project_id()) :: String.t()

Returns the directory path for outputs for a given project. Uses Settings.get_user_home() and returns ~/fnord/outputs/<project_id>.

save(project_id, raw_response, opts \\ [])

@spec save(project_id(), raw_response(), save_opts()) :: save_result()

Saves the raw assistant markdown response for a project. Derives the filename slug from the first line "# Title: ..." if present, falls back to "conversation-<conversation_id>" or "untitled". Resolves filename collisions by appending "-N". Uses FileLock.with_lock and Settings.write_atomic! for atomic writes. Returns {:ok, output_path} on success or {:error, reason} on failure.

slugify(text)

@spec slugify(String.t()) :: slug()

Converts a text string into a URL-friendly slug. Lowercases, trims whitespace, replaces non-alphanumeric characters with hyphens, and trims leading/trailing hyphens.