feat: startup git clone for template repo + pass config through

- ensure_repo_ready() at startup: clone if missing, fetch if exists
- TemplateRepoConfig gains local_path field
- list_all_templates/select_template/extract_repo_template accept repo config
- Remove hardcoded repo_dir(), use config.local_path
This commit is contained in:
Fam Zheng
2026-03-09 08:42:23 +00:00
parent 815477a73b
commit d4d9edeb78
5 changed files with 93 additions and 18 deletions

View File

@@ -38,6 +38,16 @@ pub struct TemplateRepoConfig {
pub gitea_url: String,
pub owner: String,
pub repo: String,
#[serde(default = "default_repo_path")]
pub local_path: String,
}
fn default_repo_path() -> String {
if std::path::Path::new("/app/oseng-templates").is_dir() {
"/app/oseng-templates".to_string()
} else {
"oseng-templates".to_string()
}
}
#[derive(Debug, Clone, serde::Deserialize)]
@@ -84,9 +94,15 @@ async fn main() -> anyhow::Result<()> {
}
};
// Ensure template repo is cloned before serving
if let Some(ref repo_cfg) = config.template_repo {
template::ensure_repo_ready(repo_cfg).await;
}
let agent_mgr = agent::AgentManager::new(
database.pool.clone(),
config.llm.clone(),
config.template_repo.clone(),
kb_arc.clone(),
);