$vars Placeholder => value map. * * @throws RuntimeException when the template file does not exist. */ public static function load(string $name, array $vars = []): string { $path = resource_path("ai/prompts/{$name}.md"); if (! is_file($path)) { throw new RuntimeException("Missing AI prompt template: {$name} (expected at {$path})"); } $template = (string) file_get_contents($path); if ($vars === []) { return trim($template); } $replacements = []; foreach ($vars as $key => $value) { $replacements['{{'.$key.'}}'] = (string) $value; } return trim(strtr($template, $replacements)); } }