Resolves the stack using the full resolution chain. Priority: CLI flag > config layers (user `[project. ]` > project `.tsk/tsk.toml` > user `[defaults]`) > auto-detect from project files > `"default"` fallback.
(
cli_stack: Option<String>,
tsk_config: &TskConfig,
project_name: &str,
project_config: Option<&SharedConfig>,
repo_root: &Path,
)
| 739 | /// Priority: CLI flag > config layers (user `[project.<name>]` > project `.tsk/tsk.toml` |
| 740 | /// > user `[defaults]`) > auto-detect from project files > `"default"` fallback. |
| 741 | pub async fn resolve_stack( |
| 742 | cli_stack: Option<String>, |
| 743 | tsk_config: &TskConfig, |
| 744 | project_name: &str, |
| 745 | project_config: Option<&SharedConfig>, |
| 746 | repo_root: &Path, |
| 747 | ) -> String { |
| 748 | if let Some(stack) = cli_stack { |
| 749 | return stack; |
| 750 | } |
| 751 | |
| 752 | let config_stack = tsk_config |
| 753 | .project |
| 754 | .get(project_name) |
| 755 | .and_then(|p| p.stack.clone()) |
| 756 | .or_else(|| project_config.and_then(|pc| pc.stack.clone())) |
| 757 | .or_else(|| tsk_config.defaults.stack.clone()); |
| 758 | |
| 759 | if let Some(stack) = config_stack { |
| 760 | return stack; |
| 761 | } |
| 762 | |
| 763 | match crate::repository::detect_stack(repo_root).await { |
| 764 | Ok(detected) => detected, |
| 765 | Err(e) => { |
| 766 | eprintln!("Warning: Failed to detect stack: {e}. Using default."); |
| 767 | "default".to_string() |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | /// Resolves the agent from CLI flag or resolved config. |
| 773 | /// |