PtcRunner.PromptLoader (PtcRunner v0.9.0)

Copy Markdown View Source

Compile-time utilities for loading prompt templates from files.

Extracts content between <!-- PTC_PROMPT_START --> and <!-- PTC_PROMPT_END --> markers. If markers are not found, returns the trimmed full content.

Examples

# Basic extraction
content = File.read!("priv/prompts/my-prompt.md")
prompt = PtcRunner.PromptLoader.extract_content(content)

# With header (for metadata parsing)
{header, content} = PtcRunner.PromptLoader.extract_with_header(content)

Summary

Functions

Extract prompt content from file content string.

Extract prompt content with metadata header.

Functions

extract_content(file_content)

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

Extract prompt content from file content string.

Returns content between markers, or trimmed full content if markers not found.

Examples

iex> PtcRunner.PromptLoader.extract_content("before<!-- PTC_PROMPT_START -->content<!-- PTC_PROMPT_END -->after")
"content"

iex> PtcRunner.PromptLoader.extract_content("<!-- PTC_PROMPT_START -->only start marker")
"only start marker"

iex> PtcRunner.PromptLoader.extract_content("  no markers  ")
"no markers"

extract_with_header(file_content)

@spec extract_with_header(String.t()) :: {String.t(), String.t()}

Extract prompt content with metadata header.

Returns {header, content} tuple where header is text before the start marker. Used by LanguageSpec for version metadata parsing.

Examples

iex> PtcRunner.PromptLoader.extract_with_header("header<!-- PTC_PROMPT_START -->content<!-- PTC_PROMPT_END -->after")
{"header", "content"}

iex> PtcRunner.PromptLoader.extract_with_header("header<!-- PTC_PROMPT_START -->only start")
{"header", "only start"}

iex> PtcRunner.PromptLoader.extract_with_header("  no markers  ")
{"  no markers  ", "no markers"}