Spectre.Prompt.Operation (Spectre v0.3.0)

Copy Markdown View Source

One typed prompt-composition declaration compiled from inject.

Summary

Functions

Builds and validates an injection operation.

Normalizes handler/runtime inject: specifications into operations.

Assigns a materialized runtime scope to an operation.

Types

position()

@type position() :: :start | :end | :replace

source()

@type source() :: {:prompt, atom() | String.t()} | {:provider, module(), atom()}

t()

@type t() :: %Spectre.Prompt.Operation{
  condition: nil | {module(), atom()} | function(),
  id: term(),
  opts: keyword(),
  position: position(),
  required?: boolean(),
  scope: term(),
  source: source(),
  source_line: non_neg_integer() | nil,
  target: target(),
  trust: :instruction | :data
}

target()

@type target() :: :instructions | :context | :task

Functions

new(id, opts, scope \\ :definition)

@spec new(term(), keyword(), term()) :: t()

Builds and validates an injection operation.

normalize(operation, scope)

@spec normalize(term(), term()) :: [t()]

Normalizes handler/runtime inject: specifications into operations.

A specification may be an operation, a prompt atom/string, a keyword list, or a list containing those shapes.

put_scope(operation, scope)

@spec put_scope(t(), term()) :: t()

Assigns a materialized runtime scope to an operation.