Create or refresh the tracedecay-owned Kiro agent. Returns true when tracedecay owns the resulting agent file. A pre-existing user-managed `tracedecay.json` is preserved and returns false so the default agent selector is not pointed at a file whose policy tracedecay does not own.
(
path: &Path,
tracedecay_bin: &str,
steering_path: &Path,
profile_home: &Path,
managed_skill_index_path: Option<&Path>,
)
| 394 | /// user-managed `tracedecay.json` is preserved and returns false so the default |
| 395 | /// agent selector is not pointed at a file whose policy tracedecay does not own. |
| 396 | fn install_managed_agent( |
| 397 | path: &Path, |
| 398 | tracedecay_bin: &str, |
| 399 | steering_path: &Path, |
| 400 | profile_home: &Path, |
| 401 | managed_skill_index_path: Option<&Path>, |
| 402 | ) -> Result<bool> { |
| 403 | if path.exists() && !is_owned_agent_file(path) { |
| 404 | eprintln!( |
| 405 | " {} already exists and is user-managed, leaving unchanged", |
| 406 | path.display() |
| 407 | ); |
| 408 | return Ok(false); |
| 409 | } |
| 410 | |
| 411 | let managed_skill_index_path = match managed_skill_index_path { |
| 412 | Some(index_path) => install_kiro_managed_skill_index(profile_home, index_path)?, |
| 413 | None => None, |
| 414 | }; |
| 415 | let backup = backup_config_file(path)?; |
| 416 | let config = managed_agent_config(tracedecay_bin, steering_path, managed_skill_index_path); |
| 417 | safe_write_json_file(path, &config, backup.as_deref())?; |
| 418 | eprintln!( |
| 419 | "\x1b[32m✔\x1b[0m Wrote tracedecay Kiro agent to {}", |
| 420 | path.display() |
| 421 | ); |
| 422 | Ok(true) |
| 423 | } |
| 424 | |
| 425 | fn install_kiro_managed_skill_index<'a>( |
| 426 | home: &Path, |
no test coverage detected