Outputs (fnord v0.9.29)
View SourceHelpers for persisting raw assistant outputs for a project.
Outputs are written under:
~/fnord/outputs/<project_id>/<slug>.mdThe 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
@type conversation_id() :: String.t()
A conversation identifier used for default slug generation.
@type output_path() :: String.t()
The path to an output file.
@type project_id() :: String.t()
Represents a project identifier.
@type raw_response() :: String.t()
The raw response text from the assistant.
@type save_opts() :: [{:conversation_id, conversation_id()}]
Options for the save function, currently supported keys:
- :conversation_id - a conversation_id
@type save_result() :: {:ok, output_path()} | {:error, term()}
Result of a save operation. On success returns {:ok, output_path}, on failure {:error, reason}.
@type slug() :: String.t()
A slug generated for output filenames.
Functions
@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.
@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>.
@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.
Converts a text string into a URL-friendly slug. Lowercases, trims whitespace, replaces non-alphanumeric characters with hyphens, and trims leading/trailing hyphens.