feat: add template setup executable support
Templates can now include a `setup` file that runs in the workdir before agent execution starts. Used for workspace initialization like pulling tool binaries or installing dependencies.
This commit is contained in:
16
src/agent.rs
16
src/agent.rs
@@ -327,6 +327,22 @@ async fn agent_loop(
|
||||
ensure_workspace(&exec, &workdir).await;
|
||||
let _ = tokio::fs::write(format!("{}/requirement.md", workdir), &requirement).await;
|
||||
|
||||
// Run template setup if present
|
||||
if let Some(ref tid) = template_id {
|
||||
let template_dir = if template::is_repo_template(tid) {
|
||||
template::extract_repo_template(tid, mgr.template_repo.as_ref())
|
||||
.await
|
||||
.ok()
|
||||
} else {
|
||||
Some(std::path::Path::new(template::templates_dir()).join(tid))
|
||||
};
|
||||
if let Some(ref tdir) = template_dir {
|
||||
if let Err(e) = template::run_setup(tdir, &workdir).await {
|
||||
tracing::error!("Template setup failed for {}: {}", tid, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let instructions = if let Some(ref t) = loaded_template {
|
||||
t.instructions.clone()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user