From d055a634c2e00372e89251084a14ebbe553ad453 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sun, 19 Jul 2026 04:10:33 -0400 Subject: [PATCH] Formatted src/services --- .../pipeline/src/services/prompt_directory.cc | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/tooling/pipeline/src/services/prompt_directory.cc b/tooling/pipeline/src/services/prompt_directory.cc index d567454b..858d82cd 100644 --- a/tooling/pipeline/src/services/prompt_directory.cc +++ b/tooling/pipeline/src/services/prompt_directory.cc @@ -23,80 +23,80 @@ PromptDirectory::PromptDirectory(const std::filesystem::path& prompt_dir) PromptDirectory::PromptDirectory(const std::filesystem::path& prompt_dir, std::shared_ptr logger) : prompt_dir_(prompt_dir), logger_(std::move(logger)) { - std::error_code ec; + std::error_code ec; - // Directory must exist. - if (!std::filesystem::exists(prompt_dir_, ec) || ec) { - throw std::runtime_error( - "PromptDirectory: prompt directory does not exist: " + - prompt_dir_.string()); - } + // Directory must exist. + if (!std::filesystem::exists(prompt_dir_, ec) || ec) { + throw std::runtime_error( + "PromptDirectory: prompt directory does not exist: " + + prompt_dir_.string()); + } - // Path must be a directory, not a file. - if (!std::filesystem::is_directory(prompt_dir_, ec) || ec) { - throw std::runtime_error( - "PromptDirectory: prompt directory path is not a directory: " + - prompt_dir_.string()); - } + // Path must be a directory, not a file. + if (!std::filesystem::is_directory(prompt_dir_, ec) || ec) { + throw std::runtime_error( + "PromptDirectory: prompt directory path is not a directory: " + + prompt_dir_.string()); + } - // Directory must be readable (probe with directory_iterator). - std::filesystem::directory_iterator probe(prompt_dir_, ec); - if (ec) { - throw std::runtime_error(std::format( - "PromptDirectory: prompt directory is not readable: {} ({})", - prompt_dir_.string(), ec.message())); - } + // Directory must be readable (probe with directory_iterator). + std::filesystem::directory_iterator probe(prompt_dir_, ec); + if (ec) { + throw std::runtime_error(std::format( + "PromptDirectory: prompt directory is not readable: {} ({})", + prompt_dir_.string(), ec.message())); + } - if (logger_) { - logger_->Log( - {.level = LogLevel::Info, - .phase = PipelinePhase::Startup, - .message = - std::string("[PromptDirectory] Resolved prompt directory: ") + - prompt_dir_.string()}); - } + if (logger_) { + logger_->Log( + {.level = LogLevel::Info, + .phase = PipelinePhase::Startup, + .message = + std::string("[PromptDirectory] Resolved prompt directory: ") + + prompt_dir_.string()}); + } } std::string PromptDirectory::Load(std::string_view key) { - const std::string key_str(key); + const std::string key_str(key); - // Return cached content if already loaded during this run. - const auto cache_it = cache_.find(key_str); - if (cache_it != cache_.end()) { - return cache_it->second; - } + // Return cached content if already loaded during this run. + const auto cache_it = cache_.find(key_str); + if (cache_it != cache_.end()) { + return cache_it->second; + } - // Resolve /.md and require it to exist. - const std::filesystem::path file_path = - prompt_dir_ / std::filesystem::path(std::format("{}.md", key_str)); + // Resolve /.md and require it to exist. + const std::filesystem::path file_path = + prompt_dir_ / std::filesystem::path(std::format("{}.md", key_str)); - std::ifstream file(file_path); - if (!file.is_open()) { - throw std::runtime_error( - std::format("PromptDirectory: prompt file not found for key '{}': {}", - key_str, file_path.string())); - } + std::ifstream file(file_path); + if (!file.is_open()) { + throw std::runtime_error( + std::format("PromptDirectory: prompt file not found for key '{}': {}", + key_str, file_path.string())); + } - std::string content((std::istreambuf_iterator(file)), - std::istreambuf_iterator()); - file.close(); + std::string content((std::istreambuf_iterator(file)), + std::istreambuf_iterator()); + file.close(); - if (content.empty()) { - throw std::runtime_error( - std::format("PromptDirectory: prompt file for key '{}' is empty: {}", - key_str, file_path.string())); - } + if (content.empty()) { + throw std::runtime_error( + std::format("PromptDirectory: prompt file for key '{}' is empty: {}", + key_str, file_path.string())); + } - if (logger_) { - logger_->Log( - {.level = LogLevel::Info, - .phase = PipelinePhase::Startup, - .message = std::format( - "[PromptDirectory] Loaded prompt '{}' from '{}' ({} chars)", - key_str, file_path.string(), content.size())}); - } + if (logger_) { + logger_->Log( + {.level = LogLevel::Info, + .phase = PipelinePhase::Startup, + .message = std::format( + "[PromptDirectory] Loaded prompt '{}' from '{}' ({} chars)", + key_str, file_path.string(), content.size())}); + } - // Cache the loaded content for future calls. - cache_.emplace(key_str, content); - return content; + // Cache the loaded content for future calls. + cache_.emplace(key_str, content); + return content; }