PtcRunner.SubAgent.Signature.Renderer (PtcRunner v0.10.1)

Copy Markdown View Source

Renders signatures back to string representation.

Converts internal signature format to human-readable syntax for use in prompts and debugging.

Summary

Functions

Render a signature to its string representation.

Render a type spec to its string representation.

Convert a snake_case field name to kebab-case for LLM-facing prompts.

Functions

render(arg)

@spec render({:signature, list(), term()}) :: String.t()

Render a signature to its string representation.

Examples

iex> sig = {:signature, [{"id", :int}], :string}
iex> PtcRunner.SubAgent.Signature.Renderer.render(sig)
"(id :int) -> :string"

iex> sig = {:signature, [], {:map, [{"count", :int}]}}
iex> PtcRunner.SubAgent.Signature.Renderer.render(sig)
"-> {count :int}"

render_type(type, opts \\ [])

@spec render_type(
  term(),
  keyword()
) :: String.t()

Render a type spec to its string representation.

Converts type tuples and atoms to their PTC-Lisp syntax representation (e.g., :string, [int], {key :string}).

Accepts an optional key_style option:

  • :lisp_prompt — converts map field names to kebab-case for LLM-facing prompts

Examples

iex> PtcRunner.SubAgent.Signature.Renderer.render_type(:string)
":string"

iex> PtcRunner.SubAgent.Signature.Renderer.render_type({:optional, :int})
":int?"

iex> PtcRunner.SubAgent.Signature.Renderer.render_type({:list, :string})
"[:string]"

to_lisp_key(name)

@spec to_lisp_key(String.t()) :: String.t()

Convert a snake_case field name to kebab-case for LLM-facing prompts.

Strips leading _, replaces remaining _ with -, prepends _ back.

Examples

iex> PtcRunner.SubAgent.Signature.Renderer.to_lisp_key("q1_total")
"q1-total"

iex> PtcRunner.SubAgent.Signature.Renderer.to_lisp_key("_email_ids")
"_email-ids"

iex> PtcRunner.SubAgent.Signature.Renderer.to_lisp_key("name")
"name"