An interactive prompt document supporting multi-turn conversations with coding agents.
Sessions operate in two modes:
- Initial mode: A new session without
***Prompt***separators, where the entire content (after the controls prologue) forms the prompt. - Continuation mode: A session with
***Prompt***and***Response***separators for multi-turn conversations, where only the last prompt section is assembled for execution.
The response_mode controls whether a response instruction is appended
to the assembled prompt (:disabled, :enabled, or :auto).
Stored in the sessions/ directory of the vault.
Summary
Functions
Finds the latest response file for a given session.
Imports a response from an external file into the session document.
Extracts the AST nodes of the last Prompt section.
Loads a document from the given path or document.
Loads a document from the given path or document and raises an exception in error cases.
Loads a document from the given Obsidian link, i.e. a string of the form "[[name]]".
Detects the session mode based on the presence of Prompt separators.
Returns the session_response_mode for this session.
Types
@type parts() :: [{section_type(), [Panpipe.AST.Node.t()]}]
@type response_mode() :: :disabled | :enabled | :auto
@type section_type() :: :initial | :prompt | :response | :notes
Functions
Finds the latest response file for a given session.
Returns {:ok, path} if found, {:error, :not_found} if no response files exist.
Imports a response from an external file into the session document.
Finds the latest response file for the session, reads its content, replaces the import button with the response content, and deletes the response file.
@spec last_prompt_part(t()) :: [Panpipe.AST.Node.t()] | nil
Extracts the AST nodes of the last Prompt section.
Returns the AST nodes if in continuation mode.
Returns nil if in initial mode (no Prompt sections found).
Loads a document from the given path or document.
If the loaded document is not of the proper document type an Magma.InvalidDocumentType
exception is returned in an :error tuple.
Loads a document from the given path or document and raises an exception in error cases.
Loads a document from the given Obsidian link, i.e. a string of the form "[[name]]".
If the referenced document is not of the proper document type an Magma.InvalidDocumentType
exception is returned in an :error tuple.
@spec mode(t()) :: :initial | :continuation
Detects the session mode based on the presence of Prompt separators.
Returns :initial if no ***Prompt*** separators are found (initial mode).
Returns :continuation if ***Prompt*** separators are present (continuation mode).
@spec response_mode(t()) :: response_mode()
Returns the session_response_mode for this session.
Checks the session's response_mode field first, falling back to system config.